Skip to content

regtest: add source-built Loop server - #1222

Open
sputn1ck wants to merge 1 commit into
masterfrom
kon/regtest-loop-server
Open

regtest: add source-built Loop server#1222
sputn1ck wants to merge 1 commit into
masterfrom
kon/regtest-loop-server

Conversation

@sputn1ck

@sputn1ck sputn1ck commented Sep 1, 2026

Copy link
Copy Markdown
Member

Summary

  • add a regtest-only Loop server that completes real protocol-11 Loop Out, standard Loop In, and static-address deposit Loop In swaps
  • build the server from this repository and place it behind an L402-authenticated Aperture proxy in the disposable Docker topology
  • add protocol-focused tests, a clean-start harness, an automated three-flow acceptance script, and a complete operator runbook
  • recover a Loop Out preimage from a fully validated confirmed Taproot success spend when the client's best-effort preimage RPC is lost

Safety boundary

The server refuses non-regtest lnd nodes and intentionally keeps swap state in memory. It is a protocol fixture, not a production service, and the runbook warns against exposing it to untrusted networks or valuable funds.

Testing

  • make lint
  • go test -race ./regtest/server -count=1
  • go test ./... -run '^$'
  • go test ./regtest/server -run '^TestLoopOutRecoversPreimageFromSuccessSpend$' -count=20
  • ./regtest/regtest.sh start
  • ./regtest/e2e.sh

The live acceptance run completed Loop Out and standard Loop In in SUCCESS, static-address Loop In in SUCCEEDED, and its deposit in LOOPED_IN, with an empty mempool after scripted confirmation mining.

Copilot AI lite review requested due to automatic review settings September 1, 2026 17:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a source-built, regtest-only Loop server (built from this repo) plus a refreshed Docker-based regtest topology, scripts, and tests to exercise real protocol flows (Loop Out, standard Loop In, static-address deposit Loop In) through loopd/loop.

Changes:

  • Introduces a new regtest/server implementation of the swap + static-address server RPCs, including update/notification hubs and protocol-driven tests.
  • Adds a new cmd/loopserver-regtest binary and a Docker build for it, wiring it behind an L402-authenticated Aperture proxy in the regtest Compose stack.
  • Updates the regtest operator experience (scripts, e2e acceptance runner, runbook) and adds release notes for the new environment.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
regtest/server/updates.go In-memory state update hub + notification hub used by swap/static-address flows.
regtest/server/updates_test.go Unit tests for update/notification replay and cancellation behavior.
regtest/server/staticaddr_test.go Static-address protocol tests (MuSig2 signing, admission policy, idempotence, etc.).
regtest/server/server.go Core regtest server wiring/config validation and lifecycle management.
regtest/server/server_test.go Validation tests for server config bounds (Loop In CLTV delta).
regtest/server/rpc.go Implements small RPC surface including L402 fetch and notification streaming.
regtest/server/loopout.go Protocol-11 Loop Out server implementation with HTLC publication, confirmation, and preimage recovery.
regtest/server/loopout_test.go Loop Out protocol tests (happy path, ambiguous broadcast reconciliation, preimage recovery, cancellation).
regtest/server/loopin.go Standard Loop In server implementation with probe payment handshake and on-chain claim.
regtest/server/loopin_test.go Loop In protocol tests including duplicate/idempotence handling and sweep publishing.
regtest/server/helpers.go Shared helpers for keys, amount validation, invoice decoding/validation, chain height, etc.
regtest/regtest.sh Reworked regtest orchestration script (compose selection, readiness waits, clean start, L402 bootstrap).
regtest/README.md New runbook describing the source-built regtest server topology, safety boundary, and workflows.
regtest/e2e.sh Automated acceptance script to run all three flows via real CLI/API, mining required confirmations.
regtest/Dockerfile Multi-stage build for the loopserver-regtest binary used in the Compose topology.
regtest/docker-compose.yml Updates Compose stack to build/run the in-repo server, pin Aperture build, and refresh supporting services.
regtest/aperture.yaml Aperture config for L402 + routing to the loopserver backend in regtest.
docs/release-notes/release-notes-next.md Release note entry for the new source-built regtest server environment.
cmd/loopserver-regtest/main.go New entrypoint binary: connects to lnd/bitcoind, enforces regtest-only policy, serves gRPC (+ optional TLS).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 56 to 58
- "--debuglevel=debug"
- "--externalip=lndserver"
- "--tlsextradomain=lndserver"
Comment thread regtest/server/server.go
Comment on lines +189 to +193
func (s *Server) goSwap(run func(context.Context)) {
s.wg.Go(func() {
run(s.ctx)
})
}
Comment on lines +83 to +90
minLndVersion := &verrpc.Version{
AppMajor: 0,
AppMinor: 18,
AppPatch: 4,
BuildTags: []string{
"signrpc", "walletrpc", "chainrpc", "invoicesrpc",
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants