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

Convert the inner PSBT v2 to a PSBT v0 (lossy) #31

Open
DanGould opened this issue Sep 16, 2024 · 5 comments · May be fixed by #33
Open

Convert the inner PSBT v2 to a PSBT v0 (lossy) #31

DanGould opened this issue Sep 16, 2024 · 5 comments · May be fixed by #33
Labels
enhancement New feature or request

Comments

@DanGould
Copy link
Collaborator

It'd be nice to be able to convert between PSBTv2 and PSBTv0, but this code is commented out. @tcharding, what hurdles did you face when attempting to implement this function in the first place? Looks like it wasn't as straightforward as once imagined?

// /// Converts the inner PSBT v2 to a PSBT v0.

@DanGould DanGould added the enhancement New feature or request label Sep 16, 2024
@tcharding
Copy link
Owner

tcharding commented Sep 16, 2024

I took 2 minutes looking and I cannot remember what hurdle I hit. I want to say that v0 doesn't map to v2, but that would be just from squinting my eyes hard and trying to remember. FTR I don't normally leave commented code lying around so my guess is I wrote that stuff then hit a problem trying to implement into_v0 on the map types and left the commented code to remind me what was broken, which it hasn't so fail :) I'd have to go back and try to re-implement it to work it out. How bad do you want to know, I can put half an hour into it if you want me to. Holla at me.

oooo, I just wrote that then looked at the issue title again, I bet it was because its lossy that I didn't do it. Again just guessing what Tobin six months ago did.

@DanGould
Copy link
Collaborator Author

It'd definitely be useful if we could use PSBTv2 internally in rust-payjoin and still serialize (the bulk of) PSBTv2 data to PSBTv0 format. Doing so would let us take advantage of PSBTv2's maps for internal mutation and still serialize to payjoin v1 messages which require for PSBTv0. Additionally, we could use PSBTv2 in the Async Payjoin (payjoin v2) protocol spec which helps simplilfy implementation but is not strictly necessary, it's just a good way to advance PSBTv2 adoption for easier multi-party transaction contribution.

To be explicit for posterity: the conversion from PSBTv2 to PSBTv0 is lossy because PSBTv2 has new fields like the modification flags

In order to support payjoin V2, we'd also to be able to take a PSBTv0 and serialize it into v2 for internal mutation after which it would be converted back into PSBTv0

@tcharding
Copy link
Owner

If the conversion is lossy what do you propose we do about the lost information?

@DanGould
Copy link
Collaborator Author

I think dropping that info and documenting it is OK. That's what the PSBTv2 BIP 370 recommends.

@tcharding
Copy link
Owner

Ah nice, sounds reasonable then, thanks.

@DanGould DanGould linked a pull request Oct 6, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants