<p>Firstly, the raw unsigned transaction shouldn't actually have anything in the scriptSigs. They should be empty. You only add stuff to them during the signing process, then remove whatever was added.</p>

<p>For multiple inputs, each input actually signs its own input specific version of the transaction. For the input you are currently signing, you put the <code>scriptPubKey</code> of the output that input spends into the <code>scriptSig</code> as you did previously (and are doing now). However all of the other inputs need to have blank <code>scriptSig</code>s (i.e. they are <code>00</code>). So what you currently have is incorrect.</p>

<p>The result is that input 0 has its own "version" of the unsigned transaction where its <code>scriptSig</code> has the output's <code>scriptPubKey</code> and inputs 1, 2, and 3 have blank <code>scriptSigs</code>. Then you have another version for input 1 that has its output's <code>scriptPubKey</code> in the <code>scriptSig</code> and blank <code>scriptSigs</code> for inputs 0, 1, and 2. And so on for each input.</p>

<p>The keys involved in each input just sign their input's "version" of the transaction.</p>

CC BY-SA 4.0
2020-04-28T09:51:15.633Z
Thank you very much for the explanation. Now I finally understood the signing procedure. I could create, sign and broadcast a raw transaction with multiple UTXOs.
Bumblebee
CC BY-SA 4.0
2020-04-27T21:39:49.447Z
2020-04-27T21:39:49.447Z
Ava Chow
<p>You can refer to the documentation here: <a href="https://bitcoincore.org/en/doc/0.18.0/rpc/rawtransactions/createrawtransaction/" rel="nofollow noreferrer">https://bitcoincore.org/en/doc/0.18.0/rpc/rawtransactions/createrawtransaction/</a></p>

<p>Inputs are a JSON array of JSON objects </p>

<p><code>[]</code> = array<br>
<code>{}</code> = object<br>
<code>[{}]</code> = object in array</p>

<p>From the documentation:</p>

<p><code>createrawtransaction [{"txid":"hex","vout":n,"sequence":n},...]</code></p>

<p>The sequence is optional and ellipses <code>...</code> is where you would put your second input object so</p>

<p><code>createrawtransaction [{"txid":"hex","vout":n},{"txid":"hex","vout":n}]</code></p>

<p>Each new input requires a new <code>{}</code>object in the array. Please note the above wouldn't work without an output which I left out the output portion as this example was just for multiple inputs. </p>

<p>Below is a full example with two inputs and one output (beware of your change!) in testnet </p>

<p><code>createrawtransaction [{"txid":"1e1a0111ac4a918066d16180e397dea5537f934af1b4924105d27df48719b2c9","vout":0},{"txid":"c3877645f62f91b6fd5016ce9124acdc16b0a52f3b311c143a9e40e59618611b","vout":0}] [{"2N3peQ73BXhG9GDNVdAvWYpGBZZmr2ZqFeV":0.01}]</code></p>

CC BY-SA 4.0
2020-04-28T03:04:17.280Z
2020-04-28T03:04:17.280Z
m1xolyd1an
<p>I've successfully created, signed an broadcasted a raw transaction. But this transaction had just one input. Now I would like to create a raw transaction where I take the funds from multiple transactions.</p>

<p>Here are the UTXOs of the from address:</p>

<pre><code>{
    "address": "msJaKN7KCGARZrKWyy169GzztFLx7aTRBf",
    "amount": 0.001,
    "confirmations": 19,
    "label": "",
    "safe": true,
    "scriptPubKey": "76a914814a2c0bb0d155667341be55633e7351a7d5c57888ac",
    "solvable": false,
    "spendable": false,
    "txid": "0f5d09f4fa14f664e8fd55222e2e1e030afa0cf3b131d77e3bba7ef2a48a5580",
    "vout": 0
}
{
    "address": "msJaKN7KCGARZrKWyy169GzztFLx7aTRBf",
    "amount": 0.69735717,
    "confirmations": 16,
    "label": "",
    "safe": true,
    "scriptPubKey": "76a914814a2c0bb0d155667341be55633e7351a7d5c57888ac",
    "solvable": false,
    "spendable": false,
    "txid": "05ab7541fb9549707a8c467bc401a80e68461a4e31c416daf9f78169210a33d4",
    "vout": 1
}
{
    "address": "msJaKN7KCGARZrKWyy169GzztFLx7aTRBf",
    "amount": 0.01783446,
    "confirmations": 1031,
    "label": "",
    "safe": true,
    "scriptPubKey": "76a914814a2c0bb0d155667341be55633e7351a7d5c57888ac",
    "solvable": false,
    "spendable": false,
    "txid": "ccd36c5467ad0d9d1fa4f4d081020c066f1fa7ab9b734d9b0cc90b491eeeabdc",
    "vout": 0
}
{
    "address": "msJaKN7KCGARZrKWyy169GzztFLx7aTRBf",
    "amount": 0.005,
    "confirmations": 409,
    "label": "",
    "safe": true,
    "scriptPubKey": "76a914814a2c0bb0d155667341be55633e7351a7d5c57888ac",
    "solvable": false,
    "spendable": false,
    "txid": "7a2c020179f721b5321b58d3fcbb2988dbe4db905e174e918bd936a4e8a10ff8",
    "vout": 1
}
</code></pre>

<p>My unsigned raw transactions looks like this:</p>

<pre><code>010000000480558aa4f27eba3b7ed731b1f30cfa0a031e2e2e2255fde864f614faf4095d0f000000001976a914814a2c0bb0d155667341be55633e7351a7d5c57888acffffffffd4330a216981f7f9da16c4314e1a46680ea801c47b468c7a704995fb4175ab05010000001976a914814a2c0bb0d155667341be55633e7351a7d5c57888acffffffffdcabee1e490bc90c9b4d739baba71f6f060c0281d0f4a41f9d0dad67546cd3cc000000001976a914814a2c0bb0d155667341be55633e7351a7d5c57888acfffffffff80fa1e8a436d98b914e175e90dbe4db8829bbfcd3581b32b521f77901022c7a010000001976a914814a2c0bb0d155667341be55633e7351a7d5c57888acffffffff02801d2c04000000001976a91459fe1a9f9f0a5af33396c59990f064be1ca5127488acdb072000000000001976a914814a2c0bb0d155667341be55633e7351a7d5c57888ac00000000
</code></pre>

<pre><code>{
    "error": null,
    "id": "1",
    "result": {
        "hash": "c705c781ba6e131ec419582908ef607b628276948bd90f0d136b29a3c9524ff7",
        "locktime": 0,
        "size": 342,
        "txid": "c705c781ba6e131ec419582908ef607b628276948bd90f0d136b29a3c9524ff7",
        "version": 1,
        "vin": [
            {
                "scriptSig": {
                    "asm": "OP_DUP OP_HASH160 814a2c0bb0d155667341be55633e7351a7d5c578 OP_EQUALVERIFY OP_CHECKSIG",
                    "hex": "76a914814a2c0bb0d155667341be55633e7351a7d5c57888ac"
                },
                "sequence": 4294967295,
                "txid": "0f5d09f4fa14f664e8fd55222e2e1e030afa0cf3b131d77e3bba7ef2a48a5580",
                "vout": 0
            },
            {
                "scriptSig": {
                    "asm": "OP_DUP OP_HASH160 814a2c0bb0d155667341be55633e7351a7d5c578 OP_EQUALVERIFY OP_CHECKSIG",
                    "hex": "76a914814a2c0bb0d155667341be55633e7351a7d5c57888ac"
                },
                "sequence": 4294967295,
                "txid": "05ab7541fb9549707a8c467bc401a80e68461a4e31c416daf9f78169210a33d4",
                "vout": 1
            },
            {
                "scriptSig": {
                    "asm": "OP_DUP OP_HASH160 814a2c0bb0d155667341be55633e7351a7d5c578 OP_EQUALVERIFY OP_CHECKSIG",
                    "hex": "76a914814a2c0bb0d155667341be55633e7351a7d5c57888ac"
                },
                "sequence": 4294967295,
                "txid": "ccd36c5467ad0d9d1fa4f4d081020c066f1fa7ab9b734d9b0cc90b491eeeabdc",
                "vout": 0
            },
            {
                "scriptSig": {
                    "asm": "OP_DUP OP_HASH160 814a2c0bb0d155667341be55633e7351a7d5c578 OP_EQUALVERIFY OP_CHECKSIG",
                    "hex": "76a914814a2c0bb0d155667341be55633e7351a7d5c57888ac"
                },
                "sequence": 4294967295,
                "txid": "7a2c020179f721b5321b58d3fcbb2988dbe4db905e174e918bd936a4e8a10ff8",
                "vout": 1
            }
        ],
        "vout": [
            {
                "n": 0,
                "scriptPubKey": {
                    "addresses": [
                        "moinqaiuWShfsemB9nGcAGFZNMa3ZwPMq6"
                    ],
                    "asm": "OP_DUP OP_HASH160 59fe1a9f9f0a5af33396c59990f064be1ca51274 OP_EQUALVERIFY OP_CHECKSIG",
                    "hex": "76a91459fe1a9f9f0a5af33396c59990f064be1ca5127488ac",
                    "reqSigs": 1,
                    "type": "pubkeyhash"
                },
                "value": 0.7
            },
            {
                "n": 1,
                "scriptPubKey": {
                    "addresses": [
                        "msJaKN7KCGARZrKWyy169GzztFLx7aTRBf"
                    ],
                    "asm": "OP_DUP OP_HASH160 814a2c0bb0d155667341be55633e7351a7d5c578 OP_EQUALVERIFY OP_CHECKSIG",
                    "hex": "76a914814a2c0bb0d155667341be55633e7351a7d5c57888ac",
                    "reqSigs": 1,
                    "type": "pubkeyhash"
                },
                "value": 0.02099163
            }
        ],
        "vsize": 342,
        "weight": 1368
    }
}
</code></pre>

<p>I don't really know how the vin has to look like. My solution is obviously wrong.</p>

<p>How do the vins in the unsigned transaction to look like?</p>

<p>How do the vins in the signed transaction have to look like?</p>

<bitcoin-core>
How does vin[] have to look like with multiple inputs in a raw transaction?
Bumblebee
# How does vin[] have to look like with multiple inputs in a raw transaction?

(Asked by: username_0 on 2020-04-27)

I've successfully created, signed an broadcasted a raw transaction. But this transaction had just one input. Now I would like to create a raw transaction where I take the funds from multiple transactions.

Here are the UTXOs of the from address:

```
{
    "address": "msJaKN7KCGARZrKWyy169GzztFLx7aTRBf",
    "amount": 0.001,
    "confirmations": 19,
    "label": "",
    "safe": true,
    "scriptPubKey": "76a914814a2c0bb0d155667341be55633e7351a7d5c57888ac",
    "solvable": false,
    "spendable": false,
    "txid": "0f5d09f4fa14f664e8fd55222e2e1e030afa0cf3b131d77e3bba7ef2a48a5580",
    "vout": 0
}
{
    "address": "msJaKN7KCGARZrKWyy169GzztFLx7aTRBf",
    "amount": 0.69735717,
    "confirmations": 16,
    "label": "",
    "safe": true,
    "scriptPubKey": "76a914814a2c0bb0d155667341be55633e7351a7d5c57888ac",
    "solvable": false,
    "spendable": false,
    "txid": "05ab7541fb9549707a8c467bc401a80e68461a4e31c416daf9f78169210a33d4",
    "vout": 1
}
{
    "address": "msJaKN7KCGARZrKWyy169GzztFLx7aTRBf",
    "amount": 0.01783446,
    "confirmations": 1031,
    "label": "",
    "safe": true,
    "scriptPubKey": "76a914814a2c0bb0d155667341be55633e7351a7d5c57888ac",
    "solvable": false,
    "spendable": false,
    "txid": "ccd36c5467ad0d9d1fa4f4d081020c066f1fa7ab9b734d9b0cc90b491eeeabdc",
    "vout": 0
}
{
    "address": "msJaKN7KCGARZrKWyy169GzztFLx7aTRBf",
    "amount": 0.005,
    "confirmations": 409,
    "label": "",
    "safe": true,
    "scriptPubKey": "76a914814a2c0bb0d155667341be55633e7351a7d5c57888ac",
    "solvable": false,
    "spendable": false,
    "txid": "7a2c020179f721b5321b58d3fcbb2988dbe4db905e174e918bd936a4e8a10ff8",
    "vout": 1
}

```

