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"]; }
/// <summary> /// Loads or creates a wallet at the specified path. /// </summary> /// <param name="path">The path of the wallet file.</param> /// <param name="settings">The <see cref="ProtocolSettings"/> to be used by the wallet.</param> /// <param name="name">The name of the wallet. If the wallet is loaded from an existing file, this parameter is ignored.</param> public NEP6Wallet(string path, ProtocolSettings settings, string name = null) : base(path, settings) { if (File.Exists(path)) { JObject wallet = JObject.Parse(File.ReadAllBytes(path)); LoadFromJson(wallet, out Scrypt, out accounts, out extra); } else { this.name = name; this.version = Version.Parse("1.0"); this.Scrypt = ScryptParameters.Default; this.accounts = new Dictionary <UInt160, NEP6Account>(); this.extra = JObject.Null; } }