Legacy와 Segwit 혼합 Transaction

Legacy + Segwit Transaction Serialization

아래는 Legacy Transaction과 Segwit Transaction이 혼합되어 있는 트랜잭션을 Serialization 하여 Binary 레벨의 Raw Data를 분석한 예이다.

Serialized Raw Data:
02000000000102e8f2c6239fce39bab19c17c3f46f8e0d0fada5b59429cd2339e3573be9efa901010000006b483045022100d8c95e75d77e1cb2c42d98a8d7d678b677bb0a16bc95cb428c9f66fc5081362102202af52593e2fffc9baecc920e9744b6e9f814454e2321fb3005b17e8f88f7a39c0121032e0ba6520d9874454e6f93cb8e0a7a88d235c1cc893260b840eb21dc6308cca5fdffffff625269071d3af9e1a97d0be7f082ff344ea0ea61a444d5f90680f8bcf12b78c30000000000fdffffff0200b70400000000001976a914eef735390f1e2a980763ca619b4ba327c626887688acd06c0400000000001600140162edc36c8f40c8c3d3b5e014cb525eaefe9b5e0002483045022100e21fa153074ba3715cb38b3bf56cd1fadfd271e23bc203484e5968240f76bf2a02207f4cdf0a4cb0c22072d1de5e56088b2a9ee17b16353bb8a5c381534f72bfb557012103e9f6f8060c67c98bfefc84e6ec4eb97378ac9d44d57b2f5276862eb63c53b2cf3c472500

Raw Data 분석:

02000000 (Version)
00 (Segwit Marker)
01 (Segwit Flag)
-- Inputs
02 (# of inputs)
e8f2c6239fce39bab19c17c3f46f8e0d0fada5b59429cd2339e3573be9efa901 (txid)
01000000 (vout)
6b       (scriptSigSize)
483045022100d8c95e75d77e1cb2c42d98a8d7d678b677bb0a16bc95cb428c9f66fc5081362102202af52593e2fffc9baecc920e9744b6e9f814454e2321fb3005b17e8f88f7a39c0121032e0ba6520d9874454e6f93cb8e0a7a88d235c1cc893260b840eb21dc6308cca5       (scriptSig)
fdffffff (sequence)
625269071d3af9e1a97d0be7f082ff344ea0ea61a444d5f90680f8bcf12b78c3 (txid)
00000000 (vout)
00       (scriptSig/segwit)
fdffffff (sequence)
-- Outputs
02 (# of outputs)
00b7040000000000 (amount)
1976a914eef735390f1e2a980763ca619b4ba327c626887688ac (scriptpubkey)
d06c040000000000 (amount)
1600140162edc36c8f40c8c3d3b5e014cb525eaefe9b5e (scriptpubkey)
-- Witnesses
00 (len/ empty for legacy tx)
02 48 3045022100e21fa153074ba3715cb38b3bf56cd1fadfd271e23bc203484e5968240f76bf2a02207f4cdf0a4cb0c22072d1de5e56088b2a9ee17b16353bb8a5c381534f72bfb557 (DER(sig))
    01 (sighash)
    21 03e9f6f8060c67c98bfefc84e6ec4eb97378ac9d44d57b2f5276862eb63c53b2cf (pubkey)
-- locktime
3c472500    

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

$ bitcoin-cli decoderawtransaction 02000000000102e8f2c6239fce39bab19c17c3f46f8e0d0fada5b59429cd2339e3573be9efa901010000006b483045022100d8c95e75d77e1cb2c42d98a8d7d678b677bb0a16bc95cb428c9f66fc5081362102202af52593e2fffc9baecc920e9744b6e9f814454e2321fb3005b17e8f88f7a39c0121032e0ba6520d9874454e6f93cb8e0a7a88d235c1cc893260b840eb21dc6308cca5fdffffff625269071d3af9e1a97d0be7f082ff344ea0ea61a444d5f90680f8bcf12b78c30000000000fdffffff0200b70400000000001976a914eef735390f1e2a980763ca619b4ba327c626887688acd06c0400000000001600140162edc36c8f40c8c3d3b5e014cb525eaefe9b5e0002483045022100e21fa153074ba3715cb38b3bf56cd1fadfd271e23bc203484e5968240f76bf2a02207f4cdf0a4cb0c22072d1de5e56088b2a9ee17b16353bb8a5c381534f72bfb557012103e9f6f8060c67c98bfefc84e6ec4eb97378ac9d44d57b2f5276862eb63c53b2cf3c472500
{
  "txid": "c5ddd8288a994996e3454074c67a092f65c0c8108e7c9571e3fa18314fb214f8",
  "hash": "e51db0ff6372afa57f2502bc66d1b701fa193d8f4e82bc048e320970a4d37499",
  "version": 2,
  "size": 375,
  "vsize": 292,
  "weight": 1167,
  "locktime": 2443068,
  "vin": [
    {
      "txid": "01a9efe93b57e33923cd2994b5a5ad0f0d8e6ff4c3179cb1ba39ce9f23c6f2e8",
      "vout": 1,
      "scriptSig": {
        "asm": "3045022100d8c95e75d77e1cb2c42d98a8d7d678b677bb0a16bc95cb428c9f66fc5081362102202af52593e2fffc9baecc920e9744b6e9f814454e2321fb3005b17e8f88f7a39c[ALL] 032e0ba6520d9874454e6f93cb8e0a7a88d235c1cc893260b840eb21dc6308cca5",
        "hex": "483045022100d8c95e75d77e1cb2c42d98a8d7d678b677bb0a16bc95cb428c9f66fc5081362102202af52593e2fffc9baecc920e9744b6e9f814454e2321fb3005b17e8f88f7a39c0121032e0ba6520d9874454e6f93cb8e0a7a88d235c1cc893260b840eb21dc6308cca5"
      },
      "sequence": 4294967293
    },
    {
      "txid": "c3782bf1bcf88006f9d544a461eaa04e34ff82f0e70b7da9e1f93a1d07695262",
      "vout": 0,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "txinwitness": [
        "3045022100e21fa153074ba3715cb38b3bf56cd1fadfd271e23bc203484e5968240f76bf2a02207f4cdf0a4cb0c22072d1de5e56088b2a9ee17b16353bb8a5c381534f72bfb55701",
        "03e9f6f8060c67c98bfefc84e6ec4eb97378ac9d44d57b2f5276862eb63c53b2cf"
      ],
      "sequence": 4294967293
    }
  ],
  "vout": [
    {
      "value": 0.00308992,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 eef735390f1e2a980763ca619b4ba327c6268876 OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a914eef735390f1e2a980763ca619b4ba327c626887688ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "n3JVG1sRb34x4mux1a3MQiMBRME1DPjA22"
        ]
      }
    },
    {
      "value": 0.00290000,
      "n": 1,
      "scriptPubKey": {
        "asm": "0 0162edc36c8f40c8c3d3b5e014cb525eaefe9b5e",
        "hex": "00140162edc36c8f40c8c3d3b5e014cb525eaefe9b5e",
        "reqSigs": 1,
        "type": "witness_v0_keyhash",
        "addresses": [
          "tb1qq93wmsmv3aqv3s7nkhspfj6jt6h0ax67dmldgx"
        ]
      }
    }
  ]
}

웰렛의 구현 방식에 따라 어떤 월렛은 이렇게 혼합된 트랜잭션을 Broadcast 하지 못할 수 있다. 참고로, Electrum에서 Load Transaction을 하여 Broadcasting 하는 것을 테스트 하였는데, 잘 동작하였다.

본 웹사이트는 광고를 포함하고 있습니다. 광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.