My unsigned raw transactions looks like this:

```
010000000480558aa4f27eba3b7ed731b1f30cfa0a031e2e2e2255fde864f614faf4095d0f000000001976a914814a2c0bb0d155667341be55633e7351a7d5c57888acffffffffd4330a216981f7f9da16c4314e1a46680ea801c47b468c7a704995fb4175ab05010000001976a914814a2c0bb0d155667341be55633e7351a7d5c57888acffffffffdcabee1e490bc90c9b4d739baba71f6f060c0281d0f4a41f9d0dad67546cd3cc000000001976a914814a2c0bb0d155667341be55633e7351a7d5c57888acfffffffff80fa1e8a436d98b914e175e90dbe4db8829bbfcd3581b32b521f77901022c7a010000001976a914814a2c0bb0d155667341be55633e7351a7d5c57888acffffffff02801d2c04000000001976a91459fe1a9f9f0a5af33396c59990f064be1ca5127488acdb072000000000001976a914814a2c0bb0d155667341be55633e7351a7d5c57888ac00000000

```

```
{
    "error": null,
    "id": "1",
    "result": {
        "hash": "c705c781ba6e131ec419582908ef607b628276948bd90f0d136b29a3c9524ff7",
        "locktime": 0,
        "size": 342,
        "txid": "c705c781ba6e131ec419582908ef607b628276948bd90f0d136b29a3c9524ff7",
        "version": 1,
        "vin": [
            {
                "scriptSig": {
                    "asm": "OP_DUP OP_HASH160 814a2c0bb0d155667341be55633e7351a7d5c578 OP_EQUALVERIFY OP_CHECKSIG",
                    "hex": "76a914814a2c0bb0d155667341be55633e7351a7d5c57888ac"
                },
                "sequence": 4294967295,
                "txid": "0f5d09f4fa14f664e8fd55222e2e1e030afa0cf3b131d77e3bba7ef2a48a5580",
                "vout": 0
            },
            {
                "scriptSig": {
                    "asm": "OP_DUP OP_HASH160 814a2c0bb0d155667341be55633e7351a7d5c578 OP_EQUALVERIFY OP_CHECKSIG",
                    "hex": "76a914814a2c0bb0d155667341be55633e7351a7d5c57888ac"
                },
                "sequence": 4294967295,
                "txid": "05ab7541fb9549707a8c467bc401a80e68461a4e31c416daf9f78169210a33d4",
                "vout": 1
            },
            {
                "scriptSig": {
                    "asm": "OP_DUP OP_HASH160 814a2c0bb0d155667341be55633e7351a7d5c578 OP_EQUALVERIFY OP_CHECKSIG",
                    "hex": "76a914814a2c0bb0d155667341be55633e7351a7d5c57888ac"
                },
                "sequence": 4294967295,
                "txid": "ccd36c5467ad0d9d1fa4f4d081020c066f1fa7ab9b734d9b0cc90b491eeeabdc",
                "vout": 0
            },
            {
                "scriptSig": {
                    "asm": "OP_DUP OP_HASH160 814a2c0bb0d155667341be55633e7351a7d5c578 OP_EQUALVERIFY OP_CHECKSIG",
                    "hex": "76a914814a2c0bb0d155667341be55633e7351a7d5c57888ac"
                },
                "sequence": 4294967295,
                "txid": "7a2c020179f721b5321b58d3fcbb2988dbe4db905e174e918bd936a4e8a10ff8",
                "vout": 1
            }
        ],
        "vout": [
            {
                "n": 0,
                "scriptPubKey": {
                    "addresses": [
                        "moinqaiuWShfsemB9nGcAGFZNMa3ZwPMq6"
                    ],
                    "asm": "OP_DUP OP_HASH160 59fe1a9f9f0a5af33396c59990f064be1ca51274 OP_EQUALVERIFY OP_CHECKSIG",
                    "hex": "76a91459fe1a9f9f0a5af33396c59990f064be1ca5127488ac",
                    "reqSigs": 1,
                    "type": "pubkeyhash"
                },
                "value": 0.7
            },
            {
                "n": 1,
                "scriptPubKey": {
                    "addresses": [
                        "msJaKN7KCGARZrKWyy169GzztFLx7aTRBf"
                    ],
                    "asm": "OP_DUP OP_HASH160 814a2c0bb0d155667341be55633e7351a7d5c578 OP_EQUALVERIFY OP_CHECKSIG",
                    "hex": "76a914814a2c0bb0d155667341be55633e7351a7d5c57888ac",
                    "reqSigs": 1,
                    "type": "pubkeyhash"
                },
                "value": 0.02099163
            }
        ],
        "vsize": 342,
        "weight": 1368
    }
}

```

I don't really know how the vin has to look like. My solution is obviously wrong.

How do the vins in the unsigned transaction to look like?

How do the vins in the signed transaction have to look like?

**Tags:** bitcoin-core


---

## 2 answers

### Answer by username_1 on 2020-04-27. Score: 3 | Accepted answer

Firstly, the raw unsigned transaction shouldn't actually have anything in the scriptSigs. They should be empty. You only add stuff to them during the signing process, then remove whatever was added.

For multiple inputs, each input actually signs its own input specific version of the transaction. For the input you are currently signing, you put the `scriptPubKey` of the output that input spends into the `scriptSig` as you did previously (and are doing now). However all of the other inputs need to have blank `scriptSig`s (i.e. they are `00`). So what you currently have is incorrect.

The result is that input 0 has its own "version" of the unsigned transaction where its `scriptSig` has the output's `scriptPubKey` and inputs 1, 2, and 3 have blank `scriptSigs`. Then you have another version for input 1 that has its output's `scriptPubKey` in the `scriptSig` and blank `scriptSigs` for inputs 0, 1, and 2. And so on for each input.

The keys involved in each input just sign their input's "version" of the transaction.

> **Comments:**
> **username_0**: Thank you very much for the explanation. Now I finally understood the signing procedure. I could create, sign and broadcast a raw transaction with multiple UTXOs.  

---

### Answer by username_2 on 2020-04-28. Score: 1

You can refer to the documentation here: <https://bitcoincore.org/en/doc/0.18.0/rpc/rawtransactions/createrawtransaction/>

Inputs are a JSON array of JSON objects

`[]` = array  
`{}` = object  
`[{}]` = object in array

From the documentation:

`createrawtransaction [{"txid":"hex","vout":n,"sequence":n},...]`

The sequence is optional and ellipses `...` is where you would put your second input object so

`createrawtransaction [{"txid":"hex","vout":n},{"txid":"hex","vout":n}]`

Each new input requires a new `{}`object in the array. Please note the above wouldn't work without an output which I left out the output portion as this example was just for multiple inputs.

Below is a full example with two inputs and one output (beware of your change!) in testnet

`createrawtransaction [{"txid":"1e1a0111ac4a918066d16180e397dea5537f934af1b4924105d27df48719b2c9","vout":0},{"txid":"c3877645f62f91b6fd5016ce9124acdc16b0a52f3b311c143a9e40e59618611b","vout":0}] [{"2N3peQ73BXhG9GDNVdAvWYpGBZZmr2ZqFeV":0.01}]`


---

