Commit graph

11 commits

Author SHA1 Message Date
Boris Nagaev
abf3bb4abf
sweepbatcher: presign transactions in parallel
If a SignTx call is slow, the whole presign() function could timeout if all
the calls are done sequentially. In this commit each call is done in a separate
goroutine to reduce total latency.
2025-10-14 22:37:18 -03:00
Boris Nagaev
1f15c604ac
sweepbatcher: fix fee rate calculation (publish)
We forgot to account for change outputs when checking the feerate of
signed transaction. The bug resulted in fee rate overestimation in the
log message.
2025-10-11 22:15:56 -03:00
Boris Nagaev
54652dc641
sweepbatcher: subtle adjustments for change
- ensurePresigned: use passed minRelayFeeRate instead of chainfee.FeePerKwFloor
 - presign: use minRelayFeeRate for start and minRelayFee
 - presign: make sure minRelayFeeRate is set
 - add tests for presign to test this new behavior; make sure the number of
   transactions is lower if minRelayFeeRate is higher
 - update error message in constructUnsignedTx: use <, not <= (more accurate)
 - use utils.DustLimitForPkScript instead of lnwallet.DustLimitForSize in tests
 - in tests adjust amounts to edge values, add controls
2025-07-29 12:33:56 +02:00
Slyghtning
29348a94df
sweepbatcher: consider min relay fee when constructing batch tx
if constructUnsignedTx constructs a batch transaction that is
below the minimum relay fee, an error is returned.
2025-07-29 12:33:56 +02:00
Slyghtning
bc7d155e69
sweepbatcher: consider change in presigning and batch tx
Presigning sweeps takes change outputs into account.
Each primary deposit id of a sweep group points to
an optional change output.
sweepbatcher.presign scans all passed sweeps for
change outputs and passes them to constructUnsignedTx.
Optional change of a swap is encoded in its sweeps
as a pointer to the same change output. This change
is taken into account when constructing the unsigned
batch transaction when it comes to tx weight and
outputs.
2025-07-29 12:33:55 +02:00
Boris Nagaev
72caafa14e
sweepbatcher: fix a bug in dest address selection
For presigned possible remaining groups, the destination address of the current
batch was used instead of the destination address of an expected future batch.

TODO: reproduce in unit test "purged". For this, each swap should have a
separate destination address.
2025-06-26 14:01:16 -03:00
Boris Nagaev
59a3af31cc
sweepbatcher: format pkscript as hex 2025-06-26 14:01:16 -03:00
Boris Nagaev
e7d5172a79
sweepbatcher: remove method Presign
Method Presign is not as reliable as SignTx, because it checks transaction by
txid and can miss for example if LockTime is different. SignTx can do everything
Presign was used for.
2025-06-26 14:01:16 -03:00
Boris Nagaev
f19f9f5288
sweepbatcher/presigned: minRelayFee edge cases
Make sure that broadcasted tx has feeRate >= minRelayFee.
Make sure that feeRate of broadcasted tx doesn't decrease.
2025-06-26 14:01:16 -03:00
Boris Nagaev
1036214160
sweepbatcher: add an option to ignore HTLC txids
Added option WithSkippedTxns, which has one historical problematic tx by default.
Sweeps originating from these transactions are omitted when reading from DB.

loopdb: add column sweep_batches.cancelled and replaced DropBatch with
CancelBatch. It is needed, because sweep.batch_id is a foreign key to batch.

Changed StoreMock.InsertSweepBatch not to reuse batch_id. This is needed by
the test, which checks that new batch has fresh ID.
2025-06-17 14:47:49 -03:00
Boris Nagaev
b9b256f4b3
sweepbatcher: add mode with presigned transactions
In this mode sweepbatcher uses transactions provided by the Presigned helper.
Transactions are signed upon adding an input to a batch.

A single Batcher instance can handle both presigned and regular batches.
Currently presigned and non-presigned sweeps never appear in the same batch.
2025-05-08 17:24:10 -03:00