fix: enter Lightning invoice amounts in sats (#3525)
What changed, and why it matters
This commit fixes a user-interface bug when receiving Bitcoin over the Lightning Network in Cake Wallet. Previously, the app showed the invoice amount in whole Bitcoin (BTC) instead of satoshis (sats), because an internal currency code was being remapped incorrectly. The patch makes the receive screen explicitly set the currency to the Lightning-specific code so the amount field displays in sats as intended. There is no indication this allowed theft, unauthorized access, or code execution; it is a usability/display fix.
Treat as a routine bug-fix release; no security-specific action required. Users who create Lightning invoices may verify amounts are now shown in sats before sharing invoices.
Security signals we found
No memory-safety, cryptographic, or authorization changes observed
No input validation, parsing, or serialization changes observed
No network, wallet-seed, or key-handling changes observed
Fixes a UI display/currency denomination bug
No vendor security disclosure or advisory language present
Evidence from the diff
In the Lightning receive flow, the UI was remapping CryptoCurrency.btcln to CryptoCurrency.btc before selecting the display currency. Because setTokenCurrency treated btcln the same as wallet.currency (BTC), tokenCurrency was cleared and selectedCurrency became BTC, so the default ‘sats (LN)’ display mode never applied. The fix calls setTokenCurrency(CryptoCurrency.btcln) directly from the receive page, and updates setTokenCurrency to handle btcln as a distinct case that sets selectedCurrency to btcln. This restores satoshi-denominated amount entry for Lightning invoices.
Changed components
lib/new-ui/pages/receive_page.dartlib/view_model/wallet_address_list/wallet_address_list_view_model.dartInspect captured patch +7 / −1
### lib/new-ui/pages/receive_page.dart
@@ -72,6 +72,7 @@ class _NewReceivePageState extends State<NewReceivePage> {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (widget.lightningMode) {
+ widget.addressListViewModel.setTokenCurrency(CryptoCurrency.btcln);
widget.receiveOptionViewModel.selectReceiveOption(
widget.receiveOptionViewModel.options
.firstWhereOrNull((item) => item.value.contains("Lightning")) ??
### lib/view_model/wallet_address_list/wallet_address_list_view_model.dart
@@ -86,7 +86,12 @@ abstract class WalletAddressListViewModelBase extends WalletChangeListenerViewMo
);
void setTokenCurrency(Currency curr) {
- if (curr == wallet.currency || curr == CryptoCurrency.btcln) {
+ if (curr == CryptoCurrency.btcln) {
+ tokenCurrency = null;
+ selectedCurrency = CryptoCurrency.btcln;
+ return;
+ }
+ if (curr == wallet.currency) {
tokenCurrency = null;
selectedCurrency = wallet.currency;
return;Why this scored 19/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.