Skip to main content

TransactionToSign

Struct TransactionToSign 

Source
#[repr(C)]
pub struct TransactionToSign<'a> { pub tx_bytes: &'a [u8], pub inputs_to_sign: &'a [InputToSign], }
Expand description

Represents a transaction that needs to be signed with associated inputs.

This struct holds the raw transaction bytes and a list of inputs that need to be signed, each with their own index and signer public key.

Fields§

§tx_bytes: &'a [u8]

The raw transaction bytes to be signed.

§inputs_to_sign: &'a [InputToSign]

List of inputs within the transaction that need signatures.

Implementations§

Source§

impl<'a> TransactionToSign<'a>

Source

pub fn serialise(&self) -> Vec<u8>

Serializes the TransactionToSign into a byte vector.

The serialized format is:

  • 4 bytes: length of tx_bytes (u32, little endian)
  • N bytes: tx_bytes content
  • 4 bytes: number of inputs to sign (u32, little endian)
  • For each input:
    • 4 bytes: input index (u32, little endian)
    • 32 bytes: signer public key
§Returns

A vector of bytes containing the serialized transaction.

Source

pub fn serialise_inputs_to_sign(inputs_to_sign: &[InputToSign]) -> Vec<u8>

Source

pub fn serialise_with_tx( tx: &Transaction, inputs_to_sign: &[InputToSign], ) -> Vec<u8>

Serializes a Transaction and inputs_to_sign directly into a single buffer without intermediate allocations

§Parameters
  • tx - A reference to the Bitcoin transaction to serialize.
  • inputs_to_sign - A slice of InputToSign structs representing the inputs to sign.
§Returns

A vector of bytes containing the serialized transaction.

Source

pub fn from_slice(data: &'a [u8]) -> Result<Self, ProgramError>

Deserializes a byte slice into a TransactionToSign.

§Parameters
  • data - A byte slice containing the serialized transaction.
§Returns

A new TransactionToSign instance.

§Panics

This function will panic if the input data is malformed or doesn’t contain enough bytes for the expected format.

Trait Implementations§

Source§

impl<'a> Clone for TransactionToSign<'a>

Source§

fn clone(&self) -> TransactionToSign<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for TransactionToSign<'a>

Source§

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

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

impl<'a> Default for TransactionToSign<'a>

Source§

fn default() -> TransactionToSign<'a>

Returns the “default value” for a type. Read more
Source§

impl<'a> PartialEq for TransactionToSign<'a>

Source§

fn eq(&self, other: &TransactionToSign<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Eq for TransactionToSign<'a>

Source§

impl<'a> StructuralPartialEq for TransactionToSign<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for TransactionToSign<'a>

§

impl<'a> RefUnwindSafe for TransactionToSign<'a>

§

impl<'a> Send for TransactionToSign<'a>

§

impl<'a> Sync for TransactionToSign<'a>

§

impl<'a> Unpin for TransactionToSign<'a>

§

impl<'a> UnsafeUnpin for TransactionToSign<'a>

§

impl<'a> UnwindSafe for TransactionToSign<'a>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.