Check for available funds before call to SendMoney. #5393

pull paveljanik wants to merge 1 commits into bitcoin:master from paveljanik:insufffunds changing 1 files +4 −0
  1. paveljanik commented at 10:09 AM on November 29, 2014: contributor

    RPC call sendtoaddress doesn't check for available funds before the call to SendMoney. This results in suboptimal RPC error code returned. RPC_WALLET_ERROR (-4) instead of RPC_WALLET_INSUFFICIENT_FUNDS (-6):

    # Before:
    pavel$ ./bitcoin-cli sendtoaddress m...address... 1000
    error: {"code":-4,"message":"Insufficient funds"}
    # After:
    pavel$ ./bitcoin-cli sendtoaddress m...address... 1000
    error: {"code":-6,"message":"Insufficient funds"}
    

    This fixes issue #3007.

  2. Check for available funds before call to SendMoney. 8bb724740c
  3. laanwj added the label Wallet on Dec 1, 2014
  4. laanwj commented at 11:43 AM on December 1, 2014: member

    This would work, although I'd prefer a deeper overhaul of SendMoney where it returns a status code instead of (or as well as) a string. Note that SendMoney is only used in the RPC interface (the GUI uses CreateTransaction/CommitTransaction), so you could move the function to rpcwallet.cpp and make it return a RPC status code as well.

    BTW unrelated but looking at the function it makes no sense that the error messages returned over RPC are translated using _().

  5. paveljanik commented at 1:36 PM on December 1, 2014: contributor

    Can do that. But not for 0.10 IMO. For 0.10 I think the current branch and removing _() should be done (I can do that even in this branch). OK?

  6. laanwj commented at 3:02 PM on December 2, 2014: member

    Closing in favor of #5399

  7. laanwj closed this on Dec 2, 2014

  8. paveljanik deleted the branch on Dec 2, 2014
  9. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-21 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me