RooSoft / bitcoinlib

Create Bitcoin keys, addresses and spend funds
The Unlicense
10 stars 6 forks source link

Segwit transaction failure #4

Open wchenNL opened 6 months ago

wchenNL commented 6 months ago

Tried to follow this livebook for Segwit transactions (P2SH), had to fix some APIs due to outdated dependency. I was able to generate an encoded transaction like below for address 2MzhhVCh8GvuXyzbc7wJae9WbYyCH9CUytY on testnet. Tried to spend the received funds in this txn.

01000000016a99b7047272e1bf5fc4b3b0f54b3313ce2e55d3d78b883fd907be15a6feaaa3000000006a473044022040c814d00da3b95aeccca8958370299e34bd4ca2fce03ff1f228c9045c01356f02201e252dc1dab37a1b735920f938042a70929ce080dc9867422b36fc9a77c0a2a40121039d109ebbb5ea0b46b993b182198209822748680696b471d1e606ef0f1e0935e5ffffffff02f40100000000000017a91409d6cbc4a478c8f1cbde9085b10fb84519591afb87881300000000000017a914e8046c97f9c1c38ff6c15e4d7696385309d543888700000000

Got an error of mandatory-script-verify-flag-failed (Opcode missing or not understood) when broadcasting it on the chain.

@RooSoft Can you kindly remind what might be the issue here?

RooSoft commented 6 months ago

OMG, this thing is a tad outdated... can you send a PR including your changes?

wchenNL commented 6 months ago

Thanks for the reply. @RooSoft Not entirely sure if the fix is correct, but this is what I have https://github.com/RooSoft/bitcoinlib/pull/5

RooSoft commented 6 months ago

Figuring out that the segwit transaction signing feature has never been fully developed. The reason is that bitcoinlib has been built from scratch and haven't yet gained much traction over time... Eventually, other more pressing tasks eventually took my attention away. As a result, develpment has pretty much ben stopped since 2022 apparently without much folks noticing.

Now, it seems you are attempting to use it as we speak. I have to thank you for your interest in this project. It brought my attention back to it, and makes me wonder why I left it in the first place.

So, if you'd like to help develop it, I'd be glad to assist. But alas, I can't devote too much time to it at the moment, as I have other projects to put into production before. Still, my interest has been renewed this week, so be sure I will come back as soon as I find time to improve it.