mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-01-26 23:37:01 -05:00
Add command to print Bitcoin and Monero balance
This commit is contained in:
parent
96008ec130
commit
04b49d7117
@ -38,6 +38,7 @@ pub enum Command {
|
|||||||
#[structopt(long = "address", help = "The address to receive the Bitcoin.")]
|
#[structopt(long = "address", help = "The address to receive the Bitcoin.")]
|
||||||
address: Address,
|
address: Address,
|
||||||
},
|
},
|
||||||
|
Balance,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_btc(s: &str) -> Result<Amount, ParseAmountError> {
|
fn parse_btc(s: &str) -> Result<Amount, ParseAmountError> {
|
||||||
|
@ -78,6 +78,20 @@ async fn main() -> Result<()> {
|
|||||||
let bitcoin_wallet = init_bitcoin_wallet(&config, &seed, env_config).await?;
|
let bitcoin_wallet = init_bitcoin_wallet(&config, &seed, env_config).await?;
|
||||||
let monero_wallet = init_monero_wallet(&config, env_config).await?;
|
let monero_wallet = init_monero_wallet(&config, env_config).await?;
|
||||||
|
|
||||||
|
let bitcoin_balance = bitcoin_wallet.balance().await?;
|
||||||
|
info!("Bitcoin balance: {}", bitcoin_balance);
|
||||||
|
|
||||||
|
let monero_balance = monero_wallet.get_balance().await?;
|
||||||
|
if monero_balance == Amount::ZERO {
|
||||||
|
let deposit_address = monero_wallet.get_main_address();
|
||||||
|
warn!(
|
||||||
|
"The Monero balance is 0, make sure to deposit funds at: {}",
|
||||||
|
deposit_address
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
info!("Monero balance: {}", monero_balance);
|
||||||
|
}
|
||||||
|
|
||||||
let kraken_rate_updates = kraken::connect()?;
|
let kraken_rate_updates = kraken::connect()?;
|
||||||
|
|
||||||
let mut swarm = swarm::new::<Behaviour>(&seed)?;
|
let mut swarm = swarm::new::<Behaviour>(&seed)?;
|
||||||
@ -144,6 +158,15 @@ async fn main() -> Result<()> {
|
|||||||
|
|
||||||
bitcoin_wallet.broadcast(signed_tx, "withdraw").await?;
|
bitcoin_wallet.broadcast(signed_tx, "withdraw").await?;
|
||||||
}
|
}
|
||||||
|
Command::Balance => {
|
||||||
|
let bitcoin_wallet = init_bitcoin_wallet(&config, &seed, env_config).await?;
|
||||||
|
let monero_wallet = init_monero_wallet(&config, env_config).await?;
|
||||||
|
|
||||||
|
let bitcoin_balance = bitcoin_wallet.balance().await?;
|
||||||
|
let monero_balance = monero_wallet.get_balance().await?;
|
||||||
|
|
||||||
|
tracing::info!("Current balance: {}, {}", bitcoin_balance, monero_balance);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -167,12 +190,6 @@ async fn init_bitcoin_wallet(
|
|||||||
|
|
||||||
wallet.sync().await?;
|
wallet.sync().await?;
|
||||||
|
|
||||||
let balance = wallet.balance().await?;
|
|
||||||
info!(
|
|
||||||
"Connection to Bitcoin wallet succeeded, balance: {}",
|
|
||||||
balance
|
|
||||||
);
|
|
||||||
|
|
||||||
Ok(wallet)
|
Ok(wallet)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,16 +204,5 @@ async fn init_monero_wallet(
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let balance = wallet.get_balance().await?;
|
|
||||||
if balance == Amount::ZERO {
|
|
||||||
let deposit_address = wallet.get_main_address();
|
|
||||||
warn!(
|
|
||||||
"The Monero balance is 0, make sure to deposit funds at: {}",
|
|
||||||
deposit_address
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
info!("Monero balance: {}", balance);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(wallet)
|
Ok(wallet)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user