Clementine is Citrea's BitVM-based, trust-minimized two-way peg program. This repository includes a CLI tool to interact with Clementine. For detailed usage and documentation, refer to this guide.
The current functionality of the CLI includes:
- Deposit (work in progress)
- Withdraw (fully functional)
- Deposit Reclaim (fully functional)
Deposit
Currently, the deposit operation is provided through a UI. The primary function is to communicate with a backend that generates a deposit address tied to the user's EVM address and initiates backend tasks for BitVM pre-signature collection.
In the future, we plan to migrate the deposit functionality into this CLI. The implementation is still work in progress.
Withdraw
The withdraw operation is fully functional via this CLI. Users can initiate a withdrawal from Clementine using two main parameters:
min-amount
: The minimum BTC amount the user wants to withdraw.precision
: The decimal precision for the withdrawal amount.
The program will start publishing withdrawal intents, beginning with 10 BTC and decreasing in equal steps defined by the precision parameter. If there is no response from the Citrea node, the program will cancel the operation at the specified minimum withdrawal amount.
Example:
A user runs the CLI with min-amount 9.995
and precision 0.001
. The CLI will publish withdrawal intents as follows:
- Request 10 BTC, if no response:
- Request 9.999 BTC, if no response:
- Request 9.998 BTC, if no response:
- Request 9.997 BTC, if no response:
- Request 9.996 BTC, if no response:
- Request 9.995 BTC, if no response:
- Cancel the operation if there is no response at 9.995 BTC.
Deposit Reclaim
The transaction can be generated using the deposit-reclaim
command. The program will generate the hex of the transaction to reclaim the deposit amount. This transaction then can be be broadcasted to the network. This operation does not require the Bitcoin Core to be running.
Example:
node ./deposit-reclaim.js \
--private-key YOUR_PRIVATE_KEY \
--address YOUR_BTC_ADDRESS \
--evm-address YOUR_EVM_ADDRESS \
--txid DEPOSIT_TXID \
--vout DEPOSIT_TX_VOUT \
--amount DEPOSIT_TX_AMOUNT \
--fee FEE_AMOUNT (optional)
Before running the CLI, ensure you have the following prerequisites:
You may follow the instructions specific to your operating system to install prerequisites:
See the official Bitcoin Core installation guide for detailed instructions.
sudo apt update
sudo apt install nodejs npm
brew install node
Download and install Node.js from the official website.
Clone this repository and install the dependencies:
npm install
Before running the CLI, you need to configure the config.json
. Copy the config.example.json
file and update as needed:
cp config.example.json config.json
Then, run the CLI with the following command to initiate a withdrawal with default parameters (min-amount 9.99 and precision 0.001):
./clementine-cli.js withdraw \
--withdrawal-address YOUR_BTC_ADDRESS
Alternatively, you can specify the min-amount
and precision
parameters:
./clementine-cli.js withdraw \
--withdrawal-address YOUR_BTC_ADDRESS \
--min-withdrawal-amount 9.995 \
--precision 0.001
- This CLI interacts with your local Bitcoin Core wallet. The wallet will receive the funds after the withdrawal is processed.
- Use a local and secure Bitcoin Core node for the withdrawal process to ensure the safety of your funds.
- While you can use any Citrea RPC endpoint, the funds are controlled locally by the provided private key.