Cannot make valid Bitcoin Cash transaction

2

I've been way in over my head hacking around in various Python Bitcoin libraries. From what I understand, input public keys have to be compressed to be accepted. Is that correct? I have an uncompressed address that I am trying to send funds from.

If I compress the input public key it shows the input address as the compressed version which shows no balance in block explorers. However, I get a Signature must be zero for failed CHECK(MULTI)SIG operation error when I try to broadcast this transaction.

This is the transaction: 0100000001edc990f08c1ddd5102dfc7f4af32e7927a14fd8d0bc9996725f38ede549b91f8010000008b483045022100ed2a0f6644ff41b9baba8c35356a414b3da24edaea1bf68396efc7ffcbc5b8e902207b1b22c6201c2e4975cbbfc869632d4a2c89b46477b71ef6f875f1c844346d4d414104e1c33577152151109fe5e02c600f386fda865594c1b989ce0fcfbc0fb0b144a2c8fd98053fd86a4ccc7e0dcbcdd6a15c38eb32a27b3653c54f78ba00ffd71d19ffffffff0238300000000000001976a9141a586975175967c83e2b90422bcd8af9a623156288acfdc20d00000000001976a91470fb690a177e8721098d90284ab3c3304ee19cd588ac00000000

If I do not compress the input I get this error: Script failed an OP_EQUALVERIFY operation

And this is the uncompressed key transaction: 0100000001edc990f08c1ddd5102dfc7f4af32e7927a14fd8d0bc9996725f38ede549b91f8010000006b483045022100ed2a0f6644ff41b9baba8c35356a414b3da24edaea1bf68396efc7ffcbc5b8e902207b1b22c6201c2e4975cbbfc869632d4a2c89b46477b71ef6f875f1c844346d4d412103e1c33577152151109fe5e02c600f386fda865594c1b989ce0fcfbc0fb0b144a2ffffffff0238300000000000001976a9141a586975175967c83e2b90422bcd8af9a623156288acfdc20d00000000001976a91470fb690a177e8721098d90284ab3c3304ee19cd588ac00000000

Am I correct in understanding that OP_CHECKSIG comes after OP_EQUALVERIFY, so the first transaction is closer to being valid? And thus all I need to do is fix the signature? Or is there something else I'm missing?

Thank you!

sega01

Posted 2017-11-24T03:49:59.380

Reputation: 23

All I can say is, "Whoops".fuzz 2017-11-24T04:52:00.613

I didn't leak a private key by mistake, did I?sega01 2017-11-24T14:17:53.477

No. Publishing invalid signature twice does not cause leaking private key. Usually :)amaclin 2017-11-24T17:19:20.473

Good day? Do you resolve this problem with bitcash? Same situationAlex Muravyov 2018-01-25T09:23:55.827

@AlexMuravyov yes! This works in bitcash now.sega01 2018-02-05T18:12:33.683

Answers

1

first (uncompressed pubkey):

sendrawtransaction 0100000001edc990f08c1ddd5102dfc7f4af32e7927a14fd8d0bc9996725f38ede549b91f8010000008b483045022100ed2a0f6644ff41b9baba8c35356a414b3da24edaea1bf68396efc7ffcbc5b8e902207b1b22c6201c2e4975cbbfc869632d4a2c89b46477b71ef6f875f1c844346d4d414104e1c33577152151109fe5e02c600f386fda865594c1b989ce0fcfbc0fb0b144a2c8fd98053fd86a4ccc7e0dcbcdd6a15c38eb32a27b3653c54f78ba00ffd71d19ffffffff0238300000000000001976a9141a586975175967c83e2b90422bcd8af9a623156288acfdc20d00000000001976a91470fb690a177e8721098d90284ab3c3304ee19cd588ac00000000
16: mandatory-script-verify-flag-failed (Signature must be zero for failed CHECK(MULTI)SIG operation) (code -26)

second (compressed pubkey):

sendrawtransaction 0100000001edc990f08c1ddd5102dfc7f4af32e7927a14fd8d0bc9996725f38ede549b91f8010000006b483045022100ed2a0f6644ff41b9baba8c35356a414b3da24edaea1bf68396efc7ffcbc5b8e902207b1b22c6201c2e4975cbbfc869632d4a2c89b46477b71ef6f875f1c844346d4d412103e1c33577152151109fe5e02c600f386fda865594c1b989ce0fcfbc0fb0b144a2ffffffff0238300000000000001976a9141a586975175967c83e2b90422bcd8af9a623156288acfdc20d00000000001976a91470fb690a177e8721098d90284ab3c3304ee19cd588ac00000000
16: mandatory-script-verify-flag-failed (Script failed an OP_EQUALVERIFY operation) (code -26)

input: https://blockdozer.com/insight/tx/f8919b54de8ef3256799c90b8dfd147a92e732aff4c7df0251dd1d8cf090c9ed

from address: 1BJPrnDajNczh8cQw2cHGgWyCcRXRDWNFU

checking pubkeys:

void checkpub ( )
{
  const MyByteArray classic    ( QByteArray::fromHex ( "04e1c33577152151109fe5e02c600f386fda865594c1b989ce0fcfbc0fb0b144a2c8fd98053fd86a4ccc7e0dcbcdd6a15c38eb32a27b3653c54f78ba00ffd71d19" ) );
  const MyByteArray compressed ( QByteArray::fromHex ( "03e1c33577152151109fe5e02c600f386fda865594c1b989ce0fcfbc0fb0b144a2" ) );
  qDebug ( ) << classic.hash160 ( ).toString ( );
  qDebug ( ) << compressed.hash160 ( ).toString ( );
}

the result:

"1BJPrnDajNczh8cQw2cHGgWyCcRXRDWNFU"
"1Fk7x75LYzySLi9e7wj9DBJkcAhe3kVcCa"

Conclusion: your first transaction with uncompressed public key is closer to be correct, but the signature is wrong. BitcoinCash has another algorithm for transaction digest calculation

amaclin

Posted 2017-11-24T03:49:59.380

Reputation: 5 763

Thank you! I thought maybe the "invalid signature" message was a bit generic and being thrown for the use of uncompressed keys in the transaction.sega01 2017-11-24T13:57:42.590

BIP 143 says that uncompressed public keys are not allowed. Does that apply to Bitcoin Cash?

https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki#Restrictions_on_public_key_type

sega01 2017-11-24T14:18:53.693

1Uncompressed public keys are not allowed in segwit parts of Bitcoin. They are ok in regular Bitcoin/BitcoinCash transactionsamaclin 2017-11-24T17:16:15.733