loopout: fix fee estimate failure if conf_target=1

The fee estimator fails if conf_target=1. Use conf_target=2 instead.

Fix https://github.com/lightninglabs/loop/issues/898
This commit is contained in:
Boris Nagaev 2025-03-18 10:58:23 -03:00
parent a253b40062
commit ddeb43d293
No known key found for this signature in database
2 changed files with 10 additions and 10 deletions

View file

@ -136,14 +136,14 @@ func (p *loopOutSweepFeerateProvider) GetConfTargetAndFeeRate(
// opens for the client to sweep.
blocksUntilExpiry := contract.CltvExpiry - height
// Find confTarget. If the sweep has expired, use confTarget=1, because
// confTarget must be positive.
// Find confTarget. If the sweep has expired, use confTarget=2, because
// fee estimator fails if confTarget < 2.
confTarget := blocksUntilExpiry
if confTarget <= 0 {
if confTarget < 2 {
log.Infof("Swap %x has expired (blocksUntilExpiry=%d), using "+
"confTarget=1 for it.", swapHash[:6], blocksUntilExpiry)
"confTarget=2 for it.", swapHash[:6], blocksUntilExpiry)
confTarget = 1
confTarget = 2
}
feeFactor := float64(1.0)

View file

@ -35,7 +35,7 @@ func (s testSweeper) GetSweepFeeDetails(ctx context.Context,
return 0, 0, 0, fmt.Errorf("zero sweepConfTarget")
case sweepConfTarget == 1:
feeRate = 30000
return 0, 0, 0, fmt.Errorf("sweepConfTarget is 1")
case sweepConfTarget == 2:
feeRate = 25000
@ -213,8 +213,8 @@ func TestLoopOutSweepFeerateProvider(t *testing.T) {
height: 800_999,
amount: 1_000_000,
protocolVersion: loopdb.ProtocolVersionMuSig2,
wantConfTarget: 1,
wantFeeRate: 33000,
wantConfTarget: 2,
wantFeeRate: 27500,
},
{
name: "expired",
@ -222,8 +222,8 @@ func TestLoopOutSweepFeerateProvider(t *testing.T) {
height: 801_000,
amount: 1_000_000,
protocolVersion: loopdb.ProtocolVersionMuSig2,
wantConfTarget: 1,
wantFeeRate: 33000,
wantConfTarget: 2,
wantFeeRate: 27500,
},
}