mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-23 15:00:34 +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);
|
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`
|
/* `getfeerate`
|
||||||
*
|
*
|
||||||
* Gather feerate from our Bitcoin backend. Will set the feerate to `null`
|
* 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_num(req->stream, "blocks", call->blocks[call->i]);
|
||||||
json_add_string(req->stream, "mode", call->estmode[call->i]);
|
json_add_string(req->stream, "mode", call->estmode[call->i]);
|
||||||
jsonrpc_request_end(req);
|
jsonrpc_request_end(req);
|
||||||
plugin_request_send(strmap_get(&bitcoind->pluginsmap,
|
bitcoin_plugin_send(bitcoind, req);
|
||||||
"getfeerate"), req);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void bitcoind_estimate_fees_(struct bitcoind *bitcoind,
|
void bitcoind_estimate_fees_(struct bitcoind *bitcoind,
|
||||||
|
@ -311,8 +322,7 @@ void bitcoind_sendrawtx_(struct bitcoind *bitcoind,
|
||||||
call);
|
call);
|
||||||
json_add_string(req->stream, "tx", hextx);
|
json_add_string(req->stream, "tx", hextx);
|
||||||
jsonrpc_request_end(req);
|
jsonrpc_request_end(req);
|
||||||
plugin_request_send(strmap_get(&bitcoind->pluginsmap,
|
bitcoin_plugin_send(bitcoind, req);
|
||||||
"sendrawtransaction"), req);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* `getrawblockbyheight`
|
/* `getrawblockbyheight`
|
||||||
|
@ -412,8 +422,7 @@ void bitcoind_getrawblockbyheight_(struct bitcoind *bitcoind,
|
||||||
notleak(call));
|
notleak(call));
|
||||||
json_add_num(req->stream, "height", height);
|
json_add_num(req->stream, "height", height);
|
||||||
jsonrpc_request_end(req);
|
jsonrpc_request_end(req);
|
||||||
plugin_request_send(strmap_get(&bitcoind->pluginsmap,
|
bitcoin_plugin_send(bitcoind, req);
|
||||||
"getrawblockbyheight"), req);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* `getchaininfo`
|
/* `getchaininfo`
|
||||||
|
@ -507,8 +516,7 @@ void bitcoind_getchaininfo_(struct bitcoind *bitcoind,
|
||||||
req = jsonrpc_request_start(bitcoind, "getchaininfo", bitcoind->log,
|
req = jsonrpc_request_start(bitcoind, "getchaininfo", bitcoind->log,
|
||||||
getchaininfo_callback, call);
|
getchaininfo_callback, call);
|
||||||
jsonrpc_request_end(req);
|
jsonrpc_request_end(req);
|
||||||
plugin_request_send(strmap_get(&bitcoind->pluginsmap, "getchaininfo"),
|
bitcoin_plugin_send(bitcoind, req);
|
||||||
req);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* `getutxout`
|
/* `getutxout`
|
||||||
|
@ -591,8 +599,7 @@ void bitcoind_getutxout_(struct bitcoind *bitcoind,
|
||||||
json_add_txid(req->stream, "txid", txid);
|
json_add_txid(req->stream, "txid", txid);
|
||||||
json_add_num(req->stream, "vout", outnum);
|
json_add_num(req->stream, "vout", outnum);
|
||||||
jsonrpc_request_end(req);
|
jsonrpc_request_end(req);
|
||||||
plugin_request_send(strmap_get(&bitcoind->pluginsmap, "getutxout"),
|
bitcoin_plugin_send(bitcoind, req);
|
||||||
req);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Context for the getfilteredblock call. Wraps the actual arguments while we
|
/* Context for the getfilteredblock call. Wraps the actual arguments while we
|
||||||
|
|
Loading…
Add table
Reference in a new issue