Satisfier

Trait Satisfier 

Source
pub trait Satisfier<'brand, Pk: ToXOnlyPubkey> {
    // Required method
    fn inference_context(&self) -> &Context<'brand>;

    // Provided methods
    fn lookup_tap_leaf_script_sig(
        &self,
        _: &Pk,
        _: &TapLeafHash,
    ) -> Option<SchnorrSig> { ... }
    fn lookup_sha256(&self, _: &Pk::Sha256) -> Option<Preimage32> { ... }
    fn check_older(&self, _: Sequence) -> bool { ... }
    fn check_after(&self, _: LockTime) -> bool { ... }
    fn lookup_asm_program(
        &self,
        _: Cmr,
    ) -> Option<Arc<ConstructNode<'brand, Elements>>> { ... }
}
Expand description

Lookup table for signatures, hash preimages, etc.

Every method has a default implementation that simply returns None on every query. Users are expected to override the methods that they have data for.

Required Methods§

Source

fn inference_context(&self) -> &Context<'brand>

Returns at type inference context to be used when constructing programs.

Unlike in Miniscript, satisfactions can’t exist independently of the programs they satisfy. Instead, they are represented by programs whose ‘witness’ nodes are populated with the witness data. Therefore, during satisfaction, we must construct a program, doing type inference along the way.

In order to support the Self::lookup_asm_program method, which needs to return a ConstructNode with the same type inference context as the other parts of the constructed program, this context must be part of the satisfier and made available through this method.

Because of Rust’s lack of specialization, this is true even for satisfiers that do not implement Self::lookup_asm_program.

Provided Methods§

Source

fn lookup_tap_leaf_script_sig( &self, _: &Pk, _: &TapLeafHash, ) -> Option<SchnorrSig>

Given a public key, look up a Schnorr signature with that key.

Source

fn lookup_sha256(&self, _: &Pk::Sha256) -> Option<Preimage32>

Given a SHA256 hash, look up its preimage.

Source

fn check_older(&self, _: Sequence) -> bool

Assert that a relative lock time is satisfied.

Source

fn check_after(&self, _: LockTime) -> bool

Assert that an absolute lock time is satisfied.

Source

fn lookup_asm_program( &self, _: Cmr, ) -> Option<Arc<ConstructNode<'brand, Elements>>>

Given a CMR, look up a matching assembly program.

§Successful execution

It is the responsibility of the implementor to ensure that the returned assembly program has sufficient witness data to successfully run on the Bit Machine.

The execution of a program depends on the transaction environment, so implementations should compute witness data based on that.

If the assembly program fails to run for the current transaction environment, then implementations should return None.

Implementations on Foreign Types§

Source§

impl<'brand, Pk: ToXOnlyPubkey> Satisfier<'brand, Pk> for (&Context<'brand>, LockTime)

Source§

fn inference_context(&self) -> &Context<'brand>

Source§

fn check_after(&self, n: LockTime) -> bool

Source§

impl<'brand, Pk: ToXOnlyPubkey> Satisfier<'brand, Pk> for (&Context<'brand>, Sequence)

Source§

fn inference_context(&self) -> &Context<'brand>

Source§

fn check_older(&self, n: Sequence) -> bool

Implementors§