-
Notifications
You must be signed in to change notification settings - Fork 120
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
Stop assuming Mainnet in Address From impls #1191
Conversation
@yaahc rust style question: Should we pass a tuple to the impl From<(Script, Network)> for Address {
fn from((script, network): (Script, Network)) -> Self { Or define a custom struct: /// Custom type that holds a script and the network it belongs to.
pub struct ScriptForNetwork {
pub script: Script,
pub network: Network,
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
I am also interested in this |
I don't know of any convention for this, I don't think either of these options sounds ideal off of the top of my head tho the second one I might need to think about more. My instinct would be to have it be converted with a method on script that takes an Network argument. maybe something like |
Ok, I'll switch to a method on Script - that's what we do for the other conversions and checks that take a Network argument. |
See c01f804 for the method refactor - I needed to use a trait to implement methods on a foreign type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add the extra script conversions in #1170, because they are needed to make the block subsidy checks work. |
I added the extra conversions into #1170 after a rebase. This is being tested with zcashd test vectors in |
Motivation
Some
From<...> for Address
impls assume all addresses are on mainnet. But we also need to support testnet addresses.Solution
Modify theFrom<...> for Address
impls to take a tuple containing aNetwork
enum value.Replace the
From<...> for Address
impls with methods that take aNetwork
enum value.Add tests for testnet addresses.
Related Issues
Closes #1187.