Protocol Methods ================ blockchain.address.get_balance ------------------------------ Return the confirmed and unconfirmed balances of a bitcoin address. **Signature** .. function:: blockchain.address.get_balance(address) .. deprecated:: 1.2 * *address* The address as a Base58 string. **Result** See :func:`blockchain.scripthash.get_balance`. blockchain.address.get_history ------------------------------ Return the confirmed and unconfirmed history of a bitcoin address. **Signature** .. function:: blockchain.address.get_history(address) .. deprecated:: 1.2 * *address* The address as a Base58 string. **Result** As for :func:`blockchain.scripthash.get_history`. blockchain.address.get_mempool ------------------------------ Return the unconfirmed transactions of a bitcoin address. **Signature** .. function:: blockchain.address.get_mempool(address) .. deprecated:: 1.2 * *address* The address as a Base58 string. **Result** As for :func:`blockchain.scripthash.get_mempool`. blockchain.address.listunspent ------------------------------ Return an ordered list of UTXOs sent to a bitcoin address. **Signature** .. function:: blockchain.address.listunspent(address) .. deprecated:: 1.2 * *address* The address as a Base58 string. **Result** As for :func:`blockchain.scripthash.listunspent`. blockchain.address.subscribe ---------------------------- Subscribe to a bitcoin address. **Signature** .. function:: blockchain.address.subscribe(address) .. deprecated:: 1.2 *address* The address as a Base58 string. **Result** The :ref:`status ` of the address. **Notifications** As this is a subcription, the client will receive a notification when the :ref:`status ` of the address changes. Its signature is .. function:: blockchain.address.subscribe(address, status) blockchain.block.get_header --------------------------- Return the :ref:`deserialized header ` of the block at the given height. **Signature** .. function:: blockchain.block.get_header(height) *height* The height of the block, an integer. **Result** The coin-specific :ref:`deserialized header `. **Example Result** :: { "bits": 392292856, "block_height": 510000, "merkle_root": "297cfcc6a66e063692b20650d21cc0ac7a2a80f7277ebd7c5d6c7010a070d25c", "nonce": 3347656422, "prev_block_hash": "0000000000000000002292de0d9f03dfa15a04dbf09102d5d4552117b717fa86", "timestamp": 1519083654, "version": 536870912 } blockchain.block.get_chunk -------------------------- Return a concatenated chunk of block headers from the main chain. Typically, a chunk consists of a fixed number of block headers over which difficulty is constant, and at the end of which difficulty is retargeted. In the case of Bitcoin a chunk is 2,016 headers, each of 80 bytes, so chunk 5 consists of the block headers from height 10,080 to 12,095 inclusive. When encoded as hexadecimal, the result string is twice as long, so for Bitcoin it takes 322,560 bytes, making this a bandwidth-intensive request. **Signature** .. function:: blockchain.block.get_chunk(index) .. deprecated:: 1.2 *index* The zero-based index of the chunk, an integer. **Result** The binary block headers as hexadecimal strings, in-order and concatenated together. As many as headers as are available at the implied starting height will be returned; this may range from zero to the coin-specific chunk size. blockchain.block.headers ------------------------ Return a concatenated chunk of block headers from the main chain. **Signature** .. function:: blockchain.block.headers(start_height, count) .. versionadded:: 1.2 *start_height* The height of the first header requested, a non-negative integer. *count* The number of headers requested, a non-negative integer. **Result** A dictionary with the following members: * *count* The number of headers returned, between zero and the number requested. If the chain has not extended sufficiently far, only the available headers will be returned. If more headers than *max* were requested at most *max* will be returned. * *hex* The binary block headers concatenated together in-order as a hexadecimal string. * *max* The maximum number of headers the server will return in a single request. **Example Response** :: { "count": 2, "hex": "0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a29ab5f49ffff001d1dac2b7c010000006fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000982051fd1e4ba744bbbe680e1fee14677ba1a3c3540bf7b1cdb606e857233e0e61bc6649ffff001d01e36299" "max": 2016 } blockchain.estimatefee ---------------------- Return the estimated transaction fee per kilobyte for a transaction to be confirmed within a certain number of blocks. **Signature** .. function:: blockchain.estimatefee(number) *number* The number of blocks to target for confirmation. **Result** The estimated transaction fee in coin units per kilobyte, as a floating point number. If the daemon does not have enough information to make an estimate, the integer ``-1`` is returned. **Example Result** :: 0.00101079 blockchain.headers.subscribe ---------------------------- Subscribe to receive block headers when a new block is found. **Signature** .. function:: blockchain.headers.subscribe(raw=False) .. versionchanged:: 1.2 Optional *raw* parameter added. * *raw* :const:`False` or :const:`True`. The value :const:`False` is deprecated. **Result** The header of the current block chain tip. If *raw* is :const:`True` the result is a dictionary with two members: * *hex* The binary header as a hexadecimal string. * *height* The height of the header, an integer. If *raw* is :const:`False` the result is the coin-specific :ref:`deserialized header `. **Example Result** With *raw* :const:`False`:: { "bits": 402858285, "block_height": 520481, "merkle_root": "8e8e932eb858fd53cf09943d7efc9a8f674dc1363010ee64907a292d2fb0c25d", "nonce": 3288656012, "prev_block_hash": "000000000000000000b512b5d9fc7c5746587268547c04aa92383aaea0080289", "timestamp": 1520495819, "version": 536870912 } With *raw* :const:`True`:: { "height": 520481, "hex": "00000020890208a0ae3a3892aa047c5468725846577cfcd9b512b50000000000000000005dc2b02f2d297a9064ee103036c14d678f9afc7e3d9409cf53fd58b82e938e8ecbeca05a2d2103188ce804c4" } **Notifications** As this is a subcription, the client will receive a notification when a new block is found. The notification's signature is: .. function:: blockchain.headers.subscribe(header) * *header* See **Result** above. .. note:: should a new block arrive quickly, perhaps while the server is still processing prior blocks, the server may only notify of the most recent chain tip. The protocol does not guarantee notification of all intermediate block headers. In a similar way the client must be prepared to handle chain reorganisations. Should a re-org happen the new chain tip will not sit directly on top of the prior chain tip. The client must be able to figure out the common ancestor block and request any missing block headers to acquire a consistent view of the chain state. blockchain.numblocks.subscribe ------------------------------ Subscribe to receive the block height when a new block is found. **Signature** .. function:: blockchain.numblocks.subscribe() *Removed in version 1.1.* **Result** The height of the current block, an integer. **Notifications** As this is a subcription, the client will receive a notification when a new block is found. The notification's signature is: .. function:: blockchain.numblocks.subscribe(height) blockchain.relayfee ------------------- Return the minimum fee a low-priority transaction must pay in order to be accepted to the daemon's memory pool. **Signature** .. function:: blockchain.relayfee() **Result** The fee in whole coin units (BTC, not satoshis for Bitcoin) as a floating point number. **Example Results** :: 1e-05 :: 0.0 blockchain.scripthash.get_balance --------------------------------- Return the confirmed and unconfirmed balances of a :ref:`script hash