Struct bsv_wasm::script::Script [−][src]
pub struct Script(_);Implementations
Script Template
pub fn match_impl(
&self,
script_template: &ScriptTemplate
) -> Result<Vec<(MatchDataTypes, Vec<u8>)>, ScriptTemplateErrors>
pub fn matches(
&self,
script_template: &ScriptTemplate
) -> Result<Vec<(MatchDataTypes, Vec<u8>)>, ScriptTemplateErrors>
pub fn matches(
&self,
script_template: &ScriptTemplate
) -> Result<Vec<(MatchDataTypes, Vec<u8>)>, ScriptTemplateErrors>
Matches the Script against the provided ScriptTemplate.
If any data can be gleaned from the Script (ie. OP_DATA, OP_PUBKEY, OP_SIG, etc.), it will return it in a Vec<Match>
Example
use bsv_wasm::{ Script, MatchDataTypes, ScriptTemplate };
let script = Script::from_asm_string("OP_HASH160 b8bcb07f6344b42ab04250c86a6e8b75d3fdbbc6 OP_EQUALVERIFY OP_DUP OP_HASH160 f9dfc5a4ae5256e5938c2d819738f7b57e4d7b46 OP_EQUALVERIFY OP_CHECKSIG OP_RETURN 21e8").unwrap();
let script_template = ScriptTemplate::from_asm_string("OP_HASH160 OP_DATA=20 OP_EQUALVERIFY OP_DUP OP_HASH160 OP_PUBKEYHASH OP_EQUALVERIFY OP_CHECKSIG OP_RETURN OP_DATA").unwrap();
let match_result = script.matches(&script_template);
let extracted = match_result.unwrap();
assert_eq!(extracted.len(), 3);
match &extracted[0] {
(MatchDataTypes::Data, v) => {
assert_eq!(v.len(), 20, "Data was not 20 bytes long");
assert_eq!(v, &hex::decode("b8bcb07f6344b42ab04250c86a6e8b75d3fdbbc6").unwrap())
}
_ => assert!(false, "Index 0 did not contain Signature"),
}Matches the Script against the provided ScriptTemplate.
Returns true if the Script matches the ScriptTemplate.
Shared Functions
Only export to inside Rust calling code
Native Specific Functions
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for Script
impl UnwindSafe for Script
Blanket Implementations
Mutably borrows from an owned value. Read more
