Commit graph

2435 commits

Author SHA1 Message Date
Slyghtning
caa50cc35d
build: increase lint timeout
Allow golangci-lint more time for the larger static-address test suite.
2026-06-30 16:15:52 +02:00
Slyghtning
f32669c70f
cmd/loop: update static loop-in replay fixtures
Refresh static loop-in replay sessions for the low-confirmation warning
and payment-timeout prompts. Add replay coverage for the warning prompt
and update fee and payment-timeout variants for the new interaction
sequence.
2026-06-30 16:15:52 +02:00
Slyghtning
64187c9502
cmd/loop: warn for low-confirmation static deposits
Warn before dispatching a static loop-in that selects deposits below
the conservative six-confirmation threshold. Mirror automatic coin
selection before prompting so the warning reflects both manual and
auto-selected deposits.

Cover manual and auto-selected warning paths in CLI tests.
2026-06-30 16:15:52 +02:00
Slyghtning
fc3fba7c23
staticaddr/loopin: persist risk decisions
Store server confirmation-risk decisions with static loop-in swaps and
recover accepted payment-deadline timers after restart. Wire
notification persistence through loopd so recovered swaps do not lose
pending risk state.

Deduplicate notification fanout cache entries by swap hash.
2026-06-30 16:15:43 +02:00
Slyghtning
d045d5ecd2
staticaddr/loopin: wait for risk decisions
Subscribe to static loop-in confirmation-risk notifications before
starting the payment deadline. Start that deadline only after server
acceptance or the legacy confirmation fallback, and cancel the swap
invoice when the server rejects the risk wait.

Refresh selected deposits before the legacy fallback so recovered
monitors use current confirmation heights.
2026-06-30 16:15:43 +02:00
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
e02e5bc258
staticaddr/loopin: add lnd txout checker
Add a TxOutChecker interface for testing whether an original deposit
outpoint is still available before a static loop-in signs its HTLC
transaction.

Implement the checker using lnd's wallet transaction view so wallet-known
spends, including mempool spends when requested, cause the outpoint to be
reported unavailable.
2026-06-30 16:15:16 +02:00
Slyghtning
cee30f29ae
staticaddr/loopin: preserve selected deposit outpoints
Store an independent snapshot of the deposit outpoints selected for a
static loop-in. This keeps recovered swaps tied to the original funding
outputs even if the deposit records later reflect replacement or
confirmation changes.

Avoid recovering an empty database outpoint string as a synthetic
outpoint entry, and cover recovery of the stored snapshot separately
from the current deposit metadata.
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
7cc33bd027
staticaddr/loopin: account for unconfirmed deposit expiry
Treat unconfirmed static-address deposits as swappable because their CSV
timeout has not started yet. Keep confirmed deposits ahead of
unconfirmed ones during automatic selection, then sort by value and
remaining lifetime within each confirmation group.

Share the expiry calculation with the dynamic-programming selector so
unconfirmed deposits do not look like the earliest-expiring candidates.
2026-06-30 15:08:51 +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
Slyghtning
a134cb1f22
Merge pull request #1158 from hieblmi/log-htlc-tx-fee
Some checks failed
CI / RPC compilation check (push) Has been cancelled
CI / SQL compilation check (push) Has been cancelled
CI / go mod check (push) Has been cancelled
CI / build and lint code (push) Has been cancelled
CI / verify that auto-generated documentation is up-to-date (push) Has been cancelled
CI / run unit-test sqlite3 race (push) Has been cancelled
CI / run unit-test postgres race (push) Has been cancelled
CI / run LiT itests (push) Has been cancelled
CI / run LiT unit tests (push) Has been cancelled
staticaddr/loopin: log HTLC fee guard inputs
2026-06-24 14:39:36 +02:00
Slyghtning
22cec7486c
staticaddr/loopin: log HTLC fee guard inputs
Log the static address loop-in HTLC weight, fee rates, computed fees, and configured fee caps before fee validation. This keeps the existing fee guard behavior intact while making validation failures easier to diagnose.
2026-06-24 14:22:15 +02:00
Boris Nagaev
375c02e0f6
Merge pull request #1156 from starius/lnd-21-improvements
Some checks are pending
CI / RPC compilation check (push) Waiting to run
CI / SQL compilation check (push) Waiting to run
CI / go mod check (push) Waiting to run
CI / build and lint code (push) Waiting to run
CI / verify that auto-generated documentation is up-to-date (push) Waiting to run
CI / run unit-test sqlite3 race (push) Waiting to run
CI / run unit-test postgres race (push) Waiting to run
CI / run LiT itests (push) Waiting to run
CI / run LiT unit tests (push) Waiting to run
Use new features of LND 0.21
2026-06-23 09:56:53 -05:00
Boris Nagaev
682d45405c
cmd/loop: expose both taproot channel types
LND v0.21 added the production TAPROOT commitment type while
SIMPLE_TAPROOT remains available as the legacy enum.

