Class

Mining

Mining()

Constructor

# new Mining()

View Source methods/mining/mining.ts, line 2

Methods

# estimateFee(params) → {Promise.<number>}

DEPRECATED. Please use estimateSmartFee for more intelligent estimates.

Estimates the approximate fee per kilobyte needed for a transaction to begin confirmation within nblocks blocks.

Uses virtual transaction size of transaction as defined in BIP 141 (witness data is discounted).

Parameters:
Name Type Description
params
nblocks number
Deprecated:
  • Yes

View Source methods/mining/mining.ts, line 356

Estimated fee-per-kilobyte.

A negative value is returned if not enough transactions and blocks have been observed to make an estimate.

-1 is always returned for nblocks == 1 as it is impossible to calculate a fee that is high enough to get reliably included in the next block.

Promise.<number>

# estimateRawFee(params) → {Promise.<EstimateRawFeeResponse>}

WARNING: This interface is unstable and may disappear or change!

WARNING: This is an advanced API call that is tightly coupled to the specific implementation of fee estimation.

The parameters it can be called with and the results it returns will change if the internal implementation changes.

Estimates the approximate fee per kilobyte needed for a transaction to begin confirmation within conf_target blocks if possible.

Uses virtual transaction size as defined in BIP 141 (witness data is discounted).

Parameters:
Name Type Attributes Default Description
params
conf_target number

Confirmation target in blocks (1 - 1008)

threshold number <optional>
0.95

The proportion of transactions in a given feerate range that must have been confirmed within conf_target in order to consider those feerates as high enough and proceed to check lower buckets. Default: 0.95

View Source methods/mining/mining.ts, line 387

Results are returned for any horizon which tracks blocks up to the confirmation target.

Promise.<EstimateRawFeeResponse>

# estimateSmartFee(params) → {Promise.<EstimateSmartFeeResponse>}

Estimates the approximate fee per kilobyte needed for a transaction to begin confirmation within conf_target blocks if possible and return the number of blocks for which the estimate is valid. Uses virtual transaction size as defined in BIP 141 (witness data is discounted).

Parameters:
Name Type Attributes Default Description
params
conf_target number

Confirmation target in blocks (1 - 1008)

estimate_mode string <optional>
'CONSERVATIVE'

Default = CONSERVATIVE. The fee estimate mode. Whether to return a more conservative estimate which also satisfies a longer history.

A conservative estimate potentially returns a higher feerate and is more likely to be sufficient for the desired target, but is not as responsive to short term drops in the prevailing fee market.

Must be one of: "UNSET", "ECONOMICAL", "CONSERVATIVE"

View Source methods/mining/mining.ts, line 370

Promise.<EstimateSmartFeeResponse>

# generateToAddress(params) → {Promise.<Array.<string>>}

Mine blocks immediately to a specified address (before the RPC call returns)

Parameters:
Name Type Attributes Description
params
nblocks number

How many blocks are generated immediately.

address string

The address to send the newly generated raven to.

maxtries number <optional>

How many iterations to try (default = 1000000).

View Source methods/mining/mining.ts, line 339

Array of hashes of blocks generated

Promise.<Array.<string>>

# getBlockTemplate(params) → {Promise}

If the request parameters include a 'mode' key, that is used to explicitly select between the default 'template' request or a 'proposal'.

It returns data needed to construct a block to work on.

For full specification, see BIPs 22, 23, 9, and 145:

  • https://github.com/raven/bips/blob/master/bip-0022.mediawiki
  • https://github.com/raven/bips/blob/master/bip-0023.mediawiki
  • https://github.com/raven/bips/blob/master/bip-0009.mediawiki#getblocktemplate_changes
  • https://github.com/raven/bips/blob/master/bip-0145.mediawiki
Parameters:
Name Type Description
params
template_request TemplateRequest

View Source methods/mining/mining.ts, line 74

Promise
Example
client.mining.getBlockTemplate()

