Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chanfunding: improve sanityCheckFee error message for clarity #9219

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lnwallet/chanfunding/coin_select.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
11 changes: 6 additions & 5 deletions lnwallet/chanfunding/coin_select_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -606,7 +606,8 @@ func TestCoinSelectSubtractFees(t *testing.T) {
},
spendValue: 5 * fundingFee(highFeeRate, 1, false),

expectErr: "fee <amt> BTC on total output value <amt> BTC",
expectErr: "fee (<amt> BTC) exceeds <amt>% of total " +
"output (<amt> BTC)",
},
}

Expand Down Expand Up @@ -812,8 +813,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.
Expand Down
Loading