onchaind: Store and annotate transactions we broadcast ourselves

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker
2019-05-27 13:04:10 +02:00
committed by Rusty Russell
parent 05dbf1a2a9
commit ae0bc4aed0
4 changed files with 51 additions and 5 deletions

View File

@@ -165,12 +165,19 @@ static void watch_tx_and_outputs(struct channel *channel,
static void handle_onchain_broadcast_tx(struct channel *channel, const u8 *msg)
{
struct bitcoin_tx *tx;
struct wallet *w = channel->peer->ld->wallet;
struct bitcoin_txid txid;
txtypes type;
if (!fromwire_onchain_broadcast_tx(msg, msg, &tx)) {
if (!fromwire_onchain_broadcast_tx(msg, msg, &tx, &type)) {
channel_internal_error(channel, "Invalid onchain_broadcast_tx");
return;
}
bitcoin_txid(tx, &txid);
wallet_transaction_add(w, tx, 0, 0);
wallet_transaction_annotate(w, &txid, type, channel->dbid);
/* We don't really care if it fails, we'll respond via watch. */
broadcast_tx(channel->peer->ld->topology, channel, tx, NULL);
}