Back to Blog
blockchain
3 min read

Custom electrum servers with the BDK-Kotlin wallet

A quick guide on how the user can change the wallet's electrum servers.

Tang Yetong
Tang Yetong
Full Stack Developer and former Data Analyst Intern at Fivetran with a background in government digital services and blockchain technology.

A quick guide on how the user can change the wallet's electrum servers.

Why

Lets say, for example, you have promised your wallet users absolute anonymity when using it. Nobody should be able to come close to figuring out what you or your users are doing on the blockchain. Perhaps you heard from a friend that the public blockchain indexing services are collecting the data of people who used it.

Although that is highly unlikely, the possibility that a public electrum server can conduct malicious activities might not sit well with everyone. To give an idea of what they can do :

  • Lie to you and tell you you have coins that you don't
  • Refuse to relay your spending transactions

It can't however :

  • Give you a fake receive address
  • Steal your wallet private keys

Electrum shares your wallet addresses with the server you are connected to so the server sees all your transactions.

If you have your own electrum server set up, or just simply want to switch to different electrum addresses on the fly, it is trivially easy to accomplish using the BDK-Kotlin library.

How

All you have to do is create a new BlockchainConfig object with the new electrum server URL, create the new Blockchain object off it, and finally sync the Wallet to the new Blockchain.

val newBlockchainConfig = BlockchainConfig.Electrum(ElectrumConfig(customElectrumURL, null, 5u, null, 10u))
val newBlockchain = Blockchain(blockchainConfig)
wallet.sync(newBlockchain)

And that's it! You are now connected to a new public electrum server, or you own custom run one.

Do note, however, if the electrum server URL you have passed in is invalid (does not point to a server), the app might freeze. Do provide your own error handling either on the UI or the backend side.

Tags

BDK-Kotlin
Bitcoin
Electrum
Privacy
Tang Yetong

Tang Yetong

Full Stack Developer and former Data Analyst Intern at Fivetran with a background in government digital services and blockchain technology.

Related Articles

Featured
5 mins

How to contribute to Padawan Wallet

blockchain

A quick summary of what the Padawan Wallet is, why it exists and how you can contribute to it!

Bitcoin
Open Source
BDK-Kotlin
+1
Read Article: How to contribute to Padawan Wallet
Featured
8 mins

Summer of Bitcoin 2022

blockchain

This is the last week of the Summer of Bitcoin (SoB) 2022 internship and what a journey it has been.

SoB
Internship
Bitcoin
+1
Read Article: Summer of Bitcoin 2022
4 mins

Bumping RBF Enabled Transaction Fees using BDK-Kotlin

blockchain

A quick guide on how to use the BDK-Kotlin 0.8.0 library to bump Replace-By-Fee(RBF) enabled transaction fees.

BDK-Kotlin
Bitcoin
RBF
+1
Read Article: Bumping RBF Enabled Transaction Fees using BDK-Kotlin