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
12 changes: 0 additions & 12 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,16 +267,6 @@ func (s *Client) FetchSwaps() ([]*SwapInfo, error) {

swapInfo.HtlcAddressP2TR = htlcP2TR.Address
} else {
htlcNP2WSH, err := swap.NewHtlc(
swap.HtlcV1, swp.Contract.CltvExpiry,
swp.Contract.SenderKey, swp.Contract.ReceiverKey,
swp.Hash, swap.HtlcNP2WSH,
s.lndServices.ChainParams,
)
if err != nil {
return nil, err
}

htlcP2WSH, err := swap.NewHtlc(
swap.HtlcV2, swp.Contract.CltvExpiry,
swp.Contract.SenderKey, swp.Contract.ReceiverKey,
Expand All @@ -288,7 +278,6 @@ func (s *Client) FetchSwaps() ([]*SwapInfo, error) {
}

swapInfo.HtlcAddressP2WSH = htlcP2WSH.Address
swapInfo.HtlcAddressNP2WSH = htlcNP2WSH.Address
}

swaps = append(swaps, swapInfo)
Expand Down Expand Up @@ -615,7 +604,6 @@ func (s *Client) LoopIn(globalCtx context.Context,
}

if loopdb.CurrentProtocolVersion() < loopdb.ProtocolVersionHtlcV3 {
swapInfo.HtlcAddressNP2WSH = swap.htlcNP2WSH.Address
swapInfo.HtlcAddressP2WSH = swap.htlcP2WSH.Address
} else {
swapInfo.HtlcAddressP2TR = swap.htlcP2TR.Address
Expand Down
3 changes: 0 additions & 3 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,6 @@ func testLoopOutSuccess(ctx *testContext, amt btcutil.Amount, hash lntypes.Hash,

var preImageIndex int
switch scriptVersion {
case swap.HtlcV1:
preImageIndex = 1

case swap.HtlcV2:
preImageIndex = 0

Expand Down
4 changes: 0 additions & 4 deletions cmd/loop/loopin.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,6 @@ func loopIn(ctx *cli.Context) error {
if resp.HtlcAddressP2Tr != "" {
fmt.Printf("HTLC address (P2TR): %v\n", resp.HtlcAddressP2Tr)
} else {
if external {
fmt.Printf("HTLC address (NP2WSH): %v\n",
resp.HtlcAddressNp2Wsh)
}
fmt.Printf("HTLC address (P2WSH): %v\n", resp.HtlcAddressP2Wsh)
}

Expand Down
4 changes: 0 additions & 4 deletions cmd/loop/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,6 @@ func logSwap(swap *looprpc.SwapStatus) {
fmt.Printf(" P2WSH: %v", swap.HtlcAddressP2Wsh)
}

if swap.HtlcAddressNp2Wsh != "" {
fmt.Printf(" NP2WSH: %v", swap.HtlcAddressNp2Wsh)
}

if swap.HtlcAddressP2Tr != "" {
fmt.Printf(" P2TR: %v", swap.HtlcAddressP2Tr)
}
Expand Down
8 changes: 0 additions & 8 deletions interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,6 @@ type LoopInSwapInfo struct { // nolint
// where the loop-in funds may be paid.
HtlcAddressP2WSH btcutil.Address

// HtlcAddressNP2WSH contains the nested segwit swap htlc address,
// where the loop-in funds may be paid.
HtlcAddressNP2WSH btcutil.Address

// HtlcAddresP2TR contains the v3 (pay to taproot) htlc address.
HtlcAddressP2TR btcutil.Address

Expand Down Expand Up @@ -350,10 +346,6 @@ type SwapInfo struct {
// swap htlc. This is used for both loop-in and loop-out.
HtlcAddressP2WSH btcutil.Address

// HtlcAddressNP2WSH stores the address of the NP2WSH (nested segwit)
// swap htlc. This is only used for external loop-in.
HtlcAddressNP2WSH btcutil.Address

// HtlcAddressP2TR stores the address of the P2TR (taproot) swap htlc.
// This is used for both internal and external loop-in and loop out.
HtlcAddressP2TR btcutil.Address
Expand Down
3 changes: 1 addition & 2 deletions liquidity/liquidity.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,7 @@ func (m *Manager) autoloop(ctx context.Context) error {
}

log.Infof("loop in automatically dispatched: hash: %v, "+
"address: np2wsh(%v), p2wsh(%v), p2tr(%v)",
loopIn.SwapHash, loopIn.HtlcAddressNP2WSH,
"address: p2wsh(%v), p2tr(%v)", loopIn.SwapHash,
loopIn.HtlcAddressP2WSH, loopIn.HtlcAddressP2TR)
}

Expand Down
63 changes: 24 additions & 39 deletions loopd/swapclient_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,9 @@ func (s *swapClientServer) marshallSwap(loopSwap *loop.SwapInfo) (

var swapType clientrpc.SwapType
var (
htlcAddress string
htlcAddressP2TR string
htlcAddressP2WSH string
htlcAddressNP2WSH string
htlcAddress string
htlcAddressP2TR string
htlcAddressP2WSH string
)
var outGoingChanSet []uint64
var lastHop []byte
Expand All @@ -248,14 +247,7 @@ func (s *swapClientServer) marshallSwap(loopSwap *loop.SwapInfo) (
} else {
htlcAddressP2WSH =
loopSwap.HtlcAddressP2WSH.EncodeAddress()

if loopSwap.ExternalHtlc {
htlcAddressNP2WSH =
loopSwap.HtlcAddressNP2WSH.EncodeAddress()
htlcAddress = htlcAddressNP2WSH
} else {
htlcAddress = htlcAddressP2WSH
}
htlcAddress = htlcAddressP2WSH
}

if loopSwap.LastHop != nil {
Expand All @@ -279,24 +271,23 @@ func (s *swapClientServer) marshallSwap(loopSwap *loop.SwapInfo) (
}

return &clientrpc.SwapStatus{
Amt: int64(loopSwap.AmountRequested),
Id: loopSwap.SwapHash.String(),
IdBytes: loopSwap.SwapHash[:],
State: state,
FailureReason: failureReason,
InitiationTime: loopSwap.InitiationTime.UnixNano(),
LastUpdateTime: loopSwap.LastUpdate.UnixNano(),
HtlcAddress: htlcAddress,
HtlcAddressP2Tr: htlcAddressP2TR,
HtlcAddressP2Wsh: htlcAddressP2WSH,
HtlcAddressNp2Wsh: htlcAddressNP2WSH,
Type: swapType,
CostServer: int64(loopSwap.Cost.Server),
CostOnchain: int64(loopSwap.Cost.Onchain),
CostOffchain: int64(loopSwap.Cost.Offchain),
Label: loopSwap.Label,
LastHop: lastHop,
OutgoingChanSet: outGoingChanSet,
Amt: int64(loopSwap.AmountRequested),
Id: loopSwap.SwapHash.String(),
IdBytes: loopSwap.SwapHash[:],
State: state,
FailureReason: failureReason,
InitiationTime: loopSwap.InitiationTime.UnixNano(),
LastUpdateTime: loopSwap.LastUpdate.UnixNano(),
HtlcAddress: htlcAddress,
HtlcAddressP2Tr: htlcAddressP2TR,
HtlcAddressP2Wsh: htlcAddressP2WSH,
Type: swapType,
CostServer: int64(loopSwap.Cost.Server),
CostOnchain: int64(loopSwap.Cost.Onchain),
CostOffchain: int64(loopSwap.Cost.Offchain),
Label: loopSwap.Label,
LastHop: lastHop,
OutgoingChanSet: outGoingChanSet,
}, nil
}

Expand Down Expand Up @@ -701,15 +692,9 @@ func (s *swapClientServer) LoopIn(ctx context.Context,
}

if loopdb.CurrentProtocolVersion() < loopdb.ProtocolVersionHtlcV3 {
if req.ExternalHtlc {
np2wshAddr := swapInfo.HtlcAddressNP2WSH.String()
response.HtlcAddress = np2wshAddr
response.HtlcAddressNp2Wsh = np2wshAddr
} else {
p2wshAddr := swapInfo.HtlcAddressP2WSH.String()
response.HtlcAddress = p2wshAddr
response.HtlcAddressP2Wsh = p2wshAddr
}
p2wshAddr := swapInfo.HtlcAddressP2WSH.String()
response.HtlcAddress = p2wshAddr
response.HtlcAddressP2Wsh = p2wshAddr
} else {
p2trAddr := swapInfo.HtlcAddressP2TR.String()
response.HtlcAddress = p2trAddr
Expand Down
16 changes: 14 additions & 2 deletions loopd/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,24 @@ func viewOut(swapClient *loop.Client, chainParams *chaincfg.Params) error {
}

for _, s := range swaps {
scriptVersion := loop.GetHtlcScriptVersion(
s.Contract.ProtocolVersion,
)

var outputType swap.HtlcOutputType
switch scriptVersion {
case swap.HtlcV2:
outputType = swap.HtlcP2WSH

case swap.HtlcV3:
outputType = swap.HtlcP2TR
}
htlc, err := swap.NewHtlc(
loop.GetHtlcScriptVersion(s.Contract.ProtocolVersion),
s.Contract.CltvExpiry,
s.Contract.SenderKey,
s.Contract.ReceiverKey,
s.Hash, swap.HtlcP2WSH, chainParams,
s.Hash, outputType, chainParams,
)
if err != nil {
return err
Expand Down Expand Up @@ -106,7 +118,7 @@ func viewIn(swapClient *loop.Client, chainParams *chaincfg.Params) error {
s.Contract.CltvExpiry,
s.Contract.SenderKey,
s.Contract.ReceiverKey,
s.Hash, swap.HtlcNP2WSH, chainParams,
s.Hash, swap.HtlcP2WSH, chainParams,
)
if err != nil {
return err
Expand Down
25 changes: 0 additions & 25 deletions loopin.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ type loopInSwap struct {

htlcP2WSH *swap.Htlc

htlcNP2WSH *swap.Htlc

htlcP2TR *swap.Htlc

// htlcTxHash is the confirmed htlc tx id.
Expand Down Expand Up @@ -423,17 +421,9 @@ func (s *loopInSwap) initHtlcs() error {
return err
}

htlcNP2WSH, err := s.swapKit.getHtlc(swap.HtlcNP2WSH)
if err != nil {
return err
}

// Log htlc addresses for debugging.
s.swapKit.log.Infof("Htlc address (P2WSH): %v", htlcP2WSH.Address)
s.swapKit.log.Infof("Htlc address (NP2WSH): %v", htlcNP2WSH.Address)

s.htlcP2WSH = htlcP2WSH
s.htlcNP2WSH = htlcNP2WSH

return nil
}
Expand All @@ -447,7 +437,6 @@ func (s *loopInSwap) sendUpdate(ctx context.Context) error {
info.HtlcAddressP2TR = s.htlcP2TR.Address
} else {
info.HtlcAddressP2WSH = s.htlcP2WSH.Address
info.HtlcAddressNP2WSH = s.htlcNP2WSH.Address
}

info.ExternalHtlc = s.ExternalHtlc
Expand Down Expand Up @@ -643,11 +632,6 @@ func (s *loopInSwap) waitForHtlcConf(globalCtx context.Context) (
return nil, err
}

confChanNP2WSH, confErrNP2WSH, err := notifyConfirmation(s.htlcNP2WSH)
if err != nil {
return nil, err
}

confChanP2TR, confErrP2TR, err := notifyConfirmation(s.htlcP2TR)
if err != nil {
return nil, err
Expand All @@ -662,11 +646,6 @@ func (s *loopInSwap) waitForHtlcConf(globalCtx context.Context) (
s.htlc = s.htlcP2WSH
s.log.Infof("P2WSH htlc confirmed")

// NP2WSH htlc confirmed.
case conf = <-confChanNP2WSH:
s.htlc = s.htlcNP2WSH
s.log.Infof("NP2WSH htlc confirmed")

// P2TR htlc confirmed.
case conf = <-confChanP2TR:
s.htlc = s.htlcP2TR
Expand All @@ -676,10 +655,6 @@ func (s *loopInSwap) waitForHtlcConf(globalCtx context.Context) (
case err := <-confErrP2WSH:
return nil, err

// Conf ntfn error.
case err := <-confErrNP2WSH:
return nil, err

// Conf ntfn error.
case err := <-confErrP2TR:
return nil, err
Expand Down
26 changes: 2 additions & 24 deletions loopin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,6 @@ func testLoopInSuccess(t *testing.T) {
// Expect register for htlc conf (only one, since the htlc is p2tr).
<-ctx.lnd.RegisterConfChannel

// If the swap is legacy, then we'll register two confirmation
// notifications.
if !IsTaprootSwap(&inSwap.SwapContract) {
<-ctx.lnd.RegisterConfChannel
}

// Confirm htlc.
ctx.lnd.ConfChannel <- &chainntnfs.TxConfirmation{
Tx: &htlcTx,
Expand Down Expand Up @@ -266,11 +260,7 @@ func testLoopInTimeout(t *testing.T, externalValue int64) {
// Create an external htlc publish tx.
var pkScript []byte
if !IsTaprootSwap(&inSwap.SwapContract) {
if req.ExternalHtlc {
pkScript = inSwap.htlcNP2WSH.PkScript
} else {
pkScript = inSwap.htlcP2WSH.PkScript
}
pkScript = inSwap.htlcP2WSH.PkScript
} else {
pkScript = inSwap.htlcP2TR.PkScript
}
Expand All @@ -288,12 +278,6 @@ func testLoopInTimeout(t *testing.T, externalValue int64) {
// Expect register for htlc conf.
<-ctx.lnd.RegisterConfChannel

// If the swap is legacy, then we'll register two confirmation
// notifications.
if !IsTaprootSwap(&inSwap.SwapContract) {
<-ctx.lnd.RegisterConfChannel
}

// Confirm htlc.
ctx.lnd.ConfChannel <- &chainntnfs.TxConfirmation{
Tx: &htlcTx,
Expand Down Expand Up @@ -473,7 +457,7 @@ func testLoopInResume(t *testing.T, state loopdb.SwapState, expired bool,

scriptVersion := GetHtlcScriptVersion(storedVersion)

outputType := swap.HtlcNP2WSH
outputType := swap.HtlcP2WSH
if scriptVersion == swap.HtlcV3 {
outputType = swap.HtlcP2TR
}
Expand Down Expand Up @@ -571,12 +555,6 @@ func testLoopInResume(t *testing.T, state loopdb.SwapState, expired bool,
// Expect register for htlc conf.
<-ctx.lnd.RegisterConfChannel

// If the swap is legacy, then we'll register two confirmation
// notifications.
if !IsTaprootSwap(&inSwap.SwapContract) {
<-ctx.lnd.RegisterConfChannel
}

// Confirm htlc.
ctx.lnd.ConfChannel <- &chainntnfs.TxConfirmation{
Tx: &htlcTx,
Expand Down
Loading