Skip to content

Commit 47ca202

Browse files
committed
Write initial draft of BIP 40
1 parent b3701fa commit 47ca202

File tree

2 files changed

+68
-3
lines changed

2 files changed

+68
-3
lines changed

README.mediawiki

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,12 @@ Those proposing changes should consider that ultimately consent may rest with th
210210
| Standard
211211
| Proposed
212212
|-
213-
| 40
213+
| [[bip-0040.mediawiki|40]]
214214
| API/RPC
215215
| Stratum wire protocol
216-
| Marek Palatinus
216+
| Marek Palatinus, Ben van Hartingsveldt
217217
| Standard
218-
| BIP number allocated
218+
| Draft
219219
|-
220220
| 41
221221
| API/RPC

bip-0040.mediawiki

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<pre>
2+
BIP: 40
3+
Layer: Applications
4+
Title: Stratum wire protocol
5+
Author: Marek Palatinus <[email protected]>
6+
Ben van Hartingsveldt <[email protected]>
7+
Comments-Summary: No comments yet.
8+
Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0040
9+
Status: Draft
10+
Type: Standards Track
11+
Created: 2024-03-07
12+
License: PD
13+
</pre>
14+
15+
==Abstract==
16+
17+
This document describes the Stratum wire protocol used in clients such as Electrum, and which also laid the foundation for the Stratum mining protocol, used in many Bitcoin pools.
18+
19+
The specification is intended to set a standard for connections between clients and servers in which the client is able to request data without having to download the full blockchain.
20+
21+
The specification consists of three parts. In the first part, the data format is defined. In the second part, the possible transport protocols (including encapsulation) are described. In the third part, the available methods are documented.
22+
23+
==Motivation==
24+
25+
Many clients want to give users access to the Bitcoin ecosystem. However, for specific reasons not every user is able to download the full blockchain to their machine.
26+
27+
The Stratum wire protocol defines a way to access the blockchain without having it downloaded. For example, a client can request both the genesis block and the latest block with the same latency, because the server does synchronize and index all blocks for us.
28+
29+
==History==
30+
31+
Stratum wire protocol was introduced by Marek Palatinus in late 2011 and early 2012. It was a language independent alternative for the Python-based protocol in early versions of Electrum, created by Thomas Voegtlin. The Stratum wire protocol made it possible to create compatible servers which Electrum could connect to, but it also made it possible to write alternative clients.
32+
33+
Later in 2012, Marek Palatinus introduced Stratum also for mining pools: The Stratum mining protocol, as defined in [[bip-0044.mediawiki|BIP 44]].
34+
35+
==Specification: Data Format==
36+
37+
Stratum leverages [https://www.jsonrpc.org/ JSON-RPC]. Both versions 1.0 and 2.0 are allowed. Rules of that version apply accordingly.
38+
39+
Additionally, it is a convention to give all Stratum methods in the `method` property a name in the following form: `<service>.<method>`, where `<service>` is allowed to have dots and `<method>` isn't. For example, the the value `blockchain.block.subscribe`.
40+
41+
Note: In JSON-RPC 1.0, the `param` property is an array, so everything should be passed in the right order. In JSON-RPC 2.0, also named parameters are allowed. In that case, the parameter names that are documented should be used. If not, the method can fail. It is maybe also possible that a specific method (or server) only does support `params` being an array, because it doesn't know how to handle the named ones, even if it supports JSON-RPC 2.0.
42+
43+
==Specification: Transport Protocols==
44+
45+
It is possible to send JSON-RPC messages over different transport protocols, like TCP and HTTP. It is also possible to protect these protocols with SSL/TLS.
46+
47+
TODO:
48+
* Websocket
49+
* Websocket over SSL/TLS
50+
* HTTP
51+
* HTTP over SSL/TLS
52+
53+
===TCP===
54+
55+
Stratum over a TCP connection. Every JSON-RPC message is send on a single line, ending with a line-feed (\n). Line-feeds inside the JSON should be encoded as usual. Both client and server can initiate a request on which the other side could respond with a result or an error.
56+
57+
Default port: 50001
58+
59+
===TCP over SSL/TLS===
60+
61+
Stratum over a TCP connection with SSL/TLS. Just the same as TCP, but with SSL/TLS enabled.
62+
63+
==Specification: Commands==
64+
65+
TODO

0 commit comments

Comments
 (0)