Esempio n. 1
0
 public static BRC6Account FromJson(JObject json, BRC6Wallet wallet)
 {
     return(new BRC6Account(wallet, json["address"].AsString().ToScriptHash(), json["key"]?.AsString())
     {
         Label = json["label"]?.AsString(),
         IsDefault = json["isDefault"].AsBoolean(),
         Lock = json["lock"].AsBoolean(),
         Contract = BRC6Contract.FromJson(json["contract"]),
         Extra = json["extra"]
     });
 }
Esempio n. 2
0
 public static BRC6Wallet Migrate(WalletIndexer indexer, string path, string db3path, string password)
 {
     using (UserWallet wallet_old = UserWallet.Open(indexer, db3path, password))
     {
         BRC6Wallet wallet_new = new BRC6Wallet(indexer, path, wallet_old.Name);
         using (wallet_new.Unlock(password))
         {
             foreach (WalletAccount account in wallet_old.GetAccounts())
             {
                 wallet_new.CreateAccount(account.Contract, account.GetKey());
             }
         }
         return(wallet_new);
     }
 }
Esempio n. 3
0
 public BRC6Account(BRC6Wallet wallet, UInt160 scriptHash, KeyPair key, string password)
     : this(wallet, scriptHash, key.Export(password, wallet.Scrypt.N, wallet.Scrypt.R, wallet.Scrypt.P))
 {
     this.key = key;
 }
Esempio n. 4
0
 public BRC6Account(BRC6Wallet wallet, UInt160 scriptHash, string brc2key = null)
     : base(scriptHash)
 {
     this.wallet  = wallet;
     this.brc2key = brc2key;
 }
Esempio n. 5
0
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="Oldpassword">老密码</param>
        /// <param name="Newpassword">新密码</param>
        /// <param name="wallet">修改密码的钱包</param>
        /// <returns></returns>
        public IDisposable ChangeBrc6WalletPassword(string Oldpassword, string Newpassword, BRC6Wallet wallet)
        {
            if (!VerifyPassword(Oldpassword))
            {
                throw new CryptographicException();
            }

            for (int i = 0; i < wallet.GetAccounts().ToArray().Length; i++)
            {
                byte[]      privatekey_1 = wallet.GetAccount(wallet.GetAccounts().ToArray()[i].Address.ToScriptHash()).GetKey().PrivateKey.ToHexString().HexToBytes();
                KeyPair     key          = new KeyPair(privatekey_1);
                BRC6Account account      = new BRC6Account(this, wallet.GetAccounts().ToArray()[i].Contract.ScriptHash, key, Newpassword)
                {
                    Contract = wallet.GetAccounts().ToArray()[i].Contract
                };
                accounts[wallet.GetAccounts().ToArray()[i].Address.ToScriptHash()] = account;
            }
            this.password = Newpassword;
            return(new WalletLocker(this));
        }
Esempio n. 6
0
 public WalletLocker(BRC6Wallet wallet)
 {
     this.wallet = wallet;
 }