mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-24 01:24:26 +01:00
mfc: allow a 'close_to' address to be passed in
This will allow us to let `fundchannel` handle a close to address, also
This commit is contained in:
7
doc/lightning-multifundchannel.7
generated
7
doc/lightning-multifundchannel.7
generated
@@ -53,6 +53,11 @@ If set to \fBfalse\fR, the channel is unpublished\.
|
||||
node\.
|
||||
This is a gift to the peer, and you do not get a proof-of-payment
|
||||
out of this\.
|
||||
.IP \[bu]
|
||||
\fIclose_to\fR is a Bitcoin address to which the channel funds should be sent to
|
||||
on close\. Only valid if both peers have negotiated
|
||||
\fBoption_upfront_shutdown_script\fR\. Returns \fBclose_to\fR set to
|
||||
closing script iff is negotiated\.
|
||||
|
||||
.RE
|
||||
|
||||
@@ -167,4 +172,4 @@ ZmnSCPxj \fI<ZmnSCPxj@protonmail.com\fR> is mainly responsible\.
|
||||
|
||||
Main web site: \fIhttps://github.com/ElementsProject/lightning\fR
|
||||
|
||||
\" SHA256STAMP:c4bf503a2f8d981131960bedc07e9f08a0b65246964852a34df4292a9a36b663
|
||||
\" SHA256STAMP:70be8ab919df4a69f18103dcf3d1067e4b1d7466eb69ca474ffae3ea1f8d0ae1
|
||||
|
||||
@@ -47,6 +47,10 @@ Readiness is indicated by **listpeers** reporting a *state* of
|
||||
node.
|
||||
This is a gift to the peer, and you do not get a proof-of-payment
|
||||
out of this.
|
||||
* *close_to* is a Bitcoin address to which the channel funds should be sent to
|
||||
on close. Only valid if both peers have negotiated
|
||||
`option_upfront_shutdown_script`. Returns `close_to` set to
|
||||
closing script iff is negotiated.
|
||||
|
||||
There must be at least one entry in *destinations*;
|
||||
it cannot be an empty array.
|
||||
|
||||
@@ -71,6 +71,14 @@ struct multifundchannel_destination {
|
||||
const u8 *funding_script;
|
||||
const char *funding_addr;
|
||||
|
||||
/* The bitcoin address to close to */
|
||||
const char *close_to_str;
|
||||
|
||||
/* The scriptpubkey we will close to. Only set if
|
||||
* peer supports opt_upfront_shutdownscript and
|
||||
* we passsed in a valid close_to_str */
|
||||
const u8 *close_to_script;
|
||||
|
||||
/* The amount to be funded for this destination.
|
||||
If the specified amount is "all" then the `all`
|
||||
flag is set, and the amount is initially 0 until
|
||||
@@ -516,6 +524,11 @@ param_destinations_array(struct command *cmd, const char *name,
|
||||
p_opt_def("announce", param_bool, &announce, true),
|
||||
p_opt_def("push_msat", param_msat, &push_msat,
|
||||
AMOUNT_MSAT(0)),
|
||||
/* FIXME: do address validation here?
|
||||
* Note that it will fail eventually (when
|
||||
* passed in to fundchannel_start) if invalid*/
|
||||
p_opt("close_to", param_string,
|
||||
&dest->close_to_str),
|
||||
NULL))
|
||||
return command_param_failed();
|
||||
|
||||
@@ -1156,6 +1169,8 @@ fundchannel_start_dest(struct multifundchannel_destination *dest)
|
||||
json_add_bool(req->js, "announce", dest->announce);
|
||||
json_add_string(req->js, "push_msat",
|
||||
fmt_amount_msat(tmpctx, &dest->push_msat));
|
||||
if (dest->close_to_str)
|
||||
json_add_string(req->js, "close_to", dest->close_to_str);
|
||||
|
||||
send_outreq(cmd->plugin, req);
|
||||
}
|
||||
@@ -1172,6 +1187,7 @@ fundchannel_start_ok(struct command *cmd,
|
||||
struct multifundchannel_command *mfc = dest->mfc;
|
||||
const jsmntok_t *address_tok;
|
||||
const jsmntok_t *script_tok;
|
||||
const jsmntok_t *close_to_tok;
|
||||
|
||||
plugin_log(mfc->cmd->plugin, LOG_DBG,
|
||||
"mfc %"PRIu64", dest %u: fundchannel_start %s done.",
|
||||
@@ -1204,6 +1220,16 @@ fundchannel_start_ok(struct command *cmd,
|
||||
json_tok_full_len(script_tok),
|
||||
json_tok_full(buf, script_tok));
|
||||
|
||||
close_to_tok = json_get_member(buf, result, "close_to");
|
||||
/* Only returned if a) we requested and b) peer supports
|
||||
* opt_upfront_shutdownscript */
|
||||
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;
|
||||
|
||||
|
||||
dest->state = MULTIFUNDCHANNEL_STARTED;
|
||||
|
||||
return fundchannel_start_done(dest);
|
||||
@@ -1773,6 +1799,9 @@ multifundchannel_finished(struct multifundchannel_command *mfc)
|
||||
json_add_node_id(out, "id", &mfc->destinations[i].id);
|
||||
json_add_string(out, "channel_id", mfc->destinations[i].channel_id);
|
||||
json_add_num(out, "outnum", mfc->destinations[i].outnum);
|
||||
if (mfc->destinations[i].close_to_script)
|
||||
json_add_hex_talarr(out, "close_to",
|
||||
mfc->destinations[i].close_to_script);
|
||||
json_object_end(out);
|
||||
}
|
||||
json_array_end(out);
|
||||
|
||||
Reference in New Issue
Block a user