如何生成比特幣現金雜湊原像?
我正在嘗試手動生成一個簽名交易,該交易將從我的新地址格式的地址
1GiJZtN7wjUuL4V5i7ZYYDAvFtqi5AhCDr
發送。bitcoincash:qzk9nxh6qpd9yt3hvv6vvun78s834f3escdhu2vdjp
我在此交易中使用未壓縮的公鑰。我有以下未簽名的比特幣現金交易。如何找到它的散列原像,即在此交易簽名中使用的散列?
010000000001FB4A8E5C7AC5311F32FBE127F031134EE3E7490F3308CA19C567F78D6AA966050000000000福絡甜燈0100a000000〜8000000/19360000/193686066CA850000福絡絡0100000000福絡絡0100a100007606665C250076066CA8FB36CE093692BE886CE093692BE88AC00000000
分解它,它看起來像這樣:
01000000
- n版本
01
- 輸入數量
fb4a8e5c7ac5311f32fbe127f031134ee3e7490f3308ca19c567f78d6aa96d77
- txid (little-endian)
00000000
- 投票
00
- sigScript 的大小
ffffffff
- 序列號
01
- 輸出數量
00a0070000000000
- 數量(十六進制,小端)
1976a914a8e181e0847b495df439066ca8fb36ce093692be88ac
- scriptPubKey
00000000
- 時間鎖定我正在嘗試使用 txid: 消耗
776da96a8df767c519ca08330f49e7e34e1331f027e1fb321f31c57a5c8e4afb
交易的輸出 0,該交易的輸出 0 的 scriptPubKey 是:1976a914ac599afa005a522e376334c6727e3c0f1aa6398688ac
接收輸出的值為 0.005 BCH
我試圖消耗的交易可以在這裡找到: https://bch.btc.com/776da96a8df767c519ca08330f49e7e34e1331f027e1fb321f31c57a5c8e4afb 而對於我想消費交易的rawtx是在這裡: https://bch.btc.com/776da96a8df767c519ca08330f49e7e34e1331f027e1fb321f31c57a5c8e4afb.rawhex
有誰能夠幫我?
比特幣現金使用BIP 143來創建簽名雜湊。
來自 BIP:
Double SHA256 of the serialization of: 1. nVersion of the transaction (4-byte little endian) 2. hashPrevouts (32-byte hash) 3. hashSequence (32-byte hash) 4. outpoint (32-byte hash + 4-byte little endian) 5. scriptCode of the input (serialized as scripts inside CTxOuts) 6. value of the output spent by this input (8-byte little endian) 7. nSequence of the input (4-byte little endian) 8. hashOutputs (32-byte hash) 9. nLocktime of the transaction (4-byte little endian) 10. sighash type of the signature (4-byte little endian)
所以雜湊原像將如下所示:
01000000be16f25831b40c713fed6627e39aa7717170f5cdd62c765bd4882abbefdaa50e3bb13029ce7b1f559ef5e747fcac439f1455a2ec7c5f09b72290795e70665044fb4a8e5c7ac5311f32fbe127f031134ee3e7490f3308ca19c567f78d6aa96d77000000001976a914ac599afa005a522e376334c6727e3c0f1aa6398688ac20a1070000000000ffffffffc8e2e71fe663fc91d7aa109feffee0f1497862af35525f68f500cbd55f6ed6620000000041000000
這是它的細分:
nVersion: 01000000 hashPrevouts: be16f25831b40c713fed6627e39aa7717170f5cdd62c765bd4882abbefdaa50e hashSequence: 3bb13029ce7b1f559ef5e747fcac439f1455a2ec7c5f09b72290795e70665044 outpoint: fb4a8e5c7ac5311f32fbe127f031134ee3e7490f3308ca19c567f78d6aa96d7700000000 scriptCode: 1976a914ac599afa005a522e376334c6727e3c0f1aa6398688ac value: 20a1070000000000 nSequence: ffffffff hashOutputs: c8e2e71fe663fc91d7aa109feffee0f1497862af35525f68f500cbd55f6ed662 nLocktime: 00000000 sighash: 41000000