<p>Try this:</p>

<p>You need to provide the private keys and the utxo as arrays and make sure it is valid json and in quotes.</p>

<p><code>$ /usr/bin/bitcoin-cli -testnet signrawtransactionwithkey "02000000017b0cd6ab6beebace32e00f27aea8092879e178a77d2d0e74d001e10b39f560d10100000000ffffffff0100093d000000000017a9145e235c002eb66a1c33abccfb805043a036baf7798700000000" '["cNoe7mVGEVFwUwQXuCJadosEVPYU5rcCVxzTr46gYWbWMD8gXR7b"]'  '[{"txid":"d160f5390be101d0740e2d7da778e1792809a8ae270fe032cebaee6babd60c7b","vout":1,"scriptPubKey":"a9145c975f4c6d18fa1abd25018e1fa3c18e58c9e93b87","redeemScript":"5221029558bd8bc6e0cac883cac93a420bf8e68e76e8e07944f6034e3c5eadd3f1a4db21038d217a8fa3960a3b3212bc545566c5c48add11003551cb23c0d744a13f9ab8272102fcd0e6ff324c7a3bc9a8e224d61cd9ccd244c54186848ca3035a54736a9780d653ae"}]'</code></p>

CC BY-SA 4.0
2018-12-06T02:17:59.127Z
Ok, so the single and double quotes instead of backslashes, got it.
Tom
CC BY-SA 4.0
2018-12-06T02:18:49.680Z
Also, if I want to sign one key at a time, do I need to set the sighashtype param to 'SINGLE' ?
Tom
CC BY-SA 4.0
2018-12-06T02:24:54.183Z
No, sighash is a way to specify what you actually want to sign, not the keys you want to sign with. See https://bitcoin.org/en/developer-guide#term-signature-hash
JBaczuk
CC BY-SA 4.0
2018-12-06T02:28:07.573Z
no problem. You could also provide the quoted json in this format (escaping the inner quotes): `"[\"privkey\"]"` but I find the above easier to read.
JBaczuk
CC BY-SA 4.0
2018-12-06T02:10:19.790Z
2018-12-06T02:10:19.790Z
JBaczuk
<p>I have issues trying to sign a 2/3 multisig tx with the first private key.</p>

<p>What am I doing something wrong or am I missing something for the arg?</p>

<p>Command format:</p>

<pre><code>/usr/bin/bitcoin-cli -testnet signrawtransactionwithkey "multisig_tx_hexstring" \"privatekey1\"  {\"txid\":\"id\",\"vout\":n,\"scriptPubKey\":\"hex\",\"redeemScript\":\"hex\"}
</code></pre>

<p>Filled in:</p>

<pre><code>/usr/bin/bitcoin-cli -testnet signrawtransactionwithkey "02000000017b0cd6ab6beebace32e00f27aea8092879e178a77d2d0e74d001e10b39f560d10100000000ffffffff0100093d000000000017a9145e235c002eb66a1c33abccfb805043a036baf7798700000000" \"cNoe7mVGEVFwUwQXuCJadosEVPYU5rcCVxzTr46gYWbWMD8gXR7b\"  {\"txid\":\"d160f5390be101d0740e2d7da778e1792809a8ae270fe032cebaee6babd60c7b\",\"vout\":1,\"scriptPubKey\":\"a9145c975f4c6d18fa1abd25018e1fa3c18e58c9e93b87\",\"redeemScript\":\"5221029558bd8bc6e0cac883cac93a420bf8e68e76e8e07944f6034e3c5eadd3f1a4db21038d217a8fa3960a3b3212bc545566c5c48add11003551cb23c0d744a13f9ab8272102fcd0e6ff324c7a3bc9a8e224d61cd9ccd244c54186848ca3035a54736a9780d653ae\"}
</code></pre>

<p>And the error: </p>

<pre><code>error: Error parsing JSON:"txid":"d160f5390be101d0740e2d7da778e1792809a8ae270fe032cebaee6babd60c7b"
</code></pre>

