web3.path

PHASE 26 Lightning and production proof · 20–40 hours

Lightning Engineering & Production Capstone

Lightning is a payment network with online operational requirements. Model payment states and reconciliation explicitly; do not equate an invoice string with settlement.

Goal — deliver a recoverable, observable Lightning payment integration or an equivalent EVM/Bitcoin production capstone with evidence another engineer can reproduce.

1. Channel and payment state

StateWhat the application must do
Invoice createdPersist idempotency key, amount, expiry, destination/account, and status; do not credit user.
Payment pendingShow pending; retain correlation IDs; retry only using a defined policy.
SettledConsume node event, reconcile durable ledger, credit exactly once.
Failed/expiredRecord reason; do not silently create another payment attempt.
Channel impairedSurface liquidity/route issue; do not claim the network is unavailable without evidence.
Force close/recoveryFollow the documented backup/watchtower/reconciliation runbook.

Study BOLTs and choose LND, Core Lightning, or LDK deliberately. Channels use funding outputs, commitment transactions, HTLCs, timelocks, routing, and liquidity management. Inbound and outbound liquidity are separate constraints.

1b. LDK embedding & watchtowers

2. Service implementation pattern

POST /invoices
  require(Idempotency-Key)
  validate(amount, currency, customer)
  persist(orderId, idempotencyKey, status="created")
  create invoice through authenticated node adapter
  persist(invoiceId, expiresAt, status="pending")

node event consumer
  verify event identity and deduplicate
  transactionally transition pending → settled
  append immutable ledger entry
  emit application event

reconciler (scheduled)
  compare node invoices/payments, channel state, on-chain wallet and ledger
  alert on mismatches; never auto-delete evidence

3. Operational drills

4. Capstone acceptance criteria

TrackRequired evidence
EVM protocolThreat model, Foundry unit/fuzz/invariant/fork tests, verified testnet deploy, Safe/timelock plan, monitoring and incident drill
EVM infrastructureReorg-safe indexer, provider failover, replay tests, durable nonce handling, dashboard and load/failure evidence
Bitcoin walletDescriptor/PSBT tests, independent transaction review, multisig recovery drill, RBF/CPFP policy, signer isolation
Lightning serviceIdempotent settlement ledger, event/reconciliation tests, liquidity/channel monitoring, recovery and force-close drill
Deliverable — publish a repository that can be cloned and run from a documented environment. Include pinned dependencies, test commands, a threat model, architecture diagram, deployment/config manifest (without secrets), dashboard screenshots or definitions, runbooks, and a postmortem for one induced failure. A reviewer must be able to reproduce the most important tests without your help.

Template: labs/phase-26-capstone/ · Rubric: capstone rubric · Lightning lab: labs/phase-26-lightning/

Safety — completing a course capstone does not make real-money systems safe. Obtain independent review, start with limits and controlled rollout, and do not keep user custody unless you are prepared to operate the security and compliance program it requires.
← Phase 25Back to Home