-
Notifications
You must be signed in to change notification settings - Fork 331
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
Inserting transactions in the Wallet
should always include a last_seen
.
#1644
Closed
evanlinjin
wants to merge
4
commits into
bitcoindevkit:master
from
evanlinjin:fix/1642-add-last-seen-to-wallet-insert-tx
Closed
Inserting transactions in the Wallet
should always include a last_seen
.
#1644
evanlinjin
wants to merge
4
commits into
bitcoindevkit:master
from
evanlinjin:fix/1642-add-last-seen-to-wallet-insert-tx
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We rm `ConfirmationTime` because it is essentially the same thing as `ChainPosition<ConfirmationBlockTime>` without the block hash. We also impl `serde::Deserialize` and `serde::Serialize` for `ChainPosition`.
Previously, `Wallet::insert_tx` would insert a tx without a `last_seen` value. This meant that inserted transactions will not show up in the canonical history, nor be part of the UTXO set. Hence, new transactions created by the wallet may implicitly replace inserted transactions. This is somewhat unexpected for users. The new behavior of `insert_tx` inserts a tx with the current timestamp as `last_seen`. This, of course requires `std`. Therefore, we also introduced `insert_tx_at` which allows the caller to manually specify the `last_seen` timestamp. In addition, `test_insert_tx_balance_and_utxos` is removed since the behavior being tested is no longer expected.
This is no longer relevant as we direct callers to only insert tx into the wallet after a successful broadcast.
Not including a `seen_at` alongside the update means the unconfirmed txs of the update will not be considered to be part of the canonical history. Therefore, transactions created with this wallet may replace the update's unconfirmed txs (which is unintuitive behavior). Also updated the docs.
evanlinjin
added
bug
Something isn't working
discussion
There's still a discussion ongoing
module-wallet
api
A breaking API change
labels
Oct 10, 2024
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.
8 tasks
5 tasks
@oleonardolima good catch, I didn't notice a3d4eef was already merged. Closing for now and @evanlinjin please re-open if you don't agree all the commits here were already merged. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
api
A breaking API change
bug
Something isn't working
discussion
There's still a discussion ongoing
module-wallet
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Partially fixes #1642
Description
As mentioned in #1642,
Wallet::insert_tx
has some confusing behavior. Callers typically expect that anything inserted into the wallet will not be replaced, and transaction inserted later will have precedence (in the case when we have conflicting txs).This PR modifies the behavior of
Wallet::insert_tx
to always add the current unix timestamp as thelast_seen
-in-mempool value alongside the transaction being inserted. Since this is now astd
-only method, we also introduce aWallet::insert_tx_at
where thelast_seen
timestamp is provided by the caller. We expect callers to only insert txs into the wallet after a successful broadcast. The documentation is updated to reflect this.Wallet::unbroadcast_transactions
is removed since callers are not expected to store unbroadcasted transactions in wallet anymore.In addition, the
seen_at
input is made mandatory forWallet::apply_update_at
. Without this, callers may end up replacing unconfirmed txs when building txs.Notes to the reviewers
I don't think this is the perfect solution because a failed broadcast may be due to a network issue. In this case, the caller may need to persist the transaction external to wallet.
Changelog notice
Wallet::insert_tx
to always insert the tx alongside alast_seen
-in-mempool timestamp (using the current timestamp).Wallet::insert_tx_at
, which is a version oginsert_tx
where the user can explicitly set thelast_seen
timestamp.Wallet::apply_update_at
to always expect alast_seen
value (not have it wrapped inOption
).Wallet::unbroadcast_transactions
.Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingBugfixes: