Skip to content

Comments

Wallet sync with the mempool after initial sync#2016

Open
OBorce wants to merge 1 commit intomasterfrom
feature/wallet-mempool-sync
Open

Wallet sync with the mempool after initial sync#2016
OBorce wants to merge 1 commit intomasterfrom
feature/wallet-mempool-sync

Conversation

@OBorce
Copy link
Contributor

@OBorce OBorce commented Feb 18, 2026

After opening or creating a new wallet and finishing the initial sync with chainstate, fetch and add all transactions from the mempool before proceeding to process mempool events. This will handle any missed transaction events from the mempool while the wallet was closed.

@OBorce OBorce force-pushed the feature/wallet-mempool-sync branch 2 times, most recently from c21e435 to f75e2ee Compare February 19, 2026 09:21
@OBorce OBorce force-pushed the feature/wallet-mempool-sync branch from f75e2ee to e9d5aa3 Compare February 20, 2026 06:23
Comment on lines +111 to +135
token_fee = 1000
coins_to_send = 1
token_fee_output = {
"Transfer": [
{"Coin": token_fee * ATOMS_PER_COIN},
{
"PublicKey": {
"key": {"Secp256k1Schnorr": {"pubkey_data": pub_key_bytes}}
}
},
],
}
tx_fee_output = {
"Transfer": [
{"Coin": coins_to_send * ATOMS_PER_COIN},
{
"PublicKey": {
"key": {"Secp256k1Schnorr": {"pubkey_data": pub_key_bytes}}
}
},
],
}
encoded_tx, tx_id = make_tx(
[reward_input(tip_id)], [token_fee_output] + [tx_fee_output] * 2, 0
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. There are no tokens involved in this test.
  2. The duplication of tx_fee_output looks arbitrary, is it really needed?

I assume this all is due to copy-pasting? Plz clean the test up.

P.S. I can see the same happens in wallet_mempool_events.py, which was added recently. I guess it's also due to copy-paste, if so, plz clean it up too.

wallet_events: W,

mempool_events: MempoolEvents,
finished_initial_sync: bool,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use SetFlag to make sure it can only go from false to true?

if let Err(err) =
self.wallet.add_mempool_transactions(&txs, &self.wallet_events)
{
log::error!("Txs from mempool failed to be added in the wallet because of an error: {err}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"to the wallet".
But IMO it's' too wordy, something like "Error adding mempool transactions: {err}" would be better.

}
}
Err(err) => {
log::error!("Failed to fetch all transactios from the mempool: {err}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo - transactios

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants