Bitcoin Forum
May 21, 2018, 06:02:35 PM *
News: Latest stable version of Bitcoin Core: 0.16.0  [Torrent]. (New!)
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: JSON error  (Read 168 times)
columbo
Jr. Member
*
Offline Offline

Activity: 44
Merit: 0


View Profile
November 08, 2017, 01:15:04 PM
 #1

I have a bitcoin core setup under a specific linux user name: xbt.
I would like to run bitcoin-cli with the root user. For this, I wrote a shell script, xbt-bitcoin.sh:

#!/bin/bash

/home/xbt/bitcoin-0.15.0/bin/bitcoin-cli -conf=/home/xbt/.bitcoin/bitcoin.conf $@

So basically this shell script pass all arguments to my bitcoin-cli and it is working very well for simple commands like:
./xbt-bitcoin.sh getbalance
./sbt-bitcoin.sh getnewaddress
./xbt-bitcoin.sh getbalance "AccountName"
etc.

However, I have issues with more complex commands like:

.xbt-bitcoin.sh sendmany "" "{\"address1\":0.02,\"address2\":0.01}" 1 ""
I get an error like:

"error code: -1
error message:
JSON value is not an object as expected"

I guess something is wrong with the way I pass the arguments via the shell script but I can't figure it out how to resolve this.
What can be wrong here?
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1526925755
Hero Member
*
Offline Offline

Posts: 1526925755

View Profile Personal Message (Offline)

Ignore
1526925755
Reply with quote  #2

1526925755
Report to moderator
1526925755
Hero Member
*
Offline Offline

Posts: 1526925755

View Profile Personal Message (Offline)

Ignore
1526925755
Reply with quote  #2

1526925755
Report to moderator
1526925755
Hero Member
*
Offline Offline

Posts: 1526925755

View Profile Personal Message (Offline)

Ignore
1526925755
Reply with quote  #2

1526925755
Report to moderator
aleksej996
Sr. Member
****
Offline Offline

Activity: 308
Merit: 259


★777Coin.com★ Fun BTC Casino!


View Profile WWW
November 09, 2017, 08:08:27 PM
 #2

Perhaps for that command bitcoin-cli requires to be passed quotation marks and the shell strips them away and only passes the string inside of them.
Maybe try adding a backslash to all of your quotation marks and if the bitcoin-cli requires to be passed a backslash for some quotation marks then add those with the double backslash as well.

Example:

Your command
Code:
./xbt-bitcoin.sh sendmany "" "{\"address1\":0.02,\"address2\":0.01}" 1 ""
might pass arguments to bitcoin-cli as this
Code:
.xbt-bitcoin.sh sendmany  {"address1":0.02,"address2":0.01}" 1
The way it might work
Code:
.xbt-bitcoin.sh sendmany \"\" \"{\\\"address1\\\":0.02,\\\"address2\\\":0.01}\" 1 \"\"

Just and idea you can try.

Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!