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() -> Self
pub fn then(self, next: impl FnOnce(Self) -> Self) -> Self
Sourcepub fn add_signed_child(
self,
name: impl AsRef<str>,
signed_partial_transaction: impl ResolvableSignedPartialTransaction,
) -> Self
pub fn add_signed_child( self, name: impl AsRef<str>, signed_partial_transaction: impl ResolvableSignedPartialTransaction, ) -> Self
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(TransactionManifestV2Builder) -> TransactionManifestV2Builder,
) -> Self
pub fn manifest_builder( self, build_manifest: impl FnOnce(TransactionManifestV2Builder) -> TransactionManifestV2Builder, ) -> Self
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(TransactionManifestV2Builder, ManifestNameLookup) -> TransactionManifestV2Builder,
) -> Self
pub fn manifest_builder_with_lookup( self, build_manifest: impl FnOnce(TransactionManifestV2Builder, ManifestNameLookup) -> TransactionManifestV2Builder, ) -> Self
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) -> Self
pub fn manifest(self, manifest: TransactionManifestV2) -> Self
§Panics:
- If called with a manifest which references different children to those provided by
add_signed_child
.
pub fn message(self, message: MessageV2) -> Self
pub fn intent_header(self, intent_header: IntentHeaderV2) -> Self
pub fn transaction_header(self, transaction_header: TransactionHeaderV2) -> Self
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: Signer>(self, signer: S) -> Self
pub fn multi_sign<S: Signer>(self, signers: impl IntoIterator<Item = S>) -> Self
pub fn add_signature(self, signature: SignatureWithPublicKeyV1) -> Self
pub fn create_signed_transaction_intent(&mut self) -> &SignedTransactionIntentV2
pub fn create_prepared_signed_transaction_intent( &mut self, ) -> &PreparedSignedTransactionIntentV2
pub fn notarize<S: Signer>(self, signer: &S) -> Self
pub fn notary_signature(self, signature: SignatureV1) -> Self
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 more