예제 #1
0
        static public void Import(string privatekey, string walletFile = "./Data/walletImport.json")
        {
            var walletKey = new WalletKey();

            walletKey.random = privatekey.HexToBytes();
            ed25519.ed25519_create_keypair(walletKey.publickey, walletKey.privatekey, walletKey.random);

            var keys = new List <WalletKey>();

            keys.Add(walletKey);

            var walletJson = new WalletJson();

            walletJson.curIndex = 0;
            walletJson.accounts = new List <WalletJsonAddress>();

            var aes256 = new AesEverywhere.AES256();

            for (int i = 0; i < keys.Count; i++)
            {
                var walletJsonAddress = new WalletJsonAddress();

                walletJsonAddress.address   = keys[i].ToAddress();
                walletJsonAddress.encrypted = aes256.Encrypt(keys[i].random.ToHexString(), "smartx123");

                walletJson.accounts.Add(walletJsonAddress);
            }

            File.WriteAllText(walletFile, JsonHelper.ToJson(walletJson), System.Text.Encoding.UTF8);
        }
예제 #2
0
        public void SaveWallet()
        {
            var walletJson = new WalletJson();

            walletJson.curIndex = curIndex;
            walletJson.accounts = new List <WalletJsonAddress>();

            var aes256 = new AesEverywhere.AES256();

            for (int i = 0; i < keys.Count; i++)
            {
                var walletJsonAddress = new WalletJsonAddress();

                walletJsonAddress.address   = keys[i].ToAddress();
                walletJsonAddress.encrypted = aes256.Encrypt(keys[i].random.ToHexString(), passwords);

                walletJson.accounts.Add(walletJsonAddress);
            }

            File.WriteAllText(walletFile, JsonHelper.ToJson(walletJson), System.Text.Encoding.UTF8);
        }