Skip to content

Commit 3443ade

Browse files
committed
Merge pull request #3253
6a86c24 Coin Control Features (Cozz Lovan) 8dfd8c6 pass nBytes as parameter to GetMinFee(..) (Cozz Lovan)
2 parents 0b4bd48 + 6a86c24 commit 3443ade

25 files changed

+2562
-48
lines changed

src/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ DIST_SUBDIRS = . qt test
1313
# bitcoin core #
1414
BITCOIN_CORE_H = addrman.h alert.h allocators.h base58.h bignum.h \
1515
bitcoinrpc.h bloom.h chainparams.h checkpoints.h checkqueue.h \
16-
clientversion.h compat.h core.h coins.h crypter.h db.h hash.h init.h \
16+
clientversion.h coincontrol.h compat.h core.h coins.h crypter.h db.h hash.h init.h \
1717
key.h keystore.h leveldbwrapper.h limitedmap.h main.h miner.h mruset.h \
1818
netbase.h net.h noui.h protocol.h script.h serialize.h sync.h threadsafety.h \
1919
txdb.h txmempool.h ui_interface.h uint256.h util.h version.h walletdb.h wallet.h

src/coincontrol.h

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#ifndef COINCONTROL_H
2+
#define COINCONTROL_H
3+
4+
#include "core.h"
5+
6+
/** Coin Control Features. */
7+
class CCoinControl
8+
{
9+
public:
10+
CTxDestination destChange;
11+
12+
CCoinControl()
13+
{
14+
SetNull();
15+
}
16+
17+
void SetNull()
18+
{
19+
destChange = CNoDestination();
20+
setSelected.clear();
21+
}
22+
23+
bool HasSelected() const
24+
{
25+
return (setSelected.size() > 0);
26+
}
27+
28+
bool IsSelected(const uint256& hash, unsigned int n) const
29+
{
30+
COutPoint outpt(hash, n);
31+
return (setSelected.count(outpt) > 0);
32+
}
33+
34+
void Select(COutPoint& output)
35+
{
36+
setSelected.insert(output);
37+
}
38+
39+
void UnSelect(COutPoint& output)
40+
{
41+
setSelected.erase(output);
42+
}
43+
44+
void UnSelectAll()
45+
{
46+
setSelected.clear();
47+
}
48+
49+
void ListSelected(std::vector<COutPoint>& vOutpoints)
50+
{
51+
vOutpoints.assign(setSelected.begin(), setSelected.end());
52+
}
53+
54+
private:
55+
std::set<COutPoint> setSelected;
56+
57+
};
58+
59+
#endif // COINCONTROL_H

src/main.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -599,12 +599,11 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state)
599599
return true;
600600
}
601601

602-
int64_t GetMinFee(const CTransaction& tx, bool fAllowFree, enum GetMinFee_mode mode)
602+
int64_t GetMinFee(const CTransaction& tx, unsigned int nBytes, bool fAllowFree, enum GetMinFee_mode mode)
603603
{
604604
// Base fee is either nMinTxFee or nMinRelayTxFee
605605
int64_t nBaseFee = (mode == GMF_RELAY) ? tx.nMinRelayTxFee : tx.nMinTxFee;
606606

607-
unsigned int nBytes = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
608607
int64_t nMinFee = (1 + (int64_t)nBytes / 1000) * nBaseFee;
609608

610609
if (fAllowFree)
@@ -740,7 +739,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
740739
unsigned int nSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
741740

742741
// Don't accept it if it can't get into a block
743-
int64_t txMinFee = GetMinFee(tx, true, GMF_RELAY);
742+
int64_t txMinFee = GetMinFee(tx, nSize, true, GMF_RELAY);
744743
if (fLimitFree && nFees < txMinFee)
745744
return state.DoS(0, error("AcceptToMemoryPool : not enough fees %s, %"PRId64" < %"PRId64,
746745
hash.ToString().c_str(), nFees, txMinFee),

src/main.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ enum GetMinFee_mode
258258
GMF_SEND,
259259
};
260260

261-
int64_t GetMinFee(const CTransaction& tx, bool fAllowFree, enum GetMinFee_mode mode);
261+
int64_t GetMinFee(const CTransaction& tx, unsigned int nBytes, bool fAllowFree, enum GetMinFee_mode mode);
262262

263263
//
264264
// Check transaction inputs, and make sure any

src/qt/Makefile.am

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ QT_TS = locale/bitcoin_ach.ts \
7272
locale/bitcoin_zh_TW.ts
7373

7474
QT_FORMS_UI = forms/aboutdialog.ui forms/addressbookpage.ui \
75-
forms/askpassphrasedialog.ui forms/editaddressdialog.ui forms/intro.ui \
75+
forms/askpassphrasedialog.ui \
76+
forms/coincontroldialog.ui \
77+
forms/editaddressdialog.ui \
78+
forms/intro.ui \
7679
forms/openuridialog.ui \
7780
forms/optionsdialog.ui forms/overviewpage.ui forms/receiverequestdialog.ui \
7881
forms/receivecoinsdialog.ui \
@@ -83,6 +86,8 @@ QT_MOC_CPP = moc_aboutdialog.cpp moc_addressbookpage.cpp \
8386
moc_addresstablemodel.cpp moc_askpassphrasedialog.cpp \
8487
moc_bitcoinaddressvalidator.cpp moc_bitcoinamountfield.cpp \
8588
moc_bitcoingui.cpp moc_bitcoinunits.cpp moc_clientmodel.cpp \
89+
moc_coincontroldialog.cpp \
90+
moc_coincontroltreewidget.cpp \
8691
moc_csvmodelwriter.cpp moc_editaddressdialog.cpp moc_guiutil.cpp \
8792
moc_intro.cpp moc_macdockiconhandler.cpp moc_macnotificationhandler.cpp \
8893
moc_monitoreddatamapper.cpp moc_notificator.cpp \
@@ -110,7 +115,7 @@ PROTOBUF_PROTO = paymentrequest.proto
110115

111116
BITCOIN_QT_H = aboutdialog.h addressbookpage.h addresstablemodel.h \
112117
askpassphrasedialog.h bitcoinaddressvalidator.h bitcoinamountfield.h \
113-
bitcoingui.h bitcoinunits.h clientmodel.h csvmodelwriter.h \
118+
bitcoingui.h bitcoinunits.h clientmodel.h coincontroldialog.h coincontroltreewidget.h csvmodelwriter.h \
114119
editaddressdialog.h guiconstants.h guiutil.h intro.h macdockiconhandler.h \
115120
macnotificationhandler.h monitoreddatamapper.h notificator.h \
116121
openuridialog.h \
@@ -143,7 +148,10 @@ RES_ICONS = res/icons/bitcoin.png res/icons/address-book.png \
143148
BITCOIN_QT_CPP = aboutdialog.cpp addressbookpage.cpp \
144149
addresstablemodel.cpp askpassphrasedialog.cpp bitcoinaddressvalidator.cpp \
145150
bitcoinamountfield.cpp bitcoin.cpp bitcoingui.cpp \
146-
bitcoinunits.cpp clientmodel.cpp csvmodelwriter.cpp editaddressdialog.cpp \
151+
bitcoinunits.cpp clientmodel.cpp \
152+
coincontroldialog.cpp \
153+
coincontroltreewidget.cpp \
154+
csvmodelwriter.cpp editaddressdialog.cpp \
147155
guiutil.cpp intro.cpp monitoreddatamapper.cpp notificator.cpp \
148156
openuridialog.cpp \
149157
optionsdialog.cpp optionsmodel.cpp overviewpage.cpp paymentrequestplus.cpp \

0 commit comments

Comments
 (0)