The port to access the API on. Normally 11898 for a TurtleCoin daemon, 80 for a HTTP api, or 443 for a HTTPS api.
You can optionally specify whether this API is a blockchain cache API to save a couple of requests. If you're not sure, do not specify this parameter - we will work it out automatically.
You can optionally specify whether this API supports ssl/tls/https to save a couple of requests. If you're not sure, do not specify this parameter - we will work it out automatically.
This is emitted whenever the interface fails to contact the underlying daemon. This event will only be emitted on the first disconnection. It will not be emitted again, until the daemon connects, and then disconnects again.
Example:
daemon.on('disconnect', (error) => {
console.log('Possibly lost connection to daemon: ' + error.toString());
});
This is emitted whenever the interface previously failed to contact the underlying daemon, and has now reconnected. This event will only be emitted on the first connection. It will not be emitted again, until the daemon disconnects, and then reconnects again.
Example:
daemon.on('connect', () => {
console.log('Regained connection to daemon!');
});
This is emitted whenever either the localDaemonBlockCount or the networkDaemonBlockCount changes.
Example:
daemon.on('heightchange', (localDaemonBlockCount, networkDaemonBlockCount) => {
console.log(localDaemonBlockCount, networkDaemonBlockCount);
});
This is emitted every time we download a block from the daemon. Will only be emitted if the daemon is using /getrawblocks (All non blockchain cache daemons should support this).
This block object is an instance of the Block turtlecoin-utils class. See the Utils docs for further info on using this value.
Note that a block emitted after a previous one could potentially have a lower height, if a blockchain fork took place.
Example:
daemon.on('rawblock', (block) => {
console.log(`Downloaded new block ${block.hash}`);
});
This is emitted every time we download a transaction from the daemon. Will only be emitted if the daemon is using /getrawblocks (All non blockchain cache daemons should support this).
This transaction object is an instance of the Transaction turtlecoin-utils class. See the Utils docs for further info on using this value.
Note that a transaction emitted after a previous one could potentially have a lower height in the chain, if a blockchain fork took place.
Example:
daemon.on('rawtransaction', (block) => {
console.log(`Downloaded new transaction ${transaction.hash}`);
});
The number of blocks to download per /getwalletsyncdata request
Did our last contact with the daemon succeed. Set to true initially so initial failure to connect will fire disconnect event.
The address node fees will go to
The amount of the node fee in atomic units
Daemon/API host
Whether we're talking to a conventional daemon, or a blockchain cache API
Have we determined if this is a cache API or not?
The hashrate of the last known local block
Last time the daemon height updated. If this goes over the configured limit, we'll emit deadnode.
Last time the network height updated. If this goes over the configured limit, we'll emit deadnode.
The amount of blocks the daemon we're connected to has
The amount of blocks the network has
The amount of peers we have, incoming+outgoing
Daemon/API port
Whether we should use https for our requests
Have we determined if we should be using ssl or not?
Should we use /getrawblocks instead of /getwalletsyncdata
Sets or gets the default captureRejection value for all emitters.
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.
Returns a mapping of transaction hashes to global indexes
Get global indexes for the transactions in the range [startHeight, endHeight]
Get the amount of blocks the daemon we're connected to has
Get the amount of blocks the network has
Gets random outputs for the given amounts. requestedOuts per. Usually mixin+1.
Returns an array of amounts to global indexes and keys. There should be requestedOuts indexes if the daemon fully fulfilled our request.
Hashes of the last known blocks. Later blocks (higher block height) should be ordered at the front of the array.
Height to start taking blocks from
Block timestamp to start taking blocks from
Gets blocks from the daemon. Blocks are returned starting from the last known block hash (if higher than the startHeight/startTimestamp)
Initialize the daemon and the fee info
Makes a get request to the given endpoint
Get the node fee and address
Update the daemon info
Update the fee address and amount
Generated using TypeDoc
The host to access the API on. Can be an IP, or a URL, for example, 1.1.1.1, or blockapi.turtlepay.io