mirror of
https://github.com/monero-project/monero-gui.git
synced 2025-01-18 16:54:39 +00:00
Stagenet
This commit is contained in:
parent
c5363da1e8
commit
c8f0cf3543
22 changed files with 161 additions and 112 deletions
|
@ -29,6 +29,7 @@
|
||||||
import QtQuick 2.2
|
import QtQuick 2.2
|
||||||
import QtGraphicalEffects 1.0
|
import QtGraphicalEffects 1.0
|
||||||
import moneroComponents.Wallet 1.0
|
import moneroComponents.Wallet 1.0
|
||||||
|
import moneroComponents.NetworkType 1.0
|
||||||
import "components"
|
import "components"
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
@ -104,8 +105,8 @@ Rectangle {
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: testnetLabel
|
id: testnetLabel
|
||||||
visible: persistentSettings.testnet
|
visible: persistentSettings.nettype !== NetworkType.MAINNET
|
||||||
text: qsTr("Testnet") + translationManager.emptyString
|
text: (persistentSettings.nettype === NetworkType.TESTNET ? qsTr("Testnet") : qsTr("Stagenet")) + translationManager.emptyString
|
||||||
anchors.top: logo.bottom
|
anchors.top: logo.bottom
|
||||||
anchors.topMargin: 5
|
anchors.topMargin: 5
|
||||||
anchors.left: viewOnly ? viewOnlyLabel.right : parent.left
|
anchors.left: viewOnly ? viewOnlyLabel.right : parent.left
|
||||||
|
|
|
@ -128,7 +128,7 @@ Window {
|
||||||
placeholderText: qsTr("command + enter (e.g help)") + translationManager.emptyString
|
placeholderText: qsTr("command + enter (e.g help)") + translationManager.emptyString
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
if(text.length > 0)
|
if(text.length > 0)
|
||||||
daemonManager.sendCommand(text,currentWallet.testnet);
|
daemonManager.sendCommand(text,currentWallet.nettype);
|
||||||
text = ""
|
text = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
3
main.cpp
3
main.cpp
|
@ -145,6 +145,9 @@ int main(int argc, char *argv[])
|
||||||
qRegisterMetaType<TransactionInfo::Direction>();
|
qRegisterMetaType<TransactionInfo::Direction>();
|
||||||
qRegisterMetaType<TransactionHistoryModel::TransactionInfoRole>();
|
qRegisterMetaType<TransactionHistoryModel::TransactionInfoRole>();
|
||||||
|
|
||||||
|
qRegisterMetaType<NetworkType::Type>();
|
||||||
|
qmlRegisterType<NetworkType>("moneroComponents.NetworkType", 1, 0, "NetworkType");
|
||||||
|
|
||||||
#ifdef WITH_SCANNER
|
#ifdef WITH_SCANNER
|
||||||
qmlRegisterType<QrCodeScanner>("moneroComponents.QRCodeScanner", 1, 0, "QRCodeScanner");
|
qmlRegisterType<QrCodeScanner>("moneroComponents.QRCodeScanner", 1, 0, "QRCodeScanner");
|
||||||
#endif
|
#endif
|
||||||
|
|
27
main.qml
27
main.qml
|
@ -35,6 +35,7 @@ import Qt.labs.settings 1.0
|
||||||
|
|
||||||
import moneroComponents.Wallet 1.0
|
import moneroComponents.Wallet 1.0
|
||||||
import moneroComponents.PendingTransaction 1.0
|
import moneroComponents.PendingTransaction 1.0
|
||||||
|
import moneroComponents.NetworkType 1.0
|
||||||
|
|
||||||
|
|
||||||
import "components"
|
import "components"
|
||||||
|
@ -71,7 +72,7 @@ ApplicationWindow {
|
||||||
property bool remoteNodeConnected: false
|
property bool remoteNodeConnected: false
|
||||||
property bool androidCloseTapped: false;
|
property bool androidCloseTapped: false;
|
||||||
// Default daemon addresses
|
// Default daemon addresses
|
||||||
readonly property string localDaemonAddress : !persistentSettings.testnet ? "localhost:18081" : "localhost:28081"
|
readonly property string localDaemonAddress : persistentSettings.nettype === NetworkType.MAINNET ? "localhost:18081" : persistentSettings.nettype === NetworkType.TESTNET ? "localhost:28081" : "localhost:38081"
|
||||||
property string currentDaemonAddress;
|
property string currentDaemonAddress;
|
||||||
property bool startLocalNodeCancelled: false
|
property bool startLocalNodeCancelled: false
|
||||||
|
|
||||||
|
@ -225,9 +226,9 @@ ApplicationWindow {
|
||||||
if(isIOS)
|
if(isIOS)
|
||||||
wallet_path = moneroAccountsDir + wallet_path;
|
wallet_path = moneroAccountsDir + wallet_path;
|
||||||
// console.log("opening wallet at: ", wallet_path, "with password: ", appWindow.walletPassword);
|
// console.log("opening wallet at: ", wallet_path, "with password: ", appWindow.walletPassword);
|
||||||
console.log("opening wallet at: ", wallet_path, ", testnet: ", persistentSettings.testnet);
|
console.log("opening wallet at: ", wallet_path, ", network type: ", persistentSettings.nettype === NetworkType.MAINNET ? "mainnet" : persistentSettings.nettype === NetworkType.TESTNET ? "testnet" : "stagenet");
|
||||||
walletManager.openWalletAsync(wallet_path, walletPassword,
|
walletManager.openWalletAsync(wallet_path, walletPassword,
|
||||||
persistentSettings.testnet);
|
persistentSettings.nettype);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -262,9 +263,9 @@ ApplicationWindow {
|
||||||
viewOnly = currentWallet.viewOnly;
|
viewOnly = currentWallet.viewOnly;
|
||||||
|
|
||||||
// New wallets saves the testnet flag in keys file.
|
// New wallets saves the testnet flag in keys file.
|
||||||
if(persistentSettings.testnet != currentWallet.testnet) {
|
if(persistentSettings.nettype != currentWallet.nettype) {
|
||||||
console.log("Using testnet flag from keys file")
|
console.log("Using network type from keys file")
|
||||||
persistentSettings.testnet = currentWallet.testnet;
|
persistentSettings.nettype = currentWallet.nettype;
|
||||||
}
|
}
|
||||||
|
|
||||||
// connect handlers
|
// connect handlers
|
||||||
|
@ -326,7 +327,7 @@ ApplicationWindow {
|
||||||
middlePanel.transferView.updatePriorityDropdown();
|
middlePanel.transferView.updatePriorityDropdown();
|
||||||
|
|
||||||
// If wallet isnt connected and no daemon is running - Ask
|
// If wallet isnt connected and no daemon is running - Ask
|
||||||
if(!isMobile && walletManager.isDaemonLocal(appWindow.persistentSettings.daemon_address) && !walletInitialized && status === Wallet.ConnectionStatus_Disconnected && !daemonManager.running(persistentSettings.testnet)){
|
if(!isMobile && walletManager.isDaemonLocal(appWindow.persistentSettings.daemon_address) && !walletInitialized && status === Wallet.ConnectionStatus_Disconnected && !daemonManager.running(persistentSettings.nettype)){
|
||||||
daemonManagerDialog.open();
|
daemonManagerDialog.open();
|
||||||
}
|
}
|
||||||
// initialize transaction history once wallet is initialized first time;
|
// initialize transaction history once wallet is initialized first time;
|
||||||
|
@ -478,13 +479,13 @@ ApplicationWindow {
|
||||||
currentWallet.pauseRefresh();
|
currentWallet.pauseRefresh();
|
||||||
|
|
||||||
appWindow.showProcessingSplash(qsTr("Waiting for daemon to start..."))
|
appWindow.showProcessingSplash(qsTr("Waiting for daemon to start..."))
|
||||||
daemonManager.start(flags, persistentSettings.testnet, persistentSettings.blockchainDataDir, persistentSettings.bootstrapNodeAddress);
|
daemonManager.start(flags, persistentSettings.nettype, persistentSettings.blockchainDataDir, persistentSettings.bootstrapNodeAddress);
|
||||||
persistentSettings.daemonFlags = flags
|
persistentSettings.daemonFlags = flags
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopDaemon(){
|
function stopDaemon(){
|
||||||
appWindow.showProcessingSplash(qsTr("Waiting for daemon to stop..."))
|
appWindow.showProcessingSplash(qsTr("Waiting for daemon to stop..."))
|
||||||
daemonManager.stop(persistentSettings.testnet);
|
daemonManager.stop(persistentSettings.nettype);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onDaemonStarted(){
|
function onDaemonStarted(){
|
||||||
|
@ -991,8 +992,8 @@ ApplicationWindow {
|
||||||
property int auto_donations_amount : 50
|
property int auto_donations_amount : 50
|
||||||
property bool allow_background_mining : false
|
property bool allow_background_mining : false
|
||||||
property bool miningIgnoreBattery : true
|
property bool miningIgnoreBattery : true
|
||||||
property bool testnet: false
|
property var nettype: NetworkType.MAINNET
|
||||||
property string daemon_address: testnet ? "localhost:28081" : "localhost:18081"
|
property string daemon_address: nettype === NetworkType.TESTNET ? "localhost:28081" : nettype === NetworkType.STAGENET ? "localhost:38081" : "localhost:18081"
|
||||||
property string payment_id
|
property string payment_id
|
||||||
property int restore_height : 0
|
property int restore_height : 0
|
||||||
property bool is_recovering : false
|
property bool is_recovering : false
|
||||||
|
@ -1633,7 +1634,7 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If daemon is running - prompt user before exiting
|
// If daemon is running - prompt user before exiting
|
||||||
if(typeof daemonManager != "undefined" && daemonManager.running(persistentSettings.testnet)) {
|
if(typeof daemonManager != "undefined" && daemonManager.running(persistentSettings.nettype)) {
|
||||||
|
|
||||||
// Show confirmation dialog
|
// Show confirmation dialog
|
||||||
confirmationDialog.title = qsTr("Daemon is running") + translationManager.emptyString;
|
confirmationDialog.title = qsTr("Daemon is running") + translationManager.emptyString;
|
||||||
|
@ -1645,7 +1646,7 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
confirmationDialog.onRejectedCallback = function() {
|
confirmationDialog.onRejectedCallback = function() {
|
||||||
daemonManager.stop(persistentSettings.testnet);
|
daemonManager.stop(persistentSettings.nettype);
|
||||||
closeAccepted();
|
closeAccepted();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ HEADERS += \
|
||||||
src/libwalletqt/TransactionInfo.h \
|
src/libwalletqt/TransactionInfo.h \
|
||||||
src/libwalletqt/QRCodeImageProvider.h \
|
src/libwalletqt/QRCodeImageProvider.h \
|
||||||
src/libwalletqt/Transfer.h \
|
src/libwalletqt/Transfer.h \
|
||||||
|
src/NetworkType.h \
|
||||||
oshelper.h \
|
oshelper.h \
|
||||||
TranslationManager.h \
|
TranslationManager.h \
|
||||||
src/model/TransactionHistoryModel.h \
|
src/model/TransactionHistoryModel.h \
|
||||||
|
|
|
@ -109,7 +109,7 @@ Rectangle {
|
||||||
releasedColor: "#FF6C3C"
|
releasedColor: "#FF6C3C"
|
||||||
pressedColor: "#FF4304"
|
pressedColor: "#FF4304"
|
||||||
text: qsTr("Add") + translationManager.emptyString
|
text: qsTr("Add") + translationManager.emptyString
|
||||||
enabled: checkInformation(addressLine.text, paymentIdLine.text, appWindow.persistentSettings.testnet)
|
enabled: checkInformation(addressLine.text, paymentIdLine.text, appWindow.persistentSettings.nettype)
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (!currentWallet.addressBook.addRow(addressLine.text.trim(), paymentIdLine.text.trim(), descriptionLine.text)) {
|
if (!currentWallet.addressBook.addRow(addressLine.text.trim(), paymentIdLine.text.trim(), descriptionLine.text)) {
|
||||||
|
@ -177,13 +177,13 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkInformation(address, payment_id, testnet) {
|
function checkInformation(address, payment_id, nettype) {
|
||||||
address = address.trim()
|
address = address.trim()
|
||||||
payment_id = payment_id.trim()
|
payment_id = payment_id.trim()
|
||||||
|
|
||||||
var address_ok = walletManager.addressValid(address, testnet)
|
var address_ok = walletManager.addressValid(address, nettype)
|
||||||
var payment_id_ok = payment_id.length == 0 || walletManager.paymentIdValid(payment_id)
|
var payment_id_ok = payment_id.length == 0 || walletManager.paymentIdValid(payment_id)
|
||||||
var ipid = walletManager.paymentIdFromAddress(address, testnet)
|
var ipid = walletManager.paymentIdFromAddress(address, nettype)
|
||||||
if (ipid.length > 0 && payment_id.length > 0)
|
if (ipid.length > 0 && payment_id.length > 0)
|
||||||
payment_id_ok = false
|
payment_id_ok = false
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ Rectangle {
|
||||||
walletManager.closeWallet();
|
walletManager.closeWallet();
|
||||||
walletManager.clearWalletCache(persistentSettings.wallet_path);
|
walletManager.clearWalletCache(persistentSettings.wallet_path);
|
||||||
walletManager.openWalletAsync(persistentSettings.wallet_path, appWindow.walletPassword,
|
walletManager.openWalletAsync(persistentSettings.wallet_path, appWindow.walletPassword,
|
||||||
persistentSettings.testnet);
|
persistentSettings.nettype);
|
||||||
}
|
}
|
||||||
|
|
||||||
confirmationDialog.onRejectedCallback = null;
|
confirmationDialog.onRejectedCallback = null;
|
||||||
|
@ -291,7 +291,7 @@ Rectangle {
|
||||||
releasedColor: "#FF6C3C"
|
releasedColor: "#FF6C3C"
|
||||||
pressedColor: "#FF4304"
|
pressedColor: "#FF4304"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
daemonManager.sendCommand("status",currentWallet.testnet);
|
daemonManager.sendCommand("status",currentWallet.nettype);
|
||||||
daemonConsolePopup.open();
|
daemonConsolePopup.open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -598,7 +598,7 @@ Rectangle {
|
||||||
walletManager.closeWallet();
|
walletManager.closeWallet();
|
||||||
walletManager.clearWalletCache(persistentSettings.wallet_path);
|
walletManager.clearWalletCache(persistentSettings.wallet_path);
|
||||||
walletManager.openWalletAsync(persistentSettings.wallet_path, appWindow.walletPassword,
|
walletManager.openWalletAsync(persistentSettings.wallet_path, appWindow.walletPassword,
|
||||||
persistentSettings.testnet);
|
persistentSettings.nettype);
|
||||||
}
|
}
|
||||||
|
|
||||||
confirmationDialog.onRejectedCallback = null;
|
confirmationDialog.onRejectedCallback = null;
|
||||||
|
@ -698,7 +698,7 @@ Rectangle {
|
||||||
|
|
||||||
|
|
||||||
if(typeof daemonManager != "undefined")
|
if(typeof daemonManager != "undefined")
|
||||||
appWindow.daemonRunning = daemonManager.running(persistentSettings.testnet)
|
appWindow.daemonRunning = daemonManager.running(persistentSettings.nettype)
|
||||||
}
|
}
|
||||||
|
|
||||||
// fires only once
|
// fires only once
|
||||||
|
|
|
@ -43,8 +43,8 @@ Rectangle {
|
||||||
|
|
||||||
Clipboard { id: clipboard }
|
Clipboard { id: clipboard }
|
||||||
|
|
||||||
function checkAddress(address, testnet) {
|
function checkAddress(address, nettype) {
|
||||||
return walletManager.addressValid(address, testnet)
|
return walletManager.addressValid(address, nettype)
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageDialog {
|
MessageDialog {
|
||||||
|
|
|
@ -268,7 +268,7 @@ Rectangle {
|
||||||
if (result) {
|
if (result) {
|
||||||
var parts = result.split("|")
|
var parts = result.split("|")
|
||||||
if (parts.length == 2) {
|
if (parts.length == 2) {
|
||||||
var address_ok = walletManager.addressValid(parts[1], appWindow.persistentSettings.testnet)
|
var address_ok = walletManager.addressValid(parts[1], appWindow.persistentSettings.nettype)
|
||||||
if (parts[0] === "true") {
|
if (parts[0] === "true") {
|
||||||
if (address_ok) {
|
if (address_ok) {
|
||||||
addressLine.text = parts[1]
|
addressLine.text = parts[1]
|
||||||
|
@ -329,7 +329,7 @@ Rectangle {
|
||||||
shadowPressedColor: "#B32D00"
|
shadowPressedColor: "#B32D00"
|
||||||
releasedColor: "#FF6C3C"
|
releasedColor: "#FF6C3C"
|
||||||
pressedColor: "#FF4304"
|
pressedColor: "#FF4304"
|
||||||
enabled : !appWindow.viewOnly && pageRoot.checkInformation(amountLine.text, addressLine.text, paymentIdLine.text, appWindow.persistentSettings.testnet)
|
enabled : !appWindow.viewOnly && pageRoot.checkInformation(amountLine.text, addressLine.text, paymentIdLine.text, appWindow.persistentSettings.nettype)
|
||||||
onClicked: {
|
onClicked: {
|
||||||
console.log("Transfer: paymentClicked")
|
console.log("Transfer: paymentClicked")
|
||||||
var priority = priorityModelV5.get(priorityDropdown.currentIndex).priority
|
var priority = priorityModelV5.get(priorityDropdown.currentIndex).priority
|
||||||
|
@ -344,14 +344,14 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkInformation(amount, address, payment_id, testnet) {
|
function checkInformation(amount, address, payment_id, nettype) {
|
||||||
address = address.trim()
|
address = address.trim()
|
||||||
payment_id = payment_id.trim()
|
payment_id = payment_id.trim()
|
||||||
|
|
||||||
var amount_ok = amount.length > 0
|
var amount_ok = amount.length > 0
|
||||||
var address_ok = walletManager.addressValid(address, testnet)
|
var address_ok = walletManager.addressValid(address, nettype)
|
||||||
var payment_id_ok = payment_id.length == 0 || walletManager.paymentIdValid(payment_id)
|
var payment_id_ok = payment_id.length == 0 || walletManager.paymentIdValid(payment_id)
|
||||||
var ipid = walletManager.paymentIdFromAddress(address, testnet)
|
var ipid = walletManager.paymentIdFromAddress(address, nettype)
|
||||||
if (ipid.length > 0 && payment_id.length > 0)
|
if (ipid.length > 0 && payment_id.length > 0)
|
||||||
payment_id_ok = false
|
payment_id_ok = false
|
||||||
|
|
||||||
|
@ -472,7 +472,7 @@ Rectangle {
|
||||||
releasedColor: "#FF6C3C"
|
releasedColor: "#FF6C3C"
|
||||||
pressedColor: "#FF4304"
|
pressedColor: "#FF4304"
|
||||||
visible: appWindow.viewOnly
|
visible: appWindow.viewOnly
|
||||||
enabled: pageRoot.checkInformation(amountLine.text, addressLine.text, paymentIdLine.text, appWindow.persistentSettings.testnet)
|
enabled: pageRoot.checkInformation(amountLine.text, addressLine.text, paymentIdLine.text, appWindow.persistentSettings.nettype)
|
||||||
onClicked: {
|
onClicked: {
|
||||||
console.log("Transfer: saveTx Clicked")
|
console.log("Transfer: saveTx Clicked")
|
||||||
var priority = priorityModelV5.get(priorityDropdown.currentIndex).priority
|
var priority = priorityModelV5.get(priorityDropdown.currentIndex).priority
|
||||||
|
|
|
@ -40,8 +40,8 @@ Rectangle {
|
||||||
|
|
||||||
Clipboard { id: clipboard }
|
Clipboard { id: clipboard }
|
||||||
|
|
||||||
function checkAddress(address, testnet) {
|
function checkAddress(address, nettype) {
|
||||||
return walletManager.addressValid(address, testnet)
|
return walletManager.addressValid(address, nettype)
|
||||||
}
|
}
|
||||||
|
|
||||||
function check256(str, length) {
|
function check256(str, length) {
|
||||||
|
@ -188,7 +188,7 @@ Rectangle {
|
||||||
shadowPressedColor: "#B32D00"
|
shadowPressedColor: "#B32D00"
|
||||||
releasedColor: "#FF6C3C"
|
releasedColor: "#FF6C3C"
|
||||||
pressedColor: "#FF4304"
|
pressedColor: "#FF4304"
|
||||||
enabled: checkTxID(getProofTxIdLine.text) && (getProofAddressLine.text.length == 0 || checkAddress(getProofAddressLine.text, appWindow.persistentSettings.testnet))
|
enabled: checkTxID(getProofTxIdLine.text) && (getProofAddressLine.text.length == 0 || checkAddress(getProofAddressLine.text, appWindow.persistentSettings.nettype))
|
||||||
onClicked: {
|
onClicked: {
|
||||||
console.log("getProof: Generate clicked: txid " + getProofTxIdLine.text + ", address " + getProofAddressLine.text + ", message: " + getProofMessageLine.text);
|
console.log("getProof: Generate clicked: txid " + getProofTxIdLine.text + ", address " + getProofAddressLine.text + ", message: " + getProofMessageLine.text);
|
||||||
root.getProofClicked(getProofTxIdLine.text, getProofAddressLine.text, getProofMessageLine.text)
|
root.getProofClicked(getProofTxIdLine.text, getProofAddressLine.text, getProofMessageLine.text)
|
||||||
|
@ -328,7 +328,7 @@ Rectangle {
|
||||||
shadowPressedColor: "#B32D00"
|
shadowPressedColor: "#B32D00"
|
||||||
releasedColor: "#FF6C3C"
|
releasedColor: "#FF6C3C"
|
||||||
pressedColor: "#FF4304"
|
pressedColor: "#FF4304"
|
||||||
enabled: checkTxID(checkProofTxIdLine.text) && checkSignature(checkProofSignatureLine.text) && ((checkProofSignatureLine.text.indexOf("SpendProofV") === 0 && checkProofAddressLine.text.length == 0) || (checkProofSignatureLine.text.indexOf("SpendProofV") !== 0 && checkAddress(checkProofAddressLine.text, appWindow.persistentSettings.testnet)))
|
enabled: checkTxID(checkProofTxIdLine.text) && checkSignature(checkProofSignatureLine.text) && ((checkProofSignatureLine.text.indexOf("SpendProofV") === 0 && checkProofAddressLine.text.length == 0) || (checkProofSignatureLine.text.indexOf("SpendProofV") !== 0 && checkAddress(checkProofAddressLine.text, appWindow.persistentSettings.nettype)))
|
||||||
onClicked: {
|
onClicked: {
|
||||||
console.log("checkProof: Check clicked: txid " + checkProofTxIdLine.text + ", address " + checkProofAddressLine.text + ", message " + checkProofMessageLine.text + ", signature " + checkProofSignatureLine.text);
|
console.log("checkProof: Check clicked: txid " + checkProofTxIdLine.text + ", address " + checkProofAddressLine.text + ", message " + checkProofMessageLine.text + ", signature " + checkProofSignatureLine.text);
|
||||||
root.checkProofClicked(checkProofTxIdLine.text, checkProofAddressLine.text, checkProofMessageLine.text, checkProofSignatureLine.text)
|
root.checkProofClicked(checkProofTxIdLine.text, checkProofAddressLine.text, checkProofMessageLine.text, checkProofSignatureLine.text)
|
||||||
|
|
17
src/NetworkType.h
Normal file
17
src/NetworkType.h
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <wallet/api/wallet2_api.h>
|
||||||
|
|
||||||
|
class NetworkType : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum Type : uint8_t {
|
||||||
|
MAINNET = Monero::MAINNET,
|
||||||
|
TESTNET = Monero::TESTNET,
|
||||||
|
STAGENET = Monero::STAGENET
|
||||||
|
};
|
||||||
|
Q_ENUM(Type)
|
||||||
|
};
|
|
@ -32,7 +32,7 @@ DaemonManager *DaemonManager::instance(const QStringList *args)
|
||||||
return m_instance;
|
return m_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DaemonManager::start(const QString &flags, bool testnet, const QString &dataDir, const QString &bootstrapNodeAddress)
|
bool DaemonManager::start(const QString &flags, NetworkType::Type nettype, const QString &dataDir, const QString &bootstrapNodeAddress)
|
||||||
{
|
{
|
||||||
// prepare command line arguments and pass to monerod
|
// prepare command line arguments and pass to monerod
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
|
@ -42,8 +42,10 @@ bool DaemonManager::start(const QString &flags, bool testnet, const QString &dat
|
||||||
arguments << "--detach";
|
arguments << "--detach";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(testnet)
|
if (nettype == NetworkType::TESTNET)
|
||||||
arguments << "--testnet";
|
arguments << "--testnet";
|
||||||
|
else if (nettype == NetworkType::STAGENET)
|
||||||
|
arguments << "--stagenet";
|
||||||
|
|
||||||
foreach (const QString &str, m_clArgs) {
|
foreach (const QString &str, m_clArgs) {
|
||||||
qDebug() << QString(" [%1] ").arg(str);
|
qDebug() << QString(" [%1] ").arg(str);
|
||||||
|
@ -60,11 +62,7 @@ bool DaemonManager::start(const QString &flags, bool testnet, const QString &dat
|
||||||
|
|
||||||
// Custom data-dir
|
// Custom data-dir
|
||||||
if(!dataDir.isEmpty()) {
|
if(!dataDir.isEmpty()) {
|
||||||
if(testnet)
|
arguments << "--data-dir" << dataDir;
|
||||||
arguments << "--testnet-data-dir";
|
|
||||||
else
|
|
||||||
arguments << "--data-dir";
|
|
||||||
arguments << dataDir;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bootstrap node address
|
// Bootstrap node address
|
||||||
|
@ -99,7 +97,7 @@ bool DaemonManager::start(const QString &flags, bool testnet, const QString &dat
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start start watcher
|
// Start start watcher
|
||||||
QFuture<bool> future = QtConcurrent::run(this, &DaemonManager::startWatcher, testnet);
|
QFuture<bool> future = QtConcurrent::run(this, &DaemonManager::startWatcher, nettype);
|
||||||
QFutureWatcher<bool> * watcher = new QFutureWatcher<bool>();
|
QFutureWatcher<bool> * watcher = new QFutureWatcher<bool>();
|
||||||
connect(watcher, &QFutureWatcher<bool>::finished,
|
connect(watcher, &QFutureWatcher<bool>::finished,
|
||||||
this, [this, watcher]() {
|
this, [this, watcher]() {
|
||||||
|
@ -116,14 +114,14 @@ bool DaemonManager::start(const QString &flags, bool testnet, const QString &dat
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DaemonManager::stop(bool testnet)
|
bool DaemonManager::stop(NetworkType::Type nettype)
|
||||||
{
|
{
|
||||||
QString message;
|
QString message;
|
||||||
sendCommand("exit",testnet,message);
|
sendCommand("exit", nettype, message);
|
||||||
qDebug() << message;
|
qDebug() << message;
|
||||||
|
|
||||||
// Start stop watcher - Will kill if not shutting down
|
// Start stop watcher - Will kill if not shutting down
|
||||||
QFuture<bool> future = QtConcurrent::run(this, &DaemonManager::stopWatcher, testnet);
|
QFuture<bool> future = QtConcurrent::run(this, &DaemonManager::stopWatcher, nettype);
|
||||||
QFutureWatcher<bool> * watcher = new QFutureWatcher<bool>();
|
QFutureWatcher<bool> * watcher = new QFutureWatcher<bool>();
|
||||||
connect(watcher, &QFutureWatcher<bool>::finished,
|
connect(watcher, &QFutureWatcher<bool>::finished,
|
||||||
this, [this, watcher]() {
|
this, [this, watcher]() {
|
||||||
|
@ -138,14 +136,14 @@ bool DaemonManager::stop(bool testnet)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DaemonManager::startWatcher(bool testnet) const
|
bool DaemonManager::startWatcher(NetworkType::Type nettype) const
|
||||||
{
|
{
|
||||||
// Check if daemon is started every 2 seconds
|
// Check if daemon is started every 2 seconds
|
||||||
QTime timer;
|
QTime timer;
|
||||||
timer.restart();
|
timer.restart();
|
||||||
while(true && !m_app_exit && timer.elapsed() / 1000 < DAEMON_START_TIMEOUT_SECONDS ) {
|
while(true && !m_app_exit && timer.elapsed() / 1000 < DAEMON_START_TIMEOUT_SECONDS ) {
|
||||||
QThread::sleep(2);
|
QThread::sleep(2);
|
||||||
if(!running(testnet)) {
|
if(!running(nettype)) {
|
||||||
qDebug() << "daemon not running. checking again in 2 seconds.";
|
qDebug() << "daemon not running. checking again in 2 seconds.";
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "daemon is started. Waiting 5 seconds to let daemon catch up";
|
qDebug() << "daemon is started. Waiting 5 seconds to let daemon catch up";
|
||||||
|
@ -156,14 +154,14 @@ bool DaemonManager::startWatcher(bool testnet) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DaemonManager::stopWatcher(bool testnet) const
|
bool DaemonManager::stopWatcher(NetworkType::Type nettype) const
|
||||||
{
|
{
|
||||||
// Check if daemon is running every 2 seconds. Kill if still running after 10 seconds
|
// Check if daemon is running every 2 seconds. Kill if still running after 10 seconds
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
while(true && !m_app_exit) {
|
while(true && !m_app_exit) {
|
||||||
QThread::sleep(2);
|
QThread::sleep(2);
|
||||||
counter++;
|
counter++;
|
||||||
if(running(testnet)) {
|
if(running(nettype)) {
|
||||||
qDebug() << "Daemon still running. " << counter;
|
qDebug() << "Daemon still running. " << counter;
|
||||||
if(counter >= 5) {
|
if(counter >= 5) {
|
||||||
qDebug() << "Killing it! ";
|
qDebug() << "Killing it! ";
|
||||||
|
@ -211,10 +209,10 @@ void DaemonManager::printError()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DaemonManager::running(bool testnet) const
|
bool DaemonManager::running(NetworkType::Type nettype) const
|
||||||
{
|
{
|
||||||
QString status;
|
QString status;
|
||||||
sendCommand("status",testnet, status);
|
sendCommand("status", nettype, status);
|
||||||
qDebug() << status;
|
qDebug() << status;
|
||||||
// `./monerod status` returns BUSY when syncing.
|
// `./monerod status` returns BUSY when syncing.
|
||||||
// Treat busy as connected, until fixed upstream.
|
// Treat busy as connected, until fixed upstream.
|
||||||
|
@ -223,21 +221,23 @@ bool DaemonManager::running(bool testnet) const
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool DaemonManager::sendCommand(const QString &cmd,bool testnet) const
|
bool DaemonManager::sendCommand(const QString &cmd, NetworkType::Type nettype) const
|
||||||
{
|
{
|
||||||
QString message;
|
QString message;
|
||||||
return sendCommand(cmd, testnet, message);
|
return sendCommand(cmd, nettype, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DaemonManager::sendCommand(const QString &cmd,bool testnet, QString &message) const
|
bool DaemonManager::sendCommand(const QString &cmd, NetworkType::Type nettype, QString &message) const
|
||||||
{
|
{
|
||||||
QProcess p;
|
QProcess p;
|
||||||
QStringList external_cmd;
|
QStringList external_cmd;
|
||||||
external_cmd << cmd;
|
external_cmd << cmd;
|
||||||
|
|
||||||
// Add testnet flag if needed
|
// Add network type flag if needed
|
||||||
if (testnet)
|
if (nettype == NetworkType::TESTNET)
|
||||||
external_cmd << "--testnet";
|
external_cmd << "--testnet";
|
||||||
|
else if (nettype == NetworkType::STAGENET)
|
||||||
|
external_cmd << "--stagenet";
|
||||||
|
|
||||||
qDebug() << "sending external cmd: " << external_cmd;
|
qDebug() << "sending external cmd: " << external_cmd;
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
|
#include "NetworkType.h"
|
||||||
|
|
||||||
class DaemonManager : public QObject
|
class DaemonManager : public QObject
|
||||||
{
|
{
|
||||||
|
@ -14,21 +15,21 @@ public:
|
||||||
|
|
||||||
static DaemonManager * instance(const QStringList *args);
|
static DaemonManager * instance(const QStringList *args);
|
||||||
|
|
||||||
Q_INVOKABLE bool start(const QString &flags, bool testnet, const QString &dataDir = "", const QString &bootstrapNodeAddress = "");
|
Q_INVOKABLE bool start(const QString &flags, NetworkType::Type nettype, const QString &dataDir = "", const QString &bootstrapNodeAddress = "");
|
||||||
Q_INVOKABLE bool stop(bool testnet);
|
Q_INVOKABLE bool stop(NetworkType::Type nettype);
|
||||||
|
|
||||||
// return true if daemon process is started
|
// return true if daemon process is started
|
||||||
Q_INVOKABLE bool running(bool testnet) const;
|
Q_INVOKABLE bool running(NetworkType::Type nettype) const;
|
||||||
// Send daemon command from qml and prints output in console window.
|
// Send daemon command from qml and prints output in console window.
|
||||||
Q_INVOKABLE bool sendCommand(const QString &cmd, bool testnet) const;
|
Q_INVOKABLE bool sendCommand(const QString &cmd, NetworkType::Type nettype) const;
|
||||||
Q_INVOKABLE void exit();
|
Q_INVOKABLE void exit();
|
||||||
Q_INVOKABLE QVariantMap validateDataDir(const QString &dataDir) const;
|
Q_INVOKABLE QVariantMap validateDataDir(const QString &dataDir) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool sendCommand(const QString &cmd, bool testnet, QString &message) const;
|
bool sendCommand(const QString &cmd, NetworkType::Type nettype, QString &message) const;
|
||||||
bool startWatcher(bool testnet) const;
|
bool startWatcher(NetworkType::Type nettype) const;
|
||||||
bool stopWatcher(bool testnet) const;
|
bool stopWatcher(NetworkType::Type nettype) const;
|
||||||
signals:
|
signals:
|
||||||
void daemonStarted() const;
|
void daemonStarted() const;
|
||||||
void daemonStopped() const;
|
void daemonStopped() const;
|
||||||
|
|
|
@ -102,9 +102,9 @@ Wallet::Status Wallet::status() const
|
||||||
return static_cast<Status>(m_walletImpl->status());
|
return static_cast<Status>(m_walletImpl->status());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Wallet::testnet() const
|
NetworkType::Type Wallet::nettype() const
|
||||||
{
|
{
|
||||||
return m_walletImpl->testnet();
|
return static_cast<NetworkType::Type>(m_walletImpl->nettype());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "wallet/api/wallet2_api.h" // we need to have an access to the Monero::Wallet::Status enum here;
|
#include "wallet/api/wallet2_api.h" // we need to have an access to the Monero::Wallet::Status enum here;
|
||||||
#include "PendingTransaction.h" // we need to have an access to the PendingTransaction::Priority enum here;
|
#include "PendingTransaction.h" // we need to have an access to the PendingTransaction::Priority enum here;
|
||||||
#include "UnsignedTransaction.h"
|
#include "UnsignedTransaction.h"
|
||||||
|
#include "NetworkType.h"
|
||||||
|
|
||||||
namespace Monero {
|
namespace Monero {
|
||||||
class Wallet; // forward declaration
|
class Wallet; // forward declaration
|
||||||
|
@ -29,7 +30,7 @@ class Wallet : public QObject
|
||||||
Q_PROPERTY(QString seed READ getSeed)
|
Q_PROPERTY(QString seed READ getSeed)
|
||||||
Q_PROPERTY(QString seedLanguage READ getSeedLanguage)
|
Q_PROPERTY(QString seedLanguage READ getSeedLanguage)
|
||||||
Q_PROPERTY(Status status READ status)
|
Q_PROPERTY(Status status READ status)
|
||||||
Q_PROPERTY(bool testnet READ testnet)
|
Q_PROPERTY(NetworkType::Type nettype READ nettype)
|
||||||
// Q_PROPERTY(ConnectionStatus connected READ connected)
|
// Q_PROPERTY(ConnectionStatus connected READ connected)
|
||||||
Q_PROPERTY(quint32 currentSubaddressAccount READ currentSubaddressAccount)
|
Q_PROPERTY(quint32 currentSubaddressAccount READ currentSubaddressAccount)
|
||||||
Q_PROPERTY(bool synchronized READ synchronized)
|
Q_PROPERTY(bool synchronized READ synchronized)
|
||||||
|
@ -82,8 +83,8 @@ public:
|
||||||
//! returns last operation's status
|
//! returns last operation's status
|
||||||
Status status() const;
|
Status status() const;
|
||||||
|
|
||||||
//! returns true testnet wallet.
|
//! returns network type of the wallet.
|
||||||
bool testnet() const;
|
NetworkType::Type nettype() const;
|
||||||
|
|
||||||
//! returns whether the wallet is connected, and version status
|
//! returns whether the wallet is connected, and version status
|
||||||
Q_INVOKABLE ConnectionStatus connected(bool forceCheck = false);
|
Q_INVOKABLE ConnectionStatus connected(bool forceCheck = false);
|
||||||
|
|
|
@ -25,7 +25,7 @@ WalletManager *WalletManager::instance()
|
||||||
}
|
}
|
||||||
|
|
||||||
Wallet *WalletManager::createWallet(const QString &path, const QString &password,
|
Wallet *WalletManager::createWallet(const QString &path, const QString &password,
|
||||||
const QString &language, bool testnet)
|
const QString &language, NetworkType::Type nettype)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
if (m_currentWallet) {
|
if (m_currentWallet) {
|
||||||
|
@ -33,22 +33,22 @@ Wallet *WalletManager::createWallet(const QString &path, const QString &password
|
||||||
delete m_currentWallet;
|
delete m_currentWallet;
|
||||||
}
|
}
|
||||||
Monero::Wallet * w = m_pimpl->createWallet(path.toStdString(), password.toStdString(),
|
Monero::Wallet * w = m_pimpl->createWallet(path.toStdString(), password.toStdString(),
|
||||||
language.toStdString(), testnet);
|
language.toStdString(), static_cast<Monero::NetworkType>(nettype));
|
||||||
m_currentWallet = new Wallet(w);
|
m_currentWallet = new Wallet(w);
|
||||||
return m_currentWallet;
|
return m_currentWallet;
|
||||||
}
|
}
|
||||||
|
|
||||||
Wallet *WalletManager::openWallet(const QString &path, const QString &password, bool testnet)
|
Wallet *WalletManager::openWallet(const QString &path, const QString &password, NetworkType::Type nettype)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
if (m_currentWallet) {
|
if (m_currentWallet) {
|
||||||
qDebug() << "Closing open m_currentWallet" << m_currentWallet;
|
qDebug() << "Closing open m_currentWallet" << m_currentWallet;
|
||||||
delete m_currentWallet;
|
delete m_currentWallet;
|
||||||
}
|
}
|
||||||
qDebug("%s: opening wallet at %s, testnet = %d ",
|
qDebug("%s: opening wallet at %s, nettype = %d ",
|
||||||
__PRETTY_FUNCTION__, qPrintable(path), testnet);
|
__PRETTY_FUNCTION__, qPrintable(path), nettype);
|
||||||
|
|
||||||
Monero::Wallet * w = m_pimpl->openWallet(path.toStdString(), password.toStdString(), testnet);
|
Monero::Wallet * w = m_pimpl->openWallet(path.toStdString(), password.toStdString(), static_cast<Monero::NetworkType>(nettype));
|
||||||
qDebug("%s: opened wallet: %s, status: %d", __PRETTY_FUNCTION__, w->address(0, 0).c_str(), w->status());
|
qDebug("%s: opened wallet: %s, status: %d", __PRETTY_FUNCTION__, w->address(0, 0).c_str(), w->status());
|
||||||
m_currentWallet = new Wallet(w);
|
m_currentWallet = new Wallet(w);
|
||||||
|
|
||||||
|
@ -60,10 +60,10 @@ Wallet *WalletManager::openWallet(const QString &path, const QString &password,
|
||||||
return m_currentWallet;
|
return m_currentWallet;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletManager::openWalletAsync(const QString &path, const QString &password, bool testnet)
|
void WalletManager::openWalletAsync(const QString &path, const QString &password, NetworkType::Type nettype)
|
||||||
{
|
{
|
||||||
QFuture<Wallet*> future = QtConcurrent::run(this, &WalletManager::openWallet,
|
QFuture<Wallet*> future = QtConcurrent::run(this, &WalletManager::openWallet,
|
||||||
path, password, testnet);
|
path, password, nettype);
|
||||||
QFutureWatcher<Wallet*> * watcher = new QFutureWatcher<Wallet*>();
|
QFutureWatcher<Wallet*> * watcher = new QFutureWatcher<Wallet*>();
|
||||||
|
|
||||||
connect(watcher, &QFutureWatcher<Wallet*>::finished,
|
connect(watcher, &QFutureWatcher<Wallet*>::finished,
|
||||||
|
@ -76,19 +76,19 @@ void WalletManager::openWalletAsync(const QString &path, const QString &password
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Wallet *WalletManager::recoveryWallet(const QString &path, const QString &memo, bool testnet, quint64 restoreHeight)
|
Wallet *WalletManager::recoveryWallet(const QString &path, const QString &memo, NetworkType::Type nettype, quint64 restoreHeight)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
if (m_currentWallet) {
|
if (m_currentWallet) {
|
||||||
qDebug() << "Closing open m_currentWallet" << m_currentWallet;
|
qDebug() << "Closing open m_currentWallet" << m_currentWallet;
|
||||||
delete m_currentWallet;
|
delete m_currentWallet;
|
||||||
}
|
}
|
||||||
Monero::Wallet * w = m_pimpl->recoveryWallet(path.toStdString(), memo.toStdString(), testnet, restoreHeight);
|
Monero::Wallet * w = m_pimpl->recoveryWallet(path.toStdString(), memo.toStdString(), static_cast<Monero::NetworkType>(nettype), restoreHeight);
|
||||||
m_currentWallet = new Wallet(w);
|
m_currentWallet = new Wallet(w);
|
||||||
return m_currentWallet;
|
return m_currentWallet;
|
||||||
}
|
}
|
||||||
|
|
||||||
Wallet *WalletManager::createWalletFromKeys(const QString &path, const QString &language, bool testnet,
|
Wallet *WalletManager::createWalletFromKeys(const QString &path, const QString &language, NetworkType::Type nettype,
|
||||||
const QString &address, const QString &viewkey, const QString &spendkey,
|
const QString &address, const QString &viewkey, const QString &spendkey,
|
||||||
quint64 restoreHeight)
|
quint64 restoreHeight)
|
||||||
{
|
{
|
||||||
|
@ -98,7 +98,7 @@ Wallet *WalletManager::createWalletFromKeys(const QString &path, const QString &
|
||||||
delete m_currentWallet;
|
delete m_currentWallet;
|
||||||
m_currentWallet = NULL;
|
m_currentWallet = NULL;
|
||||||
}
|
}
|
||||||
Monero::Wallet * w = m_pimpl->createWalletFromKeys(path.toStdString(), language.toStdString(), testnet, restoreHeight,
|
Monero::Wallet * w = m_pimpl->createWalletFromKeys(path.toStdString(), language.toStdString(), static_cast<Monero::NetworkType>(nettype), restoreHeight,
|
||||||
address.toStdString(), viewkey.toStdString(), spendkey.toStdString());
|
address.toStdString(), viewkey.toStdString(), spendkey.toStdString());
|
||||||
m_currentWallet = new Wallet(w);
|
m_currentWallet = new Wallet(w);
|
||||||
return m_currentWallet;
|
return m_currentWallet;
|
||||||
|
@ -196,24 +196,24 @@ bool WalletManager::paymentIdValid(const QString &payment_id) const
|
||||||
return Monero::Wallet::paymentIdValid(payment_id.toStdString());
|
return Monero::Wallet::paymentIdValid(payment_id.toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WalletManager::addressValid(const QString &address, bool testnet) const
|
bool WalletManager::addressValid(const QString &address, NetworkType::Type nettype) const
|
||||||
{
|
{
|
||||||
return Monero::Wallet::addressValid(address.toStdString(), testnet);
|
return Monero::Wallet::addressValid(address.toStdString(), static_cast<Monero::NetworkType>(nettype));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WalletManager::keyValid(const QString &key, const QString &address, bool isViewKey, bool testnet) const
|
bool WalletManager::keyValid(const QString &key, const QString &address, bool isViewKey, NetworkType::Type nettype) const
|
||||||
{
|
{
|
||||||
std::string error;
|
std::string error;
|
||||||
if(!Monero::Wallet::keyValid(key.toStdString(), address.toStdString(), isViewKey, testnet, error)){
|
if(!Monero::Wallet::keyValid(key.toStdString(), address.toStdString(), isViewKey, static_cast<Monero::NetworkType>(nettype), error)){
|
||||||
qDebug() << QString::fromStdString(error);
|
qDebug() << QString::fromStdString(error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString WalletManager::paymentIdFromAddress(const QString &address, bool testnet) const
|
QString WalletManager::paymentIdFromAddress(const QString &address, NetworkType::Type nettype) const
|
||||||
{
|
{
|
||||||
return QString::fromStdString(Monero::Wallet::paymentIdFromAddress(address.toStdString(), testnet));
|
return QString::fromStdString(Monero::Wallet::paymentIdFromAddress(address.toStdString(), static_cast<Monero::NetworkType>(nettype)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletManager::setDaemonAddress(const QString &address)
|
void WalletManager::setDaemonAddress(const QString &address)
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <wallet/api/wallet2_api.h>
|
#include <wallet/api/wallet2_api.h>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
#include "NetworkType.h"
|
||||||
|
|
||||||
class Wallet;
|
class Wallet;
|
||||||
namespace Monero {
|
namespace Monero {
|
||||||
|
@ -32,30 +33,30 @@ public:
|
||||||
static WalletManager * instance();
|
static WalletManager * instance();
|
||||||
// wizard: createWallet path;
|
// wizard: createWallet path;
|
||||||
Q_INVOKABLE Wallet * createWallet(const QString &path, const QString &password,
|
Q_INVOKABLE Wallet * createWallet(const QString &path, const QString &password,
|
||||||
const QString &language, bool testnet = false);
|
const QString &language, NetworkType::Type nettype = NetworkType::MAINNET);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief openWallet - opens wallet by given path
|
* \brief openWallet - opens wallet by given path
|
||||||
* \param path - wallet filename
|
* \param path - wallet filename
|
||||||
* \param password - wallet password. Empty string in wallet isn't password protected
|
* \param password - wallet password. Empty string in wallet isn't password protected
|
||||||
* \param testnet - determines if we running testnet
|
* \param nettype - type of network the wallet is running on
|
||||||
* \return wallet object pointer
|
* \return wallet object pointer
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE Wallet * openWallet(const QString &path, const QString &password, bool testnet = false);
|
Q_INVOKABLE Wallet * openWallet(const QString &path, const QString &password, NetworkType::Type nettype = NetworkType::MAINNET);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief openWalletAsync - asynchronous version of "openWallet". Returns immediately. "walletOpened" signal
|
* \brief openWalletAsync - asynchronous version of "openWallet". Returns immediately. "walletOpened" signal
|
||||||
* emitted when wallet opened;
|
* emitted when wallet opened;
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE void openWalletAsync(const QString &path, const QString &password, bool testnet = false);
|
Q_INVOKABLE void openWalletAsync(const QString &path, const QString &password, NetworkType::Type nettype = NetworkType::MAINNET);
|
||||||
|
|
||||||
// wizard: recoveryWallet path; hint: internally it recorvers wallet and set password = ""
|
// wizard: recoveryWallet path; hint: internally it recorvers wallet and set password = ""
|
||||||
Q_INVOKABLE Wallet * recoveryWallet(const QString &path, const QString &memo,
|
Q_INVOKABLE Wallet * recoveryWallet(const QString &path, const QString &memo,
|
||||||
bool testnet = false, quint64 restoreHeight = 0);
|
NetworkType::Type nettype = NetworkType::MAINNET, quint64 restoreHeight = 0);
|
||||||
|
|
||||||
Q_INVOKABLE Wallet * createWalletFromKeys(const QString &path,
|
Q_INVOKABLE Wallet * createWalletFromKeys(const QString &path,
|
||||||
const QString &language,
|
const QString &language,
|
||||||
bool testnet,
|
NetworkType::Type nettype,
|
||||||
const QString &address,
|
const QString &address,
|
||||||
const QString &viewkey,
|
const QString &viewkey,
|
||||||
const QString &spendkey = "",
|
const QString &spendkey = "",
|
||||||
|
@ -99,10 +100,10 @@ public:
|
||||||
Q_INVOKABLE QString maximumAllowedAmountAsSting() const;
|
Q_INVOKABLE QString maximumAllowedAmountAsSting() const;
|
||||||
|
|
||||||
Q_INVOKABLE bool paymentIdValid(const QString &payment_id) const;
|
Q_INVOKABLE bool paymentIdValid(const QString &payment_id) const;
|
||||||
Q_INVOKABLE bool addressValid(const QString &address, bool testnet) const;
|
Q_INVOKABLE bool addressValid(const QString &address, NetworkType::Type nettype) const;
|
||||||
Q_INVOKABLE bool keyValid(const QString &key, const QString &address, bool isViewKey, bool testnet) const;
|
Q_INVOKABLE bool keyValid(const QString &key, const QString &address, bool isViewKey, NetworkType::Type nettype) const;
|
||||||
|
|
||||||
Q_INVOKABLE QString paymentIdFromAddress(const QString &address, bool testnet) const;
|
Q_INVOKABLE QString paymentIdFromAddress(const QString &address, NetworkType::Type nettype) const;
|
||||||
|
|
||||||
Q_INVOKABLE void setDaemonAddress(const QString &address);
|
Q_INVOKABLE void setDaemonAddress(const QString &address);
|
||||||
Q_INVOKABLE bool connected() const;
|
Q_INVOKABLE bool connected() const;
|
||||||
|
|
|
@ -85,9 +85,9 @@ ColumnLayout {
|
||||||
|
|
||||||
var tmp_wallet_filename = oshelper.temporaryFilename();
|
var tmp_wallet_filename = oshelper.temporaryFilename();
|
||||||
console.log("Creating temporary wallet", tmp_wallet_filename)
|
console.log("Creating temporary wallet", tmp_wallet_filename)
|
||||||
var testnet = appWindow.persistentSettings.testnet;
|
var nettype = appWindow.persistentSettings.nettype;
|
||||||
var wallet = walletManager.createWallet(tmp_wallet_filename, "", settingsObject.wallet_language,
|
var wallet = walletManager.createWallet(tmp_wallet_filename, "", settingsObject.wallet_language,
|
||||||
testnet)
|
nettype)
|
||||||
uiItem.wordsTextItem.memoText = wallet.seed
|
uiItem.wordsTextItem.memoText = wallet.seed
|
||||||
// saving wallet in "global" settings object
|
// saving wallet in "global" settings object
|
||||||
// TODO: wallet should have a property pointing to the file where it stored or loaded from
|
// TODO: wallet should have a property pointing to the file where it stored or loaded from
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
import QtQuick 2.2
|
import QtQuick 2.2
|
||||||
import QtQuick.Layouts 1.1
|
import QtQuick.Layouts 1.1
|
||||||
|
import moneroComponents.NetworkType 1.0
|
||||||
|
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
|
@ -50,8 +51,8 @@ ColumnLayout {
|
||||||
autoDonationAmount = wizard.settings["auto_donations_amount"] + " %",
|
autoDonationAmount = wizard.settings["auto_donations_amount"] + " %",
|
||||||
backgroundMiningEnabled = wizard.settings["allow_background_mining"] === true,
|
backgroundMiningEnabled = wizard.settings["allow_background_mining"] === true,
|
||||||
backgroundMiningText = backgroundMiningEnabled ? qsTr("Enabled") : qsTr("Disabled"),
|
backgroundMiningText = backgroundMiningEnabled ? qsTr("Enabled") : qsTr("Disabled"),
|
||||||
testnetEnabled = appWindow.persistentSettings.testnet,
|
nettype = appWindow.persistentSettings.nettype,
|
||||||
testnetText = testnetEnabled ? qsTr("Enabled") : qsTr("Disabled"),
|
networkText = nettype === NetworkType.TESTNET ? qsTr("Testnet") : nettype === NetworkType.STAGENET ? qsTr("Stagenet") : qsTr("Mainnet"),
|
||||||
restoreHeightEnabled = wizard.settings['restore_height'] !== undefined;
|
restoreHeightEnabled = wizard.settings['restore_height'] !== undefined;
|
||||||
|
|
||||||
return "<table>"
|
return "<table>"
|
||||||
|
@ -65,7 +66,7 @@ ColumnLayout {
|
||||||
// : "")
|
// : "")
|
||||||
// + trStart + qsTr("Background mining") + trMiddle + backgroundMiningText + trEnd
|
// + trStart + qsTr("Background mining") + trMiddle + backgroundMiningText + trEnd
|
||||||
+ trStart + qsTr("Daemon address") + trMiddle + persistentSettings.daemon_address + trEnd
|
+ trStart + qsTr("Daemon address") + trMiddle + persistentSettings.daemon_address + trEnd
|
||||||
+ trStart + qsTr("Testnet") + trMiddle + testnetText + trEnd
|
+ trStart + qsTr("Network Type") + trMiddle + networkText + trEnd
|
||||||
+ (restoreHeightEnabled
|
+ (restoreHeightEnabled
|
||||||
? trStart + qsTr("Restore height") + trMiddle + wizard.settings['restore_height'] + trEnd
|
? trStart + qsTr("Restore height") + trMiddle + wizard.settings['restore_height'] + trEnd
|
||||||
: "")
|
: "")
|
||||||
|
|
|
@ -56,10 +56,10 @@ ColumnLayout {
|
||||||
property int rowSpacing: 10
|
property int rowSpacing: 10
|
||||||
|
|
||||||
function checkFields(){
|
function checkFields(){
|
||||||
var addressOK = walletManager.addressValid(addressLine.text, persistentSettings.testnet)
|
var addressOK = walletManager.addressValid(addressLine.text, persistentSettings.nettype)
|
||||||
var viewKeyOK = walletManager.keyValid(viewKeyLine.text, addressLine.text, true, persistentSettings.testnet)
|
var viewKeyOK = walletManager.keyValid(viewKeyLine.text, addressLine.text, true, persistentSettings.nettype)
|
||||||
// Spendkey is optional
|
// Spendkey is optional
|
||||||
var spendKeyOK = (spendKeyLine.text.length > 0)? walletManager.keyValid(spendKeyLine.text, addressLine.text, false, persistentSettings.testnet) : true
|
var spendKeyOK = (spendKeyLine.text.length > 0)? walletManager.keyValid(spendKeyLine.text, addressLine.text, false, persistentSettings.nettype) : true
|
||||||
|
|
||||||
addressLine.error = !addressOK && addressLine.text.length != 0
|
addressLine.error = !addressOK && addressLine.text.length != 0
|
||||||
viewKeyLine.error = !viewKeyOK && viewKeyLine.text.length != 0
|
viewKeyLine.error = !viewKeyOK && viewKeyLine.text.length != 0
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
import QtQuick 2.2
|
import QtQuick 2.2
|
||||||
import QtQml 2.2
|
import QtQml 2.2
|
||||||
import QtQuick.Layouts 1.1
|
import QtQuick.Layouts 1.1
|
||||||
|
import moneroComponents.NetworkType 1.0
|
||||||
import "../components"
|
import "../components"
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
|
@ -231,12 +232,13 @@ ColumnLayout {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
ColumnLayout {
|
||||||
Layout.leftMargin: wizardLeftMargin
|
Layout.leftMargin: wizardLeftMargin
|
||||||
Layout.rightMargin: wizardRightMargin
|
Layout.rightMargin: wizardRightMargin
|
||||||
Layout.topMargin: 30 * scaleRatio
|
Layout.topMargin: 30 * scaleRatio
|
||||||
Layout.alignment: Qt.AlignCenter
|
Layout.alignment: Qt.AlignCenter
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
spacing: 50 * scaleRatio
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
width: 100 * scaleRatio
|
width: 100 * scaleRatio
|
||||||
|
@ -248,10 +250,30 @@ ColumnLayout {
|
||||||
fontSize: 16 * scaleRatio
|
fontSize: 16 * scaleRatio
|
||||||
checkedIcon: "../images/checkedVioletIcon.png"
|
checkedIcon: "../images/checkedVioletIcon.png"
|
||||||
uncheckedIcon: "../images/uncheckedIcon.png"
|
uncheckedIcon: "../images/uncheckedIcon.png"
|
||||||
checked: appWindow.persistentSettings.testnet;
|
checked: appWindow.persistentSettings.nettype === NetworkType.TESTNET;
|
||||||
onClicked: {
|
onClicked: {
|
||||||
persistentSettings.testnet = testNet.checked
|
persistentSettings.nettype = testNet.checked ? NetworkType.TESTNET : NetworkType.MAINNET
|
||||||
console.log("testnet set to ", persistentSettings.testnet)
|
stageNet.checked = false;
|
||||||
|
console.log("Network type set to ", persistentSettings.nettype === NetworkType.TESTNET ? "Testnet" : "Mainnet")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
width: 100 * scaleRatio
|
||||||
|
CheckBox {
|
||||||
|
id: stageNet
|
||||||
|
text: qsTr("Stagenet") + translationManager.emptyString
|
||||||
|
background: "#FFFFFF"
|
||||||
|
fontColor: "#4A4646"
|
||||||
|
fontSize: 16 * scaleRatio
|
||||||
|
checkedIcon: "../images/checkedVioletIcon.png"
|
||||||
|
uncheckedIcon: "../images/uncheckedIcon.png"
|
||||||
|
checked: appWindow.persistentSettings.nettype === NetworkType.STAGENET;
|
||||||
|
onClicked: {
|
||||||
|
persistentSettings.nettype = stageNet.checked ? NetworkType.STAGENET : NetworkType.MAINNET
|
||||||
|
testNet.checked = false;
|
||||||
|
console.log("Network type set to ", persistentSettings.nettype === NetworkType.STAGENET ? "Stagenet" : "Mainnet")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ ColumnLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
function recoveryWallet(settingsObject, fromSeed) {
|
function recoveryWallet(settingsObject, fromSeed) {
|
||||||
var testnet = appWindow.persistentSettings.testnet;
|
var nettype = appWindow.persistentSettings.nettype;
|
||||||
var restoreHeight = settingsObject.restore_height;
|
var restoreHeight = settingsObject.restore_height;
|
||||||
var tmp_wallet_filename = oshelper.temporaryFilename()
|
var tmp_wallet_filename = oshelper.temporaryFilename()
|
||||||
console.log("Creating temporary wallet", tmp_wallet_filename)
|
console.log("Creating temporary wallet", tmp_wallet_filename)
|
||||||
|
@ -89,9 +89,9 @@ ColumnLayout {
|
||||||
|
|
||||||
// From seed or keys
|
// From seed or keys
|
||||||
if(fromSeed)
|
if(fromSeed)
|
||||||
var wallet = walletManager.recoveryWallet(tmp_wallet_filename, settingsObject.words, testnet, restoreHeight)
|
var wallet = walletManager.recoveryWallet(tmp_wallet_filename, settingsObject.words, nettype, restoreHeight)
|
||||||
else
|
else
|
||||||
var wallet = walletManager.createWalletFromKeys(tmp_wallet_filename, settingsObject.wallet_language, testnet,
|
var wallet = walletManager.createWalletFromKeys(tmp_wallet_filename, settingsObject.wallet_language, nettype,
|
||||||
settingsObject.recover_address, settingsObject.recover_viewkey,
|
settingsObject.recover_address, settingsObject.recover_viewkey,
|
||||||
settingsObject.recover_spendkey, restoreHeight)
|
settingsObject.recover_spendkey, restoreHeight)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue