Skip to content

Make address encoding more modular / flexible #642

@benma

Description

@benma

Would be possible to put the bech32 hrp, base58 version, etc. into the Network directly?

E.g. pub struct Network { pub bech32_hrp: &'static str, ... }.

Then the data would not be scattered around like here, aiding readability.

The predefined networks (Bitcoin, Testnet, etc). could then be constants to choose from.

It would look something like this: https://github.com/digitalbitbox/bitbox02-firmware/blob/5003a78801faca996cc4d027ef36818e9f711bf7/src/rust/bitbox02-rust/src/hww/api/bitcoin/params.rs#L22

This would make it easy for clients use network parameters for other chains without needing to make PRs by simply defining their own network instances.

Imho this would be much better than adding all network params that users requests to this repo. Adding to the Network enum would be a breaking change every time.

Context: I am looking into using this crate in the BitBox02 firmware. It seems promising that we could start using this crate, but is missing e.g. Litecoin params.

Let me know if this would be good change, then I could attempt a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions