Skip to content

Documentation / @cashconnect-js/core / primitives/transaction

TransactionFromArgs ​

ts
type TransactionFromArgs = Parameters<typeof from>[0];

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:530


Transaction ​

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:160

Transaction Primitive.

Example ​

ts
// Import our primitives.
import { Transaction } from '@libcash/primitives';

// Instantiate primitive from Transaction Hex.
const transaction = Transaction.from('transactionHex');

// Output Transaction Information.
console.log(transaction.getVersion());
console.log(transaction.getLocktime());
console.log(transaction.getInputs());
console.log(transaction.getOutputs());

// Output the Transaction Hash.
console.log(transaction.toHash().toHex());

Extends ​

  • BaseTransaction

Methods ​

from() ​

ts
static from(transaction): Transaction;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:177

Instantiates a transaction from either:

  1. Transaction bytecode
  2. Transaction bytecode (in hexadecimal format)
Parameters ​
ParameterTypeDescription
transaction| string | Uint8Array<ArrayBufferLike> | TransactionBCH | TransactionThe transaction in one of the above formats.
Returns ​

Transaction

The created Transaction Primitive.

Throws ​

If transaction data cannot be decoded.

fromBytes() ​

ts
static fromBytes(bytes): Transaction;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:204

Create a Transaction Primitive from the given byte data.

Parameters ​
ParameterTypeDescription
bytesUint8ArrayThe raw byte data of the transaction.
Returns ​

Transaction

The created Transaction Primitive.

Throws ​

If transaction data cannot be decoded.

fromHex() ​

ts
static fromHex(hex): Transaction;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:226

Create a Transaction Primitive from the given byte data encoded as hexadecimal string.

Parameters ​
ParameterTypeDescription
hexstringThe raw byte data (encoded as hexadecimal string) of the transaction.
Returns ​

Transaction

The created Transaction Primitive.

Throws ​

If transaction cannot be decoded.

fromRaw() ​

ts
static fromRaw(transaction): Transaction;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:240

Create a Transaction Primitive from LibAuth's TransactionBCH type.

Parameters ​
ParameterTypeDescription
transactionTransactionBCHThe transaction object (as per LibAuth).
Returns ​

Transaction

The created Transaction Primitive.

Remarks ​

This method is UNSAFE and MUST only be used where input is already verified or trusted.

isValid() ​

ts
static isValid(transaction): boolean;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:251

Validates the structure of a transaction.

Parameters ​
ParameterTypeDescription
transactionstring | Uint8Array<ArrayBufferLike>The transaction (as hex or bytes).
Returns ​

boolean

boolean indicating whether the transaction structure is valid.

toRaw() ​

ts
toRaw(): TransactionBCH;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:265

Converts transaction to a raw object representation.

Returns ​

TransactionBCH

A TransactionBCH LibAuth object.

toBytes() ​

ts
toBytes(): Uint8Array;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:24

Serializes the transaction to a byte array.

Returns ​

Uint8Array

The transaction serialized as a Uint8Array

Inherited from ​
ts
BaseTransaction.toBytes

toHex() ​

ts
toHex(): string;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:34

Serializes the transaction to a byte array (represented as a hex string).

Returns ​

string

The transaction serialized in hex

Inherited from ​
ts
BaseTransaction.toHex

toHash() ​

ts
toHash(): TransactionHash;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:44

Hashes the transaction and returns a TransactionHash primitive.

Returns ​

TransactionHash

The transaction hash primitive.

Inherited from ​
ts
BaseTransaction.toHash

toHashHex() ​

ts
toHashHex(): string;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:52

Hashes the transaction and returns the hash as hexadecimal.

Returns ​

string

The transaction hash hex.

Inherited from ​
ts
BaseTransaction.toHashHex

toHashBytes() ​

ts
toHashBytes(): Uint8Array;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:60

Hashes the transaction and returns the hash as a Uint8Array.

Returns ​

Uint8Array

The transaction hash bytes.

Inherited from ​
ts
BaseTransaction.toHashBytes

getVersion() ​

ts
getVersion(): number;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:71

Experimental

Gets the version for this transaction.

Returns ​

number

The version of this transaction

Inherited from ​
ts
BaseTransaction.getVersion

getInputs() ​

ts
getInputs(): Input[];

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:82

Experimental

Gets the inputs in this transaction.

Returns ​

Input[]

The inputs in this transaction

Inherited from ​
ts
BaseTransaction.getInputs

getOutputs() ​

ts
getOutputs(): Output[];

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:93

Experimental

Gets the outputs in this transaction.

Returns ​

Output[]

The outputs in this transaction

Inherited from ​
ts
BaseTransaction.getOutputs

getLocktime() ​

ts
getLocktime(): number;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:104

Experimental

Gets the locktime for this transaction.

Returns ​

number

The locktime of this transaction

Inherited from ​
ts
BaseTransaction.getLocktime

isCoinbase() ​

ts
isCoinbase(): boolean;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:117

Experimental

Checks whether this transaction is a Coinbase Transaction.

Returns ​

boolean

True if this is a Coinbase Transaction

Remarks ​

UNTESTED

Inherited from ​
ts
BaseTransaction.isCoinbase

TransactionResolved ​

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:270

Extends ​

  • BaseTransaction

Methods ​

from() ​

ts
static from(transaction, sourceOutputs): TransactionResolved;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:293

Instantiates a transaction from either:

  1. Transaction bytecode
  2. Transaction bytecode (in hexadecimal format)
Parameters ​
ParameterTypeDescription
transactionstring | Uint8Array<ArrayBufferLike>The transaction in one of the above formats.
sourceOutputsany[]-
Returns ​

TransactionResolved

The created Transaction Primitive.

Throws ​

If transaction data cannot be decoded.

fromBytes() ​

ts
static fromBytes(bytes, sourceOutputs): TransactionResolved;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:311

Create a Transaction Primitive from the given byte data.

Parameters ​
ParameterTypeDescription
bytesUint8ArrayThe raw byte data of the transaction.
sourceOutputsany[]-
Returns ​

TransactionResolved

The created Transaction Primitive.

Throws ​

If transaction data cannot be decoded.

fromHex() ​

ts
static fromHex(hex, sourceOutputs): TransactionResolved;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:333

Create a Transaction Primitive from the given byte data encoded as hexadecimal string.

Parameters ​
ParameterTypeDescription
hexstringThe raw byte data (encoded as hexadecimal string) of the transaction.
sourceOutputsany[]-
Returns ​

TransactionResolved

The created Transaction Primitive.

Throws ​

If transaction cannot be decoded.

fromRaw() ​

ts
static fromRaw(resolvedTransaction): TransactionResolved;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:347

Create a Transaction Primitive from LibAuth's TransactionBCH type.

Parameters ​
ParameterTypeDescription
resolvedTransactionResolvedTransactionCommonThe transaction object (as per LibAuth).
Returns ​

TransactionResolved

The created Transaction Primitive.

Remarks ​

This method is UNSAFE and MUST only be used where input is already verified or trusted.

isValid() ​

ts
static isValid(transaction, sourceOutputs): boolean;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:361

Validates the structure of a transaction.

Parameters ​
ParameterTypeDescription
transactionstring | Uint8Array<ArrayBufferLike>The transaction (as hex or bytes).
sourceOutputsany[]-
Returns ​

boolean

boolean indicating whether the transaction structure is valid.

toRaw() ​

ts
toRaw(): object;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:374

Returns ​

object

NameTypeDefined in
transactionTransactionBCHcashconnect-js/packages/core/src/primitives/transaction.ts:376
sourceOutputsany[]cashconnect-js/packages/core/src/primitives/transaction.ts:377

toBytes() ​

ts
toBytes(): Uint8Array;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:24

Serializes the transaction to a byte array.

Returns ​

Uint8Array

The transaction serialized as a Uint8Array

Inherited from ​
ts
BaseTransaction.toBytes

toHex() ​

ts
toHex(): string;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:34

Serializes the transaction to a byte array (represented as a hex string).

Returns ​

string

The transaction serialized in hex

Inherited from ​
ts
BaseTransaction.toHex

toHash() ​

ts
toHash(): TransactionHash;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:44

Hashes the transaction and returns a TransactionHash primitive.

Returns ​

TransactionHash

The transaction hash primitive.

Inherited from ​
ts
BaseTransaction.toHash

toHashHex() ​

ts
toHashHex(): string;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:52

Hashes the transaction and returns the hash as hexadecimal.

Returns ​

string

The transaction hash hex.

Inherited from ​
ts
BaseTransaction.toHashHex

toHashBytes() ​

ts
toHashBytes(): Uint8Array;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:60

Hashes the transaction and returns the hash as a Uint8Array.

Returns ​

Uint8Array

The transaction hash bytes.

Inherited from ​
ts
BaseTransaction.toHashBytes

