@@ -1622,42 +1622,42 @@ func (m *resumeManager) handleUnfinishedLoopOut(ctx context.Context,
16221622
16231623 typ := swap .State ().State .Type ()
16241624 // Check the state of the swap and take appropriate action.
1625- if typ != loopdb .StateTypePending && typ != loopdb .StateTypeFail {
1626- trackChanCtx , cancel := context .WithCancel (ctx )
1627- // Check if the swap offchain htlc went through.
1628- trackChan , errChan , err := m .lnd .Router .TrackPayment (
1629- trackChanCtx , swap .Hash ,
1630- )
1631- if err == nil {
1632- // Omit errors here as the payment may not have been
1633- // initiated from this client.
1634- trackChanLoop:
1635- for {
1636- select {
1637- case <- ctx .Done ():
1638- cancel ()
1639- return nil
1640-
1641- case trackResp := <- trackChan :
1642- if trackResp .State !=
1643- lnrpc .Payment_FAILED {
1644- // Nothing more to do.
1645- cancel ()
1646- return nil
1647- }
1648- break trackChanLoop
1649-
1650- case <- errChan :
1651- break trackChanLoop
1652- }
1625+ if typ == loopdb .StateTypePending && typ == loopdb .StateTypeFail {
1626+ return nil
1627+ }
1628+ trackChanCtx , cancel := context .WithCancel (ctx )
1629+ defer cancel ()
1630+
1631+ // Check if the swap offchain htlc went through.
1632+ trackChan , errChan , err := m .lnd .Router .TrackPayment (
1633+ trackChanCtx , swap .Hash ,
1634+ )
1635+ if err != nil {
1636+ return err
1637+ }
1638+
1639+ // Omit errors here as the payment may not have been
1640+ // initiated from this client.
1641+ trackChanLoop:
1642+ for {
1643+ select {
1644+ case <- ctx .Done ():
1645+ return nil
1646+
1647+ case trackResp := <- trackChan :
1648+ if trackResp .State !=
1649+ lnrpc .Payment_FAILED {
1650+ return nil
16531651 }
1652+ break trackChanLoop
1653+ case <- errChan :
1654+ return err
16541655 }
1655- cancel ()
1656+ }
16561657
1657- if swap .LastUpdate ().Cost .Server == 0 {
1658- // If the server cost is zero resume the payment.
1659- return m .resumeLoopOutPayment (ctx , swap )
1660- }
1658+ if swap .LastUpdate ().Cost .Server == 0 {
1659+ // If the server cost is zero resume the payment.
1660+ return m .resumeLoopOutPayment (ctx , swap )
16611661 }
16621662
16631663 return nil
0 commit comments