Skip to content

Script Signature problem with bcash-transaction 'signrawtransaction' RPC call. #94

@adityataday

Description

@adityataday

Hi,

I am trying to test a transaction model where given a valid testnet bitcoin cash address I a transfer funds from one address to another. I am able to fetch the UTXO's and I am able to create a raw transaction successfully using 'createrawtransaction' RPC. However, I feel like there is something wrong that is going on while I am signing the raw transaction using the 'signrawtransaction' RPC. There are no errors and I am also able to send the raw transaction but its not getting mined. So I tried to broadcast the transaction through 'https://test-bch-insight.bitpay.com/' and it returned an error saying

"An error occurred: 16: mandatory-script-verify-flag-failed (Signature must be zero for failed CHECK(MULTI)SIG operation). Code:-26"

Then the next step I took is to create the transaction using bitcoincashjs and compare the raw transaction after signature. There seems to be a difference in script signature for both of the raw transactions.

Decoding Bcash raw transaction:

{ "result":{ "txid":"4a63b8e508fd3b2db475f5f33b2259eb1db9e0fa8e14d002f48f81340edbd73f", "hash":{ "type":"Buffer", "data":[ 63, 215, 219, 14, 52, 129, 143, 244, 2, 208, 20, 142, 250, 224, 185, 29, 235, 89, 34, 59, 243, 245, 117, 180, 45, 59, 253, 8, 229, 184, 99, 74 ] }, "size":191, "version":1, "locktime":0, "vin":[ { "txid":"b5386f1196479ed09a700e3c545e3056244923ee100781d2e01ea50074028af7", "scriptSig":{ "asm":"30440220161cf68b6d123f0885224f142dac796032740af8e8f4407de4b80a97bba9e94502206427bb240eb316c0f0650c5adfd724ddf6a02ab21bc3009d52ef2393421e4d6141 03f1eca16f7a149255e47d14513ba7fbd7aebccdefe5ebf1e87481e544ad878471", "hex":"4730440220161cf68b6d123f0885224f142dac796032740af8e8f4407de4b80a97bba9e94502206427bb240eb316c0f0650c5adfd724ddf6a02ab21bc3009d52ef2393421e4d61412103f1eca16f7a149255e47d14513ba7fbd7aebccdefe5ebf1e87481e544ad878471" }, "sequence":4294967295, "vout":1 } ], "vout":[ { "value":0.01, "n":0, "scriptPubKey":{ "asm":"OP_DUP OP_HASH160 7beb3ad9baec5f26589be35a0c805a5d9ba6044a OP_EQUALVERIFY OP_CHECKSIG", "hex":"76a9147beb3ad9baec5f26589be35a0c805a5d9ba6044a88ac", "type":"PUBKEYHASH", "reqSigs":1, "addresses":[ "bchtest:qpa7kwkehtk97fjcn0345ryqtfwehfsyfgsgvqja0t" ] } } ], "blockhash":null, "confirmations":0, "time":0, "blocktime":0 }, "error":null, "id":null }

Decoding bitcoincashjs raw transaction

{ "result":{ "txid":"acef24502e990c9230805ac4217dc13d9ff074fe383ea75eb2a3ce3686afc771", "hash":{ "type":"Buffer", "data":[ 113, 199, 175, 134, 54, 206, 163, 178, 94, 167, 62, 56, 254, 116, 240, 159, 61, 193, 125, 33, 196, 90, 128, 48, 146, 12, 153, 46, 80, 36, 239, 172 ] }, "size":192, "version":1, "locktime":0, "vin":[ { "txid":"b5386f1196479ed09a700e3c545e3056244923ee100781d2e01ea50074028af7", "scriptSig":{ "asm":"3045022100d318b1747ce6cca924fd4fecf479466f0ed0a0e5a2860221dd286ece540e0b6702200e25431f737089809adf2da18db383094e38fa50c28ed24cb384803f46d598f941 03f1eca16f7a149255e47d14513ba7fbd7aebccdefe5ebf1e87481e544ad878471", "hex":"483045022100d318b1747ce6cca924fd4fecf479466f0ed0a0e5a2860221dd286ece540e0b6702200e25431f737089809adf2da18db383094e38fa50c28ed24cb384803f46d598f9412103f1eca16f7a149255e47d14513ba7fbd7aebccdefe5ebf1e87481e544ad878471" }, "sequence":4294967295, "vout":1 } ], "vout":[ { "value":0.01, "n":0, "scriptPubKey":{ "asm":"OP_DUP OP_HASH160 7beb3ad9baec5f26589be35a0c805a5d9ba6044a OP_EQUALVERIFY OP_CHECKSIG", "hex":"76a9147beb3ad9baec5f26589be35a0c805a5d9ba6044a88ac", "type":"PUBKEYHASH", "reqSigs":1, "addresses":[ "bchtest:qpa7kwkehtk97fjcn0345ryqtfwehfsyfgsgvqja0t" ] } } ], "blockhash":null, "confirmations":0, "time":0, "blocktime":0 }, "error":null, "id":null }

image

In testing this I have used the same address with same amounts for the transaction. I have used the bcash 'decoderawtransaction' to decode both the raw transactions. The signed raw transaction by bitcoincashjs is able to also mine.

FYI: I have used bcoin to create the same model for bitcoin and that works fantastic.

Kindly request the developers to through some light.

Thank you for your help in advance.

Aditya Taday

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions