Apply the dust fix to trades which use BSQ for the fee

Also, use `Restrictions.getMinNonDustOutput()` for the dust limit
This commit is contained in:
jmacxx 2020-03-29 20:23:11 -05:00
parent bd5044a315
commit 4fce853dec
No known key found for this signature in database
GPG Key ID: 155297BABFE94A1B

View File

@ -260,6 +260,7 @@ public class TradeWalletService {
checkNotNull(wallet, "Wallet must not be null");
wallet.completeTx(sendRequest);
Transaction resultTx = sendRequest.tx;
removeDust(resultTx);
// Sign all BTC inputs
for (int i = preparedBsqTxInputsSize; i < resultTx.getInputs().size(); i++) {
@ -1228,11 +1229,11 @@ public class TradeWalletService {
List<TransactionOutput> originalTransactionOutputs = transaction.getOutputs();
List<TransactionOutput> keepTransactionOutputs = new ArrayList<>();
for (TransactionOutput transactionOutput: originalTransactionOutputs) {
if (transactionOutput.getValue().value >= preferences.getIgnoreDustThreshold()) {
keepTransactionOutputs.add(transactionOutput);
if (transactionOutput.getValue().isLessThan(Restrictions.getMinNonDustOutput())) {
log.info("your transaction would have contained a dust output of {}", transactionOutput.toString());
}
else {
log.info("your transaction would have contained a dust output of {}", transactionOutput.toString());
keepTransactionOutputs.add(transactionOutput);
}
}
// if dust was detected, keepTransactionOutputs will have fewer elements than originalTransactionOutputs