Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: NeuroticFish on October 24, 2021, 10:00:41 AM



Title: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: NeuroticFish on October 24, 2021, 10:00:41 AM
This may be useful to others too, since I've spent quite a lot of time figuring out how to have everything working on a machine that runs a lot, but it's on Windows.

This walkthough is meant to show how to install an Electrum server (electrs) and a block explorer (BTC RPC Explorer) on (more or less) Windows. It's "more or less" because I actually use WSL (windows subsystem for linux) to get a Debian run under Windows.

If you have only one wallet and you don't want your block explorer, Electrum Personal Server may be enough for you. Start reading the other thread from here (https://bitcointalk.org/index.php?topic=5362554.msg58047028#msg58047028), I have 2 posts on that topic.

Electrs is not restricted to one wallet and also has useful data for the block explorer, hence this more generic setup was what I was looking for.

I will post all the details I remember and I will post also my config files too. Improvements are welcome, since I'm not really a Linux guy and, as said, most of this setup is still under Linux.

Bitcoin

Bitcoin is easy to install under Windows, it just runs, make sure your data directory is set somewhere with plenty of space, I use an external drive (X:\BitcoinDataDir)
I've created in X:\BitcoinDataDir a file bitcoin.conf with the following content:
Code: (bitcoin.conf)
txindex=1
server=1
rpcbind=127.0.0.1
rpcallow=127.0.0.1
rpccookiefile=.mycookie

Some extras:
1. If you want to not be too generous with the network, you may be tempted to use maxconnections in your config. Although I've read you should put minimum value 12, it's not enough. When I've tried that the block explorer may not be able to connect. With a value like 25 it was OK.
2. Make sure that if you use maxuploadtarget in your config, you also add whitelist=download@127.0.0.1

Of course, you can just keep it simple and don't add those extras.

I've also made 2 batch files because I'm lazy. Both are in the same folder ad bitcoind.exe and I've made for both shortcuts onto desktop.

Code: (start_bitcoin.bat )
bitcoind -datadir=X:\BitcoinDataDir

Code: (stop_bitcoin.bat)
bitcoin-cli.exe -datadir=X:\BitcoinDataDir stop

As a note, keep in mind that bitcoind will "discuss" with electrs and the block explorer only after the console shows progress=1.000000
And yes, you should leave at least bitcoind run as much as possible.


