mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
loop: integrate sweepbatcher to loopout flow
This commit is contained in:
parent
849d26bba6
commit
0914074b10
7 changed files with 216 additions and 473 deletions
39
client.go
39
client.go
|
|
@ -17,6 +17,7 @@ import (
|
|||
"github.com/lightninglabs/loop/loopdb"
|
||||
"github.com/lightninglabs/loop/swap"
|
||||
"github.com/lightninglabs/loop/sweep"
|
||||
"github.com/lightninglabs/loop/sweepbatcher"
|
||||
"github.com/lightninglabs/loop/utils"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
|
|
@ -61,7 +62,7 @@ var (
|
|||
// probeTimeout is the maximum time until a probe is allowed to take.
|
||||
probeTimeout = 3 * time.Minute
|
||||
|
||||
republishDelay = 10 * time.Second
|
||||
repushDelay = 1 * time.Second
|
||||
|
||||
// MinerFeeEstimationFailed is a magic number that is returned in a
|
||||
// quote call as the miner fee if the fee estimation in lnd's wallet
|
||||
|
|
@ -134,7 +135,8 @@ type ClientConfig struct {
|
|||
|
||||
// NewClient returns a new instance to initiate swaps with.
|
||||
func NewClient(dbDir string, loopDB loopdb.SwapStore,
|
||||
cfg *ClientConfig) (*Client, func(), error) {
|
||||
sweeperDb sweepbatcher.BatcherStore, cfg *ClientConfig) (
|
||||
*Client, func(), error) {
|
||||
|
||||
lsatStore, err := lsat.NewFileStore(dbDir)
|
||||
if err != nil {
|
||||
|
|
@ -162,27 +164,36 @@ func NewClient(dbDir string, loopDB loopdb.SwapStore,
|
|||
Lnd: cfg.Lnd,
|
||||
}
|
||||
|
||||
verifySchnorrSig := func(pubKey *btcec.PublicKey, hash, sig []byte) error {
|
||||
schnorrSig, err := schnorr.ParseSignature(sig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !schnorrSig.Verify(hash, pubKey) {
|
||||
return fmt.Errorf("invalid signature")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
batcher := sweepbatcher.NewBatcher(
|
||||
cfg.Lnd.WalletKit, cfg.Lnd.ChainNotifier, cfg.Lnd.Signer,
|
||||
swapServerClient.MultiMuSig2SignSweep, verifySchnorrSig,
|
||||
cfg.Lnd.ChainParams, sweeperDb, loopDB,
|
||||
)
|
||||
|
||||
executor := newExecutor(&executorConfig{
|
||||
lnd: cfg.Lnd,
|
||||
store: loopDB,
|
||||
sweeper: sweeper,
|
||||
batcher: batcher,
|
||||
createExpiryTimer: config.CreateExpiryTimer,
|
||||
loopOutMaxParts: cfg.LoopOutMaxParts,
|
||||
totalPaymentTimeout: cfg.TotalPaymentTimeout,
|
||||
maxPaymentRetries: cfg.MaxPaymentRetries,
|
||||
cancelSwap: swapServerClient.CancelLoopOutSwap,
|
||||
verifySchnorrSig: func(pubKey *btcec.PublicKey, hash, sig []byte) error {
|
||||
schnorrSig, err := schnorr.ParseSignature(sig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !schnorrSig.Verify(hash, pubKey) {
|
||||
return fmt.Errorf("invalid signature")
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
verifySchnorrSig: verifySchnorrSig,
|
||||
})
|
||||
|
||||
client := &Client{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue