コード例 #1
0
ファイル: UserWallet.cs プロジェクト: qixuecheng/AntShares
 public override void AddContract(WalletContract contract)
 {
     base.AddContract(contract);
     using (WalletDataContext ctx = new WalletDataContext(DbPath))
     {
         Contract db_contract = ctx.Contracts.FirstOrDefault(p => p.ScriptHash.SequenceEqual(contract.ScriptHash.ToArray()));
         if (db_contract != null)
         {
             db_contract.PublicKeyHash = contract.PublicKeyHash.ToArray();
         }
         else
         {
             Address db_address = ctx.Addresses.FirstOrDefault(p => p.ScriptHash.SequenceEqual(contract.ScriptHash.ToArray()));
             if (db_address == null)
             {
                 ctx.Addresses.Add(new Address
                 {
                     ScriptHash = contract.ScriptHash.ToArray()
                 });
             }
             ctx.Contracts.Add(new Contract
             {
                 RawData       = contract.ToArray(),
                 ScriptHash    = contract.ScriptHash.ToArray(),
                 PublicKeyHash = contract.PublicKeyHash.ToArray()
             });
         }
         ctx.SaveChanges();
     }
 }
コード例 #2
0
ファイル: UserWallet.cs プロジェクト: qixuecheng/AntShares
        public override WalletAccount CreateAccount(byte[] privateKey)
        {
            WalletAccount account = base.CreateAccount(privateKey);

            OnCreateAccount(account);
            AddContract(WalletContract.CreateSignatureContract(account.PublicKey));
            return(account);
        }
コード例 #3
0
ファイル: UserWallet.cs プロジェクト: hack1t/research
 public override void AddContract(WalletContract contract)
 {
     base.AddContract(contract);
     using (WalletDataContext ctx = new WalletDataContext(DbPath))
     {
         Contract db_contract = ctx.Contracts.FirstOrDefault(p => p.ScriptHash.SequenceEqual(contract.ScriptHash.ToArray()));
         if (db_contract == null)
         {
             db_contract = ctx.Contracts.Add(new Contract
             {
                 Type          = contract.GetType().ToString(),
                 RawData       = contract.ToArray(),
                 ScriptHash    = contract.ScriptHash.ToArray(),
                 PublicKeyHash = contract.PublicKeyHash.ToArray()
             }).Entity;
         }
         else
         {
             db_contract.PublicKeyHash = contract.PublicKeyHash.ToArray();
         }
         ctx.SaveChanges();
     }
 }
コード例 #4
0
ファイル: UserWallet.cs プロジェクト: zhengger/AntShares
 public override void AddContract(WalletContract contract)
 {
     base.AddContract(contract);
     using (WalletDataContext ctx = new WalletDataContext(DbPath))
     {
         Contract db_contract = ctx.Contracts.FirstOrDefault(p => p.ScriptHash.SequenceEqual(contract.ScriptHash.ToArray()));
         if (db_contract == null)
         {
             db_contract = ctx.Contracts.Add(new Contract
             {
                 Type = contract.GetType().ToString(),
                 RawData = contract.ToArray(),
                 ScriptHash = contract.ScriptHash.ToArray(),
                 PublicKeyHash = contract.PublicKeyHash.ToArray()
             }).Entity;
         }
         else
         {
             db_contract.PublicKeyHash = contract.PublicKeyHash.ToArray();
         }
         ctx.SaveChanges();
     }
 }