-
Notifications
You must be signed in to change notification settings - Fork 48
Return wallet events when applying updates and blocks (3.0 milestone) #319
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?
Return wallet events when applying updates and blocks (3.0 milestone) #319
Conversation
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.
Hey @notmandatory thanks for your work on this! I left some comments related to code quality. As always, nits are non-blocking.
| if chain_tip1 != chain_tip2 { | ||
| events.push(WalletEvent::ChainTipChanged { | ||
| old_tip: chain_tip1, | ||
| new_tip: chain_tip2, | ||
| }); | ||
| } |
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 think it would be helpful to know which blocks were connected and/or disconnected.
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.
Do you mean a list of connected/disconnected block ids? I didn't add any other info here because @tnull didn't need it for LDK's use case. Do you have some use or user in mind for this extra info?
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.
Yeah I mean the block IDs. It's just a more complete way of describing how the chain tip changed.
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.
@ValuedMammal are you thinking of something like adding connected and disconnected fields to this variant:
/// The latest chain tip known to the wallet changed.
ChainTipChanged {
/// Previous chain tip.
old_tip: BlockId,
/// New chain tip.
new_tip: BlockId,
/// Newly connected blocks.
connected: Vec<BlockId>,
/// Newly disconnected blocks.
disconnected: Vec<BlockId>,
},I'm still not clear on how this info would be used by a wallet user since it's more of an internal detail.
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.
Pull Request Test Coverage Report for Build 18893642494Details
💛 - Coveralls |
21eaa1f to
488b373
Compare
|
Addressed initial comments from @ValuedMammal and rebased on Next steps:
|
488b373 to
2891853
Compare
|
I will cherry-pick and incorporate commits from #336 for |
8d580ed to
6c5c755
Compare
|
Finished cherry-picking from #336 and rebased on |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #319 +/- ##
==========================================
+ Coverage 85.24% 85.78% +0.53%
==========================================
Files 23 24 +1
Lines 8229 8348 +119
==========================================
+ Hits 7015 7161 +146
+ Misses 1214 1187 -27
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
# Conflicts: # src/wallet/event.rs
WalletEvent is a enum of user facing events that are generated when a sync update is applied to a wallet using the Wallet::apply_update_events function.
per suggestions from ValuedMammal: 1. re-export WalletEvent type 2. add comments to wallet_events function 3. rename ambiguous variable names in wallet_events from cp to pos 4. remove signing from wallet_event tests 5. change wallet_events function assert_eq to debug_asset_eq 6. update ADR 0003 decision outcome and add option 4 re: creating events only from Update
Previously, we added a new `Wallet::apply_update_events` method that returned `WalletEvent`s. Unfortunately, no corresponding APIs were added for the `apply_block` counterparts. Here we fix this omission.
Co-authored-by: Steve Myers <github@notmandatory.org>
Also did minor cleanup of apply_update_events tests.
6c5c755 to
e0bef3b
Compare
BREAKING CHANGE: 1. changed functions to return WalletEvents: - Wallet::apply_update - Wallet::apply_block - Wallet::apply_block_connected_to 2. removed functions: - Wallet::apply_update_events - Wallet::apply_block_events - Wallet::apply_block_connected_to_events
a868aa8 to
66cedb4
Compare
|
Refactored to return events from original apply_update, apply_block* functions, removed *_events functions, see 66cedb4. |
|
Added one more commit with some docs improvements and refactored out helper method based on suggestions from Claude LLM 🤖. |
- Enhanced WalletEvent documentation with clearer explanations - Expanded apply_update() docs with examples and persistence warnings - Extracted collect_wallet_txs() to reduce code duplication - Fixed minor typos and improved code clarity 🤖 LLM-assisted changes
5f276a6 to
45b3cd0
Compare
|
I haven't added an example for getting affected UTXOs/addresses from a Transaction related WalletEvents. This is a bit out of scope for this PR and should get it's own PR, either to add an example or add a helper function to Wallet to do it. |
My thinking is to provide a new helper method |
|
In 95e681a: If this is a fixup commit I guess it can be squashed into the previous one. |
On second thought isn't this precisely what the user is asking for in issue #6, suggesting we should have something like |
Description
Cherry-pick of commits from #310 and #336.
Refactored Wallet apply updates or blocks to return events and removed v2.x
*_eventsfunctions.Notes to the reviewers
I decided to remove the
*_eventsfunctions added in bdk_wallet-2.2 and 2.3 releases and return events from the originalapply_*functions since 3.0 is a breaking milestone and I want to remove the redundant functions.Changelog notice
BREAKING CHANGES
Refactored Wallet apply updates or blocks to return
Vec<WalletEvent>- Wallet::apply_update
- Wallet::apply_block
- Wallet::apply_block_connected_to
Removed redundant functions:
- Wallet::apply_update_events
- Wallet::apply_block_events
- Wallet::apply_block_connected_to_events
Checklists
All Submissions:
just pbefore pushingNew Features: