Ecash wallet and mint for Bitcoin Lightning
Project description
cashu
Cashu is a Chaumian Ecash wallet and mint for Bitcoin Lightning.
Disclaimer: The author is NOT a cryptographer and this work has not been reviewed. This means that there is very likely a fatal flaw somewhere. Cashu is still experimental and not production-ready.
Cashu is an Ecash implementation based on David Wagner's variant of Chaumian blinding (protocol specs). Token logic based on minicash (description) which implements a Blind Diffie-Hellman Key Exchange scheme written down here. The database mechanics and the Lightning backend uses parts from LNbits.
Cashu client protocol · Quick Install · Manual install · Configuration · Using Cashu · Run a mint
Feature overview
- Full Bitcoin Lightning support
- Standalone CLI wallet and mint server
- Mint library includable into other Python projects
- PostgreSQL and SQLite database support
- Builtin Tor for hiding IPs for wallet and mint interactions
- Multimint wallet for tokens from different mints
- Send tokens to nostr pubkeys
Cashu client protocol
There are ongoing efforts to implement alternative Cashu clients that use the same protocol. If you are interested in helping with Cashu development, please refer to the protocol specs protocol specs.
Easy Install
The easiest way to use Cashu is to install the package it via pip:
pip install cashu
To update Cashu, use pip install cashu -U
.
If you have problems running the command above on Ubuntu, run sudo apt install -y pip pkg-config
and pip install wheel
. On macOS, you might have to run pip install wheel
and brew install pkg-config
.
You can skip the entire next section about Poetry and jump right to Using Cashu.
Hard install: Poetry
These steps help you install Python via pyenv and Poetry. If you already have Poetry running on your computer, you can skip this step and jump right to Install Cashu.
Poetry: Prerequisites
# on ubuntu:
sudo apt install -y build-essential pkg-config libffi-dev libpq-dev zlib1g-dev libssl-dev python3-dev libsqlite3-dev ncurses-dev libbz2-dev libreadline-dev lzma-dev
# install python using pyenv
curl https://pyenv.run | bash
# !! follow the instructions of pyenv init to setup pyenv !!
pyenv init
# restart your shell (or source your .rc file), then install python:
pyenv install 3.9.13
# install poetry
curl -sSL https://install.python-poetry.org | python3 -
echo export PATH=\"$HOME/.local/bin:$PATH\" >> ~/.bashrc
source ~/.bashrc
Poetry: Install Cashu
# install cashu
git clone https://github.com/callebtc/cashu.git --recurse-submodules
cd cashu
pyenv local 3.9.13
poetry install
Poetry: Update Cashu
To update Cashu to the newest version enter
git pull && poetry install
Poetry: Using Cashu
Cashu should be now installed. To execute the following commands, activate your virtual Poetry environment via
poetry shell
If you don't activate your environment, just prepend poetry run
to all following commands.
Configuration
mv .env.example .env
# edit .env file
vim .env
To use the wallet with the public test mint, you need to change the appropriate entries in the .env
file.
Test instance
Warning: this instance is just for demonstration only. The server could vanish at any moment so consider any Satoshis you deposit a donation.
Change the appropriate .env
file settings to
MINT_HOST=8333.space
MINT_PORT=3338
Using Cashu
cashu info
Returns:
Version: 0.9.2
Debug: False
Cashu dir: /home/user/.cashu
Wallet: wallet
Mint URL: https://8333.space:3338
Check balance
cashu balance
Generate a Lightning invoice
This command will return a Lightning invoice that you need to pay to mint new ecash tokens.
cashu invoice 420
The client will check every few seconds if the invoice has been paid. If you abort this step but still pay the invoice, you can use the command cashu invoice <amount> --hash <hash>
.
Pay a Lightning invoice
cashu pay lnbc120n1p3jfmdapp5r9jz...
Send tokens
To send tokens to another user, enter
cashu send 69
You should see the encoded token. Copy the token and send it to another user such as via email or a messenger. The token looks like this:
eyJwcm9vZnMiOiBbey...
You can now see that your available balance has dropped by the amount that you reserved for sending if you enter cashu balance
:
Balance: 420 sat
Receive tokens
To receive tokens, another user enters:
cashu receive eyJwcm9vZnMiOiBbey...
You should see the balance increase:
Balance: 0 sat
Balance: 69 sat
Running a mint
This command runs the mint on your local computer. Skip this step if you want to use the public test mint instead.
python -m cashu.mint
You can turn off Lightning support and mint as many tokens as you like by setting LIGHTNING=FALSE
in the .env
file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file cashu-0.9.2.tar.gz
.
File metadata
- Download URL: cashu-0.9.2.tar.gz
- Upload date:
- Size: 13.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a231022f40da3e5238714a5b4e5e9b915b11003860c50c8aa2bd4df4fbb72bb |
|
MD5 | e3f89e32ccdaddd8ff536e4dc7c1c9b3 |
|
BLAKE2b-256 | ec62ecba55db1d913686eed3de511d46d995a59b628df52085fbafd2f29af1ab |
File details
Details for the file cashu-0.9.2-py3-none-any.whl
.
File metadata
- Download URL: cashu-0.9.2-py3-none-any.whl
- Upload date:
- Size: 13.5 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 197e008d37c7df6cce36b316e4cc718d1821d45bc59955622ed011424ab0eaa3 |
|
MD5 | f4294e1c07f81c15d37551ded199dabf |
|
BLAKE2b-256 | 75bc6b6b72477aca3cfdcde0f711d085c194775a9b03e2f50b17b74ac2fea9b7 |