mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
Merge pull request #644 from bhandras/easy-autoloop-destaddr-fixup
liquidity: dest address support for easy autloop
This commit is contained in:
commit
7dd30a731e
4 changed files with 28 additions and 13 deletions
|
|
@ -1256,6 +1256,14 @@ func TestAutoLoopRecurringBudget(t *testing.T) {
|
|||
func TestEasyAutoloop(t *testing.T) {
|
||||
defer test.Guard(t)
|
||||
|
||||
// Decode a dummy p2wkh address to use as the destination address for
|
||||
// the swaps.
|
||||
p2wkhAddr := "bcrt1qq68r6ff4k4pjx39efs44gcyccf7unqnu5qtjjz"
|
||||
addr, err := btcutil.DecodeAddress(p2wkhAddr, nil)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
// We need to change the default channels we use for tests so that they
|
||||
// have different local balances in order to know which one is going to
|
||||
// be selected by easy autoloop.
|
||||
|
|
@ -1284,6 +1292,7 @@ func TestEasyAutoloop(t *testing.T) {
|
|||
|
||||
params = Parameters{
|
||||
Autoloop: true,
|
||||
DestAddr: addr,
|
||||
AutoFeeBudget: 36000,
|
||||
AutoFeeRefreshPeriod: time.Hour * 3,
|
||||
AutoloopBudgetLastRefresh: testBudgetStart,
|
||||
|
|
@ -1305,6 +1314,7 @@ func TestEasyAutoloop(t *testing.T) {
|
|||
|
||||
chan1Swap = &loop.OutRequest{
|
||||
Amount: btcutil.Amount(maxAmt),
|
||||
DestAddr: addr,
|
||||
OutgoingChanSet: loopdb.ChannelSet{easyChannel1.ChannelID},
|
||||
Label: labels.AutoloopLabel(swap.TypeOut),
|
||||
Initiator: autoloopSwapInitiator,
|
||||
|
|
@ -1352,6 +1362,9 @@ func TestEasyAutoloop(t *testing.T) {
|
|||
easyChannel1, easyChannel2,
|
||||
}
|
||||
|
||||
// Remove the custom dest address.
|
||||
params.DestAddr = nil
|
||||
|
||||
c = newAutoloopTestCtx(t, params, channels, testRestrictions)
|
||||
c.start()
|
||||
|
||||
|
|
|
|||
|
|
@ -402,6 +402,11 @@ func (c *autoloopTestCtx) easyautoloop(step *easyAutoloopStep, noop bool) {
|
|||
c.t, expected.request.OutgoingChanSet,
|
||||
actual.OutgoingChanSet,
|
||||
)
|
||||
if expected.request.DestAddr != nil {
|
||||
require.Equal(
|
||||
c.t, expected.request.DestAddr, actual.DestAddr,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Since we're checking if any false-positive swaps were dispatched we
|
||||
|
|
|
|||
|
|
@ -450,12 +450,6 @@ func (m *Manager) autoloop(ctx context.Context) error {
|
|||
// Create a copy of our range var so that we can reference it.
|
||||
swap := swap
|
||||
|
||||
// Check if the parameter for custom address is defined for loop
|
||||
// outs.
|
||||
if m.params.DestAddr != nil {
|
||||
swap.DestAddr = m.params.DestAddr
|
||||
}
|
||||
|
||||
go m.dispatchStickyLoopOut(
|
||||
ctx, swap, defaultAmountBackoffRetry,
|
||||
defaultAmountBackoff,
|
||||
|
|
|
|||
|
|
@ -161,14 +161,17 @@ func (b *loopOutBuilder) buildSwap(ctx context.Context, pubkey route.Vertex,
|
|||
account = params.Account
|
||||
addrType = params.AccountAddrType
|
||||
}
|
||||
|
||||
addr, err := b.cfg.Lnd.WalletKit.NextAddr(
|
||||
ctx, account, addrType, false,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if params.DestAddr != nil {
|
||||
request.DestAddr = params.DestAddr
|
||||
} else {
|
||||
addr, err := b.cfg.Lnd.WalletKit.NextAddr(
|
||||
ctx, account, addrType, false,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
request.DestAddr = addr
|
||||
}
|
||||
request.DestAddr = addr
|
||||
}
|
||||
|
||||
return &loopOutSwapSuggestion{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue