Monero

Monero Network Artwork Created with ChatGPT v4 and GIMP

In order to understand monero and it’s benefits, first make sure you understand bitcoin and it’s technical simplicity, relative to more elaborate, smart-contract enabled, proof-of-stake governance models in Ethereum at al, first. Monero is its own code-base, not a fork or copy of bitcoin code but closely builds upon the principles and mechanisms originating in bitcoin. Monero is not a smart contract platform, but other smart contract enabled cryptocurrencies built on monero do exist.

Interestingly, the bitcoin whitepaper was written by an anonymous group or person called Satoshi Nakamoto, initials SN. Monero’s “CryptoNote” whitepaper that emerged a few years later, was written by an anonymous person “Nicolas van Saberhagen”, initials NS. A likely candidate for both could be Nick Szabo who worked with others, the names of which are disclosed in the bitcoin whitepaper. But it can never be proved.

The monero system takes the principles of bitcoin and addresses the technical and practical drawbacks of them, adding the following key ingredients while retaining the Proof-Of-Work governance/mining model, albeit with an entirely new code base.

  1. Private Keys required to View as well as Spend.

2. Decoy spends are generated to obfuscate the “real” transaction.

3. Stealth addresses generated by transaction rather than using primary / sub addresses.

3. Flexible block sizes within limits to keep fees low while disincentivising spammers with fines for transactions exceeding a reasonable size in bytes.

4. Faster block cadence (full settlement) of 2 minutes instead of 10.

5. ASIC resistant mining algorithm to prevent centralisation of mining power to entities with access to enormous amounts of computing power.

6. Tail emission rather than a hard cap to continue to incentivise mining after the last coin is mined to maintain network security. The tail emission is often criticised however the asymptotic curve of deflation is akin to that of bitcoin and the tail emission is very small – actually less than bitcoin right now!

7. IP Address obfuscation using Dandelion++

Each of these features helps protect the privacy and anonymity of the sender and recipient at each layer in the tech stack. Clever cryptography ensures that the right amount of money reaches the intended recipient without being double-spent or manipulated and disputes can be settled by the sender optionally sending a key to the recipient so that they can verify an amount sent for a given transaction ID, but that’s it. Due to these features, the fungibilty of monero is the best there is of any cryptocurrency, i.e. 1 XMR really is 1 XMR.

Since both bitcoin and monero were originally intended as a digital currency with a tamper proof monetary policy, monero has surpassed bitcoin by holding a stabler price over longer time frames, especially in bitcoin and crypto bear markets. As a result of the stable price (relatively speaking) and private anonymity of its novel featureset over bitcoin, it has become the dominant form of currency used in the “dark markets” where people good and bad, trade goods and services with one another, peer-to-peer.

Traditionally, any well executed novel technology is first adopted and exploited by shadier characters. That’s not to say the technology is bad. In the case of monero, it’s just tokenised value, backed by energy – the same as bitcoin. Energy and Value aren’t bad, even if the persons choosing to use them to commit illegal actions are.

Global value transfer systems like bitcoin and monero are used all over the world by people who have different sets of laws applied to them in their jurisdiction due to the rich and varies cultures, governments and religions that have shaped their respective societies.

Irrespective of ones jurisdiction, all governments trend towards totalitarianism and all fiat currencies controlled by central banks trend towards zero.

For this reason alone, one can arrive at the conclusion that the biggest risk associated with bitcoin and monero is to not hold any!

As mentioned on my bitcoin page, the best strategy to build wealth with bitcoin and monero, is to simply allocate a small amount of net income regularly and build your position, allowing the volatility in terms of fiat price to rise and fall as it will as the price of these digital assets is tamper-proof, and the market caps still relatively small, so the free market decides its price in real-time based on supply and demand. Violent price movements are to be seen as an opportunity to buy more on a dip, or maybe take some profit on a pump with a view to recycling those funds into the next big dip that usually follows. That is up to you to decide, but trading risks your stack of fiat AND your stack of crypto, whereas holding of “hodling” protects your stack of crypto such that it is only subjected to unrealised losses and gains.

Running Monero Wallet/Client

The monero desktop wallet available from getmonero.org is very polished. It provides the ability to create multiple wallets that contain their own individual primary address and sub-addresses (one should always generate and use sub addresses in the public domain), full monero network node and the option to mine using a proportion of your CPU power to contribute to maintaining network security. Everything under one roof. As with bitcoin wallets, be sure to store your recovery phrases safely to prevent your address on the blockchain from being hacked remotely.

For mobile devices, I recommend using Cake Wallet. Cake wallet requires some time to sync up with bitcoin and monero nodes before you can use it, but it contains some very cool features like built in access to decentralised exchanges to trade between multiple cryptocurrencies – a great way to acquire monero is to trade some btc for it, for example. It also allows you to purchase top-up credit cards and merchant vouchers using your XMR tokens, with the Cake Pay feature.

Running your own Node

Since the View key is also private with Monero, in order to see the balance of your address, you need to submit your private View key to the node that your wallet is connected to in order to see the balance. This view key could in theory be intercepted, so it makes sense to run your own node, connect your wallet to it, then you’re only ever showing your private view key to your own node. You can still run your node as an open public full node to allow others to connect their wallets to your node, or not and just have it for yourself. The blockchain will still sync with other nodes.

https://monerodocs.org/running-node/open-node-tor-onion/

Enable NTP Time Synchronisation

Before installing and configuring monero, make sure that your Raspberry Pi (or any other node/OS) is synchronizing it’s time properly.

sudo apt-get install ntp
sudo systemctl status ntp
ntpq -p

sudo systemctl enable ntp

Disable IPv6 (not recommended)

sudo vi /boot/cmdline.txt
Add ipv6.disable=1 to the end of the file and save (Esc :wq! Enter)

sudo vi /etc/sysctl.conf

Add the following lines to the end of the file and save (Esc :wq! Enter)

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

sudo reboot

Disable Wireless Hardware on Pi 4 (only if wired connection)

sudo nano /etc/modprobe.d/raspi-blacklist.conf

blacklist brcmfmac

Running monerod as a service

Once you’re sufficiently happy that your monero node is accessible from your monero wallet app (Use Cake Wallet to configure preferred node address, connect and sync), then you need to make your node as resilient as possible.

Having the monerod daemon run as a background service (with or without an allocation of cpu power to mining to help decentralise the network security) will bring your node back online in the event of a reboot or power cut.

To do this you need to create a systemd service unit for the monero daemon and also create a systemd periodic restart for that service unit.

Whether you use sudo or cd to root is up to you, but all

sudo nano /etc/systemd/system/monerod.service

[Unit] Description=Monero Daemon

After=network.target

Wants=network.target

[Service]

ExecStart=/opt/monero/monerod –detach –config-file /etc/monero.conf –pidfile /run/monero/monerod.pid

ExecStartPost=/bin/sleep 0.1 Type=forking

PIDFile=/run/monero/monerod.pid

Restart=always

RestartSec=16

User=monero

Group=monero

RuntimeDirectory=monero

StandardOutput=journal

StandardError=journal [Install]

WantedBy=multi-user.target

Periodic Restarts

Building and running a monero node on a SBC is fun, challenging and you come away not just learning about monerod but learning a lot of useful linux skills along the way.

In reality though, it’s only a matter of time before the node is offline, so in the quest to build as much resilience into it as possible, I’d recommend implementing periodic restarts of the monerod service unit that is now running as a background service, controlled by systemctl.

This is not done via the cron scheduler, but by systemctl itself, which handles the service daemon unit for monerod.

sudo nano /etc/systemd/system/monerod-restart.timer

[Unit]

Description=Monero Full Node Restart Timer

[Timer]

OnBootSec=30min

OnUnitActiveSec=2h

Unit=monerod.service

[Install]

WantedBy=timers.target

If anything goes awry with your running monerod daemon, it’s only a short time before it’ll all get restarted. Provided the config hasn’t changed or the blockchain corrupted, your wallet will be able to re-sync with your node again within the hour (or whatever you set the restart interval to above).

Any configuration changes to the systemctl monerod service unit or to the restart timer config should be applied to the running systemctl service management system by typing the following.

sudo systemctl daemon-reload

to affect the changes in the config to the running monerod and restart timer service units managed by systemctl, type the following.

sudo systemctl start monerod-restart.timer

sudo systemctl enable monerod-restart.timer

sudo systemctl status monerod-restart.timer

Changes don’t just take effect on their own, nor do they take effect if you restart the service unit. You must remember to update the running “parent” systemctl service management system too. Otherwise you’ll be scratching your head why your change/fix hasn’t worked!

systemd Service Unit and Restart Timer for tor

The above steps to create a service unit for monerod and a service restart timer for it will also need to be done for tor. Depending on your OS, check the /etc/passwd and /etc/group files for the tor user – it maybe called debian-tor.

This is easier done as root user. Change to root user using sudo su –

grep tor /etc/passwd && grep tor /etc/group

vi /etc/systemd/system/tor.service

[Unit]
Description=Tor anonymity network daemon
After=network.target

[Service]
Type=simple
User=debian-tor
Group=debian-tor
ExecStart=/usr/bin/tor -f /etc/tor/torrc
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=SIGINT
LimitNOFILE=4096
Restart=on-failure
RestartSec=30s
StartLimitInterval=60s
StartLimitBurst=2

[Install]
WantedBy=multi-user.target

vi /etc/systemd/system/tor-restart.timer

[Unit]

Description=Timer to periodically restart Tor

[Timer]

OnBootSec=10min
OnUnitActiveSec=24h
Unit=tor.service

[Install]
WantedBy=timers.target

Reload daemon and add new service items

sudo systemctl daemon-reload

sudo systemctl start tor.service

sudo systemctl enable tor.service

sudo systemctl status tor.service

sudo systemctl start tor-restart.timer

sudo systemctl enable tor-restart.timer

sudo systemctl status tor-restart.timer

Troubleshooting systemd Service Units and Restart Timers

Use the systemctl list-units –all and systemctl status and journalctl -xe commands to see the status of systemd and troubleshoot any potential issues. Zero in on monero and tor by piping systemctl status | grep tor or | grep monero as applicable. Check all dependent service units are started before trying to start the restart timers and check that the tor username is correct and the service names match. Use ss-nlt to view all listening ports. Use tor –version to see version info. Torrify your entire shell so you don’t have to prface every command with torsocks to force traffic through tor proxy with source torsocks on

monero@xmrnode:/etc/tor $ ss -nlt
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 4096 127.0.0.1:9050 0.0.0.0:*
LISTEN 0 128 127.0.0.1:631 0.0.0.0:*
LISTEN 0 100 127.0.0.1:18082 0.0.0.0:*
LISTEN 0 128 127.0.0.1:18081 0.0.0.0:*
LISTEN 0 128 0.0.0.0:18080 0.0.0.0:*
LISTEN 0 5 0.0.0.0:5900 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 [::1]:631 [::]:*
LISTEN 0 5 [::]:5900 [::]:*
LISTEN 0 128 [::]:22 [::]:*
monero@xmrnode:/etc/tor $

monero@xmrnode:/etc/tor $ tor --version
Tor version 0.4.5.16.
monero@xmrnode:/etc/tor $ wget -qO - https://api.ipify.org; echo
109.156.xxx.xx
monero@xmrnode:/etc/tor $ torsocks wget -qO - https://api.ipify.org; echo
185.165.xxx.xx
monero@xmrnode:/etc/tor $ 

monero@xmrnode:/etc/tor $ source torsocks on
Tor mode activated. Every command will be torified for this shell.
monero@xmrnode:/etc/tor $ wget -qO - https://api.ipify.org; echo
185.165.xxx.xx
monero@xmrnode:/etc/tor $ 

echo ". torsocks on" >> ~/.bashrc will enable for all shells
source torsocks off will disable it

In the case of tor use journalctl -u tor@default.service to check the tor logs

In the case of monerod you can increase the logging level for the /var/log/monero/monero.log file by adding log-level=1 to /etc/monero.conf increasing all the way to 6 (start with 1 first!). Only do this for troubleshooting purposes though. Use tail -f /var/log/monero/monero.log to see the log being written in real time.

If your confident you’ve found and fixed any issues, reset the systemd failed state with systemctl reset-failed

Mining Monero with xmrig

First compile xmrig on the Raspberry Pi since there is no direct download of an ARM v8 version of xmrig from the xmrig website

sudo apt update sudo apt upgrade -y

sudo apt install git build-essential cmake libuv1-dev libssl-dev libhwloc-dev -y

git clone https://github.com/xmrig/xmrig.git
cd xmrig
mkdir build
cd build
cmake ..
make -j$(nproc)

Create a config.json configuration file for xmrig using the Wizard and copy it into the ~/xmrig/build/ folder once the build has completed.

{
    "autosave": true,
    "donate-level": 5,
    "cpu": true,
    "opencl": false,
    "cuda": false,
    "pools": [
        {
            "url": "xmr.pool.gntl.co.uk:20009",
            "user": "83W7e6VRb72eJJtkXUQMieP6jZUo9VyZEYevGVGTDHBRFJZNFCs5So6bcDUfBsREWzbj1fwBU17JriNSfKF9fg2QK8QJNSf",
            "pass": "RaspberryPi5",
            "keepalive": true,
            "tls": true
        }
    ]
}



To mine Monero XMR use the following command:

sudo ./xmrig --donate-level 5 -o xmr.pool.gntl.co.uk:20009 -u 83W7e6VRb72eJJtkXUQMieP6jZUo9VyZEYevGVGTDHBRFJZNFCs5So6bcDUfBsREWzbj1fwBU17JriNSfKF9fg2QK8QJNSf -k --tls -p RaspberryPi5


Alternatively, mine Haven XHV tokens using the following command:

sudo ./xmrig --url pool.hashvault.pro:80 --user hvxy6kyvmW65zVkGZ8vnpZ5P4LroFwnZe1eJxkhuQzDdcxFXHZph6H8g81eimB4gpZChm6ZXqwbmWjD731GdhRWA8gn6e2ybZA --pass cyberfellaXHV --donate-level 1 --tls --tls-fingerprint 420c7850e09b7c0bdcf748a7da9eb3647daf8515718f36d9ccfdd6b9ff834b14

Note that you will need to substitute your own monero or haven addresses in place of the ones above (unless you’re feeling super charitable!). In the case of monero, you should generate a sub-address (begin with an 8) in the monero wallet client instead of using your primary address (begin with a 4).

Haven XHV and Monero XMR being simultaneously mined using xmrig on a Raspberry Pi 5 (not recommended)