Skip to content

Commit 03f85c5

Browse files
committed
sweepbatcher: make sure HTLC.PkScript is filled
1 parent c7014ec commit 03f85c5

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

sweepbatcher/sweep_batcher.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,13 @@ func (b *Batcher) loadSweep(ctx context.Context, swapHash lntypes.Hash,
14441444
swapHash[:6], err)
14451445
}
14461446

1447+
// Make sure that PkScript of the coin is filled. Otherwise
1448+
// RegisterSpendNtfn fails.
1449+
if len(s.HTLC.PkScript) == 0 {
1450+
return nil, fmt.Errorf("sweep data for %x doesn't have "+
1451+
"HTLC.PkScript set", swapHash[:6])
1452+
}
1453+
14471454
// Find minimum fee rate for the sweep. Use customFeeRate if it is
14481455
// provided, otherwise use wallet's EstimateFeeRate.
14491456
var minFeeRate chainfee.SatPerKWeight

sweepbatcher/sweep_batcher_presigned_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/btcsuite/btcd/wire"
1515
"github.com/btcsuite/btclog/v2"
1616
"github.com/lightninglabs/loop/loopdb"
17+
"github.com/lightninglabs/loop/swap"
1718
"github.com/lightninglabs/loop/test"
1819
"github.com/lightningnetwork/lnd/chainntnfs"
1920
"github.com/lightningnetwork/lnd/lntypes"
@@ -232,13 +233,18 @@ func (h *mockPresignedHelper) FetchSweep(_ context.Context,
232233
h.mu.Lock()
233234
defer h.mu.Unlock()
234235

235-
_, has := h.onlineOutpoints[utxo]
236+
// Find IsPresigned.
237+
_, isPresigned := h.onlineOutpoints[utxo]
236238

237239
return &SweepInfo{
238240
// Set Timeout to prevent warning messages about timeout=0.
239241
Timeout: sweepTimeout,
240242

241-
IsPresigned: has,
243+
IsPresigned: isPresigned,
244+
245+
HTLC: swap.Htlc{
246+
PkScript: []byte{10, 11, 12},
247+
},
242248
}, nil
243249
}
244250

0 commit comments

Comments
 (0)