commands: take advantage of 1.48 compat riddance

This commit is contained in:
Antoine Poinsot 2023-06-27 17:17:47 +02:00
parent 117221e9ee
commit b2f95ada58
No known key found for this signature in database
GPG Key ID: E13FC145CD3F4304

View File

@ -293,12 +293,10 @@ impl DaemonControl {
/// Get a list of all known coins.
pub fn list_coins(&self) -> ListCoinsResult {
let mut db_conn = self.db.connection();
#[allow(clippy::iter_kv_map)] // Because Rust 1.48
let coins: Vec<ListCoinsEntry> = db_conn
.coins(CoinType::All)
// Can't use into_values as of Rust 1.48
.into_iter()
.map(|(_, coin)| {
.into_values()
.map(|coin| {
let Coin {
amount,
outpoint,
@ -728,15 +726,12 @@ impl DaemonControl {
let timelock =
timelock.unwrap_or_else(|| self.config.main_descriptor.first_timelock_value());
let height_delta: i32 = timelock.try_into().expect("Must fit, it's a u16");
let sweepable_coins = db_conn
.coins(CoinType::Unspent)
.into_iter()
.filter(|(_, c)| {
// We are interested in coins available at the *next* block
c.block_info
.map(|b| current_height + 1 >= b.height + height_delta)
.unwrap_or(false)
});
let sweepable_coins = db_conn.coins(CoinType::Unspent).into_values().filter(|c| {
// We are interested in coins available at the *next* block
c.block_info
.map(|b| current_height + 1 >= b.height + height_delta)
.unwrap_or(false)
});
// Fill-in the transaction inputs and PSBT inputs information. Record the value
// that is fed to the transaction while doing so, to compute the fees afterward.
@ -744,7 +739,7 @@ impl DaemonControl {
let txin_sat_vb = self.config.main_descriptor.max_sat_vbytes();
let mut sat_vb = 0;
let mut spent_txs = HashMap::new();
for (_, coin) in sweepable_coins {
for coin in sweepable_coins {
in_value += coin.amount;
psbt.unsigned_tx.input.push(bitcoin::TxIn {
previous_output: coin.outpoint,