You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bcli: a failed gettxout reads as "spent", and gossip and fundchannel_cancel act on it #9714
getutxout in plugins/bcli.c answers {"amount": null, "script": null} both when bitcoind says the output is spent or unknown (exit 0, empty output) and when the bitcoin-cli gettxout call fails (bitcoind unreachable, in warmup, timed out):
if (res->exitstatus!=0||res->output_len==0) {
response=jsonrpc_stream_success(cmd);
json_add_null(response, "amount");
json_add_null(response, "script");
lightningd can't tell the two apart, and some callers act on a "spent" answer:
Gossip:process_getfilteredblock_step2() leaves the output out of the filtered block, and got_filteredblock() saves the block to the DB. From then on, get_txout() answers "spent or invalid" for that block from the DB, so one failed gettxout rejects a channel announcement for good.
fundchannel_cancel:process_check_funding_broadcast() takes a NULL txout as "funding not broadcast" and forgets the channel. The wallet check before it only covers transactions we broadcast ourselves, so with an externally broadcast funding tx this is the only guard.
dev-forget-channel forgets without force for the same reason.
The other callers (check_utxo_block(), validate_input_unspent()) fail safe.
Returning an error from bcli on a failed call isn't enough on its own: get_bitcoin_result() turns any backend error into fatal(), so a transient bitcoind failure would then abort lightningd (see #9573). It needs either:
bcli to return an error only for a failed call (exit status non-zero), keeping the null for exit 0 with empty output, and lightningd's getutxout callers to retry on errors, with the same kind of error callback as [WIP] lightningd: don't abort on transient bitcoin backend errors #9574 adds for getchaininfo, or
as a stopgap, bcli to retry a failed gettxout until bitcoin-retry-timeout and only then fail. lightningd still aborts after the timeout, but it never acts on a wrong "spent".
To reproduce: mock gettxout to fail (e.g. {"error": {"code": -28, "message": "Loading block index..."}} through the test bitcoind proxy) and call lightning-cli getutxout <txid> <vout> for an unspent wallet output: it returns amount: null. With an externally broadcast funding tx and gettxout failing, fundchannel_cancel forgets the channel instead of refusing with "The funding transaction has been broadcast".
Activity
bcli: retry a failed gettxout instead of answering that the output is…
bcli: retry a failed gettxout instead of answering that the output is…