Browse Source

df: pass back 'close_to' for completed/commitment secured channels

When commitments are secured, also return the 'close_to' script if we've
got a local_upfront_shutdown_script set.
fix-mocks
niftynei 4 years ago
committed by neil saitug
parent
commit
6077eca660
  1. 16
      doc/lightning-openchannel_update.7
  2. 8
      doc/lightning-openchannel_update.7.md
  3. 3
      lightningd/dual_open_control.c
  4. 10
      plugins/spender/openchannel.c

16
doc/lightning-openchannel_update.7

@ -35,6 +35,20 @@ complete \fIpsbt\fR for this channel's funding transaction; and the flag
If \fIcommitments_secured\fR is true, caller should proceed with signing the If \fIcommitments_secured\fR is true, caller should proceed with signing the
returned PSBT and calling \fBopenchannel_signed\fR to complete the channel open\. returned PSBT and calling \fBopenchannel_signed\fR to complete the channel open\.
If \fIcommitments_secured\fR is true, will also return:
.RS
.IP \[bu]
The derived \fIchannel_id\fR\.
.IP \[bu]
A \fIclose_to\fR script, iff a \fBclose_to\fR address was provided to
\fBopenchannel_init\fR and the peer supports \fBoption_upfront_shutdownscript\fR\.
.IP \[bu]
The \fIfunding_outnum\fR, the index of the funding output for this channel
in the funding transaction\.
.RE
.RS .RS
.IP \[bu] .IP \[bu]
-32602: If the given parameters are wrong\. -32602: If the given parameters are wrong\.
@ -63,4 +77,4 @@ lightning-fundchannel_\fBstart\fR(7), lightning-fundchannel_\fBcomplete\fR(7),
Main web site: \fIhttps://github.com/ElementsProject/lightning\fR Main web site: \fIhttps://github.com/ElementsProject/lightning\fR
\" SHA256STAMP:ab3d19be91c8b2e651a6f4a23552f21323c4f0096ceda8026bb2450c2f9c616c \" SHA256STAMP:de370bb6e61a0390a50a85e97f533238f379c908cddd822436d0ac4c72b43d6e

8
doc/lightning-openchannel_update.7.md

@ -34,6 +34,14 @@ complete *psbt* for this channel's funding transaction; and the flag
If *commitments_secured* is true, caller should proceed with signing the If *commitments_secured* is true, caller should proceed with signing the
returned PSBT and calling `openchannel_signed` to complete the channel open. returned PSBT and calling `openchannel_signed` to complete the channel open.
If *commitments_secured* is true, will also return:
- The derived *channel_id*.
- A *close_to* script, iff a `close_to` address was provided to
`openchannel_init` and the peer supports `option_upfront_shutdownscript`.
- The *funding_outnum*, the index of the funding output for this channel
in the funding transaction.
- -32602: If the given parameters are wrong. - -32602: If the given parameters are wrong.
- -1: Catchall nonspecific error. - -1: Catchall nonspecific error.
- 305: Peer is not connected. - 305: Peer is not connected.

3
lightningd/dual_open_control.c

@ -933,6 +933,9 @@ static void opener_commit_received(struct subd *dualopend,
json_add_bool(response, "commitments_secured", true); json_add_bool(response, "commitments_secured", true);
/* For convenience sake, we include the funding outnum */ /* For convenience sake, we include the funding outnum */
json_add_num(response, "funding_outnum", funding_outnum); json_add_num(response, "funding_outnum", funding_outnum);
if (local_upfront_shutdown_script)
json_add_hex_talarr(response, "close_to",
local_upfront_shutdown_script);
/* Now that we've got the final PSBT, save it */ /* Now that we've got the final PSBT, save it */
channel->psbt = tal_steal(channel, psbt); channel->psbt = tal_steal(channel, psbt);
wallet_channel_save(uc->fc->cmd->ld->wallet, channel); wallet_channel_save(uc->fc->cmd->ld->wallet, channel);

10
plugins/spender/openchannel.c

@ -715,7 +715,7 @@ openchannel_update_ok(struct command *cmd,
json_tok_full(buf, result)); json_tok_full(buf, result));
if (done) { if (done) {
const jsmntok_t *outnum_tok; const jsmntok_t *outnum_tok, *close_to_tok;
outnum_tok = json_get_member(buf, result, "funding_outnum"); outnum_tok = json_get_member(buf, result, "funding_outnum");
if (!outnum_tok) if (!outnum_tok)
@ -732,6 +732,14 @@ openchannel_update_ok(struct command *cmd,
json_tok_full_len(result), json_tok_full_len(result),
json_tok_full(buf, result)); json_tok_full(buf, result));
close_to_tok = json_get_member(buf, result, "close_to");
if (close_to_tok)
dest->close_to_script =
json_tok_bin_from_hex(dest->mfc, buf,
close_to_tok);
else
dest->close_to_script = NULL;
/* It's possible they beat us to the SIGNED flag, /* It's possible they beat us to the SIGNED flag,
* in which case we just let that be the more senior * in which case we just let that be the more senior
* state position */ * state position */

Loading…
Cancel
Save