-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add tests and fix insert_descriptor
#6
base: issue/1101
Are you sure you want to change the base?
Add tests and fix insert_descriptor
#6
Conversation
let old_desc = self | ||
.keychains_to_descriptors | ||
.insert(keychain.clone(), (descriptor_id, descriptor.clone())); | ||
if let Some((old_desc_id, _)) = old_desc { | ||
self.descriptor_ids_to_keychain.remove(&old_desc_id); | ||
} |
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.
You're removing the old descriptor id if it got replaced, but you're not removing the old keychain id if the keychain got replaced. Is there a specific reason for this behavior?
Also, is it really necessary to remove the old descriptor? EDIT: yes it is!
@@ -531,3 +531,67 @@ fn test_non_wildcard_derivations() { | |||
1, | |||
); | |||
} | |||
|
|||
/// `::index_txout` should still index txouts with spks derived from descriptors without keychains. |
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.
Why is this desirable? Right now index_txout works only if you have the keychain -> desc_id
, is this a problem?
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.
For consistency. The keychain may be removed from a tracked descriptor and added later. You can see this scenario playing out in the test I introduced in this PR
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.
Refer to my comment here: bitcoindevkit#1203 (comment)
08178cb
to
2045e9c
Compare
f483fdf
to
bf9102b
Compare
b050826
to
94b9751
Compare
4984d5a
to
2a125f8
Compare
Pull Request Test Coverage Report for Build 8968355961Details
💛 - Coveralls |
a1d55f2
to
0150ac5
Compare
We plan to record `Descriptor` additions into persistence. Hence, we need to add `Descriptor`s to the changeset. This depends on `miniscript`. Moving this into `txout_index.rs` makes sense as this is consistent with all the other files. The only reason why this wasn't this way before, is because the changeset didn't need miniscript. Co-Authored-By: Daniela Brozzoni <[email protected]>
...everywhere
- The KeychainTxOutIndex's internal SpkIterator now uses DescriptorId instead of K. The DescriptorId -> K translation is made at the KeychainTxOutIndex level. - The keychain::Changeset is now a struct, which includes a map for last revealed indexes, and one for newly added keychains and their descriptor. API changes in bdk: - Wallet::keychains returns a `impl Iterator` instead of `BTreeMap` - Wallet::load doesn't take descriptors anymore, since they're stored in the db - Wallet::new_or_load checks if the loaded descriptor from db is the same as the provided one API changes in bdk_chain: - `ChangeSet` is now a struct, which includes a map for last revealed indexes, and one for keychains and descriptors. - `KeychainTxOutIndex::inner` returns a `SpkIterator<(DescriptorId, u32)>` - `KeychainTxOutIndex::outpoints` returns a `impl Iterator` instead of `&BTreeSet` - `KeychainTxOutIndex::keychains` returns a `impl Iterator` instead of `&BTreeMap` - `KeychainTxOutIndex::txouts` doesn't return a ExactSizeIterator anymore - `KeychainTxOutIndex::unbounded_spk_iter` returns an `Option` - `KeychainTxOutIndex::next_index` returns an `Option` - `KeychainTxOutIndex::last_revealed_indices` returns a `BTreeMap` instead of `&BTreeMap` - `KeychainTxOutIndex::reveal_to_target` returns an `Option` - `KeychainTxOutIndex::reveal_next_spk` returns an `Option` - `KeychainTxOutIndex::next_unused_spk` returns an `Option` - `KeychainTxOutIndex::add_keychain` has been renamed to `KeychainTxOutIndex::insert_descriptor`, and now it returns a ChangeSet
…wallet::ChangeSet
...secret keys in the wallet in Wallet::load
We only need to loop though entries of `other`. The logic before was wasteful because we were also looping though all entries of `self` even if we do not need to modify the `self` entry.
This fixes the bug where the result of applying individual changesets may result in a different outcome than applying the aggregate changeset. The nature of the changeset allows different keychain types to be associated with the same descriptor. The previous design did not take this into account. Methods of `KeychainTxOutIndex` only returns one keychain type per spk/txout/outpoint. This PR makes the keychain type returned to be consistent by ranking keychain variants by `Ord`. The lowest keychain variant (according to `Ord`) takes precedence.
0150ac5
to
e1f3b53
Compare
078a932
to
f3c463a
Compare
9822040
to
86711d4
Compare
No description provided.