pub struct Script(/* private fields */);
Expand description
A Bitcoin-style script for spending or encumbering coins in transparent transactions.
Script
represents a serialized Bitcoin script, which is a sequence of operations used to
specify conditions for spending Zcash coins in transparent transactions. In ZeWIF,
scripts appear in two contexts:
script_pubkey
in outputs: Defines spending conditions (e.g., P2PKH, P2SH)script_sig
in inputs: Contains signatures and data to satisfy spending conditions
Internally, Script
is a wrapper around Data
, providing a
type-safe representation for script handling.
§Zcash Concept Relation
Zcash inherits the Bitcoin script system for its transparent UTXO model. Unlike shielded transactions, which use zero-knowledge proofs, transparent transactions use explicit scripts to validate spending conditions.
Common script patterns in Zcash transparent addresses include:
- Pay to Public Key Hash (P2PKH): Sends to a standard transparent address
- Pay to Script Hash (P2SH): Sends to a script hash, enabling more complex conditions
§Data Preservation
The Script
type preserves the exact binary representation of transaction scripts
from wallet data, ensuring cryptographic integrity during wallet migrations.
§Examples
// Create a script from binary data (this would typically be from a transaction)
let script_bytes = vec![0x76, 0xa9, 0x14, /* more script bytes */];
let script = Script::from(Data::from_vec(script_bytes.clone()));
// Check script properties
assert_eq!(script.len(), script_bytes.len());
assert!(!script.is_empty());
Implementations§
Trait Implementations§
Source§impl From<Data> for Script
Creates a Script from Data, allowing conversion from variable-length bytes
impl From<Data> for Script
Creates a Script from Data, allowing conversion from variable-length bytes
Source§impl From<Script> for Data
Converts a Script to a Data value, allowing manipulation as variable-length bytes
impl From<Script> for Data
Converts a Script to a Data value, allowing manipulation as variable-length bytes
impl Eq for Script
impl StructuralPartialEq for Script
Auto Trait Implementations§
impl Freeze for Script
impl RefUnwindSafe for Script
impl Send for Script
impl Sync for Script
impl Unpin for Script
impl UnwindSafe for Script
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> CBORDecodable for T
impl<T> CBORDecodable for T
Source§impl<T> CBOREncodable for T
impl<T> CBOREncodable for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> EnvelopeEncodable for T
impl<T> EnvelopeEncodable for T
Source§fn into_envelope(self) -> Envelope
fn into_envelope(self) -> Envelope
Converts the value into an envelope by using its Into<Envelope>
implementation.
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 moreSource§impl<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
self
into the result. Lower case
letters are used (e.g. f9b4ca
)Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
self
into the result. Upper case
letters are used (e.g. F9B4CA
)