Commit graph

98 commits

Author SHA1 Message Date
Slyghtning
514c3f06ad
loopd: close tapd client connections
Close the TapdClient when daemon initialization fails, during normal
shutdown, and after the view command completes. This prevents gRPC
transport resources from leaking across embedded daemon lifecycles and
error paths.
2026-08-03 10:05:04 +02:00
Gustavo Stingelin
e3e6205a4b
staticaddr/loopin: publish status updates after persistence 2026-07-21 11:33:47 -03:00
Slyghtning
3e2b9452fe
loopd: wire static risk decision persistence
Create the static loop-in SQL store before the notification manager and
pass a persistence callback so server confirmation-risk decisions are
durably recorded before fanout.
2026-07-12 09:14:34 +02:00
Slyghtning
6582aa0807
staticaddr/loopin: check deposits before htlc signing
Before we send HTLC signatures to the server, the server cannot publish
the HTLC transaction. After those signatures are handed over, the server
can publish an HTLC that spends the selected deposits even if it never
pays the swap invoice.

Defend against stale local deposit state by checking the wallet's current
txout view immediately before signing. A deposit can have been spent by a
known withdrawal, channel open, timeout sweep, replacement, or another
wallet transaction while the loop-in FSM is recovering or while earlier
state still marked it as selected.

Failing before signing leaves the server without spend authority over an
unavailable input. Include mempool spends in the check so wallet-known
unconfirmed spends are treated as unavailable too.
2026-07-08 09:02:06 +02:00
Boris Nagaev
5d8a5019cf
lint: enable deprecation checks
Enable staticcheck's SA1019 check in golangci-lint so deprecated
identifiers are caught in CI.

Replace deprecated standard library and bbolt APIs with their current
equivalents. Keep intentional compatibility reads and writes of
deprecated Loop RPC fields behind narrow nolint annotations, because
older clients and persisted liquidity parameters still depend on those
fields.
2026-06-22 12:46:12 -05:00
Boris Nagaev
f443fe4f62
loopd: recover confirmed htlcs with direct sweep 2026-05-29 23:00:29 -05:00
Boris Nagaev
7fcc508193
liquidity: gate static autoloop
Static-address loop-ins in autoloop are still experimental. Reject
loop_in_source=static-address at the RPC boundary unless loopd was started
with --experimental, and pass the same opt-in into the liquidity manager so
persisted params cannot bypass the gate after restart.

The existing static swap accounting remains wired through the manager; the
gate only controls accepting and planning new static-address autoloops.
2026-05-22 02:32:15 -05:00
Boris Nagaev
7cf0a87c2b
liquidity: count static loop-ins
Teach the liquidity manager to include persisted static loop-ins
in budget accounting, in-flight limits, and peer traffic backoff.
This adds the static fee model used for conservative accounting
and passes storage errors through the relevant planner helpers.

The daemon wiring now exposes static loop-ins to liquidity so the
manager can see the same ongoing swaps that the static-address
subsystem persists, while easy autoloop keeps working with the new
fallible traffic lookup path.
2026-05-22 02:20:36 -05:00
Slyghtning
b702aebbf4
multi: inject clocks into swap lifecycle and update tests
Inject clock.Clock into swapConfig so that swap initiation times
are deterministic and testable. Update all swap tests to use
TestClock with a fixed time, and assert that InitiationTime
matches the clock value.
2026-03-13 08:58:56 +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
b74dab8af4
loopd: instantiate static address open channel manager 2026-02-26 20:57:27 +01:00
Boris Nagaev
d1c4a7da8a
loopd: test error reporting logic 2025-12-20 06:31:02 +01:00
Slyghtning
f4e7e676d4
loopd: fix errors.Is argument order 2025-12-19 10:18:09 +01:00
Boris Nagaev
a4dc59099b
cli: add command "loop stop"
* add StopDaemon RPC with permissions + REST binding
* expose `loop stop` CLI (with optional --wait) and wait logic
* pass daemon shutdown callback + unit test and regenerate docs/protos
2025-11-19 23:42:48 -03: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
Andras Banki-Horvath
460fc116d8
loop: add resume manager 2025-10-30 22:41:00 +01: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
38a44968c7
loopd: atomic var to enforce daemon singelton 2025-08-19 22:08:29 +02:00
Slyghtning
bd6271e633
loopd: log correct error if daemon start fails 2025-08-19 21:57:00 +02:00
Slyghtning
6e7441ba8d
staticaddr: migrate swap hashes to deposits 2025-08-01 11:26:32 +02:00
Boris Nagaev
6f50b27b7d
loopd: increase withdrawal manager start timeout
This is needed for neutrino.
2025-06-24 01:44:32 -03:00
Slyghtning
13247c4651
staticaddr: wait for address manager initiation 2025-06-13 15:37:38 +02:00
Slyghtning
614d61937e
loopd: retrieve historic withdrawal info 2025-06-10 17:07:32 +02:00
ffranr
64e6bbd451
perms: move perms.go into looprpc
The Lightning Node Connect (LNC) WASM client currently imports both
`looprpc` and the entire `loop` module to access `perms.go`. This
creates problems because `loop` imports `taproot-assets`, resulting in
too many symbols for the WASM build.

To fix this, we will move `perms.go`—which defines RPC endpoint
permissions—into `looprpc`. After this change, the LNC WASM client will
import only `looprpc`, while the rest of `loop` can continue importing
`taproot-assets` without affecting the LNC WASM build.
2025-04-28 12:56:21 -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
4c292f179f
staticaddr: fix race conditions in current height
Make the current height an atomic variable in staticaddr/address/manager.go and
in staticaddr/withdraw/manager.go.
Removed the initiation height from staticaddr/deposit/manager.go (not needed).
2025-03-19 15:00:30 +01:00
Boris Nagaev
e0e66a9b38
loopd: fix data races of logger 2025-03-19 15:00:30 +01:00
Boris Nagaev
2249c41d2f
loopdb: switch to go.etcd.io/bbolt
github.com/coreos/bbolt has race conditions:
https://github.com/golang/go/issues/54690
2025-03-19 15:00:30 +01:00
sputn1ck
8451f29f8f
loopd: add asset client to swap config 2025-01-21 14:38:02 +01:00
Slyghtning
10b970c5cc
staticaddr: no experimental flag for static 2024-12-13 21:40:42 +01:00
Slyghtning
fc6c9f224c
staticaddr: add initiation height of address 2024-12-12 18:31:10 +01:00
sputn1ck
a98e16184e
loopd/staticaddr: add ntfn manager 2024-12-12 18:31:09 +01:00
Slyghtning
21c37a910a
loopd: static address loop-in support 2024-12-12 18:31:08 +01:00
Slyghtning
a7f2f2d8c8
loopd: static address withdrawals support 2024-12-12 18:31:05 +01:00
Slyghtning
3914ab840f
staticaddr: deposits for server and daemon 2024-12-12 18:31:03 +01:00
Slyghtning
40c731f654
daemon: integrate static address manager and sql store 2024-12-12 18:31:01 +01:00
Slyghtning
22b1f53e3e
daemon: add signet support 2024-11-21 13:47:23 +01:00
sputn1ck
e9f1a1aef3
ntfn: use l402 store for tokens
This commit changes the way we fetch the l402 tokens for the
notification stream. Instead of fetching them from the server and
paying an invoice, we now look into our local store for the token.
This means that a loop client will not autofetch a token.
2024-10-30 17:12:28 +01:00
sputn1ck
f2fb722901
reservation: add initchan
This fixes a flake in the unit tests
2024-10-22 11:46:31 +02:00
sputn1ck
7409ae73c6
loopd: add notification manager
This commit adds the notification manager to the
loopd daemon.
2024-10-08 14:58:41 +02:00
Andras Banki-Horvath
0e2a36004a
loopd: allow setting RPC batch size when running cost migration
Previously we defaulted to fetching 1000 payments at a time when running
the cost migration however due to slowness on LND side this may prevent
the migration from completing due to RPC timeout kicking in. This commit
adds a new config value to give more control to the user by setting the
batch size as needed.
2024-09-20 10:13:48 +02:00
Boris Nagaev
1947b90842
multi: typed callback in ExecTx
Provide a wrapped store type, exposing ExecTx method with a subset
interface in the callback argument. BaseDB interfaces in instantout,
reservation and sweepbatcher use ExecTx with their subset Querier
instead of whole sqlc.Querier (*sqlc.Queries).

This is needed to make the packages more reusable, so they don't
depend on methods of *sqlc.Queries they don't use.
2024-06-19 10:38:55 -03:00
Andras Banki-Horvath
3754730525
loop: paginate fetching payments when running the cost migration 2024-06-05 08:54:24 +02:00
Andras Banki-Horvath
c7fa1e4109
loopd: run the cost migration on start 2024-06-03 14:54:18 +02:00
Slyghtning
636f8b611b
daemon: fix wrapped errors and typos 2024-05-01 07:55:01 +02:00
Boris Nagaev
e30cb5f2a8
multi: apply make fmt 2024-04-23 15:18:15 -03:00
sputn1ck
7cafbe957d
loopd: add instantout handling 2024-02-06 15:07:59 +01:00
George Tsagkarelis
0914074b10
loop: integrate sweepbatcher to loopout flow 2024-01-23 20:38:10 +02:00
sputn1ck
f00329d7c7
loopd: hide reservation manager behind flag. 2024-01-17 15:59:08 +01:00