Transactions

推送交易時出現“公鑰既未壓縮也未壓縮”錯誤,但對我來說一切都很好

  • January 19, 2022

我對比特幣開發非常陌生,並試圖做出一些個人里程碑,其中一個是將交易廣播到測試網。但是,由於以下錯誤,我很難過。我嘗試調試自己,並且已經在Google上搜尋了一段時間,但找不到專門提到此錯誤消息的文章。我相信這裡有無數個與交易相關的問題,所以我不願意再上傳一個,但我自己解決不了。:(

這是我將交易推送到https://blockstream.info/testnet/tx/push

{"code":-26,"message":"mandatory-script-verify-flag-failed (Public key is neither compressed or uncompressed)"}

我的交易由普通的 pay-to-pubkey-hash 腳本組成,將一些比特幣發送到錢包和我自己。它看起來像這樣:

0x01000000013b9b28d08f63b37326c0d13896aaf8a05102e3a4478a44ca3ebbd1659197f594010000001976a91
417c195d4043de16d73706a3701aa0a240ab54f9c88acefffffff0210270000000000001976a9145d08c7d64b
7122f674d1dbd85531698a4ec5158f88acb8880000000000001976a91417c195d4043de16d73706a3701aa0a2
40ab54f9c88ac1027000001000000

要麼

{
"addresses": [
   "mhgZk1KDXD4HMtv85fhVNzdd4mk9JSJyR2",
   "mozseyudq9DnEyb2mnGX1wiWSxPAEAU8eU"
],
"block_height": -1,
"block_index": -1,
"confirmations": 0,
"double_spend": false,
"fees": 5000,
"hash": "4f4ccb367412f4bf033d6da99a4d83e1a371c762abf54875e3b920754e765cc7",
"inputs": [
   {
       "addresses": [
           "mhgZk1KDXD4HMtv85fhVNzdd4mk9JSJyR2"
       ],
       "age": 2135099,
       "output_index": 1,
       "output_value": 50000,
       "prev_hash": "94f5979165d1bb3eca448a47a4e30251a0f8aa9638d1c02673b3638fd0289b3b",
       "script": "483045022100b91b2ec7604d4bc64d9a912b47ebca09d41c23250f87d7252fe55f54a891e8c5022073fdab46d21014c01ca90abbff66bb797d66e48968db82758f5d81ceb2b413f1012003eefbe8bcf8cc9d3f4b5aeb632ea64a7c7b9190fbf4d87e659d2516c01e50e8",
       "script_type": "pay-to-pubkey-hash",
       "sequence": 4294967295
   }
],
"lock_time": 10000,
"outputs": [
   {
       "addresses": [
           "mozseyudq9DnEyb2mnGX1wiWSxPAEAU8eU"
       ],
       "script": "76a9145d08c7d64b7122f674d1dbd85531698a4ec5158f88ac",
       "script_type": "pay-to-pubkey-hash",
       "value": 10000
   },
   {
       "addresses": [
           "mhgZk1KDXD4HMtv85fhVNzdd4mk9JSJyR2"
       ],
       "script": "76a91417c195d4043de16d73706a3701aa0a240ab54f9c88ac",
       "script_type": "pay-to-pubkey-hash",
       "value": 35000
   }
],
"preference": "low",
"received": "2022-01-19T06:12:04.937364983Z",
"relayed_by": "44.201.2.248",
"size": 225,
"total": 45000,
"ver": 1,
"vin_sz": 1,
"vout_sz": 2,
"vsize": 225

}

假設從錯誤消息中,我猜問題應該在輸入腳本中。(長度為0x6a

0x483045022100b91b2ec7604d4bc64d9a912b47ebca09d41c23250f87d7252fe55f54a891e8c5022073fdab46d21014c01ca90abbff66bb797d66e48968db82758f5d81ceb2b413f1012003eefbe8bcf8cc9d3f4b5aeb632ea64a7c7b9190fbf4d87e659d2516c01e50e8

我可以將其解析為鎖定腳本

0x03eefbe8bcf8cc9d3f4b5aeb632ea64a7c7b9190fbf4d87e659d2516c01e50e8

進一步解析為

X: 0xeefbe8bcf8cc9d3f4b5aeb632ea64a7c7b9190fbf4d87e659d2516c01e50e8
Y: 0xe1e61bc26c7b62f3639e5a0fc61f64d05dabf35249473bc6d91c607493b397ad

看起來公鑰是有效的。

另一方面,對於解鎖腳本,

0x3045022100b91b2ec7604d4bc64d9a912b47ebca09d41c23250f87d7252fe55f54a891e8c5022073fdab46d21014c01ca90abbff66bb797d66e48968db82758f5d81ceb2b413f101

我可以使用簽名雜湊自己驗證交易z=0x450e73dd9d2a81e316abeb238f8192a0df09fefdac707de6eac2aed94c493419

所以對我來說,它看起來像是一個帶有壓縮公鑰的有效交易。我在這裡想念什麼?誰能幫我調試一下?

先感謝您!

‘03eefbe8bcf8cc9d3f4b5aeb632ea64a7c7b9190fbf4d87e659d2516c01e50e8’ 不是有效的公鑰

它應該是 33 字節長,你的是 32。

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