Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LedgerDevice

An easy to use interface that uses a Ledger HW transport to communicate with the TurtleCoin application running on a ledger device. Please see. See https://github.com/LedgerHQ/ledgerjs for available transport providers

Hierarchy

  • EventEmitter
    • LedgerDevice

Index

Constructors

constructor

  • new LedgerDevice(transport: Transport, config?: ICoinConfig): LedgerDevice
  • Creates a new instance of the Ledger interface The transport MUST be connected already before passing to this constructor

    Parameters

    Returns LedgerDevice

Properties

Static defaultMaxListeners

defaultMaxListeners: number

Static Readonly errorMonitor

errorMonitor: keyof symbol

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted, therefore the process will still crash if no regular 'error' listener is installed.

Accessors

transport

  • get transport(): Transport

Methods

addListener

  • addListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

checkIdent

  • checkIdent(): Promise<boolean>
  • Checks to make sure that the application running on the ledger at least claims to be the TurtleCoin ledger application

    Returns Promise<boolean>

checkKey

  • checkKey(key: string): Promise<boolean>
  • Checks to confirm that the key is a valid public key

    Parameters

    • key: string

      the key to check

    Returns Promise<boolean>

checkRingSignatures

  • checkRingSignatures(tx_prefix_hash: string, key_image: string, public_keys: string[], signatures: string[]): Promise<boolean>
  • Checks the ring signatures given for their validity to verify that the proper private key was used for signing purposes

    Parameters

    • tx_prefix_hash: string

      the transaction prefix hash

    • key_image: string

      the key image spent in the input

    • public_keys: string[]

      the ring participant keys

    • signatures: string[]

      the signatures to verify

    Returns Promise<boolean>

checkScalar

  • checkScalar(scalar: string): Promise<boolean>
  • Checks to confirm that the scalar is indeed a scalar value

    Parameters

    • scalar: string

      the scalar to check

    Returns Promise<boolean>

checkSignature

  • checkSignature(message_digest: string, public_key: string, signature: string): Promise<boolean>
  • Checks a given signature using the supplied public key for validity

    Parameters

    • message_digest: string

      the message digest (hash)

    • public_key: string

      the public key of the private key used to sign the transaction

    • signature: string

      the signature to validate

    Returns Promise<boolean>

checkVersion

  • checkVersion(requiredVersion: string): Promise<boolean>

completeRingSignature

  • completeRingSignature(tx_public_key: string, output_index: number, output_key: string, k: string, signature: string, confirm?: boolean): Promise<string>
  • Completes the given ring signature for using the supplied parameters

    Parameters

    • tx_public_key: string

      the transaction public key of the input used

    • output_index: number

      the index of the given output in the transaction of the input used

    • output_key: string

      the key of the given output in the transaction of the input used

    • k: string

      the random scalar returned by preparing the signatures before completion

    • signature: string

      the incomplete ring signature for the given input

    • Default value confirm: boolean = true

      whether the device will prompt the user to confirm their actions (to disable, must be running a DEBUG build)

    Returns Promise<string>

derivePublicKey

  • derivePublicKey(derivation: string, output_index: number, confirm?: boolean): Promise<KeyPair>
  • Generates the public ephemeral of the given output in a transaction

    Parameters

    • derivation: string

      the key derivation

    • output_index: number

      the index of the output in the transaction

    • Default value confirm: boolean = true

      whether the device will prompt the user to confirm their actions (to disable, must be running a DEBUG build)

    Returns Promise<KeyPair>

deriveSecretKey

  • deriveSecretKey(derivation: string, output_index: number, confirm?: boolean): Promise<KeyPair>
  • Generates the private ephemeral of the given output in a transaction

    Parameters

    • derivation: string

      the key derivation

    • output_index: number

      the index of the output in the transaction

    • Default value confirm: boolean = true

      whether the device will prompt the user to confirm their actions (to disable, must be running a DEBUG build)

    Returns Promise<KeyPair>

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

eventNames

  • eventNames(): Array<string | symbol>
  • Returns Array<string | symbol>

finalizeTransactionPrefix

  • finalizeTransactionPrefix(): Promise<void>

generateKeyDerivation

  • generateKeyDerivation(tx_public_key: string, confirm?: boolean): Promise<string>
  • Generates the transaction key derivation using the private view key stored on the ledger device

    Parameters

    • tx_public_key: string

      the transactions public key

    • Default value confirm: boolean = true

      whether the device will prompt the user to confirm their actions (to disable, must be running a DEBUG build)

    Returns Promise<string>

generateKeyImage

  • generateKeyImage(tx_public_key: string, output_index: number, output_key: string, confirm?: boolean): Promise<string>
  • Generates a key image on the device using the supplied parameters

    Parameters

    • tx_public_key: string

      the transaction public key

    • output_index: number

      the index of the given output in the transaction

    • output_key: string

      the key of the given output in the transaction

    • Default value confirm: boolean = true

      whether the device will prompt the user to confirm their actions (to disable, must be running a DEBUG build)

    Returns Promise<string>

generateKeyImagePrimitive

  • generateKeyImagePrimitive(derivation: string, output_index: number, output_key: string, confirm?: boolean): Promise<string>
  • Generates a key image on the device using the supplied parameters

    Parameters

    • derivation: string

      the output derivation

    • output_index: number

      the index of the given output in the transaction

    • output_key: string

      the key of the given output in the transaction

    • Default value confirm: boolean = true

      whether the device will prompt the user to confirm their actions (to disable, must be running a DEBUG build)

    Returns Promise<string>

generateRingSignatures

  • generateRingSignatures(tx_public_key: string, output_index: number, output_key: string, tx_prefix_hash: string, input_keys: string[], real_output_index: number, confirm?: boolean): Promise<string[]>
  • Generates the ring signatures for the given inputs on the ledger device without revealing the private spend key

    Parameters

    • tx_public_key: string

      the transaction public key of input being spent

    • output_index: number

      the index of the input being spent in the transaction

    • output_key: string

      the output key of the input being spent

    • tx_prefix_hash: string

      our transaction prefix hash

    • input_keys: string[]

      the ring participant keys (mixins + us)

    • real_output_index: number

      the index of the real output in the input_keys

    • Default value confirm: boolean = true

      whether the device will prompt the user to confirm their actions (to disable, must be running a DEBUG build)

    Returns Promise<string[]>

generateSignature

  • generateSignature(message_digest: string, confirm?: boolean): Promise<string>
  • Generates a signature of the message digest using the private spend key stored on the ledger device without revealing the private spend key

    Parameters

    • message_digest: string

      the message digest (hash)

    • Default value confirm: boolean = true

      whether the device will prompt the user to confirm their actions (to disable, must be running a DEBUG build)

    Returns Promise<string>

getAddress

  • getAddress(confirm?: boolean): Promise<Address>
  • Gets the public wallet address from the connected device

    Parameters

    • Default value confirm: boolean = true

      whether the device will prompt the user to confirm their actions (to disable, must be running a DEBUG build)

    Returns Promise<Address>

getIdent

  • getIdent(): Promise<string>
  • Retrieves the current identification bytes of the application running on the ledger device

    Returns Promise<string>

getMaxListeners

  • getMaxListeners(): number

getPrivateSpendKey

  • getPrivateSpendKey(confirm?: boolean): Promise<KeyPair>
  • Retrieves the private spend key from the connected ledger device !! WARNING !! Retrieving the private spend key from the device may result in a complete loss of funds as the private spend key should normally remain on the device and never leave

    Parameters

    • Default value confirm: boolean = true

      whether the device will prompt the user to confirm their actions (to disable, must be running a DEBUG build)

    Returns Promise<KeyPair>

getPrivateViewKey

  • getPrivateViewKey(confirm?: boolean): Promise<KeyPair>
  • Retrieves the private view key from the connected ledger device

    Parameters

    • Default value confirm: boolean = true

      whether the device will prompt the user to confirm their actions (to disable, must be running a DEBUG build)

    Returns Promise<KeyPair>

