Please let me know BTG rawTransaction before sign

Hi, I’m hoyoung.
Our team make kasse(Hardware Wallet) in Hyundai-Pay.

We dicide to add btg in Kasse.
So while developing btg wallet, we faced last problem.
Our rawTransaction signature made this error.
Erroe code 16 : mandatory-script-verify-flag-failed (Signature must be zero for failed CHECK(MULTI)SIG operation):Code : 26

We did not find right signature.
We want to know rawTransaction hexcode logic before sign.

Before sign, I made this transaction just like this
Except SIGHASH value, what value must I change?

01000000 //version
01 //input count
11dcdf0b719eaae1e67a84e3fd9d2d58bbe3ac26fbc30d56ed4e7e2edcad1cdb //reverse txid
00000000 //vout
1976a914 //OPCODE
ac323d6964f5bb37ba39be425f73dfc95f05866d //PUBKEYHASH
88ac //OPCODE
ffffffff //SEQUENCE
02 //output count
1027000000000000 //reverse amount
1976a914 //OPCODE
9ab554d4ad3799550dd9fdee8140e00efb39fc6a //PUBKEYHASH
88ac //OPCODE
0053070000000000 //reverse amount
1976a914 //OPCODE
6560ac3f9c10dd9fe9a209ff70e4f080a7bac620 //PUBKEYHASH
88ac //OPCODE
00000000 //Locktime
414f0000 //SIGHASH add 0x40 + (79 << 8)

If anybody help this ploblem in btg, you will meet bitcoin gold personal wallet more quickly.

Thank you.

Thanks for coming here, @ho-young. This is beyond my technical depth, but I’ve tagged our developers in other channels; I expect someone will be able to spare some time to look at this soon.

Hey, looks like you are using a wrong sighash format. You have followed the regular Bitcoin signature hash format. However, as a part of our replay protection, we have adopted a new format, BIP143, for all the BTG transactions after the fork.

BIP143 is used by Bitcoin SegWit transactions and also all the transactions in Bitcoin Cash. BIP143 make it much more hardware wallet friendly.

Here you can find the exact code to serialize a transaction. Please be aware that the amount of the vin is also hashed. This solved the quadratic hash problem.

Please don’t hesitate to ask me if you need more assistance.


As I saw btg rawtransaction in, vin amount did not show in rawtransactions.
So I did not try in bitcoincash style(include vin amount).
My thought is wrong.
I thought btg is mixed style bitcoin & bitcoincash format.

Thank you for your kindness.