Bitcoin-ABC / bitcoin-abc

Bitcoin ABC develops node software and infrastructure for the eCash project. This a mirror of the official Bitcoin-ABC repository. Please see README.md
https://reviews.bitcoinabc.org
MIT License
1.24k stars 790 forks source link

mandatory-script-verify-flag-failed error when I enable -ecash flag #437

Open redred77 opened 3 years ago

redred77 commented 3 years ago

I was using bitcoincash abc node fine before. I create transaction manually, sign, and send on the network. But my signed transaction is not accepted from wallet with ecash enabled latest release.

Here are some things I considered, checked.

1) I turned on -ecash with latest release 2) changed amount unit to match. x1000000 for my input and output values. 3) checked that new ecash vout addresses are correctly converted to legacy address as before. I insert legacy vout address in transaction.

I get mandatory-script-verify-flag-failed (Signature must be zero for failed CHECK(MULTI)SIG operation)

Is XEC change some internal logic when I enable ecash? Please advice.

PiRK commented 2 years ago

Hi. The ecash flag does not change internal logic, only the unit and ticker for values displayed in the GUI and in the some RPC parameters and outputs where it previously used BCHA.

It specifically does not change values that were in satoshis. Values in satoshis should not be multiplied.

Could you be more specific about what you mean when you write that you create transaction "manually"? Are you using a RPC call (createrawtransaction)? Or are you building them with custom scripts/programs? If it is the latter, you should not change anything. The raw transaction format has not changed, it encodes amounts as integers (satoshis). If it is createrawtransaction, then you need to use XEC amounts in the outputs.

ccconnor commented 2 years ago

I setup a regtest node, and run the following command

curl --location --request POST 'http://localhost:6650' \
--header 'Authorization: Basic xxxxxxxxxx' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "1.0",
    "id": "curltest",
    "method": "sendtoaddress",
    "params": [
        "n4LbNgMA1LNr1CqvPHa71ndypUSQucPwpi",
        1000000
    ]
}'

Debug.log

2021-12-02T10:57:52Z [default wallet] keypool added 1 keys (1 internal), size=2000 (1000 internal)
2021-12-02T10:57:52Z [default wallet] keypool reserve 1043
2021-12-02T10:57:52Z [default wallet] keypool keep 1043
2021-12-02T10:57:52Z [default wallet] keypool added 1 keys (1 internal), size=2000 (1000 internal)
2021-12-02T10:57:52Z [default wallet] keypool reserve 1044
2021-12-02T10:57:52Z [default wallet] keypool keep 1044
2021-12-02T10:57:52Z [default wallet] Fee non-grouped = 519, grouped = 1548, using non-grouped
2021-12-02T10:57:52Z [default wallet] CommitTransaction:
CTransaction(txid=fc55160b8a, ver=2, vin.size=3, vout.size=2, nLockTime=1728)
    CTxIn(COutPoint(c48a452bd9, 0), scriptSig=473044022079f4fd95ddebc3, nSequence=4294967294)
    CTxIn(COutPoint(d77d1d79e4, 0), scriptSig=473044022060a79cc3a7fd2a, nSequence=4294967294)
    CTxIn(COutPoint(3c29a481bd, 0), scriptSig=47304402201aee6c7f65a4c4, nSequence=4294967294)
    CTxOut(nValue=0.02538543, scriptPubKey=76a91402e930228df787835bf512ab)
    CTxOut(nValue=1.00000000, scriptPubKey=76a914fa5545229d7b43d73e12d4a3)
2021-12-02T10:57:52Z [default wallet] AddToWallet fc55160b8aa002eb2336b7158fbdd48d63f818f7ca8731b4be5b9bc27a2935c1  newupdate
2021-12-02T10:57:52Z [default wallet] Submitting wtx fc55160b8aa002eb2336b7158fbdd48d63f818f7ca8731b4be5b9bc27a2935c1 to mempool for relay
2021-12-02T10:57:52Z [default wallet] CommitTransaction(): Transaction cannot be broadcast immediately, mandatory-script-verify-flag-failed (Signature must be zero for failed CHECK(MULTI)SIG operation)

Strangely, the last tx succeeded.