pub struct TransactionV2Builder { /* private fields */ }
Expand description
A builder for a NotarizedTransactionV2
.
This should be used in the following order:
- Configure the root transaction intent:
- Set the
transaction_header
- Set the
intent_header
- Optionally, set the
message
- Optionally, add one or more signed partial transaction children with
add_signed_child
. These can be created with thePartialTransactionV2Builder
methods [build_with_names()
][PartialTransactionV2Builder::build_with_names] orbuild
. - Set the manifest with
manifest_builder
.
- Set the
- Sign the root transaction manifest zero or more times:
- Use methods
sign
ormulti_sign
add_signature
- Use methods
- Notarize once with the notary key from the intent header:
- Use either
notarize
ornotary_signature
.
- Use either
- Build:
- Use method
build
,build_no_validate
,build_minimal
orbuild_minimal_no_validate
- Use method
The error messages aren’t great if used out of order. In future, this may become a state-machine style builder, to catch more errors at compile time.
Implementations§
Source§impl TransactionV2Builder
impl TransactionV2Builder
pub fn new() -> TransactionV2Builder
pub fn then( self, next: impl FnOnce(TransactionV2Builder) -> TransactionV2Builder, ) -> TransactionV2Builder
Sourcepub fn add_signed_child(
self,
name: impl AsRef<str>,
signed_partial_transaction: impl ResolvableSignedPartialTransaction,
) -> TransactionV2Builder
pub fn add_signed_child( self, name: impl AsRef<str>, signed_partial_transaction: impl ResolvableSignedPartialTransaction, ) -> TransactionV2Builder
When used with the manifest_builder
method, the provided name and hash
are provided automatically via use_child
at the start of manifest creation.
When used with the manifest
method, the provided name is simply ignored - names
are returned from the provided manifest.
Sourcepub fn manifest_builder(
self,
build_manifest: impl FnOnce(ManifestBuilder<TransactionManifestV2>) -> ManifestBuilder<TransactionManifestV2>,
) -> TransactionV2Builder
pub fn manifest_builder( self, build_manifest: impl FnOnce(ManifestBuilder<TransactionManifestV2>) -> ManifestBuilder<TransactionManifestV2>, ) -> TransactionV2Builder
If the intent has any children, you should call add_signed_child
first.
These children will get added to the manifest for you, with the corresponding names.
You may also want to try manifest_builder_with_lookup
.
Sourcepub fn manifest_builder_with_lookup(
self,
build_manifest: impl FnOnce(ManifestBuilder<TransactionManifestV2>, ManifestNameLookup) -> ManifestBuilder<TransactionManifestV2>,
) -> TransactionV2Builder
pub fn manifest_builder_with_lookup( self, build_manifest: impl FnOnce(ManifestBuilder<TransactionManifestV2>, ManifestNameLookup) -> ManifestBuilder<TransactionManifestV2>, ) -> TransactionV2Builder
If the intent has any children, you should call add_signed_child
first.
These children will get added to the manifest for you, with the corresponding names.
Sourcepub fn manifest(self, manifest: TransactionManifestV2) -> TransactionV2Builder
pub fn manifest(self, manifest: TransactionManifestV2) -> TransactionV2Builder
§Panics:
- If called with a manifest which references different children to those provided by
add_signed_child
.
pub fn message(self, message: MessageV2) -> TransactionV2Builder
pub fn intent_header( self, intent_header: IntentHeaderV2, ) -> TransactionV2Builder
pub fn transaction_header( self, transaction_header: TransactionHeaderV2, ) -> TransactionV2Builder
pub fn create_intent_and_subintent_info(&mut self) -> &TransactionIntentV2
pub fn create_prepared_intent(&mut self) -> &PreparedTransactionIntentV2
pub fn intent_hash(&mut self) -> TransactionIntentHash
pub fn sign<S>(self, signer: S) -> TransactionV2Builderwhere
S: Signer,
pub fn multi_sign<S>(
self,
signers: impl IntoIterator<Item = S>,
) -> TransactionV2Builderwhere
S: Signer,
pub fn add_signature( self, signature: SignatureWithPublicKeyV1, ) -> TransactionV2Builder
pub fn create_signed_transaction_intent(&mut self) -> &SignedTransactionIntentV2
pub fn create_prepared_signed_transaction_intent( &mut self, ) -> &PreparedSignedTransactionIntentV2
pub fn notarize<S>(self, signer: &S) -> TransactionV2Builderwhere
S: Signer,
pub fn notary_signature(self, signature: SignatureV1) -> TransactionV2Builder
Sourcepub fn build_preview_transaction(
&mut self,
transaction_intent_signer_keys: impl IntoIterator<Item = PublicKey>,
) -> PreviewTransactionV2
pub fn build_preview_transaction( &mut self, transaction_intent_signer_keys: impl IntoIterator<Item = PublicKey>, ) -> PreviewTransactionV2
Creates a PreviewTransactionV2
. For all non-root subintents, existing signatures
are converted into the corresponding public key.
§Panics
- Panics if any subintent signatures are not recoverable. Untrusted partial transactions should be validated before using in the transaction builder.
- If the resulting preview transaction could not be validated.
Sourcepub fn build_preview_transaction_no_validate(
&mut self,
transaction_intent_signer_keys: impl IntoIterator<Item = PublicKey>,
) -> PreviewTransactionV2
pub fn build_preview_transaction_no_validate( &mut self, transaction_intent_signer_keys: impl IntoIterator<Item = PublicKey>, ) -> PreviewTransactionV2
Creates a PreviewTransactionV2
. For all non-root subintents, existing signatures
are converted into the corresponding public key.
§Panics
- Panics if any subintent signatures are not recoverable. Untrusted partial transactions should be validated before using in the transaction builder.
Sourcepub fn build_no_validate(self) -> DetailedNotarizedTransactionV2
pub fn build_no_validate(self) -> DetailedNotarizedTransactionV2
Builds a DetailedNotarizedTransactionV2
, including the NotarizedTransactionV2
and other useful data.
§Panics
- If the builder has not been notarized
- If the transaction is not preparable against latest settings (e.g. it is too big)
Sourcepub fn build(self) -> DetailedNotarizedTransactionV2
pub fn build(self) -> DetailedNotarizedTransactionV2
Builds and validates a DetailedNotarizedTransactionV2
, which includes
a NotarizedTransactionV2
and other useful data.
§Panics
- Panics if the built transaction does not pass validation with the latest validator.
You can use build_no_validate()
to skip this validation.
Sourcepub fn build_minimal_no_validate(self) -> NotarizedTransactionV2
pub fn build_minimal_no_validate(self) -> NotarizedTransactionV2
Builds the NotarizedTransactionV2
, with no validation.
Sourcepub fn build_minimal(self) -> NotarizedTransactionV2
pub fn build_minimal(self) -> NotarizedTransactionV2
Builds and validates the NotarizedTransactionV2
.
You may prefer build()
instead if you need the transaction hashes,
or wish to keep a record of the names used in the manifest variables.
§Panics
Panics if the built transaction does not pass validation with the latest validator.
You can use build_minimal_no_validate()
to skip this validation.
Trait Implementations§
Source§impl Clone for TransactionV2Builder
impl Clone for TransactionV2Builder
Source§fn clone(&self) -> TransactionV2Builder
fn clone(&self) -> TransactionV2Builder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Default for TransactionV2Builder
impl Default for TransactionV2Builder
Source§fn default() -> TransactionV2Builder
fn default() -> TransactionV2Builder
Auto Trait Implementations§
impl Freeze for TransactionV2Builder
impl RefUnwindSafe for TransactionV2Builder
impl Send for TransactionV2Builder
impl Sync for TransactionV2Builder
impl Unpin for TransactionV2Builder
impl UnwindSafe for TransactionV2Builder
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, U> ContextualTryInto<U> for Twhere
U: ContextualTryFrom<T>,
impl<T, U> ContextualTryInto<U> for Twhere
U: ContextualTryFrom<T>,
type Error = <U as ContextualTryFrom<T>>::Error
type Context = <U as ContextualTryFrom<T>>::Context
fn contextual_try_into( self, context: &<U as ContextualTryFrom<T>>::Context, ) -> Result<U, <U as ContextualTryFrom<T>>::Error>
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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 more