Closed benma closed 2 years ago
This change looks quite invasive. A better solution might to add the p2pkh
, p2sh
, p2wpkh
, p2shwpkh
etc. functions also to Payload
, making it usable without tying it to a network like the Address does. It would be some additional functions and no breaking change.
Please check this PR as a proposal, following my 2nd comment to introduce this function in a backwards compatible way:
Seems to be closed by #643. @benma please feel free to re-open this issue if I missed something
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.