Filter dust from coin selection (#3866)

This commit is contained in:
benthecarman 2022-01-21 13:15:12 -06:00 committed by GitHub
parent 3162c1b2d0
commit 42d6955f79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,6 +2,7 @@ package org.bitcoins.wallet.internal
import org.bitcoins.core.api.wallet.db.{AccountDb, SpendingInfoDb}
import org.bitcoins.core.api.wallet.{CoinSelectionAlgo, CoinSelector}
import org.bitcoins.core.policy.Policy
import org.bitcoins.core.protocol.transaction._
import org.bitcoins.core.wallet.builder._
import org.bitcoins.core.wallet.fee.FeeUnit
@ -83,9 +84,15 @@ trait FundTransactionHandling extends WalletLogger { self: Wallet =>
val selectedUtxosF: Future[Vector[(SpendingInfoDb, Transaction)]] =
for {
walletUtxos <- utxosF
// filter out dust
selectableUtxos = walletUtxos
.map(_._1)
.filter(_.output.value > Policy.dustThreshold)
utxos = CoinSelector.selectByAlgo(
coinSelectionAlgo = coinSelectionAlgo,
walletUtxos = walletUtxos.map(_._1),
walletUtxos = selectableUtxos,
outputs = destinations,
feeRate = feeRate,
longTermFeeRateOpt = Some(self.walletConfig.longTermFeeRate)