Bitcoin Forum
November 08, 2024, 02:19:23 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Bitcoin / Development & Technical Discussion / Re: Bitcoin RPC send error code -3 - Invalid Amount on: October 18, 2022, 01:10:41 PM
0.0002462028

{"result":null,"error":{"code":-3,"message":"Invalid amount"},"id":null}

I'm aware of the other question on this forum that says -3 is a type error that only appears when amount is negative or zero, but that is not the case as you can see above in the call body.
The error message is already telling you what the problem is and it is not just about being negative or zero, it is about being an "invalid" value for amount which could be for many different reasons like not being a number; in this case the problem is that the value has more decimal places than defined in Bitcoin (10 instead of Cool.

Thank you, this solved the problem. Here's the new code:

Code:
const response = await bitcoin.send(
    [{ [output]: sending.toFixed(8).toString() }],
    6, // conf_target
    "economical",
    undefined, // fee_rate
    {
      "change_position": 1,
      "subtract_fee_from_outputs": [0],
      "inputs": [input],
    },
  );
2  Bitcoin / Development & Technical Discussion / Re: Bitcoin RPC send error code -3 - Invalid Amount on: October 18, 2022, 12:24:10 AM
Can you share the whole cURL or code snippet you're using to submit that request?

It's hard to get that because I'm using my own RPC library. The JSON body I put in the post is printing from inside the library right before it makes the request. Here's the TypeScript code that's trying to send:

Code:
const response = await bitcoin.send(
    [{ [output]: sending.toString() }],
    6, // conf_target
    "economical",
    undefined, // fee_rate
    {
      "change_position": 1,
      "subtract_fee_from_outputs": [0],
      "inputs": [input],
    },
  );

Again, I have run it without the options object and have the same result. Additionally, this code works on the testnet but not the mainnet if that helps.
3  Bitcoin / Development & Technical Discussion / Bitcoin RPC send error code -3 - Invalid Amount on: October 17, 2022, 11:13:03 PM
Hello, I'm having a problem with Bitcoin RPC's send method. Here is my RPC call:

{"jsonrpc":"2.0","method":"send","params":[[{"3NKnXgAuRZ52uUMgDztyQM1aNsXoyoxM7D":0.0002462028}],6,"economical",null,{"change_position":1,"subtract_fee_from_outputs":[0],"inputs":[{"txid":"69c77704508f14949448a989b2b5662292128f92cad9620961118f767799d1be","vout":0,"sequence":0}]}]}

This is the RPC response:

{"result":null,"error":{"code":-3,"message":"Invalid amount"},"id":null}

I'm aware of the other question on this forum that says -3 is a type error that only appears when amount is negative or zero, but that is not the case as you can see above in the call body.

As you can see on a chain explorer, this transaction ID has more than the send amount at that index. As a test, I removed the additional options to see if it would send without them and it results in the same error.

I've tried specifying the amount as a string and a number, neither work.

Any help would be appreciated. Thanks.
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!