public NEP6Wallet(WalletIndexer indexer, string path, string name = null) { this.indexer = indexer; this.path = path; if (File.Exists(path)) { JObject wallet; using (StreamReader reader = new StreamReader(path)) { wallet = JObject.Parse(reader); } this.name = wallet["name"]?.AsString(); this.version = Version.Parse(wallet["version"].AsString()); this.Scrypt = ScryptParameters.FromJson(wallet["scrypt"]); this.accounts = ((JArray)wallet["accounts"]).Select(p => NEP6Account.FromJson(p, this)).ToDictionary(p => p.ScriptHash); this.extra = wallet["extra"]; indexer.RegisterAccounts(accounts.Keys); } else { this.name = name; this.version = Version.Parse("1.0"); this.Scrypt = ScryptParameters.Default; this.accounts = new Dictionary <UInt160, NEP6Account>(); this.extra = JObject.Null; } indexer.WalletTransaction += WalletIndexer_WalletTransaction; }
private void LoadFromJson(JObject wallet, out ScryptParameters scrypt, out Dictionary <UInt160, NEP6Account> accounts, out JObject extra) { this.name = wallet["name"]?.AsString(); this.version = Version.Parse(wallet["version"].AsString()); scrypt = ScryptParameters.FromJson(wallet["scrypt"]); accounts = ((JArray)wallet["accounts"]).Select(p => NEP6Account.FromJson(p, this)).ToDictionary(p => p.ScriptHash); extra = wallet["extra"]; }
private void LoadFromJson(JObject wallet, out ScryptParameters scrypt, out Dictionary <UInt160, NEP6Account> accounts, out JObject extra) { this.version = Version.Parse(wallet["version"].AsString()); this.name = wallet["name"]?.AsString(); scrypt = ScryptParameters.FromJson(wallet["scrypt"]); accounts = ((JArray)wallet["accounts"]).Select(p => NEP6Account.FromJson(p, this)).ToDictionary(p => p.ScriptHash); extra = wallet["extra"]; if (!VerifyPasswordInternal(password)) { throw new InvalidOperationException("Wrong password."); } }