[][src]Struct tari_crypto::script::TariScript

pub struct TariScript { /* fields omitted */ }

Implementations

impl TariScript[src]

pub fn new(script: Vec<Opcode>) -> Self[src]

pub fn execute(&self, inputs: &ExecutionStack) -> Result<(), ScriptError>[src]

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

This code runs with edition 2018
use tari_crypto::script::TariScript;
use tari_utilities::hex::Hex;

let hex_script = "71b07aae2337ce44f9ebb6169c863ec168046cb35ab4ef7aa9ed4f5f1f669bb74b09e58170ac";
let script = TariScript::from_hex(hex_script).unwrap();
let ops = vec![
    "Dup",
    "HashBlake256",
    "PushHash(ae2337ce44f9ebb6169c863ec168046cb35ab4ef7aa9ed4f5f1f669bb74b09e5)",
    "EqualVerify",
    "Drop",
    "CheckSig",
]
.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]

Calculate the message hash that CHECKSIG uses to verify signatures

Trait Implementations

impl Clone for TariScript[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]

impl Display for TariScript[src]

impl Eq for TariScript[src]

impl Hex for TariScript[src]

impl PartialEq<TariScript> for TariScript[src]

impl Serialize for TariScript[src]

impl StructuralEq for TariScript[src]

impl StructuralPartialEq for TariScript[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> Cast<U> for T where
    U: FromCast<T>, 

impl<T> Clear for T where
    T: InitializableFromZeroed + ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T> FromBits<T> for T

impl<T> FromCast<T> for T

impl<T> Hex for T where
    T: ByteArray
[src]

impl<T> InitializableFromZeroed for T where
    T: Default
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> IntoBits<U> for T where
    U: FromBits<T>, 

impl<T> MessageFormat for T where
    T: DeserializeOwned + Serialize
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,