Skip to content

Commit 8c784ef

Browse files
committed
sweepbatcher: pass utxo to fee provider
1 parent 7ebe2e5 commit 8c784ef

File tree

4 files changed

+28
-26
lines changed

4 files changed

+28
-26
lines changed

loopout_feerate.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/btcsuite/btcd/btcutil"
88
"github.com/btcsuite/btcd/chaincfg"
99
"github.com/btcsuite/btcd/txscript"
10+
"github.com/btcsuite/btcd/wire"
1011
"github.com/lightninglabs/loop/loopdb"
1112
"github.com/lightninglabs/loop/swap"
1213
"github.com/lightninglabs/loop/utils"
@@ -71,7 +72,8 @@ func newLoopOutSweepFeerateProvider(sweeper sweeper,
7172

7273
// GetMinFeeRate returns minimum required feerate for a sweep by swap hash.
7374
func (p *loopOutSweepFeerateProvider) GetMinFeeRate(ctx context.Context,
74-
swapHash lntypes.Hash) (chainfee.SatPerKWeight, error) {
75+
swapHash lntypes.Hash,
76+
_ wire.OutPoint) (chainfee.SatPerKWeight, error) {
7577

7678
_, feeRate, err := p.GetConfTargetAndFeeRate(ctx, swapHash)
7779

sweepbatcher/sweep_batcher.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ type VerifySchnorrSig func(pubKey *btcec.PublicKey, hash, sig []byte) error
203203

204204
// FeeRateProvider is a function that returns min fee rate of a batch sweeping
205205
// the UTXO of the swap.
206-
type FeeRateProvider func(ctx context.Context,
207-
swapHash lntypes.Hash) (chainfee.SatPerKWeight, error)
206+
type FeeRateProvider func(ctx context.Context, swapHash lntypes.Hash,
207+
utxo wire.OutPoint) (chainfee.SatPerKWeight, error)
208208

209209
// InitialDelayProvider returns the duration after which a newly created batch
210210
// is first published. It allows to customize the duration based on total value
@@ -1519,7 +1519,7 @@ func (b *Batcher) loadSweep(ctx context.Context, swapHash lntypes.Hash,
15191519
// provided, otherwise use wallet's EstimateFeeRate.
15201520
var minFeeRate chainfee.SatPerKWeight
15211521
if b.customFeeRate != nil {
1522-
minFeeRate, err = b.customFeeRate(ctx, swapHash)
1522+
minFeeRate, err = b.customFeeRate(ctx, swapHash, outpoint)
15231523
if err != nil {
15241524
return nil, fmt.Errorf("failed to fetch min fee rate "+
15251525
"for %x: %w", swapHash[:6], err)

sweepbatcher/sweep_batcher_presigned_test.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ func testPresigned_forgotten_presign(t *testing.T,
254254
ctx, cancel := context.WithCancel(context.Background())
255255
defer cancel()
256256

257-
customFeeRate := func(_ context.Context,
258-
_ lntypes.Hash) (chainfee.SatPerKWeight, error) {
257+
customFeeRate := func(_ context.Context, _ lntypes.Hash,
258+
_ wire.OutPoint) (chainfee.SatPerKWeight, error) {
259259

260260
return chainfee.SatPerKWeight(10_000), nil
261261
}
@@ -330,8 +330,8 @@ func testPresigned_input1_offline_then_input2(t *testing.T,
330330
setFeeRate := func(feeRate chainfee.SatPerKWeight) {
331331
currentFeeRate = feeRate
332332
}
333-
customFeeRate := func(_ context.Context,
334-
_ lntypes.Hash) (chainfee.SatPerKWeight, error) {
333+
customFeeRate := func(_ context.Context, _ lntypes.Hash,
334+
_ wire.OutPoint) (chainfee.SatPerKWeight, error) {
335335

336336
return currentFeeRate, nil
337337
}
@@ -511,8 +511,8 @@ func testPresigned_two_inputs_one_goes_offline(t *testing.T,
511511
setFeeRate := func(feeRate chainfee.SatPerKWeight) {
512512
currentFeeRate = feeRate
513513
}
514-
customFeeRate := func(_ context.Context,
515-
_ lntypes.Hash) (chainfee.SatPerKWeight, error) {
514+
customFeeRate := func(_ context.Context, _ lntypes.Hash,
515+
_ wire.OutPoint) (chainfee.SatPerKWeight, error) {
516516

517517
return currentFeeRate, nil
518518
}
@@ -647,8 +647,8 @@ func testPresigned_first_publish_fails(t *testing.T,
647647
setFeeRate := func(feeRate chainfee.SatPerKWeight) {
648648
currentFeeRate = feeRate
649649
}
650-
customFeeRate := func(_ context.Context,
651-
_ lntypes.Hash) (chainfee.SatPerKWeight, error) {
650+
customFeeRate := func(_ context.Context, _ lntypes.Hash,
651+
_ wire.OutPoint) (chainfee.SatPerKWeight, error) {
652652

653653
return currentFeeRate, nil
654654
}
@@ -770,8 +770,8 @@ func testPresigned_locktime(t *testing.T,
770770
setFeeRate := func(feeRate chainfee.SatPerKWeight) {
771771
currentFeeRate = feeRate
772772
}
773-
customFeeRate := func(_ context.Context,
774-
_ lntypes.Hash) (chainfee.SatPerKWeight, error) {
773+
customFeeRate := func(_ context.Context, _ lntypes.Hash,
774+
_ wire.OutPoint) (chainfee.SatPerKWeight, error) {
775775

776776
return currentFeeRate, nil
777777
}
@@ -854,8 +854,8 @@ func testPresigned_presigned_group(t *testing.T,
854854
ctx, cancel := context.WithCancel(context.Background())
855855
defer cancel()
856856

857-
customFeeRate := func(_ context.Context,
858-
_ lntypes.Hash) (chainfee.SatPerKWeight, error) {
857+
customFeeRate := func(_ context.Context, _ lntypes.Hash,
858+
_ wire.OutPoint) (chainfee.SatPerKWeight, error) {
859859

860860
return chainfee.SatPerKWeight(10_000), nil
861861
}
@@ -1091,8 +1091,8 @@ func testPresigned_presigned_and_regular_sweeps(t *testing.T, store testStore,
10911091
setFeeRate := func(feeRate chainfee.SatPerKWeight) {
10921092
currentFeeRate = feeRate
10931093
}
1094-
customFeeRate := func(_ context.Context,
1095-
_ lntypes.Hash) (chainfee.SatPerKWeight, error) {
1094+
customFeeRate := func(_ context.Context, _ lntypes.Hash,
1095+
_ wire.OutPoint) (chainfee.SatPerKWeight, error) {
10961096

10971097
return currentFeeRate, nil
10981098
}
@@ -1372,8 +1372,8 @@ func testPresigned_purging(t *testing.T, numSwaps, numConfirmedSwaps int,
13721372
ctx, cancel := context.WithCancel(context.Background())
13731373
defer cancel()
13741374

1375-
customFeeRate := func(_ context.Context,
1376-
_ lntypes.Hash) (chainfee.SatPerKWeight, error) {
1375+
customFeeRate := func(_ context.Context, _ lntypes.Hash,
1376+
_ wire.OutPoint) (chainfee.SatPerKWeight, error) {
13771377

13781378
return feeRate, nil
13791379
}

sweepbatcher/sweep_batcher_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,8 @@ func testFeeBumping(t *testing.T, store testStore,
408408
// Disable fee bumping, if requested.
409409
var opts []BatcherOption
410410
if noFeeBumping {
411-
customFeeRate := func(ctx context.Context,
412-
swapHash lntypes.Hash) (chainfee.SatPerKWeight, error) {
411+
customFeeRate := func(_ context.Context, _ lntypes.Hash,
412+
_ wire.OutPoint) (chainfee.SatPerKWeight, error) {
413413

414414
// Always provide the same value, no bumping.
415415
return test.DefaultMockFee, nil
@@ -3844,8 +3844,8 @@ func testSweepFetcher(t *testing.T, store testStore,
38443844
require.NoError(t, err)
38453845
store.AssertLoopOutStored()
38463846

3847-
customFeeRate := func(ctx context.Context,
3848-
swapHash lntypes.Hash) (chainfee.SatPerKWeight, error) {
3847+
customFeeRate := func(_ context.Context, _ lntypes.Hash,
3848+
_ wire.OutPoint) (chainfee.SatPerKWeight, error) {
38493849

38503850
// Always provide the same value, no bumping.
38513851
return feeRate, nil
@@ -4691,8 +4691,8 @@ func testFeeRateGrows(t *testing.T, store testStore,
46914691
swap2feeRate[swapHash] = rate
46924692
}
46934693

4694-
customFeeRate := func(ctx context.Context,
4695-
swapHash lntypes.Hash) (chainfee.SatPerKWeight, error) {
4694+
customFeeRate := func(_ context.Context, swapHash lntypes.Hash,
4695+
_ wire.OutPoint) (chainfee.SatPerKWeight, error) {
46964696

46974697
swap2feeRateMu.Lock()
46984698
defer swap2feeRateMu.Unlock()

0 commit comments

Comments
 (0)