============== Protocol Ideas ============== .. note:: This is a draft of ideas for a future protocol tentatively called 2.0; they are not implemented and it is likely they will change and that protocol 2.0 will be quite different. This protocol version makes changes intended to allow clients and servers to more easily scale to support queries about busy addresses. It has changes to reduce the amount of round-trip queries made in common usage, and to make results more compact to reduce bandwidth consumption. RPC calls with potentially large responses have pagination support, and the return value of :func:`blockchain.scripthash.subscribe` changes. Script hash :ref:`status ` had to be recalculated with each new transaction and was undefined if it included more than one mempool transaction. Its calculation is linear in history length resulting in quadratic complexity as history grows. Its calculation for large histories was demanding for both the server to compute and the client to check. RPC calls and notifications that combined the effects of the mempool and confirmed history are removed. The changes are beneficial to clients and servers alike, but will require changes to both client-side and server-side logic. In particular, the client should track what block (by hash and height) wallet data is synchronized to, and if that hash is no longer part of the main chain, it will need to remove wallet data for blocks that were reorganized away and get updated information as of the first reorganized block. The effects are limited to script hashes potentially affected by the reorg, and for most clients this will be the empty set. blockchain.scripthash.subscribe =============================== Subscribe to a script hash. **Signature** .. function:: blockchain_.scripthash.subscribe(scripthash) *scripthash* The script hash as a hexadecimal string. **Result** .. versionchanged:: 2.0 As of protocol 2.0, the transaction hash of the last confirmed transaction in blockchain order, or :const:`null` if there are none. For protocol versions 1.4 and below, the :ref:`status ` of the script hash. **Notifications** .. versionchanged:: 2.0 As this is a subscription, the client receives notifications when the confirmed transaction history and/or associated mempool transactions change. As of protocol 2.0, the initial mempool and subsequent changes to it are sent with :func:`mempool.changes` notifications. When confirmed history changes, a notification with signature .. function:: blockchain.scripthash.subscribe(scripthash, tx_hash) :noindex: is sent, where *tx_hash* is the hash of the last confirmed transaction in blockchain order. blockchain.scripthash.history ============================= Return part of the confirmed history of a :ref:`script hash