loopin: modify internally published htlc to use p2wsh

pull/184/head
Andras Banki-Horvath 4 years ago
parent f0aff9b7bd
commit 0aa978bd09

@ -131,11 +131,14 @@ func (s *swapClientServer) marshallSwap(loopSwap *loop.SwapInfo) (
switch loopSwap.SwapType { switch loopSwap.SwapType {
case swap.TypeIn: case swap.TypeIn:
swapType = looprpc.SwapType_LOOP_IN swapType = looprpc.SwapType_LOOP_IN
htlcAddressP2WSH = loopSwap.HtlcAddressP2WSH.EncodeAddress()
if loopSwap.ExternalHtlc { 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: case swap.TypeOut:
swapType = looprpc.SwapType_LOOP_OUT swapType = looprpc.SwapType_LOOP_OUT

@ -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) 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, tx, err := s.lnd.WalletKit.SendOutputs(ctx,
[]*wire.TxOut{{ []*wire.TxOut{{
PkScript: s.htlcNP2WSH.PkScript, PkScript: s.htlcP2WSH.PkScript,
Value: int64(s.LoopInContract.AmountRequested), Value: int64(s.LoopInContract.AmountRequested),
}}, }},
feeRate, feeRate,

@ -119,7 +119,7 @@ func TestLoopInSuccess(t *testing.T) {
func TestLoopInTimeout(t *testing.T) { func TestLoopInTimeout(t *testing.T) {
testAmt := int64(testLoopInRequest.Amount) testAmt := int64(testLoopInRequest.Amount)
t.Run("internal htlc", func(t *testing.T) { 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} outputTypes := []swap.HtlcOutputType{swap.HtlcP2WSH, swap.HtlcNP2WSH}

Loading…
Cancel
Save