Bitcoin Forum
November 23, 2017, 09:55:46 AM *
News: Latest stable version of Bitcoin Core: 0.15.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: JSON error  (Read 148 times)
columbo
Jr. Member
*
Offline Offline

Activity: 35


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?
1511430946
Hero Member
*
Offline Offline

Posts: 1511430946

View Profile Personal Message (Offline)

Ignore
1511430946
Reply with quote  #2

1511430946
Report to moderator
Join ICO Now A blockchain platform for effective freelancing
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1511430946
Hero Member
*
Offline Offline

Posts: 1511430946

View Profile Personal Message (Offline)

Ignore
1511430946
Reply with quote  #2

1511430946
Report to moderator
1511430946
Hero Member
*
Offline Offline

Posts: 1511430946

View Profile Personal Message (Offline)

Ignore
1511430946
Reply with quote  #2

1511430946
Report to moderator
aleksej996
Full Member
***
Offline Offline

Activity: 140


★777Coin.com★ Fun BTC Casino!


View Profile
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!