Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve code for the Combiner role #15

Merged
merged 8 commits into from
Feb 1, 2024
Merged

Improve code for the Combiner role #15

merged 8 commits into from
Feb 1, 2024

Conversation

tcharding
Copy link
Owner

Improve code in the v0 and v2 modules for the Combiner role. Includes refactoring and bug fixes. Note that the v2 stuff is all new and was previously just copied from v0.

@tcharding
Copy link
Owner Author

tcharding commented Jan 11, 2024

@DanGould this PR fixes a pretty big hole in the v2 implementation. We have a similar problem with transaction extraction (next on my todo list). I'm mentioning it because this very much invalidates my claim that the v2 module is "ready for alpha usage", apologies for that. Note I still have not looked closely at the miniscript stuff so it should be assumed to be incomplete.

Add two new macros and refactor the `combine` functions to use them.

Refactor only, no logic changes.
It does not make sense to allow our `v0` implementation to combine two
PSBTs with different versions, error if this is attempted.

While we are at it, move the `CombineError` into `global` because that
is where it originates. Although this is not important in `v0`, over in
`v2` there will be different `CombineError`s for the different maps -
lets be uniform already.
Add a function `combine` to the `v0` module as we do in `v2`. While we
are at it make all the docs and calling conventions uniform.
If an attempt is made to combine two PSBTs with different values for the
global map fields `version` or `tx_version` return an error.

This is in line with what we did in `v0`.
The current version of `Input::combine` is copied from the `v0` module
and is not correct for `v2` - fix it.
As we did in other places use plural form for fields in the `Output`
map.
As we did for `v2::Input`.

The current version of `Output::combine` is copied from the `v0` module
and is not correct for `v2` - fix it.
We have now fully replaced the usage of this private macro, remove it.
@tcharding tcharding merged commit f7c9cc8 into master Feb 1, 2024
4 checks passed
@tcharding tcharding deleted the 01-11-combine branch February 1, 2024 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant