Skip to main content

Crate dig_offers

Crate dig_offers 

Source
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:

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§

AssetInfo
Cat
Contains all information needed to spend the outer puzzles of CAT coins. The CatInfo is used to construct the puzzle, but the LineageProof is needed for the solution.
CatAssetInfo
NftAssetInfo
Offer
OfferCost
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.
OfferSummary
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 by summarize without committing to the offer.
OfferedSide
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.
RequestedPayments
RequestedSide
The maker’s requested side of a make-offer: what the taker must pay, and where it is paid.
SpendContext
A wrapper around Allocator that caches puzzles and keeps track of a list of CoinSpend. It’s used to construct spend bundles in an easy and efficient way.
TakerFunds
The taker’s funding coins for taking an offer: its spendable XCH, CAT, and NFT coins, and where change / received assets return.
UnsignedCancel
The unsigned artifact of cancel_build: the reclaim coin spends the maker must sign to invalidate an outstanding offer.
UnsignedMake
The unsigned artifact of make_build: the coin spends the caller must sign, and the requested-payment context to hand back to make_assemble once signed.
UnsignedTake
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.
OfferAsset
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.
RequiredSignature

Functions§

cancel_build
Build the UNSIGNED spends that reclaim the offered coins of offer_str to reclaim_puzzle_hash, reserving fee (mojos) on the first spend.
combine
Combine offers into one offer1… string a single taker can settle atomically.
decode
Decode a bech32 offer1… string into the maker’s SpendBundle.
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 offered into settlement, assert requested, and reserve fee (mojos).
offer_id
The canonical id of the offer encoded by offer_str.
parse
Parse a decoded SpendBundle into a spendable Offer within ctx.
required_signatures
Compute every signature coin_spends requires, given the network’s agg_sig_me additional 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 from funds and reserving fee (mojos).
take_combine
Combine the maker’s already-signed offer with the taker’s signed_taker bundle into one atomic settlement SpendBundle ready to broadcast.
version
The crate’s semantic version, surfaced so a consumer can record which builder version produced a spend.

Type Aliases§

Nft
Contains all information needed to spend the outer puzzles of NFT coins. The NftInfo is used to construct the puzzle, but the Proof is needed for the solution.
Result
The result of a dig-offers operation.