# getGenerate() → {Promise.<boolean>}

Return if the server is set to generate coins or not. The default is false.

It is set with the command line argument -gen (or " + std::string(RAVEN_CONF_FILENAME) + " setting gen)

It can also be set with the setgenerate call.

View Source methods/mining/mining.ts, line 314

If the server is set to generate coins or not

Promise.<boolean>
Example
client.mining.getGenerate()

# getKawpowHash(params) → {Promise}

Get the kawpow hash for a block given its block data

Parameters:
Name Type Attributes Description
params
header_hash string

The prow_pow header hash that was given to the gpu miner from this rpc client

mix_hash string

The mix hash that was mined by the gpu miner via rpc

nonce string

The hex nonce of the block that hashed the valid block

height number

The height of the block data that is being hashed

target string <optional>

The target of the block that is hash is trying to meet

View Source methods/mining/mining.ts, line 302

Promise

# getMiningInfo() → {Promise.<GetMiningInfoResponse>}

Returns a json object containing mining-related information.

View Source methods/mining/mining.ts, line 246

Promise.<GetMiningInfoResponse>
Example
client.mining.getMiningInfo()

# getNetworkHashPs(params) → {Promise.<number>}

Returns the estimated network hashes per second based on the last n blocks.

Pass in [blocks] to override # of blocks, -1 specifies since last difficulty change.

Pass in [height] to estimate the network speed at the time when a certain block was found.

Parameters:
Name Type Attributes Default Description
params
nblocks number <optional>
120

The number of blocks, or -1 for blocks since last difficulty change.

height number <optional>
1

To estimate at the time of the given height.

View Source methods/mining/mining.ts, line 238

Hashes per second estimated

Promise.<number>
Example
client.mining.getNetworkHashPs()

# pprpcsb(params) → {Promise}

Attempts to submit new block to network mined by kawpow gpu miner via rpc.

Parameters:
Name Type Description
params
header_hash string

The prow_pow header hash that was given to the gpu miner from this rpc client

mix_hash string

The mix hash that was mined by the gpu miner via rpc

nonce string

The nonce of the block that hashed the valid block

View Source methods/mining/mining.ts, line 290

Promise

# prioritiseTransaction(params) → {Promise.<boolean>}

Accepts the transaction into mined blocks at a higher (or lower) priority

Parameters:
Name Type Attributes Description
params
txid string

The transaction id.

dummy number <optional>

API-Compatibility for previous API. Must be zero or null. DEPRECATED. For forward compatibility use named arguments and omit this parameter.

fee_delta number

The fee value (in satoshis) to add (or subtract, if negative). The fee is not actually paid, only the algorithm for selecting transactions into a block considers the transaction as it would have paid a higher (or lower) fee.

View Source methods/mining/mining.ts, line 258

Returns true

Promise.<boolean>
Example
client.mining.prioritiseTransaction({ txid: 'e71417299f383b4e1ec54b95ed803bf038330fc01019b4ac74b0be1e5060ac08', fee_delta: 100000 })

# setGenerate(params) → {Promise.<string>}

Set 'generate' true or false to turn generation on or off.

Generation is limited to 'genproclimit' processors, -1 is unlimited.

See the getgenerate call for the current setting.

Parameters:
Name Type Attributes Description
params
generate boolean

Set to true to turn on generation, false to turn off.

genproclimit number <optional>

Set the processor limit for when generation is on. Can be -1 for unlimited.

View Source methods/mining/mining.ts, line 329

Promise.<string>
Example
client.mining.setGenerate()

# submitBlock(params) → {Promise}

Attempts to submit new block to network.

See https://en.bitcoin.it/wiki/BIP_0022 for full specification.

Parameters:
Name Type Attributes Description
params
hexdata string

The hex-encoded block data to submit

dummy string <optional>

Dummy value, for compatibility with BIP22. This value is ignored.

View Source methods/mining/mining.ts, line 280

Promise