Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/keep-starknet-strange/cashubrew
Cashu Mint, written in Elixir.
https://github.com/keep-starknet-strange/cashubrew
bitcoin cashu cashubtc ecash elixir elixir-phoenix lightning-network
Last synced: 20 days ago
JSON representation
Cashu Mint, written in Elixir.
- Host: GitHub
- URL: https://github.com/keep-starknet-strange/cashubrew
- Owner: keep-starknet-strange
- License: mit
- Created: 2024-09-18T11:19:26.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2024-10-24T13:53:16.000Z (23 days ago)
- Last Synced: 2024-10-25T00:23:00.687Z (23 days ago)
- Topics: bitcoin, cashu, cashubtc, ecash, elixir, elixir-phoenix, lightning-network
- Language: Elixir
- Homepage: https://cashubrew.app
- Size: 798 KB
- Stars: 11
- Watchers: 1
- Forks: 8
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Contributing: docs/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# ๐ Cashubrew: Cashu Mint with Elixir Magic โจ
> ๐ก 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.
[Why Elixir ?](https://whyelixirlang.com/) - [Learn Elixir](https://elixir-lang.org/learning.html)
## ๐ Learn about Cashu
Before diving into Cashubrew, it's essential to understand Cashu.
Cashu is a free and open-source Chaumian ecash protocol built for [Bitcoin](https://bitcoin.org/bitcoin.pdf).
Essentially, it is a privacy-preserving ecash protocol that enables instant, nearly free, and private transactions.
To learn more about Cashu:
- ๐ [Cashu Specifications (NUTs)](https://cashubtc.github.io/nuts/): Dive deep into the technical details of the Cashu protocol.
- ๐ [Cashu Documentation](https://docs.cashu.space/): Comprehensive guide to understanding and implementing Cashu.
- ๐จ [Cashu Visual Explainer](https://lconf.gandlaf.com/): 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!
## ๐ Quick Start
Embark on your Cashubrew journey with these simple steps:
1. **Clone the Treasure Map**
```bash
git clone https://github.com/keep-starknet-strange/cashubrew.git
cd cashubrew
```2. **Summon the Dependencies**
```bash
mix deps.get
```3. **Prepare the Vault (Database)**
- Start the PostgreSQL database using Docker Compose (optional, you can connect to an existing database if you already have one):
```bash
docker-compose -f infra/docker-compose.yml up -d
```- Adjust the incantation in `config/dev.exs` if needed
- Create and migrate your vault:```bash
mix ecto.setup
```## ๐ญ Running the Show
Launch your Cashubrew server with a single command:
```bash
mix phx.server
```๐ Voilร ! Your mint is now live at `http://localhost:4000`.
## ๐งโโ๏ธ Wallet CLI Magic
Interact with your Cashubrew instance using the Wallet CLI:
1. **Mint Tokens**
To mint 42 tokens:
```bash
mix run -e 'Cashubrew.Wallet.CLI.main(["mint", "42"])'
```2. **Check Balance**
To view your current balance:
```bash
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.
## ๐ฎ Conjuring the Release Binary
Harness the full power of Cashubrew by creating a production-ready release binary:
1. **Craft the Magical Artifact**
Invoke this powerful incantation to forge your release binary:
```bash
MIX_ENV=prod mix release
```This spell will weave together all the necessary components, creating a self-contained magical artifact ready for deployment.
2. **Unleash the Magic**
To bring your Cashubrew release to life, chant the following:
```bash
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.
3. **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:
```bash
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! ๐
## ๐ ๏ธ Developer's Toolkit
- **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`### ๐งช Testing Magic
- **Run All Tests**: `mix test`
- **Mock the Database**:
To use a mock database for testing, set the `MOCK_REPO` environment variable:```bash
MOCK_REPO=true mix test
```- **Test Coverage**:
Unveil the secrets of your test coverage:```bash
MIX_ENV=test mix coveralls
```For a detailed HTML report, cast this spell:
```bash
MIX_ENV=test mix coveralls.html
```The mystical report will appear in `cover/excoveralls.html`.
### ๐ Code Quality and Security
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!
## ๐ณ Docker Deployment
Sail the high seas with Cashubrew in a Docker container:
1. **Build your ship**:
```bash
docker build -t cashubrew:latest .
```2. **Set sail**:
```bash
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.
## ๐ต๏ธ Phoenix Live Dashboard
Peek behind the curtain at `http://localhost:4000/dashboard`. Don't forget your secret key!
```bash
SECRET_KEY_BASE=$(mix phx.gen.secret) MIX_ENV=dev mix phx.server
```> ๐ก Note: The dashboard is only available in the `dev` environment.
## ๐๏ธ Turbocharge with Benchmarks
Rev up your engines:
```bash
mix bench
```## ๐งฉ Supported NUTs
Here's a table of the currently supported mandatory NUTs:
| NUT | Description | Supported |
| --------------------------------------------- | ----------------------- | --------- |
| [NUT-00](https://cashubtc.github.io/nuts/00/) | Cryptography and Models | โ |
| [NUT-01](https://cashubtc.github.io/nuts/01/) | Mint public keys | โ |
| [NUT-02](https://cashubtc.github.io/nuts/02/) | Keysets and fees | โ |
| [NUT-03](https://cashubtc.github.io/nuts/03/) | Swapping tokens | |
| [NUT-04](https://cashubtc.github.io/nuts/04/) | Minting tokens | |
| [NUT-05](https://cashubtc.github.io/nuts/05/) | Melting tokens | |
| [NUT-06](https://cashubtc.github.io/nuts/06/) | Mint info | โ |Here's a table of the currently supported optional NUTs:
| NUT | Description | Supported |
| --------------------------------------------- | --------------------------------- | --------- |
| [NUT-07](https://cashubtc.github.io/nuts/07/) | Token state check | |
| [NUT-08](https://cashubtc.github.io/nuts/08/) | Overpaid Lightning fees | |
| [NUT-09](https://cashubtc.github.io/nuts/09/) | Signature restore | |
| [NUT-10](https://cashubtc.github.io/nuts/10/) | Spending conditions | |
| [NUT-11](https://cashubtc.github.io/nuts/11/) | Pay-To-Pubkey (P2PK) | |
| [NUT-12](https://cashubtc.github.io/nuts/12/) | DLEQ proofs | |
| [NUT-13](https://cashubtc.github.io/nuts/13/) | Deterministic secrets | |
| [NUT-14](https://cashubtc.github.io/nuts/14/) | Hashed Timelock Contracts (HTLCs) | |
| [NUT-15](https://cashubtc.github.io/nuts/15/) | Partial multi-path payments (MPP) | |
| [NUT-16](https://cashubtc.github.io/nuts/16/) | Animated QR codes | |
| [NUT-17](https://cashubtc.github.io/nuts/17/) | WebSocket subscriptions | |## ๐ค Join the Cashubrew Community
We're always looking for fellow wizards to join our quest. Check out our [contribution guidelines](docs/CONTRIBUTING.md) and let's make magic together!
## ๐ License
Cashubrew is released under the MIT License. See the [LICENSE](LICENSE) file for more details.
## Contributors โจ
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Aโฟdel โ/21M
๐ป
MSG
๐ป
Timothรฉe Delabrouille
๐ป
Abdullah Al-Khulaifi
๐ป
John Yellow
๐ป
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!