[wallet] Replace ChangeSpendPolicy::filter_utxos with a predicate

To make composing it with other filtering conditions easier.
This commit is contained in:
LLFourn
2020-10-21 15:53:00 +11:00
parent 365a91f805
commit c549281ace
2 changed files with 20 additions and 16 deletions

View File

@@ -1015,16 +1015,11 @@ where
}
// otherwise limit ourselves to the spendable utxos for the selected policy, and the `send_all` setting
None => {
let utxos = self.list_unspent()?.into_iter();
let utxos = change_policy.filter_utxos(utxos).into_iter();
let utxos = self.list_unspent()?.into_iter().filter(|u| {
change_policy.is_satisfied_by(u) && !unspendable_set.contains(&u.outpoint)
});
Ok((
utxos
.filter(|u| !unspendable_set.contains(&u.outpoint))
.map(add_weight)
.collect(),
send_all,
))
Ok((utxos.map(add_weight).collect(), send_all))
}
}
}