From 42549519ca6676f27530139ef24f5ad70d254675 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 10 Aug 2022 18:33:52 -0700 Subject: [PATCH] lnwallet/chanfunding: assumes all change outputs are P2TR --- lnwallet/chanfunding/coin_select.go | 7 ++++--- lnwallet/chanfunding/coin_select_test.go | 6 +++--- lnwallet/chanfunding/wallet_assembler.go | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lnwallet/chanfunding/coin_select.go b/lnwallet/chanfunding/coin_select.go index 761f7c032..049d94cdd 100644 --- a/lnwallet/chanfunding/coin_select.go +++ b/lnwallet/chanfunding/coin_select.go @@ -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 } diff --git a/lnwallet/chanfunding/coin_select_test.go b/lnwallet/chanfunding/coin_select_test.go index 0f3d4ef4b..d243cd358 100644 --- a/lnwallet/chanfunding/coin_select_test.go +++ b/lnwallet/chanfunding/coin_select_test.go @@ -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, }, diff --git a/lnwallet/chanfunding/wallet_assembler.go b/lnwallet/chanfunding/wallet_assembler.go index 376360901..6d9c1974e 100644 --- a/lnwallet/chanfunding/wallet_assembler.go +++ b/lnwallet/chanfunding/wallet_assembler.go @@ -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.