Reject spending withdrawal outputs in transactions#103
Open
1440000bytes wants to merge 2 commits into
Open
Conversation
Contributor
Author
|
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.
A withdrawal output (
OutputContent::Withdrawal) is created with the withdrawing user's own address and inserted intostate.utxos+ the utreexo accumulator like any output. When a withdrawal bundle is collected,collect_withdrawal_bundleonly reads those UTXOs (via a read-only txn) to build the M6, stores the bundle asPending, and the node broadcasts the M6 to the mainchain but the UTXOs are not removed from the set or the accumulator until the laterSubmittedevent.During that Pending - Submitted window the owner can spend the withdrawal output back to a
Valueoutput. Every consensus check passes: the utreexo leaf is still live,validate_utxo_hashesmatches the real output's hash,validate_filled_transactionseesvalue_in == value_out, and authorization succeeds with the owner's key. Nothing rejected spending aWithdrawal-content output (is_withdrawal()was only used in wallet coin-selection).Impact:
Submittedevent later runsif !state.utxos.delete(...) { return Err(NoUtxo) }, the UTXO is already gone, so block connection fails for every node on deterministic 2WPD data.Fix
validate_filled_transactionnow rejects any transaction input whose spent output isWithdrawal-content (Error::SpendWithdrawalOutput). A withdrawal output is committed to a bundle and can only be consumed by the bundle mechanism, never by a transaction which also guarantees theSubmitteddelete succeeds.