Skip to content

Commit 7534295

Browse files
committed
swap: fix htlc address generation
This commit fixes the generation of the htlc address. This bug didn't affect the swap execution, because the htlc address is only used for display to the user/caller.
1 parent ca3cfc1 commit 7534295

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

swap/htlc.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,13 @@ func NewHtlc(cltvExpiry int32, senderKey, receiverKey [33]byte,
6767
return nil, err
6868
}
6969

70-
p2wshPkScriptHash := sha256.Sum256(p2wshPkScript)
71-
7270
var pkScript, sigScript []byte
7371
var address btcutil.Address
7472

7573
switch outputType {
7674
case HtlcNP2WSH:
7775
// Generate p2sh script for p2wsh (nested).
78-
76+
p2wshPkScriptHash := sha256.Sum256(p2wshPkScript)
7977
hash160 := input.Ripemd160H(p2wshPkScriptHash[:])
8078

8179
builder := txscript.NewScriptBuilder()
@@ -111,7 +109,7 @@ func NewHtlc(cltvExpiry int32, senderKey, receiverKey [33]byte,
111109
pkScript = p2wshPkScript
112110

113111
address, err = btcutil.NewAddressWitnessScriptHash(
114-
p2wshPkScriptHash[:],
112+
p2wshPkScript[2:],
115113
chainParams,
116114
)
117115
if err != nil {

0 commit comments

Comments
 (0)