The static open-channel CLI previously used "taproot" for
SIMPLE_TAPROOT. Keep both choices available by renaming that legacy
spelling to "simple-taproot" and mapping "taproot" to TAPROOT. This
makes the CLI spelling match the channel type it requests while still
leaving an explicit path for users that need SIMPLE_TAPROOT.
2026-06-22 15:06:25 -05: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
d324b4bfd8
loop: omit payment hops in cost migration
The cost cleanup migration pages through LND payments only to build
a payment-hash to fee map. It does not inspect HTLC attempts,
routes, or per-hop data; pagination still uses the top-level index
offsets returned by ListPayments.

Setting OmitHops is safe for this migration because LND only strips
hop-level route data from HTLC attempts, while preserving the top-level
payment fields the migration reads: hash, fee, and response offsets.
This reduces response size and query cost for nodes with many or large
MPP payments without changing the calculated swap costs.

The migration test records the mocked ListPayments requests and asserts
that OmitHops is set.
2026-06-22 12:46:12 -05:00
Boris Nagaev
09c92527ea
staticaddr: accept production taproot channels
LND v0.21 exposes CommitmentType_TAPROOT as the production taproot
channel commitment type, while SIMPLE_TAPROOT remains a legacy taproot
enum. Static address channel opens previously rejected TAPROOT and only
classified SIMPLE_TAPROOT as a taproot output for fee and weight
estimates.

Accept TAPROOT in the static address open-channel validator and keep
accepting SIMPLE_TAPROOT for compatibility. Treat both taproot
commitment enums as P2TR outputs for deposit-selection and withdrawal
fee estimates. Callers using the production enum then get the same
weight accounting as the legacy taproot enum.

This does not change the CLI mapping for user-facing
channel_type=taproot. It only makes the static address path compatible
with callers that already send LND production taproot commitment type.
2026-06-22 12:46:12 -05:00
Boris Nagaev
a92f6bc875
build: bump lndclient to v0.21.0-2
Use the tagged lndclient release that exposes the ListPayments
request fields needed by Loop optimizations.
2026-06-22 12:41:03 -05:00
Slyghtning
129d9c1d26
Merge pull request #1154 from hieblmi/pre-dyn-conf-fixes
Some checks are pending
CI / RPC compilation check (push) Waiting to run
CI / SQL compilation check (push) Waiting to run
CI / go mod check (push) Waiting to run
CI / build and lint code (push) Waiting to run
CI / verify that auto-generated documentation is up-to-date (push) Waiting to run
CI / run unit-test sqlite3 race (push) Waiting to run
CI / run unit-test postgres race (push) Waiting to run
CI / run LiT itests (push) Waiting to run
CI / run LiT unit tests (push) Waiting to run
confrisk: preparatory changes
2026-06-22 11:35:02 +02:00
Slyghtning
0bb06b0ba3
notifications: queue blocking fanout
Required notification fanout should not block the manager lock, but subscribers still need ordered delivery once brief backpressure clears. Sending must-deliver notifications directly can couple manager progress to subscriber receive timing, while queueing optional reservation notifications would contradict their best-effort delivery semantics.

Add bounded per-subscriber queues for must-deliver notifications, let those queues own channel shutdown instead of relying on recover for closed-channel sends, keep reservation fanout best-effort, and cover queued delivery, queue cleanup, and capacity drops in manager tests.
2026-06-22 10:58:37 +02:00
Slyghtning
d0c613e5c9 notifications: drop best-effort messages for slow subscribers
A slow optional notification subscriber must not stall the manager lock, while recovery and sweep work requests still need reliable local delivery to keep daemon progress deterministic. Treating all subscribers as blocking makes best-effort fanout a backpressure source for unrelated required work.

Make reservation fanout nonblocking for slow subscribers, keep recovery and sweep notifications on a required cancellation-aware delivery path, and cover both slow best-effort subscribers and required subscribers in manager tests.
2026-06-22 10:18:07 +02:00
Slyghtning
f982ceb753 staticaddr/loopin: include failed swaps in state queries
The final-state query previously formatted the state list with braces, which broke the comma-delimited match for both boundary entries: the first state was compared with a leading brace and the last state with a trailing brace. Final-state callers need swaps at both ends of the list, including HtlcTimeoutSwept and Failed, to remain visible once they reach a terminal status.

