Wallet creation
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
</HEAD>
|
||||
<BODY ID=CSiaDriveDlg BGCOLOR=LIGHTGREY style="font-family: MS Shell Dlg; font-size:10">
|
||||
<BODY ID=CSiaDriveDlg BGCOLOR=LIGHTGREY style="font-family: MS Shell Dlg; font-size:14">
|
||||
<div style="float: right;">
|
||||
<table>
|
||||
<tr>
|
||||
@@ -46,9 +46,18 @@
|
||||
<div id="exit_window" style="display: none" align="center">
|
||||
<BUTTON STYLE="WIDTH: 100" ID="ExitYes">Yes</BUTTON> <BUTTON STYLE="WIDTH: 100" ID="ExitNo">No</BUTTON>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="create_wallet" style="display: none">
|
||||
<h3>Create New Wallet</h3>
|
||||
<p>Click 'Create' to create a new Sia wallet or exit the application if this is not what you want to do.</p>
|
||||
<button ID="CreateWalletButton">Create</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>
|
||||
<textarea rows=4 cols=60 width="100%" id="WalletCreatedSeed"></textarea><br/><br/>
|
||||
<button ID="ConfirmSeedButton">Done</button>
|
||||
</div>
|
||||
|
||||
<div id="tab_page" style="display: none">
|
||||
|
Binary file not shown.
@@ -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<IHTMLD
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
/*
|
||||
austere teeming factual pause lymph huddle wounded otter poaching tiers roomy arrow stacking howls dozen seeded dented uttered website jaded wipeout giving knife salads jailed calamity legion jabbed ability
|
||||
*/
|
||||
void CSiaDriveDlg::DisplayCreateWallet()
|
||||
{
|
||||
CComPtr<IHTMLDOMNode> mainNode;
|
||||
@@ -320,7 +333,7 @@ void CSiaDriveDlg::DisplayCreateWallet()
|
||||
if (SUCCEEDED(parent->removeChild(walletCreateNode, &removedNode)))
|
||||
{
|
||||
CComPtr<IHTMLDOMNode> appendedNode;
|
||||
if (SUCCEEDED(parent->appendChild(removedNode, &appendedNode)))
|
||||
if (SUCCEEDED(mainNode->appendChild(removedNode, &appendedNode)))
|
||||
{
|
||||
CComPtr<IHTMLStyle> 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<IHTMLDOMNode> mainNode;
|
||||
if (SUCCEEDED(GetDomElementById(L"main_window", mainNode)))
|
||||
{
|
||||
CComPtr<IHTMLElement> div;
|
||||
CComPtr<IHTMLDOMNode> dispWalletSeedNode;
|
||||
if (SUCCEEDED(GetDomElementAndNodeById(L"disp_wallet_seed", dispWalletSeedNode, div)))
|
||||
{
|
||||
CComPtr<IHTMLDOMNode> parent;
|
||||
if (SUCCEEDED(dispWalletSeedNode->get_parentNode(&parent)))
|
||||
{
|
||||
CComPtr<IHTMLDOMNode> removedNode;
|
||||
if (SUCCEEDED(parent->removeChild(dispWalletSeedNode, &removedNode)))
|
||||
{
|
||||
CComPtr<IHTMLDOMNode> child;
|
||||
if (SUCCEEDED(mainNode->get_firstChild(&child)))
|
||||
{
|
||||
CComPtr<IHTMLDOMNode> removed;
|
||||
if (SUCCEEDED(mainNode->removeChild(child, &removed)))
|
||||
{
|
||||
CComPtr<IHTMLDOMNode> appendedNode;
|
||||
if (SUCCEEDED(mainNode->appendChild(removedNode, &appendedNode)))
|
||||
{
|
||||
_walletCreatedSeed = seed.c_str();
|
||||
UpdateData(FALSE);
|
||||
|
||||
CComPtr<IHTMLStyle> 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;
|
||||
}
|
@@ -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<IHTMLDOMNode>& node);
|
||||
HRESULT GetDomElementAndNodeById(const CString& id, CComPtr<IHTMLDOMNode>& node, CComPtr<IHTMLElement>& 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;
|
||||
};
|
||||
|
Reference in New Issue
Block a user