99 "time"
1010
1111 "github.com/btcsuite/btcd/btcutil"
12+ "github.com/btcsuite/btcd/chaincfg"
1213 "github.com/btcsuite/btcd/chaincfg/chainhash"
1314 "github.com/lightninglabs/loop/loopdb/sqlc"
1415 "github.com/lightningnetwork/lnd/keychain"
@@ -31,13 +32,16 @@ func (s *BaseDB) FetchLoopOutSwaps(ctx context.Context) ([]*LoopOut,
3132 loopOuts = make ([]* LoopOut , len (swaps ))
3233
3334 for i , swap := range swaps {
34- updates , err := s .Queries .GetSwapUpdates (ctx , swap .SwapHash )
35+ updates , err := s .Queries .GetSwapUpdates (
36+ ctx , swap .SwapHash ,
37+ )
3538 if err != nil {
3639 return err
3740 }
3841
39- loopOut , err := s .convertLoopOutRow (
40- sqlc .GetLoopOutSwapRow (swap ), updates ,
42+ loopOut , err := ConvertLoopOutRow (
43+ s .network , sqlc .GetLoopOutSwapRow (swap ),
44+ updates ,
4145 )
4246 if err != nil {
4347 return err
@@ -72,8 +76,8 @@ func (s *BaseDB) FetchLoopOutSwap(ctx context.Context,
7276 return err
7377 }
7478
75- loopOut , err = s . convertLoopOutRow (
76- swap , updates ,
79+ loopOut , err = ConvertLoopOutRow (
80+ s . network , swap , updates ,
7781 )
7882 if err != nil {
7983 return err
@@ -430,6 +434,7 @@ func loopOutToInsertArgs(hash lntypes.Hash,
430434 return sqlc.InsertLoopOutParams {
431435 SwapHash : hash [:],
432436 DestAddress : loopOut .DestAddr .String (),
437+ SingleSweep : loopOut .IsExternalAddr ,
433438 SwapInvoice : loopOut .SwapInvoice ,
434439 MaxSwapRoutingFee : int64 (loopOut .MaxSwapRoutingFee ),
435440 SweepConfTarget : loopOut .SweepConfTarget ,
@@ -479,9 +484,9 @@ func swapToHtlcKeysInsertArgs(hash lntypes.Hash,
479484 }
480485}
481486
482- // convertLoopOutRow converts a database row containing a loop out swap to a
487+ // ConvertLoopOutRow converts a database row containing a loop out swap to a
483488// LoopOut struct.
484- func ( s * BaseDB ) convertLoopOutRow ( row sqlc.GetLoopOutSwapRow ,
489+ func ConvertLoopOutRow ( network * chaincfg. Params , row sqlc.GetLoopOutSwapRow ,
485490 updates []sqlc.SwapUpdate ) (* LoopOut , error ) {
486491
487492 htlcKeys , err := fetchHtlcKeys (
@@ -498,7 +503,7 @@ func (s *BaseDB) convertLoopOutRow(row sqlc.GetLoopOutSwapRow,
498503 return nil , err
499504 }
500505
501- destAddress , err := btcutil .DecodeAddress (row .DestAddress , s . network )
506+ destAddress , err := btcutil .DecodeAddress (row .DestAddress , network )
502507 if err != nil {
503508 return nil , err
504509 }
@@ -523,6 +528,7 @@ func (s *BaseDB) convertLoopOutRow(row sqlc.GetLoopOutSwapRow,
523528 ProtocolVersion : ProtocolVersion (row .ProtocolVersion ),
524529 },
525530 DestAddr : destAddress ,
531+ IsExternalAddr : row .SingleSweep ,
526532 SwapInvoice : row .SwapInvoice ,
527533 MaxSwapRoutingFee : btcutil .Amount (row .MaxSwapRoutingFee ),
528534 SweepConfTarget : row .SweepConfTarget ,
0 commit comments