Priority aka fee multiplier integrated

This commit is contained in:
Ilya Kitaev 2016-06-27 15:45:48 +03:00
parent 17f38a930e
commit 409c5701e2
6 changed files with 43 additions and 25 deletions

View file

@ -30,7 +30,7 @@ import QtQuick 2.2
Rectangle { Rectangle {
color: "#F0EEEE" color: "#F0EEEE"
signal paymentClicked(string address, string paymentId, double amount, int mixinCount) signal paymentClicked(string address, string paymentId, double amount, int mixinCount, int priority)
signal generatePaymentIdInvoked() signal generatePaymentIdInvoked()
states: [ states: [
@ -89,7 +89,7 @@ Rectangle {
target: loader.item target: loader.item
onPaymentClicked : { onPaymentClicked : {
console.log("MiddlePanel: paymentClicked") console.log("MiddlePanel: paymentClicked")
paymentClicked(address, paymentId, amount, mixinCount) paymentClicked(address, paymentId, amount, mixinCount, priority)
} }
} }

View file

@ -169,15 +169,18 @@ ApplicationWindow {
return wallets.length > 0; return wallets.length > 0;
} }
function handlePayment(address, paymentId, amount, mixinCount) { function handlePayment(address, paymentId, amount, mixinCount, priority) {
console.log("Process payment here: ", address, paymentId, amount, mixinCount) console.log("Creating transaction: ")
// TODO: handle payment id console.log("\taddress: ", address,
// TODO: handle fee; ", payment_id: ", paymentId,
// TODO: handle mixins ", amount: ", amount,
", mixins: ", mixinCount,
", priority: ", priority);
var amountxmr = walletManager.amountFromString(amount); var amountxmr = walletManager.amountFromString(amount);
console.log("integer amount: ", amountxmr); console.log("integer amount: ", amountxmr);
var pendingTransaction = wallet.createTransaction(address, amountxmr, mixinCount); var pendingTransaction = wallet.createTransaction(address, paymentId, amountxmr, mixinCount, priority);
if (pendingTransaction.status !== PendingTransaction.Status_Ok) { if (pendingTransaction.status !== PendingTransaction.Status_Ok) {
console.error("Can't create transaction: ", pendingTransaction.errorString); console.error("Can't create transaction: ", pendingTransaction.errorString);
} else { } else {

View file

@ -27,10 +27,13 @@
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import QtQuick 2.0 import QtQuick 2.0
import Bitmonero.PendingTransaction 1.0
import "../components" import "../components"
Rectangle { Rectangle {
signal paymentClicked(string address, string paymentId, double amount, int mixinCount) signal paymentClicked(string address, string paymentId, double amount, int mixinCount,
int priority)
color: "#F0EEEE" color: "#F0EEEE"
@ -54,7 +57,7 @@ Rectangle {
text: qsTr("Amount") text: qsTr("Amount")
fontSize: 14 fontSize: 14
} }
/*
Label { Label {
id: transactionPriority id: transactionPriority
anchors.top: parent.top anchors.top: parent.top
@ -63,8 +66,6 @@ Rectangle {
x: (parent.width - 17) / 2 + 17 x: (parent.width - 17) / 2 + 17
text: qsTr("Transaction prority") text: qsTr("Transaction prority")
} }
*/
Row { Row {
id: amountRow id: amountRow
@ -92,11 +93,11 @@ Rectangle {
ListModel { ListModel {
id: priorityModel id: priorityModel
ListElement { column1: "LOW"; column2: "( fee: 0.0002 )" } ListElement { column1: "LOW"; column2: ""; priority: PendingTransaction.Priority_Low }
ListElement { column1: "MEDIUM"; column2: "( fee: 0.0004 )" } ListElement { column1: "MEDIUM"; column2: ""; priority: PendingTransaction.Priority_Medium }
ListElement { column1: "HIGH"; column2: "( fee: 0.0008 )" } ListElement { column1: "HIGH"; column2: ""; priority: PendingTransaction.Priority_High }
} }
/*
StandardDropdown { StandardDropdown {
id: priorityDropdown id: priorityDropdown
anchors.top: transactionPriority.bottom anchors.top: transactionPriority.bottom
@ -111,7 +112,7 @@ Rectangle {
dataModel: priorityModel dataModel: priorityModel
z: 1 z: 1
} }
*/
Label { Label {
@ -243,7 +244,10 @@ Rectangle {
if (addressLine.text.length > 0 && amountLine.text.length > 0) { if (addressLine.text.length > 0 && amountLine.text.length > 0) {
console.log("paymentClicked") console.log("paymentClicked")
paymentClicked(addressLine.text, paymentIdLine.text, amountLine.text, scaleValueToMixinCount(privacyLevelItem.fillLevel)) var priority = priorityModel.get(priorityDropdown.currentIndex).priority
console.log("priority: " + priority)
paymentClicked(addressLine.text, paymentIdLine.text, amountLine.text, scaleValueToMixinCount(privacyLevelItem.fillLevel),
priority)
} }
} }
} }

View file

@ -23,9 +23,16 @@ public:
Status_Ok = Bitmonero::PendingTransaction::Status_Ok, Status_Ok = Bitmonero::PendingTransaction::Status_Ok,
Status_Error = Bitmonero::PendingTransaction::Status_Error Status_Error = Bitmonero::PendingTransaction::Status_Error
}; };
Q_ENUM(Status) Q_ENUM(Status)
enum Priority {
Priority_Low = Bitmonero::PendingTransaction::Priority_Low,
Priority_Medium = Bitmonero::PendingTransaction::Priority_Medium,
Priority_High = Bitmonero::PendingTransaction::Priority_High
};
Q_ENUM(Priority)
Status status() const; Status status() const;
QString errorString() const; QString errorString() const;
Q_INVOKABLE bool commit(); Q_INVOKABLE bool commit();

View file

@ -89,10 +89,12 @@ bool Wallet::refresh()
} }
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)
{ {
Bitmonero::PendingTransaction * ptImpl = m_walletImpl->createTransaction( Bitmonero::PendingTransaction * ptImpl = m_walletImpl->createTransaction(
dst_addr.toStdString(), payment_id.toStdString(), amount, mixin_count); dst_addr.toStdString(), payment_id.toStdString(), amount, mixin_count,
static_cast<Bitmonero::PendingTransaction::Priority>(priority));
PendingTransaction * result = new PendingTransaction(ptImpl, this); PendingTransaction * result = new PendingTransaction(ptImpl, this);
return result; return result;
} }

View file

@ -3,13 +3,15 @@
#include <QObject> #include <QObject>
#include "wallet/wallet2_api.h" // we need to access Status enum here; #include "wallet/wallet2_api.h" // we need to have an access to the Bitmonero::Wallet::Status enum here;
#include "PendingTransaction.h" // we need to have an access to the PendingTransaction::Priority enum here;
namespace Bitmonero { namespace Bitmonero {
class Wallet; // forward declaration class Wallet; // forward declaration
} }
class PendingTransaction;
class TransactionHistory; class TransactionHistory;
class Wallet : public QObject class Wallet : public QObject
@ -77,8 +79,8 @@ public:
//! 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,
PendingTransaction::Priority priority = PendingTransaction::Priority_Low);
//! deletes transaction and frees memory //! deletes transaction and frees memory
Q_INVOKABLE void disposeTransaction(PendingTransaction * t); Q_INVOKABLE void disposeTransaction(PendingTransaction * t);