Beispiel #1
0
        public Account GenerateNewAccount(bool isAddtoCache = true)
        {
            var dac = AccountDac.Default;

            byte[] privateKey;
            byte[] publicKey;
            using (var dsa = ECDsa.GenerateNewKeyPair())
            {
                privateKey = dsa.PrivateKey;
                publicKey  = dsa.PublicKey;
            }

            var id = AccountIdHelper.CreateAccountAddress(publicKey);

            if (dac.IsExisted(id))
            {
                throw new Exception("Account id is existed");
            }

            Account account = new Account();

            account.Id          = id;
            account.PrivateKey  = Base16.Encode(privateKey);
            account.PublicKey   = Base16.Encode(publicKey);
            account.Balance     = 0;
            account.IsDefault   = false;
            account.WatchedOnly = false;

            AccountDac.Default.Insert(account);
            return(account);
        }
        public Account GenerateNewAccount()
        {
            var dac = new AccountDac();

            byte[] privateKey;
            byte[] publicKey;
            using (var dsa = ECDsa.GenerateNewKeyPair())
            {
                privateKey = dsa.PrivateKey;
                publicKey  = dsa.PublicKey;
            }

            var id = AccountIdHelper.CreateAccountAddress(publicKey);

            if (dac.IsExisted(id))
            {
                throw new Exception("Account id is existed");
            }

            Account account = new Account();

            account.Id          = id;
            account.PrivateKey  = Base16.Encode(privateKey);
            account.PublicKey   = Base16.Encode(publicKey);
            account.Balance     = 0;
            account.IsDefault   = false;
            account.WatchedOnly = false;

            dac.Insert(account);

            if (UtxoSet.Instance != null)
            {
                UtxoSet.Instance.AddAccountId(account.Id);
            }

            return(account);
        }