/// <summary>
 /// Initializes a new instance of the <see cref="SimpleWallet"/> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="network">The network.</param>
 /// <param name="wlt">The WLT.</param>
 /// <param name="encryptedPrivateKey">The encrypted private key.</param>
 internal SimpleWallet(string name, NetworkType.Types network, WalletObject wlt, EncryptedPrivateKey encryptedPrivateKey)
 {
     Name = name;
     EncryptedPrivateKey = encryptedPrivateKey;
     WalletObj           = wlt;
     Network             = network;
 }
        internal static SimpleWallet CreateNewSimpleWallet(string name, Password password, PrivateAccount account, NetworkType.Types network)
        {
            var encKey = new EncryptedPrivateKey(CryptoUtils.EncodePrivateKey(account.PrivateKey, password.Value));

            var wlt = new WalletObject()
            {
                Accounts = new WalletAccounts()
                {
                    Account = new List <WalletAccount>
                    {
                        new WalletAccount
                        {
                            Address   = account.Address.Plain,
                            Algo      = "pass:bip32",
                            Brain     = false,
                            Child     = "",
                            Encrypted = encKey.EncryptedKey,
                            Iv        = encKey.Iv,
                            Label     = "Primary",
                            Network   = network.GetNetwork()
                        }
                    }
                },
                Name       = name,
                PrivateKey = ""
            };

            return(new SimpleWallet(name, network, wlt, encKey));
        }
 /// <summary>
 /// Opens the wallet with a specified password.
 /// </summary>
 /// <param name="password">The password.</param>
 /// <returns>Account.</returns>
 public PrivateAccount Open(Password password)
 {
     return(PrivateAccount.CreateFromPrivateKey(EncryptedPrivateKey.Decrypt(password), Network));
 }
 /// <summary>
 /// Unlocks the private key.
 /// </summary>
 /// <param name="password">The password.</param>
 /// <returns>System.String.</returns>
 public string UnlockPrivateKey(Password password)
 {
     return(PrivateAccount.CreateFromPrivateKey(EncryptedPrivateKey.Decrypt(password), Network)
            .PrivateKey);
 }