When analyzing the code and writing my own hub, I struggled with the server.version method. In LBRY a request of server.version looks like {"method":"server.version","id":58,"jsonrpc":"2.0","params":["0.113.0","0.113.0"]} and a response looks like {"jsonrpc":"2.0","result":["0.107.0","0.113.0"],"id":47}. At first glance, it doesn't look compatible with the server.version of Electrum, but it is.
First the request. Electrum defines server.version(client_name, protocol_version), where client_name is the name of the client and protocol_version is the supported version or range of supported versions of the client. When looking at the code at https://github.com/lbryio/hub/blob/ebcc6e508660f72fe11d308ae4031971b5fbf782/hub/herald/session.py#L1688, this is indeed the case. The LBRY request is fully compatible with the Electrum request, so it is also possible to send a request like {"method":"server.version","id":58,"jsonrpc":"2.0","params":["LBRY Desktop 1.0.0","0.113.0"]} or {"method":"server.version","id":58,"jsonrpc":"2.0","params":["LBRY Desktop 1.0.0",["0.113.0","0.113.0"]]}.
Note the response[0]. Why does this client code check for the first variable? The protocol information is in the second variable. I assume that response[1] is the right solution.
Also, some logging (note line 106):
2024-05-21 21:34:42,756 ERROR lbry.wallet.network:219: wallet server connection loop crashed
Traceback (most recent call last):
File "lbry\wallet\network.py", line 216, in loop_task_done_callback
File "lbry\wallet\network.py", line 321, in network_loop
File "lbry\wallet\network.py", line 304, in connect_to_fastest
File "lbry\wallet\network.py", line 106, in ensure_server_version
File "lbry\wallet\network.py", line 106, in <genexpr>
ValueError: invalid literal for int() with base 10: 'LBRYum Hub 1'
Dear,
When analyzing the code and writing my own hub, I struggled with the
server.version
method. In LBRY a request ofserver.version
looks like{"method":"server.version","id":58,"jsonrpc":"2.0","params":["0.113.0","0.113.0"]}
and a response looks like{"jsonrpc":"2.0","result":["0.107.0","0.113.0"],"id":47}
. At first glance, it doesn't look compatible with theserver.version
of Electrum, but it is.First the request. Electrum defines
server.version(client_name, protocol_version)
, whereclient_name
is the name of the client andprotocol_version
is the supported version or range of supported versions of the client. When looking at the code at https://github.com/lbryio/hub/blob/ebcc6e508660f72fe11d308ae4031971b5fbf782/hub/herald/session.py#L1688, this is indeed the case. The LBRY request is fully compatible with the Electrum request, so it is also possible to send a request like{"method":"server.version","id":58,"jsonrpc":"2.0","params":["LBRY Desktop 1.0.0","0.113.0"]}
or{"method":"server.version","id":58,"jsonrpc":"2.0","params":["LBRY Desktop 1.0.0",["0.113.0","0.113.0"]]}
.Then the response. Electrum defines it as returning
[server_software_version, protocol_version]
, whereserver_software_version
is the name of server andprotocol_version
is the chosen protocol version by the server to communicate with. Looking at https://github.com/lbryio/hub/blob/ebcc6e508660f72fe11d308ae4031971b5fbf782/hub/herald/session.py#L1695 and https://github.com/lbryio/hub/blob/ebcc6e508660f72fe11d308ae4031971b5fbf782/hub/herald/session.py#L1723, it indeed returns 2 variables.Now we take a look at the following code: https://github.com/lbryio/lbry-sdk/blob/eb5da9511e162ef1080cb34af2ee087383cfa94a/lbry/wallet/network.py#L106
Note the
response[0]
. Why does this client code check for the first variable? The protocol information is in the second variable. I assume thatresponse[1]
is the right solution.Also, some logging (note line 106):