Skip to content

Commit 463ccec

Browse files
committed
Squashed commit of the following:
commit 0cbe387 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Wed Sep 3 12:22:41 2025 +0300 feat(docs/deposit): Add broadcast recovery TX steps. commit e4e62d5 Merge: 6aa6e65 6ba26aa Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Wed Sep 3 11:47:12 2025 +0300 Merge branch 'main' into ceyhun/broadcast-tx commit 6aa6e65 Merge: 304bb58 439a761 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Wed Sep 3 11:43:18 2025 +0300 Merge branch 'cli-rust-rewrite' into ceyhun/broadcast-tx commit 439a761 Author: Ekrem BAL <mail.ekrembal@gmail.com> Date: Wed Sep 3 11:28:46 2025 +0300 Update aggregated_public_key in bridge_cli_config.toml for testnet4 (#89) Co-authored-by: Ceyhun Şen <ceyhuusen@gmail.com> commit 304bb58 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Tue Sep 2 17:50:27 2025 +0300 chore: Spelling. commit 7fda14c Merge: 2127d56 66de77d Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Tue Sep 2 17:49:13 2025 +0300 Merge branch 'cli-rust-rewrite' into ceyhun/broadcast-tx commit 66de77d Author: Ahmet Oguz Engin <85455415+aoengin@users.noreply.github.com> Date: Tue Sep 2 17:48:52 2025 +0300 Add Deposit Message (#92) * fix: enhance deposit address output with bold formatting and additional info message * feat: add command example for sending BTC to deposit address commit 2127d56 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Tue Sep 2 17:48:36 2025 +0300 fix: Clippy. commit 18c1b25 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Tue Sep 2 17:43:23 2025 +0300 feat: Implement CLI interface. commit 425d918 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Tue Sep 2 17:29:24 2025 +0300 fix: Revert merge errors. commit e0d8081 Merge: 0f6fd28 12c7b91 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Tue Sep 2 17:19:50 2025 +0300 Merge branch 'cli-rust-rewrite' into ceyhun/broadcast-tx commit 0f6fd28 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Tue Sep 2 17:12:27 2025 +0300 feat: Implement broadcast_recovery_tx_with_mempool. commit 12c7b91 Author: Ahmet Oguz Engin <85455415+aoengin@users.noreply.github.com> Date: Tue Sep 2 16:39:59 2025 +0300 Bug Bash Fixes (#83) * fix: update print_all_wallets_with_addresses to filter by network and sort by "create_at" * fix: refactor print_all_wallets_with_addresses to remove network parameter and improve wallet listing * fix: update sign_recovery_tx to require non-optional fee_rate and amount parameters * fix: reorder evm_address in VerifyRecoveryTx command for consistency * fix: reorder citrea_address in DepositCommands for consistency * feat: add UTXO handling from mempool API and improve deposit status reporting * remove global network argument and add only to necessary subcommands * fix: update withdrawal instructions to display amount in bitcoins * fix: enhance error reporting * refactor: replace hardcoded prefixes with constants in Purpose enum * fix: validate claim and withdrawal addresses before processing * fmt * fix: update error handling for invalid purpose to use more descriptive prefix error * feat: implement DepositStatusEnum for better status handling in deposits * fix: update DepositStatusEnum string representation for consistency * fix: sort UTXOs by transaction ID before processing withdrawals * fix: enhance UTXO handling by filtering for specific amounts and adding warnings for discrepancies * fix: add security notice for unique signer address in withdrawal operations * refactor: improve deposit status output formatting and add refund message handling * feat: add optimistic withdrawal amount to configuration and update withdrawal signature commands * fix: improve display formatting for DepositStatus by handling empty fields * refactor: streamline deposit status handling and improve refund message logic * fix: update refund message logic in deposit status to handle different cases * fmt * fix: rename optimistic_withdrawal_amount to operator_withdrawal_amount for consistency * feat: add optimistic_withdrawal_amount to configuration and update withdrawal command logic * fix: ensure wallet exists before creating signed recovery transaction * fmt * fix: update withdrawal amount display from sats to btc for clarity * fix: refactor should_not_have_purpose function for improved clarity and accessibility * fix: update wallet list command documentation to include networks * fix: rename mempool API functions to reflect updated naming convention * fix: refactor withdrawal scanning logic into cli_scan_withdrawals function for improved readability and maintainability * fmt + clippy commit 81dc3ef Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Tue Sep 2 15:34:42 2025 +0300 feat: Add initial broadcast_recovery_tx. commit c7b03fd Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Tue Sep 2 15:34:23 2025 +0300 fix: Check for trailing slashes in config. commit 23769b6 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Tue Sep 2 15:32:11 2025 +0300 chore: Get keypair outside of deposit_create_signed_recovery_tx. commit 3f9dc39 Author: Ozan Kaymak <92448699+ozankaymak@users.noreply.github.com> Date: Mon Sep 1 17:13:49 2025 +0300 Wallet documentation, address check beforehand (#84) * Documentation * Add address check before deposit and withdrawal start steps * Add error for missing Purpose prefix in Taproot address validation * Add missing command docs * Refactor display message * Refactor PurposeMismatch error handling to use named fields for clarity * Clearer println * Better UX with better next step prompts * Refactor withdrawal and deposit commands to use UTXO outpoints instead of txid and vout * Review changes * Copilot review changes * Fix withdrawal status response parsing * Small fix * Small fix * Update documentation and CLI commands for deposit and withdrawal processes * Add caution note to save generated withdrawal signature for future authorization * Remove address_exists check for online device * fmt commit 4ca7de1 Merge: 179fefd 5fed1f5 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Fri Aug 29 14:07:32 2025 +0300 Merge pull request #82 from chainwayxyz/ekrem/fix-get-tx-details Fix get tx details commit 5fed1f5 Merge: af94469 179fefd Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Fri Aug 29 14:05:07 2025 +0300 Merge branch 'cli-rust-rewrite' into ekrem/fix-get-tx-details commit 179fefd Merge: a9d46a1 f475f98 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Fri Aug 29 14:04:59 2025 +0300 Merge pull request #72 from chainwayxyz/ceyhun/doc_recovery_tx Recovery tx documentation commit af94469 Author: Ekrem BAL <mail.ekrembal@gmail.com> Date: Fri Aug 29 13:02:04 2025 +0300 fix lint commit d6fd43a Merge: 7821f48 a9d46a1 Author: Ekrem BAL <mail.ekrembal@gmail.com> Date: Fri Aug 29 12:58:04 2025 +0300 Merge branch 'cli-rust-rewrite' into ekrem/fix-get-tx-details commit 7821f48 Author: Ekrem BAL <mail.ekrembal@gmail.com> Date: Fri Aug 29 12:57:28 2025 +0300 Fix get tx details commit f475f98 Merge: caf81d0 a9d46a1 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Thu Aug 28 18:28:23 2025 +0300 Merge branch 'cli-rust-rewrite' into ceyhun/doc_recovery_tx commit a9d46a1 Merge: f84a3f4 a9d070a Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Thu Aug 28 18:28:14 2025 +0300 Merge pull request #71 from chainwayxyz/ozan/hot-fixes-v2 Fix mempool api url commit caf81d0 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Thu Aug 28 18:24:21 2025 +0300 docs: Add recovery tx steps. commit 59c4647 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Thu Aug 28 18:24:06 2025 +0300 chore: Rename sign_recovery_tx. commit a9d070a Author: ozankaymak <ozan.kaymak@boun.edu.tr> Date: Thu Aug 28 17:02:02 2025 +0300 Fix mempool api url commit f84a3f4 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Thu Aug 28 14:59:09 2025 +0300 fix: mempool_api_url. commit 9b41e01 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Thu Aug 28 14:55:51 2025 +0300 fix: Config and docs. commit 83d672a Author: Ozan Kaymak <92448699+ozankaymak@users.noreply.github.com> Date: Thu Aug 28 14:49:31 2025 +0300 Ozan/hot fixes v1 (#70) * Fix prompt message for withdrawal * Format prompt message commit 6fbb233 Author: Ahmet Oguz Engin <85455415+aoengin@users.noreply.github.com> Date: Thu Aug 28 14:47:51 2025 +0300 Implement Remaining Deposit & Withdrawal Operations (#68) * Add deposit status functionality and refactor related components * Enhance deposit status output with informative messages for empty results * Implement withdrawal status and send signature (#69) * Implement withdrawal status and send signature * Refactor serde imports for DepositStatus and WithdrawalStatus structs * Use amount for signature sending * Enhance withdrawal status output with empty state handling and improved messaging --------- Co-authored-by: aoengin <ahmetoguzengin@hotmail.com> --------- Co-authored-by: Ozan Kaymak <92448699+ozankaymak@users.noreply.github.com> commit 2b2579a Author: ozankaymak <ozan.kaymak@boun.edu.tr> Date: Thu Aug 28 12:40:05 2025 +0300 Fix signet aggregated_public_key to correct value commit eec7866 Author: Ozan Kaymak <92448699+ozankaymak@users.noreply.github.com> Date: Thu Aug 28 12:39:03 2025 +0300 Implement Start and Scan commands for withdrawal (#66) * Add withdrawal commands for starting and scanning withdrawals * Remove bitcoin-core rpc method * Implement fallback mechanism for UTXO retrieval using mempool API and Bitcoin RPC * fmt * eprintln --------- Co-authored-by: Ahmet Oguz Engin <85455415+aoengin@users.noreply.github.com> commit 9ed8bd6 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Thu Aug 28 12:34:20 2025 +0300 Initial README and docs (#67) * feat: Add initial docs. * chore: Remove todos. * docs: Fix bin name. * feat: Add CalculatedRecoveryTaprootAddressMismatch. * fix: Missing dir creation. * fix: Clippy. commit 8da4e6b Author: Ahmet Oguz Engin <85455415+aoengin@users.noreply.github.com> Date: Thu Aug 28 12:23:09 2025 +0300 CLI and Wallet Refactor (#65) * Refactor wallet management by removing delete_wallet function * remove delete - refactor wallet functions and cli * Refactor wallet module exports to include scan_wallet_files and get_registry_wallet_set * fmt * Refactor wallet creation to securely display mnemonic after wallet creation commit 22891e2 Author: Ozan Kaymak <92448699+ozankaymak@users.noreply.github.com> Date: Wed Aug 27 14:15:23 2025 +0300 Refactor deposit and withdrawal logic to use structured types for add… (#64) * Refactor deposit and withdrawal logic to use structured types for addresses and improve function signatures * Fix prompt message formatting in delete_wallet function --------- Co-authored-by: aoengin <ahmetoguzengin@hotmail.com> commit 4e74595 Author: Ozan Kaymak <92448699+ozankaymak@users.noreply.github.com> Date: Wed Aug 27 12:24:51 2025 +0300 Refactor printlns (#62) * refactor: replace handle_or_exit with print_or_exit in wallet commands and update return types for wallet functions * Move to main.rs, refactor, update visibility * refactor: enhance wallet and deposit operations, update visibility of functions * WIP merge * Fix merge errors * Refactor wallet functions to improve mnemonic handling and update return types * Refactor wallet and withdrawal logic to improve error handling and streamline user prompts * Add universal CLI command handler macro for improved error handling and convenience * Rename get_all_wallets_with_addresses to print_all_wallets_with_addresses commit a92572d Author: Ahmet Oguz Engin <85455415+aoengin@users.noreply.github.com> Date: Tue Aug 26 17:35:29 2025 +0300 Update Wallet Addresses (#63) * update wallet commands to use labels instead of names - replace wallet name with address to map wallets * fmt * refactor: move get_registry_wallet_set function to wallet_storage module * feat: enhance wallet functionality with address validation and secure passphrase prompts * feat: Enhance wallet address handling with TaprootAddressWithPrefix struct * fmt + clippy * feat: add 'wit' to codespell ignore list * feat: enhance deposit command to serialize and encode recovery transaction * fix: reorder imports for clarity in wallet_storage.rs commit 8d072b4 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Tue Aug 26 17:21:09 2025 +0300 Multiple network config file (#59) * feat: Add multiple networks to config file. * feat: Add try_parse_config, which will check for 3 places for config. * fix: testnet4 instead of testnet and fix typo. commit 5b74a4a Author: Ozan Kaymak <92448699+ozankaymak@users.noreply.github.com> Date: Mon Aug 25 15:05:31 2025 +0300 CLI improvements (#54) * feat: Better response for wallets imported from private keys for show-mnemonic * Check claim address not in the wallet and some refactor * Small refactor, remove length req. for passphrase * Fix clippy * Small refactor * refactor: restructure wallet integrity verification and improve registry handling * Delete unnecessary import * refactor: streamline wallet management by removing unused imports and enhancing address validation * fmt * refactor: remove empty passphrase error handling from prompt functions * refactor: update address generation to return BitcoinAddress type and improve mnemonic validation * refactor: simplify wallet integrity reporting commit 26295a7 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Mon Aug 25 12:27:40 2025 +0300 Println removal from lib modules and tracing support (#52) * fix: getdepositaddress async bug. * feat: Add verbose flag. * chore: Convert old debugs to tracing. * feat: Get agg xpk instead of verifier pks. * feat: Deposit commands returns values. * chore: Convert withdrawal fns to returning. * fix: Config file test. * fix-chore: devnet deposit address checks. * feat: Add additional devnet config. * chore: Remove old debug_colored macro. * feat: Add version flag. * fix: Compilation. * Fix POST request field * chore: Remove old todos * fix: Compilation. * chore: Add older deployment values. --------- Co-authored-by: ozankaymak <ozan.kaymak@boun.edu.tr> commit 7d4374b Merge: 746b34e cad08c9 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Mon Aug 25 12:22:16 2025 +0300 Merge pull request #51 from chainwayxyz/oguz/small-updates Enhance CLI with Minor Improvements commit cad08c9 Author: aoengin <ahmetoguzengin@hotmail.com> Date: Mon Aug 25 11:47:37 2025 +0300 remove SecureMnemonic wrapper commit aceeda0 Author: aoengin <ahmetoguzengin@hotmail.com> Date: Mon Aug 25 00:12:36 2025 +0300 refactor: streamline wallet management by centralizing wallet file operations and enhancing error handling commit f33abb0 Author: aoengin <ahmetoguzengin@hotmail.com> Date: Sat Aug 23 21:09:33 2025 +0300 refactor: enhance mnemonic security by using SecureString for phrase handling and validation commit f8453ea Author: aoengin <ahmetoguzengin@hotmail.com> Date: Sat Aug 23 20:54:29 2025 +0300 fmt commit 177c4b5 Author: aoengin <ahmetoguzengin@hotmail.com> Date: Sat Aug 23 20:54:18 2025 +0300 refactor: replace Keypair and SecretKey with SecureKeypair and SecureSecretKey for enhanced security across wallet operations commit 18abb9f Author: aoengin <ahmetoguzengin@hotmail.com> Date: Fri Aug 22 18:24:25 2025 +0300 fmt commit 0194987 Author: aoengin <ahmetoguzengin@hotmail.com> Date: Fri Aug 22 18:22:47 2025 +0300 refactor: update wallet storage to use WalletRegistryEntry for better type safety commit 782489c Author: aoengin <ahmetoguzengin@hotmail.com> Date: Fri Aug 22 18:10:12 2025 +0300 feat: enhance wallet validation by introducing validation modes for name and address checks commit 9e378e7 Author: aoengin <ahmetoguzengin@hotmail.com> Date: Fri Aug 22 17:52:51 2025 +0300 fix: improve error handling output by simplifying error reporting commit dd2a779 Author: aoengin <ahmetoguzengin@hotmail.com> Date: Fri Aug 22 17:33:47 2025 +0300 refactor: remove backtrace enabling code for cleaner error handling commit b40e788 Author: aoengin <ahmetoguzengin@hotmail.com> Date: Fri Aug 22 17:12:51 2025 +0300 fmt commit 8ad6748 Author: aoengin <ahmetoguzengin@hotmail.com> Date: Fri Aug 22 16:59:55 2025 +0300 clippy + fmt commit 56128ab Author: aoengin <ahmetoguzengin@hotmail.com> Date: Fri Aug 22 16:33:08 2025 +0300 feat: add wallet availability validation to prevent duplicate names and addresses commit 4858a6f Author: aoengin <ahmetoguzengin@hotmail.com> Date: Fri Aug 22 14:51:19 2025 +0300 fix: update color-eyre dependency to version 0.6.5 commit 42bce65 Author: aoengin <ahmetoguzengin@hotmail.com> Date: Fri Aug 22 14:48:07 2025 +0300 feat: add color-eyre for enhanced error reporting and backtrace support commit a73ab25 Author: aoengin <ahmetoguzengin@hotmail.com> Date: Fri Aug 22 14:34:32 2025 +0300 fix: improve error message formatting and remove redundant field from wallet registry commit 746b34e Author: atacann <111396231+atacann@users.noreply.github.com> Date: Fri Aug 22 13:16:20 2025 +0200 Remove bitcoin rpc port (#36) * remove bitcoin url port, use reqwest url joins * use Url type in config * add / to default urls * update test config * Update Cargo.lock --------- Co-authored-by: Ekrem BAL <mail.ekrembal@gmail.com> commit 984b167 Author: Ahmet Oguz Engin <85455415+aoengin@users.noreply.github.com> Date: Fri Aug 22 14:10:35 2025 +0300 New Wallet Commands (#40) * Add export private key and list stored keys commands * WIP * Use alloy::primitives::Address instead of manual impl * Remove unused import and add logging for checksummed Citrea address in get_deposit_address function * feat: Add initial CI/CD. * feat: Add code checks CI/CD * fix: Tests. * chore: Remove some of the todos and fix codespell. * chore: Remove more todos. * fix: Clippy. * chore: vers * fix: Specify toolchain. * fix clippy * Configuration struct and file (#24) * feat: Add initial CliConfig. * feat: Add parse from file. * feat: Add from_network to config. * feat: Pass config to some deposit functions. * fix: Compilation. * chore: Pass config to functions those use from_network. * chore: Remove old constants. * feat: Add BitcoinConfig. * feat: Replace network with config file. * feat: Add the optional bitcoin_config to test config. * fix: Remove todo. * Use values in config (#29) * feat: Add initial CliConfig. * feat: Add parse from file. * feat: Add from_network to config. * feat: Pass config to some deposit functions. * fix: Compilation. * chore: Pass config to functions those use from_network. * chore: Remove old constants. * feat: Add BitcoinConfig. * init * fix issues * fix issues * fix params --------- Co-authored-by: Ceyhun Şen <ceyhuusen@gmail.com> * feat: Implement secure key storage with encryption - Added AES-256-GCM encryption for private keys using Argon2id for key derivation. - Introduced SecureString and DerivedKey wrappers for sensitive data management. - Updated `store_key` and `load_key` functions to handle encrypted keys. - Implemented passphrase prompts for key encryption and decryption. - Enhanced tests for key storage, encryption, and decryption workflows. - Updated dependencies in Cargo.toml for cryptographic operations. * fix: Update test cases to use Testnet4 network for taproot address calculations * test: Refactor tests to use temporary directories for key storage and cleanup * test: Refactor tests to use tempfile for temporary directories * update testnet to testnet4 * fix: Update thiserror dependency to version 2.0.14 and add dirs dependency * fix: Revert Rust toolchain channel to 1.88 and update deposit command to use config.network * test: Remove redundant test for key and taproot address generation * WIP Use alternate screen for mnemonic display * refactor: Clean up code formatting and improve readability in various files * Fix clippy * Fix clippy * refactor: Restructure CLI commands for wallet operations and enhance mnemonic generation functionality * WIP * feat: Add wallet backup functionality and list available wallets * feat: Implement wallet import functionality from file, mnemonic, and private key * feat: Implement wallet management features including import, delete, and integrity verification * WIP * Standardize error handling * Refactor wallet import functionality and enhance mnemonic handling - Renamed `import_wallet_with_mnemonic` to `import_wallet_from_mnemonic` for clarity. - Introduced `ImportFromFile` command to handle wallet imports from files. - Updated `import_wallet_from_mnemonic` to securely collect mnemonic input word by word. - Added passphrase confirmation step during wallet import for enhanced security. - Implemented AES-256-GCM encryption for both mnemonic and private key storage. - Removed deprecated functions related to mnemonic import from file. - Improved error handling and user feedback during wallet import processes. - Updated tests to reflect changes in mnemonic import functionality. * Remove unncessary code pieces and add new cli commands * refactor: Simplify wallet integrity checks and enhance error messages for existing wallet scenarios * refactor: Replace std::io::Error with anyhow::Error for improved error handling in configuration and wallet functions * refactor: Improve decryption error message for clarity on password issues * refactor: Update dependencies and improve random number generation in encryption and mnemonic handling * refactor: Code formatting, remove passphrase req. when deleting, add docs for passphrase and encryption * refactor: Update encryption method to aes256_gcm_argon2id_secure in wallet storage and tests * Fix clippy * Remove example wallet file * feat: Add support for 'testnet4' network in parse_network function * remove unneccesary emojies * copilot recommendations * switch from anyhow to eyre * fix: Refactor address extraction and input handling for clarity and correctness - ci * cargo.lock * Enhance secure display functionality and wallet management - Implemented a secure display manager for private keys, allowing for secure viewing with timeouts and user confirmations. - Refactored the secure display for mnemonics to improve readability and maintainability, including better error handling and user prompts. - Updated wallet deletion functionality to use wallet names instead of addresses for clarity. - Improved wallet import and export functions to support custom filenames and enhanced error messages. - Adjusted tests to focus on valid 12-word BIP-39 mnemonics and updated comments for clarity. * use BridgeCliError * fmt * clippy * update toolchain version to use latest nightly * refactor: enhance error handling by including error messages in BridgeCliError variants * fmt * remove todo * fix: correct wallet name reference in error handling and improve error messages * refactor: simplify passphrase validation logic by removing max attempts tracking * refactor: streamline wallet import functions and enhance wallet name handling * clippy * remove duplicate * chore: update dependencies and fix import paths for alloy types * update function and file visibilities * fmt * feat: add example bridge CLI configuration file * feat: add passphrase confirmation option in prompt_passphrase function * fix: update test configuration file path for bridge CLI tests * fix: remove unused getrandom import in encryption module * refactor: replace get_validated_passphrase with prompt_passphrase for consistency * clippy + fmt * fix: remove unused tempfile dependency * refactor all the code + change withdrawal and deposit methods so they use new wallet methods * move wallet functionality into dedicated module * fix: change network configuration from signet to regtest * fix: improve error handling for config file parsing * fix: enhance error messages for config file parsing * refactor: rename wallet command variants for consistency * Fix clippy * fix: improve error messages for transaction hex fetching in withdrawal logic * Redirect to withdrawal UI page (#10) * Redirect user to withdrawal UI URL at citrea.xyz * Update query params * fix: Compilation. * fix: URL opening. * fix: Testnet URL. * chore: Clippy. * Use pub(crate) on Citrea structs * fix: Query params. * Fix withdrawal ui calldata (#49) * Fix merge conflict * revert config to old values --------- Co-authored-by: Ceyhun Şen <ceyhuusen@gmail.com> Co-authored-by: Ekrem BAL <mail.ekrembal@gmail.com> --------- Co-authored-by: ozankaymak <ozan.kaymak@boun.edu.tr> Co-authored-by: Ceyhun Şen <ceyhuusen@gmail.com> Co-authored-by: atacann <atacaniyidogan@gmail.com> Co-authored-by: atacann <111396231+atacann@users.noreply.github.com> Co-authored-by: Ozan Kaymak <92448699+ozankaymak@users.noreply.github.com> Co-authored-by: kalyberk <31245745+kalyberk@users.noreply.github.com> Co-authored-by: Ekrem BAL <mail.ekrembal@gmail.com> commit e2cfede Merge: 50e77c3 3890d81 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Wed Aug 20 15:32:14 2025 +0300 Merge pull request #28 from chainwayxyz/ceyhun/eyre Eyre support and BridgeCliError commit 3890d81 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Wed Aug 13 17:56:45 2025 +0300 chore: Rename bridge cli config. (#30) commit 3f00b0e Merge: f091bdd 50e77c3 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Wed Aug 13 16:07:44 2025 +0300 Merge branch 'cli-rust-rewrite' into ceyhun/eyre commit f091bdd Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Wed Aug 13 16:03:46 2025 +0300 chore: Rename bridge cli error. commit 3ab2652 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Wed Aug 13 16:03:24 2025 +0300 chore: Convert rest to the CliError. commit 9e8ebec Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Wed Aug 13 15:39:20 2025 +0300 chore: Rename cli error. commit d865c24 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Wed Aug 13 15:38:56 2025 +0300 feat: Convert bitcoin errors to clierror. commit 5fb3bc8 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Wed Aug 13 15:25:52 2025 +0300 feat: Merge backend errors to CliError. commit 6caaaae Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Wed Aug 13 15:14:34 2025 +0300 feat: Seperate error for config. commit 50e77c3 Author: atacann <111396231+atacann@users.noreply.github.com> Date: Wed Aug 13 13:38:32 2025 +0200 Use values in config (#29) * feat: Add initial CliConfig. * feat: Add parse from file. * feat: Add from_network to config. * feat: Pass config to some deposit functions. * fix: Compilation. * chore: Pass config to functions those use from_network. * chore: Remove old constants. * feat: Add BitcoinConfig. * init * fix issues * fix issues * fix params --------- Co-authored-by: Ceyhun Şen <ceyhuusen@gmail.com> commit 6965791 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Wed Aug 13 14:36:34 2025 +0300 feat: Add initial errors module. commit 828c8a7 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Wed Aug 13 12:35:41 2025 +0300 fix: Convert configs to eyre also. commit a9bdb6a Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Wed Aug 13 12:27:19 2025 +0300 feat: Convert rest of the boxed errors to eyre. commit c081dcd Merge: 846c262 32ab9e1 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Wed Aug 13 12:20:56 2025 +0300 Merge branch 'cli-rust-rewrite' into ceyhun/eyre commit 846c262 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Wed Aug 13 12:08:41 2025 +0300 feat: First batch of eyre. commit 32ab9e1 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Wed Aug 13 11:57:42 2025 +0300 Configuration struct and file (#24) * feat: Add initial CliConfig. * feat: Add parse from file. * feat: Add from_network to config. * feat: Pass config to some deposit functions. * fix: Compilation. * chore: Pass config to functions those use from_network. * chore: Remove old constants. * feat: Add BitcoinConfig. * feat: Replace network with config file. * feat: Add the optional bitcoin_config to test config. * fix: Remove todo. commit 32e79a3 Merge: 33b4bbd 05c18e3 Author: Ozan Kaymak <92448699+ozankaymak@users.noreply.github.com> Date: Wed Aug 13 11:44:57 2025 +0300 Merge pull request #25 from chainwayxyz/ozan/use-alloy-addr Use alloy::primitives::Address instead of manual implementation commit 05c18e3 Author: atacann <atacaniyidogan@gmail.com> Date: Wed Aug 13 10:36:40 2025 +0200 fix clippy commit 2e8dfa7 Merge: e0ce54b 33b4bbd Author: ozankaymak <ozan.kaymak@boun.edu.tr> Date: Wed Aug 13 11:07:37 2025 +0300 Merge branch 'cli-rust-rewrite' into ozan/use-alloy-addr commit e0ce54b Author: ozankaymak <ozan.kaymak@boun.edu.tr> Date: Tue Aug 12 17:22:49 2025 +0300 Remove unused import and add logging for checksummed Citrea address in get_deposit_address function commit 33b4bbd Merge: 7bd7b25 33c9dbc Author: atacann <111396231+atacann@users.noreply.github.com> Date: Tue Aug 12 15:38:38 2025 +0200 Merge pull request #20 from chainwayxyz/ceyhun/initial_ci_cd Initial CI/CD jobs commit eb41762 Author: ozankaymak <ozan.kaymak@boun.edu.tr> Date: Tue Aug 12 16:03:16 2025 +0300 Use alloy::primitives::Address instead of manual impl commit 33c9dbc Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Tue Aug 12 14:55:30 2025 +0300 fix: Specify toolchain. commit db5147f Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Tue Aug 12 14:48:25 2025 +0300 chore: vers commit 3fbccad Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Tue Aug 12 11:53:30 2025 +0300 chore: Convert todo to issue. commit 0b70a38 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Tue Aug 12 11:50:13 2025 +0300 fix: Clippy. commit 1e9180d Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Tue Aug 12 11:32:39 2025 +0300 chore: Remove more todos. commit c540a00 Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Tue Aug 12 11:28:39 2025 +0300 chore: Remove some of the todos and fix codespell. commit 59b062d Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Mon Aug 11 16:48:30 2025 +0300 fix: Tests. commit 43323fd Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Mon Aug 11 16:41:59 2025 +0300 feat: Add code checks CI/CD commit e58e6ca Author: Ceyhun Şen <ceyhuusen@gmail.com> Date: Mon Aug 11 16:40:18 2025 +0300 feat: Add initial CI/CD. commit 7bd7b25 Author: Ekrem BAL <mail.ekrembal@gmail.com> Date: Thu Aug 7 11:38:27 2025 -0400 Ekrem/add depoist params generation (#11) * Add deposit params getting * Use our async fork * use BE flag * Add safe withdrawal with secret key * Implement withdrawal signing * Update withdrawal signature sequence to enable RBF without locktime * update verification * fix sequence in safe withdrawal params as well * Don't enforce taproot on withdrawal address * update parsing --------- Co-authored-by: aoengin <ahmetoguzengin@hotmail.com> commit a374747 Author: Ekrem BAL <mail.ekrembal@gmail.com> Date: Wed Jul 30 10:26:09 2025 -0400 Address comments commit 50eec9b Author: Ekrem BAL <mail.ekrembal@gmail.com> Date: Mon Jul 28 15:31:20 2025 -0400 Update src/bitcoin_utils.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> commit 7301254 Author: Ekrem BAL <mail.ekrembal@gmail.com> Date: Mon Jul 28 15:30:37 2025 -0400 Update src/withdrawal.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> commit 79960c2 Author: Ekrem BAL <mail.ekrembal@gmail.com> Date: Mon Jul 28 15:30:22 2025 -0400 Update src/withdrawal.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> commit 7cab210 Author: Ekrem BAL <mail.ekrembal@gmail.com> Date: Thu Jul 17 16:42:02 2025 -0400 Clementine CLI rust rewrite
1 parent 6ba26aa commit 463ccec

File tree

6 files changed

+338
-45
lines changed

6 files changed

+338
-45
lines changed

docs/deposit.md

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
This guide covers the complete process for depositing Bitcoin to Citrea using Clementine CLI. The deposit process involves generating a deposit address, sending Bitcoin, and monitoring the bridging process.
44

5-
View all deposit commands:
5+
View all deposit commands:
6+
67
```sh
7-
clementine-cli --network <NETWORK> deposit --help
8+
clementine-cli deposit --help
89
```
910

1011
## Prerequisites
1112

1213
Before starting a deposit, ensure you have:
14+
1315
- A Citrea address (Ethereum format)
1416
- A Clementine wallet with `deposit` purpose ("dep" prefix address) which will be used as the recovery taproot address
1517
- Access to a Bitcoin wallet or node for sending funds
@@ -18,13 +20,15 @@ Before starting a deposit, ensure you have:
1820
## Deposit Process Overview
1921

2022
The deposit process consists of several stages:
23+
2124
1. **Generate deposit address** - Create a unique deposit address
2225
2. **Send Bitcoin** - Transfer funds to the deposit address
2326
3. **Monitor status** - Track the bridging process
2427
4. **Recovery (if needed)** - Recover funds if bridging fails
2528

2629
> [!IMPORTANT]
2730
> The `RECOVERY_TAPROOT_ADDRESS` and the `DEPOSIT_ADDRESS` are different. The `RECOVERY_TAPROOT_ADDRESS` will belong to your Clementine wallet to be able to perform deposit specific signing operations in case the deposit fails, whereas `DEPOSIT_ADDRESS` is the address that the deposited BTC funds are sent to. Your `RECOVERY_TAPROOT_ADDRESS` is used when creating the `DEPOSIT_ADDRESS` to make sure should the deposit fails, you can recover your funds back to your `CLAIM_ADDRESS`.
31+
2832
## Step 1: Generate Deposit Address
2933

3034
**TWO-DEVICE PROCESS:**
@@ -34,12 +38,13 @@ The deposit process consists of several stages:
3438
Create a deposit address using your Citrea (EVM) address and recovery taproot address:
3539

3640
```sh
37-
clementine-cli --network <BITCOIN_NETWORK> deposit get-deposit-address <CITREA_ADDRESS> <RECOVERY_TAPROOT_ADDRESS>
41+
clementine-cli deposit get-deposit-address --network <BITCOIN_NETWORK> <RECOVERY_TAPROOT_ADDRESS> <CITREA_ADDRESS>
3842
```
3943

4044
**Example:**
45+
4146
```sh
42-
clementine-cli --network testnet4 deposit get-deposit-address 0x742d35Cc6631C0532925a3b8D0dE4E8de4C837Be depbc1p...
47+
clementine-cli deposit get-deposit-address --network testnet4 depbc1p... 0x742d35Cc6631C0532925a3b8D0dE4E8de4C837Be
4348
```
4449

4550
> [!IMPORTANT]
@@ -51,42 +56,46 @@ clementine-cli --network testnet4 deposit get-deposit-address 0x742d35Cc6631C053
5156

5257
```sh
5358
# Run this on airgapped device to verify the deposit address matches
54-
clementine-cli --network <BITCOIN_NETWORK> deposit get-deposit-address <EVM_ADDRESS> <RECOVERY_TAPROOT_ADDRESS>
59+
clementine-cli deposit get-deposit-address --network <BITCOIN_NETWORK> <RECOVERY_TAPROOT_ADDRESS> <EVM_ADDRESS>
5560
```
5661

5762
## Step 2: Send Bitcoin to Deposit Address
5863

5964
Send your Bitcoin to the generated deposit address. You can use any Bitcoin wallet or client. The deposit address is fixed to `10 BTC`.
6065

6166
**Using bitcoin-cli:**
67+
6268
```sh
6369
bitcoin-cli -<NETWORK> sendtoaddress <DEPOSIT_ADDRESS> 10
6470
```
6571

6672
**Example:**
73+
6774
```sh
6875
bitcoin-cli -testnet4 sendtoaddress "tb1pd..." 10
6976
```
7077

7178
> [!CAUTION]
72-
> Save your deposit transaction ID immediately. This is required for recovery if the Move to Vault transaction fails after 200 blocks.
79+
> Save your deposit TxId immediately. This is required for recovery if the Move to Vault transaction fails after 200 blocks.
7380
7481
## Step 3: Monitor Deposit Status
7582

7683
**ONLINE DEVICE OPERATION:** Track the progress of your deposit through the bridging process:
7784

7885
```sh
79-
clementine-cli --network <BITCOIN_NETWORK> deposit status <DEPOSIT_ADDRESS>
86+
clementine-cli deposit status --network <BITCOIN_NETWORK> <DEPOSIT_ADDRESS>
8087
```
8188

8289
**Example:**
90+
8391
```sh
8492
clementine-cli --network testnet4 deposit status tb1pd...
8593
```
8694

8795
The status will show the response from the backend.
8896

8997
**Two-Device Monitoring Protocol:**
98+
9099
1. **Online Device**: Run status checks regularly
91100
2. **Document Status**: Record all status changes with timestamps
92101
3. **Critical Threshold**: Monitor closely around 200-block threshold
@@ -110,15 +119,17 @@ Gather all necessary information on your online device:
110119
**AIRGAPPED DEVICE ONLY:** Transfer recovery data to airgapped device and generate signed recovery transaction:
111120

112121
```sh
113-
clementine-cli --network <BITCOIN_NETWORK> deposit create-signed-recovery-tx <RECOVERY_TAPROOT_ADDRESS> <CITREA_ADDRESS> <DEPOSIT_OUTPOINT> <CLAIM_ADDRESS>
122+
clementine-cli deposit create-signed-recovery-tx --network <BITCOIN_NETWORK> <RECOVERY_TAPROOT_ADDRESS> <CITREA_ADDRESS> <DEPOSIT_OUTPOINT> <CLAIM_ADDRESS> <FEE_RATE> <AMOUNT>
114123
```
115124

116125
**Example:**
126+
117127
```sh
118-
clementine-cli --network testnet4 deposit create-signed-recovery-tx tb1pd... 0x742d35... abc123def456... 0 tb1qe...
128+
clementine-cli deposit create-signed-recovery-tx --network testnet4 tb1pd... 0x742d35... abc123def456... 0 tb1qe...
119129
```
120130

121131
**Airgapped Recovery Protocol:**
132+
122133
1. **Transfer Data**: Move all recovery parameters to airgapped device via secure method
123134
2. **Generate TX**: Run create-signed-recovery-tx command on airgapped device
124135
3. **Verify Details**: Double-check all parameters before execution
@@ -129,19 +140,26 @@ clementine-cli --network testnet4 deposit create-signed-recovery-tx tb1pd... 0x7
129140
**BOTH DEVICES:** Verify the recovery transaction details before broadcasting:
130141

131142
**Airgapped Device (Generate Verification):**
143+
132144
```sh
133-
clementine-cli --network <BITCOIN_NETWORK> deposit verify-recovery-tx <RECOVERY_TX> <CITREA_ADDRESS> <RECOVERY_TAPROOT_ADDRESS>
145+
clementine-cli deposit verify-recovery-tx --network <BITCOIN_NETWORK> <RECOVERY_TX> <RECOVERY_TAPROOT_ADDRESS> <CITREA_ADDRESS>
134146
```
135147

136148
### Broadcast Recovery Transaction (Online Device)
137149

138150
**ONLINE DEVICE ONLY:** Send the recovery transaction to the Bitcoin network:
139151

140152
```sh
141-
bitcoin-cli sendrawtransaction <RECOVERY_TX>
153+
clementine-cli deposit broadcast-recovery-tx --network <BITCOIN_NETWORK> <RECOVERY_TX>
142154
```
143155

156+
> [!TIP]
157+
> You don't have to use `clementine-cli` if you know how to send raw transactions
158+
> by yourself. `clementine-cli` only provides helping wrappers around Mempool
159+
> post tx api and Bitcoin CLI.
160+
144161
**Broadcasting Protocol:**
162+
145163
1. **Receive**: Get signed recovery transaction from airgapped device
146164
2. **Final Verification**: Optionally run verify-recovery-tx on online device
147165
3. **Broadcast**: Submit transaction to Bitcoin network
@@ -154,31 +172,35 @@ bitcoin-cli sendrawtransaction <RECOVERY_TX>
154172
Retrieve deposit parameters for advanced operations:
155173

156174
```sh
157-
clementine-cli --network <NETWORK> deposit get-deposit-params
175+
clementine-cli deposit get-deposit-params --network <NETWORK> <MOVE_TO_VAULT_TXID>
158176
```
159177

160178
## Troubleshooting
161179

162180
### Common Issues
163181

164182
**Deposit address generation fails:**
183+
165184
- Verify EVM address format (0x...)
166185
- Check recovery taproot address format (bc1p...)
167186
- Ensure network parameter matches your Bitcoin network
168187

169188
**Status check returns no results:**
189+
170190
- Confirm deposit address is correct
171191
- Wait for Bitcoin network confirmation (usually 1-6 blocks)
172192
- Check if deposit transaction was actually broadcasted
173193

174194
**Recovery transaction creation fails:**
195+
175196
- Verify all parameters match original deposit exactly
176197
- Check that 200 blocks have actually passed
177198
- Ensure recovery taproot address is from the correct wallet
178199

179200
### Getting Help
180201

181202
For command-specific help:
203+
182204
```sh
183205
clementine-cli deposit --help
184206
clementine-cli deposit <subcommand> --help

src/cli.rs

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ use crate::{
3030
scan_wallet_files,
3131
wallet_storage::get_storage_dir,
3232
wallet_utils::{
33-
WalletValidationMode, ensure_wallet_exists, parse_and_validate_imported_wallet,
34-
report_integrity_results, validate_wallet_availability,
33+
WalletValidationMode, ensure_wallet_exists, load_key,
34+
parse_and_validate_imported_wallet, report_integrity_results,
35+
validate_wallet_availability,
3536
},
3637
},
3738
withdrawal::{self, start_withdrawal},
@@ -253,6 +254,39 @@ pub async fn deposit_status(
253254
Ok(())
254255
}
255256

257+
pub async fn deposit_create_signed_recovery_tx(
258+
citrea_addr: &CitreaAddress,
259+
recovery_taproot_address: &TaprootAddressWithPrefix<bitcoin::address::NetworkChecked>,
260+
outpoint: &OutPoint,
261+
claim_addr: &BitcoinAddress,
262+
fee_rate: u64,
263+
amount: f64,
264+
config: &BridgeCliConfig,
265+
) -> Result<(), BridgeCliError> {
266+
ensure_wallet_exists(recovery_taproot_address)?;
267+
268+
// Always prompt for passphrase for maximum security
269+
let secure_passphrase = prompt_unlock_passphrase()?;
270+
let keypair = load_key(recovery_taproot_address, &secure_passphrase)?;
271+
let keypair = keypair.as_ref();
272+
273+
let tx = deposit::create_signed_recovery_tx(
274+
citrea_addr,
275+
recovery_taproot_address,
276+
outpoint,
277+
claim_addr,
278+
*keypair,
279+
fee_rate,
280+
amount,
281+
config,
282+
)?;
283+
284+
let raw_tx = hex::encode(bitcoin::consensus::serialize(&tx));
285+
println!("{raw_tx}");
286+
287+
Ok(())
288+
}
289+
256290
pub async fn withdrawal_status(
257291
withdrawal_index: u32,
258292
config: &BridgeCliConfig,

src/config.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,21 @@ impl BridgeCliConfig {
102102

103103
let network_configs = toml::from_str::<NetworkConfigs>(&contents)?;
104104

105-
Ok(match network {
105+
let mut config = match network {
106106
Network::Bitcoin => network_configs.bitcoin,
107107
Network::Testnet | Network::Testnet4 => network_configs.testnet4,
108108
Network::Signet => network_configs.signet,
109109
Network::Regtest => network_configs.regtest,
110-
})
110+
};
111+
112+
// All of the URLs needs a trailing slash. If not present, add it.
113+
if !config.mempool_api_url.to_string().ends_with("/") {
114+
let str_url = config.mempool_api_url.to_string() + "/";
115+
config.mempool_api_url =
116+
Url::from_str(&str_url).wrap_err("Can't add trailing slash to URL")?;
117+
}
118+
119+
Ok(config)
111120
}
112121

113122
pub async fn connect_to_bitcoin_rpc(&self) -> Result<Client, BridgeCliError> {

0 commit comments

Comments
 (0)