Skip to content

fix: MemPool::get_unconfirmed_utxos: skip outputs spent by mempool txs - #56

Open
giaki3003 wants to merge 4 commits into
LayerTwo-Labs:masterfrom
giaki3003:fix/w3-20260703-1444-openclaw-confirm-kimiclaw--plain-bitassets-mempool-reports-already-spent-un
Open

giaki3003 wants to merge 4 commits into
LayerTwo-Labs:masterfrom
giaki3003:fix/w3-20260703-1444-openclaw-confirm-kimiclaw--plain-bitassets-mempool-reports-already-spent-un

Conversation

@giaki3003

Copy link
Copy Markdown
Contributor

What's wrong

MemPool::get_unconfirmed_utxos (lib/mempool.rs) collects every output of every mempool transaction that pays the requested address, without consulting the mempool's own spent_utxos index. When one mempool transaction spends another's unconfirmed output, that output is still reported as a UTXO. The result reaches users through Node::get_unconfirmed_utxos_by_addresses, the my_unconfirmed_utxos RPC, and the wallet's unconfirmed UTXO set, so unconfirmed balances are overstated, and a caller that treats the result as spendable can build a transaction that MemPool::put then rejects with UtxoDoubleSpent.

The fix

Replaces the final collect() with a try_fold that looks each outpoint up in self.spent_utxos, in the same read transaction, and drops those already spent by another mempool transaction.

No regression test in this patch; happy to add one if you'd like it covered.

Finding report (access-controlled): https://giaki3003.tech/#/findings/20260703-1444-openclaw-confirm-kimiclaw-plain-bitassets-mempool-unconfirmed-utxo-spent-blindness


Part of a short series for this repo (fix 4 of 4); builds on #55, so it reads best merged after that one. Happy to rebase or split if you'd prefer them independent.

giaki3003 and others added 4 commits July 29, 2026 11:01
Bug: w3-20260630-1952-kimiclaw-confirm-openclaw- (primary)
Finding: findings/20260630-1952-kimiclaw-confirm-openclaw-plain-bitassets-dutch-auction-dust-bid-drain.md
Severity: R4-T1

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
(cherry picked from commit b3baea9)
…ty check on a mis-assigned n_unique_bitasset_outputs variable (filled from spent BitAsset INPUTS via unique_spent_bitassets() instead of the computed-but-unused bitasset_outputs() count), so a normal LP-redemption burn is deterministically rejected by block validation with Error::Amm(InvalidBurn)

Bug: w3-20260611-0220-bitassets-amm-burn-validat (primary)
Finding: findings/20260611-0220-bitassets-amm-burn-validator-counts-spent-bitassets-not-outputs-rejects-normal-burn.md
Severity: R4-T2

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
(cherry picked from commit caeb6d5)
… block

Bug: w3-20260702-2346-kimiclaw-confirm-glmclaw-p (primary)
Finding: findings/20260702-2346-kimiclaw-confirm-glmclaw-plain-bitassets-amm-swap-prevalidate-connect-gap.md
Severity: R4-T2

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
(cherry picked from commit 574f79d)
…s as UTXOs

Bug: w3-20260703-1444-openclaw-confirm-kimiclaw- (primary)
Finding: findings/20260703-1444-openclaw-confirm-kimiclaw-plain-bitassets-mempool-unconfirmed-utxo-spent-blindness.md
Severity: R4-T4

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
(cherry picked from commit e9daa80)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant