Commit graph

2379 commits

Author SHA1 Message Date
Alex Bosworth
92b2004127
version: bump version to v0.33.1-beta 2026-05-24 13:15:50 -07:00
Boris Nagaev
772e67fb86
Merge pull request #1146 from starius/go-mod-fix
ci: fix mod-check
2026-05-24 12:42:57 -05:00
Boris Nagaev
4b8bdfdbb1
ci: fix mod-check
GitLab probably blocked GitHub's CI runner IP address. So we can't download
packages from GitLab directly during this check. Workaround applied: download
these particular packages from proxy.golang.org which works in CI.
2026-05-24 11:38:10 -05:00
Boris Nagaev
12ef083e91
go mod tidy 2026-05-23 15:32:08 -05:00
Boris Nagaev
859ba4508e
Merge pull request #1119 from starius/static-autoloop
autoloop: support static loop-ins
2026-05-22 02:50:42 -05:00
Boris Nagaev
83534a283c
cmd/loop: record static autoloop CLI
Add recorded CLI coverage for selecting the static-address autoloop
loop-in source, displaying the resulting parameters, and showing a static
loop-in suggestion. Also record the non-experimental rejection so the
opt-in gate is covered.

Update existing liquidity fixtures with the default loop-in source field
emitted by the newer RPC shape.
2026-05-22 02:32:15 -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
8d6df2bf20
staticaddr: use dp autoloop selector
Replace the recursive full-deposit autoloop selector with a bounded-memory
DP implementation in staticaddr/loopin/autoloop_dp.go. The new selector
keeps the existing no-change semantics, first finds the best reachable
total, then applies the 25 percent band rule so earlier-expiring deposits
can win inside that near-optimal range.

The DP table is capped at 128 MiB and keeps exact satoshi sums alongside
compressed bucket weights, so planning stays memory-bounded without
allowing oversized candidates. The compressed weighting now rounds down
with a minimum of one bucket, which avoids rejecting valid sums after
multiple per-deposit rounding steps while leaving the exact-sum check
as the real safety boundary.
2026-05-22 02:20:36 -05:00
Boris Nagaev
616b0534a6
docs: update (autoloop supports static) 2026-05-22 02:20:36 -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
94fc04a71a
staticaddr: add autoloop loop-in prep
Add the static-address helper that prepares full-deposit autoloop loop-ins
without dispatching them. The helper selects no-change deposit sets, records
explicit outpoints, and quotes the exact selected amount before the planner
tries to dispatch anything.

The tests cover the full-deposit selector, the quoted request construction,
and excluded outpoint handling so later liquidity work can rely on a stable
preparation surface.
2026-05-22 02:20:36 -05:00
Boris Nagaev
48a7bdc7d0
staticaddr/loopin: makeDeposit gets confheight arg
Test-only change. This is needed to reuse it in another test.
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
Boris Nagaev
ac58336104
looprpc: add autoloop loop-in source
Add a dedicated loop-in source enum to the liquidity parameters
rpc and wire it through the internal parameter model and CLI.

This keeps the source selection explicit before any static
autoloop planning lands, so operators can choose between the
legacy wallet-funded path and a future static-address-backed
path without relying on implicit fallback behavior.
2026-05-22 02:20:36 -05:00
Boris Nagaev
8d5cc2168a
cmd/loop: avoid escaped session text
Disable JSON HTML escaping for recorded session files and for the nested
session payloads rewritten by bless mode. This keeps CLI text such as
"> 1 sat/vByte" readable instead of turning it into "\u003e".

Keep the metadata field order aligned with existing fixtures so a bless
pass does not rewrite unrelated sessions just because the encoder changed.
2026-05-22 02:20:36 -05:00
Slyghtning
72a38c535b
Merge pull request #1133 from 0xfandom/refactor/1056-move-parameters-to-script
staticaddr: move address.Parameters to script package
2026-05-20 22:02:57 +02:00
Boris Nagaev
60d43898f0
Merge pull request #1072 from starius/cli-tests20
cmd/loop: CLI session recording and replay tests
2026-05-20 13:35:37 -05:00
Boris Nagaev
3abede2d8e
cmd/loop: fix openchannel help typo
Correct the duplicated article in the static openchannel
help text so the command summary reads cleanly. Refresh the
recorded help fixtures that surface that summary directly,
including the dedicated openchannel help output and the
parent static command listing.
2026-05-20 03:12:04 -05:00
Boris Nagaev
ca1ce698f0
cmd/loop: bless text-only session updates
Add an env-gated bless mode to recorded-session replay so
CLI-only text changes can refresh fixtures without a live
recording pass. The replay still uses the recorded gRPC
traffic, stdin, and environment, and it only rewrites
stdout, stderr, and run_error after the command preserves
the recorded success or failure shape.

