Skip to content

Commit

Permalink
Merge pull request #3253
Browse files Browse the repository at this point in the history
6a86c24 Coin Control Features (Cozz Lovan)
8dfd8c6 pass nBytes as parameter to GetMinFee(..) (Cozz Lovan)
  • Loading branch information
laanwj committed Nov 16, 2013
2 parents 0b4bd48 + 6a86c24 commit 3443ade
Show file tree
Hide file tree
Showing 25 changed files with 2,562 additions and 48 deletions.
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ DIST_SUBDIRS = . qt test
# bitcoin core #
BITCOIN_CORE_H = addrman.h alert.h allocators.h base58.h bignum.h \
bitcoinrpc.h bloom.h chainparams.h checkpoints.h checkqueue.h \
clientversion.h compat.h core.h coins.h crypter.h db.h hash.h init.h \
clientversion.h coincontrol.h compat.h core.h coins.h crypter.h db.h hash.h init.h \
key.h keystore.h leveldbwrapper.h limitedmap.h main.h miner.h mruset.h \
netbase.h net.h noui.h protocol.h script.h serialize.h sync.h threadsafety.h \
txdb.h txmempool.h ui_interface.h uint256.h util.h version.h walletdb.h wallet.h
Expand Down
59 changes: 59 additions & 0 deletions src/coincontrol.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#ifndef COINCONTROL_H
#define COINCONTROL_H

#include "core.h"

/** Coin Control Features. */
class CCoinControl
{
public:
CTxDestination destChange;

CCoinControl()
{
SetNull();
}

void SetNull()
{
destChange = CNoDestination();
setSelected.clear();
}

bool HasSelected() const
{
return (setSelected.size() > 0);
}

bool IsSelected(const uint256& hash, unsigned int n) const
{
COutPoint outpt(hash, n);
return (setSelected.count(outpt) > 0);
}

void Select(COutPoint& output)
{
setSelected.insert(output);
}

void UnSelect(COutPoint& output)
{
setSelected.erase(output);
}

void UnSelectAll()
{
setSelected.clear();
}

void ListSelected(std::vector<COutPoint>& vOutpoints)
{
vOutpoints.assign(setSelected.begin(), setSelected.end());
}

private:
std::set<COutPoint> setSelected;

};

#endif // COINCONTROL_H
5 changes: 2 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,12 +599,11 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state)
return true;
}

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

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

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

// Don't accept it if it can't get into a block
int64_t txMinFee = GetMinFee(tx, true, GMF_RELAY);
int64_t txMinFee = GetMinFee(tx, nSize, true, GMF_RELAY);
if (fLimitFree && nFees < txMinFee)
return state.DoS(0, error("AcceptToMemoryPool : not enough fees %s, %"PRId64" < %"PRId64,
hash.ToString().c_str(), nFees, txMinFee),
Expand Down
2 changes: 1 addition & 1 deletion src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ enum GetMinFee_mode
GMF_SEND,
};

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

//
// Check transaction inputs, and make sure any
Expand Down
14 changes: 11 additions & 3 deletions src/qt/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ QT_TS = locale/bitcoin_ach.ts \
locale/bitcoin_zh_TW.ts

QT_FORMS_UI = forms/aboutdialog.ui forms/addressbookpage.ui \
forms/askpassphrasedialog.ui forms/editaddressdialog.ui forms/intro.ui \
forms/askpassphrasedialog.ui \
forms/coincontroldialog.ui \
forms/editaddressdialog.ui \
forms/intro.ui \
forms/openuridialog.ui \
forms/optionsdialog.ui forms/overviewpage.ui forms/receiverequestdialog.ui \
forms/receivecoinsdialog.ui \
Expand All @@ -83,6 +86,8 @@ QT_MOC_CPP = moc_aboutdialog.cpp moc_addressbookpage.cpp \
moc_addresstablemodel.cpp moc_askpassphrasedialog.cpp \
moc_bitcoinaddressvalidator.cpp moc_bitcoinamountfield.cpp \
moc_bitcoingui.cpp moc_bitcoinunits.cpp moc_clientmodel.cpp \
moc_coincontroldialog.cpp \
moc_coincontroltreewidget.cpp \
moc_csvmodelwriter.cpp moc_editaddressdialog.cpp moc_guiutil.cpp \
moc_intro.cpp moc_macdockiconhandler.cpp moc_macnotificationhandler.cpp \
moc_monitoreddatamapper.cpp moc_notificator.cpp \
Expand Down Expand Up @@ -110,7 +115,7 @@ PROTOBUF_PROTO = paymentrequest.proto

BITCOIN_QT_H = aboutdialog.h addressbookpage.h addresstablemodel.h \
askpassphrasedialog.h bitcoinaddressvalidator.h bitcoinamountfield.h \
bitcoingui.h bitcoinunits.h clientmodel.h csvmodelwriter.h \
bitcoingui.h bitcoinunits.h clientmodel.h coincontroldialog.h coincontroltreewidget.h csvmodelwriter.h \
editaddressdialog.h guiconstants.h guiutil.h intro.h macdockiconhandler.h \
macnotificationhandler.h monitoreddatamapper.h notificator.h \
openuridialog.h \
Expand Down Expand Up @@ -143,7 +148,10 @@ RES_ICONS = res/icons/bitcoin.png res/icons/address-book.png \
BITCOIN_QT_CPP = aboutdialog.cpp addressbookpage.cpp \
addresstablemodel.cpp askpassphrasedialog.cpp bitcoinaddressvalidator.cpp \
bitcoinamountfield.cpp bitcoin.cpp bitcoingui.cpp \
bitcoinunits.cpp clientmodel.cpp csvmodelwriter.cpp editaddressdialog.cpp \
bitcoinunits.cpp clientmodel.cpp \
coincontroldialog.cpp \
coincontroltreewidget.cpp \
csvmodelwriter.cpp editaddressdialog.cpp \
guiutil.cpp intro.cpp monitoreddatamapper.cpp notificator.cpp \
openuridialog.cpp \
optionsdialog.cpp optionsmodel.cpp overviewpage.cpp paymentrequestplus.cpp \
Expand Down
Loading

0 comments on commit 3443ade

Please sign in to comment.