Fix bug in offer implementation#805
Merged
Merged
Conversation
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.
Note
High Risk
Changes offer-taking coin selection and signing behavior in wallet code paths that move funds; mistakes could enable double-spend or signing attacker-injected spends.
Overview
Fixes take-offer coin selection and signing so the taker cannot reuse or sign coins already spent in the incoming offer bundle.
select_spendsnow delegates toselect_spends_excluding, which treats offer input coin IDs as unavailable when auto-selecting XCH/CAT for the counterparty payment.take_offerpasses every coin ID from the offer’scoin_spendsinto that exclusion list, then returns aTakenOffer(offer+ unsigned takerspend_bundle) instead of a finished bundle.The API
take_offerpath signs only the taker’s spends (sign_transactionwithpartial: false) and appliesoffer.takeafterward. Tests use a sharedsign_taken_offerhelper and add coverage for re-taking your own offer (coin selection error) and for injected malicious spends in the offer (excluded from signing; resulting bundle fails simulation).Reviewed by Cursor Bugbot for commit b7000ef. Bugbot is set up for automated code reviews on this repo. Configure here.