Skip to main content

CoinLookup

Trait CoinLookup 

Source
pub trait CoinLookup {
    // Required methods
    fn get_coin_state(&self, coin_id: &Bytes32) -> Option<CoinState>;
    fn get_chain_height(&self) -> u64;
    fn get_chain_timestamp(&self) -> u64;
}
Expand description

Coin state lookup for Tier 3 (state) validation (SPEC §7.2, STV-001).

Implementors provide access to the persistent coin set. The three methods supply the chain context needed for:

  • Coin existence checks (STV-002): get_coin_state returns the coin’s lifecycle.
  • Height/time lock evaluation (STV-005): get_chain_height / get_chain_timestamp provide the reference clock for ASSERT_HEIGHT_* / ASSERT_SECONDS_* conditions.

§Object safety

All methods take &self and return owned/copyable types — no Self in return position, no generic parameters. Box<dyn CoinLookup> and &dyn CoinLookup are valid.

§Chia parity

Method signatures mirror chia-blockchain/chia/consensus/block_body_validation.py where CoinStore.get_coin_record(coin_id) returns Optional[CoinRecord] (Check 15).

Required Methods§

Source

fn get_coin_state(&self, coin_id: &Bytes32) -> Option<CoinState>

Look up a coin’s current state by its ID.

Returns None if the coin is unknown to this lookup source. Callers (STV-002) then check the ephemeral set (ExecutionResult.additions) before rejecting.

Source

fn get_chain_height(&self) -> u64

Current chain tip height as observed by this lookup source.

Used by STV-005 for ASSERT_HEIGHT_ABSOLUTE / BEFORE_HEIGHT_ABSOLUTE evaluation.

Source

fn get_chain_timestamp(&self) -> u64

Current chain tip timestamp (Unix seconds) as observed by this lookup source.

Used by STV-005 for ASSERT_SECONDS_ABSOLUTE / BEFORE_SECONDS_ABSOLUTE evaluation.

Implementors§