Skip to main content

exercise

Function exercise 

Source
pub fn exercise(
    ctx: &mut SpendContext,
    holder: &Owner<'_>,
    created: &CreatedOption,
    strike: &StrikePayment,
) -> Result<OptionSpend>
Expand description

Build the unsigned coin spends that EXERCISE created by its holder, paying strike.

Spends the option singleton through its exercise path, unlocks the locked XCH underlying to the holder, and pays the XCH strike into the settlement puzzle — settled to the creator’s requested payment — all in one bundle. Rejects a strike.funding_coin smaller than the strike amount.

v0.1.0 scope: only an XCH strike can be exercised. A CAT/NFT strike returns Error::InvalidInput rather than emitting an incorrect spend — building the CAT/NFT settlement leg is a documented follow-up.

Pure: does NOT sign or broadcast. Returns OptionSpend with created: None.

CRITICAL: The returned coin_spends include the settlement leg that claims the unlocked underlying to the holder. That leg is REQUIRED but only builder-enforced: consensus forces the strike payment to the creator, but does NOT force the underlying claim. Callers MUST broadcast the full returned bundle intact — dropping or reordering the underlying-claim spend strands the underlying at a publicly-claimable settlement coin that anyone can take. Never submit a subset of these spends.