public async Task ValidateAddress() { Accounts accounts = new Accounts(); AddressInfoOM result = await accounts.ValidateAddress("fiiitFmH9Cqk5B9gTH3LqZzBtqb8pxgHJ7sVqY"); Assert.IsNotNull(result); }
public async Task SetAccountTag() { Accounts accounts = new Accounts(); //first validate address string address = "fiiitFmH9Cqk5B9gTH3LqZzBtqb8pxgHJ7sVqY"; AddressInfoOM result = await accounts.ValidateAddress(address); if (result.IsValid) { await accounts.SetAccountTag(address, "new tag"); } }
public async Task <AddressInfoOM> ValidateAddress(string address) { AuthenticationHeaderValue authHeaderValue = null; RpcClient client = new RpcClient(new Uri(WalletNetwork.NetWork), authHeaderValue, null, null, "application/json"); RpcRequest request = RpcRequest.WithParameterList("ValidateAddress", new[] { address }, 1); RpcResponse response = await client.SendRequestAsync(request); if (response.HasError) { throw new ApiCustomException(response.Error.Code, response.Error.Message); } AddressInfoOM responseValue = response.GetResult <AddressInfoOM>(); return(responseValue); }
public static async Task <ApiResponse> ValidateAddress(string address) { ApiResponse response = new ApiResponse(); try { Accounts account = new Accounts(); AddressInfo info = new AddressInfo(); AddressInfoOM result = await account.ValidateAddress(address); if (result != null) { info.Address = result.Address; info.Account = result.Account; info.Addresses = result.Addresses; info.Hdkeypath = result.Hdkeypath; info.Hdmasterkeyid = result.Hdmasterkeyid; info.Hex = result.Hex; info.IsCompressed = result.IsCompressed; info.IsMine = result.IsMine; info.IsScript = result.IsScript; info.IsValid = result.IsValid; info.IsWatchOnly = result.IsWatchOnly; info.PubKey = result.PubKey; info.Script = result.Script; info.ScriptPubKey = result.ScriptPubKey; info.Sigrequired = result.Sigrequired; response.Result = Newtonsoft.Json.Linq.JToken.FromObject(info); } else { response.Result = null; } } catch (ApiCustomException ex) { Logger.Singleton.Error(ex.ToString()); response.Error = new ApiError(ex.ErrorCode, ex.ToString()); } catch (Exception ex) { Logger.Singleton.Error(ex.ToString()); response.Error = new ApiError(ex.HResult, ex.ToString()); } return(response); }