Skip to content

Prepare Liquid2 merge into dev - #366

Open
BullishNode wants to merge 89 commits into
devfrom
bullishnode/liquid2-dev-ready
Open

Prepare Liquid2 merge into dev#366
BullishNode wants to merge 89 commits into
devfrom
bullishnode/liquid2-dev-ready

Conversation

@BullishNode

@BullishNode BullishNode commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Prepare features/liquid2 for merge into dev, including features/elgetaddrinfo.

This branch brings the Liquid/Elements integration forward onto current dev, keeps Bitcoin behavior compatible, hardens the Liquid request/runtime paths, and adds repeatable merge-readiness test coverage.

Merge strategy

The strategy was compatibility-first:

  • Bring the Liquid2 feature work onto current dev.
  • Include the separate Elements getaddressinfo endpoint because the Liquid watch flow benefits from a first-class way to inspect owned Elements addresses.
  • Avoid redesigning the Liquid2 architecture.
  • Add only focused merge-readiness changes on top: concrete runtime fixes, defensive request handling at API/RPC boundaries, database migration coverage, and repeatable local/staging validation.

Commit-level rationale

elements_getaddressinfo endpoint

Rationale:

  • This intentionally brings in features/elgetaddrinfo.
  • It exposes the Elements equivalent of address inspection through the existing proxy/Gatekeeper path.
  • It is useful for Liquid watch flows because Elements Core can report wallet ownership and the unconfidential form of a confidential address.

Strategy:

  • Keep the endpoint permission at the existing watcher level, matching the address-inspection use case.
  • Add it to both sample and generated Gatekeeper API properties.
  • Add it to the Gatekeeper authorization test coverage.
  • Route the request through the existing Elements RPC helper, with optional wallet support.

Make Liquid integration merge-ready

Rationale:

  • This is the main reconciliation commit after bringing Liquid2 onto current dev.
  • It addresses concrete merge-readiness gaps found while exercising Elements watches, migrations, Paymentalist build/runtime behavior, and callback handling.
  • It keeps the existing Liquid2 model intact while aligning fresh installs and upgraded databases.

Strategy:

  • Add a PostgreSQL migration that makes the Elements watch identity include watching_assetid, matching the fresh-install schema and allowing the same address/callback pair to be watched for different assets.
  • Make the migration idempotent and transactional so it is safe to run during upgrades.
  • Select a deterministic matching Elements transaction detail by watched address and optional asset before persisting callback state.
  • Preserve one-shot callback semantics while making the persisted vout, amount, and asset come from the selected watched output.
  • Fix Elements wallet/RPC routing and response handling where tests showed mismatches.
  • Add Elements regression tests for the merge-sensitive cases rather than relying only on manual smoke testing.

Harden Elements RPC request handling

Rationale:

  • The Elements RPC layer accepts API-provided values such as addresses, txids, asset ids, labels, wallet selectors, and callback parameters.
  • For merge readiness, these values should be passed to JSON-RPC as data, not by string-splicing request bodies.
  • Invalid wallet selectors or malformed request values should fail deterministically before reaching the node.

Strategy:

  • Build Elements JSON-RPC payloads with jq --arg and --argjson so request values cannot alter the JSON-RPC method or structure.
  • Validate wallet selector values before constructing wallet-specific RPC URLs.
  • Validate txid and asset-id shape where those values are used for persistence or lookup.
  • Validate JSON-RPC response shape from Elements before treating a response as successful.
  • Keep endpoint response shapes compatible while tightening error paths and adding regression coverage.

Harden Liquid watch and Paymentalist runtime

Rationale:

  • Liquid watch/unwatch paths store and return API-provided strings in SQL and JSON responses.
  • Those paths need consistent quoting and input validation because they are merge-critical: watches must be persisted, removed, and reported reliably.
  • Paymentalist should run as a lean service image without shipping test helpers or logging request/response bodies.

Strategy:

  • Add shared shell helpers for SQL string literals and JSON string literals, then use them in Elements watch/unwatch paths.
  • Validate numeric watch ids, txids, xpub derivation positions, and callback requirements before mutating watch state.
  • Support a Liquid-specific xpub derivation-gap override while preserving the existing generic default.
  • Ensure watch/unwatch JSON responses remain valid even when labels, callbacks, xpubs, or addresses contain special characters.
  • Trim the Paymentalist runtime image to the service binary and reduce HTTP middleware logging to metadata/status/duration.

Add Liquid2 merge-readiness test harness

Rationale:

  • The PR needs repeatable evidence that the branch can be reviewed and retested without depending on one-off manual commands.
  • Existing regression scripts needed to work reliably in non-interactive Docker Compose environments.
  • Upgrade safety needed a direct check from current dev schema to the candidate Liquid2 schema.

Strategy:

  • Add contrib/liquid2-merge-readiness/local-static.sh for local static checks, Elements shell regressions, Paymentalist Rust checks, and Docker image builds.
  • Add contrib/liquid2-merge-readiness/migration-dev-to-liquid2.sh to create an isolated current-dev database, run candidate migrations twice, and verify Bitcoin data survives while Liquid tables/indexes are present.
  • Add contrib/liquid2-merge-readiness/staging-server-live-smoke.sh for live deployed-stack smoke coverage against Bitcoin Core and Elements without broadcasting spends.
  • Add contrib/liquid2-merge-readiness/gatekeeper-auth-matrix.sh to test every deployed Gatekeeper action against no token, invalid token, and all configured API ids.
  • Make the existing watch/missed-confirmation test helpers non-interactive and Docker Compose-aware so they can be run repeatedly in local automation.
  • Keep the readiness scripts outside runtime paths; they are review/test gates, not production dependencies.

Validation

Passed:

  • contrib/liquid2-merge-readiness/local-static.sh
  • contrib/liquid2-merge-readiness/migration-dev-to-liquid2.sh
  • contrib/liquid2-merge-readiness/gatekeeper-auth-matrix.sh
  • contrib/liquid2-merge-readiness/staging-server-live-smoke.sh
  • proxy_docker/app/tests/test-watches.sh
  • proxy_docker/app/tests/test-elements-manage-missed.sh
  • proxy_docker/app/tests/test-manage-missed.sh

Live staging validation covered:

  • Docker service health for broker, gatekeeper, Paymentalist, PostgreSQL, and proxy.
  • Bitcoin Core and Elements RPC connectivity on mainnet/Liquid mainnet.
  • Gatekeeper action inventory and authorization matrix coverage.
  • Bitcoin and Elements watch/missed-confirmation regression paths.

Notes for reviewers

  • This is a draft PR so review can happen before the final merge decision.
  • The new readiness scripts are not product runtime dependencies; they are repeatable gates for local and staging verification.

Kexkey added 30 commits March 14, 2024 16:12
filecommander and others added 29 commits April 17, 2025 11:50
* Paymentalist / check_bolt11_mrh

---------

Co-authored-by: Philippe Lamy <philippe@philippelamy.ca>
…p-testing-script

Feature/create reverse swap testing script
Bump ELEMENTS_VERSION to v23.2.5
(cherry picked from commit 5d034a4)
(cherry picked from commit cc55bd9)
(cherry picked from commit 850deb7)
* Testing watching from spender

* Support for multiple spending wallets
…v-ready

# Conflicts:
#	cyphernodeconf_docker/templates/bitcoin/walletnotify.sh
#	proxy_docker/app/script/manage_missed_conf.sh
@BullishNode
BullishNode marked this pull request as ready for review July 24, 2026 18:08
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.

6 participants