public static async Task <Wallet> OpenWithKeyAsync(string networkId, string privateKey) { // create wallet and update balance var memStor = new AccountInMemoryStorage(); var acctWallet = new ExchangeAccountWallet(memStor, networkId); acctWallet.AccountName = "tmpAcct"; await acctWallet.RestoreAccountAsync("", privateKey); acctWallet.OpenAccount("", acctWallet.AccountName); Console.WriteLine("Sync wallet for " + acctWallet.AccountId); var rpcClient = await LyraRestClient.CreateAsync(networkId, Environment.OSVersion.Platform.ToString(), "Lyra Client Cli", "1.0a"); await acctWallet.Sync(rpcClient); return(acctWallet); }
public async Task <APIResultCodes> RestoreAsync(string NetworkId, string NodeAPIURL, string PrivateKey) { try { var storage = new AccountInMemoryStorage(); _wallet = Wallet.Create(storage, string.Empty, string.Empty, NetworkId, PrivateKey); var rpcClient = LyraRestClient.Create(NetworkId, "Windows", $"{LyraGlobal.PRODUCTNAME} Client Cli", "1.0a", NodeAPIURL); var syncResult = await _wallet.SyncAsync(rpcClient); if (syncResult != APIResultCodes.Success) { _wallet = null; } return(syncResult); } catch { return(APIResultCodes.FailedToSyncAccount); } }
public static async Task <Wallet> OpenAsync(string networkId, string walletName) { var walletStore = new LiteAccountDatabase(); var tmpWallet = new Wallet(walletStore, networkId); string lyrawalletfolder = BaseAccount.GetFullFolderName("Lyra-CLI-" + networkId); tmpWallet.OpenAccount(lyrawalletfolder, walletName); // create wallet and update balance var memStor = new AccountInMemoryStorage(); var acctWallet = new ExchangeAccountWallet(memStor, networkId); acctWallet.AccountName = "tmpAcct"; await acctWallet.RestoreAccountAsync("", tmpWallet.PrivateKey); acctWallet.OpenAccount("", acctWallet.AccountName); Console.WriteLine("Sync wallet for " + acctWallet.AccountId); var rpcClient = await LyraRestClient.CreateAsync(networkId, Environment.OSVersion.Platform.ToString(), "Lyra Client Cli", "1.0a"); await acctWallet.Sync(rpcClient); return(acctWallet); }