This commit is contained in:
fosse 2024-02-09 13:37:30 -05:00
parent 1a32c91217
commit 65686719ee
9 changed files with 41 additions and 21 deletions

View file

@ -5,6 +5,8 @@ CryptoCurrency currencyForWalletType(WalletType type) {
switch (type) { switch (type) {
case WalletType.bitcoin: case WalletType.bitcoin:
return CryptoCurrency.btc; return CryptoCurrency.btc;
case WalletType.lightning:
return CryptoCurrency.btc;
case WalletType.monero: case WalletType.monero:
return CryptoCurrency.xmr; return CryptoCurrency.xmr;
case WalletType.litecoin: case WalletType.litecoin:

View file

@ -101,29 +101,29 @@ abstract class LightningWalletBase extends ElectrumWallet with Store {
} }
Future<void> setupBreeze(Uint8List seedBytes) async { Future<void> setupBreeze(Uint8List seedBytes) async {
// Initialize SDK logs listener // // Initialize SDK logs listener
final sdk = BreezSDK(); // final sdk = BreezSDK();
sdk.initialize(); // sdk.initialize();
NodeConfig breezNodeConfig = NodeConfig.greenlight( // NodeConfig breezNodeConfig = NodeConfig.greenlight(
config: GreenlightNodeConfig( // config: GreenlightNodeConfig(
partnerCredentials: null, // partnerCredentials: null,
inviteCode: secrets.breezInviteCode, // inviteCode: secrets.breezInviteCode,
), // ),
); // );
Config breezConfig = await sdk.defaultConfig( // Config breezConfig = await sdk.defaultConfig(
envType: EnvironmentType.Production, // envType: EnvironmentType.Production,
apiKey: secrets.breezApiKey, // apiKey: secrets.breezApiKey,
nodeConfig: breezNodeConfig, // nodeConfig: breezNodeConfig,
); // );
// Customize the config object according to your needs // // Customize the config object according to your needs
String workingDir = (await getApplicationDocumentsDirectory()).path; // String workingDir = (await getApplicationDocumentsDirectory()).path;
workingDir = "$workingDir/wallets/bitcoin/${walletInfo.name}/breez/"; // workingDir = "$workingDir/wallets/lightning/${walletInfo.name}/breez/";
new Directory(workingDir).createSync(recursive: true); // new Directory(workingDir).createSync(recursive: true);
breezConfig = breezConfig.copyWith(workingDir: workingDir); // breezConfig = breezConfig.copyWith(workingDir: workingDir);
await sdk.connect(config: breezConfig, seed: seedBytes); // await sdk.connect(config: breezConfig, seed: seedBytes);
print("initialized: ${(await sdk.isInitialized())}"); // print("initialized: ${(await sdk.isInitialized())}");
} }
} }

View file

@ -873,6 +873,7 @@ abstract class SettingsStoreBase with Store {
if (bitcoinElectrumServer != null) { if (bitcoinElectrumServer != null) {
nodes[WalletType.bitcoin] = bitcoinElectrumServer; nodes[WalletType.bitcoin] = bitcoinElectrumServer;
nodes[WalletType.lightning] = bitcoinElectrumServer;
} }
if (litecoinElectrumServer != null) { if (litecoinElectrumServer != null) {
@ -1205,6 +1206,7 @@ abstract class SettingsStoreBase with Store {
if (bitcoinElectrumServer != null) { if (bitcoinElectrumServer != null) {
nodes[WalletType.bitcoin] = bitcoinElectrumServer; nodes[WalletType.bitcoin] = bitcoinElectrumServer;
nodes[WalletType.lightning] = bitcoinElectrumServer;
} }
if (litecoinElectrumServer != null) { if (litecoinElectrumServer != null) {

View file

@ -54,6 +54,9 @@ abstract class NodeListViewModelBase with Store {
case WalletType.bitcoin: case WalletType.bitcoin:
node = getBitcoinDefaultElectrumServer(nodes: _nodeSource)!; node = getBitcoinDefaultElectrumServer(nodes: _nodeSource)!;
break; break;
case WalletType.lightning:
node = getBitcoinDefaultElectrumServer(nodes: _nodeSource)!;
break;
case WalletType.monero: case WalletType.monero:
node = getMoneroDefaultNode(nodes: _nodeSource); node = getMoneroDefaultNode(nodes: _nodeSource);
break; break;

View file

@ -377,6 +377,8 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
case WalletType.polygon: case WalletType.polygon:
return polygon!.createPolygonTransactionCredentials(outputs, return polygon!.createPolygonTransactionCredentials(outputs,
priority: priority!, currency: selectedCryptoCurrency); priority: priority!, currency: selectedCryptoCurrency);
case WalletType.lightning:
throw Exception("TODO: CW-563 Implement lightning tx send!");
default: default:
throw Exception('Unexpected wallet type: ${wallet.type}'); throw Exception('Unexpected wallet type: ${wallet.type}');
} }

View file

@ -237,6 +237,11 @@ abstract class WalletAddressListViewModelBase extends WalletChangeListenerViewMo
return BitcoinURI(amount: amount, address: address.address); return BitcoinURI(amount: amount, address: address.address);
} }
if (wallet.type == WalletType.lightning) {
// TODO: CW-563
return BitcoinURI(amount: amount, address: address.address);
}
if (wallet.type == WalletType.litecoin) { if (wallet.type == WalletType.litecoin) {
return LitecoinURI(amount: amount, address: address.address); return LitecoinURI(amount: amount, address: address.address);
} }

View file

@ -165,6 +165,8 @@ abstract class WalletKeysViewModelBase with Store {
return 'banano-wallet'; return 'banano-wallet';
case WalletType.polygon: case WalletType.polygon:
return 'polygon-wallet'; return 'polygon-wallet';
case WalletType.lightning:
return 'lightning-wallet';
default: default:
throw Exception('Unexpected wallet type: ${_appStore.wallet!.toString()}'); throw Exception('Unexpected wallet type: ${_appStore.wallet!.toString()}');
} }

View file

@ -1,5 +1,6 @@
import 'package:cake_wallet/ethereum/ethereum.dart'; import 'package:cake_wallet/ethereum/ethereum.dart';
import 'package:cake_wallet/bitcoin_cash/bitcoin_cash.dart'; import 'package:cake_wallet/bitcoin_cash/bitcoin_cash.dart';
import 'package:cake_wallet/lightning/lightning.dart';
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import 'package:mobx/mobx.dart'; import 'package:mobx/mobx.dart';
import 'package:cake_wallet/monero/monero.dart'; import 'package:cake_wallet/monero/monero.dart';
@ -61,6 +62,8 @@ abstract class WalletNewVMBase extends WalletCreationVM with Store {
name: name, language: options!.first as String, isPolyseed: options.last as bool); name: name, language: options!.first as String, isPolyseed: options.last as bool);
case WalletType.bitcoin: case WalletType.bitcoin:
return bitcoin!.createBitcoinNewWalletCredentials(name: name); return bitcoin!.createBitcoinNewWalletCredentials(name: name);
case WalletType.lightning:
return lightning!.createLightningNewWalletCredentials(name: name);
case WalletType.litecoin: case WalletType.litecoin:
return bitcoin!.createBitcoinNewWalletCredentials(name: name); return bitcoin!.createBitcoinNewWalletCredentials(name: name);
case WalletType.haven: case WalletType.haven:

View file

@ -5,4 +5,5 @@ cd cw_bitcoin && flutter pub get && flutter packages pub run build_runner build
cd cw_haven && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd .. cd cw_haven && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd ..
cd cw_nano && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd .. cd cw_nano && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd ..
cd cw_bitcoin_cash && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd .. cd cw_bitcoin_cash && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd ..
cd cw_lightning && flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs && cd ..
flutter packages pub run build_runner build --delete-conflicting-outputs flutter packages pub run build_runner build --delete-conflicting-outputs