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
|
|
@ -36,6 +36,9 @@ type serverMock struct {
|
|||
|
||||
swapInvoice string
|
||||
swapHash lntypes.Hash
|
||||
|
||||
// preimagePush is a channel that preimage pushes are sent into.
|
||||
preimagePush chan lntypes.Preimage
|
||||
}
|
||||
|
||||
var _ swapServerClient = (*serverMock)(nil)
|
||||
|
|
@ -49,6 +52,8 @@ func newServerMock() *serverMock {
|
|||
prepayInvoiceAmt: 100,
|
||||
|
||||
height: 600,
|
||||
|
||||
preimagePush: make(chan lntypes.Preimage),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -151,6 +156,15 @@ func (s *serverMock) NewLoopInSwap(ctx context.Context,
|
|||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *serverMock) PushLoopOutPreimage(_ context.Context,
|
||||
preimage lntypes.Preimage) error {
|
||||
|
||||
// Push the preimage into the mock's preimage channel.
|
||||
s.preimagePush <- preimage
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *serverMock) GetLoopInTerms(ctx context.Context) (
|
||||
*LoopInTerms, error) {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue