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

  • EventEmitter
    • LedgerNote

Implements

  • ICryptoNote

Index

Constructors

constructor

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

    Parameters

    • transport: Transport<string>

      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

Properties

Private m_address

m_address: Address = ...

Protected m_config

m_config: ICoinRunningConfig = ...

Private m_fetched

m_fetched: boolean = false

Private Readonly m_ledger

m_ledger: LedgerDevice

Accessors

address

  • Provides the public wallet address of the ledger device

    Returns Address

config

  • get config(): ICoinConfig
  • set config(config: ICoinConfig): void
  • The current coin configuration

    Returns ICoinConfig

  • The current coin configuration

    Parameters

    • config: ICoinConfig

    Returns 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: string[] | BigInteger[] | number[]): number[]
  • Converts absolute global index offsets to relative ones

    Parameters

    • offsets: string[] | BigInteger[] | 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: undefined | 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?: number | AddressPrefix): Promise<string>
  • Creates an integrated address using the supplied values

    Parameters

    • address: string

      the wallet address

    • paymentId: string

      the payment ID

    • Optional prefix: number | AddressPrefix

    Returns Promise<string>

    the integrated address

createTransaction

  • 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: number
    • Optional paymentId: string
    • Optional unlockTime: number
    • Optional extraData: any

    Returns Promise<Transaction>

    the newly created transaction object and it's input data

createTransactionStructure

  • 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: number
    • Optional paymentId: string
    • Optional unlockTime: 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: number | BigInteger): string
  • Formats atomic units into human readable units

    Parameters

    • amount: number | BigInteger

      the amount in atomic units

    Returns string

    the amount in human readable units

generateKeyDerivation

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

    Parameters

    • transactionPublicKey: string

      the transaction public key

    • privateViewKey: undefined | string

      the private view key (ignored)

    Returns Promise<string>

generateKeyImage

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

    async

    Parameters

    • transactionPublicKey: string

      the transaction public key

    • privateViewKey: undefined | string

      the private view key

    • publicSpendKey: undefined | string

      the public spend key

    • privateSpendKey: undefined | string

      the private spend key

    • outputIndex: number

      the index of the output in the transaction

    Returns Promise<IKeyImage>

    the key image

generateKeyImagePrimitive

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

    async

    Parameters

    • publicSpendKey: undefined | string

      the public spend key

    • privateSpendKey: undefined | string

      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>
  • Manually initializes the class if necessary

    Returns Promise<void>

isOurTransactionOutput

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

      the private view key

    • publicSpendKey: undefined | string

      the public spend key

    • Optional privateSpendKey: string
    • generatePartial: boolean = false

    Returns Promise<Output>

    the output if it belongs to us

on

  • on(event: "user_confirm", listener: () => void): LedgerNote
  • on(event: "transport_receive", listener: (data: string) => void): LedgerNote
  • on(event: "transport_send", listener: (data: string) => void): LedgerNote
  • Emits an event if we have sent a command to the cryptographic library that is likely awaiting manual user confirmation on the device

    Parameters

    • event: "user_confirm"
    • listener: () => void
        • (): void
        • Returns void

    Returns LedgerNote

  • Emits an event when the underlying cryptographic library receives data

    Parameters

    • event: "transport_receive"
    • listener: (data: string) => void
        • (data: string): void
        • Parameters

          • data: string

          Returns void

    Returns LedgerNote

  • Emits an event when the underlying cryptographic library sends data

    Parameters

    • event: "transport_send"
    • listener: (data: string) => void
        • (data: string): void
        • Parameters

          • data: string

          Returns void

    Returns LedgerNote

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: number
    • Optional paymentId: string
    • Optional unlockTime: number
    • Optional extraData: any
    • Optional randomKey: 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: string[] | BigInteger[] | number[]): number[]
  • Converts relative global index offsets to absolute offsets

    Parameters

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

      the relative offsets

    Returns number[]

    the absolute offsets

scanTransactionOutputs

  • scanTransactionOutputs(transactionPublicKey: string, outputs: Output[], privateViewKey: string, publicSpendKey: string, privateSpendKey?: string, generatePartial?: boolean): 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: string
    • Optional generatePartial: boolean

    Returns Promise<Output[]>

    an list of outputs that belong to us

signMessage

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

    async

    Parameters

    • message: any

      the arbitrary message to sign

    • privateKey: undefined | string

      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