Browse Source

mfc-df: have both paths use redo_multifundchannel

Still need handling of failure for v2 opens (no rpc exists?!)
fix-mocks
niftynei 4 years ago
committed by neil saitug
parent
commit
95de8b1174
  1. 20
      plugins/spender/multifundchannel.c
  2. 3
      plugins/spender/multifundchannel.h
  3. 38
      plugins/spender/openchannel.c

20
plugins/spender/multifundchannel.c

@ -115,8 +115,13 @@ mfc_cleanup_(struct multifundchannel_command *mfc,
struct multifundchannel_destination *dest; struct multifundchannel_destination *dest;
dest = &mfc->destinations[i]; dest = &mfc->destinations[i];
/* If not started, nothing to clean up. */ // FIXME: openchannel_abort??
if (dest->state != MULTIFUNDCHANNEL_STARTED) if (dest->protocol == OPEN_CHANNEL)
continue;
/* If not started/completed, nothing to clean up. */
if (dest->state != MULTIFUNDCHANNEL_STARTED &&
dest->state != MULTIFUNDCHANNEL_COMPLETED)
continue; continue;
plugin_log(mfc->cmd->plugin, LOG_DBG, plugin_log(mfc->cmd->plugin, LOG_DBG,
@ -423,10 +428,6 @@ Command Processing
/* Function to redo multifundchannel after a failure. /* 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 * static struct command_result *
perform_multiconnect(struct multifundchannel_command *mfc); perform_multiconnect(struct multifundchannel_command *mfc);
@ -1169,7 +1170,10 @@ after_fundchannel_start(struct multifundchannel_command *mfc)
continue; continue;
/* One of them failed, oh no. */ /* 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. */ /* Next step. */
@ -1673,7 +1677,7 @@ struct multifundchannel_redo {
static struct command_result * static struct command_result *
post_cleanup_redo_multifundchannel(struct multifundchannel_redo *redo); post_cleanup_redo_multifundchannel(struct multifundchannel_redo *redo);
static struct command_result * struct command_result *
redo_multifundchannel(struct multifundchannel_command *mfc, redo_multifundchannel(struct multifundchannel_command *mfc,
const char *failing_method) const char *failing_method)
{ {

3
plugins/spender/multifundchannel.h

@ -250,4 +250,7 @@ size_t dest_count(const struct multifundchannel_command *mfc,
struct command_result * struct command_result *
mfc_finished(struct multifundchannel_command *, struct json_stream *response); 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 */ #endif /* LIGHTNING_PLUGINS_SPENDER_MULTIFUNDCHANNEL_H */

38
plugins/spender/openchannel.c

@ -44,16 +44,6 @@ find_dest_by_channel_id(struct channel_id *cid)
return NULL; 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 /* 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 * the PSBT input/outputs in such a way that we can Do The
* Right Thing for each of our peers. * Right Thing for each of our peers.
@ -499,7 +489,7 @@ perform_openchannel_signed(struct multifundchannel_command *mfc)
dest = &mfc->destinations[i]; dest = &mfc->destinations[i];
if (dest->state != MULTIFUNDCHANNEL_SIGNED) { if (dest->state != MULTIFUNDCHANNEL_SIGNED) {
// FIXME: these channels are all borked. // 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]; dest = &mfc->destinations[i];
if (dest->state == MULTIFUNDCHANNEL_FAILED) if (dest->state == MULTIFUNDCHANNEL_FAILED)
return redo_multiopenchannel(mfc, return redo_multifundchannel(mfc,
"openchannel_update"); "openchannel_update");
/* If any *one* is secured or signed, they should all /* 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, if (!update_parent_psbt(mfc, dest, dest->psbt,
dest->updated_psbt, dest->updated_psbt,
&mfc->psbt)) &mfc->psbt)) {
return redo_multiopenchannel(mfc, fail_destination(dest, "Unable to update parent "
"with node's PSBT");
return redo_multifundchannel(mfc,
"openchannel_init_parent"); "openchannel_init_parent");
}
/* Get everything sorted correctly */ /* Get everything sorted correctly */
psbt_sort_by_serial_id(mfc->psbt); psbt_sort_by_serial_id(mfc->psbt);
@ -897,14 +890,19 @@ perform_openchannel_update(struct multifundchannel_command *mfc)
struct multifundchannel_destination *dest; struct multifundchannel_destination *dest;
dest = &mfc->destinations[i]; dest = &mfc->destinations[i];
if (!update_node_psbt(mfc, mfc->psbt, &dest->psbt)) if (!update_node_psbt(mfc, mfc->psbt, &dest->psbt)) {
return redo_multiopenchannel(mfc, fail_destination(dest, "Unable to node PSBT"
" with parent PSBT");
return redo_multifundchannel(mfc,
"openchannel_init_node"); "openchannel_init_node");
}
} }
mfc->pending = tal_count(mfc->destinations); mfc->pending = dest_count(mfc, OPEN_CHANNEL);
for (i = 0; i < tal_count(mfc->destinations); i++) for (i = 0; i < tal_count(mfc->destinations); i++) {
openchannel_update_dest(&mfc->destinations[i]); if (mfc->destinations[i].protocol == OPEN_CHANNEL)
openchannel_update_dest(&mfc->destinations[i]);
}
assert(mfc->pending != 0); assert(mfc->pending != 0);
return command_still_pending(mfc->cmd); return command_still_pending(mfc->cmd);
@ -932,7 +930,7 @@ after_openchannel_init(struct multifundchannel_command *mfc)
continue; continue;
/* One of them failed, oh no. */ /* 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 /* We need to add the change output here, for now. Will

Loading…
Cancel
Save