Lightweight modes
Run Bitcoin and Litecoin through Electrum servers and Monero or Wownero through a remote node, so BasicSwap can trade without downloading those blockchains.
Running a full node for every coin is the most private and independent way to use BasicSwap, but it means downloading and checking each blockchain, which for Bitcoin and Monero runs to hundreds of gigabytes and days of syncing. For four coins there's a lighter option. Bitcoin and Litecoin can run as Electrum light wallets that ask public servers about the blockchain, and Monero and Wownero can use a remote node in place of a local one. In both cases your keys and wallet stay on your computer, and what you give up is some privacy and the guarantee that you checked the chain yourself. Every other coin still runs a full node.
Electrum light wallets for Bitcoin and Litecoin
In its usual mode, which BasicSwap calls RPC, BasicSwap runs a full node for the coin and checks every block and transaction on your own machine. In Electrum mode it runs no node for that coin at all. It connects instead to ElectrumX servers, which index the blockchain and answer questions about balances, transactions and unspent outputs on your behalf. Your keys never leave your computer, although the server does learn which addresses you're asking about.
What you trade
| Full node (RPC) | Electrum light wallet | |
|---|---|---|
| Blockchain download | The whole chain | None |
| Disk space | Tens of GB for Bitcoin, with old blocks pruned | A few MB |
| Ready to use | After hours or days of syncing | Within seconds |
| Trust | You check everything yourself | You rely on the server's answers |
| Privacy | No one sees your queries | The server sees which addresses you query |
| Availability | Your own node | Public servers, with automatic failover between them |
Electrum mode covers Bitcoin and Litecoin only. Litecoin works this way from BasicSwap 0.17.5 on, the first release that could confirm Litecoin transactions over Electrum. Its MWEB addresses, the ones starting with ltcmweb1, don't work in this mode, so a Litecoin light wallet uses standard addresses only.
Turn on Electrum mode at setup
The simplest way is to choose it when you first run basicswap-prepare. The --light option puts every supported coin you enable, Bitcoin and Litecoin, on Electrum:
Docker
docker-compose run --rm swapclient basicswap-prepare --datadir=/coindata --withcoins=monero,bitcoin --htmlhost="0.0.0.0" --wshost="0.0.0.0" --xmrrestoreheight=$CURRENT_XMR_HEIGHT --lightFrom source
basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,bitcoin --xmrrestoreheight=$CURRENT_XMR_HEIGHT --lightTo choose coin by coin, use --btc-mode=electrum and --ltc-mode=electrum instead, which lets you, for example, keep a full Bitcoin node while running Litecoin as a light wallet:
Docker
docker-compose run --rm swapclient basicswap-prepare --datadir=/coindata --withcoins=monero,bitcoin,litecoin --htmlhost="0.0.0.0" --wshost="0.0.0.0" --xmrrestoreheight=$CURRENT_XMR_HEIGHT --ltc-mode=electrumFrom source
basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,bitcoin,litecoin --xmrrestoreheight=$CURRENT_XMR_HEIGHT --ltc-mode=electrumIf you'd rather use a server you trust than the built-in list, name it with --btc-electrum-server or --ltc-electrum-server in the form host:port:ssl, where ssl is true or false. If you leave it off, BasicSwap uses SSL for every server except an onion or local network one, which it reaches without SSL:
basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=bitcoin --btc-mode=electrum --btc-electrum-server=custom.server.com:50002:true
With basicswap-bash, the installer and bsx-addcoin both ask whether to use Electrum for Bitcoin and Litecoin. The installer uses the built-in servers, while bsx-addcoin also lets you enter your own server when you first add the coin.
Switch an existing coin
An installed Bitcoin or Litecoin wallet can move between a full node and Electrum at any time, as long as none of its swaps is in progress. The usual way is through the web UI:
- Open Settings and find Bitcoin or Litecoin.
- Change Connection Type from Full Node (RPC) to Light Wallet (Electrum), or back again.
- Optionally, enter your own Electrum servers in the server lists.
- Ignore Address Gap Limit, which only appears in debug mode. BasicSwap neither saves nor reads it, as the reference table below explains.
- Click Apply Changes, confirm the switch in the dialog that opens, then restart BasicSwap. When you switch from Electrum back to a full node with a balance, the dialog also asks what to do with it, as described below.
You can also make the change by hand, but that skips the key backup and the fund transfer the web UI runs during a switch, so it's best kept for an empty wallet. Stop BasicSwap, open basicswap.json in your data folder, set the coin's connection type and turn off its daemon, then start BasicSwap again:
{
"chainclients": {
"bitcoin": {
"connection_type": "electrum",
"manage_daemon": false
}
}
}
Both modes derive the wallet from the same recovery phrase. A Bitcoin wallet created with descriptors, the default for new installs, uses the same native segwit (BIP84) addresses in either mode, so its funds show up in both and normally don't need to move. A Litecoin full-node wallet, or an older Bitcoin wallet, uses different key paths that the light wallet can't derive. A transfer only matters for funds on addresses like these, which the other mode can't derive, and the switching dialog handles them differently depending on the direction.
From a full node to Electrum, the dialog first shows the coin's extended private key, a zprv… or yprv… string, with instructions for importing it into an external Electrum wallet, and asks you to tick "I have written down this key" before it goes on. It then looks for funds on legacy or imported addresses that the BIP84 path can't reach from your phrase. If those funds are worth more than twice the estimated fee to move them, BasicSwap consolidates them onto a BIP84 address as part of the switch, and there's no way to opt out in this direction. If they're worth less, the dialog says so and leaves them. Funds already on BIP84 addresses stay where they are.
From Electrum back to a full node, the dialog checks the light wallet's balance against the estimated fee. When the balance is no more than twice the fee, it shows "Balance (…) is too low to transfer - fee would exceed funds." and moves nothing. Otherwise it offers you a choice between two options. Auto-transfer funds to RPC wallet, the default, sends the light wallet's balance to the full-node wallet during the switch, at a fixed fee rate of 5 sat/vB. Keep funds on current addresses moves nothing at the moment of the switch, but BasicSwap still sweeps the balance into the full-node wallet the next time it starts, which happens anyway with the restart the switch needs.
BasicSwap doesn't remember either choice, and asks again at every switch. If you'd rather not use the dialog at all, send the coin's balance to another wallet you control before switching, so there's nothing left to move, and bring it back afterwards if you like.
Electrum servers
BasicSwap comes with a list of public servers for each coin and moves between them on its own. You can replace the list for more control or privacy.
Bitcoin
| Server | Port | SSL |
|---|---|---|
| bitcoin.stackwallet.com | 50002 | Yes |
| electrum.blockstream.info | 50002 | Yes |
| electrum.emzy.de | 50002 | Yes |
| electrum.bitaroo.net | 50002 | Yes |
| electrum.acinq.co | 50002 | Yes |
| btc.lastingcoin.net | 50002 | Yes |
Litecoin
| Server | Port | SSL |
|---|---|---|
| litecoin.stackwallet.com | 20063 | Yes |
| electrum-ltc.bysh.me | 50002 | Yes |
| electrum.ltc.xurious.com | 50002 | Yes |
| backup.electrum-ltc.org | 443 | Yes |
| ltc.rentonisk.com | 50002 | Yes |
| electrum-ltc.petrkr.net | 60002 | Yes |
| electrum.jochen-hoenicke.de | 50004 | Yes |
You write each server as host:port:ssl, so bitcoin.stackwallet.com:50002:true uses SSL and my-server.local:50001:false doesn't. To use your own, open Settings, choose the coin, and enter one server per line in the clearnet or onion server fields. basicswap.json keeps the same lists under electrum_clearnet_servers and electrum_onion_servers:
{
"chainclients": {
"bitcoin": {
"connection_type": "electrum",
"manage_daemon": false,
"electrum_clearnet_servers": [
"bitcoin.stackwallet.com:50002:true",
"electrum.blockstream.info:50002:true"
],
"electrum_onion_servers": [
"your-onion-server.onion:50001:false"
]
}
}
}
Electrum over Tor
When BasicSwap runs over Tor, its Electrum connections go through the Tor proxy too, and the onion server list decides how. BasicSwap has no built-in onion servers, so you add any you want yourself. If the list contains at least one onion server, BasicSwap uses only the onion servers and ignores every clearnet entry while Tor is on, without falling back to them. With no onion servers listed, it uses the clearnet servers, your own or the defaults, through the Tor proxy. Tor doesn't change any server's SSL setting. Clearnet servers usually use SSL, while onion servers are usually set to false and leave the encryption to Tor, which already protects the connection end to end.
Following an Electrum wallet
On the Wallets page, a coin in Electrum mode shows the server it uses and that server's version, with Electrum Wallet Synced or Waiting for Electrum Server... in place of a sync bar, and it's ready to use as soon as it connects. The coin's own wallet page adds the connection state next to the server. (Connected) means all is well, while (Disconnected - Reconnecting...) means BasicSwap lost the server and is reconnecting. (All Servers Failed) means none of the configured servers answered, which usually points to the server list or your network.
Behind that, BasicSwap pings its servers regularly, moves to another server when one stops answering, backs off for five minutes from a server that rate-limits it, and favours servers that have been fast and reliable.
Electrum settings
| Setting | Type | Default | What it does |
|---|---|---|---|
connection_type |
string | "rpc" |
"electrum" turns on light wallet mode. |
manage_daemon |
bool | true |
Must be false in Electrum mode. |
electrum_clearnet_servers |
list | The built-in servers | Your clearnet servers, as host:port:ssl. |
electrum_onion_servers |
list | [] |
Your onion servers, used when Tor is on. |
electrum_poll_interval |
int | 10 |
How often, in seconds, the wallet checks for updates. |
max_electrum_servers |
int | 2 |
How many servers BasicSwap keeps connected at once. |
address_gap_limit |
int | 50 |
Has no effect. BasicSwap neither saves nor reads it. When looking for funds it scans 50 addresses on either side of the highest one it has derived, and it keeps 20 unused addresses ready past the last used one. |
Monero remote nodes
Monero and Wownero can use a node running somewhere else in place of the monerod daemon BasicSwap would otherwise run, which saves downloading the Monero blockchain. Only the daemon moves elsewhere, while the wallet, monero-wallet-rpc, still runs on your computer, creates and holds your keys there, and only asks the remote daemon for blockchain data and to broadcast transactions.
| Local daemon | Remote node | |
|---|---|---|
| Blockchain download | The whole chain, over 200 GB | None |
| Disk space | Roughly 90 GB once pruned | Wallet data only |
| Ready to use | After hours or days of syncing | Within seconds |
| Trust | You check everything yourself | You rely on the node's answers |
| Privacy | No one sees your queries | The node sees your wallet's queries |
| Availability | Your own node | Depends on the remote node |
Use a remote node at setup
To use a remote node from the start, give its address to basicswap-prepare in the XMR_RPC_HOST and XMR_RPC_PORT environment variables, and BasicSwap won't set up a daemon of its own:
Docker
docker-compose run --rm -e XMR_RPC_HOST="node2.monerodevs.org" -e XMR_RPC_PORT=18089 swapclient basicswap-prepare --datadir=/coindata --withcoins=monero,bitcoin --htmlhost="0.0.0.0" --wshost="0.0.0.0" --xmrrestoreheight=$CURRENT_XMR_HEIGHTFrom source
XMR_RPC_HOST="node2.monerodevs.org" XMR_RPC_PORT=18089 basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,bitcoin --xmrrestoreheight=$CURRENT_XMR_HEIGHTIf the node asks for a login, add XMR_RPC_USER and XMR_RPC_PWD as well:
Docker
docker-compose run --rm -e XMR_RPC_HOST="192.168.1.9" -e XMR_RPC_PORT=18089 -e XMR_RPC_USER="myuser" -e XMR_RPC_PWD="mypassword" swapclient basicswap-prepare --datadir=/coindata --withcoins=monero,bitcoin --htmlhost="0.0.0.0" --wshost="0.0.0.0" --xmrrestoreheight=$CURRENT_XMR_HEIGHTFrom source
XMR_RPC_HOST="192.168.1.9" XMR_RPC_PORT=18089 XMR_RPC_USER="myuser" XMR_RPC_PWD="mypassword" basicswap-prepare --datadir=$SWAP_DATADIR --withcoins=monero,bitcoin --xmrrestoreheight=$CURRENT_XMR_HEIGHTThe basicswap-bash installer asks the same question, and checks that it can reach the node before it carries on.
Switch an existing install to a remote node
In the web UI, open Settings and expand the Monero card. Set Manage Daemon to False, enter the node's address in Daemon RPC Host and its port in Daemon RPC Port, which is usually 18081 or 18089, and click Apply Changes, then restart BasicSwap. The same card also lets you list several nodes under Trusted Public Nodes with Automatically Select Daemon turned on, and choose a Transaction Fee Priority of Auto, Slow, Normal or Fast.
To do it by hand instead, stop BasicSwap and set the node under chainclients.monero in basicswap.json, adding rpcuser and rpcpassword if the node needs a login, then start BasicSwap again:
{
"chainclients": {
"monero": {
"connection_type": "rpc",
"manage_daemon": false,
"manage_wallet_daemon": true,
"rpchost": "192.168.1.9",
"rpcport": 18089,
"rpcuser": "myuser",
"rpcpassword": "mypassword"
}
}
}
Your own node on another machine
If you run a Monero node elsewhere, for example on a home server, you can connect BasicSwap to it over the network with a login, or keep its RPC port closed and reach it through an SSH tunnel.
To connect directly, give the node a restricted RPC port with a login in its monerod.conf, open that port in its firewall, and use the basicswap.json settings above with the node's address:
rpc-login=myuser:mypassword
rpc-restricted-bind-port=18089
rpc-restricted-bind-ip=0.0.0.0
You can test the connection from the BasicSwap machine before starting BasicSwap:
curl http://192.168.1.9:18089/json_rpc -u myuser:mypassword --digest -d '{"jsonrpc":"2.0","id":"0","method":"get_info"}' -H 'Content-Type: application/json'
An SSH tunnel avoids exposing the port at all, and SSH then takes care of authentication, so the node needs no RPC login. Set rpc-restricted-bind-port=18089 in the node's monerod.conf, then open the tunnel from the BasicSwap machine with the first command below, or from the node with the second:
ssh -N -L 18089:localhost:18089 user@REMOTE_NODE_IP
ssh -N -R 18089:localhost:18089 user@LOCAL_BSX_IP
BasicSwap then reaches the node at localhost:
{
"chainclients": {
"monero": {
"connection_type": "rpc",
"manage_daemon": false,
"manage_wallet_daemon": true,
"rpchost": "localhost",
"rpcport": 18089
}
}
}
Trusted and untrusted nodes
A fresh install treats a remote Monero or Wownero node as trusted, with "trusted_daemon": true, which lets the wallet skip some checks and work faster.
Turning Tor on or off with the --enabletor and --disabletor options, or with the bsx-enabletor and bsx-disabletor commands that run them, leaves that setting alone unless you add --trustremotenode for a trusted node or --trustremotenode=false for an untrusted one to the --enabletor or --disabletor command. You can also set it to "auto", where trust follows the node's address. A node at a private address, meaning 127.x.x.x, 10.x.x.x, 172.16-31.x.x, 192.168.x.x, localhost, a *.local name or a private IPv6 address, counts as trusted, and any other node is untrusted, so the wallet runs extra checks against it in case it's dishonest.
To set the mode yourself, stop BasicSwap and set "trusted_daemon" to true, false or "auto" in the Monero or Wownero section of basicswap.json.
Several nodes with automatic selection
BasicSwap can pick from a list of remote nodes, which gives you a fallback when one goes down. Unlike Electrum, which changes servers while running, Monero picks its node only at startup. It tries the node it used last if that node is in the list, and if that fails, it shuffles the list and tries each node in turn, keeping the first one that answers as the new default.
To turn it on, enable Automatically Select Daemon and fill in Trusted Public Nodes in Settings, or set it in basicswap.json:
{
"chainclients": {
"monero": {
"connection_type": "rpc",
"manage_daemon": false,
"manage_wallet_daemon": true,
"automatically_select_daemon": true,
"remote_daemon_urls": [
"node2.monerodevs.org:18089",
"your-node.example:18089"
]
}
}
}
Remote nodes over Tor
When BasicSwap runs over Tor, it routes connections to a remote Monero node through the Tor proxy without any further setup. The exception is a node at a private address, which BasicSwap reaches directly over your own network.
Monero settings
| Setting | Type | Default | What it does |
|---|---|---|---|
manage_daemon |
bool | true |
false for a remote node. |
manage_wallet_daemon |
bool | true |
The wallet always runs locally, so leave it true. |
rpchost |
string | "127.0.0.1" |
The node's address or hostname. |
rpcport |
int | 29798 |
The node's RPC port. 29798 is BasicSwap's own default, picked to stay clear of a monerod already running on the computer, so change it for a public node, which usually listens on 18081 for unrestricted access or 18089 for restricted access. |
rpcuser |
string | "" |
The node's RPC username, if it has one. |
rpcpassword |
string | "" |
The node's RPC password, if it has one. |
trusted_daemon |
bool or string | true |
true, false or "auto", which decides from the node's address. |
automatically_select_daemon |
bool | false |
Picks a node from remote_daemon_urls at startup. |
remote_daemon_urls |
list | [] |
Nodes to choose from, as host:port. |
fee_priority |
int | 0 |
Transaction fee priority: 0 auto, 1 slow, 2 normal, 3 fast. |
rpctimeout |
int | 60 |
How long, in seconds, to wait for the node. |
A remote node is a compromise worth understanding before you rely on it. The node sees which transactions you broadcast and which outputs your wallet asks about. Public nodes can also be slow, rate-limited or disappear without notice, which is why your own node, even on another machine, beats a public one, and why several nodes listed for automatic selection beat a single one. The wallet itself still runs on your computer, though it needs far less than a full daemon would.