Author

Topic: How to correct sign bitcoin cash inputs with libbitcoin? (Read 127 times)

newbie
Activity: 5
Merit: 0
Hello
I try to use libbitcoin for create bitcoin CASH transaction I used this example - https://github.com/libbitcoin/libbitcoin/wiki/Building-Transactions with my BITCOIN prv/pub/inputs/outputs/etc It's work correctly. For bitcoin CASH i use my prv/pub/inputs/outputs/etc and set sighash_algorithm "all | 0x40". As described in bitcoin cash manuals, we need use SIGHASH_FORKID = 0x40(bit 6 set) to sign transaction. "Electron cash" also use this sighash_algorithm. I look on differents with https://github.com/Electron-Cash/Electron-Cash/blob/master/lib/transaction.py https://github.com/spesmilo/electrum/blob/master/electrum/transaction.py and see it

electron cash:

Code:
def nHashType(cls): '''Hash type in hex.''' return 0x01 | (cls.SIGHASH_FORKID + (cls.FORKID << 8))

electron cash:
Code:
def serialize_preimage(self, i): nVersion = int_to_hex(self.version, 4) nHashType = int_to_hex(self.nHashType(), 4)
electrum-btc:

Code:
def serialize_preimage(self, i): nVersion = int_to_hex(self.version, 4) nHashType = int_to_hex(1, 4)

..... so,if use sighash_algorithm "0x01" with bitcoin CASH transaction, i got answer from electrum node:

Quote
the transaction was rejected by network rules.\n\n16: mandatory-script-verify-flag-failed (Signature must use SIGHASH_FORKID)

OK,after this answer i use 0x40 | 0x01 and got this answer

Quote
the transaction was rejected by network rules.\n\n16: mandatory-script-verify-flag-failed (Signature must be zero for failed CHECK(MULTI)SIG operation)

I make similar rawtx in electron cash.My rawtx and rawtx from electron cash are different. electron cash rawtx - correct.

How to correct sign bitcoin CASH inputs with libbitcoin? sry for my english, but i hope you understand this
Jump to: