Implement isDustAttackUtxo protection

This commit is contained in:
chimp1984 2021-01-31 21:36:10 -05:00
parent 2b9b9ef8a8
commit 24370146e6
No known key found for this signature in database
GPG key ID: 9801B4EC591F90E3

View file

@ -19,6 +19,7 @@ package bisq.core.btc.wallet;
import bisq.core.dao.state.DaoStateService;
import bisq.core.dao.state.model.blockchain.TxOutputKey;
import bisq.core.user.Preferences;
import org.bitcoinj.core.Transaction;
import org.bitcoinj.core.TransactionConfidence;
@ -26,6 +27,7 @@ import org.bitcoinj.core.TransactionOutput;
import javax.inject.Inject;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
/**
@ -35,6 +37,8 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public class NonBsqCoinSelector extends BisqDefaultCoinSelector {
private DaoStateService daoStateService;
@Setter
private Preferences preferences;
@Inject
public NonBsqCoinSelector(DaoStateService daoStateService) {
@ -60,9 +64,9 @@ public class NonBsqCoinSelector extends BisqDefaultCoinSelector {
return !daoStateService.existsTxOutput(key) || daoStateService.isRejectedIssuanceOutput(key);
}
// BTC utxo in the BSQ wallet are usually from rejected comp request so we don't expect dust attack utxos here.
// Prevent to use dust attack utxos
@Override
protected boolean isDustAttackUtxo(TransactionOutput output) {
return false;
return output.getValue().value < preferences.getIgnoreDustThreshold();
}
}