guard regeneration of lightning address
Omar committed
Aug 9, 2026 at 16:01 UTC
931b6fb9d21da949ff0bba9d8d36b6d3cdf142b9
4 files changed
+14
-1
cw_bitcoin/lib/electrum_wallet_addresses.dart
+4
@@ -442,6 +442,10 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
442
443
@action
444
BaseBitcoinAddressRecord generateNewAddress({String label = ''}) {
445
+ if (addressPageType is LightningAddressType) {
446
+ throw Exception("Lightning addresses cannot be rotated");
447
+ }
448
+
449
if (addressPageType == SilentPaymentsAddresType.p2sp && silentAddress != null) {
450
final currentSilentAddressIndex = silentAddresses
451
.where((addressRecord) => addressRecord.type != SegwitAddresType.p2tr)
lib/bitcoin/cw_bitcoin.dart
+6
@@ -317,6 +317,12 @@ class CWBitcoin extends Bitcoin {
317
return bitcoinWallet.walletAddresses.addressPageType == SilentPaymentsAddresType.p2sp;
318
}
319
320
+ @override
321
+ bool hasSelectedLightning(Object wallet) {
322
+ final bitcoinWallet = wallet as ElectrumWallet;
323
+ return bitcoinWallet.walletAddresses.addressPageType is LightningAddressType;
324
+ }
325
+
326
@override
327
BitcoinAddressType getBitcoinAddressType(ReceivePageOption option) {
328
switch (option) {
lib/view_model/wallet_address_list/wallet_address_list_view_model.dart
+2
-1
@@ -614,7 +614,8 @@ abstract class WalletAddressListViewModelBase extends WalletChangeListenerViewMo
614
615
@computed
616
bool get isLightning =>
617
- wallet.type == WalletType.bitcoin && selectedCurrency == CryptoCurrency.btcln;
617
+ wallet.type == WalletType.bitcoin &&
618
+ (selectedCurrency == CryptoCurrency.btcln || bitcoin!.hasSelectedLightning(wallet));
619
620
@computed
621
bool get isZCashTransparent {
tool/configure.dart
+2
@@ -149,6 +149,7 @@ import 'package:cw_bitcoin/bitcoin_amount_format.dart';
149
import 'package:cw_bitcoin/bitcoin_address_record.dart';
150
import 'package:cw_bitcoin/bitcoin_wallet_addresses.dart';
151
import 'package:cw_bitcoin/bitcoin_transaction_credentials.dart';
152
+import 'package:cw_bitcoin/lightning/lightning_addres_type.dart';
153
import 'package:cw_bitcoin/lightning/pending_lightning_transaction.dart';
154
import 'package:cw_bitcoin/litecoin_wallet_service.dart';
155
import 'package:cw_bitcoin/litecoin_wallet.dart';
@@ -245,6 +246,7 @@ abstract class Bitcoin {
246
ReceivePageOption getLitecoinMwebReceivePageOption();
247
bool isPayjoinAvailable(Object wallet);
248
bool hasSelectedSilentPayments(Object wallet);
249
+ bool hasSelectedLightning(Object wallet);
250
bool isBitcoinReceivePageOption(ReceivePageOption option);
251
BitcoinAddressType getOptionToType(ReceivePageOption option);
252
bool hasTaprootInput(PendingTransaction pendingTransaction);