Segwit Transaction Serialization Layout

Segwit Transaction : Serialization Layout

아래는 Segwit Transaction을 Serialization 하여 Binary 레벨의 Raw Data를 분석한 예이다.

Serialized Raw Data:

020000000001027d5684d8326ae19ced71607ead23ae3f4b6207a884d9da930d8133d681b8d19d0100000000fdffffffe2720eea1685aa99fe0c3fe1cd005a25b4155392898175f629b2ac09d2e7c87b0100000000fdffffff028fe90000000000001600148e6b11d554d284aebf67e3582a51a3c7e8592879f049020000000000160014049f4ee16b3af12b1ba4a9f60a0dad7de27a0b5e02483045022100db12b12a7e01ab4bfce995dce861c0eea58724f67ef60c9d59c952dd8bc332d202207c8f6b84a1f99ee61f624dfa5182a0d5d65009f5cb859e22528e61bd5bc029360121022945a495fcc87c44e94f8bf1d6a07cda8503c47be1963f117f25d2c3980437100247304402207330a4907cd665d83210eede8a980355600129ece02de77b73947d470fd34c0f02204fc6e0b8502c0d00a314119e367c2cc01c70c29dc0d25d148fb60f3ce9b587ed0121026c5e0b668176c6d25820fc295fef8f482defe339c1bd3bf83a7e15b7baaacb1635432500
Raw Data 분석:

02000000 (Version)
00 (Segwit Marker)
01 (Segwit Flag)
-- Inputs
02 (# of inputs)
7d5684d8326ae19ced71607ead23ae3f4b6207a884d9da930d8133d681b8d19d (txid)
01000000 (vout)
00       (scriptSig)
fdffffff (sequence)
e2720eea1685aa99fe0c3fe1cd005a25b4155392898175f629b2ac09d2e7c87b (txid)
01000000 (vout)
00       (scriptSig)
fdffffff (sequence)
-- Outputs
02 (# of outputs)
8fe9000000000000 (amount)
1600148e6b11d554d284aebf67e3582a51a3c7e8592879 (scriptpubkey)
f049020000000000 (amount)
160014049f4ee16b3af12b1ba4a9f60a0dad7de27a0b5e (scriptpubkey)
-- Witnesses
02 (len)
    48 3045022100fda564cb29acad5d9463b4a581276f4c81cbd4e904d9e5c78fa354de94ac0858022060fb7839c6a8fd33e0df6fef9d0fcbb65621b7c7fec09cbce9d4d33abc45b615 (DER(sig))
    01 (sighash)
    21 022945a495fcc87c44e94f8bf1d6a07cda8503c47be1963f117f25d2c398043710 (pubkey)
02 48 3045022100d3b9e50b0418e8359d1ed722d1d7692ab917dfb5a64f0b9d28df34c05550a7ce0220700bccd400bed029c5a73627156e02a5e9ba6cae0dee79054e0cfa7257a8957c (DER(sig))
    01 (sighash)
    21 026c5e0b668176c6d25820fc295fef8f482defe339c1bd3bf83a7e15b7baaacb16 (pubkey)
-- locktime
35432500     

위의 Raw Binary 데이타를 Decode하면 아래와 같이 된다.

$ bitcoin-cli decoderawtransaction 020000000001027d5684d8326ae19ced71607ead23ae3f4b6207a884d9da930d8133d681b8d19d0100000000fdffffffe2720eea1685aa99fe0c3fe1cd005a25b4155392898175f629b2ac09d2e7c87b0100000000fdffffff028fe90000000000001600148e6b11d554d284aebf67e3582a51a3c7e8592879f049020000000000160014049f4ee16b3af12b1ba4a9f60a0dad7de27a0b5e02483045022100db12b12a7e01ab4bfce995dce861c0eea58724f67ef60c9d59c952dd8bc332d202207c8f6b84a1f99ee61f624dfa5182a0d5d65009f5cb859e22528e61bd5bc029360121022945a495fcc87c44e94f8bf1d6a07cda8503c47be1963f117f25d2c3980437100247304402207330a4907cd665d83210eede8a980355600129ece02de77b73947d470fd34c0f02204fc6e0b8502c0d00a314119e367c2cc01c70c29dc0d25d148fb60f3ce9b587ed0121026c5e0b668176c6d25820fc295fef8f482defe339c1bd3bf83a7e15b7baaacb1635432500   
{
    "txid": "e4f40acec1c374ca15a38b0909782d64b1a74bb4fcdf3c7f01bcfdf42405a6e1",
    "hash": "418eab22d4e4d0322c12951524bf830e048726dd77b8f701e710c6b6a0377d3c",
    "version": 2,
    "size": 371,
    "vsize": 209,
    "weight": 833,
    "locktime": 2442037,
    "vin": [
      {
        "txid": "9dd1b881d633810d93dad984a807624b3fae23ad7e6071ed9ce16a32d884567d",
        "vout": 1,
        "scriptSig": {
          "asm": "",
          "hex": ""
        },
        "txinwitness": [
          "3045022100db12b12a7e01ab4bfce995dce861c0eea58724f67ef60c9d59c952dd8bc332d202207c8f6b84a1f99ee61f624dfa5182a0d5d65009f5cb859e22528e61bd5bc0293601",
          "022945a495fcc87c44e94f8bf1d6a07cda8503c47be1963f117f25d2c398043710"
        ],
        "sequence": 4294967293
      },
      {
        "txid": "7bc8e7d209acb229f6758189925315b4255a00cde13f0cfe99aa8516ea0e72e2",
        "vout": 1,
        "scriptSig": {
          "asm": "",
          "hex": ""
        },
        "txinwitness": [
          "304402207330a4907cd665d83210eede8a980355600129ece02de77b73947d470fd34c0f02204fc6e0b8502c0d00a314119e367c2cc01c70c29dc0d25d148fb60f3ce9b587ed01",
          "026c5e0b668176c6d25820fc295fef8f482defe339c1bd3bf83a7e15b7baaacb16"
        ],
        "sequence": 4294967293
      }
    ],
    "vout": [
      {
        "value": 0.00059791,
        "n": 0,
        "scriptPubKey": {
          "asm": "0 8e6b11d554d284aebf67e3582a51a3c7e8592879",
          "hex": "00148e6b11d554d284aebf67e3582a51a3c7e8592879",
          "reqSigs": 1,
          "type": "witness_v0_keyhash",
          "addresses": [
            "tb1q3e43r42562z2a0m8udvz55drcl59j2rezqh5zl"
          ]
        }
      },
      {
        "value": 0.00150000,
        "n": 1,
        "scriptPubKey": {
          "asm": "0 049f4ee16b3af12b1ba4a9f60a0dad7de27a0b5e",
          "hex": "0014049f4ee16b3af12b1ba4a9f60a0dad7de27a0b5e",
          "reqSigs": 1,
          "type": "witness_v0_keyhash",
          "addresses": [
            "tb1qqj05actt8tcjkxay48mq5rdd0h385z6788rg4z"
          ]
        }
      }
    ]
  }
본 웹사이트는 광고를 포함하고 있습니다. 광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.