LE: If you prefer to use all this with RPC user/password instead of RPC cookie file, the configs are adapted in this later post (https://bitcointalk.org/index.php?topic=5367296.msg61517989#msg61517989).


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: NeuroticFish on October 24, 2021, 10:35:12 AM
WSL on Windows, Debian

Under windows (10), go to Start menu and type Turn Windows features on or off
Near the end of the list there's Windows Subsystem for Linux. Set that checked, OK, let it install/restart and so on.

When that's done, Start menu and type Run, and in the run box type https://aka.ms/wslstore <enter>
There install Debian (I had troubles with Ubuntu, so Debian it is).
Keep in mind that Debian and what's on it will take some 4.5 GB on the Windows drive. [Edit 2022-02-17: if the size on windows partition is a problem like it was for me, here's the solution (https://bitcointalk.org/index.php?topic=5367296.msg59280489#msg59280489).]

Start Debian, create an user and password for yourself and we can continue the real deal.

If you have an aggressive antivirus like myself (e.g. Comodo), it may be a good idea to disable the auto containment component. And don't forget to re-renable it after all the install is done.
I didn't do this at start and I've lost a lot of time because this or that was blocked from running under WSL.

It worth mentioning (thank you HCP, you have spared me a lot of time (https://bitcointalk.org/index.php?topic=5362554.msg58177335#msg58177335)) that for each Windows drive, under Debian you'll have /mnt/<drive letter>/your path on that drive

Update the OS:

Code:
sudo apt update
sudo apt dist-upgrade


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: NeuroticFish on October 24, 2021, 10:35:36 AM
Electrs (from https://github.com/romanz/electrs)

The steps are based on the official install page (https://github.com/romanz/electrs/blob/master/doc/install.md) and my struggle.
Some of the tools (curl, git) were missing and I had to install them myself.

I had to do all the following commands, one by one:

Code:
sudo apt install curl
sudo curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env

sudo apt install cargo

sudo apt update
sudo apt install clang cmake build-essential

sudo apt install librocksdb-dev=6.11.4-3

sudo apt install git
git clone https://github.com/romanz/electrs
cd electrs
ROCKSDB_INCLUDE_DIR=/usr/include ROCKSDB_LIB_DIR=/usr/lib cargo build --locked --release

[later note: if sudo apt install librocksdb-dev=6.11.4-3 fails on Debian you can try sudo apt install librocksdb-dev=6.11.4*]
[later note: if sudo apt install librocksdb-dev=6.11.4-3 still fails (probably on Ubuntu), read this post (https://bitcointalk.org/index.php?topic=5367296.msg58288344#msg58288344) for workaround]

I've edited under Windows (as e:\electrs.toml, keep this path in mind, you'll have to copy it to Linux) the config file; it was based on the config from the official example (https://github.com/romanz/electrs/blob/master/doc/config_example.toml) and mine looks like this (I also kept only the useful lines)

Code: (electrs.toml)
cookie_file = "/mnt/x/BitcoinDataDir/.mycookie"
daemon_dir = "/mnt/x/BitcoinDataDir"
daemon_rpc_addr = "127.0.0.1:8332"
daemon_p2p_addr = "127.0.0.1:8333"
db_dir = "/mnt/y/ElectrsData"
network = "bitcoin"
electrum_rpc_addr = "127.0.0.1:50001"
#verbose = 2 -> obsolete, was working with version 0.9.0, no longer works in 0.9.3
#use log-filters for version 0.9.3+
log_filters = "INFO"
server_banner = "Electrs @ NeuroticFish, yay!"

[Edit: version 0.9.3 doesn't like verbose in the config, using log-filters instead.]

This means that the Electrs data (up to 70 GB, according to some docs, but right now that folder on my computer is only 30 GB) will be on drive Y:, as Y:\ElectrsData
Under Debian, please create that folder:
Code:
mkdir /mnt/y/ElectrsData

Go into the correct folder and copy the config (you've saved it, right?). And don't forget the ending space and point
Code:
cd target/release
cp /mnt/e/electrs.toml .

Start electrs and let it sync, it'll take some hours in the first run.

Code:
./electrs

At a later point it will show the sweet:

Code:
[2021-10-16T13:31:39.392Z INFO  electrs::server] serving Electrum RPC on 127.0.0.1:50001


Edit 2022-04-17: If, at a later point, you might want to update Electrs, you can take a look here: https://bitcointalk.org/index.php?topic=5367296.msg59888827#msg59888827


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: NeuroticFish on October 24, 2021, 10:51:34 AM
BTC RPC Explorer (from https://github.com/janoside/btc-rpc-explorer)

I expect this to be installed after Electrs is completely synced, and it's running.
Open a new Debian (R-Click on the Debian rectangle on the task bar and select Debian) and let's go.
Again some Linux commands to be ran:

Code:
sudo su
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
apt-get install -y nodejs
exit
git clone https://github.com/janoside/btc-rpc-explorer
cd btc-rpc-explorer
npm install

Now I've made, again under Windows, and again on my E: drive a file called .env with the content based on the official sample (https://github.com/janoside/btc-rpc-explorer/blob/master/.env-sample):

Code: (.env)
BTCEXP_BASEURL=/exp/
BTCEXP_BITCOIND_HOST=127.0.0.1
BTCEXP_BITCOIND_PORT=8332
BTCEXP_BITCOIND_COOKIE=/mnt/X/BitcoinDataDir/.mycookie
BTCEXP_BITCOIND_RPC_TIMEOUT=5000
BTCEXP_ADDRESS_API=electrum
BTCEXP_ELECTRUM_SERVERS=tcp://127.0.0.1:50001
BTCEXP_ELECTRUM_TXINDEX=true
BTCEXP_SLOW_DEVICE_MODE=false
BTCEXP_PRIVACY_MODE=true
BTCEXP_NO_RATES=true

Now copy .env into the Linux folder and start

Code:
cp /mnt/e/.env .
npm start

Edit 2022-04-17: If, at a later point, you might want to update BTC RPC Explorer, you can take a look here: https://bitcointalk.org/index.php?topic=5367296.msg59888845#msg59888845


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: NeuroticFish on October 24, 2021, 11:11:05 AM
Fine tuning and other info.

Electrum

From this moment onwards, you'll be able to use Electrum with your own server.
Although I use Electrum on the same computer, I use the portable one (yeah, I'm lazy)
I've made a batch file which I run from now on instead of Electrum's exe and it looks like this:

Code: (run-electrum.bat)
electrum-4.1.5-portable.exe --oneserver --server 127.0.0.1:50001:t

Linux batch files and others

Open a new Debian console. This time we will create 2 batch files under Linux, because we are lazy. Just now we will make them directly under Linux:

Code:
nano $HOME/run_electrs.sh

And inside nano editor:

Code: (run_electrs.sh)
cd $HOME/electrs/target/release
./electrs

CTRL-X and Save

again

Code:
nano $HOME/run_explorer.sh
Code: (run_explorer.sh)
cd $HOME/btc-rpc-explorer
npm start

CTRL-X and Save

two more lines to execute:
Code:
chmod +x $HOME/run_electrs.sh
chmod +x $HOME/run_explorer.sh

Now, when you want to exit Electrs or BTC RPC Explorer, you press CTRL+C in those consoles, then exit.
When you want to run them, you start ./run_electrs.sh in one console then ./run_explorer.exe in another

Web page for block explorer

http://localhost:3002/exp/


Thank you

  • HCP for setting me on the right track
  • ETFbitcoin for hinting the correct block explorer
  • DaveF and NotATether for making me understand VirtualBox is not such a great idea
  • DireWolfM14 for trying to help me with auto-starting services, although I still don't know how to do that  :D
  • everybody active in the Dev & Tech from whom I've learned a lot
  • and obviously the teams implementing all the great software I've installed and using now



It may be better to have a way to start everything from one click but I don't know how.
I've noticed that if I started bitcoind and immediately electrs, the second has failed, so now I just check when bitcoid is synced and then start electrs, I wait for electrs show it's ready and then start blockchain explorer and/or electrum. It's not optimal, but it's OK for my needs and... this is how much I've manged to do.


Edit 1: corrected/improved wording
Edit 2: corrected the .sh files per ETFbitcoin suggestion (https://bitcointalk.org/index.php?topic=5367296.msg58264119#msg58264119) and ensured their paths too.


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: DaveF on October 24, 2021, 03:14:22 PM
Side note.
Disable automatic updates on Windows, and install the Windows updates manually.
When done then shutdown Debian
Reboot Windows and bring up Debian.

In theory, Windows should cleanly save the linux subsystem to disk, and then reboot.
In reality, at times something locks and it's not done cleanly. And bad things can happen....

-Dave


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: MixMAx123 on October 24, 2021, 04:39:16 PM
Great instructions! This is something that many people can use well, thank you for your effort!
I will try it with your instructions, sobal my system runs correctly again.


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: DireWolfM14 on October 25, 2021, 03:04:06 AM
Good job, I hope you had fun.  You're on the right path, and you'll pick up tricks that work for you as you go along.  WSL is a great way for Windows users to immerse themselves in Linux.

I prefer to run my node on dedicated hardware which I can leave running full time.  All my services are started on boot by systemd, so I just need to make sure the machine is powered on.  Unlike Linux on a physical or virtual machine, WSL doesn't have a system startup daemon like systemd.  It shouldn't be confused with a virtual machine, it's a virtual environment.

It's bugging me that you are unable to install Ubuntu.  I noticed that you used the Control Panel gui app to enable WSL, did also enable virtualization?  I've always installed WSL manually, you can find the installation instructions here (don't forget to start powershell as administrator):  https://docs.microsoft.com/en-us/windows/wsl/install-manual

Also, you can use powershell to interact with your WSL instances and, run them with alternate options.  For starters:

Code:
wsl --help


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: NeuroticFish on October 25, 2021, 07:07:42 AM
In theory, Windows should cleanly save the linux subsystem to disk, and then reboot.
In reality, at times something locks and it's not done cleanly. And bad things can happen....

Thanks for the heads up. I try to always exit the consoles as gracefully as I can (CTRL-C then exit) before leaving windows do shutdown or restart. I hope that I'm on the safe side.

Good job, I hope you had fun.  You're on the right path, and you'll pick up tricks that work for you as you go along.  WSL is a great way for Windows users to immerse themselves in Linux.

Thank you for the kind words.

I prefer to run my node on dedicated hardware which I can leave running full time.  All my services are started on boot by systemd, so I just need to make sure the machine is powered on.  Unlike Linux on a physical or virtual machine, WSL doesn't have a system startup daemon like systemd.  It shouldn't be confused with a virtual machine, it's a virtual environment.

I may get there too, but for now I cannot: even the oldest working laptop in the house is being used by the kids for online classes and when I bought a RasPi for my needs I was not smart enough and bought a weak one (Zero W), from what I've read it's too weak for this job.
Maybe I'll get to buy in the near future a RasPi 4 and a 1-2 TB HDD (I find SSD overpriced for the job at this size), maybe I open a new topic on that, since Black Friday is pretty close.

It's bugging me that you are unable to install Ubuntu.

I was able to install Ubuntu. I had other problems there:
  • it didn't find for me librocksdb-dev=6.11.4-3
  • it failed in creating files/folders onto my Windows partition for electrs data

Of course, it was my first install and the problems may have been caused by something I didn't do right or I didn't do at all. Or my antivirus blocking something I forgot to unblock.
Maybe I was just luckier with Debian. However, this worked, I've noted down this and that (for the case I have to do "backtracking" until I get it right) and.. this is what I have.
If people want to try it out on any other distro, be my guest, really  :D

I noticed that you used the Control Panel gui app to enable WSL, did also enable virtualization?

If you mean Hyper-V, no, it's not enabled and I don't intend to unless I really have to.
I've understood that it may interfere badly with VBox, which I still need now and then for my own tests (for simulating a fresh Windows or for running suspect apps) and my CPU is i7 so it has some in-built features, I think.

I've always installed WSL manually, you can find the installation instructions here (don't forget to start powershell as administrator):  https://docs.microsoft.com/en-us/windows/wsl/install-manual

Also, you can use powershell to interact with your WSL instances and, run them with alternate options.  For starters:
Code:
wsl --help

Although I work on Windows since Windows 95 (even 3.1, but that was for too short time), I have little experience with Power Shell. I find it too... Linux like and I didn't really need it; most of the time the normal command prompt or apps done by myself could do all I've needed.

Great instructions! This is something that many people can use well, thank you for your effort!
I will try it with your instructions, sobal my system runs correctly again.

Thank you! Please let me know if I've missed or didn't explain good enough something.


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: ABCbits on October 25, 2021, 11:08:51 AM
And inside nano editor:
Code:
cd ./electrs/target/release
./electrs

CTRL-X and Save

This script will fail if you run it from different location (location when you run nano to create the script). You should replace it with absolute path.


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: NeuroticFish on October 25, 2021, 12:56:49 PM
This script will fail if you run it from different location (location when you run nano to create the script). You should replace it with absolute path.

In my defense :), if it's done as I expect, the .sh files are created in user home folder, the same folder the user gets in when he starts the Linux console, so he should not need to run that from somewhere else.
Also I tried to avoid having path containing the user name, but I've learned meanwhile about $HOME.

But you're right, users may do things in a way I don't expect  :D
Fixed it. Thank you.


...And if I started this, I've also ensured the paths for the .sh files are exactly where I expect them to be. So double thanks  ;)


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: MixMAx123 on October 25, 2021, 04:59:12 PM
As threatened, I try to imitate this now.
At this point, the first problems occur:
Code:
sudo apt install cargo
error: "Problems can not be corrected, they have retained defective packages "
https://de.share-your-photo.com/img/d80a1b2e3a.png

annotation
I'm trying this on Ubuntu 18.04.3 LTS.
I reinstalled Ubuntu yesterday. BitcoinCore now runs properly. No further software is installed.
I am an absolute Linux failure.
Things that you think for yourself, I have probably done wrong.
So put the worst case in advance.

Yesterday I also made a backup from the system. Every time something is defective, I simply set up the backup again.
And believe me, that happens very often!
So because of the security, I do not worry, I repeat and test as long as it goes.

Another note:
I do not know if that's normal, but if I want to install something with "sudo apt install xxx", this almost always fails with various errors.


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: NeuroticFish on October 26, 2021, 07:52:47 AM
I'm trying this on Ubuntu 18.04.3 LTS.

Do you have something older than Win 10? I'm asking because I see on the Windows store Ubuntu 20.04 LTS...
However, I'm not surprised, I had my own share of surprises with Ubuntu.

Unfortunately I am also far from good at Linux; this tutorial was made simply because I didn't find any reasonably good/complete one.
For your problems I have only one possible advice, if you didn't do this at start. Update your binaries:

Code:
sudo apt update
sudo apt dist-upgrade

Also, I'm a bit surprised. If you are not great at Linux, why didn't you try with Debian as I did?

Another note:
I do not know if that's normal, but if I want to install something with "sudo apt install xxx", this almost always fails with various errors.

I don't find it normal. But the environment variables may be different between your user and the super user (I hope that I didn't say something silly) and that could be one reason.
I'm not sure that it will help, but you can try to do sudo su, do the things without sudo in front and when you're done do exit.


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: MixMAx123 on October 26, 2021, 07:57:03 PM
Also, I'm a bit surprised. If you are not great at Linux, why didn't you try with Debian as I did?

Well, it's easy, I decided on Ubuntu at that time because people said it was the best for me.
Now I have used it for a few years and you need good arguments or a weapon to bring me to learn again a new system.
I have now found and resolve many mistakes. You are right, it lay on the outdated packet. Two days I only searched for this error.
NodeJS and BTC Explorer work now.
I'll continue and now try to install electrumX or an elevated tool that creates a database for the bitcoin-addresses.
I believe I have to install Python3. At this point I had the last time my ubuntu destroyed. So now I'm here where I was the last time. :-(
When I'm done and everything works well, I will post a detailed description here as it is to set up on Ubuntu.


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: MixMAx123 on October 27, 2021, 11:38:24 PM
So I came far now, but at this point I get a mistake:
Code:
sudo apt install librocksdb-dev=6.11.4-3
I did it that way:
Code:
sudo apt install librocksdb-dev
This has been installed version (5.8.8-1).
I tried "sudo apt update" but it did not work.
I can not update this version.
I tried to continue with this version.
But fatal mistakes are the result, it can not be right.
Can you help me again how I can install the version "librocksdb-dev=6.11.4-3"?
Thanks very much! :-)


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: NeuroticFish on October 28, 2021, 09:48:00 AM
Can you help me again how I can install the version "librocksdb-dev=6.11.4-3"?

I also couldn't install that library on Ubuntu in my tests. You can see me complaining here (https://bitcointalk.org/index.php?topic=5362554.msg58194737#msg58194737), it was the "smaller" problem I had.
The good news is that you can go without that lib, just then instead of dynamic linking (see the lines in my initial post)

Code:
$ ROCKSDB_INCLUDE_DIR=/usr/include ROCKSDB_LIB_DIR=/usr/lib cargo build --locked --release

you have to go with static linking

Code:
cargo build --locked --release

and you get error here too, you may have to set

Code:
$ RUSTFLAGS="-C link-args=-latomic" cargo build --locked --release

and retry with

Code:
cargo build --locked --release

Source/details: https://github.com/romanz/electrs/blob/master/doc/install.md#static-linking


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: MixMAx123 on October 29, 2021, 04:34:30 PM
Thanks @NeuroticFish
I have done it now and it runs.
As announced I created a guide for Ubuntu:
https://bitcointalk.org/index.php?topic=5368219.0


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: NeuroticFish on February 17, 2022, 02:46:56 PM
I was told how to handle the 4.5GB Debian takes on windows drive, I will add also here the relevant information in order to Move after Install that Debian anywhere else you want.

Check this answer https://stackoverflow.com/a/64219885 (https://stackoverflow.com/a/64219885). But 4.5GB is rather small compared with Windows itself and some popular application on Windows (such as Ms Office), so i wouldn't bother move it.

I've installed that app with chocolatey, ran the command line, got some warnings, but went through. Now that Debian is successfully moved to HDD, I don't even mind if it's slower.

More detailed:

1. Installed Chocolatey to my Windows

1.1. Ran PowerShell as administrator and pasted there

1.2 Ran this command in that PowerShell (source: https://chocolatey.org/install ; make sure you use the latest instructions/command line from there)

Code:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

2. Installed LxRunOffline (https://github.com/DDoSolitary/LxRunOffline) with chocolatey

In PowerShell started as administrator ran the command:

Code:
choco install lxrunoffline

3. Opened a completely new command prompt (cmd) as admin and there:

Code:
lxrunoffline move -n Debian -d x:\the\new\folder\

And waited for some time. Got some warnings, but went through. (Thanks again ETFbitcoin)


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: NeuroticFish on February 18, 2022, 09:37:02 AM
Glad it works. But what kind of warnings you received? Reduced performance? Might broken when windows release update for WSL/WSL2?

Code:
[WARNING] Ignoring an unsupported file "\\?\C:\Users\<my_user_name>\AppData\Local\Packages\TheDebianProject.DebianGNULinux_<something>\LocalState\rootfs\dev\full" of type 0020000.
[WARNING] Ignoring an unsupported file "\\?\C:\Users\<my_user_name>\AppData\Local\Packages\TheDebianProject.DebianGNULinux_<something>\LocalState\rootfs\dev\null" of type 0020000.
[WARNING] Ignoring an unsupported file "\\?\C:\Users\<my_user_name>\AppData\Local\Packages\TheDebianProject.DebianGNULinux_<something>\LocalState\rootfs\dev\ptmx" of type 0020000.
[WARNING] Ignoring an unsupported file "\\?\C:\Users\<my_user_name>\AppData\Local\Packages\TheDebianProject.DebianGNULinux_<something>\LocalState\rootfs\dev\random" of type 0020000.
[WARNING] Ignoring an unsupported file "\\?\C:\Users\<my_user_name>\AppData\Local\Packages\TheDebianProject.DebianGNULinux_<something>\LocalState\rootfs\dev\tty" of type 0020000.
[WARNING] Ignoring an unsupported file "\\?\C:\Users\<my_user_name>\AppData\Local\Packages\TheDebianProject.DebianGNULinux_<something>\LocalState\rootfs\dev\urandom" of type 0020000.
[WARNING] Ignoring an unsupported file "\\?\C:\Users\<my_user_name>\AppData\Local\Packages\TheDebianProject.DebianGNULinux_<something>\LocalState\rootfs\dev\zero" of type 0020000.

These are my warnings. I've hide replaced 2 parts, for privacy/security.

* Yesterday after the move I've checked that Debian, the Electrum server and the block explorer, all were working fine.
* I've had yesterday evening a Windows update and worked (I don't know what it contained though).


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: ABCbits on February 18, 2022, 11:15:53 AM
Glad it works. But what kind of warnings you received? Reduced performance? Might broken when windows release update for WSL/WSL2?

Code:
[WARNING] Ignoring an unsupported file "\\?\C:\Users\<my_user_name>\AppData\Local\Packages\TheDebianProject.DebianGNULinux_<something>\LocalState\rootfs\dev\full" of type 0020000.
[WARNING] Ignoring an unsupported file "\\?\C:\Users\<my_user_name>\AppData\Local\Packages\TheDebianProject.DebianGNULinux_<something>\LocalState\rootfs\dev\null" of type 0020000.
[WARNING] Ignoring an unsupported file "\\?\C:\Users\<my_user_name>\AppData\Local\Packages\TheDebianProject.DebianGNULinux_<something>\LocalState\rootfs\dev\ptmx" of type 0020000.
[WARNING] Ignoring an unsupported file "\\?\C:\Users\<my_user_name>\AppData\Local\Packages\TheDebianProject.DebianGNULinux_<something>\LocalState\rootfs\dev\random" of type 0020000.
[WARNING] Ignoring an unsupported file "\\?\C:\Users\<my_user_name>\AppData\Local\Packages\TheDebianProject.DebianGNULinux_<something>\LocalState\rootfs\dev\tty" of type 0020000.
[WARNING] Ignoring an unsupported file "\\?\C:\Users\<my_user_name>\AppData\Local\Packages\TheDebianProject.DebianGNULinux_<something>\LocalState\rootfs\dev\urandom" of type 0020000.
[WARNING] Ignoring an unsupported file "\\?\C:\Users\<my_user_name>\AppData\Local\Packages\TheDebianProject.DebianGNULinux_<something>\LocalState\rootfs\dev\zero" of type 0020000.

These are my warnings. I've hide replaced 2 parts, for privacy/security.

* Yesterday after the move I've checked that Debian, the Electrum server and the block explorer, all were working fine.
* I've had yesterday evening a Windows update and worked (I don't know what it contained though).


IIRC files in /dev represent your device and generated/removed during boot. Looks like my worry was for nothing.


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: HCP on March 31, 2022, 12:05:40 AM
Because I'm an idiot with bad time management... I decided that I could spare some time getting WSL and electrs up and running again... but I seem to be stuck getting electrs to start up :(

I don't remember having to do anything too special to make it work... but when I attempt to start electrs I get:
Code:
hcp@HCP-PC:~/electrs$ ./target/release/electrs
Starting electrs 0.9.6 on x86_64 linux with Config { network: Bitcoin, db_path: "/home/hcp/electrs/bitcoin", daemon_dir: "/mnt/e/Bitcoin", daemon_auth: CookieFile("/mnt/e/Bitcoin/.cookie"), daemon_rpc_addr: 127.0.0.1:8332, daemon_p2p_addr: 127.0.0.1:8333, electrum_rpc_addr: 127.0.0.1:50001, monitoring_addr: 127.0.0.1:4224, wait_duration: 10s, jsonrpc_timeout: 15s, index_batch_size: 10, index_lookup_limit: None, reindex_last_blocks: 0, auto_reindex: true, ignore_mempool: false, sync_once: false, disable_electrum_rpc: false, server_banner: "Welcome to electrs 0.9.6 (Electrum Rust Server)!", args: [] }
[2022-03-30T23:47:35.040Z INFO  electrs::metrics::metrics_impl] serving Prometheus metrics on 127.0.0.1:4224
[2022-03-30T23:47:35.040Z INFO  electrs::server] serving Electrum RPC on 127.0.0.1:50001
[2022-03-30T23:47:35.053Z INFO  electrs::db] "/home/hcp/electrs/bitcoin": 9 SST files, 0.000007245 GB, 0.000000009 Grows
[2022-03-30T23:47:35.056Z INFO  electrs::db] closing DB at /home/hcp/electrs/bitcoin
Error: electrs failed

Caused by:
    0: bitcoind RPC polling failed
    1: daemon not available
    2: JSON-RPC error: transport error: Couldn't connect to host: Connection refused (os error 111)
hcp@HCP-PC:~/electrs$

Really not sure what is causing the issue... any one else come across this? ???


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: NeuroticFish on March 31, 2022, 07:06:52 AM
Code:
Error: electrs failed

Caused by:
    0: bitcoind RPC polling failed
    1: daemon not available
    2: JSON-RPC error: transport error: Couldn't connect to host: Connection refused (os error 111)
hcp@HCP-PC:~/electrs$

Really not sure what is causing the issue... any one else come across this? ???

I can easily reproduce this when bitcoin core is running, but it's not synced.
So I'd start with getting full sync.

If that's not the cause, maybe take a look at rpcbind or rpcallowip in bitcoin.conf...


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: NeuroticFish on April 17, 2022, 02:17:42 PM
Maintenance: updating Electrs

Now and then it makes sense to update the server, since fixes and improvements are being added to the newer versions.
The details for updating are pretty much described at: https://github.com/romanz/electrs/blob/master/doc/upgrading.md still, I thought it won't hurt to have also a newbie friendly one here, focused on what we've installed.

Version
If you start your local electrs it will show its version. Mine is now 0.9.3 (yeah, I've done at some point in the past another/newer install).
In any git page of the project (like https://github.com/romanz/electrs ) there's a combobox telling "master". If you click it, and click tags, you'll see all the versions; more important, you'll see which is the latest one. In my case it's 0.9.6, so I'll update to that.

Update OS
Well, this should be run more often than updaing electrs, however, here we are:
Code:
sudo apt update
sudo apt upgrade

Optional prerequisites
Although it's not a required step to verify the signature, I will do that.
However, for that to work, we have to make sure our pgp "knows" the signature of the developer.
Code:
curl https://romanzey.de/pgp.txt
curl -o romanz.pgp https://romanzey.de/pgp.txt
gpg --import romanz.pgp

It should tell: "imported: 1".

Update Electrs
Since we have manual install, that path is what I'll follow.

Keep in mind that this code is for version 0.9.6; if you'll find newer versions on git, please adapt to that one.

Code:
cd ~
cd electrs
git checkout master
git pull

Now there's the optional step of verifying what we get. If you didn't import the pgp key, you will probably also skip this.

Code:
git verify-tag v0.9.6

It should tell things like "good signature" and "Primary key fingerprint: 15C8 C357 4AE4 F1E2 5F3F  35C5 87CA E5FA 4691 7CBB"
It may also give a warning that it's not the most trusted signature, but it's fine.

Let's proceed:

Code:
git checkout v0.9.6
ROCKSDB_INCLUDE_DIR=/usr/include ROCKSDB_LIB_DIR=/usr/lib cargo build --locked --release

If, back at install time, your install of librocksdb-dev has failed and have used a workaround, you'll have to look in git (https://github.com/romanz/electrs/blob/master/doc/upgrading.md) and adapt this last command (probably go for static linked path).

And we're done! If you also have the sh file I've created here (https://bitcointalk.org/index.php?topic=5367296.msg58256768#msg58256768), then:
Code:
cd ~
./run_electrs.sh


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: NeuroticFish on April 17, 2022, 02:20:56 PM
Maintenance: updating BTC RPC Explorer
Warning: it was not the nicest and cleanest update, but it works. You may want to read the warnings at the end.

Unlike Electrs, I didn't find any clear tutorial on how to update BTC RPC Explorer. But it's not difficult either.

Version
When you start your local BTC RPC Explorer it will show, at very start, its version. Or it can be seen at the bottom of web page. Mine is now 3.2.0.
In the git page of the project ( https://github.com/janoside/btc-rpc-explorer ) there's a combobox telling "master". If you click it, and click tags, you'll see all the versions; more important, you'll see which is the latest one. Now it shows 3.3.0, so I'll update to that.

Update OS
Well, this should be run more often and you may want to skip it if you've just done that when updating Electrs.
Code:
sudo apt update
sudo apt upgrade

Now.. let's go:

Code:
cd btc-rpc-explorer
git checkout master
git pull

Here I was told that I have local changes. If you don't, skip this part.

Code:
git reset --hard
git pull

Back on track; keep in mind that unlike Electrs, here I couldn't find a way to verify.

Code:
git checkout v3.3.0
npm install

It gave multiple warnings, but it seems to be installed (I've checked it and it works, so maybe you'll skip the fix warnings part.)

The Warnings
As I wrote, although it's well updated, it gave me warnings. Amongst those, it asked me to run

Code:
npm audit fix

and it didn't do much. So the next step I've done was the more risky (allegedly it can break things!)

Code:
npm audit fix --force

and it looked much better. I ran again, for a test

Code:
npm install

and seems happier now. Yay! ;D

...It also wrote that it would be nice if I update to newer npm, but I've failed badly that part so I'll leave it out :D

Run
If you've made the shell file like here (https://bitcointalk.org/index.php?topic=5367296.msg58256768#msg58256768), then:
Code:
cd ~
./run_explorer.sh


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: e8180kimo on November 26, 2022, 10:56:13 PM
Do you know how to setup with Tor or how to connect to my node with your setup remotely?


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: NeuroticFish on November 27, 2022, 10:11:06 AM
Do you know how to setup with Tor or how to connect to my node with your setup remotely?

Sorry, I didn't do such tests, I use this configuration locally.
But if you install this Electrs and want to use from outside of the local computer, I think that a first step would be to set the correct address you're accessing it from, or, if you want to allow all addresses then probably

Code:
electrum_rpc_addr = "0.0.0.0:50001"

instead of

Code:
electrum_rpc_addr = "127.0.0.1:50001"

But I advise this only on LAN. If you go out of your LAN then you'll probably have to configure SSL too (and allow some port forwarding in your router too).


Tor, sorry, I really don't know...



Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: BlackHatCoiner on November 27, 2022, 07:27:14 PM
Do you know how to setup with Tor or how to connect to my node with your setup remotely?
Update and install tor:
Code:
sudo apt update
sudo apt install tor

Check if Tor is installed:
Code:
tor --version
> Tor version 0.4.X
[...]

Edit the configuration file:
Code:
sudo nano /etc/tor/torrc

Add the following at the end of the file:
Code:
HiddenServiceDir /var/lib/tor/hidden_service_electrs/
HiddenServiceVersion 3
HiddenServicePort 50001 127.0.0.1:50002
(I think it needs to listen to 50001, because I see no SSL in this guide)

Reload tor:
Code:
sudo systemctl reload tor

Get the onion address with:
Code:
sudo cat /var/lib/tor/hidden_service_electrs/hostname

You connect to abc...xyz.onion:50002.


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: NeuroticFish on December 12, 2022, 07:06:27 PM
I may need help from more experienced people.

It was not only my WSL affected by the badly configured/partitioned SSD and I had the opportunity to pretty much wipe everything and start anew.
I've installed everything per this tutorial - obviously the latest versions - and I've got a strange surprise I don't like: no matter how long I leave it running, Electrs doesn't want to show me the "serving Electrum RPC on 127.0.0.1:50001" message.

Electrum connects to it, BTC-RPC-Explorer also connects to it, all seem to be fine, but I am missing that message I knew it announced that everything is up and running.
Does anybody know how to make it show up again? Is this a new feature? Can I enable it from config or command line?
Thanks.


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: BlackHatCoiner on December 12, 2022, 07:15:03 PM
Does anybody know how to make it show up again? Is this a new feature? Can I enable it from config or command line?
It should be showing it to you, because it does on raspibolt (https://raspibolt.org/guide/bitcoin/electrum-server.html), and that uses v0.9.10.

What's your log? It should log you stuff if you've enabled it at the configuration (just add these two lines[1]). What is it showing you after you enter "./electrs"?

[1]
Code:
log_filters = "INFO"
timestamp = true


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: NeuroticFish on December 12, 2022, 07:24:18 PM
It should be showing it to you, because it does on raspibolt (https://raspibolt.org/guide/bitcoin/electrum-server.html), and that uses v0.9.10.

What's your log? It should log you stuff if you've enabled it at the configuration (just add these two lines[1]). What is it showing you after you enter "./electrs"?

The config is the one from this post (https://bitcointalk.org/index.php?topic=5367296.msg58256539#msg58256539). I've added now your timestamp line, but no change.
After running electrs I see only the starting line containing basically the configuration (I've replaced this or that in case it's supposed to be private).

Starting electrs 0.9.10 on x86_64 linux with Config { network: Bitcoin, db_path: "/mnt/x/some/folder", daemon_dir: "/mnt/y/another/folder", daemon_auth: CookieFile("/mnt/x/some/folder/.somecookie"), daemon_rpc_addr: 127.0.0.1:8332, daemon_p2p_addr: 127.0.0.1:8333, electrum_rpc_addr: 127.0.0.1:50001, monitoring_addr: 127.0.0.1:4224, wait_duration: 10s, jsonrpc_timeout: 15s, index_batch_size: 10, index_lookup_limit: None, reindex_last_blocks: 0, auto_reindex: true, ignore_mempool: false, sync_once: false, disable_electrum_rpc: false, server_banner: "Electrs @ NeuroticFish", signet_magic: 3somenumber1, args: [] }


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: NeuroticFish on December 16, 2022, 12:57:02 PM

I've found the problem and it is, as in many similar cases, between the keyboard and the chair.
Yep, you were right and I am stupid. I managed to be careless with the config key.
I had, by mistake

Code:
log-filters = "INFO"

instead of the correct

Code:
log_filters = "INFO"

All fixed now. Thanks.


Title: Re: Bitcoin + Electrum server + Block explorer under Windows (with WSL and Debian)
Post by: NeuroticFish on December 30, 2022, 11:18:23 AM
I've done some tests with having an username and a password for RPC in Bitcoin Core instead of cookie file and I will post them here in case somebody wants to do that.
I will comment out (not delete) the config lines related to RPC cookie file.
Let's say that the username will be UsErNaMe and the password will be PaSsWoRd (please use much better ones though, just I would avoid using # or : in them).

This would make x:\BitcoinDataDir\bitcoin.conf (see this post (https://bitcointalk.org/index.php?topic=5367296.msg58256348#msg58256348)) look like:
Code: (bitcoin.conf)
txindex=1
server=1
rpcbind=127.0.0.1
rpcallow=127.0.0.1
#rpccookiefile=.mycookie
rpcuser=UsErNaMe
rpcpassword=PaSsWoRd

For Electrs, the content of $HOME/electrs/target/release/electrs.toml (see this post (https://bitcointalk.org/index.php?topic=5367296.msg58256539#msg58256539)) will become:
Code: (electrs.toml)
#cookie_file = "/mnt/x/BitcoinDataDir/.mycookie"
auth="UsErNaMe:PaSsWoRd"
daemon_dir = "/mnt/x/BitcoinDataDir"
daemon_rpc_addr = "127.0.0.1:8332"
daemon_p2p_addr = "127.0.0.1:8333"
db_dir = "/mnt/y/ElectrsData"
network = "bitcoin"
electrum_rpc_addr = "127.0.0.1:50001"
#verbose = 2 -> obsolete, was working with version 0.9.0, no longer works in 0.9.3
#use log-filters for version 0.9.3+
log_filters = "INFO"
server_banner = "Electrs @ NeuroticFish, yay!"

And for BTC RPC Explorer, $HOME/btc-rpc-explorer/.env (see this post (https://bitcointalk.org/index.php?topic=5367296.msg58256653#msg58256653)) becomes:
Code: (.env)
BTCEXP_BASEURL=/exp/
BTCEXP_BITCOIND_HOST=127.0.0.1
BTCEXP_BITCOIND_PORT=8332
#BTCEXP_BITCOIND_COOKIE=/mnt/X/BitcoinDataDir/.mycookie
BTCEXP_BITCOIND_USER=UsErNaMe
BTCEXP_BITCOIND_PASS=PaSsWoRd
BTCEXP_BITCOIND_RPC_TIMEOUT=5000
BTCEXP_ADDRESS_API=electrum
BTCEXP_ELECTRUM_SERVERS=tcp://127.0.0.1:50001
BTCEXP_ELECTRUM_TXINDEX=true
BTCEXP_SLOW_DEVICE_MODE=false
BTCEXP_PRIVACY_MODE=true
BTCEXP_NO_RATES=true

However, as said in Electrs pages, Electrs is meant for local networks, not exposed to the internet. So this setup is still not safe for the "outer world".
For that you'll probably need Blockstream's fork of electrs and maybe mempool space as explorer. And, clearly, SSL.
I wanted to make this clear, since some may expect that using Bitcoin Core RPC with user/password simply makes everything safe.