Skip to content

Add offer construction and verification bindings#359

Open
hoffmang9 wants to merge 8 commits intoxch-dev:mainfrom
hoffmang9:greenfloor-from-input-spend-bundle
Open

Add offer construction and verification bindings#359
hoffmang9 wants to merge 8 commits intoxch-dev:mainfrom
hoffmang9:greenfloor-from-input-spend-bundle

Conversation

@hoffmang9
Copy link

@hoffmang9 hoffmang9 commented Feb 23, 2026

Exposes two new offer-related functions through the Python/WASM bindings:

from_input_spend_bundle — Converts an input spend bundle and a set of XCH requested payments into a canonical offer spend bundle via Offer::from_input_spend_bundle. This enables callers to programmatically construct valid offers from pre-built spends without going through the full wallet offer flow.

verify_offer — Decodes an offer string and validates it by parsing through Offer::from_spend_bundle, returning true if the offer is structurally valid. Useful for pre-validating offers before downstream submission (e.g. to a DEX or exchange venue).

Both functions are added to the binding definitions (offer.json), the Rust binding implementations, and the Python type stubs.

Add a binding helper that converts an input spend bundle and xch requested payments into a canonical offer spend bundle through Offer::from_input_spend_bundle.
Expose verify_offer for Python by decoding offer text and validating it through Offer::from_spend_bundle before downstream venue submission.
@hoffmang9 hoffmang9 changed the title Greenfloor from input spend bundle Add offer construction and verification bindings Feb 23, 2026
hoffmang9 and others added 6 commits February 22, 2026 22:13
Centralize offer decode/parse validation in chia-sdk-driver with validate_offer_str and keep bindings verify_offer as a thin wrapper.

Co-authored-by: Cursor <cursoragent@cursor.com>
Change verify_offer to return unit on success and propagate errors on invalid offers, and align bindings metadata and Python stubs with that contract.

Co-authored-by: Cursor <cursoragent@cursor.com>
Use validation-focused naming across bindings and align the checked-in NAPI JS/TS surface with the new function plus from_input_spend_bundle exports.

Co-authored-by: Cursor <cursoragent@cursor.com>
Cover validate_offer_str and validate_offer with positive and negative cases, and verify from_input_spend_bundle output parses into expected requested payment data.

Co-authored-by: Cursor <cursoragent@cursor.com>
Clarify API semantics by renaming from_input_spend_bundle to from_input_spend_bundle_xch (and corresponding NAPI/Python names) so callers do not assume multi-asset requested payment support.

Co-authored-by: Cursor <cursoragent@cursor.com>
This updates formatting-only diffs and replaces an unnecessary unwrap in tests so the Rust workflow passes reliably.

Co-authored-by: Cursor <cursoragent@cursor.com>
@hoffmang9
Copy link
Author

I went another way in my project but it does seem like folks wanting good access to Offers in python, etc could use these. Happy to drop it, also happy to go another way with changes here.

@Rigidity
Copy link
Collaborator

I'm considering taking this change for now, but long term I want a whole Offer class that's a mirror of the SDK's Offer class for full functionality

@hoffmang9
Copy link
Author

If you're going to do it better, I don't need that soon so I lean reject it

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.

2 participants