<p>For the first command, you need to include the JSON in single quotes, like so:</p>

<pre><code>$ bitcoin-cli createrawtransaction '[{"txid":"dbdc2e2c7f143af70c5e7e8725f55d226b3c058d7bf34a303091b3c6a514848c","vout":1}]' '{"1BCi1L25GC9hUSvtSyGjmEvSyywoYubk4P":0.00011}'
01000000018c8414a5c6b39130304af37b8d053c6b225df525877e5e0cf73a147f2c2edcdb0100000000ffffffff01f82a0000000000001976a9146fe8102ebe0fccb56de43ec82601ba16c68496af88ac00000000
</code></pre>

<p>The <code>bitcoin-tx</code> utility uses a shorthand that is deployed in the bitcoin unit tests. This example might help you use this command:</p>

<pre><code>$ ./bitcoin-tx -create in=0fb9df5614be8b33be0434ce4062750d83f1b7ce05cc1296604f82eb9abf802b:0 outscript=0.00159999:"DUP HASH160 0x14 0x6793a38f79b8cd51dbb6face6dc75a4af5c1bf29 EQUALVERIFY CHECKSIG"
01000000012b80bf9aeb824f609612cc05ceb7f1830d756240ce3404be338bbe1456dfb90f0000000000ffffffff01ff700200000000001976a9146793a38f79b8cd51dbb6face6dc75a4af5c1bf2988ac00000000
</code></pre>

<p>The code for parsing the scripts can be found <a href="https://github.com/bitcoin/bitcoin/blob/v0.10.0/src/core_read.cpp#L27" rel="nofollow">here</a>. However, I find just looking at some examples in <a href="https://github.com/bitcoin/bitcoin/blob/v0.10.0/src/test/data/tx_valid.json#L60" rel="nofollow">the unit test data</a> to be helpful as well.</p>

