Skip to content

fix(mock): return paymentHash from /decodeinvoice (#67) - #68

Merged
tcheeric merged 2 commits into
developfrom
fix/67-mock-decodeinvoice-payment-hash
Oct 5, 2026
Merged

tcheeric merged 2 commits into
developfrom
fix/67-mock-decodeinvoice-payment-hash

Conversation

@tcheeric

@tcheeric tcheeric commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

Fixes #67.

Problem

Staging's phoenixd-mock /decodeinvoice returned {"amount":1000,"description":"1 Blockaccino"} with no paymentHash. payment-adapter 0.17.2 (PhoenixdGateway.askPhoenixd) decodes each RECEIVE quote's invoice, reads getPaymentHash(), and calls GET /payments/incoming/{hash}. With no hash it throws phoenixd_lookup_failed, the mint answers 500, and MintCircuitBreakerFlapping fires on every e2e run.

There was a second cause on the client side. DecodeInvoiceResponse.paymentHash was @JsonIgnore, so Jackson dropped the field even when the server sent it (checked against the published 0.3.0 jar: hash=null). The mock also had no /payments/incoming route.

Fix

  • mock /decodeinvoice returns phoenixd's shape: chain, amount, paymentHash, description, minFinalCltvExpiryDelta, timestampSeconds. The hash is chosen in this order: the hash the mock issued with the invoice, then the BOLT11 p field, then the SHA-256 of the string, so the answer is always deterministic.
  • mock invoices now carry a real 32-byte hex hash, encoded in the p field of the invoice.
  • mock GET /payments/incoming/{hash} returns paymentHash, isPaid, receivedSat, externalId, ... and gives 404 for an unknown hash. Those are the fields IncomingPaymentResponse reads in the adapter.
  • model: paymentHash is deserialized, and the class sets @JsonIgnoreProperties(ignoreUnknown = true).
  • Release 0.3.3.

Tests

Each test failed before the fix and passes after it. In phoenixd-model (1) and phoenixd-mock (4): issued hash round-trip, the BOLT11 spec vector's p field, deterministic hash for an unknown string, decode then incoming lookup, and DTO deserialization. mvn verify passes on model, rest, base, and mock. phoenixd-test could not bind port 9740 locally because a phoenixd was already running there, so CI covers that module.

Note: payment-adapter still pins phoenixd-java 0.3.0. Against real phoenixd, its client drops paymentHash until it bumps to 0.3.3.

tcheeric added 2 commits October 5, 2026 20:06
…/incoming

The mock's /decodeinvoice answered only amount and description, so
payment-adapter 0.17.2's RECEIVE lookup failed on every quote and the mint
returned 500s. It now returns the issued hash for its own invoices, the p
field for other BOLT11 strings, or a deterministic SHA-256 otherwise, and
serves GET /payments/incoming/{hash}, which the adapter calls next.

DecodeInvoiceResponse no longer @JsonIgnore's paymentHash, which made the
client drop it even when phoenixd sent it, and ignores unknown fields.

Fixes #67
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

Qodana Community for JVM

5 new problems were found

Inspection name Severity Problems
Constant values 🔶 Warning 3
AutoCloseable used without 'try'-with-resources 🔶 Warning 1
Simplifiable conditional expression 🔶 Warning 1

☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

@tcheeric
tcheeric merged commit 01ea3b9 into develop Oct 5, 2026
4 of 6 checks passed
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.

1 participant