update dust fee rate to bitcoin core 0.19 DUST_RELAY_TX_FEE

This commit is contained in:
Craig Raw 2020-07-11 11:39:43 +02:00
parent 49a4b548b4
commit b86887838f
2 changed files with 5 additions and 2 deletions

View file

@ -22,7 +22,10 @@ public class Transaction extends ChildMessage {
public static final long SATOSHIS_PER_BITCOIN = 100 * 1000 * 1000L; public static final long SATOSHIS_PER_BITCOIN = 100 * 1000 * 1000L;
public static final long MAX_BLOCK_LOCKTIME = 500000000L; public static final long MAX_BLOCK_LOCKTIME = 500000000L;
public static final int WITNESS_SCALE_FACTOR = 4; 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 version;
private long locktime; private long locktime;

View file

@ -301,7 +301,7 @@ public class Wallet {
long changeAmt = differenceAmt - noChangeFeeRequiredAmt; long changeAmt = differenceAmt - noChangeFeeRequiredAmt;
WalletNode changeNode = getFreshNode(KeyPurpose.CHANGE); WalletNode changeNode = getFreshNode(KeyPurpose.CHANGE);
TransactionOutput changeOutput = new TransactionOutput(transaction, changeAmt, getOutputScript(changeNode)); 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) { if(changeAmt > dustThreshold) {
//Change output is required, determine new fee once change output has been added //Change output is required, determine new fee once change output has been added
int changeVSize = noChangeVSize + changeOutput.getLength(); int changeVSize = noChangeVSize + changeOutput.getLength();