mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-11-16 15:58:11 +00:00
Write support for tx notes
Support still needs adding for displaying them in the history, but at least they're saved in the cache now, and not ignored.
This commit is contained in:
parent
c9bb2f5718
commit
d95e4a37cf
8 changed files with 56 additions and 9 deletions
|
@ -47,13 +47,13 @@ Rectangle {
|
||||||
property alias unlockedBalanceText : availableBalanceText.text;
|
property alias unlockedBalanceText : availableBalanceText.text;
|
||||||
// repeating signal to the outside world
|
// repeating signal to the outside world
|
||||||
signal paymentClicked(string address, string paymentId, double amount, int mixinCount,
|
signal paymentClicked(string address, string paymentId, double amount, int mixinCount,
|
||||||
int priority)
|
int priority, string description)
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: transferBasic
|
target: transferBasic
|
||||||
onPaymentClicked: {
|
onPaymentClicked: {
|
||||||
console.log("BasicPanel: paymentClicked")
|
console.log("BasicPanel: paymentClicked")
|
||||||
root.paymentClicked(address, paymentId, amount, mixinCount, priority)
|
root.paymentClicked(address, paymentId, amount, mixinCount, priority, description)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ Rectangle {
|
||||||
property Settings settingsView: Settings { }
|
property Settings settingsView: Settings { }
|
||||||
|
|
||||||
|
|
||||||
signal paymentClicked(string address, string paymentId, double amount, int mixinCount, int priority)
|
signal paymentClicked(string address, string paymentId, double amount, int mixinCount, int priority, string description)
|
||||||
signal generatePaymentIdInvoked()
|
signal generatePaymentIdInvoked()
|
||||||
|
|
||||||
// Disable transfer page if daemon isnt fully synced
|
// Disable transfer page if daemon isnt fully synced
|
||||||
|
@ -297,7 +297,7 @@ Rectangle {
|
||||||
target: transferView
|
target: transferView
|
||||||
onPaymentClicked : {
|
onPaymentClicked : {
|
||||||
console.log("MiddlePanel: paymentClicked")
|
console.log("MiddlePanel: paymentClicked")
|
||||||
paymentClicked(address, paymentId, amount, mixinCount, priority)
|
paymentClicked(address, paymentId, amount, mixinCount, priority, description)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
30
main.qml
30
main.qml
|
@ -52,6 +52,7 @@ ApplicationWindow {
|
||||||
property alias persistentSettings : persistentSettings
|
property alias persistentSettings : persistentSettings
|
||||||
property var currentWallet;
|
property var currentWallet;
|
||||||
property var transaction;
|
property var transaction;
|
||||||
|
property var transactionDescription;
|
||||||
property alias password : passwordDialog.password
|
property alias password : passwordDialog.password
|
||||||
property int splashCounter: 0
|
property int splashCounter: 0
|
||||||
property bool isNewWallet: false
|
property bool isNewWallet: false
|
||||||
|
@ -346,13 +347,14 @@ ApplicationWindow {
|
||||||
|
|
||||||
|
|
||||||
// called on "transfer"
|
// called on "transfer"
|
||||||
function handlePayment(address, paymentId, amount, mixinCount, priority) {
|
function handlePayment(address, paymentId, amount, mixinCount, priority, description) {
|
||||||
console.log("Creating transaction: ")
|
console.log("Creating transaction: ")
|
||||||
console.log("\taddress: ", address,
|
console.log("\taddress: ", address,
|
||||||
", payment_id: ", paymentId,
|
", payment_id: ", paymentId,
|
||||||
", amount: ", amount,
|
", amount: ", amount,
|
||||||
", mixins: ", mixinCount,
|
", mixins: ", mixinCount,
|
||||||
", priority: ", priority);
|
", priority: ", priority,
|
||||||
|
", description: ", description);
|
||||||
|
|
||||||
|
|
||||||
// validate amount;
|
// validate amount;
|
||||||
|
@ -398,6 +400,8 @@ ApplicationWindow {
|
||||||
console.log("Transaction created, amount: " + walletManager.displayAmount(transaction.amount)
|
console.log("Transaction created, amount: " + walletManager.displayAmount(transaction.amount)
|
||||||
+ ", fee: " + walletManager.displayAmount(transaction.fee));
|
+ ", fee: " + walletManager.displayAmount(transaction.fee));
|
||||||
|
|
||||||
|
transactionDescription = description;
|
||||||
|
|
||||||
// here we show confirmation popup;
|
// here we show confirmation popup;
|
||||||
|
|
||||||
transactionConfirmationPopup.title = qsTr("Confirmation") + translationManager.emptyString
|
transactionConfirmationPopup.title = qsTr("Confirmation") + translationManager.emptyString
|
||||||
|
@ -407,6 +411,7 @@ ApplicationWindow {
|
||||||
+ qsTr("\n\nAmount: ") + walletManager.displayAmount(transaction.amount)
|
+ qsTr("\n\nAmount: ") + walletManager.displayAmount(transaction.amount)
|
||||||
+ qsTr("\nFee: ") + walletManager.displayAmount(transaction.fee)
|
+ qsTr("\nFee: ") + walletManager.displayAmount(transaction.fee)
|
||||||
+ qsTr("\n\nMixin: ") + mixinCount
|
+ qsTr("\n\nMixin: ") + mixinCount
|
||||||
|
+ qsTr("\n\nDescription: ") + description
|
||||||
+ translationManager.emptyString
|
+ translationManager.emptyString
|
||||||
transactionConfirmationPopup.icon = StandardIcon.Question
|
transactionConfirmationPopup.icon = StandardIcon.Question
|
||||||
transactionConfirmationPopup.open()
|
transactionConfirmationPopup.open()
|
||||||
|
@ -416,6 +421,16 @@ ApplicationWindow {
|
||||||
|
|
||||||
// called after user confirms transaction
|
// called after user confirms transaction
|
||||||
function handleTransactionConfirmed() {
|
function handleTransactionConfirmed() {
|
||||||
|
// grab transaction.txid before commit, since it clears it.
|
||||||
|
// we actually need to copy it, because QML will incredibly
|
||||||
|
// call the function multiple times when the variable is used
|
||||||
|
// after commit, where it returns another result...
|
||||||
|
// Of course, this loop is also calling the function multiple
|
||||||
|
// times, but at least with the same result.
|
||||||
|
var txid = [], txid_org = transaction.txid, txid_text = ""
|
||||||
|
for (var i = 0; i < txid_org.length; ++i)
|
||||||
|
txid[i] = txid_org[i]
|
||||||
|
|
||||||
if (!transaction.commit()) {
|
if (!transaction.commit()) {
|
||||||
console.log("Error committing transaction: " + transaction.errorString);
|
console.log("Error committing transaction: " + transaction.errorString);
|
||||||
informationPopup.title = qsTr("Error") + translationManager.emptyString
|
informationPopup.title = qsTr("Error") + translationManager.emptyString
|
||||||
|
@ -423,8 +438,17 @@ ApplicationWindow {
|
||||||
informationPopup.icon = StandardIcon.Critical
|
informationPopup.icon = StandardIcon.Critical
|
||||||
} else {
|
} else {
|
||||||
informationPopup.title = qsTr("Information") + translationManager.emptyString
|
informationPopup.title = qsTr("Information") + translationManager.emptyString
|
||||||
informationPopup.text = qsTr("Money sent successfully") + translationManager.emptyString
|
for (var i = 0; i < txid.length; ++i) {
|
||||||
|
if (txid_text.length > 0)
|
||||||
|
txid_text += ", "
|
||||||
|
txid_text += txid[i]
|
||||||
|
}
|
||||||
|
informationPopup.text = qsTr("Money sent successfully: %1 transaction(s) ").arg(txid.length) + txid_text + translationManager.emptyString
|
||||||
informationPopup.icon = StandardIcon.Information
|
informationPopup.icon = StandardIcon.Information
|
||||||
|
if (transactionDescription.length > 0) {
|
||||||
|
for (var i = 0; i < txid.length; ++i)
|
||||||
|
currentWallet.setUserNote(txid[i], transactionDescription);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
informationPopup.onCloseCallback = null
|
informationPopup.onCloseCallback = null
|
||||||
informationPopup.open()
|
informationPopup.open()
|
||||||
|
|
|
@ -34,7 +34,7 @@ import "../components"
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: root
|
id: root
|
||||||
signal paymentClicked(string address, string paymentId, double amount, int mixinCount,
|
signal paymentClicked(string address, string paymentId, double amount, int mixinCount,
|
||||||
int priority)
|
int priority, string description)
|
||||||
|
|
||||||
color: "#F0EEEE"
|
color: "#F0EEEE"
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ Rectangle {
|
||||||
addressLine.text = addressLine.text.trim()
|
addressLine.text = addressLine.text.trim()
|
||||||
paymentIdLine.text = paymentIdLine.text.trim()
|
paymentIdLine.text = paymentIdLine.text.trim()
|
||||||
root.paymentClicked(addressLine.text, paymentIdLine.text, amountLine.text, scaleValueToMixinCount(privacyLevelItem.fillLevel),
|
root.paymentClicked(addressLine.text, paymentIdLine.text, amountLine.text, scaleValueToMixinCount(privacyLevelItem.fillLevel),
|
||||||
priority)
|
priority, descriptionLine.text)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,15 @@ quint64 PendingTransaction::fee() const
|
||||||
return m_pimpl->fee();
|
return m_pimpl->fee();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<QString> PendingTransaction::txid() const
|
||||||
|
{
|
||||||
|
QList<QString> list;
|
||||||
|
std::vector<std::string> txid = m_pimpl->txid();
|
||||||
|
for (const auto &t: txid)
|
||||||
|
list.append(QString::fromStdString(t));
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
PendingTransaction::PendingTransaction(Bitmonero::PendingTransaction *pt, QObject *parent)
|
PendingTransaction::PendingTransaction(Bitmonero::PendingTransaction *pt, QObject *parent)
|
||||||
: QObject(parent), m_pimpl(pt)
|
: QObject(parent), m_pimpl(pt)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,6 +17,7 @@ class PendingTransaction : public QObject
|
||||||
Q_PROPERTY(quint64 amount READ amount)
|
Q_PROPERTY(quint64 amount READ amount)
|
||||||
Q_PROPERTY(quint64 dust READ dust)
|
Q_PROPERTY(quint64 dust READ dust)
|
||||||
Q_PROPERTY(quint64 fee READ fee)
|
Q_PROPERTY(quint64 fee READ fee)
|
||||||
|
Q_PROPERTY(QList<QString> txid READ txid)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Status {
|
enum Status {
|
||||||
|
@ -39,6 +40,7 @@ public:
|
||||||
quint64 amount() const;
|
quint64 amount() const;
|
||||||
quint64 dust() const;
|
quint64 dust() const;
|
||||||
quint64 fee() const;
|
quint64 fee() const;
|
||||||
|
QList<QString> txid() const;
|
||||||
private:
|
private:
|
||||||
explicit PendingTransaction(Bitmonero::PendingTransaction * pt, QObject *parent = 0);
|
explicit PendingTransaction(Bitmonero::PendingTransaction * pt, QObject *parent = 0);
|
||||||
|
|
||||||
|
|
|
@ -260,6 +260,15 @@ void Wallet::setPaymentId(const QString &paymentId)
|
||||||
m_paymentId = paymentId;
|
m_paymentId = paymentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Wallet::setUserNote(const QString &txid, const QString ¬e)
|
||||||
|
{
|
||||||
|
return m_walletImpl->setUserNote(txid.toStdString(), note.toStdString());
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Wallet::getUserNote(const QString &txid) const
|
||||||
|
{
|
||||||
|
return QString::fromStdString(m_walletImpl->getUserNote(txid.toStdString()));
|
||||||
|
}
|
||||||
|
|
||||||
Wallet::Wallet(Bitmonero::Wallet *w, QObject *parent)
|
Wallet::Wallet(Bitmonero::Wallet *w, QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
|
|
|
@ -138,6 +138,9 @@ public:
|
||||||
|
|
||||||
void setPaymentId(const QString &paymentId);
|
void setPaymentId(const QString &paymentId);
|
||||||
|
|
||||||
|
Q_INVOKABLE bool setUserNote(const QString &txid, const QString ¬e);
|
||||||
|
Q_INVOKABLE QString getUserNote(const QString &txid) const;
|
||||||
|
|
||||||
// TODO: setListenter() when it implemented in API
|
// TODO: setListenter() when it implemented in API
|
||||||
signals:
|
signals:
|
||||||
// emitted on every event happened with wallet
|
// emitted on every event happened with wallet
|
||||||
|
|
Loading…
Reference in a new issue