1
mirror of https://github.com/monero-project/monero-gui synced 2024-12-20 04:15:53 +01:00

Merge pull request #115

d95e4a3 Write support for tx notes (moneromooo.monero)
This commit is contained in:
Riccardo Spagni 2016-11-09 20:42:44 +02:00
commit 60b65b9bcc
No known key found for this signature in database
GPG Key ID: 55432DF31CCD4FCD
8 changed files with 56 additions and 9 deletions

View File

@ -47,13 +47,13 @@ Rectangle {
property alias unlockedBalanceText : availableBalanceText.text;
// repeating signal to the outside world
signal paymentClicked(string address, string paymentId, double amount, int mixinCount,
int priority)
int priority, string description)
Connections {
target: transferBasic
onPaymentClicked: {
console.log("BasicPanel: paymentClicked")
root.paymentClicked(address, paymentId, amount, mixinCount, priority)
root.paymentClicked(address, paymentId, amount, mixinCount, priority, description)
}
}

View File

@ -50,7 +50,7 @@ Rectangle {
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 checkPaymentClicked(string address, string txid, string txkey);
@ -302,7 +302,7 @@ Rectangle {
target: transferView
onPaymentClicked : {
console.log("MiddlePanel: paymentClicked")
paymentClicked(address, paymentId, amount, mixinCount, priority)
paymentClicked(address, paymentId, amount, mixinCount, priority, description)
}
}
}

View File

@ -52,6 +52,7 @@ ApplicationWindow {
property alias persistentSettings : persistentSettings
property var currentWallet;
property var transaction;
property var transactionDescription;
property alias password : passwordDialog.password
property int splashCounter: 0
property bool isNewWallet: false
@ -347,13 +348,14 @@ ApplicationWindow {
// called on "transfer"
function handlePayment(address, paymentId, amount, mixinCount, priority) {
function handlePayment(address, paymentId, amount, mixinCount, priority, description) {
console.log("Creating transaction: ")
console.log("\taddress: ", address,
", payment_id: ", paymentId,
", amount: ", amount,
", mixins: ", mixinCount,
", priority: ", priority);
", priority: ", priority,
", description: ", description);
// validate amount;
@ -399,6 +401,8 @@ ApplicationWindow {
console.log("Transaction created, amount: " + walletManager.displayAmount(transaction.amount)
+ ", fee: " + walletManager.displayAmount(transaction.fee));
transactionDescription = description;
// here we show confirmation popup;
transactionConfirmationPopup.title = qsTr("Confirmation") + translationManager.emptyString
@ -408,6 +412,7 @@ ApplicationWindow {
+ qsTr("\n\nAmount: ") + walletManager.displayAmount(transaction.amount)
+ qsTr("\nFee: ") + walletManager.displayAmount(transaction.fee)
+ qsTr("\n\nMixin: ") + mixinCount
+ qsTr("\n\nDescription: ") + description
+ translationManager.emptyString
transactionConfirmationPopup.icon = StandardIcon.Question
transactionConfirmationPopup.open()
@ -417,6 +422,16 @@ ApplicationWindow {
// called after user confirms transaction
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()) {
console.log("Error committing transaction: " + transaction.errorString);
informationPopup.title = qsTr("Error") + translationManager.emptyString
@ -424,8 +439,17 @@ ApplicationWindow {
informationPopup.icon = StandardIcon.Critical
} else {
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
if (transactionDescription.length > 0) {
for (var i = 0; i < txid.length; ++i)
currentWallet.setUserNote(txid[i], transactionDescription);
}
}
informationPopup.onCloseCallback = null
informationPopup.open()

View File

@ -34,7 +34,7 @@ import "../components"
Rectangle {
id: root
signal paymentClicked(string address, string paymentId, double amount, int mixinCount,
int priority)
int priority, string description)
color: "#F0EEEE"
@ -277,7 +277,7 @@ Rectangle {
addressLine.text = addressLine.text.trim()
paymentIdLine.text = paymentIdLine.text.trim()
root.paymentClicked(addressLine.text, paymentIdLine.text, amountLine.text, scaleValueToMixinCount(privacyLevelItem.fillLevel),
priority)
priority, descriptionLine.text)
}
}

View File

@ -31,6 +31,15 @@ quint64 PendingTransaction::fee() const
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)
: QObject(parent), m_pimpl(pt)
{

View File

@ -17,6 +17,7 @@ class PendingTransaction : public QObject
Q_PROPERTY(quint64 amount READ amount)
Q_PROPERTY(quint64 dust READ dust)
Q_PROPERTY(quint64 fee READ fee)
Q_PROPERTY(QList<QString> txid READ txid)
public:
enum Status {
@ -39,6 +40,7 @@ public:
quint64 amount() const;
quint64 dust() const;
quint64 fee() const;
QList<QString> txid() const;
private:
explicit PendingTransaction(Bitmonero::PendingTransaction * pt, QObject *parent = 0);

View File

@ -260,6 +260,15 @@ void Wallet::setPaymentId(const QString &paymentId)
m_paymentId = paymentId;
}
bool Wallet::setUserNote(const QString &txid, const QString &note)
{
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)
: QObject(parent)

View File

@ -138,6 +138,9 @@ public:
void setPaymentId(const QString &paymentId);
Q_INVOKABLE bool setUserNote(const QString &txid, const QString &note);
Q_INVOKABLE QString getUserNote(const QString &txid) const;
// TODO: setListenter() when it implemented in API
signals:
// emitted on every event happened with wallet