Setting up Bitcoin, Electrum server, and Block explorer on Windows using WSL and Debian

19 replies 487 views
L0neDegenSenior Member
Posts: 331 · Reputation: 1464
#1May 25, 2022, 11:09 AM
I think this might help some folks since I spent a good chunk of time figuring out how to get everything running on a Windows machine. This guide is gonna walk you through installing an Electrum server (electrs) and a block explorer (BTC RPC Explorer) on Windows, or close enough to it. It’s ‘close enough’ because I actually use WSL (Windows Subsystem for Linux) to run Debian under Windows. If you’re just using one wallet and don’t really need a block explorer, Electrum Personal Server might do the trick for you. Check out the other thread for that; I have a couple of posts there. Electrs isn’t limited to just one wallet and gives you useful info for the block explorer, which is why I opted for this more general setup. I’ll share all the details I can remember, along with my config files. If you have tips, feel free to throw them my way since I'm not a Linux pro, and most of this setup is still on Linux. Bitcoin Getting Bitcoin up and running on Windows is pretty simple. Just make sure your data directory has enough space; I use an external drive (X:\BitcoinDataDir). I’ve created a bitcoin.conf file in X:\BitcoinDataDir with the following settings: A couple of extra tips: 1. If you want to limit your connections, you might think about setting maxconnections in your config. I’ve read that a minimum of 12 is needed, but that’s not enough. When I tried that, the block explorer couldn’t connect. A value around 25 worked fine for me. 2. Just a heads up, if you use maxuploadtarget in your config, make sure to also add whitelist=dow.
2 Reply Quote Share
L0neDegenSenior Member
Posts: 331 · Reputation: 1464
#2May 25, 2022, 01:45 PM
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.] 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) that for each Windows drive, under Debian you'll have /mnt/<drive letter>/your path on that drive Update the OS:
0 Reply Quote Share
L0neDegenSenior Member
Posts: 331 · Reputation: 1464
#3May 25, 2022, 05:22 PM
Electrs (from https://github.com/romanz/electrs) The steps are based on the official install page 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: [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 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 and mine looks like this (I also kept only the useful lines) [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: Go into the correct folder and copy the config (you've saved it, right?). And don't forget the ending space and point Start electrs and let it sync, it'll take some hours in the first run. At a later point it will show the sweet: 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
1 Reply Quote Share
L0neDegenSenior Member
Posts: 331 · Reputation: 1464
#4May 25, 2022, 07:41 PM
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: 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: Now copy .env into the Linux folder and 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
0 Reply Quote Share
L0neDegenSenior Member
Posts: 331 · Reputation: 1464
#5May 26, 2022, 01:14 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: 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: And inside nano editor: CTRL-X and Save again CTRL-X and Save two more lines to execute: 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 trackETFbitcoin for hinting the correct block explorerDaveF and NotATether for making me understand VirtualBox is not such a great ideaDireWolfM14 for trying to help me with auto-starting services, although I still don't know how to do that  everybody active in the Dev & Tech from whom I've learned a lotand 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 and ensured their paths too.
6 Reply Quote Share
colddiamondHero Member
Posts: 623 · Reputation: 2467
#6May 26, 2022, 03:26 AM
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
1 Reply Quote Share
paulmoonMember
Posts: 8 · Reputation: 90
#7May 26, 2022, 04:22 AM
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.
2 Reply Quote Share
seed_vaultFull Member
Posts: 71 · Reputation: 451
#8May 27, 2022, 11:24 PM
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:
0 Reply Quote Share
L0neDegenSenior Member
Posts: 331 · Reputation: 1464
#9May 28, 2022, 05:28 AM
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. Thank you for the kind words. 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. I was able to install Ubuntu. I had other problems there: it didn't find for me librocksdb-dev=6.11.4-3it 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   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. 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. Thank you! Please let me know if I've missed or didn't explain good enough something.
1 Reply Quote Share
hash_bossLegendary
Posts: 1166 · Reputation: 5261
#10May 30, 2022, 01:20 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.
3 Reply Quote Share
L0neDegenSenior Member
Posts: 331 · Reputation: 1464
#11Jun 1, 2022, 04:43 AM
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   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
0 Reply Quote Share
paulmoonMember
Posts: 8 · Reputation: 90
#12Jun 1, 2022, 07:04 AM
As threatened, I try to imitate this now. At this point, the first problems occur: 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.
1 Reply Quote Share
L0neDegenSenior Member
Posts: 331 · Reputation: 1464
#13Jun 1, 2022, 11:23 AM
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: Also, I'm a bit surprised. If you are not great at Linux, why didn't you try with Debian as I did? 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.
2 Reply Quote Share
paulmoonMember
Posts: 8 · Reputation: 90
#14Jun 2, 2022, 03:50 AM
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.
0 Reply Quote Share
paulmoonMember
Posts: 8 · Reputation: 90
#15Jun 2, 2022, 04:48 AM
So I came far now, but at this point I get a mistake: I did it that way: 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! :-)
4 Reply Quote Share
L0neDegenSenior Member
Posts: 331 · Reputation: 1464
#16Jun 3, 2022, 03:24 PM
I also couldn't install that library on Ubuntu in my tests. You can see me complaining here, 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) you have to go with static linking and you get error here too, you may have to set and retry with Source/details: https://github.com/romanz/electrs/blob/master/doc/install.md#static-linking
4 Reply Quote Share
paulmoonMember
Posts: 8 · Reputation: 90
#17Jun 3, 2022, 07:51 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
1 Reply Quote Share
L0neDegenSenior Member
Posts: 331 · Reputation: 1464
#18Jun 5, 2022, 11:16 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. 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) 2. Installed LxRunOffline with chocolatey In PowerShell started as administrator ran the command: 3. Opened a completely new command prompt (cmd) as admin and there: And waited for some time. Got some warnings, but went through. (Thanks again ETFbitcoin)
2 Reply Quote Share
L0neDegenSenior Member
Posts: 331 · Reputation: 1464
#19Jun 6, 2022, 04:24 AM
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).
2 Reply Quote Share
hash_bossLegendary
Posts: 1166 · Reputation: 5261
#20Jun 7, 2022, 05:48 PM
IIRC files in /dev represent your device and generated/removed during boot. Looks like my worry was for nothing.
2 Reply Quote Share

Related topics