qubenix / qubes-whonix-bitcoin

GNU General Public License v3.0
17 stars 13 forks source link

Electrum not connecting to Electrum Personal Server #3

Open s7n4qg3 opened 4 years ago

s7n4qg3 commented 4 years ago

I've installed bitcoind, Electrum Personal Server (EPS), and Electrum on QubesOS using the information in these guides. When I run all of these, Electrum shows that it is 'Not connected' at the bottom left corner of the window. When I check the debug.log for EPS, it shows the following text:

user@host:~$ sudo tail -f /home/electrum-personal-server/.eps/debug.log
DEBUG:2020-09-22 23:13:36,775: <= {"jsonrpc": "2.0", "result": {"hex": "040000009a93abd98a0fa11edb7316b84109dcf5241b353354b652000000000000000000e6f742a66814fb94e58ca43f9af8bf4cab51809e793866fd1841e8328dba1c2e6691c55614a10718dc6f25b7", "height": 398984}, "id": 1}
DEBUG:2020-09-22 23:13:36,777: => {"jsonrpc": "2.0", "method": "blockchain.estimatefee", "id": 2, "params": [25]}
DEBUG:2020-09-22 23:13:36,786: <= {"jsonrpc": "2.0", "result": 0.0001, "id": 2}
DEBUG:2020-09-22 23:13:36,788: => {"jsonrpc": "2.0", "method": "blockchain.estimatefee", "id": 3, "params": [10]}
DEBUG:2020-09-22 23:13:36,833: <= {"jsonrpc": "2.0", "result": 0.0001, "id": 3}
DEBUG:2020-09-22 23:13:36,834: => {"jsonrpc": "2.0", "method": "blockchain.estimatefee", "id": 4, "params": [5]}
DEBUG:2020-09-22 23:13:36,881: <= {"jsonrpc": "2.0", "result": 0.0001, "id": 4}
DEBUG:2020-09-22 23:13:36,882: => {"jsonrpc": "2.0", "method": "blockchain.estimatefee", "id": 5, "params": [2]}
DEBUG:2020-09-22 23:13:36,887: <= {"jsonrpc": "2.0", "result": 0.0001, "id": 5}
DEBUG:2020-09-22 23:13:36,890: Electrum wallet disconnected
DEBUG:2020-09-22 23:13:47,383: Electrum connected from 127.0.0.1
DEBUG:2020-09-22 23:13:47,404: => {"jsonrpc": "2.0", "method": "server.version", "id": 0, "params": ["electrum/4.0.3", "1.4"]}
DEBUG:2020-09-22 23:13:47,406: <= {"jsonrpc": "2.0", "result": ["ElectrumPersonalServer 0.2.1.1", "1.4"], "id": 0}
DEBUG:2020-09-22 23:13:47,411: => {"jsonrpc": "2.0", "method": "blockchain.headers.subscribe", "id": 1}
DEBUG:2020-09-22 23:13:47,411: are_headers_raw = True
DEBUG:2020-09-22 23:13:47,502: <= {"jsonrpc": "2.0", "result": {"hex": "04000000e675a895401ea94bfd325bb6dd4f91208dadbc7b26745e0000000000000000009cd5f8267ea4315b543c23b9c878e450cce64678684358fe3c88bb5a007c1c9ae3bcc55614a10718a675c773", "height": 399007}, "id": 1}
DEBUG:2020-09-22 23:13:47,503: => {"jsonrpc": "2.0", "method": "blockchain.estimatefee", "id": 2, "params": [25]}
DEBUG:2020-09-22 23:13:47,543: <= {"jsonrpc": "2.0", "result": 0.0001, "id": 2}
DEBUG:2020-09-22 23:13:47,543: => {"jsonrpc": "2.0", "method": "blockchain.estimatefee", "id": 3, "params": [10]}
DEBUG:2020-09-22 23:13:47,546: <= {"jsonrpc": "2.0", "result": 0.0001, "id": 3}
DEBUG:2020-09-22 23:13:47,547: => {"jsonrpc": "2.0", "method": "blockchain.estimatefee", "id": 4, "params": [5]}
DEBUG:2020-09-22 23:13:47,549: <= {"jsonrpc": "2.0", "result": 0.0001, "id": 4}
DEBUG:2020-09-22 23:13:47,550: => {"jsonrpc": "2.0", "method": "blockchain.estimatefee", "id": 5, "params": [2]}
DEBUG:2020-09-22 23:13:47,591: <= {"jsonrpc": "2.0", "result": 0.0001, "id": 5}
DEBUG:2020-09-22 23:13:47,593: Electrum wallet disconnected
DEBUG:2020-09-22 23:13:57,601: Electrum connected from 127.0.0.1
DEBUG:2020-09-22 23:13:57,602: => {"jsonrpc": "2.0", "method": "server.version", "id": 0, "params": ["electrum/4.0.3", "1.4"]}
DEBUG:2020-09-22 23:13:57,603: <= {"jsonrpc": "2.0", "result": ["ElectrumPersonalServer 0.2.1.1", "1.4"], "id": 0}
DEBUG:2020-09-22 23:13:57,605: => {"jsonrpc": "2.0", "method": "blockchain.headers.subscribe", "id": 1}
DEBUG:2020-09-22 23:13:57,606: are_headers_raw = True
DEBUG:2020-09-22 23:13:57,652: <= {"jsonrpc": "2.0", "result": {"hex": "040000004c373db84ed0d8a0a953c397fb0ca810142272780b9b9500000000000000000088a9d1dfb611a427c1998bc9273e2cfd519db472a53dd9c3c13624c61bfc344eca05c65614a10718aacf26c4", "height": 399054}, "id": 1}
DEBUG:2020-09-22 23:13:57,654: => {"jsonrpc": "2.0", "method": "blockchain.estimatefee", "id": 2, "params": [25]}
DEBUG:2020-09-22 23:13:57,666: <= {"jsonrpc": "2.0", "result": 0.0001, "id": 2}
DEBUG:2020-09-22 23:13:57,667: => {"jsonrpc": "2.0", "method": "blockchain.estimatefee", "id": 3, "params": [10]}
DEBUG:2020-09-22 23:13:57,714: <= {"jsonrpc": "2.0", "result": 0.0001, "id": 3}
DEBUG:2020-09-22 23:13:57,714: => {"jsonrpc": "2.0", "method": "blockchain.estimatefee", "id": 4, "params": [5]}
DEBUG:2020-09-22 23:13:57,757: <= {"jsonrpc": "2.0", "result": 0.0001, "id": 4}
DEBUG:2020-09-22 23:13:57,757: => {"jsonrpc": "2.0", "method": "blockchain.estimatefee", "id": 5, "params": [2]}
DEBUG:2020-09-22 23:13:57,800: <= {"jsonrpc": "2.0", "result": 0.0001, "id": 5}
DEBUG:2020-09-22 23:13:57,801: Electrum wallet disconnected
DEBUG:2020-09-22 23:14:07,802: Electrum connected from 127.0.0.1
DEBUG:2020-09-22 23:14:07,804: => {"jsonrpc": "2.0", "method": "server.version", "id": 0, "params": ["electrum/4.0.3", "1.4"]}
DEBUG:2020-09-22 23:14:07,805: <= {"jsonrpc": "2.0", "result": ["ElectrumPersonalServer 0.2.1.1", "1.4"], "id": 0}
DEBUG:2020-09-22 23:14:07,807: => {"jsonrpc": "2.0", "method": "blockchain.headers.subscribe", "id": 1}
DEBUG:2020-09-22 23:14:07,808: are_headers_raw = True
DEBUG:2020-09-22 23:14:08,003: <= {"jsonrpc": "2.0", "result": {"hex": "04000000804fb47ac09719c8b375a04a9e34b547990b998e6de3f40000000000000000000db127a4ed9324eaca318df941a88dc21caf46dc6cd6994dc46f5034c79fd5882d5cc65614a10718b8fbd1c9", "height": 399088}, "id": 1}
DEBUG:2020-09-22 23:14:08,004: => {"jsonrpc": "2.0", "method": "blockchain.estimatefee", "id": 2, "params": [25]}
DEBUG:2020-09-22 23:14:08,008: <= {"jsonrpc": "2.0", "result": 0.0001, "id": 2}
DEBUG:2020-09-22 23:14:08,009: => {"jsonrpc": "2.0", "method": "blockchain.estimatefee", "id": 3, "params": [10]}
DEBUG:2020-09-22 23:14:08,012: <= {"jsonrpc": "2.0", "result": 0.0001, "id": 3}
DEBUG:2020-09-22 23:14:08,013: => {"jsonrpc": "2.0", "method": "blockchain.estimatefee", "id": 4, "params": [5]}
DEBUG:2020-09-22 23:14:08,018: <= {"jsonrpc": "2.0", "result": 0.0001, "id": 4}
DEBUG:2020-09-22 23:14:08,019: => {"jsonrpc": "2.0", "method": "blockchain.estimatefee", "id": 5, "params": [2]}
DEBUG:2020-09-22 23:14:08,022: <= {"jsonrpc": "2.0", "result": 0.0001, "id": 5}
DEBUG:2020-09-22 23:14:08,023: Electrum wallet disconnected

