mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-24 01:24:26 +01:00
mfc-df: once we've gotten the PSBT finalized, we wait for peer sigs
We need our peer's signatures to arrive before we sign/broadcast the funding transaction (but only if there's v2 peers present)
This commit is contained in:
@@ -1340,10 +1340,12 @@ perform_fundchannel_complete(struct multifundchannel_command *mfc)
|
||||
"mfc %"PRIu64": parallel fundchannel_complete.",
|
||||
mfc->id);
|
||||
|
||||
mfc->pending = tal_count(mfc->destinations);
|
||||
mfc->pending = dest_count(mfc, FUND_CHANNEL);
|
||||
|
||||
for (i = 0; i < tal_count(mfc->destinations); ++i)
|
||||
fundchannel_complete_dest(&mfc->destinations[i]);
|
||||
for (i = 0; i < tal_count(mfc->destinations); ++i) {
|
||||
if (mfc->destinations[i].protocol == FUND_CHANNEL)
|
||||
fundchannel_complete_dest(&mfc->destinations[i]);
|
||||
}
|
||||
|
||||
assert(mfc->pending != 0);
|
||||
return command_still_pending(mfc->cmd);
|
||||
@@ -1466,7 +1468,7 @@ fundchannel_complete_done(struct multifundchannel_destination *dest)
|
||||
}
|
||||
|
||||
static struct command_result *
|
||||
perform_sendpsbt(struct multifundchannel_command *mfc);
|
||||
perform_signpsbt(struct multifundchannel_command *mfc);
|
||||
|
||||
static struct command_result *
|
||||
after_fundchannel_complete(struct multifundchannel_command *mfc)
|
||||
@@ -1482,6 +1484,8 @@ after_fundchannel_complete(struct multifundchannel_command *mfc)
|
||||
struct multifundchannel_destination *dest;
|
||||
|
||||
dest = &mfc->destinations[i];
|
||||
if (dest->protocol != FUND_CHANNEL)
|
||||
continue;
|
||||
|
||||
assert(dest->state == MULTIFUNDCHANNEL_COMPLETED
|
||||
|| dest->state == MULTIFUNDCHANNEL_FAILED);
|
||||
@@ -1493,7 +1497,10 @@ after_fundchannel_complete(struct multifundchannel_command *mfc)
|
||||
return redo_multifundchannel(mfc, "fundchannel_complete");
|
||||
}
|
||||
|
||||
return perform_sendpsbt(mfc);
|
||||
if (dest_count(mfc, OPEN_CHANNEL) > 0)
|
||||
return check_sigs_ready(mfc);
|
||||
|
||||
return perform_signpsbt(mfc);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@@ -1509,7 +1516,7 @@ after_signpsbt(struct command *cmd,
|
||||
struct multifundchannel_command *mfc);
|
||||
|
||||
static struct command_result *
|
||||
perform_sendpsbt(struct multifundchannel_command *mfc)
|
||||
perform_signpsbt(struct multifundchannel_command *mfc)
|
||||
{
|
||||
struct out_req *req;
|
||||
|
||||
|
||||
@@ -583,8 +583,8 @@ collect_sigs(struct multifundchannel_command *mfc)
|
||||
return send_outreq(mfc->cmd->plugin, req);
|
||||
}
|
||||
|
||||
static void
|
||||
openchannel_dest_signed(struct multifundchannel_command *mfc)
|
||||
struct command_result *
|
||||
check_sigs_ready(struct multifundchannel_command *mfc)
|
||||
{
|
||||
bool ready = true;
|
||||
for (size_t i = 0; i < tal_count(mfc->destinations); i++)
|
||||
@@ -593,6 +593,8 @@ openchannel_dest_signed(struct multifundchannel_command *mfc)
|
||||
|
||||
if (ready)
|
||||
collect_sigs(mfc);
|
||||
|
||||
return command_still_pending(mfc->cmd);
|
||||
}
|
||||
|
||||
static void json_peer_sigs(struct command *cmd,
|
||||
@@ -667,7 +669,7 @@ static void json_peer_sigs(struct command *cmd,
|
||||
|
||||
tal_wally_end(dest->mfc->psbt);
|
||||
dest->state = MULTIFUNDCHANNEL_SIGNED;
|
||||
openchannel_dest_signed(dest->mfc);
|
||||
check_sigs_ready(dest->mfc);
|
||||
}
|
||||
|
||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
|
||||
|
||||
@@ -21,4 +21,7 @@ void openchannel_init(struct plugin *p, const char *b,
|
||||
struct command_result *
|
||||
perform_openchannel_update(struct multifundchannel_command *mfc);
|
||||
|
||||
struct command_result *
|
||||
check_sigs_ready(struct multifundchannel_command *mfc);
|
||||
|
||||
#endif /* LIGHTNING_PLUGINS_SPENDER_OPENCHANNEL_H */
|
||||
|
||||
Reference in New Issue
Block a user