mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
df: Pass the serial_id of the funding output to openchannel_init caller
This is handy/necessary for getting multifundchannel to work, as we need to know what output to tell all the other peers about. Changelog-Added: Experimental!! JSON-RPC: openchannel_init returns a field `funding_serial` that indicates the serial_id of the funding output in the provided PSBT
This commit is contained in:
parent
8bf9b4132b
commit
5c04ff1ad7
6
doc/lightning-openchannel_init.7
generated
6
doc/lightning-openchannel_init.7
generated
@ -48,7 +48,9 @@ sent on close\. Only valid if both peers have negotiated
|
||||
On success, returns the \fIchannel_id\fR for this channel; an updated
|
||||
incomplete \fIinitialpsbt\fR for this funding transaction; and the flag
|
||||
\fIcommitments_secured\fR, which indiciates the completeness of the
|
||||
passed back \fIpsbt\fR\. (Will always be false)\.
|
||||
passed back \fIpsbt\fR\. (Will always be false)\. Also returns the
|
||||
\fIfunding_serial\fR, indicating the serial_id of the funding output
|
||||
in the \fIpsbt\fR\.
|
||||
|
||||
|
||||
If the peer does not support \fBoption_dual_fund\fR, this command
|
||||
@ -94,4 +96,4 @@ lightning-fundchannel_\fBstart\fR(7), lightning-fundchannel_\fBcomplete\fR(7),
|
||||
|
||||
Main web site: \fIhttps://github.com/ElementsProject/lightning\fR
|
||||
|
||||
\" SHA256STAMP:a06dc67176c3c9863e4fc3048de7d0172eb79d091479415eb639335b3d096860
|
||||
\" SHA256STAMP:d73cf35c01e641d80688352058111421d9213b0a23043e9cdc807398442efd7a
|
||||
|
@ -45,7 +45,9 @@ RETURN VALUE
|
||||
On success, returns the *channel_id* for this channel; an updated
|
||||
incomplete *initialpsbt* for this funding transaction; and the flag
|
||||
*commitments_secured*, which indiciates the completeness of the
|
||||
passed back *psbt*. (Will always be false).
|
||||
passed back *psbt*. (Will always be false). Also returns the
|
||||
*funding_serial*, indicating the serial\_id of the funding output
|
||||
in the *psbt*.
|
||||
|
||||
If the peer does not support `option_dual_fund`, this command
|
||||
will return an error.
|
||||
|
@ -635,12 +635,13 @@ static void opener_psbt_changed(struct subd *dualopend,
|
||||
const u8 *msg)
|
||||
{
|
||||
struct channel_id cid;
|
||||
u16 funding_serial;
|
||||
struct wally_psbt *psbt;
|
||||
struct json_stream *response;
|
||||
struct command *cmd = uc->fc->cmd;
|
||||
|
||||
if (!fromwire_dual_open_psbt_changed(cmd, msg,
|
||||
&cid,
|
||||
&cid, &funding_serial,
|
||||
&psbt)) {
|
||||
log_broken(dualopend->log,
|
||||
"Malformed dual_open_psbt_changed %s",
|
||||
@ -654,6 +655,7 @@ static void opener_psbt_changed(struct subd *dualopend,
|
||||
type_to_string(tmpctx, struct channel_id, &cid));
|
||||
json_add_psbt(response, "psbt", psbt);
|
||||
json_add_bool(response, "commitments_secured", false);
|
||||
json_add_num(response, "funding_serial", funding_serial);
|
||||
|
||||
uc->cid = cid;
|
||||
uc->fc->inflight = true;
|
||||
@ -900,6 +902,7 @@ failed:
|
||||
static void accepter_psbt_changed(struct subd *dualopend,
|
||||
const u8 *msg)
|
||||
{
|
||||
u16 unused;
|
||||
struct openchannel2_psbt_payload *payload =
|
||||
tal(dualopend, struct openchannel2_psbt_payload);
|
||||
payload->dualopend = dualopend;
|
||||
@ -908,6 +911,7 @@ static void accepter_psbt_changed(struct subd *dualopend,
|
||||
|
||||
if (!fromwire_dual_open_psbt_changed(payload, msg,
|
||||
&payload->rcvd->cid,
|
||||
&unused,
|
||||
&payload->psbt)) {
|
||||
log_broken(dualopend->log, "Malformed dual_open_psbt_changed %s",
|
||||
tal_hex(tmpctx, msg));
|
||||
|
@ -121,6 +121,9 @@ struct state {
|
||||
|
||||
/* Set of pending changes to send to peer */
|
||||
struct psbt_changeset *changeset;
|
||||
|
||||
/* The serial_id of the funding output */
|
||||
u16 funding_serial;
|
||||
};
|
||||
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
@ -602,7 +605,9 @@ fetch_psbt_changes(struct state *state, const struct wally_psbt *psbt)
|
||||
struct wally_psbt *updated_psbt;
|
||||
|
||||
/* Go ask lightningd what other changes we've got */
|
||||
msg = towire_dual_open_psbt_changed(NULL, &state->channel_id, psbt);
|
||||
msg = towire_dual_open_psbt_changed(NULL, &state->channel_id,
|
||||
state->funding_serial,
|
||||
psbt);
|
||||
|
||||
wire_sync_write(REQ_FD, take(msg));
|
||||
msg = wire_sync_read(tmpctx, REQ_FD);
|
||||
@ -1287,6 +1292,10 @@ static u8 *accepter_start(struct state *state, const u8 *oc2_msg)
|
||||
sync_crypto_write(state->pps, msg);
|
||||
peer_billboard(false, "channel open: accept sent, waiting for reply");
|
||||
|
||||
/* This is unused in this flow. We re-use
|
||||
* the wire method between accepter + opener, so we set it
|
||||
* to an invalid number, 1 (initiator sets; valid is even) */
|
||||
state->funding_serial = 1;
|
||||
/* Figure out what the funding transaction looks like! */
|
||||
if (!run_tx_interactive(state, &psbt, TX_ACCEPTER))
|
||||
return NULL;
|
||||
@ -1484,7 +1493,6 @@ static u8 *opener_start(struct state *state, u8 *msg)
|
||||
struct amount_msat our_msats;
|
||||
struct wally_psbt *psbt;
|
||||
struct wally_psbt_output *funding_out;
|
||||
u16 serial_id;
|
||||
struct sha256 podle;
|
||||
struct wally_tx_output *direct_outputs[NUM_SIDES];
|
||||
struct penalty_base *pbase;
|
||||
@ -1631,8 +1639,8 @@ static u8 *opener_start(struct state *state, u8 *msg)
|
||||
wscript),
|
||||
total);
|
||||
/* Add a serial_id for this output */
|
||||
serial_id = psbt_new_input_serial(psbt, TX_INITIATOR);
|
||||
psbt_output_set_serial_id(psbt, funding_out, serial_id);
|
||||
state->funding_serial = psbt_new_input_serial(psbt, TX_INITIATOR);
|
||||
psbt_output_set_serial_id(psbt, funding_out, state->funding_serial);
|
||||
|
||||
/* Add all of our inputs/outputs to the changeset */
|
||||
init_changeset(state, psbt);
|
||||
|
@ -86,6 +86,7 @@ msgdata,dual_open_commit_rcvd,remote_shutdown_scriptpubkey,u8,remote_shutdown_le
|
||||
# dualopend->master: peer updated the psbt
|
||||
msgtype,dual_open_psbt_changed,7107
|
||||
msgdata,dual_open_psbt_changed,channel_id,channel_id,
|
||||
msgdata,dual_open_psbt_changed,funding_serial,u16,
|
||||
msgdata,dual_open_psbt_changed,psbt,wally_psbt,
|
||||
|
||||
# master->dualopend: we updated the psbt
|
||||
|
Can't render this file because it has a wrong number of fields in line 11.
|
8
openingd/dualopend_wiregen.c
generated
8
openingd/dualopend_wiregen.c
generated
@ -310,17 +310,18 @@ bool fromwire_dual_open_commit_rcvd(const tal_t *ctx, const void *p, struct chan
|
||||
|
||||
/* WIRE: DUAL_OPEN_PSBT_CHANGED */
|
||||
/* dualopend->master: peer updated the psbt */
|
||||
u8 *towire_dual_open_psbt_changed(const tal_t *ctx, const struct channel_id *channel_id, const struct wally_psbt *psbt)
|
||||
u8 *towire_dual_open_psbt_changed(const tal_t *ctx, const struct channel_id *channel_id, u16 funding_serial, const struct wally_psbt *psbt)
|
||||
{
|
||||
u8 *p = tal_arr(ctx, u8, 0);
|
||||
|
||||
towire_u16(&p, WIRE_DUAL_OPEN_PSBT_CHANGED);
|
||||
towire_channel_id(&p, channel_id);
|
||||
towire_u16(&p, funding_serial);
|
||||
towire_wally_psbt(&p, psbt);
|
||||
|
||||
return memcheck(p, tal_count(p));
|
||||
}
|
||||
bool fromwire_dual_open_psbt_changed(const tal_t *ctx, const void *p, struct channel_id *channel_id, struct wally_psbt **psbt)
|
||||
bool fromwire_dual_open_psbt_changed(const tal_t *ctx, const void *p, struct channel_id *channel_id, u16 *funding_serial, struct wally_psbt **psbt)
|
||||
{
|
||||
const u8 *cursor = p;
|
||||
size_t plen = tal_count(p);
|
||||
@ -328,6 +329,7 @@ bool fromwire_dual_open_psbt_changed(const tal_t *ctx, const void *p, struct cha
|
||||
if (fromwire_u16(&cursor, &plen) != WIRE_DUAL_OPEN_PSBT_CHANGED)
|
||||
return false;
|
||||
fromwire_channel_id(&cursor, &plen, channel_id);
|
||||
*funding_serial = fromwire_u16(&cursor, &plen);
|
||||
*psbt = fromwire_wally_psbt(ctx, &cursor, &plen);
|
||||
return cursor != NULL;
|
||||
}
|
||||
@ -477,4 +479,4 @@ bool fromwire_dual_open_dev_memleak_reply(const void *p, bool *leak)
|
||||
*leak = fromwire_bool(&cursor, &plen);
|
||||
return cursor != NULL;
|
||||
}
|
||||
// SHA256STAMP:37f122e865f6e2432cffb5ae82c77ca2f8a3714baed0c9724a92541092f3aa54
|
||||
// SHA256STAMP:ed548e8b85302ef620646a1aab503b1279fece3b9d9aeedd47a371fa2a9fbe56
|
||||
|
6
openingd/dualopend_wiregen.h
generated
6
openingd/dualopend_wiregen.h
generated
@ -75,8 +75,8 @@ bool fromwire_dual_open_commit_rcvd(const tal_t *ctx, const void *p, struct chan
|
||||
|
||||
/* WIRE: DUAL_OPEN_PSBT_CHANGED */
|
||||
/* dualopend->master: peer updated the psbt */
|
||||
u8 *towire_dual_open_psbt_changed(const tal_t *ctx, const struct channel_id *channel_id, const struct wally_psbt *psbt);
|
||||
bool fromwire_dual_open_psbt_changed(const tal_t *ctx, const void *p, struct channel_id *channel_id, struct wally_psbt **psbt);
|
||||
u8 *towire_dual_open_psbt_changed(const tal_t *ctx, const struct channel_id *channel_id, u16 funding_serial, const struct wally_psbt *psbt);
|
||||
bool fromwire_dual_open_psbt_changed(const tal_t *ctx, const void *p, struct channel_id *channel_id, u16 *funding_serial, struct wally_psbt **psbt);
|
||||
|
||||
/* WIRE: DUAL_OPEN_PSBT_UPDATED */
|
||||
/* master->dualopend: we updated the psbt */
|
||||
@ -109,4 +109,4 @@ bool fromwire_dual_open_dev_memleak_reply(const void *p, bool *leak);
|
||||
|
||||
|
||||
#endif /* LIGHTNING_OPENINGD_DUALOPEND_WIREGEN_H */
|
||||
// SHA256STAMP:37f122e865f6e2432cffb5ae82c77ca2f8a3714baed0c9724a92541092f3aa54
|
||||
// SHA256STAMP:ed548e8b85302ef620646a1aab503b1279fece3b9d9aeedd47a371fa2a9fbe56
|
||||
|
Loading…
Reference in New Issue
Block a user