It looks as if Electrum cannot connect persistently to EPS (but I may be mistaken?)

For context, here's the '[bitcoin-rpc]' part of my EPS config.cfg:

[bitcoin-rpc]
host = 127.0.0.1
port = 8332
rpc_user = REDACTED
rpc_password = REDACTED
wallet_filename = 
poll_interval_listening = 30
poll_interval_connected = 1
initial_import_count = 1000
gap_limit = 25

And here's my bitcoin.conf:

listen=1
onion=10.137.0.13:9111
onlynet=onion
proxy=10.137.0.13:9111
txindex=1
server=1

# Electrum Personal Server Auth
rpcauth=REDACTED
# Electrum Personal Server Wallet
wallet=electrum-personal-server

And here's my Electrum config:

{
    "auto_connect": false,
    "blockchain_preferred_block": {
        "hash": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
        "height": 0
    },
    "check_updates": false,
    "config_version": 3,
    "decimal_point": 8,
    "gui_last_wallet": REDACTED,
    "is_maximized": false,
    "oneserver": true,
    "qt_gui_color_theme": "dark",
    "recently_open": REDACTED,
    "rpcpassword": REDACTED,
    "rpcuser": "user",
    "server": "127.0.0.1:50002:s"
}

Can anyone help me with this? Thanks in advance!