CC BY-SA 3.0
2016-05-24T15:33:28.777Z
For DOS, you need to remove single quotes and escape double quotes... bitcoin-cli -regtest createrawtransaction [{\"txid\":\"c6343009c5d73572f750359480ae95170a00cfb41063f8cd70e1c14d06e8776c\",\"vout\":0}] {\"myf8U7KUzidun3WzjK2WM4nYVyE1ZkpSGH\":49.9999}
Steve Hibbert
CC BY-SA 3.0
2015-02-20T05:04:58.170Z
2015-02-20T05:04:58.170Z
morsecoder
<p>I'm trying to create a raw transaction using Bitcoin Core v0.10.0 (on Windows 7 x64, and with txindex=1 optioned).</p>

<p>Bitcoin Core v0.10.0 comes with a new <em>Bitcoin-tx</em> executable utility. The help menu is as follows (under Windows 7 x64):</p>

<pre><code>Bitcoin Core bitcoin-tx utility version v0.10.0

Usage:
  bitcoin-tx [options] &lt;hex-tx&gt; [commands]  Update hex-encoded bitcoin transaction
  bitcoin-tx [options] -create [commands]   Create hex-encoded bitcoin transaction

Options:
  -?                      This help message
  -create                 Create new, empty TX.
  -json                   Select JSON output
  -txid                   Output only the hex-encoded transaction id of the resultant transaction.
  -regtest                Enter regression test mode, which uses a special chain in which blocks can be solved instantly.
  -testnet                Use the test network

Commands:
  delin=N                Delete input N from TX
  delout=N               Delete output N from TX
  in=TXID:VOUT           Add input to TX
  locktime=N             Set TX lock time to N
  nversion=N             Set TX version to N
  outaddr=VALUE:ADDRESS  Add address-based output to TX
  outscript=VALUE:SCRIPT Add raw script output to TX
  sign=SIGHASH-FLAGS     Add zero or more signatures to transaction
      This command requires JSON registers:
      prevtxs=JSON object
      privatekeys=JSON object
      See signrawtransaction docs for format of sighash flags, JSON objects.

Register Commands:
  load=NAME:FILENAME     Load JSON file FILENAME into register NAME
  set=NAME:JSON-STRING   Set register NAME to given JSON-STRING
</code></pre>

<p>Using Windows CLI, I'm running into issues with <em>createrawtransaction</em> as it's not parsing the command the same as it does in the Bitcoin-QT console window. </p>

<pre><code>bitcoin-cli createrawtransaction [{"txid":"dbdc2e2c7f143af70c5e7e8725f55d226b3c058d7bf34a303091b3c6a514848c","vout":1}] {"1BCi1L25GC9hUSvtSyGjmEvSyywoYubk4P":0.00011}
</code></pre>

<p>Gives <code>error: Error parsing JSON:[{txid:dbdc2e2c7f143af70c5e7e8725f55d226b3c058d7bf34a303091b3c6a514848c,vout:1}]</code></p>

<p>Likewise, the <code>bitcoin-tx</code> utility won't work with this:</p>

<pre><code>bitcoin-tx.exe -create in=dbdc2e2c7f143af70c5e7e8725f55d226b3c058d7bf34a303091b3c6a514848c:1 locktime=0 nversion=1 outaddr=2000:1BCi1L25GC9hUSvtSyGjmEvSyywoYubk4P outscript=0:687474703a2f2f676f6f2e676c2f7869556243555
</code></pre>

<p>How can I create a raw transaction using <em>Bitcoin-cli</em> and <em>bitcoin-tx</em>?</p>

CC BY-SA 3.0
2015-02-20T04:04:16.307Z
When Bitcoin emits `Error parsing JSON:`, it give you the token that confused it, exactly as it got it. Is your shell eating your `"` characters?
Nick ODell
<client><windows><raw-transaction>
Creating a raw transaction using Bitcoin Core v0.10.0 bitcoin-tx / createrawtransaction
Wizard Of Ozzie
# Creating a raw transaction using Bitcoin Core v0.10.0 bitcoin-tx / createrawtransaction

(Asked by: username_0 on 2015-02-20)

I'm trying to create a raw transaction using Bitcoin Core v0.10.0 (on Windows 7 x64, and with txindex=1 optioned).

Bitcoin Core v0.10.0 comes with a new *Bitcoin-tx* executable utility. The help menu is as follows (under Windows 7 x64):

```
Bitcoin Core bitcoin-tx utility version v0.10.0

Usage:
  bitcoin-tx [options] <hex-tx> [commands]  Update hex-encoded bitcoin transaction
  bitcoin-tx [options] -create [commands]   Create hex-encoded bitcoin transaction

Options:
  -?                      This help message
  -create                 Create new, empty TX.
  -json                   Select JSON output
  -txid                   Output only the hex-encoded transaction id of the resultant transaction.
  -regtest                Enter regression test mode, which uses a special chain in which blocks can be solved instantly.
  -testnet                Use the test network

Commands:
  delin=N                Delete input N from TX
  delout=N               Delete output N from TX
  in=TXID:VOUT           Add input to TX
  locktime=N             Set TX lock time to N
  nversion=N             Set TX version to N
  outaddr=VALUE:ADDRESS  Add address-based output to TX
  outscript=VALUE:SCRIPT Add raw script output to TX
  sign=SIGHASH-FLAGS     Add zero or more signatures to transaction
      This command requires JSON registers:
      prevtxs=JSON object
      privatekeys=JSON object
      See signrawtransaction docs for format of sighash flags, JSON objects.

Register Commands:
  load=NAME:FILENAME     Load JSON file FILENAME into register NAME
  set=NAME:JSON-STRING   Set register NAME to given JSON-STRING

```

Using Windows CLI, I'm running into issues with *createrawtransaction* as it's not parsing the command the same as it does in the Bitcoin-QT console window.

```
bitcoin-cli createrawtransaction [{"txid":"dbdc2e2c7f143af70c5e7e8725f55d226b3c058d7bf34a303091b3c6a514848c","vout":1}] {"1BCi1L25GC9hUSvtSyGjmEvSyywoYubk4P":0.00011}

```

Gives `error: Error parsing JSON:[{txid:dbdc2e2c7f143af70c5e7e8725f55d226b3c058d7bf34a303091b3c6a514848c,vout:1}]`

Likewise, the `bitcoin-tx` utility won't work with this:

```
bitcoin-tx.exe -create in=dbdc2e2c7f143af70c5e7e8725f55d226b3c058d7bf34a303091b3c6a514848c:1 locktime=0 nversion=1 outaddr=2000:1BCi1L25GC9hUSvtSyGjmEvSyywoYubk4P outscript=0:687474703a2f2f676f6f2e676c2f7869556243555

```

How can I create a raw transaction using *Bitcoin-cli* and *bitcoin-tx*?

**Tags:** client, windows, raw-transaction

> **Comments:**
> **username_1**: When Bitcoin emits `Error parsing JSON:`, it give you the token that confused it, exactly as it got it. Is your shell eating your `"` characters?  

---

## 1 answers

### Answer by username_2 on 2015-02-20. Score: 3 | Accepted answer

For the first command, you need to include the JSON in single quotes, like so:

```
$ bitcoin-cli createrawtransaction '[{"txid":"dbdc2e2c7f143af70c5e7e8725f55d226b3c058d7bf34a303091b3c6a514848c","vout":1}]' '{"1BCi1L25GC9hUSvtSyGjmEvSyywoYubk4P":0.00011}'
01000000018c8414a5c6b39130304af37b8d053c6b225df525877e5e0cf73a147f2c2edcdb0100000000ffffffff01f82a0000000000001976a9146fe8102ebe0fccb56de43ec82601ba16c68496af88ac00000000

```

The `bitcoin-tx` utility uses a shorthand that is deployed in the bitcoin unit tests. This example might help you use this command:

```
$ ./bitcoin-tx -create in=0fb9df5614be8b33be0434ce4062750d83f1b7ce05cc1296604f82eb9abf802b:0 outscript=0.00159999:"DUP HASH160 0x14 0x6793a38f79b8cd51dbb6face6dc75a4af5c1bf29 EQUALVERIFY CHECKSIG"
01000000012b80bf9aeb824f609612cc05ceb7f1830d756240ce3404be338bbe1456dfb90f0000000000ffffffff01ff700200000000001976a9146793a38f79b8cd51dbb6face6dc75a4af5c1bf2988ac00000000

```

The code for parsing the scripts can be found [here](https://github.com/bitcoin/bitcoin/blob/v0.10.0/src/core_read.cpp#L27). However, I find just looking at some examples in [the unit test data](https://github.com/bitcoin/bitcoin/blob/v0.10.0/src/test/data/tx_valid.json#L60) to be helpful as well.

> **Comments:**
> **username_3**: For DOS, you need to remove single quotes and escape double quotes... bitcoin-cli -regtest createrawtransaction [{\"txid\":\"c6343009c5d73572f750359480ae95170a00cfb41063f8cd70e1c14d06e8776c\",\"vout\":0}] {\"myf8U7KUzidun3WzjK2WM4nYVyE1ZkpSGH\":49.9999}  

---

