mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-12-18 10:02:45 -05:00
feat(controller, orchestratror): Add bitcoin-seed command
This commit is contained in:
parent
0df8ea00d2
commit
ee71024466
7 changed files with 37 additions and 5 deletions
|
|
@ -7,9 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
- ORCHESTRATOR: We incorrectly passed the `--mainnet` flag to the `asb` binary but it is the default for the asb.
|
||||
- CONTROLLER: Add a `bitcoin-seed` command to the controller. You can use it to export the descriptor of the internal Bitcoin wallet.
|
||||
|
||||
## [3.0.0-beta.10] - 2025-08-14
|
||||
|
||||
GUI + CLI + ASB: Fix an issue where the Monero RPC pool would fail to build TLS handshakes over Tor
|
||||
- GUI + CLI + ASB: Fix an issue where the Monero RPC pool would fail to build TLS handshakes over Tor
|
||||
|
||||
## [3.0.0-beta.9] - 2025-08-12
|
||||
|
||||
|
|
|
|||
2
justfile
2
justfile
|
|
@ -69,7 +69,7 @@ swap:
|
|||
|
||||
# Run the asb on testnet
|
||||
asb-testnet:
|
||||
cargo run -p swap-asb --bin asb -- --trace --testnet start
|
||||
cargo run -p swap-asb --bin asb -- --trace --testnet start --rpc-bind-port 9944 --rpc-bind-host 0.0.0.0
|
||||
|
||||
# Updates our submodules (currently only Monero C++ codebase)
|
||||
update_submodules:
|
||||
|
|
|
|||
|
|
@ -8,6 +8,11 @@ pub struct BitcoinBalanceResponse {
|
|||
pub balance: bitcoin::Amount,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct BitcoinSeedResponse {
|
||||
pub descriptor: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct MoneroBalanceResponse {
|
||||
pub balance: u64,
|
||||
|
|
@ -46,6 +51,8 @@ pub trait AsbApi {
|
|||
async fn check_connection(&self) -> Result<(), ErrorObjectOwned>;
|
||||
#[method(name = "bitcoin_balance")]
|
||||
async fn bitcoin_balance(&self) -> Result<BitcoinBalanceResponse, ErrorObjectOwned>;
|
||||
#[method(name = "bitcoin_seed")]
|
||||
async fn bitcoin_seed(&self) -> Result<BitcoinSeedResponse, ErrorObjectOwned>;
|
||||
#[method(name = "monero_balance")]
|
||||
async fn monero_balance(&self) -> Result<MoneroBalanceResponse, ErrorObjectOwned>;
|
||||
#[method(name = "monero_address")]
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ pub enum Cmd {
|
|||
CheckConnection,
|
||||
/// Get Bitcoin balance
|
||||
BitcoinBalance,
|
||||
/// Get Bitcoin descriptor containing private keys
|
||||
BitcoinSeed,
|
||||
/// Get Monero balance
|
||||
MoneroBalance,
|
||||
/// Get Monero wallet address
|
||||
|
|
|
|||
|
|
@ -80,6 +80,10 @@ async fn dispatch(cmd: Cmd, client: impl AsbApiClient) -> anyhow::Result<()> {
|
|||
}
|
||||
}
|
||||
}
|
||||
Cmd::BitcoinSeed => {
|
||||
let response = client.bitcoin_seed().await?;
|
||||
println!("Descriptor (BIP-0382) containing the private keys of the internal Bitcoin wallet: \n{}", response.descriptor);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,9 @@ impl Network {
|
|||
impl IntoFlag for Network {
|
||||
fn to_flag(self) -> Flag {
|
||||
match self.0 {
|
||||
(monero::Network::Mainnet, bitcoin::Network::Bitcoin) => flag!("--mainnet"),
|
||||
// Mainnet is the default for the asb
|
||||
(monero::Network::Mainnet, bitcoin::Network::Bitcoin) => Flag(None),
|
||||
// Testnet requires the --testnet flag
|
||||
(monero::Network::Stagenet, bitcoin::Network::Testnet) => flag!("--testnet"),
|
||||
_ => panic!("Only either Mainnet Bitcoin & Mainnet Monero or Testnet Bitcoin & Stagenet Monero are supported"),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ use jsonrpsee::types::error::ErrorCode;
|
|||
use jsonrpsee::types::ErrorObjectOwned;
|
||||
use std::sync::Arc;
|
||||
use swap_controller_api::{
|
||||
ActiveConnectionsResponse, AsbApiServer, BitcoinBalanceResponse, MoneroAddressResponse,
|
||||
MoneroBalanceResponse, MoneroSeedResponse, MultiaddressesResponse, Swap,
|
||||
ActiveConnectionsResponse, AsbApiServer, BitcoinBalanceResponse, BitcoinSeedResponse,
|
||||
MoneroAddressResponse, MoneroBalanceResponse, MoneroSeedResponse, MultiaddressesResponse, Swap,
|
||||
};
|
||||
use tokio_util::task::AbortOnDropHandle;
|
||||
|
||||
|
|
@ -72,6 +72,20 @@ impl AsbApiServer for RpcImpl {
|
|||
Ok(BitcoinBalanceResponse { balance })
|
||||
}
|
||||
|
||||
async fn bitcoin_seed(&self) -> Result<BitcoinSeedResponse, ErrorObjectOwned> {
|
||||
static EXPORT_ROLE: &str = "asb";
|
||||
|
||||
let wallet_export = self
|
||||
.bitcoin_wallet
|
||||
.wallet_export(EXPORT_ROLE)
|
||||
.await
|
||||
.into_json_rpc_result()?;
|
||||
|
||||
Ok(BitcoinSeedResponse {
|
||||
descriptor: format!("{}", wallet_export.descriptor()),
|
||||
})
|
||||
}
|
||||
|
||||
async fn monero_balance(&self) -> Result<MoneroBalanceResponse, ErrorObjectOwned> {
|
||||
let wallet = self.monero_wallet.main_wallet().await;
|
||||
let balance = wallet.total_balance().await;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue