Skip to content

keep-starknet-strange/cashubrew

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

90 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒŸ 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!