diff --git a/src/main/java/com/sparrowwallet/drongo/protocol/Transaction.java b/src/main/java/com/sparrowwallet/drongo/protocol/Transaction.java index e7c7f22..46425a3 100644 --- a/src/main/java/com/sparrowwallet/drongo/protocol/Transaction.java +++ b/src/main/java/com/sparrowwallet/drongo/protocol/Transaction.java @@ -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() { diff --git a/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java b/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java index d772166..17f3d06 100644 --- a/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java +++ b/src/main/java/com/sparrowwallet/drongo/wallet/Wallet.java @@ -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);