Options
All
  • Public
  • Public/Protected
  • All
Menu

Class WalletAPI

A class interface that allows for easy interaction with the wallet-api service

Hierarchy

  • HTTPClient
    • WalletAPI

Index

Constructors

constructor

  • new WalletAPI(password: string, host?: string, port?: number, timeout?: number, ssl?: boolean, userAgent?: string, keepAlive?: boolean, defaultMixin?: number, decimalDivisor?: number, defaultFeePerByte?: number, defaultUnlockTime?: number): WalletAPI
  • Initializes a new WalletAPI interface

    Parameters

    • password: string

      the API password for the WalletAPI instance

    • Optional host: string

      the address of the wallet-api instance

    • Optional port: number

      the port of the wallet-api instance

    • Optional timeout: number

      the timeout to wait for each request in ms

    • Optional ssl: boolean

      whether the wallet-api instance uses SSL (HTTPS) or not

    • Optional userAgent: string

      the user agent string to use with requests

    • Optional keepAlive: boolean

      whether the underlying HTTP(s) connection should be kept alive and reused

    • Optional defaultMixin: number

      the default mixin used for generated transactions

    • Optional decimalDivisor: number

      the decimal divisor to use in converting between atomic units and human readable values

    • Optional defaultFeePerByte: number

      the default fee per byte to use in generating transactions

    • Optional defaultUnlockTime: number

      the default unlock time to use in generating transaction

    Returns WalletAPI

Properties

Private Readonly m_decimalDivisor

m_decimalDivisor: number = 100

Private Readonly m_defaultFeePerByte

m_defaultFeePerByte: number = 1.953125

Private Optional Readonly m_defaultMixin

m_defaultMixin: undefined | number

Private Readonly m_defaultUnlockTime

m_defaultUnlockTime: number = 0

Accessors

agent

  • get agent(): Agent | Agent
  • Returns Agent | Agent

headers

  • get headers(): Headers
  • Returns Headers

host

  • get host(): string
  • Returns string

keepAlive

  • get keepAlive(): boolean
  • Returns boolean

key

  • get key(): undefined | string
  • Returns undefined | string

port

  • get port(): number
  • Returns number

protocol

  • get protocol(): string
  • Returns string

ssl

  • get ssl(): boolean
  • Returns boolean

timeout

  • get timeout(): number
  • Returns number

userAgent

  • get userAgent(): string
  • Returns string

Methods

addresses

  • addresses(): Promise<string[]>
  • Retrieves a list of the addresses in the wallet container

    Returns Promise<string[]>

alive

  • alive(): Promise<boolean>
  • Returns if the Wallet-API service is reachable

    Returns Promise<boolean>

balance

  • balance(address?: string): Promise<IWalletBalance>
  • Retrieves the balance for the entire wallet container or the specified wallet address

    Parameters

    • Optional address: string

      the wallet address to check or undefined for the entire container

    Returns Promise<IWalletBalance>

balances

  • balances(): Promise<IWalletBalances[]>
  • Retrieves the balance for every wallet address in the container

    Returns Promise<IWalletBalances[]>

close

  • close(): Promise<void>
  • Closes the wallet container that is currently open

    Returns Promise<void>

create

  • create(filename: string, password: string, daemonHost?: string, daemonPort?: number, daemonSSL?: boolean): Promise<void>
  • Creates a new wallet container using the specified parameters

    Parameters

    • filename: string

      the filename of the wallet container

    • password: string

      the password of the wallet container

    • daemonHost: string = '127.0.0.1'

      the node to use for the wallet container

    • daemonPort: number = 11898

      the node port to use for the wallet container

    • daemonSSL: boolean = false

      whether the node uses SSL or not

    Returns Promise<void>

createAddress

  • createAddress(): Promise<IWallet>
  • Creates a new, random address in the wallet container

    Returns Promise<IWallet>

createIntegratedAddress

  • createIntegratedAddress(address: string, paymentId: string): Promise<string>
  • Creates an integrated address forom the given address and payment ID

    Parameters

    • address: string

      the address to use to generate the integrated address

    • paymentId: string

      the payment ID to use to generate the integrated address

    Returns Promise<string>

Protected delete

  • delete(endpoint: string): Promise<void>
  • Parameters

    • endpoint: string

    Returns Promise<void>

deleteAddress

  • deleteAddress(address: string): Promise<void>
  • Deletes the given subwallet from the container

    Parameters

    • address: string

      the address of the subwallet to delete

    Returns Promise<void>

deletePreparedTransaction

  • deletePreparedTransaction(hash: string): Promise<void>
  • t * Deletes a previous prepared transaction

    Parameters

    • hash: string

      the hash of the prepared transaction

    Returns Promise<void>

Protected get

  • get(endpoint: string): Promise<any>
  • Parameters

    • endpoint: string

    Returns Promise<any>

getNode

  • getNode(): Promise<INode>
  • Retrieves the node, address, port, fee, and fee address of the connected node

    Returns Promise<INode>

importAddress

  • importAddress(privateSpendKey: string, scanHeight?: number): Promise<string>
  • Imports a subwallet with the given private spend key starting at the specified can height

    Parameters

    • privateSpendKey: string

      the private spend key of the subwallet to import

    • scanHeight: number = 0

      the height to start scanning from upon import of the subwallet

    Returns Promise<string>

importDeterministic

  • importDeterministic(walletIndex?: number, scanHeight?: number): Promise<string>
  • Imports a deterministic subwallet with the given wallet index number

    Parameters

    • walletIndex: number = 0

      the index of the deterministic subwallet

    • scanHeight: number = 0

      the height to start scanning from upon import of the subwallet

    Returns Promise<string>

importKey

  • importKey(filename: string, password: string, privateViewKey: string, privateSpendKey: string, scanHeight?: number, daemonHost?: string, daemonPort?: number, daemonSSL?: boolean): Promise<void>
  • Imports a new wallet container using the specified keys and optional params

    Parameters

    • filename: string

      the filename of the wallet container

    • password: string

      the password of the wallet container

    • privateViewKey: string

      the private view key of the wallet

    • privateSpendKey: string

      the private spend key of the wallet

    • scanHeight: number = 0

      the height to start scanning from upon import of the wallet

    • Optional daemonHost: string

      the node to use for the wallet container

    • Optional daemonPort: number

      the node port to use for the wallet container

    • Optional daemonSSL: boolean

      whether the node uses SSL or not

    Returns Promise<void>

importSeed

  • importSeed(filename: string, password: string, mnemonicSeed: string, scanHeight?: number, daemonHost?: string, daemonPort?: number, daemonSSL?: boolean): Promise<void>
  • Imports a new wallet container using the specified mnemonic seed and optional params

    Parameters

    • filename: string

      the filename of the wallet container

    • password: string

      the password of the wallet container

    • mnemonicSeed: string

      the mnemonic seed of the wallet to import

    • scanHeight: number = 0

      the height to start scanning from upon import of the wallet

    • Optional daemonHost: string

      the node to use for the wallet container

    • Optional daemonPort: number

      the node port to use for the wallet container

    • Optional daemonSSL: boolean

      whether the node uses SSL or not

    Returns Promise<void>

importViewAddress

  • importViewAddress(publicSpendKey: string, scanHeight?: number): Promise<string>
  • Imports a view only subwallet with the given public spend key

    Parameters

    • publicSpendKey: string

      the public spend key of the subwallet

    • scanHeight: number = 0

      the height to start scanning from upon import of the subwallet

    Returns Promise<string>

importViewOnly

  • importViewOnly(filename: string, password: string, privateViewKey: string, address: string, scanHeight?: number, daemonHost?: string, daemonPort?: number, daemonSSL?: boolean): Promise<void>
  • Imports a new view only wallet container using the specified mnemonic seed and optional params

    Parameters

    • filename: string

      the filename of the wallet container

    • password: string

      the password of the wallet container

    • privateViewKey: string

      the private view key of the wallet

    • address: string

      the public wallet address

    • scanHeight: number = 0

      the height to start scanning from upon import of the wallet

    • Optional daemonHost: string

      the node to use for the wallet container

    • Optional daemonPort: number

      the node port to use for the wallet container

    • Optional daemonSSL: boolean

      whether the node uses SSL or not

    Returns Promise<void>

keys

  • keys(address?: string): Promise<string | IWallet>
  • Retrieves the wallet container's shared private view key, or if an address is specified, returns the public and private spend keys for the given address

    Parameters

    • Optional address: string

      the wallet address

    Returns Promise<string | IWallet>

keysMnemonic

  • keysMnemonic(address: string): Promise<string>
  • Retrieves the menemonic seed for the given address if possible

    Parameters

    • address: string

      the wallet address

    Returns Promise<string>

newDestination

  • newDestination(address: string, amount: number): ITransferDestination
  • Creates a new output destination object

    Parameters

    • address: string

      the address of the recipient

    • amount: number

      the human readable amount to send to the recipient

    Returns ITransferDestination

open

  • open(filename: string, password: string, daemonHost?: string, daemonPort?: number, daemonSSL?: boolean): Promise<void>
  • Opens an existing wallet container

    Parameters

    • filename: string

      the filename of the wallet container

    • password: string

      the password of the wallet container

    • Optional daemonHost: string

      the node to use for the wallet container

    • Optional daemonPort: number

      the node port to use for the wallet container

    • Optional daemonSSL: boolean

      whether the node uses SSL or not

    Returns Promise<void>

Protected post

  • post(endpoint: string, body?: any): Promise<any>
  • Parameters

    • endpoint: string
    • Optional body: any

    Returns Promise<any>

prepareAdvanced

  • prepareAdvanced(destinations: ITransferDestination[], mixin?: number, fee?: IFeeType, sourceAddresses?: string[], paymentId?: string, changeAddress?: string, unlockTime?: number, extraData?: any): Promise<ISendTransactionResult>
  • Prepares an advanced transaction

    Parameters

    • destinations: ITransferDestination[]

      the destination(s) of the transaction

    • Optional mixin: number

      the number of mixins to use

    • Optional fee: IFeeType

      the transaction fee to pay

    • Optional sourceAddresses: string[]

      the source addresses, if any, of the funds for the transaction

    • Optional paymentId: string

      the payment ID to include with the transactions

    • Optional changeAddress: string

      the address to send transaction change to

    • Optional unlockTime: number

      the unlock time of the new transaction

    • Optional extraData: any

      any extra data to be included in the TX_EXTRA field of the transaction

    Returns Promise<ISendTransactionResult>

prepareBasic

  • prepareBasic(address: string, amount: number, paymentId?: string): Promise<ISendTransactionResult>
  • Prepares a basic transaction

    Parameters

    • address: string

      the address to send funds to

    • amount: number

      the amount to send in the transaction

    • Optional paymentId: string

      the payment ID to include with the transaction

    Returns Promise<ISendTransactionResult>

primaryAddress

  • primaryAddress(): Promise<string>
  • Retrieves the primary public wallet address of the container

    Returns Promise<string>

Protected put

  • put(endpoint: string, body?: any): Promise<any>
  • Parameters

    • endpoint: string
    • Optional body: any

    Returns Promise<any>

reset

  • reset(scanHeight?: number): Promise<void>
  • Resets and saves the wallet container, beginning scanning from the height given, if any

    Parameters

    • scanHeight: number = 0

      the scan height at which to begin scanning

    Returns Promise<void>

Protected rpcPost

  • rpcPost(method: string, params?: any): Promise<any>
  • Parameters

    • method: string
    • Optional params: any

    Returns Promise<any>

save

  • save(): Promise<void>
  • Saves the wallet container currently open to disk

    Returns Promise<void>

