A plugin for running a mint right on your node!
This project is nixified, so first make sure you have nix installed and experimental features turned on so that you can use the nix develop
command.
Once nix is installed, clone the repo and inside the project directory run:
nix develop
The first time you run this expect to wait for everthing to download/build.
Now, you have bitcoin and lightning nodes, all the required packages, and shell variables defined!
Source the startup_regtest.sh
script and then start 2 nodes.
source ./startup_regtest.sh
start_ln #default is 2 nodes
The fund_nodes
function comes from the startup script and requires that all your nodes are running.
This function first checks to make sure your bitcoind wallet is funded, then sends coins to your lightning nodes, and finally opens a channel from node 1 to node 2.
fund_nodes
The restart_plugin.sh
script takes an optional argument to specify which node you want to start the plugin on.
./restart_plugin.sh 1 #start the plugin on node 1
NOTE: any changes to your plugin will require you to re run this script.
Right now, there is a lot of scratch in the notebooks. Check out the mint_melt.ipynb and swap.ipynb notebooks to see a the flow of minting, melting, and swapping tokens.
Assuming you got the environment set up right with nix these two notebooks should run all the way through!
Sometimes the node directories ends up in a bad state and things break... use the
stop_ln
thendestroy_ln
functions fromstartup_regtest.sh
(or delete your node directories) to reset.
The RPC commands exposed by this plugin match each of the routes defined in the cashu spec.
For now, refer to the above notebooks on how to use these commands.
Below is the summary of each method defined in the provided code, formatted in markdown as requested:
- Route:
GET /keys
- Summary: Returns the public keyset of the mint.
- Routes:
GET /keysets
&GET /keyset/{keysetId}
- Summary: Returns all or a specific keyset of the mint. Currently, it only supports returning the mint's primary keyset.
- Summary: Retrieves the mint's private keys. This method exposes the private keys from the mint's keyset, formatted for external use. This method is development use only.
- Route:
POST /v1/mint/quote/bolt11
- Summary: Returns a quote for minting tokens. It generates a quote, and creates an invoice for the requested amount.
- Route:
GET /v1/mint/quote/bolt11/{quote_id}
- Summary: Checks the status of a quote request for minting tokens. It finds the invoice associated with the quote and returns the quote's status, including whether it has been paid.
- Route:
POST /v1/mint/bolt11
- Summary: Returns blinded signatures for blinded messages once a quote request is paid. It verifies the quote's payment status, validates the requested amount, and issues blinded signatures if the conditions are met.
- Route:
POST /v1/melt/quote/bolt11
- Summary: Returns a quote for melting tokens.
- Route:
GET /v1/melt/quote/bolt11/{quote_id}
- Summary: Checks the status of the invoice associated with the melt quote.
- Route:
POST /v1/melt/bolt11
- Summary: Processes melting tokens into a payment. It verifies the quote and the sum of input amounts, validates the inputs, and executes a payment if all conditions are met, marking tokens as spent.
- Route:
POST /v1/swap
- Summary: Swaps tokens for other tokens. It validates the total amounts of inputs and outputs are equal, checks the inputs, creates blinded signatures for the outputs, and marks the input tokens as spent.