Skip to content

Commit 18cd596

Browse files
UdjinM6codablock
authored andcommitted
Sort recipients in SendCoins dialog via BIP69 rule (#2546)
1 parent 5830353 commit 18cd596

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/qt/sendcoinsdialog.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,11 @@ void SendCoinsDialog::on_sendButton_clicked()
254254
return;
255255
}
256256

257+
// apply BIP69
258+
if (bBIP69Enabled) {
259+
std::sort(recipients.begin(), recipients.end(), CompareSendCoinsRecipientBIP69());
260+
}
261+
257262
QString strFunds = tr("using") + " <b>" + tr("anonymous funds") + "</b>";
258263
QString strFee = "";
259264
recipients[0].inputType = ONLY_DENOMINATED;

src/qt/walletmodel.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@ class SendCoinsRecipient
101101
}
102102
};
103103

104+
// same as CompareOutputBIP69 in primitives/transaction.h
105+
struct CompareSendCoinsRecipientBIP69
106+
{
107+
inline bool operator()(const SendCoinsRecipient& a, const SendCoinsRecipient& b) const
108+
{
109+
return a.amount < b.amount || (a.amount == b.amount && a.address < b.address);
110+
}
111+
};
112+
104113
/** Interface to Bitcoin wallet from Qt view code. */
105114
class WalletModel : public QObject
106115
{

0 commit comments

Comments
 (0)