Wallet must not spend boxes tracked by external scans only (#1905) - #2451
Open
Ergologica wants to merge 1 commit into
Open
Wallet must not spend boxes tracked by external scans only (#1905)#2451Ergologica wants to merge 1 commit into
Ergologica wants to merge 1 commit into
Conversation
11 tasks
This was referenced Jul 31, 2026
Author
|
On the red CI — Here it fails on Different test each time, in a suite this branch does not touch: the wallet change here is in |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #1905
The problem
As reported in #1905,
/wallet/payment/sendcould try to spend boxes belonging to a custom application scan not shared with the wallet, while/wallet/boxes/unspent(with default parameters) does not even return such boxes.Cause:
ErgoWalletState.getBoxesToSpendassembles spendable boxes asregistry.walletUnspentBoxes(...) ++ offChainRegistry.offChainBoxes. The confirmed part is correctly limited to the wallet's payments scan, butOffChainRegistry.offChainBoxesholds the off-chain boxes of all scans (it also serves the scan APIs), including boxes tracked only by external application scans. So any unconfirmed box matching a custom scan became spendable by wallet transactions. The same leak affected/wallet/boxes/unspent?considerUnconfirmed=true.The fix
OffChainRegistry.walletOffChainBoxes: off-chain boxes tracked by the wallet'sPaymentsScanId(which includes boxes of scans shared with the wallet, and excludes external-scan-only boxes).ErgoWalletState.getBoxesToSpendandErgoWalletService.getWalletBoxes(bothunspentOnlybranches) now use it.getScanUnspentBoxesetc.) keep using the unfilteredoffChainBoxes, so external scans still see their unconfirmed boxes.Testing
New property in
ErgoWalletServiceSpecwith three off-chain boxes — wallet-only, external-scan-only, and shared (wallet + external scan):getBoxesToSpendandgetWalletBoxes(considerUnconfirmed = true)must return the wallet and shared boxes but not the external-scan-only one, whilegetScanUnspentBoxesfor the external scan still returns its two boxes.The whole
ErgoWalletServiceSpecsuite passes locally.