Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Latest commit

 

History

History
295 lines (198 loc) · 13 KB

README.md

File metadata and controls

295 lines (198 loc) · 13 KB

🌟 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 ? - Learn Elixir

📚 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.

Essentially, it is a privacy-preserving ecash protocol that enables instant, nearly free, and private transactions.

To learn more about Cashu:

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

    git clone https://github.com/keep-starknet-strange/cashubrew.git
    cd cashubrew
  2. Summon the Dependencies

    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):

      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

🎭 Running the Show

Launch your Cashubrew server with a single command:

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:

    mix run -e 'Cashubrew.Wallet.CLI.main(["mint", "42"])'
  2. 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.

🔮 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:

    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:

    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:

    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:
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.

🔍 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:

    docker build -t cashubrew:latest .
  2. 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.

🕵️ Phoenix Live Dashboard

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.

🏎️ Turbocharge with Benchmarks

Rev up your engines:

mix bench

🧩 Supported NUTs

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

🤝 Join the Cashubrew Community

We're always looking for fellow wizards to join our quest. Check out our contribution guidelines and let's make magic together!

📜 License

Cashubrew is released under the MIT License. See the LICENSE file for more details.

Contributors ✨

Thanks goes to these wonderful people (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 specification. Contributions of any kind welcome!