Merge pull request #8774 from yyforyongyu/fix-size-calc

lnwallet+sweep: fix wrong unit used in fee calculation
This commit is contained in:
Olaoluwa Osuntokun authored and GitHub committed 2024-05-27 18:44:29 -07:00
commit ff85328050
38 files changed
+301 -156

No files matched your search

+2 -6
View File
@@ -1660,8 +1660,6 @@ func (w *WalletKit) fundPsbtInternalWallet(account string,
// fundPsbtCoinSelect uses the "new" PSBT funding method using the channel
// funding coin selection algorithm that allows specifying custom inputs while
// selecting coins.
//
//nolint:funlen
func (w *WalletKit) fundPsbtCoinSelect(account string, changeIndex int32,
packet *psbt.Packet, minConfs int32,
changeType chanfunding.ChangeAddressType,
@@ -1737,7 +1735,7 @@ func (w *WalletKit) fundPsbtCoinSelect(account string, changeIndex int32,
// Do we already have enough inputs specified to pay for the TX as it
// is? In that case we only need to allocate any change, if there is
// any.
packetFeeNoChange := feeRate.FeeForWeight(int64(estimator.Weight()))
packetFeeNoChange := feeRate.FeeForWeight(estimator.Weight())
if inputSum >= outputSum+packetFeeNoChange {
// Calculate the packet's fee with a change output so, so we can
// let the coin selection algorithm decide whether to use a
@@ -1749,9 +1747,7 @@ func (w *WalletKit) fundPsbtCoinSelect(account string, changeIndex int32,
case chanfunding.P2WKHChangeAddress:
estimator.AddP2WKHOutput()
}
packetFeeWithChange := feeRate.FeeForWeight(
int64(estimator.Weight()),
)
packetFeeWithChange := feeRate.FeeForWeight(estimator.Weight())
changeAmt, needMore, err := chanfunding.CalculateChangeAmount(
inputSum, outputSum, packetFeeNoChange,
+1 -1
View File
@@ -132,7 +132,7 @@ func TestFundPsbtCoinSelect(t *testing.T) {
}
weight := estimator.Weight()
fee := chainfee.FeePerKwFloor.FeeForWeight(int64(weight))
fee := chainfee.FeePerKwFloor.FeeForWeight(weight)
return fee + dust
}