Skip to content

[WIP] feat(lightning): add CLN RPC#903

Open
b-l-u-e wants to merge 1 commit intocashubtc:mainfrom
b-l-u-e:feat/lightning-cln-rpc
Open

[WIP] feat(lightning): add CLN RPC#903
b-l-u-e wants to merge 1 commit intocashubtc:mainfrom
b-l-u-e:feat/lightning-cln-rpc

Conversation

@b-l-u-e
Copy link
Copy Markdown
Contributor

@b-l-u-e b-l-u-e commented Feb 24, 2026

  • CLNRPCWallet in cashu/lightning/cln_rpc.py (JSON-RPC over Unix socket)
  • CLNRPCFundingSource in settings; export in lightning init
  • Tests in tests/mint/test_mint_lightning_cln_rpc.py
  • .env.example: add CLNRPCWallet to supported list and MINT_CLN_RPC_* vars

This closes #519

- CLNRPCWallet in cashu/lightning/cln_rpc.py (JSON-RPC over Unix socket)
- CLNRPCFundingSource in settings; export in lightning __init__
- Tests in tests/mint/test_mint_lightning_cln_rpc.py
- .env.example: add CLNRPCWallet to supported list and MINT_CLN_RPC_* vars

Signed-off-by: b-l-u-e <winnie.gitau282@gmail.com>
@callebtc
Copy link
Copy Markdown
Collaborator

I love this PR

@b-l-u-e b-l-u-e marked this pull request as ready for review March 22, 2026 17:38
@a1denvalu3
Copy link
Copy Markdown
Collaborator

The most serious vulnerability in the feat/lightning-cln-rpc branch is a Zero Division Error leading to a Denial of Service (DoS) in the pay_invoice method of CLNRPCWallet.

When a user requests a MeltQuote with is_mpp=True and mpp_amount=0, the get_payment_quote method creates a quote with amount=0. When the user subsequently pays this quote, the pay_invoice method calculates fee_limit_percent by dividing by quote_amount_msat (which is 0):

quote_amount_msat = Amount(Unit[quote.unit], quote.amount).to(Unit.msat).amount
fee_limit_percent = fee_limit_msat / quote_amount_msat * 100  # ZeroDivisionError

This raises a ZeroDivisionError, crashing the payment process and returning an HTTP 500 error. An attacker can repeatedly trigger this to cause a DoS.

Exploit PoC:

  1. Create a valid Bolt11 invoice.
  2. Request a MeltQuote via POST /v1/melt/quote with is_mpp=True and mpp_amount=0.
  3. Pay the resulting quote via POST /v1/melt.
  4. The server crashes with a ZeroDivisionError in cln_rpc.py.

Additionally, there is a severe functional bug breaking all Multi-Part Payments (MPP):
In pay_invoice, the code uses params["partial_msat"] = quote_amount_msat. However, Core Lightning's pay RPC does not accept a partial_msat parameter (it expects amount_msat). This causes Core Lightning to reject any MPP payment with an "Unknown parameter" error, rendering the MPP functionality completely broken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

[Mint] Feature request: use LND and CLN RPC backends (instead of only REST)

3 participants