ScriptUnlocker

Trait ScriptUnlocker 

Source
pub trait ScriptUnlocker: Sync + Send {
    // Required methods
    fn match_args(&self, args: &[u8]) -> bool;
    fn unlock_async<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        tx: &'life1 TransactionView,
        script_group: &'life2 ScriptGroup,
        tx_dep_provider: &'life3 dyn TransactionDependencyProvider,
    ) -> Pin<Box<dyn Future<Output = Result<TransactionView, UnlockError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn fill_placeholder_witness_async<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        tx: &'life1 TransactionView,
        script_group: &'life2 ScriptGroup,
        tx_dep_provider: &'life3 dyn TransactionDependencyProvider,
    ) -> Pin<Box<dyn Future<Output = Result<TransactionView, UnlockError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;

    // Provided methods
    fn is_unlocked_async<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        _tx: &'life1 TransactionView,
        _script_group: &'life2 ScriptGroup,
        _tx_dep_provider: &'life3 dyn TransactionDependencyProvider,
    ) -> Pin<Box<dyn Future<Output = Result<bool, UnlockError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait { ... }
    fn is_unlocked(
        &self,
        tx: &TransactionView,
        script_group: &ScriptGroup,
        tx_dep_provider: &dyn TransactionDependencyProvider,
    ) -> Result<bool, UnlockError> { ... }
    fn unlock(
        &self,
        tx: &TransactionView,
        script_group: &ScriptGroup,
        tx_dep_provider: &dyn TransactionDependencyProvider,
    ) -> Result<TransactionView, UnlockError> { ... }
    fn clear_placeholder_witness(
        &self,
        tx: &TransactionView,
        _script_group: &ScriptGroup,
    ) -> Result<TransactionView, UnlockError> { ... }
    fn fill_placeholder_witness(
        &self,
        tx: &TransactionView,
        script_group: &ScriptGroup,
        tx_dep_provider: &dyn TransactionDependencyProvider,
    ) -> Result<TransactionView, UnlockError> { ... }
}
Expand description

Script unlock logic:

  • Parse the script.args
  • Sign the transaction
  • Put extra unlock information into transaction (e.g. SMT proof in omni-lock case)

See example in examples/script_unlocker_example.rs

Required Methods§

Source

fn match_args(&self, args: &[u8]) -> bool

Source

fn unlock_async<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, tx: &'life1 TransactionView, script_group: &'life2 ScriptGroup, tx_dep_provider: &'life3 dyn TransactionDependencyProvider, ) -> Pin<Box<dyn Future<Output = Result<TransactionView, UnlockError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Add signature or other information to witnesses, when the script is already unlocked should reset the witness instead.

Source

fn fill_placeholder_witness_async<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, tx: &'life1 TransactionView, script_group: &'life2 ScriptGroup, tx_dep_provider: &'life3 dyn TransactionDependencyProvider, ) -> Pin<Box<dyn Future<Output = Result<TransactionView, UnlockError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Fill a placehodler witness before balance the transaction capacity

Provided Methods§

Source

fn is_unlocked_async<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, _tx: &'life1 TransactionView, _script_group: &'life2 ScriptGroup, _tx_dep_provider: &'life3 dyn TransactionDependencyProvider, ) -> Pin<Box<dyn Future<Output = Result<bool, UnlockError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Check if the script group is already unlocked

Source

fn is_unlocked( &self, tx: &TransactionView, script_group: &ScriptGroup, tx_dep_provider: &dyn TransactionDependencyProvider, ) -> Result<bool, UnlockError>

Source

fn unlock( &self, tx: &TransactionView, script_group: &ScriptGroup, tx_dep_provider: &dyn TransactionDependencyProvider, ) -> Result<TransactionView, UnlockError>

Source

fn clear_placeholder_witness( &self, tx: &TransactionView, _script_group: &ScriptGroup, ) -> Result<TransactionView, UnlockError>

Source

fn fill_placeholder_witness( &self, tx: &TransactionView, script_group: &ScriptGroup, tx_dep_provider: &dyn TransactionDependencyProvider, ) -> Result<TransactionView, UnlockError>

Implementors§