From 9ce07eca61cdbc5b7e60575fde47acf81ea1efc2 Mon Sep 17 00:00:00 2001 From: niftynei Date: Wed, 10 Mar 2021 20:22:03 -0600 Subject: [PATCH] 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. --- plugins/spender/multifundchannel.c | 17 ++++++++++------- plugins/spender/multifundchannel.h | 3 ++- plugins/spender/openchannel.c | 21 ++++++++++++--------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/plugins/spender/multifundchannel.c b/plugins/spender/multifundchannel.c index 23ad394af..d30e6fb2d 100644 --- a/plugins/spender/multifundchannel.c +++ b/plugins/spender/multifundchannel.c @@ -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; diff --git a/plugins/spender/multifundchannel.h b/plugins/spender/multifundchannel.h index 0dab8a6f8..f0d190548 100644 --- a/plugins/spender/multifundchannel.h +++ b/plugins/spender/multifundchannel.h @@ -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 */ diff --git a/plugins/spender/openchannel.c b/plugins/spender/openchannel.c index d7dc55057..14e9617a1 100644 --- a/plugins/spender/openchannel.c +++ b/plugins/spender/openchannel.c @@ -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