btcd icon indicating copy to clipboard operation
btcd copied to clipboard

base58.CheckDecode handles the version bytes incorrectly

Open benma opened this issue 5 years ago • 1 comments

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.

benma avatar Mar 10 '20 09:03 benma

Transferred from the old btcutil repo.

Roasbeef avatar Jan 29 '22 01:01 Roasbeef