<p>Modern transaction, since SegWit, include signatures in a new field: the witness. The witness replaces the scriptSig. You can see in your example how <code>txinwitness</code> contains a public key and a signature for the single input of your transaction.</p>
<p>Related: &quot;<a href="https://bitcoin.stackexchange.com/q/77180/101498">What is the Witness and what data does it contain?</a>&quot;.</p>

CC BY-SA 4.0
2023-05-11T12:52:21.020Z
What about legacy transactions?
Amir reza Riahi
CC BY-SA 4.0
2023-05-11T15:01:59.487Z
@AmirrezaRiahi In pre-segwit transaction inputs, the signature data is in the `scriptSig`. In segwit transaction inputs, the signature data is in the witness.
Pieter Wuille
CC BY-SA 4.0
2023-05-11T15:09:36.353Z
@PieterWuille Thanks for clarification
Amir reza Riahi
CC BY-SA 4.0
2023-05-11T15:11:02.097Z
The `scriptSig` is a per input entity, right? not for a whole transaction. My question is about the signature of the whole transaction.
Amir reza Riahi
CC BY-SA 4.0
2023-05-11T15:17:35.770Z
There is no such thing as a signature for the whole transaction. Signatutes are always per input.
Pieter Wuille
CC BY-SA 4.0
2023-05-11T15:36:45.077Z
@PieterWuille So how the input is protected against being used to another output? One can put a signed input and create another transaction and use that input in it.
Amir reza Riahi
CC BY-SA 4.0
2023-05-11T16:17:51.933Z
@AmirrezaRiahi Every signature (typically) signs *all* inputs (including itself) and *all* outputs. It just doesn't sign the *signatures* in those inputs.
Pieter Wuille
CC BY-SA 4.0
2023-05-11T09:18:27.787Z
2023-05-11T09:18:27.787Z
Antoine Poinsot
<p>To spend a UTXO, we need to sign it (have the <code>scriptSig</code>). Then we can spend that UTXO to any address we want, which it wasn't included in the signature we produced for unlocking the UTXO. So we should provide another signature to express our intention that we want to spend to this specific output[s]. Is this right?
When I try to observe a transaction using <code>bitcoin-cli</code> I don't see any signature for the whole transaction.</p>
<pre><code># bitcoin-cli -regtest  gettransaction 58abd7cda78c3140383bbf950420171b6e630f784d33392b968d9db7ea7d6c25
{
  &quot;amount&quot;: 0.00000000,
  &quot;fee&quot;: -0.00002820,
  &quot;confirmations&quot;: 0,
  &quot;trusted&quot;: true,
  &quot;txid&quot;: &quot;58abd7cda78c3140383bbf950420171b6e630f784d33392b968d9db7ea7d6c25&quot;,
  &quot;wtxid&quot;: &quot;40ef85dd2f2f54254f13c179b8fa18a247d493fd3f583ce4c0932754dfad89ed&quot;,
  &quot;walletconflicts&quot;: [
  ],
  &quot;time&quot;: 1683793800,
  &quot;timereceived&quot;: 1683793800,
  &quot;bip125-replaceable&quot;: &quot;yes&quot;,
  &quot;details&quot;: [
    {
      &quot;address&quot;: &quot;bcrt1qt3lltc5dx4gwmlcd0uqxkl85xrv7msfkmjyjts&quot;,
      &quot;category&quot;: &quot;send&quot;,
      &quot;amount&quot;: -12.34500000,
      &quot;label&quot;: &quot;&quot;,
      &quot;vout&quot;: 1,
      &quot;fee&quot;: -0.00002820,
      &quot;abandoned&quot;: false
    },
    {
      &quot;address&quot;: &quot;bcrt1qt3lltc5dx4gwmlcd0uqxkl85xrv7msfkmjyjts&quot;,
      &quot;parent_descs&quot;: [
        &quot;wpkh(tpubD6NzVbkrYhZ4YcCHtvXU4pzZAcAH2eet5KJvzXoxvjGGdBzAepGK3keAQS8pv1pQYyM4VdudgnmaDr4YXXemgdtKh4Yh5cbG3uCHV8q7Aub/84'/1'/0'/0/*)#h8mhq3zh&quot;
      ],
      &quot;category&quot;: &quot;receive&quot;,
      &quot;amount&quot;: 12.34500000,
      &quot;label&quot;: &quot;&quot;,
      &quot;vout&quot;: 1
    }
  ],
  &quot;hex&quot;: &quot;020000000001016c34e216d1f6821d91bc42e377290a7d30968da52c88678ecc2b47757ee8333d0000000000fdffffff025ced70e000000000160014bde66028298d70a6ec1bbb8e9c0a87f40db4c8d9a0f99449000000001600145c7ff5e28d3550edff0d7f006b7cf430d9edc136024730440220045193a2e68e19f815741f1b6338fc8c52d6808b5b63e387f1ef411e509bf78002207ab592b6d5bd9b47a6c0b4cdad119b05a43cb8274ecb5bffd16de881ecaa005d0121024bad563526f76fdbb915e7af18aed4ff8c48cf853440c2fda07076078d1c1346cb000000&quot;
}
</code></pre>
<pre><code># bitcoin-cli -regtest getblock 757783d237294945126b5966a46ddaf44e3ce04b0cd5bba726dc441dbadbb5be 2
{
  &quot;hash&quot;: &quot;757783d237294945126b5966a46ddaf44e3ce04b0cd5bba726dc441dbadbb5be&quot;,
  &quot;confirmations&quot;: 1,
  &quot;height&quot;: 204,
  &quot;version&quot;: 805306368,
  &quot;versionHex&quot;: &quot;30000000&quot;,
  &quot;merkleroot&quot;: &quot;b2de6af12b36d32bad5f358cabab6d5dee5d976568a5039f5fd7273ee0905afa&quot;,
  &quot;time&quot;: 1683795140,
  &quot;mediantime&quot;: 1683793734,
  &quot;nonce&quot;: 0,
  &quot;bits&quot;: &quot;207fffff&quot;,
  &quot;difficulty&quot;: 4.656542373906925e-10,
  &quot;chainwork&quot;: &quot;000000000000000000000000000000000000000000000000000000000000019a&quot;,
  &quot;nTx&quot;: 2,
  &quot;previousblockhash&quot;: &quot;2b6ce151ace43623880979d4b137e14865e07d59195b242fa273b13dd6b59c13&quot;,
  &quot;strippedsize&quot;: 327,
  &quot;size&quot;: 472,
  &quot;weight&quot;: 1453,
  &quot;tx&quot;: [
    {
      &quot;txid&quot;: &quot;860c1c07d52b2709e717780f1c91845ca338199da9eead89069ff458dc59e509&quot;,
      &quot;hash&quot;: &quot;957b22a4ce7df3e0b05bdf216f9ca14bd8f1bcae3ebc68870ef92035af941fe4&quot;,
      &quot;version&quot;: 2,
      &quot;size&quot;: 169,
      &quot;vsize&quot;: 142,
      &quot;weight&quot;: 568,
      &quot;locktime&quot;: 0,
      &quot;vin&quot;: [
        {
          &quot;coinbase&quot;: &quot;02cc0000&quot;,
          &quot;txinwitness&quot;: [
            &quot;0000000000000000000000000000000000000000000000000000000000000000&quot;
          ],
          &quot;sequence&quot;: 4294967295
        }
      ],
      &quot;vout&quot;: [
        {
          &quot;value&quot;: 25.00002820,
          &quot;n&quot;: 0,
          &quot;scriptPubKey&quot;: {
            &quot;asm&quot;: &quot;0 798fcf4772e285431c55ce67f2e0333f11d03f8b&quot;,
            &quot;desc&quot;: &quot;addr(bcrt1q0x8u73mju2z5x8z4eenl9cpn8ugaq0utj7n0jd)#nxvln3g4&quot;,
            &quot;hex&quot;: &quot;0014798fcf4772e285431c55ce67f2e0333f11d03f8b&quot;,
            &quot;address&quot;: &quot;bcrt1q0x8u73mju2z5x8z4eenl9cpn8ugaq0utj7n0jd&quot;,
            &quot;type&quot;: &quot;witness_v0_keyhash&quot;
          }
        },
        {
          &quot;value&quot;: 0.00000000,
          &quot;n&quot;: 1,


      &quot;weight&quot;: 561,
      &quot;locktime&quot;: 203,
      &quot;vin&quot;: [
        {
          &quot;txid&quot;: &quot;3d33e87e75472bcc8e67882ca58d96307d0a2977e342bc911d82f6d116e2346c&quot;,
          &quot;vout&quot;: 0,
          &quot;scriptSig&quot;: {
            &quot;asm&quot;: &quot;&quot;,
            &quot;hex&quot;: &quot;&quot;
          },
          &quot;txinwitness&quot;: [
            &quot;30440220045193a2e68e19f815741f1b6338fc8c52d6808b5b63e387f1ef411e509bf78002207ab592b6d5bd9b47a6c0b4cdad119b05a43cb8274ecb5bffd16de881ecaa005d01&quot;,
            &quot;024bad563526f76fdbb915e7af18aed4ff8c48cf853440c2fda07076078d1c1346&quot;
          ],
          &quot;sequence&quot;: 4294967293
        }
      ],
      &quot;vout&quot;: [
        {
          &quot;value&quot;: 37.65497180,
          &quot;n&quot;: 0,
          &quot;scriptPubKey&quot;: {
            &quot;asm&quot;: &quot;0 bde66028298d70a6ec1bbb8e9c0a87f40db4c8d9&quot;,
            &quot;desc&quot;: &quot;addr(bcrt1qhhnxq2pf34c2dmqmhw8fcz587sxmfjxef2k5ag)#x0qwx2ck&quot;,
            &quot;hex&quot;: &quot;0014bde66028298d70a6ec1bbb8e9c0a87f40db4c8d9&quot;,
            &quot;address&quot;: &quot;bcrt1qhhnxq2pf34c2dmqmhw8fcz587sxmfjxef2k5ag&quot;,
            &quot;type&quot;: &quot;witness_v0_keyhash&quot;
          }
        },
        {
          &quot;value&quot;: 12.34500000,
          &quot;n&quot;: 1,
          &quot;scriptPubKey&quot;: {
            &quot;asm&quot;: &quot;0 5c7ff5e28d3550edff0d7f006b7cf430d9edc136&quot;,
            &quot;desc&quot;: &quot;addr(bcrt1qt3lltc5dx4gwmlcd0uqxkl85xrv7msfkmjyjts)#f706enkn&quot;,
            &quot;hex&quot;: &quot;00145c7ff5e28d3550edff0d7f006b7cf430d9edc136&quot;,
            &quot;address&quot;: &quot;bcrt1qt3lltc5dx4gwmlcd0uqxkl85xrv7msfkmjyjts&quot;,
            &quot;type&quot;: &quot;witness_v0_keyhash&quot;
          }
        }
      ],
      &quot;fee&quot;: 0.00002820,
      &quot;hex&quot;: &quot;020000000001016c34e216d1f6821d91bc42e377290a7d30968da52c88678ecc2b47757ee8333d0000000000fdffffff025ced70e000000000160014bde66028298d70a6ec1bbb8e9c0a87f40db4c8d9a0f99449000000001600145c7ff5e28d3550edff0d7f006b7cf430d9edc136024730440220045193a2e68e19f815741f1b6338fc8c52d6808b5b63e387f1ef411e509bf78002207ab592b6d5bd9b47a6c0b4cdad119b05a43cb8274ecb5bffd16de881ecaa005d0121024bad563526f76fdbb915e7af18aed4ff8c48cf853440c2fda07076078d1c1346cb000000&quot;
    }
  ]
}
</code></pre>

<transactions><signature><input-script>
Where are transaction signatures beside the scriptSig?
Amir reza Riahi
# Where are transaction signatures beside the scriptSig?

(Asked by: username_0 on 2023-05-11)

To spend a UTXO, we need to sign it (have the `scriptSig`). Then we can spend that UTXO to any address we want, which it wasn't included in the signature we produced for unlocking the UTXO. So we should provide another signature to express our intention that we want to spend to this specific output[s]. Is this right?
When I try to observe a transaction using `bitcoin-cli` I don't see any signature for the whole transaction.

```
# bitcoin-cli -regtest  gettransaction 58abd7cda78c3140383bbf950420171b6e630f784d33392b968d9db7ea7d6c25
{
  "amount": 0.00000000,
  "fee": -0.00002820,
  "confirmations": 0,
  "trusted": true,
  "txid": "58abd7cda78c3140383bbf950420171b6e630f784d33392b968d9db7ea7d6c25",
  "wtxid": "40ef85dd2f2f54254f13c179b8fa18a247d493fd3f583ce4c0932754dfad89ed",
  "walletconflicts": [
  ],
  "time": 1683793800,
  "timereceived": 1683793800,
  "bip125-replaceable": "yes",
  "details": [
    {
      "address": "bcrt1qt3lltc5dx4gwmlcd0uqxkl85xrv7msfkmjyjts",
      "category": "send",
      "amount": -12.34500000,
      "label": "",
      "vout": 1,
      "fee": -0.00002820,
      "abandoned": false
    },
    {
      "address": "bcrt1qt3lltc5dx4gwmlcd0uqxkl85xrv7msfkmjyjts",
      "parent_descs": [
        "wpkh(tpubD6NzVbkrYhZ4YcCHtvXU4pzZAcAH2eet5KJvzXoxvjGGdBzAepGK3keAQS8pv1pQYyM4VdudgnmaDr4YXXemgdtKh4Yh5cbG3uCHV8q7Aub/84'/1'/0'/0/*)#h8mhq3zh"
      ],
      "category": "receive",
      "amount": 12.34500000,
      "label": "",
      "vout": 1
    }
  ],
  "hex": "020000000001016c34e216d1f6821d91bc42e377290a7d30968da52c88678ecc2b47757ee8333d0000000000fdffffff025ced70e000000000160014bde66028298d70a6ec1bbb8e9c0a87f40db4c8d9a0f99449000000001600145c7ff5e28d3550edff0d7f006b7cf430d9edc136024730440220045193a2e68e19f815741f1b6338fc8c52d6808b5b63e387f1ef411e509bf78002207ab592b6d5bd9b47a6c0b4cdad119b05a43cb8274ecb5bffd16de881ecaa005d0121024bad563526f76fdbb915e7af18aed4ff8c48cf853440c2fda07076078d1c1346cb000000"
}

```

```
# bitcoin-cli -regtest getblock 757783d237294945126b5966a46ddaf44e3ce04b0cd5bba726dc441dbadbb5be 2
{
  "hash": "757783d237294945126b5966a46ddaf44e3ce04b0cd5bba726dc441dbadbb5be",
  "confirmations": 1,
  "height": 204,
  "version": 805306368,
  "versionHex": "30000000",
  "merkleroot": "b2de6af12b36d32bad5f358cabab6d5dee5d976568a5039f5fd7273ee0905afa",
  "time": 1683795140,
  "mediantime": 1683793734,
  "nonce": 0,
  "bits": "207fffff",
  "difficulty": 4.656542373906925e-10,
  "chainwork": "000000000000000000000000000000000000000000000000000000000000019a",
  "nTx": 2,
  "previousblockhash": "2b6ce151ace43623880979d4b137e14865e07d59195b242fa273b13dd6b59c13",
  "strippedsize": 327,
  "size": 472,
  "weight": 1453,
  "tx": [
    {
      "txid": "860c1c07d52b2709e717780f1c91845ca338199da9eead89069ff458dc59e509",
      "hash": "957b22a4ce7df3e0b05bdf216f9ca14bd8f1bcae3ebc68870ef92035af941fe4",
      "version": 2,
      "size": 169,
      "vsize": 142,
      "weight": 568,
      "locktime": 0,
      "vin": [
        {
          "coinbase": "02cc0000",
          "txinwitness": [
            "0000000000000000000000000000000000000000000000000000000000000000"
          ],
          "sequence": 4294967295
        }
      ],
      "vout": [
        {
          "value": 25.00002820,
          "n": 0,
          "scriptPubKey": {
            "asm": "0 798fcf4772e285431c55ce67f2e0333f11d03f8b",
            "desc": "addr(bcrt1q0x8u73mju2z5x8z4eenl9cpn8ugaq0utj7n0jd)#nxvln3g4",
            "hex": "0014798fcf4772e285431c55ce67f2e0333f11d03f8b",
            "address": "bcrt1q0x8u73mju2z5x8z4eenl9cpn8ugaq0utj7n0jd",
            "type": "witness_v0_keyhash"
          }
        },
        {
          "value": 0.00000000,
          "n": 1,

      "weight": 561,
      "locktime": 203,
      "vin": [
        {
          "txid": "3d33e87e75472bcc8e67882ca58d96307d0a2977e342bc911d82f6d116e2346c",
          "vout": 0,
          "scriptSig": {
            "asm": "",
            "hex": ""
          },
          "txinwitness": [
            "30440220045193a2e68e19f815741f1b6338fc8c52d6808b5b63e387f1ef411e509bf78002207ab592b6d5bd9b47a6c0b4cdad119b05a43cb8274ecb5bffd16de881ecaa005d01",
            "024bad563526f76fdbb915e7af18aed4ff8c48cf853440c2fda07076078d1c1346"
          ],
          "sequence": 4294967293
        }
      ],
      "vout": [
        {
          "value": 37.65497180,
          "n": 0,
          "scriptPubKey": {
            "asm": "0 bde66028298d70a6ec1bbb8e9c0a87f40db4c8d9",
            "desc": "addr(bcrt1qhhnxq2pf34c2dmqmhw8fcz587sxmfjxef2k5ag)#x0qwx2ck",
            "hex": "0014bde66028298d70a6ec1bbb8e9c0a87f40db4c8d9",
            "address": "bcrt1qhhnxq2pf34c2dmqmhw8fcz587sxmfjxef2k5ag",
            "type": "witness_v0_keyhash"
          }
        },
        {
          "value": 12.34500000,
          "n": 1,
          "scriptPubKey": {
            "asm": "0 5c7ff5e28d3550edff0d7f006b7cf430d9edc136",
            "desc": "addr(bcrt1qt3lltc5dx4gwmlcd0uqxkl85xrv7msfkmjyjts)#f706enkn",
            "hex": "00145c7ff5e28d3550edff0d7f006b7cf430d9edc136",
            "address": "bcrt1qt3lltc5dx4gwmlcd0uqxkl85xrv7msfkmjyjts",
            "type": "witness_v0_keyhash"
          }
        }
      ],
      "fee": 0.00002820,
      "hex": "020000000001016c34e216d1f6821d91bc42e377290a7d30968da52c88678ecc2b47757ee8333d0000000000fdffffff025ced70e000000000160014bde66028298d70a6ec1bbb8e9c0a87f40db4c8d9a0f99449000000001600145c7ff5e28d3550edff0d7f006b7cf430d9edc136024730440220045193a2e68e19f815741f1b6338fc8c52d6808b5b63e387f1ef411e509bf78002207ab592b6d5bd9b47a6c0b4cdad119b05a43cb8274ecb5bffd16de881ecaa005d0121024bad563526f76fdbb915e7af18aed4ff8c48cf853440c2fda07076078d1c1346cb000000"
    }
  ]
}

```

**Tags:** transactions, signature, input-script


---

## 1 answers

### Answer by username_1 on 2023-05-11. Score: 3 | Accepted answer

Modern transaction, since SegWit, include signatures in a new field: the witness. The witness replaces the scriptSig. You can see in your example how `txinwitness` contains a public key and a signature for the single input of your transaction.

Related: "[What is the Witness and what data does it contain?](https://bitcoin.stackexchange.com/q/77180/101498)".

> **Comments:**
> **username_0**: What about legacy transactions?  
> **username_2**: @username_0 In pre-segwit transaction inputs, the signature data is in the `scriptSig`. In segwit transaction inputs, the signature data is in the witness.  
> **username_0**: @username_2 Thanks for clarification  
> **username_0**: The `scriptSig` is a per input entity, right? not for a whole transaction. My question is about the signature of the whole transaction.  
> **username_2**: There is no such thing as a signature for the whole transaction. Signatutes are always per input.  
> **username_0**: @username_2 So how the input is protected against being used to another output? One can put a signed input and create another transaction and use that input in it.  
> **username_2**: @username_0 Every signature (typically) signs *all* inputs (including itself) and *all* outputs. It just doesn't sign the *signatures* in those inputs.  

---

