mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 22:45:27 +01:00
getblockhash: don't get upset if we fail.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
810abb6b21
commit
985a0b431f
2 changed files with 8 additions and 1 deletions
|
@ -491,6 +491,12 @@ static void process_getblockhash(struct bitcoin_cli *bcli)
|
|||
const struct bitcoin_blkid *blkid,
|
||||
void *arg) = bcli->cb;
|
||||
|
||||
/* If it failed, call with NULL block. */
|
||||
if (*bcli->exitstatus != 0) {
|
||||
cb(bcli->bitcoind, NULL, bcli->cb_arg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (bcli->output_bytes == 0
|
||||
|| !bitcoin_blkid_from_hex(bcli->output, bcli->output_bytes-1,
|
||||
&blkid)) {
|
||||
|
@ -511,7 +517,7 @@ void bitcoind_getblockhash_(struct bitcoind *bitcoind,
|
|||
char str[STR_MAX_CHARS(height)];
|
||||
sprintf(str, "%u", height);
|
||||
|
||||
start_bitcoin_cli(bitcoind, NULL, process_getblockhash, false, cb, arg,
|
||||
start_bitcoin_cli(bitcoind, NULL, process_getblockhash, true, cb, arg,
|
||||
"getblockhash", str, NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -112,6 +112,7 @@ void bitcoind_getblockcount_(struct bitcoind *bitcoind,
|
|||
u32 blockcount), \
|
||||
(arg))
|
||||
|
||||
/* blkid is NULL if call fails. */
|
||||
void bitcoind_getblockhash_(struct bitcoind *bitcoind,
|
||||
u32 height,
|
||||
void (*cb)(struct bitcoind *bitcoind,
|
||||
|
|
Loading…
Add table
Reference in a new issue