Struct tari_crypto::script::TariScript [−][src]
Implementations
impl TariScript
[src]
pub fn new(script: Vec<Opcode>) -> Self
[src]
pub fn execute(&self, inputs: &ExecutionStack) -> Result<StackItem, ScriptError>
[src]
Executes the script using a default context. If successful, returns the final stack item.
pub fn execute_with_context(
&self,
inputs: &ExecutionStack,
context: &ScriptContext
) -> Result<StackItem, ScriptError>
[src]
&self,
inputs: &ExecutionStack,
context: &ScriptContext
) -> Result<StackItem, ScriptError>
Execute the script with the given inputs and the provided context. If successful, returns the final stack item.
pub fn as_bytes(&self) -> Vec<u8>
[src]
pub fn as_hash<D: Digest>(&self) -> Result<HashValue, ScriptError>
[src]
Calculate the hash of the script.
as_hash
returns ScriptError::InvalidDigest if the digest function does not produce at least 32 bytes of
output.
pub fn from_bytes(bytes: &[u8]) -> Result<Self, ScriptError>
[src]
Try to deserialise a byte slice into a valid Tari script
pub fn to_opcodes(&self) -> Vec<String>
[src]
Convert the script into an array of opcode strings.
Example
use tari_crypto::script::TariScript; use tari_utilities::hex::Hex; let hex_script = "71b07aae2337ce44f9ebb6169c863ec168046cb35ab4ef7aa9ed4f5f1f669bb74b09e58170ac276657a418820f34036b20ea615302b373c70ac8feab8d30681a3e0f0960e708"; let script = TariScript::from_hex(hex_script).unwrap(); let ops = vec![ "Dup", "HashBlake256", "PushHash(ae2337ce44f9ebb6169c863ec168046cb35ab4ef7aa9ed4f5f1f669bb74b09e5)", "EqualVerify", "Drop", "CheckSig(276657a418820f34036b20ea615302b373c70ac8feab8d30681a3e0f0960e708)", ] .into_iter() .map(String::from) .collect::<Vec<String>>(); assert_eq!(script.to_opcodes(), ops);
pub fn script_message(
&self,
pub_key: &RistrettoPublicKey
) -> Result<RistrettoSecretKey, ScriptError>
[src]
&self,
pub_key: &RistrettoPublicKey
) -> Result<RistrettoSecretKey, ScriptError>
Calculate the message hash that CHECKSIG uses to verify signatures
Trait Implementations
impl Clone for TariScript
[src]
fn clone(&self) -> TariScript
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for TariScript
[src]
impl Default for TariScript
[src]
The default Tari script is to push a single zero onto the stack; which will execute successfully with zero inputs.
impl<'de> Deserialize<'de> for TariScript
[src]
fn deserialize<D>(de: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl Display for TariScript
[src]
impl Eq for TariScript
[src]
impl Hex for TariScript
[src]
fn from_hex(hex: &str) -> Result<Self, HexError> where
Self: Sized,
[src]
Self: Sized,
fn to_hex(&self) -> String
[src]
impl PartialEq<TariScript> for TariScript
[src]
fn eq(&self, other: &TariScript) -> bool
[src]
fn ne(&self, other: &TariScript) -> bool
[src]
impl Serialize for TariScript
[src]
impl StructuralEq for TariScript
[src]
impl StructuralPartialEq for TariScript
[src]
Auto Trait Implementations
impl RefUnwindSafe for TariScript
impl Send for TariScript
impl Sync for TariScript
impl Unpin for TariScript
impl UnwindSafe for TariScript
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> Cast<U> for T where
U: FromCast<T>,
U: FromCast<T>,
pub fn cast(self) -> U
impl<T> Clear for T where
T: InitializableFromZeroed + ?Sized,
[src]
T: InitializableFromZeroed + ?Sized,
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T> FromBits<T> for T
pub fn from_bits(t: T) -> T
impl<T> FromCast<T> for T
pub fn from_cast(t: T) -> T
impl<T> InitializableFromZeroed for T where
T: Default,
[src]
T: Default,
pub unsafe fn initialize(place: *mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> IntoBits<U> for T where
U: FromBits<T>,
U: FromBits<T>,
pub fn into_bits(self) -> U
impl<T> MessageFormat for T where
T: DeserializeOwned + Serialize,
[src]
T: DeserializeOwned + Serialize,
pub fn to_binary(&self) -> Result<Vec<u8, Global>, MessageFormatError>
[src]
pub fn to_json(&self) -> Result<String, MessageFormatError>
[src]
pub fn to_base64(&self) -> Result<String, MessageFormatError>
[src]
pub fn from_binary(msg: &[u8]) -> Result<T, MessageFormatError>
[src]
pub fn from_json(msg: &str) -> Result<T, MessageFormatError>
[src]
pub fn from_base64(msg: &str) -> Result<T, MessageFormatError>
[src]
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,