2
0
mirror of https://github.com/lightninglabs/loop synced 2024-11-08 01:10:29 +00:00

loopd: correct htlc output type on view command

Previously view may have set the output type wrongly for internal p2wsh
and p2tr loop-in swaps which is corrected in this commit.
This commit is contained in:
Andras Banki-Horvath 2022-11-04 10:44:16 +01:00
parent f5806aebef
commit b36885fb65
No known key found for this signature in database
GPG Key ID: 80E5375C094198D8

View File

@ -49,12 +49,27 @@ func viewOut(swapClient *loop.Client, chainParams *chaincfg.Params) error {
}
for _, s := range swaps {
scriptVersion := loop.GetHtlcScriptVersion(
s.Contract.ProtocolVersion,
)
var outputType swap.HtlcOutputType
switch scriptVersion {
case swap.HtlcV1:
outputType = swap.HtlcNP2WSH
case swap.HtlcV2:
outputType = swap.HtlcP2WSH
case swap.HtlcV3:
outputType = swap.HtlcP2TR
}
htlc, err := swap.NewHtlc(
loop.GetHtlcScriptVersion(s.Contract.ProtocolVersion),
s.Contract.CltvExpiry,
s.Contract.SenderKey,
s.Contract.ReceiverKey,
s.Hash, swap.HtlcP2WSH, chainParams,
s.Hash, outputType, chainParams,
)
if err != nil {
return err
@ -106,7 +121,7 @@ func viewIn(swapClient *loop.Client, chainParams *chaincfg.Params) error {
s.Contract.CltvExpiry,
s.Contract.SenderKey,
s.Contract.ReceiverKey,
s.Hash, swap.HtlcNP2WSH, chainParams,
s.Hash, swap.HtlcP2WSH, chainParams,
)
if err != nil {
return err