mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-12-27 02:26:44 +00:00
use fractional tx virtual size
This commit is contained in:
parent
5b2e21b3d7
commit
533791edcf
2 changed files with 4 additions and 4 deletions
|
@ -303,8 +303,8 @@ public class Transaction extends ChildMessage {
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getVirtualSize() {
|
public double getVirtualSize() {
|
||||||
return (int)Math.ceil((double)getWeightUnits() / (double)WITNESS_SCALE_FACTOR);
|
return (double)getWeightUnits() / (double)WITNESS_SCALE_FACTOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getWeightUnits() {
|
public int getWeightUnits() {
|
||||||
|
|
|
@ -489,7 +489,7 @@ public class Wallet {
|
||||||
transaction.addOutput(payment.getAmount(), payment.getAddress());
|
transaction.addOutput(payment.getAmount(), payment.getAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
int noChangeVSize = transaction.getVirtualSize();
|
double noChangeVSize = transaction.getVirtualSize();
|
||||||
long noChangeFeeRequiredAmt = (fee == null ? (long)(feeRate * noChangeVSize) : fee);
|
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
|
//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
|
//Change output is required, determine new fee once change output has been added
|
||||||
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));
|
||||||
int changeVSize = noChangeVSize + changeOutput.getLength();
|
double changeVSize = noChangeVSize + changeOutput.getLength();
|
||||||
long changeFeeRequiredAmt = (fee == null ? (long)(feeRate * changeVSize) : fee);
|
long changeFeeRequiredAmt = (fee == null ? (long)(feeRate * changeVSize) : fee);
|
||||||
changeFeeRequiredAmt = (feeRate == Transaction.DEFAULT_MIN_RELAY_FEE ? changeFeeRequiredAmt + 1 : changeFeeRequiredAmt);
|
changeFeeRequiredAmt = (feeRate == Transaction.DEFAULT_MIN_RELAY_FEE ? changeFeeRequiredAmt + 1 : changeFeeRequiredAmt);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue