mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
multi: add preimage push to loop out after sweep attempt
Once we have revealed our preimage to the world with a sweep attempt, we can safely push our preimage to the server to speed up on chain claim. Rather than rely on the server, we use the state of our invoice in lnd to determine whether we should continue trying to push the preimage to the server.
This commit is contained in:
parent
488df785e0
commit
65c847674d
11 changed files with 600 additions and 72 deletions
|
|
@ -12,7 +12,9 @@ import (
|
|||
"github.com/lightninglabs/loop/lndclient"
|
||||
"github.com/lightninglabs/loop/loopdb"
|
||||
"github.com/lightninglabs/loop/test"
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -261,6 +263,10 @@ func testSuccess(ctx *testContext, amt btcutil.Amount, hash lntypes.Hash,
|
|||
|
||||
ctx.AssertRegisterSpendNtfn(confIntent.PkScript)
|
||||
|
||||
// Assert that a call to track payment was sent, and respond with status
|
||||
// in flight so that our swap will push its preimage to the server.
|
||||
ctx.trackPayment(lnrpc.Payment_IN_FLIGHT)
|
||||
|
||||
// Publish tick.
|
||||
ctx.expiryChan <- testTime
|
||||
|
||||
|
|
@ -287,6 +293,13 @@ func testSuccess(ctx *testContext, amt btcutil.Amount, hash lntypes.Hash,
|
|||
ctx.T.Fatalf("incorrect preimage")
|
||||
}
|
||||
|
||||
// Since we successfully published our sweep, we expect the preimage to
|
||||
// have been pushed to our mock server.
|
||||
preimage, err := lntypes.MakePreimage(clientPreImage)
|
||||
require.NoError(ctx.T, err)
|
||||
|
||||
ctx.assertPreimagePush(preimage)
|
||||
|
||||
// Simulate server pulling payment.
|
||||
signalSwapPaymentResult(nil)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue