Electrum on Windows

Installing electrum by windows installer.

After installation you will have two shortcuts in “Start” menu “Electrum” and “Electrum Testnet”. As we are going to use testnet mode click on respective shortcut.

Since electrum doesn’t work with cmd in windows we should use GUI to restore a wallet from seed phrase and load it.

Next we should configure rpc. The file config for testnet is on the path:

C:\Users\UserName\AppData\Roaming\Electrum\testnet

Make sure that you changed rpcuser and rpcpassword and also added rpcport:

 …  
"rpcpassword": "t",
"rpcport": 7777,
"rpcuser": "user",
…

Now restart electrum testnet and watch whether the daemon is listening 7777 port. For that open cmd and type:

netstat -a

And if you get:

  Имя    Локальный адрес        Внешний адрес          Состояние
...
  TCP    127.0.0.1:7777         DESKTOP-88AQOQA:0      LISTENING 
...

That means that it is all right.

Getting some testnet coins

To get some testnet bitcoins go here https://coinfaucet.eu/en/btc-testnet/

Java program example

Now let’s try some code. Let’s try getbalance method of JSON-RPC. Copy from the electrum docs https://electrum.readthedocs.io/en/latest/protocol.html

curl --data-binary '{"jsonrpc":"2.0","id":"curltext","method":"getbalance","params":[]}' http://username:password@127.0.0.1:7777

to https://curlconverter.com/java/

And we get the code where we need replace the username and the password.

Then open your IDE and create new maven project:

Choose Create a simple project:

Set names for Group Id and Artifact Id:

If you have jdk 8 or higher you should add dependency to the pom

		<dependency>
    		<groupId>javax.xml.bind</groupId>
    		<artifactId>jaxb-api</artifactId>
    		<version>2.3.1</version>
		</dependency>

That’s it, now paste the code to main class and run it.

package electrum_api;

import javax.xml.bind.DatatypeConverter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;

class Main {

	public static void main(String[] args) throws IOException {
		URL url = new URL("http://127.0.0.1:7777");
		HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
		httpConn.setRequestMethod("POST");

		httpConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

		//username:password
		byte[] message = ("user:t").getBytes("UTF-8"); 
		String basicAuth = DatatypeConverter.printBase64Binary(message);
		httpConn.setRequestProperty("Authorization", "Basic " + basicAuth);

		httpConn.setDoOutput(true);
		OutputStreamWriter writer = new OutputStreamWriter(httpConn.getOutputStream());
		writer.write("{\"jsonrpc\":\"2.0\",\"id\":\"curltext\",\"method\":\"getbalance\",\"params\":[]}");
		writer.flush();
		writer.close();
		httpConn.getOutputStream().close();

		InputStream responseStream = httpConn.getResponseCode() / 100 == 2
				? httpConn.getInputStream()
				: httpConn.getErrorStream();
		Scanner s = new Scanner(responseStream).useDelimiter("\\A");
		String response = s.hasNext() ? s.next() : "";
		System.out.println(response);
	}
}

That is what you should get in the console:

{"id": "curltext", "jsonrpc": "2.0", "result": {"confirmed": "0.03508005"}}

If you got something like this:

{"id": "curltext", "jsonrpc": "2.0", "error": {"code": 1, "message": "wallet not loaded"}}

Make sure that you loaded your wallet

One more useful tip is: if you want to get help for electrum commands type in powershell:

set-alias electrum (get-item "C:\Program Files (x86)\Electrum\electrum-*-debug.exe")

and then

electrum help

12 responses to “Electrum on Windows”

  1. Denis says:

    “Make sure that you loaded your wallet”

    Hello, I’m getting “wallet not loaded”. What should I do?

  2. Anonymous says:

    Open your Electrum testnet GUI.
    In File menu click Open. And choose your wallet.

  3. spunky game says:

    Sprunki Incredibox really elevates the music-mixing fun with fresh beats and cool visuals. It’s a must-try if you love creative gameplay. Check out Spunky Game for more innovative mods!

  4. 68wim says:

    Interesting post! Understanding player preferences is key, something 555wim seems to nail with localized options. Solid strategy discussion here – balancing risk & reward is crucial, just like choosing the right game!

  5. jljl55phapp says:

    Baccarat strategy is fascinating – understanding patterns is key! Seeing platforms like JLJL55 PH App offer structured learning is great for new players. Check out their jljl55 ph app slot options – a solid starting point for anyone wanting to improve their game!

  6. axiebet88 says:

    Dice games are all about calculated risk, aren’t they? It’s fascinating how probability plays out! Thinking of trying some online fun – heard good things about the community over at axiebet88 slot download, especially their easy app access! Seems legit. 😉

  7. Thinking about becoming an affiliate? Checked out lunabetaffiliate and it looks pretty promising. Anyone have experience with them? lunabetaffiliate

  8. Chưa dừng lại ở đó, hệ thống bảo mật của chúng tôi cũng đã nhận về rất nhiều lời khen từ chuyên gia cá cược. 888slot freebet Nhà cái hiện đang sử dụng công nghệ mã hoá SSL chuẩn 128 bit hiện đại. Vì vậy toàn bộ thông tin cá nhân người dùng sẽ tránh được hoàn toàn tình trạng hacker xâm nhập và đánh cắp. Tuy nhiên để tăng tính an toàn tối đa, thương hiệu vẫn thường xuyên khuyến cáo bet thủ nên thay đổi password định kỳ. TONY12-30

  9. xn88 win says:

    Chỉ với một tài khoản duy nhất tại xn88 win , bạn có thể tham gia từ cá cược thể thao đến các sòng casino trực tiếp sang trọng nhất. TONY12-30

  10. Một trong những yếu tố khiến 888slot 888slot 888 slot nổi bật là sự đa dạng trong các dịch vụ cá cược và giải trí. Những thể loại từ thể thao đến sòng bài trực tuyến trò chơi khác như bắn cá, slot game. Đây là những loại hình giải trí thu hút nhiều hội viên với tính chất vừa giải trí, vừa có thể mang lại thu nhập nếu biết cách đặt cược hợp lý. TONY01-12

  11. 888slot says:

    888slot không giới hạn số lần rút tiền/ngày – bạn thắng bao nhiêu, rút bấy nhiêu, miễn là đủ điều kiện theo quy định. TONY02-03H

Leave a Reply to 888slot Cancel reply

Your email address will not be published. Required fields are marked *