Segregated-Witness

隔離見證交易廣播錯誤

  • January 22, 2022

我有我創建的這個測試網事務:

Version: 01000000
Marker: 00
Flag: 01
Input Count: 01
   Input #1 TXID: 42a752fe4ebd0bdc69cb1b3724de6ccc364661028ab9c043526f3f7cb0571147
   Input #1 VOUT: 00000000
   Input #1 ScriptSize: 00
   Input #1 ScriptSig:
   Input #1 Sequence: ffffffff
Output Count: 01
   Output Value: e8fd000000000000
   Output Script Length:16
   Output Script: 00143778e5361fdad0d209de8a16c2ec4ca64618993e
Witness:
   Witness Stack Size: 02
   Witness Signature Length: 47
   Witness Signature: 304402204af85395dd8c758ac379c343bc278351f73cdf9d8548d933aada5fa4e13194a80220126c0614f75520709e63ac41 9308344c00a4a22c021e1b9d8b42115aa73e37b01
   Witness PubKey Length: 21
   Witness PubKey: 02ad2a42eed9fecc022093e8682b62b034690b06587be18f01bb8e60df1afeaaf8
Locktime: 00000000

當我嘗試廣播它時,它給了我這個錯誤:

Mempool accept test failed: 64: non-mandatory-script-verify-flag (Signature must be zero for failed CHECK(MULTI)SIG operation)

我相信這個錯誤的發生是因為簽名不正確,但我很難確定我是如何創建錯誤的簽名的。

以下是我簽署交易的步驟:

Sign the hash of the following with the signing key:
1. Transaction version (4 bytes little endian)
2. The hash of all input outpoints (32 bytes)
3. The hash of all input sequences (32 bytes)
4. The outpoint (32 + 4 bytes)
5. The script code (26 bytes consisting of 0x1976a914<20 byte pub key hash>88ac)
6. The value of the input being signed (8 bytes little endian)
7. The sequence of the input being signed (4 byte little endian)
8. The hash of all the outputs (32 byte)
9. The locktime of the transaction (4 bytes little endian)
10. Sighash type (4 bytes little endian)

然後將該簽名與簽名密鑰的公鑰結合使用,以創建如上所示的見證腳本。

這是我用來創建交易的資訊:

Input #1:
   txid: 471157b07c3f6f5243c0b98a02614636cc6cde24371bcb69dc0bbd4efe52a742
   out: 0
   signing key wif: 3a8c0c731cba400917f66bc3435a405387a9a5b20cdbfdedb19e37d0c6cad8b9

Output #1
   value: 65000
   recipient: tb1qxauw2dslmtgdyzw73gtv9mzv5erp3xf7mt83vq

見證人簽名: 304402204af85395dd8c758ac379c343bc278351f73cdf9d8548d933aada5fa4e13194a80220126c0614f75520709e63ac41 9308344c00a4a22c151e1b9d8b02e3e

似乎簽名值包含空格。

下面不是正確的簽名值嗎?

30440220722ed739d8a69832ecf6e5d636b2949ab6dc00026b88129a8652916904b80c6e0220370d30e8fb3e2d76f6c64b6d89e050ab47faefd3ca017752496035329534207e01

完整的 tx 是:

01000000000101471157b07c3f6f5243c0b98a02614636cc6cde24371bcb69dc0bbd4efe52a7420000000000ffffffff01e8fd0000000000001600143778e5361fdad0d209de8a16c2ec4ca64618993e024730440220722ed739d8a69832ecf6e5d636b2949ab6dc00026b88129a8652916904b80c6e0220370d30e8fb3e2d76f6c64b6d89e050ab47faefd3ca017752496035329534207e012102ad2a42eed9fecc022093e8682b62b034690b06587be18f01bb8e60df1afeaaf800000000

tx_hash_big_endian“:”5da8f74aa4d6612c58c0a740b4740579db57c95828e4cdf04e7d18c23b66cb4a“,”tx_hash“:”4acb663bc2187d4ef0cde42858c957db790574b440a7c0582c61d6a44af7a85d“,自動更正^類S256Point(點):… DEF秒(個體經營):‘‘‘返回SEC格式的二進制版本’‘‘返回b ‘\x04’ + self.x.num.to_bytes(32, ‘big’) \ + self.y.num.to_bytes(32, ‘big’)

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