mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-12-18 01:54:29 -05:00
feat(swap-controller): Add monero-seed RPC command (#511)
This commit is contained in:
parent
dac835f925
commit
6861f38f16
5 changed files with 37 additions and 2 deletions
|
|
@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- GUI: Add white background to QR code modal to make it better scannable
|
||||
- GUI + CLI + ASB: Add `/dns4/rendezvous.observer/tcp/8888/p2p/12D3KooWMjceGXrYuGuDMGrfmJxALnSDbK4km6s1i1sJEgDTgGQa` to the default list of rendezvous points
|
||||
- GUI + CLI + ASB: Monero RPC pool now prioritizes nodes with pre-established TCP connections
|
||||
- ASB + CONTROLLER: Add a `monero_seed` command to the controller shell. You can use it to export the seed and restore height of the internal Monero wallet. You can use those to import the wallet into a wallet software of your own choosing.
|
||||
|
||||
## [3.0.0-beta.6] - 2025-08-07
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,12 @@ pub struct Swap {
|
|||
pub state: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct MoneroSeedResponse {
|
||||
pub seed: String,
|
||||
pub restore_height: u64,
|
||||
}
|
||||
|
||||
#[rpc(client, server)]
|
||||
pub trait AsbApi {
|
||||
#[method(name = "check_connection")]
|
||||
|
|
@ -44,6 +50,8 @@ pub trait AsbApi {
|
|||
async fn monero_balance(&self) -> Result<MoneroBalanceResponse, ErrorObjectOwned>;
|
||||
#[method(name = "monero_address")]
|
||||
async fn monero_address(&self) -> Result<MoneroAddressResponse, ErrorObjectOwned>;
|
||||
#[method(name = "monero_seed")]
|
||||
async fn monero_seed(&self) -> Result<MoneroSeedResponse, ErrorObjectOwned>;
|
||||
#[method(name = "multiaddresses")]
|
||||
async fn multiaddresses(&self) -> Result<MultiaddressesResponse, ErrorObjectOwned>;
|
||||
#[method(name = "active_connections")]
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ pub enum Cmd {
|
|||
MoneroBalance,
|
||||
/// Get Monero wallet address
|
||||
MoneroAddress,
|
||||
/// Get Monero seed and restore height
|
||||
MoneroSeed,
|
||||
/// Get external multiaddresses
|
||||
Multiaddresses,
|
||||
/// Get active connection count
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ mod repl;
|
|||
|
||||
use clap::Parser;
|
||||
use cli::{Cli, Cmd};
|
||||
use swap_controller_api::AsbApiClient;
|
||||
use swap_controller_api::{AsbApiClient, MoneroSeedResponse};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
|
|
@ -43,6 +43,19 @@ async fn dispatch(cmd: Cmd, client: impl AsbApiClient) -> anyhow::Result<()> {
|
|||
let response = client.monero_address().await?;
|
||||
println!("The primary Monero address is {}", response.address);
|
||||
}
|
||||
Cmd::MoneroSeed => {
|
||||
let MoneroSeedResponse {
|
||||
seed,
|
||||
restore_height,
|
||||
} = client.monero_seed().await?;
|
||||
|
||||
println!("The seed of the internal Monero wallet is: \n{}", seed);
|
||||
println!();
|
||||
println!(
|
||||
"The restore height of the internal Monero wallet is {}",
|
||||
restore_height
|
||||
);
|
||||
}
|
||||
Cmd::Multiaddresses => {
|
||||
let response = client.multiaddresses().await?;
|
||||
if response.multiaddresses.is_empty() {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use jsonrpsee::types::ErrorObjectOwned;
|
|||
use std::sync::Arc;
|
||||
use swap_controller_api::{
|
||||
ActiveConnectionsResponse, AsbApiServer, BitcoinBalanceResponse, MoneroAddressResponse,
|
||||
MoneroBalanceResponse, MultiaddressesResponse, Swap,
|
||||
MoneroBalanceResponse, MoneroSeedResponse, MultiaddressesResponse, Swap,
|
||||
};
|
||||
use tokio_util::task::AbortOnDropHandle;
|
||||
|
||||
|
|
@ -90,6 +90,17 @@ impl AsbApiServer for RpcImpl {
|
|||
})
|
||||
}
|
||||
|
||||
async fn monero_seed(&self) -> Result<MoneroSeedResponse, ErrorObjectOwned> {
|
||||
let wallet = self.monero_wallet.main_wallet().await;
|
||||
let seed = wallet.seed().await.into_json_rpc_result()?;
|
||||
let restore_height = wallet.get_restore_height().await.into_json_rpc_result()?;
|
||||
|
||||
Ok(MoneroSeedResponse {
|
||||
seed,
|
||||
restore_height,
|
||||
})
|
||||
}
|
||||
|
||||
async fn multiaddresses(&self) -> Result<MultiaddressesResponse, ErrorObjectOwned> {
|
||||
let (_, addresses) = self
|
||||
.event_loop_service
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue