-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Description
When using bitcoin-cli
command gettxout
, the program does not return an error if the utxo queried doesn't exist. I initially found this behavior a bit confusing, as in command line contexts a command not returning anything usually means "it worked". Similar calls like getmempoolentry
will return Transaction not in mempool
errors, so I expected something like that from gettxout
.
Expected behavior
(maybe this is more like "desired" behavior)
How about something like:
user@computer:~$ bitcoin-cli gettxout 0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098 1
error code: -5
error message:
Transaction output not found
user@computer:~$
Actual behavior
user@computer:~$ bitcoin-cli gettxout 0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098 0
{
"bestblock": "00000000000000000000b2320e348d60a5eb0532a1fe67bddd197077f7782637",
"confirmations": 623664,
"value": 50.00000000,
"scriptPubKey": {
"asm": "0496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858ee OP_CHECKSIG",
"hex": "410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac",
"type": "pubkey"
},
"coinbase": true
}
user@computer:~$ bitcoin-cli gettxout 0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098 1
user@computer:~$
To reproduce
Query any non-exsistent utxo with gettxout
. Nothing happens, and the program returns with no error.
System information
Ubuntu 18.04.3 LTS, Bitcoin Core 0.19.01
Fix?
Is there a reason why either the RPC call itself or bitcoin-cli
doesn't return an error in this case? If so, or if it's complicated to fix, then the lack of an error message isn't not a big deal, and I can close this or leave it around as a "yeah maybe should fix that someday". If it's just an omission however, I'd be happy to open a PR changing it to return some kind of error message.