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

Bech32 decoding incompatible with Bitcoin addresses #442

Open
keithsue opened this issue Dec 17, 2024 · 0 comments
Open

Bech32 decoding incompatible with Bitcoin addresses #442

keithsue opened this issue Dec 17, 2024 · 0 comments

Comments

@keithsue
Copy link

keithsue commented Dec 17, 2024

In the current fiattokenfactory implementation, the recipient addresses are validated by bech32.DecodeToBase256() .

This will cause the following issues for Segwit and Taproot, which are bech32 encoded by combining the segwit version and base32(5-bit) bytes.

  1. For Segwit, the validation will fail due to that decoded 5-bit bytes can not be converted to base256 (the first byte needs to be trimmed)

  2. For Taproot, the validation passes but the decoded base256 byte slice is not the actual taproot output key (the first byte needs to be trimmed when converted)

Possible solution:

  1. Remove conversion to base256. Using bech32.Decode() instead of bech32.DecodeToBase256(), the validation will pass for all bech32(m) encoded addresses including Segwit and Taproot.

  2. Then, use the decoded 5-bit bytes as the address bytes if needed, such as blacklist. This will eliminate the chain-specific differences.

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

1 participant