@@ -15,6 +15,7 @@ import (
1515 "github.com/btcsuite/btcd/chaincfg"
1616 sqlite_migrate "github.com/golang-migrate/migrate/v4/database/sqlite"
1717 "github.com/lightninglabs/loop/loopdb/sqlc"
18+ "github.com/lightningnetwork/lnd/zpay32"
1819
1920 "github.com/stretchr/testify/require"
2021 _ "modernc.org/sqlite" // Register relevant drivers.
@@ -213,7 +214,7 @@ func (db *BaseDB) ExecTx(ctx context.Context, txOptions TxOptions,
213214func (b * BaseDB ) FixFaultyTimestamps (ctx context.Context ) error {
214215 // Manually fetch all the loop out swaps.
215216 rows , err := b .DB .QueryContext (
216- ctx , "SELECT swap_hash, publication_deadline FROM loopout_swaps" ,
217+ ctx , "SELECT swap_hash, swap_invoice, publication_deadline FROM loopout_swaps" ,
217218 )
218219 if err != nil {
219220 return err
@@ -226,6 +227,7 @@ func (b *BaseDB) FixFaultyTimestamps(ctx context.Context) error {
226227 // the sqlite driver will fail on faulty timestamps.
227228 type LoopOutRow struct {
228229 Hash []byte `json:"swap_hash"`
230+ SwapInvoice string `json:"swap_invoice"`
229231 PublicationDeadline string `json:"publication_deadline"`
230232 }
231233
@@ -234,7 +236,7 @@ func (b *BaseDB) FixFaultyTimestamps(ctx context.Context) error {
234236 for rows .Next () {
235237 var swap LoopOutRow
236238 err := rows .Scan (
237- & swap .Hash , & swap .PublicationDeadline ,
239+ & swap .Hash , & swap .SwapInvoice , & swap . PublicationDeadline ,
238240 )
239241 if err != nil {
240242 return err
@@ -264,14 +266,15 @@ func (b *BaseDB) FixFaultyTimestamps(ctx context.Context) error {
264266
265267 // Skip if the year is not in the future.
266268 thisYear := time .Now ().Year ()
267- if year <= thisYear {
269+ if year > 2020 && year <= thisYear {
268270 continue
269271 }
270272
271- fixedTime , err := fixTimeStamp (swap .PublicationDeadline )
273+ payReq , err := zpay32 . Decode (swap .SwapInvoice , b . network )
272274 if err != nil {
273275 return err
274276 }
277+ fixedTime := payReq .Timestamp .Add (time .Minute * 30 )
275278
276279 // Update the faulty time to a valid time.
277280 _ , err = tx .ExecContext (
0 commit comments