fix: import scanned wallets
This commit is contained in:
parent
6af9199a76
commit
4d027e0555
|
@ -409,7 +409,9 @@ class GenerateWalletsProvider with ChangeNotifier {
|
||||||
? 'currentWallet'.tr()
|
? 'currentWallet'.tr()
|
||||||
: '${'wallet'.tr()} ${scanedValidWalletNumber + 1}';
|
: '${'wallet'.tr()} ${scanedValidWalletNumber + 1}';
|
||||||
await sub.importAccount(
|
await sub.importAccount(
|
||||||
derivePath: '//$derivationNbr', password: pin.text);
|
mnemonic: generatedMnemonic!,
|
||||||
|
derivePath: '//$derivationNbr',
|
||||||
|
password: pin.text);
|
||||||
|
|
||||||
WalletData myWallet = WalletData(
|
WalletData myWallet = WalletData(
|
||||||
version: dataVersion,
|
version: dataVersion,
|
||||||
|
@ -445,7 +447,7 @@ class GenerateWalletsProvider with ChangeNotifier {
|
||||||
"${addressData.address!}: ${balance['transferableBalance']} $currencyName");
|
"${addressData.address!}: ${balance['transferableBalance']} $currencyName");
|
||||||
if (balance['transferableBalance'] != 0) {
|
if (balance['transferableBalance'] != 0) {
|
||||||
String walletName = 'myRootWallet'.tr();
|
String walletName = 'myRootWallet'.tr();
|
||||||
await sub.importAccount(password: pin.text);
|
await sub.importAccount(mnemonic: generatedMnemonic!, password: pin.text);
|
||||||
|
|
||||||
WalletData myWallet = WalletData(
|
WalletData myWallet = WalletData(
|
||||||
version: dataVersion,
|
version: dataVersion,
|
||||||
|
|
|
@ -370,52 +370,6 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
return nodeParams;
|
return nodeParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future csToV2(String salt, String password) async {
|
|
||||||
final scrypt = pc.KeyDerivator('scrypt');
|
|
||||||
|
|
||||||
scrypt.init(
|
|
||||||
pc.ScryptParameters(
|
|
||||||
4096,
|
|
||||||
16,
|
|
||||||
1,
|
|
||||||
32,
|
|
||||||
Uint8List.fromList(salt.codeUnits),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
final rawSeed = scrypt.process(Uint8List.fromList(password.codeUnits));
|
|
||||||
final rawSeedHex = '0x${HEX.encode(rawSeed)}';
|
|
||||||
|
|
||||||
// final newAddress1 = await sdk.api.keyring.addressFromRawSeed(ss58,
|
|
||||||
// cryptoType: CryptoType.ed25519, rawSeed: '0x$rawSeedString');
|
|
||||||
|
|
||||||
// log.d('csconvert address: ${newAddress1.address}');
|
|
||||||
|
|
||||||
final json = await sdk.api.keyring
|
|
||||||
.importAccount(keyring,
|
|
||||||
keyType: KeyType.rawSeed,
|
|
||||||
key: rawSeedHex,
|
|
||||||
name: 'test',
|
|
||||||
password: 'password',
|
|
||||||
derivePath: '',
|
|
||||||
cryptoType: CryptoType.ed25519)
|
|
||||||
.catchError((e) {
|
|
||||||
importIsLoading = false;
|
|
||||||
notifyListeners();
|
|
||||||
});
|
|
||||||
|
|
||||||
final keypair = await sdk.api.keyring.addAccount(
|
|
||||||
keyring,
|
|
||||||
keyType: KeyType.rawSeed,
|
|
||||||
acc: json!,
|
|
||||||
password: password,
|
|
||||||
);
|
|
||||||
await sdk.api.keyring.deleteAccount(keyring, keypair);
|
|
||||||
|
|
||||||
// final keypair2 = KeyPairData.fromJson(json as Map<String, dynamic>);
|
|
||||||
|
|
||||||
log.d(keypair.address);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<String> importAccount(
|
Future<String> importAccount(
|
||||||
{String mnemonic = '',
|
{String mnemonic = '',
|
||||||
String derivePath = '',
|
String derivePath = '',
|
||||||
|
@ -593,6 +547,47 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
return await sdk.api.keyring.checkMnemonicValid(mnemonic);
|
return await sdk.api.keyring.checkMnemonicValid(mnemonic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future csToV2(String salt, String password) async {
|
||||||
|
final scrypt = pc.KeyDerivator('scrypt');
|
||||||
|
|
||||||
|
scrypt.init(
|
||||||
|
pc.ScryptParameters(
|
||||||
|
4096,
|
||||||
|
16,
|
||||||
|
1,
|
||||||
|
32,
|
||||||
|
Uint8List.fromList(salt.codeUnits),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final rawSeed = scrypt.process(Uint8List.fromList(password.codeUnits));
|
||||||
|
final rawSeedHex = '0x${HEX.encode(rawSeed)}';
|
||||||
|
|
||||||
|
// Just get the address without keystore
|
||||||
|
// final newAddress1 = await sdk.api.keyring.addressFromRawSeed(ss58,
|
||||||
|
// cryptoType: CryptoType.ed25519, rawSeed: '0x$rawSeedString');
|
||||||
|
// log.d('csconvert address: ${newAddress1.address}');
|
||||||
|
|
||||||
|
final json = await sdk.api.keyring.importAccount(keyring,
|
||||||
|
keyType: KeyType.rawSeed,
|
||||||
|
key: rawSeedHex,
|
||||||
|
name: 'test',
|
||||||
|
password: 'password',
|
||||||
|
derivePath: '',
|
||||||
|
cryptoType: CryptoType.ed25519);
|
||||||
|
|
||||||
|
final keypair = await sdk.api.keyring.addAccount(
|
||||||
|
keyring,
|
||||||
|
keyType: KeyType.rawSeed,
|
||||||
|
acc: json!,
|
||||||
|
password: password,
|
||||||
|
);
|
||||||
|
await sdk.api.keyring.deleteAccount(keyring, keypair);
|
||||||
|
|
||||||
|
// final keypair2 = KeyPairData.fromJson(json as Map<String, dynamic>);
|
||||||
|
|
||||||
|
log.d(keypair.address);
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
///////// 5: CALLS EXECUTION /////////
|
///////// 5: CALLS EXECUTION /////////
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
|
|
Loading…
Reference in New Issue