[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
|
evanlinjin
left a comment
There was a problem hiding this comment.
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
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_addressLastUnused->next_unused_address(assuming this is whatLastUnusedreally means)Peek->peek_addressWondering whether it makes sense to expose
is_usedfor Wallet as well.fixes #898
Changelog notice
Added:
peek_addressreveal_next_addressnext_unused_addressreveal_addresses_tolist_unused_addressesmark_usedunmark_usedRemoved:
Removed Wallet methods:
get_addressget_internal_addresstry_get_addresstry_get_internal_addressRemoved type AddressIndex
Checklists
cargo fmtandcargo clippybefore committingFeature