diff --git a/plugins/spender/multifundchannel.c b/plugins/spender/multifundchannel.c index 2c8a02ce5..4b9c1c6c3 100644 --- a/plugins/spender/multifundchannel.c +++ b/plugins/spender/multifundchannel.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -1702,10 +1703,10 @@ perform_multiconnect(struct multifundchannel_command *mfc) /* Initiate the multifundchannel execution. */ -static struct command_result * +static void perform_multifundchannel(struct multifundchannel_command *mfc) { - return perform_multiconnect(mfc); + perform_multiconnect(mfc); } @@ -1792,6 +1793,10 @@ post_cleanup_redo_multifundchannel(struct multifundchannel_redo *redo) */ /* Re-add to new destinations. */ tal_arr_expand(&new_destinations, *dest); + /* FIXME: If this were an array of pointers, + * we could make dest itself the parent of + * ->addrhint and not need this wart! */ + tal_steal(new_destinations, dest->addrhint); } } mfc->destinations = new_destinations; @@ -1825,8 +1830,11 @@ post_cleanup_redo_multifundchannel(struct multifundchannel_redo *redo) return mfc_finished(mfc, out); } - /* Okay, we still have destinations to try --- reinvoke. */ - return perform_multifundchannel(mfc); + /* Okay, we still have destinations to try: wait a second in case it + * takes that long to disconnect from peer, then retry. */ + notleak(plugin_timer(mfc->cmd->plugin, time_from_sec(1), + perform_multifundchannel, mfc)); + return command_still_pending(mfc->cmd); } struct command_result * @@ -2059,7 +2067,8 @@ json_multifundchannel(struct command *cmd, /* Stop memleak from complaining */ tal_free(minconf); - return perform_multifundchannel(mfc); + perform_multifundchannel(mfc); + return command_still_pending(mfc->cmd); } const struct plugin_command multifundchannel_commands[] = {