Skip to content

fix(lightning): improve error message for unsupported LND partial self-payments - #1113

Merged
callebtc merged 2 commits into
cashubtc:mainfrom
Hardeezah:feat/lnd-allow-self-payment
Aug 13, 2026
Merged

fix(lightning): improve error message for unsupported LND partial self-payments#1113
callebtc merged 2 commits into
cashubtc:mainfrom
Hardeezah:feat/lnd-allow-self-payment

Conversation

@Hardeezah

@Hardeezah Hardeezah commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Description

Refs #1112

Partial (MPP) self-payments fail because the manual routing path used by pay_partial_invoice (QueryRoutes + SendToRouteV2, and the REST equivalents) cannot forward allow_self_payment: neither
QueryRoutesRequest nor SendToRouteRequest exposes the flag, while only SendPaymentRequest does. A functional fix (routing partial payments through SendPaymentV2's manual dest/amt/payment_hash shard mode) is tracked separately in #1112.

This PR is a UX stopgap: it does not enable partial self-payments. When MINT_LND_ALLOW_SELF_PAYMENT is enabled and a partial-payment failure matches the known pathfinding-failure strings (target not found / no route), it appends a note explaining that the cause is an upstream LND limitation on the QueryRoutes path. This lets a mint operator distinguish an expected self-payment failure from an unexpected routing problem.

Changes Made

  • cashu/lightning/lnd_grpc/lnd_grpc.py: in pay_partial_invoice, when the
    QueryRoutes/SendToRouteV2 call raises AioRpcError and the error
    message contains target not found or no route, append the note if the
    self-payment setting is enabled.
  • cashu/lightning/lndrest.py: same handling for the route-fetch error
    branch of pay_partial_invoice.
  • tests/lightning/test_lnd_partial_mocked.py: parametrized tests for both
    backends covering the note appended (setting enabled) and unchanged error
    (setting disabled).

Caveats

  • String matching on target not found / no route is best-effort and LND-version-dependent; the tests assert the note only when these exact substrings appear.
  • No successful-payment flow is changed: the note is appended only in the existing failure branches and only when the opt-in setting is enabled.

Testing

  • make check clean (Ruff + mypy)
  • make test local suite passes; new tests cover all modified lines

@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.45%. Comparing base (0ae760f) to head (efd6ce1).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1113      +/-   ##
==========================================
+ Coverage   74.35%   74.45%   +0.09%     
==========================================
  Files         115      115              
  Lines       13155    13160       +5     
==========================================
+ Hits         9782     9798      +16     
+ Misses       3373     3362      -11     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@Hardeezah
Hardeezah force-pushed the feat/lnd-allow-self-payment branch from 1fcd02f to efd6ce1 Compare August 12, 2026 11:26
@callebtc
callebtc merged commit cdb61ef into cashubtc:main Aug 13, 2026
28 of 29 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in nutshell Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants