Skip to content

Commit ffd52ab

Browse files
committed
loopout: add low/high routing plugin
1 parent 1d1354d commit ffd52ab

File tree

4 files changed

+561
-13
lines changed

4 files changed

+561
-13
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ require (
66
github.com/btcsuite/btcutil v1.0.3-0.20210527170813-e2ba6805a890
77
github.com/btcsuite/btcwallet/wtxmgr v1.3.1-0.20210822222949-9b5a201c344c
88
github.com/coreos/bbolt v1.3.3
9+
github.com/davecgh/go-spew v1.1.1
910
github.com/fortytw2/leaktest v1.3.0
1011
github.com/grpc-ecosystem/grpc-gateway/v2 v2.5.0
1112
github.com/jessevdk/go-flags v1.4.0

loopout.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,8 @@ func (s *loopOutSwap) payInvoices(ctx context.Context) {
590590
s.LoopOutContract.OutgoingChanSet, pluginType,
591591
)
592592

593-
// Pay the prepay invoice. Won't use the routing plugin here.
593+
// Pay the prepay invoice. Won't use the routing plugin here as the
594+
// prepay is trivially small and shouldn't normally need any help.
594595
s.log.Infof("Sending prepayment %v", s.PrepayInvoice)
595596
s.prePaymentChan = s.payInvoice(
596597
ctx, s.PrepayInvoice, s.MaxPrepayRoutingFee,
@@ -670,7 +671,9 @@ func (s *loopOutSwap) payInvoiceAsync(ctx context.Context,
670671
// Extract hash from payment request. Unfortunately the request
671672
// components aren't available directly.
672673
chainParams := s.lnd.ChainParams
673-
target, hash, amt, err := swap.DecodeInvoice(chainParams, invoice)
674+
target, routeHints, hash, amt, err := swap.DecodeInvoice(
675+
chainParams, invoice,
676+
)
674677
if err != nil {
675678
return nil, err
676679
}
@@ -680,7 +683,7 @@ func (s *loopOutSwap) payInvoiceAsync(ctx context.Context,
680683

681684
// Attempt to acquire and initialize the routing plugin.
682685
routingPlugin, err := AcquireRoutingPlugin(
683-
ctx, pluginType, *s.lnd, target, nil, amt,
686+
ctx, pluginType, *s.lnd, target, routeHints, amt,
684687
)
685688
if err != nil {
686689
return nil, err
@@ -1314,7 +1317,7 @@ func validateLoopOutContract(lnd *lndclient.LndServices,
13141317
// Check invoice amounts.
13151318
chainParams := lnd.ChainParams
13161319

1317-
_, swapInvoiceHash, swapInvoiceAmt, err := swap.DecodeInvoice(
1320+
_, _, swapInvoiceHash, swapInvoiceAmt, err := swap.DecodeInvoice(
13181321
chainParams, response.swapInvoice,
13191322
)
13201323
if err != nil {
@@ -1327,7 +1330,7 @@ func validateLoopOutContract(lnd *lndclient.LndServices,
13271330
swapInvoiceHash, swapHash)
13281331
}
13291332

1330-
_, _, prepayInvoiceAmt, err := swap.DecodeInvoice(
1333+
_, _, _, prepayInvoiceAmt, err := swap.DecodeInvoice(
13311334
chainParams, response.prepayInvoice,
13321335
)
13331336
if err != nil {

0 commit comments

Comments
 (0)