New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error codes from various RPCs #9853

Merged
merged 7 commits into from Mar 9, 2017

Conversation

Projects
None yet
5 participants
@jnewbery
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)

This comment has been minimized.

@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.

@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.

This comment has been minimized.

@laanwj

laanwj Feb 25, 2017

Member

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.

@laanwj

laanwj Feb 25, 2017

Member

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.

This comment has been minimized.

@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.

@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.

Show outdated Hide outdated src/wallet/rpcwallet.cpp Outdated
Show outdated Hide outdated src/wallet/rpcdump.cpp Outdated
Show outdated Hide outdated src/wallet/rpcdump.cpp Outdated
@@ -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.");

This comment has been minimized.

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

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

This comment has been minimized.

@jnewbery

jnewbery Feb 28, 2017

Member

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

@jnewbery

jnewbery Feb 28, 2017

Member

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

This comment has been minimized.

@laanwj

laanwj Mar 2, 2017

Member

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.

@laanwj

laanwj Mar 2, 2017

Member

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

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.
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.
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.
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.
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.
@jnewbery

This comment has been minimized.

Show comment
Hide comment
Member

jnewbery commented Mar 7, 2017

@laanwj laanwj self-assigned this Mar 8, 2017

@laanwj

This comment has been minimized.

Show comment
Hide comment
@laanwj

laanwj Mar 8, 2017

Member

utACK 3ff485e

Member

laanwj commented Mar 8, 2017

utACK 3ff485e

@MarcoFalke

This comment has been minimized.

Show comment
Hide comment
@MarcoFalke

MarcoFalke Mar 8, 2017

Member
Member

MarcoFalke commented Mar 8, 2017

@laanwj

This comment has been minimized.

Show comment
Hide comment
@laanwj

laanwj Mar 8, 2017

Member

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

It does.

Member

laanwj commented Mar 8, 2017

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

It does.

@ryanofsky

This comment has been minimized.

Show comment
Hide comment
@ryanofsky

ryanofsky Mar 8, 2017

Contributor

utACK 3ff485e

Confirmed only minor changes since previous ACK.

Contributor

ryanofsky commented Mar 8, 2017

utACK 3ff485e

Confirmed only minor changes since previous ACK.

jnewbery added some commits Feb 24, 2017

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.
@jnewbery

This comment has been minimized.

Show comment
Hide comment
@jnewbery

jnewbery Mar 8, 2017

Member

Release notes updated. Otherwise no change.

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 added a commit that referenced this pull request Mar 9, 2017

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

@jnewbery jnewbery deleted the jnewbery:fixerrorcodes branch Mar 9, 2017

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

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: bitcoin#9853
Rebased-From: a012087

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

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: bitcoin#9853
Rebased-From: 6d07c62

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

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: bitcoin#9853
Rebased-From: c119096

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

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: bitcoin#9853
Rebased-From: 960bc7f

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

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: bitcoin#9853
Rebased-From: dab804c

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

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

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: bitcoin#9853
Rebased-From: 6d07c62

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

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: bitcoin#9853
Rebased-From: c119096

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

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: bitcoin#9853
Rebased-From: 960bc7f

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

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: bitcoin#9853
Rebased-From: a012087

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

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: bitcoin#9853
Rebased-From: dab804c

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

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

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: bitcoin#9853
Rebased-From: 6d07c62

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

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: bitcoin#9853
Rebased-From: c119096

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

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: bitcoin#9853
Rebased-From: 960bc7f

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

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: bitcoin#9853
Rebased-From: a012087

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

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: bitcoin#9853
Rebased-From: dab804c

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

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

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

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

Merge bitcoin#10234, bitcoin#10143 (fixes only), and bitcoin#9853 via…
… branch 'disconnect_ban_fixes-0.14' into 0.14.2_fixes

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

Merge bitcoin#10234, bitcoin#10143 (fixes only), and bitcoin#9853 via…
… branch 'disconnect_ban_fixes-0.14' into 0.14.2_fixes

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

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: bitcoin#9853
Rebased-From: 6d07c62

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

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: bitcoin#9853
Rebased-From: c119096

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

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: bitcoin#9853
Rebased-From: 960bc7f

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

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: bitcoin#9853
Rebased-From: a012087

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

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: bitcoin#9853
Rebased-From: dab804c

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

karel-3d added a commit to karel-3d/bitcoin that referenced this pull request Oct 30, 2017

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: bitcoin#9853
Rebased-From: 6d07c62

karel-3d added a commit to karel-3d/bitcoin that referenced this pull request Oct 30, 2017

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: bitcoin#9853
Rebased-From: c119096

karel-3d added a commit to karel-3d/bitcoin that referenced this pull request Oct 30, 2017

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: bitcoin#9853
Rebased-From: 960bc7f

karel-3d added a commit to karel-3d/bitcoin that referenced this pull request Oct 30, 2017

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: bitcoin#9853
Rebased-From: a012087

karel-3d added a commit to karel-3d/bitcoin that referenced this pull request Oct 30, 2017

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: bitcoin#9853
Rebased-From: dab804c

karel-3d added a commit to karel-3d/bitcoin that referenced this pull request Oct 30, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment