Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TurtleCoind

A class interface that allows for easy interaction with TurtleCoind

Hierarchy

  • HTTPClient
    • TurtleCoind

Implements

  • ITurtleCoind

Index

Constructors

constructor

  • new TurtleCoind(host?: string, port?: number, timeout?: number, ssl?: boolean, userAgent?: string, keepAlive?: boolean, apiKey?: string, errorHandler?: (statusCode: number, error: IError) => Error): TurtleCoind
  • Parameters

    • host: string = '127.0.0.1'
    • port: number = 11898
    • timeout: number = 30000
    • ssl: boolean = false
    • userAgent: string = ...
    • keepAlive: boolean = true
    • Optional apiKey: string
    • Optional errorHandler: (statusCode: number, error: IError) => Error
        • (statusCode: number, error: IError): Error
        • Parameters

          • statusCode: number
          • error: IError

          Returns Error

    Returns TurtleCoind

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

block

  • block(block: string | number): Promise<IBlock>
  • Retrieves the block information for the specified block Requires the daemon to have the explorer enabled

    Parameters

    • block: string | number

      the block height or hash

    Returns Promise<IBlock>

blockCount

  • blockCount(): Promise<number>
  • Retrieves the number of blocks the node has in its chain

    Returns Promise<number>

blockHeaders

  • blockHeaders(height: number): Promise<IBlock[]>
  • Retrieves the block information for the last 30 blocks up to the current height Requires the daemon to have the explorer enabled

    Parameters

    • height: number

      the height to stop at

    Returns Promise<IBlock[]>

blockTemplate

  • blockTemplate(address: string, reserveSize?: number): Promise<IBlockTemplate>
  • Retrieves a mining block template using the specified address and reserve size

    Parameters

    • address: string

      the wallet address that will receive the coinbase outputs

    • reserveSize: number = 6

      the amount of data to reserve in the miner transaction

    Returns Promise<IBlockTemplate>

Protected delete

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

    • endpoint: string

    Returns Promise<void>

fee

  • fee(): Promise<IFee>
  • Retrieves the node fee information

    Returns Promise<IFee>

Protected get

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

    • endpoint: string

    Returns Promise<any>

height

  • height(): Promise<IHeight>
  • Retrieves the node height information

    Returns Promise<IHeight>

indexes

  • indexes(startHeight: number, endHeight: number): Promise<ITransactionIndexes[]>
  • Retrieves the global indexes for all transactions contained within the blocks heights specified (non-inclusive)

    Parameters

    • startHeight: number

      the starting block height

    • endHeight: number

      the ending block height

    Returns Promise<ITransactionIndexes[]>

info

  • info(): Promise<IInfo>
  • Retrieves the node information

    Returns Promise<IInfo>

lastBlock

  • lastBlock(): Promise<IBlock>
  • Retrieves the block information for the last block available

    Returns Promise<IBlock>

peers

  • peers(): Promise<IPeers>
  • Retrieves the node peer information

    Returns Promise<IPeers>

Protected post

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

    • endpoint: string
    • Optional body: any

    Returns Promise<any>

Protected put

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

    • endpoint: string
    • Optional body: any

    Returns Promise<any>

randomIndexes

  • randomIndexes(amounts: number[], count?: number): Promise<IRandomOutput[]>
  • Retrieves random global indexes typically used for mixing operations for the specified amounts and for the number requested (if available)

    Parameters

    • amounts: number[]

      an array of amounts for which we need random global indexes

    • count: number = 3

      the number of global indexes to return for each amount

    Returns Promise<IRandomOutput[]>

rawBlock

  • rawBlock(block: string | number): Promise<IRawBlock>
  • Retrieves the RawBlock information from the node for the specified block Requires the daemon to have the explorer enabled

    Parameters

    • block: string | number

      the block height or hash

    Returns Promise<IRawBlock>

rawSync

  • rawSync(checkpoints?: string[], height?: number, timestamp?: number, skipCoinbaseTransactions?: boolean, count?: number): Promise<IRawSync>
  • Retrieves the RawBlocks & RawTransactions for syncing a wallet (or other utility) against the node

    Parameters

    • checkpoints: string[] = ...

      a list of block hashes that we know about in descending height order

    • height: number = 0

      the height to start syncing from

    • timestamp: number = 0

      the timestamp to start syncing from

    • skipCoinbaseTransactions: boolean = false

      whether we should skip blocks that only include coinbase transactions

    • count: number = 100

      the number of blocks to return

    Returns Promise<IRawSync>

rawTransaction

  • rawTransaction(hash: string): Promise<string>
  • Retrieves the RawTransaction from the node for the specified transaction Requires the daemon to have the explorer enabled

    Parameters

    • hash: string

      the transaction hash

    Returns Promise<string>

rawTransactionPool

  • rawTransactionPool(): Promise<string[]>
  • Retrieves the RawTransactions currently in the memory pool Requires the daemon to have the explorer enabled

    Returns Promise<string[]>

Protected rpcPost

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

    • method: string
    • Optional params: any

    Returns Promise<any>

submitBlock

  • submitBlock(block: string): Promise<string>
  • Submits a block to the node for processing

    Parameters

    • block: string

      the hex representation of the block

    Returns Promise<string>

submitTransaction

  • submitTransaction(transaction: string): Promise<string>
  • Submits a transaction to the node for processing

    Parameters

    • transaction: string

      the hex representation of the transaction

    Returns Promise<string>

sync

  • sync(checkpoints?: string[], height?: number, timestamp?: number, skipCoinbaseTransactions?: boolean, count?: number): Promise<ISync>
  • Retrieves the information necessary for syncing a wallet (or other utility) against the node

    Parameters

    • checkpoints: string[] = ...

      a list of block hashes that we know about in descending height order

    • height: number = 0

      the height to start syncing from

    • timestamp: number = 0

      the timestamp to start syncing from

    • skipCoinbaseTransactions: boolean = false

      whether we should skip blocks that only include coinbase transactions

    • count: number = 100

      the number of blocks to return

    Returns Promise<ISync>

transaction

  • transaction(hash: string): Promise<ITransaction>
  • Retrieves the transaction information for the specified transaction Requires the daemon to have the explorer enabled

    Parameters

    • hash: string

      the transaction hash

    Returns Promise<ITransaction>

transactionPool

  • transactionPool(): Promise<TransactionSummary[]>
  • Retrieves the transaction summary information for the transactions currently Requires the daemon to have the explorer enabled in the memory pool

    Returns Promise<TransactionSummary[]>

transactionPoolChanges

  • transactionPoolChanges(lastKnownBlock: string, transactions?: string[]): Promise<ITransactionPoolDelta>
  • Gets the transaction memory pool changes given the last known block hash and the transactions we last knew to be in the memory pool

    Parameters

    • lastKnownBlock: string

      the last known block hash

    • transactions: string[] = ...

      an array of transaction hashes we last saw in the memory pool

    Returns Promise<ITransactionPoolDelta>

transactionsStatus

  • transactionsStatus(transactions: string[]): Promise<ITransactionsStatus>
  • Retrieves information on where the specified transactions are located

    Parameters

    • transactions: string[]

      an array of transaction hashes

    Returns Promise<ITransactionsStatus>

Generated using TypeDoc