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

sign-psbt.py example does not support electrum's testnet xpub encoding for p2wsh #71

Closed
kanzure opened this issue Aug 22, 2022 · 3 comments

Comments

@kanzure
Copy link

kanzure commented Aug 22, 2022

For regtest/testnet mode, bitcointx raises an error when attempting to sign an electrum-generated PSBT because of the presence of an xpub with prefix 0x043587cf (tpub) and does not accept an xpub with prefix 0x02575483 (Vpub).

https://electrum.readthedocs.io/en/latest/xpub_version_bytes.html#specification

I think the simplest solution here would be some xpub type coercion when the user calls the signer with a special flag? Or even type coercion based on --regtest/--mainnet flags.

That said, @darosior mentions:

hardcoding of specific script types inside the encoding of an extended public key is an unscalable and terrible layer violation

@dgpv
Copy link

dgpv commented Aug 23, 2022

The exception should be raised within deserialization code, not within the signing code.

Please check if the following PR would fix your problem: #72

in that PR, PartiallySignedTransaction.deserialize() accepts optional arg acceptable_xpub_prefixes which is the list of 4-byte prefixes acceptable for xpubs. The example sign-psbt.py is also updated (use --acceptable-xpub-prefixes).

@dgpv
Copy link

dgpv commented Aug 23, 2022

Please note that the serialization will use standard prefixes, so when PSBT with non-standard prefixes is deserialized and then serialized again the result will differ from the original

@dgpv
Copy link

dgpv commented Jun 17, 2023

@kanzure, has #72 fixed the problem ?

@kanzure kanzure closed this as completed Sep 21, 2023
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

No branches or pull requests

2 participants