Skip to content

feat(lightning): add USD (Stablesats) support for Blink backend#869

Open
Forte11Cuba wants to merge 7 commits intocashubtc:mainfrom
Forte11Cuba:feat/blink-usd-stablesats-support
Open

feat(lightning): add USD (Stablesats) support for Blink backend#869
Forte11Cuba wants to merge 7 commits intocashubtc:mainfrom
Forte11Cuba:feat/blink-usd-stablesats-support

Conversation

@Forte11Cuba
Copy link

  • Add Unit.usd to supported_units in BlinkWallet
  • Implement USD invoice creation via lnUsdInvoiceCreateOnBehalfOfRecipient
  • Implement USD fee probe via lnUsdInvoiceFeeProbe
  • Add sats to cents conversion using currencyConversionEstimation API
  • Update pay_invoice and get_payment_status to use correct wallet
  • Add comprehensive tests for USD operations

  - Add Unit.usd to supported_units in BlinkWallet
  - Implement USD invoice creation via lnUsdInvoiceCreateOnBehalfOfRecipient
  - Implement USD fee probe via lnUsdInvoiceFeeProbe
  - Add sats to cents conversion using currencyConversionEstimation API
  - Update pay_invoice and get_payment_status to use correct wallet
  - Add comprehensive tests for USD operations
  - Change unit verification order to check BTC (sat/msat) before USD
  - Use explicit if/elif/else pattern instead of if/else
  - Add exception handling for unsupported units
  - Follow Strike backend pattern for consistency
  - Improves performance by checking most common case first
@codecov
Copy link

codecov bot commented Jan 19, 2026

Codecov Report

❌ Patch coverage is 81.25000% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.46%. Comparing base (516cee2) to head (29b4dc7).
⚠️ Report is 18 commits behind head on main.

Files with missing lines Patch % Lines
cashu/lightning/blink.py 81.25% 18 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #869       +/-   ##
===========================================
- Coverage   64.71%   49.46%   -15.25%     
===========================================
  Files          91       89        -2     
  Lines       10900    10619      -281     
===========================================
- Hits         7054     5253     -1801     
- Misses       3846     5366     +1520     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

  backend

  - Remove invalid type: ignore comments (cents/sats) in blink.py lines 113, 117
  - Add type: ignore to _get_sats_per_usd post call (line 492)
  - Fix PRICE_RESPONSE mock to use currencyConversionEstimation instead of
  realtimePrice
@a1denvalu3
Copy link
Collaborator

Can we use the settlementFee instead of doing dangerous conversions? settlementFee is returned in usd for the usd wallet.

self.wallet_ids[Unit.sat] = wallet_dict["id"] # type: ignore
balance = wallet_dict["balance"] # type: ignore
if self.unit == Unit.sat or self.unit == Unit.msat:
balance = wallet_dict["balance"] # type: ignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does the same thing as line 113, why don't we just merge the conditions or do we intend to handle USD balances differently in the future?

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

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

5 participants