Daemon rpc login support

requires #1803
This commit is contained in:
Jaquee 2017-02-25 22:16:58 +01:00
parent 2ca2376d45
commit 00aa23162c
No known key found for this signature in database
GPG key ID: 384E52B09F45DC39
5 changed files with 58 additions and 4 deletions

View file

@ -35,6 +35,7 @@ Item {
property alias validator: input.validator property alias validator: input.validator
property alias readOnly : input.readOnly property alias readOnly : input.readOnly
property alias cursorPosition: input.cursorPosition property alias cursorPosition: input.cursorPosition
property alias echoMode: input.echoMode
property int fontSize: 18 property int fontSize: 18
property bool error: false property bool error: false
signal editingFinished() signal editingFinished()

View file

@ -257,6 +257,10 @@ ApplicationWindow {
console.log("initializing with daemon address: ", persistentSettings.daemon_address) console.log("initializing with daemon address: ", persistentSettings.daemon_address)
console.log("Recovering from seed: ", persistentSettings.is_recovering) console.log("Recovering from seed: ", persistentSettings.is_recovering)
console.log("restore Height", persistentSettings.restore_height) console.log("restore Height", persistentSettings.restore_height)
// Use saved daemon rpc login settings
currentWallet.setDaemonLogin(persistentSettings.daemonUsername, persistentSettings.daemonPassword);
currentWallet.initAsync(persistentSettings.daemon_address, 0, persistentSettings.is_recovering, persistentSettings.restore_height); currentWallet.initAsync(persistentSettings.daemon_address, 0, persistentSettings.is_recovering, persistentSettings.restore_height);
} }
@ -800,6 +804,8 @@ ApplicationWindow {
property string daemonFlags property string daemonFlags
property int logLevel: 0 property int logLevel: 0
property string logCategories: "" property string logCategories: ""
property string daemonUsername: ""
property string daemonPassword: ""
} }
// Information dialog // Information dialog

View file

@ -236,7 +236,35 @@ Rectangle {
text: (daemonAddress !== undefined) ? daemonAddress[1] : "18081" text: (daemonAddress !== undefined) ? daemonAddress[1] : "18081"
placeholderText: qsTr("Port") placeholderText: qsTr("Port")
} }
}
RowLayout {
Label {
id: daemonLoginLabel
Layout.fillWidth: true
color: "#4A4949"
text: qsTr("Login (optional)") + translationManager.emptyString
fontSize: 16
}
LineEdit {
id: daemonUsername
Layout.preferredWidth: 100
Layout.fillWidth: true
text: persistentSettings.daemonUsername
placeholderText: qsTr("Username")
}
LineEdit {
id: daemonPassword
Layout.preferredWidth: 100
Layout.fillWidth: true
text: persistentSettings.daemonPassword
placeholderText: qsTr("Password")
echoMode: TextInput.Password
}
StandardButton { StandardButton {
id: daemonAddrSave id: daemonAddrSave
@ -253,12 +281,17 @@ Rectangle {
var newDaemon = daemonAddr.text + ":" + daemonPort.text var newDaemon = daemonAddr.text + ":" + daemonPort.text
if(persistentSettings.daemon_address != newDaemon) { if(persistentSettings.daemon_address != newDaemon) {
persistentSettings.daemon_address = newDaemon persistentSettings.daemon_address = newDaemon
//Reinit wallet
currentWallet.initAsync(newDaemon)
} }
// Update daemon login
persistentSettings.daemonUsername = daemonUsername.text;
persistentSettings.daemonPassword = daemonPassword.text;
currentWallet.setDaemonLogin(persistentSettings.daemonUsername, persistentSettings.daemonPassword);
//Reinit wallet
currentWallet.initAsync(newDaemon);
} }
} }
} }
RowLayout { RowLayout {

View file

@ -178,10 +178,17 @@ bool Wallet::init(const QString &daemonAddress, quint64 upperTransactionLimit, b
m_walletImpl->setRecoveringFromSeed(true); m_walletImpl->setRecoveringFromSeed(true);
m_walletImpl->setRefreshFromBlockHeight(restoreHeight); m_walletImpl->setRefreshFromBlockHeight(restoreHeight);
} }
m_walletImpl->init(daemonAddress.toStdString(), upperTransactionLimit); m_walletImpl->init(daemonAddress.toStdString(), upperTransactionLimit, m_daemonUsername.toStdString(), m_daemonPassword.toStdString());
return true; return true;
} }
void Wallet::setDaemonLogin(const QString &daemonUsername, const QString &daemonPassword)
{
// store daemon login
m_daemonUsername = daemonUsername;
m_daemonPassword = daemonPassword;
}
void Wallet::initAsync(const QString &daemonAddress, quint64 upperTransactionLimit, bool isRecovering, quint64 restoreHeight) void Wallet::initAsync(const QString &daemonAddress, quint64 upperTransactionLimit, bool isRecovering, quint64 restoreHeight)
{ {
qDebug() << "initAsync: " + daemonAddress; qDebug() << "initAsync: " + daemonAddress;
@ -593,6 +600,8 @@ Wallet::Wallet(Monero::Wallet *w, QObject *parent)
m_daemonBlockChainTargetHeightTime.restart(); m_daemonBlockChainTargetHeightTime.restart();
m_initialized = false; m_initialized = false;
m_connectionStatusRunning = false; m_connectionStatusRunning = false;
m_daemonUsername = "";
m_daemonPassword = "";
} }
Wallet::~Wallet() Wallet::~Wallet()

View file

@ -106,6 +106,9 @@ public:
//! initializes wallet asynchronously //! initializes wallet asynchronously
Q_INVOKABLE void initAsync(const QString &daemonAddress, quint64 upperTransactionLimit = 0, bool isRecovering = false, quint64 restoreHeight = 0); Q_INVOKABLE void initAsync(const QString &daemonAddress, quint64 upperTransactionLimit = 0, bool isRecovering = false, quint64 restoreHeight = 0);
// Set daemon rpc user/pass
Q_INVOKABLE void setDaemonLogin(const QString &daemonUsername = "", const QString &daemonPassword = "");
//! create a view only wallet //! create a view only wallet
Q_INVOKABLE bool createViewOnly(const QString &path, const QString &password) const; Q_INVOKABLE bool createViewOnly(const QString &path, const QString &password) const;
@ -271,6 +274,8 @@ private:
mutable AddressBookModel * m_addressBookModel; mutable AddressBookModel * m_addressBookModel;
QMutex m_connectionStatusMutex; QMutex m_connectionStatusMutex;
bool m_connectionStatusRunning; bool m_connectionStatusRunning;
QString m_daemonUsername;
QString m_daemonPassword;
}; };