Extracted the Esplora wallet into a struct
This commit is contained in:
@@ -11,14 +11,14 @@ use crate::bitcoin::clients;
|
||||
/// Also, it very handily works with the mutinynet.com esplora server, which is configured
|
||||
/// with 30 second block times.
|
||||
pub(crate) async fn run() -> Result<(), anyhow::Error> {
|
||||
let (mut wallet, mut db) = clients::esplora::create_wallet("dave")?;
|
||||
let mut wallet = clients::esplora::create_wallet("dave")?;
|
||||
|
||||
let _next_address = clients::esplora::next_unused_address(&mut wallet, &mut db)?;
|
||||
let _next_address = wallet.next_unused_address()?;
|
||||
|
||||
let balance = wallet.balance();
|
||||
println!("Wallet balance before syncing: {} sats", balance.total());
|
||||
|
||||
let client = clients::esplora::sync(&mut wallet, &mut db).await?;
|
||||
wallet.sync().await?;
|
||||
|
||||
let balance = wallet.balance();
|
||||
println!("Wallet balance after syncing: {} sats", balance.total());
|
||||
@@ -35,8 +35,9 @@ pub(crate) async fn run() -> Result<(), anyhow::Error> {
|
||||
std::process::exit(0);
|
||||
}
|
||||
|
||||
let tx = clients::esplora::build_send_tx(wallet, faucet_address, send_amount)?;
|
||||
client.broadcast(&tx).await?;
|
||||
let tx = wallet.build_send_tx(faucet_address, send_amount)?;
|
||||
wallet.broadcast(&tx).await?;
|
||||
|
||||
println!("Tx broadcasted! Txid: {}", tx.compute_txid());
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user