Author

Topic: JSON error (Read 295 times)

sr. member
Activity: 490
Merit: 389
Do not trust the government
November 09, 2017, 03: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.
jr. member
Activity: 45
Merit: 1
November 08, 2017, 08:15:04 AM
#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?
Jump to: