|
|
@ -112,6 +112,12 @@ func newLoopOutSwap(globalCtx context.Context, cfg *swapConfig,
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check channel set for duplicates.
|
|
|
|
|
|
|
|
chanSet, err := loopdb.NewChannelSet(request.OutgoingChanSet)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Instantiate a struct that contains all required data to start the
|
|
|
|
// Instantiate a struct that contains all required data to start the
|
|
|
|
// swap.
|
|
|
|
// swap.
|
|
|
|
initiationTime := time.Now()
|
|
|
|
initiationTime := time.Now()
|
|
|
@ -121,7 +127,6 @@ func newLoopOutSwap(globalCtx context.Context, cfg *swapConfig,
|
|
|
|
DestAddr: request.DestAddr,
|
|
|
|
DestAddr: request.DestAddr,
|
|
|
|
MaxSwapRoutingFee: request.MaxSwapRoutingFee,
|
|
|
|
MaxSwapRoutingFee: request.MaxSwapRoutingFee,
|
|
|
|
SweepConfTarget: request.SweepConfTarget,
|
|
|
|
SweepConfTarget: request.SweepConfTarget,
|
|
|
|
UnchargeChannel: request.LoopOutChannel,
|
|
|
|
|
|
|
|
PrepayInvoice: swapResp.prepayInvoice,
|
|
|
|
PrepayInvoice: swapResp.prepayInvoice,
|
|
|
|
MaxPrepayRoutingFee: request.MaxPrepayRoutingFee,
|
|
|
|
MaxPrepayRoutingFee: request.MaxPrepayRoutingFee,
|
|
|
|
SwapPublicationDeadline: request.SwapPublicationDeadline,
|
|
|
|
SwapPublicationDeadline: request.SwapPublicationDeadline,
|
|
|
@ -136,6 +141,7 @@ func newLoopOutSwap(globalCtx context.Context, cfg *swapConfig,
|
|
|
|
MaxMinerFee: request.MaxMinerFee,
|
|
|
|
MaxMinerFee: request.MaxMinerFee,
|
|
|
|
MaxSwapFee: request.MaxSwapFee,
|
|
|
|
MaxSwapFee: request.MaxSwapFee,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
OutgoingChanSet: chanSet,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
swapKit := newSwapKit(
|
|
|
|
swapKit := newSwapKit(
|
|
|
@ -430,15 +436,9 @@ func (s *loopOutSwap) payInvoices(ctx context.Context) {
|
|
|
|
// Pay the swap invoice.
|
|
|
|
// Pay the swap invoice.
|
|
|
|
s.log.Infof("Sending swap payment %v", s.SwapInvoice)
|
|
|
|
s.log.Infof("Sending swap payment %v", s.SwapInvoice)
|
|
|
|
|
|
|
|
|
|
|
|
var outgoingChanIds []uint64
|
|
|
|
|
|
|
|
if s.LoopOutContract.UnchargeChannel != nil {
|
|
|
|
|
|
|
|
outgoingChanIds = append(
|
|
|
|
|
|
|
|
outgoingChanIds, *s.LoopOutContract.UnchargeChannel,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
s.swapPaymentChan = s.payInvoice(
|
|
|
|
s.swapPaymentChan = s.payInvoice(
|
|
|
|
ctx, s.SwapInvoice, s.MaxSwapRoutingFee, outgoingChanIds,
|
|
|
|
ctx, s.SwapInvoice, s.MaxSwapRoutingFee,
|
|
|
|
|
|
|
|
s.LoopOutContract.OutgoingChanSet,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// Pay the prepay invoice.
|
|
|
|
// Pay the prepay invoice.
|
|
|
@ -452,7 +452,7 @@ func (s *loopOutSwap) payInvoices(ctx context.Context) {
|
|
|
|
// payInvoice pays a single invoice.
|
|
|
|
// payInvoice pays a single invoice.
|
|
|
|
func (s *loopOutSwap) payInvoice(ctx context.Context, invoice string,
|
|
|
|
func (s *loopOutSwap) payInvoice(ctx context.Context, invoice string,
|
|
|
|
maxFee btcutil.Amount,
|
|
|
|
maxFee btcutil.Amount,
|
|
|
|
outgoingChanIds []uint64) chan lndclient.PaymentResult {
|
|
|
|
outgoingChanIds loopdb.ChannelSet) chan lndclient.PaymentResult {
|
|
|
|
|
|
|
|
|
|
|
|
resultChan := make(chan lndclient.PaymentResult)
|
|
|
|
resultChan := make(chan lndclient.PaymentResult)
|
|
|
|
|
|
|
|
|
|
|
@ -481,8 +481,8 @@ func (s *loopOutSwap) payInvoice(ctx context.Context, invoice string,
|
|
|
|
|
|
|
|
|
|
|
|
// payInvoiceAsync is the asynchronously executed part of paying an invoice.
|
|
|
|
// payInvoiceAsync is the asynchronously executed part of paying an invoice.
|
|
|
|
func (s *loopOutSwap) payInvoiceAsync(ctx context.Context,
|
|
|
|
func (s *loopOutSwap) payInvoiceAsync(ctx context.Context,
|
|
|
|
invoice string, maxFee btcutil.Amount, outgoingChanIds []uint64) (
|
|
|
|
invoice string, maxFee btcutil.Amount,
|
|
|
|
*lndclient.PaymentStatus, error) {
|
|
|
|
outgoingChanIds loopdb.ChannelSet) (*lndclient.PaymentStatus, error) {
|
|
|
|
|
|
|
|
|
|
|
|
// Extract hash from payment request. Unfortunately the request
|
|
|
|
// Extract hash from payment request. Unfortunately the request
|
|
|
|
// components aren't available directly.
|
|
|
|
// components aren't available directly.
|
|
|
|