mfc: have error messages for redos be more robust (include why)

Makes it easiser to figure out what's going on.

Also, make sure that every 'fail_destination' error description includes
quote escapes.
This commit is contained in:
niftynei
2021-03-10 20:22:03 -06:00
committed by Rusty Russell
parent 822441558c
commit 9ce07eca61
3 changed files with 24 additions and 17 deletions

View File

@@ -586,7 +586,8 @@ after_fundchannel_complete(struct multifundchannel_command *mfc)
continue;
/* One of them failed, oh no. */
return redo_multifundchannel(mfc, "fundchannel_complete");
return redo_multifundchannel(mfc, "fundchannel_complete",
dest->error);
}
if (dest_count(mfc, OPEN_CHANNEL) > 0)
@@ -885,7 +886,8 @@ after_channel_start(struct multifundchannel_command *mfc)
return redo_multifundchannel(mfc,
is_v2(dest) ?
"openchannel_init" :
"fundchannel_start");
"fundchannel_start",
dest->error);
}
/* Next step. */
@@ -1406,7 +1408,7 @@ after_multiconnect(struct multifundchannel_command *mfc)
continue;
/* One of them failed, oh no. */
return redo_multifundchannel(mfc, "connect");
return redo_multifundchannel(mfc, "connect", dest->error);
}
return perform_fundpsbt(mfc);
@@ -1664,16 +1666,17 @@ post_cleanup_redo_multifundchannel(struct multifundchannel_redo *redo)
struct command_result *
redo_multifundchannel(struct multifundchannel_command *mfc,
const char *failing_method)
const char *failing_method,
const char *why)
{
struct multifundchannel_redo *redo;
assert(mfc->pending == 0);
plugin_log(mfc->cmd->plugin, LOG_DBG,
"mfc %"PRIu64": trying redo despite '%s' failure; "
"will cleanup for now.",
mfc->id, failing_method);
"mfc %"PRIu64": trying redo despite '%s' failure (%s);"
" will cleanup for now.",
mfc->id, failing_method, why);
redo = tal(mfc, struct multifundchannel_redo);
redo->mfc = mfc;

View File

@@ -270,5 +270,6 @@ multifundchannel_finished(struct multifundchannel_command *mfc);
struct command_result *
redo_multifundchannel(struct multifundchannel_command *mfc,
const char *failing_method);
const char *failing_method,
const char *why);
#endif /* LIGHTNING_PLUGINS_SPENDER_MULTIFUNDCHANNEL_H */

View File

@@ -817,7 +817,8 @@ perform_openchannel_update(struct multifundchannel_command *mfc)
if (dest->state == MULTIFUNDCHANNEL_FAILED)
return redo_multifundchannel(mfc,
"openchannel_update");
"openchannel_update",
dest->error);
if (dest->state == MULTIFUNDCHANNEL_SECURED ||
dest->state == MULTIFUNDCHANNEL_SIGNED) {
@@ -845,10 +846,11 @@ perform_openchannel_update(struct multifundchannel_command *mfc)
if (!update_parent_psbt(mfc, dest, dest->psbt,
dest->updated_psbt,
&mfc->psbt)) {
fail_destination(dest, "Unable to update parent "
"with node's PSBT");
fail_destination(dest, "\"Unable to update parent "
"with node's PSBT\"");
return redo_multifundchannel(mfc,
"openchannel_init_parent");
"openchannel_init_parent",
dest->error);
}
/* Get everything sorted correctly */
psbt_sort_by_serial_id(mfc->psbt);
@@ -869,10 +871,11 @@ perform_openchannel_update(struct multifundchannel_command *mfc)
continue;
if (!update_node_psbt(mfc, mfc->psbt, &dest->psbt)) {
fail_destination(dest, "Unable to node PSBT"
" with parent PSBT");
fail_destination(dest, "\"Unable to node PSBT"
" with parent PSBT\"");
return redo_multifundchannel(mfc,
"openchannel_init_node");
"openchannel_init_node",
dest->error);
}
}
@@ -955,8 +958,8 @@ openchannel_init_ok(struct command *cmd,
if (!update_parent_psbt(dest->mfc, dest, dest->psbt,
dest->updated_psbt, &mfc->psbt)) {
fail_destination(dest,
take(tal_fmt(NULL, "Unable to update parent"
" with node's PSBT")));
take(tal_fmt(NULL, "\"Unable to update parent"
" with node's PSBT\"")));
}
/* Clone updated-psbt to psbt, so original changeset