kaspa_cli_lib/modules/
sweep.rs1use crate::imports::*;
2
3#[derive(Default, Handler)]
4#[help("Reduces account UTXO size by re-sending all funds to the account's default address")]
5pub struct Sweep;
6
7impl Sweep {
8 async fn main(self: Arc<Self>, ctx: &Arc<dyn Context>, _argv: Vec<String>, _cmd: &str) -> Result<()> {
9 let ctx = ctx.clone().downcast_arc::<KaspaCli>()?;
10
11 let account = ctx.wallet().account()?;
12 let (wallet_secret, payment_secret) = ctx.ask_wallet_secret(Some(&account)).await?;
13 let abortable = Abortable::default();
14 let (summary, _ids) = account
16 .sweep(
17 wallet_secret,
18 payment_secret,
19 &abortable,
20 Some(Arc::new(move |_ptx| {
21 })),
23 )
24 .await?;
25
26 tprintln!(ctx, "Sweep: {summary}");
27
28 Ok(())
29 }
30}