diff --git a/lightningd/onchain_control.c b/lightningd/onchain_control.c index 67fa22f6c..bbd254b78 100644 --- a/lightningd/onchain_control.c +++ b/lightningd/onchain_control.c @@ -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: diff --git a/onchaind/onchain_wire.csv b/onchaind/onchain_wire.csv index 88de07d8c..af8a113cd 100644 --- a/onchaind/onchain_wire.csv +++ b/onchaind/onchain_wire.csv @@ -99,3 +99,10 @@ onchain_dev_memleak,5033 onchain_dev_memleak_reply,5133 onchain_dev_memleak_reply,,leak,bool + +# Tell the main daemon what we've been watching, mainly used for transactions +# that we tracked automatically but only onchaind knows how to classify their +# transactions. +onchain_transaction_annotate,5034 +onchain_transaction_annotate,,txid,struct bitcoin_txid +onchain_transaction_annotate,,type,u16