Skip to content

Commit e74e0f1

Browse files
committed
follow-up scriptpubkeys
1 parent aee18f8 commit e74e0f1

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

docs/protocol-changes.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,7 @@ Changes
195195
the :func:`server.version` message must be the first message sent.
196196
That is, version negotiation must happen before any other messages.
197197
* The `blockchain.scripthash.*` methods are all replaced with `blockchain.scriptpubkey.*`
198-
methods. Note: `sha256(scriptPubKey) == scripthash`. This should be easy to implement:
199-
previously clients were calculating the sha256 hash prior to sending a request,
200-
now the server can decide whether to apply sha256 when processing the request.
201-
(some server implementations might want to apply sha256, to keep the same DB structure)
198+
methods. Note: `sha256(scriptPubKey) == scripthash`.
202199
* The status of a scripthash/scriptpubkey has its definition tightened in a
203200
backwards-compatible way: mempool txs now have a canonical ordering
204201
defined for the calculation (previously their order was undefined).

docs/protocol-methods.rst

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,10 +518,19 @@ Subscribe to a :ref:`scriptPubKey <scriptpubkeys>`.
518518

519519
**Notifications**
520520

521-
The client will receive a notification when the :ref:`status <status>` of the script
522-
hash changes. Its signature is
523-
524-
.. function:: blockchain.scriptpubkey.subscribe(scriptpubkey, status)
521+
The client will receive a notification when the :ref:`status <status>` of the
522+
scriptPubKey changes. Importantly, the notifications use :ref:`script hash <script hashes>`
523+
instead of scriptPubKey. The scripthash corresponds to the scriptPubKey from the
524+
original request.
525+
The client is expected to maintain a mapping scripthash->scriptpubkey, or similar,
526+
to be able to figure out what the notification refers to.
527+
Notably, this way servers do not have to store in memory the scriptpubkey corresponding
528+
to the original request (which can be up to 10 KB in size, as per Bitcoin consensus),
529+
only the scripthash (which is fixed size). Also, this limits upstream bandwidth usage
530+
of servers.
531+
The signature is
532+
533+
.. function:: blockchain.scriptpubkey.subscribe(scripthash, status)
525534
:noindex:
526535

527536
blockchain.scriptpubkey.unsubscribe

0 commit comments

Comments
 (0)