[Unit Tests] Lock/unlock wallet
This commit is contained in:
@@ -41,7 +41,7 @@ bool CSiaApi::_CSiaWallet::Refresh()
|
||||
if (API_SUCCESS(SiaCurlError, error))
|
||||
{
|
||||
SetCreated(result["encrypted"].get<bool>());
|
||||
SetLocked(result["unlocked"].get<bool>());
|
||||
SetLocked(!result["unlocked"].get<bool>());
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -84,17 +84,35 @@ SiaApiError CSiaApi::_CSiaWallet::Lock()
|
||||
SiaApiError error = GetCreated() ? (GetLocked() ? SiaApiError::WalletLocked : SiaApiError::Success) : SiaApiError::WalletNotCreated;
|
||||
if (API_SUCCESS(SiaApiError, error))
|
||||
{
|
||||
error = SiaApiError::RequestError;
|
||||
|
||||
json result;
|
||||
SiaCurlError cerror = _siaCurl.Post(L"/wallet/lock", {}, result);
|
||||
if (API_SUCCESS(SiaCurlError, cerror))
|
||||
{
|
||||
Refresh();
|
||||
error = SiaApiError::Success;
|
||||
}
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
SiaApiError CSiaApi::_CSiaWallet::Unlock()
|
||||
SiaApiError CSiaApi::_CSiaWallet::Unlock(const String& password)
|
||||
{
|
||||
SiaApiError error = GetCreated() ? (GetLocked() ? SiaApiError::Success : SiaApiError::WalletUnlocked) : SiaApiError::WalletNotCreated;
|
||||
if (API_SUCCESS(SiaApiError, error))
|
||||
{
|
||||
error = SiaApiError::RequestError;
|
||||
|
||||
json result;
|
||||
SiaCurlError cerror = _siaCurl.Post(L"/wallet/unlock", { {L"encryptionpassword", password} }, result);
|
||||
if (API_SUCCESS(SiaCurlError, cerror))
|
||||
{
|
||||
Refresh();
|
||||
error = SiaApiError::Success;
|
||||
}
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
Reference in New Issue
Block a user