Commit f0cffb3
committed
feat: Automatically negotiate protocol version on connect
Send `server.version` as the first message after establishing a
connection, as required by Electrum protocol v1.6. The negotiated
protocol version is stored in `RawClient` and can be retrieved via
the new `protocol_version()` method.
- Add `CLIENT_NAME`, `PROTOCOL_VERSION_MIN`, `PROTOCOL_VERSION_MAX` constants
- Add `protocol_version` field to `RawClient` to store negotiated version
- All constructors (`new`, `new_ssl`, `new_ssl_from_stream`, `new_proxy`)
now automatically call `server.version` after connecting
- The `server_version()` method also updates the stored version when called
This is a breaking change as the constructors now return errors if
protocol negotiation fails.
Co-Authored-By: Claude Code AI
Signed-off-by: Elias Rohrer <dev@tnull.de>1 parent 12b34a3 commit f0cffb3
2 files changed
Lines changed: 87 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
48 | 57 | | |
49 | 58 | | |
50 | 59 | | |
| |||
142 | 151 | | |
143 | 152 | | |
144 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
145 | 157 | | |
146 | 158 | | |
147 | 159 | | |
| |||
163 | 175 | | |
164 | 176 | | |
165 | 177 | | |
| 178 | + | |
| 179 | + | |
166 | 180 | | |
167 | 181 | | |
168 | 182 | | |
| |||
173 | 187 | | |
174 | 188 | | |
175 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
176 | 193 | | |
177 | 194 | | |
178 | 195 | | |
| |||
187 | 204 | | |
188 | 205 | | |
189 | 206 | | |
190 | | - | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
191 | 210 | | |
192 | 211 | | |
193 | 212 | | |
| |||
285 | 304 | | |
286 | 305 | | |
287 | 306 | | |
288 | | - | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
289 | 310 | | |
290 | 311 | | |
291 | 312 | | |
| |||
466 | 487 | | |
467 | 488 | | |
468 | 489 | | |
469 | | - | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
470 | 493 | | |
471 | 494 | | |
472 | 495 | | |
| |||
496 | 519 | | |
497 | 520 | | |
498 | 521 | | |
499 | | - | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
500 | 525 | | |
501 | 526 | | |
502 | 527 | | |
| |||
551 | 576 | | |
552 | 577 | | |
553 | 578 | | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
554 | 603 | | |
555 | 604 | | |
556 | 605 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| |||
240 | 242 | | |
241 | 243 | | |
242 | 244 | | |
243 | | - | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
244 | 277 | | |
245 | 278 | | |
246 | 279 | | |
| |||
0 commit comments