Bitcoin Forum
July 07, 2024, 07:28:29 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to correct sign bitcoin cash inputs with libbitcoin?  (Read 110 times)
alab (OP)
Newbie
*
Offline Offline

Activity: 5
Merit: 0


View Profile
November 08, 2018, 07:03:03 AM
 #1

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
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!