# 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. Token logic based on [minicash](https://github.com/phyro/minicash) ([description](https://gist.github.com/phyro/935badc682057f418842c72961cf096c)) which implements a [Blind Diffie-Hellman Key Exchange](https://cypherpunks.venona.com/date/1996/03/msg01848.html) scheme written down by Ruben Somsen [here](https://gist.github.com/RubenSomsen/be7a4760dd4596d06963d67baf140406). The database mechanics and the Lightning backend uses parts from [LNbits](https://github.com/lnbits/lnbits-legend).
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 such as a [Cashu Javascript wallet](https://github.com/motorina0/cashu-js-wallet). If you are interested in helping with Cashu development, please see the [docs](docs/) for the notation and conventions used. ## Easy Install The easiest way to use Cashu is to install the package it via pip: ```bash 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](#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-install-cashu). #### Poetry: Prerequisites ```bash # 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 ```bash # 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 ```bash git pull && poetry install ``` #### Poetry: Using Cashu Cashu should be now installed. To execute the following commands, activate your virtual Poetry environment via ```bash poetry shell ``` If you don't activate your environment, just prepend `poetry run` to all following commands. ## Configuration ```bash mv .env.example .env # edit .env file vim .env ``` To use the wallet with the [public test mint](#test-instance), 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 ```bash MINT_HOST=8333.space MINT_PORT=3338 ``` # Using Cashu ```bash cashu info ``` Returns: ```bash Version: 0.8 Debug: False Cashu dir: /home/user/.cashu Wallet: wallet Mint URL: https://8333.space:3338 ``` #### Check balance ```bash cashu balance ``` #### Generate a Lightning invoice This command will return a Lightning invoice that you need to pay to mint new ecash tokens. ```bash 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