getPublicKeys

  • getPublicKeys(confirm?: boolean): Promise<Keys>
  • Retrieves the public keys from the connected ledger device

    Parameters

    • Default value confirm: boolean = true

      whether the device will prompt the user to confirm their actions (to disable, must be running a DEBUG build)

    Returns Promise<Keys>

getRandomKeyPair

  • getRandomKeyPair(): Promise<KeyPair>

getVersion

  • getVersion(): Promise<{ major: number; minor: number; patch: number }>
  • Retrieves the current version of the application running on the ledger device

    Returns Promise<{ major: number; minor: number; patch: number }>

getViewWallet

  • getViewWallet(confirm?: boolean): Promise<Address>
  • Retrieves the the public spend key and private view key from the ledger device which is essentially a view only wallet

    Parameters

    • Default value confirm: boolean = true

      whether the device will prompt the user to confirm their actions (to disable, must be running a DEBUG build)

    Returns Promise<Address>

isDebug

  • isDebug(): Promise<boolean>
  • Returns if the application running on the ledger is a debug build

    Returns Promise<boolean>

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

loadTransactionInput

  • loadTransactionInput(input_tx_public_key: string, input_output_index: number, amount: number, public_keys: string[], offsets: number[], real_output_index: number): Promise<void>
  • Load a transaction input to the transaction construction process

    Parameters

    • input_tx_public_key: string

      the transaction public key of the input

    • input_output_index: number

      the output index of the transaction of the input

    • amount: number

      the amount of the input

    • public_keys: string[]

      the ring participant keys

    • offsets: number[]

      the RELATIVE offsets of the ring participant keys

    • real_output_index: number

      the index in the public_keys of the real output being spent

    Returns Promise<void>

loadTransactionOutput

  • loadTransactionOutput(amount: number, output_key: string): Promise<void>
  • Load a transaction output to the transaction construction process

    Parameters

    • amount: number

      the amount of the output

    • output_key: string

      the output key

    Returns Promise<void>

off

  • off(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

once

  • once(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependListener

  • prependListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

privateToPublic

  • privateToPublic(private_key: string): Promise<KeyPair>
  • Calculates the public key for the given private key

    Parameters

    • private_key: string

      the private key

    Returns Promise<KeyPair>

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • Parameters

    • Optional event: string | symbol

    Returns this

removeListener

  • removeListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

resetKeys

  • resetKeys(confirm?: boolean): Promise<void>
  • Resets the keys on the ledger device the same way that they are first initialized on the device

    Parameters

    • Default value confirm: boolean = true

    Returns Promise<void>

resetTransaction

  • resetTransaction(confirm?: boolean): Promise<void>
  • Resets the transaction state of the transaction construction process on the ledger device

    Parameters

    • Default value confirm: boolean = true

    Returns Promise<void>

retrieveTransaction

setMaxListeners

  • setMaxListeners(n: number): this

signTransaction

  • signTransaction(confirm?: boolean): Promise<{ hash: string; size: number }>
  • Instructs the ledger device to sign the transaction we have constructed

    Parameters

    • Default value confirm: boolean = true

    Returns Promise<{ hash: string; size: number }>

startTransaction

  • startTransaction(unlock_time?: number, input_count?: number, output_count?: number, tx_public_key: string, payment_id?: undefined | string): Promise<void>
  • Starts a new transaction construction on the ledger device

    Parameters

    • Default value unlock_time: number = 0

      the unlock time (or block) of the transaction

    • Default value input_count: number = 0

      the number of inputs that will be included in the transaction

    • Default value output_count: number = 0

      the number of outputs that will be included in the transaction

    • tx_public_key: string

      the transaction public key

    • Optional payment_id: undefined | string

      the transaction payment id if one needs to be included

    Returns Promise<void>

startTransactionInputLoad

  • startTransactionInputLoad(): Promise<void>
  • Signals to the ledger that we are ready to start loading transaction inputs

    Returns Promise<void>

startTransactionOutputLoad

  • startTransactionOutputLoad(): Promise<void>
  • Signals to the ledger that we are ready to start loading transaction outputs

    Returns Promise<void>

transactionState

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Generated using TypeDoc