@@ -213,35 +213,56 @@ func (s *Client) FetchSwaps() ([]*SwapInfo, error) {
213213 }
214214
215215 for _ , swp := range loopInSwaps {
216- htlcNP2WSH , err := swap .NewHtlc (
217- GetHtlcScriptVersion (swp .Contract .ProtocolVersion ),
218- swp .Contract .CltvExpiry , swp .Contract .SenderKey ,
219- swp .Contract .ReceiverKey , swp .Hash , swap .HtlcNP2WSH ,
220- s .lndServices .ChainParams ,
221- )
222- if err != nil {
223- return nil , err
216+ swapInfo := & SwapInfo {
217+ SwapType : swap .TypeIn ,
218+ SwapContract : swp .Contract .SwapContract ,
219+ SwapStateData : swp .State (),
220+ SwapHash : swp .Hash ,
221+ LastUpdate : swp .LastUpdateTime (),
224222 }
225223
226- htlcP2WSH , err := swap .NewHtlc (
227- GetHtlcScriptVersion (swp .Contract .ProtocolVersion ),
228- swp .Contract .CltvExpiry , swp .Contract .SenderKey ,
229- swp .Contract .ReceiverKey , swp .Hash , swap .HtlcP2WSH ,
230- s .lndServices .ChainParams ,
224+ scriptVersion := GetHtlcScriptVersion (
225+ swp .Contract .SwapContract .ProtocolVersion ,
231226 )
232- if err != nil {
233- return nil , err
227+
228+ if scriptVersion == swap .HtlcV3 {
229+ htlcP2TR , err := swap .NewHtlc (
230+ swap .HtlcV3 , swp .Contract .CltvExpiry ,
231+ swp .Contract .SenderKey , swp .Contract .ReceiverKey ,
232+ swp .Hash , swap .HtlcP2TR ,
233+ s .lndServices .ChainParams ,
234+ )
235+ if err != nil {
236+ return nil , err
237+ }
238+
239+ swapInfo .HtlcAddressP2TR = htlcP2TR .Address
240+ } else {
241+ htlcNP2WSH , err := swap .NewHtlc (
242+ swap .HtlcV1 , swp .Contract .CltvExpiry ,
243+ swp .Contract .SenderKey , swp .Contract .ReceiverKey ,
244+ swp .Hash , swap .HtlcNP2WSH ,
245+ s .lndServices .ChainParams ,
246+ )
247+ if err != nil {
248+ return nil , err
249+ }
250+
251+ htlcP2WSH , err := swap .NewHtlc (
252+ swap .HtlcV2 , swp .Contract .CltvExpiry ,
253+ swp .Contract .SenderKey , swp .Contract .ReceiverKey ,
254+ swp .Hash , swap .HtlcP2WSH ,
255+ s .lndServices .ChainParams ,
256+ )
257+ if err != nil {
258+ return nil , err
259+ }
260+
261+ swapInfo .HtlcAddressP2WSH = htlcP2WSH .Address
262+ swapInfo .HtlcAddressNP2WSH = htlcNP2WSH .Address
234263 }
235264
236- swaps = append (swaps , & SwapInfo {
237- SwapType : swap .TypeIn ,
238- SwapContract : swp .Contract .SwapContract ,
239- SwapStateData : swp .State (),
240- SwapHash : swp .Hash ,
241- LastUpdate : swp .LastUpdateTime (),
242- HtlcAddressP2WSH : htlcP2WSH .Address ,
243- HtlcAddressNP2WSH : htlcNP2WSH .Address ,
244- })
265+ swaps = append (swaps , swapInfo )
245266 }
246267
247268 return swaps , nil
@@ -546,11 +567,17 @@ func (s *Client) LoopIn(globalCtx context.Context,
546567 // Return hash so that the caller can identify this swap in the updates
547568 // stream.
548569 swapInfo := & LoopInSwapInfo {
549- SwapHash : swap .hash ,
550- HtlcAddressP2WSH : swap .htlcP2WSH .Address ,
551- HtlcAddressNP2WSH : swap .htlcNP2WSH .Address ,
552- ServerMessage : initResult .serverMessage ,
570+ SwapHash : swap .hash ,
571+ ServerMessage : initResult .serverMessage ,
553572 }
573+
574+ if loopdb .CurrentProtocolVersion () < loopdb .ProtocolVersionHtlcV3 {
575+ swapInfo .HtlcAddressNP2WSH = swap .htlcNP2WSH .Address
576+ swapInfo .HtlcAddressP2WSH = swap .htlcP2WSH .Address
577+ } else {
578+ swapInfo .HtlcAddressP2TR = swap .htlcP2TR .Address
579+ }
580+
554581 return swapInfo , nil
555582}
556583
0 commit comments