Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CryptoNote

CryptoNote helper class for constructing transactions and performing various other cryptographic items during the receipt or transfer of funds on the network

Hierarchy

  • CryptoNote

Index

Constructors

constructor

  • Constructs a new instance of the object If a configuration is supplied, it is also passed to the underlying cryptographic library

    Parameters

    Returns CryptoNote

Methods

absoluteToRelativeOffsets

  • absoluteToRelativeOffsets(offsets: BigInteger.BigInteger[] | string[] | number[]): number[]
  • Converts absolute global index offsets to relative ones

    Parameters

    • offsets: BigInteger.BigInteger[] | string[] | number[]

      the absolute offsets

    Returns number[]

    the relative offsets

calculateMinimumTransactionFee

  • calculateMinimumTransactionFee(txSize: number): number
  • Calculates the minimum transaction fee given the transaction size (bytes)

    Parameters

    • txSize: number

      the transaction size in bytes

    Returns number

    the minimum transaction fee

completeTransaction

  • Completes a prepared transaction using the supplied private ephemeral The resulting transaction can be broadcast to the network. Please note that the PreparedTransaction signatures meta data must be updated to include the proper private ephemeral

    Parameters

    • preparedTransaction: PreparedTransaction

      the prepared transaction

    • privateSpendKey: string

      the private spend key of the wallet that contains the funds

    Returns Promise<Transaction>

    the completed transaction

createIntegratedAddress

  • createIntegratedAddress(address: string, paymentId: string, prefix?: AddressPrefix | number): string
  • Creates an integrated address using the supplied values

    Parameters

    • address: string

      the wallet address

    • paymentId: string

      the payment ID

    • Optional prefix: AddressPrefix | number

    Returns string

    the integrated address

createTransaction

  • createTransaction(outputs: GeneratedOutput[], inputs: Output[], randomOutputs: RandomOutput[][], mixin: number, feeAmount?: undefined | number, paymentId?: undefined | string, unlockTime?: undefined | number, extraData?: any): Promise<Transaction>
  • Constructs a new Transaction using the supplied values. The resulting transaction can be broadcasted to the TurtleCoin network

    async

    Parameters

    • outputs: GeneratedOutput[]

      the new outputs for the transaction (TO)

    • inputs: Output[]

      outputs we will be spending (FROM)

    • randomOutputs: RandomOutput[][]

      the random outputs to use for mixing

    • mixin: number

      the number of mixins to use

    • Optional feeAmount: undefined | number
    • Optional paymentId: undefined | string
    • Optional unlockTime: undefined | number
    • Optional extraData: any

    Returns Promise<Transaction>

    the newly created transaction object

createTransactionStructure

  • createTransactionStructure(outputs: GeneratedOutput[], inputs: Output[], randomOutputs: RandomOutput[][], mixin: number, feeAmount?: undefined | number, paymentId?: undefined | string, unlockTime?: undefined | number, extraData?: any): Promise<IPreparedTransaction>
  • Constructs a new Transaction using the supplied values. Note: Does not sign the transaction

    async

    Parameters

    • outputs: GeneratedOutput[]

      the new outputs for the transaction (TO)

    • inputs: Output[]

      outputs we will be spending (FROM)

    • randomOutputs: RandomOutput[][]

      the random outputs to use for mixing

    • mixin: number

      the number of mixins to use

    • Optional feeAmount: undefined | number
    • Optional paymentId: undefined | string
    • Optional unlockTime: undefined | number
    • Optional extraData: any

    Returns Promise<IPreparedTransaction>

    the newly created transaction object and it's input data

formatMoney

  • formatMoney(amount: BigInteger.BigInteger | number): string
  • Formats atomic units into human readable units

    Parameters

    • amount: BigInteger.BigInteger | number

      the amount in atomic units

    Returns string

    the amount in human readable units

generateKeyImage

  • generateKeyImage(transactionPublicKey: string, privateViewKey: string, publicSpendKey: string, privateSpendKey: string, outputIndex: number): Promise<string>
  • Generates a key image from the supplied values

    async

    Parameters

    • transactionPublicKey: string

      the transaction public key

    • privateViewKey: string

      the private view key

    • publicSpendKey: string

      the public spend key

    • privateSpendKey: string

      the private spend key

    • outputIndex: number

      the index of the output in the transaction

    Returns Promise<string>

    the key image

