From 1db0ec8b75c84d47a9d210b1b07446164df0e0ce Mon Sep 17 00:00:00 2001 From: Michael Schmoock Date: Fri, 3 Sep 2021 16:24:46 +0200 Subject: [PATCH] hook: adds channel_id and commitnum to commitment_revocation If commitment_revocation hook is not being used for a whatchtower but something else, the channel_id is missing. Changelog-Added: addes channel_id and commitnum to commitment_revocation hook --- lightningd/peer_htlcs.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index 8975e19dc..3ae970d44 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -2048,8 +2048,9 @@ struct commitment_revocation_payload { struct bitcoin_txid commitment_txid; const struct bitcoin_tx *penalty_tx; struct wallet *wallet; - u64 channel_id; + u64 channel_dbid; u64 commitnum; + struct channel_id channel_id; }; static void commitment_revocation_hook_serialize( @@ -2058,11 +2059,13 @@ static void commitment_revocation_hook_serialize( { json_add_txid(stream, "commitment_txid", &payload->commitment_txid); json_add_tx(stream, "penalty_tx", payload->penalty_tx); + json_add_channel_id(stream, "channel_id", &payload->channel_id); + json_add_u64(stream, "commitnum", payload->commitnum); } static void commitment_revocation_hook_cb(struct commitment_revocation_payload *p STEALS){ - wallet_penalty_base_delete(p->wallet, p->channel_id, p->commitnum); + wallet_penalty_base_delete(p->wallet, p->channel_dbid, p->commitnum); } static bool @@ -2209,8 +2212,9 @@ void peer_got_revoke(struct channel *channel, const u8 *msg) payload->commitment_txid = pbase->txid; payload->penalty_tx = tal_steal(payload, penalty_tx); payload->wallet = ld->wallet; - payload->channel_id = channel->dbid; + payload->channel_dbid = channel->dbid; payload->commitnum = pbase->commitment_num; + payload->channel_id = channel->cid; plugin_hook_call_commitment_revocation(ld, payload); }