sweepbatcher: make sure HTLC.PkScript is filled

This commit is contained in:
Boris Nagaev 2025-05-06 14:26:06 -03:00
parent d75f17df47
commit 7735bdfe27
No known key found for this signature in database
2 changed files with 15 additions and 2 deletions

View file

@ -1515,6 +1515,13 @@ func (b *Batcher) loadSweep(ctx context.Context, swapHash lntypes.Hash,
swapHash[:6], err)
}
// Make sure that PkScript of the coin is filled. Otherwise
// RegisterSpendNtfn fails.
if len(s.HTLC.PkScript) == 0 {
return nil, fmt.Errorf("sweep data for %x doesn't have "+
"HTLC.PkScript set", swapHash[:6])
}
// Find minimum fee rate for the sweep. Use customFeeRate if it is
// provided, otherwise use wallet's EstimateFeeRate.
var minFeeRate chainfee.SatPerKWeight

View file

@ -14,6 +14,7 @@ import (
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btclog/v2"
"github.com/lightninglabs/loop/loopdb"
"github.com/lightninglabs/loop/swap"
"github.com/lightninglabs/loop/test"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/lntypes"
@ -232,13 +233,18 @@ func (h *mockPresignedHelper) FetchSweep(_ context.Context,
h.mu.Lock()
defer h.mu.Unlock()
_, has := h.onlineOutpoints[utxo]
// Find IsPresigned.
_, isPresigned := h.onlineOutpoints[utxo]
return &SweepInfo{
// Set Timeout to prevent warning messages about timeout=0.
Timeout: sweepTimeout,
IsPresigned: has,
IsPresigned: isPresigned,
HTLC: swap.Htlc{
PkScript: []byte{10, 11, 12},
},
}, nil
}