What's the purpose of ScriptSig in a SegWit transaction?

2

1

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

Posted 2016-11-01T15:40:19.023

Reputation: 2 236

I think its to store the hash of signature. I am not completely sure though.abeikverdi 2016-11-01T17:38:18.050

Answers

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

Posted 2016-11-01T15:40:19.023

Reputation: 54 032

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 2016-11-05T23:19:07.790

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 2016-11-06T00:20:54.187

0

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

amaclin

Posted 2016-11-01T15:40:19.023

Reputation: 5 763