onchaind: Allow onchaind to annotate transactions we watch

This is important for things we automatically watched because it spends a
watch txo, but only onchaind knows the details about what the TX really is and
how it should be handled.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker
2019-05-27 13:06:02 +02:00
committed by Rusty Russell
parent ae0bc4aed0
commit a54b7da705
2 changed files with 23 additions and 0 deletions

View File

@@ -291,6 +291,18 @@ static void onchain_add_utxo(struct channel *channel, const u8 *msg)
wallet_add_utxo(channel->peer->ld->wallet, u, p2wpkh);
}
static void onchain_transaction_annotate(struct channel *channel, const u8 *msg)
{
struct bitcoin_txid txid;
txtypes type;
if (!fromwire_onchain_transaction_annotate(msg, &txid, &type))
fatal("onchaind gave invalid onchain_transaction_annotate "
"message: %s",
tal_hex(msg, msg));
wallet_transaction_annotate(channel->peer->ld->wallet, &txid, type,
channel->dbid);
}
static unsigned int onchain_msg(struct subd *sd, const u8 *msg, const int *fds UNUSED)
{
enum onchain_wire_type t = fromwire_peektype(msg);
@@ -328,6 +340,10 @@ static unsigned int onchain_msg(struct subd *sd, const u8 *msg, const int *fds U
onchain_add_utxo(sd->channel, msg);
break;
case WIRE_ONCHAIN_TRANSACTION_ANNOTATE:
onchain_transaction_annotate(sd->channel, msg);
break;
/* We send these, not receive them */
case WIRE_ONCHAIN_INIT:
case WIRE_ONCHAIN_SPENT: