@@ -1080,13 +1080,14 @@ static struct command_result *signpsbt_done(struct command *aux_cmd,
10801080
10811081/* If there are any channels with unsigned PSBTs in AWAITING_LOCKIN,
10821082 * sign them now (assume we crashed) */
1083- static void list_awaiting_channels (struct command * init_cmd )
1083+ static struct command_result * list_awaiting_channels (struct command * timer_cmd ,
1084+ void * unused UNUSED )
10841085{
10851086 const char * buf ;
10861087 size_t i ;
10871088 const jsmntok_t * resp , * t , * channels ;
10881089
1089- resp = jsonrpc_request_sync (tmpctx , init_cmd ,
1090+ resp = jsonrpc_request_sync (tmpctx , timer_cmd ,
10901091 "listpeerchannels" ,
10911092 NULL , & buf );
10921093 channels = json_get_member (buf , resp , "channels" );
@@ -1113,21 +1114,27 @@ static void list_awaiting_channels(struct command *init_cmd)
11131114 continue ;
11141115
11151116 /* Don't do this sync, as it can reasonably fail! */
1116- aux_cmd = aux_command (init_cmd );
1117+ aux_cmd = aux_command (timer_cmd );
11171118 req = jsonrpc_request_start (aux_cmd , "signpsbt" ,
11181119 signpsbt_done , psbt_error ,
11191120 tal_dup (aux_cmd , struct channel_id , & cid ));
11201121 json_add_psbt (req -> js , "psbt" , psbt );
11211122 send_outreq (req );
11221123 }
1124+
1125+ return timer_complete (timer_cmd );
11231126}
11241127
11251128void openchannel_init (struct command * init_cmd , const char * b , const jsmntok_t * t )
11261129{
11271130 /* Initialize our list! */
11281131 list_head_init (& mfc_commands );
11291132
1130- list_awaiting_channels (init_cmd );
1133+ /* Recover any waiting channel funding PSBTs after plugin init returns.
1134+ * Signing can be slow on large wallets, and doing it during init can block
1135+ * other important builtins from completing their startup handshake. */
1136+ global_timer (init_cmd -> plugin , time_from_sec (0 ),
1137+ list_awaiting_channels , NULL );
11311138}
11321139
11331140const struct plugin_notification openchannel_notifs [] = {
0 commit comments