2
0
mirror of https://github.com/lightninglabs/loop synced 2024-11-09 19:10:47 +00:00
Commit Graph

20 Commits

Author SHA1 Message Date
Boris Nagaev
1290ebe535
sweepbatcher: fix copy-paste in sweep creation 2024-07-18 13:38:57 -03:00
Andras Banki-Horvath
6a4ef3683a
sweepbatcher: fix spawning condition "unattached" spend notifiers
Previously, when handling a sweep we assumed that if a sweep status
was completed, the parent batch was also finished. However, since the
batch confirmation status depends on three on-chain confirmations, it
is possible that a spend notifier was started for a sweep of an active
batch. The notifier would fetch the parent batch from the database, but
because we incorrectly assumed that  the parent was confirmed (when it
was not), the DB call would fail with a 'no rows returned' error.
This failure would cause the sweep to fail and the sweep batcher to
stop, resulting in a permanent failure state.
2024-07-11 13:15:39 +02:00
Boris Nagaev
aa6d748647
sweepbatcher: add option WithCustomSignMuSig2
It is needed to provide a custom MuSig2 signer.
2024-06-28 13:13:35 -03:00
Boris Nagaev
fd971d4951
sweepbatcher: add field SweepInfo.MinFeeRate
MinFeeRate is minimum fee rate that must be used by a batch of
the sweep. If it is specified, confTarget is ignored.

This is useful for external source of fees.
2024-06-26 14:21:59 -03:00
Boris Nagaev
1b9e3069a8
sweepbatcher: add option WithNoBumping
It disables fee bumping. It is useful when fee rate is set externally.

Add test for fee bumping, testing both modes.
2024-06-26 10:19:49 -03:00
Boris Nagaev
137dd80d39
sweepbatcher: use %w for wrapped errors
Fix errors.Is(err, context.Canceled) check in tests.
2024-06-20 14:14:24 -03:00
Boris Nagaev
0c2ba74dba
sweepbatcher: factor out loopdb-less version
Changed argument of function NewBatcher from LoopOutFetcher to SweepFetcher
(returning new public type SweepInfo).
This change is backwards-incompatible on the package layer, but nobody seems
to use the package outside of Loop.

To use NewBatcher inside Loop, turn loopdb into SweepFetcher using
function NewSweepFetcherFromSwapStore.
2024-06-03 18:34:35 -03:00
Boris Nagaev
16132d1593
sweepbatcher: load swap from loopdb, not own store
Method Store.GetBatchSweeps provides data from tables outside of sweepbatcher:
swaps, loopout_swaps, htlc_keys. It makes it harder to reuse. Batcher already
has a straightforward way to get swap data: LoopOutFetcher interface (loopdb).

In this commit I switch the source of data from the field returned by Store
(LoopOut) to loading independently by calling LoopOutFetcher.FetchLoopOutSwap.
2024-05-31 12:28:02 -03:00
Boris Nagaev
87fb185a9b
sweepbatcher: remove const defaultBatchConfTarget
It is always overwritten with primary sweep's confTarget.

Print a warning if batchConfTarget is 0 in updateRbfRate.

See https://github.com/lightninglabs/loop/pull/754#discussion_r1613514363
2024-05-30 12:17:43 -03:00
Boris Nagaev
40ad1ce609
sweepbatcher: load from DB preserves confTarget
It used to be set to default (defaultBatchConfTarget = 12) which
could in theory affect fee rate if updateRbfRate() and publish()
were not called before the batch was saved. (Unlikely scenario.)
2024-05-30 12:17:43 -03:00
Boris Nagaev
4258b95dd2
sweepbatcher: fix too long lines 2024-05-29 12:17:18 -03:00
Boris Nagaev
0b2c177445
sweepbatcher: exit early in handleSweep
If the sweep was successfully updated in the batch, no need to
try to add it to all other batches.

Added a test reproducing adding a sweep to both batches without this change.
2024-05-29 12:03:14 -03:00
Boris Nagaev
dc5d0fe30c
sweepbatcher: narrow down interface of swapStore
Only one method of loopdb.SwapStore is used (FetchLoopOutSwap).
Local interface LoopOutFetcher was defined to reflect this.
2024-05-27 10:03:19 -03:00
Andras Banki-Horvath
14de8f1f5d
sweepbatcher: test that empty batches won't prevent startup 2024-05-24 18:44:05 +02:00
Andras Banki-Horvath
e5ade6a0b1
sweepbatcher: close the quit channel when the batcher is shutting down 2024-05-24 18:44:05 +02:00
Andras Banki-Horvath
c01e8014e1
sweepbatcher: do not fail on restoring empty batches
Previously storing an empty batch would make the batcher fail to start
as spinning up a restored batch assumes that there's a primary sweep
added already. As there's no point in spinning up such batch we can just
skip over it.
Furthermore we'll ensure that we won't try to ever publish an empty
batch to avoid setting the fee rate too early.
2024-05-24 18:44:04 +02:00
Andras Banki-Horvath
e1ddb50dfe
loopout+sweepbatcher: calculate the per sweep onchain fees correctly
Previously we'd report the fees per sweep as the total sweep cost of a
batch. With this change the reported cost will be the proportional fee
which should be equal for all sweeps except if there's any rounding
difference in which case that is paid by the sweep belonging to the
first input of the batch tx.
2024-03-04 16:15:21 +01:00
Andras Banki-Horvath
b4ebb19a77
loopdb+sweepbatcher: add GetParentBatch and TotalSwept calls 2024-03-04 16:15:21 +01:00
Andras Banki-Horvath
c094ad4a85
sweepbatcher: refactor monitorSpendAndNotify to return an error 2024-03-04 16:15:20 +01:00
George Tsagkarelis
7081fb7aae
sweepbatcher: add sweep batcher 2024-01-23 20:38:09 +02:00