Allow alternative address prefixes in bip122 blockchain account ids #206
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A Bitcoin address in Base58Check encoding has a version byte prefix that indicates the type or use of the address. Bitcoin mainnet uses a zero byte, but test networks and forks or alternative networks typically use different version bytes.
Here are a few values of version bytes for addresses:
0x00
0x6f
0x30
0x0e
0x1e
0x71
More info:
This PR updates this implementation to allow using version bytes other than
0x00
, to allow for non-Bitcoin-mainnet addresses.Essentially it ignores the version byte during verification by passing it through from the address that is being verified against.
The previous behavior was to always use
0x00
, meaning that Bitcoin mainnet address format would need to be used even for testnet and forks/altnets.If it is desired to verify consistency between the CAIP-4 reference (BIP122 chain ID) and the address byte (e.g. so that an address with the Bitcoin mainnet prefix could only be used with the Bitcoin mainnet chain ID), the byte could instead be looked up from a mapping of known chain ids to version bytes.
These changes do not affect the validity of signature in relation to public keys, only the allowed formats of the account ids (which are hashes of public keys).