mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-23 06:55:13 +01:00
bitcoind: check that Bitcoin plugin is alive before requesting
This commit is contained in:
parent
8539442de3
commit
06e9a9f31f
1 changed files with 17 additions and 10 deletions
|
@ -121,6 +121,18 @@ static void bitcoin_plugin_error(struct bitcoind *bitcoind, const char *buf,
|
|||
toks->end - toks->start, buf + toks->start);
|
||||
}
|
||||
|
||||
/* Send a request to the Bitcoin plugin which registered that method,
|
||||
* if it's still alive. */
|
||||
static void bitcoin_plugin_send(struct bitcoind *bitcoind,
|
||||
struct jsonrpc_request *req)
|
||||
{
|
||||
struct plugin *plugin = strmap_get(&bitcoind->pluginsmap, req->method);
|
||||
if (!plugin)
|
||||
fatal("Bitcoin backend plugin for %s died.", req->method);
|
||||
|
||||
plugin_request_send(plugin, req);
|
||||
}
|
||||
|
||||
/* `getfeerate`
|
||||
*
|
||||
* Gather feerate from our Bitcoin backend. Will set the feerate to `null`
|
||||
|
@ -211,8 +223,7 @@ static void do_one_estimatefee(struct bitcoind *bitcoind,
|
|||
json_add_num(req->stream, "blocks", call->blocks[call->i]);
|
||||
json_add_string(req->stream, "mode", call->estmode[call->i]);
|
||||
jsonrpc_request_end(req);
|
||||
plugin_request_send(strmap_get(&bitcoind->pluginsmap,
|
||||
"getfeerate"), req);
|
||||
bitcoin_plugin_send(bitcoind, req);
|
||||
}
|
||||
|
||||
void bitcoind_estimate_fees_(struct bitcoind *bitcoind,
|
||||
|
@ -311,8 +322,7 @@ void bitcoind_sendrawtx_(struct bitcoind *bitcoind,
|
|||
call);
|
||||
json_add_string(req->stream, "tx", hextx);
|
||||
jsonrpc_request_end(req);
|
||||
plugin_request_send(strmap_get(&bitcoind->pluginsmap,
|
||||
"sendrawtransaction"), req);
|
||||
bitcoin_plugin_send(bitcoind, req);
|
||||
}
|
||||
|
||||
/* `getrawblockbyheight`
|
||||
|
@ -412,8 +422,7 @@ void bitcoind_getrawblockbyheight_(struct bitcoind *bitcoind,
|
|||
notleak(call));
|
||||
json_add_num(req->stream, "height", height);
|
||||
jsonrpc_request_end(req);
|
||||
plugin_request_send(strmap_get(&bitcoind->pluginsmap,
|
||||
"getrawblockbyheight"), req);
|
||||
bitcoin_plugin_send(bitcoind, req);
|
||||
}
|
||||
|
||||
/* `getchaininfo`
|
||||
|
@ -507,8 +516,7 @@ void bitcoind_getchaininfo_(struct bitcoind *bitcoind,
|
|||
req = jsonrpc_request_start(bitcoind, "getchaininfo", bitcoind->log,
|
||||
getchaininfo_callback, call);
|
||||
jsonrpc_request_end(req);
|
||||
plugin_request_send(strmap_get(&bitcoind->pluginsmap, "getchaininfo"),
|
||||
req);
|
||||
bitcoin_plugin_send(bitcoind, req);
|
||||
}
|
||||
|
||||
/* `getutxout`
|
||||
|
@ -591,8 +599,7 @@ void bitcoind_getutxout_(struct bitcoind *bitcoind,
|
|||
json_add_txid(req->stream, "txid", txid);
|
||||
json_add_num(req->stream, "vout", outnum);
|
||||
jsonrpc_request_end(req);
|
||||
plugin_request_send(strmap_get(&bitcoind->pluginsmap, "getutxout"),
|
||||
req);
|
||||
bitcoin_plugin_send(bitcoind, req);
|
||||
}
|
||||
|
||||
/* Context for the getfilteredblock call. Wraps the actual arguments while we
|
||||
|
|
Loading…
Add table
Reference in a new issue