getVersion() ​

ts
getVersion(): number;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:71

Experimental

Gets the version for this transaction.

Returns ​

number

The version of this transaction

Inherited from ​
ts
BaseTransaction.getVersion

getInputs() ​

ts
getInputs(): Input[];

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:82

Experimental

Gets the inputs in this transaction.

Returns ​

Input[]

The inputs in this transaction

Inherited from ​
ts
BaseTransaction.getInputs

getOutputs() ​

ts
getOutputs(): Output[];

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:93

Experimental

Gets the outputs in this transaction.

Returns ​

Output[]

The outputs in this transaction

Inherited from ​
ts
BaseTransaction.getOutputs

getLocktime() ​

ts
getLocktime(): number;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:104

Experimental

Gets the locktime for this transaction.

Returns ​

number

The locktime of this transaction

Inherited from ​
ts
BaseTransaction.getLocktime

isCoinbase() ​

ts
isCoinbase(): boolean;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:117

Experimental

Checks whether this transaction is a Coinbase Transaction.

Returns ​

boolean

True if this is a Coinbase Transaction

Remarks ​

UNTESTED

Inherited from ​
ts
BaseTransaction.isCoinbase

TransactionHash ​

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:385

Transaction Hash Primitive.

Methods ​

from() ​

ts
static from(hash): TransactionHash;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:404

Instantiates a TransactionHash from either the Hash Hex or Hash Bytes.

Parameters ​
ParameterTypeDescription
hashstring | Uint8Array<ArrayBufferLike>The Transaction Hash as either hex or bytes.
Returns ​

TransactionHash

The created Public Key Primitive.

Throws ​

If the hash is invalid.

fromBytes() ​

ts
static fromBytes(bytes): TransactionHash;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:419

Instantiates TransactionHash from Hash Bytes.

Parameters ​
ParameterTypeDescription
bytesUint8ArrayThe hash as bytes.
Returns ​

TransactionHash

Instance of TransactionHash.

Throws ​

If hash is invalid.

fromHex() ​

ts
static fromHex(hex): TransactionHash;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:439

Instantiates TransactionHash from a hex string.

Parameters ​
ParameterTypeDescription
hexstring{string} The hex string.
Returns ​

TransactionHash

Instance of TransactionHash.

Throws ​

If hex is invalid.

fromTransaction() ​

ts
static fromTransaction(transaction): TransactionHash;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:453

Instantiates a TransactionHash from either the Transaction Hex or Transaction Hash.

Parameters ​
ParameterTypeDescription
transactionstring | Uint8Array<ArrayBufferLike>The Transaction as either hex or bytes.
Returns ​

TransactionHash

The created Public Key Primitive.

Throws ​

If the public key cannot be decoded.

fromTransactionBytes() ​

ts
static fromTransactionBytes(transactionBytes): TransactionHash;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:466

Instantiates TransactionHash from a Transaction's bytes.

Parameters ​
ParameterTypeDescription
transactionBytesUint8Array{Uint8Array} The Transaction's bytes.
Returns ​

TransactionHash

Instance of TransactionHash.

fromTransactionHex() ​

ts
static fromTransactionHex(transactionHex): TransactionHash;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:483

Instantiates TransactionHash from a Transaction's bytes in hex.

Parameters ​
ParameterTypeDescription
transactionHexstring{Uint8Array} The Transaction's bytes in hex.
Returns ​

TransactionHash

Instance of TransactionHash.

Throws ​

If hex is invalid.

fromRaw() ​

ts
static fromRaw(bytes): TransactionHash;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:497

Creates an instance from serialized data.

Parameters ​
ParameterTypeDescription
bytesUint8ArraySerialized Primitive Data
Returns ​

TransactionHash

A new instance of this primitive.

Remarks ​

This method is UNSAFE and MUST only be used where input is already verified or trusted.

toHex() ​

ts
toHex(): string;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:506

Returns transaction hash as a hex string.

Returns ​

string

Hex string of the Transaction Hash.

toBytes() ​

ts
toBytes(): Uint8Array;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:515

Returns transaction hash as a Uint8Array.

Returns ​

Uint8Array

Uint8Array of the Transaction Hash.

toRaw() ​

ts
toRaw(): Uint8Array<ArrayBufferLike>;

Defined in: cashconnect-js/packages/core/src/primitives/transaction.ts:524

Converts this primitive to a serializable representation.

Returns ​

Uint8Array<ArrayBufferLike>

Serialzied primitive data.