s7n4qg3 commented 4 years ago

Looking at the EPS debug.log, it looks as if EPS is not successfully connecting to bitcoind - every 30 seconds, it's creating a new rpc connection, as can be seen below:

user@host:~$ sudo tail -f /home/electrum-personal-server/.eps/debug.log
DEBUG:2020-09-22 23:43:51,102: Process ID (PID) = 797
DEBUG:2020-09-22 23:43:51,102: obtaining auth from rpc_user/pass
DEBUG:2020-09-22 23:43:51,395: Checking whether rescan is in progress
INFO:2020-09-22 23:43:51,651: Displaying first 3 addresses of each master public key:
INFO:2020-09-22 23:43:51,713: 
REDACTED =>
    REDACTED
    REDACTED
    REDACTED
INFO:2020-09-22 23:43:51,731: Obtaining bitcoin addresses to monitor . . .
INFO:2020-09-22 23:41:53,448: Obtained list of addresses to monitor in -118.00461316108704sec
INFO:2020-09-22 23:41:53,450: Building history with 2000 addresses . . .
DEBUG:2020-09-22 23:41:53,511: listtransactions skip=0 len(ret)=0
DEBUG:2020-09-22 23:41:53,521: unconfirmed_txes = defaultdict(<class 'list'>, {})
DEBUG:2020-09-22 23:41:53,523: reorganizable_txes = []
DEBUG:2020-09-22 23:41:53,524: last_known_wallet_txid = None
INFO:2020-09-22 23:41:53,525: Found 0 txes. History built in 0.07369017601013184sec
DEBUG:2020-09-22 23:41:53,526: Starting electrum server
DEBUG:2020-09-22 23:41:53,530: using cert: /home/electrum-personal-server/.eps/certs/server.crt, key: /home/electrum-personal-server/.eps/certs/server.key
INFO:2020-09-22 23:41:53,531: Listening for Electrum Wallet on ('0.0.0.0', 50002)

If this project is valuable to you please consider donating:
    bc1qwt8kh83dpdj4yuquvsf28rhcft2rjh6jvy6678
DEBUG:2020-09-22 23:42:24,043: Creating new jsonrpc HTTPConnection
DEBUG:2020-09-22 23:42:54,816: Creating new jsonrpc HTTPConnection
DEBUG:2020-09-22 23:43:25,552: Creating new jsonrpc HTTPConnection
DEBUG:2020-09-22 23:43:56,283: Creating new jsonrpc HTTPConnection
DEBUG:2020-09-22 23:44:26,951: Creating new jsonrpc HTTPConnection
DEBUG:2020-09-22 23:44:57,918: Creating new jsonrpc HTTPConnection
DEBUG:2020-09-22 23:45:28,841: Creating new jsonrpc HTTPConnection
qubenix commented 4 years ago

I don't typically use EPS, but in order to check on this for you I updated my testnet EPS, bitcoind, and Electrum. My testnet VMs are not having any of the connectivity issues that you're experiencing. The only things I can think of are:

s7n4qg3 commented 4 years ago

Thanks @qubenix. I've updated my poll_interval_connected setting but that hasn't made a difference. I'm using the same versions as you but I'm using Electrum 4.0.3. I might delete my VMs and start over from scratch, just in case I've missed anything.

I've never used ElectrumX or Electrs. If I can't get EPS to work in a new VM, I might try the latter to see if I have more luck with that.

s7n4qg3 commented 4 years ago

After deleting my VMs and starting over, I'm having exactly the same problem as before. I've submitted a pull request with minor amendments to the guides that I used - perhaps there will be some clues there to inform what's going wrong.