You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
2.3 KiB
87 lines
2.3 KiB
/*
|
|
This file is part of cpp-ethereum.
|
|
|
|
cpp-ethereum is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
cpp-ethereum is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
/** @file OtherAccounts.h
|
|
* @author Gav Wood <i@gavwood.com>
|
|
* @date 2015
|
|
*/
|
|
|
|
#include "OtherAccounts.h"
|
|
#include <QSettings>
|
|
#include <libdevcore/Log.h>
|
|
#include <libethereum/Client.h>
|
|
#include <ui_OtherAccounts.h>
|
|
using namespace std;
|
|
using namespace dev;
|
|
using namespace az;
|
|
using namespace eth;
|
|
|
|
DEV_AZ_NOTE_PLUGIN(OtherAccounts);
|
|
|
|
OtherAccounts::OtherAccounts(MainFace* _m):
|
|
AccountNamerPlugin(_m, "OtherAccounts")
|
|
{
|
|
connect(addMenuItem("New Brain Wallet...", "menuTools", true), SIGNAL(triggered()), SLOT(import()));
|
|
}
|
|
|
|
void OtherAccounts::import()
|
|
{
|
|
QDialog d;
|
|
Ui_OtherAccounts u;
|
|
u.setupUi(&d);
|
|
d.setWindowTitle("Add Named Accounts");
|
|
if (d.exec() == QDialog::Accepted)
|
|
{
|
|
QStringList sl = u.accounts->toPlainText().split("\n");
|
|
for (QString const& s: sl)
|
|
{
|
|
Address addr = toAddress(s.section("[ \\t]+", 0, 1).toStdString());
|
|
string name = s.section("[ \\t]+", 1).toStdString();
|
|
m_toName[addr] = name;
|
|
m_toAddress[name] = addr;
|
|
}
|
|
main()->noteSettingsChanged();
|
|
main()->noteAddressesChanged();
|
|
}
|
|
}
|
|
|
|
void OtherAccounts::readSettings(QSettings const& _s)
|
|
{
|
|
m_toName.clear();
|
|
m_toAddress.clear();
|
|
for (QVariant const& i: _s.value("OtherAccounts", QVariantList()).toList())
|
|
{
|
|
QStringList l = i.toStringList();
|
|
if (l.size() == 2)
|
|
{
|
|
m_toName[Address(l[0].toStdString())] = l[1].toStdString();
|
|
m_toAddress[l[1].toStdString()] = Address(l[0].toStdString());
|
|
}
|
|
}
|
|
}
|
|
|
|
void OtherAccounts::writeSettings(QSettings& _s)
|
|
{
|
|
QVariantList r;
|
|
for (auto const& i: m_toName)
|
|
{
|
|
QStringList l;
|
|
l += QString::fromStdString(i.first.hex());
|
|
l += QString::fromStdString(i.second);
|
|
r += QVariant(l);
|
|
}
|
|
_s.setValue("OtherAccounts", r);
|
|
}
|
|
|