public Task <T> CreateXPubAsync <T>(CancellationToken cancellationToken, NetworkCoin networkCoin, string password) where T : CreateXPubResponse, new() { var request = Requests.CreateXPub(networkCoin, password); return(GetAsyncResponse <T>(request, cancellationToken)); }
public void EmptyAddresses_Exception(NetworkCoin networkCoin) { var walletName = $"{networkCoin.Coin}{networkCoin.Network}EmptyAddressesWallet"; var addresses = new List <string>(); Manager.Blockchains.Wallet.CreateWallet <WalletInfoResponse>(networkCoin, walletName, addresses); }
public void NullAddress_Exception(NetworkCoin networkCoin) { string address = null; Manager.Blockchains.Address.GetAddressTransactions <GetEthAddressTransactionsResponse>( networkCoin, address); }
public void AllCorrect_ShouldPass(NetworkCoin networkCoin) { if (!IsAdditionalPackagePlan) { return; } var response = Manager.Blockchains.PaymentForwarding.GetPayments <GetBtcPaymentsResponse>(networkCoin); AssertNullErrorMessage(response); foreach (var payment in response.Payments) { var deleteResponse = Manager.Blockchains.PaymentForwarding.DeletePayment <DeleteBtcPaymentResponse>( networkCoin, payment.Id); AssertNullErrorMessage(response); Assert.IsFalse(string.IsNullOrEmpty(deleteResponse.Payload.Message), $"'{nameof(deleteResponse.Payload.Message)}' must not be null"); Assert.AreEqual($"Payment Forwarding with uuid {payment.Id} was successfully deleted", deleteResponse.Payload.Message, "'Message' is wrong"); } var secondResponse = Manager.Blockchains.PaymentForwarding.GetPayments <GetBtcPaymentsResponse>(networkCoin); AssertNullErrorMessage(secondResponse); AssertEmptyCollection(nameof(secondResponse.Payments), secondResponse.Payments); }
public T Deploy <T>(NetworkCoin networkCoin, string fromAddress, double gasPrice, double gasLimit, string privateKey, string byteCode) where T : DeployContractResponse, new() { return(DeployAsync <T>(CancellationToken.None, networkCoin, fromAddress, gasPrice, gasLimit, privateKey, byteCode).GetAwaiter().GetResult()); }
public void NullUrl_Exception(NetworkCoin networkCoin) { string nullUrl = null; var address = "some address (not using in test)"; Manager.Blockchains.WebhookNotification.CreateAddress <CreateEthAddressWebHookResponse>(networkCoin, nullUrl, address); }
public IRestRequest Deploy(NetworkCoin networkCoin, string fromAddress, double gasPrice, double gasLimit, string privateKey, string byteCode) { if (string.IsNullOrEmpty(fromAddress)) { throw new ArgumentNullException(nameof(fromAddress)); } if (string.IsNullOrEmpty(privateKey)) { throw new ArgumentNullException(nameof(privateKey)); } if (string.IsNullOrEmpty(byteCode)) { throw new ArgumentNullException(nameof(byteCode)); } if (gasPrice <= 0) { throw new ArgumentOutOfRangeException(nameof(gasPrice), gasPrice, "GasPrice is negative or zero"); } if (gasLimit <= 0) { throw new ArgumentOutOfRangeException(nameof(gasLimit), gasLimit, "GasLimit is negative or zero"); } return(Request.Post($"{Consts.Blockchain}/{networkCoin}/contracts", new DeployContractRequest(privateKey, fromAddress, gasPrice, gasLimit, byteCode))); }
public T Transfer <T>(NetworkCoin networkCoin, string fromAddress, string toAddress, string contract, double gasPrice, double gasLimit, double amount, string privateKey) where T : TransferTokensResponse, new() { return(TransferAsync <T>(CancellationToken.None, networkCoin, fromAddress, toAddress, contract, gasPrice, gasLimit, amount, privateKey).GetAwaiter().GetResult()); }
public void NullAddress_Exception(NetworkCoin networkCoin) { string address = null; Manager.Blockchains.Address.GetAddressInMultisignatureAddresses <GetBtcMultisignatureAddressesResponse>( networkCoin, address); }
private void CheckEmptyWebhookNotificationCollection(NetworkCoin networkCoin) { var response = Manager.Blockchains.WebhookNotification.GetHooks <GetBtcHooksResponse>(networkCoin); AssertNullErrorMessage(response); AssertEmptyCollection(nameof(response.Hooks), response.Hooks); }
private void CreateWebNotification(NetworkCoin networkCoin, string url) { var response = Manager.Blockchains.WebhookNotification.CreateNewBlock <BtcWebHookResponse>(networkCoin, url); AssertNullErrorMessage(response); Assert.IsFalse(string.IsNullOrEmpty(response.Hook.Id), $"'{nameof(response.Hook.Id)}' must not be null"); }
public IRestRequest GetAddressTransactions(NetworkCoin networkCoin, string address, int skip, int limit) { if (string.IsNullOrEmpty(address)) { throw new ArgumentNullException(nameof(address)); } if (skip < 0) { throw new ArgumentOutOfRangeException(nameof(skip), skip, "Skip is negative"); } if (limit <= 0) { throw new ArgumentOutOfRangeException(nameof(limit), limit, "Limit is negative or zero"); } if (limit > 50) { throw new ArgumentOutOfRangeException(nameof(limit), limit, $"The maximum value of limit is 50. Actual value is {limit}"); } var request = Request.Get($"{Consts.Blockchain}/{networkCoin}/address/{address}/transactions"); request.AddQueryParameter("index", skip.ToString()); request.AddQueryParameter("limit", limit.ToString()); return(request); }
private IRestRequest InternalCreatePayment(NetworkCoin networkCoin, CreateEthPaymentRequest request) { if (string.IsNullOrEmpty(request.FromAddress)) { throw new ArgumentNullException(nameof(request.FromAddress)); } if (string.IsNullOrEmpty(request.ToAddress)) { throw new ArgumentNullException(nameof(request.ToAddress)); } if (string.IsNullOrEmpty(request.Callback)) { throw new ArgumentNullException(nameof(request.Callback)); } if (request.Confirmations <= 0) { throw new ArgumentOutOfRangeException(nameof(request.Confirmations), request.Confirmations, "Confirmations is negative or zero"); } if (request.GasPrice.HasValue && request.GasPrice <= 0) { throw new ArgumentOutOfRangeException(nameof(request.GasPrice), request.GasPrice, "GasPrice is negative or zero"); } if (request.GasLimit.HasValue && request.GasLimit <= 0) { throw new ArgumentOutOfRangeException(nameof(request.GasLimit), request.GasLimit, "GasLimit is negative or zero"); } return(Request.Post($"{Consts.Blockchain}/{networkCoin}/payments", request)); }
public Task <T> GetHdWalletsAsync <T>(CancellationToken cancellationToken, NetworkCoin networkCoin) where T : GetHdWalletsResponse, new() { var request = Requests.GetHdWallets(networkCoin); return(GetAsyncResponse <T>(request, cancellationToken)); }
private IRestRequest InternalTransfer(NetworkCoin networkCoin, TransferTokensRequest request) { if (string.IsNullOrEmpty(request.FromAddress)) { throw new ArgumentNullException(nameof(request.FromAddress)); } if (string.IsNullOrEmpty(request.ToAddress)) { throw new ArgumentNullException(nameof(request.ToAddress)); } if (string.IsNullOrEmpty(request.Contract)) { throw new ArgumentNullException(nameof(request.Contract)); } if (request.GasPrice <= 0) { throw new ArgumentOutOfRangeException(nameof(request.GasPrice), request.GasPrice, "GasPrice is negative or zero"); } if (request.GasLimit <= 0) { throw new ArgumentOutOfRangeException(nameof(request.GasLimit), request.GasLimit, "GasLimit is negative or zero"); } if (request.Amount <= 0) { throw new ArgumentOutOfRangeException(nameof(request.Amount), request.Amount, "Amount is negative or zero"); } return(Request.Post($"{Consts.Blockchain}/{networkCoin}/tokens/transfer")); }
public T SendAllAmountUsingPrivateKey <T>( NetworkCoin networkCoin, string fromAddress, string toAddress, string privateKey) where T : CreateEthTransactionResponse, new() { return(SendAllAmountUsingPrivateKeyAsync <T>(CancellationToken.None, networkCoin, fromAddress, toAddress, privateKey).GetAwaiter().GetResult()); }
public Task <T> GetAddressAsync <T>(CancellationToken cancellationToken, NetworkCoin networkCoin, string address) where T : GetAddressResponse, new() { var request = Requests.GetAddress(networkCoin, address); return(GetAsyncResponse <T>(request, cancellationToken)); }
public T NewTransaction <T>(NetworkCoin networkCoin, IEnumerable <TransactionAddress> inputAddresses, IEnumerable <TransactionAddress> outputAddresses, Fee fee, IEnumerable <string> wifs) where T : NewBtcTransactionResponse, new() { return(NewTransactionAsync <T>(CancellationToken.None, networkCoin, inputAddresses, outputAddresses, fee, wifs).GetAwaiter().GetResult()); }
public void NullAddress_Exception(NetworkCoin networkCoin) { var url = "http://www.mocky.io/v2/5b0d4b5f3100006e009d55f5"; string address = null; Manager.Blockchains.WebhookNotification.CreateAddress <CreateEthAddressWebHookResponse>(networkCoin, url, address); }
public T EstimateTransactionGas <T>(NetworkCoin networkCoin, string fromAddress, string toAddress, double value, string data = null) where T : EstimateTransactionGasResponse, new() { return(EstimateTransactionGasAsync <T>(CancellationToken.None, networkCoin, fromAddress, toAddress, value, data).GetAwaiter().GetResult()); }
public void ExistingWallet_ErrorMessage(NetworkCoin networkCoin) { var addressCount = 3; var password = "******"; var walletName = $"{networkCoin.Coin}{networkCoin.Network}ExistingWallet"; // Create the first wallet var response = Manager.Blockchains.Wallet.CreateHdWallet <BtcHdWalletInfoResponse>(networkCoin, walletName, addressCount, password); try { AssertNullErrorMessage(response); Assert.AreEqual(walletName, response.Wallet.Name); // Create the second wallet var response2 = Manager.Blockchains.Wallet.CreateHdWallet <BtcHdWalletInfoResponse>(networkCoin, walletName, addressCount, password); AssertErrorMessage(response2, $"Wallet '{walletName}' already exists"); } finally { // DeleteWallet var deleteResponse = Manager.Blockchains.Wallet.DeleteHdWallet <DeleteWalletResponse>(networkCoin, walletName); AssertNullErrorMessage(deleteResponse); Assert.AreEqual($"Wallet {walletName} was successfully deleted!", deleteResponse.Payload.Message); } }
public T CreateTransaction <T>(NetworkCoin networkCoin, string fromAddress, string toAddress, double value, string password) where T : CreateEthTransactionResponse, new() { return(CreateTransactionAsync <T>(CancellationToken.None, networkCoin, fromAddress, toAddress, value, password).GetAwaiter().GetResult()); }
public void AllCorrect_ShouldPass(NetworkCoin networkCoin, int blockHeight) { var response = Manager.Blockchains.Info.GetBlockHeight <GetBtcHashInfoResponse>(networkCoin, blockHeight); AssertNullErrorMessage(response); Assert.AreEqual(blockHeight, response.HashInfo.Height, $"'{nameof(blockHeight)}' is wrong"); }
public T CreateTransaction <T>(NetworkCoin networkCoin, string fromAddress, string toAddress, string privateKey, double value, double gasPrice, double gasLimit) where T : CreateEthTransactionResponse, new() { return(CreateTransactionAsync <T>(CancellationToken.None, networkCoin, fromAddress, toAddress, privateKey, value, gasPrice, gasLimit).GetAwaiter().GetResult()); }
public void AllCorrect_ShouldPass(NetworkCoin networkCoin, string blockHash) { var response = Manager.Blockchains.Info.GetBlockHash <GetEthHashInfoResponse>(networkCoin, blockHash); AssertNullErrorMessage(response); Assert.AreEqual(blockHash, response.HashInfo.Hash, $"'{nameof(blockHash)}' is wrong"); }
public T CreateHdWallet <T>(NetworkCoin networkCoin, string walletName, int addressCount, string password) where T : HdWalletInfoResponse, new() { return(CreateHdWalletAsync <T>(CancellationToken.None, networkCoin, walletName, addressCount, password).GetAwaiter().GetResult()); }
private void CheckDeletedHook(NetworkCoin networkCoin, WebHook hook) { var response = Manager.Blockchains.WebhookNotification.GetHooks <GetEthHooksResponse>(networkCoin); AssertNullErrorMessage(response); CollectionAssert.DoesNotContain(response.Hooks, hook); }
public T GenerateHdAddress <T>(NetworkCoin networkCoin, string walletName, int addressCount, string encryptedPassword) where T : HdWalletInfoResponse, new() { return(GenerateHdAddressAsync <T>(CancellationToken.None, networkCoin, walletName, addressCount, encryptedPassword).GetAwaiter().GetResult()); }
public void NullUrl(NetworkCoin networkCoin) { string url = null; var address = "some add'ress"; Manager.Blockchains.WebhookNotification.CreateToken <CreateEthAddressWebHookResponse>(networkCoin, url, address); }
public Task <T> DeleteHdWalletAsync <T>(CancellationToken cancellationToken, NetworkCoin networkCoin, string walletName) where T : DeleteWalletResponse, new() { var request = Requests.DeleteHdWallet(networkCoin, walletName); return(GetAsyncResponse <T>(request, cancellationToken)); }