Bitcoin Forum
May 12, 2024, 02:23:37 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Problems with curl  (Read 757 times)
michelemm (OP)
Newbie
*
Offline Offline

Activity: 2
Merit: 0


View Profile
February 27, 2016, 03:28:21 PM
 #1

Hi all,

  this is my first post on BTC Forum.  I am experimenting with Bitcoin Core RPC, and with curl in particular, on Ubuntu.
  I start the server:  > bitcoind -rest &
  I have a Bitcoin Core wallet just for testing. I am able to call some RPC, using bitcoin-cli and curl, for instance:

curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "listaccounts", "params": [6] }' http://USER:PASSWD@127.0.0.1:8332/

I successfully RPC-ed the "walletpassphrase"

curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "walletpassphrase", "params": ["WALLETPASSWD", 60] }' http://USER:PASSWD@127.0.0.1:8332/ , getting:
{"result":null,"error":null,"id":"curltest"}

When I try to call the "sendmany" procedure, I get errors:

- if I try to transfer 0.0002 BTC to 3 addresses:
  curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "sendmany", "params": ["",  "{\"1HwLtBDtLGeHrLkGWHKfE7WgbCz5FbdWW4\":0.0002, \"1G3kKtEK356sfkKaykQvnv37GFUPR3Lns4\":0.0002, \"1KigrTAFLRiZQuHEeX1TwfgzvijtvxU4WA\":0.0002}", 6, "testing"] }'  http://USER:PASSWD@127.0.0.1:8332/ ,  I get:
{"result":null,"error":{"code":-1,"message":"JSON value is not an object as expected"},"id":"curltest"}

- if I try to transfer 0.0002 BTC to 2 addresses (same call): 
curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "sendmany", "params": ["",  "{\"1HwLtBDtLGeHrLkGWHKfE7WgbCz5FbdWW4\":0.0002, \"1G3kKtEK356sfkKaykQvnv37GFUPR3Lns4\":0.0002}", 6, "testing"] }'  http://USER:PASSWD@127.0.0.1:8332/  ,  I get:
{"result":null,"error":{"code":-32700,"message":"Parse error"},"id":null}

  Can someone please help?

TIA

Michele
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
Moloch
Hero Member
*****
Offline Offline

Activity: 798
Merit: 722



View Profile
February 28, 2016, 06:45:10 PM
 #2

This is just a guess, but it looks like you are sending it an empty string as the first object in your array

Quote
"params": ["",  "{\"1HwLtBDtLGeHrLkGWHKfE7WgbCz5FbdWW4\":0.0002, \"1G3kKtEK356sfkKaykQvnv37GFUPR3Lns4\":0.0002, \"1KigrTAFLRiZQuHEeX1TwfgzvijtvxU4WA\":0.0002}", 6, "testing"]

Have you tried it without an empty string as the first object?

Quote
"params": ["{\"1HwLtBDtLGeHrLkGWHKfE7WgbCz5FbdWW4\":0.0002, \"1G3kKtEK356sfkKaykQvnv37GFUPR3Lns4\":0.0002, \"1KigrTAFLRiZQuHEeX1TwfgzvijtvxU4WA\":0.0002}", 6, "testing"]
michelemm (OP)
Newbie
*
Offline Offline

Activity: 2
Merit: 0


View Profile
February 29, 2016, 09:35:01 PM
 #3

This is just a guess, but it looks like you are sending it an empty string as the first object in your array

Quote
"params": ["",  "{\"1HwLtBDtLGeHrLkGWHKfE7WgbCz5FbdWW4\":0.0002, \"1G3kKtEK356sfkKaykQvnv37GFUPR3Lns4\":0.0002, \"1KigrTAFLRiZQuHEeX1TwfgzvijtvxU4WA\":0.0002}", 6, "testing"]

Have you tried it without an empty string as the first object?

Quote
"params": ["{\"1HwLtBDtLGeHrLkGWHKfE7WgbCz5FbdWW4\":0.0002, \"1G3kKtEK356sfkKaykQvnv37GFUPR3Lns4\":0.0002, \"1KigrTAFLRiZQuHEeX1TwfgzvijtvxU4WA\":0.0002}", 6, "testing"]

Tanks for the help.
The first object of the array is the name of the sending account. The empty string means the default account.
Anyway, I dropped the object and rerun the curl command, but this time the server did not even bother to answer an error (and the transaction was not sent).
Giving the same "sendall" command (with the empty string) directly as parameter of bitcoin-cli, however, works.

I am still in trouble.

Michele
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!