Author

Topic: Bitcoin RPC send error code -3 - Invalid Amount (Read 214 times)

staff
Activity: 3374
Merit: 6530
Just writing some code
as You see I print value of "amo - txfee" = 0.14297412 - and in first case it is INVALID
but in another case the same value of "amo - txfee" = 0.14297412 - is GOOD
Can you print out the values for amo and txfee too?

and this error I got only when update core wallet to 0.15 version ((
may be in 0.16 It will be fixed?
No, it will not be fixed because 0.16 has the same error messages guarded by the same conditions.

If you have an http packet inspection tool, you can intercept the packets being sent to your node and see what the actual JSON for the command is being sent. That will give you more information too about the error as you can see what was actually sent by your code.
legendary
Activity: 1554
Merit: 1008
?? Why I see this error code -3 ??

PYTHON code:
Code:
           print 'res = cc.sendtoaddress(addr, amo - txfee)', amo - txfee
            res = cc.sendtoaddress(addr, amo - txfee)
            print "SENDed? ", res

first run >>>
Quote
balance 0.25229647
try send: 0.14307412BTC to 3QgwCppatHV847dA4BYv538aZq8xz6uWuv
res = cc.sendtoaddress(addr, amo - txfee) 0.14297412
SENDed?  {u'id': 1, u'result': None, u'error': {u'message': u'Invalid amount for send', u'code': -3}}

second run >>>
Quote
balance 0.25229647
try send: 0.14307412BTC 3QgwCppatHV847dA4BYv538aZq8xz6uWuv
res = cc.sendtoaddress(addr, amo - txfee) 0.14297412
SENDed?  032e3710d5ac263ddb8bc9f9e295b086c00af8997f7f7ad3af8beca99287f85f
PAYed xcurr - res: {'payment_id': u'032e3710d5ac263ddb8bc9f9e295b086c00af8997f7f7ad3af8beca99287f85f', 'status': 'success'}

why??
balances not changed...

as You see I print value of "amo - txfee" = 0.14297412 - and in first case it is INVALID
but in another case the same value of "amo - txfee" = 0.14297412 - is GOOD

and this error I got only when update core wallet to 0.15 version ((
may be in 0.16 It will be fixed?
staff
Activity: 3374
Merit: 6530
Just writing some code
no, amount in float is > 0
That error code and string occur in only 4 places in the code, with each one protected by an if branch checking whether the amount given is <= 0. If you are getting this error, then your amount is being interpreted as being <= 0, regardless of what you intended it to be.
I don't think it is because the value is <= 0.
According to OP, there is a value > 0 (at least thats what it looks like according to the output to the screen):

print 'res = cc.sendtoaddress(addr, amo - txfee)', amo - txfee
res = cc.sendtoaddress(addr, amo - txfee) 0.14297412
I assume it is a type error. Thats what status code -3 should be for:
Quote
RPC_TYPE_ERROR = -3, //!< Unexpected type was passed as parameter
from: https://github.com/bitcoin/bitcoin/blob/v0.15.0.1/src/rpc/protocol.h#L50
Every RPC error comes with an error code and a message. The message was "Invalid amount for send". As I said earlier, this only appears in 4 places and is guarded by only a check for negative or 0 values. This error can only be triggered by having a negative or 0 amount. This is still a type error, but type error can still mean many things. In this case, the type is "positive decimal" which is not what is being provided.
legendary
Activity: 1624
Merit: 2481
no, amount in float is > 0
That error code and string occur in only 4 places in the code, with each one protected by an if branch checking whether the amount given is <= 0. If you are getting this error, then your amount is being interpreted as being <= 0, regardless of what you intended it to be.



I don't think it is because the value is <= 0.
According to OP, there is a value > 0 (at least thats what it looks like according to the output to the screen):

print 'res = cc.sendtoaddress(addr, amo - txfee)', amo - txfee
res = cc.sendtoaddress(addr, amo - txfee) 0.14297412



I assume it is a type error. Thats what status code -3 should be for:


Quote
RPC_TYPE_ERROR = -3, //!< Unexpected type was passed as parameter
from: https://github.com/bitcoin/bitcoin/blob/v0.15.0.1/src/rpc/protocol.h#L50
staff
Activity: 3374
Merit: 6530
Just writing some code
no, amount in float is > 0
That error code and string occur in only 4 places in the code, with each one protected by an if branch checking whether the amount given is <= 0. If you are getting this error, then your amount is being interpreted as being <= 0, regardless of what you intended it to be.
legendary
Activity: 1624
Merit: 2481
As achow101 already mentioned, it most probably is a bug in your code.
Mind sharing the relevant parts? We can't spot your bug without anything to look at.



but some times when bitcoin rate move up or down and amount to send is updating and transaction was created successfully

Could you explain this ?
Why does the bitcoin rate (BTC/USD price ?) influence your ability to create transactions ?

And what libary are you using? python-bitcoinrpc (https://github.com/jgarzik/python-bitcoinrpc) ?
legendary
Activity: 1554
Merit: 1008
The error has nothing to do with the wallet.

Error code -3 means that there was a type error. With the error message "invalid amount for send", the amount that was specified was less than or equal to 0. This means that your code probably has a bug in it where amo is too small.

no, amount in float is > 0

but some times when bitcoin rate move up or down and amount to send is updating and transaction was created successfully

why? It only was on 0.15 version of core wallet
hero member
Activity: 854
Merit: 658
rgbkey.github.io/pgp.txt
Are you sending the amounts in Satoshis, instead of in floating points? I'm unfamiliar with the interface that you're using but that would be the first thing I check.
staff
Activity: 3374
Merit: 6530
Just writing some code
The error has nothing to do with the wallet.

Error code -3 means that there was a type error. With the error message "invalid amount for send", the amount that was specified was less than or equal to 0. This means that your code probably has a bug in it where amo is too small.
legendary
Activity: 1554
Merit: 1008
?? Why I see this error code -3 ??

PYTHON code:
Code:
            print 'res = cc.sendtoaddress(addr, amo - txfee)', amo - txfee
            res = cc.sendtoaddress(addr, amo - txfee)
            print "SENDed? ", res

first run >>>
Quote
balance 0.25229647
try send: 0.14307412BTC to 3QgwCppatHV847dA4BYv538aZq8xz6uWuv
res = cc.sendtoaddress(addr, amo - txfee) 0.14297412
SENDed?  {u'id': 1, u'result': None, u'error': {u'message': u'Invalid amount for send', u'code': -3}}

second run >>>
Quote
balance 0.25229647
try send: 0.14307412BTC 3QgwCppatHV847dA4BYv538aZq8xz6uWuv
res = cc.sendtoaddress(addr, amo - txfee) 0.14297412
SENDed?  032e3710d5ac263ddb8bc9f9e295b086c00af8997f7f7ad3af8beca99287f85f
PAYed xcurr - res: {'payment_id': u'032e3710d5ac263ddb8bc9f9e295b086c00af8997f7f7ad3af8beca99287f85f', 'status': 'success'}

why??
balances not changed...
Jump to: