-
Notifications
You must be signed in to change notification settings - Fork 40
feat!: use NetworkKind
#250
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
base: master
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build 18329864246Details
💛 - Coveralls |
22d27a6
to
e6e6266
Compare
e6e6266
to
ecefb4c
Compare
ecefb4c
to
3e25aef
Compare
You certainly did take some liberties with the code, definitely an improvement overall. In the future it would be nice to make a separate patch for things like documentation and code comments. |
03fb39c
to
3ee3ae2
Compare
ACK 3ee3ae2 |
Will need a rebase. Sorry for the inconvenience. |
3ee3ae2
to
34fe4d6
Compare
// As expected, this does not compile due to invalid context: | ||
// ``` | ||
// let desc_key: DescriptorKey<Segwitv0> = (xprv, path.clone()).into_descriptor_key().unwrap(); | ||
// let (desc, _key_map, _valid_network_kinds) = descriptor!(pkh(desc_key)).unwrap(); | ||
// ``` |
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.
question/nit: could we have this as doctest instead and use compile_fail ?
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.
Wouldn't a single doc block look odd among all tests?
.unwrap(); | ||
check( | ||
P2Pkh(prvkey).build(Network::Bitcoin), | ||
P2Pkh(prvkey).build(NetworkKind::Test), |
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.
question: any reason to change this from mainnet to test ?
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 believe we agreed to use NetworkKind::Test
on all tests.
); | ||
check( | ||
Bip44Public(pubkey, fingerprint, KeychainKind::Internal).build(Network::Bitcoin), | ||
Bip44Public(pubkey, fingerprint, KeychainKind::Internal).build(NetworkKind::Test), |
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.
question: same here.
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 believe we agreed to use NetworkKind::Test
on all tests.
I have just a quick feedback that might help you in further PRs @luisschwab. Last week I saw your message on Discord looking for review on this, and I decided to take a look. In the end the diffs are really big because it's so much docs changes all mixed up with code changes, and I didn't have enough time before my day was over. My advice for further work would be to separate docs and code changes in different commits (I don't actually mind that they are in the same PR, and I know that sometimes we're in a given part of the codebase and it makes sense to fix docs while we're there and thinking about it). I actually like these little ongoing fixes/polish of the docs. But when the diff is big, I review one commit at a time, and that makes it much easier if the two ideas are separate. |
Yeah, Mammal mentioned that as well. This PR is pretty old, but I'll keep that in mind for the future. |
34fe4d6
to
24da1b6
Compare
..to require the NetworkKind when generating the key. This fixes an issue where keys generated for mainnet were incorrectly marked valid for any network. test(keys): Add `test_xpriv_generate_options` fixes bitcoindevkit#22
24da1b6
to
554bb75
Compare
Description
Closes #22.
Closes #94.
This PR replaces
bitcoin::Network
forbitcoin::NetworkKind
where it applies.I also took the liberty of fixing up and adding comments on the files I touched.
Changelog
wallet_name_from_descriptor()
takesNetworkKind
instead ofNetwork
.DescriptorToExtract
takesNetworkKind
instead ofNetwork
.impl IntoWalletDescriptor for <T>
takesNetwork
insteadNetworkKind
.DescriptorTemplate::build()
takesNetworkKind
instead ofNetwork
.ExtendedKey::into_xprv()
takesNetworkKind
instead ofNetwork
.ExtendedKey::into_xpub()
takesNetworkKind
instead ofNetwork
.DerivableKey::into_extended_key()
examples updated to useNetworkKind
instead ofNetwork
.any_network()
renamed toany_network_kind()
.mainnet_network()
renamed tomainnet_network_kind()
.test_networks()
renamed totest_network_kind()
.merge_networks()
renamed tomerge_network_kinds()
.ValidNetworks
type alias renamed toValidNetworkKinds
.GeneratedKey::new()
takesValidNetworkKinds
instead ofValidNetworks
.DescriptorKey::from_public()
takesValidNetworkKinds
instead ofValidNetworks
.DescriptorKey::from_secret()
takesValidNetworkKinds
instead ofValidNetworks
.KeyError::InvalidNetwork
renamed toKeyError::InvalidNetworkKind
.DescriptorKey::override_valid_networks()
renamed tooverride_valid_network_kinds()
.NetworkKind
instead ofNetwork
.NetworkKind::Test
instead ofNetwork::{Regtest, Signet, Testnet, Testnet4}
.NetworkKind
instead ofNetwork
.Checklists
All Submissions:
cargo +nightly fmt
andcargo clippy
before committingNew Features:
Bugfixes: