lnwallet/chanfunding: assumes all change outputs are P2TR

This commit is contained in:
Olaoluwa Osuntokun committed 2022-08-11 17:26:23 -07:00
1 parent 322937a67e
commit 42549519ca
3 files changed
+8 -7

No files matched your search

+4 -3
View File
@@ -98,8 +98,8 @@ func calculateFees(utxos []Coin, feeRate chainfee.SatPerKWeight) (btcutil.Amount
requiredFeeNoChange := feeRate.FeeForWeight(totalWeight) requiredFeeNoChange := feeRate.FeeForWeight(totalWeight)
// Estimate the fee required for a transaction with a change output. // Estimate the fee required for a transaction with a change output.
// Assume that change output is a P2WKH output. // Assume that change output is a P2TR output.
weightEstimate.AddP2WKHOutput() weightEstimate.AddP2TROutput()
// Now that we have added the change output, redo the fee // Now that we have added the change output, redo the fee
// estimate. // estimate.
@@ -209,7 +209,8 @@ func CoinSelectSubtractFees(feeRate chainfee.SatPerKWeight, amt,
// Obtain fee estimates both with and without using a change // Obtain fee estimates both with and without using a change
// output. // output.
requiredFeeNoChange, requiredFeeWithChange, err := calculateFees( requiredFeeNoChange, requiredFeeWithChange, err := calculateFees(
selectedUtxos, feeRate) selectedUtxos, feeRate,
)
if err != nil { if err != nil {
return nil, 0, 0, err return nil, 0, 0, err
} }
+3 -3
View File
@@ -44,7 +44,7 @@ func fundingFee(feeRate chainfee.SatPerKWeight, numInput int, // nolint:unparam
// Optionally count a change output. // Optionally count a change output.
if change { if change {
weightEstimate.AddP2WKHOutput() weightEstimate.AddP2TROutput()
} }
totalWeight := int64(weightEstimate.Weight()) totalWeight := int64(weightEstimate.Weight())
@@ -81,7 +81,7 @@ func TestCalculateFees(t *testing.T) {
}, },
expectedFeeNoChange: 487, expectedFeeNoChange: 487,
expectedFeeWithChange: 611, expectedFeeWithChange: 659,
expectedErr: nil, expectedErr: nil,
}, },
@@ -97,7 +97,7 @@ func TestCalculateFees(t *testing.T) {
}, },
expectedFeeNoChange: 579, expectedFeeNoChange: 579,
expectedFeeWithChange: 703, expectedFeeWithChange: 751,
expectedErr: nil, expectedErr: nil,
}, },
+1 -1
View File
@@ -21,7 +21,7 @@ import (
// //
// Steps to final channel provisioning: // Steps to final channel provisioning:
// 1. Call BindKeys to notify the intent which keys to use when constructing // 1. Call BindKeys to notify the intent which keys to use when constructing
// the multi-sig output. // the multi-sig output.
// 2. Call CompileFundingTx afterwards to obtain the funding transaction. // 2. Call CompileFundingTx afterwards to obtain the funding transaction.
// //
// If either of these steps fail, then the Cancel method MUST be called. // If either of these steps fail, then the Cancel method MUST be called.