Add a button to sweep unmixable outputs

This commit is contained in:
moneromooo.monero 2016-11-08 20:23:50 +00:00
parent b8ea2ffc74
commit 2143392b84
5 changed files with 77 additions and 2 deletions

View file

@ -52,6 +52,7 @@ Rectangle {
signal paymentClicked(string address, string paymentId, string amount, int mixinCount, int priority, string description) signal paymentClicked(string address, string paymentId, string amount, int mixinCount, int priority, string description)
signal sweepUnmixableClicked()
signal generatePaymentIdInvoked() signal generatePaymentIdInvoked()
signal checkPaymentClicked(string address, string txid, string txkey); signal checkPaymentClicked(string address, string txid, string txkey);
@ -308,5 +309,9 @@ Rectangle {
console.log("MiddlePanel: paymentClicked") console.log("MiddlePanel: paymentClicked")
paymentClicked(address, paymentId, amount, mixinCount, priority, description) paymentClicked(address, paymentId, amount, mixinCount, priority, description)
} }
onSweepUnmixableClicked : {
console.log("MiddlePanel: sweepUnmixableClicked")
sweepUnmixableClicked()
}
} }
} }

View file

@ -157,6 +157,7 @@ ApplicationWindow {
middlePanel.checkPaymentClicked.disconnect(handleCheckPayment); middlePanel.checkPaymentClicked.disconnect(handleCheckPayment);
} }
middlePanel.paymentClicked.connect(handlePayment); middlePanel.paymentClicked.connect(handlePayment);
middlePanel.sweepUnmixableClicked.connect(handleSweepUnmixable);
// basicPanel.paymentClicked.connect(handlePayment); // basicPanel.paymentClicked.connect(handlePayment);
middlePanel.checkPaymentClicked.connect(handleCheckPayment); middlePanel.checkPaymentClicked.connect(handleCheckPayment);
@ -451,6 +452,45 @@ ApplicationWindow {
currentWallet.createTransactionAsync(address, paymentId, amountxmr, mixinCount, priority); currentWallet.createTransactionAsync(address, paymentId, amountxmr, mixinCount, priority);
} }
function handleSweepUnmixable() {
console.log("Creating transaction: ")
transaction = currentWallet.createSweepUnmixableTransaction();
if (transaction.status !== PendingTransaction.Status_Ok) {
console.error("Can't create transaction: ", transaction.errorString);
informationPopup.title = qsTr("Error") + translationManager.emptyString;
informationPopup.text = qsTr("Can't create transaction: ") + transaction.errorString
informationPopup.icon = StandardIcon.Critical
informationPopup.onCloseCallback = null
informationPopup.open();
// deleting transaction object, we don't want memleaks
currentWallet.disposeTransaction(transaction);
} else if (transaction.txCount == 0) {
informationPopup.title = qsTr("No unmixable outputs to sweep") + translationManager.emptyString
informationPopup.text = qsTr("No unmixable outputs to sweep") + translationManager.emptyString
informationPopup.icon = StandardIcon.Information
informationPopup.onCloseCallback = null
informationPopup.open()
// deleting transaction object, we don't want memleaks
currentWallet.disposeTransaction(transaction);
} else {
console.log("Transaction created, amount: " + walletManager.displayAmount(transaction.amount)
+ ", fee: " + walletManager.displayAmount(transaction.fee));
// here we show confirmation popup;
transactionConfirmationPopup.title = qsTr("Confirmation") + translationManager.emptyString
transactionConfirmationPopup.text = qsTr("Please confirm transaction:\n")
+ qsTr("\n\nAmount: ") + walletManager.displayAmount(transaction.amount)
+ qsTr("\nFee: ") + walletManager.displayAmount(transaction.fee)
+ translationManager.emptyString
transactionConfirmationPopup.icon = StandardIcon.Question
transactionConfirmationPopup.open()
// committing transaction
}
}
// called after user confirms transaction // called after user confirms transaction
function handleTransactionConfirmed() { function handleTransactionConfirmed() {
// grab transaction.txid before commit, since it clears it. // grab transaction.txid before commit, since it clears it.

View file

@ -35,6 +35,7 @@ Rectangle {
id: root id: root
signal paymentClicked(string address, string paymentId, string amount, int mixinCount, signal paymentClicked(string address, string paymentId, string amount, int mixinCount,
int priority, string description) int priority, string description)
signal sweepUnmixableClicked()
color: "#F0EEEE" color: "#F0EEEE"
@ -295,4 +296,24 @@ Rectangle {
} }
} }
StandardButton {
id: sweepUnmixableButton
anchors.right: parent.right
anchors.top: descriptionLine.bottom
anchors.rightMargin: 17
anchors.topMargin: 17
width: 60*2
text: qsTr("SWEEP UNMIXABLE") + translationManager.emptyString
shadowReleasedColor: "#FF4304"
shadowPressedColor: "#B32D00"
releasedColor: "#FF6C3C"
pressedColor: "#FF4304"
enabled : true
onClicked: {
console.log("Transfer: sweepUnmixableClicked")
root.sweepUnmixableClicked()
}
}
} }

View file

@ -216,7 +216,6 @@ PendingTransaction *Wallet::createTransaction(const QString &dst_addr, const QSt
return result; return result;
} }
void Wallet::createTransactionAsync(const QString &dst_addr, const QString &payment_id, void Wallet::createTransactionAsync(const QString &dst_addr, const QString &payment_id,
quint64 amount, quint32 mixin_count, quint64 amount, quint32 mixin_count,
PendingTransaction::Priority priority) PendingTransaction::Priority priority)
@ -233,7 +232,12 @@ void Wallet::createTransactionAsync(const QString &dst_addr, const QString &paym
}); });
} }
PendingTransaction *Wallet::createSweepUnmixableTransaction()
{
Bitmonero::PendingTransaction * ptImpl = m_walletImpl->createSweepUnmixableTransaction();
PendingTransaction * result = new PendingTransaction(ptImpl, this);
return result;
}
void Wallet::disposeTransaction(PendingTransaction *t) void Wallet::disposeTransaction(PendingTransaction *t)
{ {

View file

@ -130,6 +130,11 @@ public:
Q_INVOKABLE void createTransactionAsync(const QString &dst_addr, const QString &payment_id, Q_INVOKABLE void createTransactionAsync(const QString &dst_addr, const QString &payment_id,
quint64 amount, quint32 mixin_count, quint64 amount, quint32 mixin_count,
PendingTransaction::Priority priority); PendingTransaction::Priority priority);
//
//! creates sweep unmixable transaction
Q_INVOKABLE PendingTransaction * createSweepUnmixableTransaction();
//! deletes transaction and frees memory //! deletes transaction and frees memory
Q_INVOKABLE void disposeTransaction(PendingTransaction * t); Q_INVOKABLE void disposeTransaction(PendingTransaction * t);