0

I am very new to Bitcoin development and trying to make some personal milestones, one of which is broadcasting a transaction to the testnet. However, I am having a hard time due to the following error. I tried to debug myself, and have been googling a while, but could not find a post specifically mentioning this error message. I believe there have been an infinite number of transaction related question here, so I was reluctant to upload yet another, but I could not solve it myself. :(

This is the error message I am getting when I push my transaction to https://blockstream.info/testnet/tx/push

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

My transaction is composed of ordinary pay-to-pubkey-hash scripts, sending some bitcoin to a wallet and myself. It looks like this:

0x01000000013b9b28d08f63b37326c0d13896aaf8a05102e3a4478a44ca3ebbd1659197f594010000001976a91
417c195d4043de16d73706a3701aa0a240ab54f9c88acefffffff0210270000000000001976a9145d08c7d64b
7122f674d1dbd85531698a4ec5158f88acb8880000000000001976a91417c195d4043de16d73706a3701aa0a2
40ab54f9c88ac1027000001000000

Or

{
"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

}

Assuming from the error message, I guess the issue should be in the input script. (The length is 0x6a)

0x483045022100b91b2ec7604d4bc64d9a912b47ebca09d41c23250f87d7252fe55f54a891e8c5022073fdab46d21014c01ca90abbff66bb797d66e48968db82758f5d81ceb2b413f1012003eefbe8bcf8cc9d3f4b5aeb632ea64a7c7b9190fbf4d87e659d2516c01e50e8

which I could parse into a locking script

0x03eefbe8bcf8cc9d3f4b5aeb632ea64a7c7b9190fbf4d87e659d2516c01e50e8

which is further parsed into

X: 0xeefbe8bcf8cc9d3f4b5aeb632ea64a7c7b9190fbf4d87e659d2516c01e50e8
Y: 0xe1e61bc26c7b62f3639e5a0fc61f64d05dabf35249473bc6d91c607493b397ad

It looks like the public key is valid.

On the other hand, for the unlocking script,

0x3045022100b91b2ec7604d4bc64d9a912b47ebca09d41c23250f87d7252fe55f54a891e8c5022073fdab46d21014c01ca90abbff66bb797d66e48968db82758f5d81ceb2b413f101

I could verify the transaction myself using a signature hash z=0x450e73dd9d2a81e316abeb238f8192a0df09fefdac707de6eac2aed94c493419

so to me it looks like a valid transaction with compressed public key. What am I missing here? Could anyone help me debugging this?

Thank you in advance!

1 Answer 1

0

'03eefbe8bcf8cc9d3f4b5aeb632ea64a7c7b9190fbf4d87e659d2516c01e50e8' is not valid public key

It should be 33 bytes long, yours is 32.

2
  • Thank you for the comment. My understanding was that the first byte (0x03 in this case) is added for identification of the public key (0x03 for odd, 0x02 for even). Do you mean the it should be 32 bytes after adding that first byte?
    – 마피아
    Commented Jan 19, 2022 at 19:45
  • My bad, I misread the comment. You are right. Thank you so much.
    – 마피아
    Commented Jan 19, 2022 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.