Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LedgerNote

Ledger CryptoNote helper class for constructing transactions and performing various other cryptographic items during the receipt or transfer of funds on the network using a Ledger based hardware device

Hierarchy

  • LedgerNote

Implements

Index

Constructors

constructor

  • new LedgerNote(transport: Transport, config?: ICoinConfig, cryptoConfig?: ICryptoConfig): LedgerNote
  • Constructs a new instance of the Ledger-based CryptoNote tools

    Parameters

    • transport: Transport

      the transport mechanism for talking to a Ledger device

    • Optional config: ICoinConfig

      the base configuration to apply to our helper

    • Optional cryptoConfig: ICryptoConfig

      configuration to allow for overriding the provided cryptographic primitives

    Returns LedgerNote

Accessors

address

config

  • get config(): ICoinConfig
  • set config(config: ICoinConfig): void

cryptoConfig

  • get cryptoConfig(): ICryptoConfig
  • set cryptoConfig(config: ICryptoConfig): void
  • The current cryptographic primitives configuration

    Returns ICryptoConfig

  • The current cryptographic primitives configuration

    Parameters

    • config: ICryptoConfig

    Returns void

ready

  • get ready(): boolean
  • Indicates whether the keys have been fetched from the ledger device and this instance of the class is ready for further interaction

    Returns boolean

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 | undefined

      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): Promise<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 Promise<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. 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<Transaction>

    the newly created transaction object and it's input data

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

fetchKeys

  • fetchKeys(): Promise<void>
  • Fetches the public keys and private view key from the Ledger device and stores it locally for use later

    Returns Promise<void>

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

generateKeyDerivation

  • generateKeyDerivation(transactionPublicKey: string, privateViewKey: string | undefined): Promise<string>
  • Generates a key derivation

    Parameters

    • transactionPublicKey: string

      the transaction public key

    • privateViewKey: string | undefined

      the private view key (ignored)

    Returns Promise<string>

generateKeyImage

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

    async

    Parameters

    • transactionPublicKey: string

      the transaction public key

    • privateViewKey: string | undefined

      the private view key

    • publicSpendKey: string | undefined

      the public spend key

    • privateSpendKey: string | undefined

      the private spend key

    • outputIndex: number

      the index of the output in the transaction

    Returns Promise<IKeyImage>

    the key image

generateKeyImagePrimitive

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

    async

    Parameters

    • publicSpendKey: string | undefined

      the public spend key

    • privateSpendKey: string | undefined

      the private spend key

    • outputIndex: number

      the index of the output in the transaction

    • derivation: string

      the key derivation

    Returns Promise<IKeyImage>

    the key image

generateTransactionOutputs

  • generateTransactionOutputs(address: string, amount: number): Promise<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 Promise<GeneratedOutput[]>

    a list of transaction outputs

init

  • init(): Promise<void>

isOurTransactionOutput

  • isOurTransactionOutput(transactionPublicKey: string, output: Output, privateViewKey: string | undefined, publicSpendKey: string | undefined, privateSpendKey?: undefined | string, generatePartial?: boolean): 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 | undefined

      the private view key

    • publicSpendKey: string | undefined

      the public spend key

    • Optional privateSpendKey: undefined | string
    • Default value generatePartial: boolean = false

    Returns Promise<Output>

    the output if it belongs to us

prepareTransaction

  • prepareTransaction(outputs: GeneratedOutput[], inputs: Output[], randomOutputs: RandomOutput[][], mixin: number, feeAmount?: undefined | number, paymentId?: undefined | string, unlockTime?: undefined | number, extraData?: any, randomKey?: undefined | string): Promise<PreparedTransaction>
  • 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
    • Optional randomKey: undefined | string

    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 | undefined): Promise<string>
  • Signs an arbitrary message using the supplied private key

    async

    Parameters

    • message: any

      the arbitrary message to sign

    • privateKey: string | undefined

      the private key to sign with

    Returns Promise<string>

    the signature

verifyMessageSignature

  • verifyMessageSignature(message: any, publicKey: string, signature: string): Promise<boolean>
  • 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<boolean>

    whether the signature is valid

Generated using TypeDoc