Refactoring
This commit is contained in:
@@ -21,8 +21,8 @@ static String SeedLangToString(const SiaSeedLanguage& lang)
|
||||
}
|
||||
}
|
||||
|
||||
CSiaApi::_CSiaWallet::_CSiaWallet(CSiaCurl& siaCurl) :
|
||||
_siaCurl(siaCurl),
|
||||
CSiaApi::_CSiaWallet::_CSiaWallet(const CSiaCurl& siaCurl) :
|
||||
CSiaBase(siaCurl),
|
||||
_Created(false),
|
||||
_Locked(false)
|
||||
{
|
||||
@@ -37,7 +37,7 @@ CSiaApi::_CSiaWallet::~_CSiaWallet()
|
||||
bool CSiaApi::_CSiaWallet::Refresh()
|
||||
{
|
||||
json result;
|
||||
SiaCurlError error = _siaCurl.Get(L"/wallet", result);
|
||||
SiaCurlError error = GetSiaCurl().Get(L"/wallet", result);
|
||||
if (ApiSuccess(error))
|
||||
{
|
||||
SetCreated(result["encrypted"].get<bool>());
|
||||
@@ -59,7 +59,7 @@ SiaApiError CSiaApi::_CSiaWallet::Create(const SiaSeedLanguage& seedLanguage, St
|
||||
{
|
||||
error = SiaApiError::RequestError;
|
||||
json result;
|
||||
SiaCurlError cerror = _siaCurl.Post(L"/wallet/init", { {L"dictionary", SeedLangToString(seedLanguage)} }, result);
|
||||
SiaCurlError cerror = GetSiaCurl().Post(L"/wallet/init", { {L"dictionary", SeedLangToString(seedLanguage)} }, result);
|
||||
if (ApiSuccess(cerror))
|
||||
{
|
||||
error = SiaApiError::Success;
|
||||
@@ -87,7 +87,7 @@ SiaApiError CSiaApi::_CSiaWallet::Lock()
|
||||
error = SiaApiError::RequestError;
|
||||
|
||||
json result;
|
||||
SiaCurlError cerror = _siaCurl.Post(L"/wallet/lock", {}, result);
|
||||
SiaCurlError cerror = GetSiaCurl().Post(L"/wallet/lock", {}, result);
|
||||
if (ApiSuccess(cerror))
|
||||
{
|
||||
Refresh();
|
||||
@@ -106,7 +106,7 @@ SiaApiError CSiaApi::_CSiaWallet::Unlock(const String& password)
|
||||
error = SiaApiError::RequestError;
|
||||
|
||||
json result;
|
||||
SiaCurlError cerror = _siaCurl.Post(L"/wallet/unlock", { {L"encryptionpassword", password} }, result);
|
||||
SiaCurlError cerror = GetSiaCurl().Post(L"/wallet/unlock", { {L"encryptionpassword", password} }, result);
|
||||
if (ApiSuccess(cerror))
|
||||
{
|
||||
Refresh();
|
||||
@@ -134,7 +134,7 @@ SiaApiError CSiaApi::_CSiaWallet::GetConfirmedBalance(SiaCurrency& balance) cons
|
||||
balance = 0;
|
||||
|
||||
json result;
|
||||
SiaCurlError cerror = _siaCurl.Get(L"/wallet", result);
|
||||
SiaCurlError cerror = GetSiaCurl().Get(L"/wallet", result);
|
||||
if (ApiSuccess(cerror))
|
||||
{
|
||||
balance = HastingsStringToSiaCurrency(String(CA2W(result["confirmedsiacoinbalance"].get<std::string>().c_str())));
|
||||
@@ -150,7 +150,7 @@ SiaApiError CSiaApi::_CSiaWallet::GetUnonfirmedBalance(SiaCurrency& balance) con
|
||||
balance = 0;
|
||||
|
||||
json result;
|
||||
SiaCurlError cerror = _siaCurl.Get(L"/wallet", result);
|
||||
SiaCurlError cerror = GetSiaCurl().Get(L"/wallet", result);
|
||||
if (ApiSuccess(cerror))
|
||||
{
|
||||
balance = HastingsStringToSiaCurrency(String(CA2W(result["unconfirmedincomingsiacoins"].get<std::string>().c_str())));
|
||||
@@ -166,7 +166,7 @@ SiaApiError CSiaApi::_CSiaWallet::GetAddress(String& address) const
|
||||
address = L"";
|
||||
|
||||
json result;
|
||||
SiaCurlError cerror = _siaCurl.Get(L"/wallet/address", result);
|
||||
SiaCurlError cerror = GetSiaCurl().Get(L"/wallet/address", result);
|
||||
if (ApiSuccess(cerror))
|
||||
{
|
||||
address = CA2W(result["address"].get<std::string>().c_str());
|
||||
|
Reference in New Issue
Block a user