mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
Generic fixes (#1427)
* fix for private key solana * Fix Solana wallet open
This commit is contained in:
@@ -145,12 +145,17 @@ abstract class SolanaWalletBase
|
||||
Future<Wallet> getWalletPair({String? mnemonic, String? privateKey}) async {
|
||||
assert(mnemonic != null || privateKey != null);
|
||||
|
||||
if (privateKey != null) {
|
||||
final privateKeyBytes = base58decode(privateKey);
|
||||
return await Wallet.fromPrivateKeyBytes(privateKey: privateKeyBytes.take(32).toList());
|
||||
if (mnemonic != null) {
|
||||
return Wallet.fromMnemonic(mnemonic, account: 0, change: 0);
|
||||
}
|
||||
|
||||
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
|
||||
@@ -360,7 +365,7 @@ abstract class SolanaWalletBase
|
||||
|
||||
String toJSON() => json.encode({
|
||||
'mnemonic': _mnemonic,
|
||||
'private_key': privateKey,
|
||||
'private_key': _hexPrivateKey,
|
||||
'balance': balance[currency]!.toJSON(),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user