1010#include <common/json_param.h>
1111#include <common/json_stream.h>
1212#include <common/memleak.h>
13- #include <common/timeout.h>
1413#include <errno.h>
1514#include <plugins/libplugin.h>
1615
@@ -102,7 +101,6 @@ static const char **gather_argsv(const tal_t *ctx, const char *cmd, va_list ap)
102101 const char * arg ;
103102
104103 args [0 ] = bitcoind -> cli ? bitcoind -> cli : chainparams -> cli ;
105-
106104 if (chainparams -> cli_args )
107105 add_arg (& args , chainparams -> cli_args );
108106 if (bitcoind -> datadir )
@@ -1035,23 +1033,14 @@ static void parse_getnetworkinfo_result(struct plugin *p, const char *buf)
10351033 tal_free (result );
10361034}
10371035
1038- static void log_warm_up (struct plugin * p )
1039- {
1040- plugin_log (p , LOG_UNUSUAL , "Waiting for bitcoind to warm up..." );
1041- }
1042-
10431036static void wait_and_check_bitcoind (struct plugin * p )
10441037{
10451038 int in , from , status ;
10461039 pid_t child ;
1047- const char * * cmd =
1048- gather_args ( bitcoind , "-rpcwait" , "getnetworkinfo" , NULL );
1040+ const char * * cmd = gather_args (
1041+ bitcoind , "-rpcwait" , "-rpcwaittimeout=30 " , "getnetworkinfo" , NULL );
10491042 char * output = NULL ;
10501043
1051- struct timers * timer = tal (cmd , struct timers );
1052- timers_init (timer , time_mono ());
1053- new_reltimer (timer , timer , time_from_sec (30 ), log_warm_up , p );
1054-
10551044 child = pipecmdarr (& in , & from , & from , cast_const2 (char * * , cmd ));
10561045
10571046 if (bitcoind -> rpcpass )
@@ -1077,6 +1066,11 @@ static void wait_and_check_bitcoind(struct plugin *p)
10771066 cmd [0 ], WTERMSIG (status )));
10781067
10791068 if (WEXITSTATUS (status ) != 0 ) {
1069+ if (WEXITSTATUS (status ) == 1 )
1070+ bitcoind_failure (p ,
1071+ "RPC connection timed out. Could "
1072+ "not connect to bitcoind using "
1073+ "bitcoin-cli. Is bitcoind running?" );
10801074 bitcoind_failure (p ,
10811075 tal_fmt (bitcoind , "%s exited with code %i: %s" ,
10821076 cmd [0 ], WEXITSTATUS (status ), output ));
0 commit comments