Struct zcash_hsmbuilder::txbuilder::Builder
source · [−]pub struct Builder<P: Parameters, R: RngCore + CryptoRng> {
pub sighash: [u8; 32],
/* 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 zcash_primitives::transaction::builder::Builder
.
Fields
sighash: [u8; 32]
Implementations
sourceimpl<P: Parameters> Builder<P, OsRng>
impl<P: Parameters> Builder<P, OsRng>
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
sourceimpl<P: Parameters, R: RngCore + CryptoRng> Builder<P, R>
impl<P: Parameters, R: RngCore + CryptoRng> Builder<P, R>
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
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 add_transparent_input(
&mut self,
pubkey: PublicKey,
utxo: OutPoint,
coin: TxOut
) -> Result<(), Error>
pub fn add_transparent_input(
&mut self,
pubkey: PublicKey,
utxo: OutPoint,
coin: TxOut
) -> Result<(), Error>
Adds a transparent coin to be spent in this transaction.
sourcepub fn add_transparent_output(
&mut self,
to: Script,
value: Amount
) -> Result<(), Error>
pub fn add_transparent_output(
&mut self,
to: Script,
value: Amount
) -> Result<(), Error>
Adds a transparent address to send funds to.
sourcepub fn build(
&mut self,
consensus_branch_id: BranchId,
prover: &impl HsmTxProver
) -> Result<HsmTxData, Error>
pub fn build(
&mut self,
consensus_branch_id: BranchId,
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.
sourcepub fn add_signatures_transparant(
&mut self,
signatures: Vec<Signature>,
consensus_branch_id: BranchId
) -> Result<(), Error>
pub fn add_signatures_transparant(
&mut self,
signatures: Vec<Signature>,
consensus_branch_id: BranchId
) -> Result<(), Error>
Attempt to apply the signatures for the transparent components of the transaction
sourcepub fn add_signatures_spend(
&mut self,
sign: Vec<Signature>
) -> Result<(), Error>
pub fn add_signatures_spend(
&mut self,
sign: Vec<Signature>
) -> Result<(), Error>
Attempt to apply the signatures for the shielded components of the transaction
sourcepub fn finalize(self) -> Result<(Transaction, TransactionMetadata), Error>
pub fn finalize(self) -> Result<(Transaction, TransactionMetadata), 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> RefUnwindSafe for Builder<P, R> where
P: RefUnwindSafe,
R: RefUnwindSafe,
impl<P, R> Send for Builder<P, R> where
P: Send,
R: Send,
impl<P, R> Sync for Builder<P, R> where
P: Sync,
R: Sync,
impl<P, R> Unpin for Builder<P, R> where
P: Unpin,
R: Unpin,
impl<P, R> UnwindSafe for Builder<P, R> where
P: UnwindSafe,
R: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> FmtForward for T
impl<T> FmtForward for T
fn fmt_binary(self) -> FmtBinary<Self> where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self> where
Self: Binary,
Causes self
to use its Binary
implementation when Debug
-formatted.
fn fmt_display(self) -> FmtDisplay<Self> where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self> where
Self: Display,
Causes self
to use its Display
implementation when
Debug
-formatted. Read more
fn fmt_lower_exp(self) -> FmtLowerExp<Self> where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self> where
Self: LowerExp,
Causes self
to use its LowerExp
implementation when
Debug
-formatted. Read more
fn fmt_lower_hex(self) -> FmtLowerHex<Self> where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self> where
Self: LowerHex,
Causes self
to use its LowerHex
implementation when
Debug
-formatted. Read more
fn fmt_octal(self) -> FmtOctal<Self> where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self> where
Self: Octal,
Causes self
to use its Octal
implementation when Debug
-formatted.
fn fmt_pointer(self) -> FmtPointer<Self> where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self> where
Self: Pointer,
Causes self
to use its Pointer
implementation when
Debug
-formatted. Read more
fn fmt_upper_exp(self) -> FmtUpperExp<Self> where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self> where
Self: UpperExp,
Causes self
to use its UpperExp
implementation when
Debug
-formatted. Read more
fn fmt_upper_hex(self) -> FmtUpperHex<Self> where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self> where
Self: UpperHex,
Causes self
to use its UpperHex
implementation when
Debug
-formatted. Read more
impl<T> PipeAsRef for T
impl<T> PipeAsRef for T
fn pipe_as_ref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: AsRef<T>,
T: 'a,
R: 'a,
fn pipe_as_ref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: AsRef<T>,
T: 'a,
R: 'a,
Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more
fn pipe_as_mut<'a, T, R>(&'a mut self, func: impl FnOnce(&'a mut T) -> R) -> R where
Self: AsMut<T>,
T: 'a,
R: 'a,
fn pipe_as_mut<'a, T, R>(&'a mut self, func: impl FnOnce(&'a mut T) -> R) -> R where
Self: AsMut<T>,
T: 'a,
R: 'a,
Pipes a trait mutable borrow into a function that cannot normally be called in suffix position. Read more
impl<T> PipeBorrow for T
impl<T> PipeBorrow for T
fn pipe_borrow<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: Borrow<T>,
T: 'a,
R: 'a,
fn pipe_borrow<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: Borrow<T>,
T: 'a,
R: 'a,
Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more
fn pipe_borrow_mut<'a, T, R>(
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
Self: BorrowMut<T>,
T: 'a,
R: 'a,
fn pipe_borrow_mut<'a, T, R>(
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
Self: BorrowMut<T>,
T: 'a,
R: 'a,
Pipes a trait mutable borrow into a function that cannot normally be called in suffix position. Read more
impl<T> PipeDeref for T
impl<T> PipeDeref for T
fn pipe_deref<'a, R>(&'a self, func: impl FnOnce(&'a Self::Target) -> R) -> R where
Self: Deref,
R: 'a,
fn pipe_deref<'a, R>(&'a self, func: impl FnOnce(&'a Self::Target) -> R) -> R where
Self: Deref,
R: 'a,
Pipes a dereference into a function that cannot normally be called in suffix position. Read more
fn pipe_deref_mut<'a, R>(
&'a mut self,
func: impl FnOnce(&'a mut Self::Target) -> R
) -> R where
Self: DerefMut,
R: 'a,
fn pipe_deref_mut<'a, R>(
&'a mut self,
func: impl FnOnce(&'a mut Self::Target) -> R
) -> R where
Self: DerefMut,
R: 'a,
Pipes a mutable dereference into a function that cannot normally be called in suffix position. Read more
impl<T> PipeRef for T
impl<T> PipeRef for T
impl<T> Tap for T
impl<T> Tap for T
fn tap<F, R>(self, func: F) -> Self where
F: FnOnce(&Self) -> R,
fn tap<F, R>(self, func: F) -> Self where
F: FnOnce(&Self) -> R,
Provides immutable access for inspection. Read more
fn tap_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&Self) -> R,
fn tap_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&Self) -> R,
Calls tap
in debug builds, and does nothing in release builds.
fn tap_mut<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self) -> R,
fn tap_mut<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self) -> R,
Provides mutable access for modification. Read more
fn tap_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self) -> R,
fn tap_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self) -> R,
Calls tap_mut
in debug builds, and does nothing in release builds.
impl<T, U> TapAsRef<U> for T where
U: ?Sized,
impl<T, U> TapAsRef<U> for T where
U: ?Sized,
fn tap_ref<F, R>(self, func: F) -> Self where
Self: AsRef<T>,
F: FnOnce(&T) -> R,
fn tap_ref<F, R>(self, func: F) -> Self where
Self: AsRef<T>,
F: FnOnce(&T) -> R,
Provides immutable access to the reference for inspection.
fn tap_ref_dbg<F, R>(self, func: F) -> Self where
Self: AsRef<T>,
F: FnOnce(&T) -> R,
fn tap_ref_dbg<F, R>(self, func: F) -> Self where
Self: AsRef<T>,
F: FnOnce(&T) -> R,
Calls tap_ref
in debug builds, and does nothing in release builds.
fn tap_ref_mut<F, R>(self, func: F) -> Self where
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
fn tap_ref_mut<F, R>(self, func: F) -> Self where
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
Provides mutable access to the reference for modification.
fn tap_ref_mut_dbg<F, R>(self, func: F) -> Self where
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
fn tap_ref_mut_dbg<F, R>(self, func: F) -> Self where
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
Calls tap_ref_mut
in debug builds, and does nothing in release builds.
impl<T, U> TapBorrow<U> for T where
U: ?Sized,
impl<T, U> TapBorrow<U> for T where
U: ?Sized,
fn tap_borrow<F, R>(self, func: F) -> Self where
Self: Borrow<T>,
F: FnOnce(&T) -> R,
fn tap_borrow<F, R>(self, func: F) -> Self where
Self: Borrow<T>,
F: FnOnce(&T) -> R,
Provides immutable access to the borrow for inspection. Read more
fn tap_borrow_dbg<F, R>(self, func: F) -> Self where
Self: Borrow<T>,
F: FnOnce(&T) -> R,
fn tap_borrow_dbg<F, R>(self, func: F) -> Self where
Self: Borrow<T>,
F: FnOnce(&T) -> R,
Calls tap_borrow
in debug builds, and does nothing in release builds.
fn tap_borrow_mut<F, R>(self, func: F) -> Self where
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
fn tap_borrow_mut<F, R>(self, func: F) -> Self where
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
Provides mutable access to the borrow for modification.
fn tap_borrow_mut_dbg<F, R>(self, func: F) -> Self where
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
fn tap_borrow_mut_dbg<F, R>(self, func: F) -> Self where
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
Calls tap_borrow_mut
in debug builds, and does nothing in release
builds. Read more
impl<T> TapDeref for T
impl<T> TapDeref for T
fn tap_deref<F, R>(self, func: F) -> Self where
Self: Deref,
F: FnOnce(&Self::Target) -> R,
fn tap_deref<F, R>(self, func: F) -> Self where
Self: Deref,
F: FnOnce(&Self::Target) -> R,
Immutably dereferences self
for inspection.
fn tap_deref_dbg<F, R>(self, func: F) -> Self where
Self: Deref,
F: FnOnce(&Self::Target) -> R,
fn tap_deref_dbg<F, R>(self, func: F) -> Self where
Self: Deref,
F: FnOnce(&Self::Target) -> R,
Calls tap_deref
in debug builds, and does nothing in release builds.
fn tap_deref_mut<F, R>(self, func: F) -> Self where
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
fn tap_deref_mut<F, R>(self, func: F) -> Self where
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
Mutably dereferences self
for modification.
fn tap_deref_mut_dbg<F, R>(self, func: F) -> Self where
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
fn tap_deref_mut_dbg<F, R>(self, func: F) -> Self where
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
Calls tap_deref_mut
in debug builds, and does nothing in release
builds. Read more