Beispiel #1
0
 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;
 }
Beispiel #2
0
        public NEP6Wallet(string data)
        {
            if (!string.IsNullOrEmpty(data))
            {
                JObject wallet;

                wallet = JObject.Parse(data);

                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"];
            }
            else
            {
                this.name     = null;
                this.version  = Version.Parse("1.0");
                this.Scrypt   = ScryptParameters.Default;
                this.accounts = new Dictionary <UInt160, NEP6Account>();
                this.extra    = JObject.Null;
            }
        }