Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

Awesome Lists containing this project

README

        

cashubrew-logo

GitHub Workflow Status
Elixir
Bitcoin
Bitcoin Lightning

# ๐ŸŒŸ 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
Aโ‚ฟdel โˆž/21M

๐Ÿ’ป
MSG
MSG

๐Ÿ’ป
Timothรฉe Delabrouille
Timothรฉe Delabrouille

๐Ÿ’ป
Abdullah Al-Khulaifi
Abdullah Al-Khulaifi

๐Ÿ’ป
John Yellow
John Yellow

๐Ÿ’ป

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!