NearCoin.fromPrivateKey constructor
NearCoin.fromPrivateKey(
- dynamic privateKey, [
- WalletSetting? setting
Implementation
factory NearCoin.fromPrivateKey(dynamic privateKey,
[WalletSetting? setting]) {
final wallet = NearCoin(setting: setting);
if (privateKey.runtimeType.toString() == 'String') {
if (privateKey.startsWith('ed25519:')) {
final data = privateKey.substring(8);
final secretKey = base58.decode(data);
wallet.initFromPrivateKey(dynamicToUint8List(secretKey.sublist(0, 32)));
} else {
wallet.initFromPrivateKey(dynamicToUint8List(privateKey));
}
} else {
throw Exception('Unsupported private key');
}
return wallet;
}