Skip to content

Bech32 decoding incompatible with Bitcoin addresses #442

@keithsue

Description

@keithsue

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions