๐ก Cashubrew: Where Elixir meets Cashu, creating a symphony of secure, scalable, and lightning-fast ecash transactions!
โ ๏ธ Disclaimer: This is a proof of concept and is not ready for production use.
Before diving into Cashubrew, it's essential to understand Cashu.
Cashu is a free and open-source Chaumian ecash protocol built for Bitcoin.
Essentially, it is a privacy-preserving ecash protocol that enables instant, nearly free, and private transactions.
To learn more about Cashu:
- ๐ Cashu Specifications (NUTs): Dive deep into the technical details of the Cashu protocol.
- ๐ Cashu Documentation: Comprehensive guide to understanding and implementing Cashu.
- ๐จ Cashu Visual Explainer: An interactive visual guide to help you grasp Cashu concepts.
Understanding Cashu will help you appreciate the magic behind Cashubrew and contribute more effectively to the project!
Embark on your Cashubrew journey with these simple steps:
-
Clone the Treasure Map
git clone https://github.com/keep-starknet-strange/cashubrew.git cd cashubrew
-
Summon the Dependencies
mix deps.get
-
Prepare the Vault (Database)
-
Start the PostgreSQL database using Docker Compose (optional, you can connect to an existing database if you already have one):
docker-compose -f infra/docker-compose.yml up -d
-
Adjust the incantation in
config/dev.exs
if needed -
Create and migrate your vault:
mix ecto.setup
-
Launch your Cashubrew server with a single command:
mix phx.server
๐ Voilร ! Your mint is now live at http://localhost:4000
.
Interact with your Cashubrew instance using the Wallet CLI:
-
Mint Tokens
To mint 42 tokens:
mix run -e 'Cashubrew.Wallet.CLI.main(["mint", "42"])'
-
Check Balance
To view your current balance:
mix run -e 'Cashubrew.Wallet.CLI.main(["balance"])'
These commands allow you to interact with your Cashubrew instance directly from the command line, making it easy to test and manage your ecash transactions.
Harness the full power of Cashubrew by creating a production-ready release binary:
-
Craft the Magical Artifact
Invoke this powerful incantation to forge your release binary:
MIX_ENV=prod mix release
This spell will weave together all the necessary components, creating a self-contained magical artifact ready for deployment.
-
Unleash the Magic
To bring your Cashubrew release to life, chant the following:
SECRET_KEY_BASE=$(mix phx.gen.secret) \ DATABASE_URL="ecto://postgres:postgres@localhost/cashubrew_dev" \ _build/prod/rel/cashubrew/bin/cashubrew start
Adjust the
DATABASE_URL
as needed for your mystical realm.๐งโโ๏ธ Pro Tip: For enhanced security in production environments, avoid using default credentials. Craft unique incantations (environment variables) for each deployment.
-
Customizing Your Magical Realm
Fine-tune your Cashubrew instance by adjusting these mystic variables:
SECRET_KEY_BASE
: The secret key for your realm. Generate a new one for each deployment.DATABASE_URL
: The sacred text to connect to your data vault.PORT
: The gateway through which users will access your mint (default: 4000).
Example of a fully customized summoning:
SECRET_KEY_BASE=$(mix phx.gen.secret) \ DATABASE_URL="ecto://username:password@localhost/cashubrew_prod" \ PORT=8080 \ _build/prod/rel/cashubrew/bin/cashubrew start
May your Cashubrew instance thrive and bring forth a new era of magical transactions! ๐
- Test the Waters:
mix test
- Polish Your Code:
mix format
- Manage Your Vault:
- Create:
mix ecto.create
- Migrate:
mix ecto.migrate
- Reset:
mix ecto.reset
- Create:
- Run All Tests:
mix test
- Mock the Database:
To use a mock database for testing, set the
MOCK_REPO
environment variable:
MOCK_REPO=true mix test
- Test Coverage: Unveil the secrets of your test coverage:
MIX_ENV=test mix coveralls
For a detailed HTML report, cast this spell:
MIX_ENV=test mix coveralls.html
The mystical report will appear in cover/excoveralls.html
.
Ensure your code is top-notch with these magical incantations:
- Security Checks:
mix sobelow
- Elixir Best Practices:
mix credo
- Static Analysis:
mix dialyzer
Run these spells regularly to keep your code base clean and secure!
Sail the high seas with Cashubrew in a Docker container:
-
Build your ship:
docker build -t cashubrew:latest .
-
Set sail:
docker run \ --name cashubrew \ --network host \ -e DATABASE_URL="ecto://postgres:postgres@localhost/cashubrew_dev" \ -e SECRET_KEY_BASE=$(mix phx.gen.secret) \ -e PORT=4000 \ -e MIX_ENV=prod \ cashubrew:latest
Adjust the
DATABASE_URL
and other environment variables as needed for your voyage.
Peek behind the curtain at http://localhost:4000/dashboard
. Don't forget your secret key!
SECRET_KEY_BASE=$(mix phx.gen.secret) MIX_ENV=dev mix phx.server
๐ก Note: The dashboard is only available in the
dev
environment.
Rev up your engines:
mix bench
Here's a table of the currently supported mandatory NUTs:
NUT | Description | Supported |
---|---|---|
NUT-00 | Cryptography and Models | โ |
NUT-01 | Mint public keys | โ |
NUT-02 | Keysets and fees | โ |
NUT-03 | Swapping tokens | |
NUT-04 | Minting tokens | |
NUT-05 | Melting tokens | |
NUT-06 | Mint info | โ |
Here's a table of the currently supported optional NUTs:
NUT | Description | Supported |
---|---|---|
NUT-07 | Token state check | |
NUT-08 | Overpaid Lightning fees | |
NUT-09 | Signature restore | |
NUT-10 | Spending conditions | |
NUT-11 | Pay-To-Pubkey (P2PK) | |
NUT-12 | DLEQ proofs | |
NUT-13 | Deterministic secrets | |
NUT-14 | Hashed Timelock Contracts (HTLCs) | |
NUT-15 | Partial multi-path payments (MPP) | |
NUT-16 | Animated QR codes | |
NUT-17 | WebSocket subscriptions |
We're always looking for fellow wizards to join our quest. Check out our contribution guidelines and let's make magic together!
Cashubrew is released under the MIT License. See the LICENSE file for more details.
Thanks goes to these wonderful people (emoji key):
Aโฟdel โ/21M ๐ป |
MSG ๐ป |
Timothรฉe Delabrouille ๐ป |
Abdullah Al-Khulaifi ๐ป |
John Yellow ๐ป |
This project follows the all-contributors specification. Contributions of any kind welcome!