Skip to content

Commit

Permalink
wire: import shutdown proposal from lightning/bolts#847
Browse files Browse the repository at this point in the history
  • Loading branch information
niftynei authored and rustyrussell committed Jun 28, 2021
1 parent 88616c7 commit 16fb867
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 12 deletions.
7 changes: 5 additions & 2 deletions closingd/closingd.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ static void send_offer(struct per_peer_state *pps,
type_to_string(tmpctx, struct amount_sat, &fee_to_offer));

assert(our_sig.sighash_type == SIGHASH_ALL);
msg = towire_closing_signed(NULL, channel_id, fee_to_offer, &our_sig.s);
msg = towire_closing_signed(NULL, channel_id, fee_to_offer, &our_sig.s, NULL);
sync_crypto_write(pps, take(msg));
}

Expand Down Expand Up @@ -231,6 +231,7 @@ receive_offer(struct per_peer_state *pps,
struct amount_sat received_fee;
struct bitcoin_signature their_sig;
struct bitcoin_tx *tx;
struct tlv_closing_signed_tlvs *close_tlvs;

/* Wait for them to say something interesting */
do {
Expand All @@ -254,8 +255,10 @@ receive_offer(struct per_peer_state *pps,
} while (!msg);

their_sig.sighash_type = SIGHASH_ALL;
close_tlvs = tlv_closing_signed_tlvs_new(msg);
if (!fromwire_closing_signed(msg, &their_channel_id,
&received_fee, &their_sig.s))
&received_fee, &their_sig.s,
close_tlvs))
peer_failed_warn(pps, channel_id,
"Expected closing_signed: %s",
tal_hex(tmpctx, msg));
Expand Down
13 changes: 13 additions & 0 deletions wire/extracted_peer_04_closing_fee_nego.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- wire/peer_wire.csv 2021-05-18 11:15:05.539134131 -0500
+++ - 2021-05-18 11:15:15.690789516 -0500
@@ -90,6 +90,10 @@
msgdata,closing_signed,channel_id,channel_id,
msgdata,closing_signed,fee_satoshis,u64,
msgdata,closing_signed,signature,signature,
+msgdata,closing_signed,tlvs,closing_signed_tlvs,
+tlvtype,closing_signed_tlvs,fee_range,1
+tlvdata,closing_signed_tlvs,fee_range,min_fee_satoshis,u64,
+tlvdata,closing_signed_tlvs,fee_range,max_fee_satoshis,u64,
msgtype,update_add_htlc,128
msgdata,update_add_htlc,channel_id,channel_id,
msgdata,update_add_htlc,id,u64,
34 changes: 33 additions & 1 deletion wire/peer_printgen.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion wire/peer_printgen.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions wire/peer_wire.csv
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ msgtype,closing_signed,39
msgdata,closing_signed,channel_id,channel_id,
msgdata,closing_signed,fee_satoshis,u64,
msgdata,closing_signed,signature,signature,
msgdata,closing_signed,tlvs,closing_signed_tlvs,
tlvtype,closing_signed_tlvs,fee_range,1
tlvdata,closing_signed_tlvs,fee_range,min_fee_satoshis,u64,
tlvdata,closing_signed_tlvs,fee_range,max_fee_satoshis,u64,
msgtype,update_add_htlc,128
msgdata,update_add_htlc,channel_id,channel_id,
msgdata,update_add_htlc,id,u64,
Expand Down
65 changes: 62 additions & 3 deletions wire/peer_wiregen.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 52 additions & 3 deletions wire/peer_wiregen.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions wire/test/run-peer-wire.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,20 +611,27 @@ static struct msg_funding_signed *fromwire_struct_funding_signed(const tal_t *ct
static void *towire_struct_closing_signed(const tal_t *ctx,
const struct msg_closing_signed *s)
{
struct tlv_closing_signed_tlvs *close_tlvs;

close_tlvs = tlv_closing_signed_tlvs_new(ctx);
return towire_closing_signed(ctx,
&s->channel_id,
s->fee_satoshis,
&s->signature);
&s->signature,
close_tlvs);
}

static struct msg_closing_signed *fromwire_struct_closing_signed(const tal_t *ctx, const void *p)
{
struct msg_closing_signed *s = tal(ctx, struct msg_closing_signed);
struct tlv_closing_signed_tlvs *close_tlvs;

close_tlvs = tlv_closing_signed_tlvs_new(ctx);
if (fromwire_closing_signed(p,
&s->channel_id,
&s->fee_satoshis,
&s->signature))
&s->signature,
close_tlvs))
return s;
return tal_free(s);
}
Expand Down

0 comments on commit 16fb867

Please sign in to comment.