Expand description
§dig-offers — the DIG Network canonical Chia offers expert crate
dig-offers is a pure, key-free, network-free SpendBundle-builder for Chia offers
(settlement per CHIP-0023/CHIP-0024). It constructs the exact
CoinSpends for every offer operation — make, take, combine,
cancel, and summarize/inspect — over any asset (XCH / CAT / NFT), and reports the exact
signatures a caller must produce.
§The custody model (HARD invariants)
dig-offers never holds a secret key, never signs, and never touches the network. Every
builder takes only public inputs (puzzle hashes, asset ids, public keys, and coins with their
lineage proofs) and appends unsigned coin spends to a caller-owned
chia_wallet_sdk::driver::SpendContext. The consumer signs the messages
reported by required_signatures, assembles/combines the SpendBundle, and broadcasts. This
keeps the signing decision — and the secret key — entirely on the caller’s side of the identity
boundary (#908).
§The make/take two-phase flow
Building and assembling are split so the caller signs BETWEEN them, in ONE shared context:
- make:
make_build→required_signatures→ caller signs →make_assemble. - take:
take_build→required_signatures→ caller signs →take_combine.
The two phases of each flow MUST share the same SpendContext, because a parsed/requested
NFT carries an allocator-relative metadata pointer that only survives in that context.
§The requested-side rule (no self-fund)
A make’s requested side is an assertion plus a phantom carrier — never a settle action — so the
maker never funds both sides of its own offer. Settle actions appear only when taking. See
SPEC.md for the normative contract.
Structs§
- Asset
Info - Cat
- Contains all information needed to spend the outer puzzles of CAT coins.
The
CatInfois used to construct the puzzle, but theLineageProofis needed for the solution. - CatAsset
Info - NftAsset
Info - Offer
- Offer
Cost - What a taker must fund to take an offer: the requested-over-offered surplus (the offer’s arbitrage). NFTs the taker receives are not a cost; NFTs the taker gives up are expressed by the requested-NFT legs, not here.
- Offer
Summary - A read-only summary of an
offer1…string: what it offers, what it requests, the taker’s arbitrage cost, and any NFT royalties it carries. Produced bysummarizewithout committing to the offer. - Offered
Side - The maker’s side of a make-offer: the coins it spends into the settlement puzzle (its funding XCH, CAT, and NFT coins), the fungible amounts it offers, and where change returns.
- Requested
Payments - Requested
Side - The maker’s requested side of a make-offer: what the taker must pay, and where it is paid.
- 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. - Taker
Funds - The taker’s funding coins for taking an offer: its spendable XCH, CAT, and NFT coins, and where change / received assets return.
- Unsigned
Cancel - The unsigned artifact of
cancel_build: the reclaim coin spends the maker must sign to invalidate an outstanding offer. - Unsigned
Make - The unsigned artifact of
make_build: the coin spends the caller must sign, and the requested-payment context to hand back tomake_assembleonce signed. - Unsigned
Take - The unsigned artifact of
take_build: the taker’s own coin spends to sign, the maker’s already-signed offer, and the cost the take funds.
Enums§
- Error
- Everything that can go wrong while building, taking, combining, cancelling, or inspecting a Chia offer.
- Offer
Asset - A single asset leg, used to describe what an offer offers or requests in a read-only
OfferSummary. Amounts are the asset’s base units (mojos for XCH, base units for CATs); an NFT is always quantity one and identified by its launcher id. - Required
Signature
Functions§
- cancel_
build - Build the UNSIGNED spends that reclaim the offered coins of
offer_strtoreclaim_puzzle_hash, reservingfee(mojos) on the first spend. - combine
- Combine
offersinto oneoffer1…string a single taker can settle atomically. - decode
- Decode a bech32
offer1…string into the maker’sSpendBundle. - decode_
offer - encode_
offer - make_
assemble - Assemble a signed maker bundle into a one-sided
offer1…string. - make_
build - Build the maker’s UNSIGNED offer spends: spend
offeredinto settlement, assertrequested, and reservefee(mojos). - offer_
id - The canonical id of the offer encoded by
offer_str. - parse
- Parse a decoded
SpendBundleinto a spendableOfferwithinctx. - required_
signatures - Compute every signature
coin_spendsrequires, given the network’sagg_sig_meadditional data (the genesis challenge — mainnet or testnet). - summarize
- Summarize the offer encoded by
offer_str: its offered and requested assets, the taker’s arbitrage cost, and its royalties. - take_
build - Build the taker’s UNSIGNED spends for taking the offer encoded by
offer_str, funding the requested payments fromfundsand reservingfee(mojos). - take_
combine - Combine the maker’s already-signed
offerwith the taker’ssigned_takerbundle into one atomic settlementSpendBundleready to broadcast. - version
- The crate’s semantic version, surfaced so a consumer can record which builder version produced a spend.