-
Notifications
You must be signed in to change notification settings - Fork 340
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
[wallet] Improve address API #1402
[wallet] Improve address API #1402
Conversation
6fdf314
to
662e3ca
Compare
c75c9b6
to
191314a
Compare
If |
Yes. I also feel that replacing How about something like this: /// Get the first derived address of the external keychain without revealing it.
///
/// Shorthand for calling [`peek_address`](Self::peek_address) at index 0.
pub fn first_address(&self) -> AddressInfo {
self.peek_address(KeychainKind::External, 0)
} |
@ValuedMammal Do you mean inconvenient as in we need to refactor many of the tests? As you mentioned, I don't think avoiding large test refactors should be a driving factor in API design. For the |
"Inconvenient" in the sense that it requires an additional function arg compared to the current I think any descriptor is capable of producing a first address, wildcard or not. Alternatively, we drop |
191314a
to
e7ef55a
Compare
|
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.
LGTM, just a small addition to docs and I will be happy to ACK/merge!
e7ef55a
to
1ed1f24
Compare
The last push includes documentation improvements and the fix for 📌 We're using |
Everything looks pretty good to me. 👍 |
Introduce a new API for getting addresses from the Wallet that reflects a similiar interface as the underlying indexer `KeychainTxOutIndex` in preparation for removing `AddressIndex` enum. Before this change, the only way to get an address was via the methods `try_get{_internal}_address` which required a `&mut` reference to the wallet, matching on the desired AddressIndex variant. This is too restrictive since for example peeking or listing unused addresses shouldn't change the state of the wallet. Hence we provide separate methods for each use case which makes for a more efficient API.
As this is now made redundant by the newly added wallet address methods.
Adds test coverage for Wallet methods `reveal_addresses_to`, `mark_used`, and `unmark_used`
1ed1f24
to
d39b319
Compare
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.
ACK d39b319
Improvements to the wallet address API, see commit messages for details.
Notes to the reviewers
The logic of getting addresses is roughly the same as before when using
AddressIndex
, following this mapping:New
->reveal_next_address
LastUnused
->next_unused_address
(assuming this is whatLastUnused
really means)Peek
->peek_address
Wondering whether it makes sense to expose
is_used
for Wallet as well.fixes #898
Changelog notice
Added:
peek_address
reveal_next_address
next_unused_address
reveal_addresses_to
list_unused_addresses
mark_used
unmark_used
Removed:
Removed Wallet methods:
get_address
get_internal_address
try_get_address
try_get_internal_address
Removed type AddressIndex
Checklists
cargo fmt
andcargo clippy
before committingFeature