generateKeyImagePrimitive

  • generateKeyImagePrimitive(publicSpendKey: string, privateSpendKey: string, outputIndex: number, derivation: string): Promise<string>
  • Primitive method for generating a key image from the supplied values

    async

    Parameters

    • publicSpendKey: string

      the public spend key

    • privateSpendKey: string

      the private spend key

    • outputIndex: number

      the index of the output in the transaction

    • derivation: string

      the key derivation

    Returns Promise<string>

    the key image

generateTransactionOutputs

  • generateTransactionOutputs(address: string, amount: number): GeneratedOutput[]
  • Generates an array of transaction outputs (new destinations) for the given address and the given amount within the allowed rules of the network

    Parameters

    • address: string

      the destination wallet address

    • amount: number

      the amount to send

    Returns GeneratedOutput[]

    a list of transaction outputs

isOurTransactionOutput

  • isOurTransactionOutput(transactionPublicKey: string, output: Output, privateViewKey: string, publicSpendKey: string, privateSpendKey?: undefined | string, generatePartial?: undefined | false | true): Promise<Output>
  • Scans the given transaction output to determine if it belongs to us, if so, we return the output with the private ephemeral and key image if the privateSpendKey was supplied

    async

    Parameters

    • transactionPublicKey: string

      the transaction public key

    • output: Output

      the transaction output

    • privateViewKey: string

      the private view key

    • publicSpendKey: string

      the public spend key

    • Optional privateSpendKey: undefined | string
    • Optional generatePartial: undefined | false | true

    Returns Promise<Output>

    the output if it belongs to us

prepareTransaction

  • Constructs a new Transaction using the supplied values. The resulting transaction can be broadcasted to the TurtleCoin network

    async

    Parameters

    • outputs: GeneratedOutput[]

      the new outputs for the transaction (TO)

    • inputs: Output[]

      outputs we will be spending (FROM)

    • randomOutputs: RandomOutput[][]

      the random outputs to use for mixing

    • mixin: number

      the number of mixins to use

    • Optional feeAmount: undefined | number
    • Optional paymentId: undefined | string
    • Optional unlockTime: undefined | number
    • Optional extraData: any

    Returns Promise<PreparedTransaction>

    the newly created transaction object with prepared signatures

privateKeyToPublicKey

  • privateKeyToPublicKey(privateKey: string): Promise<string>
  • Provides the public key of the supplied private key

    async

    Parameters

    • privateKey: string

      the private key

    Returns Promise<string>

    the public key

relativeToAbsoluteOffsets

  • relativeToAbsoluteOffsets(offsets: BigInteger.BigInteger[] | string[] | number[]): number[]
  • Converts relative global index offsets to absolute offsets

    Parameters

    • offsets: BigInteger.BigInteger[] | string[] | number[]

      the relative offsets

    Returns number[]

    the absolute offsets

scanTransactionOutputs

  • scanTransactionOutputs(transactionPublicKey: string, outputs: Output[], privateViewKey: string, publicSpendKey: string, privateSpendKey?: undefined | string, generatePartial?: undefined | false | true): Promise<Output[]>
  • Scans the provided transaction outputs and returns those outputs which belong to us. If the privateSpendKey is not supplied, the private ephemeral and key image will be undefined

    async

    Parameters

    • transactionPublicKey: string

      the transaction public key

    • outputs: Output[]

      the transaction outputs

    • privateViewKey: string

      the private view key

    • publicSpendKey: string

      the public spend key

    • Optional privateSpendKey: undefined | string
    • Optional generatePartial: undefined | false | true

    Returns Promise<Output[]>

    an list of outputs that belong to us

signMessage

  • signMessage(message: any, privateKey: string): Promise<string>
  • Signs an arbitrary message using the supplied private key

    async

    Parameters

    • message: any

      the arbitrary message to sign

    • privateKey: string

      the private key to sign with

    Returns Promise<string>

    the signature

verifyMessageSignature

  • verifyMessageSignature(message: any, publicKey: string, signature: string): Promise<void>
  • Verifies the signature of an arbitrary message using the signature and the supplied public key

    async

    Parameters

    • message: any

      the arbitrary message that was signed

    • publicKey: string

      the public key of the private key that was used to sign

    • signature: string

      the signature

    Returns Promise<void>

    whether the signature is valid

Generated using TypeDoc