SimpleSatisfier

Struct SimpleSatisfier 

Source
pub struct SimpleSatisfier {
    pub signatures: HashMap<Vec<u8>, Vec<u8>>,
    pub after_satisfied: HashSet<u32>,
    pub older_satisfied: HashSet<u32>,
    pub sha256_preimages: HashMap<Vec<u8>, Vec<u8>>,
    pub ripemd160_preimages: HashMap<Vec<u8>, Vec<u8>>,
    pub hash256_preimages: HashMap<Vec<u8>, Vec<u8>>,
    pub hash160_preimages: HashMap<Vec<u8>, Vec<u8>>,
}
Expand description

A simple satisfier that uses pre-populated data.

This is a convenience implementation of Satisfier that stores signatures, hash preimages, and timelock information in hash maps and sets. Populate the fields before passing to Miniscript::satisfy().

§Example

use miniscript_core_ffi::SimpleSatisfier;

let mut satisfier = SimpleSatisfier::new();

// Add a signature for key "A"
satisfier.signatures.insert(b"A".to_vec(), vec![0x30, 0x44, /* ... */]);

// Mark absolute timelock 500000 as satisfied
satisfier.after_satisfied.insert(500000);

// Add a SHA256 preimage
let hash = vec![/* 32-byte hash */];
let preimage = vec![/* preimage bytes */];
satisfier.sha256_preimages.insert(hash, preimage);

Fields§

§signatures: HashMap<Vec<u8>, Vec<u8>>

Map from key bytes to signature bytes

§after_satisfied: HashSet<u32>

Set of satisfied absolute timelocks

§older_satisfied: HashSet<u32>

Set of satisfied relative timelocks

§sha256_preimages: HashMap<Vec<u8>, Vec<u8>>

Map from SHA256 hash to preimage

§ripemd160_preimages: HashMap<Vec<u8>, Vec<u8>>

Map from RIPEMD160 hash to preimage

§hash256_preimages: HashMap<Vec<u8>, Vec<u8>>

Map from HASH256 hash to preimage

§hash160_preimages: HashMap<Vec<u8>, Vec<u8>>

Map from HASH160 hash to preimage

Implementations§

Source§

impl SimpleSatisfier

Source

pub fn new() -> Self

Create a new empty satisfier.

Trait Implementations§

Source§

impl Default for SimpleSatisfier

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Satisfier for SimpleSatisfier

Source§

fn sign(&self, key: &[u8]) -> (Availability, Option<Vec<u8>>)

Sign with the given key, returning the signature bytes. Read more
Source§

fn check_after(&self, value: u32) -> bool

Check if the absolute timelock is satisfied. Read more
Source§

fn check_older(&self, value: u32) -> bool

Check if the relative timelock is satisfied. Read more
Source§

fn sat_sha256(&self, hash: &[u8]) -> (Availability, Option<Vec<u8>>)

Get the preimage for a SHA256 hash. Read more
Source§

fn sat_ripemd160(&self, hash: &[u8]) -> (Availability, Option<Vec<u8>>)

Get the preimage for a RIPEMD160 hash. Read more
Source§

fn sat_hash256(&self, hash: &[u8]) -> (Availability, Option<Vec<u8>>)

Get the preimage for a HASH256 (double SHA256) hash. Read more
Source§

fn sat_hash160(&self, hash: &[u8]) -> (Availability, Option<Vec<u8>>)

Get the preimage for a HASH160 hash. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.