NxtChg / tsbw

The Simplest Bitcoin Wallet
43 stars 16 forks source link

Troubles with transaction signing #4

Closed volbil closed 5 years ago

volbil commented 5 years ago

Hello @NxtChg, first of all thanks for your awesome wallet :)

Now about the issue: I used your Bitcoin Cash version as base for MicroBitcoin (Bitcoin hardfork) web wallet. It works just fine with when you sending transaction with only one input (transactions successfully broadcasting to network), but when it uses two or more inputs, this error appears: error code: -26 error message: 16: mandatory-script-verify-flag-failed (Signature must be zero for failed CHECK(MULTI)SIG operation).

Here is raw transaction which I trying to broadcast

01000000024f5d326262958f27bf87f7ef54848f8efa22e4a9a09e55e839c449ba01b20631000000006b483045022100c3c637a272e549c44176dc614f4670ea808c98c023afb5f26a2c2327ccb6db4c02207f8ce1c269399ed1255da32a1798c7ba4d41bfae8861a83a7474fd4d8173f245b92102c02288147fc0c0d15f75d985f30b6f391c78fd07b3b8c786edf3b8658dfdd6980000000064dda3fc01b434e26c429494dd845cf3acc21151dcbb0b322be5fbfde1821fa5000000006a47304402203d4aff9c8f47ac0ae8d7bb98c547ad69a59cf6b1e0613d8728ff3afe70f7013802206ca4880c44d1296038ce4e31c1068191f204b2c2e550bb1c8bbb3391b78f7d86b92102c02288147fc0c0d15f75d985f30b6f391c78fd07b3b8c786edf3b8658dfdd6980000000002c0fa7623000000001976a914f8326086855893281630a3dee7174ac1c4e1c92b88acf00b2318000000001976a91427ee5000046b83b4706700c1e2b4cb034c90a08188ac00000000

After some research I find out that this error may be related to hardforks reply protection, so your Bitcoin Cash version also may be affected (I don't have BCH to test it haha).

Here is wallet source and live wallet, I also can provide test network address with coins for tests (if you have time to do this, of course).

P.s. sorry if I ask some stupin noob question, I still learning :)

NxtChg commented 5 years ago

Thanks for reporting this. If MicroBitcoin is a fork of Bitcoin, it might have a different format as a replay protection. Also keep in mind, that Bitcoin Cash changed the signing process, so it's not compatible with the old Bitcoin.

It's a strange error, I don't think it applies to Bitcoin Cash because that's the version I use the most and it seems to be working fine.

Bitcoin version might be outdated as I am not using Bitcoin myself anymore, but TSBW.io seems working fine and nobody reported anything.

I suspect the most probable reason is a bug in your code. Unfortunately, I don't have much time to investigate it. I can help with any questions, but that's about it, sorry.

You need to look at MicroBitcoin spec for tx signing and double-check your code.

NxtChg commented 5 years ago

BTW, nice face-lift on the wallet, looks modern! :)

volbil commented 5 years ago

Thanks :)

volbil commented 5 years ago

So, I figure it out, it was MicroBitcoin core issue. Thanks for your help!

NxtChg commented 5 years ago

@volbil Glad to hear!