-
Notifications
You must be signed in to change notification settings - Fork 11
SPV broadcast_transaction does not notify local wallet manager — balance stale until block #487
Description
Summary
When DashSpvClient broadcasts a transaction via PeerNetworkManager::broadcast(), it does not call WalletManager::process_mempool_transaction() on its own wallet. As a result, the local wallet is unaware of the outgoing transaction until the transaction is confirmed in a mined block.
Steps to Reproduce
- Use dash-spv in SPV mode with a
WalletManagerattached. - Broadcast a core-to-core transaction via
DashSpvClient. - Observe wallet balance and UTXO set immediately after the broadcast.
Expected: Wallet balance reflects the sent amount (with spent UTXOs marked as pending) immediately after broadcast.
Actual: Wallet balance is unchanged. UTXOs are not marked as spent. No WalletEvent::TransactionReceived or WalletEvent::BalanceUpdated is emitted. The wallet only updates after the transaction is included in a block (~2.5 min on mainnet).
Root Cause
In dash-spv/src/client/lifecycle.rs (and the broadcast handler in the sync coordinator), after a successful nm.broadcast(NetworkMessage::Tx(tx)) call, there is no follow-up call to notify the local wallet about the outgoing transaction.
The peer that received the broadcast will not relay the transaction back to the originating node (self-relay prevention in Bitcoin/Dash P2P), so the wallet cannot discover the transaction through normal mempool tracking. Other peers may eventually relay it back, but with unpredictable and often significant delay.
All Required Infrastructure Already Exists
All the necessary pieces are already implemented — the only missing step is wiring them together after a successful broadcast:
WalletInterface::process_mempool_transaction()— exists and is implemented inWalletManagerTransactionContext::Mempoolvariant — existsWalletEvent::TransactionReceivedandWalletEvent::BalanceUpdated— exist- Mempool tracking infrastructure (
MempoolStrategy::FetchAll,store_mempool_transaction) — fully built - The broadcast handler has access to the wallet
Proposed Fix
After a successful nm.broadcast(NetworkMessage::Tx(tx)) in the broadcast handler, add:
// Notify the local wallet about the outgoing transaction
wallet.process_mempool_transaction(&tx);This will:
- Mark the spent UTXOs as pending.
- Update the wallet balance immediately.
- Emit
WalletEvent::TransactionReceivedandWalletEvent::BalanceUpdatedso consumers can react immediately.
Impact
Any application using dash-spv for SPV wallet functionality combined with transaction broadcasting is affected. After sending a transaction, users see a stale balance until the next block is mined. On mainnet this is approximately 2.5 minutes; on testnet it can be significantly longer.
This issue was observed in Dash Evo Tool where core-to-core SPV transactions do not reflect in the wallet UI until block confirmation.
Severity
Medium — the funds are not lost and the transaction is broadcast correctly, but the UX regression is significant: users cannot confirm their send completed from the wallet UI alone, and may attempt to re-send.