Commit graph

2538 commits

Author SHA1 Message Date
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
Slyghtning
db9bd06629
staticaddr: reject malformed MuSig2 signing data
Server-supplied nonces and partial signatures are consumed by the static address loop-in and withdrawal MuSig2 signing paths. Reject nil signing info, wrong nonce lengths, and wrong partial signature lengths before registering nonces or combining signatures, so malformed responses cannot be silently zero-padded into signing attempts.

Add withdrawal coverage for nil and malformed server signing data.
2026-05-29 11:53:32 +02:00
Slyghtning
c78988291c
loopout: fix test wording 2026-05-27 11:51:09 +02:00
Slyghtning
11bf5ca219
loopdb: clean up comments 2026-05-27 11:50:30 +02:00
Slyghtning
089743dacc
liquidity: fix comment typos 2026-05-27 11:50:08 +02:00
Slyghtning
1fa919711f
staticaddr: fix timeout comment typo 2026-05-27 11:49:49 +02:00
Alex Bosworth
aa772faf98
version: bump version to v0.33.1-beta
version: bump version to v0.33.1-beta
2026-05-26 07:32:04 -07:00
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