We only have one bitcoin client now, simplifying
This commit is contained in:
@@ -1 +0,0 @@
|
||||
pub mod esplora;
|
||||
@@ -5,7 +5,21 @@ use tracing_subscriber::filter::EnvFilter;
|
||||
use tracing_subscriber::util::SubscriberInitExt;
|
||||
use tracing_subscriber::{fmt, layer::SubscriberExt};
|
||||
|
||||
use super::clients::esplora::BitcoinClient;
|
||||
use super::client::BitcoinClient;
|
||||
|
||||
async fn setup() -> Result<(BitcoinClient, BitcoinClient), anyhow::Error> {
|
||||
tracing_setup();
|
||||
let dave = BitcoinClient::create_wallet("dave", Network::Signet)?;
|
||||
let sammy = BitcoinClient::create_wallet("sammy", Network::Signet)?;
|
||||
|
||||
dave.sync()?;
|
||||
let _ = dave.wallet.get_balance();
|
||||
|
||||
sammy.sync()?;
|
||||
let _ = sammy.wallet.get_balance();
|
||||
|
||||
Ok((dave, sammy))
|
||||
}
|
||||
|
||||
pub(crate) async fn simple_transfer() -> Result<(), anyhow::Error> {
|
||||
let (mut dave, sammy) = setup().await?;
|
||||
@@ -20,31 +34,6 @@ pub(crate) async fn simple_transfer() -> Result<(), anyhow::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn setup() -> Result<(BitcoinClient, BitcoinClient), anyhow::Error> {
|
||||
tracing_setup();
|
||||
let dave = BitcoinClient::create_wallet("dave", Network::Signet)?;
|
||||
let sammy = BitcoinClient::create_wallet("sammy", Network::Signet)?;
|
||||
let _ = dave.wallet.get_balance();
|
||||
dave.sync()?;
|
||||
let _ = dave.wallet.get_balance();
|
||||
let _sammy = sammy.wallet.get_balance();
|
||||
sammy.sync()?;
|
||||
let _ = sammy.wallet.get_balance();
|
||||
Ok((dave, sammy))
|
||||
}
|
||||
|
||||
/// Exit if the wallet does not have enough sats to send.
|
||||
fn ensure_enough_sats(wallet: &BitcoinClient, send_amount: u64) -> anyhow::Result<()> {
|
||||
if wallet.wallet.get_balance()?.get_total() < send_amount {
|
||||
tracing::error!(
|
||||
"Please send at least {} sats to the receiving address. Exiting.",
|
||||
send_amount
|
||||
);
|
||||
std::process::exit(0);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn htlc() -> anyhow::Result<()> {
|
||||
tracing::info!("starting htlc flow");
|
||||
let (dave, sammy) = setup().await?;
|
||||
@@ -90,3 +79,15 @@ fn tracing_setup() {
|
||||
|
||||
tracing::info!("Tracing initialized.");
|
||||
}
|
||||
|
||||
/// Exit if the wallet does not have enough sats to send.
|
||||
fn ensure_enough_sats(wallet: &BitcoinClient, send_amount: u64) -> anyhow::Result<()> {
|
||||
if wallet.wallet.get_balance()?.get_total() < send_amount {
|
||||
tracing::error!(
|
||||
"Please send at least {} sats to the receiving address. Exiting.",
|
||||
send_amount
|
||||
);
|
||||
std::process::exit(0);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
pub mod clients;
|
||||
pub mod client;
|
||||
pub mod driver;
|
||||
pub mod htlc;
|
||||
pub mod keys;
|
||||
|
||||
Reference in New Issue
Block a user