Struct ledger_zcash_builder::txbuilder::Builder
source · pub struct Builder<P: Parameters, R: RngCore + CryptoRng, A: Authorization> { /* private fields */ }
Expand description
Generates a Transaction
from its inputs and outputs.
This is a rather low level builder, and is a HSM-compatible version
of [crate::zcash::primitives::transaction::builder::Builder
].
Implementations§
sourcepub fn new(params: P, height: u32) -> Self
pub fn new(params: P, height: u32) -> Self
Creates a new Builder
targeted for inclusion in the block with the
given height, using default values for general transaction fields
and the default OS random.
§Default values
The expiry height will be set to the given height plus the default transaction expiry delta (20 blocks).
The fee will be set to the default fee (0.0001 ZEC).
pub fn new_with_fee(params: P, height: u32, fee: u64) -> Self
sourcepub fn new_with_rng(params: P, height: u32, rng: R) -> Self
pub fn new_with_rng(params: P, height: u32, rng: R) -> Self
Creates a new Builder
targeted for inclusion in the block with the
given height and randomness source, using default values for general
transaction fields.
§Default values
The expiry height will be set to the given height plus the default transaction expiry delta (20 blocks).
The fee will be set to the default fee (0.0001 ZEC).
pub fn new_with_fee_rng(params: P, height: u32, rng: R, fee: u64) -> Self
source§impl<P, R, A> Builder<P, R, A>where
P: Parameters,
R: RngCore + CryptoRng,
A: Authorization,
A::TransparentAuth: Clone,
A::SaplingAuth: Clone,
impl<P, R, A> Builder<P, R, A>where
P: Parameters,
R: RngCore + CryptoRng,
A: Authorization,
A::TransparentAuth: Clone,
A::SaplingAuth: Clone,
sourcepub fn transaction_data(&self) -> Option<TransactionData<A>>
pub fn transaction_data(&self) -> Option<TransactionData<A>>
Retrieve the TransactionData
of the current builder state
sourcepub fn add_sapling_spend(
&mut self,
diversifier: Diversifier,
note: Note,
merkle_path: MerklePath<Node>,
alpha: Fr,
proofkey: ProofGenerationKey,
rcv: Fr
) -> Result<(), Error>
pub fn add_sapling_spend( &mut self, diversifier: Diversifier, note: Note, merkle_path: MerklePath<Node>, alpha: Fr, proofkey: ProofGenerationKey, rcv: Fr ) -> Result<(), Error>
Adds a Sapling note to be spent in this transaction.
Returns an error if the given Merkle path does not have the same anchor as the paths for previous Sapling notes.
sourcepub fn add_sapling_output(
&mut self,
ovk: Option<OutgoingViewingKey>,
to: PaymentAddress,
value: Amount,
memo: Option<Memo>,
rcv: Fr,
rseed: Rseed,
hash_seed: Option<HashSeed>
) -> Result<(), Error>
pub fn add_sapling_output( &mut self, ovk: Option<OutgoingViewingKey>, to: PaymentAddress, value: Amount, memo: Option<Memo>, rcv: Fr, rseed: Rseed, hash_seed: Option<HashSeed> ) -> Result<(), Error>
Adds a Sapling address to send funds to.
sourcepub fn build(
&mut self,
consensus_branch_id: BranchId,
tx_version: Option<TxVersion>,
prover: &impl HsmTxProver
) -> Result<HsmTxData, Error>
pub fn build( &mut self, consensus_branch_id: BranchId, tx_version: Option<TxVersion>, prover: &impl HsmTxProver ) -> Result<HsmTxData, Error>
Prepares a transaction to be transmitted to the HSM from the configured spends and outputs.
Upon success, returns the structure that can be serialized in in the format understood by the HSM and subsequently transmitted via the appropriate method.
After having retrieved the signatures from the HSM and having applied
them with the appropriate methods of the builder, it’s possible to
retrieve the final signature using Builder::finalize
consensus_branch_id
must be valid for the block height that this
transaction is targeting. An invalid consensus_branch_id
will
not result in an error from this function, and instead will
generate a transaction that will be rejected by the network.
pub fn build_with_progress_notifier( &mut self, consensus_branch_id: BranchId, tx_version: Option<TxVersion>, prover: &impl HsmTxProver, progress_notifier: Option<Sender<Progress>> ) -> Result<HsmTxData, Error>
sourcepub fn add_signatures_transparent(
self,
signatures: Vec<Signature>
) -> Result<Builder<P, R, MixedAuthorization<Authorized, SA>>, Error>
pub fn add_signatures_transparent( self, signatures: Vec<Signature> ) -> Result<Builder<P, R, MixedAuthorization<Authorized, SA>>, Error>
Attempt to apply the signatures for the transparent components of the transaction
sourcepub fn add_signatures_spend(
self,
signatures: Vec<Signature>
) -> Result<Builder<P, R, MixedAuthorization<TA, Authorized>>, Error>
pub fn add_signatures_spend( self, signatures: Vec<Signature> ) -> Result<Builder<P, R, MixedAuthorization<TA, Authorized>>, Error>
Attempt to apply the signatures for the shielded components of the transaction
source§impl<P: Parameters, R: RngCore + CryptoRng> Builder<P, R, MixedAuthorization<Authorized, Authorized>>
impl<P: Parameters, R: RngCore + CryptoRng> Builder<P, R, MixedAuthorization<Authorized, Authorized>>
sourcepub fn finalize(self) -> Result<(Transaction, SaplingMetadata), Error>
pub fn finalize(self) -> Result<(Transaction, SaplingMetadata), Error>
Finalize the transaction, after having obtained all the signatures from the the HSM.
Upon success, returns a tuple containing the final transaction, and the
[TransactionMetadata
] generated during the build process.
Auto Trait Implementations§
impl<P, R, A> Freeze for Builder<P, R, A>where
R: Freeze,
P: Freeze,
<A as Authorization>::TransparentAuth: Freeze,
<A as Authorization>::SaplingAuth: Freeze,
impl<P, R, A> RefUnwindSafe for Builder<P, R, A>where
R: RefUnwindSafe,
P: RefUnwindSafe,
<A as Authorization>::TransparentAuth: RefUnwindSafe,
<A as Authorization>::SaplingAuth: RefUnwindSafe,
<<A as Authorization>::TransparentAuth as Authorization>::ScriptSig: RefUnwindSafe,
<<A as Authorization>::SaplingAuth as Authorization>::Proof: RefUnwindSafe,
<<A as Authorization>::SaplingAuth as Authorization>::AuthSig: RefUnwindSafe,
impl<P, R, A> Send for Builder<P, R, A>where
R: Send,
P: Send,
<A as Authorization>::TransparentAuth: Send,
<A as Authorization>::SaplingAuth: Send,
<<A as Authorization>::TransparentAuth as Authorization>::ScriptSig: Send,
<<A as Authorization>::SaplingAuth as Authorization>::Proof: Send,
<<A as Authorization>::SaplingAuth as Authorization>::AuthSig: Send,
impl<P, R, A> Sync for Builder<P, R, A>where
R: Sync,
P: Sync,
<A as Authorization>::TransparentAuth: Sync,
<A as Authorization>::SaplingAuth: Sync,
<<A as Authorization>::TransparentAuth as Authorization>::ScriptSig: Sync,
<<A as Authorization>::SaplingAuth as Authorization>::Proof: Sync,
<<A as Authorization>::SaplingAuth as Authorization>::AuthSig: Sync,
impl<P, R, A> Unpin for Builder<P, R, A>where
R: Unpin,
P: Unpin,
<A as Authorization>::TransparentAuth: Unpin,
<A as Authorization>::SaplingAuth: Unpin,
<<A as Authorization>::TransparentAuth as Authorization>::ScriptSig: Unpin,
<<A as Authorization>::SaplingAuth as Authorization>::Proof: Unpin,
<<A as Authorization>::SaplingAuth as Authorization>::AuthSig: Unpin,
impl<P, R, A> UnwindSafe for Builder<P, R, A>where
R: UnwindSafe,
P: UnwindSafe,
<A as Authorization>::TransparentAuth: UnwindSafe,
<A as Authorization>::SaplingAuth: UnwindSafe,
<<A as Authorization>::TransparentAuth as Authorization>::ScriptSig: UnwindSafe,
<<A as Authorization>::SaplingAuth as Authorization>::Proof: UnwindSafe,
<<A as Authorization>::SaplingAuth as Authorization>::AuthSig: UnwindSafe,
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> FmtForward for T
impl<T> FmtForward for T
source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> R
source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> Tap for T
impl<T> Tap for T
source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moresource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moresource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moresource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moresource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moresource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moresource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.