Commit graph

1956 commits

Author SHA1 Message Date
Boris Nagaev
1794aa21e5
loopdb: remove unused method ConfirmBatch 2025-06-26 14:01:16 -03: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
64a24177ae
sweepbatcher: more logging in PresignSweepsGroup 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
7735bdfe27
sweepbatcher: make sure HTLC.PkScript is filled 2025-06-26 14:01:16 -03:00
Boris Nagaev
d75f17df47
sweepbatcher: simplify presigned/purging test
It doesn't need loopdb, so remove that code.
2025-06-26 14:01:16 -03:00
Boris Nagaev
8a07107811
sweepbatcher: make sure dest pkscript is filled 2025-06-26 14:01:16 -03:00
Boris Nagaev
8c784ef761
sweepbatcher: pass utxo to fee provider 2025-06-26 14:01:16 -03:00
Boris Nagaev
7ebe2e5b30
loopout: close sweepbatcher quitChan
This is needed because sweepbatcher can use this channel in multiple
select statements to unblock itself if the caller cancels.
2025-06-26 14:01:16 -03:00
Boris Nagaev
b961e18fa0
sweepbatcher: fix OnChainFeePortion values
There were two mistakes.

In case of a swap with multiple sweeps only the fee of the first sweep
of a swap was accounted.

Rounding diff (the remainder) was attributed to all the sweeps rather than to
the first (primary) sweep of the batch. The sweep to attribute the remainder
was chosen by comparing SignatureScript which is always empty. New approach is
to find the primary sweep and to compare its outpoint directly.
2025-06-26 14:01:16 -03:00
Boris Nagaev
650cf20fe9
sweepbatcher: re-add sweeps after fully confirmed
In case of a reorg sweeps should not go to another batch but stay in the current
batch until it is reorg-safely confirmed. Only after that the remaining sweeps
are re-added to another batch.

Field sweep.completed is now set to true only for reorg-safely confirmed sweeps.

In handleConf we now use batch.persist() (i.e. store.UpdateSweepBatch) instead
of ConfirmBatch, because we set not only Confirmed flag, but also batchTxid.
2025-06-26 13:36:55 -03:00
Boris Nagaev
d2c168945b
test/chainnotifier: send to specific spend reg
This is needed to have multiple spending registrations running and to send
a notification to a specific spending registration.
2025-06-25 22:53:18 -03:00
Boris Nagaev
fab4a646df
Merge pull request #967 from starius/neutrino-fixes
staticaddr: neutrino fixes
2025-06-25 13:41:50 -03:00
András Bánki-Horváth
2538055d7d
Merge pull request #970 from bhandras/listswaps-assetclient-panic
loopd: avoid panic if asset client is not set
2025-06-24 18:09:32 +02:00
Andras Banki-Horvath
d12dc0362d
loopd: avoid panic if asset client is not set 2025-06-24 14:55:42 +02:00
Boris Nagaev
51b74512b8
staticaddr: fix error formatting in the log 2025-06-24 01:44:32 -03:00
Boris Nagaev
61542197f6
staticaddr: use tx hash not *wire.MsgTx as a key
Do not rely on GetActiveDepositsInState reusing the same *wire.MsgTx
pointer for a unique transaction.
2025-06-24 01:44:32 -03:00
Boris Nagaev
38aaa4d07a
staticaddr: recover withdrawals in parallel
Use errgroup to publish each transaction in a separate goroutine.
Publishing a transaction can take a while in neutrino mode.
2025-06-24 01:44:32 -03:00
Boris Nagaev
6f50b27b7d
loopd: increase withdrawal manager start timeout
This is needed for neutrino.
2025-06-24 01:44:32 -03:00
Boris Nagaev
3ed8c7a9fc
staticaddr/withdraw: log PublishTransaction start 2025-06-24 01:44:32 -03:00
Boris Nagaev
cc5113da0a
staticaddr: remove an unused interface method 2025-06-24 01:44:32 -03:00
Slyghtning
e145963f2e
Merge pull request #956 from hieblmi/minor-static-fixes
staticaddr: minor fixes
2025-06-23 11:17:25 +02:00
Slyghtning
d526192de7
staticaddr: thread-safe loop-in recovery 2025-06-23 11:00:06 +02:00
Slyghtning
3963bad3a1
staticaddr: remove duplicate deposit finalize method 2025-06-23 11:00:06 +02:00
Slyghtning
f7769d2bf8
Merge pull request #954 from hieblmi/fix-deadlock
staticaddr: fix deposit recovery deadlock
2025-06-23 10:59:47 +02:00
Slyghtning
c579a3e933
staticaddr: fix deposit recovery deadlock 2025-06-23 10:35:16 +02:00
Boris Nagaev
3153489ea2
Merge pull request #965 from starius/fix-release-sh
release.sh: fix version matching
2025-06-20 11:36:27 -03:00
Boris Nagaev
7a4dbb751e
release.sh: fix version matching
A commit_hash component was added to the version string:
"loop version 0.31.2-beta commit=v0.31.2-beta-dirty commit_hash=xxx".
As .* is greedy, it captured "0.31.2-beta commit=v0.31.2-beta-dirty"
instead of just "0.31.2-beta".

This commit fixes this.
2025-06-17 19:44:57 -03:00
Alex Bosworth
e5751709d2
Merge pull request #964 from lightninglabs/update-to-v0.31.2
version: bump version to v0.31.2-beta
2025-06-17 14:47:27 -07:00
Alex Bosworth
761b5bb84f
version: bump version to v0.31.2-beta 2025-06-17 12:02:56 -07:00
Boris Nagaev
0ca371e6bc
Merge pull request #958 from starius/skip-utxos
loopout: ignore saved HTLC txid, add an option to skip some HTLC transactions
2025-06-17 15:55:55 -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
1ab73a6272
loopout: ignore saved HTLC txid
If a reorg happens, the saved txid prevents loop-out from discoveing new txid.
2025-06-17 11:34:25 -03:00
Slyghtning
19ad091ff3
Merge pull request #953 from hieblmi/init-addr-mgr
staticaddr: wait for address manager initiation
2025-06-16 11:52:34 +02:00
Slyghtning
13247c4651
staticaddr: wait for address manager initiation 2025-06-13 15:37:38 +02:00
Boris Nagaev
59f67de306
Merge pull request #919 from starius/conf-chan
sweepbatcher: notify caller about confirmations
2025-06-12 15:14:15 -03:00
Boris Nagaev
c70257a4a5
sweepbatcher: notify caller about confirmations
Add fields ConfChan and ConfErrChan to SpendNotifier type which is a part of
SweepRequest passed to AddSweep method.

This is needed to reuse confirmation notifications on the calling side the same
way it is done for spending notifications.
2025-06-12 12:32:09 -03:00
Boris Nagaev
8466e0f8eb
sweepbatcher: test spending notification and error 2025-06-12 12:32:09 -03:00
Boris Nagaev
980c7d4e00
sweepbatcher: align dbBatch type with DB schema
Previously, dbBatch had a State field (enum: Open, Closed, Confirmed), but in
the database it is represented as a boolean Confirmed. The Closed state was
stored the same way as Open. This wasn't an issue in practice, since an Open
batch is quickly transitioned to Closed after startup.

However, the in-memory mock stores plain dbBatch instances, leading to
inconsistent behavior between the mock and the real DB-backed store. This
commit updates dbBatch to match the database representation by replacing
the State field with a Confirmed boolean.
2025-06-12 12:32:09 -03:00
Boris Nagaev
7edbfeadd8
sweepbatcher: store batch status before monitoring
If monitorConfirmations fails, we still want to persist the state to DB.
2025-06-12 12:32:09 -03:00
Boris Nagaev
fa1bc48a68
sweepbatcher: remove unneeded for loops
The loop always had exactly one iteration.
2025-06-12 12:31:58 -03:00
Boris Nagaev
01664ad635
sweepbatcher: cancel spendCtx after processing
Function monitorSpendAndNotify used to cancel the context passed to
RegisterSpendNtfn right after starting the goroutine processing results.
Spend notifications were missed.

Now the context is canceled when the goroutine finishes.
2025-06-11 10:34:22 -03:00
Boris Nagaev
2f05934dbb
test/chainnotifier_mock: support errors
Support sending errors to error channels returned by RegisterSpendNtfn and
RegisterConfirmationsNtfn.
2025-06-11 10:34:22 -03:00
Boris Nagaev
cb7c31c1b9
sweepbatcher: fix mistake in batch reading from DB 2025-06-11 10:34:22 -03:00
Boris Nagaev
c036c2adbd
sweepbatcher: fix mock TotalSweptAmount
Forgot to return the calculated total value.
2025-06-11 10:34:22 -03:00
Boris Nagaev
7636ffdc64
test: fix error messages 2025-06-11 10:34:22 -03:00
Boris Nagaev
39f859a046
sweepbatcher: send spend error to notifier 2025-06-11 10:34:22 -03:00
Boris Nagaev
501faa8375
sweepbatcher: unblock sending if notifier quits 2025-06-11 10:34:22 -03:00