Hierarchy

  • Utxo

Constructors

  • Description

    Initialize a new utxo - unspent transaction output or input. Note, a full TX consists of 2 inputs and 2 outputs

    Parameters

    • __namedParameters: {
          account?: Account;
          amounts?: BN[];
          appData?: any;
          appDataHash?: BN;
          appDataIdl?: Idl;
          assetLookupTable: string[];
          assets?: PublicKey[];
          blinding?: BN;
          includeAppData?: boolean;
          index?: number;
          poolType?: BN;
          poseidon: any;
          verifierAddress?: PublicKey;
          verifierProgramLookupTable: string[];
      }
      • Optional account?: Account
      • Optional amounts?: BN[]
      • Optional appData?: any
      • Optional appDataHash?: BN
      • Optional appDataIdl?: Idl
      • assetLookupTable: string[]
      • Optional assets?: PublicKey[]
      • Optional blinding?: BN
      • Optional includeAppData?: boolean
      • Optional index?: number
      • Optional poolType?: BN
      • poseidon: any
      • Optional verifierAddress?: PublicKey
      • verifierProgramLookupTable: string[]

    Returns Utxo

Properties

_commitment?: string
_nullifier?: string
account: Account
amounts: BN[]

Param

array of utxo amounts, amounts[0] is the sol amount amounts[1] is the spl amount

Param

array of utxo assets, assets[0] is the sol asset assets[1] is the spl asset

Param

Blinding factor, a 31 bytes big number, to add randomness to the commitment hash.

Param

the account owning the utxo.

Param

the index of the utxo's commitment hash in the Merkle tree.

Param

application data of app utxos not provided for normal utxos.

Param

the solana address of the verifier, SystemProgramId/BN(0) for system verifiers.

Param

hashAndTruncateToCircuit(verifierAddress) to fit into 254 bit field size of bn254.

Param

is the poseidon hash of app utxo data. This compresses the app data and ties it to the app utxo.

Param

is the pool type domain of the utxo default is [0;32].

Param

flag whether to include app data when serializing utxo to bytes.

Param

cached commitment hash to avoid recomputing.

Param

cached nullifier hash to avoid recomputing.

appData: any
appDataHash: BN
appDataIdl?: Idl
assets: PublicKey[]
assetsCircuit: BN[]
blinding: BN
includeAppData: boolean
index?: number
poolType: BN
splAssetIndex: BN
transactionVersion: string
verifierAddress: PublicKey
verifierAddressCircuit: BN
verifierProgramIndex: BN

Methods

  • Description

    Encrypts the utxo to the utxo's accounts public key with nacl.box.

    Parameters

    • poseidon: any
    • Optional merkleTreePdaPublicKey: PublicKey
    • Optional transactionNonce: number
    • compressed: boolean = true

    Returns Promise<Uint8Array>

    with the first 24 bytes being the nonce

  • Description

    Returns commitment for this utxo

    Description

    PoseidonHash(amountHash, shieldedPubkey, blinding, assetHash, appDataHash, poolType, verifierAddressCircuit)

    Parameters

    • poseidon: any

    Returns string

  • Description

    Computes the nullifier for this utxo.

    Description

    PoseidonHash(commitment, index, signature)

    Parameters

    • poseidon: any
    • Optional index: number

      Merkle tree index of the utxo commitment (Optional)

    Returns undefined | string

  • Description

    Parses a utxo to bytes.

    Parameters

    • compressed: boolean = false

    Returns Promise<Buffer>

  • Converts the Utxo instance into a base58 encoded string.

    Async

    Returns Promise<string>

    A promise that resolves to the base58 encoded string representation of the Utxo.

  • Description

    Decrypts a utxo from an array of bytes, the last 24 bytes are the nonce.

    Parameters

    • __namedParameters: {
          account: Account;
          aes?: boolean;
          appDataIdl?: Idl;
          assetLookupTable: string[];
          commitment: Uint8Array;
          compressed?: boolean;
          encBytes: Uint8Array;
          index: number;
          merkleTreePdaPublicKey?: PublicKey;
          poseidon: any;
          transactionNonce?: number;
          verifierProgramLookupTable: string[];
      }
      • account: Account
      • Optional aes?: boolean
      • Optional appDataIdl?: Idl
      • assetLookupTable: string[]
      • commitment: Uint8Array
      • Optional compressed?: boolean
      • encBytes: Uint8Array
      • index: number
      • Optional merkleTreePdaPublicKey?: PublicKey
      • poseidon: any
      • Optional transactionNonce?: number
      • verifierProgramLookupTable: string[]

    Returns Promise<null | Utxo>

  • Description

    Compares two Utxos.

    Parameters

    • poseidon: any
    • utxo0: Utxo
    • utxo1: Utxo
    • skipNullifier: boolean = false

    Returns void

  • Description

    Parses a utxo from bytes.

    Parameters

    • __namedParameters: {
          account?: Account;
          appDataIdl?: Idl;
          assetLookupTable: string[];
          bytes: Buffer;
          includeAppData?: boolean;
          index?: number;
          poseidon: any;
          verifierAddress?: PublicKey;
          verifierProgramLookupTable: string[];
      }
      • Optional account?: Account
      • Optional appDataIdl?: Idl
      • assetLookupTable: string[]
      • bytes: Buffer
      • Optional includeAppData?: boolean
      • Optional index?: number
      • poseidon: any
      • Optional verifierAddress?: PublicKey
      • verifierProgramLookupTable: string[]

    Returns Utxo

  • Creates a new Utxo from a given base58 encoded string.

    Static

    Parameters

    • string: string

      The base58 encoded string representation of the Utxo.

    • poseidon: any
    • assetLookupTable: string[]
    • verifierProgramLookupTable: string[]

    Returns Utxo

    The newly created Utxo.

Generated using TypeDoc