30 return _(
"Passing not funded");
32 return _(
"Not Passing");
64 if (remainingPayments <= 0) {
66 }
else if (isPassing) {
92 std::list<ProposalInfo> ret;
96 bool isPassing = std::find(budget.begin(), budget.end(), *prop) != budget.end();
99 if (filterFinished && propInfo.
isFinished())
continue;
100 if (!filterByStatus || propInfo.
status == *filterByStatus) {
101 ret.emplace_back(propInfo);
109 if (!filterByStatus || propInfo.
status == *filterByStatus) {
110 ret.emplace_back(propInfo);
133 return BUDGET_VOTE_UPDATE_MIN;
143 return PROPOSAL_FEE_TX;
150 return chainHeight - chainHeight % nBlocksPerCycle + nBlocksPerCycle;
156 std::vector<std::pair<COutPoint, std::string>> vecLocalMn;
158 vecLocalMn.emplace_back(std::make_pair(
165 std::vector<VoteInfo> localVotes;
170 const auto& mapVotes = prop->
GetVotes();
171 for (
const auto& it : mapVotes) {
172 for (
const auto& mn : vecLocalMn) {
173 if (it.first == mn.first && it.second.IsValid()) {
174 localVotes.emplace_back(mn.first, (
VoteInfo::VoteDirection) it.second.GetDirection(), mn.second, it.second.GetTime());
186 if (strName !=
name.toStdString()) {
187 return {
false,
_(
"Invalid name, invalid characters")};
189 if (strName.size() > (
int)PROP_NAME_MAX_SIZE) {
190 return {
false,
strprintf(
_(
"Invalid name, maximum size of %d exceeded"), PROP_NAME_MAX_SIZE)};
198 if (strURL !=
url.toStdString()) {
199 return {
false,
_(
"Invalid URL, invalid characters")};
201 std::string strError;
202 return {
validateURL(strURL, strError, PROP_URL_MAX_SIZE), strError};
207 if (amount < PROPOSAL_MIN_AMOUNT) {
208 return {
false,
strprintf(
_(
"Amount below the minimum of %s PIV"),
FormatMoney(PROPOSAL_MIN_AMOUNT))};
219 if (paymentCount < 1)
return {
false,
_(
"Invalid payment count, must be greater than zero.")};
221 if (paymentCount > nMaxPayments) {
222 return {
false,
strprintf(
_(
"Invalid payment count, cannot be greater than %d"), nMaxPayments)};
233 const std::string& strURL,
236 const std::string& strPaymentAddr)
243 if (!dest)
return {
false,
_(
"invalid recipient address for the proposal")};
254 if (!opRes)
return opRes;
262 const std::vector<std::string>& mnVotingAlias)
265 for (
const auto& mnAlias : mnVotingAlias) {
266 bool fLegacyMN =
true;
271 isVotePositive ? CBudgetVote::VoteDirection::VOTE_YES : CBudgetVote::VoteDirection::VOTE_NO,
275 if (obj[
"result"].getValStr() !=
"success") {
276 return {
false, obj[
"error"].
getValStr()};
314 LogPrint(
BCLog::QT,
"Cannot broadcast budget proposal - %s\n", it->IsInvalidReason());
316 if (it->IsInvalidReason().find(
"Can't find collateral tx") != std::string::npos) {
322 if (chainHeight >= it->GetBlockStart()) {
359 const auto& it = wtx->mapValue.find(
"proposal");
360 if (it != wtx->mapValue.end()) {
361 const std::vector<unsigned char> vec =
ParseHex(it->second);
362 if (vec.empty())
return;
int64_t CAmount
Amount in PIV (Can be negative)
CBudgetManager g_budgetman
UniValue mnBudgetVoteInner(CWallet *const pwallet, bool fLegacyMN, const uint256 &budgetHash, bool fFinal, const CBudgetVote::VoteDirection &nVote, const Optional< std::string > &mnAliasFilter)
const CChainParams & Params()
Return the currently selected parameters.
bool AddProposal(CBudgetProposal &budgetProposal)
bool HaveProposal(const uint256 &propHash) const
static CAmount GetTotalBudget(int nHeight)
bool HasAnyProposal() const
CBudgetProposal * FindProposal(const uint256 &nHash)
std::vector< CBudgetProposal > GetBudget()
RecursiveMutex cs_proposals
std::vector< CBudgetProposal * > GetAllProposalsOrdered()
int GetRemainingPaymentCount(int nCurrentHeight) const
bool IsExpired(int nCurrentHeight) const
int GetBlockStart() const
std::map< COutPoint, CBudgetVote > GetVotes() const
std::string GetURL() const
std::string IsInvalidReason() const
void SetFeeTxHash(const uint256 &txid)
std::string GetName() const
CAmount GetAmount() const
bool IsWellFormed(const CAmount &nTotalBudget)
int GetTotalPaymentCount() const
const Consensus::Params & GetConsensus() const
An outpoint - a combination of a transaction hash and an index n into its vout.
Serialized script, used inside transaction inputs and outputs.
Model for PIVX network client.
int getMasternodesCount() const
int getLastBlockProcessedHeight() const
int getPropMaxPaymentsCount() const
~GovernanceModel() override
WalletModel * walletModel
int getNextSuperblockHeight() const
GovernanceModel(ClientModel *_clientModel, MNModel *_mnModel)
OperationResult validatePropPaymentCount(int paymentCount) const
int getProposalVoteUpdateMinTime() const
std::vector< CBudgetProposal > waitingPropsForConfirmations
OperationResult validatePropURL(const QString &url) const
OperationResult validatePropName(const QString &name) const
ProposalInfo buildProposalInfo(const CBudgetProposal *prop, bool isPassing, bool isPending)
void scheduleBroadcast(const CBudgetProposal &proposal)
ClientModel * clientModel
void txLoaded(const QString &hash, const int txType, const int txStatus)
OperationResult voteForProposal(const ProposalInfo &prop, bool isVotePositive, const std::vector< std::string > &mnVotingAlias)
CAmount getProposalFeeAmount() const
OperationResult validatePropAmount(CAmount amount) const
int getNumBlocksPerBudgetCycle() const
void pollGovernanceChanged()
void setWalletModel(WalletModel *_walletModel)
OperationResult createProposal(const std::string &strProposalName, const std::string &strURL, int nPaymentCount, CAmount nAmount, const std::string &strPaymentAddr)
std::list< ProposalInfo > getProposals(const ProposalInfo::Status *filterByStatus=nullptr, bool filterFinished=true)
CAmount getMaxAvailableBudgetAmount() const
std::vector< VoteInfo > getLocalMNsVotesForProposal(const ProposalInfo &propInfo)
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QModelIndex index(int row, int column, const QModelIndex &parent) const override
@ ALIAS
User specified MN alias.
bool IsBlockchainSynced() const
@ NotAccepted
Mined but not accepted.
@ Conflicted
Conflicts with other transaction or mempool.
void txLoaded(const QString &hash, const int txType, const int txStatus)
const std::string & getValStr() const
const UniValue & get_array() const
bool exists(const std::string &key) const
Interface to PIVX wallet from Qt view code.
bool isTestNetwork() const
OperationResult createAndSendProposalFeeTx(CBudgetProposal &prop)
const CWalletTx * getTx(uint256 id)
TransactionTableModel * getTransactionTableModel()
#define LogPrint(category,...)
const CTxDestination * GetTransparentDestination(const CWDestination &dest)
std::string EncodeDestination(const CWDestination &address, const CChainParams::Base58Type addrType)
CWDestination DecodeDestination(const std::string &strAddress)
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a PIVX scriptPubKey for the given CTxDestination.
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet, bool fColdStake)
Parse a standard scriptPubKey for the destination address.
boost::variant< CNoDestination, CKeyID, CScriptID, CExchangeKeyID > CTxDestination
A txout script template with a specific destination.
std::string statusToStr() const
Status status
Proposal state.
std::string _(const char *psz)
Translation function: Call Translate signal on UI interface, which returns a Optional result.
TierTwoSyncState g_tiertwo_sync_state
const uint256 UINT256_ZERO
constant uint256 instances
uint256 uint256S(const char *str)
std::string FormatMoney(const CAmount &n, bool fPlus)
Money parsing/formatting utilities.
std::vector< unsigned char > ParseHex(const char *psz)
bool validateURL(const std::string &strURL)
std::string SanitizeString(const std::string &str, int rule)
Remove unsafe chars.