mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-12-27 02:26:44 +00:00
handle longer signature with min relay fee set
This commit is contained in:
parent
b877e94cd0
commit
9c6d3ec94b
1 changed files with 4 additions and 0 deletions
|
@ -462,6 +462,9 @@ public class Wallet {
|
||||||
int noChangeVSize = transaction.getVirtualSize();
|
int 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
|
||||||
|
noChangeFeeRequiredAmt = (feeRate == Transaction.DEFAULT_MIN_RELAY_FEE ? noChangeFeeRequiredAmt + 1 : noChangeFeeRequiredAmt);
|
||||||
|
|
||||||
//If sending all selected utxos, set the recipient amount to equal to total of those utxos less the no change fee
|
//If sending all selected utxos, set the recipient amount to equal to total of those utxos less the no change fee
|
||||||
long maxSendAmt = totalSelectedAmt - noChangeFeeRequiredAmt;
|
long maxSendAmt = totalSelectedAmt - noChangeFeeRequiredAmt;
|
||||||
if(sendAll && recipientAmount != maxSendAmt) {
|
if(sendAll && recipientAmount != maxSendAmt) {
|
||||||
|
@ -487,6 +490,7 @@ public class Wallet {
|
||||||
TransactionOutput changeOutput = new TransactionOutput(transaction, changeAmt, getOutputScript(changeNode));
|
TransactionOutput changeOutput = new TransactionOutput(transaction, changeAmt, getOutputScript(changeNode));
|
||||||
int changeVSize = noChangeVSize + changeOutput.getLength();
|
int 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);
|
||||||
|
|
||||||
//Recalculate the change amount with the new fee
|
//Recalculate the change amount with the new fee
|
||||||
changeAmt = differenceAmt - changeFeeRequiredAmt;
|
changeAmt = differenceAmt - changeFeeRequiredAmt;
|
||||||
|
|
Loading…
Reference in a new issue