pub struct Program { /* private fields */ }Expand description
Represents a program structure containing its source, a public key, arguments, and associated storage.
Abstraction giving the power to execute Simplicity contracts without specifying any additional parameters.
Implementations§
Source§impl Program
impl Program
Sourcepub fn new(source: &'static str, arguments: Box<dyn ArgumentsTrait>) -> Program
pub fn new(source: &'static str, arguments: Box<dyn ArgumentsTrait>) -> Program
Creates a new instance of the struct with the provided source string and arguments.
Sourcepub fn with_taproot_pubkey(self, pub_key: XOnlyPublicKey) -> Program
pub fn with_taproot_pubkey(self, pub_key: XOnlyPublicKey) -> Program
Sets the pub_key field of the struct to the provided XOnlyPublicKey value and returns the updated builder instance.
This is used to set the taproot public key for the program.
Sourcepub fn with_storage_capacity(self, capacity: usize) -> Program
pub fn with_storage_capacity(self, capacity: usize) -> Program
Sets storage capacity for further usage.
Sourcepub fn set_storage_at(&mut self, index: usize, new_value: [u8; 32])
pub fn set_storage_at(&mut self, index: usize, new_value: [u8; 32])
Sets a 32-byte value at the specified index in the storage.
§Panics
Panics if the index is out of bounds for the initiasized storage.
Sourcepub fn get_storage_len(&self) -> usize
pub fn get_storage_len(&self) -> usize
Returns the number of storage chunks for a program.
Sourcepub fn get_storage(&self) -> &[[u8; 32]]
pub fn get_storage(&self) -> &[[u8; 32]]
Returns storage as a whole array of 32-byte chunks.
Sourcepub fn get_storage_at(&self, index: usize) -> [u8; 32]
pub fn get_storage_at(&self, index: usize) -> [u8; 32]
Returns storage value at a certain index.
§Panics
Panics if the index is out of bounds for the initiated storage.
Sourcepub fn get_tr_address(&self, network: &SimplicityNetwork) -> Address
pub fn get_tr_address(&self, network: &SimplicityNetwork) -> Address
Returns a taproot address for a defined SimplicityNetwork.
§Panics
Panics if generating the taproot spending information fails.
Sourcepub fn get_script_pubkey(&self, network: &SimplicityNetwork) -> Script
pub fn get_script_pubkey(&self, network: &SimplicityNetwork) -> Script
Retrieves the ScriptPubKey associated with the Simplicity address for the specified network.
Sourcepub fn get_script_hash(&self, network: &SimplicityNetwork) -> [u8; 32]
pub fn get_script_hash(&self, network: &SimplicityNetwork) -> [u8; 32]
Retrieves the 32-byte ScriptPubKey hash associated with the Simplicity address for the specified network.
Sourcepub fn get_argument_types(&self) -> Result<Parameters, ProgramError>
pub fn get_argument_types(&self) -> Result<Parameters, ProgramError>
Retrieves program ABI metadata for argument types.
§Errors
Returns a ProgramError if compilation fails or generating ABI metadata fails.
Sourcepub fn get_witness_types(&self) -> Result<WitnessTypes, ProgramError>
pub fn get_witness_types(&self) -> Result<WitnessTypes, ProgramError>
Retrieves the witness types from the compiled program’s ABI metadata.
§Errors
Returns a ProgramError if compilation fails or generating ABI metadata fails.
Trait Implementations§
Source§impl ProgramTrait for Program
impl ProgramTrait for Program
Source§fn get_argument_types(&self) -> Result<Parameters, ProgramError>
fn get_argument_types(&self) -> Result<Parameters, ProgramError>
simplicity program. Read moreSource§fn get_witness_types(&self) -> Result<WitnessTypes, ProgramError>
fn get_witness_types(&self) -> Result<WitnessTypes, ProgramError>
simplicity program. Read moreSource§fn get_env(
&self,
pst: &PartiallySignedTransaction,
input_index: usize,
network: &SimplicityNetwork,
) -> Result<ElementsEnv<Arc<Transaction>>, ProgramError>
fn get_env( &self, pst: &PartiallySignedTransaction, input_index: usize, network: &SimplicityNetwork, ) -> Result<ElementsEnv<Arc<Transaction>>, ProgramError>
Source§fn execute(
&self,
pst: &PartiallySignedTransaction,
witness: &WitnessValues,
input_index: usize,
network: &SimplicityNetwork,
) -> Result<(Arc<Node<Redeem<Elements>>>, Value), ProgramError>
fn execute( &self, pst: &PartiallySignedTransaction, witness: &WitnessValues, input_index: usize, network: &SimplicityNetwork, ) -> Result<(Arc<Node<Redeem<Elements>>>, Value), ProgramError>
Source§fn finalize(
&self,
pst: &PartiallySignedTransaction,
witness: &WitnessValues,
input_index: usize,
network: &SimplicityNetwork,
) -> Result<Vec<Vec<u8>>, ProgramError>
fn finalize( &self, pst: &PartiallySignedTransaction, witness: &WitnessValues, input_index: usize, network: &SimplicityNetwork, ) -> Result<Vec<Vec<u8>>, ProgramError>
pruned_witness as output after executing the program on certain parameters. Read moreAuto Trait Implementations§
impl Freeze for Program
impl !RefUnwindSafe for Program
impl !Send for Program
impl !Sync for Program
impl Unpin for Program
impl UnsafeUnpin for Program
impl !UnwindSafe for Program
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more