diff --git a/loopd/swapclient_server.go b/loopd/swapclient_server.go index 8fae91d..8cf1754 100644 --- a/loopd/swapclient_server.go +++ b/loopd/swapclient_server.go @@ -131,11 +131,14 @@ func (s *swapClientServer) marshallSwap(loopSwap *loop.SwapInfo) ( switch loopSwap.SwapType { case swap.TypeIn: swapType = looprpc.SwapType_LOOP_IN + htlcAddressP2WSH = loopSwap.HtlcAddressP2WSH.EncodeAddress() + if loopSwap.ExternalHtlc { - htlcAddressP2WSH = loopSwap.HtlcAddressP2WSH.EncodeAddress() + htlcAddressNP2WSH = loopSwap.HtlcAddressNP2WSH.EncodeAddress() + htlcAddress = htlcAddressNP2WSH + } else { + htlcAddress = htlcAddressP2WSH } - htlcAddressNP2WSH = loopSwap.HtlcAddressNP2WSH.EncodeAddress() - htlcAddress = htlcAddressNP2WSH case swap.TypeOut: swapType = looprpc.SwapType_LOOP_OUT diff --git a/loopin.go b/loopin.go index 8b1bcdb..b72359c 100644 --- a/loopin.go +++ b/loopin.go @@ -472,9 +472,10 @@ func (s *loopInSwap) publishOnChainHtlc(ctx context.Context) (bool, error) { s.log.Infof("Publishing on chain HTLC with fee rate %v", feeRate) + // Internal loop-in is always P2WSH. tx, err := s.lnd.WalletKit.SendOutputs(ctx, []*wire.TxOut{{ - PkScript: s.htlcNP2WSH.PkScript, + PkScript: s.htlcP2WSH.PkScript, Value: int64(s.LoopInContract.AmountRequested), }}, feeRate, diff --git a/loopin_test.go b/loopin_test.go index 8c15705..08f3fd3 100644 --- a/loopin_test.go +++ b/loopin_test.go @@ -119,7 +119,7 @@ func TestLoopInSuccess(t *testing.T) { func TestLoopInTimeout(t *testing.T) { testAmt := int64(testLoopInRequest.Amount) t.Run("internal htlc", func(t *testing.T) { - testLoopInTimeout(t, swap.HtlcNP2WSH, 0) + testLoopInTimeout(t, swap.HtlcP2WSH, 0) }) outputTypes := []swap.HtlcOutputType{swap.HtlcP2WSH, swap.HtlcNP2WSH}