libsv / go-bt

The go-to Bitcoin Transaction (BT) Go library.
https://pkg.go.dev/mod/github.com/libsv/go-bt
ISC License
67 stars 26 forks source link

DRY changes and adding support for BIP-239 Extended Transaction Format #130

Closed ordishs closed 1 year ago

ordishs commented 1 year ago

All TX parsing functions now delegate to the tx.ReadFrom() function. All duplicate code has been removed.

Added support for parsing raw transactions that are using the BIP-239 Extended Transaction Format.

codecov-commenter commented 1 year ago

Codecov Report

Base: 83.86% // Head: 83.70% // Decreases project coverage by -0.16% :warning:

Coverage data is based on head (548edc8) compared to base (34e82d8). Patch coverage: 75.51% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #130 +/- ## ========================================== - Coverage 83.86% 83.70% -0.17% ========================================== Files 34 34 Lines 3670 3701 +31 ========================================== + Hits 3078 3098 +20 - Misses 426 434 +8 - Partials 166 169 +3 ``` | [Impacted Files](https://codecov.io/gh/libsv/go-bt/pull/130?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libsv) | Coverage Δ | | |---|---|---| | [bscript/address.go](https://codecov.io/gh/libsv/go-bt/pull/130/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libsv#diff-YnNjcmlwdC9hZGRyZXNzLmdv) | `85.96% <ø> (ø)` | | | [bscript/interpreter/debug/debugger.go](https://codecov.io/gh/libsv/go-bt/pull/130/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libsv#diff-YnNjcmlwdC9pbnRlcnByZXRlci9kZWJ1Zy9kZWJ1Z2dlci5nbw==) | `97.70% <ø> (ø)` | | | [bscript/interpreter/errs/error.go](https://codecov.io/gh/libsv/go-bt/pull/130/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libsv#diff-YnNjcmlwdC9pbnRlcnByZXRlci9lcnJzL2Vycm9yLmdv) | `50.00% <ø> (ø)` | | | [unlocker/simple.go](https://codecov.io/gh/libsv/go-bt/pull/130/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libsv#diff-dW5sb2NrZXIvc2ltcGxlLmdv) | `65.00% <ø> (ø)` | | | [bscript/interpreter/state.go](https://codecov.io/gh/libsv/go-bt/pull/130/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libsv#diff-YnNjcmlwdC9pbnRlcnByZXRlci9zdGF0ZS5nbw==) | `29.16% <50.00%> (ø)` | | | [input.go](https://codecov.io/gh/libsv/go-bt/pull/130/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libsv#diff-aW5wdXQuZ28=) | `79.59% <62.50%> (-1.49%)` | :arrow_down: | | [tx.go](https://codecov.io/gh/libsv/go-bt/pull/130/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libsv#diff-dHguZ28=) | `77.29% <74.07%> (-1.23%)` | :arrow_down: | | [bscript/interpreter/operations.go](https://codecov.io/gh/libsv/go-bt/pull/130/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libsv#diff-YnNjcmlwdC9pbnRlcnByZXRlci9vcGVyYXRpb25zLmdv) | `96.54% <100.00%> (ø)` | | | [bscript/script.go](https://codecov.io/gh/libsv/go-bt/pull/130/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libsv#diff-YnNjcmlwdC9zY3JpcHQuZ28=) | `65.25% <100.00%> (+2.02%)` | :arrow_up: | | [txinput.go](https://codecov.io/gh/libsv/go-bt/pull/130/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libsv#diff-dHhpbnB1dC5nbw==) | `80.00% <100.00%> (-2.50%)` | :arrow_down: | | ... and [2 more](https://codecov.io/gh/libsv/go-bt/pull/130/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libsv) | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libsv). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=libsv)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

theflyingcodr commented 1 year ago

Thanks for this Simon, will get at a look it. A quick Google has failed me though, where can I find info on BIP-239

ordishs commented 1 year ago

Hi Mark

You're a bit too quick!

We haven't finished writing the BIP yet because we wanted to include references to go-bt and another JavaScript library along with code examples. The go-bt work is done (as you know) and the JS was finished 1 hour ago. Now, we need to complete the BIP.

Regards

Simon

On 11 Nov 2022, at 17:00, Mark Smith @.***> wrote:

Thanks for this Simon, will get at a look it. A quick Google has failed me though, where can I find info on BIP-239

— Reply to this email directly, view it on GitHubhttps://github.com/libsv/go-bt/pull/130#issuecomment-1311948602, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAAROAVESXQPS6YZLGJUDRTWHZ3TDANCNFSM6AAAAAAR4XVKOE. You are receiving this because you were assigned.Message ID: @.***>

theflyingcodr commented 1 year ago

I see, that explains why I can't find it, hard to review the PR in that case :)

One thing, is it likely that will be other Tx formats / extensions such as this, if so we should probably think of a nice way of handling those additions other than adding additional boolean flags to the various methods like this https://github.com/libsv/go-bt/pull/130/files#diff-8ef97170810c3ede0de2d34df9b1656ec156498c289d7ab2dea5ed8c28e92acdR51 as they will just grow and grow. Perhaps an option and a handler func like map[string]TXExtensionFunc that will get executed depending on tx settings?

theflyingcodr commented 1 year ago

Also thanks for picking up those linter failures, do you think this will be WiP for a bit, I could fix these linter failures in another PR in the mean time to unblock another 2 PRs that are failing because of them. (we run the linter github action which always uses latest linter so it will no doubt pick up stuff the old runs didn't)