fix(wallet): keep change off protocol-reserved output values - #203
Merged
Conversation
A num is minted at value % 100 == 77 (delegation opt-in 78, revival 88) and spaces track value % 10 == 2. In a spaces or num-minting tx these are evaluated at every output, so a wallet change output that coincidentally lands on one of these residues gets silently captured by the protocol — e.g. the wallet's change becomes a num, locking the funds into a num identity. Sanitize the drain/change output before signing. `build_tx` pins TxOrdering::Untouched and bdk appends the drain output last, so the change (when present) is always the final output; it is nudged to the nearest non-reserved value (down by at most 2 sats, absorbed by the fee) only when it is unambiguously change: a multi-output tx, an is-mine output on the internal (change) keychain, above the dust floor. Received nums/spaces and funded-transfer maker outputs use the external keychain, and the intentional space/num dust outputs sit below the dust floor, so none of them are ever touched.
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.
No description provided.