Skip to content

Commit

Permalink
CoinControl features added
Browse files Browse the repository at this point in the history
Review and pull if all looks accurate.
  • Loading branch information
Kergekoin committed Apr 8, 2014
1 parent dad7971 commit af6c0b9
Show file tree
Hide file tree
Showing 24 changed files with 4,402 additions and 647 deletions.
6 changes: 6 additions & 0 deletions mintcoin-qt.pro
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ HEADERS += src/qt/bitcoingui.h \
src/qt/transactiontablemodel.h \
src/qt/addresstablemodel.h \
src/qt/optionsdialog.h \
src/qt/coincontroldialog.h \
src/qt/coincontroltreewidget.h \
src/qt/sendcoinsdialog.h \
src/qt/addressbookpage.h \
src/qt/signverifymessagedialog.h \
Expand All @@ -118,6 +120,7 @@ HEADERS += src/qt/bitcoingui.h \
src/bignum.h \
src/checkpoints.h \
src/compat.h \
src/coincontrol.h \
src/sync.h \
src/util.h \
src/uint256.h \
Expand Down Expand Up @@ -182,6 +185,8 @@ SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \
src/qt/addresstablemodel.cpp \
src/qt/optionsdialog.cpp \
src/qt/sendcoinsdialog.cpp \
src/qt/coincontroldialog.cpp \
src/qt/coincontroltreewidget.cpp \
src/qt/addressbookpage.cpp \
src/qt/signverifymessagedialog.cpp \
src/qt/aboutdialog.cpp \
Expand Down Expand Up @@ -246,6 +251,7 @@ RESOURCES += \
src/qt/bitcoin.qrc

FORMS += \
src/qt/forms/coincontroldialog.ui \
src/qt/forms/sendcoinsdialog.ui \
src/qt/forms/addressbookpage.ui \
src/qt/forms/signverifymessagedialog.ui \
Expand Down
57 changes: 57 additions & 0 deletions src/coincontrol.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#ifndef COINCONTROL_H
#define COINCONTROL_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 @@ -503,12 +503,11 @@ bool CTransaction::CheckTransaction() const


int64 CTransaction::GetMinFee(unsigned int nBlockSize, bool fAllowFree,
enum GetMinFee_mode mode) const
enum GetMinFee_mode mode, unsigned int nBytes) const
{
// Base fee is either MIN_TX_FEE or MIN_RELAY_TX_FEE
int64 nBaseFee = (mode == GMF_RELAY) ? MIN_RELAY_TX_FEE : MIN_TX_FEE;

unsigned int nBytes = ::GetSerializeSize(*this, SER_NETWORK, PROTOCOL_VERSION);
unsigned int nNewBlockSize = nBlockSize + nBytes;
int64 nMinFee = (1 + (int64)nBytes / 1000) * nBaseFee;

Expand Down Expand Up @@ -624,7 +623,7 @@ bool CTxMemPool::accept(CTxDB& txdb, CTransaction &tx, bool fCheckInputs,
unsigned int nSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);

// Don't accept it if it can't get into a block
int64 txMinFee = tx.GetMinFee(1000, false, GMF_RELAY);
int64 txMinFee = tx.GetMinFee(1000, false, GMF_RELAY, nSize);
if (nFees < txMinFee)
return error("CTxMemPool::accept() : not enough fees %s, %"PRI64d" < %"PRI64d,
hash.ToString().c_str(),
Expand Down
2 changes: 1 addition & 1 deletion src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ class CTransaction
return dPriority > COIN * 2880 / 250;
}

int64 GetMinFee(unsigned int nBlockSize=1, bool fAllowFree=false, enum GetMinFee_mode mode=GMF_BLOCK) const;
int64 GetMinFee(unsigned int nBlockSize=1, bool fAllowFree=false, enum GetMinFee_mode mode=GMF_BLOCK, unsigned int nBytes = 0) const;

bool ReadFromDisk(CDiskTxPos pos, FILE** pfileRet=NULL)
{
Expand Down
Loading

0 comments on commit af6c0b9

Please sign in to comment.