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

[WIP] Impl conversion from v2::Psbt to v0::Psbt #33

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

DanGould
Copy link
Collaborator

@DanGould DanGould commented Oct 6, 2024

Close #31

I implemented both From<raw::Key> and raw::Key::into_v0 in the first and second commits respectively. Let me know which design you think makes more sense, I tend to lean to the former but I wanted to show both to make a fully informed decision.

@tcharding
Copy link
Owner

tcharding commented Oct 6, 2024

Hi @DanGould, either way is fine for me. I'm happy to merge and release this if you are using it but FYI I'm in the middle of re-writing a PSBTv2 crate from scratch that does not import all the bitcoin and miniscript code. I'm away traveling at the moment hacking on it, hopefully will have something ready soon. The API will be similar to whats here so it should be easy to drop in in place of this one.

If you want to look its here: https://github.com/tcharding/rust-psbt-v2
And on top of: rust-bitcoin/rust-bitcoin#3424

Its not nearly done but the to/from psbt version stuff is more or less done and the approach should be obvious.

@DanGould
Copy link
Collaborator Author

DanGould commented Oct 7, 2024

is the idea to use primitives instead of the full bitcoin crate? Getting this merged is not urgent as I'm not using it but a downstream user asked for a way to do the conversion.

@tcharding
Copy link
Owner

No, the psbt stuff will never go in primitives. The reason for my multiple attempts at this (I'm on the third crate now rust-psbt, rust-psbt-v0, and rust-psbt-v2) is that I wanted to totally remove all the code from rust-bitcoin (I've had two goes at this idea, this crate and rust-psbt-v0). But it seems this is not going to fly, so I've started of rust-psbt-v2 that doesn't import. And will hopefully just deprecate stuff in rust-bitcoin - time will tell.

@DanGould
Copy link
Collaborator Author

DanGould commented Oct 9, 2024

I meant the opposite, that the PSBT crate depends only on primitives, and not rust-bitcoin

@tcharding
Copy link
Owner

Woops, we are talking around each other. The psbt logic currently in bitcoin will likely stay in bitcoin but hopefully get dumber and this crate will be downstream of bitcoin. Does that make sense? The bitcoin::psbt::Psbt type will remain in bitcoin and not move into primitives.

@DanGould
Copy link
Collaborator Author

DanGould commented Oct 9, 2024

yes that does make sense. This crate still needs to depend on primitives since it uses e.g. TxOut, right?

@tcharding
Copy link
Owner

Transitively yes, but bitcoin will re-export all primitives types. Users of bitcoin need never know or care about primitives until they want to remove the dependency on bitcoin - which psbt users will not be able to do currently. I'm still thinking about ways to improve this. I'm hoping writing the new rust-psbt-v2 crate and testing it with the new bitcoind-json-rpc crates will turn me into a user of PSBT and I'll figure something good out - we will see.

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.

Convert the inner PSBT v2 to a PSBT v0 (lossy)
2 participants