Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cmd/loopd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const (

var defaultConfig = config{
Network: "mainnet",
SwapServer: mainnetServer,
RPCListen: "localhost:11010",
RESTListen: "localhost:8081",
Insecure: false,
Expand Down
19 changes: 14 additions & 5 deletions cmd/loopd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"errors"
"fmt"
"net"
"net/http"
Expand All @@ -26,13 +27,21 @@ func daemon(config *config) error {
}
defer lnd.Close()

// If the user is targeting the testnet network, and they haven't
// specified new swap server, then we'll point towards the testnet swap
// server rather than the mainnet endpoint.
if config.Network == "testnet" && config.SwapServer == "" {
config.SwapServer = testnetServer
// If no swap server is specified, use the default addresses for mainnet
// and testnet.
if config.SwapServer == "" {
switch config.Network {
case "mainnet":
config.SwapServer = mainnetServer
case "testnet":
config.SwapServer = testnetServer
default:
return errors.New("no swap server address specified")
}
}

logger.Infof("Swap server address: %v", config.SwapServer)

// Create an instance of the loop client library.
swapClient, cleanup, err := getClient(
config.Network, config.SwapServer, config.Insecure,
Expand Down
6 changes: 2 additions & 4 deletions swap/htlc.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,13 @@ func NewHtlc(cltvExpiry int32, senderKey, receiverKey [33]byte,
return nil, err
}

p2wshPkScriptHash := sha256.Sum256(p2wshPkScript)

var pkScript, sigScript []byte
var address btcutil.Address

switch outputType {
case HtlcNP2WSH:
// Generate p2sh script for p2wsh (nested).

p2wshPkScriptHash := sha256.Sum256(p2wshPkScript)
hash160 := input.Ripemd160H(p2wshPkScriptHash[:])

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

address, err = btcutil.NewAddressWitnessScriptHash(
p2wshPkScriptHash[:],
p2wshPkScript[2:],
chainParams,
)
if err != nil {
Expand Down