mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-02-02 19:26:27 +00:00
Mnemonic for electrum
This commit is contained in:
parent
c5b739d36a
commit
9ad76376d9
5 changed files with 2322 additions and 7 deletions
2297
lib/bitcoin/bitcoin_mnemonic.dart
Normal file
2297
lib/bitcoin/bitcoin_mnemonic.dart
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,7 +1,7 @@
|
|||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_mnemonic.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:bip39/bip39.dart' as bip39;
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:rxdart/rxdart.dart';
|
||||
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
|
||||
|
@ -42,8 +42,9 @@ abstract class BitcoinWalletBase extends WalletBase<BitcoinBalance> with Store {
|
|||
BitcoinBalance initialBalance})
|
||||
: balance =
|
||||
initialBalance ?? BitcoinBalance(confirmed: 0, unconfirmed: 0),
|
||||
hd = bitcoin.HDWallet.fromSeed(bip39.mnemonicToSeed(mnemonic),
|
||||
network: bitcoin.bitcoin),
|
||||
hd = bitcoin.HDWallet.fromSeed(mnemonicToSeedBytes(mnemonic),
|
||||
network: bitcoin.bitcoin)
|
||||
.derivePath("m/0'/0"),
|
||||
addresses = initialAddresses != null
|
||||
? ObservableList<BitcoinAddressRecord>.of(initialAddresses)
|
||||
: ObservableList<BitcoinAddressRecord>(),
|
||||
|
@ -58,7 +59,7 @@ abstract class BitcoinWalletBase extends WalletBase<BitcoinBalance> with Store {
|
|||
{@required String password,
|
||||
@required String name,
|
||||
@required String dirPath,
|
||||
@required WalletInfo walletInfo,
|
||||
@required WalletInfo walletInfo,
|
||||
String jsonSource}) {
|
||||
final data = json.decode(jsonSource) as Map;
|
||||
final mnemonic = data['mnemonic'] as String;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import 'dart:io';
|
||||
import 'package:bip39/bip39.dart' as bip39;
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_mnemonic.dart';
|
||||
import 'package:cake_wallet/bitcoin/file.dart';
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_wallet_creation_credentials.dart';
|
||||
import 'package:cake_wallet/core/wallet_base.dart';
|
||||
|
@ -24,7 +24,7 @@ class BitcoinWalletService extends WalletService<
|
|||
type: WalletType.bitcoin, name: credentials.name);
|
||||
final wallet = BitcoinWalletBase.build(
|
||||
dirPath: dirPath,
|
||||
mnemonic: bip39.generateMnemonic(),
|
||||
mnemonic: generateMnemonic(),
|
||||
password: credentials.password,
|
||||
name: credentials.name,
|
||||
walletInfo: credentials.walletInfo);
|
||||
|
|
16
pubspec.lock
16
pubspec.lock
|
@ -247,12 +247,19 @@ packages:
|
|||
source: hosted
|
||||
version: "2.1.1"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: crypto
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.5"
|
||||
cryptography:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: cryptography
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.4.1"
|
||||
cupertino_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -924,6 +931,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.0-nullsafety.3"
|
||||
unorm_dart:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: unorm_dart
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.2"
|
||||
url_launcher:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
|
@ -60,6 +60,7 @@ dependencies:
|
|||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
cupertino_icons: ^0.1.2
|
||||
encrypt: ^4.0.0
|
||||
crypto: ^2.1.5
|
||||
password: ^1.0.0
|
||||
basic_utils: ^1.0.8
|
||||
bitcoin_flutter: ^2.0.0
|
||||
|
@ -67,6 +68,8 @@ dependencies:
|
|||
connectivity: ^0.4.9+2
|
||||
keyboard_actions: ^3.3.0
|
||||
flushbar: ^1.10.4
|
||||
unorm_dart: ^0.1.2
|
||||
cryptography: ^1.4.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
|
Loading…
Reference in a new issue