Last active
October 26, 2016 19:24
-
-
Save jayrulez/b550138a7df7cc53db05963338e58d65 to your computer and use it in GitHub Desktop.
Tranfer coins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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