Transactions

可替換交易或不可替換。如何從原始交易中辨識它?

  • April 23, 2017

我在 Electrum Mac 客戶端上創建了兩個事務。第一個事務是可替換的,另一個是不可替換的。以下是兩個交易的get-rawtransaction的結果。如何從兩個原始事務中辨識是否可替換。我猜“sequence=4294967295”的意思是不可替換的。

可更換:

{
   "result": {
       "hex": "0100000001344620a6c74ecc9df79d035f6c470c9fcada00e6103b8aa6da55b2eced1161f7000000006a473044022039a9d24c53605797c7fe74f69e97564b6e9346779ce32e208624049011fcbc04022010d481a6ca5aa88e0891b30caba160675ad21bf29dffa6bee63c2e6c98ac43bb01210228a0fc2a9872fab14eab65f3994089c2c285a549dbcbf0924788fee759960a96fdffffff0210270000000000001976a9141485d9d03b41aaa9dca7d70d7f63ff4a0826100e88acc0a20100000000001976a914e6df3a7f505b79b8da79c6fc6f5444ffe843f5f588ac00000000",
       "txid": "43f882c7ab0cf18678b171a69278cd496a85152bd88b66b73562601485ff3725",
       "hash": "43f882c7ab0cf18678b171a69278cd496a85152bd88b66b73562601485ff3725",
       "size": 225,
       "vsize": 225,
       "version": 1,
       "locktime": 0,
       "vin": [
           {
               "txid": "f76111edecb255daa68a3b10e600daca9f0c476c5f039df79dcc4ec7a6204634",
               "vout": 0,
               "scriptSig": {
                   "asm": "3044022039a9d24c53605797c7fe74f69e97564b6e9346779ce32e208624049011fcbc04022010d481a6ca5aa88e0891b30caba160675ad21bf29dffa6bee63c2e6c98ac43bb[ALL] 0228a0fc2a9872fab14eab65f3994089c2c285a549dbcbf0924788fee759960a96",
                   "hex": "473044022039a9d24c53605797c7fe74f69e97564b6e9346779ce32e208624049011fcbc04022010d481a6ca5aa88e0891b30caba160675ad21bf29dffa6bee63c2e6c98ac43bb01210228a0fc2a9872fab14eab65f3994089c2c285a549dbcbf0924788fee759960a96"
               },
               "sequence": 4294967293
           }
       ],
       "vout": [
           {
               "value": 0.00010000,
               "n": 0,
               "scriptPubKey": {
                   "asm": "OP_DUP OP_HASH160 1485d9d03b41aaa9dca7d70d7f63ff4a0826100e OP_EQUALVERIFY OP_CHECKSIG",
                   "hex": "76a9141485d9d03b41aaa9dca7d70d7f63ff4a0826100e88ac",
                   "reqSigs": 1,
                   "type": "pubkeyhash",
                   "addresses": [
                       "12sWrxRY7E7Nhmuyjbz4TtGE9jRewGqEZD"
                   ]
               }
           },
           {
               "value": 0.00107200,
               "n": 1,
               "scriptPubKey": {
                   "asm": "OP_DUP OP_HASH160 e6df3a7f505b79b8da79c6fc6f5444ffe843f5f5 OP_EQUALVERIFY OP_CHECKSIG",
                   "hex": "76a914e6df3a7f505b79b8da79c6fc6f5444ffe843f5f588ac",
                   "reqSigs": 1,
                   "type": "pubkeyhash",
                   "addresses": [
                       "1N3jqJwykPZGrskiDi2UujWgmaiPqdcaPz"
                   ]
               }
           }
       ]
   },
   "error": null,
   "id": null
}

不可更換:

{
   "result": {
       "hex": "01000000017502aa8b1662b3974e9f36a308d993e5de6d9acc0a417789f763c77cc1b8774b010000006b483045022100c716b5d6d23e6e980a1be76b62033d4d4213e6308684ef18c02449e9c687581d0220565c89f68fd9f220b6007950da1264e1c29edce8caf2600889b5f22f6e6e69fd012102078eb65f8cdfac159ba9babf0fd28b74477ed1ac108a7ec7f50c3c8b0e05647cffffffff0210270000000000001976a9141485d9d03b41aaa9dca7d70d7f63ff4a0826100e88acfc020100000000001976a914beb0e18e168aab7a1b9601430dd317c1c18b286b88ac00000000",
       "txid": "c374698cff5c784f2af87a637ee9ff571bd2951baecf1942ab377002a599cc16",
       "hash": "c374698cff5c784f2af87a637ee9ff571bd2951baecf1942ab377002a599cc16",
       "size": 226,
       "vsize": 226,
       "version": 1,
       "locktime": 0,
       "vin": [
           {
               "txid": "4b77b8c17cc763f78977410acc9a6ddee593d908a3369f4e97b362168baa0275",
               "vout": 1,
               "scriptSig": {
                   "asm": "3045022100c716b5d6d23e6e980a1be76b62033d4d4213e6308684ef18c02449e9c687581d0220565c89f68fd9f220b6007950da1264e1c29edce8caf2600889b5f22f6e6e69fd[ALL] 02078eb65f8cdfac159ba9babf0fd28b74477ed1ac108a7ec7f50c3c8b0e05647c",
                   "hex": "483045022100c716b5d6d23e6e980a1be76b62033d4d4213e6308684ef18c02449e9c687581d0220565c89f68fd9f220b6007950da1264e1c29edce8caf2600889b5f22f6e6e69fd012102078eb65f8cdfac159ba9babf0fd28b74477ed1ac108a7ec7f50c3c8b0e05647c"
               },
               "sequence": 4294967295
           }
       ],
       "vout": [
           {
               "value": 0.00010000,
               "n": 0,
               "scriptPubKey": {
                   "asm": "OP_DUP OP_HASH160 1485d9d03b41aaa9dca7d70d7f63ff4a0826100e OP_EQUALVERIFY OP_CHECKSIG",
                   "hex": "76a9141485d9d03b41aaa9dca7d70d7f63ff4a0826100e88ac",
                   "reqSigs": 1,
                   "type": "pubkeyhash",
                   "addresses": [
                       "12sWrxRY7E7Nhmuyjbz4TtGE9jRewGqEZD"
                   ]
               }
           },
           {
               "value": 0.00066300,
               "n": 1,
               "scriptPubKey": {
                   "asm": "OP_DUP OP_HASH160 beb0e18e168aab7a1b9601430dd317c1c18b286b OP_EQUALVERIFY OP_CHECKSIG",
                   "hex": "76a914beb0e18e168aab7a1b9601430dd317c1c18b286b88ac",
                   "reqSigs": 1,
                   "type": "pubkeyhash",
                   "addresses": [
                       "1JPHHMtzGbATPDKWtSwX9cZ7qq3KNLg1qZ"
                   ]
               }
           }
       ]
   },
   "error": null,
   "id": null
}

來自BIP-125 Opt-in Full Replace-by-Fee Signaling:

該策略指定事務可以用兩種方式表示它是可替換的。

  • 顯式信號:如果任何輸入的 nSequence 數小於 (0xffffffff - 1),則認為交易已選擇允許替換自身。
  • 繼承的信號:沒有明確表示可替換性的事務在此策略下是可替換的,只要它們的任何一個祖先發出可替換性信號並且仍未確認。

因為 0xffffffff = 4294967295,並且第一筆交易有nSequence = 4294967293,所以它發出信號。

引用自:https://bitcoin.stackexchange.com/questions/52933