Merge pull request #131 from tnull/2024-02-align-rustfmt
[ldk-sample] / src / sweep.rs
index 01cea9d32bbc7c042d4a7b457015b23a01409d4d..fbfa62c97c41c1b6ab5d69bed5e83c6cc7e5ac22 100644 (file)
@@ -12,8 +12,8 @@ use lightning::util::ser::{Readable, WithoutLength, Writeable};
 
 use lightning_persister::fs_store::FilesystemStore;
 
+use bitcoin::blockdata::locktime::absolute::LockTime;
 use bitcoin::secp256k1::Secp256k1;
-use bitcoin::{LockTime, PackedLockTime};
 use rand::{thread_rng, Rng};
 
 use crate::hex_utils;
@@ -101,7 +101,7 @@ pub(crate) async fn periodic_sweep(
                                        match file.read_exact(&mut [0; 1]) {
                                                Ok(_) => {
                                                        file.seek(SeekFrom::Current(-1)).unwrap();
-                                               }
+                                               },
                                                Err(e) if e.kind() == io::ErrorKind::UnexpectedEof => break,
                                                Err(e) => Err(e).unwrap(),
                                        }
@@ -109,8 +109,8 @@ pub(crate) async fn periodic_sweep(
                                }
                                let destination_address = bitcoind_client.get_new_address().await;
                                let output_descriptors = &outputs.iter().map(|a| a).collect::<Vec<_>>();
-                               let tx_feerate =
-                                       bitcoind_client.get_est_sat_per_1000_weight(ConfirmationTarget::Background);
+                               let tx_feerate = bitcoind_client
+                                       .get_est_sat_per_1000_weight(ConfirmationTarget::ChannelCloseMinimum);
 
                                // We set nLockTime to the current height to discourage fee sniping.
                                // Occasionally randomly pick a nLockTime even further back, so
@@ -126,8 +126,8 @@ pub(crate) async fn periodic_sweep(
                                        cur_height = cur_height.saturating_sub(thread_rng().gen_range(0, 100));
                                }
 
-                               let locktime: PackedLockTime =
-                                       LockTime::from_height(cur_height).map_or(PackedLockTime::ZERO, |l| l.into());
+                               let locktime =
+                                       LockTime::from_height(cur_height).map_or(LockTime::ZERO, |l| l.into());
 
                                if let Ok(spending_tx) = keys_manager.spend_spendable_outputs(
                                        output_descriptors,