loopin: modify internally published htlc to use p2wsh

This commit is contained in:
Andras Banki-Horvath 2020-04-28 17:30:20 +02:00
parent f0aff9b7bd
commit 0aa978bd09
3 changed files with 9 additions and 5 deletions

View file

@ -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

View file

@ -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,

View file

@ -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}