@@ -46,9 +46,18 @@
-
+
Create New Wallet
+
Click 'Create' to create a new Sia wallet or exit the application if this is not what you want to do.
+
+
+
+
+
Wallet Created
+
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.
+
+
diff --git a/SiaDrive/SiaDrive.rc b/SiaDrive/SiaDrive.rc
index 29d6858..09de1ce 100644
Binary files a/SiaDrive/SiaDrive.rc and b/SiaDrive/SiaDrive.rc differ
diff --git a/SiaDrive/SiaDriveDlg.cpp b/SiaDrive/SiaDriveDlg.cpp
index 54a1b90..aafa2fa 100644
--- a/SiaDrive/SiaDriveDlg.cpp
+++ b/SiaDrive/SiaDriveDlg.cpp
@@ -51,6 +51,8 @@ END_MESSAGE_MAP()
BEGIN_DHTML_EVENT_MAP(CSiaDriveDlg)
DHTML_EVENT_ONCLICK(_T("ButtonOK"), OnButtonOK)
DHTML_EVENT_ONCLICK(_T("ButtonCancel"), OnButtonCancel)
+ DHTML_EVENT_ONCLICK(_T("CreateWalletButton"), OnButtonCreateWallet)
+ DHTML_EVENT_ONCLICK(_T("ConfirmSeedButton"), OnButtonConfirmSeed)
END_DHTML_EVENT_MAP()
@@ -69,6 +71,7 @@ void CSiaDriveDlg::DoDataExchange(CDataExchange* pDX)
DDX_DHtml_ElementInnerText(pDX, _T("WalletBalanceTotal"), _walletBalanceTotal);
DDX_DHtml_ElementInnerText(pDX, _T("WalletBalanceConfirmed"), _walletBalanceConfirmed);
DDX_DHtml_ElementInnerText(pDX, _T("WalletBalanceUnconfirmed"), _walletBalanceUnconfirmed);
+ DDX_DHtml_ElementInnerText(pDX, _T("WalletCreatedSeed"), _walletCreatedSeed);
}
BEGIN_MESSAGE_MAP(CSiaDriveDlg, CDHtmlDialog)
@@ -172,6 +175,14 @@ HRESULT CSiaDriveDlg::OnButtonCancel(IHTMLElement* /*pElement*/)
return S_OK;
}
+HRESULT CSiaDriveDlg::OnButtonConfirmSeed(IHTMLElement* /*pElement*/)
+{
+ _seedCreation = false;
+ this->Navigate(this->m_strCurrentUrl);
+
+ return S_OK;
+}
+
BOOL CSiaDriveDlg::PreTranslateMessage(MSG* pMsg)
{
//TODO: Implement copy/paste context menu
@@ -190,9 +201,9 @@ bool IsRefreshKeyMessage(const MSG *message)
&& (message->wParam == VK_F5);
}
-HRESULT CSiaDriveDlg::TranslateAccelerator(MSG *message, const GUID *, DWORD)
+HRESULT CSiaDriveDlg::TranslateAccelerator(MSG *message, const GUID * guid, DWORD dw)
{
- return IsRefreshKeyMessage(message) ? E_FAIL : S_OK;
+ return IsRefreshKeyMessage(message) ? E_FAIL : CDHtmlDialog::TranslateAccelerator(message, guid, dw);
}
void CSiaDriveDlg::OnDocumentComplete(LPDISPATCH, LPCTSTR)
@@ -271,13 +282,13 @@ bool CSiaDriveDlg::UpdateUi(const bool& refresh)
{
UpdateData(FALSE);
}
- else
+ else if (!_seedCreation)
{
KillTimer(IDT_UPDATE);
this->Navigate(this->m_strCurrentUrl);
}
}
- else if (refresh)
+ else if (refresh && !_seedCreation)
{
_connected = false;
KillTimer(IDT_UPDATE);
@@ -303,7 +314,9 @@ HRESULT CSiaDriveDlg::GetDomElementAndNodeById(const CString& id, CComPtr mainNode;
@@ -320,7 +333,7 @@ void CSiaDriveDlg::DisplayCreateWallet()
if (SUCCEEDED(parent->removeChild(walletCreateNode, &removedNode)))
{
CComPtr appendedNode;
- if (SUCCEEDED(parent->appendChild(removedNode, &appendedNode)))
+ if (SUCCEEDED(mainNode->appendChild(removedNode, &appendedNode)))
{
CComPtr style;
if (SUCCEEDED(div->get_style(&style)))
@@ -338,10 +351,80 @@ void CSiaDriveDlg::DisplayWalletTab()
{
if (_siaApi.GetWallet()->GetCreated())
{
+ if (_siaApi.GetWallet()->GetLocked())
+ {
+ DisplayUnlockWallet();
+ }
+ else
+ {
+ }
}
else
{
DisplayCreateWallet();
}
}
+
+void CSiaDriveDlg::DisplaySeedCreated(const String& seed)
+{
+ CComPtr mainNode;
+ if (SUCCEEDED(GetDomElementById(L"main_window", mainNode)))
+ {
+ CComPtr div;
+ CComPtr dispWalletSeedNode;
+ if (SUCCEEDED(GetDomElementAndNodeById(L"disp_wallet_seed", dispWalletSeedNode, div)))
+ {
+ CComPtr parent;
+ if (SUCCEEDED(dispWalletSeedNode->get_parentNode(&parent)))
+ {
+ CComPtr removedNode;
+ if (SUCCEEDED(parent->removeChild(dispWalletSeedNode, &removedNode)))
+ {
+ CComPtr child;
+ if (SUCCEEDED(mainNode->get_firstChild(&child)))
+ {
+ CComPtr removed;
+ if (SUCCEEDED(mainNode->removeChild(child, &removed)))
+ {
+ CComPtr appendedNode;
+ if (SUCCEEDED(mainNode->appendChild(removedNode, &appendedNode)))
+ {
+ _walletCreatedSeed = seed.c_str();
+ UpdateData(FALSE);
+
+ CComPtr style;
+ if (SUCCEEDED(div->get_style(&style)))
+ {
+ style->put_display(L"block");
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+void CSiaDriveDlg::DisplayUnlockWallet()
+{
+
+}
+
+HRESULT CSiaDriveDlg::OnButtonCreateWallet(IHTMLElement* pElement)
+{
+ if (!_seedCreation)
+ {
+ _seedCreation = true;
+ KillTimer(IDT_UPDATE);
+
+ String seed;
+ if (API_SUCCESS(SiaApiError, _siaApi.GetWallet()->Create(SiaSeedLanguage::English, seed)))
+ {
+ DisplaySeedCreated(seed);
+ }
+ }
+
+ return S_OK;
+}
\ No newline at end of file
diff --git a/SiaDrive/SiaDriveDlg.h b/SiaDrive/SiaDriveDlg.h
index e3c57cd..5fbf787 100644
--- a/SiaDrive/SiaDriveDlg.h
+++ b/SiaDrive/SiaDriveDlg.h
@@ -24,6 +24,8 @@ public:
HRESULT OnButtonOK(IHTMLElement *pElement);
HRESULT OnButtonCancel(IHTMLElement *pElement);
+ HRESULT OnButtonCreateWallet(IHTMLElement* pElement);
+ HRESULT OnButtonConfirmSeed(IHTMLElement* pElement);
// Implementation
protected:
@@ -45,7 +47,9 @@ protected:
private:
void DisplayCreateWallet();
void DisplayWalletTab();
+ void DisplaySeedCreated(const String& seed);
bool DisplaySiaInfo();
+ void DisplayUnlockWallet();
bool UpdateUi(const bool& refresh = true);
HRESULT GetDomElementById(const CString& id, CComPtr& node);
HRESULT GetDomElementAndNodeById(const CString& id, CComPtr& node, CComPtr& elem);
@@ -58,7 +62,9 @@ private:
CString _walletBalanceTotal;
CString _walletBalanceConfirmed;
CString _walletBalanceUnconfirmed;
+ CString _walletCreatedSeed;
bool _connected = false;
+ bool _seedCreation = false;
static const UINT IDT_UPDATE = 1;
static const std::uint8_t WALLET_TAB = 0;
};