Skip to content

Commit 4bd9d38

Browse files
authored
Merge pull request #39 from lightning-signer/2021-10-justice-sweep
Add destination wallet keypath to justice sweeps.
2 parents 546f608 + 6e7bcf1 commit 4bd9d38

22 files changed

+124
-78
lines changed

channeld/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ CHANNELD_COMMON_OBJS := \
7272
common/per_peer_state.o \
7373
common/permute_tx.o \
7474
common/ping.o \
75+
common/psbt_internal.o \
7576
common/psbt_open.o \
7677
common/private_channel_announcement.o \
7778
common/pseudorand.o \

channeld/channeld.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ struct peer {
153153
u32 fee_per_satoshi;
154154

155155
/* The scriptpubkey to use for shutting down. */
156+
u32 final_index;
157+
struct ext_key final_ext_key;
156158
u8 *final_scriptpubkey;
157159

158160
/* If master told us to shut down */
@@ -1856,6 +1858,7 @@ static u8 *got_revoke_msg(struct peer *peer, u64 revoke_num,
18561858
if (pbase) {
18571859
ptx = penalty_tx_create(
18581860
NULL, peer->channel, peer->feerate_penalty,
1861+
peer->final_index, &peer->final_ext_key,
18591862
peer->final_scriptpubkey, per_commitment_secret,
18601863
&pbase->txid, pbase->outnum, pbase->amount,
18611864
HSM_FD);
@@ -3537,7 +3540,10 @@ static void handle_shutdown_cmd(struct peer *peer, const u8 *inmsg)
35373540
{
35383541
u8 *local_shutdown_script;
35393542

3540-
if (!fromwire_channeld_send_shutdown(peer, inmsg, &local_shutdown_script,
3543+
if (!fromwire_channeld_send_shutdown(peer, inmsg,
3544+
&peer->final_index,
3545+
&peer->final_ext_key,
3546+
&local_shutdown_script,
35413547
&peer->shutdown_wrong_funding))
35423548
master_badmsg(WIRE_CHANNELD_SEND_SHUTDOWN, inmsg);
35433549

@@ -3787,6 +3793,8 @@ static void init_channel(struct peer *peer)
37873793
&reconnected,
37883794
&peer->send_shutdown,
37893795
&peer->shutdown_sent[REMOTE],
3796+
&peer->final_index,
3797+
&peer->final_ext_key,
37903798
&peer->final_scriptpubkey,
37913799
&peer->channel_flags,
37923800
&fwd_msg,

channeld/channeld_wire.csv

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <bitcoin/psbt.h>
22
#include <bitcoin/tx.h>
3+
#include <common/bip32.h>
34
#include <common/blockheight_states.h>
45
#include <common/cryptomsg.h>
56
#include <common/channel_config.h>
@@ -58,6 +59,8 @@ msgdata,channeld_init,funding_short_id,short_channel_id,
5859
msgdata,channeld_init,reestablish,bool,
5960
msgdata,channeld_init,send_shutdown,bool,
6061
msgdata,channeld_init,remote_shutdown_received,bool,
62+
msgdata,channeld_init,final_index,u32,
63+
msgdata,channeld_init,final_ext_key,ext_key,
6164
msgdata,channeld_init,final_scriptpubkey_len,u16,
6265
msgdata,channeld_init,final_scriptpubkey,u8,final_scriptpubkey_len
6366
msgdata,channeld_init,flags,u8,
@@ -175,6 +178,8 @@ msgtype,channeld_got_revoke_reply,1122
175178

176179
# Tell peer to shut down channel.
177180
msgtype,channeld_send_shutdown,1023
181+
msgdata,channeld_send_shutdown,final_index,u32,
182+
msgdata,channeld_send_shutdown,final_ext_key,ext_key,
178183
msgdata,channeld_send_shutdown,shutdown_len,u16,
179184
msgdata,channeld_send_shutdown,shutdown_scriptpubkey,u8,shutdown_len
180185
msgdata,channeld_send_shutdown,wrong_funding,?bitcoin_outpoint,

channeld/channeld_wiregen.c

Lines changed: 13 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)