From b86887838f7145d532a4572b6b3a81700e74acfb Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Sat, 11 Jul 2020 11:39:43 +0200 Subject: [PATCH] update dust fee rate to bitcoin core 0.19 DUST_RELAY_TX_FEE --- .../java/com/sparrowwallet/drongo/protocol/Transaction.java | 5 ++++- src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/sparrowwallet/drongo/protocol/Transaction.java b/src/main/java/com/sparrowwallet/drongo/protocol/Transaction.java index 65bd140..b492a39 100644 --- a/src/main/java/com/sparrowwallet/drongo/protocol/Transaction.java +++ b/src/main/java/com/sparrowwallet/drongo/protocol/Transaction.java @@ -22,7 +22,10 @@ public class Transaction extends ChildMessage { public static final long SATOSHIS_PER_BITCOIN = 100 * 1000 * 1000L; public static final long MAX_BLOCK_LOCKTIME = 500000000L; public static final int WITNESS_SCALE_FACTOR = 4; - public static final double DEFAULT_DISCARD_FEE_RATE = 10000d / 1000; + + //Min feerate for defining dust, defined in sats/vByte + //From: https://github.com/bitcoin/bitcoin/blob/0.19/src/policy/policy.h#L50 + public static final double DUST_RELAY_TX_FEE = 3d; private long version; private long locktime; diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java b/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java index 2c170cc..0577d85 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java @@ -301,7 +301,7 @@ public class Wallet { long changeAmt = differenceAmt - noChangeFeeRequiredAmt; WalletNode changeNode = getFreshNode(KeyPurpose.CHANGE); TransactionOutput changeOutput = new TransactionOutput(transaction, changeAmt, getOutputScript(changeNode)); - long dustThreshold = getScriptType().getDustThreshold(changeOutput, Transaction.DEFAULT_DISCARD_FEE_RATE); + long dustThreshold = getScriptType().getDustThreshold(changeOutput, Transaction.DUST_RELAY_TX_FEE); if(changeAmt > dustThreshold) { //Change output is required, determine new fee once change output has been added int changeVSize = noChangeVSize + changeOutput.getLength();