import MoneroAltChain from "./model/MoneroAltChain"; import MoneroBan from "./model/MoneroBan"; import MoneroBlock from "./model/MoneroBlock"; import MoneroBlockHeader from "./model/MoneroBlockHeader"; import MoneroBlockTemplate from "./model/MoneroBlockTemplate"; import MoneroDaemonInfo from "./model/MoneroDaemonInfo"; import MoneroDaemonListener from "./model/MoneroDaemonListener"; import MoneroDaemonSyncInfo from "./model/MoneroDaemonSyncInfo"; import MoneroDaemonUpdateCheckResult from "./model/MoneroDaemonUpdateCheckResult"; import MoneroDaemonUpdateDownloadResult from "./model/MoneroDaemonUpdateDownloadResult"; import MoneroFeeEstimate from "./model/MoneroFeeEstimate"; import MoneroHardForkInfo from "./model/MoneroHardForkInfo"; import MoneroKeyImageSpentStatus from "./model/MoneroKeyImageSpentStatus"; import MoneroMinerTxSum from "./model/MoneroMinerTxSum"; import MoneroMiningStatus from "./model/MoneroMiningStatus"; import MoneroOutput from "./model/MoneroOutput"; import MoneroOutputHistogramEntry from "./model/MoneroOutputHistogramEntry"; import MoneroPeer from "./model/MoneroPeer"; import MoneroPruneResult from "./model/MoneroPruneResult"; import MoneroSubmitTxResult from "./model/MoneroSubmitTxResult"; import MoneroTx from "./model/MoneroTx"; import MoneroTxPoolStats from "./model/MoneroTxPoolStats"; import MoneroVersion from "./model/MoneroVersion"; /** * Copyright (c) woodser * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ /** * Monero daemon interface and default implementations. */ export default class MoneroDaemon { /** * Register a listener to receive daemon notifications. * * @param {MoneroDaemonListener} listener - listener to receive daemon notifications * @return {Promise} */ addListener(listener: MoneroDaemonListener): Promise; /** * Unregister a listener to receive daemon notifications. * * @param {MoneroDaemonListener} listener - listener to unregister * @return {Promise} */ removeListener(listener: MoneroDaemonListener): Promise; /** * Get the listeners registered with the daemon. * * @return {MoneroDaemonListener[]} the registered listeners */ getListeners(): MoneroDaemonListener[]; /** * Indicates if the client is connected to the daemon via RPC. * * @return {Promise} true if the client is connected to the daemon, false otherwise */ isConnected(): Promise; /** * Gets the version of the daemon. * * @return {Promise} the version of the daemon */ getVersion(): Promise; /** * Indicates if the daemon is trusted xor untrusted. * * @return {Promise} true if the daemon is trusted, false otherwise */ isTrusted(): Promise; /** * Get the number of blocks in the longest chain known to the node. * * @return {Promise} the number of blocks! */ getHeight(): Promise; /** * Get a block's hash by its height. * * @param {number} height - height of the block hash to get * @return {Promise} the block's hash at the given height */ getBlockHash(height: number): Promise; /** * Get a block template for mining a new block. * * @param {string} walletAddress - address of the wallet to receive miner transactions if block is successfully mined * @param {number} [reserveSize] - reserve size (optional) * @return {Promise} is a block template for mining a new block */ getBlockTemplate(walletAddress: string, reserveSize?: number): Promise; /** * Get the last block's header. * * @return {Promise} last block's header */ getLastBlockHeader(): Promise; /** * Get a block header by its hash. * * @param {string} blockHash - hash of the block to get the header of * @return {Promise} block's header */ getBlockHeaderByHash(blockHash: string): Promise; /** * Get a block header by its height. * * @param {number} height - height of the block to get the header of * @return {Promise} block's header */ getBlockHeaderByHeight(height: number): Promise; /** * Get block headers for the given range. * * @param {number} [startHeight] - start height lower bound inclusive (optional) * @param {number} [endHeight] - end height upper bound inclusive (optional) * @return {Promise} for the given range */ getBlockHeadersByRange(startHeight?: number, endHeight?: number): Promise; /** * Get a block by hash. * * @param {string} blockHash - hash of the block to get * @return {Promise} with the given hash */ getBlockByHash(blockHash: string): Promise; /** * Get blocks by hash. * * @param {string[]} blockHashes - array of hashes; first 10 blocks hashes goes sequential, * next goes in pow(2,n) offset, like 2, 4, 8, 16, 32, 64 and so on, * and the last one is always genesis block * @param {number} startHeight - start height to get blocks by hash * @param {boolean} [prune] - specifies if returned blocks should be pruned (defaults to false) // TODO: test default * @return {Promise} retrieved blocks */ getBlocksByHash(blockHashes: string[], startHeight: number, prune?: boolean): Promise; /** * Get a block by height. * * @param {number} height - height of the block to get * @return {Promise} with the given height */ getBlockByHeight(height: number): Promise; /** * Get blocks at the given heights. * * @param {number[]} heights - heights of the blocks to get * @return {Promise} are blocks at the given heights */ getBlocksByHeight(heights: number[]): Promise; /** * Get blocks in the given height range. * * @param {number} [startHeight] - start height lower bound inclusive (optional) * @param {number} [endHeight] - end height upper bound inclusive (optional) * @return {Promise} are blocks in the given height range */ getBlocksByRange(startHeight?: number, endHeight?: number): Promise; /** * Get blocks in the given height range as chunked requests so that each request is * not too big. * * @param {number} [startHeight] - start height lower bound inclusive (optional) * @param {number} [endHeight] - end height upper bound inclusive (optional) * @param {number} [maxChunkSize] - maximum chunk size in any one request (default 3,000,000 bytes) * @return {Promise} blocks in the given height range */ getBlocksByRangeChunked(startHeight?: number, endHeight?: number, maxChunkSize?: number): Promise; /** * Get block hashes as a binary request to the daemon. * * @param {string[]} blockHashes - specify block hashes to fetch; first 10 blocks hash goes * sequential, next goes in pow(2,n) offset, like 2, 4, 8, 16, 32, 64 * and so on, and the last one is always genesis block * @param {number} startHeight - starting height of block hashes to return * @return {Promise} requested block hashes */ getBlockHashes(blockHashes: string[], startHeight: number): Promise; /** * Get a transaction by hash. * * @param {string} txHash - hash of the transaction to get * @param {boolean} [prune] - specifies if the returned tx should be pruned (defaults to false) * @return {Promise} transaction with the given hash or undefined if not found */ getTx(txHash?: string, prune?: boolean): Promise; /** * Get transactions by hashes. * * @param {string[]} txHashes - hashes of transactions to get * @param {boolean} [prune] - specifies if the returned txs should be pruned (defaults to false) * @return {Promise} found transactions with the given hashes */ getTxs(txHashes: string[], prune?: boolean): Promise; /** * Get a transaction hex by hash. * * @param {string} txHash - hash of the transaction to get hex from * @param {boolean} [prune] - specifies if the returned tx hex should be pruned (defaults to false) * @return {Promise} tx hex with the given hash */ getTxHex(txHash: string, prune?: boolean): Promise; /** * Get transaction hexes by hashes. * * @param {string[]} txHashes - hashes of transactions to get hexes from * @param {boolean} [prune] - specifies if the returned tx hexes should be pruned (defaults to false) * @return {Promise} tx hexes */ getTxHexes(txHashes: string[], prune?: boolean): Promise; /** * Gets the total emissions and fees from the genesis block to the current height. * * @param {number} height - height to start computing the miner sum * @param {number} numBlocks - number of blocks to include in the sum * @return {Promise} encapsulates the total emissions and fees since the genesis block */ getMinerTxSum(height: number, numBlocks: number): Promise; /** * Get mining fee estimates per kB. * * @param {number} graceBlocks TODO * @return {Promise} mining fee estimates per kB */ getFeeEstimate(graceBlocks?: number): Promise; /** * Submits a transaction to the daemon's pool. * * @param {string} txHex - raw transaction hex to submit * @param {boolean} doNotRelay specifies if the tx should be relayed (default false, i.e. relay) * @return {Promise} contains submission results */ submitTxHex(txHex: string, doNotRelay?: boolean): Promise; /** * Relays a transaction by hash. * * @param {string} txHash - hash of the transaction to relay * @return {Promise} */ relayTxByHash(txHash: string): Promise; /** * Relays transactions by hash. * * @param {string[]} txHashes - hashes of the transactinos to relay * @return {Promise} */ relayTxsByHash(txHashes: string[]): Promise; /** * Get valid transactions seen by the node but not yet mined into a block, as well * as spent key image information for the tx pool. * * @return {Promise} are transactions in the transaction pool! */ getTxPool(): Promise; /** * Get hashes of transactions in the transaction pool. * * @return {string[]} are hashes of transactions in the transaction pool */ getTxPoolHashes(): Promise; /** * Get transaction pool statistics. * * @return {Promise} contains statistics about the transaction pool */ getTxPoolStats(): Promise; /** * Flush transactions from the tx pool. * * @param {(string | string[])} [hashes] - specific transactions to flush (defaults to all) * @return {Promise} */ flushTxPool(hashes?: string | string[]): Promise; /** * Get the spent status of the given key image. * * @param {string} keyImage - key image hex to get the status of * @return {Promise} status of the key image */ getKeyImageSpentStatus(keyImage: string): Promise; /** * Get the spent status of each given key image. * * @param {string[]} keyImages are hex key images to get the statuses of * @return {Promise} status for each key image */ getKeyImageSpentStatuses(keyImages: string[]): Promise; /** * Get outputs identified by a list of output amounts and indices as a binary * request. * * @param {MoneroOutput[]} outputs - identify each output by amount and index * @return {Promise} identified outputs */ getOutputs(outputs: MoneroOutput[]): Promise; /** * Get a histogram of output amounts. For all amounts (possibly filtered by * parameters), gives the number of outputs on the chain for that amount. * RingCT outputs counts as 0 amount. * * @param {bigint[]} [amounts] - amounts of outputs to make the histogram with * @param {number} [minCount] - TODO * @param {number} [maxCount] - TODO * @param {boolean} [isUnlocked] - makes a histogram with outputs with the specified lock state * @param {number} [recentCutoff] - TODO * @return {Promise} are entries meeting the parameters */ getOutputHistogram(amounts?: bigint[], minCount?: number, maxCount?: number, isUnlocked?: boolean, recentCutoff?: number): Promise; /** * Get general information about the state of the node and the network. * * @return {Promise} is general information about the node and network */ getInfo(): Promise; /** * Get synchronization information. * * @return {Promise} contains sync information */ getSyncInfo(): Promise; /** * Look up information regarding hard fork voting and readiness. * * @return {Promise } contains hard fork information */ getHardForkInfo(): Promise; /** * Get alternative chains seen by the node. * * @return {Promise} alternative chains */ getAltChains(): Promise; /** * Get known block hashes which are not on the main chain. * * @return {Promise} known block hashes which are not on the main chain */ getAltBlockHashes(): Promise; /** * Get the download bandwidth limit. * * @return {Promise} download bandwidth limit */ getDownloadLimit(): Promise; /** * Set the download bandwidth limit. * * @param {number} limit - download limit to set (-1 to reset to default) * @return {number} new download limit after setting */ setDownloadLimit(limit: number): Promise; /** * Reset the download bandwidth limit. * * @return {Promise} download bandwidth limit after resetting */ resetDownloadLimit(): Promise; /** * Get the upload bandwidth limit. * * @return {Promise} upload bandwidth limit */ getUploadLimit(): Promise; /** * Set the upload bandwidth limit. * * @param limit - upload limit to set (-1 to reset to default) * @return {Promise} new upload limit after setting */ setUploadLimit(limit: number): Promise; /** * Reset the upload bandwidth limit. * * @return {Promise} upload bandwidth limit after resetting */ resetUploadLimit(): Promise; /** * Get peers with active incoming or outgoing connections to the node. * * @return {Promise} the daemon's peers */ getPeers(): Promise; /** * Get known peers including their last known online status. * * @return {MoneroPeer[]} the daemon's known peers */ getKnownPeers(): Promise; /** * Limit number of outgoing peers. * * @param {number} limit - maximum number of outgoing peers * @return {Promise} */ setOutgoingPeerLimit(limit: number): Promise; /** * Limit number of incoming peers. * * @param {number} limit - maximum number of incoming peers * @return {Promise} */ setIncomingPeerLimit(limit: number): Promise; /** * Get peer bans. * * @return {Promise} entries about banned peers */ getPeerBans(): Promise; /** * Ban a peer node. * * @param {MoneroBan} ban - contains information about a node to ban * @return {Promise} */ setPeerBan(ban: MoneroBan): Promise; /** * Ban peers nodes. * * @param {MoneroBan[]} bans - specify which peers to ban * @return {Promise} */ setPeerBans(bans: MoneroBan[]): Promise; /** * Start mining. * * @param {string} address - address given miner rewards if the daemon mines a block * @param {integer} [numThreads] - number of mining threads to run (default 1) * @param {boolean} [isBackground] - specifies if the miner should run in the background or not (default false) * @param {boolean} [ignoreBattery] - specifies if the battery state (e.g. on laptop) should be ignored or not (default false) * @return {Promise} */ startMining(address: string, numThreads?: number, isBackground?: boolean, ignoreBattery?: boolean): Promise; /** * Stop mining. * * @return {Promise} */ stopMining(): Promise; /** * Get the daemon's mining status. * * @return {Promise} daemon's mining status */ getMiningStatus(): Promise; /** * Submit a mined block to the network. * * @param {string} blockBlob - mined block to submit * @return {Promise} */ submitBlock(blockBlob: string): Promise; /** * Prune the blockchain. * * @param {boolean} check specifies to check the pruning (default false) * @return {Promise} the prune result */ pruneBlockchain(check: boolean): Promise; /** * Submit mined blocks to the network. * * @param {string[]} blockBlobs - mined blocks to submit * @return {Promise} */ submitBlocks(blockBlobs: string[]): Promise; /** * Check for update. * * @return {Promise} the result */ checkForUpdate(): Promise; /** * Download an update. * * @param {string} [path] - path to download the update (optional) * @return {Promise} the result */ downloadUpdate(path?: string): Promise; /** * Safely disconnect and shut down the daemon. * * @return {Promise} */ stop(): Promise; /** * Get the header of the next block added to the chain. * * @return {Promise} header of the next block added to the chain */ waitForNextBlockHeader(): Promise; }