sendAdvanced

  • sendAdvanced(destinations: ITransferDestination[], mixin?: number, fee?: IFeeType, sourceAddresses?: string[], paymentId?: string, changeAddress?: string, unlockTime?: number, extraData?: any): Promise<ISendTransactionResult>
  • Sends an advanced transaction

    Parameters

    • destinations: ITransferDestination[]

      the destination(s) of the transaction

    • Optional mixin: number

      the number of mixins to use

    • Optional fee: IFeeType

      the transaction fee to pay

    • Optional sourceAddresses: string[]

      the source addresses, if any, of the funds for the transaction

    • Optional paymentId: string

      the payment ID to include with the transactions

    • Optional changeAddress: string

      the address to send transaction change to

    • Optional unlockTime: number

      the unlock time of the new transaction

    • Optional extraData: any

      any extra data to be included in the TX_EXTRA field of the transaction

    Returns Promise<ISendTransactionResult>

sendBasic

  • sendBasic(address: string, amount: number, paymentId?: string): Promise<ISendTransactionResult>
  • Sends a basic transaction

    Parameters

    • address: string

      the address to send funds to

    • amount: number

      the amount to send in the transaction

    • Optional paymentId: string

      the payment ID to include with the transaction

    Returns Promise<ISendTransactionResult>

sendFusionAdvanced

  • sendFusionAdvanced(address: string, mixin?: number, sourceAddresses?: string[]): Promise<string>
  • Sends an advanced fusion transaction

    Parameters

    • address: string

      the address to send the fusion transaction to

    • Optional mixin: number

      the number of mixins to use in the fusion transaction

    • Optional sourceAddresses: string[]

      the source addresses, if any, of the funds for the fusion transaction

    Returns Promise<string>

sendFusionBasic

  • sendFusionBasic(): Promise<string>
  • Sends a basic fusion transaction

    Returns Promise<string>

sendPrepared

  • sendPrepared(transactionHash: string): Promise<void>
  • Sends a previously prepared transaction

    Parameters

    • transactionHash: string

      the hash of the prepared transaction

    Returns Promise<void>

setNode

  • setNode(daemonHost?: string, daemonPort?: number, daemonSSL?: boolean): Promise<void>
  • Opens an existing wallet container

    Parameters

    • Optional daemonHost: string

      the node to use for the wallet container

    • Optional daemonPort: number

      the node port to use for the wallet container

    • daemonSSL: boolean = false

      whether the node uses SSL or not

    Returns Promise<void>

status

  • status(): Promise<IStatusInfo>
  • Retrieves the wallet sync status, peer count, and network hashrate

    Returns Promise<IStatusInfo>

transactionByHash

  • transactionByHash(hash: string): Promise<ITransactionInfo>
  • Retrieves details on a given transaction if found

    Parameters

    • hash: string

      the transaction hash to retrieve

    Returns Promise<ITransactionInfo>

transactionPrivateKey

  • transactionPrivateKey(hash: string): Promise<string>
  • Retrieves the transaction private key that can be used to audit a transaction

    Parameters

    • hash: string

    Returns Promise<string>

transactions

  • transactions(startHeight?: number, endHeight?: number): Promise<ITransactionInfo[]>
  • Retrieves a list of all transactions in the wallet container and/or within the supplied constraints

    Parameters

    • Optional startHeight: number

      the height to return transfers from

    • Optional endHeight: number

      the height to return transactions until

    Returns Promise<ITransactionInfo[]>

transactionsByAddress

  • transactionsByAddress(address: string, startHeight?: number, endHeight?: number): Promise<ITransactionInfo[]>
  • Retrieves a list of all transactions in the wallet container by address and/or within the supplied constraints

    Parameters

    • address: string

      the wallet address

    • startHeight: number = 0

      the height to return transfers from

    • Optional endHeight: number

      the height to return transactions until

    Returns Promise<ITransactionInfo[]>

unconfirmedTransactions

  • unconfirmedTransactions(address?: string): Promise<ITransactionInfo[]>
  • Retrieves a list of all unconfirmed outgoing transactions in the wallet container

    Parameters

    • Optional address: string

    Returns Promise<ITransactionInfo[]>

validateAddress

  • validateAddress(address: string): Promise<IValidationInfo>
  • Validates a given address

    Parameters

    • address: string

      the wallet address to validate

    Returns Promise<IValidationInfo>

Generated using TypeDoc