Skip to content

Instantly share code, notes, and snippets.

@jayrulez
Last active October 26, 2016 19:24
Show Gist options
  • Save jayrulez/b550138a7df7cc53db05963338e58d65 to your computer and use it in GitHub Desktop.
Save jayrulez/b550138a7df7cc53db05963338e58d65 to your computer and use it in GitHub Desktop.
Tranfer coins
var data = new Dictionary<string, object>()
{
{ "walletPassphrase", _dataProtector.Unprotect(walletPassphrase) },
{ "address", destinationAddress },
{ "amount", satoshis }
};
if (fee != null)
{
data.Add("fee", fee);
}
if (!string.IsNullOrEmpty(message))
{
data.Add("message", message);
}
if (!string.IsNullOrEmpty(sequenceId))
{
data.Add("sequence", sequenceId);
}
var feeWallet = _feeWalletProvider.GetActiveFeeWallet();
if(feeWallet == null)
{
throw new ServiceException("Active fee wallet is null.");
}
data.Add("feeSingleKeyWIF", _feeWalletProvider.Decrypt(feeWallet.PrivateKey));
var requestContent = JsonConvert.SerializeObject(data);
var response = await _httpClient.PostAsync($"wallet/{accountId}/sendcoins", new StringContent(requestContent, Encoding.UTF8, "application/json"));
var content = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode)
{
throw new Exception(content);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment