Class TransactionExtensions
Useful extension methods for ITransaction.
Inherited Members
Namespace: Libplanet.Types.Tx
Assembly: Libplanet.Types.dll
Syntax
public static class TransactionExtensions
Methods
| Improve this Doc View SourceCombine(ITxInvoice, ITxSigningMetadata)
Creates a new UnsignedTx instance by combining an ITxInvoice and an ITxSigningMetadata. Note that when the arguments are not instances of TxInvoice or TxSigningMetadata, this constructor creates new instances of TxInvoice and TxSigningMetadata by copying.
Declaration
public static UnsignedTx Combine(this ITxInvoice invoice, ITxSigningMetadata signingMetadata)
Parameters
Type | Name | Description |
---|---|---|
ITxInvoice | invoice | The invoice to combine with |
ITxSigningMetadata | signingMetadata | The signing metadata to combine with
|
Returns
Type | Description |
---|---|
UnsignedTx | An UnsignedTx instance. |
Sign(ITxInvoice, PrivateKey, Int64)
Creates a new Transaction instance by signing the given
invoice
with the given privateKey
.
Declaration
public static Transaction Sign(this ITxInvoice invoice, PrivateKey privateKey, long nonce)
Parameters
Type | Name | Description |
---|---|---|
ITxInvoice | invoice | The ITxInvoice to sign. |
PrivateKey | privateKey | The PrivateKey to sign the transaction. |
System.Int64 | nonce | The nonce to use for the transaction. |
Returns
Type | Description |
---|---|
Transaction | A Transaction instance. |
Sign(IUnsignedTx, PrivateKey)
Creates a new Transaction instance by signing an
unsignedTx
with a privateKey
.
Declaration
public static Transaction Sign(this IUnsignedTx unsignedTx, PrivateKey privateKey)
Parameters
Type | Name | Description |
---|---|---|
IUnsignedTx | unsignedTx | The IUnsignedTx instance to sign. |
PrivateKey | privateKey | The private key to sign |
Returns
Type | Description |
---|---|
Transaction | A Transaction instance. |
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown when the given |
ValidateTxNonces(IEnumerable<ITransaction>, Int64)
Validates if transactions
has valid nonces.
It assumes all given transactions
belong to a block together.
Declaration
public static void ValidateTxNonces(this IEnumerable<ITransaction> transactions, long blockIndex)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<ITransaction> | transactions | A list of transactions. Their order does not matter. |
System.Int64 | blockIndex | The index of the block that transactions will belong to. It's only used for exception messages. |
Exceptions
Type | Condition |
---|---|
InvalidTxNonceException | Thrown when the same tx nonce is used by
a signer twice or more, or a tx nonce is used without its previous nonce by a signer.
Note that this validates only a block's intrinsic integrity between its transactions,
but does not guarantee integrity between blocks. Such validation needs to be conducted
by |
InvalidTxGenesisHashException | Thrown when transactions to set have inconsistent genesis hashes. |
Verify(IUnsignedTx, ImmutableArray<Byte>)
Creates a new Transaction instance by verifying a
signature
of an unsignedTx
.
Declaration
public static Transaction Verify(this IUnsignedTx unsignedTx, ImmutableArray<byte> signature)
Parameters
Type | Name | Description |
---|---|---|
IUnsignedTx | unsignedTx | The IUnsignedTx instance to combine with
|
System.Collections.Immutable.ImmutableArray<System.Byte> | signature | The signature to combine with |
Returns
Type | Description |
---|---|
Transaction | A Transaction instance. |
Exceptions
Type | Condition |
---|---|
InvalidTxSignatureException | Thrown when the given
|