cashu-js
is an npm package for building Cashu ecash wallets.
Cashu is an Ecash implementation based on David Wagner's variant of Chaumian blinding. Token logic based on minicash (description) which implements a Blind Diffie-Hellman Key Exchange scheme written down by Ruben Somsen here.
- Request mint
- Mint tokens
- Split tokens
- Send tokens
- Receive tokens
- Melt tokens
- Check spendable
- Check fees
- Keysets
- Local storage
- Serialize tokens V1
- Serialize tokens V2
You need a Cashu mint for testing. If you don't already have one, follow the instructions below to set one up. Then we will run the JS code in this repo.
Install the Cashu Python mint and run the server on localhost:3338
. Don't be afraid. This is a quick an easy process if you follow the instructions carefully.
Run the mint:
LIGHTNING=FALSE poetry run mint
Here we made sure to disable Lightning for testing purposes, otherwise the mint will demand a Lightning payment (set LIGHTNING=FALSE
in .env
file to disable it permanently).
Clone this repository and install the dependencies:
git clone https://github.com/cashubtc/cashu-js-wallet.git
npm install
node src/index.js mint 420 <invoice_hash>
Note: If you've set LIGHTNING=FALSE
in the mint, you can use any invoice_hash
you want here.
node src/index.js pay <invoice>
node src/index.js send 69
node src/index.js receive W3siaWQiOiJEU0FsOW52dnlm...
node src/index.js receive W3siaWQiOiJEU0FsOW52dnlm...
...