mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 03:59:23 +00:00
[skipci] save
This commit is contained in:
parent
626a5395aa
commit
f8c190b5e5
20 changed files with 372 additions and 58 deletions
|
@ -53,7 +53,11 @@ abstract class LightningWalletBase extends ElectrumWallet with Store {
|
|||
networkType: networkType);
|
||||
|
||||
// initialize breeze:
|
||||
setupBreeze(seedBytes);
|
||||
try {
|
||||
setupBreez(seedBytes);
|
||||
} catch (e) {
|
||||
print("Error initializing Breez: $e");
|
||||
}
|
||||
|
||||
autorun((_) {
|
||||
this.walletAddresses.isEnabledAutoGenerateSubaddress = this.isEnabledAutoGenerateSubaddress;
|
||||
|
@ -100,30 +104,30 @@ abstract class LightningWalletBase extends ElectrumWallet with Store {
|
|||
initialChangeAddressIndex: snp.changeAddressIndex);
|
||||
}
|
||||
|
||||
Future<void> setupBreeze(Uint8List seedBytes) async {
|
||||
// // Initialize SDK logs listener
|
||||
// final sdk = BreezSDK();
|
||||
// sdk.initialize();
|
||||
Future<void> setupBreez(Uint8List seedBytes) async {
|
||||
// Initialize SDK logs listener
|
||||
final sdk = BreezSDK();
|
||||
sdk.initialize();
|
||||
|
||||
// NodeConfig breezNodeConfig = NodeConfig.greenlight(
|
||||
// config: GreenlightNodeConfig(
|
||||
// partnerCredentials: null,
|
||||
// inviteCode: secrets.breezInviteCode,
|
||||
// ),
|
||||
// );
|
||||
// Config breezConfig = await sdk.defaultConfig(
|
||||
// envType: EnvironmentType.Production,
|
||||
// apiKey: secrets.breezApiKey,
|
||||
// nodeConfig: breezNodeConfig,
|
||||
// );
|
||||
|
||||
// // Customize the config object according to your needs
|
||||
// String workingDir = (await getApplicationDocumentsDirectory()).path;
|
||||
// workingDir = "$workingDir/wallets/lightning/${walletInfo.name}/breez/";
|
||||
// new Directory(workingDir).createSync(recursive: true);
|
||||
// breezConfig = breezConfig.copyWith(workingDir: workingDir);
|
||||
// await sdk.connect(config: breezConfig, seed: seedBytes);
|
||||
NodeConfig breezNodeConfig = NodeConfig.greenlight(
|
||||
config: GreenlightNodeConfig(
|
||||
partnerCredentials: null,
|
||||
inviteCode: secrets.breezInviteCode,
|
||||
),
|
||||
);
|
||||
Config breezConfig = await sdk.defaultConfig(
|
||||
envType: EnvironmentType.Production,
|
||||
apiKey: secrets.breezApiKey,
|
||||
nodeConfig: breezNodeConfig,
|
||||
);
|
||||
|
||||
// print("initialized: ${(await sdk.isInitialized())}");
|
||||
// Customize the config object according to your needs
|
||||
String workingDir = (await getApplicationDocumentsDirectory()).path;
|
||||
workingDir = "$workingDir/wallets/lightning/${walletInfo.name}/breez/";
|
||||
new Directory(workingDir).createSync(recursive: true);
|
||||
breezConfig = breezConfig.copyWith(workingDir: workingDir);
|
||||
await sdk.connect(config: breezConfig, seed: seedBytes);
|
||||
|
||||
print("initialized: ${(await sdk.isInitialized())}");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,10 +12,8 @@ import 'package:cw_lightning/lightning_wallet.dart';
|
|||
import 'package:hive/hive.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
class LightningWalletService extends WalletService<
|
||||
BitcoinNewWalletCredentials,
|
||||
BitcoinRestoreWalletFromSeedCredentials,
|
||||
BitcoinRestoreWalletFromWIFCredentials> {
|
||||
class LightningWalletService extends WalletService<BitcoinNewWalletCredentials,
|
||||
BitcoinRestoreWalletFromSeedCredentials, BitcoinRestoreWalletFromWIFCredentials> {
|
||||
LightningWalletService(this.walletInfoSource, this.unspentCoinsInfoSource);
|
||||
|
||||
final Box<WalletInfo> walletInfoSource;
|
||||
|
@ -42,29 +40,41 @@ class LightningWalletService extends WalletService<
|
|||
|
||||
@override
|
||||
Future<LightningWallet> openWallet(String name, String password) async {
|
||||
final walletInfo = walletInfoSource.values.firstWhereOrNull(
|
||||
(info) => info.id == WalletBase.idFor(name, getType()))!;
|
||||
|
||||
final wallet = await LightningWalletBase.open(
|
||||
password: password, name: name, walletInfo: walletInfo,
|
||||
unspentCoinsInfo: unspentCoinsInfoSource);
|
||||
await wallet.init();
|
||||
return wallet;
|
||||
final walletInfo = walletInfoSource.values
|
||||
.firstWhereOrNull((info) => info.id == WalletBase.idFor(name, getType()))!;
|
||||
try {
|
||||
final wallet = await LightningWalletBase.open(
|
||||
password: password,
|
||||
name: name,
|
||||
walletInfo: walletInfo,
|
||||
unspentCoinsInfo: unspentCoinsInfoSource);
|
||||
await wallet.init();
|
||||
saveBackup(name);
|
||||
return wallet;
|
||||
} catch (_) {
|
||||
await restoreWalletFilesFromBackup(name);
|
||||
final wallet = await LightningWalletBase.open(
|
||||
password: password,
|
||||
name: name,
|
||||
walletInfo: walletInfo,
|
||||
unspentCoinsInfo: unspentCoinsInfoSource);
|
||||
await wallet.init();
|
||||
return wallet;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> remove(String wallet) async {
|
||||
File(await pathForWalletDir(name: wallet, type: getType()))
|
||||
.delete(recursive: true);
|
||||
final walletInfo = walletInfoSource.values.firstWhereOrNull(
|
||||
(info) => info.id == WalletBase.idFor(wallet, getType()))!;
|
||||
File(await pathForWalletDir(name: wallet, type: getType())).delete(recursive: true);
|
||||
final walletInfo = walletInfoSource.values
|
||||
.firstWhereOrNull((info) => info.id == WalletBase.idFor(wallet, getType()))!;
|
||||
await walletInfoSource.delete(walletInfo.key);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> rename(String currentName, String password, String newName) async {
|
||||
final currentWalletInfo = walletInfoSource.values.firstWhereOrNull(
|
||||
(info) => info.id == WalletBase.idFor(currentName, getType()))!;
|
||||
final currentWalletInfo = walletInfoSource.values
|
||||
.firstWhereOrNull((info) => info.id == WalletBase.idFor(currentName, getType()))!;
|
||||
final currentWallet = await LightningWalletBase.open(
|
||||
password: password,
|
||||
name: currentName,
|
||||
|
@ -72,6 +82,7 @@ class LightningWalletService extends WalletService<
|
|||
unspentCoinsInfo: unspentCoinsInfoSource);
|
||||
|
||||
await currentWallet.renameWalletFiles(newName);
|
||||
await saveBackup(newName);
|
||||
|
||||
final newWalletInfo = currentWalletInfo;
|
||||
newWalletInfo.id = WalletBase.idFor(newName, getType());
|
||||
|
@ -81,13 +92,11 @@ class LightningWalletService extends WalletService<
|
|||
}
|
||||
|
||||
@override
|
||||
Future<LightningWallet> restoreFromKeys(
|
||||
BitcoinRestoreWalletFromWIFCredentials credentials) async =>
|
||||
Future<LightningWallet> restoreFromKeys(BitcoinRestoreWalletFromWIFCredentials credentials) async =>
|
||||
throw UnimplementedError();
|
||||
|
||||
@override
|
||||
Future<LightningWallet> restoreFromSeed(
|
||||
BitcoinRestoreWalletFromSeedCredentials credentials) async {
|
||||
Future<LightningWallet> restoreFromSeed(BitcoinRestoreWalletFromSeedCredentials credentials) async {
|
||||
if (!validateMnemonic(credentials.mnemonic)) {
|
||||
throw BitcoinMnemonicIsIncorrectException();
|
||||
}
|
||||
|
@ -101,4 +110,4 @@ class LightningWalletService extends WalletService<
|
|||
await wallet.init();
|
||||
return wallet;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ class SeedValidator extends Validator<MnemonicItem> {
|
|||
static List<String> getWordList({required WalletType type, required String language}) {
|
||||
switch (type) {
|
||||
case WalletType.bitcoin:
|
||||
return getBitcoinWordList(language);
|
||||
case WalletType.lightning:
|
||||
case WalletType.litecoin:
|
||||
return getBitcoinWordList(language);
|
||||
case WalletType.monero:
|
||||
|
|
|
@ -3,6 +3,7 @@ import 'package:cake_wallet/routes.dart';
|
|||
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
|
||||
import 'package:cake_wallet/utils/show_pop_up.dart';
|
||||
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MainActions {
|
||||
|
@ -11,8 +12,7 @@ class MainActions {
|
|||
|
||||
final bool Function(DashboardViewModel viewModel)? isEnabled;
|
||||
final bool Function(DashboardViewModel viewModel)? canShow;
|
||||
final Future<void> Function(
|
||||
BuildContext context, DashboardViewModel viewModel) onTap;
|
||||
final Future<void> Function(BuildContext context, DashboardViewModel viewModel) onTap;
|
||||
|
||||
MainActions._({
|
||||
required this.name,
|
||||
|
@ -55,6 +55,10 @@ class MainActions {
|
|||
name: (context) => S.of(context).receive,
|
||||
image: 'assets/images/received.png',
|
||||
onTap: (BuildContext context, DashboardViewModel viewModel) async {
|
||||
if (viewModel.wallet.type == WalletType.lightning) {
|
||||
Navigator.pushNamed(context, Routes.lightningReceive);
|
||||
return;
|
||||
}
|
||||
Navigator.pushNamed(context, Routes.addressPage);
|
||||
},
|
||||
);
|
||||
|
@ -75,6 +79,10 @@ class MainActions {
|
|||
name: (context) => S.of(context).send,
|
||||
image: 'assets/images/upload.png',
|
||||
onTap: (BuildContext context, DashboardViewModel viewModel) async {
|
||||
if (viewModel.wallet.type == WalletType.lightning) {
|
||||
Navigator.pushNamed(context, Routes.lightningSend);
|
||||
return;
|
||||
}
|
||||
Navigator.pushNamed(context, Routes.send);
|
||||
},
|
||||
);
|
||||
|
@ -114,4 +122,4 @@ class MainActions {
|
|||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,8 +68,11 @@ void startCurrentWalletChangeReaction(
|
|||
.get<SharedPreferences>()
|
||||
.setInt(PreferencesKey.currentWalletType, serializeToInt(wallet.type));
|
||||
|
||||
if (wallet.type == WalletType.monero || wallet.type == WalletType.bitcoin ||
|
||||
wallet.type == WalletType.litecoin || wallet.type == WalletType.bitcoinCash ) {
|
||||
if (wallet.type == WalletType.monero ||
|
||||
wallet.type == WalletType.bitcoin ||
|
||||
wallet.type == WalletType.litecoin ||
|
||||
wallet.type == WalletType.bitcoinCash ||
|
||||
wallet.type == WalletType.lightning) {
|
||||
_setAutoGenerateSubaddressStatus(wallet, settingsStore);
|
||||
}
|
||||
|
||||
|
|
|
@ -634,6 +634,18 @@ Route<dynamic> createRoute(RouteSettings settings) {
|
|||
case Routes.torPage:
|
||||
return MaterialPageRoute<void>(builder: (_) => getIt.get<TorPage>());
|
||||
|
||||
case Routes.lightningSend:
|
||||
return CupertinoPageRoute<void>(
|
||||
fullscreenDialog: true, builder: (_) => getIt.get<ExchangePage>());
|
||||
|
||||
case Routes.lightningReceive:
|
||||
return CupertinoPageRoute<void>(
|
||||
fullscreenDialog: true, builder: (_) => getIt.get<ExchangePage>());
|
||||
|
||||
case Routes.lightningSettings:
|
||||
return CupertinoPageRoute<void>(
|
||||
fullscreenDialog: true, builder: (_) => getIt.get<ExchangePage>());
|
||||
|
||||
default:
|
||||
return MaterialPageRoute<void>(
|
||||
builder: (_) => Scaffold(
|
||||
|
|
|
@ -106,4 +106,7 @@ class Routes {
|
|||
static const nftDetailsPage = '/nft_details_page';
|
||||
static const importNFTPage = '/import_nft_page';
|
||||
static const torPage = '/tor_page';
|
||||
static const lightningSend = '/lightning_send';
|
||||
static const lightningReceive = '/lightning_receive';
|
||||
static const lightningSettings = '/lightning_settings';
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ class MenuWidgetState extends State<MenuWidget> {
|
|||
this.fromBottomEdge = 25,
|
||||
this.moneroIcon = Image.asset('assets/images/monero_menu.png'),
|
||||
this.bitcoinIcon = Image.asset('assets/images/bitcoin_menu.png'),
|
||||
this.lightningIcon = Image.asset('assets/images/bitcoin_menu.png'),
|
||||
this.litecoinIcon = Image.asset('assets/images/litecoin_menu.png'),
|
||||
this.havenIcon = Image.asset('assets/images/haven_menu.png'),
|
||||
this.ethereumIcon = Image.asset('assets/images/eth_icon.png'),
|
||||
|
@ -49,6 +50,7 @@ class MenuWidgetState extends State<MenuWidget> {
|
|||
|
||||
Image moneroIcon;
|
||||
Image bitcoinIcon;
|
||||
Image lightningIcon;
|
||||
Image litecoinIcon;
|
||||
Image havenIcon;
|
||||
Image ethereumIcon;
|
||||
|
@ -98,6 +100,8 @@ class MenuWidgetState extends State<MenuWidget> {
|
|||
color: Theme.of(context).extension<CakeMenuTheme>()!.iconColor);
|
||||
bitcoinIcon = Image.asset('assets/images/bitcoin_menu.png',
|
||||
color: Theme.of(context).extension<CakeMenuTheme>()!.iconColor);
|
||||
lightningIcon = Image.asset('assets/images/bitcoin_menu.png',
|
||||
color: Theme.of(context).extension<CakeMenuTheme>()!.iconColor);
|
||||
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
|
@ -210,6 +214,8 @@ class MenuWidgetState extends State<MenuWidget> {
|
|||
return moneroIcon;
|
||||
case WalletType.bitcoin:
|
||||
return bitcoinIcon;
|
||||
case WalletType.lightning:
|
||||
return lightningIcon;
|
||||
case WalletType.litecoin:
|
||||
return litecoinIcon;
|
||||
case WalletType.haven:
|
||||
|
|
244
lib/src/screens/receive/lightning_receive_page.dart
Normal file
244
lib/src/screens/receive/lightning_receive_page.dart
Normal file
|
@ -0,0 +1,244 @@
|
|||
import 'package:cake_wallet/src/screens/nano_accounts/nano_account_list_page.dart';
|
||||
import 'package:cake_wallet/src/widgets/keyboard_done_button.dart';
|
||||
import 'package:cake_wallet/themes/extensions/balance_page_theme.dart';
|
||||
import 'package:cake_wallet/themes/extensions/keyboard_theme.dart';
|
||||
import 'package:cake_wallet/themes/extensions/receive_page_theme.dart';
|
||||
import 'package:cake_wallet/src/widgets/gradient_background.dart';
|
||||
import 'package:cake_wallet/src/widgets/section_divider.dart';
|
||||
import 'package:cake_wallet/themes/theme_base.dart';
|
||||
import 'package:cake_wallet/utils/share_util.dart';
|
||||
import 'package:cake_wallet/utils/show_pop_up.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/di.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/src/screens/monero_accounts/monero_account_list_page.dart';
|
||||
import 'package:cake_wallet/src/screens/receive/widgets/header_tile.dart';
|
||||
import 'package:cake_wallet/src/screens/receive/widgets/address_cell.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_address_list/wallet_account_list_header.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_header.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_item.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_view_model.dart';
|
||||
import 'package:cake_wallet/src/screens/receive/widgets/qr_widget.dart';
|
||||
import 'package:keyboard_actions/keyboard_actions.dart';
|
||||
|
||||
class LightningReceivePage extends BasePage {
|
||||
LightningReceivePage({required this.addressListViewModel})
|
||||
: _cryptoAmountFocus = FocusNode(),
|
||||
_amountController = TextEditingController(),
|
||||
_formKey = GlobalKey<FormState>() {
|
||||
_amountController.addListener(() {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
addressListViewModel.changeAmount(_amountController.text);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
final WalletAddressListViewModel addressListViewModel;
|
||||
final TextEditingController _amountController;
|
||||
final GlobalKey<FormState> _formKey;
|
||||
static const _heroTag = 'receive_page';
|
||||
|
||||
@override
|
||||
String get title => S.current.receive;
|
||||
|
||||
@override
|
||||
bool get gradientBackground => true;
|
||||
|
||||
@override
|
||||
bool get resizeToAvoidBottomInset => true;
|
||||
|
||||
final FocusNode _cryptoAmountFocus;
|
||||
|
||||
@override
|
||||
Widget middle(BuildContext context) {
|
||||
return Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 18.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontFamily: 'Lato',
|
||||
color: pageIconColor(context)),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget Function(BuildContext, Widget) get rootWrapper =>
|
||||
(BuildContext context, Widget scaffold) =>
|
||||
GradientBackground(scaffold: scaffold);
|
||||
|
||||
@override
|
||||
Widget trailing(BuildContext context) {
|
||||
return Material(
|
||||
color: Colors.transparent,
|
||||
child: Semantics(
|
||||
label: S.of(context).share,
|
||||
child: IconButton(
|
||||
padding: EdgeInsets.zero,
|
||||
constraints: BoxConstraints(),
|
||||
highlightColor: Colors.transparent,
|
||||
splashColor: Colors.transparent,
|
||||
iconSize: 25,
|
||||
onPressed: () {
|
||||
ShareUtil.share(
|
||||
text: addressListViewModel.uri.toString(),
|
||||
context: context,
|
||||
);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.share,
|
||||
size: 20,
|
||||
color: pageIconColor(context),
|
||||
),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) {
|
||||
final isElectrumWallet = addressListViewModel.isElectrumWallet;
|
||||
return (addressListViewModel.type == WalletType.monero ||
|
||||
addressListViewModel.type == WalletType.haven ||
|
||||
addressListViewModel.type == WalletType.nano ||
|
||||
isElectrumWallet)
|
||||
? KeyboardActions(
|
||||
config: KeyboardActionsConfig(
|
||||
keyboardActionsPlatform: KeyboardActionsPlatform.IOS,
|
||||
keyboardBarColor: Theme.of(context).extension<KeyboardTheme>()!.keyboardBarColor,
|
||||
nextFocus: false,
|
||||
actions: [
|
||||
KeyboardActionsItem(
|
||||
focusNode: _cryptoAmountFocus,
|
||||
toolbarButtons: [(_) => KeyboardDoneButton()],
|
||||
)
|
||||
]),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(24, 50, 24, 24),
|
||||
child: QRWidget(
|
||||
addressListViewModel: addressListViewModel,
|
||||
formKey: _formKey,
|
||||
heroTag: _heroTag,
|
||||
amountTextFieldFocusNode: _cryptoAmountFocus,
|
||||
amountController: _amountController,
|
||||
isLight: currentTheme.type == ThemeType.light),
|
||||
),
|
||||
Observer(
|
||||
builder: (_) => ListView.separated(
|
||||
padding: EdgeInsets.all(0),
|
||||
separatorBuilder: (context, _) => const HorizontalSectionDivider(),
|
||||
shrinkWrap: true,
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
itemCount: addressListViewModel.items.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = addressListViewModel.items[index];
|
||||
Widget cell = Container();
|
||||
|
||||
if (item is WalletAccountListHeader) {
|
||||
cell = HeaderTile(
|
||||
showTrailingButton: true,
|
||||
walletAddressListViewModel: addressListViewModel,
|
||||
trailingButtonTap: () async {
|
||||
if (addressListViewModel.type == WalletType.monero ||
|
||||
addressListViewModel.type == WalletType.haven) {
|
||||
await showPopUp<void>(
|
||||
context: context,
|
||||
builder: (_) => getIt.get<MoneroAccountListPage>());
|
||||
} else {
|
||||
await showPopUp<void>(
|
||||
context: context,
|
||||
builder: (_) => getIt.get<NanoAccountListPage>());
|
||||
}
|
||||
},
|
||||
title: S.of(context).accounts,
|
||||
trailingIcon: Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
size: 14,
|
||||
color: Theme.of(context).extension<ReceivePageTheme>()!.iconsColor,
|
||||
));
|
||||
}
|
||||
|
||||
if (item is WalletAddressListHeader) {
|
||||
cell = HeaderTile(
|
||||
title: S.of(context).addresses,
|
||||
walletAddressListViewModel: addressListViewModel,
|
||||
showTrailingButton: !addressListViewModel.isAutoGenerateSubaddressEnabled,
|
||||
showSearchButton: true,
|
||||
trailingButtonTap: () =>
|
||||
Navigator.of(context).pushNamed(Routes.newSubaddress),
|
||||
trailingIcon: Icon(
|
||||
Icons.add,
|
||||
size: 20,
|
||||
color: Theme.of(context)
|
||||
.extension<ReceivePageTheme>()!
|
||||
.iconsColor,
|
||||
));
|
||||
}
|
||||
|
||||
if (item is WalletAddressListItem) {
|
||||
cell = Observer(builder: (_) {
|
||||
final isCurrent =
|
||||
item.address == addressListViewModel.address.address;
|
||||
final backgroundColor = isCurrent
|
||||
? Theme.of(context).extension<ReceivePageTheme>()!.currentTileBackgroundColor
|
||||
: Theme.of(context).extension<ReceivePageTheme>()!.tilesBackgroundColor;
|
||||
final textColor = isCurrent
|
||||
? Theme.of(context).extension<ReceivePageTheme>()!.currentTileTextColor
|
||||
: Theme.of(context).extension<ReceivePageTheme>()!.tilesTextColor;
|
||||
|
||||
return AddressCell.fromItem(item,
|
||||
isCurrent: isCurrent,
|
||||
hasBalance: addressListViewModel.isElectrumWallet,
|
||||
backgroundColor: backgroundColor,
|
||||
textColor: textColor,
|
||||
onTap: (_) => addressListViewModel.setAddress(item),
|
||||
onEdit: () => Navigator.of(context)
|
||||
.pushNamed(Routes.newSubaddress, arguments: item));
|
||||
});
|
||||
}
|
||||
|
||||
return index != 0
|
||||
? cell
|
||||
: ClipRRect(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(30),
|
||||
topRight: Radius.circular(30)),
|
||||
child: cell,
|
||||
);
|
||||
})),
|
||||
],
|
||||
),
|
||||
))
|
||||
: Padding(
|
||||
padding: EdgeInsets.fromLTRB(24, 24, 24, 32),
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 7,
|
||||
child: QRWidget(
|
||||
formKey: _formKey,
|
||||
heroTag: _heroTag,
|
||||
addressListViewModel: addressListViewModel,
|
||||
amountTextFieldFocusNode: _cryptoAmountFocus,
|
||||
amountController: _amountController,
|
||||
isLight: currentTheme.type == ThemeType.light),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: SizedBox(),
|
||||
),
|
||||
Text(S.of(context).electrum_address_disclaimer,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Theme.of(context).extension<BalancePageTheme>()!.labelTextColor)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -96,6 +96,7 @@ class WalletListBody extends StatefulWidget {
|
|||
class WalletListBodyState extends State<WalletListBody> {
|
||||
final moneroIcon = Image.asset('assets/images/monero_logo.png', height: 24, width: 24);
|
||||
final bitcoinIcon = Image.asset('assets/images/bitcoin.png', height: 24, width: 24);
|
||||
final lightningIcon = Image.asset('assets/images/bitcoin.png', height: 24, width: 24);
|
||||
final litecoinIcon = Image.asset('assets/images/litecoin_icon.png', height: 24, width: 24);
|
||||
final nonWalletTypeIcon = Image.asset('assets/images/close.png', height: 24, width: 24);
|
||||
final havenIcon = Image.asset('assets/images/haven_logo.png', height: 24, width: 24);
|
||||
|
@ -299,6 +300,8 @@ class WalletListBodyState extends State<WalletListBody> {
|
|||
switch (type) {
|
||||
case WalletType.bitcoin:
|
||||
return bitcoinIcon;
|
||||
case WalletType.lightning:
|
||||
return lightningIcon;
|
||||
case WalletType.monero:
|
||||
return moneroIcon;
|
||||
case WalletType.litecoin:
|
||||
|
|
|
@ -72,6 +72,7 @@ class TransactionListItem extends ActionListItem with Keyable {
|
|||
price: price);
|
||||
break;
|
||||
case WalletType.bitcoin:
|
||||
case WalletType.lightning:
|
||||
case WalletType.litecoin:
|
||||
case WalletType.bitcoinCash:
|
||||
amount = calculateFiatAmountRaw(
|
||||
|
|
|
@ -264,6 +264,7 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
|
|||
|
||||
bool get hasAllAmount =>
|
||||
(wallet.type == WalletType.bitcoin ||
|
||||
wallet.type == WalletType.lightning ||
|
||||
wallet.type == WalletType.litecoin ||
|
||||
wallet.type == WalletType.bitcoinCash) &&
|
||||
depositCurrency == wallet.currency;
|
||||
|
|
|
@ -66,6 +66,7 @@ abstract class WalletRestorationFromQRVMBase extends WalletCreationVM with Store
|
|||
spendKey: restoreWallet.spendKey ?? '',
|
||||
height: restoreWallet.height ?? 0);
|
||||
case WalletType.bitcoin:
|
||||
case WalletType.lightning:
|
||||
case WalletType.litecoin:
|
||||
return bitcoin!.createBitcoinRestoreWalletFromWIFCredentials(
|
||||
name: name, password: password, wif: wif);
|
||||
|
|
|
@ -22,6 +22,9 @@ class WalletRestoreFromQRCode {
|
|||
'bitcoin': WalletType.bitcoin,
|
||||
'bitcoin-wallet': WalletType.bitcoin,
|
||||
'bitcoin_wallet': WalletType.bitcoin,
|
||||
'lightning': WalletType.lightning,
|
||||
'lightning-wallet': WalletType.lightning,
|
||||
'lightning_wallet': WalletType.lightning,
|
||||
'litecoin': WalletType.litecoin,
|
||||
'litecoin-wallet': WalletType.litecoin,
|
||||
'litecoin_wallet': WalletType.litecoin,
|
||||
|
|
|
@ -141,6 +141,7 @@ abstract class TransactionDetailsViewModelBase with Store {
|
|||
case WalletType.monero:
|
||||
return S.current.view_transaction_on + 'Monero.com';
|
||||
case WalletType.bitcoin:
|
||||
case WalletType.lightning:
|
||||
return S.current.view_transaction_on + 'mempool.space';
|
||||
case WalletType.litecoin:
|
||||
case WalletType.bitcoinCash:
|
||||
|
|
|
@ -58,7 +58,7 @@ abstract class UnspentCoinsListViewModelBase with Store {
|
|||
String formatAmountToString(int fullBalance) {
|
||||
if (wallet.type == WalletType.monero)
|
||||
return monero!.formatterMoneroAmountToString(amount: fullBalance);
|
||||
if ([WalletType.bitcoin, WalletType.litecoin, WalletType.bitcoinCash].contains(wallet.type))
|
||||
if ([WalletType.bitcoin, WalletType.litecoin, WalletType.bitcoinCash, WalletType.lightning].contains(wallet.type))
|
||||
return bitcoin!.formatterBitcoinAmountToString(amount: fullBalance);
|
||||
return '';
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ abstract class UnspentCoinsListViewModelBase with Store {
|
|||
if (wallet.type == WalletType.monero) {
|
||||
await monero!.updateUnspents(wallet);
|
||||
}
|
||||
if ([WalletType.bitcoin, WalletType.litecoin, WalletType.bitcoinCash].contains(wallet.type)) {
|
||||
if ([WalletType.bitcoin, WalletType.litecoin, WalletType.bitcoinCash, WalletType.lightning].contains(wallet.type)) {
|
||||
await bitcoin!.updateUnspents(wallet);
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ abstract class UnspentCoinsListViewModelBase with Store {
|
|||
|
||||
List<Unspent> _getUnspents() {
|
||||
if (wallet.type == WalletType.monero) return monero!.getUnspents(wallet);
|
||||
if ([WalletType.bitcoin, WalletType.litecoin, WalletType.bitcoinCash].contains(wallet.type))
|
||||
if ([WalletType.bitcoin, WalletType.litecoin, WalletType.bitcoinCash, WalletType.lightning].contains(wallet.type))
|
||||
return bitcoin!.getUnspents(wallet);
|
||||
return List.empty();
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ class WalletKeysViewModel = WalletKeysViewModelBase with _$WalletKeysViewModel;
|
|||
abstract class WalletKeysViewModelBase with Store {
|
||||
WalletKeysViewModelBase(this._appStore)
|
||||
: title = _appStore.wallet!.type == WalletType.bitcoin ||
|
||||
_appStore.wallet!.type == WalletType.lightning ||
|
||||
_appStore.wallet!.type == WalletType.litecoin ||
|
||||
_appStore.wallet!.type == WalletType.bitcoinCash ||
|
||||
_appStore.wallet!.type == WalletType.ethereum ||
|
||||
|
@ -103,6 +104,7 @@ abstract class WalletKeysViewModelBase with Store {
|
|||
}
|
||||
|
||||
if (_appStore.wallet!.type == WalletType.bitcoin ||
|
||||
_appStore.wallet!.type == WalletType.lightning ||
|
||||
_appStore.wallet!.type == WalletType.litecoin ||
|
||||
_appStore.wallet!.type == WalletType.bitcoinCash) {
|
||||
items.addAll([
|
||||
|
|
|
@ -63,7 +63,8 @@ abstract class WalletNewVMBase extends WalletCreationVM with Store {
|
|||
case WalletType.bitcoin:
|
||||
return bitcoin!.createBitcoinNewWalletCredentials(name: name);
|
||||
case WalletType.lightning:
|
||||
return lightning!.createLightningNewWalletCredentials(name: name);
|
||||
// return lightning!.createLightningNewWalletCredentials(name: name);// TODO: CW-563 see if necessary
|
||||
return bitcoin!.createBitcoinNewWalletCredentials(name: name);
|
||||
case WalletType.litecoin:
|
||||
return bitcoin!.createBitcoinNewWalletCredentials(name: name);
|
||||
case WalletType.haven:
|
||||
|
|
|
@ -90,6 +90,12 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
|
|||
mnemonic: seed,
|
||||
password: password,
|
||||
);
|
||||
case WalletType.lightning:
|
||||
return bitcoin!.createBitcoinRestoreWalletFromSeedCredentials(
|
||||
name: name,
|
||||
mnemonic: seed,
|
||||
password: password,
|
||||
);
|
||||
case WalletType.litecoin:
|
||||
return bitcoin!.createBitcoinRestoreWalletFromSeedCredentials(
|
||||
name: name, mnemonic: seed, password: password);
|
||||
|
|
|
@ -54,6 +54,7 @@ Future<void> main(List<String> args) async {
|
|||
hasBanano: hasBanano,
|
||||
hasBitcoinCash: hasBitcoinCash,
|
||||
hasPolygon: hasPolygon,
|
||||
hasLightning: hasLightning,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1058,7 +1059,8 @@ Future<void> generateWalletTypes(
|
|||
required bool hasNano,
|
||||
required bool hasBanano,
|
||||
required bool hasBitcoinCash,
|
||||
required bool hasPolygon}) async {
|
||||
required bool hasPolygon,
|
||||
required bool hasLightning}) async {
|
||||
final walletTypesFile = File(walletTypesPath);
|
||||
|
||||
if (walletTypesFile.existsSync()) {
|
||||
|
@ -1077,6 +1079,10 @@ Future<void> generateWalletTypes(
|
|||
outputContent += '\tWalletType.bitcoin,\n';
|
||||
}
|
||||
|
||||
if (hasLightning) {
|
||||
outputContent += '\tWalletType.lightning,\n';
|
||||
}
|
||||
|
||||
if (hasEthereum) {
|
||||
outputContent += '\tWalletType.ethereum,\n';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue