Skip to main content

Code

Struct Code 

Source
pub struct Code(pub Vec<u8>);
Expand description

Serialized script, used inside transaction inputs and outputs

Tuple Fields§

§0: Vec<u8>

Implementations§

Source§

impl Code

Source

pub fn parse(&self) -> Parser<'_> ⓘ

Produce an Opcode iterator from Code.

Source

pub fn annotate(&self, flags: &Flags) -> Vec<Result<Opcode, Vec<Error>>>

Returns a script annotated with errors that could occur during evaluation.

Source

pub fn to_component(&self) -> Result<Component<PossiblyBad>, Error>

Convert this into a Component, which can then be combined in authored scripts in Script.

Source

pub fn serialize(script: &[Opcode]) -> Vec<u8> ⓘ

Convert a sequence of Opcodes to the bytes that would be included in a transaction.

Source

pub fn sig_op_count(&self, accurate: bool) -> u32

Pre-version-0.6, Bitcoin always counted CHECKMULTISIGs as 20 sigops. With pay-to-script-hash, that changed: CHECKMULTISIGs serialized in script_sigs are counted more accurately, assuming they are of the form … OP_N CHECKMULTISIG …

Source

pub fn is_unspendable(&self) -> bool

Returns whether the script is guaranteed to fail at execution, regardless of the initial stack.

The only purpose of this function is to reproduce the behavior of the zcashd function IsUnspendable(), which is used for “asm” encoding and dust transaction filtering. https://github.com/zcash/zcash/blob/2352fbc1ed650ac4369006bea11f7f20ee046b84/src/script/script.h#L617-L620

Trait Implementations§

Source§

impl Asm for Code

Source§

fn to_asm(&self, attempt_sighash_decode: bool) -> String

Return the “asm” representation of this type. Read more
Source§

impl Clone for Code

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Code

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Code

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Evaluable for Code

Source§

fn byte_len(&self) -> usize

Get the byte length of this script sig.

Source§

fn to_bytes(&self) -> Vec<u8> ⓘ

Convert a sequence of Opcodes to the bytes that would be included in a transaction.

Source§

fn is_pay_to_script_hash(&self) -> bool

Returns true iff this script is P2SH.

Source§

fn is_push_only(&self) -> bool

Called by IsStandardTx and P2SH/BIP62 VerifyScript (which makes it consensus-critical).

Source§

fn eval( &self, flags: Flags, checker: &dyn SignatureChecker, stack: Stack<Vec<u8>>, ) -> Result<Stack<Vec<u8>>, Error>

Evaluate this script component.

Auto Trait Implementations§

§

impl Freeze for Code

§

impl RefUnwindSafe for Code

§

impl Send for Code

§

impl Sync for Code

§

impl Unpin for Code

§

impl UnsafeUnpin for Code

§

impl UnwindSafe for Code

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.