lnwallet/chanfunding: assumes all change outputs are P2TR

This commit is contained in:
Olaoluwa Osuntokun 2022-08-10 18:33:52 -07:00
parent 322937a67e
commit 42549519ca
No known key found for this signature in database
GPG Key ID: 3BBD59E99B280306
3 changed files with 8 additions and 7 deletions

View File

@ -98,8 +98,8 @@ func calculateFees(utxos []Coin, feeRate chainfee.SatPerKWeight) (btcutil.Amount
requiredFeeNoChange := feeRate.FeeForWeight(totalWeight)
// Estimate the fee required for a transaction with a change output.
// Assume that change output is a P2WKH output.
weightEstimate.AddP2WKHOutput()
// Assume that change output is a P2TR output.
weightEstimate.AddP2TROutput()
// Now that we have added the change output, redo the fee
// estimate.
@ -209,7 +209,8 @@ func CoinSelectSubtractFees(feeRate chainfee.SatPerKWeight, amt,
// Obtain fee estimates both with and without using a change
// output.
requiredFeeNoChange, requiredFeeWithChange, err := calculateFees(
selectedUtxos, feeRate)
selectedUtxos, feeRate,
)
if err != nil {
return nil, 0, 0, err
}

View File

@ -44,7 +44,7 @@ func fundingFee(feeRate chainfee.SatPerKWeight, numInput int, // nolint:unparam
// Optionally count a change output.
if change {
weightEstimate.AddP2WKHOutput()
weightEstimate.AddP2TROutput()
}
totalWeight := int64(weightEstimate.Weight())
@ -81,7 +81,7 @@ func TestCalculateFees(t *testing.T) {
},
expectedFeeNoChange: 487,
expectedFeeWithChange: 611,
expectedFeeWithChange: 659,
expectedErr: nil,
},
@ -97,7 +97,7 @@ func TestCalculateFees(t *testing.T) {
},
expectedFeeNoChange: 579,
expectedFeeWithChange: 703,
expectedFeeWithChange: 751,
expectedErr: nil,
},

View File

@ -21,7 +21,7 @@ import (
//
// Steps to final channel provisioning:
// 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.
//
// If either of these steps fail, then the Cancel method MUST be called.