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

base58.CheckDecode handles the version bytes incorrectly #1795

Open
benma opened this issue Mar 10, 2020 · 1 comment
Open

base58.CheckDecode handles the version bytes incorrectly #1795

benma opened this issue Mar 10, 2020 · 1 comment

Comments

@benma
Copy link
Contributor

benma commented Mar 10, 2020

Hi

https://github.com/btcsuite/btcutil/blob/02a4fd9de1d52e877491996349a92d54c653ccbf/base58/base58check.go#L43

CheckDecode shaves off 1 version byte, but there are situations where there are for example 4 version bytes (xpub base58 encoding), or possibly none at all. I currently call this function and glue together the 4 byte version from the first byte returned and the first three bytes of the result, which is not ideal.

Actually, CheckDecode should not worry about the version at all, as that is not part of base58 check encoding. If there are version bytes and how they look like should be decided by the client.

Thoughts on how to fix it? For backwards compatibility, maybe it makes sense to add another function CheckDecodePlain that just decodes and returns the complete result without the first byte treated differently.

@Roasbeef Roasbeef transferred this issue from btcsuite/btcutil Jan 29, 2022
@Roasbeef
Copy link
Member

Transferred from the old btcutil repo.

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