navio-blsct
Version:
TypeScript bindings for the `libblsct` library used by the [Navio](https://nav.io/) blockchain to construct confidential transactions based on the BLS12-381 curve.
87 lines (86 loc) • 3.59 kB
TypeScript
import { ManagedObj } from './managedObj';
import { OutPoint } from './outPoint';
import { Scalar } from './scalar';
import { TokenId } from './tokenId';
/** Represents a transaction input used to construct CTxIn in a confidential transaction.
*
* Examples:
* ```ts
* const { Scalar, ChildKey, OutPoint, Scalar, TokenId, CTxId, TxIn, CTX_ID_SIZE } = require('navio-blsct')
* const { randomBytes } = require('crypto')
* const cTxIdHex = randomBytes(CTX_ID_SIZE).toString('hex')
* const cTxId = CTxId.deserialize(cTxIdHex)
* const amount = 123
* const gamma = 100
* const s = Scalar.random()
* const ck = new ChildKey(s)
* const txk = ck.toTxKey()
* const spendingKey = txk.toSpendingKey()
* const tokenId = TokenId.default()
* const outPoint = OutPoint.generate(cTxId, 0)
* const txIn = TxIn.generate(amount, gamma, spendingKey, tokenId, outPoint)
* txIn.getAmount() // 123
* txIn.getGamma() // 100
* txIn.getSpendingKey()
* txIn.getTokenId()
* txIn.getOutPoint()
* txIn.getStakedCommitment() // false
* txIn.getRbf() // false
* const ser = txIn.serialize()
* const deser = TxIn.deserialize(ser)
* ser === deser.serialize() // true
* ```
*/
export declare class TxIn extends ManagedObj {
constructor(obj: any);
/** Constructs a new `TxIn` instance.
* @param amount - The amount of the input.
* @param gamma - The gamma of the input.
* @param spendingKey - The spending key associated with the input.
* @param tokenId - The token ID associated with the input.
* @param outPoint - The outpoint associated with the input.
* @param isStakedCommitment - Indicates if the commitment is staked (default: false).
* @param isRbf - Indicates if the transaction is replaceable by fee (default: false).
* @returns A new `TxIn` instance.
*/
static generate(amount: number, gamma: number, spendingKey: Scalar, tokenId: TokenId, outPoint: OutPoint, isStakedCommitment?: boolean, isRbf?: boolean): TxIn;
value(): any;
/** Returns the amount of the transaction input.
* @returns The amount of the transaction input.
*/
getAmount(): number;
/** Returns the gamma of the transaction input.
* @returns The gamma of the transaction input.
*/
getGamma(): number;
/** Returns the spending key associated with the transaction input.
* @returns The spending key associated with the transaction input.
*/
getSpendingKey(): Scalar;
/** Returns the token ID associated with the transaction input.
* @returns The token ID associated with the transaction input.
*/
getTokenId(): TokenId;
/** Returns the outpoint associated with the transaction input.
* @returns The outpoint associated with the transaction input.
*/
getOutPoint(): OutPoint;
/** Returns if the transaction input is a staked commitment.
* @returns `true` if the transaction input is a staked commitment, otherwise `false`.
*/
getStakedCommitment(): boolean;
/** Returns if the transaction input is replaceable by fee (RBF).
* @returns `true` if the transaction input is RBF, otherwise `false`.
*/
getRbf(): boolean;
/** Returns a deep copy of the instance.
* @returns A new `TxIn` instance that is a deep copy of this instance.
*/
clone(): TxIn;
serialize(): string;
/** Deserializes a hexadecimal string into a `TxIn` instance.
* @param hex - The hexadecimal string to deserialize.
* @returns A new `TxIn` instance.
*/
static deserialize(this: new (obj: any) => TxIn, hex: string): TxIn;
}