Beispiel #1
0
 public ArkAccount GetArkAccount()
 {
     if (_account == null)
     {
         _account = AccountService.GetByAddress(Crypto.GetAddress(Crypto.GetKeys(_passPhrase), ArkNetApi.Instance.NetworkSettings.BytePrefix)).Account;
     }
     return(_account);
 }
Beispiel #2
0
 public AccountController(string passphrase)
 {
     _account = new ArkAccount()
     {
         Address   = Crypto.GetAddress(Crypto.GetKeys(passphrase), ArkNetApi.Instance.NetworkSettings.BytePrefix),
         PublicKey = Crypto.GetKeys(passphrase).PubKey.ToString()
     };
 }
Beispiel #3
0
        public async Task <ArkAccount> GetArkAccountAsync()
        {
            if (_account == null)
            {
                var accountResponse = await AccountService.GetByAddressAsync(Crypto.GetAddress(Crypto.GetKeys(_passPhrase), ArkNetApi.Instance.NetworkSettings.BytePrefix));

                _account = accountResponse.Account;
            }
            return(_account);
        }
        public static ArkAccount GetByAddress(string address)
        {
            var response = NetworkApi.Instance.ActivePeer.MakeRequest("GET", "/api/accounts/?address=" + address);
            var parsed   = JObject.Parse(response);

            var account = new ArkAccount();

            if (!Convert.ToBoolean(parsed["success"]))
            {
                account.Address = parsed["error"].ToString();
            }
            else
            {
                account = JsonConvert.DeserializeObject <ArkAccount>(parsed["account"].ToString());
            }
            return(account);
        }
Beispiel #5
0
        /// <summary>
        /// Get ark account's information.
        /// </summary>
        /// <returns>
        /// The <see cref="ArkAccount"/>.
        /// </returns>
        public ArkAccount GetArkAccount()
        {
            if (_account == null)
            {
                _account = _arkNetApi.AccountService.GetByAddress(Crypto.GetAddress(Crypto.GetKeys(_passPhrase), _arkNetApi.NetworkApi.NetworkSettings.BytePrefix)).Account;
            }

            //Account not on chain yet because it's a new account.
            if (_account == null)
            {
                _account = new ArkAccount()
                {
                    Address   = Crypto.GetAddress(Crypto.GetKeys(_passPhrase), _arkNetApi.NetworkApi.NetworkSettings.BytePrefix),
                    PublicKey = Crypto.GetKeys(_passPhrase).PubKey.ToString()
                };
            }

            return(_account);
        }
Beispiel #6
0
        /// <summary>
        /// Get the informations about the account asynchroneously.
        /// </summary>
        /// <returns>
        /// Return an <inheritdoc cref="ArkAccount"/>
        /// </returns>
        public async Task <ArkAccount> GetArkAccountAsync()
        {
            if (_account == null)
            {
                var accountResponse = await _arkNetApi.AccountService.GetByAddressAsync(Crypto.GetAddress(Crypto.GetKeys(_passPhrase), _arkNetApi.NetworkApi.NetworkSettings.BytePrefix)).ConfigureAwait(false);

                _account = accountResponse.Account;
            }

            //Account not on chain yet because it's a new account.
            if (_account == null)
            {
                _arkNetApi.LoggingApi.Info(string.Format("Address <<{0}>> not found on chain", Crypto.GetAddress(Crypto.GetKeys(_passPhrase), _arkNetApi.NetworkApi.NetworkSettings.BytePrefix)));
                _account = new ArkAccount()
                {
                    Address   = Crypto.GetAddress(Crypto.GetKeys(_passPhrase), _arkNetApi.NetworkApi.NetworkSettings.BytePrefix),
                    PublicKey = Crypto.GetKeys(_passPhrase).PubKey.ToString()
                };
            }

            return(_account);
        }