use fractional tx virtual size

This commit is contained in:
Craig Raw 2021-03-08 16:20:35 +02:00
parent 5b2e21b3d7
commit 533791edcf
2 changed files with 4 additions and 4 deletions

View file

@ -303,8 +303,8 @@ public class Transaction extends ChildMessage {
return length;
}
public int getVirtualSize() {
return (int)Math.ceil((double)getWeightUnits() / (double)WITNESS_SCALE_FACTOR);
public double getVirtualSize() {
return (double)getWeightUnits() / (double)WITNESS_SCALE_FACTOR;
}
public int getWeightUnits() {

View file

@ -489,7 +489,7 @@ public class Wallet {
transaction.addOutput(payment.getAmount(), payment.getAddress());
}
int noChangeVSize = transaction.getVirtualSize();
double noChangeVSize = transaction.getVirtualSize();
long noChangeFeeRequiredAmt = (fee == null ? (long)(feeRate * noChangeVSize) : fee);
//Add 1 satoshi to accommodate longer signatures when feeRate equals default min relay fee to ensure fee is sufficient
@ -528,7 +528,7 @@ public class Wallet {
//Change output is required, determine new fee once change output has been added
WalletNode changeNode = getFreshNode(KeyPurpose.CHANGE);
TransactionOutput changeOutput = new TransactionOutput(transaction, changeAmt, getOutputScript(changeNode));
int changeVSize = noChangeVSize + changeOutput.getLength();
double changeVSize = noChangeVSize + changeOutput.getLength();
long changeFeeRequiredAmt = (fee == null ? (long)(feeRate * changeVSize) : fee);
changeFeeRequiredAmt = (feeRate == Transaction.DEFAULT_MIN_RELAY_FEE ? changeFeeRequiredAmt + 1 : changeFeeRequiredAmt);