Avoid dust coin selection in transactions - #548
Merged
Conversation
Add MINIMUM_UTXO_VALUE_SATS constant (default 546 sats, configurable via environment variable) and use it to filter dust UTXOs out of coin selection both server-side in NodeGuardService and in the Wallets UI. - Introduce MINIMUM_UTXO_VALUE_SATS in Constants with env-var override - Server-side: append dust outpoints to ignoreOutpoints so selection strategies don't count them toward requested amounts (which would otherwise result in short selections after local stripping) - UI: mark dust UTXOs with a warning "dust" badge and disable the freeze toggle for them, since they are auto-excluded
Jossec101
enabled auto-merge (squash)
July 30, 2026 11:50
When `NBXPLORER_ENABLE_CUSTOM_BACKEND` is enabled, locked, frozen and dust UTXOs were counted by the backend towards the requested amount and only stripped by the local filter afterwards, producing selections that fell short of the target. - Extract `GetLockedFrozenOutpoints` from `FilterLockedFrozenUTXOs` so the outpoint list can be reused. - Fetch all UTXOs, compute dust outpoints (<= `MINIMUM_UTXO_VALUE_SATS`) and merge them with locked/frozen outpoints, then forward the combined list to `GetUTXOsByLimitAsync` as `ignoreOutpoints`. - Make `Constants.NBXPLORER_ENABLE_CUSTOM_BACKEND` mutable so tests can toggle the custom-backend path.
RodriFS
reviewed
Jul 30, 2026
Jossec101
disabled auto-merge
July 30, 2026 13:33
…ern of maximum amount of ignored outpoints. When `NBXPLORER_ENABLE_CUSTOM_BACKEND` is enabled and the custom UTXO selection endpoint throws, callers previously got a hard failure. Wrap the custom-backend path in a try/catch and degrade to the plain `GetUTXOsAsync` listing on error, matching the code path used when the custom backend is disabled. The local filter still strips locked, frozen and dust UTXOs, so none can leak through. A warning is logged with the requested strategy for observability. Adds a unit test covering the failure path to ensure the fallback returns only the available UTXO and excludes locked and dust ones.
Restore the previous GetAvailableUtxos behavior where a failing custom NBXplorer backend yields an empty UTXO selection instead of surfacing an error to the caller. NBXplorerService.GetUTXOsByLimitAsync now correctly throws on non-success responses (replacing the unreachable empty return and fixing `throw e` stack rewrite), so NodeGuardService wraps the call in try/catch, logs a warning, and falls back to an empty UTXOChanges. Adds a unit test covering the custom-backend failure path.
markettes
reviewed
Jul 30, 2026
… redundant RPC dust filter Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
markettes
approved these changes
Jul 30, 2026
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.
Implement logic to prevent the selection of dust coins during transaction creation, this shall prevent dust attacks.
Dust UTXOs are tagged accordinly and cannot be frozen/unfrozen.