Skip to content

Commit 0aa978b

Browse files
committed
loopin: modify internally published htlc to use p2wsh
1 parent f0aff9b commit 0aa978b

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

loopd/swapclient_server.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,14 @@ func (s *swapClientServer) marshallSwap(loopSwap *loop.SwapInfo) (
131131
switch loopSwap.SwapType {
132132
case swap.TypeIn:
133133
swapType = looprpc.SwapType_LOOP_IN
134+
htlcAddressP2WSH = loopSwap.HtlcAddressP2WSH.EncodeAddress()
135+
134136
if loopSwap.ExternalHtlc {
135-
htlcAddressP2WSH = loopSwap.HtlcAddressP2WSH.EncodeAddress()
137+
htlcAddressNP2WSH = loopSwap.HtlcAddressNP2WSH.EncodeAddress()
138+
htlcAddress = htlcAddressNP2WSH
139+
} else {
140+
htlcAddress = htlcAddressP2WSH
136141
}
137-
htlcAddressNP2WSH = loopSwap.HtlcAddressNP2WSH.EncodeAddress()
138-
htlcAddress = htlcAddressNP2WSH
139142

140143
case swap.TypeOut:
141144
swapType = looprpc.SwapType_LOOP_OUT

loopin.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,9 +472,10 @@ func (s *loopInSwap) publishOnChainHtlc(ctx context.Context) (bool, error) {
472472

473473
s.log.Infof("Publishing on chain HTLC with fee rate %v", feeRate)
474474

475+
// Internal loop-in is always P2WSH.
475476
tx, err := s.lnd.WalletKit.SendOutputs(ctx,
476477
[]*wire.TxOut{{
477-
PkScript: s.htlcNP2WSH.PkScript,
478+
PkScript: s.htlcP2WSH.PkScript,
478479
Value: int64(s.LoopInContract.AmountRequested),
479480
}},
480481
feeRate,

loopin_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func TestLoopInSuccess(t *testing.T) {
119119
func TestLoopInTimeout(t *testing.T) {
120120
testAmt := int64(testLoopInRequest.Amount)
121121
t.Run("internal htlc", func(t *testing.T) {
122-
testLoopInTimeout(t, swap.HtlcNP2WSH, 0)
122+
testLoopInTimeout(t, swap.HtlcP2WSH, 0)
123123
})
124124

125125
outputTypes := []swap.HtlcOutputType{swap.HtlcP2WSH, swap.HtlcNP2WSH}

0 commit comments

Comments
 (0)