mirror of
https://github.com/monero-project/monero-gui.git
synced 2025-01-09 12:30:10 +00:00
Async API integration in progress
This commit is contained in:
parent
c027922cb7
commit
d9f031ec2a
4 changed files with 88 additions and 9 deletions
1
main.cpp
1
main.cpp
|
@ -56,6 +56,7 @@ int main(int argc, char *argv[])
|
||||||
qmlRegisterUncreatableType<Wallet>("Bitmonero.Wallet", 1, 0, "Wallet", "Wallet can't be instantiated directly");
|
qmlRegisterUncreatableType<Wallet>("Bitmonero.Wallet", 1, 0, "Wallet", "Wallet can't be instantiated directly");
|
||||||
qmlRegisterUncreatableType<PendingTransaction>("Bitmonero.PendingTransaction", 1, 0, "PendingTransaction",
|
qmlRegisterUncreatableType<PendingTransaction>("Bitmonero.PendingTransaction", 1, 0, "PendingTransaction",
|
||||||
"PendingTransaction can't be instantiated directly");
|
"PendingTransaction can't be instantiated directly");
|
||||||
|
|
||||||
qRegisterMetaType<PendingTransaction::Priority>();
|
qRegisterMetaType<PendingTransaction::Priority>();
|
||||||
|
|
||||||
|
|
||||||
|
|
43
main.qml
43
main.qml
|
@ -35,6 +35,7 @@ import Qt.labs.settings 1.0
|
||||||
import Bitmonero.Wallet 1.0
|
import Bitmonero.Wallet 1.0
|
||||||
import Bitmonero.PendingTransaction 1.0
|
import Bitmonero.PendingTransaction 1.0
|
||||||
|
|
||||||
|
|
||||||
import "components"
|
import "components"
|
||||||
import "wizard"
|
import "wizard"
|
||||||
|
|
||||||
|
@ -50,6 +51,7 @@ ApplicationWindow {
|
||||||
property var wallet;
|
property var wallet;
|
||||||
property var transaction;
|
property var transaction;
|
||||||
|
|
||||||
|
|
||||||
function altKeyReleased() { ctrlPressed = false; }
|
function altKeyReleased() { ctrlPressed = false; }
|
||||||
|
|
||||||
function showPageRequest(page) {
|
function showPageRequest(page) {
|
||||||
|
@ -122,7 +124,7 @@ ApplicationWindow {
|
||||||
|
|
||||||
|
|
||||||
function initialize() {
|
function initialize() {
|
||||||
|
console.log("initializing..")
|
||||||
middlePanel.paymentClicked.connect(handlePayment);
|
middlePanel.paymentClicked.connect(handlePayment);
|
||||||
|
|
||||||
if (typeof wizard.settings['wallet'] !== 'undefined') {
|
if (typeof wizard.settings['wallet'] !== 'undefined') {
|
||||||
|
@ -143,24 +145,34 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
console.log("Wallet opened successfully: ", wallet.errorString);
|
console.log("Wallet opened successfully: ", wallet.errorString);
|
||||||
}
|
}
|
||||||
|
// display splash screen...
|
||||||
|
|
||||||
|
console.log("initializing with daemon address..")
|
||||||
if (!wallet.init(persistentSettings.daemon_address, 0)) {
|
if (!wallet.init(persistentSettings.daemon_address, 0)) {
|
||||||
console.log("Error initialize wallet: ", wallet.errorString);
|
console.log("Error initialize wallet: ", wallet.errorString);
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
console.log("Wallet initialized successfully")
|
||||||
|
// TODO: update network indicator
|
||||||
|
|
||||||
// subscribing for wallet updates
|
// subscribing for wallet updates
|
||||||
wallet.updated.connect(onWalletUpdate);
|
wallet.updated.connect(onWalletUpdate);
|
||||||
|
wallet.refreshed.connect(onWalletRefresh);
|
||||||
|
console.log("refreshing wallet async")
|
||||||
// TODO: refresh asynchronously without blocking UI, implement signal(s)
|
// TODO: refresh asynchronously without blocking UI, implement signal(s)
|
||||||
wallet.refresh();
|
wallet.refreshAsync();
|
||||||
|
|
||||||
console.log("wallet balance: ", wallet.balance)
|
console.log("wallet balance: ", wallet.balance)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onWalletUpdate() {
|
function onWalletUpdate() {
|
||||||
console.log("wallet updated")
|
console.log(">>> wallet updated")
|
||||||
|
leftPanel.unlockedBalanceText = walletManager.displayAmount(wallet.unlockedBalance);
|
||||||
|
leftPanel.balanceText = walletManager.displayAmount(wallet.balance);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onWalletRefresh() {
|
||||||
|
console.log(">>> wallet refreshed")
|
||||||
leftPanel.unlockedBalanceText = walletManager.displayAmount(wallet.unlockedBalance);
|
leftPanel.unlockedBalanceText = walletManager.displayAmount(wallet.unlockedBalance);
|
||||||
leftPanel.balanceText = walletManager.displayAmount(wallet.balance);
|
leftPanel.balanceText = walletManager.displayAmount(wallet.balance);
|
||||||
}
|
}
|
||||||
|
@ -206,10 +218,10 @@ ApplicationWindow {
|
||||||
|
|
||||||
transactionConfirmationPopup.title = qsTr("Confirmation")
|
transactionConfirmationPopup.title = qsTr("Confirmation")
|
||||||
transactionConfirmationPopup.text = qsTr("Please confirm transaction:\n\n")
|
transactionConfirmationPopup.text = qsTr("Please confirm transaction:\n\n")
|
||||||
+ "\nAddress: " + address
|
+ qsTr("\nAddress: ") + address
|
||||||
+ "\nPayment ID: " + paymentId
|
+ qsTr("\nPayment ID: ") + paymentId
|
||||||
+ "\nAmount: " + walletManager.displayAmount(transaction.amount)
|
+ qsTr("\nAmount: ") + walletManager.displayAmount(transaction.amount)
|
||||||
+ "\nFee: " + walletManager.displayAmount(transaction.fee)
|
+ qsTr("\nFee: ") + walletManager.displayAmount(transaction.fee)
|
||||||
transactionConfirmationPopup.icon = StandardIcon.Question
|
transactionConfirmationPopup.icon = StandardIcon.Question
|
||||||
transactionConfirmationPopup.open()
|
transactionConfirmationPopup.open()
|
||||||
// committing transaction
|
// committing transaction
|
||||||
|
@ -288,6 +300,19 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Window {
|
||||||
|
id: walletInitializationSplash
|
||||||
|
modality: Qt.ApplicationModal
|
||||||
|
flags: Qt.SplashScreen
|
||||||
|
height: 100
|
||||||
|
width: 250
|
||||||
|
Text {
|
||||||
|
anchors.fill: parent
|
||||||
|
text: qsTr("Initializing Wallet...");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: rootItem
|
id: rootItem
|
||||||
|
|
|
@ -14,6 +14,45 @@ namespace {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class WalletListenerImpl : public Bitmonero::WalletListener
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WalletListenerImpl(Wallet * w)
|
||||||
|
: m_wallet(w)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void moneySpent(const std::string &txId, uint64_t amount)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
Q_UNUSED(txId)
|
||||||
|
Q_UNUSED(amount)
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void moneyReceived(const std::string &txId, uint64_t amount)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
Q_UNUSED(txId)
|
||||||
|
Q_UNUSED(amount)
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void updated()
|
||||||
|
{
|
||||||
|
emit m_wallet->updated();
|
||||||
|
}
|
||||||
|
|
||||||
|
// called when wallet refreshed by background thread or explicitly
|
||||||
|
virtual void refreshed()
|
||||||
|
{
|
||||||
|
emit m_wallet->refreshed();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Wallet * m_wallet;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QString Wallet::getSeed() const
|
QString Wallet::getSeed() const
|
||||||
{
|
{
|
||||||
|
@ -88,6 +127,11 @@ bool Wallet::refresh()
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Wallet::refreshAsync()
|
||||||
|
{
|
||||||
|
m_walletImpl->refreshAsync();
|
||||||
|
}
|
||||||
|
|
||||||
PendingTransaction *Wallet::createTransaction(const QString &dst_addr, const QString &payment_id,
|
PendingTransaction *Wallet::createTransaction(const QString &dst_addr, const QString &payment_id,
|
||||||
quint64 amount, quint32 mixin_count,
|
quint64 amount, quint32 mixin_count,
|
||||||
PendingTransaction::Priority priority)
|
PendingTransaction::Priority priority)
|
||||||
|
|
|
@ -77,6 +77,10 @@ public:
|
||||||
//! refreshes the wallet
|
//! refreshes the wallet
|
||||||
Q_INVOKABLE bool refresh();
|
Q_INVOKABLE bool refresh();
|
||||||
|
|
||||||
|
|
||||||
|
//! refreshes the wallet asynchronously
|
||||||
|
Q_INVOKABLE void refreshAsync();
|
||||||
|
|
||||||
//! creates transaction
|
//! creates transaction
|
||||||
Q_INVOKABLE PendingTransaction * createTransaction(const QString &dst_addr, const QString &payment_id,
|
Q_INVOKABLE PendingTransaction * createTransaction(const QString &dst_addr, const QString &payment_id,
|
||||||
quint64 amount, quint32 mixin_count,
|
quint64 amount, quint32 mixin_count,
|
||||||
|
@ -103,6 +107,10 @@ public:
|
||||||
signals:
|
signals:
|
||||||
void updated();
|
void updated();
|
||||||
|
|
||||||
|
// emitted when refresh process finished (could take a long time)
|
||||||
|
// signalling only after we
|
||||||
|
void refreshed();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Wallet(Bitmonero::Wallet *w, QObject * parent = 0);
|
Wallet(Bitmonero::Wallet *w, QObject * parent = 0);
|
||||||
|
@ -110,6 +118,7 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class WalletManager;
|
friend class WalletManager;
|
||||||
|
friend class WalletListenerImpl;
|
||||||
//! libwallet's
|
//! libwallet's
|
||||||
Bitmonero::Wallet * m_walletImpl;
|
Bitmonero::Wallet * m_walletImpl;
|
||||||
// history lifetime managed by wallet;
|
// history lifetime managed by wallet;
|
||||||
|
|
Loading…
Reference in a new issue