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:
parent
ae0bc4aed0
commit
a54b7da705
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
Loading…
Reference in New Issue