diff --git a/cw_bitcoin/lib/bitcoin_derivations.dart b/cw_bitcoin/lib/bitcoin_derivations.dart index 47ae6ef95..eec7508e9 100644 --- a/cw_bitcoin/lib/bitcoin_derivations.dart +++ b/cw_bitcoin/lib/bitcoin_derivations.dart @@ -1,12 +1,20 @@ import 'package:cw_core/wallet_info.dart'; Map> bitcoin_derivations = { - DerivationType.bip39: [ + DerivationType.electrum2: [ DerivationInfo( derivationType: DerivationType.bip39, derivationPath: "m/0'/1", - description: "cake default?", - script_type: "p2wpkh",// TODO: not really sure what cake uses by default + description: "Electrum 2", + script_type: "p2wpkh", + ), + ], + DerivationType.bip39: [ + DerivationInfo( + derivationType: DerivationType.bip39, + derivationPath: "m/44'/0'/0'/0/0", + description: "Standard BIP44", + script_type: "p2pkh", ), DerivationInfo( derivationType: DerivationType.bip39, @@ -20,6 +28,12 @@ Map> bitcoin_derivations = { description: "Standard BIP49 compatibility segwit", script_type: "p2wpkh-p2sh", ), + DerivationInfo( + derivationType: DerivationType.bip39, + derivationPath: "m/84'/0'/0'/0/0", + description: "Standard BIP84", + script_type: "p2wpkh", + ), DerivationInfo( derivationType: DerivationType.bip39, derivationPath: "m/84'/0'/0'", @@ -87,5 +101,4 @@ Map> bitcoin_derivations = { script_type: "p2wpkh", ), ], - }; diff --git a/cw_bitcoin/lib/bitcoin_wallet_service.dart b/cw_bitcoin/lib/bitcoin_wallet_service.dart index f94067d12..cb37fc250 100644 --- a/cw_bitcoin/lib/bitcoin_wallet_service.dart +++ b/cw_bitcoin/lib/bitcoin_wallet_service.dart @@ -1,4 +1,5 @@ import 'dart:io'; +import 'dart:typed_data'; import 'package:cw_bitcoin/address_to_output_script.dart'; import 'package:cw_bitcoin/bitcoin_mnemonic.dart'; import 'package:cw_bitcoin/bitcoin_mnemonic_is_incorrect_exception.dart'; @@ -20,6 +21,8 @@ import 'package:collection/collection.dart'; import 'package:mobx/mobx.dart'; import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin; import 'package:cw_bitcoin/bitcoin_derivations.dart'; +import 'package:bip32/bip32.dart' as bip32; +import 'package:bip39/bip39.dart' as bip39; class BitcoinWalletService extends WalletService { @@ -96,7 +99,6 @@ class BitcoinWalletService extends WalletService restoreFromSeed(BitcoinRestoreWalletFromSeedCredentials credentials) async { - final wallet = await BitcoinWalletBase.create( password: credentials.password!, mnemonic: credentials.mnemonic, @@ -110,7 +112,6 @@ class BitcoinWalletService extends WalletService> compareDerivationMethods( {required String mnemonic, required Node node}) async { - if (await checkIfMnemonicIsElectrum2(mnemonic)) { return [DerivationType.electrum2]; } @@ -126,54 +127,60 @@ class BitcoinWalletService extends WalletService b.height.compareTo(a.height)); + return list; } diff --git a/lib/src/screens/restore/wallet_restore_choose_derivation.dart b/lib/src/screens/restore/wallet_restore_choose_derivation.dart index 904fc6599..5cf40e588 100644 --- a/lib/src/screens/restore/wallet_restore_choose_derivation.dart +++ b/lib/src/screens/restore/wallet_restore_choose_derivation.dart @@ -62,7 +62,7 @@ class WalletRestoreChooseDerivationPage extends BasePage { contentPadding: EdgeInsets.all(16), title: Center( child: Text( - "${derivation.derivationType.toString().split('.').last}", + "${derivation.description ?? derivation.derivationType.toString().split('.').last}", style: Theme.of(context).primaryTextTheme.labelMedium!.copyWith( fontSize: 18, fontWeight: FontWeight.w800, diff --git a/lib/view_model/wallet_restore_choose_derivation_view_model.dart b/lib/view_model/wallet_restore_choose_derivation_view_model.dart index 494707fe4..3d287c06c 100644 --- a/lib/view_model/wallet_restore_choose_derivation_view_model.dart +++ b/lib/view_model/wallet_restore_choose_derivation_view_model.dart @@ -26,6 +26,4 @@ abstract class WalletRestoreChooseDerivationViewModelBase with Store { @observable WalletRestoreMode mode; - - }