Show / Hide Table of Contents

Class TransactionExtensions

Useful extension methods for ITransaction.

Inheritance
System.Object
TransactionExtensions
Namespace: Libplanet.Types.Tx
Assembly: Libplanet.Types.dll
Syntax
public static class TransactionExtensions : object

Methods

| Improve this Doc View Source

Combine(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 signingMetadata.

ITxSigningMetadata signingMetadata

The signing metadata to combine with invoice.

Returns
Type Description
UnsignedTx

An UnsignedTx instance.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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 unsignedTx with.

Returns
Type Description
Transaction

A Transaction instance.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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 signature.

ImmutableArray<System.Byte> signature

The signature to combine with unsignedTx.

Returns
Type Description
Transaction

A Transaction instance.

Exceptions
Type Condition
InvalidTxSignatureException

Thrown when the given signature is not valid for unsignedTx.

  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2023 Planetarium