ExBitcoin v0.3.0 ExBitcoin.Mining View Source

Mining RPC

Link to this section Summary

Functions

getblocktemplate ( TemplateRequest )

getmininginfo

getnetworkhashps ( nblocks height )

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

submitblock “hexdata” ( “dummy” )

Link to this section Functions

Link to this function getblocktemplate(template_request) View Source
getblocktemplate(:"String.t") :: any()

getblocktemplate ( TemplateRequest )

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/bitcoin/bips/blob/master/bip-0022.mediawiki
https://github.com/bitcoin/bips/blob/master/bip-0023.mediawiki
https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki#getblocktemplate_changes
https://github.com/bitcoin/bips/blob/master/bip-0145.mediawiki

Arguments:

  1. template_request (json object, optional) A json object in the following spec { “mode”:”template” (string, optional) This must be set to “template”, “proposal” (see BIP 23), or omitted “capabilities”:[ (array, optional) A list of strings

       "support"          (string) client side supported feature, 'longpoll', 'coinbasetxn', 'coinbasevalue', 'proposal', 'serverlist', 'workid'
       ,...

    ], “rules”:[ (array, optional) A list of strings

       "support"          (string) client side supported softfork deployment
       ,...

    ] }

Result: { “version” : n, (numeric) The preferred block version “rules” : [ “rulename”, … ], (array of strings) specific block rules that are to be enforced “vbavailable” : { (json object) set of pending, supported versionbit (BIP 9) softfork deployments

  "rulename" : bitnumber          (numeric) identifies the bit number as indicating acceptance and readiness for the named softfork rule
  ,...

}, “vbrequired” : n, (numeric) bit mask of versionbits the server requires set in submissions “previousblockhash” : “xxxx”, (string) The hash of current highest block “transactions” : [ (array) contents of non-coinbase transactions that should be included in the next block

  {
     "data" : "xxxx",             (string) transaction data encoded in hexadecimal (byte-for-byte)
     "txid" : "xxxx",             (string) transaction id encoded in little-endian hexadecimal
     "hash" : "xxxx",             (string) hash encoded in little-endian hexadecimal (including witness data)
     "depends" : [                (array) array of numbers 
         n                          (numeric) transactions before this one (by 1-based index in 'transactions' list) that must be present in the final block if this one is
         ,...
     ],
     "fee": n,                    (numeric) difference in value between transaction inputs and outputs (in Satoshis); for coinbase transactions, this is a negative Number of the total collected block fees (ie, not including the block subsidy); if key is not present, fee is unknown and clients MUST NOT assume there isn't one
     "sigops" : n,                (numeric) total SigOps cost, as counted for purposes of block limits; if key is not present, sigop cost is unknown and clients MUST NOT assume it is zero
     "weight" : n,                (numeric) total transaction weight, as counted for purposes of block limits
     "required" : true|false      (boolean) if provided and true, this transaction must be in the final block
  }
  ,...

], “coinbaseaux” : { (json object) data that should be included in the coinbase’s scriptSig content

  "flags" : "xx"                  (string) key name is to be ignored, and value included in scriptSig

}, “coinbasevalue” : n, (numeric) maximum allowable input to coinbase transaction, including the generation award and transaction fees (in Satoshis) “coinbasetxn” : { … }, (json object) information for coinbase transaction “target” : “xxxx”, (string) The hash target “mintime” : xxx, (numeric) The minimum timestamp appropriate for next block time in seconds since epoch (Jan 1 1970 GMT) “mutable” : [ (array of string) list of ways the block template may be changed

 "value"                          (string) A way the block template may be changed, e.g. 'time', 'transactions', 'prevblock'
 ,...

], “noncerange” : “00000000ffffffff”,(string) A range of valid nonces “sigoplimit” : n, (numeric) limit of sigops in blocks “sizelimit” : n, (numeric) limit of block size “weightlimit” : n, (numeric) limit of block weight “curtime” : ttt, (numeric) current timestamp in seconds since epoch (Jan 1 1970 GMT) “bits” : “xxxxxxxx”, (string) compressed target of next block “height” : n (numeric) The height of the next block }

Examples:

bitcoin-cli getblocktemplate curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “getblocktemplate”, “params”: [] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function getmininginfo() View Source
getmininginfo() :: any()

getmininginfo

Returns a json object containing mining-related information. Result: { “blocks”: nnn, (numeric) The current block “currentblockweight”: nnn, (numeric) The last block weight “currentblocktx”: nnn, (numeric) The last block transaction “difficulty”: xxx.xxxxx (numeric) The current difficulty “errors”: “…” (string) Current errors “networkhashps”: nnn, (numeric) The network hashes per second “pooledtx”: n (numeric) The size of the mempool “chain”: “xxxx”, (string) current network name as defined in BIP70 (main, test, regtest) }

Examples:

bitcoin-cli getmininginfo curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “getmininginfo”, “params”: [] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function getnetworkhashps(nblocks, height) View Source
getnetworkhashps(:"String.t", :"String.t") :: any()

getnetworkhashps ( nblocks height )

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.

Arguments:

  1. nblocks (numeric, optional, default=120) The number of blocks, or -1 for blocks since last difficulty change.
  2. height (numeric, optional, default=-1) To estimate at the time of the given height.

Result: x (numeric) Hashes per second estimated

Examples:

bitcoin-cli getnetworkhashps curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “getnetworkhashps”, “params”: [] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function prioritisetransaction(txid, dummy, fee_delta) View Source
prioritisetransaction(:"String.t", :"String.t", :"String.t") :: any()

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

Arguments:

  1. “txid” (string, required) The transaction id.
  2. dummy (numeric, optional) API-Compatibility for previous API. Must be zero or null. DEPRECATED. For forward compatibility use named arguments and omit this parameter.
  3. fee_delta (numeric, required) 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.

Result: true (boolean) Returns true

Examples:

bitcoin-cli prioritisetransaction “txid” 0.0 10000 curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “prioritisetransaction”, “params”: [“txid”, 0.0, 10000] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/

Link to this function submitblock() View Source
submitblock() :: any()

submitblock “hexdata” ( “dummy” )

Attempts to submit new block to network. See https://en.bitcoin.it/wiki/BIP_0022 for full specification.

Arguments

  1. “hexdata” (string, required) the hex-encoded block data to submit
  2. “dummy” (optional) dummy value, for compatibility with BIP22. This value is ignored.

Result:

Examples:

bitcoin-cli submitblock “mydata” curl —user myusername —data-binary ‘{“jsonrpc”: “1.0”, “id”:”curltest”, “method”: “submitblock”, “params”: [“mydata”] }’ -H ‘content-type: text/plain;’ http://127.0.0.1:8332/