Fix error codes from various RPCs #9853
Merged
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a012087
Return correct error codes in setban().
jnewbery 6d07c62
Return correct error codes in bumpfee().
jnewbery dab804c
Return correct error codes in fundrawtransaction().
jnewbery 960bc7f
Return correct error codes in removeprunedfunds().
jnewbery c119096
Return correct error codes in blockchain.cpp.
jnewbery 338bf06
Add commenting around JSON error codes
jnewbery adaa281
Update release notes to include RPC error code changes.
jnewbery
Jump to file or symbol
Failed to load files and symbols.
| @@ -128,7 +128,7 @@ def test_segwit_bumpfee_succeeds(rbf_node, dest_address): | ||
| def test_nonrbf_bumpfee_fails(peer_node, dest_address): | ||
| # cannot replace a non RBF transaction (from node which did not enable RBF) | ||
| not_rbfid = create_fund_sign_send(peer_node, {dest_address: 0.00090000}) | ||
| - assert_raises_message(JSONRPCException, "not BIP 125 replaceable", peer_node.bumpfee, not_rbfid) | ||
| + assert_raises_jsonrpc(-4, "not BIP 125 replaceable", peer_node.bumpfee, not_rbfid) | ||
laanwj
Owner
|
||
| def test_notmine_bumpfee_fails(rbf_node, peer_node, dest_address): | ||
| @@ -148,7 +148,7 @@ def test_notmine_bumpfee_fails(rbf_node, peer_node, dest_address): | ||
| signedtx = rbf_node.signrawtransaction(rawtx) | ||
| signedtx = peer_node.signrawtransaction(signedtx["hex"]) | ||
| rbfid = rbf_node.sendrawtransaction(signedtx["hex"]) | ||
| - assert_raises_message(JSONRPCException, "Transaction contains inputs that don't belong to this wallet", | ||
| + assert_raises_jsonrpc(-4, "Transaction contains inputs that don't belong to this wallet", | ||
| rbf_node.bumpfee, rbfid) | ||
| @@ -159,7 +159,7 @@ def test_bumpfee_with_descendant_fails(rbf_node, rbf_node_address, dest_address) | ||
| tx = rbf_node.createrawtransaction([{"txid": parent_id, "vout": 0}], {dest_address: 0.00020000}) | ||
| tx = rbf_node.signrawtransaction(tx) | ||
| txid = rbf_node.sendrawtransaction(tx["hex"]) | ||
| - assert_raises_message(JSONRPCException, "Transaction has descendants in the wallet", rbf_node.bumpfee, parent_id) | ||
| + assert_raises_jsonrpc(-8, "Transaction has descendants in the wallet", rbf_node.bumpfee, parent_id) | ||
| def test_small_output_fails(rbf_node, dest_address): | ||
| @@ -174,7 +174,7 @@ def test_small_output_fails(rbf_node, dest_address): | ||
| Decimal("0.00100000"), | ||
| {dest_address: 0.00080000, | ||
| get_change_address(rbf_node): Decimal("0.00010000")}) | ||
| - assert_raises_message(JSONRPCException, "Change output is too small", rbf_node.bumpfee, rbfid, {"totalFee": 20001}) | ||
| + assert_raises_jsonrpc(-4, "Change output is too small", rbf_node.bumpfee, rbfid, {"totalFee": 20001}) | ||
| def test_dust_to_fee(rbf_node, dest_address): | ||
| @@ -209,15 +209,15 @@ def test_rebumping(rbf_node, dest_address): | ||
| rbf_node.settxfee(Decimal("0.00001000")) | ||
| rbfid = create_fund_sign_send(rbf_node, {dest_address: 0.00090000}) | ||
| bumped = rbf_node.bumpfee(rbfid, {"totalFee": 1000}) | ||
| - assert_raises_message(JSONRPCException, "already bumped", rbf_node.bumpfee, rbfid, {"totalFee": 2000}) | ||
| + assert_raises_jsonrpc(-4, "already bumped", rbf_node.bumpfee, rbfid, {"totalFee": 2000}) | ||
| rbf_node.bumpfee(bumped["txid"], {"totalFee": 2000}) | ||
| def test_rebumping_not_replaceable(rbf_node, dest_address): | ||
| # check that re-bumping a non-replaceable bump tx fails | ||
| rbfid = create_fund_sign_send(rbf_node, {dest_address: 0.00090000}) | ||
| bumped = rbf_node.bumpfee(rbfid, {"totalFee": 10000, "replaceable": False}) | ||
| - assert_raises_message(JSONRPCException, "Transaction is not BIP 125 replaceable", rbf_node.bumpfee, bumped["txid"], | ||
| + assert_raises_jsonrpc(-4, "Transaction is not BIP 125 replaceable", rbf_node.bumpfee, bumped["txid"], | ||
| {"totalFee": 20000}) | ||
| @@ -268,7 +268,7 @@ def test_bumpfee_metadata(rbf_node, dest_address): | ||
| def test_locked_wallet_fails(rbf_node, dest_address): | ||
| rbfid = create_fund_sign_send(rbf_node, {dest_address: 0.00090000}) | ||
| rbf_node.walletlock() | ||
| - assert_raises_message(JSONRPCException, "Please enter the wallet passphrase with walletpassphrase first.", | ||
| + assert_raises_jsonrpc(-13, "Please enter the wallet passphrase with walletpassphrase first.", | ||
| rbf_node.bumpfee, rbfid) | ||
| @@ -315,9 +315,7 @@ def submit_block_with_tx(node, tx): | ||
| block.rehash() | ||
| block.hashMerkleRoot = block.calc_merkle_root() | ||
| block.solve() | ||
| - error = node.submitblock(bytes_to_hex_str(block.serialize(True))) | ||
| - if error is not None: | ||
| - raise Exception(error) | ||
| + node.submitblock(bytes_to_hex_str(block.serialize(True))) | ||
| return block | ||
Oops, something went wrong.
Is there a plan to switch from integer literals to constants in a later PR? Seems like it would be nice to say
RPC_WALLET_ERRORinstead of-4.