Skip to content

utils: tie-break equal output indices instead of throwing - #187

Open
aleksraiden wants to merge 1 commit into
woodser:masterfrom
aleksraiden:fix/duplicate-output-indices
Open

aleksraiden wants to merge 1 commit into
woodser:masterfrom
aleksraiden:fix/duplicate-output-indices

Conversation

@aleksraiden

Copy link
Copy Markdown

Fixes a crash in get_outputs() on a real wallet with many outputs.

vout_before threw Should never sort outputs with duplicate indices when two outputs had the same account, subaddress and local index. std::sort may compare any two elements; a comparator that throws is not a valid ordering, and the comment above the code already promised a key-image tie-break that was missing.

The comparator now uses the key image hex, then the transaction hash, and returns false for two truly identical outputs. This keeps a strict weak ordering and unblocks wallet.getOutputs() — and with it freeze/thaw and output queries.

Reproduction and root-cause notes: aleksraiden/monero-ts#1

vout_before threw when two outputs shared account, subaddress and local index, although std::sort may compare any two elements. The comment already promised a key-image tie-break; implement it, fall back to the transaction hash, and compare equal outputs as equal.

This branch has not been deployed

No deployments
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