Skip to content

Commit 9351173

Browse files
committed
docs: describe protocol version 1.5
1 parent be14f02 commit 9351173

3 files changed

Lines changed: 147 additions & 14 deletions

File tree

docs/protocol-basics.rst

Lines changed: 6 additions & 8 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`.
73-
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.
71+
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:

docs/protocol-changes.rst

Lines changed: 25 additions & 3 deletions
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
===========
@@ -159,10 +159,32 @@ Changes
159159
Non-AuxPoW chains are unaffected.
160160

161161

162-
Version 1.4.1
162+
Version 1.4.2
163163
=============
164164

165165
New methods
166166
-----------
167167

168-
* :func:`blockchain.scipthash.unsubscribe` to unsubscribe from a script hash.
168+
* :func:`blockchain.scripthash.unsubscribe` to unsubscribe from a script hash.
169+
170+
.. _version 1.5:
171+
172+
Version 1.5
173+
===========
174+
175+
Changes
176+
-------
177+
178+
* Breaking change for the version negotiation: we now mandate that
179+
the :func:`server.version` message must be the first message sent.
180+
That is, version negotiation must happen before any other messages.
181+
* The previously required *height* argument for
182+
:func:`blockchain.transaction.get_merkle` is now optional.
183+
* Optional *mode* argument added to :func:`blockchain.estimatefee`.
184+
185+
New methods
186+
-----------
187+
188+
* :func:`blockchain.outpoint.subscribe` to subscribe to a transaction
189+
outpoint, and get a notification when it gets spent.
190+
* :func:`blockchain.outpoint.unsubscribe` to unsubscribe from a TXO.

docs/protocol-methods.rst

Lines changed: 116 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,19 @@ be confirmed within a certain number of blocks.
160160

161161
**Signature**
162162

163-
.. function:: blockchain.estimatefee(number)
163+
.. function:: blockchain.estimatefee(number, mode=None)
164+
.. versionchanged:: 1.5
165+
*mode* argument added
164166

165167
*number*
166168

167169
The number of blocks to target for confirmation.
168170

171+
*mode*
172+
173+
A string to pass to the bitcoind *estimatesmartfee* RPC as the
174+
*estimate_mode* parameter. Optional.
175+
169176
**Result**
170177

171178
The estimated transaction fee in coin units per kilobyte, as a
@@ -498,6 +505,109 @@ Unsubscribe from a script hash, preventing future notifications if its :ref:`sta
498505
Note that :const:`False` might be returned even for something subscribed to earlier,
499506
because the server can drop subscriptions in rare circumstances.
500507

508+
blockchain.outpoint.subscribe
509+
===============================
510+
511+
Subscribe to a transaction outpoint (TXO), to get notifications about its status.
512+
A status involves up to two transactions: the funding transaction that creates
513+
the TXO (as one of its outputs), and the spending transaction that uses it
514+
as an input (spends it).
515+
516+
**Signature**
517+
518+
.. function:: blockchain.outpoint.subscribe(tx_hash, txout_idx)
519+
.. versionadded:: 1.5
520+
521+
*tx_hash*
522+
523+
The TXID of the funding transaction as a hexadecimal string.
524+
(sometimes called prevout_hash, in inputs)
525+
526+
*txout_idx*
527+
528+
The output index, a non-negative integer. (sometimes called prevout_n, in inputs)
529+
530+
**Result**
531+
532+
The status of the TXO, taking the mempool into consideration.
533+
The output is a dictionary, containing 0, 1, or 3 of the following items:
534+
535+
* *height*
536+
537+
The integer height of the block the funding transaction was confirmed in.
538+
``0`` if the funding transaction is in the mempool.
539+
This key must be present if and only if there exists a funding transaction
540+
(either in the best chain or in the mempool), regardless of spentness.
541+
542+
* *spender_txhash*
543+
544+
The TXID of the spending transaction as a hexadecimal string.
545+
This key is present if and only if there exists a spending transaction
546+
(either in the best chain or in the mempool).
547+
548+
* *spender_height*
549+
550+
The integer height of the block the spending transaction was confirmed in.
551+
``0`` if the spending transaction is in the mempool.
552+
This key is present if and only if the `spender_txhash` key is present.
553+
554+
555+
**Result Examples**
556+
557+
::
558+
559+
{}
560+
561+
::
562+
563+
{
564+
"height": 1866594
565+
}
566+
567+
::
568+
569+
{
570+
"height": 1866594,
571+
"spender_txhash": "4a19a360f71814c566977114c49ccfeb8a7e4719eda26cee27fa504f3f02ca09",
572+
"spender_height": 0
573+
}
574+
575+
**Notifications**
576+
577+
The client will receive a notification when the `status` of the outpoint changes.
578+
The protocol does not guarantee but the client might also receive a notification
579+
if the status does not change but there was a reorg.
580+
Its signature is
581+
582+
.. function:: blockchain.outpoint.subscribe([tx_hash, txout_idx], status)
583+
:noindex:
584+
585+
blockchain.outpoint.unsubscribe
586+
=================================
587+
588+
Unsubscribe from a transaction outpoint (TXO), preventing future notifications
589+
if its `status` changes.
590+
591+
**Signature**
592+
593+
.. function:: blockchain.outpoint.unsubscribe(tx_hash, txout_idx)
594+
.. versionadded:: 1.5
595+
596+
*tx_hash*
597+
598+
The TXID of the funding transaction as a hexadecimal string.
599+
600+
*txout_idx*
601+
602+
The output index, a non-negative integer.
603+
604+
**Result**
605+
606+
Returns :const:`True` if the outpoint was subscribed to, otherwise :const:`False`.
607+
Note that :const:`False` might be returned even for something subscribed to earlier,
608+
because the server can drop subscriptions in rare circumstances.
609+
610+
501611
blockchain.transaction.broadcast
502612
================================
503613

@@ -625,15 +735,17 @@ and height.
625735

626736
**Signature**
627737

628-
.. function:: blockchain.transaction.get_merkle(tx_hash, height)
738+
.. function:: blockchain.transaction.get_merkle(tx_hash, height=None)
739+
.. versionchanged:: 1.5
740+
*height* argument made optional (previously mandatory)
629741

630742
*tx_hash*
631743

632744
The transaction hash as a hexadecimal string.
633745

634746
*height*
635747

636-
The height at which it was confirmed, an integer.
748+
Optionally, the height at which it was confirmed, an integer.
637749

638750
**Result**
639751

@@ -968,6 +1080,7 @@ server.version
9681080
==============
9691081

9701082
Identify the client to the server and negotiate the protocol version.
1083+
This must be the first message sent on the wire.
9711084
Only the first :func:`server.version` message is accepted.
9721085

9731086
**Signature**

0 commit comments

Comments
 (0)