You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
rs-platform-wallet: on_address_found overwrites the managed account balance before checking proof height #5760
When a Platform address balance sync arrives late, platform-wallet can briefly show an address balance older than one it already knows, for example one from before a spend. Features that read that balance, such as shielding, can then offer an amount the network refuses.
User story
As a wallet user, I want the balance my wallet uses for Platform address spends to never go backwards to an older value, so that the amounts I am offered are amounts the network will accept.
Scenario
Base flow
A wallet has Platform address funds and runs periodic address balance syncs.
The user spends from a Platform address; the spend result (height H2) is applied.
A sync that started earlier (its proof at height H1 < H2) finishes after the spend.
Actual behavior
The late sync writes its older balance into key-wallet's managed Platform payment account. Shield and other readers of that account see the pre-spend figure until the next sync. The network later refuses an amount based on it. No funds are at risk.
Expected behavior
A balance proven at an older height than the one already held for that address is not written to the managed account.
Detailed discussion
packages/rs-platform-wallet/src/wallet/platform_addresses/provider.rs, PlatformPaymentAddressProvider::on_address_found calls account.set_address_credit_balance(p2pkh, funds.balance, ..) unconditionally (still present on v5.1-dev). The height-aware handling only happens later, when sync_finished flushes per_wallet_in_sync into per_wallet, so the managed account is mutated before any freshness check.
Suggested fix: compare funds.as_of_height with the height already held for that address (committed state or the account) and skip set_address_credit_balance when it is older; keep marking the address used / gap-limit generation as today.
Activity