Struct cardano_serialization_lib::crypto::ScriptHash
source · pub struct ScriptHash(_);
Implementations§
source§impl ScriptHash
impl ScriptHash
pub fn from_bytes(bytes: Vec<u8>) -> Result<ScriptHash, DeserializeError>
source§impl ScriptHash
impl ScriptHash
sourcepub fn to_bytes(&self) -> Vec<u8>
pub fn to_bytes(&self) -> Vec<u8>
Examples found in repository?
src/address.rs (line 159)
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
fn to_raw_bytes(&self) -> Vec<u8> {
match &self.0 {
StakeCredType::Key(hash) => hash.to_bytes(),
StakeCredType::Script(hash) => hash.to_bytes(),
}
}
}
impl_to_from!(StakeCredential);
impl cbor_event::se::Serialize for StakeCredential {
fn serialize<'se, W: Write>(
&self,
serializer: &'se mut Serializer<W>,
) -> cbor_event::Result<&'se mut Serializer<W>> {
serializer.write_array(cbor_event::Len::Len(2))?;
match &self.0 {
StakeCredType::Key(keyhash) => {
serializer.write_unsigned_integer(0u64)?;
serializer.write_bytes(keyhash.to_bytes())
}
StakeCredType::Script(scripthash) => {
serializer.write_unsigned_integer(1u64)?;
serializer.write_bytes(scripthash.to_bytes())
}
}
}
More examples
src/tx_builder.rs (line 171)
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
fn assert_required_mint_scripts(
mint: &Mint,
maybe_mint_scripts: Option<&NativeScripts>,
) -> Result<(), JsError> {
if maybe_mint_scripts.is_none_or_empty() {
return Err(JsError::from_str(
"Mint is present in the builder, but witness scripts are not provided!",
));
}
let mint_scripts = maybe_mint_scripts.unwrap();
let witness_hashes: HashSet<ScriptHash> =
mint_scripts.0.iter().map(|script| script.hash()).collect();
for mint_hash in mint.keys().0.iter() {
if !witness_hashes.contains(mint_hash) {
return Err(JsError::from_str(&format!(
"No witness script is found for mint policy '{:?}'! Script is required!",
hex::encode(mint_hash.to_bytes()),
)));
}
}
Ok(())
}
pub fn to_bech32(&self, prefix: &str) -> Result<String, JsError>
pub fn from_bech32(bech_str: &str) -> Result<ScriptHash, JsError>
pub fn to_hex(&self) -> String
pub fn from_hex(hex: &str) -> Result<ScriptHash, JsError>
source§impl ScriptHash
impl ScriptHash
pub const BYTE_COUNT: usize = 28usize
Trait Implementations§
source§impl Clone for ScriptHash
impl Clone for ScriptHash
source§fn clone(&self) -> ScriptHash
fn clone(&self) -> ScriptHash
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ScriptHash
impl Debug for ScriptHash
source§impl<'de> Deserialize<'de> for ScriptHash
impl<'de> Deserialize<'de> for ScriptHash
source§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
source§impl Deserialize for ScriptHash
impl Deserialize for ScriptHash
fn deserialize<R: BufRead>(
raw: &mut Deserializer<R>
) -> Result<Self, DeserializeError>
source§impl Display for ScriptHash
impl Display for ScriptHash
source§impl Hash for ScriptHash
impl Hash for ScriptHash
source§impl JsonSchema for ScriptHash
impl JsonSchema for ScriptHash
source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref
keyword. Read moresource§impl Ord for ScriptHash
impl Ord for ScriptHash
source§fn cmp(&self, other: &ScriptHash) -> Ordering
fn cmp(&self, other: &ScriptHash) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq<ScriptHash> for ScriptHash
impl PartialEq<ScriptHash> for ScriptHash
source§fn eq(&self, other: &ScriptHash) -> bool
fn eq(&self, other: &ScriptHash) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<ScriptHash> for ScriptHash
impl PartialOrd<ScriptHash> for ScriptHash
source§fn partial_cmp(&self, other: &ScriptHash) -> Option<Ordering>
fn partial_cmp(&self, other: &ScriptHash) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more