Unlock wallet functionality
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -241,3 +241,5 @@ ModelManifest.xml
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
/UnitTests/data
|
||||
/3rd-party/Sia-v1.1.0-windows-amd64/data
|
||||
/SiaDrive/Config
|
||||
|
@@ -53,6 +53,13 @@
|
||||
<button ID="CreateWalletButton">Create</button>
|
||||
</div>
|
||||
|
||||
<div id="unlock_wallet" style="display: none">
|
||||
<h3>Unlock Wallet</h3>
|
||||
<p>Enter wallet password and click 'Unlock' to continue.</p>
|
||||
<input type="password" width="100%" id="WalletUnlockPwd" />
|
||||
<button ID="UnlockWalletButton">Unlock</button>
|
||||
</div>
|
||||
|
||||
<div width="100%" id="disp_wallet_seed" style="display: none">
|
||||
<h3>Wallet Created</h3>
|
||||
<p>Please save the following seed. You will need this to unlock and/or restore your wallet. Click 'Done' once you've backed-up your seed.</p>
|
||||
|
@@ -12,8 +12,12 @@
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
/* Home Test
|
||||
/*
|
||||
* Home Test
|
||||
wept saxophone dialect depth update jaunt loincloth asleep lush gnome laptop upper olive itches essential neither feel fewest siblings brunt tasked upwards coal niece faked dating hedgehog magically abort
|
||||
|
||||
* Work Test
|
||||
lush poverty vary fudge ongoing taboo awakened unnoticed piloted ultimate below bikini inundate afraid itches domestic tender poker awoken vitals opus ammo itself alerts brunt wobbly poetry daft addicted
|
||||
*/
|
||||
|
||||
// CAboutDlg dialog used for App About
|
||||
@@ -56,6 +60,7 @@ BEGIN_DHTML_EVENT_MAP(CSiaDriveDlg)
|
||||
DHTML_EVENT_ONCLICK(_T("ButtonCancel"), OnButtonCancel)
|
||||
DHTML_EVENT_ONCLICK(_T("CreateWalletButton"), OnButtonCreateWallet)
|
||||
DHTML_EVENT_ONCLICK(_T("ConfirmSeedButton"), OnButtonConfirmSeed)
|
||||
DHTML_EVENT_ONCLICK(_T("UnlockWalletButton"), OnButtonUnlockWallet)
|
||||
END_DHTML_EVENT_MAP()
|
||||
|
||||
|
||||
@@ -75,6 +80,7 @@ void CSiaDriveDlg::DoDataExchange(CDataExchange* pDX)
|
||||
DDX_DHtml_ElementInnerText(pDX, _T("WalletBalanceConfirmed"), _walletBalanceConfirmed);
|
||||
DDX_DHtml_ElementInnerText(pDX, _T("WalletBalanceUnconfirmed"), _walletBalanceUnconfirmed);
|
||||
DDX_DHtml_ElementInnerText(pDX, _T("WalletCreatedSeed"), _walletCreatedSeed);
|
||||
DDX_DHtml_ElementValue(pDX, _T("WalletUnlockPwd"), _unlockWalletPwd);
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(CSiaDriveDlg, CDHtmlDialog)
|
||||
@@ -188,6 +194,26 @@ HRESULT CSiaDriveDlg::OnButtonConfirmSeed(IHTMLElement* /*pElement*/)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CSiaDriveDlg::OnButtonUnlockWallet(IHTMLElement* /*pElement*/)
|
||||
{
|
||||
UpdateData(TRUE);
|
||||
|
||||
if (API_SUCCESS(SiaApiError, _siaApi.GetWallet()->Unlock(_unlockWalletPwd.GetBuffer())))
|
||||
{
|
||||
_unlockWalletPwd = L"";
|
||||
UpdateData(FALSE);
|
||||
this->Navigate(this->m_strCurrentUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
_unlockWalletPwd = L"";
|
||||
UpdateData(FALSE);
|
||||
AfxMessageBox(L"Invalid password entered");
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
BOOL CSiaDriveDlg::PreTranslateMessage(MSG* pMsg)
|
||||
{
|
||||
//TODO: Implement copy/paste context menu
|
||||
@@ -221,6 +247,8 @@ void CSiaDriveDlg::OnDocumentComplete(LPDISPATCH, LPCTSTR)
|
||||
_walletBalanceUnconfirmed = L"";
|
||||
_walletBalanceTotal = L"";
|
||||
|
||||
SetTimer(IDT_UPDATE, 2000, nullptr);
|
||||
|
||||
if ((_connected = UpdateUi(false)))
|
||||
{
|
||||
switch (_siaConfig.GetUI_Main_TabIndex())
|
||||
@@ -236,8 +264,6 @@ void CSiaDriveDlg::OnDocumentComplete(LPDISPATCH, LPCTSTR)
|
||||
{
|
||||
UpdateData(FALSE);
|
||||
}
|
||||
|
||||
SetTimer(IDT_UPDATE, 2000, nullptr);
|
||||
}
|
||||
|
||||
void CSiaDriveDlg::OnTimer(UINT_PTR nIDEvent)
|
||||
@@ -255,7 +281,7 @@ void CSiaDriveDlg::OnTimer(UINT_PTR nIDEvent)
|
||||
bool CSiaDriveDlg::DisplaySiaInfo()
|
||||
{
|
||||
_serverVersion = _siaApi.GetServerVersion().c_str();
|
||||
if (_serverVersion)
|
||||
if (_serverVersion.GetLength())
|
||||
{
|
||||
if (_siaApi.GetWallet()->Refresh())
|
||||
{
|
||||
@@ -434,7 +460,8 @@ void CSiaDriveDlg::DisplaySeedCreated(const String& seed)
|
||||
|
||||
void CSiaDriveDlg::DisplayUnlockWallet()
|
||||
{
|
||||
|
||||
KillTimer(IDT_UPDATE);
|
||||
SetMainWindow(L"unlock_wallet");
|
||||
}
|
||||
|
||||
HRESULT CSiaDriveDlg::OnButtonCreateWallet(IHTMLElement* pElement)
|
||||
|
@@ -26,6 +26,7 @@ public:
|
||||
HRESULT OnButtonCancel(IHTMLElement *pElement);
|
||||
HRESULT OnButtonCreateWallet(IHTMLElement* pElement);
|
||||
HRESULT OnButtonConfirmSeed(IHTMLElement* pElement);
|
||||
HRESULT OnButtonUnlockWallet(IHTMLElement* pElement);
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
@@ -62,10 +63,11 @@ private:
|
||||
CSiaApi _siaApi;
|
||||
CString _serverVersion;
|
||||
CString _clientVersion;
|
||||
CString _walletBalanceTotal;
|
||||
CString _walletBalanceConfirmed;
|
||||
CString _walletBalanceTotal;
|
||||
CString _walletBalanceUnconfirmed;
|
||||
CString _walletCreatedSeed;
|
||||
CString _unlockWalletPwd;
|
||||
bool _connected = false;
|
||||
bool _seedCreation = false;
|
||||
static const UINT IDT_UPDATE = 1;
|
||||
|
Reference in New Issue
Block a user