mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 03:59:23 +00:00
Merge branch 'main' into MrCyjaneK-cyjan-monerodart
This commit is contained in:
commit
8955df8f2c
5 changed files with 77 additions and 44 deletions
|
@ -1,23 +1,24 @@
|
|||
import 'package:bitcoin_base/bitcoin_base.dart';
|
||||
import 'package:convert/convert.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:bip39/bip39.dart' as bip39;
|
||||
import 'package:bitcoin_base/bitcoin_base.dart';
|
||||
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
|
||||
import 'package:convert/convert.dart';
|
||||
import 'package:cw_bitcoin/bitcoin_address_record.dart';
|
||||
import 'package:cw_bitcoin/bitcoin_mnemonic.dart';
|
||||
import 'package:cw_bitcoin/bitcoin_wallet_addresses.dart';
|
||||
import 'package:cw_bitcoin/electrum_balance.dart';
|
||||
import 'package:cw_bitcoin/electrum_wallet.dart';
|
||||
import 'package:cw_bitcoin/electrum_wallet_snapshot.dart';
|
||||
import 'package:cw_bitcoin/psbt_transaction_builder.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:cw_core/unspent_coins_info.dart';
|
||||
import 'package:cw_core/wallet_info.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:ledger_bitcoin/ledger_bitcoin.dart';
|
||||
import 'package:ledger_flutter/ledger_flutter.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
|
||||
import 'package:cw_bitcoin/electrum_wallet_snapshot.dart';
|
||||
import 'package:cw_bitcoin/electrum_wallet.dart';
|
||||
import 'package:cw_core/wallet_info.dart';
|
||||
import 'package:cw_bitcoin/bitcoin_address_record.dart';
|
||||
import 'package:cw_bitcoin/electrum_balance.dart';
|
||||
import 'package:cw_bitcoin/bitcoin_wallet_addresses.dart';
|
||||
import 'package:bip39/bip39.dart' as bip39;
|
||||
|
||||
part 'bitcoin_wallet.g.dart';
|
||||
|
||||
|
@ -215,4 +216,23 @@ abstract class BitcoinWalletBase extends ElectrumWallet with Store {
|
|||
final rawHex = await _bitcoinLedgerApp!.signPsbt(_ledgerDevice!, psbt: psbt.psbt);
|
||||
return BtcTransaction.fromRaw(hex.encode(rawHex));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> signMessage(String message, {String? address = null}) async {
|
||||
if (walletInfo.isHardwareWallet) {
|
||||
final addressEntry = address != null
|
||||
? walletAddresses.allAddresses.firstWhere((element) => element.address == address)
|
||||
: null;
|
||||
final index = addressEntry?.index ?? 0;
|
||||
final isChange = addressEntry?.isHidden == true ? 1 : 0;
|
||||
final accountPath = walletInfo.derivationInfo?.derivationPath;
|
||||
final derivationPath = accountPath != null ? "$accountPath/$isChange/$index" : null;
|
||||
|
||||
final signature = await _bitcoinLedgerApp!
|
||||
.signMessage(_ledgerDevice!, message: ascii.encode(message), signDerivationPath: derivationPath);
|
||||
return base64Encode(signature);
|
||||
}
|
||||
|
||||
return super.signMessage(message, address: address);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -475,10 +475,10 @@ packages:
|
|||
description:
|
||||
path: "."
|
||||
ref: HEAD
|
||||
resolved-ref: b6ed573cbeb57d5f0d39dfe4254bf9d15b620ab6
|
||||
url: "https://github.com/cake-tech/ledger-bitcoin.git"
|
||||
resolved-ref: f819d37e235e239c315e93856abbf5e5d3b71dab
|
||||
url: "https://github.com/cake-tech/ledger-bitcoin"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
version: "0.0.2"
|
||||
ledger_flutter:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
|
@ -38,7 +38,7 @@ dependencies:
|
|||
ledger_flutter: ^1.0.1
|
||||
ledger_bitcoin:
|
||||
git:
|
||||
url: https://github.com/cake-tech/ledger-bitcoin.git
|
||||
url: https://github.com/cake-tech/ledger-bitcoin
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
|
|
@ -3,6 +3,7 @@ import 'dart:io';
|
|||
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
// import 'package:cake_wallet/src/screens/connect_device/debug_device_page.dart';
|
||||
import 'package:cake_wallet/src/screens/connect_device/widgets/device_tile.dart';
|
||||
import 'package:cake_wallet/themes/extensions/cake_text_theme.dart';
|
||||
import 'package:cake_wallet/utils/responsive_layout_util.dart';
|
||||
|
@ -78,15 +79,13 @@ class ConnectDevicePageBodyState extends State<ConnectDevicePageBody> {
|
|||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
Future.delayed(
|
||||
Duration(seconds: 1),
|
||||
() => _bleRefresh = ledger.scan().listen((device) => setState(() => bleDevices.add(device))),
|
||||
);
|
||||
// _bleRefreshTimer = Timer.periodic(Duration(seconds: 1), (_) => _refreshBleDevices());
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_bleRefreshTimer = Timer.periodic(Duration(seconds: 1), (_) => _refreshBleDevices());
|
||||
|
||||
if (Platform.isAndroid) {
|
||||
_usbRefreshTimer = Timer.periodic(Duration(seconds: 1), (_) => _refreshUsbDevices());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -103,14 +102,16 @@ class ConnectDevicePageBodyState extends State<ConnectDevicePageBody> {
|
|||
}
|
||||
|
||||
Future<void> _refreshBleDevices() async {
|
||||
final isBleEnabled = await Permission.bluetooth.serviceStatus.isEnabled;
|
||||
|
||||
setState(() => bleIsEnabled = isBleEnabled);
|
||||
|
||||
if (isBleEnabled) {
|
||||
_bleRefresh = ledger.scan().listen((device) => setState(() => bleDevices.add(device)));
|
||||
try {
|
||||
_bleRefresh = ledger.scan().listen((device) => setState(() => bleDevices.add(device)))
|
||||
..onError((e) {
|
||||
throw e as Exception;
|
||||
});
|
||||
setState(() => bleIsEnabled = true);
|
||||
_bleRefreshTimer?.cancel();
|
||||
_bleRefreshTimer = null;
|
||||
} catch (e) {
|
||||
setState(() => bleIsEnabled = false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,6 +143,15 @@ class ConnectDevicePageBodyState extends State<ConnectDevicePageBody> {
|
|||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
// DeviceTile(
|
||||
// onPressed: () => Navigator.of(context).push(
|
||||
// MaterialPageRoute<void>(
|
||||
// builder: (BuildContext context) => DebugDevicePage(),
|
||||
// ),
|
||||
// ),
|
||||
// title: "Debug Ledger",
|
||||
// leading: imageLedger,
|
||||
// ),
|
||||
if (!bleIsEnabled)
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 20, right: 20, bottom: 20),
|
||||
|
|
|
@ -117,6 +117,8 @@ class _DesktopWalletSelectionDropDownState extends State<DesktopWalletSelectionD
|
|||
if (selectedWallet.isCurrent || !selectedWallet.isEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
final confirmed = await showPopUp<bool>(
|
||||
context: context,
|
||||
builder: (dialogContext) {
|
||||
|
@ -133,6 +135,7 @@ class _DesktopWalletSelectionDropDownState extends State<DesktopWalletSelectionD
|
|||
if (confirmed) {
|
||||
await _loadWallet(selectedWallet);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Image _imageFor({required WalletType type}) {
|
||||
|
|
Loading…
Reference in a new issue