Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 2 additions & 48 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,60 +47,14 @@ src/qt/.deps
src/qt/.dirstamp
src/qt/bitcoin.moc
src/qt/bitcoinamountfield.moc
src/qt/moc_aboutdialog.cpp
src/qt/moc_addressbookpage.cpp
src/qt/moc_addresstablemodel.cpp
src/qt/moc_askpassphrasedialog.cpp
src/qt/moc_bip38tooldialog.cpp
src/qt/moc_bitcoinaddressvalidator.cpp
src/qt/moc_bitcoinamountfield.cpp
src/qt/moc_bitcoingui.cpp
src/qt/moc_bitcoinunits.cpp
src/qt/moc_clientmodel.cpp
src/qt/moc_coincontroldialog.cpp
src/qt/moc_coincontroltreewidget.cpp
src/qt/moc_csvmodelwriter.cpp
src/qt/moc_editaddressdialog.cpp
src/qt/moc_guiutil.cpp
src/qt/moc_macdockiconhandler.cpp
src/qt/moc_monitoreddatamapper.cpp
src/qt/moc_notificator.cpp
src/qt/moc_optionsdialog.cpp
src/qt/moc_optionsmodel.cpp
src/qt/moc_overviewpage.cpp
src/qt/moc_qrcodedialog.cpp
src/qt/moc_qvalidatedlineedit.cpp
src/qt/moc_qvaluecombobox.cpp
src/qt/moc_rpcconsole.cpp
src/qt/moc_sendcoinsdialog.cpp
src/qt/moc_sendcoinsentry.cpp
src/qt/moc_signverifymessagedialog.cpp
src/qt/moc_transactiondesc.cpp
src/qt/moc_transactiondescdialog.cpp
src/qt/moc_transactionfilterproxy.cpp
src/qt/moc_transactiontablemodel.cpp
src/qt/moc_transactionview.cpp
src/qt/moc_walletmodel.cpp
src/qt/moc_*
src/qt/overviewpage.moc
src/qt/rpcconsole.moc
Makefile.in
src/config/bitcoin-config.h
src/config/bitcoin-config.h.in
src/config/stamp-h1
src/qt/forms/ui_aboutdialog.h
src/qt/forms/ui_addressbookpage.h
src/qt/forms/ui_askpassphrasedialog.h
src/qt/forms/ui_bip38tooldialog.h
src/qt/forms/ui_coincontroldialog.h
src/qt/forms/ui_editaddressdialog.h
src/qt/forms/ui_optionsdialog.h
src/qt/forms/ui_overviewpage.h
src/qt/forms/ui_qrcodedialog.h
src/qt/forms/ui_rpcconsole.h
src/qt/forms/ui_sendcoinsdialog.h
src/qt/forms/ui_sendcoinsentry.h
src/qt/forms/ui_signverifymessagedialog.h
src/qt/forms/ui_transactiondescdialog.h
src/qt/forms/ui_*
config.log
config.status
libtool
Expand Down
11 changes: 11 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,17 @@ bool CTxMemPool::accept(CTxDB& txdb, CTransaction &tx, bool fCheckInputs,
if (ptxOld)
EraseFromWallets(ptxOld->GetHash());

// If the transaction is a proposal then verify validity
if (tx.IsProposal()) {
CVoteProposal proposal;
ProposalFromTransaction(tx, proposal);

// Verify that the proposal is valid
if(!proposalManager.CheckProposal(proposal)) {
return error("CTxMemPool::accept() : Invalid Proposal %s", hash.ToString().substr(0,10).c_str());
}
}

printf("CTxMemPool::accept() : accepted %s (poolsz %lu)\n",
hash.ToString().substr(0,10).c_str(),
mapTx.size());
Expand Down
36 changes: 36 additions & 0 deletions src/voteproposalmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,42 @@

using namespace std;

bool CVoteProposalManager::CheckProposal(const CVoteProposal &proposal)
{
// If the proposal is already in the blockchain then it's guaranteed to be valid
if (mapProposalData.count(proposal.GetHash()) != 0) {
return true;
}

// Proposal name length must be between 1 and MAX_CHAR_NAME (inclusive)
if (proposal.GetName().empty() || proposal.GetName().size() > MAX_CHAR_NAME) {
return false;
}

// Proposal description length must be between 1 and MAX_CHAR_ABSTRACT (inclusive)
if (proposal.GetDescription().empty() || proposal.GetDescription().size() > MAX_CHAR_ABSTRACT) {
return false;
}

// Proposal voting period cannot start before or at the current height or after MAX_BLOCKS_IN_FUTURE
if (proposal.GetStartHeight() <= nBestHeight || proposal.GetStartHeight() > nBestHeight + MAX_BLOCKS_IN_FUTURE) {
return false;
}

// Proposal voting period length must be between 1 and MAX_CHECKSPAN (inclusive)
if (!proposal.GetCheckSpan() || proposal.GetCheckSpan() > MAX_CHECKSPAN) {
return false;
}

// Check to see if there is room on the blockchain for this proposal
VoteLocation location;
if (!GetNextLocation(proposal.GetBitCount(), proposal.GetStartHeight(), proposal.GetCheckSpan(), location)) {
return false;
}

return true;
}

//! Add a proposal to the manager. Note that it must not have conflicts in its scheduling.
bool CVoteProposalManager::Add(const CVoteProposal& proposal)
{
Expand Down
1 change: 1 addition & 0 deletions src/voteproposalmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class CVoteProposalManager
std::map<uint256, VoteLocation> GetActive(int nHeight);
bool GetNextLocation(int nBitCount, int nStartHeight, int nCheckSpan, VoteLocation& location);
std::map<uint256, CProposalMetaData> GetAllProposals() const { return mapProposalData; };
bool CheckProposal (const CVoteProposal& proposal);
};

#endif //HYPERSTAKE_VOTEPROPOSALMANAGER_H