CC BY-SA 4.0
2018-12-06T02:07:18.953Z
you need to pack the JSON object in quotes `
Jonas Schnelli
<bitcoin-core><bitcoind><json-rpc><bitcoin-cli><rpc-error-25>
Error parsing JSON in bitcoin-cli signrawtransactionwithkey
Tom
# Error parsing JSON in bitcoin-cli signrawtransactionwithkey

(Asked by: username_0 on 2018-12-06)

I have issues trying to sign a 2/3 multisig tx with the first private key.

What am I doing something wrong or am I missing something for the arg?

Command format:

```
/usr/bin/bitcoin-cli -testnet signrawtransactionwithkey "multisig_tx_hexstring" \"privatekey1\"  {\"txid\":\"id\",\"vout\":n,\"scriptPubKey\":\"hex\",\"redeemScript\":\"hex\"}

```

Filled in:

```
/usr/bin/bitcoin-cli -testnet signrawtransactionwithkey "02000000017b0cd6ab6beebace32e00f27aea8092879e178a77d2d0e74d001e10b39f560d10100000000ffffffff0100093d000000000017a9145e235c002eb66a1c33abccfb805043a036baf7798700000000" \"cNoe7mVGEVFwUwQXuCJadosEVPYU5rcCVxzTr46gYWbWMD8gXR7b\"  {\"txid\":\"d160f5390be101d0740e2d7da778e1792809a8ae270fe032cebaee6babd60c7b\",\"vout\":1,\"scriptPubKey\":\"a9145c975f4c6d18fa1abd25018e1fa3c18e58c9e93b87\",\"redeemScript\":\"5221029558bd8bc6e0cac883cac93a420bf8e68e76e8e07944f6034e3c5eadd3f1a4db21038d217a8fa3960a3b3212bc545566c5c48add11003551cb23c0d744a13f9ab8272102fcd0e6ff324c7a3bc9a8e224d61cd9ccd244c54186848ca3035a54736a9780d653ae\"}

```

And the error:

```
error: Error parsing JSON:"txid":"d160f5390be101d0740e2d7da778e1792809a8ae270fe032cebaee6babd60c7b"

```

**Tags:** bitcoin-core, bitcoind, json-rpc, bitcoin-cli, rpc-error-25

> **Comments:**
> **username_1**: you need to pack the JSON object in quotes `  

---

## 1 answers

### Answer by username_2 on 2018-12-06. Score: 2

Try this:

You need to provide the private keys and the utxo as arrays and make sure it is valid json and in quotes.

`$ /usr/bin/bitcoin-cli -testnet signrawtransactionwithkey "02000000017b0cd6ab6beebace32e00f27aea8092879e178a77d2d0e74d001e10b39f560d10100000000ffffffff0100093d000000000017a9145e235c002eb66a1c33abccfb805043a036baf7798700000000" '["cNoe7mVGEVFwUwQXuCJadosEVPYU5rcCVxzTr46gYWbWMD8gXR7b"]' '[{"txid":"d160f5390be101d0740e2d7da778e1792809a8ae270fe032cebaee6babd60c7b","vout":1,"scriptPubKey":"a9145c975f4c6d18fa1abd25018e1fa3c18e58c9e93b87","redeemScript":"5221029558bd8bc6e0cac883cac93a420bf8e68e76e8e07944f6034e3c5eadd3f1a4db21038d217a8fa3960a3b3212bc545566c5c48add11003551cb23c0d744a13f9ab8272102fcd0e6ff324c7a3bc9a8e224d61cd9ccd244c54186848ca3035a54736a9780d653ae"}]'`

> **Comments:**
> **username_0**: Ok, so the single and double quotes instead of backslashes, got it.  
> **username_0**: Also, if I want to sign one key at a time, do I need to set the sighashtype param to 'SINGLE' ?  
> **username_2**: No, sighash is a way to specify what you actually want to sign, not the keys you want to sign with. See https://bitcoin.org/en/developer-guide#term-signature-hash  
> **username_2**: no problem. You could also provide the quoted json in this format (escaping the inner quotes): `"[\"privkey\"]"` but I find the above easier to read.  

---

