From 18cd5965cc91694a558399e941eb0e8ef962456e Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Mon, 10 Dec 2018 16:57:22 +0300 Subject: [PATCH] Sort recipients in SendCoins dialog via BIP69 rule (#2546) --- src/qt/sendcoinsdialog.cpp | 5 +++++ src/qt/walletmodel.h | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 0aedece4de..ecca3344b9 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -254,6 +254,11 @@ void SendCoinsDialog::on_sendButton_clicked() return; } + // apply BIP69 + if (bBIP69Enabled) { + std::sort(recipients.begin(), recipients.end(), CompareSendCoinsRecipientBIP69()); + } + QString strFunds = tr("using") + " " + tr("anonymous funds") + ""; QString strFee = ""; recipients[0].inputType = ONLY_DENOMINATED; diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index f52657749c..1a9e457d54 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -101,6 +101,15 @@ public: } }; +// same as CompareOutputBIP69 in primitives/transaction.h +struct CompareSendCoinsRecipientBIP69 +{ + inline bool operator()(const SendCoinsRecipient& a, const SendCoinsRecipient& b) const + { + return a.amount < b.amount || (a.amount == b.amount && a.address < b.address); + } +}; + /** Interface to Bitcoin wallet from Qt view code. */ class WalletModel : public QObject {