mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-02 12:44:26 +01:00
mfc-df: have both paths use redo_multifundchannel
Still need handling of failure for v2 opens (no rpc exists?!)
This commit is contained in:
@@ -115,8 +115,13 @@ mfc_cleanup_(struct multifundchannel_command *mfc,
|
||||
struct multifundchannel_destination *dest;
|
||||
dest = &mfc->destinations[i];
|
||||
|
||||
/* If not started, nothing to clean up. */
|
||||
if (dest->state != MULTIFUNDCHANNEL_STARTED)
|
||||
// FIXME: openchannel_abort??
|
||||
if (dest->protocol == OPEN_CHANNEL)
|
||||
continue;
|
||||
|
||||
/* If not started/completed, nothing to clean up. */
|
||||
if (dest->state != MULTIFUNDCHANNEL_STARTED &&
|
||||
dest->state != MULTIFUNDCHANNEL_COMPLETED)
|
||||
continue;
|
||||
|
||||
plugin_log(mfc->cmd->plugin, LOG_DBG,
|
||||
@@ -423,10 +428,6 @@ Command Processing
|
||||
|
||||
/* Function to redo multifundchannel after a failure.
|
||||
*/
|
||||
static struct command_result *
|
||||
redo_multifundchannel(struct multifundchannel_command *mfc,
|
||||
const char *failing_method);
|
||||
|
||||
static struct command_result *
|
||||
perform_multiconnect(struct multifundchannel_command *mfc);
|
||||
|
||||
@@ -1169,7 +1170,10 @@ after_fundchannel_start(struct multifundchannel_command *mfc)
|
||||
continue;
|
||||
|
||||
/* One of them failed, oh no. */
|
||||
return redo_multifundchannel(mfc, "fundchannel_start");
|
||||
return redo_multifundchannel(mfc,
|
||||
dest->protocol == OPEN_CHANNEL ?
|
||||
"openchannel_init" :
|
||||
"fundchannel_start");
|
||||
}
|
||||
|
||||
/* Next step. */
|
||||
@@ -1673,7 +1677,7 @@ struct multifundchannel_redo {
|
||||
static struct command_result *
|
||||
post_cleanup_redo_multifundchannel(struct multifundchannel_redo *redo);
|
||||
|
||||
static struct command_result *
|
||||
struct command_result *
|
||||
redo_multifundchannel(struct multifundchannel_command *mfc,
|
||||
const char *failing_method)
|
||||
{
|
||||
|
||||
@@ -250,4 +250,7 @@ size_t dest_count(const struct multifundchannel_command *mfc,
|
||||
struct command_result *
|
||||
mfc_finished(struct multifundchannel_command *, struct json_stream *response);
|
||||
|
||||
struct command_result *
|
||||
redo_multifundchannel(struct multifundchannel_command *mfc,
|
||||
const char *failing_method);
|
||||
#endif /* LIGHTNING_PLUGINS_SPENDER_MULTIFUNDCHANNEL_H */
|
||||
|
||||
@@ -44,16 +44,6 @@ find_dest_by_channel_id(struct channel_id *cid)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct command_result *
|
||||
redo_multiopenchannel(struct multifundchannel_command *mfc,
|
||||
const char *failing_method)
|
||||
{
|
||||
// FIXME
|
||||
plugin_err(mfc->cmd->plugin,
|
||||
"REDO CALLED AT %s", failing_method);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* There's a few ground rules here about how we store/keep
|
||||
* the PSBT input/outputs in such a way that we can Do The
|
||||
* Right Thing for each of our peers.
|
||||
@@ -499,7 +489,7 @@ perform_openchannel_signed(struct multifundchannel_command *mfc)
|
||||
dest = &mfc->destinations[i];
|
||||
if (dest->state != MULTIFUNDCHANNEL_SIGNED) {
|
||||
// FIXME: these channels are all borked.
|
||||
redo_multiopenchannel(mfc, "openchannel_signed");
|
||||
redo_multifundchannel(mfc, "openchannel_signed");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -853,7 +843,7 @@ perform_openchannel_update(struct multifundchannel_command *mfc)
|
||||
dest = &mfc->destinations[i];
|
||||
|
||||
if (dest->state == MULTIFUNDCHANNEL_FAILED)
|
||||
return redo_multiopenchannel(mfc,
|
||||
return redo_multifundchannel(mfc,
|
||||
"openchannel_update");
|
||||
|
||||
/* If any *one* is secured or signed, they should all
|
||||
@@ -880,9 +870,12 @@ perform_openchannel_update(struct multifundchannel_command *mfc)
|
||||
|
||||
if (!update_parent_psbt(mfc, dest, dest->psbt,
|
||||
dest->updated_psbt,
|
||||
&mfc->psbt))
|
||||
return redo_multiopenchannel(mfc,
|
||||
&mfc->psbt)) {
|
||||
fail_destination(dest, "Unable to update parent "
|
||||
"with node's PSBT");
|
||||
return redo_multifundchannel(mfc,
|
||||
"openchannel_init_parent");
|
||||
}
|
||||
/* Get everything sorted correctly */
|
||||
psbt_sort_by_serial_id(mfc->psbt);
|
||||
|
||||
@@ -897,14 +890,19 @@ perform_openchannel_update(struct multifundchannel_command *mfc)
|
||||
struct multifundchannel_destination *dest;
|
||||
dest = &mfc->destinations[i];
|
||||
|
||||
if (!update_node_psbt(mfc, mfc->psbt, &dest->psbt))
|
||||
return redo_multiopenchannel(mfc,
|
||||
if (!update_node_psbt(mfc, mfc->psbt, &dest->psbt)) {
|
||||
fail_destination(dest, "Unable to node PSBT"
|
||||
" with parent PSBT");
|
||||
return redo_multifundchannel(mfc,
|
||||
"openchannel_init_node");
|
||||
}
|
||||
}
|
||||
|
||||
mfc->pending = tal_count(mfc->destinations);
|
||||
for (i = 0; i < tal_count(mfc->destinations); i++)
|
||||
openchannel_update_dest(&mfc->destinations[i]);
|
||||
mfc->pending = dest_count(mfc, OPEN_CHANNEL);
|
||||
for (i = 0; i < tal_count(mfc->destinations); i++) {
|
||||
if (mfc->destinations[i].protocol == OPEN_CHANNEL)
|
||||
openchannel_update_dest(&mfc->destinations[i]);
|
||||
}
|
||||
|
||||
assert(mfc->pending != 0);
|
||||
return command_still_pending(mfc->cmd);
|
||||
@@ -932,7 +930,7 @@ after_openchannel_init(struct multifundchannel_command *mfc)
|
||||
continue;
|
||||
|
||||
/* One of them failed, oh no. */
|
||||
return redo_multiopenchannel(mfc, "openchannel_init");
|
||||
return redo_multifundchannel(mfc, "openchannel_init");
|
||||
}
|
||||
|
||||
/* We need to add the change output here, for now. Will
|
||||
|
||||
Reference in New Issue
Block a user