Skip to content
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
Merged

Commits on Mar 7, 2017

  1. 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.
    jnewbery committed Mar 7, 2017
    Copy the full SHA
    6d07c62 View commit details
    Browse the repository at this point in the history
  2. 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 committed Mar 7, 2017
    Copy the full SHA
    c119096 View commit details
    Browse the repository at this point in the history
  3. 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.
    jnewbery committed Mar 7, 2017
    Copy the full SHA
    960bc7f View commit details
    Browse the repository at this point in the history
  4. 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.
    jnewbery committed Mar 7, 2017
    Copy the full SHA
    a012087 View commit details
    Browse the repository at this point in the history
  5. 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.
    jnewbery committed Mar 7, 2017
    Copy the full SHA
    dab804c View commit details
    Browse the repository at this point in the history

Commits on Mar 8, 2017

  1. 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 committed Mar 8, 2017
    Copy the full SHA
    338bf06 View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    adaa281 View commit details
    Browse the repository at this point in the history