Protocol Methods ================ blockchain.address.get_balance ------------------------------ Return the confirmed and unconfirmed balances of a bitcoin address. .. note:: This method is deprecated; support will be removed in a later protocol version. Use :func:`blockchain.scripthash.get_balance` instead. **Signature** .. function:: blockchain.address.get_balance(address) * *address* The address as a Base58 string. **Result** A dictionary with keys `confirmed` and `unconfirmed`. The value of each is the appropriate balance in coin units as a string. **Result Example**:: { "confirmed": "1.03873966", "unconfirmed": "0.236844" } blockchain.address.get_history ------------------------------ Return the confirmed and unconfirmed history of a bitcoin address. .. note:: This method is deprecated; support will be removed in a later protocol version. Use :func:`blockchain.scripthash.get_history` instead. **Signature** .. function:: blockchain.address.get_history(address) * *address* The address as a Base58 string. **Result** A list of confirmed transactions in blockchain order, with the output of :func:`blockchain.address.get_mempool` appended to the list. Each confirmed transaction is a dictionary with the following keys: * *height* The integer height of the block the transaction was confirmed in. * *tx_hash* The transaction hash in hexadecimal. See :func:`blockchain.address.get_mempool` for how mempool transactions are returned. **Result Examples** :: [ { "height": 200004, "tx_hash": "acc3758bd2a26f869fcc67d48ff30b96464d476bca82c1cd6656e7d506816412" }, { "height": 215008, "tx_hash": "f3e1bf48975b8d6060a9de8884296abb80be618dc00ae3cb2f6cee3085e09403" } ] :: [ { "fee": 20000, "height": 0, "tx_hash": "9fbed79a1e970343fcd39f4a2d830a6bde6de0754ed2da70f489d0303ed558ec" } ] blockchain.address.get_mempool ------------------------------ Return the unconfirmed transactions of a bitcoin address. .. note:: This method is deprecated; support will be removed in a later protocol version. Use :func:`blockchain.scripthash.get_mempool` instead. **Signature** .. function:: blockchain.address.get_mempool(address) * *address* The address as a Base58 string. **Result** A list of mempool transactions in arbitrary order. Each mempool transaction is a dictionary with the following keys: * *height* ``0`` if all inputs are confirmed, and ``-1`` otherwise. * *tx_hash* The transaction hash in hexadecimal. * *fee* The transaction fee in minimum coin units (satoshis). **Result Example** :: [ { "tx_hash": "45381031132c57b2ff1cbe8d8d3920cf9ed25efd9a0beb764bdb2f24c7d1c7e3", "height": 0, "fee": 24310 } ] blockchain.address.listunspent ------------------------------ Return an ordered list of UTXOs sent to a bitcoin address. .. note:: This method is deprecated; support will be removed in a later protocol version. Use :func:`blockchain.scripthash.get_mempool` instead. **Signature** .. function:: blockchain.address.listunspent(address) * *address* The address as a Base58 string. **Result** A list of unspent outputs in blockchain order. This function takes the mempool into account. Mempool transactions paying to the address are included at the end of the list in an undefined order. Any output that is spent in the mempool does not appear. Each output is a dictionary with the following keys: * *height* The integer height of the block the transaction was confirmed in. ``0`` if the transaction is in the mempool. * *tx_pos* The zero-based index of the output in the transaction's list of outputs. * *tx_hash* The output's transaction hash as a hexadecimal string. * *value* The output's value in minimum coin units (satoshis). **Result Example** :: [ { "tx_pos": 0, "value": 45318048, "tx_hash": "9f2c45a12db0144909b5db269415f7319179105982ac70ed80d76ea79d923ebf", "height": 437146 }, { "tx_pos": 0, "value": 919195, "tx_hash": "3d2290c93436a3e964cfc2f0950174d8847b1fbe3946432c4784e168da0f019f", "height": 441696 } ] blockchain.address.subscribe ---------------------------- Subscribe to a bitcoin address. .. note:: This method is deprecated; support will be removed in a later protocol version. Use :func:`blockchain.scripthash.subscribe` instead. **Signature** .. function:: blockchain.address.subscribe(address) *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. 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) *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.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() **Result** The coin-specific :ref:`deserialized header ` of the current block chain tip. **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* The coin-specific :ref:`deserialized header ` of the new block chain tip. .. 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 blocks. 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. .. note:: This subscription is deprecated in favour of :func:`blockchain.headers.subscribe` which provides more detailed and useful information. **Signature** .. function:: blockchain.numblocks.subscribe() **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) .. 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 height. The protocol does not guarantee notification of all intermediate block heights. Similarly if a chain reorganization occurs resulting in the same chain height, the client may or may not receive a notification. 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.transaction.broadcast -------------------------------- Broadcast a transaction to the network. **Signature** .. function:: blockchain.transaction.broadcast(raw_tx) *raw_tx* The raw transaction as a hexadecimal string. **Result** The transaction hash as a hexadecimal string. .. note:: protocol version 1.0 (only) does not respond according to the JSON RPC specification if an error occurs. If the daemon rejects the transaction, the result is the error message string from the daemon, as if the call were successful. The client needs to determine if an error occurred by comparing the result to the expected transaction hash. Protocol version 1.1 and later return a JSON RPC error as would be expected. **Result Examples** :: "a76242fce5753b4212f903ff33ac6fe66f2780f34bdb4b33b175a7815a11a98e" Protocol version 1.0 returning an error as the result: :: "258: txn-mempool-conflict" blockchain.transaction.get -------------------------- Return a raw transaction. **Signature** .. function:: blockchain.transaction.get(tx_hash, verbose=False) *tx_hash* The transaction hash as a hexadecimal string. *verbose* .. versionadded:: 1.2 .. note:: Protocol version 1.0 also had a 2nd argument but ignored it. This was removed in protocol 1.1 which took a single argument only. **Result** If *verbose* is :const:`False`, the raw transaction as a hexadecimal string. If :const:`True`, the result is coin-specific and whatever the coin daemon returns when asked for a verbose form of the raw transaction. **Example Results** When *verbose* is :const:`False`:: "01000000015bb9142c960a838329694d3fe9ba08c2a6421c5158d8f7044cb7c48006c1b48" "4000000006a4730440220229ea5359a63c2b83a713fcc20d8c41b20d48fe639a639d2a824" "6a137f29d0fc02201de12de9c056912a4e581a62d12fb5f43ee6c08ed0238c32a1ee76921" "3ca8b8b412103bcf9a004f1f7a9a8d8acce7b51c983233d107329ff7c4fb53e44c855dbe1" "f6a4feffffff02c6b68200000000001976a9141041fb024bd7a1338ef1959026bbba86006" "4fe5f88ac50a8cf00000000001976a91445dac110239a7a3814535c15858b939211f85298" "88ac61ee0700" When *verbose* is :const:`True`:: { "blockhash": "0000000000000000015a4f37ece911e5e3549f988e855548ce7494a0a08b2ad6", "blocktime": 1520074861, "confirmations": 679, "hash": "36a3692a41a8ac60b73f7f41ee23f5c917413e5b2fad9e44b34865bd0d601a3d", "hex": "01000000015bb9142c960a838329694d3fe9ba08c2a6421c5158d8f7044cb7c48006c1b484000000006a4730440220229ea5359a63c2b83a713fcc20d8c41b20d48fe639a639d2a8246a137f29d0fc02201de12de9c056912a4e581a62d12fb5f43ee6c08ed0238c32a1ee769213ca8b8b412103bcf9a004f1f7a9a8d8acce7b51c983233d107329ff7c4fb53e44c855dbe1f6a4feffffff02c6b68200000000001976a9141041fb024bd7a1338ef1959026bbba860064fe5f88ac50a8cf00000000001976a91445dac110239a7a3814535c15858b939211f8529888ac61ee0700", "locktime": 519777, "size": 225, "time": 1520074861, "txid": "36a3692a41a8ac60b73f7f41ee23f5c917413e5b2fad9e44b34865bd0d601a3d", "version": 1, "vin": [ { "scriptSig": { "asm": "30440220229ea5359a63c2b83a713fcc20d8c41b20d48fe639a639d2a8246a137f29d0fc02201de12de9c056912a4e581a62d12fb5f43ee6c08ed0238c32a1ee769213ca8b8b[ALL|FORKID] 03bcf9a004f1f7a9a8d8acce7b51c983233d107329ff7c4fb53e44c855dbe1f6a4", "hex": "4730440220229ea5359a63c2b83a713fcc20d8c41b20d48fe639a639d2a8246a137f29d0fc02201de12de9c056912a4e581a62d12fb5f43ee6c08ed0238c32a1ee769213ca8b8b412103bcf9a004f1f7a9a8d8acce7b51c983233d107329ff7c4fb53e44c855dbe1f6a4" }, "sequence": 4294967294, "txid": "84b4c10680c4b74c04f7d858511c42a6c208bae93f4d692983830a962c14b95b", "vout": 0}], "vout": [ { "n": 0, "scriptPubKey": { "addresses": [ "12UxrUZ6tyTLoR1rT1N4nuCgS9DDURTJgP"], "asm": "OP_DUP OP_HASH160 1041fb024bd7a1338ef1959026bbba860064fe5f OP_EQUALVERIFY OP_CHECKSIG", "hex": "76a9141041fb024bd7a1338ef1959026bbba860064fe5f88ac", "reqSigs": 1, "type": "pubkeyhash"}, "value": 0.0856647}, { "n": 1, "scriptPubKey": { "addresses": [ "17NMgYPrguizvpJmB1Sz62ZHeeFydBYbZJ"], "asm": "OP_DUP OP_HASH160 45dac110239a7a3814535c15858b939211f85298 OP_EQUALVERIFY OP_CHECKSIG", "hex": "76a91445dac110239a7a3814535c15858b939211f8529888ac", "reqSigs": 1, "type": "pubkeyhash"}, "value": 0.1360904}]} blockchain.transaction.get_merkle --------------------------------- Return the markle branch to a confirmed transaction given its hash and height. **Signature** .. function:: blockchain.transaction.get_merkle(tx_hash, height) *tx_hash* The transaction hash as a hexadecimal string. *height* The height at which it was confirmed, an integer. **Result** A dictionary with the following keys: * *block_height* The height of the block the transaction was confirmed in. * *merkle* A list of transaction hashes the current hash is paired with, recursively, in order to trace up to obtain merkle root of the block, deepest pairing first. * *pos* The 0-based index of the position of the transaction in the ordered list of transactions in the block. **Result Example** :: { "merkle": [ "713d6c7e6ce7bbea708d61162231eaa8ecb31c4c5dd84f81c20409a90069cb24", "03dbaec78d4a52fbaf3c7aa5d3fccd9d8654f323940716ddf5ee2e4bda458fde", "e670224b23f156c27993ac3071940c0ff865b812e21e0a162fe7a005d6e57851", "369a1619a67c3108a8850118602e3669455c70cdcdb89248b64cc6325575b885", "4756688678644dcb27d62931f04013254a62aeee5dec139d1aac9f7b1f318112", "7b97e73abc043836fd890555bfce54757d387943a6860e5450525e8e9ab46be5", "61505055e8b639b7c64fd58bce6fc5c2378b92e025a02583303f69930091b1c3", "27a654ff1895385ac14a574a0415d3bbba9ec23a8774f22ec20d53dd0b5386ff", "5312ed87933075e60a9511857d23d460a085f3b6e9e5e565ad2443d223cfccdc", "94f60b14a9f106440a197054936e6fb92abbd69d6059b38fdf79b33fc864fca0", "2d64851151550e8c4d337f335ee28874401d55b358a66f1bafab2c3e9f48773d" ], "block_height": 450538, "pos": 710 } mempool.get_fee_histogram ------------------------- Return a histogram of the fee rates paid by transactions in the memory pool, weighted by transaction size. **Signature** .. function:: mempool.get_fee_histogram() .. versionadded:: 1.2 **Result** The histogram is an array of [*fee*, *vsize*] pairs, where |vsize_n| is the cumulative virtual size of mempool transactions with a fee rate in the interval [|fee_n1|, |fee_n|], and |fee_n1| > |fee_n|. .. |vsize_n| replace:: vsize\ :sub:`n` .. |fee_n| replace:: fee\ :sub:`n` .. |fee_n1| replace:: fee\ :sub:`n-1` Fee intervals may have variable size. The choice of appropriate intervals is currently not part of the protocol. **Example Result** :: [[12, 128812], [4, 92524], [2, 6478638], [1, 22890421]] server.add_peer --------------- This call is intended for a new server to get itself into a server's peers list, and should not be used by wallet clients. **Signature** .. function:: server.add_peer(features) .. versionadded:: 1.1 * *features* The same information that a call to the sender's :func:`server.features` RPC call would return. **Result** A boolean indicating whether the request was tentatively accepted. The requesting server will appear in :func:`server.peers.subscribe` when further sanity checks complete successfully. server.banner ------------- Return a banner to be shown in the Electrum console. **Signature** .. function:: server.banner() **Result** A string. **Example Result** :: "Welcome to Electrum!" server.donation_address ----------------------- Return a server donation address. **Signature** .. function:: server.donation_address() **Result** A string. **Example Result** :: "1BWwXJH3q6PRsizBkSGm2Uw4Sz1urZ5sCj" server.features --------------- Return a list of features and services supported by the server. **Signature** .. function:: server.features() **Result** A dictionary of keys and values. Each key represents a feature or service of the server, and the value gives additional information. The following features MUST be reported by the server. Additional key-value pairs may be returned. * *hosts* A dictionary, keyed by host name, that this server can be reached at. Normally this will only have a single entry; other entries can be used in case there are other connection routes (e.g. Tor). The value for a host is itself a dictionary, with the following optional keys: * *ssl_port* An integer. Omit or set to :const:`null` if SSL connectivity is not provided. * *tcp_port* An integer. Omit or set to :const:`null` if TCP connectivity is not provided. A server should ignore information provided about any host other than the one it connected to. * *genesis_hash* The hash of the genesis block. This is used to detect if a peer is connected to one serving a different network. * *hash_function* The hash function the server uses for :ref:`script hashing