Package: cashu
Cashu NutshellCashu Nutshell is a Chaumian Ecash wallet and mint for Bitcoin Lightning. Cashu Nutshell is the reference implementation in Python.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 onminicash(description) which implements aBlind Diffie-Hellman Key Exchangescheme written downhere. The database mechanics in Cashu Nutshell and the Lightning backend uses parts fromLNbits.Cashu protocol·Quick Install·Manual install·Configuration·Using Cashu·Run a mintFeature overview of NutshellBitcoin Lightning supportStandalone Cashu CLI  wallet and mint serverWallet and mint library to include in Python projectsPostgreSQL and SQLiteWallet with builtin TorUse multiple mints in one walletSend and receive tokens on nostrAdvanced featuresDeterministic wallet with seed phrase backupProgrammable ecash with, e.g., Pay-to-Pubkey supportWallet and mint support for keyset rotationsDLEQ proofs for offline transactionsThe Cashu protocolDifferent Cashu clients and mints use the same protocol to achieve interoperability. See thedocumentation pagefor more information on other projects. If you are interested in developing on your own Cashu project, please refer to the protocol specsprotocol specs.Easy InstallThe easiest way to use Cashu is to install the package it via pip:pipinstallcashuTo update Cashu, usepip install cashu -U.If you have problems running the command above on Ubuntu, runsudo apt install -y pip pkg-configandpip install wheel. On macOS, you might have to runpip install wheelandbrew install pkg-config.You can skip the entire next section about Poetry and jump right toUsing Cashu.Manual install: PoetryThese 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 toInstall Cashu.Poetry: Prerequisites# on ubuntu:sudoaptinstall-ybuild-essentialpkg-configlibffi-devlibpq-devzlib1g-devlibssl-devpython3-devlibsqlite3-devncurses-devlibbz2-devlibreadline-devlzma-dev# install python using pyenvcurlhttps://pyenv.run|bash# !! follow the instructions of pyenv init to setup pyenv !!pyenvinit# restart your shell (or source your .rc file), then install python:pyenvinstall3.10.4# install poetrycurl-sSLhttps://install.python-poetry.org|python3-echoexportPATH=\"$HOME/.local/bin:$PATH\">>~/.bashrcsource~/.bashrcPoetry: Install Cashu# install cashugitclonehttps://github.com/cashubtc/nutshell.gitcashucdcashu
pyenvlocal3.10.4
poetryinstallIf you would like to use PostgreSQL as the mint database, use the commandpoetry install --extras pgsql.Poetry: Update CashuTo update Cashu to the newest version entergitpull&&poetryinstallPoetry: Using the Nutshell walletCashu should be now installed. To execute the following commands, activate your virtual Poetry environment viapoetryshellIf you don't activate your environment, just prependpoetry runto all following commands.Configurationmv.env.example.env# edit .env filevim.envTo use the wallet with thepublic test mint, you need to change the appropriate entries in the.envfile.Test instanceWarning: 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.envfile settings toMINT_URL=https://8333.space:3338Using CashucashuinfoThis command shows information about your wallet.Check balancecashubalanceGenerate a Lightning invoiceThis command will return a Lightning invoice that you need to pay to mint new ecash tokens.cashuinvoice420The 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 commandcashu invoice <amount> --id <id>.Pay a Lightning invoicecashupaylnbc120n1p3jfmdapp5r9jz...Send tokensTo send tokens to another user, entercashusend69You 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:cashuAeyJwcm9vZnMiOiBbey...Receive tokensTo receive tokens, another user enters:cashureceivecashuAeyJwcm9vZnMiOiBbey...Starting the wallet API daemonNutshell wallet can be used in daemon mode that can be controlled through a REST API:cashu-dYou can find the API docs athttp://localhost:4448/docs.Running a mintThis command runs the mint on your local computer. Skip this step if you want to use thepublic test mintinstead.Before you can run your own mint, make sure to enable a Lightning backend inMINT_LIGHTNING_BACKENDand setMINT_PRIVATE_KEYin your.envfile.poetryrunmintFor testing, you can use Nutshell without a Lightning backend by settingMINT_LIGHTNING_BACKEND=FakeWalletin the.envfile.Running testsTo run the tests in this repository, first install the dev dependencies withpoetryinstall--withdevThen, make sure to set up your mint's.envfile to use a fake Lightning backend and disable Tor:MINT_LIGHTNING_BACKEND=FakeWalletTOR=FALSEYou can run the tests withpoetryrunpytesttests