Bitcoin Forum
November 05, 2024, 10:12:45 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoin RPC send error code -3 - Invalid Amount  (Read 226 times)
icreator (OP)
Legendary
*
Offline Offline

Activity: 1554
Merit: 1008



View Profile WWW
July 03, 2018, 09:04:19 PM
 #1

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

Erachain Blockchain is fully ready for use Digital Ecosystem based on blockchain technology for business and government with low transaction costs, identification and built-in functions.
+Decentralized exchange of tokens in Erachain
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3542
Merit: 6885


Just writing some code


View Profile WWW
July 04, 2018, 12:08:12 AM
 #2

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.

RGBKey
Hero Member
*****
Offline Offline

Activity: 854
Merit: 658


rgbkey.github.io/pgp.txt


View Profile WWW
July 04, 2018, 12:35:07 AM
 #3

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.
icreator (OP)
Legendary
*
Offline Offline

Activity: 1554
Merit: 1008



View Profile WWW
July 05, 2018, 11:21:38 AM
 #4

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

Erachain Blockchain is fully ready for use Digital Ecosystem based on blockchain technology for business and government with low transaction costs, identification and built-in functions.
+Decentralized exchange of tokens in Erachain
bob123
Legendary
*
Offline Offline

Activity: 1624
Merit: 2481



View Profile WWW
July 05, 2018, 07:48:06 PM
 #5

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) ?

achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3542
Merit: 6885


Just writing some code


View Profile WWW
July 05, 2018, 07:52:40 PM
 #6

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.

bob123
Legendary
*
Offline Offline

Activity: 1624
Merit: 2481



View Profile WWW
July 05, 2018, 08:00:25 PM
 #7

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

achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3542
Merit: 6885


Just writing some code


View Profile WWW
July 05, 2018, 10:04:47 PM
 #8

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.

icreator (OP)
Legendary
*
Offline Offline

Activity: 1554
Merit: 1008



View Profile WWW
July 06, 2018, 08:00:29 PM
 #9

?? 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?

Erachain Blockchain is fully ready for use Digital Ecosystem based on blockchain technology for business and government with low transaction costs, identification and built-in functions.
+Decentralized exchange of tokens in Erachain
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3542
Merit: 6885


Just writing some code


View Profile WWW
July 06, 2018, 09:58:32 PM
 #10

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.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!