Tor can actually make things more risky. Some of the guides for using Tor with Electrum set it up in such a way that you are only connecting to a single server in order to maximize privacy. This obviously means you are downloading the block headers and all your wallet information from only a single source, which increases the risks of being fed incorrect or malicious information.
Do keep in mind this holds true if the one Tor server you're connecting to is not yours.
When I connect to my own Electrum node through Tor, I do connect to a single Electrum server, but there is no risk of getting malicious information.
As for the yet unanswered question about
electrs default logfile location;
electrs doesn't create a logfile by default. It uses Rust's built-in
env_logger, which supports log levels from 'ERROR' (very serious errors) to 'TRACE' (extremely verbose) - all the log levels are declared in Rust's
enum.Level.
There's also a
table in electrs' GitHub with pretty much the same information.
By default, env_logger writes everything to
stderr. But keep in mind it's a trivial task piping stderr to a file.
In my little experiment with log level DEBUG, I could not see the IP or Tor address I was connecting from and in the code it doesn't seem that it's logged, either. But it's simple to add, as others mentioned.
I do see the queried addresses, though.
If you run
electrs with log_filter = DEBUG and grep stderr for
DEBUG electrs::server] 0:, you will get the communication between your SPV wallet and your Electrum server.
bitcoin@localhost:~/electrs> /home/bitcoin/electrs/target/release/electrs 2> >(grep 'DEBUG electrs::server] 0:')
[~snip~ DEBUG electrs::server] 0: connected
[~snip~ DEBUG electrs::server] 0: recv {"jsonrpc":"2.0","method":"server.version","params":["Sparrow","1.4"],"id":1}
[~snip~ DEBUG electrs::server] 0: send {"id":1,"jsonrpc":"2.0","result":["electrs/0.9.8","1.4"]}
[~snip~ DEBUG electrs::server] 0: recv {"jsonrpc":"2.0","method":"blockchain.headers.subscribe","params":[],"id":2}
[~snip~ DEBUG electrs::server] 0: send {"id":2,"jsonrpc":"2.0","result":{"height":747717,"hex":"00c00020c072fd1a50fe409f82942c9dfc46565761c38522589103000000000000000000d8c783dcd4e3eb05372ae116978d9fbd2d4fd1d29f3a3c6dfa4f841bb739ac623faee962042a0a17ae7fbf9d"}}
[~snip~ DEBUG electrs::server] 0: recv {"jsonrpc":"2.0","method":"server.banner","params":[],"id":3}
[~snip~ DEBUG electrs::server] 0: send {"id":3,"jsonrpc":"2.0","result":"Welcome to electrs 0.9.8 (Electrum Rust Server)!"}
[~snip~ DEBUG electrs::server] 0: recv [{"jsonrpc":"2.0","method":"blockchain.estimatefee","params":[1],"id":4},{"jsonrpc":"2.0","method":"blockchain.estimatefee","params":[2],"id":5},{"jsonrpc":"2.0","method":"blockchain.estimatefee","params":[3],"id":6},{"jsonrpc":"2.0","method":"blockchain.estimatefee","params":[4],"id":7},{"jsonrpc":"2.0","method":"blockchain.estimatefee","params":[5],"id":8},{"jsonrpc":"2.0","method":"blockchain.estimatefee","params":[10],"id":9},{"jsonrpc":"2.0","method":"blockchain.estimatefee","params":[25],"id":10},{"jsonrpc":"2.0","method":"blockchain.estimatefee","params":[50],"id":11}]
[~snip~ DEBUG electrs::server] 0: send [{"id":4,"jsonrpc":"2.0","result":0.00013},{"id":5,"jsonrpc":"2.0","result":0.00013},{"id":6,"jsonrpc":"2.0","result":0.00013},{"id":7,"jsonrpc":"2.0","result":0.00011838},{"id":8,"jsonrpc":"2.0","result":0.00010052},{"id":9,"jsonrpc":"2.0","result":0.00005394},{"id":10,"jsonrpc":"2.0","result":0.00001},{"id":11,"jsonrpc":"2.0","result":0.00001}]
[~snip~ DEBUG electrs::server] 0: recv {"jsonrpc":"2.0","method":"mempool.get_fee_histogram","params":[],"id":12}
[~snip~ DEBUG electrs::server] 0: send {"id":12,"jsonrpc":"2.0","result":[[1023,560],[511,1662],[255,12801],[127,12906],[63,59896],[31,195453],[15,1397569],[7,756035],[3,430544],[1,314814],[0,0]]}
[~snip~ DEBUG electrs::server] 0: recv {"jsonrpc":"2.0","method":"blockchain.relayfee","params":[],"id":13}
[~snip~ DEBUG electrs::server] 0: send {"id":13,"jsonrpc":"2.0","result":0.00001}
[~snip~ DEBUG electrs::server] 0: recv {"jsonrpc":"2.0","method":"server.ping","params":[],"id":14}
[~snip~ DEBUG electrs::server] 0: send {"id":14,"jsonrpc":"2.0","result":null}
[~snip~ DEBUG electrs::server] 0: recv [{"jsonrpc":"2.0","method":"blockchain.scripthash.subscribe","params":[~scripthash~],"id":16},{"jsonrpc":"2.0","method":"blockchain.scripthash.subscribe","params":[~scripthash~],"id":17}, ...]
[~snip~ DEBUG electrs::server] 0: send [{"id":16,"jsonrpc":"2.0","result":"~snip~"},{"id":17,"jsonrpc":"2.0","result":"~snip~"}, ...]
...
I obviously had to redact a lot; but in essence, the client (in this case, Sparrow - I noticed our esteemed forum member achow101 is
mentioned as contributor!) queries the
blockchain.scripthash.subscribe Electrum protocol method (
a list of all these methods).
In this case,
blockchain.scripthash refers to a 'hash of the binary bytes of the locking script, expressed as a hexadecimal string'
[quote: https://electrumx.readthedocs.io/en/latest/protocol-basics.html#script-hashes].
So basically wherever I wrote ~scripthash~, there are script hashes, a different representation of the addresses of whoever's querying. Especially since they're bunched together in a small number of individual requests, we can say that
electrs does link transactions together in its default logs.