-
Notifications
You must be signed in to change notification settings - Fork 5
feat: Add currency conversion support for swaps #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
BenGWeeks
wants to merge
4
commits into
lnbits:main
Choose a base branch
from
BenGWeeks:add-currency-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BenGWeeks
commented
Dec 22, 2025
Implements fiat currency support for Submarine and Reverse Submarine swaps to allow users to specify swap amounts in their preferred currency (e.g., £50 GBP) instead of manually converting to satoshis. Key features: - Added currency dropdown to swap dialogs with real-time fiat-to-sats conversion - Stores both original currency amount and converted satoshi amount in database - Displays conversion hints like "50 GBP = 50,000 sats" - Auto swaps remain sats-only to avoid unpredictable behavior with exchange rates - Fetches available currencies and rates from LNbits core API - Swap history displays amounts as "50 GBP (50,000 sats)" Changes: - Added m006_add_currency_support migration for currency and amount_display columns - Updated models with currency and amount_display fields - Enhanced swap dialogs with currency selection and conversion hints - Added Vue.js methods for currency loading, rate fetching, and conversion - Updated table displays to show both fiat and satoshi amounts Closes lnbits#53 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
8415854 to
8300198
Compare
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use this.g.allowedCurrencies / this.g.currencies instead of API call. Respects admin currency settings per lnbits/nostrmarket#116. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
9684fbe to
ff7164e
Compare
BenGWeeks
commented
Dec 22, 2025
Comment on lines
+764
to
+775
| updateFiatRate(currency) { | ||
| if (currency && currency !== 'sats') { | ||
| LNbits.api | ||
| .request('GET', '/api/v1/rate/' + currency, null) | ||
| .then(response => { | ||
| this.fiatRates[currency] = response.data.rate | ||
| }) | ||
| .catch(err => { | ||
| console.error(`Failed to get rate for ${currency}:`, err) | ||
| }) | ||
| } | ||
| }, |
Contributor
Author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like we have this.g.allowedCurrencies, is there better way to reference exchange rates @dni ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds fiat currency conversion support for swaps. Users can specify amounts in their preferred currency (e.g., £50 GBP) instead of manually calculating satoshi equivalents.
Use Case: Send specific fiat amounts from Lightning to onchain without manual sats calculation.
Key Features
Changes Made
Database (migrations.py)
m006_add_currency_supportmigrationcurrency(TEXT) column to both swap tables (default: 'sats')amount_display(REAL) column to store original fiat amount enteredModels (models.py)
SubmarineSwap,CreateSubmarineSwap,ReverseSubmarineSwap,CreateReverseSubmarineSwapcurrencyandamount_displayfields to all swap modelsUI Templates
_submarineSwapDialog.html: Added currency dropdown and conversion hints_reverseSubmarineSwapDialog.html: Added currency dropdown and conversion hintsVue.js Component (index.html)
loadCurrencies()using LNbits Core globalsupdateFiatRate(),getAmountHint(),convertFiatToSats()methodsTest Plan
Fixes #53
🤖 Definitely not generated with Claude Code