Expand description
§dig-options — the DIG Network canonical Chia option-contract expert crate
dig-options is a pure, key-free, network-free CoinSpend-builder for Chia covered
options (the CHIP-0042 option primitive). It constructs the exact
CoinSpends for the option lifecycle — create (lock an XCH
underlying, mint the option singleton), exercise (pay the strike, unlock the underlying
to the holder), clawback (the creator reclaims the underlying after expiry), and
inspect (parse/parse_child) — and reports the exact signatures a caller must
produce (required_signatures).
§The custody model (HARD invariants)
dig-options never holds a secret key, never signs, and never touches the network. Every
builder takes only public inputs (an Owner carrying a public key or a caller-supplied
inner spender, plain Bytes32 puzzle hashes, coins the caller
already fetched) and appends unsigned coin spends to a caller-owned SpendContext. The
consumer signs the messages reported by required_signatures, assembles the
SpendBundle, and broadcasts. Signing — and the secret key — stay entirely on the caller’s
side of the identity boundary (#908).
§Scope (v0.1.0)
The underlying is XCH, and the strike is XCH-only: create REJECTS a non-XCH strike
up front so create and exercise have symmetric support envelopes (no holder can acquire an
option it could never exercise). exercise builds BOTH settlement legs for an XCH strike —
the underlying is claimed to the holder and the strike is paid to the creator, in one bundle —
and keeps its non-XCH guard as defense-in-depth. clawback and inspection work for any strike
type curried into an existing option. CAT/revocable-CAT/NFT underlyings and strike are a future
extension. See SPEC.md for the normative contract.
Structs§
- Created
Option - A created option, returned by
crate::createso the caller can later exercise or claw it back — both need the option singleton, the underlying terms, and the locked-underlying coin, which only exist once the create spend is confirmed. - Option
Spend - The result of a dig-options builder: the unsigned coin spends it produced, and — for
crate::create— theCreatedOptionthe caller keeps to operate the option later. - Option
Terms - The terms of a covered option: who created it, who owns (may exercise) it, how much XCH it locks as the underlying, what strike the holder must pay, and when it expires.
- Option
Underlying - Parsed
Option - A reconstructed option plus the identity fields recoverable from its coin spend.
- Spend
Context - A wrapper around
Allocatorthat caches puzzles and keeps track of a list ofCoinSpend. It’s used to construct spend bundles in an easy and efficient way. - Strike
Payment - The strike payment funding a
exercise: the caller-supplied XCH coin the holder spends to pay the strike into the settlement puzzle.
Enums§
- Error
- Everything that can go wrong while building an option coin spend or reporting the signatures a coin spend requires.
- Option
Type - Owner
- The p2 (owner) layer that authorizes an option’s inner spend, expressed WITHOUT any secret.
- Required
Signature
Traits§
Functions§
- clawback
- Build the unsigned coin spends that CLAW BACK
created’s locked XCH underlying to its creator, authorized bycreator. - create
- Build the unsigned coin spends that CREATE an option per
terms, funded fromfunding_coinand authorized bycreator. - exercise
- Build the unsigned coin spends that EXERCISE
createdby itsholder, payingstrike. - parse
- Decode an option directly from its own coin spend (its coin, serialized puzzle reveal, and
solution). Returns
Ok(None)when the puzzle is not an option contract. - parse_
child - Reconstruct the option child created by spending
parent_coin, given that parent’s serialized puzzle reveal and solution (both fetched by the caller). - required_
signatures - Compute every signature
coin_spendsrequires, given the network’sagg_sig_meadditional data (the genesis challenge — mainnet or testnet). - version
- The crate’s semantic version, surfaced so a consumer can record which builder version produced a spend.
Type Aliases§
- Option
Contract - Result
- The result of a dig-options operation.