dualopen: use separate wire for passing updated PSBTs back to dualopend
Rusty pointed out that having an empty channel_id is suboptimal; adding another call is probably the right idea rather than re-using an existing one. Suggested-By: @rustyrussell
This commit is contained in:
parent
33769cca4f
commit
085c590a51
|
@ -500,8 +500,7 @@ openchannel2_changed_hook_cb(struct openchannel2_psbt_payload *payload STEALS)
|
||||||
payload);
|
payload);
|
||||||
|
|
||||||
subd_send_msg(dualopend,
|
subd_send_msg(dualopend,
|
||||||
take(towire_dual_open_psbt_changed(NULL,
|
take(towire_dual_open_psbt_updated(NULL,
|
||||||
&payload->rcvd->cid,
|
|
||||||
payload->psbt)));
|
payload->psbt)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1086,7 +1085,6 @@ static struct command_result *json_open_channel_update(struct command *cmd,
|
||||||
struct node_id *id;
|
struct node_id *id;
|
||||||
struct peer *peer;
|
struct peer *peer;
|
||||||
struct channel *channel;
|
struct channel *channel;
|
||||||
struct channel_id chan_id_unused;
|
|
||||||
u8 *msg;
|
u8 *msg;
|
||||||
|
|
||||||
if (!param(cmd, buffer, params,
|
if (!param(cmd, buffer, params,
|
||||||
|
@ -1123,8 +1121,7 @@ static struct command_result *json_open_channel_update(struct command *cmd,
|
||||||
|
|
||||||
peer->uncommitted_channel->fc->cmd = cmd;
|
peer->uncommitted_channel->fc->cmd = cmd;
|
||||||
|
|
||||||
memset(&chan_id_unused, 0, sizeof(chan_id_unused));
|
msg = towire_dual_open_psbt_updated(NULL, psbt);
|
||||||
msg = towire_dual_open_psbt_changed(NULL, &chan_id_unused, psbt);
|
|
||||||
subd_send_msg(peer->uncommitted_channel->open_daemon, take(msg));
|
subd_send_msg(peer->uncommitted_channel->open_daemon, take(msg));
|
||||||
return command_still_pending(cmd);
|
return command_still_pending(cmd);
|
||||||
}
|
}
|
||||||
|
@ -1327,6 +1324,7 @@ static unsigned int dual_opend_msg(struct subd *dualopend,
|
||||||
case WIRE_DUAL_OPEN_OPENER_INIT:
|
case WIRE_DUAL_OPEN_OPENER_INIT:
|
||||||
case WIRE_DUAL_OPEN_GOT_OFFER_REPLY:
|
case WIRE_DUAL_OPEN_GOT_OFFER_REPLY:
|
||||||
case WIRE_DUAL_OPEN_FAIL:
|
case WIRE_DUAL_OPEN_FAIL:
|
||||||
|
case WIRE_DUAL_OPEN_PSBT_UPDATED:
|
||||||
case WIRE_DUAL_OPEN_DEV_MEMLEAK:
|
case WIRE_DUAL_OPEN_DEV_MEMLEAK:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -376,7 +376,6 @@ fetch_psbt_changes(struct state *state, const struct wally_psbt *psbt)
|
||||||
{
|
{
|
||||||
u8 *msg;
|
u8 *msg;
|
||||||
char *err;
|
char *err;
|
||||||
struct channel_id unused;
|
|
||||||
struct wally_psbt *updated_psbt;
|
struct wally_psbt *updated_psbt;
|
||||||
|
|
||||||
/* Go ask lightningd what other changes we've got */
|
/* Go ask lightningd what other changes we've got */
|
||||||
|
@ -387,7 +386,7 @@ fetch_psbt_changes(struct state *state, const struct wally_psbt *psbt)
|
||||||
|
|
||||||
if (fromwire_dual_open_fail(msg, msg, &err))
|
if (fromwire_dual_open_fail(msg, msg, &err))
|
||||||
status_failed(STATUS_FAIL_MASTER_IO, "%s", err);
|
status_failed(STATUS_FAIL_MASTER_IO, "%s", err);
|
||||||
else if (fromwire_dual_open_psbt_changed(state, msg, &unused, &updated_psbt)) {
|
else if (fromwire_dual_open_psbt_updated(state, msg, &updated_psbt)) {
|
||||||
/* Does our PSBT meet requirements? */
|
/* Does our PSBT meet requirements? */
|
||||||
if (!check_balances(state, updated_psbt,
|
if (!check_balances(state, updated_psbt,
|
||||||
state->our_role == TX_INITIATOR,
|
state->our_role == TX_INITIATOR,
|
||||||
|
@ -1706,6 +1705,7 @@ static u8 *handle_master_in(struct state *state)
|
||||||
case WIRE_DUAL_OPEN_GOT_OFFER_REPLY:
|
case WIRE_DUAL_OPEN_GOT_OFFER_REPLY:
|
||||||
case WIRE_DUAL_OPEN_COMMIT_RCVD:
|
case WIRE_DUAL_OPEN_COMMIT_RCVD:
|
||||||
case WIRE_DUAL_OPEN_PSBT_CHANGED:
|
case WIRE_DUAL_OPEN_PSBT_CHANGED:
|
||||||
|
case WIRE_DUAL_OPEN_PSBT_UPDATED:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,11 +84,14 @@ msgdata,dual_open_commit_rcvd,remote_shutdown_len,u16,
|
||||||
msgdata,dual_open_commit_rcvd,remote_shutdown_scriptpubkey,u8,remote_shutdown_len
|
msgdata,dual_open_commit_rcvd,remote_shutdown_scriptpubkey,u8,remote_shutdown_len
|
||||||
|
|
||||||
# dualopend->master: peer updated the psbt
|
# dualopend->master: peer updated the psbt
|
||||||
# master->dualopend: response from hook when asking for next moves
|
|
||||||
msgtype,dual_open_psbt_changed,7107
|
msgtype,dual_open_psbt_changed,7107
|
||||||
msgdata,dual_open_psbt_changed,channel_id,channel_id,
|
msgdata,dual_open_psbt_changed,channel_id,channel_id,
|
||||||
msgdata,dual_open_psbt_changed,psbt,wally_psbt,
|
msgdata,dual_open_psbt_changed,psbt,wally_psbt,
|
||||||
|
|
||||||
|
# master->dualopend: we updated the psbt
|
||||||
|
msgtype,dual_open_psbt_updated,7108
|
||||||
|
msgdata,dual_open_psbt_updated,psbt,wally_psbt,
|
||||||
|
|
||||||
# master->dualopend: fail this channel open
|
# master->dualopend: fail this channel open
|
||||||
msgtype,dual_open_fail,7003
|
msgtype,dual_open_fail,7003
|
||||||
msgdata,dual_open_fail,reason,wirestring,
|
msgdata,dual_open_fail,reason,wirestring,
|
||||||
|
|
Can't render this file because it has a wrong number of fields in line 11.
|
|
@ -25,6 +25,7 @@ const char *dualopend_wire_name(int e)
|
||||||
case WIRE_DUAL_OPEN_GOT_OFFER_REPLY: return "WIRE_DUAL_OPEN_GOT_OFFER_REPLY";
|
case WIRE_DUAL_OPEN_GOT_OFFER_REPLY: return "WIRE_DUAL_OPEN_GOT_OFFER_REPLY";
|
||||||
case WIRE_DUAL_OPEN_COMMIT_RCVD: return "WIRE_DUAL_OPEN_COMMIT_RCVD";
|
case WIRE_DUAL_OPEN_COMMIT_RCVD: return "WIRE_DUAL_OPEN_COMMIT_RCVD";
|
||||||
case WIRE_DUAL_OPEN_PSBT_CHANGED: return "WIRE_DUAL_OPEN_PSBT_CHANGED";
|
case WIRE_DUAL_OPEN_PSBT_CHANGED: return "WIRE_DUAL_OPEN_PSBT_CHANGED";
|
||||||
|
case WIRE_DUAL_OPEN_PSBT_UPDATED: return "WIRE_DUAL_OPEN_PSBT_UPDATED";
|
||||||
case WIRE_DUAL_OPEN_FAIL: return "WIRE_DUAL_OPEN_FAIL";
|
case WIRE_DUAL_OPEN_FAIL: return "WIRE_DUAL_OPEN_FAIL";
|
||||||
case WIRE_DUAL_OPEN_FAILED: return "WIRE_DUAL_OPEN_FAILED";
|
case WIRE_DUAL_OPEN_FAILED: return "WIRE_DUAL_OPEN_FAILED";
|
||||||
case WIRE_DUAL_OPEN_OPENER_INIT: return "WIRE_DUAL_OPEN_OPENER_INIT";
|
case WIRE_DUAL_OPEN_OPENER_INIT: return "WIRE_DUAL_OPEN_OPENER_INIT";
|
||||||
|
@ -44,6 +45,7 @@ bool dualopend_wire_is_defined(u16 type)
|
||||||
case WIRE_DUAL_OPEN_GOT_OFFER_REPLY:;
|
case WIRE_DUAL_OPEN_GOT_OFFER_REPLY:;
|
||||||
case WIRE_DUAL_OPEN_COMMIT_RCVD:;
|
case WIRE_DUAL_OPEN_COMMIT_RCVD:;
|
||||||
case WIRE_DUAL_OPEN_PSBT_CHANGED:;
|
case WIRE_DUAL_OPEN_PSBT_CHANGED:;
|
||||||
|
case WIRE_DUAL_OPEN_PSBT_UPDATED:;
|
||||||
case WIRE_DUAL_OPEN_FAIL:;
|
case WIRE_DUAL_OPEN_FAIL:;
|
||||||
case WIRE_DUAL_OPEN_FAILED:;
|
case WIRE_DUAL_OPEN_FAILED:;
|
||||||
case WIRE_DUAL_OPEN_OPENER_INIT:;
|
case WIRE_DUAL_OPEN_OPENER_INIT:;
|
||||||
|
@ -308,7 +310,6 @@ bool fromwire_dual_open_commit_rcvd(const tal_t *ctx, const void *p, struct chan
|
||||||
|
|
||||||
/* WIRE: DUAL_OPEN_PSBT_CHANGED */
|
/* WIRE: DUAL_OPEN_PSBT_CHANGED */
|
||||||
/* dualopend->master: peer updated the psbt */
|
/* dualopend->master: peer updated the psbt */
|
||||||
/* master->dualopend: response from hook when asking for next moves */
|
|
||||||
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, const struct wally_psbt *psbt)
|
||||||
{
|
{
|
||||||
u8 *p = tal_arr(ctx, u8, 0);
|
u8 *p = tal_arr(ctx, u8, 0);
|
||||||
|
@ -331,6 +332,28 @@ bool fromwire_dual_open_psbt_changed(const tal_t *ctx, const void *p, struct cha
|
||||||
return cursor != NULL;
|
return cursor != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* WIRE: DUAL_OPEN_PSBT_UPDATED */
|
||||||
|
/* master->dualopend: we updated the psbt */
|
||||||
|
u8 *towire_dual_open_psbt_updated(const tal_t *ctx, const struct wally_psbt *psbt)
|
||||||
|
{
|
||||||
|
u8 *p = tal_arr(ctx, u8, 0);
|
||||||
|
|
||||||
|
towire_u16(&p, WIRE_DUAL_OPEN_PSBT_UPDATED);
|
||||||
|
towire_wally_psbt(&p, psbt);
|
||||||
|
|
||||||
|
return memcheck(p, tal_count(p));
|
||||||
|
}
|
||||||
|
bool fromwire_dual_open_psbt_updated(const tal_t *ctx, const void *p, struct wally_psbt **psbt)
|
||||||
|
{
|
||||||
|
const u8 *cursor = p;
|
||||||
|
size_t plen = tal_count(p);
|
||||||
|
|
||||||
|
if (fromwire_u16(&cursor, &plen) != WIRE_DUAL_OPEN_PSBT_UPDATED)
|
||||||
|
return false;
|
||||||
|
*psbt = fromwire_wally_psbt(ctx, &cursor, &plen);
|
||||||
|
return cursor != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* WIRE: DUAL_OPEN_FAIL */
|
/* WIRE: DUAL_OPEN_FAIL */
|
||||||
/* master->dualopend: fail this channel open */
|
/* master->dualopend: fail this channel open */
|
||||||
u8 *towire_dual_open_fail(const tal_t *ctx, const wirestring *reason)
|
u8 *towire_dual_open_fail(const tal_t *ctx, const wirestring *reason)
|
||||||
|
@ -454,4 +477,4 @@ bool fromwire_dual_open_dev_memleak_reply(const void *p, bool *leak)
|
||||||
*leak = fromwire_bool(&cursor, &plen);
|
*leak = fromwire_bool(&cursor, &plen);
|
||||||
return cursor != NULL;
|
return cursor != NULL;
|
||||||
}
|
}
|
||||||
// SHA256STAMP:4d357681ca9bea1ad36f3fe4d3482a0a12f808dfe20b71f0b9bee78beed0950e
|
// SHA256STAMP:37f122e865f6e2432cffb5ae82c77ca2f8a3714baed0c9724a92541092f3aa54
|
||||||
|
|
|
@ -27,8 +27,9 @@ enum dualopend_wire {
|
||||||
/* get some signatures for the funding_tx. */
|
/* get some signatures for the funding_tx. */
|
||||||
WIRE_DUAL_OPEN_COMMIT_RCVD = 7007,
|
WIRE_DUAL_OPEN_COMMIT_RCVD = 7007,
|
||||||
/* dualopend->master: peer updated the psbt */
|
/* dualopend->master: peer updated the psbt */
|
||||||
/* master->dualopend: response from hook when asking for next moves */
|
|
||||||
WIRE_DUAL_OPEN_PSBT_CHANGED = 7107,
|
WIRE_DUAL_OPEN_PSBT_CHANGED = 7107,
|
||||||
|
/* master->dualopend: we updated the psbt */
|
||||||
|
WIRE_DUAL_OPEN_PSBT_UPDATED = 7108,
|
||||||
/* master->dualopend: fail this channel open */
|
/* master->dualopend: fail this channel open */
|
||||||
WIRE_DUAL_OPEN_FAIL = 7003,
|
WIRE_DUAL_OPEN_FAIL = 7003,
|
||||||
/* dualopend->master: we failed to negotiate channel */
|
/* dualopend->master: we failed to negotiate channel */
|
||||||
|
@ -74,10 +75,14 @@ bool fromwire_dual_open_commit_rcvd(const tal_t *ctx, const void *p, struct chan
|
||||||
|
|
||||||
/* WIRE: DUAL_OPEN_PSBT_CHANGED */
|
/* WIRE: DUAL_OPEN_PSBT_CHANGED */
|
||||||
/* dualopend->master: peer updated the psbt */
|
/* dualopend->master: peer updated the psbt */
|
||||||
/* master->dualopend: response from hook when asking for next moves */
|
|
||||||
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, 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);
|
bool fromwire_dual_open_psbt_changed(const tal_t *ctx, const void *p, struct channel_id *channel_id, struct wally_psbt **psbt);
|
||||||
|
|
||||||
|
/* WIRE: DUAL_OPEN_PSBT_UPDATED */
|
||||||
|
/* master->dualopend: we updated the psbt */
|
||||||
|
u8 *towire_dual_open_psbt_updated(const tal_t *ctx, const struct wally_psbt *psbt);
|
||||||
|
bool fromwire_dual_open_psbt_updated(const tal_t *ctx, const void *p, struct wally_psbt **psbt);
|
||||||
|
|
||||||
/* WIRE: DUAL_OPEN_FAIL */
|
/* WIRE: DUAL_OPEN_FAIL */
|
||||||
/* master->dualopend: fail this channel open */
|
/* master->dualopend: fail this channel open */
|
||||||
u8 *towire_dual_open_fail(const tal_t *ctx, const wirestring *reason);
|
u8 *towire_dual_open_fail(const tal_t *ctx, const wirestring *reason);
|
||||||
|
@ -104,4 +109,4 @@ bool fromwire_dual_open_dev_memleak_reply(const void *p, bool *leak);
|
||||||
|
|
||||||
|
|
||||||
#endif /* LIGHTNING_OPENINGD_DUALOPEND_WIREGEN_H */
|
#endif /* LIGHTNING_OPENINGD_DUALOPEND_WIREGEN_H */
|
||||||
// SHA256STAMP:4d357681ca9bea1ad36f3fe4d3482a0a12f808dfe20b71f0b9bee78beed0950e
|
// SHA256STAMP:37f122e865f6e2432cffb5ae82c77ca2f8a3714baed0c9724a92541092f3aa54
|
||||||
|
|
Loading…
Reference in New Issue