Keep the updater strict by refusing to bless sessions when
replay leaves recorded gRPC events unconsumed, and add
focused tests for the rewrite rules. Document the bless
workflow next to the session fixtures, including the need
for -count=1 so the Go test cache does not skip updates.
2026-05-20 03:12:04 -05:00
Boris Nagaev
e6e3820a76
testdata: add sessions for newly added features 2026-05-20 03:12:04 -05:00
Boris Nagaev
7683da65ff
testdata: add static address and swaps sessions 2026-05-20 03:12:04 -05:00
Boris Nagaev
662f954e0f
testdata: add liquidity sessions 2026-05-20 03:12:03 -05:00
Boris Nagaev
541e0e00fc
testdata: add loop in/out and quote sessions 2026-05-20 03:12:03 -05:00
Boris Nagaev
074257e348
testdata: add instantout and l402 sessions 2026-05-20 03:12:03 -05:00
Boris Nagaev
5157dad741
testdata: add basic swap sessions 2026-05-20 03:12:03 -05:00
Boris Nagaev
9640e3bd4c
cmd/loop: add session recording guide 2026-05-20 03:12:03 -05:00
Boris Nagaev
c3009182b3
cmd/loop: add session replay tests 2026-05-20 03:12:03 -05:00
Boris Nagaev
137097915c
cmd/loop: add session recorder plumbing 2026-05-20 03:12:03 -05:00
Boris Nagaev
c3e102527a
cmd/loop: add session gRPC transport hook 2026-05-20 03:12:03 -05:00
Boris Nagaev
d0591e62b9
cmd/loop: add stdio hooks 2026-05-20 03:12:03 -05:00
Boris Nagaev
cdec0cacef
cmd/loop: add cli clock and hook 2026-05-20 03:12:03 -05:00
Boris Nagaev
3e9a99dd55
cmd/loop: factor newRootCommand 2026-05-20 03:12:03 -05:00
Boris Nagaev
74c7274b03
cmd/loop: add client conn cleanup 2026-05-20 03:12:03 -05:00
Boris Nagaev
3182be8bf1
cmd/loop: remove orphan flag access
abandonSwap used to access flag --id which does not exist.
2026-05-20 03:12:03 -05:00
Boris Nagaev
61945bd9f9
cmd/loop: print homedir in help messages as ~
Make the output homedir-independent to facilitate tests.
2026-05-20 03:12:03 -05:00
Slyghtning
ea03440f29
Merge pull request #1130 from hieblmi/fix-racae
sweepbatcher: harden AddSweep against ctx closure
2026-05-19 07:46:06 +02:00
Boris Nagaev
1b25d8a122
sweepbatcher: assert close-during-add run exit
TestSweepBatcherCloseDuringAdding previously started Batcher.Run in a
detached goroutine and called test assertions from that goroutine. The
test only waited for the add/cancel workers, so a Run-side shutdown
error could be missed or reported unreliably.

Route the Run result through a channel and wait for it in the main test
goroutine. While waiting, keep draining spend registrations so shutdown
cannot deadlock on mock notifier traffic.

This makes the existing shutdown-race test cover both sides of the race:
AddSweep callers may exit with cancellation, and Batcher.Run must also
terminate with an expected shutdown error.
2026-05-18 11:58:54 +02:00
Boris Nagaev
707fef340b
sweepbatcher: mask presign cancellation races
PresignSweepsGroup uses context-sensitive wallet and presigned-helper
calls, but it previously returned their raw wrapped errors even when the
caller context or batcher shutdown state had already become terminal.
That leaves backend/helper errors visible during normal cancellation.

Check for shutdown/cancellation before presigning and after fee lookup
or presigning failures, preferring context.Canceled or
ErrBatcherShuttingDown over lower-level errors.

Log the original presign-path error before returning the shutdown or
cancellation error so normal shutdown remains debuggable without
changing the returned error.

Add a regression test with a presigned helper that cancels the caller
context while returning driver.ErrBadConn from SignTx. The test asserts
PresignSweepsGroup reports context.Canceled and does not wrap the driver
error, and runs against both mock and SQL-backed stores.
2026-05-18 11:58:54 +02:00
Boris Nagaev
8a4e2f1941
sweepbatcher: normalize run-loop shutdown errors
AddSweep now masks cancellation races during its caller-side setup, but
a request can still be accepted by the batcher run loop before the run
context cancellation is selected. If handleSweeps then performs a
context-sensitive store call while shutdown is in progress, a
backend-specific error such as driver.ErrBadConn can still bubble out
through Batcher.Run.

Prefer the run context's terminal error when startup, handleSweeps, or
asynchronous errChan failures happen after the run context has been
canceled. This keeps normal shutdown reporting consistent and avoids
surfacing backend driver errors from the accepted-request and async
error paths.

Log the original run-loop error before returning the context error so
normal shutdown remains debuggable without changing the returned error.

Add regression tests for both covered run-loop races. One lets AddSweep
successfully hand a sweep request to Run, then cancels the run context
from the second GetSweepStatus call while returning driver.ErrBadConn.
The other queues an errChan error from the event loop while canceling
the run context. Both tests assert that Run returns context.Canceled and
does not wrap the driver error.
2026-05-18 11:58:54 +02:00
Slyghtning
b542b50f7f
sweepbatcher: harden AddSweep against ctx closure 2026-05-18 11:58:53 +02:00
Boris Nagaev
010212044a
Merge pull request #1140 from starius/fix-go-mod-check
go.mod: fix gonum replaces (fix CI)
2026-05-11 12:37:38 -05:00
Slyghtning
de279bca67
Merge pull request #1137 from hieblmi/param-validation
staticaddr: validate server address parameters
2026-05-11 09:52:42 +02:00
Slyghtning
6aa6979e77
staticaddr: validate server address parameters 2026-05-11 08:59:03 +02:00
Boris Nagaev
38481fe4a9
go.mod: fix gonum replaces
Remove gonum/plot replace in looprpc - not needed.

Add gonum replace to swapserverrpc. It was missing and caused recent CI errors.
2026-05-10 22:03:36 -05:00
Boris Nagaev
7c3eb29665
Merge pull request #1138 from starius/fix-perms
looprpc: fix build and permissions of two RPCs
2026-05-08 22:17:32 -05:00
Boris Nagaev
02dc98232c
looprpc: fix build
It depends on our protobuf-go fork. It failed with compilation errors when
building the module itself.
2026-05-07 02:37:00 -05:00
Boris Nagaev
e340797225
looprpc: fix permissions of two RPCs
Both SweepHtlc and StaticAddressLoopIn are active, so the "swap" entity
must have action=execute, not read.
2026-05-07 02:24:17 -05:00