Skip to content

Commit 1bff88f

Browse files
committed
add new protocol version 1.6
- This is mostly split off from the protocol 1.5/2.0 specs and ideas in spesmilo/electrumx#90 - notably it does not include the history pagination, and the recursive scripthash status, which are deferred for now
1 parent 6bd082c commit 1bff88f

File tree

3 files changed

+277
-29
lines changed

3 files changed

+277
-29
lines changed

docs/protocol-basics.rst

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,12 @@ revision number.
6868

6969
A party to a connection will speak all protocol versions in a range,
7070
say from `protocol_min` to `protocol_max`, which may be the same.
71-
When a connection is made, both client and server must initially
72-
assume the protocol to use is their own `protocol_min`.
7371

74-
The client should send a :func:`server.version` RPC call as early as
75-
possible in order to negotiate the precise protocol version; see its
76-
description for more detail. All responses received in the stream
77-
from and including the server's response to this call will use its
78-
negotiated protocol version.
72+
The client must send a :func:`server.version` RPC call as the first
73+
message on the wire, in order to negotiate the precise protocol
74+
version; see its description for more detail.
75+
All responses received in the stream from and including the server's
76+
response to this call will use its negotiated protocol version.
7977

8078

8179
.. _script hashes:
@@ -144,23 +142,31 @@ Status
144142
To calculate the `status` of a :ref:`script hash <script hashes>` (or
145143
address):
146144

147-
1. order confirmed transactions to the script hash by increasing
148-
height (and position in the block if there are more than one in a
149-
block)
145+
1. Consider all transactions touching the script hash (both those spending
146+
from it, and those funding it), both confirmed and unconfirmed (in mempool).
150147

151-
2. form a string that is the concatenation of strings
148+
2. Order confirmed transactions by increasing height (and position in the
149+
block if there are more than one in a block).
150+
151+
3. form a string that is the concatenation of strings
152152
``"tx_hash:height:"`` for each transaction in order, where:
153153

154154
* ``tx_hash`` is the transaction hash in hexadecimal
155155

156156
* ``height`` is the height of the block it is in.
157157

158-
3. Next, with mempool transactions in any order, append a similar
159-
string for those transactions, but where **height** is ``-1`` if the
160-
transaction has at least one unconfirmed input, and ``0`` if all
161-
inputs are confirmed.
158+
4. For mempool transactions, we define **height** to be ``-1`` if the
159+
transaction has at least one unconfirmed input, and ``0`` if all inputs are
160+
confirmed.
161+
162+
5. Order mempool transactions by ``(-height, tx_hash)``, that is,
163+
``0`` height txs come before ``-1`` height txs, and secondarily the
164+
txid (in network byteorder) is used to arrive at a canonical ordering.
165+
166+
6. Next, with mempool transactions in the specified order, append a similar
167+
strin.
162168

163-
4. The :dfn:`status` of the script hash is the :func:`sha256` hash of the
169+
7. The :dfn:`status` of the script hash is the :func:`sha256` hash of the
164170
full string expressed as a hexadecimal string, or :const:`null` if the
165171
string is empty because there are no transactions.
166172

docs/protocol-changes.rst

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Protocol Changes
33
================
44

5-
This documents lists changes made by protocol version.
5+
This document lists changes made by protocol version.
66

77
Version 1.0
88
===========
@@ -175,3 +175,40 @@ New methods
175175
-----------
176176

177177
* :func:`blockchain.name.get_value_proof` to resolve a name (with proof). Name index coins (e.g. Namecoin) only.
178+
179+
180+
Version 1.5
181+
===========
182+
183+
(this version number was skipped, no corresponding protocol is defined)
184+
185+
186+
.. _version 1.6:
187+
188+
Version 1.6
189+
===========
190+
191+
Changes
192+
-------
193+
194+
* Breaking change for the version negotiation: we now mandate that
195+
the :func:`server.version` message must be the first message sent.
196+
That is, version negotiation must happen before any other messages.
197+
* The status of a scripthash has its definition tightened in a
198+
backwards-compatible way: mempool txs now have a canonical ordering
199+
defined for the calculation (previously their order was undefined).
200+
* :func:`blockchain.scripthash.get_mempool` previously did not define
201+
an order for mempool transactions. We now mandate a specific ordering.
202+
* The previously required *height* argument for
203+
:func:`blockchain.transaction.get_merkle` is now optional.
204+
* Optional *mode* argument added to :func:`blockchain.estimatefee`.
205+
* :func:`blockchain.block.headers` now returns headers as a list,
206+
instead of a single concatenated hex string.
207+
208+
New methods
209+
-----------
210+
211+
* :func:`blockchain.outpoint.subscribe` to subscribe to a transaction
212+
outpoint, and get a notification when it gets spent.
213+
* :func:`blockchain.outpoint.unsubscribe` to unsubscribe from a TXO.
214+
* :func:`blockchain.outpoint.get_status` to get current status of a TXO, without subscribing to changes.

0 commit comments

Comments
 (0)