mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 19:49:22 +00:00
Generic fixes (#1427)
* fix for private key solana * Fix Solana wallet open
This commit is contained in:
parent
d5543ceb08
commit
043d7d7c8b
1 changed files with 10 additions and 5 deletions
|
@ -145,12 +145,17 @@ abstract class SolanaWalletBase
|
||||||
Future<Wallet> getWalletPair({String? mnemonic, String? privateKey}) async {
|
Future<Wallet> getWalletPair({String? mnemonic, String? privateKey}) async {
|
||||||
assert(mnemonic != null || privateKey != null);
|
assert(mnemonic != null || privateKey != null);
|
||||||
|
|
||||||
if (privateKey != null) {
|
if (mnemonic != null) {
|
||||||
final privateKeyBytes = base58decode(privateKey);
|
return Wallet.fromMnemonic(mnemonic, account: 0, change: 0);
|
||||||
return await Wallet.fromPrivateKeyBytes(privateKey: privateKeyBytes.take(32).toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Wallet.fromMnemonic(mnemonic!, account: 0, change: 0);
|
try {
|
||||||
|
final privateKeyBytes = base58decode(privateKey!);
|
||||||
|
return await Wallet.fromPrivateKeyBytes(privateKey: privateKeyBytes.take(32).toList());
|
||||||
|
} catch (_) {
|
||||||
|
final privateKeyBytes = HEX.decode(privateKey!);
|
||||||
|
return await Wallet.fromPrivateKeyBytes(privateKey: privateKeyBytes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -360,7 +365,7 @@ abstract class SolanaWalletBase
|
||||||
|
|
||||||
String toJSON() => json.encode({
|
String toJSON() => json.encode({
|
||||||
'mnemonic': _mnemonic,
|
'mnemonic': _mnemonic,
|
||||||
'private_key': privateKey,
|
'private_key': _hexPrivateKey,
|
||||||
'balance': balance[currency]!.toJSON(),
|
'balance': balance[currency]!.toJSON(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue