mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
sweepbatcher: pass utxo to fee provider
This commit is contained in:
parent
7ebe2e5b30
commit
8c784ef761
4 changed files with 28 additions and 26 deletions
|
|
@ -7,6 +7,7 @@ import (
|
|||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightninglabs/loop/loopdb"
|
||||
"github.com/lightninglabs/loop/swap"
|
||||
"github.com/lightninglabs/loop/utils"
|
||||
|
|
@ -71,7 +72,8 @@ func newLoopOutSweepFeerateProvider(sweeper sweeper,
|
|||
|
||||
// GetMinFeeRate returns minimum required feerate for a sweep by swap hash.
|
||||
func (p *loopOutSweepFeerateProvider) GetMinFeeRate(ctx context.Context,
|
||||
swapHash lntypes.Hash) (chainfee.SatPerKWeight, error) {
|
||||
swapHash lntypes.Hash,
|
||||
_ wire.OutPoint) (chainfee.SatPerKWeight, error) {
|
||||
|
||||
_, feeRate, err := p.GetConfTargetAndFeeRate(ctx, swapHash)
|
||||
|
||||
|
|
|
|||
|
|
@ -203,8 +203,8 @@ type VerifySchnorrSig func(pubKey *btcec.PublicKey, hash, sig []byte) error
|
|||
|
||||
// FeeRateProvider is a function that returns min fee rate of a batch sweeping
|
||||
// the UTXO of the swap.
|
||||
type FeeRateProvider func(ctx context.Context,
|
||||
swapHash lntypes.Hash) (chainfee.SatPerKWeight, error)
|
||||
type FeeRateProvider func(ctx context.Context, swapHash lntypes.Hash,
|
||||
utxo wire.OutPoint) (chainfee.SatPerKWeight, error)
|
||||
|
||||
// InitialDelayProvider returns the duration after which a newly created batch
|
||||
// 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,
|
|||
// provided, otherwise use wallet's EstimateFeeRate.
|
||||
var minFeeRate chainfee.SatPerKWeight
|
||||
if b.customFeeRate != nil {
|
||||
minFeeRate, err = b.customFeeRate(ctx, swapHash)
|
||||
minFeeRate, err = b.customFeeRate(ctx, swapHash, outpoint)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to fetch min fee rate "+
|
||||
"for %x: %w", swapHash[:6], err)
|
||||
|
|
|
|||
|
|
@ -254,8 +254,8 @@ func testPresigned_forgotten_presign(t *testing.T,
|
|||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
customFeeRate := func(_ context.Context,
|
||||
_ lntypes.Hash) (chainfee.SatPerKWeight, error) {
|
||||
customFeeRate := func(_ context.Context, _ lntypes.Hash,
|
||||
_ wire.OutPoint) (chainfee.SatPerKWeight, error) {
|
||||
|
||||
return chainfee.SatPerKWeight(10_000), nil
|
||||
}
|
||||
|
|
@ -330,8 +330,8 @@ func testPresigned_input1_offline_then_input2(t *testing.T,
|
|||
setFeeRate := func(feeRate chainfee.SatPerKWeight) {
|
||||
currentFeeRate = feeRate
|
||||
}
|
||||
customFeeRate := func(_ context.Context,
|
||||
_ lntypes.Hash) (chainfee.SatPerKWeight, error) {
|
||||
customFeeRate := func(_ context.Context, _ lntypes.Hash,
|
||||
_ wire.OutPoint) (chainfee.SatPerKWeight, error) {
|
||||
|
||||
return currentFeeRate, nil
|
||||
}
|
||||
|
|
@ -511,8 +511,8 @@ func testPresigned_two_inputs_one_goes_offline(t *testing.T,
|
|||
setFeeRate := func(feeRate chainfee.SatPerKWeight) {
|
||||
currentFeeRate = feeRate
|
||||
}
|
||||
customFeeRate := func(_ context.Context,
|
||||
_ lntypes.Hash) (chainfee.SatPerKWeight, error) {
|
||||
customFeeRate := func(_ context.Context, _ lntypes.Hash,
|
||||
_ wire.OutPoint) (chainfee.SatPerKWeight, error) {
|
||||
|
||||
return currentFeeRate, nil
|
||||
}
|
||||
|
|
@ -647,8 +647,8 @@ func testPresigned_first_publish_fails(t *testing.T,
|
|||
setFeeRate := func(feeRate chainfee.SatPerKWeight) {
|
||||
currentFeeRate = feeRate
|
||||
}
|
||||
customFeeRate := func(_ context.Context,
|
||||
_ lntypes.Hash) (chainfee.SatPerKWeight, error) {
|
||||
customFeeRate := func(_ context.Context, _ lntypes.Hash,
|
||||
_ wire.OutPoint) (chainfee.SatPerKWeight, error) {
|
||||
|
||||
return currentFeeRate, nil
|
||||
}
|
||||
|
|
@ -770,8 +770,8 @@ func testPresigned_locktime(t *testing.T,
|
|||
setFeeRate := func(feeRate chainfee.SatPerKWeight) {
|
||||
currentFeeRate = feeRate
|
||||
}
|
||||
customFeeRate := func(_ context.Context,
|
||||
_ lntypes.Hash) (chainfee.SatPerKWeight, error) {
|
||||
customFeeRate := func(_ context.Context, _ lntypes.Hash,
|
||||
_ wire.OutPoint) (chainfee.SatPerKWeight, error) {
|
||||
|
||||
return currentFeeRate, nil
|
||||
}
|
||||
|
|
@ -854,8 +854,8 @@ func testPresigned_presigned_group(t *testing.T,
|
|||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
customFeeRate := func(_ context.Context,
|
||||
_ lntypes.Hash) (chainfee.SatPerKWeight, error) {
|
||||
customFeeRate := func(_ context.Context, _ lntypes.Hash,
|
||||
_ wire.OutPoint) (chainfee.SatPerKWeight, error) {
|
||||
|
||||
return chainfee.SatPerKWeight(10_000), nil
|
||||
}
|
||||
|
|
@ -1091,8 +1091,8 @@ func testPresigned_presigned_and_regular_sweeps(t *testing.T, store testStore,
|
|||
setFeeRate := func(feeRate chainfee.SatPerKWeight) {
|
||||
currentFeeRate = feeRate
|
||||
}
|
||||
customFeeRate := func(_ context.Context,
|
||||
_ lntypes.Hash) (chainfee.SatPerKWeight, error) {
|
||||
customFeeRate := func(_ context.Context, _ lntypes.Hash,
|
||||
_ wire.OutPoint) (chainfee.SatPerKWeight, error) {
|
||||
|
||||
return currentFeeRate, nil
|
||||
}
|
||||
|
|
@ -1372,8 +1372,8 @@ func testPresigned_purging(t *testing.T, numSwaps, numConfirmedSwaps int,
|
|||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
customFeeRate := func(_ context.Context,
|
||||
_ lntypes.Hash) (chainfee.SatPerKWeight, error) {
|
||||
customFeeRate := func(_ context.Context, _ lntypes.Hash,
|
||||
_ wire.OutPoint) (chainfee.SatPerKWeight, error) {
|
||||
|
||||
return feeRate, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -408,8 +408,8 @@ func testFeeBumping(t *testing.T, store testStore,
|
|||
// Disable fee bumping, if requested.
|
||||
var opts []BatcherOption
|
||||
if noFeeBumping {
|
||||
customFeeRate := func(ctx context.Context,
|
||||
swapHash lntypes.Hash) (chainfee.SatPerKWeight, error) {
|
||||
customFeeRate := func(_ context.Context, _ lntypes.Hash,
|
||||
_ wire.OutPoint) (chainfee.SatPerKWeight, error) {
|
||||
|
||||
// Always provide the same value, no bumping.
|
||||
return test.DefaultMockFee, nil
|
||||
|
|
@ -3844,8 +3844,8 @@ func testSweepFetcher(t *testing.T, store testStore,
|
|||
require.NoError(t, err)
|
||||
store.AssertLoopOutStored()
|
||||
|
||||
customFeeRate := func(ctx context.Context,
|
||||
swapHash lntypes.Hash) (chainfee.SatPerKWeight, error) {
|
||||
customFeeRate := func(_ context.Context, _ lntypes.Hash,
|
||||
_ wire.OutPoint) (chainfee.SatPerKWeight, error) {
|
||||
|
||||
// Always provide the same value, no bumping.
|
||||
return feeRate, nil
|
||||
|
|
@ -4691,8 +4691,8 @@ func testFeeRateGrows(t *testing.T, store testStore,
|
|||
swap2feeRate[swapHash] = rate
|
||||
}
|
||||
|
||||
customFeeRate := func(ctx context.Context,
|
||||
swapHash lntypes.Hash) (chainfee.SatPerKWeight, error) {
|
||||
customFeeRate := func(_ context.Context, swapHash lntypes.Hash,
|
||||
_ wire.OutPoint) (chainfee.SatPerKWeight, error) {
|
||||
|
||||
swap2feeRateMu.Lock()
|
||||
defer swap2feeRateMu.Unlock()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue