mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 03:59:23 +00:00
fix dependency conflicts + start breez integration
This commit is contained in:
parent
8632842b6d
commit
ee2d440465
10 changed files with 101 additions and 26 deletions
|
@ -1,3 +1,5 @@
|
|||
import 'package:breez_sdk/breez_sdk.dart';
|
||||
import 'package:breez_sdk/bridge_generated.dart';
|
||||
import 'package:cw_bitcoin/bitcoin_mnemonic.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:cw_core/unspent_coins_info.dart';
|
||||
|
@ -37,31 +39,51 @@ abstract class BitcoinWalletBase extends ElectrumWallet with Store {
|
|||
initialBalance: initialBalance,
|
||||
seedBytes: seedBytes,
|
||||
currency: CryptoCurrency.btc) {
|
||||
walletAddresses = BitcoinWalletAddresses(
|
||||
walletInfo,
|
||||
walletAddresses = BitcoinWalletAddresses(walletInfo,
|
||||
electrumClient: electrumClient,
|
||||
initialAddresses: initialAddresses,
|
||||
initialRegularAddressIndex: initialRegularAddressIndex,
|
||||
initialChangeAddressIndex: initialChangeAddressIndex,
|
||||
mainHd: hd,
|
||||
sideHd: bitcoin.HDWallet.fromSeed(seedBytes, network: networkType)
|
||||
.derivePath("m/0'/1"),
|
||||
sideHd: bitcoin.HDWallet.fromSeed(seedBytes, network: networkType).derivePath("m/0'/1"),
|
||||
networkType: networkType);
|
||||
|
||||
// initialize breeze:
|
||||
String inviteCode = "<invite code>";
|
||||
String apiKey = "<api key>";
|
||||
NodeConfig breezNodeConfig = NodeConfig.greenlight(
|
||||
config: GreenlightNodeConfig(
|
||||
partnerCredentials: null,
|
||||
inviteCode: inviteCode,
|
||||
),
|
||||
);
|
||||
BreezSDK()
|
||||
.defaultConfig(
|
||||
envType: EnvironmentType.Production,
|
||||
apiKey: apiKey,
|
||||
nodeConfig: breezNodeConfig,
|
||||
)
|
||||
.then((value) {
|
||||
Config breezConfig = value;
|
||||
// Customize the config object according to your needs
|
||||
breezConfig = breezConfig.copyWith(workingDir: "/breez/${walletInfo.name}");
|
||||
BreezSDK().connect(config: breezConfig, seed: seedBytes);
|
||||
});
|
||||
|
||||
autorun((_) {
|
||||
this.walletAddresses.isEnabledAutoGenerateSubaddress = this.isEnabledAutoGenerateSubaddress;
|
||||
});
|
||||
}
|
||||
|
||||
static Future<BitcoinWallet> create({
|
||||
required String mnemonic,
|
||||
static Future<BitcoinWallet> create(
|
||||
{required String mnemonic,
|
||||
required String password,
|
||||
required WalletInfo walletInfo,
|
||||
required Box<UnspentCoinsInfo> unspentCoinsInfo,
|
||||
List<BitcoinAddressRecord>? initialAddresses,
|
||||
ElectrumBalance? initialBalance,
|
||||
int initialRegularAddressIndex = 0,
|
||||
int initialChangeAddressIndex = 0
|
||||
}) async {
|
||||
int initialChangeAddressIndex = 0}) async {
|
||||
return BitcoinWallet(
|
||||
mnemonic: mnemonic,
|
||||
password: password,
|
||||
|
|
|
@ -11,6 +11,7 @@ import 'package:cw_core/wallet_info.dart';
|
|||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:breez_sdk/breez_sdk.dart';
|
||||
|
||||
class BitcoinWalletService extends WalletService<
|
||||
BitcoinNewWalletCredentials,
|
||||
|
@ -44,6 +45,10 @@ class BitcoinWalletService extends WalletService<
|
|||
Future<BitcoinWallet> openWallet(String name, String password) async {
|
||||
final walletInfo = walletInfoSource.values.firstWhereOrNull(
|
||||
(info) => info.id == WalletBase.idFor(name, getType()))!;
|
||||
|
||||
// Initialize SDK logs listener
|
||||
BreezSDK().initialize();
|
||||
|
||||
final wallet = await BitcoinWalletBase.open(
|
||||
password: password, name: name, walletInfo: walletInfo,
|
||||
unspentCoinsInfo: unspentCoinsInfoSource);
|
||||
|
|
|
@ -27,6 +27,9 @@ dependencies:
|
|||
git:
|
||||
url: https://github.com/cake-tech/bitbox-flutter.git
|
||||
ref: master
|
||||
breez_sdk:
|
||||
git:
|
||||
url: https://github.com/breez/breez-sdk-flutter.git
|
||||
rxdart: ^0.27.5
|
||||
unorm_dart: ^0.2.0
|
||||
cryptography: ^2.0.5
|
||||
|
@ -37,7 +40,7 @@ dev_dependencies:
|
|||
build_runner: ^2.1.11
|
||||
build_resolvers: ^2.0.9
|
||||
mobx_codegen: ^2.0.7
|
||||
hive_generator: ^1.1.3
|
||||
hive_generator: ^2.0.1
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
|
|
@ -38,7 +38,7 @@ dev_dependencies:
|
|||
sdk: flutter
|
||||
build_runner: ^2.1.11
|
||||
mobx_codegen: ^2.0.7
|
||||
hive_generator: ^1.1.3
|
||||
hive_generator: ^2.0.1
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
|
|
@ -29,7 +29,7 @@ dev_dependencies:
|
|||
sdk: flutter
|
||||
build_runner: ^2.1.11
|
||||
mobx_codegen: ^2.0.7
|
||||
hive_generator: ^1.1.3
|
||||
hive_generator: ^2.0.1
|
||||
flutter_lints: ^2.0.0
|
||||
|
||||
flutter:
|
||||
|
|
|
@ -27,7 +27,7 @@ dev_dependencies:
|
|||
build_runner: ^2.1.11
|
||||
mobx_codegen: ^2.0.7
|
||||
build_resolvers: ^2.0.9
|
||||
hive_generator: ^1.1.3
|
||||
hive_generator: ^2.0.1
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
|
|
@ -29,7 +29,7 @@ dev_dependencies:
|
|||
build_runner: ^2.1.11
|
||||
build_resolvers: ^2.0.9
|
||||
mobx_codegen: ^2.0.7
|
||||
hive_generator: ^1.1.3
|
||||
hive_generator: ^2.0.1
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
|
|
@ -34,7 +34,7 @@ dev_dependencies:
|
|||
sdk: flutter
|
||||
build_runner: ^2.1.11
|
||||
mobx_codegen: ^2.0.7
|
||||
hive_generator: ^1.1.3
|
||||
hive_generator: ^2.0.1
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
|
|
@ -41,6 +41,8 @@ import 'package:uni_links/uni_links.dart';
|
|||
import 'package:cw_core/unspent_coins_info.dart';
|
||||
import 'package:cake_wallet/monero/monero.dart';
|
||||
import 'package:cw_core/cake_hive.dart';
|
||||
import 'package:breez_sdk/breez_sdk.dart';
|
||||
import 'package:breez_sdk/bridge_generated.dart';
|
||||
|
||||
final navigatorKey = GlobalKey<NavigatorState>();
|
||||
final rootKey = GlobalKey<RootState>();
|
||||
|
@ -64,6 +66,11 @@ Future<void> main() async {
|
|||
|
||||
await initializeAppConfigs();
|
||||
|
||||
// breez:
|
||||
// BreezDateUtils.setupLocales();
|
||||
// BreezLogger();
|
||||
|
||||
|
||||
runApp(App());
|
||||
}, (error, stackTrace) async {
|
||||
ExceptionHandler.onError(FlutterErrorDetails(exception: error, stack: stackTrace));
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import 'package:breez_sdk/breez_sdk.dart';
|
||||
import 'package:breez_sdk/bridge_generated.dart';
|
||||
import 'package:cake_wallet/src/screens/new_wallet/widgets/select_button.dart';
|
||||
import 'package:cake_wallet/themes/extensions/keyboard_theme.dart';
|
||||
import 'package:cake_wallet/di.dart';
|
||||
|
@ -158,6 +160,43 @@ class AddressPage extends BasePage {
|
|||
isLight: dashboardViewModel.settingsStore.currentTheme.type ==
|
||||
ThemeType.light))),
|
||||
SizedBox(height: 16),
|
||||
IconButton(
|
||||
padding: EdgeInsets.zero,
|
||||
constraints: BoxConstraints(),
|
||||
highlightColor: Colors.transparent,
|
||||
splashColor: Colors.transparent,
|
||||
iconSize: 25,
|
||||
onPressed: () async {
|
||||
// ReceivePaymentRequest req = const ReceivePaymentRequest(
|
||||
// amountMsat: 3000000,
|
||||
// description: "Invoice for 3000 sats",
|
||||
// );
|
||||
// ReceivePaymentResponse receivePaymentResponse =
|
||||
// await BreezSDK().receivePayment(req: req);
|
||||
|
||||
// print(receivePaymentResponse.lnInvoice);
|
||||
|
||||
ServiceHealthCheckResponse healthCheck = await BreezSDK().serviceHealthCheck();
|
||||
print("Current service status is: ${healthCheck.status}");
|
||||
|
||||
ReceiveOnchainRequest req = const ReceiveOnchainRequest();
|
||||
SwapInfo swapInfo = await BreezSDK().receiveOnchain(req: req);
|
||||
|
||||
// Send your funds to the below bitcoin address
|
||||
String address = swapInfo.bitcoinAddress;
|
||||
print(address);
|
||||
print("Minimum amount allowed to deposit in sats: ${swapInfo.minAllowedDeposit}");
|
||||
print("Maximum amount allowed to deposit in sats: ${swapInfo.maxAllowedDeposit}");
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.lightbulb_outline_rounded,
|
||||
size: 48,
|
||||
color: pageIconColor(context),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 40,
|
||||
),
|
||||
Observer(builder: (_) {
|
||||
if (addressListViewModel.hasAddressList) {
|
||||
return SelectButton(
|
||||
|
@ -166,8 +205,7 @@ class AddressPage extends BasePage {
|
|||
(WalletType.monero == addressListViewModel.wallet.type ||
|
||||
WalletType.haven == addressListViewModel.wallet.type)
|
||||
? await showPopUp<void>(
|
||||
context: context,
|
||||
builder: (_) => getIt.get<MoneroAccountListPage>())
|
||||
context: context, builder: (_) => getIt.get<MoneroAccountListPage>())
|
||||
: Navigator.of(context).pushNamed(Routes.receive),
|
||||
textColor: Theme.of(context).extension<SyncIndicatorTheme>()!.textColor,
|
||||
color: Theme.of(context).extension<SyncIndicatorTheme>()!.syncedBackgroundColor,
|
||||
|
|
Loading…
Reference in a new issue