From 16c0ce40797a283a85cb279144f136dd5554389a Mon Sep 17 00:00:00 2001 From: myxmaster <77545287+myxmaster@users.noreply.github.com> Date: Wed, 23 Oct 2024 23:37:54 +0200 Subject: [PATCH] chanfunding: improve sanityCheckFee error message for clarity and update coin_select_test accordingly --- lnwallet/chanfunding/coin_select.go | 4 ++-- lnwallet/chanfunding/coin_select_test.go | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lnwallet/chanfunding/coin_select.go b/lnwallet/chanfunding/coin_select.go index b9ff1be21f6..e2c85c9d342 100644 --- a/lnwallet/chanfunding/coin_select.go +++ b/lnwallet/chanfunding/coin_select.go @@ -150,8 +150,8 @@ func sanityCheckFee(totalOut, fee btcutil.Amount) error { // TODO(halseth): smarter fee limit. Make configurable or dynamic wrt // total funding size? if fee > totalOut/5 { - return fmt.Errorf("fee %v on total output value %v", fee, - totalOut) + return fmt.Errorf("fee (%v) exceeds 20%% of total output (%v)", + fee, totalOut) } return nil } diff --git a/lnwallet/chanfunding/coin_select_test.go b/lnwallet/chanfunding/coin_select_test.go index 26a257b37f8..a20d27ac95a 100644 --- a/lnwallet/chanfunding/coin_select_test.go +++ b/lnwallet/chanfunding/coin_select_test.go @@ -411,8 +411,8 @@ func TestCalculateChangeAmount(t *testing.T) { feeWithChange: 45, dustLimit: 5, - expectErr: "fee 0.00000045 BTC on total output value " + - "0.00000055", + expectErr: "fee (0.00000045 BTC) exceeds 20% of total output " + + "(0.00000055 BTC)", }, { name: "invalid usage of function", feeNoChange: 5, @@ -606,7 +606,7 @@ func TestCoinSelectSubtractFees(t *testing.T) { }, spendValue: 5 * fundingFee(highFeeRate, 1, false), - expectErr: "fee BTC on total output value BTC", + expectErr: "fee ( BTC) exceeds % of total output ( BTC)", }, } @@ -812,8 +812,8 @@ func TestCoinSelectUpToAmount(t *testing.T) { minValue: minValue, maxValue: 16 * fundingFee(feeRate, 1, false), - expectErr: "fee 0.00000192 BTC on total output value " + - "0.00000768 BTC", + expectErr: "fee (0.00000192 BTC) exceeds 20% of total output " + + "(0.00000768 BTC)", }, { // This test makes sure that the implementation detail of using // CoinSelect and CoinSelectSubtractFees is done correctly.