예제 #1
0
 private Dictionary <UInt160, UserWalletAccount> LoadAccounts()
 {
     using (WalletDataContext ctx = new WalletDataContext(path))
     {
         Dictionary <UInt160, UserWalletAccount> accounts = ctx.Addresses.Select(p => p.ScriptHash).AsEnumerable().Select(p => new UserWalletAccount(new UInt160(p))).ToDictionary(p => p.ScriptHash);
         foreach (Contract db_contract in ctx.Contracts.Include(p => p.Account))
         {
             VerificationContract contract = db_contract.RawData.AsSerializable <VerificationContract>();
             UserWalletAccount    account  = accounts[contract.ScriptHash];
             account.Contract = contract;
             account.Key      = new KeyPair(DecryptPrivateKey(db_contract.Account.PrivateKeyEncrypted));
         }
         return(accounts);
     }
 }
예제 #2
0
        public override WalletAccount CreateAccount(byte[] privateKey)
        {
            KeyPair key = new KeyPair(privateKey);
            VerificationContract contract = new VerificationContract
            {
                Script        = SmartContract.Contract.CreateSignatureRedeemScript(key.PublicKey),
                ParameterList = new[] { ContractParameterType.Signature }
            };
            UserWalletAccount account = new UserWalletAccount(contract.ScriptHash)
            {
                Key      = key,
                Contract = contract
            };

            AddAccount(account, false);
            return(account);
        }
예제 #3
0
        public override WalletAccount CreateAccount(SmartContract.Contract contract, KeyPair key = null)
        {
            VerificationContract verification_contract = contract as VerificationContract;

            if (verification_contract == null)
            {
                verification_contract = new VerificationContract
                {
                    Script        = contract.Script,
                    ParameterList = contract.ParameterList
                };
            }
            UserWalletAccount account = new UserWalletAccount(verification_contract.ScriptHash)
            {
                Key      = key,
                Contract = verification_contract
            };

            AddAccount(account, false);
            return(account);
        }