Commit graph

46 commits

Author SHA1 Message Date
Slyghtning
66a17f47e6
staticaddr: support dynamic deposit confirmation requirements
Reduce MinConfs from 6 to 3 to allow faster swap attempts while the
server enforces risk-based confirmation requirements. Update
SelectDeposits to prioritize more-confirmed deposits first, increasing
the likelihood of server acceptance. Add client-side logging of
insufficient confirmation details from server error responses.
2026-03-11 20:58:35 +01:00
Slyghtning
a10c741a26
lint: fix linter issues 2026-03-09 14:39:45 +01:00
Slyghtning
0b295123e7
staticaddr: remove dead code across managers
Remove unused errChan fields from the loopin, openchannel, and withdraw
managers. These channels were declared and initialized but never read
from or written to.

Remove the unused activeLoopIns map from the loopin manager. The map
was only written to but never read, making it dead code.

Remove the stale withdraw.Store interface whose method signatures no
longer match the concrete SqlStore API used by the manager.

Remove unused config fields from openchannel.Config (Server,
AddressManager, ChainNotifier, Signer) and deposit.ManagerConfig
(AddressClient, SwapClient, ChainParams) along with their daemon
wiring. Also remove the now-orphaned openchannel.AddressManager
interface.

Remove the unused GetStaticAddress and Close methods from
address.SqlStore and the GetStaticAddress method from the address.Store
interface, as the codebase only uses GetAllStaticAddresses.
2026-03-09 14:39:44 +01:00
Slyghtning
f80aee4dae
staticaddr: avoid startup SendEvent data races 2026-03-09 14:39:44 +01:00
Slyghtning
a9977dd5f4
godoc: address copy-paste errors accross the codebase 2026-03-09 14:39:44 +01:00
Slyghtning
4a6ccd3d29
loopin: fix data race on activeLoopIns map during recovery
recoverLoopIns wrote to the activeLoopIns map from inside a goroutine
without any synchronization. The map is shared state accessed from
the manager's main Run loop, creating a data race.

Move the map write before the goroutine spawn so it happens
synchronously during recovery. Also fix the stale log message that
said "OnStart" instead of "OnRecover".
2026-03-09 08:37:49 +01:00
Slyghtning
aadf6e2daa
loopin: exit htlc timeout sweep retry loop on context cancellation
SweepHtlcTimeoutAction used a select with a default case containing a
blocking time.After. When the context was canceled, it logged the error
but continued the retry loop instead of returning. The default case
also meant that ctx.Done was only checked when it was already signaled,
while an hour-long sleep blocked without listening for cancellation.

Replace the default+time.After pattern with a proper select on both
ctx.Done and time.After so the function exits promptly on shutdown.
2026-03-09 08:37:49 +01:00
Slyghtning
63d8f5560e
loopin: enforce HTLC output index invariant in sweep tx construction
createHtlcTx always places the HTLC output at index 0 and the change
output (if any) at index 1. Previously, createHtlcSweepTx attempted to
dynamically find the HTLC index but then unconditionally read
TxOut[0].Value, ignoring the computed index.

Replace the dynamic search with a const htlcInputIndex=0 and a fail-fast
check that errors if the layout invariant is ever violated. Add a test
that verifies the sweep value is derived from the HTLC output, not the
change output.
2026-03-09 08:37:48 +01:00
Boris Nagaev
258d33cce5
staticaddr: clear stale HTLC confs on re-register
- reset htlcConfirmed when the HTLC conf subscription errors and we re-register
- add regression test ensuring re-registers after a conf error require a fresh
  confirmation instead of sweeping on a stale one
2025-12-17 10:11:30 +01:00
Boris Nagaev
f274c689b1
staticaddr: add unit test for HTLC re-registration 2025-12-17 09:21:51 +01:00
Slyghtning
1dd145bc32
staticaddr: re-register on htlc tx conf error 2025-12-17 09:21:51 +01:00
Slyghtning
a918842374
staticutil: refactor methods into utils 2025-12-09 12:21:51 +01:00
Boris Nagaev
6d480cfd9e
staticaddr: require positive heights at startup
Loop now guards all static-address managers against zero block heights: each
constructor returns an error when invoked with a non-positive current height,
and `loopd` validates the height from `GetInfo` before instantiating them.
Tests and helper code were updated accordingly so we fail fast instead of
registering chain notifications with invalid hints.
2025-11-16 01:24:01 -03:00
Slyghtning
152385885f
staticaddr: exclude close-to-expiry depositis from SelectDeposits 2025-10-08 16:24:46 +02:00
Slyghtning
9f57c8ee01
loopin: add loop-in constants to filter expired deposits 2025-10-08 11:38:37 +02:00
Slyghtning
51258af025
staticaddr: fast-flag support
--fast allows the client to expedite the publishing
of on-chain swap transactions with change, e.g. if --amount was specified.
2025-10-07 08:53:39 +02:00
Slyghtning
55081cd8fe
staticaddr: ignoreUnknown flag for DepositsForOutpoints 2025-09-26 12:03:48 +02:00
Slyghtning
a877cfdc4c
staticaddr: checkChange method for sweep signing 2025-09-25 11:13:35 +02:00
Slyghtning
2ee772b251
staticaddr: selected swap amount migration
The selected_amount column of all previous
swaps is filled with the total value of
deposits that partook in these swaps.
2025-09-25 11:13:35 +02:00
Slyghtning
581761a12f
staticaddr: arbitrary loop-in amount
In this commit we add a new function SelectDeposits
to the loop-in manager. It coin-selects deposits that
meet an arbitrary swap amount provided by the client.
We have to ensure that the server creates the correct
change outputs for the htlc- and sweepless sweep
transactions.
2025-09-25 11:13:34 +02:00
Slyghtning
0ee9a617e6
staticaddr: log errors in manager.Run 2025-08-26 09:47:18 +02:00
Slyghtning
e98f733ef8
linter: fix lint issues after linter v2 update 2025-08-19 21:57:00 +02:00
Slyghtning
fe7622db87
staticaddr: fetch deposits as part of swap retrieval
since deposits have been normalized in the db in the
context of a static address swap this commit now
retrieves the deposit information as part of
GetLoopInByHash and GetStaticAddressLoopInSwapsByStates.
2025-08-01 11:26:33 +02:00
Slyghtning
a1af860527
staticaddr: remove unused fsm transition 2025-08-01 11:26:33 +02:00
Slyghtning
6e7441ba8d
staticaddr: migrate swap hashes to deposits 2025-08-01 11:26:32 +02:00
Slyghtning
35901d1247
staticaddr: don't append to public variable PendingStates 2025-08-01 10:34:16 +02:00
Slyghtning
e948c94b95
staticaddr: method to fetch deposits by outpoints 2025-07-29 15:52:54 +02:00
Slyghtning
d526192de7
staticaddr: thread-safe loop-in recovery 2025-06-23 11:00:06 +02:00
Slyghtning
13247c4651
staticaddr: wait for address manager initiation 2025-06-13 15:37:38 +02:00
Boris Nagaev
9f971cd371
staticaddr: fix crash in loop-in manager shutdown
If the notification manager shuts down, sweepReqs channel is closed and sweepReq
object received from it becomes nil, causing panic in handleLoopInSweepReq. Now
this is fixed by checking if the channel was closed and if it was shutting down
loop-in manager itself.
2025-05-13 19:21:57 -03:00
Boris Nagaev
4e4390416b
staticaddr: fix logs, use %v not %w in logs 2025-05-13 11:49:50 -03:00
Boris Nagaev
1af9cb793b
staticaddr: don't rename swapserverrpc to looprpc 2025-04-24 11:19:59 -03:00
Boris Nagaev
dc4a5641ac
multi: initialize block height in New, not in Run
If Run sets the current height field, it is technically a race between Run and
other methods reading the field. Setting in New is a safer option.

Removed a check that height is not 0 from static address manager.
2025-03-19 15:00:31 +01:00
Boris Nagaev
c2dddf0dfe
loopin: use context.WithoutCancel in cleanup
Ensure that MuSig2 cleanup does happen even if a context expires.
2025-03-16 18:21:32 -03:00
Oliver Gugger
722ad8839d
multi: update lnd compile-time dependency to v0.19.0 2025-03-10 22:59:49 +01:00
sputn1ck
51bdf040e3
loopins: add private flag when creating invoice 2025-01-21 18:26:20 +01:00
sputn1ck
115558bed5
staticaddr/loopin: remove unused code 2024-12-12 18:31:09 +01:00
sputn1ck
3f6759c0d4
staticaddr/loopin: update fsm for server ntfn sigs
This commit updates the loop in FSM to handle the new server based
2024-12-12 18:31:09 +01:00
sputn1ck
099e98005c
staticaddr/loopin: add listening for sweep request
This commit adds the listening for sweep requests from the server.
On a sweep request the loopin manager will fetch the loop in from the
db, do sanity and safety checks and then sign the psbt for the input
and send it back to the server.
2024-12-12 18:31:09 +01:00
sputn1ck
409b2e9929
staticaddr/sql_store: Add fetching loop in by hash 2024-12-12 18:31:09 +01:00
Slyghtning
ed1585de60
staticaddr: fix fsm logging 2024-12-12 18:31:08 +01:00
Slyghtning
439d178b96
staticaddr: cmd listdeposits and listswaps 2024-12-12 18:31:08 +01:00
Slyghtning
9a2270eb18
staticaddr: swap manager and fsm
In this commit we add the static address
loop-in state machine and its orchestration
through the manager.
2024-12-12 18:31:07 +01:00
Slyghtning
e7c3717886
staticaddr: sql_store 2024-12-12 18:31:07 +01:00
Slyghtning
1e3f75bb4e
staticaddr: loopin 2024-12-12 18:31:07 +01:00
Slyghtning
3894370302
log: static address loop-in logging 2024-12-12 18:31:06 +01:00