Support for sweeping all outputs

This commit is contained in:
moneromooo.monero 2016-11-09 13:00:43 +00:00
parent 2143392b84
commit c779b376fc
4 changed files with 59 additions and 25 deletions

View file

@ -423,33 +423,38 @@ ApplicationWindow {
transactionDescription = description; transactionDescription = description;
// validate amount; // validate amount;
var amountxmr = walletManager.amountFromString(amount); if (amount !== "(all)") {
console.log("integer amount: ", amountxmr); var amountxmr = walletManager.amountFromString(amount);
console.log("integer unlocked",currentWallet.unlockedBalance) console.log("integer amount: ", amountxmr);
if (amountxmr <= 0) { console.log("integer unlocked",currentWallet.unlockedBalance)
informationPopup.title = qsTr("Error") + translationManager.emptyString; if (amountxmr <= 0) {
informationPopup.text = qsTr("Amount is wrong: expected number from %1 to %2") informationPopup.title = qsTr("Error") + translationManager.emptyString;
.arg(walletManager.displayAmount(0)) informationPopup.text = qsTr("Amount is wrong: expected number from %1 to %2")
.arg(walletManager.maximumAllowedAmountAsSting()) .arg(walletManager.displayAmount(0))
+ translationManager.emptyString .arg(walletManager.maximumAllowedAmountAsSting())
+ translationManager.emptyString
informationPopup.icon = StandardIcon.Critical informationPopup.icon = StandardIcon.Critical
informationPopup.onCloseCallback = null informationPopup.onCloseCallback = null
informationPopup.open() informationPopup.open()
return; return;
} else if (amountxmr > currentWallet.unlockedBalance) { } else if (amountxmr > currentWallet.unlockedBalance) {
informationPopup.title = qsTr("Error") + translationManager.emptyString; informationPopup.title = qsTr("Error") + translationManager.emptyString;
informationPopup.text = qsTr("insufficient funds. Unlocked balance: %1") informationPopup.text = qsTr("insufficient funds. Unlocked balance: %1")
.arg(walletManager.displayAmount(currentWallet.unlockedBalance)) .arg(walletManager.displayAmount(currentWallet.unlockedBalance))
+ translationManager.emptyString + translationManager.emptyString
informationPopup.icon = StandardIcon.Critical informationPopup.icon = StandardIcon.Critical
informationPopup.onCloseCallback = null informationPopup.onCloseCallback = null
informationPopup.open() informationPopup.open()
return; return;
}
} }
currentWallet.createTransactionAsync(address, paymentId, amountxmr, mixinCount, priority); if (amount === "(all)")
currentWallet.createTransactionAllAsync(address, paymentId, amountxmr, mixinCount, priority);
else
currentWallet.createTransactionAsync(address, paymentId, amountxmr, mixinCount, priority);
} }
function handleSweepUnmixable() { function handleSweepUnmixable() {

View file

@ -89,7 +89,7 @@ Rectangle {
LineEdit { LineEdit {
id: amountLine id: amountLine
placeholderText: qsTr("") + translationManager.emptyString placeholderText: qsTr("") + translationManager.emptyString
width: parent.width - 37 - 17 width: parent.width - 37 - 17 - 60
validator: DoubleValidator { validator: DoubleValidator {
bottom: 0.0 bottom: 0.0
top: 18446744.073709551615 top: 18446744.073709551615
@ -98,6 +98,21 @@ Rectangle {
locale: "C" locale: "C"
} }
} }
StandardButton {
id: amountAllButton
//anchors.left: amountLine.right
//anchors.top: amountLine.top
//anchors.bottom: amountLine.bottom
width: 60
text: qsTr("or ALL") + translationManager.emptyString
shadowReleasedColor: "#FF4304"
shadowPressedColor: "#B32D00"
releasedColor: "#FF6C3C"
pressedColor: "#FF4304"
enabled : true
onClicked: amountLine.text = "(all)"
}
} }
ListModel { ListModel {

View file

@ -232,6 +232,16 @@ void Wallet::createTransactionAsync(const QString &dst_addr, const QString &paym
}); });
} }
PendingTransaction *Wallet::createTransactionAll(const QString &dst_addr, const QString &payment_id,
quint32 mixin_count, PendingTransaction::Priority priority)
{
Bitmonero::PendingTransaction * ptImpl = m_walletImpl->createTransaction(
dst_addr.toStdString(), payment_id.toStdString(), Bitmonero::optional<uint64_t>(), mixin_count,
static_cast<Bitmonero::PendingTransaction::Priority>(priority));
PendingTransaction * result = new PendingTransaction(ptImpl, this);
return result;
}
PendingTransaction *Wallet::createSweepUnmixableTransaction() PendingTransaction *Wallet::createSweepUnmixableTransaction()
{ {
Bitmonero::PendingTransaction * ptImpl = m_walletImpl->createSweepUnmixableTransaction(); Bitmonero::PendingTransaction * ptImpl = m_walletImpl->createSweepUnmixableTransaction();

View file

@ -126,12 +126,16 @@ public:
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,
PendingTransaction::Priority priority); PendingTransaction::Priority priority);
//! creates async transaction //! creates async transaction
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 transaction with all outputs
Q_INVOKABLE PendingTransaction * createTransactionAll(const QString &dst_addr, const QString &payment_id,
quint32 mixin_count, PendingTransaction::Priority priority);
//! creates sweep unmixable transaction //! creates sweep unmixable transaction
Q_INVOKABLE PendingTransaction * createSweepUnmixableTransaction(); Q_INVOKABLE PendingTransaction * createSweepUnmixableTransaction();