Fix error codes from various RPCs #9853

Merged
merged 7 commits into from Mar 9, 2017

Conversation

Projects
None yet
5 participants
Member

jnewbery commented Feb 24, 2017

(Completes #9707 and #9842)

I've changed the qa test code to properly assert error codes and messages for failed RPC calls. That's revealed a few RPCs which were returning incorrect or misleading error codes. This PR fixes all of those cases.

It also adds commenting around the definition of the JSON RPC error constants to warn against using RPC_INVALID_REQUEST and RPC_METHOD_NOT_FOUND for application-layer errors.

@@ -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)
@ryanofsky

ryanofsky Feb 24, 2017

Contributor

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_ERROR instead of -4.

@laanwj

laanwj Feb 25, 2017

Owner

Yes that would be nice, but is orthogonal to this change, so if you want to do that it'd indeed be a different PR.

@jnewbery

jnewbery Feb 28, 2017

Member

yep, I'll put that in the todo list. I'm working on a primitives.py for bitcoin messages, datastructures and constants. Seems like a good place for the RPC error constants to live.

@ryanofsky

utACK b34faf1, definitely an improvement.

src/wallet/rpcwallet.cpp
@@ -2753,33 +2753,33 @@ UniValue bumpfee(const JSONRPCRequest& request)
CWalletTx& wtx = pwalletMain->mapWallet[hash];
if (pwalletMain->HasWalletSpend(hash)) {
- throw JSONRPCError(RPC_MISC_ERROR, "Transaction has descendants in the wallet");
+ throw JSONRPCError(RPC_WALLET_ERROR, "Transaction has descendants in the wallet");
@ryanofsky

ryanofsky Feb 28, 2017

Contributor

In cases where bumpfee is called erroneously with a transaction that shouldn't be bumped, invalid parameter seems more apt than wallet error.

Probably the most important thing you want to know when you get an error message from an API is whether the error is caused by something that you control and need to fix, or whether it's caused by something out of your control (like an implementation bug, or corrupt data, or a temporary failure). RPC_INVALID_PARAMETER clearly tells you that you need to fix something, while RPC_WALLET_ERROR is vague but suggests that something's wrong with the wallet.

@jnewbery

jnewbery Feb 28, 2017

Member

Probably the most important thing you want to know when you get an error message from an API is whether the error is caused by something that you control and need to fix, or whether it's caused by something out of your control

Nicely put. I'll update this to RPC_INVALID_PARAMETER

src/wallet/rpcdump.cpp
@@ -338,11 +338,11 @@ UniValue removeprunedfunds(const JSONRPCRequest& request)
vector<uint256> vHashOut;
if(pwalletMain->ZapSelectTx(vHash, vHashOut) != DB_LOAD_OK) {
- throw JSONRPCError(RPC_INTERNAL_ERROR, "Could not properly delete the transaction.");
+ throw JSONRPCError(RPC_WALLET_ERROR, "Could not properly delete the transaction.");
@ryanofsky

ryanofsky Feb 28, 2017

Contributor

ZapSelect returns a DBErrors enum value which seems like it could be mapped to an RPC error (would also be nice to include in the error string).

@jnewbery

jnewbery Feb 28, 2017

Member

I agree we could do better, but let's leave that for a future PR.

I think this is strictly an improvement because currently the API is returning RPC_INTERNAL_ERROR even in cases where there's no internal error.

src/wallet/rpcdump.cpp
}
if(vHashOut.empty()) {
- throw JSONRPCError(RPC_INTERNAL_ERROR, "Transaction does not exist in wallet.");
+ throw JSONRPCError(RPC_WALLET_ERROR, "Transaction does not exist in wallet.");
@ryanofsky

ryanofsky Feb 28, 2017

Contributor

Maybe invalid parameter here as well.

@@ -829,7 +834,7 @@ UniValue pruneblockchain(const JSONRPCRequest& request)
+ HelpExampleRpc("pruneblockchain", "1000"));
if (!fPruneMode)
- throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Cannot prune blocks because node is not in prune mode.");
+ throw JSONRPCError(RPC_MISC_ERROR, "Cannot prune blocks because node is not in prune mode.");
@ryanofsky

ryanofsky Feb 28, 2017

Contributor

Some of these MISC_ERROR cases make it seem like we could benefit from an new RPC_INVALID_STATE value. (Blockchain too short is another case below.)

@jnewbery

jnewbery Feb 28, 2017

Member

Sounds sensible, but again let's leave that for a future PR.

@laanwj

laanwj Mar 2, 2017

Owner

Yes, there is no reason why we couldn't add new status values. There's no need to make everything fit in the arbitrary bag of codes that exists now, which has been there unchanged for a long while.

jnewbery added some commits Feb 7, 2017

@jnewbery jnewbery Return correct error codes in setban().
The setban() RPC was returning misleading or incorrect error
codes (for example RPC_CLIENT_NODE_ALREADY_ADDED when an invalid IP
address was entered). This commit fixes those error codes:

- RPC_CLIENT_INVALID_IP_OR_SUBNET should be returned if the client
  enters an invalid IP address or subnet.

This commit also updates the test cases to explicitly test the error code.

This commit also adds a testcase for trying to setban on an invalid subnet.
a012087
@jnewbery jnewbery Return correct error codes in bumpfee().
The bumpfee() RPC was returning misleading or incorrect error codes
(for example RPC_INVALID_ADDRESS_OR_KEY when the transaction was not
BIP125 replacable). This commit fixes those error codes:

- RPC_INVALID_ADDRESS_OR_KEY if an invalid address was provided:
    - Invalid change address given
- RPC_INVALID_PARAMETER if a single (non-address/key) parameter is incorrect
    - confTarget and totalFee options should not both be set.
    - Invalid confTarget
    - Insufficient totalFee (cannot be less than required fee)
- RPC_WALLET_ERROR for any other error
    - Transaction has descendants in the wallet
    - Transaction has descendants in the mempool
    - Transaction has been mined, or is conflicted with a mined transaction
    - Transaction is not BIP 125 replaceable
    - Transaction has already been bumped
    - Transaction contains inputs that don't belong to the wallet
    - Transaction has multiple change outputs
    - Transaction does not have a change output
    - Fee is higher than maxTxFee
    - New fee rate is less than the minimum fee rate
    - Change output is too small.

This commit also updates the test cases to explicitly test the error code.
6d07c62
@jnewbery jnewbery Return correct error codes in fundrawtransaction().
The fundrawtransaction() RPC was returning misleading or incorrect error
codes (for example RPC_INTERNAL_ERROR when funding the transaction
failed). This commit fixes those error codes:

- RPC_INTERNAL_ERROR should not be returned for application-level
errors, only for genuine internal errors such as corrupted data.

That error code has been replaced with RPC_WALLET_ERROR.

This commit also updates the test cases to explicitly test the error code.
dab804c
@jnewbery jnewbery Return correct error codes in removeprunedfunds().
The removeprunedfunds() RPC was returning misleading or incorrect error
codes (for example RPC_INTERNAL_ERROR when the transaction was
not found in the wallet). This commit fixes those error codes:

- RPC_INTERNAL_ERROR should not be returned for application-level
errors, only for genuine internal errors such as corrupted data.

This error code has been replaced with RPC_WALLET_ERROR.

This commit also updates the test cases to explicitly test the error code.
960bc7f
@jnewbery jnewbery Return correct error codes in blockchain.cpp.
RPCs in blockchain.cpp were returning misleading or incorrect error
codes (for example getblock() returning RPC_INTERNAL_ERROR when the
block had been pruned). This commit fixes those error codes:

- RPC_INTERNAL_ERROR should not be returned for application-level
  errors, only for genuine internal errors such as corrupted data.
- RPC_METHOD_NOT_FOUND should not be returned in response to a
  JSON request for an existing method.

Those error codes have been replaced with RPC_MISC_ERROR or
RPC_INVALID_PARAMETER as appropriate.
c119096

laanwj self-assigned this Mar 8, 2017

Owner

laanwj commented Mar 8, 2017

utACK 3ff485e

Member

MarcoFalke commented Mar 8, 2017

Owner

laanwj commented Mar 8, 2017

Also, I was wondering if this requires a mention in the release notes...

It does.

Contributor

ryanofsky commented Mar 8, 2017

utACK 3ff485e

Confirmed only minor changes since previous ACK.

jnewbery added some commits Feb 24, 2017

@jnewbery jnewbery Add commenting around JSON error codes
RPC_INVALID_REQUEST and RPC_METHOD_NOT_FOUND are mapped internally to
HTTP error codes and should not be used for application-layer errors.
This commit adds commenting around those definitions to warn not to use
them for application errors.
338bf06
@jnewbery jnewbery Update release notes to include RPC error code changes. adaa281
Member

jnewbery commented Mar 8, 2017

Release notes updated. Otherwise no change.

@laanwj laanwj merged commit adaa281 into bitcoin:master Mar 9, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@laanwj laanwj added a commit that referenced this pull request Mar 9, 2017

@laanwj laanwj Merge #9853: Fix error codes from various RPCs
adaa281 Update release notes to include RPC error code changes. (John Newbery)
338bf06 Add commenting around JSON error codes (John Newbery)
dab804c Return correct error codes in fundrawtransaction(). (John Newbery)
a012087 Return correct error codes in setban(). (John Newbery)
960bc7f Return correct error codes in removeprunedfunds(). (John Newbery)
c119096 Return correct error codes in blockchain.cpp. (John Newbery)
6d07c62 Return correct error codes in bumpfee(). (John Newbery)

Tree-SHA512: 4bb39ad221cd8c83d98ac5d7ad642f3a8c265522720dc86b2eebc70e74439a85b06d6ddcd6a874e879d986511de3ab0878bb7fe58b50cb0546b78913632ea809
02bd6e9

jnewbery deleted the jnewbery:fixerrorcodes branch Mar 9, 2017

@luke-jr luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Jun 3, 2017

@jnewbery @luke-jr jnewbery + luke-jr Return correct error codes in setban().
The setban() RPC was returning misleading or incorrect error
codes (for example RPC_CLIENT_NODE_ALREADY_ADDED when an invalid IP
address was entered). This commit fixes those error codes:

- RPC_CLIENT_INVALID_IP_OR_SUBNET should be returned if the client
  enters an invalid IP address or subnet.

This commit also updates the test cases to explicitly test the error code.

This commit also adds a testcase for trying to setban on an invalid subnet.

Github-Pull: #9853
Rebased-From: a012087
db650e5

@luke-jr luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Jun 3, 2017

@jnewbery @luke-jr jnewbery + luke-jr Return correct error codes in bumpfee().
The bumpfee() RPC was returning misleading or incorrect error codes
(for example RPC_INVALID_ADDRESS_OR_KEY when the transaction was not
BIP125 replacable). This commit fixes those error codes:

- RPC_INVALID_ADDRESS_OR_KEY if an invalid address was provided:
    - Invalid change address given
- RPC_INVALID_PARAMETER if a single (non-address/key) parameter is incorrect
    - confTarget and totalFee options should not both be set.
    - Invalid confTarget
    - Insufficient totalFee (cannot be less than required fee)
- RPC_WALLET_ERROR for any other error
    - Transaction has descendants in the wallet
    - Transaction has descendants in the mempool
    - Transaction has been mined, or is conflicted with a mined transaction
    - Transaction is not BIP 125 replaceable
    - Transaction has already been bumped
    - Transaction contains inputs that don't belong to the wallet
    - Transaction has multiple change outputs
    - Transaction does not have a change output
    - Fee is higher than maxTxFee
    - New fee rate is less than the minimum fee rate
    - Change output is too small.

This commit also updates the test cases to explicitly test the error code.

Github-Pull: #9853
Rebased-From: 6d07c62
783b4b5

@luke-jr luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Jun 3, 2017

@jnewbery @luke-jr jnewbery + luke-jr Return correct error codes in blockchain.cpp.
RPCs in blockchain.cpp were returning misleading or incorrect error
codes (for example getblock() returning RPC_INTERNAL_ERROR when the
block had been pruned). This commit fixes those error codes:

- RPC_INTERNAL_ERROR should not be returned for application-level
  errors, only for genuine internal errors such as corrupted data.
- RPC_METHOD_NOT_FOUND should not be returned in response to a
  JSON request for an existing method.

Those error codes have been replaced with RPC_MISC_ERROR or
RPC_INVALID_PARAMETER as appropriate.

Github-Pull: #9853
Rebased-From: c119096
c72ef66

@luke-jr luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Jun 3, 2017

@jnewbery @luke-jr jnewbery + luke-jr Return correct error codes in removeprunedfunds().
The removeprunedfunds() RPC was returning misleading or incorrect error
codes (for example RPC_INTERNAL_ERROR when the transaction was
not found in the wallet). This commit fixes those error codes:

- RPC_INTERNAL_ERROR should not be returned for application-level
errors, only for genuine internal errors such as corrupted data.

This error code has been replaced with RPC_WALLET_ERROR.

This commit also updates the test cases to explicitly test the error code.

Github-Pull: #9853
Rebased-From: 960bc7f
24909cb

@luke-jr luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Jun 3, 2017

@jnewbery @luke-jr jnewbery + luke-jr Return correct error codes in fundrawtransaction().
The fundrawtransaction() RPC was returning misleading or incorrect error
codes (for example RPC_INTERNAL_ERROR when funding the transaction
failed). This commit fixes those error codes:

- RPC_INTERNAL_ERROR should not be returned for application-level
errors, only for genuine internal errors such as corrupted data.

That error code has been replaced with RPC_WALLET_ERROR.

This commit also updates the test cases to explicitly test the error code.

Github-Pull: #9853
Rebased-From: dab804c
abf2414

@luke-jr luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Jun 3, 2017

@jnewbery @luke-jr jnewbery + luke-jr Update release notes to include RPC error code changes.
Github-Pull: #9853
Rebased-From: adaa281
0fb9bab

@luke-jr luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Jun 3, 2017

@jnewbery @luke-jr jnewbery + luke-jr Return correct error codes in bumpfee().
The bumpfee() RPC was returning misleading or incorrect error codes
(for example RPC_INVALID_ADDRESS_OR_KEY when the transaction was not
BIP125 replacable). This commit fixes those error codes:

- RPC_INVALID_ADDRESS_OR_KEY if an invalid address was provided:
    - Invalid change address given
- RPC_INVALID_PARAMETER if a single (non-address/key) parameter is incorrect
    - confTarget and totalFee options should not both be set.
    - Invalid confTarget
    - Insufficient totalFee (cannot be less than required fee)
- RPC_WALLET_ERROR for any other error
    - Transaction has descendants in the wallet
    - Transaction has descendants in the mempool
    - Transaction has been mined, or is conflicted with a mined transaction
    - Transaction is not BIP 125 replaceable
    - Transaction has already been bumped
    - Transaction contains inputs that don't belong to the wallet
    - Transaction has multiple change outputs
    - Transaction does not have a change output
    - Fee is higher than maxTxFee
    - New fee rate is less than the minimum fee rate
    - Change output is too small.

This commit also updates the test cases to explicitly test the error code.

Github-Pull: #9853
Rebased-From: 6d07c62
efa7de6

@luke-jr luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Jun 3, 2017

@jnewbery @luke-jr jnewbery + luke-jr Return correct error codes in blockchain.cpp.
RPCs in blockchain.cpp were returning misleading or incorrect error
codes (for example getblock() returning RPC_INTERNAL_ERROR when the
block had been pruned). This commit fixes those error codes:

- RPC_INTERNAL_ERROR should not be returned for application-level
  errors, only for genuine internal errors such as corrupted data.
- RPC_METHOD_NOT_FOUND should not be returned in response to a
  JSON request for an existing method.

Those error codes have been replaced with RPC_MISC_ERROR or
RPC_INVALID_PARAMETER as appropriate.

Github-Pull: #9853
Rebased-From: c119096
6b6d912

@luke-jr luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Jun 3, 2017

@jnewbery @luke-jr jnewbery + luke-jr Return correct error codes in removeprunedfunds().
The removeprunedfunds() RPC was returning misleading or incorrect error
codes (for example RPC_INTERNAL_ERROR when the transaction was
not found in the wallet). This commit fixes those error codes:

- RPC_INTERNAL_ERROR should not be returned for application-level
errors, only for genuine internal errors such as corrupted data.

This error code has been replaced with RPC_WALLET_ERROR.

This commit also updates the test cases to explicitly test the error code.

Github-Pull: #9853
Rebased-From: 960bc7f
1813a4a

@luke-jr luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Jun 3, 2017

@jnewbery @luke-jr jnewbery + luke-jr Return correct error codes in setban().
The setban() RPC was returning misleading or incorrect error
codes (for example RPC_CLIENT_NODE_ALREADY_ADDED when an invalid IP
address was entered). This commit fixes those error codes:

- RPC_CLIENT_INVALID_IP_OR_SUBNET should be returned if the client
  enters an invalid IP address or subnet.

This commit also updates the test cases to explicitly test the error code.

This commit also adds a testcase for trying to setban on an invalid subnet.

Github-Pull: #9853
Rebased-From: a012087
fa897c1

@luke-jr luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Jun 3, 2017

@jnewbery @luke-jr jnewbery + luke-jr Return correct error codes in fundrawtransaction().
The fundrawtransaction() RPC was returning misleading or incorrect error
codes (for example RPC_INTERNAL_ERROR when funding the transaction
failed). This commit fixes those error codes:

- RPC_INTERNAL_ERROR should not be returned for application-level
errors, only for genuine internal errors such as corrupted data.

That error code has been replaced with RPC_WALLET_ERROR.

This commit also updates the test cases to explicitly test the error code.

Github-Pull: #9853
Rebased-From: dab804c
50b052d

@luke-jr luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Jun 3, 2017

@jnewbery @luke-jr jnewbery + luke-jr Update release notes to include RPC error code changes.
Github-Pull: #9853
Rebased-From: adaa281
a44f684

@luke-jr luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Jun 5, 2017

@jnewbery @luke-jr jnewbery + luke-jr Return correct error codes in bumpfee().
The bumpfee() RPC was returning misleading or incorrect error codes
(for example RPC_INVALID_ADDRESS_OR_KEY when the transaction was not
BIP125 replacable). This commit fixes those error codes:

- RPC_INVALID_ADDRESS_OR_KEY if an invalid address was provided:
    - Invalid change address given
- RPC_INVALID_PARAMETER if a single (non-address/key) parameter is incorrect
    - confTarget and totalFee options should not both be set.
    - Invalid confTarget
    - Insufficient totalFee (cannot be less than required fee)
- RPC_WALLET_ERROR for any other error
    - Transaction has descendants in the wallet
    - Transaction has descendants in the mempool
    - Transaction has been mined, or is conflicted with a mined transaction
    - Transaction is not BIP 125 replaceable
    - Transaction has already been bumped
    - Transaction contains inputs that don't belong to the wallet
    - Transaction has multiple change outputs
    - Transaction does not have a change output
    - Fee is higher than maxTxFee
    - New fee rate is less than the minimum fee rate
    - Change output is too small.

This commit also updates the test cases to explicitly test the error code.

Github-Pull: #9853
Rebased-From: 6d07c62
3ad00b4

@luke-jr luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Jun 5, 2017

@jnewbery @luke-jr jnewbery + luke-jr Return correct error codes in blockchain.cpp.
RPCs in blockchain.cpp were returning misleading or incorrect error
codes (for example getblock() returning RPC_INTERNAL_ERROR when the
block had been pruned). This commit fixes those error codes:

- RPC_INTERNAL_ERROR should not be returned for application-level
  errors, only for genuine internal errors such as corrupted data.
- RPC_METHOD_NOT_FOUND should not be returned in response to a
  JSON request for an existing method.

Those error codes have been replaced with RPC_MISC_ERROR or
RPC_INVALID_PARAMETER as appropriate.

Github-Pull: #9853
Rebased-From: c119096
fe51c89

@luke-jr luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Jun 5, 2017

@jnewbery @luke-jr jnewbery + luke-jr Return correct error codes in removeprunedfunds().
The removeprunedfunds() RPC was returning misleading or incorrect error
codes (for example RPC_INTERNAL_ERROR when the transaction was
not found in the wallet). This commit fixes those error codes:

- RPC_INTERNAL_ERROR should not be returned for application-level
errors, only for genuine internal errors such as corrupted data.

This error code has been replaced with RPC_WALLET_ERROR.

This commit also updates the test cases to explicitly test the error code.

Github-Pull: #9853
Rebased-From: 960bc7f
18c109d

@luke-jr luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Jun 5, 2017

@jnewbery @luke-jr jnewbery + luke-jr Return correct error codes in setban().
The setban() RPC was returning misleading or incorrect error
codes (for example RPC_CLIENT_NODE_ALREADY_ADDED when an invalid IP
address was entered). This commit fixes those error codes:

- RPC_CLIENT_INVALID_IP_OR_SUBNET should be returned if the client
  enters an invalid IP address or subnet.

This commit also updates the test cases to explicitly test the error code.

This commit also adds a testcase for trying to setban on an invalid subnet.

Github-Pull: #9853
Rebased-From: a012087
4943d7a

@luke-jr luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Jun 5, 2017

@jnewbery @luke-jr jnewbery + luke-jr Return correct error codes in fundrawtransaction().
The fundrawtransaction() RPC was returning misleading or incorrect error
codes (for example RPC_INTERNAL_ERROR when funding the transaction
failed). This commit fixes those error codes:

- RPC_INTERNAL_ERROR should not be returned for application-level
errors, only for genuine internal errors such as corrupted data.

That error code has been replaced with RPC_WALLET_ERROR.

This commit also updates the test cases to explicitly test the error code.

Github-Pull: #9853
Rebased-From: dab804c
f5efe82

@luke-jr luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Jun 5, 2017

@jnewbery @luke-jr jnewbery + luke-jr Update release notes to include RPC error code changes.
Github-Pull: #9853
Rebased-From: adaa281
c25d0a8

@luke-jr luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Jun 5, 2017

@luke-jr luke-jr Merge #9853 into 0.14.2_fixes cd10719

@luke-jr luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Jun 5, 2017

@luke-jr luke-jr Merge #9853 via branch 'fixerrorcodes-0.14' into 0.14.2_fixes 99e5dbd

@luke-jr luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Jun 5, 2017

@luke-jr luke-jr Merge #10234, #10143 (fixes only), and #9853 via branch 'disconnect_b…
…an_fixes-0.14' into 0.14.2_fixes
2873484

@luke-jr luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Jun 5, 2017

@luke-jr luke-jr Merge #10234, #10143 (fixes only), and #9853 via branch 'disconnect_b…
…an_fixes-0.14' into 0.14.2_fixes
e05799a

@nomnombtc nomnombtc added a commit to nomnombtc/bitcoin that referenced this pull request Jul 17, 2017

@jnewbery @nomnombtc jnewbery + nomnombtc Return correct error codes in bumpfee().
The bumpfee() RPC was returning misleading or incorrect error codes
(for example RPC_INVALID_ADDRESS_OR_KEY when the transaction was not
BIP125 replacable). This commit fixes those error codes:

- RPC_INVALID_ADDRESS_OR_KEY if an invalid address was provided:
    - Invalid change address given
- RPC_INVALID_PARAMETER if a single (non-address/key) parameter is incorrect
    - confTarget and totalFee options should not both be set.
    - Invalid confTarget
    - Insufficient totalFee (cannot be less than required fee)
- RPC_WALLET_ERROR for any other error
    - Transaction has descendants in the wallet
    - Transaction has descendants in the mempool
    - Transaction has been mined, or is conflicted with a mined transaction
    - Transaction is not BIP 125 replaceable
    - Transaction has already been bumped
    - Transaction contains inputs that don't belong to the wallet
    - Transaction has multiple change outputs
    - Transaction does not have a change output
    - Fee is higher than maxTxFee
    - New fee rate is less than the minimum fee rate
    - Change output is too small.

This commit also updates the test cases to explicitly test the error code.

Github-Pull: #9853
Rebased-From: 6d07c62
f81e9f7

@nomnombtc nomnombtc added a commit to nomnombtc/bitcoin that referenced this pull request Jul 17, 2017

@jnewbery @nomnombtc jnewbery + nomnombtc Return correct error codes in blockchain.cpp.
RPCs in blockchain.cpp were returning misleading or incorrect error
codes (for example getblock() returning RPC_INTERNAL_ERROR when the
block had been pruned). This commit fixes those error codes:

- RPC_INTERNAL_ERROR should not be returned for application-level
  errors, only for genuine internal errors such as corrupted data.
- RPC_METHOD_NOT_FOUND should not be returned in response to a
  JSON request for an existing method.

Those error codes have been replaced with RPC_MISC_ERROR or
RPC_INVALID_PARAMETER as appropriate.

Github-Pull: #9853
Rebased-From: c119096
233996c

@nomnombtc nomnombtc added a commit to nomnombtc/bitcoin that referenced this pull request Jul 17, 2017

@jnewbery @nomnombtc jnewbery + nomnombtc Return correct error codes in removeprunedfunds().
The removeprunedfunds() RPC was returning misleading or incorrect error
codes (for example RPC_INTERNAL_ERROR when the transaction was
not found in the wallet). This commit fixes those error codes:

- RPC_INTERNAL_ERROR should not be returned for application-level
errors, only for genuine internal errors such as corrupted data.

This error code has been replaced with RPC_WALLET_ERROR.

This commit also updates the test cases to explicitly test the error code.

Github-Pull: #9853
Rebased-From: 960bc7f
ae73a04

@nomnombtc nomnombtc added a commit to nomnombtc/bitcoin that referenced this pull request Jul 17, 2017

@jnewbery @nomnombtc jnewbery + nomnombtc Return correct error codes in setban().
The setban() RPC was returning misleading or incorrect error
codes (for example RPC_CLIENT_NODE_ALREADY_ADDED when an invalid IP
address was entered). This commit fixes those error codes:

- RPC_CLIENT_INVALID_IP_OR_SUBNET should be returned if the client
  enters an invalid IP address or subnet.

This commit also updates the test cases to explicitly test the error code.

This commit also adds a testcase for trying to setban on an invalid subnet.

Github-Pull: #9853
Rebased-From: a012087
0f1741b

@nomnombtc nomnombtc added a commit to nomnombtc/bitcoin that referenced this pull request Jul 17, 2017

@jnewbery @nomnombtc jnewbery + nomnombtc Return correct error codes in fundrawtransaction().
The fundrawtransaction() RPC was returning misleading or incorrect error
codes (for example RPC_INTERNAL_ERROR when funding the transaction
failed). This commit fixes those error codes:

- RPC_INTERNAL_ERROR should not be returned for application-level
errors, only for genuine internal errors such as corrupted data.

That error code has been replaced with RPC_WALLET_ERROR.

This commit also updates the test cases to explicitly test the error code.

Github-Pull: #9853
Rebased-From: dab804c
fad19c6

@nomnombtc nomnombtc added a commit to nomnombtc/bitcoin that referenced this pull request Jul 17, 2017

@jnewbery @nomnombtc jnewbery + nomnombtc Update release notes to include RPC error code changes.
Github-Pull: #9853
Rebased-From: adaa281
fc1aa80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment