Commit graph

339 commits

Author SHA1 Message Date
Slyghtning
dad817a3b2
staticaddr/loopin: cancel signing for unavailable deposits
Check the originally selected deposit outpoints before signing a static
loop-in HTLC transaction. If any selected outpoint is no longer
available, cancel the swap invoice and fail the signing action instead
of producing signatures for stale inputs.

Wire the lnd-backed checker through loopd and make invoice-monitoring
handle closed subscription channels without spinning.
2026-06-30 16:15:16 +02:00
Slyghtning
5506d28f79
staticaddr: sync active deposits with wallet
Treat lnd wallet view as the source of spendable static-address
outputs while keeping historical deposit records in the DB. Reconcile
active FSMs against the current wallet view and reactivate known
deposits when their outpoints are visible again.

Refresh deposits before selection, withdrawal, loop-in, and channel-open
paths, and filter list and summary responses through the live active set
so stale Deposited records are not exposed as available funds.
2026-06-30 16:15:04 +02:00
Slyghtning
ad8e2ea6ca
staticaddr: expose tracked deposit availability
Build list and summary responses from tracked deposit records instead of
raw wallet UTXOs so RPC clients see the manager availability state.
Split unconfirmed value from confirmed deposited value in summaries.

Keep withdrawal and channel-open flows on confirmed inputs by rejecting
unconfirmed selected deposits in those paths.
2026-06-30 15:08:15 +02:00
Slyghtning
32b3b9650f
staticaddr/deposit: track unconfirmed deposits
Retain static-address deposits as soon as lnd reports the UTXO,
even when the output is still unconfirmed. Store the first
confirmation height once the output confirms.

Replay the startup block to recovered deposit FSMs so expiry handling
can run immediately after restart. Derive confirmation heights from a
stable wallet view because lnd reports confirmation counts.
2026-06-30 15:07:52 +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
914a3eeced
loopd: raise minimum lnd version to v0.18.4-beta
LoopMinRequiredLndVersion was 0.17.0, a value that only ever tracked the
go.mod lnd dependency rounded down and was never updated as the client
started depending on newer lnd RPC APIs. The client today uses RPC
fields that do not exist in 0.17.0:

  - routerrpc.SendPaymentRequest.first_hop_custom_records and
    lnrpc.Route.custom_channel_data, used by asset loop outs in
    loopout.go: both added in lnd v0.18.4-beta.
  - walletrpc.EstimateFeeResponse.min_relay_fee_sat_per_kw, read by the
    sweep batcher fee floor via lndclient WalletKit.MinRelayFee
    (sweepbatcher/, loopd/sweep_htlc.go): added in lnd v0.18.3-beta. On
    older lnd it silently decodes to 0, disabling the min-relay floor.

Raise the floor to the highest of these (v0.18.4-beta) so loopd fails
fast at startup rather than misbehaving at runtime, and document in
AGENTS.md the rule to keep this value pinned to the lnd APIs the client
actually uses instead of tracking go.mod.
2026-06-16 01:12:03 -05:00
Boris Nagaev
14e540fdc6
loopd: test static address swap rpc fields 2026-06-03 13:15:01 -05:00
Slyghtning
51f984f7c0
looprpc: populate static swap timing and costs 2026-06-03 15:33:02 +02:00
Boris Nagaev
f443fe4f62
loopd: recover confirmed htlcs with direct sweep 2026-05-29 23:00:29 -05:00
Boris Nagaev
33917e1dbd
loopd: prefer stored destination in sweephtlc 2026-05-29 23:00:29 -05:00
Boris Nagaev
6c57f05d8a
loopd: add missing debugf logging helper 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
8ea9adbd35
looprpc: map custom channel reason
Static autoloop testing surfaced a SuggestSwaps failure when the
planner disqualified a custom asset channel.

Add the missing AutoReason enum value and handle ReasonCustomChannelData.
2026-05-22 02:20:36 -05:00
Boris Nagaev
58ebb042ff
liquidity: add static autoloop planner
Wire static-address-backed loop-ins into the existing autoloop
planner and dispatch path. Loop-in rules can now be converted into
static candidates, prepared after global sorting, filtered with
static fee limits, and dispatched through the static manager.

This also fixes MaxAutoInFlight enforcement across all suggested
swap types and adds planner tests for missing static candidates
and mixed in-flight filtering.
2026-05-22 02:20:36 -05:00
Boris Nagaev
e467ac932b
looprpc: expose static autoloop output
Extend the public rpc surface for static autoloop integration
without turning the planner on yet. SuggestSwaps responses can
now carry static-address loop-in requests and the new planner
reason for missing static candidates is mapped over rpc.
2026-05-22 02:20:36 -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
Boris Nagaev
562416e99b
loopd: validate static loop-in labels at rpc
Move static loop-in label validation to the rpc boundary and
remove the same check from the internal manager path.

This keeps external requests aligned with the existing swap rpc
surface while allowing internal autoloop callers to keep using
reserved labels for automated swaps. The tests cover both sides of
that contract: rpc requests still reject reserved labels, and the
manager path accepts them.
2026-05-22 02:20:36 -05:00
0xfandom
8b89f77529 staticaddr: move address.Parameters to script package
The Parameters struct describes the keys, expiry and pkScript that
define the static address script, so its natural home is the script
package. Moving it there lets staticutil drop its dependency on the
address package and lets callers reuse a single type alongside
script.StaticAddress and script.NewStaticAddress.

No behavior change.

Closes #1056
2026-05-01 15:54:37 +05:30
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
a9977dd5f4
godoc: address copy-paste errors accross the codebase 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
Slyghtning
f47b611557
looprpc: extend client.proto with lnrpc.OutPoint and lnrpc.OpenChannelRequest
In this commit we import the lnd's lightning.proto into client.proto to
then be able to use lnrpc.OutPoint and lnrpc.OpenChannelRequest instead
of the looprpc.OutPoint type.
This is safe because the lnrpc and looprpc versions of OutPoint are the
same type.
2026-02-26 09:37:26 +01:00
Boris Nagaev
59140265ca
loopd: implement SweepHtlc RPC 2026-01-29 17:40:58 -05: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
Boris Nagaev
bde49d7a91
loopd: wait for chain notifier
Use https://github.com/lightninglabs/lndclient/pull/255
2025-11-16 00:26:02 -03:00
András Bánki-Horváth
0a182ee308
Merge pull request #1029 from bhandras/resume-stuck-swaps
loop: add resume manager
2025-10-31 15:01:28 +01:00
Boris Nagaev
325441bf47
loopd: fix crash in instant if no --experimental
Previously the daemon crashed with a panic. Now the CLI returns the following
message:

[loop] rpc error: code = Unimplemented desc = Restart loop with --experimental
2025-10-31 01:36:22 -03:00
Andras Banki-Horvath
460fc116d8
loop: add resume manager 2025-10-30 22:41:00 +01:00
Slyghtning
de2964efba
loopd: refactor blocks-until-expiry calculation 2025-10-09 09:14:43 +02:00
Slyghtning
0d3a4c8a19
loopd: more info in StaticAddressLoopInResponse 2025-10-08 21:34:48 +02:00
Slyghtning
68baebf478
loopd: return quoted amount in InQuoteResponse 2025-10-07 11:13:44 +02:00
Slyghtning
168420c28d
loopd: fast-flag in GetLoopInQuote and StaticAddressLoopIn 2025-10-07 09:12:38 +02:00
Slyghtning
55081cd8fe
staticaddr: ignoreUnknown flag for DepositsForOutpoints 2025-09-26 12:03:48 +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
23f6c24c0c
staticaddr: fix swap amount in listswaps command 2025-09-25 11:13:34 +02:00
Slyghtning
95a456791b
loopd: deposit selection for GetLoopInQuote
If a quote request contains an amount and flag
SelectDeposits set to true the quoting coin-
selects the required deposits to meet the
swap amount in order to quote for the number
of deposits.
2025-09-25 11:13:34 +02:00
Slyghtning
a862f8ba60
test: unit test ListUnspentDeposits 2025-08-22 16:18:15 +02:00
Slyghtning
d3a2badc8b
loopd: filter unavailable deposits in ListUnspentDeposits
ListUnspentRaw returns the unspent wallet view of the
backing lnd wallet. It might be that deposits show up
there that are actually not spendable because they
already have been used but not yet spent by the server.
We filter out such deposits in ListUnspentDeposits.
2025-08-22 15:54:19 +02:00
Slyghtning
b2a4d7af2d
staticaddr: show deposits as part of cli swap output 2025-08-20 17:07:29 +02:00
Slyghtning
a41334dd3d
staticaddr: add swap hash to deposit structs 2025-08-20 16:58:20 +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
fab4a646df
Merge pull request #967 from starius/neutrino-fixes
staticaddr: neutrino fixes
2025-06-25 13:41:50 -03:00
Andras Banki-Horvath
d12dc0362d
loopd: avoid panic if asset client is not set 2025-06-24 14:55:42 +02:00