4

Here's an example of a SegWit transaction that also contains data in the ScriptSig field:

{
  "txid": "954f43dbb30ad8024981c07d1f5eb6c9fd461e2cf1760dd1283f052af746fc88",
  "hash": "a5947589e2762107ff650958ba0e3a3cf341f53281d15593530bf9762c4edab1",
  "size": 231,
  "vsize": 148,
  "version": 1,
  "locktime": 0,
  "vin": [
    {
      "txid": "56f87210814c8baef7068454e517a70da2f2103fc3ac7f687e32a228dc80e115",
      "vout": 4,
      "scriptSig": {
        "asm": "002001d5d92effa6ffba3efa379f9830d0f75618b13393827152d26e4309000e88b1",
        "hex": "22002001d5d92effa6ffba3efa379f9830d0f75618b13393827152d26e4309000e88b1"
      },
      "txinwitness": [
        "3044022038421164c6468c63dc7bf724aa9d48d8e5abe3935564d38182addf733ad4cd81022076362326b22dd7bfaf211d5b17220723659e4fe3359740ced5762d0e497b7dcc01", 
        "21038262a6c6cec93c2d3ecd6c6072efea86d02ff8e3328bbd0242b20af3425990acac"
      ],
      "sequence": 4294967295
    }
  ],

If the txinwitness is the new location for the "unlocking script" section for a vin (as opposed to the old scriptSig field), then why would this transaction still have data in its scriptSig field?

inersha
  • 3,063
  • 1
  • 17
  • 41

2 Answers2

3

The reason is that for now, no native segwit address format exists, so transactions cannot be sent directly to segwit outputs. A proposal for native segwit addresses was created, but it won't be usable until all senders and receivers support it.

Instead, segwit-inside-P2SH is used, where outputs go to a BIP16 output with as hash script the hash of the witness program.

To spend such outputs, we must stay compatible with BIP16, and thus a scriptSig that reveals the full witness program is required. That is what you're seeing in this transaction: a BIP16 scriptSig, which reveals a witness program, which on its turn causes inspection of the witness data for the real verification.

Pieter Wuille
  • 105,497
  • 9
  • 194
  • 308
  • Are there any proposals for a native P2WPKH address format? Will such transactions be valid when segwit activates in 0.13.1? Or does all segwit have to be contained in P2SH for now? – pinhead Nov 05 '16 at 23:19
  • There is no address format for native P2WPKH, but it is included in BIP141, so such outputs are fully consensus valid and standard, there is just no way to ask a sender to construct such an output yet. I'm working on a proposal, though. – Pieter Wuille Nov 06 '16 at 00:20
0

segwit if a soft-fork, so it must be compatible with bip16. scriptSig contains a pushstack operation which hash is 2N5SJg3gxB8HNxjnj9ZyrLCTxKNrKGH5dHp

amaclin
  • 6,760
  • 1
  • 21
  • 32