mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-19 02:27:06 +01:00
lnwallet+lnrpc: use maxFeeRatio across coin selection tests
This commit is contained in:
@@ -162,10 +162,18 @@ func TestFundPsbtCoinSelect(t *testing.T) {
|
|||||||
// packet in bytes.
|
// packet in bytes.
|
||||||
expectedFee btcutil.Amount
|
expectedFee btcutil.Amount
|
||||||
|
|
||||||
|
// maxFeeRatio is the maximum fee to total output amount ratio
|
||||||
|
// that we consider valid.
|
||||||
|
maxFeeRatio float64
|
||||||
|
|
||||||
// expectedErr is the expected concrete error. If not nil, then
|
// expectedErr is the expected concrete error. If not nil, then
|
||||||
// the error must match exactly.
|
// the error must match exactly.
|
||||||
expectedErr error
|
expectedErr error
|
||||||
|
|
||||||
|
// expectedContainedErrStr is the expected string to be
|
||||||
|
// contained in the returned error.
|
||||||
|
expectedContainedErrStr string
|
||||||
|
|
||||||
// expectedErrType is the expected error type. If not nil, then
|
// expectedErrType is the expected error type. If not nil, then
|
||||||
// the error must be of this type.
|
// the error must be of this type.
|
||||||
expectedErrType error
|
expectedErrType error
|
||||||
@@ -178,6 +186,7 @@ func TestFundPsbtCoinSelect(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
changeIndex: -1,
|
changeIndex: -1,
|
||||||
feeRate: chainfee.FeePerKwFloor,
|
feeRate: chainfee.FeePerKwFloor,
|
||||||
|
maxFeeRatio: chanfunding.DefaultMaxFeeRatio,
|
||||||
expectedErrType: &chanfunding.ErrInsufficientFunds{},
|
expectedErrType: &chanfunding.ErrInsufficientFunds{},
|
||||||
}, {
|
}, {
|
||||||
name: "1 p2wpkh utxo, add p2wkh change",
|
name: "1 p2wpkh utxo, add p2wkh change",
|
||||||
@@ -193,6 +202,7 @@ func TestFundPsbtCoinSelect(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
changeIndex: -1,
|
changeIndex: -1,
|
||||||
feeRate: chainfee.FeePerKwFloor,
|
feeRate: chainfee.FeePerKwFloor,
|
||||||
|
maxFeeRatio: chanfunding.DefaultMaxFeeRatio,
|
||||||
expectedUtxoIndexes: []int{0},
|
expectedUtxoIndexes: []int{0},
|
||||||
expectChangeOutputIndex: 1,
|
expectChangeOutputIndex: 1,
|
||||||
expectedFee: calcFee(0, 1, 1, 1, 0),
|
expectedFee: calcFee(0, 1, 1, 1, 0),
|
||||||
@@ -210,6 +220,7 @@ func TestFundPsbtCoinSelect(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
changeIndex: -1,
|
changeIndex: -1,
|
||||||
feeRate: chainfee.FeePerKwFloor,
|
feeRate: chainfee.FeePerKwFloor,
|
||||||
|
maxFeeRatio: chanfunding.DefaultMaxFeeRatio,
|
||||||
changeType: chanfunding.P2TRChangeAddress,
|
changeType: chanfunding.P2TRChangeAddress,
|
||||||
expectedUtxoIndexes: []int{0},
|
expectedUtxoIndexes: []int{0},
|
||||||
expectChangeOutputIndex: 1,
|
expectChangeOutputIndex: 1,
|
||||||
@@ -228,6 +239,7 @@ func TestFundPsbtCoinSelect(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
changeIndex: -1,
|
changeIndex: -1,
|
||||||
feeRate: chainfee.FeePerKwFloor,
|
feeRate: chainfee.FeePerKwFloor,
|
||||||
|
maxFeeRatio: chanfunding.DefaultMaxFeeRatio,
|
||||||
expectedUtxoIndexes: []int{0},
|
expectedUtxoIndexes: []int{0},
|
||||||
expectChangeOutputIndex: -1,
|
expectChangeOutputIndex: -1,
|
||||||
expectedFee: calcFee(0, 1, 1, 0, 0),
|
expectedFee: calcFee(0, 1, 1, 0, 0),
|
||||||
@@ -247,6 +259,7 @@ func TestFundPsbtCoinSelect(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
changeIndex: -1,
|
changeIndex: -1,
|
||||||
feeRate: chainfee.FeePerKwFloor,
|
feeRate: chainfee.FeePerKwFloor,
|
||||||
|
maxFeeRatio: chanfunding.DefaultMaxFeeRatio,
|
||||||
changeType: chanfunding.P2WKHChangeAddress,
|
changeType: chanfunding.P2WKHChangeAddress,
|
||||||
expectedUtxoIndexes: []int{0},
|
expectedUtxoIndexes: []int{0},
|
||||||
expectChangeOutputIndex: -1,
|
expectChangeOutputIndex: -1,
|
||||||
@@ -267,6 +280,7 @@ func TestFundPsbtCoinSelect(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
changeIndex: -1,
|
changeIndex: -1,
|
||||||
feeRate: chainfee.FeePerKwFloor,
|
feeRate: chainfee.FeePerKwFloor,
|
||||||
|
maxFeeRatio: chanfunding.DefaultMaxFeeRatio,
|
||||||
changeType: chanfunding.P2TRChangeAddress,
|
changeType: chanfunding.P2TRChangeAddress,
|
||||||
expectedUtxoIndexes: []int{0},
|
expectedUtxoIndexes: []int{0},
|
||||||
expectChangeOutputIndex: -1,
|
expectChangeOutputIndex: -1,
|
||||||
@@ -285,6 +299,7 @@ func TestFundPsbtCoinSelect(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
changeIndex: 0,
|
changeIndex: 0,
|
||||||
feeRate: chainfee.FeePerKwFloor,
|
feeRate: chainfee.FeePerKwFloor,
|
||||||
|
maxFeeRatio: chanfunding.DefaultMaxFeeRatio,
|
||||||
changeType: chanfunding.ExistingChangeAddress,
|
changeType: chanfunding.ExistingChangeAddress,
|
||||||
expectedUtxoIndexes: []int{0},
|
expectedUtxoIndexes: []int{0},
|
||||||
expectChangeOutputIndex: 0,
|
expectChangeOutputIndex: 0,
|
||||||
@@ -303,6 +318,7 @@ func TestFundPsbtCoinSelect(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
changeIndex: 0,
|
changeIndex: 0,
|
||||||
feeRate: chainfee.FeePerKwFloor,
|
feeRate: chainfee.FeePerKwFloor,
|
||||||
|
maxFeeRatio: chanfunding.DefaultMaxFeeRatio,
|
||||||
changeType: chanfunding.ExistingChangeAddress,
|
changeType: chanfunding.ExistingChangeAddress,
|
||||||
expectedUtxoIndexes: []int{0},
|
expectedUtxoIndexes: []int{0},
|
||||||
expectChangeOutputIndex: 0,
|
expectChangeOutputIndex: 0,
|
||||||
@@ -321,6 +337,7 @@ func TestFundPsbtCoinSelect(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
changeIndex: 0,
|
changeIndex: 0,
|
||||||
feeRate: chainfee.FeePerKwFloor,
|
feeRate: chainfee.FeePerKwFloor,
|
||||||
|
maxFeeRatio: chanfunding.DefaultMaxFeeRatio,
|
||||||
changeType: chanfunding.ExistingChangeAddress,
|
changeType: chanfunding.ExistingChangeAddress,
|
||||||
expectedUtxoIndexes: []int{0},
|
expectedUtxoIndexes: []int{0},
|
||||||
expectChangeOutputIndex: 0,
|
expectChangeOutputIndex: 0,
|
||||||
@@ -369,6 +386,7 @@ func TestFundPsbtCoinSelect(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
changeIndex: 0,
|
changeIndex: 0,
|
||||||
feeRate: chainfee.FeePerKwFloor,
|
feeRate: chainfee.FeePerKwFloor,
|
||||||
|
maxFeeRatio: chanfunding.DefaultMaxFeeRatio,
|
||||||
changeType: chanfunding.ExistingChangeAddress,
|
changeType: chanfunding.ExistingChangeAddress,
|
||||||
expectedUtxoIndexes: []int{0, 1},
|
expectedUtxoIndexes: []int{0, 1},
|
||||||
expectChangeOutputIndex: 0,
|
expectChangeOutputIndex: 0,
|
||||||
@@ -417,6 +435,7 @@ func TestFundPsbtCoinSelect(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
changeIndex: -1,
|
changeIndex: -1,
|
||||||
feeRate: chainfee.FeePerKwFloor,
|
feeRate: chainfee.FeePerKwFloor,
|
||||||
|
maxFeeRatio: chanfunding.DefaultMaxFeeRatio,
|
||||||
changeType: chanfunding.P2TRChangeAddress,
|
changeType: chanfunding.P2TRChangeAddress,
|
||||||
expectedUtxoIndexes: []int{0, 1},
|
expectedUtxoIndexes: []int{0, 1},
|
||||||
expectChangeOutputIndex: 1,
|
expectChangeOutputIndex: 1,
|
||||||
@@ -456,6 +475,7 @@ func TestFundPsbtCoinSelect(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
changeIndex: -1,
|
changeIndex: -1,
|
||||||
feeRate: chainfee.FeePerKwFloor,
|
feeRate: chainfee.FeePerKwFloor,
|
||||||
|
maxFeeRatio: chanfunding.DefaultMaxFeeRatio,
|
||||||
changeType: chanfunding.P2WKHChangeAddress,
|
changeType: chanfunding.P2WKHChangeAddress,
|
||||||
expectedUtxoIndexes: []int{},
|
expectedUtxoIndexes: []int{},
|
||||||
expectChangeOutputIndex: 1,
|
expectChangeOutputIndex: 1,
|
||||||
@@ -497,10 +517,74 @@ func TestFundPsbtCoinSelect(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
changeIndex: -1,
|
changeIndex: -1,
|
||||||
feeRate: chainfee.FeePerKwFloor,
|
feeRate: chainfee.FeePerKwFloor,
|
||||||
|
maxFeeRatio: chanfunding.DefaultMaxFeeRatio,
|
||||||
changeType: chanfunding.P2TRChangeAddress,
|
changeType: chanfunding.P2TRChangeAddress,
|
||||||
expectedUtxoIndexes: []int{},
|
expectedUtxoIndexes: []int{},
|
||||||
expectChangeOutputIndex: -1,
|
expectChangeOutputIndex: -1,
|
||||||
expectedFee: calcFee(1, 0, 1, 0, 0),
|
expectedFee: calcFee(1, 0, 1, 0, 0),
|
||||||
|
}, {
|
||||||
|
name: "1 p2wpkh utxo, existing p2wkh change, invalid fee ratio",
|
||||||
|
utxos: []*lnwallet.Utxo{
|
||||||
|
{
|
||||||
|
Value: 250,
|
||||||
|
PkScript: p2wkhScript,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
packet: makePacket(&wire.TxOut{
|
||||||
|
Value: 50,
|
||||||
|
PkScript: p2wkhScript,
|
||||||
|
}),
|
||||||
|
changeIndex: 0,
|
||||||
|
feeRate: chainfee.FeePerKwFloor,
|
||||||
|
maxFeeRatio: chanfunding.DefaultMaxFeeRatio,
|
||||||
|
changeType: chanfunding.ExistingChangeAddress,
|
||||||
|
expectedUtxoIndexes: []int{0},
|
||||||
|
expectChangeOutputIndex: 0,
|
||||||
|
expectedFee: calcFee(0, 1, 0, 1, 0),
|
||||||
|
|
||||||
|
expectedContainedErrStr: "fee 0.00000111 BTC exceeds max fee " +
|
||||||
|
"(0.00000027 BTC) on total output value",
|
||||||
|
}, {
|
||||||
|
name: "1 p2wpkh utxo, existing p2wkh change, negative feeratio",
|
||||||
|
utxos: []*lnwallet.Utxo{
|
||||||
|
{
|
||||||
|
Value: 250,
|
||||||
|
PkScript: p2wkhScript,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
packet: makePacket(&wire.TxOut{
|
||||||
|
Value: 50,
|
||||||
|
PkScript: p2wkhScript,
|
||||||
|
}),
|
||||||
|
changeIndex: 0,
|
||||||
|
feeRate: chainfee.FeePerKwFloor,
|
||||||
|
maxFeeRatio: chanfunding.DefaultMaxFeeRatio * (-1),
|
||||||
|
changeType: chanfunding.ExistingChangeAddress,
|
||||||
|
expectedUtxoIndexes: []int{0},
|
||||||
|
expectChangeOutputIndex: 0,
|
||||||
|
expectedFee: calcFee(0, 1, 0, 1, 0),
|
||||||
|
|
||||||
|
expectedContainedErrStr: "maxFeeRatio must be between 0.00 " +
|
||||||
|
"and 1.00 got -0.20",
|
||||||
|
}, {
|
||||||
|
name: "1 p2wpkh utxo, existing p2wkh change, big fee ratio",
|
||||||
|
utxos: []*lnwallet.Utxo{
|
||||||
|
{
|
||||||
|
Value: 250,
|
||||||
|
PkScript: p2wkhScript,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
packet: makePacket(&wire.TxOut{
|
||||||
|
Value: 50,
|
||||||
|
PkScript: p2wkhScript,
|
||||||
|
}),
|
||||||
|
changeIndex: 0,
|
||||||
|
feeRate: chainfee.FeePerKwFloor,
|
||||||
|
maxFeeRatio: 0.85,
|
||||||
|
changeType: chanfunding.ExistingChangeAddress,
|
||||||
|
expectedUtxoIndexes: []int{0},
|
||||||
|
expectChangeOutputIndex: 0,
|
||||||
|
expectedFee: calcFee(0, 1, 0, 1, 0),
|
||||||
}, {
|
}, {
|
||||||
name: "large existing p2tr input, fee estimation existing " +
|
name: "large existing p2tr input, fee estimation existing " +
|
||||||
"change output",
|
"change output",
|
||||||
@@ -536,6 +620,7 @@ func TestFundPsbtCoinSelect(t *testing.T) {
|
|||||||
}),
|
}),
|
||||||
changeIndex: 0,
|
changeIndex: 0,
|
||||||
feeRate: chainfee.FeePerKwFloor,
|
feeRate: chainfee.FeePerKwFloor,
|
||||||
|
maxFeeRatio: chanfunding.DefaultMaxFeeRatio,
|
||||||
changeType: chanfunding.ExistingChangeAddress,
|
changeType: chanfunding.ExistingChangeAddress,
|
||||||
expectedUtxoIndexes: []int{},
|
expectedUtxoIndexes: []int{},
|
||||||
expectChangeOutputIndex: 0,
|
expectChangeOutputIndex: 0,
|
||||||
@@ -574,7 +659,8 @@ func TestFundPsbtCoinSelect(t *testing.T) {
|
|||||||
resp, err := rpcServer.fundPsbtCoinSelect(
|
resp, err := rpcServer.fundPsbtCoinSelect(
|
||||||
"", tc.changeIndex, copiedPacket, 0,
|
"", tc.changeIndex, copiedPacket, 0,
|
||||||
tc.changeType, tc.feeRate,
|
tc.changeType, tc.feeRate,
|
||||||
rpcServer.cfg.CoinSelectionStrategy, 0,
|
rpcServer.cfg.CoinSelectionStrategy,
|
||||||
|
tc.maxFeeRatio,
|
||||||
)
|
)
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
@@ -588,6 +674,12 @@ func TestFundPsbtCoinSelect(t *testing.T) {
|
|||||||
require.Error(tt, err)
|
require.Error(tt, err)
|
||||||
require.ErrorAs(tt, err, &tc.expectedErr)
|
require.ErrorAs(tt, err, &tc.expectedErr)
|
||||||
|
|
||||||
|
return
|
||||||
|
case tc.expectedContainedErrStr != "":
|
||||||
|
require.ErrorContains(
|
||||||
|
tt, err, tc.expectedContainedErrStr,
|
||||||
|
)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -316,7 +316,8 @@ func TestCoinSelect(t *testing.T) {
|
|||||||
selected, changeAmt, err := CoinSelect(
|
selected, changeAmt, err := CoinSelect(
|
||||||
feeRate, test.outputValue, dustLimit,
|
feeRate, test.outputValue, dustLimit,
|
||||||
test.coins, wallet.CoinSelectionLargest,
|
test.coins, wallet.CoinSelectionLargest,
|
||||||
fundingOutputEstimate, test.changeType, 0,
|
fundingOutputEstimate, test.changeType,
|
||||||
|
DefaultMaxFeeRatio,
|
||||||
)
|
)
|
||||||
|
|
||||||
if test.expectErr {
|
if test.expectErr {
|
||||||
@@ -356,6 +357,7 @@ func TestCalculateChangeAmount(t *testing.T) {
|
|||||||
feeWithChange btcutil.Amount
|
feeWithChange btcutil.Amount
|
||||||
dustLimit btcutil.Amount
|
dustLimit btcutil.Amount
|
||||||
changeType ChangeAddressType
|
changeType ChangeAddressType
|
||||||
|
maxFeeRatio float64
|
||||||
|
|
||||||
expectErr string
|
expectErr string
|
||||||
expectChangeAmt btcutil.Amount
|
expectChangeAmt btcutil.Amount
|
||||||
@@ -369,6 +371,7 @@ func TestCalculateChangeAmount(t *testing.T) {
|
|||||||
totalInputAmt: 500,
|
totalInputAmt: 500,
|
||||||
requiredAmt: 490,
|
requiredAmt: 490,
|
||||||
feeNoChange: 12,
|
feeNoChange: 12,
|
||||||
|
maxFeeRatio: DefaultMaxFeeRatio,
|
||||||
|
|
||||||
expectNeedMore: 502,
|
expectNeedMore: 502,
|
||||||
}, {
|
}, {
|
||||||
@@ -383,6 +386,7 @@ func TestCalculateChangeAmount(t *testing.T) {
|
|||||||
feeWithChange: 10,
|
feeWithChange: 10,
|
||||||
dustLimit: 100,
|
dustLimit: 100,
|
||||||
changeType: ExistingChangeAddress,
|
changeType: ExistingChangeAddress,
|
||||||
|
maxFeeRatio: DefaultMaxFeeRatio,
|
||||||
|
|
||||||
expectChangeAmt: 90,
|
expectChangeAmt: 90,
|
||||||
}, {
|
}, {
|
||||||
@@ -392,6 +396,7 @@ func TestCalculateChangeAmount(t *testing.T) {
|
|||||||
feeNoChange: 40,
|
feeNoChange: 40,
|
||||||
feeWithChange: 50,
|
feeWithChange: 50,
|
||||||
dustLimit: 100,
|
dustLimit: 100,
|
||||||
|
maxFeeRatio: DefaultMaxFeeRatio,
|
||||||
|
|
||||||
expectChangeAmt: 150,
|
expectChangeAmt: 150,
|
||||||
}, {
|
}, {
|
||||||
@@ -401,6 +406,7 @@ func TestCalculateChangeAmount(t *testing.T) {
|
|||||||
requiredAmt: 460,
|
requiredAmt: 460,
|
||||||
feeNoChange: 40,
|
feeNoChange: 40,
|
||||||
feeWithChange: 50,
|
feeWithChange: 50,
|
||||||
|
maxFeeRatio: DefaultMaxFeeRatio,
|
||||||
|
|
||||||
expectChangeAmt: 0,
|
expectChangeAmt: 0,
|
||||||
}, {
|
}, {
|
||||||
@@ -410,14 +416,36 @@ func TestCalculateChangeAmount(t *testing.T) {
|
|||||||
feeNoChange: 10,
|
feeNoChange: 10,
|
||||||
feeWithChange: 45,
|
feeWithChange: 45,
|
||||||
dustLimit: 5,
|
dustLimit: 5,
|
||||||
|
maxFeeRatio: DefaultMaxFeeRatio,
|
||||||
|
|
||||||
expectErr: "fee (0.00000045 BTC) exceeds 20% of total output " +
|
expectErr: "fee 0.00000045 BTC exceeds max fee (0.00000011 " +
|
||||||
"(0.00000055 BTC)",
|
"BTC) on total output value 0.00000055 BTC",
|
||||||
|
}, {
|
||||||
|
name: "fee percent ok",
|
||||||
|
totalInputAmt: 100,
|
||||||
|
requiredAmt: 50,
|
||||||
|
feeNoChange: 10,
|
||||||
|
feeWithChange: 45,
|
||||||
|
dustLimit: 5,
|
||||||
|
maxFeeRatio: 0.95,
|
||||||
|
|
||||||
|
expectChangeAmt: 5,
|
||||||
|
}, {
|
||||||
|
name: "invalid max fee ratio",
|
||||||
|
totalInputAmt: 100,
|
||||||
|
requiredAmt: 50,
|
||||||
|
feeNoChange: 10,
|
||||||
|
feeWithChange: 45,
|
||||||
|
dustLimit: 5,
|
||||||
|
maxFeeRatio: 3.14,
|
||||||
|
|
||||||
|
expectErr: "maxFeeRatio must be between 0.00 and 1.00",
|
||||||
}, {
|
}, {
|
||||||
name: "invalid usage of function",
|
name: "invalid usage of function",
|
||||||
feeNoChange: 5,
|
feeNoChange: 5,
|
||||||
feeWithChange: 10,
|
feeWithChange: 10,
|
||||||
changeType: ExistingChangeAddress,
|
changeType: ExistingChangeAddress,
|
||||||
|
maxFeeRatio: DefaultMaxFeeRatio,
|
||||||
|
|
||||||
expectErr: "fees for with or without change must be the same",
|
expectErr: "fees for with or without change must be the same",
|
||||||
}}
|
}}
|
||||||
@@ -428,7 +456,7 @@ func TestCalculateChangeAmount(t *testing.T) {
|
|||||||
changeAmt, needMore, err := CalculateChangeAmount(
|
changeAmt, needMore, err := CalculateChangeAmount(
|
||||||
tc.totalInputAmt, tc.requiredAmt,
|
tc.totalInputAmt, tc.requiredAmt,
|
||||||
tc.feeNoChange, tc.feeWithChange, tc.dustLimit,
|
tc.feeNoChange, tc.feeWithChange, tc.dustLimit,
|
||||||
tc.changeType, 0,
|
tc.changeType, tc.maxFeeRatio,
|
||||||
)
|
)
|
||||||
|
|
||||||
if tc.expectErr != "" {
|
if tc.expectErr != "" {
|
||||||
@@ -606,8 +634,9 @@ func TestCoinSelectSubtractFees(t *testing.T) {
|
|||||||
},
|
},
|
||||||
spendValue: 5 * fundingFee(highFeeRate, 1, false),
|
spendValue: 5 * fundingFee(highFeeRate, 1, false),
|
||||||
|
|
||||||
expectErr: "fee (<amt> BTC) exceeds <amt>% of total " +
|
expectErr: "fee <amt> BTC exceeds max fee (<amt> " +
|
||||||
"output (<amt> BTC)",
|
"BTC) on total output value <amt> BTC with " +
|
||||||
|
"max fee ratio of <amt>",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -627,7 +656,8 @@ func TestCoinSelectSubtractFees(t *testing.T) {
|
|||||||
feeRate, test.spendValue, dustLimit, test.coins,
|
feeRate, test.spendValue, dustLimit, test.coins,
|
||||||
wallet.CoinSelectionLargest,
|
wallet.CoinSelectionLargest,
|
||||||
fundingOutputEstimate,
|
fundingOutputEstimate,
|
||||||
defaultChanFundingChangeType, 0,
|
defaultChanFundingChangeType,
|
||||||
|
DefaultMaxFeeRatio,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch {
|
switch {
|
||||||
@@ -813,8 +843,9 @@ func TestCoinSelectUpToAmount(t *testing.T) {
|
|||||||
minValue: minValue,
|
minValue: minValue,
|
||||||
maxValue: 16 * fundingFee(feeRate, 1, false),
|
maxValue: 16 * fundingFee(feeRate, 1, false),
|
||||||
|
|
||||||
expectErr: "fee (0.00000192 BTC) exceeds 20% of total output " +
|
expectErr: "fee 0.00000192 BTC exceeds max fee (0.00000153 " +
|
||||||
"(0.00000768 BTC)",
|
"BTC) on total output value 0.00000768 BTC with max " +
|
||||||
|
"fee ratio of 0.20",
|
||||||
}, {
|
}, {
|
||||||
// This test makes sure that the implementation detail of using
|
// This test makes sure that the implementation detail of using
|
||||||
// CoinSelect and CoinSelectSubtractFees is done correctly.
|
// CoinSelect and CoinSelectSubtractFees is done correctly.
|
||||||
@@ -872,7 +903,8 @@ func TestCoinSelectUpToAmount(t *testing.T) {
|
|||||||
test.reserved, dustLimit, test.coins,
|
test.reserved, dustLimit, test.coins,
|
||||||
wallet.CoinSelectionLargest,
|
wallet.CoinSelectionLargest,
|
||||||
fundingOutputEstimate,
|
fundingOutputEstimate,
|
||||||
defaultChanFundingChangeType, 0,
|
defaultChanFundingChangeType,
|
||||||
|
DefaultMaxFeeRatio,
|
||||||
)
|
)
|
||||||
if len(test.expectErr) == 0 && err != nil {
|
if len(test.expectErr) == 0 && err != nil {
|
||||||
t.Fatal(err.Error())
|
t.Fatal(err.Error())
|
||||||
|
|||||||
Reference in New Issue
Block a user