Return the final-state list as plain comma-separated state names, update the store comment to match the query format, and extend the store test so it inserts and retrieves swaps in the first final state, a middle final state, and the last final state without relying on result order.
2026-06-22 10:18:07 +02:00
Slyghtning
bbeb813bfa staticaddr/deposit: finalize deposits asynchronously
Final deposit states should not stall while deposit locks are held, because a blocked manager receive loop can otherwise hold up the deposit FSM; if shutdown happens before notification delivery, startup recovery can still resume from the final state.

Send finalization notifications from a goroutine so final states are recorded without waiting on the manager receive loop, and add tests for blocked manager delivery and shutdown races.
2026-06-22 10:18:07 +02:00
Slyghtning
44a6c7a144 staticaddr/loopin: cancel orphan invoice on init failure
A static address loop-in that creates an invoice but then fails before storage cannot be recovered after restart, and persisted error paths that unlock deposits should not leave the swap invoice live either. The payment-deadline path also needs to report the real deposit unlock error instead of checking the FSM event returned by UnlockDepositsAction, because that action returns OnError on both success and failure.

Cancel private swap invoices on pre-storage init failures, monitor timeouts, and stored unlock paths using a detached timeout-limited helper. Factor deposit unlocking into an error-returning helper so deadline handling can log transition failures, and add coverage for early-init cancellation plus generic unlock invoice cleanup and error propagation.
2026-06-22 10:18:07 +02:00
Alex Bosworth
b44f8484f2
Merge pull request #1155 from lightninglabs/alexbosworth-patch-18
Some checks are pending
CI / RPC compilation check (push) Waiting to run
CI / SQL compilation check (push) Waiting to run
CI / go mod check (push) Waiting to run
CI / build and lint code (push) Waiting to run
CI / verify that auto-generated documentation is up-to-date (push) Waiting to run
CI / run unit-test sqlite3 race (push) Waiting to run
CI / run unit-test postgres race (push) Waiting to run
CI / run LiT itests (push) Waiting to run
CI / run LiT unit tests (push) Waiting to run
version: bump version to v0.33.3-beta
2026-06-21 12:50:10 -07:00
Alex Bosworth
a7fb06e205
version: bump version to v0.33.3-beta 2026-06-20 13:39:49 -07:00
Boris Nagaev
8087c7aa13
Merge pull request #1153 from starius/bump-lnd-21
Some checks are pending
CI / RPC compilation check (push) Waiting to run
CI / SQL compilation check (push) Waiting to run
CI / go mod check (push) Waiting to run
CI / build and lint code (push) Waiting to run
CI / verify that auto-generated documentation is up-to-date (push) Waiting to run
CI / run unit-test sqlite3 race (push) Waiting to run
CI / run unit-test postgres race (push) Waiting to run
CI / run LiT itests (push) Waiting to run
CI / run LiT unit tests (push) Waiting to run
build: bump lnd to v0.21
2026-06-20 13:55:04 -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
950b5f1772
test: refresh route hint preservation comments
lndclient now forwards route hints through AddInvoice. These tests
assert that Loop preserves explicit hints on generated loop-in invoices.
Remove stale comments that described the old wrapper behavior as
dropping hints.
2026-06-11 18:08:05 -05:00
Boris Nagaev
2d446b3b9e
test: remove unused PayInvoice mock path
Loop no longer pays invoices through LightningClient.PayInvoice.
Production payment paths use the router client wrappers. lndclient now
also implements PayInvoice on top of router payment APIs, so the old
SendPaymentChannel mock path is no longer exercised.

Remove the dead PayInvoice mock, its SendPaymentChannel plumbing, and
the loop-in resume assertion that watched that channel.
2026-06-11 18:08:02 -05:00
Boris Nagaev
cfe9e401c4
build: bump lnd to v0.21
Update lnd to v0.21.0-beta and lndclient to v0.21.0-1.

Regenerate the LND-derived swagger and CLI manpage outputs after the
dependency bump.
2026-06-11 16:24:30 -05:00
Alex Bosworth
af6af819cf
Merge pull request #1151 from lightninglabs/alexbosworth-patch-17
Some checks failed
CI / RPC compilation check (push) Has been cancelled
CI / SQL compilation check (push) Has been cancelled
CI / go mod check (push) Has been cancelled
CI / build and lint code (push) Has been cancelled
CI / verify that auto-generated documentation is up-to-date (push) Has been cancelled
CI / run unit-test sqlite3 race (push) Has been cancelled
CI / run unit-test postgres race (push) Has been cancelled
CI / run LiT itests (push) Has been cancelled
CI / run LiT unit tests (push) Has been cancelled
version: bump version to v0.33.2-beta
2026-06-08 11:45:43 -07:00
Alex Bosworth
9807c95344
version: bump version to v0.33.2-beta 2026-06-04 08:20:43 -07:00
Slyghtning
f879c52e65
Merge pull request #1150 from hieblmi/show-static-details
Some checks failed
CI / RPC compilation check (push) Has been cancelled
CI / SQL compilation check (push) Has been cancelled
CI / go mod check (push) Has been cancelled
CI / build and lint code (push) Has been cancelled
CI / verify that auto-generated documentation is up-to-date (push) Has been cancelled
CI / run unit-test sqlite3 race (push) Has been cancelled
CI / run unit-test postgres race (push) Has been cancelled
CI / run LiT itests (push) Has been cancelled
CI / run LiT unit tests (push) Has been cancelled
looprpc: populate static address swap timing and cost fields
2026-06-03 20:48:18 +02:00
Boris Nagaev
63affeefd6
cmd/loop: clarify static swap list help 2026-06-03 13:15:01 -05:00
Boris Nagaev
14e540fdc6
loopd: test static address swap rpc fields 2026-06-03 13:15:01 -05:00
Slyghtning
c6b4362e2d
gomod: replace dario.cat/mergo 2026-06-03 18:41:17 +02:00
Slyghtning
51f984f7c0
looprpc: populate static swap timing and costs 2026-06-03 15:33:02 +02:00
Boris Nagaev
5818b986ae
Merge pull request #1120 from starius/htlc-notification2
Some checks failed
CI / RPC compilation check (push) Has been cancelled
CI / SQL compilation check (push) Has been cancelled
CI / go mod check (push) Has been cancelled
CI / build and lint code (push) Has been cancelled
CI / verify that auto-generated documentation is up-to-date (push) Has been cancelled
CI / run unit-test sqlite3 race (push) Has been cancelled
CI / run unit-test postgres race (push) Has been cancelled
CI / run LiT itests (push) Has been cancelled
CI / run LiT unit tests (push) Has been cancelled
loopout: handle htlc confirmed notification
2026-05-30 00:36:41 -05: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
c7ee8f27e9
notifications: log unknown ntfns at debug
Log unknown server notification variants at Debug level instead of Warn
to avoid noisy logs during feature rollout mismatches.
2026-05-29 23:00:29 -05:00
Boris Nagaev
c56c6d3563
notifications: handle htlc confirmed ntfn
Add NotificationTypeHtlcConfirmed and SubscribeHtlcConfirmed so consumers
can subscribe to HTLC-confirmed notifications. Also add dispatch in
handleNotification to forward htlc_confirmed messages to subscribers.
2026-05-29 23:00:29 -05:00
Boris Nagaev
410a4551fc
swapserverrpc: add htlc confirmed notification
Add ServerHtlcConfirmedNotification message to SubscribeNotificationsResponse
oneof. This new notification type allows the server to inform the client that
a loop out HTLC has been confirmed on-chain, including the confirmed outpoint.
2026-05-29 23:00:29 -05:00
Slyghtning
e0e1da5551
Merge pull request #1148 from hieblmi/harden-musig2-handling
multi: validate server-provided signing data and clean up comments
2026-05-29 12:57:23 +02:00
Slyghtning
cc0392af3f
client: reject malformed server public keys
Loop-in and loop-out responses carry compressed server public keys that are copied into fixed-size fields and later used for HTLC construction. Validate the length and parse each compressed key before storing it, and validate the MuSig2 loop-in receiver internal key as well.

This turns short or unparsable server keys into explicit errors instead of silently zero-padding short responses or accepting an invalid internal key. Update root test mocks to return size-correct MuSig2 signing data under the stricter checks.
2026-05-29 11:53:33 +02:00
Slyghtning
605e72a261
sweepbatcher: reject malformed MuSig2 cosign data
The cooperative batch sweep path receives a server nonce and partial signature before constructing a keyspend witness. Validate both byte slice lengths before registering the nonce or combining signatures, so malformed server responses fail explicitly instead of being zero-padded into fixed-size MuSig2 buffers.

Update batcher test helpers to return size-correct placeholder signing data under the stricter validation.
2026-05-29 11:53:33 +02:00