diff --git a/src/Makefile.am b/src/Makefile.am index 62340f459..f2487df91 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -337,6 +337,7 @@ libnavcoin_consensus_a_SOURCES = \ ctokens/tokenid.h \ dotnav/namedata.h \ dotnav/namerecord.h \ + dotnav/namerecordname.h \ dotnav/names.h \ dotnav/names.cpp \ aes_helper.c \ diff --git a/src/coins.cpp b/src/coins.cpp index 6c0848144..bfc834b1c 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -55,6 +55,7 @@ bool CStateView::GetConsensusParameter(const int &pid, CConsensusParameter& cpar bool CStateView::GetToken(const uint256 &id, TokenInfo& token) const { return false; } bool CStateView::GetTokenUtxos(const uint256 &id, TokenUtxoValues &tokenUtxos) { return false; }; bool CStateView::GetNameRecord(const uint256 &id, NameRecordValue& height) const { return false; } +bool CStateView::GetNameRecordName(const uint256 &id, NameRecordNameValue& name) const { return false; } bool CStateView::GetNameData(const uint256 &id, NameDataValues& data) { return false; } bool CStateView::HaveCoins(const uint256 &txid) const { return false; } bool CStateView::HaveProposal(const uint256 &pid) const { return false; } @@ -66,6 +67,7 @@ bool CStateView::HaveConsensusParameter(const int &pid) const { return false; } bool CStateView::HaveToken(const uint256 &id) const { return false; } bool CStateView::HaveTokenUtxos(const uint256 &id) const { return false; } bool CStateView::HaveNameRecord(const uint256 &id) const { return false; } +bool CStateView::HaveNameRecordName(const uint256 &id) const { return false; } bool CStateView::HaveNameData(const uint256 &id) const { return false; } bool CStateView::GetAllProposals(CProposalMap& map) { return false; } int CStateView::GetExcludeVotes() const { return 0; } @@ -76,13 +78,24 @@ bool CStateView::GetAllConsultations(CConsultationMap& map) { return false; } bool CStateView::GetAllConsultationAnswers(CConsultationAnswerMap& map) { return false; } bool CStateView::GetAllTokens(TokenMap& map) { return false; } bool CStateView::GetAllNameRecords(NameRecordMap& map) { return false; } +bool CStateView::GetAllNameRecordNames(NameRecordNameMap& map) { return false; } uint256 CStateView::GetBestBlock() const { return uint256(); } -bool CStateView::BatchWrite(CCoinsMap &mapCoins, CProposalMap &mapProposals, - CPaymentRequestMap &mapPaymentRequests, CVoteMap &mapVotes, - CConsultationMap& mapConsultations, CConsultationAnswerMap& mapAnswers, - CConsensusParameterMap& mapConsensus, TokenMap& mapTokens, TokenUtxoMap& mapTokenUtxos, - NameRecordMap& mapNameRecords, NameDataMap& mapNameData, - const uint256 &hashBlock, const int& nCacheExcludeVotes) { return false; } +bool CStateView::BatchWrite( + CCoinsMap &mapCoins, + CProposalMap &mapProposals, + CPaymentRequestMap &mapPaymentRequests, + CVoteMap &mapVotes, + CConsultationMap& mapConsultations, + CConsultationAnswerMap& mapAnswers, + CConsensusParameterMap& mapConsensus, + TokenMap& mapTokens, + TokenUtxoMap& mapTokenUtxos, + NameRecordMap& mapNameRecords, + NameRecordNameMap& mapNameRecordNames, + NameDataMap& mapNameData, + const uint256 &hashBlock, + const int& nCacheExcludeVotes) +{ return false; } CStateViewCursor *CStateView::Cursor() const { return 0; } @@ -96,6 +109,7 @@ bool CStateViewBacked::GetConsensusParameter(const int &pid, CConsensusParameter bool CStateViewBacked::GetToken(const uint256 &id, TokenInfo& token) const { return base->GetToken(id, token); } bool CStateViewBacked::GetTokenUtxos(const uint256 &id, TokenUtxoValues &tokenUtxos) { return base->GetTokenUtxos(id, tokenUtxos); } bool CStateViewBacked::GetNameRecord(const uint256 &id, NameRecordValue& height) const { return base->GetNameRecord(id, height); } +bool CStateViewBacked::GetNameRecordName(const uint256 &id, NameRecordNameValue& name) const { return base->GetNameRecordName(id, name); } bool CStateViewBacked::GetNameData(const uint256 &id, NameDataValues& data) { return base->GetNameData(id, data); } bool CStateViewBacked::HaveCoins(const uint256 &txid) const { return base->HaveCoins(txid); } bool CStateViewBacked::HaveProposal(const uint256 &pid) const { return base->HaveProposal(pid); } @@ -107,6 +121,7 @@ bool CStateViewBacked::HaveConsensusParameter(const int &pid) const { return bas bool CStateViewBacked::HaveToken(const uint256 &id) const { return base->HaveToken(id); } bool CStateViewBacked::HaveTokenUtxos(const uint256 &id) const { return base->HaveTokenUtxos(id); } bool CStateViewBacked::HaveNameRecord(const uint256 &id) const { return base->HaveNameRecord(id); } +bool CStateViewBacked::HaveNameRecordName(const uint256 &id) const { return base->HaveNameRecordName(id); } bool CStateViewBacked::HaveNameData(const uint256 &id) const { return base->HaveNameData(id); } int CStateViewBacked::GetExcludeVotes() const { return base->GetExcludeVotes(); } bool CStateViewBacked::SetExcludeVotes(int count) { return base->SetExcludeVotes(count); } @@ -118,15 +133,40 @@ bool CStateViewBacked::GetAllConsultations(CConsultationMap& map) { return base- bool CStateViewBacked::GetAllConsultationAnswers(CConsultationAnswerMap& map) { return base->GetAllConsultationAnswers(map); } bool CStateViewBacked::GetAllTokens(TokenMap& map) { return base->GetAllTokens(map); } bool CStateViewBacked::GetAllNameRecords(NameRecordMap& map) { return base->GetAllNameRecords(map); } +bool CStateViewBacked::GetAllNameRecordNames(NameRecordNameMap& map) { return base->GetAllNameRecordNames(map); } uint256 CStateViewBacked::GetBestBlock() const { return base->GetBestBlock(); } void CStateViewBacked::SetBackend(CStateView &viewIn) { base = &viewIn; } -bool CStateViewBacked::BatchWrite(CCoinsMap &mapCoins, CProposalMap &mapProposals, - CPaymentRequestMap &mapPaymentRequests, CVoteMap &mapVotes, - CConsultationMap &mapConsultations, CConsultationAnswerMap &mapAnswers, - CConsensusParameterMap& mapConsensus, TokenMap& mapTokens, TokenUtxoMap& mapTokenUtxos, - NameRecordMap& mapNameRecords, NameDataMap& mapNameData, - const uint256 &hashBlock, const int &nCacheExcludeVotes) { - return base->BatchWrite(mapCoins, mapProposals, mapPaymentRequests, mapVotes, mapConsultations, mapAnswers, mapConsensus, mapTokens, mapTokenUtxos, mapNameRecords, mapNameData, hashBlock, nCacheExcludeVotes); +bool CStateViewBacked::BatchWrite( + CCoinsMap &mapCoins, + CProposalMap &mapProposals, + CPaymentRequestMap &mapPaymentRequests, + CVoteMap &mapVotes, + CConsultationMap &mapConsultations, + CConsultationAnswerMap &mapAnswers, + CConsensusParameterMap& mapConsensus, + TokenMap& mapTokens, + TokenUtxoMap& mapTokenUtxos, + NameRecordMap& mapNameRecords, + NameRecordNameMap& mapNameRecordNames, + NameDataMap& mapNameData, + const uint256 &hashBlock, + const int &nCacheExcludeVotes) +{ + return base->BatchWrite( + mapCoins, + mapProposals, + mapPaymentRequests, + mapVotes, + mapConsultations, + mapAnswers, + mapConsensus, + mapTokens, + mapTokenUtxos, + mapNameRecords, + mapNameRecordNames, + mapNameData, + hashBlock, + nCacheExcludeVotes); } CStateViewCursor *CStateViewBacked::Cursor() const { return base->Cursor(); } @@ -320,6 +360,23 @@ NameRecordMap::const_iterator CStateViewCache::FetchNameRecord(const uint256 &id return ret; } +NameRecordNameMap::const_iterator CStateViewCache::FetchNameRecordName(const uint256 &id) const { + NameRecordNameMap::iterator it = cacheNameRecordNames.find(id); + + if (it != cacheNameRecordNames.end()) + return it; + + NameRecordNameValue tmp; + + if (!base->GetNameRecordName(id, tmp) || tmp.IsNull()) + return cacheNameRecordNames.end(); + + NameRecordNameMap::iterator ret = cacheNameRecordNames.insert(std::make_pair(id, NameRecordNameValue())).first; + tmp.swap(ret->second); + + return ret; +} + NameDataMap::const_iterator CStateViewCache::FetchNameData(const uint256 &id) const { NameDataMap::iterator it = cacheNameData.find(id); @@ -429,6 +486,16 @@ bool CStateViewCache::GetNameRecord(const uint256 &id, NameRecordValue &height) return false; } +bool CStateViewCache::GetNameRecordName(const uint256 &id, NameRecordNameValue &name) const { + NameRecordNameMap::const_iterator it = FetchNameRecordName(id); + if (it != cacheNameRecordNames.end() && !it->second.IsNull()) { + name = it->second; + return true; + } + + return false; +} + bool CStateViewCache::GetNameData(const uint256 &id, NameDataValues &data) { NameDataMap::const_iterator it = FetchNameData(id); if (it != cacheNameData.end() && it->second.size() > 0) { @@ -524,6 +591,25 @@ bool CStateViewCache::GetAllNameRecords(NameRecordMap& mapNameRecords) { return true; } +bool CStateViewCache::GetAllNameRecordNames(NameRecordNameMap& map) { + map.clear(); + map.insert(cacheNameRecordNames.begin(), cacheNameRecordNames.end()); + + NameRecordNameMap baseMap; + + if (!base->GetAllNameRecordNames(baseMap)) + return false; + + for (auto it = baseMap.begin(); it != baseMap.end(); it++) + if (!it->second.IsNull()) + map.insert(std::make_pair(it->first, it->second)); + + for (auto it = map.begin(); it != map.end();) + it->second.IsNull() ? map.erase(it++) : ++it; + + return true; +} + bool CStateViewCache::GetAllVotes(CVoteMap& mapVotes) { mapVotes.clear(); mapVotes.insert(cacheVotes.begin(), cacheVotes.end()); @@ -668,6 +754,17 @@ NameRecordModifier CStateViewCache::ModifyNameRecord(const uint256 &id, int nHei return NameRecordModifier(*this, ret.first, nHeight); } +NameRecordNameModifier CStateViewCache::ModifyNameRecordName(const uint256 &id, int nHeight) { + assert(!hasModifier); + std::pair ret = cacheNameRecordNames.insert(std::make_pair(id, NameRecordNameValue())); + if (ret.second) { + if (!base->GetNameRecordName(id, ret.first->second)) { + ret.first->second.SetNull(); + } + } + return NameRecordNameModifier(*this, ret.first, nHeight); +} + NameDataModifier CStateViewCache::ModifyNameData(const uint256 &id, int nHeight) { assert(!hasModifier); std::pair ret = cacheNameData.insert(std::make_pair(id, NameDataValues())); @@ -841,6 +938,15 @@ bool CStateViewCache::AddNameRecord(const NameRecord& namerecord) const { return true; } +bool CStateViewCache::AddNameRecordName(const NameRecordName& name) const { + if (cacheNameRecordNames.count(name.first)) + cacheNameRecordNames[name.first]=name.second; + else + cacheNameRecordNames.insert(std::make_pair(name.first, name.second)); + + return true; +} + bool CStateViewCache::AddNameData(const uint256& id, const NameDataEntry& namerecord) const { if (cacheNameData.count(id)) { cacheNameData[id].erase( @@ -915,6 +1021,22 @@ bool CStateViewCache::RemoveNameRecord(const uint256 &id) const { return true; } +bool CStateViewCache::RemoveNameRecordName(const uint256 &id, const int64_t& height) const { + if (!HaveNameRecordName(id)) + return false; + + if (cacheNameRecordNames.count(id)) + { + if (cacheNameRecordNames[id].height == height) { + cacheNameRecordNames[id] = NameRecordNameValue(); + + assert(cacheNameRecordNames[id].IsNull()); + } + } + + return true; +} + bool CStateViewCache::RemoveNameData(const NameDataKey &id) const { if (!HaveNameData(id.id)) return false; @@ -1048,6 +1170,11 @@ bool CStateViewCache::HaveNameRecord(const uint256 &id) const { return (it != cacheNameRecords.end() && !it->second.IsNull()); } +bool CStateViewCache::HaveNameRecordName(const uint256 &id) const { + NameRecordNameMap::const_iterator it = FetchNameRecordName(id); + return (it != cacheNameRecordNames.end() && !it->second.IsNull()); +} + bool CStateViewCache::HaveNameData(const uint256 &id) const { NameDataMap::const_iterator it = FetchNameData(id); return (it != cacheNameData.end() && it->second.size()); @@ -1097,10 +1224,22 @@ void CStateViewCache::SetBestBlock(const uint256 &hashBlockIn) { hashBlock = hashBlockIn; } -bool CStateViewCache::BatchWrite(CCoinsMap &mapCoins, CProposalMap &mapProposals, CPaymentRequestMap &mapPaymentRequests, - CVoteMap& mapVotes, CConsultationMap& mapConsultations, CConsultationAnswerMap& mapAnswers, - CConsensusParameterMap& mapConsensus, TokenMap& mapTokens, TokenUtxoMap& mapTokenUtxos, NameRecordMap& mapNameRecords, - NameDataMap& mapNameData, const uint256 &hashBlockIn, const int &nCacheExcludeVotesIn) { +bool CStateViewCache::BatchWrite( + CCoinsMap &mapCoins, + CProposalMap &mapProposals, + CPaymentRequestMap &mapPaymentRequests, + CVoteMap& mapVotes, + CConsultationMap& mapConsultations, + CConsultationAnswerMap& mapAnswers, + CConsensusParameterMap& mapConsensus, + TokenMap& mapTokens, + TokenUtxoMap& mapTokenUtxos, + NameRecordMap& mapNameRecords, + NameRecordNameMap& mapNameRecordNames, + NameDataMap& mapNameData, + const uint256 &hashBlockIn, + const int &nCacheExcludeVotesIn) +{ assert(!hasModifier); assert(!hasModifierConsensus); for (CCoinsMap::iterator it = mapCoins.begin(); it != mapCoins.end();) { @@ -1218,6 +1357,13 @@ bool CStateViewCache::BatchWrite(CCoinsMap &mapCoins, CProposalMap &mapProposals mapNameRecords.erase(itOld); } + for (NameRecordNameMap::iterator it = mapNameRecordNames.begin(); it != mapNameRecordNames.end();) { + NameRecordNameValue& entry = cacheNameRecordNames[it->first]; + entry.swap(it->second); + NameRecordNameMap::iterator itOld = it++; + mapNameRecordNames.erase(itOld); + } + for (NameDataMap::iterator it = mapNameData.begin(); it != mapNameData.end();) { NameDataValues& entry = cacheNameData[it->first]; entry.swap(it->second); @@ -1231,7 +1377,22 @@ bool CStateViewCache::BatchWrite(CCoinsMap &mapCoins, CProposalMap &mapProposals } bool CStateViewCache::Flush() { - bool fOk = base->BatchWrite(cacheCoins, cacheProposals, cachePaymentRequests, cacheVotes, cacheConsultations, cacheAnswers, cacheConsensus, cacheTokens, cacheTokenUtxos, cacheNameRecords, cacheNameData, hashBlock, nCacheExcludeVotes); + bool fOk = base->BatchWrite( + cacheCoins, + cacheProposals, + cachePaymentRequests, + cacheVotes, + cacheConsultations, + cacheAnswers, + cacheConsensus, + cacheTokens, + cacheTokenUtxos, + cacheNameRecords, + cacheNameRecordNames, + cacheNameData, + hashBlock, + nCacheExcludeVotes + ); cacheCoins.clear(); cacheProposals.clear(); cachePaymentRequests.clear(); @@ -1242,6 +1403,7 @@ bool CStateViewCache::Flush() { cacheTokens.clear(); cacheTokenUtxos.clear(); cacheNameRecords.clear(); + cacheNameRecordNames.clear(); cacheNameData.clear(); cachedCoinsUsage = 0; nCacheExcludeVotes = -1; @@ -1515,6 +1677,12 @@ NameRecordModifier::NameRecordModifier(CStateViewCache& cache_, NameRecordMap::i prev = it->second; } +NameRecordNameModifier::NameRecordNameModifier(CStateViewCache& cache_, NameRecordNameMap::iterator it_, int height_) : cache(cache_), it(it_), height(height_) { + assert(!cache.hasModifier); + cache.hasModifier = true; + prev = it->second; +} + NameRecordModifier::~NameRecordModifier() { assert(cache.hasModifier); @@ -1530,6 +1698,21 @@ NameRecordModifier::~NameRecordModifier() } } +NameRecordNameModifier::~NameRecordNameModifier() +{ + assert(cache.hasModifier); + cache.hasModifier = false; + + if (it->second.IsNull()) { + cache.cacheNameRecordNames[it->first].SetNull(); + } + + if (!(prev == it->second)) + { + LogPrint("daoextra", "%s: Modified %sname record name %s\n", __func__, height>0?strprintf("at height %d ",height):"",it->first.ToString()); + } +} + NameDataModifier::NameDataModifier(CStateViewCache& cache_, NameDataMap::iterator it_, int height_) : cache(cache_), it(it_), height(height_) { assert(!cache.hasModifier); cache.hasModifier = true; diff --git a/src/coins.h b/src/coins.h index 77bad3110..dddaa0d0e 100644 --- a/src/coins.h +++ b/src/coins.h @@ -16,8 +16,10 @@ #include #include #include -#include #include +#include +#include +#include #include #include @@ -395,6 +397,10 @@ class CStateView virtual bool GetAllNameRecords(NameRecordMap& map); virtual bool HaveNameRecord(const uint256 &id) const; + virtual bool GetNameRecordName(const uint256 &id, NameRecordNameValue& name) const; + virtual bool GetAllNameRecordNames(NameRecordNameMap& map); + virtual bool HaveNameRecordName(const uint256 &id) const; + virtual bool GetNameData(const uint256& id, NameDataValues& data); virtual bool HaveNameData(const uint256& id) const; @@ -406,12 +412,21 @@ class CStateView //! Do a bulk modification (multiple CCoins changes + BestBlock change). //! The passed mapCoins can be modified. - virtual bool BatchWrite(CCoinsMap &mapCoins, CProposalMap &mapProposals, - CPaymentRequestMap &mapPaymentRequests, CVoteMap &mapVotes, - CConsultationMap &mapConsultations, CConsultationAnswerMap &mapAnswers, - CConsensusParameterMap& mapConsensus, TokenMap& mapTokens, TokenUtxoMap& mapTokenUtxos, - NameRecordMap& mapNameRecords, NameDataMap& mapNameData, - const uint256 &hashBlock, const int &nCacheExcludeVotes); + virtual bool BatchWrite( + CCoinsMap &mapCoins, + CProposalMap &mapProposals, + CPaymentRequestMap &mapPaymentRequests, + CVoteMap &mapVotes, + CConsultationMap &mapConsultations, + CConsultationAnswerMap &mapAnswers, + CConsensusParameterMap& mapConsensus, + TokenMap& mapTokens, + TokenUtxoMap& mapTokenUtxos, + NameRecordMap& mapNameRecords, + NameRecordNameMap& mapNameRecordNames, + NameDataMap& mapNameData, + const uint256 &hashBlock, + const int &nCacheExcludeVotes); //! Get a cursor to iterate over the whole state virtual CStateViewCursor *Cursor() const; @@ -459,6 +474,10 @@ class CStateViewBacked : public CStateView bool GetAllNameRecords(NameRecordMap& map); bool HaveNameRecord(const uint256 &id) const; + bool GetNameRecordName(const uint256 &id, NameRecordNameValue& name) const; + bool GetAllNameRecordNames(NameRecordNameMap& map); + bool HaveNameRecordName(const uint256 &id) const; + bool GetNameData(const uint256 &id, NameDataValues& data); bool HaveNameData(const uint256 &id) const; @@ -467,12 +486,21 @@ class CStateViewBacked : public CStateView uint256 GetBestBlock() const; void SetBackend(CStateView &viewIn); - bool BatchWrite(CCoinsMap &mapCoins, CProposalMap &mapProposals, - CPaymentRequestMap &mapPaymentRequests, CVoteMap &mapVotes, - CConsultationMap &mapConsultations, CConsultationAnswerMap &mapAnswers, - CConsensusParameterMap& mapConsensus, TokenMap& mapTokens, TokenUtxoMap& mapTokenUtxos, - NameRecordMap& mapNameRecords, NameDataMap& mapNameData, - const uint256 &hashBlock, const int &nCacheExcludeVotes); + bool BatchWrite( + CCoinsMap &mapCoins, + CProposalMap &mapProposals, + CPaymentRequestMap &mapPaymentRequests, + CVoteMap &mapVotes, + CConsultationMap &mapConsultations, + CConsultationAnswerMap &mapAnswers, + CConsensusParameterMap& mapConsensus, + TokenMap& mapTokens, + TokenUtxoMap& mapTokenUtxos, + NameRecordMap& mapNameRecords, + NameRecordNameMap& mapNameRecordNames, + NameDataMap& mapNameData, + const uint256 &hashBlock, + const int &nCacheExcludeVotes); CStateViewCursor *Cursor() const; }; @@ -628,6 +656,22 @@ class NameRecordModifier friend class CStateViewCache; }; +class NameRecordNameModifier +{ +private: + CStateViewCache& cache; + NameRecordNameMap::iterator it; + NameRecordNameModifier(CStateViewCache& cache_, NameRecordNameMap::iterator it_, int height=0); + NameRecordNameValue prev; + int height; + +public: + NameRecordNameValue* operator->() { return &it->second; } + NameRecordNameValue& operator*() { return it->second; } + ~NameRecordNameModifier(); + friend class CStateViewCache; +}; + class NameDataModifier { private: @@ -683,6 +727,7 @@ class CStateViewCache : public CStateViewBacked mutable TokenMap cacheTokens; mutable TokenUtxoMap cacheTokenUtxos; mutable NameRecordMap cacheNameRecords; + mutable NameRecordNameMap cacheNameRecordNames; mutable NameDataMap cacheNameData; mutable int nCacheExcludeVotes; @@ -705,6 +750,7 @@ class CStateViewCache : public CStateViewBacked bool HaveToken(const uint256& id) const; bool HaveTokenUtxos(const uint256 &id) const; bool HaveNameRecord(const uint256& id) const; + bool HaveNameRecordName(const uint256& id) const; bool HaveNameData(const uint256& id) const; bool GetProposal(const uint256 &txid, CProposal &proposal) const; bool GetPaymentRequest(const uint256 &txid, CPaymentRequest &prequest) const; @@ -715,6 +761,7 @@ class CStateViewCache : public CStateViewBacked bool GetToken(const uint256& pid, TokenInfo& token) const; bool GetTokenUtxos(const uint256 &id, TokenUtxoValues &tokenUtxos); bool GetNameRecord(const uint256& pid, NameRecordValue& height) const; + bool GetNameRecordName(const uint256& pid, NameRecordNameValue& name) const; bool GetNameData(const uint256& pid, NameDataValues& data); bool GetAllProposals(CProposalMap& map); bool GetAllPaymentRequests(CPaymentRequestMap& map); @@ -723,15 +770,25 @@ class CStateViewCache : public CStateViewBacked bool GetAllConsultationAnswers(CConsultationAnswerMap& map); bool GetAllTokens(TokenMap& map); bool GetAllNameRecords(NameRecordMap& map); + bool GetAllNameRecordNames(NameRecordNameMap& map); bool GetAnswersForConsultation(CConsultationAnswerMap& map, const uint256& parent); uint256 GetBestBlock() const; void SetBestBlock(const uint256 &hashBlock); - bool BatchWrite(CCoinsMap &mapCoins, CProposalMap &mapProposals, - CPaymentRequestMap &mapPaymentRequests, CVoteMap &mapVotes, - CConsultationMap &mapConsultations, CConsultationAnswerMap &mapAnswers, - CConsensusParameterMap& mapConsensus, TokenMap& mapTokens, TokenUtxoMap& mapTokenUtxos, - NameRecordMap& mapNameRecords, NameDataMap& mapNameData, - const uint256 &hashBlockIn, const int &nCacheExcludeVotes); + bool BatchWrite( + CCoinsMap &mapCoins, + CProposalMap &mapProposals, + CPaymentRequestMap &mapPaymentRequests, + CVoteMap &mapVotes, + CConsultationMap &mapConsultations, + CConsultationAnswerMap &mapAnswers, + CConsensusParameterMap& mapConsensus, + TokenMap& mapTokens, + TokenUtxoMap& mapTokenUtxos, + NameRecordMap& mapNameRecords, + NameRecordNameMap& mapNameRecordNames, + NameDataMap& mapNameData, + const uint256 &hashBlockIn, + const int &nCacheExcludeVotes); bool AddProposal(const CProposal& proposal) const; bool AddPaymentRequest(const CPaymentRequest& prequest) const; bool AddCachedVoter(const CVoteMapKey &voter, CVoteMapValue& vote) const; @@ -739,6 +796,7 @@ class CStateViewCache : public CStateViewBacked bool AddToken(const Token& token) const; bool AddTokenUtxo(const uint256 &id, const TokenUtxoEntry& utxo) const; bool AddNameRecord(const NameRecord& record) const; + bool AddNameRecordName(const NameRecordName& name) const; bool AddNameData(const uint256& id, const NameDataEntry& record) const; bool AddConsultationAnswer(const CConsultationAnswer& answer); bool RemoveProposal(const uint256 &pid) const; @@ -747,6 +805,7 @@ class CStateViewCache : public CStateViewBacked bool RemoveToken(const uint256 &pid) const; bool RemoveTokenUtxo(const TokenUtxoKey &key) const; bool RemoveNameRecord(const uint256 &pid) const; + bool RemoveNameRecordName(const uint256 &id, const int64_t& height) const; bool RemoveNameData(const NameDataKey &id) const; bool RemoveConsultation(const uint256 &cid); bool RemoveConsultationAnswer(const uint256 &cid); @@ -786,6 +845,7 @@ class CStateViewCache : public CStateViewBacked TokenModifier ModifyToken(const uint256 &id, int nHeight = 0); TokenUtxosModifier ModifyTokenUtxos(const uint256 &id, int blockHeight = 0); NameRecordModifier ModifyNameRecord(const uint256 &id, int nHeight = 0); + NameRecordNameModifier ModifyNameRecordName(const uint256 &id, int nHeight = 0); NameDataModifier ModifyNameData(const uint256& id, int nHeight = 0); /** @@ -850,6 +910,7 @@ class CStateViewCache : public CStateViewBacked friend class TokenModifier; friend class TokenUtxosModifier; friend class NameRecordModifier; + friend class NameRecordNameModifier; friend class NameDataModifier; private: @@ -864,6 +925,7 @@ class CStateViewCache : public CStateViewBacked TokenMap::const_iterator FetchToken(const uint256 &id) const; TokenUtxoMap::const_iterator FetchTokenUtxos(const uint256 &id) const; NameRecordMap::const_iterator FetchNameRecord(const uint256 &id) const; + NameRecordNameMap::const_iterator FetchNameRecordName(const uint256 &id) const; NameDataMap::const_iterator FetchNameData(const uint256 &id) const; /** diff --git a/src/dotnav/namerecordname.h b/src/dotnav/namerecordname.h new file mode 100644 index 000000000..89793fb1c --- /dev/null +++ b/src/dotnav/namerecordname.h @@ -0,0 +1,62 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2015 The Bitcoin Core developers +// Copyright (c) 2021 The Navcoin developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef NAVCOIN_NAME_RECORD_NAME_H +#define NAVCOIN_NAME_RECORD_NAME_H + +#include + +class NameRecordNameValue { +public: + std::string domain; + std::string subdomain; + int64_t height; + + NameRecordNameValue() { + SetNull(); + } + + NameRecordNameValue(const std::string& domain_, const std::string& subdomain_, const int64_t& height_) { + domain = domain_; + subdomain = subdomain_; + height = height_; + }; + + void SetNull() { + domain = ""; + subdomain = ""; + height = 0; + } + + bool IsNull() const { + return domain == ""; + } + + bool operator==(const NameRecordNameValue& other) { + return (domain == other.domain && subdomain == other.subdomain && height == other.height); + } + + void swap(NameRecordNameValue &to) { + std::swap(to.domain, domain); + std::swap(to.subdomain, subdomain); + std::swap(to.height, height); + } + + ADD_SERIALIZE_METHODS; + + template + inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + READWRITE(domain); + READWRITE(subdomain); + READWRITE(height); + } +}; + +typedef std::map NameRecordNameMap; +typedef std::pair NameRecordName; + + +#endif // NAVCOIN_NAME_RECORD_NAME_H diff --git a/src/init.cpp b/src/init.cpp index 8ed2f530f..440f4d6a9 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -428,6 +428,7 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-allindex", strprintf(_("Maintain all indexes supported (default: %u)"), DEFAULT_ALLINDEX)); strUsage += HelpMessageOpt("-txindex", strprintf(_("Maintain a full transaction index, used by the getrawtransaction rpc call (default: %u)"), DEFAULT_TXINDEX)); strUsage += HelpMessageOpt("-nftindex", strprintf(_("Maintain an index of ntf data, used by the nft related rpc calls (default: %u)"), DEFAULT_NFTINDEX)); + strUsage += HelpMessageOpt("-nameindex", strprintf(_("Maintain an index of names, used by the `listnames` rpc call (default: %u)"), DEFAULT_NAMEINDEX)); strUsage += HelpMessageOpt("-addressindex", strprintf(_("Maintain a full address index, used to query for the balance, txids and unspent outputs for addresses (default: %u)"), DEFAULT_ADDRESSINDEX)); strUsage += HelpMessageOpt("-timestampindex", strprintf(_("Maintain a timestamp index for block hashes, used to query blocks hashes by a range of timestamps (default: %u)"), DEFAULT_TIMESTAMPINDEX)); @@ -1636,6 +1637,12 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler, const std break; } + // Check for changed -nameindex state + if (fNameIndex != GetBoolArg("-nameindex", DEFAULT_NAMEINDEX)) { + strLoadError = _("You need to rebuild the database using -reindex-chainstate to change -nameindex"); + break; + } + // Check for changed -addressindex state if (fAddressIndex != GetBoolArg("-addressindex", DEFAULT_ADDRESSINDEX)) { strLoadError = _("You need to rebuild the database using -reindex-chainstate to change -addressindex"); diff --git a/src/main.cpp b/src/main.cpp index d49021415..68df15467 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -79,6 +79,7 @@ bool fReindex = false; bool fVerifyChain = false; bool fTxIndex = false; bool fNftIndex = false; +bool fNameIndex = false; bool fAddressIndex = false; bool fTimestampIndex = false; bool fSpentIndex = false; @@ -2994,6 +2995,13 @@ bool DisconnectBlock(const CBlock& block, CValidationState& state, const CBlockI view.RemoveNameData(NameDataKey(program.sParameters[0], pindex->nHeight)); LogPrint("dotnav", "%s: removing name data for %s %d\n", __func__, program.sParameters[0], pindex->nHeight); } + + if (fNameIndex) { + if (program.action == UPDATE_NAME_FIRST || program.action == UPDATE_NAME || program.action == RENEW_NAME) { + if (view.HaveNameRecordName(DotNav::GetHashName(program.sParameters[1] + "." + program.sParameters[0]))) + view.RemoveNameRecordName(DotNav::GetHashName(program.sParameters[1] + "." + program.sParameters[0]), pindex->nHeight); + } + } } } catch(...) { return state.DoS(100, false, REJECT_INVALID, "error-program-vdata"); @@ -4995,6 +5003,13 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin LogPrint("dotnav", "%s: updated name %s %s %s %s\n", __func__, program.sParameters[1], program.sParameters[0], program.sParameters[2], program.sParameters[3]); } + + if (fNameIndex) { + if (program.action == UPDATE_NAME_FIRST || program.action == UPDATE_NAME || program.action == RENEW_NAME) { + if (!view.HaveNameRecordName(DotNav::GetHashName(program.sParameters[1] + "." + program.sParameters[0]))) + view.AddNameRecordName(std::make_pair(DotNav::GetHashName(program.sParameters[1] + "." + program.sParameters[0]), NameRecordNameValue(program.sParameters[0], program.sParameters[1], pindex->nHeight))); + } + } } } catch(...) { return state.DoS(100, false, REJECT_INVALID, "error-program-vdata"); @@ -7352,6 +7367,10 @@ bool static LoadBlockIndexDB() pblocktree->ReadFlag("nftindex", fNftIndex); LogPrintf("%s: nft index %s\n", __func__, fNftIndex ? "enabled" : "disabled"); + // Check whether we have a name index + pblocktree->ReadFlag("nameindex", fNameIndex); + LogPrintf("%s: name index %s\n", __func__, fNameIndex ? "enabled" : "disabled"); + // Check whether we have an address index pblocktree->ReadFlag("addressindex", fAddressIndex); LogPrintf("%s: address index %s\n", __func__, fAddressIndex ? "enabled" : "disabled"); @@ -7776,6 +7795,7 @@ bool InitBlockIndex(const CChainParams& chainparams) // Load the flag values | use DEFAULT_* values if not set fTxIndex = GetBoolArg("-txindex", DEFAULT_TXINDEX); fNftIndex = GetBoolArg("-nftindex", DEFAULT_NFTINDEX); + fNameIndex = GetBoolArg("-nameindex", DEFAULT_NAMEINDEX); fAddressIndex = GetBoolArg("-addressindex", DEFAULT_ADDRESSINDEX); fTimestampIndex = GetBoolArg("-timestampindex", DEFAULT_TIMESTAMPINDEX); fSpentIndex = GetBoolArg("-spentindex", DEFAULT_SPENTINDEX); @@ -7783,7 +7803,7 @@ bool InitBlockIndex(const CChainParams& chainparams) // Check if we want all indexes if (GetBoolArg("-allindex", DEFAULT_ALLINDEX)) { - fTxIndex = fNftIndex = fAddressIndex = fTimestampIndex = fSpentIndex = true; + fTxIndex = fNftIndex = fNameIndex = fAddressIndex = fTimestampIndex = fSpentIndex = true; } // Use the provided setting for -txindex in the new database @@ -7794,6 +7814,10 @@ bool InitBlockIndex(const CChainParams& chainparams) pblocktree->WriteFlag("nftindex", fNftIndex); LogPrintf("%s: nft index %s\n", __func__, fNftIndex ? "enabled" : "disabled"); + // Use the provided setting for -nameindex in the new database + pblocktree->WriteFlag("nameindex", fNameIndex); + LogPrintf("%s: name index %s\n", __func__, fNameIndex ? "enabled" : "disabled"); + // Use the provided setting for -addressindex in the new database pblocktree->WriteFlag("addressindex", fAddressIndex); LogPrintf("%s: address index %s\n", __func__, fAddressIndex ? "enabled" : "disabled"); diff --git a/src/main.h b/src/main.h index 094392880..3410ab242 100644 --- a/src/main.h +++ b/src/main.h @@ -148,6 +148,7 @@ static const bool DEFAULT_CHECKPOINTS_ENABLED = true; static const bool DEFAULT_ALLINDEX = false; static const bool DEFAULT_TXINDEX = false; static const bool DEFAULT_NFTINDEX = false; +static const bool DEFAULT_NAMEINDEX = false; static const bool DEFAULT_ADDRESSINDEX = false; static const bool DEFAULT_TIMESTAMPINDEX = false; static const bool DEFAULT_SPENTINDEX = false; @@ -206,6 +207,7 @@ extern bool fVerifyChain; extern int nScriptCheckThreads; extern bool fTxIndex; extern bool fNftIndex; +extern bool fNameIndex; extern bool fAddressIndex; extern bool fSpentIndex; extern bool fTimestampIndex; diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 03b3a46b0..d9f08ef23 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -107,6 +107,9 @@ static const CRPCConvertParam vRPCConvertParams[] = { "keypoolrefill", 0 }, { "listaccounts", 0 }, { "listaccounts", 1 }, + { "listnames", 0 }, + { "listnfts", 0 }, + { "listnfts", 1 }, { "listprivateunspent", 0 }, { "listprivateunspent", 1 }, { "listprivateunspent", 2 }, @@ -119,8 +122,6 @@ static const CRPCConvertParam vRPCConvertParams[] = { "listsinceblock", 1 }, { "listsinceblock", 2 }, { "listtokens", 0 }, - { "listnfts", 0 }, - { "listnfts", 1 }, { "listtransactions", 1 }, { "listtransactions", 2 }, { "listtransactions", 3 }, diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp index 71d4dffde..3d25051a7 100644 --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -48,10 +48,15 @@ class CStateViewTest : public CStateView uint256 GetBestBlock() const { return hashBestBlock_; } - bool BatchWrite(CCoinsMap &mapCoins, CProposalMap &mapProposals, - CPaymentRequestMap &mapPaymentRequests, CVoteMap &mapVotes, - CConsultationMap &mapConsultations, CConsultationAnswerMap &mapAnswers, - CConsensusParameterMap& mapConsensus, const uint256 &hashBlock) + bool BatchWrite( + CCoinsMap &mapCoins, + CProposalMap &mapProposals, + CPaymentRequestMap &mapPaymentRequests, + CVoteMap &mapVotes, + CConsultationMap &mapConsultations, + CConsultationAnswerMap &mapAnswers, + CConsensusParameterMap& mapConsensus, + const uint256 &hashBlock) { for (CCoinsMap::iterator it = mapCoins.begin(); it != mapCoins.end(); ) { if (it->second.flags & CCoinsCacheEntry::DIRTY) { diff --git a/src/txdb.cpp b/src/txdb.cpp index e8633b113..e11c9878f 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -42,6 +42,7 @@ static const char DB_EXCLUDE_VOTES = 'X'; static const char DB_TOKENS = 'T'; static const char DB_TOKEN_UTXO = 'Z'; static const char DB_NAME_RECORDS = 'n'; +static const char DB_NAME_RECORD_NAMES = 'm'; static const char DB_NAME_DATA = 'N'; CStateViewDB::CStateViewDB(size_t nCacheSize, bool fMemory, bool fWipe) : db(GetDataDir() / "chainstate", nCacheSize, fMemory, fWipe, true, false, 64) @@ -254,6 +255,7 @@ bool CStateViewDB::GetNameData(const uint256& id, NameDataValues& map) { return true; } + bool CStateViewDB::GetAllNameRecords(NameRecordMap &map) { map.clear(); @@ -280,6 +282,32 @@ bool CStateViewDB::GetAllNameRecords(NameRecordMap &map) { return true; } +bool CStateViewDB::GetAllNameRecordNames(NameRecordNameMap &map) { + map.clear(); + + boost::scoped_ptr pcursor(db.NewIterator()); + + pcursor->Seek(std::make_pair(DB_NAME_RECORD_NAMES, uint256())); + + while (pcursor->Valid()) { + boost::this_thread::interruption_point(); + std::pair key; + if (pcursor->GetKey(key) && key.first == DB_NAME_RECORD_NAMES) { + NameRecordNameValue name; + if (pcursor->GetValue(name)) { + map.insert(std::make_pair(key.second, name)); + pcursor->Next(); + } else { + return error("GetAllNameRecordNames() : failed to read value"); + } + } else { + break; + } + } + + return true; +} + bool CStateViewDB::GetAllPaymentRequests(CPaymentRequestMap &map) { map.clear(); @@ -384,13 +412,22 @@ bool CStateViewDB::GetAllConsultationAnswers(CConsultationAnswerMap &map) { return true; } -bool CStateViewDB::BatchWrite(CCoinsMap &mapCoins, CProposalMap &mapProposals, - CPaymentRequestMap &mapPaymentRequests, CVoteMap &mapVotes, - CConsultationMap &mapConsultations, CConsultationAnswerMap &mapAnswers, - CConsensusParameterMap &mapConsensus, - TokenMap &mapTokens, TokenUtxoMap &mapTokenUtxos, NameRecordMap &mapNameRecords, - NameDataMap& mapNameData, - const uint256 &hashBlock, const int &nExcludeVotes) { +bool CStateViewDB::BatchWrite( + CCoinsMap &mapCoins, + CProposalMap &mapProposals, + CPaymentRequestMap &mapPaymentRequests, + CVoteMap &mapVotes, + CConsultationMap &mapConsultations, + CConsultationAnswerMap &mapAnswers, + CConsensusParameterMap &mapConsensus, + TokenMap &mapTokens, + TokenUtxoMap &mapTokenUtxos, + NameRecordMap &mapNameRecords, + NameRecordNameMap &mapNameRecordNames, + NameDataMap& mapNameData, + const uint256 &hashBlock, + const int &nExcludeVotes) +{ CDBBatch batch(db); size_t count = 0; @@ -520,6 +557,17 @@ bool CStateViewDB::BatchWrite(CCoinsMap &mapCoins, CProposalMap &mapProposals, mapNameRecords.erase(itOld); } + for (NameRecordNameMap::iterator it = mapNameRecordNames.begin(); it != mapNameRecordNames.end();) { + LogPrint("dotnav", "%s: domain %s subdomain %s\n", __func__, it->second.domain, it->second.subdomain); + if (it->second.IsNull()) { + batch.Erase(std::make_pair(DB_NAME_RECORD_NAMES, it->first)); + } else { + batch.Write(std::make_pair(DB_NAME_RECORD_NAMES, it->first), it->second); + } + NameRecordNameMap::iterator itOld = it++; + mapNameRecordNames.erase(itOld); + } + for (NameDataMap::iterator it = mapNameData.begin(); it != mapNameData.end();) { if (it->second.size() == 0) { batch.Erase(std::make_pair(DB_NAME_DATA, it->first)); diff --git a/src/txdb.h b/src/txdb.h index 25624ac18..f5c4befc5 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -124,12 +124,21 @@ class CStateViewDB : public CStateView bool HaveNameData(const uint256& id) const; uint256 GetBestBlock() const; - bool BatchWrite(CCoinsMap &mapCoins, CProposalMap &mapProposals, - CPaymentRequestMap &mapPaymentRequests, CVoteMap &mapVotes, - CConsultationMap &mapConsultations, CConsultationAnswerMap &mapAnswers, - CConsensusParameterMap& mapConsensus, TokenMap& mapTokens, TokenUtxoMap &mapTokenUtxos, - NameRecordMap& mapNameRecords, NameDataMap& mapNameData, - const uint256 &hashBlock, const int &nExcludeVotes); + bool BatchWrite( + CCoinsMap &mapCoins, + CProposalMap &mapProposals, + CPaymentRequestMap &mapPaymentRequests, + CVoteMap &mapVotes, + CConsultationMap &mapConsultations, + CConsultationAnswerMap &mapAnswers, + CConsensusParameterMap& mapConsensus, + TokenMap& mapTokens, + TokenUtxoMap &mapTokenUtxos, + NameRecordMap& mapNameRecords, + NameRecordNameMap& mapNameRecordNames, + NameDataMap& mapNameData, + const uint256 &hashBlock, + const int &nExcludeVotes); bool GetAllProposals(CProposalMap& map); bool GetAllPaymentRequests(CPaymentRequestMap& map); bool GetAllVotes(CVoteMap &map); @@ -137,6 +146,7 @@ class CStateViewDB : public CStateView bool GetAllConsultationAnswers(CConsultationAnswerMap &map); bool GetAllTokens(TokenMap &map); bool GetAllNameRecords(NameRecordMap &map); + bool GetAllNameRecordNames(NameRecordNameMap &map); int GetExcludeVotes() const; CStateViewCursor *Cursor() const; }; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index d9e748369..8c039244b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -38,9 +38,7 @@ static CCriticalSection cs_nWalletUnlockTime; std::string HelpRequiringPassphrase() { - return pwalletMain && pwalletMain->IsCrypted() - ? "\nRequires wallet passphrase to be set with walletpassphrase call." - : ""; + return pwalletMain && pwalletMain->IsCrypted() ? "\nRequires wallet passphrase to be set with walletpassphrase call." : ""; } bool EnsureWalletIsAvailable(bool avoidException) @@ -168,12 +166,12 @@ UniValue listprivateunspent(const UniValue& params, bool fHelp) " \"txid\" : \"txid\", (string) the transaction id \n" " \"vout\" : n, (numeric) the vout value\n" " \"amount\" : x.xxx, (numeric) the transaction amount in " + CURRENCY_UNIT + "\n" - " \"confirmations\" : n (numeric) The number of confirmations\n" - " }\n" - " ,...\n" - "]\n" + " \"confirmations\" : n (numeric) The number of confirmations\n" + " }\n" + " ,...\n" + "]\n" - "\nExamples\n" + "\nExamples\n" + HelpExampleCli("listprivateunspent", "") + HelpExampleCli("listprivateunspent", "6 9999999") ); @@ -257,29 +255,25 @@ UniValue getcoldstakingaddress(const UniValue& params, bool fHelp) if (fHelp || params.size() < 2) throw std::runtime_error( "getcoldstakingaddress \"stakingaddress\" \"spendingaddress\" ( \"votingaddress\" )\n" - "Returns a coldstaking address based on the address inputs\n" - "Arguments:\n" - "1. \"stakingaddress\" (string, required) The navcoin staking address.\n" - "2. \"spendingaddress\" (string, required) The navcoin spending address.\n\n" - "3. \"voting\" (string, optional) The navcoin voting address.\n\n" - "\nExamples:\n" - + HelpExampleCli("getcoldstakingaddress", "\"mqyGZvLYfEH27Zk3z6JkwJgB1zpjaEHfiW\" \"mrfjgazyerYxDQHJAPDdUcC3jpmi8WZ2uv\"") + + "Returns a coldstaking address based on the address inputs\n" + "Arguments:\n" + "1. \"stakingaddress\" (string, required) The navcoin staking address.\n" + "2. \"spendingaddress\" (string, required) The navcoin spending address.\n\n" + "3. \"voting\" (string, optional) The navcoin voting address.\n\n" + "\nExamples:\n" + + HelpExampleCli("getcoldstakingaddress", "\"mqyGZvLYfEH27Zk3z6JkwJgB1zpjaEHfiW\" \"mrfjgazyerYxDQHJAPDdUcC3jpmi8WZ2uv\"") + "\nAs a json rpc call\n" - + HelpExampleRpc("getcoldstakingaddress", "\"mqyGZvLYfEH27Zk3z6JkwJgB1zpjaEHfiW\", \"mrfjgazyerYxDQHJAPDdUcC3jpmi8WZ2uv\"") + + HelpExampleRpc("getcoldstakingaddress", "\"mqyGZvLYfEH27Zk3z6JkwJgB1zpjaEHfiW\", \"mrfjgazyerYxDQHJAPDdUcC3jpmi8WZ2uv\"") ); if (!IsColdStakingEnabled(chainActive.Tip(),Params().GetConsensus())) - throw std::runtime_error( - "Cold Staking is not active yet."); + throw std::runtime_error("Cold Staking is not active yet."); if (!IsColdStakingv2Enabled(chainActive.Tip(), Params().GetConsensus()) && params.size() == 3) - throw std::runtime_error( - "Cold Staking v2 is not active yet."); + throw std::runtime_error("Cold Staking v2 is not active yet."); if (params[0].get_str() == params[1].get_str()) - throw std::runtime_error( - "The staking address should be different to the spending address" - ); + throw std::runtime_error("The staking address should be different to the spending address"); CNavcoinAddress stakingAddress(params[0].get_str()); @@ -665,17 +659,17 @@ UniValue sendtoaddress(const UniValue& params, bool fHelp) "\nArguments:\n" "1. \"navcoinaddress\" (string, required) The navcoin address to send to.\n" "2. \"amount\" (numeric or string, required) The amount in " + CURRENCY_UNIT + " to send. eg 0.1\n" - "3. \"comment\" (string, optional) A comment used to store what the transaction is for. \n" - " This is not part of the transaction, just kept in your wallet.\n" - "4. \"comment-to\" (string, optional) A comment to store the name of the person or organization \n" - " to which you're sending the transaction. This is not part of the \n" - " transaction, just kept in your wallet.\n" - "5. \"strdzeel\" (string, optional) Attached string metadata \n" - "6. subtractfeefromamount (boolean, optional, default=false) The fee will be deducted from the amount being sent.\n" - " The recipient will receive less navcoins than you enter in the amount field.\n" - "\nResult:\n" - "\"transactionid\" (string) The transaction id.\n" - "\nExamples:\n" + "3. \"comment\" (string, optional) A comment used to store what the transaction is for. \n" + " This is not part of the transaction, just kept in your wallet.\n" + "4. \"comment-to\" (string, optional) A comment to store the name of the person or organization \n" + " to which you're sending the transaction. This is not part of the \n" + " transaction, just kept in your wallet.\n" + "5. \"strdzeel\" (string, optional) Attached string metadata \n" + "6. subtractfeefromamount (boolean, optional, default=false) The fee will be deducted from the amount being sent.\n" + " The recipient will receive less navcoins than you enter in the amount field.\n" + "\nResult:\n" + "\"transactionid\" (string) The transaction id.\n" + "\nExamples:\n" + HelpExampleCli("sendtoaddress", "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.1") + HelpExampleCli("sendtoaddress", "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.1 \"donation\" \"seans outpost\"") + HelpExampleCli("sendtoaddress", "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.1 \"\" \"\" \"\" true") @@ -754,17 +748,17 @@ UniValue privatesendtoaddress(const UniValue& params, bool fHelp) "\nArguments:\n" "1. \"navcoinaddress\" (string, required) The navcoin address to send to.\n" "2. \"amount\" (numeric or string, required) The amount in " + CURRENCY_UNIT + " to send. eg 0.1\n" - "3. \"comment\" (string, optional) A comment used to store what the transaction is for. \n" - " This is part of the transaction and will be seen by the receiver. Max 54 chars.\n" - "4. \"comment-to\" (string, optional) A comment to store the name of the person or organization \n" - " to which you're sending the transaction. This is not part of the \n" - " transaction, just kept in your wallet.\n" - "5. \"strdzeel\" (string, optional) Attached string metadata \n" - "6. subtractfeefromamount (boolean, optional, default=false) The fee will be deducted from the amount being sent.\n" - " The recipient will receive less navcoins than you enter in the amount field.\n" - "\nResult:\n" - "\"transactionid\" (string) The transaction id.\n" - "\nExamples:\n" + "3. \"comment\" (string, optional) A comment used to store what the transaction is for. \n" + " This is part of the transaction and will be seen by the receiver. Max 54 chars.\n" + "4. \"comment-to\" (string, optional) A comment to store the name of the person or organization \n" + " to which you're sending the transaction. This is not part of the \n" + " transaction, just kept in your wallet.\n" + "5. \"strdzeel\" (string, optional) Attached string metadata \n" + "6. subtractfeefromamount (boolean, optional, default=false) The fee will be deducted from the amount being sent.\n" + " The recipient will receive less navcoins than you enter in the amount field.\n" + "\nResult:\n" + "\"transactionid\" (string) The transaction id.\n" + "\nExamples:\n" + HelpExampleCli("privatesendtoaddress", "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.1") + HelpExampleCli("privatesendtoaddress", "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.1 \"donation\" \"seans outpost\"") + HelpExampleCli("privatesendtoaddress", "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.1 \"\" \"\" true") @@ -886,12 +880,8 @@ UniValue privatesendmixtoaddress(const UniValue& params, bool fHelp) else if (!dnssec_valid && GetBoolArg("-requirednssec",true)) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "OpenAlias Address does not support DNS Sec"); else - { - address_str = addresses.front(); - } - } CNavcoinAddress address(address_str); @@ -1002,22 +992,22 @@ UniValue createproposal(const UniValue& params, bool fHelp) if (fHelp || params.size() < 4) throw std::runtime_error( "createproposal \"navcoinaddress\" \"amount\" duration \"desc\" ( fee dump_raw )\n" - "\nCreates a proposal for the community fund. Min fee of " + FormatMoney(GetConsensusParameter(Consensus::CONSENSUS_PARAM_PROPOSAL_MIN_FEE, view)) + "NAV is required.\n" - + HelpRequiringPassphrase() + + "\nCreates a proposal for the community fund. Min fee of " + FormatMoney(GetConsensusParameter(Consensus::CONSENSUS_PARAM_PROPOSAL_MIN_FEE, view)) + "NAV is required.\n" + + HelpRequiringPassphrase() + "\nArguments:\n" - "1. \"navcoinaddress\" (string, required) The navcoin address where coins would be sent if proposal is approved.\n" - "2. \"amount\" (numeric or string, required) The amount in " + CURRENCY_UNIT + " to request. eg 0.1\n" - "3. duration (numeric, required) Number of seconds the proposal will exist after being accepted.\n" - "4. \"desc\" (string, required) Short description of the proposal.\n" - "5. fee (numeric, optional) Contribution to the fund used as fee.\n" - "6. dump_raw (bool, optional) Dump the raw transaction instead of sending. Default: false\n" - "7. \"owneraddress\" (string, optional) The owner of the proposal who will sign the payment requests. Default: the payment address\n" - "8. super_proposal (bool, optional) Creates a super proposal which would print new coins instead of taking from the fund. Default: false\n" - "\nResult:\n" - "\"{ hash: proposalid,\" (string) The proposal id.\n" - "\" strDZeel: string }\" (string) The attached strdzeel property.\n" - "\nExamples:\n" - + HelpExampleCli("createproposal", "\"NQFqqMUD55ZV3PJEJZtaKCsQmjLT6JkjvJ\" 1000 86400 \"Development\"") + "1. \"navcoinaddress\" (string, required) The navcoin address where coins would be sent if proposal is approved.\n" + "2. \"amount\" (numeric or string, required) The amount in " + CURRENCY_UNIT + " to request. eg 0.1\n" + "3. duration (numeric, required) Number of seconds the proposal will exist after being accepted.\n" + "4. \"desc\" (string, required) Short description of the proposal.\n" + "5. fee (numeric, optional) Contribution to the fund used as fee.\n" + "6. dump_raw (bool, optional) Dump the raw transaction instead of sending. Default: false\n" + "7. \"owneraddress\" (string, optional) The owner of the proposal who will sign the payment requests. Default: the payment address\n" + "8. super_proposal (bool, optional) Creates a super proposal which would print new coins instead of taking from the fund. Default: false\n" + "\nResult:\n" + "\"{ hash: proposalid,\" (string) The proposal id.\n" + "\" strDZeel: string }\" (string) The attached strdzeel property.\n" + "\nExamples:\n" + + HelpExampleCli("createproposal", "\"NQFqqMUD55ZV3PJEJZtaKCsQmjLT6JkjvJ\" 1000 86400 \"Development\"") + HelpExampleCli("createproposal", "\"NQFqqMUD55ZV3PJEJZtaKCsQmjLT6JkjvJ\" 12000 3600 \"Promotional stickers for everyone\" 100") ); @@ -1116,14 +1106,14 @@ UniValue createtoken(const UniValue& params, bool fHelp) if (fHelp || params.size() < 3) throw std::runtime_error( - "createtoken \"name\" \"token_code\" max_supply\n" - "\nCreates a confidential token.\n" - + HelpRequiringPassphrase() + + "createtoken \"name\" \"token_code\" max_supply\n" + "\nCreates a confidential token.\n" + + HelpRequiringPassphrase() + "\nArguments:\n" - "1. \"name\" (string, required) The name of the token\n" - "2. max_supply (numeric, optional) The max supply of the token.\n" - "\nExamples:\n" - + HelpExampleCli("createtoken", "\"BabyNAV\" \"BNAV\" 1000") + "1. \"name\" (string, required) The name of the token\n" + "2. max_supply (numeric, optional) The max supply of the token.\n" + "\nExamples:\n" + + HelpExampleCli("createtoken", "\"BabyNAV\" \"BNAV\" 1000") + HelpExampleCli("createtoken", "\"Wrapped Bitcoin\" \"wBTC\" 21000000") ); @@ -1176,13 +1166,13 @@ UniValue registername(const UniValue& params, bool fHelp) if (fHelp || params.size() < 1) throw std::runtime_error( - "registername \"name\"\n" - "\nRegister a dotNav name.\n" - + HelpRequiringPassphrase() + + "registername \"name\"\n" + "\nRegister a dotNav name.\n" + + HelpRequiringPassphrase() + "\nArguments:\n" - "1. \"name\" (string, required) The name to register\n" - "\nExamples:\n" - + HelpExampleCli("registername", "satoshi.nav") + "1. \"name\" (string, required) The name to register\n" + "\nExamples:\n" + + HelpExampleCli("registername", "satoshi.nav") ); @@ -1233,13 +1223,13 @@ UniValue genkeyname(const UniValue& params, bool fHelp) if (fHelp || params.size() < 1) throw std::runtime_error( - "genkeyname \"name\"\n" - "\nGenerates a public key for receiving a dotNav name.\n" - + HelpRequiringPassphrase() + + "genkeyname \"name\"\n" + "\nGenerates a public key for receiving a dotNav name.\n" + + HelpRequiringPassphrase() + "\nArguments:\n" - "1. \"name\" (string, required) The name \n" - "\nExamples:\n" - + HelpExampleCli("genkeyname", "satoshi.nav") + "1. \"name\" (string, required) The name \n" + "\nExamples:\n" + + HelpExampleCli("genkeyname", "satoshi.nav") ); if (!params[0].isStr() ) @@ -1275,13 +1265,13 @@ UniValue renewname(const UniValue& params, bool fHelp) if (fHelp || params.size() < 1) throw std::runtime_error( - "renewname \"name\"\n" - "\nRenews a dotNav name.\n" - + HelpRequiringPassphrase() + + "renewname \"name\"\n" + "\nRenews a dotNav name.\n" + + HelpRequiringPassphrase() + "\nArguments:\n" - "1. \"name\" (string, required) The name to renew\n" - "\nExamples:\n" - + HelpExampleCli("renewname", "satoshi.nav") + "1. \"name\" (string, required) The name to renew\n" + "\nExamples:\n" + + HelpExampleCli("renewname", "satoshi.nav") ); @@ -1318,15 +1308,15 @@ UniValue resolvename(const UniValue& params, bool fHelp) if (fHelp || params.size() < 1) throw std::runtime_error( - "resolvename \"name\"\n" - "\nResolves a dotNav name.\n" - + HelpRequiringPassphrase() + + "resolvename \"name\"\n" + "\nResolves a dotNav name.\n" + + HelpRequiringPassphrase() + "\nArguments:\n" - "1. \"name\" (string, required) The name to resolve\n" - "2. \"subdomains\" (boolean, optional) Include subdomains\n" - "\nExamples:\n" - + HelpExampleCli("resolvename", "satoshi.nav") - + HelpExampleCli("resolvename", "satoshi.nav true") + "1. \"name\" (string, required) The name to resolve\n" + "2. \"subdomains\" (boolean, optional) Include subdomains\n" + "\nExamples:\n" + + HelpExampleCli("resolvename", "satoshi.nav") + + HelpExampleCli("resolvename", "satoshi.nav true") ); if (!params[0].isStr()) @@ -1410,15 +1400,15 @@ UniValue updatename(const UniValue& params, bool fHelp) if (fHelp || params.size() < 3) throw std::runtime_error( - "updatename \"name\" \"key\" \"value\"\n" - "\nUpdates a dotNav name.\n" - + HelpRequiringPassphrase() + + "updatename \"name\" \"key\" \"value\"\n" + "\nUpdates a dotNav name.\n" + + HelpRequiringPassphrase() + "\nArguments:\n" - "1. \"name\" (string, required) The name to update\n" - "1. \"key\" (string, required) The parameter to update\n" - "1. \"value\" (string, required) The value to set\n" - "\nExamples:\n" - + HelpExampleCli("updatename", "satoshi.nav nav NQFqqMUD55ZV3PJEJZtaKCsQmjLT6JkjvJ") + "1. \"name\" (string, required) The name to update\n" + "1. \"key\" (string, required) The parameter to update\n" + "1. \"value\" (string, required) The value to set\n" + "\nExamples:\n" + + HelpExampleCli("updatename", "satoshi.nav nav NQFqqMUD55ZV3PJEJZtaKCsQmjLT6JkjvJ") ); @@ -1527,16 +1517,16 @@ UniValue createnft(const UniValue& params, bool fHelp) if (fHelp || params.size() < 3) throw std::runtime_error( - "createnft \"name\" \"scheme\" max_supply\n" - "\nCreates a nft.\n" - + HelpRequiringPassphrase() + + "createnft \"name\" \"scheme\" max_supply\n" + "\nCreates a nft.\n" + + HelpRequiringPassphrase() + "\nArguments:\n" - "1. \"name\" (string, required) The name of the NFT\n" - "1. \"scheme\" (string, required) The scheme for the NFT metadata\n" - "2. max_supply (numeric, optional) The max supply of the NFT.\n" - "\nExamples:\n" - + HelpExampleCli("createnft", "\"NAV Artwork\" \"{'resource': 'url'}\" 1000") - + HelpExampleCli("createnft", "\"Game Item\" \"{'type': 'string', 'power': 'int'}\" 100") + "1. \"name\" (string, required) The name of the NFT\n" + "1. \"scheme\" (string, required) The scheme for the NFT metadata\n" + "2. max_supply (numeric, optional) The max supply of the NFT.\n" + "\nExamples:\n" + + HelpExampleCli("createnft", "\"NAV Artwork\" \"{'resource': 'url'}\" 1000") + + HelpExampleCli("createnft", "\"Game Item\" \"{'type': 'string', 'power': 'int'}\" 100") ); @@ -1588,15 +1578,15 @@ UniValue minttoken(const UniValue& params, bool fHelp) if (fHelp || params.size() < 3) throw std::runtime_error( - "minttoken \"tokenid\" \"destination\" amount\n" - "\nMints confidential tokens.\n" - + HelpRequiringPassphrase() + + "minttoken \"tokenid\" \"destination\" amount\n" + "\nMints confidential tokens.\n" + + HelpRequiringPassphrase() + "\nArguments:\n" - "1. \"tokenid\" (string, required) The token id\n" - "2. \"destination\" (string, required) The xNAV destination addressn" - "3. amount (string, required) The amount to mint\n" - "\nExamples:\n" - + HelpExampleCli("minttoken", "\"a7be93b41e708d21d6c94920401ca5fd93dffe33d2bc197077e3b4fafcc8fe45eebb359b4c8f6bc15a303cc2971a0c48\" \"xNUNs2vtjr6QDL1NiL8TDHgmbuEo5WcY2K2jQ8ATj9pko8wkJ9RutkFQKBCtn6SsBjy6nK5ftofFyLFnAHAynreQCZjuE7dCWVxCX5DCFB2bjx87KvbqVVRCs3KBzdDre7c5FUy7QLo\" 1000") + "1. \"tokenid\" (string, required) The token id\n" + "2. \"destination\" (string, required) The xNAV destination addressn" + "3. amount (string, required) The amount to mint\n" + "\nExamples:\n" + + HelpExampleCli("minttoken", "\"a7be93b41e708d21d6c94920401ca5fd93dffe33d2bc197077e3b4fafcc8fe45eebb359b4c8f6bc15a303cc2971a0c48\" \"xNUNs2vtjr6QDL1NiL8TDHgmbuEo5WcY2K2jQ8ATj9pko8wkJ9RutkFQKBCtn6SsBjy6nK5ftofFyLFnAHAynreQCZjuE7dCWVxCX5DCFB2bjx87KvbqVVRCs3KBzdDre7c5FUy7QLo\" 1000") ); @@ -1675,16 +1665,16 @@ UniValue mintnft(const UniValue& params, bool fHelp) if (fHelp || params.size() < 4) throw std::runtime_error( - "mintnft \"tokenid\" \"nftid\" \"destination\" \"metadata\"\n" - "\nMints nft.\n" - + HelpRequiringPassphrase() + + "mintnft \"tokenid\" \"nftid\" \"destination\" \"metadata\"\n" + "\nMints nft.\n" + + HelpRequiringPassphrase() + "\nArguments:\n" - "1. \"tokenid\" (string, required) The token id\n" - "1. \"nftid\" (int, required) The ntf id\n" - "2. \"destination\" (string, required) The xNAV destination addressn" - "3. \"metadata\" (string, required) The nft metadata\n" - "\nExamples:\n" - + HelpExampleCli("mintnft", "\"a7be93b41e708d21d6c94920401ca5fd93dffe33d2bc197077e3b4fafcc8fe45eebb359b4c8f6bc15a303cc2971a0c48\" 1 \"xNUNs2vtjr6QDL1NiL8TDHgmbuEo5WcY2K2jQ8ATj9pko8wkJ9RutkFQKBCtn6SsBjy6nK5ftofFyLFnAHAynreQCZjuE7dCWVxCX5DCFB2bjx87KvbqVVRCs3KBzdDre7c5FUy7QLo\" \"{'resource':'https://navcoin.org/logo.png'}\"") + "1. \"tokenid\" (string, required) The token id\n" + "1. \"nftid\" (int, required) The ntf id\n" + "2. \"destination\" (string, required) The xNAV destination addressn" + "3. \"metadata\" (string, required) The nft metadata\n" + "\nExamples:\n" + + HelpExampleCli("mintnft", "\"a7be93b41e708d21d6c94920401ca5fd93dffe33d2bc197077e3b4fafcc8fe45eebb359b4c8f6bc15a303cc2971a0c48\" 1 \"xNUNs2vtjr6QDL1NiL8TDHgmbuEo5WcY2K2jQ8ATj9pko8wkJ9RutkFQKBCtn6SsBjy6nK5ftofFyLFnAHAynreQCZjuE7dCWVxCX5DCFB2bjx87KvbqVVRCs3KBzdDre7c5FUy7QLo\" \"{'resource':'https://navcoin.org/logo.png'}\"") ); @@ -1768,14 +1758,14 @@ UniValue burntoken(const UniValue& params, bool fHelp) if (fHelp || params.size() < 2) throw std::runtime_error( - "burntoken \"tokenid\" amount\n" - "\nBurns confidential tokens.\n" - + HelpRequiringPassphrase() + + "burntoken \"tokenid\" amount\n" + "\nBurns confidential tokens.\n" + + HelpRequiringPassphrase() + "\nArguments:\n" - "1. \"tokenid\" (string, required) The token id\n" - "3. amount (string, required) The amount to burn\n" - "\nExamples:\n" - + HelpExampleCli("burntoken", "\"a7be93b41e708d21d6c94920401ca5fd93dffe33d2bc197077e3b4fafcc8fe45eebb359b4c8f6bc15a303cc2971a0c48\" 1000") + "1. \"tokenid\" (string, required) The token id\n" + "3. amount (string, required) The amount to burn\n" + "\nExamples:\n" + + HelpExampleCli("burntoken", "\"a7be93b41e708d21d6c94920401ca5fd93dffe33d2bc197077e3b4fafcc8fe45eebb359b4c8f6bc15a303cc2971a0c48\" 1000") ); @@ -1840,15 +1830,15 @@ UniValue sendtoken(const UniValue& params, bool fHelp) if (fHelp || params.size() < 2) throw std::runtime_error( - "sendtoken \"tokenid\" \"destination\" amount\n" - "\nSends confidential tokens.\n" - + HelpRequiringPassphrase() + + "sendtoken \"tokenid\" \"destination\" amount\n" + "\nSends confidential tokens.\n" + + HelpRequiringPassphrase() + "\nArguments:\n" - "1. \"tokenid\" (string, required) The token id\n" - "2. \"destination\" (string, required) The xNAV destination addressn" - "3. amount (string, required) The amount to mint\n" - "\nExamples:\n" - + HelpExampleCli("sendtoken", "\"a7be93fd93dffe33d2bc197077e3b4fafcc8fe45eebb359b4c8f6bc15a303cc2971a0c48\" \"xNUNs2vtjr6QDL1NiL8TDHgmbuEo5WcY2K2jQ8ATj9pko8wkJ9RutkFQKBCtn6SsBjy6nK5ftofFyLFnAHAynreQCZjuE7dCWVxCX5DCFB2bjx87KvbqVVRCs3KBzdDre7c5FUy7QLo\" 1000") + "1. \"tokenid\" (string, required) The token id\n" + "2. \"destination\" (string, required) The xNAV destination addressn" + "3. amount (string, required) The amount to mint\n" + "\nExamples:\n" + + HelpExampleCli("sendtoken", "\"a7be93fd93dffe33d2bc197077e3b4fafcc8fe45eebb359b4c8f6bc15a303cc2971a0c48\" \"xNUNs2vtjr6QDL1NiL8TDHgmbuEo5WcY2K2jQ8ATj9pko8wkJ9RutkFQKBCtn6SsBjy6nK5ftofFyLFnAHAynreQCZjuE7dCWVxCX5DCFB2bjx87KvbqVVRCs3KBzdDre7c5FUy7QLo\" 1000") ); @@ -1902,15 +1892,15 @@ UniValue sendnft(const UniValue& params, bool fHelp) if (fHelp || params.size() < 2) throw std::runtime_error( - "sendnft \"tokenid\" \"nftid\" \"destination\"\n" - "\nSends nft.\n" - + HelpRequiringPassphrase() + + "sendnft \"tokenid\" \"nftid\" \"destination\"\n" + "\nSends nft.\n" + + HelpRequiringPassphrase() + "\nArguments:\n" - "1. \"tokenid\" (string, required) The token id\n" - "2. \"nftid\" (int, required) The nft id\n" - "3. \"destination\" (string, required) The xNAV destination addressn" - "\nExamples:\n" - + HelpExampleCli("sendnft", "\"a7be93fd93dffe33d2bc197077e3b4fafcc8fe45eebb359b4c8f6bc15a303cc2971a0c48\" 1 \"xNUNs2vtjr6QDL1NiL8TDHgmbuEo5WcY2K2jQ8ATj9pko8wkJ9RutkFQKBCtn6SsBjy6nK5ftofFyLFnAHAynreQCZjuE7dCWVxCX5DCFB2bjx87KvbqVVRCs3KBzdDre7c5FUy7QLo\"") + "1. \"tokenid\" (string, required) The token id\n" + "2. \"nftid\" (int, required) The nft id\n" + "3. \"destination\" (string, required) The xNAV destination addressn" + "\nExamples:\n" + + HelpExampleCli("sendnft", "\"a7be93fd93dffe33d2bc197077e3b4fafcc8fe45eebb359b4c8f6bc15a303cc2971a0c48\" 1 \"xNUNs2vtjr6QDL1NiL8TDHgmbuEo5WcY2K2jQ8ATj9pko8wkJ9RutkFQKBCtn6SsBjy6nK5ftofFyLFnAHAynreQCZjuE7dCWVxCX5DCFB2bjx87KvbqVVRCs3KBzdDre7c5FUy7QLo\"") ); @@ -1964,7 +1954,7 @@ UniValue getconsensusparameters(const UniValue& params, bool fHelp) "1. extended (bool, optional, default false) Show a more detailed output.\n" "\nReturns a list containing the current values of the consensus parameters which can be voted in the DAO.\n" - ); + ); LOCK(cs_main); CStateViewCache view(pcoinsTip); @@ -2005,18 +1995,18 @@ UniValue proposeconsensuschange(const UniValue& params, bool fHelp) if (fHelp || params.size() < 2 || !params[0].isNum() || !params[1].isNum()) throw std::runtime_error( "proposeconsensuschange parameter value ( fee dump_raw )\n" - "\nCreates a proposal to the DAO for changing a consensus paremeter. Min fee of " + FormatMoney(nMinFee) + "NAV is required.\n" - + HelpRequiringPassphrase() + + "\nCreates a proposal to the DAO for changing a consensus paremeter. Min fee of " + FormatMoney(nMinFee) + "NAV is required.\n" + + HelpRequiringPassphrase() + "\nArguments:\n" - "1. parameter (numeric, required) The parameter id as specified in the output of the getconsensusparameters rpc command.\n" - "2. value (numeric, optional) The proposed value.\n" - "3. fee (numeric, optional) Contribution to the fund used as fee.\n" - "4. dump_raw (bool, optional) Dump the raw transaction instead of sending. Default: false\n" - "\nResult:\n" - "\"{ hash: consultation_id,\" (string) The consultation id.\n" - "\" strDZeel: string }\" (string) The attached strdzeel property.\n" - "\nExamples:\n" - + HelpExampleCli("proposeconsensuschange", "1 10") + "1. parameter (numeric, required) The parameter id as specified in the output of the getconsensusparameters rpc command.\n" + "2. value (numeric, optional) The proposed value.\n" + "3. fee (numeric, optional) Contribution to the fund used as fee.\n" + "4. dump_raw (bool, optional) Dump the raw transaction instead of sending. Default: false\n" + "\nResult:\n" + "\"{ hash: consultation_id,\" (string) The consultation id.\n" + "\" strDZeel: string }\" (string) The attached strdzeel property.\n" + "\nExamples:\n" + + HelpExampleCli("proposeconsensuschange", "1 10") ); CNavcoinAddress address("NQFqqMUD55ZV3PJEJZtaKCsQmjLT6JkjvJ"); // Dummy address @@ -2102,18 +2092,18 @@ UniValue proposecombinedconsensuschange(const UniValue& params, bool fHelp) if (fHelp || params.size() < 2) throw std::runtime_error( "proposecombinedconsensuschange parameters values ( fee dump_raw )\n" - "\nCreates a proposal to the DAO for changing various consensus paremeters.\n" - + HelpRequiringPassphrase() + + "\nCreates a proposal to the DAO for changing various consensus paremeters.\n" + + HelpRequiringPassphrase() + "\nArguments:\n" - "1. parameter (array, required) The parameter ids as specified in the output of the getconsensusparameters rpc command.\n" - "2. value (array, optional) The proposed values.\n" - "3. fee (numeric, optional) Contribution to the fund used as fee.\n" - "4. dump_raw (bool, optional) Dump the raw transaction instead of sending. Default: false\n" - "\nResult:\n" - "\"{ hash: consultation_id,\" (string) The consultation id.\n" - "\" strDZeel: string }\" (string) The attached strdzeel property.\n" - "\nExamples:\n" - + HelpExampleCli("proposecombinedconsensuschange", "[1] [10]") + "1. parameter (array, required) The parameter ids as specified in the output of the getconsensusparameters rpc command.\n" + "2. value (array, optional) The proposed values.\n" + "3. fee (numeric, optional) Contribution to the fund used as fee.\n" + "4. dump_raw (bool, optional) Dump the raw transaction instead of sending. Default: false\n" + "\nResult:\n" + "\"{ hash: consultation_id,\" (string) The consultation id.\n" + "\" strDZeel: string }\" (string) The attached strdzeel property.\n" + "\nExamples:\n" + + HelpExampleCli("proposecombinedconsensuschange", "[1] [10]") ); if (!params[0].isArray() || !params[1].isArray()) @@ -2216,20 +2206,20 @@ UniValue createconsultation(const UniValue& params, bool fHelp) if (fHelp || params.size() < 1) throw std::runtime_error( "createconsultation \"question\" ( min max range fee dump_raw )\n" - "\nCreates a consultation for the DAO. Min fee of " + FormatMoney(GetConsensusParameter(Consensus::CONSENSUS_PARAM_CONSULTATION_MIN_FEE, view)) + "NAV is required.\n" - + HelpRequiringPassphrase() + + "\nCreates a consultation for the DAO. Min fee of " + FormatMoney(GetConsensusParameter(Consensus::CONSENSUS_PARAM_CONSULTATION_MIN_FEE, view)) + "NAV is required.\n" + + HelpRequiringPassphrase() + "\nArguments:\n" - "1. \"question\" (string, required) The question of the new consultation.\n" - "2. min (numeric, optional) The minimum amount for the range. Only used if range equals true.\n" - "3. max (numeric, optional) The maximum amount of answers a block can vote for.\n" - "4. range (bool, optional) The consultation answers are exclusively in the range min-max.\n" - "5. fee (numeric, optional) Contribution to the fund used as fee.\n" - "6. dump_raw (bool, optional) Dump the raw transaction instead of sending. Default: false\n" - "\nResult:\n" - "\"{ hash: consultation_id,\" (string) The consultation id.\n" - "\" strDZeel: string }\" (string) The attached strdzeel property.\n" - "\nExamples:\n" - + HelpExampleCli("createconsultation", "\"Who should be the CEO of Navcoin? /s\" 1 1") + "1. \"question\" (string, required) The question of the new consultation.\n" + "2. min (numeric, optional) The minimum amount for the range. Only used if range equals true.\n" + "3. max (numeric, optional) The maximum amount of answers a block can vote for.\n" + "4. range (bool, optional) The consultation answers are exclusively in the range min-max.\n" + "5. fee (numeric, optional) Contribution to the fund used as fee.\n" + "6. dump_raw (bool, optional) Dump the raw transaction instead of sending. Default: false\n" + "\nResult:\n" + "\"{ hash: consultation_id,\" (string) The consultation id.\n" + "\" strDZeel: string }\" (string) The attached strdzeel property.\n" + "\nExamples:\n" + + HelpExampleCli("createconsultation", "\"Who should be the CEO of Navcoin? /s\" 1 1") + HelpExampleCli("createconsultation", "\"How much should Navcoin's CEO earn per month? /s\" 1000 5000 true") ); @@ -2312,20 +2302,20 @@ UniValue createconsultationwithanswers(const UniValue& params, bool fHelp) if (fHelp || params.size() < 2) throw std::runtime_error( "createconsultationwithanswers \"question\" \"[answers]\" ( maxanswers admitsanswerproposals fee dump_raw )\n" - "\nCreates a consultation for the DAO. Min fee of " + FormatMoney(GetConsensusParameter(Consensus::CONSENSUS_PARAM_CONSULTATION_MIN_FEE, view)) + "NAV is required.\n" - + HelpRequiringPassphrase() + + "\nCreates a consultation for the DAO. Min fee of " + FormatMoney(GetConsensusParameter(Consensus::CONSENSUS_PARAM_CONSULTATION_MIN_FEE, view)) + "NAV is required.\n" + + HelpRequiringPassphrase() + "\nArguments:\n" - "1. \"question\" (string, required) The question of the new consultation.\n" - "2. \"[answers]\" (array of strings, required) An array of strings with the proposed answers.\n" - "3. maxanswers (numeric, optional) The maximum amount of answers a block can vote for at the same time.\n" - "4. admitsanswerproposals (bool, optional) Stakers are allowed to propose new answers.\n" - "5. fee (numeric, optional) Contribution to the fund used as fee.\n" - "6. dump_raw (bool, optional) Dump the raw transaction instead of sending. Default: false\n" - "\nResult:\n" - "\"{ hash: consultation_id,\" (string) The consultation id.\n" - "\" strDZeel: string }\" (string) The attached strdzeel property.\n" - "\nExamples:\n" - + HelpExampleCli("createconsultationwithanswers", "\"Who should be the CEO of Navcoin? /s\" \"[\\\"Craig Wright\\\",\\\"Loomdart\\\"]\"") + "1. \"question\" (string, required) The question of the new consultation.\n" + "2. \"[answers]\" (array of strings, required) An array of strings with the proposed answers.\n" + "3. maxanswers (numeric, optional) The maximum amount of answers a block can vote for at the same time.\n" + "4. admitsanswerproposals (bool, optional) Stakers are allowed to propose new answers.\n" + "5. fee (numeric, optional) Contribution to the fund used as fee.\n" + "6. dump_raw (bool, optional) Dump the raw transaction instead of sending. Default: false\n" + "\nResult:\n" + "\"{ hash: consultation_id,\" (string) The consultation id.\n" + "\" strDZeel: string }\" (string) The attached strdzeel property.\n" + "\nExamples:\n" + + HelpExampleCli("createconsultationwithanswers", "\"Who should be the CEO of Navcoin? /s\" \"[\\\"Craig Wright\\\",\\\"Loomdart\\\"]\"") ); CNavcoinAddress address("NQFqqMUD55ZV3PJEJZtaKCsQmjLT6JkjvJ"); // Dummy address @@ -2402,7 +2392,7 @@ std::string random_string( size_t length ) auto randchar = []() -> char { const char charset[] = - "0123456789" + "0123456789" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz"; const size_t max_index = (sizeof(charset) - 1); @@ -2421,18 +2411,18 @@ UniValue createpaymentrequest(const UniValue& params, bool fHelp) if (fHelp || params.size() < 3) throw std::runtime_error( "createpaymentrequest \"hash\" \"amount\" \"id\" ( fee dump_raw )\n" - "\nCreates a proposal to withdraw funds from the community fund. Fee: 0.0001 NAV\n" - + HelpRequiringPassphrase() + + "\nCreates a proposal to withdraw funds from the community fund. Fee: 0.0001 NAV\n" + + HelpRequiringPassphrase() + "\nArguments:\n" - "1. \"hash\" (string, required) The hash of the proposal from which you want to withdraw funds. It must be approved.\n" - "2. \"amount\" (numeric or string, required) The amount in " + CURRENCY_UNIT + " to withdraw. eg 10\n" - "3. \"id\" (string, required) Unique id to identify the payment request\n" - "4. dump_raw (bool, optional) Dump the raw transaction instead of sending. Default: false\n" - "\nResult:\n" - "\"{ hash: prequestid,\" (string) The payment request id.\n" - "\" strDZeel: string }\" (string) The attached strdzeel property.\n" - "\nExamples:\n" - + HelpExampleCli("createpaymentrequest", "\"196a4c2115d3c1c1dce1156eb2404ad77f3c5e9f668882c60cb98d638313dbd3\" 1000 \"Invoice March 2017\"") + "1. \"hash\" (string, required) The hash of the proposal from which you want to withdraw funds. It must be approved.\n" + "2. \"amount\" (numeric or string, required) The amount in " + CURRENCY_UNIT + " to withdraw. eg 10\n" + "3. \"id\" (string, required) Unique id to identify the payment request\n" + "4. dump_raw (bool, optional) Dump the raw transaction instead of sending. Default: false\n" + "\nResult:\n" + "\"{ hash: prequestid,\" (string) The payment request id.\n" + "\" strDZeel: string }\" (string) The attached strdzeel property.\n" + "\nExamples:\n" + + HelpExampleCli("createpaymentrequest", "\"196a4c2115d3c1c1dce1156eb2404ad77f3c5e9f668882c60cb98d638313dbd3\" 1000 \"Invoice March 2017\"") ); if (!Params().GetConsensus().fDaoClientActivated) @@ -2477,8 +2467,8 @@ UniValue createpaymentrequest(const UniValue& params, bool fHelp) std::string sRandom = random_string(16); std::string Secret = sRandom + "I kindly ask to withdraw " + - std::to_string(nReqAmount) + "NAV from the proposal " + - proposal.hash.ToString() + ". Payment request id: " + id; + std::to_string(nReqAmount) + "NAV from the proposal " + + proposal.hash.ToString() + ". Payment request id: " + id; CHashWriter ss(SER_GETHASH, 0); ss << strMessageMagic; @@ -2557,18 +2547,18 @@ UniValue proposeanswer(const UniValue& params, bool fHelp) if (fHelp || params.size() < 2) throw std::runtime_error( "proposeanswer \"hash\" \"answer\" ( fee dump_raw )\n" - "\nProposes an answer for an already existing consultation of the DAO. Min fee of " + FormatMoney(GetConsensusParameter(Consensus::CONSENSUS_PARAM_CONSULTATION_ANSWER_MIN_FEE, view)) + "NAV is required.\n" - + HelpRequiringPassphrase() + + "\nProposes an answer for an already existing consultation of the DAO. Min fee of " + FormatMoney(GetConsensusParameter(Consensus::CONSENSUS_PARAM_CONSULTATION_ANSWER_MIN_FEE, view)) + "NAV is required.\n" + + HelpRequiringPassphrase() + "\nArguments:\n" - "1. \"hash\" (string, required) The hash of the already existing consultation.\n" - "2. \"answer\" (string, required) The proposed answer.\n" - "3. fee (numeric, optional) Contribution to the fund used as fee.\n" - "4. dump_raw (bool, optional) Dump the raw transaction instead of sending. Default: false\n" - "\nResult:\n" - "\"{ hash: consultation_id,\" (string) The consultation id.\n" - "\" strDZeel: string }\" (string) The attached strdzeel property.\n" - "\nExamples:\n" - + HelpExampleCli("proposeanswer", "\"196a4c2115d3c1c1dce1156eb2404ad77f3c5e9f668882c60cb98d638313dbd3\" \"Vitalik Buterin\"") + "1. \"hash\" (string, required) The hash of the already existing consultation.\n" + "2. \"answer\" (string, required) The proposed answer.\n" + "3. fee (numeric, optional) Contribution to the fund used as fee.\n" + "4. dump_raw (bool, optional) Dump the raw transaction instead of sending. Default: false\n" + "\nResult:\n" + "\"{ hash: consultation_id,\" (string) The consultation id.\n" + "\" strDZeel: string }\" (string) The attached strdzeel property.\n" + "\nExamples:\n" + + HelpExampleCli("proposeanswer", "\"196a4c2115d3c1c1dce1156eb2404ad77f3c5e9f668882c60cb98d638313dbd3\" \"Vitalik Buterin\"") + HelpExampleCli("proposeanswer", "\"196a4c2115d3c1c1dce1156eb2404ad77f3c5e9f668882c60cb98d638313dbd3\" \"Satoshi Nakamoto\"") + HelpExampleCli("proposeanswer", "\"196a4c2115d3c1c1dce1156eb2404ad77f3c5e9f668882c60cb98d638313dbd3\" \"Charlie Lee\"") + HelpExampleCli("proposeanswer", "\"196a4c2115d3c1c1dce1156eb2404ad77f3c5e9f668882c60cb98d638313dbd3\" \"Riccardo Fluffypony\"") @@ -2678,11 +2668,11 @@ UniValue donatefund(const UniValue& params, bool fHelp) + HelpRequiringPassphrase() + "\nArguments:\n" "1. \"amount\" (numeric or string, required) The amount in " + CURRENCY_UNIT + " to donate. eg 0.1\n" - "2. subtractfeefromamount (boolean, optional, default=false) The fee will be deducted from the amount being sent.\n" - " The fund will receive less navcoins than you enter in the amount field.\n" - "\nResult:\n" - "\"transactionid\" (string) The transaction id.\n" - "\nExamples:\n" + "2. subtractfeefromamount (boolean, optional, default=false) The fee will be deducted from the amount being sent.\n" + " The fund will receive less navcoins than you enter in the amount field.\n" + "\nResult:\n" + "\"transactionid\" (string) The transaction id.\n" + "\nExamples:\n" + HelpExampleCli("donatefund", "0.1") + HelpExampleCli("donatefund", "0.1 true") @@ -2726,13 +2716,13 @@ UniValue listaddressgroupings(const UniValue& params, bool fHelp) " [\n" " \"navcoinaddress\", (string) The navcoin address\n" " amount, (numeric) The amount in " + CURRENCY_UNIT + "\n" - " \"account\" (string, optional) The account (DEPRECATED)\n" - " ]\n" - " ,...\n" - " ]\n" - " ,...\n" - "]\n" - "\nExamples:\n" + " \"account\" (string, optional) The account (DEPRECATED)\n" + " ]\n" + " ,...\n" + " ]\n" + " ,...\n" + "]\n" + "\nExamples:\n" + HelpExampleCli("listaddressgroupings", "") + HelpExampleRpc("listaddressgroupings", "") ); @@ -2770,13 +2760,13 @@ UniValue signmessage(const UniValue& params, bool fHelp) "signmessage \"navcoinaddress\" \"message\"\n" "\nSign a message with the private key of an address" + HelpRequiringPassphrase() + "\n" - "\nArguments:\n" - "1. \"navcoinaddress\" (string, required) The navcoin address to use for the private key.\n" - "2. \"message\" (string, required) The message to create a signature of.\n" - "\nResult:\n" - "\"signature\" (string) The signature of the message encoded in base 64\n" - "\nExamples:\n" - "\nUnlock the wallet for 30 seconds\n" + "\nArguments:\n" + "1. \"navcoinaddress\" (string, required) The navcoin address to use for the private key.\n" + "2. \"message\" (string, required) The message to create a signature of.\n" + "\nResult:\n" + "\"signature\" (string) The signature of the message encoded in base 64\n" + "\nExamples:\n" + "\nUnlock the wallet for 30 seconds\n" + HelpExampleCli("walletpassphrase", "\"mypassphrase\" 30") + "\nCreate the signature\n" + HelpExampleCli("signmessage", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XZ\" \"my message\"") + @@ -2830,8 +2820,8 @@ UniValue getreceivedbyaddress(const UniValue& params, bool fHelp) "2. minconf (numeric, optional, default=1) Only include transactions confirmed at least this many times.\n" "\nResult:\n" "amount (numeric) The total amount in " + CURRENCY_UNIT + " received at this address.\n" - "\nExamples:\n" - "\nThe amount from transactions with at least 1 confirmation\n" + "\nExamples:\n" + "\nThe amount from transactions with at least 1 confirmation\n" + HelpExampleCli("getreceivedbyaddress", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XZ\"") + "\nThe amount including unconfirmed transactions, zero confirmations\n" + HelpExampleCli("getreceivedbyaddress", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XZ\" 0") + @@ -2888,8 +2878,8 @@ UniValue getreceivedbyaccount(const UniValue& params, bool fHelp) "2. minconf (numeric, optional, default=1) Only include transactions confirmed at least this many times.\n" "\nResult:\n" "amount (numeric) The total amount in " + CURRENCY_UNIT + " received for this account.\n" - "\nExamples:\n" - "\nAmount received by the default account with at least 1 confirmation\n" + "\nExamples:\n" + "\nAmount received by the default account with at least 1 confirmation\n" + HelpExampleCli("getreceivedbyaccount", "\"\"") + "\nAmount received at the tabby account including unconfirmed amounts with zero confirmations\n" + HelpExampleCli("getreceivedbyaccount", "\"tabby\" 0") + @@ -2949,8 +2939,8 @@ UniValue getbalance(const UniValue& params, bool fHelp) "3. includeWatchonly (bool, optional, default=false) Also include balance in watchonly addresses (see 'importaddress')\n" "\nResult:\n" "amount (numeric) The total amount in " + CURRENCY_UNIT + " received for this account.\n" - "\nExamples:\n" - "\nThe total amount in the wallet\n" + "\nExamples:\n" + "\nThe total amount in the wallet\n" + HelpExampleCli("getbalance", "") + "\nThe total amount in the wallet at least 5 blocks confirmed\n" + HelpExampleCli("getbalance", "\"*\" 6") + @@ -3037,12 +3027,12 @@ UniValue movecmd(const UniValue& params, bool fHelp) "1. \"fromaccount\" (string, required) The name of the account to move funds from. May be the default account using \"\".\n" "2. \"toaccount\" (string, required) The name of the account to move funds to. May be the default account using \"\".\n" "3. amount (numeric) Quantity of " + CURRENCY_UNIT + " to move between accounts.\n" - "4. minconf (numeric, optional, default=1) Only use funds with at least this many confirmations.\n" - "5. \"comment\" (string, optional) An optional comment, stored in the wallet only.\n" - "\nResult:\n" - "true|false (boolean) true if successful.\n" - "\nExamples:\n" - "\nMove 0.01 " + CURRENCY_UNIT + " from the default account to the account named tabby\n" + "4. minconf (numeric, optional, default=1) Only use funds with at least this many confirmations.\n" + "5. \"comment\" (string, optional) An optional comment, stored in the wallet only.\n" + "\nResult:\n" + "true|false (boolean) true if successful.\n" + "\nExamples:\n" + "\nMove 0.01 " + CURRENCY_UNIT + " from the default account to the account named tabby\n" + HelpExampleCli("move", "\"\" \"tabby\" 0.01") + "\nMove 0.01 " + CURRENCY_UNIT + " timotei to akiko with a comment and funds have 6 confirmations\n" + HelpExampleCli("move", "\"timotei\" \"akiko\" 0.01 6 \"happy birthday!\"") + @@ -3081,20 +3071,20 @@ UniValue sendfrom(const UniValue& params, bool fHelp) "sendfrom \"fromaccount\" \"tonavcoinaddress\" amount ( minconf \"comment\" \"comment-to\" )\n" "\nDEPRECATED (use sendtoaddress). Sent an amount from an account to a navcoin address." + HelpRequiringPassphrase() + "\n" - "\nArguments:\n" - "1. \"fromaccount\" (string, required) The name of the account to send funds from. May be the default account using \"\".\n" - "2. \"tonavcoinaddress\" (string, required) The navcoin address to send funds to.\n" - "3. amount (numeric or string, required) The amount in " + CURRENCY_UNIT + " (transaction fee is added on top).\n" - "4. minconf (numeric, optional, default=1) Only use funds with at least this many confirmations.\n" - "5. \"comment\" (string, optional) A comment used to store what the transaction is for. \n" - " This is not part of the transaction, just kept in your wallet.\n" - "6. \"comment-to\" (string, optional) An optional comment to store the name of the person or organization \n" - " to which you're sending the transaction. This is not part of the transaction, \n" - " it is just kept in your wallet.\n" - "\nResult:\n" - "\"transactionid\" (string) The transaction id.\n" - "\nExamples:\n" - "\nSend 0.01 " + CURRENCY_UNIT + " from the default account to the address, must have at least 1 confirmation\n" + "\nArguments:\n" + "1. \"fromaccount\" (string, required) The name of the account to send funds from. May be the default account using \"\".\n" + "2. \"tonavcoinaddress\" (string, required) The navcoin address to send funds to.\n" + "3. amount (numeric or string, required) The amount in " + CURRENCY_UNIT + " (transaction fee is added on top).\n" + "4. minconf (numeric, optional, default=1) Only use funds with at least this many confirmations.\n" + "5. \"comment\" (string, optional) A comment used to store what the transaction is for. \n" + " This is not part of the transaction, just kept in your wallet.\n" + "6. \"comment-to\" (string, optional) An optional comment to store the name of the person or organization \n" + " to which you're sending the transaction. This is not part of the transaction, \n" + " it is just kept in your wallet.\n" + "\nResult:\n" + "\"transactionid\" (string) The transaction id.\n" + "\nExamples:\n" + "\nSend 0.01 " + CURRENCY_UNIT + " from the default account to the address, must have at least 1 confirmation\n" + HelpExampleCli("sendfrom", "\"\" \"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.01") + "\nSend 0.01 from the tabby account to the given address, funds must have at least 6 confirmations\n" + HelpExampleCli("sendfrom", "\"tabby\" \"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.01 6 \"donation\" \"seans outpost\"") + @@ -3145,28 +3135,28 @@ UniValue sendmany(const UniValue& params, bool fHelp) "sendmany \"fromaccount\" {\"address\":amount,...} ( minconf \"comment\" [\"address\",...] )\n" "\nSend multiple times. Amounts are double-precision floating point numbers." + HelpRequiringPassphrase() + "\n" - "\nArguments:\n" - "1. \"fromaccount\" (string, required) DEPRECATED. The account to send the funds from. Should be \"\" for the default account\n" - "2. \"amounts\" (string, required) A json object with addresses and amounts\n" - " {\n" - " \"address\":amount (numeric or string) The navcoin address is the key, the numeric amount (can be string) in " + CURRENCY_UNIT + " is the value\n" - " ,...\n" - " }\n" - "3. minconf (numeric, optional, default=1) Only use the balance confirmed at least this many times.\n" - "4. \"comment\" (string, optional) A comment\n" - "5. subtractfeefromamount (string, optional) A json array with addresses.\n" - " The fee will be equally deducted from the amount of each selected address.\n" - " Those recipients will receive less navcoins than you enter in their corresponding amount field.\n" - " If no addresses are specified here, the sender pays the fee.\n" - " [\n" - " \"address\" (string) Subtract fee from this address\n" - " ,...\n" - " ]\n" - "\nResult:\n" - "\"transactionid\" (string) The transaction id for the send. Only 1 transaction is created regardless of \n" - " the number of addresses.\n" - "\nExamples:\n" - "\nSend two amounts to two different addresses:\n" + "\nArguments:\n" + "1. \"fromaccount\" (string, required) DEPRECATED. The account to send the funds from. Should be \"\" for the default account\n" + "2. \"amounts\" (string, required) A json object with addresses and amounts\n" + " {\n" + " \"address\":amount (numeric or string) The navcoin address is the key, the numeric amount (can be string) in " + CURRENCY_UNIT + " is the value\n" + " ,...\n" + " }\n" + "3. minconf (numeric, optional, default=1) Only use the balance confirmed at least this many times.\n" + "4. \"comment\" (string, optional) A comment\n" + "5. subtractfeefromamount (string, optional) A json array with addresses.\n" + " The fee will be equally deducted from the amount of each selected address.\n" + " Those recipients will receive less navcoins than you enter in their corresponding amount field.\n" + " If no addresses are specified here, the sender pays the fee.\n" + " [\n" + " \"address\" (string) Subtract fee from this address\n" + " ,...\n" + " ]\n" + "\nResult:\n" + "\"transactionid\" (string) The transaction id for the send. Only 1 transaction is created regardless of \n" + " the number of addresses.\n" + "\nExamples:\n" + "\nSend two amounts to two different addresses:\n" + HelpExampleCli("sendmany", "\"\" \"{\\\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XZ\\\":0.01,\\\"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\":0.02}\"") + "\nSend two amounts to two different addresses setting the confirmation and comment:\n" + HelpExampleCli("sendmany", "\"\" \"{\\\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XZ\\\":0.01,\\\"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\":0.02}\" 6 \"testing\"") + @@ -3338,28 +3328,28 @@ UniValue addmultisigaddress(const UniValue& params, bool fHelp) if (fHelp || params.size() < 2 || params.size() > 3) { std::string msg = "addmultisigaddress nrequired [\"key\",...] ( \"account\" )\n" - "\nAdd a nrequired-to-sign multisignature address to the wallet.\n" - "Each key is a Navcoin address or hex-encoded public key.\n" - "If 'account' is specified (DEPRECATED), assign address to that account.\n" - - "\nArguments:\n" - "1. nrequired (numeric, required) The number of required signatures out of the n keys or addresses.\n" - "2. \"keysobject\" (string, required) A json array of navcoin addresses or hex-encoded public keys\n" - " [\n" - " \"address\" (string) navcoin address or hex-encoded public key\n" - " ...,\n" - " ]\n" - "3. \"account\" (string, optional) DEPRECATED. An account to assign the addresses to.\n" - - "\nResult:\n" - "\"navcoinaddress\" (string) A navcoin address associated with the keys.\n" - - "\nExamples:\n" - "\nAdd a multisig address from 2 addresses\n" - + HelpExampleCli("addmultisigaddress", "2 \"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") + - "\nAs json rpc call\n" - + HelpExampleRpc("addmultisigaddress", "2, \"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") - ; + "\nAdd a nrequired-to-sign multisignature address to the wallet.\n" + "Each key is a Navcoin address or hex-encoded public key.\n" + "If 'account' is specified (DEPRECATED), assign address to that account.\n" + + "\nArguments:\n" + "1. nrequired (numeric, required) The number of required signatures out of the n keys or addresses.\n" + "2. \"keysobject\" (string, required) A json array of navcoin addresses or hex-encoded public keys\n" + " [\n" + " \"address\" (string) navcoin address or hex-encoded public key\n" + " ...,\n" + " ]\n" + "3. \"account\" (string, optional) DEPRECATED. An account to assign the addresses to.\n" + + "\nResult:\n" + "\"navcoinaddress\" (string) A navcoin address associated with the keys.\n" + + "\nExamples:\n" + "\nAdd a multisig address from 2 addresses\n" + + HelpExampleCli("addmultisigaddress", "2 \"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") + + "\nAs json rpc call\n" + + HelpExampleRpc("addmultisigaddress", "2, \"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") + ; throw std::runtime_error(msg); } @@ -3380,46 +3370,46 @@ UniValue addmultisigaddress(const UniValue& params, bool fHelp) class Witnessifier : public boost::static_visitor { -public: - CScriptID result; + public: + CScriptID result; - bool operator()(const CNoDestination &dest) const { return false; } + bool operator()(const CNoDestination &dest) const { return false; } - bool operator()(const blsctDoublePublicKey &dest) const { return false; } + bool operator()(const blsctDoublePublicKey &dest) const { return false; } - bool operator()(const std::pair &dest) const { return false; } + bool operator()(const std::pair &dest) const { return false; } - bool operator()(const std::pair> &dest) const { return false; } + bool operator()(const std::pair> &dest) const { return false; } - bool operator()(const CKeyID &keyID) { - CPubKey pubkey; - if (pwalletMain && pwalletMain->GetPubKey(keyID, pubkey)) { - CScript basescript; - basescript << ToByteVector(pubkey) << OP_CHECKSIG; - CScript witscript = GetScriptForWitness(basescript); - pwalletMain->AddCScript(witscript); - result = CScriptID(witscript); - return true; + bool operator()(const CKeyID &keyID) { + CPubKey pubkey; + if (pwalletMain && pwalletMain->GetPubKey(keyID, pubkey)) { + CScript basescript; + basescript << ToByteVector(pubkey) << OP_CHECKSIG; + CScript witscript = GetScriptForWitness(basescript); + pwalletMain->AddCScript(witscript); + result = CScriptID(witscript); + return true; + } + return false; } - return false; - } - bool operator()(const CScriptID &scriptID) { - CScript subscript; - if (pwalletMain && pwalletMain->GetCScript(scriptID, subscript)) { - int witnessversion; - std::vector witprog; - if (subscript.IsWitnessProgram(witnessversion, witprog)) { - result = scriptID; + bool operator()(const CScriptID &scriptID) { + CScript subscript; + if (pwalletMain && pwalletMain->GetCScript(scriptID, subscript)) { + int witnessversion; + std::vector witprog; + if (subscript.IsWitnessProgram(witnessversion, witprog)) { + result = scriptID; + return true; + } + CScript witscript = GetScriptForWitness(subscript); + pwalletMain->AddCScript(witscript); + result = CScriptID(witscript); return true; } - CScript witscript = GetScriptForWitness(subscript); - pwalletMain->AddCScript(witscript); - result = CScriptID(witscript); - return true; + return false; } - return false; - } }; UniValue addwitnessaddress(const UniValue& params, bool fHelp) @@ -3430,16 +3420,16 @@ UniValue addwitnessaddress(const UniValue& params, bool fHelp) if (fHelp || params.size() < 1 || params.size() > 1) { std::string msg = "addwitnessaddress \"address\"\n" - "\nAdd a witness address for a script (with pubkey or redeemscript known).\n" - "It returns the witness script.\n" + "\nAdd a witness address for a script (with pubkey or redeemscript known).\n" + "It returns the witness script.\n" - "\nArguments:\n" - "1. \"address\" (string, required) An address known to the wallet\n" + "\nArguments:\n" + "1. \"address\" (string, required) An address known to the wallet\n" - "\nResult:\n" - "\"witnessaddress\", (string) The value of the new address (P2SH of witness script).\n" - "}\n" - ; + "\nResult:\n" + "\"witnessaddress\", (string) The value of the new address (P2SH of witness script).\n" + "}\n" + ; throw std::runtime_error(msg); } @@ -3626,13 +3616,13 @@ UniValue listreceivedbyaddress(const UniValue& params, bool fHelp) " \"address\" : \"receivingaddress\", (string) The receiving address\n" " \"account\" : \"accountname\", (string) DEPRECATED. The account of the receiving address. The default account is \"\".\n" " \"amount\" : x.xxx, (numeric) The total amount in " + CURRENCY_UNIT + " received by the address\n" - " \"confirmations\" : n, (numeric) The number of confirmations of the most recent transaction included\n" - " \"label\" : \"label\" (string) A comment for the address/transaction, if any\n" - " }\n" - " ,...\n" - "]\n" + " \"confirmations\" : n, (numeric) The number of confirmations of the most recent transaction included\n" + " \"label\" : \"label\" (string) A comment for the address/transaction, if any\n" + " }\n" + " ,...\n" + "]\n" - "\nExamples:\n" + "\nExamples:\n" + HelpExampleCli("listreceivedbyaddress", "") + HelpExampleCli("listreceivedbyaddress", "6 true") + HelpExampleRpc("listreceivedbyaddress", "6, true, true") @@ -3716,9 +3706,9 @@ void GetReceived(const COutputEntry& r, const CWalletTx& wtx, const std::string& entry.pushKV("amount", ValueFromAmount(r.amount)); entry.pushKV("canStake", (::IsMine(*pwalletMain, r.destination) & ISMINE_STAKABLE || - (::IsMine(*pwalletMain, r.destination) & ISMINE_SPENDABLE && - !CNavcoinAddress(r.destination).IsColdStakingAddress(Params()) && - !CNavcoinAddress(r.destination).IsColdStakingv2Address(Params()))) ? true : false); + (::IsMine(*pwalletMain, r.destination) & ISMINE_SPENDABLE && + !CNavcoinAddress(r.destination).IsColdStakingAddress(Params()) && + !CNavcoinAddress(r.destination).IsColdStakingv2Address(Params()))) ? true : false); entry.pushKV("canSpend", ((::IsMine(*pwalletMain, r.destination) & ISMINE_SPENDABLE) || (pwalletMain->IsMine(wtx.vout[r.vout]) & ISMINE_SPENDABLE_PRIVATE)) ? true : false); if (pwalletMain->mapAddressBook.count(r.destination)) entry.pushKV("label", account); @@ -3826,37 +3816,37 @@ UniValue listtransactions(const UniValue& params, bool fHelp) " transaction id or block. 'send' and 'receive' transactions are \n" " associated with an address, transaction id and block details\n" " \"amount\": x.xxx, (numeric) The amount in " + CURRENCY_UNIT + ". This is negative for the 'send' category, and for the\n" - " 'move' category for moves outbound. It is positive for the 'receive' category,\n" - " and for the 'move' category for inbound funds.\n" - " \"vout\": n, (numeric) the vout value\n" - " \"fee\": x.xxx, (numeric) The amount of the fee in " + CURRENCY_UNIT + ". This is negative and only available for the \n" - " 'send' category of transactions.\n" - " \"abandoned\": xxx (bool) 'true' if the transaction has been abandoned (inputs are respendable).\n" - " \"confirmations\": n, (numeric) The number of confirmations for the transaction. Available for 'send' and \n" - " 'receive' category of transactions. Negative confirmations indicate the\n" - " transaction conflicts with the block chain\n" - " \"trusted\": xxx (bool) Whether we consider the outputs of this unconfirmed transaction safe to spend.\n" - " \"blockhash\": \"hashvalue\", (string) The block hash containing the transaction. Available for 'send' and 'receive'\n" - " category of transactions.\n" - " \"blockindex\": n, (numeric) The index of the transaction in the block that includes it. Available for 'send' and 'receive'\n" - " category of transactions.\n" - " \"blocktime\": xxx, (numeric) The block time in seconds since epoch (1 Jan 1970 GMT).\n" - " \"txid\": \"transactionid\", (string) The transaction id. Available for 'send' and 'receive' category of transactions.\n" - " \"time\": xxx, (numeric) The transaction time in seconds since epoch (midnight Jan 1 1970 GMT).\n" - " \"timereceived\": xxx, (numeric) The time received in seconds since epoch (midnight Jan 1 1970 GMT). Available \n" - " for 'send' and 'receive' category of transactions.\n" - " \"comment\": \"...\", (string) If a comment is associated with the transaction.\n" - " \"label\": \"label\" (string) A comment for the address/transaction, if any\n" - " \"otheraccount\": \"accountname\", (string) For the 'move' category of transactions, the account the funds came \n" - " from (for receiving funds, positive amounts), or went to (for sending funds,\n" - " negative amounts).\n" - " \"bip125-replaceable\": \"yes|no|unknown\" (string) Whether this transaction could be replaced due to BIP125 (replace-by-fee);\n" - " may be unknown for unconfirmed transactions not in the mempool\n" - " }\n" - "]\n" - - "\nExamples:\n" - "\nList the most recent 10 transactions in the systems\n" + " 'move' category for moves outbound. It is positive for the 'receive' category,\n" + " and for the 'move' category for inbound funds.\n" + " \"vout\": n, (numeric) the vout value\n" + " \"fee\": x.xxx, (numeric) The amount of the fee in " + CURRENCY_UNIT + ". This is negative and only available for the \n" + " 'send' category of transactions.\n" + " \"abandoned\": xxx (bool) 'true' if the transaction has been abandoned (inputs are respendable).\n" + " \"confirmations\": n, (numeric) The number of confirmations for the transaction. Available for 'send' and \n" + " 'receive' category of transactions. Negative confirmations indicate the\n" + " transaction conflicts with the block chain\n" + " \"trusted\": xxx (bool) Whether we consider the outputs of this unconfirmed transaction safe to spend.\n" + " \"blockhash\": \"hashvalue\", (string) The block hash containing the transaction. Available for 'send' and 'receive'\n" + " category of transactions.\n" + " \"blockindex\": n, (numeric) The index of the transaction in the block that includes it. Available for 'send' and 'receive'\n" + " category of transactions.\n" + " \"blocktime\": xxx, (numeric) The block time in seconds since epoch (1 Jan 1970 GMT).\n" + " \"txid\": \"transactionid\", (string) The transaction id. Available for 'send' and 'receive' category of transactions.\n" + " \"time\": xxx, (numeric) The transaction time in seconds since epoch (midnight Jan 1 1970 GMT).\n" + " \"timereceived\": xxx, (numeric) The time received in seconds since epoch (midnight Jan 1 1970 GMT). Available \n" + " for 'send' and 'receive' category of transactions.\n" + " \"comment\": \"...\", (string) If a comment is associated with the transaction.\n" + " \"label\": \"label\" (string) A comment for the address/transaction, if any\n" + " \"otheraccount\": \"accountname\", (string) For the 'move' category of transactions, the account the funds came \n" + " from (for receiving funds, positive amounts), or went to (for sending funds,\n" + " negative amounts).\n" + " \"bip125-replaceable\": \"yes|no|unknown\" (string) Whether this transaction could be replaced due to BIP125 (replace-by-fee);\n" + " may be unknown for unconfirmed transactions not in the mempool\n" + " }\n" + "]\n" + + "\nExamples:\n" + "\nList the most recent 10 transactions in the systems\n" + HelpExampleCli("listtransactions", "") + "\nList transactions 100 to 120\n" + HelpExampleCli("listtransactions", "\"*\" 20 100") + @@ -4029,23 +4019,23 @@ UniValue listsinceblock(const UniValue& params, bool fHelp) " \"address\":\"navcoinaddress\", (string) The navcoin address of the transaction. Not present for move transactions (category = move).\n" " \"category\":\"send|receive\", (string) The transaction category. 'send' has negative amounts, 'receive' has positive amounts.\n" " \"amount\": x.xxx, (numeric) The amount in " + CURRENCY_UNIT + ". This is negative for the 'send' category, and for the 'move' category for moves \n" - " outbound. It is positive for the 'receive' category, and for the 'move' category for inbound funds.\n" - " \"vout\" : n, (numeric) the vout value\n" - " \"fee\": x.xxx, (numeric) The amount of the fee in " + CURRENCY_UNIT + ". This is negative and only available for the 'send' category of transactions.\n" - " \"confirmations\": n, (numeric) The number of confirmations for the transaction. Available for 'send' and 'receive' category of transactions.\n" - " \"blockhash\": \"hashvalue\", (string) The block hash containing the transaction. Available for 'send' and 'receive' category of transactions.\n" - " \"blockindex\": n, (numeric) The index of the transaction in the block that includes it. Available for 'send' and 'receive' category of transactions.\n" - " \"blocktime\": xxx, (numeric) The block time in seconds since epoch (1 Jan 1970 GMT).\n" - " \"txid\": \"transactionid\", (string) The transaction id. Available for 'send' and 'receive' category of transactions.\n" - " \"time\": xxx, (numeric) The transaction time in seconds since epoch (Jan 1 1970 GMT).\n" - " \"timereceived\": xxx, (numeric) The time received in seconds since epoch (Jan 1 1970 GMT). Available for 'send' and 'receive' category of transactions.\n" - " \"comment\": \"...\", (string) If a comment is associated with the transaction.\n" - " \"label\" : \"label\" (string) A comment for the address/transaction, if any\n" - " \"to\": \"...\", (string) If a comment to is associated with the transaction.\n" - " ],\n" - " \"lastblock\": \"lastblockhash\" (string) The hash of the last block\n" - "}\n" - "\nExamples:\n" + " outbound. It is positive for the 'receive' category, and for the 'move' category for inbound funds.\n" + " \"vout\" : n, (numeric) the vout value\n" + " \"fee\": x.xxx, (numeric) The amount of the fee in " + CURRENCY_UNIT + ". This is negative and only available for the 'send' category of transactions.\n" + " \"confirmations\": n, (numeric) The number of confirmations for the transaction. Available for 'send' and 'receive' category of transactions.\n" + " \"blockhash\": \"hashvalue\", (string) The block hash containing the transaction. Available for 'send' and 'receive' category of transactions.\n" + " \"blockindex\": n, (numeric) The index of the transaction in the block that includes it. Available for 'send' and 'receive' category of transactions.\n" + " \"blocktime\": xxx, (numeric) The block time in seconds since epoch (1 Jan 1970 GMT).\n" + " \"txid\": \"transactionid\", (string) The transaction id. Available for 'send' and 'receive' category of transactions.\n" + " \"time\": xxx, (numeric) The transaction time in seconds since epoch (Jan 1 1970 GMT).\n" + " \"timereceived\": xxx, (numeric) The time received in seconds since epoch (Jan 1 1970 GMT). Available for 'send' and 'receive' category of transactions.\n" + " \"comment\": \"...\", (string) If a comment is associated with the transaction.\n" + " \"label\" : \"label\" (string) A comment for the address/transaction, if any\n" + " \"to\": \"...\", (string) If a comment to is associated with the transaction.\n" + " ],\n" + " \"lastblock\": \"lastblockhash\" (string) The hash of the last block\n" + "}\n" + "\nExamples:\n" + HelpExampleCli("listsinceblock", "") + HelpExampleCli("listsinceblock", "\"000000000000000bacf66f7497b7dc45ef753ee9a7d38571037cdb1a57f663ad\" 6") + HelpExampleRpc("listsinceblock", "\"000000000000000bacf66f7497b7dc45ef753ee9a7d38571037cdb1a57f663ad\", 6") @@ -4255,9 +4245,9 @@ UniValue keypoolrefill(const UniValue& params, bool fHelp) "keypoolrefill ( newsize )\n" "\nFills the keypool." + HelpRequiringPassphrase() + "\n" - "\nArguments\n" - "1. newsize (numeric, optional, default=100) The new keypool size\n" - "\nExamples:\n" + "\nArguments\n" + "1. newsize (numeric, optional, default=100) The new keypool size\n" + "\nExamples:\n" + HelpExampleCli("keypoolrefill", "") + HelpExampleRpc("keypoolrefill", "") ); @@ -4511,17 +4501,17 @@ UniValue encrypttxdata(const UniValue& params, bool fHelp) if (fHelp || params.size() != 1) throw std::runtime_error( "encrypttxdata \"passphrase\"\n" - "\nEncrypts the wallet database using \"passphrase\", effectively encrypting your\n" - "transaction data and addressbook, you can also use this rpc command to change the\n" - "encryption \"passphrase\" of an already encrypted wallet database.\n" - "Note that this will shutdown the server.\n" - "\nArguments:\n" - "1. \"passphrase\" (string) The pass phrase to encrypt the wallet database with. It must be at least 1 character, but should be long.\n" - "\nExamples:\n" - "\nEncrypt you wallet\n" - + HelpExampleCli("encrypttxdata", "\"my pass phrase\"") + + "\nEncrypts the wallet database using \"passphrase\", effectively encrypting your\n" + "transaction data and addressbook, you can also use this rpc command to change the\n" + "encryption \"passphrase\" of an already encrypted wallet database.\n" + "Note that this will shutdown the server.\n" + "\nArguments:\n" + "1. \"passphrase\" (string) The pass phrase to encrypt the wallet database with. It must be at least 1 character, but should be long.\n" + "\nExamples:\n" + "\nEncrypt you wallet\n" + + HelpExampleCli("encrypttxdata", "\"my pass phrase\"") + "\nAs a json rpc call\n" - + HelpExampleRpc("encrypttxdata", "\"my pass phrase\"") + + HelpExampleRpc("encrypttxdata", "\"my pass phrase\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -4538,7 +4528,7 @@ UniValue encrypttxdata(const UniValue& params, bool fHelp) if (strWalletPass.length() < 1) throw std::runtime_error( "encrypttxdata \n" - "Encrypts the txdata with ."); + "Encrypts the txdata with ."); if (!pwalletMain->EncryptTx(strWalletPass)) throw JSONRPCError(RPC_TXDATA_ENCRYPTION_FAILED, "Error: Failed to encrypt the txdata."); @@ -4614,10 +4604,10 @@ UniValue lockunspent(const UniValue& params, bool fHelp) const UniValue& o = output.get_obj(); RPCTypeCheckObj(o, - { - {"txid", UniValueType(UniValue::VSTR)}, - {"vout", UniValueType(UniValue::VNUM)}, - }); + { + {"txid", UniValueType(UniValue::VSTR)}, + {"vout", UniValueType(UniValue::VNUM)}, + }); std::string txid = find_value(o, "txid").get_str(); if (!IsHex(txid)) @@ -4698,9 +4688,9 @@ UniValue settxfee(const UniValue& params, bool fHelp) "\nSet the transaction fee per kB. Overwrites the paytxfee parameter.\n" "\nArguments:\n" "1. amount (numeric or string, required) The transaction fee in " + CURRENCY_UNIT + "/kB\n" - "\nResult\n" - "true|false (boolean) Returns true if successful\n" - "\nExamples:\n" + "\nResult\n" + "true|false (boolean) Returns true if successful\n" + "\nExamples:\n" + HelpExampleCli("settxfee", "0.00001") + HelpExampleRpc("settxfee", "0.00001") ); @@ -4820,15 +4810,15 @@ UniValue listunspent(const UniValue& params, bool fHelp) " \"account\" : \"account\", (string) DEPRECATED. The associated account, or \"\" for the default account\n" " \"scriptPubKey\" : \"key\", (string) the script key\n" " \"amount\" : x.xxx, (numeric) the transaction amount in " + CURRENCY_UNIT + "\n" - " \"confirmations\" : n, (numeric) The number of confirmations\n" - " \"redeemScript\" : n (string) The redeemScript if scriptPubKey is P2SH\n" - " \"spendable\" : xxx, (bool) Whether we have the private keys to spend this output\n" - " \"solvable\" : xxx (bool) Whether we know how to spend this output, ignoring the lack of keys\n" - " }\n" - " ,...\n" - "]\n" - - "\nExamples\n" + " \"confirmations\" : n, (numeric) The number of confirmations\n" + " \"redeemScript\" : n (string) The redeemScript if scriptPubKey is P2SH\n" + " \"spendable\" : xxx, (bool) Whether we have the private keys to spend this output\n" + " \"solvable\" : xxx (bool) Whether we know how to spend this output, ignoring the lack of keys\n" + " }\n" + " ,...\n" + "]\n" + + "\nExamples\n" + HelpExampleCli("listunspent", "") + HelpExampleCli("listunspent", "6 9999999 \"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\",\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"") + HelpExampleRpc("listunspent", "6, 9999999 \"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\",\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"") @@ -4930,17 +4920,17 @@ UniValue fundrawtransaction(const UniValue& params, bool fHelp) " \"includeWatching\" (boolean, optional, default false) Also select inputs which are watch only\n" " \"lockUnspents\" (boolean, optional, default false) Lock selected unspent outputs\n" " \"feeRate\" (numeric, optional, default not set: makes wallet determine the fee) Set a specific feerate (" + CURRENCY_UNIT + " per KB)\n" - " }\n" - " for backward compatibility: passing in a true instead of an object will result in {\"includeWatching\":true}\n" - "\nResult:\n" - "{\n" - " \"hex\": \"value\", (string) The resulting raw transaction (hex-encoded string)\n" - " \"fee\": n, (numeric) Fee in " + CURRENCY_UNIT + " the resulting transaction pays\n" - " \"changepos\": n (numeric) The position of the added change output, or -1\n" - "}\n" - "\"hex\" \n" - "\nExamples:\n" - "\nCreate a transaction with no inputs\n" + " }\n" + " for backward compatibility: passing in a true instead of an object will result in {\"includeWatching\":true}\n" + "\nResult:\n" + "{\n" + " \"hex\": \"value\", (string) The resulting raw transaction (hex-encoded string)\n" + " \"fee\": n, (numeric) Fee in " + CURRENCY_UNIT + " the resulting transaction pays\n" + " \"changepos\": n (numeric) The position of the added change output, or -1\n" + "}\n" + "\"hex\" \n" + "\nExamples:\n" + "\nCreate a transaction with no inputs\n" + HelpExampleCli("createrawtransaction", "\"[]\" \"{\\\"myaddress\\\":0.01}\"") + "\nAdd sufficient unsigned inputs to meet the output value\n" + HelpExampleCli("fundrawtransaction", "\"rawtransactionhex\"") + @@ -4971,15 +4961,15 @@ UniValue fundrawtransaction(const UniValue& params, bool fHelp) UniValue options = params[1]; RPCTypeCheckObj(options, - { - {"changeAddress", UniValueType(UniValue::VSTR)}, - {"changePosition", UniValueType(UniValue::VNUM)}, - {"includeWatching", UniValueType(UniValue::VBOOL)}, - {"lockUnspents", UniValueType(UniValue::VBOOL)}, - {"private", UniValueType(UniValue::VBOOL)}, - {"feeRate", UniValueType()}, // will be checked below - }, - true, true); + { + {"changeAddress", UniValueType(UniValue::VSTR)}, + {"changePosition", UniValueType(UniValue::VNUM)}, + {"includeWatching", UniValueType(UniValue::VBOOL)}, + {"lockUnspents", UniValueType(UniValue::VBOOL)}, + {"private", UniValueType(UniValue::VBOOL)}, + {"feeRate", UniValueType()}, // will be checked below + }, + true, true); if (options.exists("changeAddress")) { CNavcoinAddress address(options["changeAddress"].get_str()); @@ -5125,8 +5115,8 @@ int GetsStakeSubTotal(vStakeRange& vRange) // scan the entire wallet transactions for (std::map::const_iterator it = pwalletMain->mapWallet.begin(); - it != pwalletMain->mapWallet.end(); - ++it) + it != pwalletMain->mapWallet.end(); + ++it) { pcoin = &(*it).second; @@ -5280,8 +5270,8 @@ UniValue getstakereport(const UniValue& params, bool fHelp) vIt--; result.pushKV("Latest Time", - vIt->Start ? DateTimeStrFormat("%Y-%m-%d %H:%M:%S",vIt->Start).c_str() : - "Never"); + vIt->Start ? DateTimeStrFormat("%Y-%m-%d %H:%M:%S",vIt->Start).c_str() : + "Never"); // Moved nTook call down here to be more accurate nTook = GetTimeMillis() - nTook; @@ -5403,11 +5393,11 @@ UniValue support(const UniValue& params, bool fHelp) if (fHelp || params.size() < 1) throw std::runtime_error( "support \"hash\" ( add )\n" - "\nShows support for the consultation or consultation answer identified by \"hash\".\n" - "\nArguments:\n" - "1. \"hash\" (string, required) The hash\n" - "2. \"add\" (bool, optional) Set to false to remove support (Default: true)\n" - ); + "\nShows support for the consultation or consultation answer identified by \"hash\".\n" + "\nArguments:\n" + "1. \"hash\" (string, required) The hash\n" + "2. \"add\" (bool, optional) Set to false to remove support (Default: true)\n" + ); LOCK(cs_main); @@ -5466,13 +5456,13 @@ UniValue consultationvote(const UniValue& params, bool fHelp) (strCommand != "yes" && strCommand != "value" && strCommand != "abs" && strCommand != "remove")) throw std::runtime_error( "consultationvote \"hash\" \"yes|value|abs|remove\" ( value )\n" - "\nArguments:\n" - "1. \"hash\" (string, required) The consultation/answer hash\n" - "2. \"command\" (string, required) 'yes' to vote yes, 'value' to vote for a range,\n" - " 'abs' to abstain, 'remove' to remove a vote from the list\n" - "3. \"value\" (integer, required) For consultations where the answer is a range,\n" - " this sets the value to vote for\n" - ); + "\nArguments:\n" + "1. \"hash\" (string, required) The consultation/answer hash\n" + "2. \"command\" (string, required) 'yes' to vote yes, 'value' to vote for a range,\n" + " 'abs' to abstain, 'remove' to remove a vote from the list\n" + "3. \"value\" (integer, required) For consultations where the answer is a range,\n" + " this sets the value to vote for\n" + ); LOCK(cs_main); @@ -5581,7 +5571,7 @@ UniValue supportlist(const UniValue& params, bool fHelp) "\nReturns a list containing the wallet's current support status for all active consultations.\n" - ); + ); LOCK(cs_main); @@ -5616,7 +5606,7 @@ UniValue consultationvotelist(const UniValue& params, bool fHelp) "\nReturns a list containing the wallet's current voting status for all active consultations.\n" - ); + ); LOCK(cs_main); @@ -5657,12 +5647,12 @@ UniValue proposalvote(const UniValue& params, bool fHelp) (strCommand != "yes" && strCommand != "no" && strCommand != "abs" && strCommand != "remove")) throw std::runtime_error( "proposalvote \"proposal_hash\" \"yes|no|abs|remove\"\n" - "\nAdds a proposal to the list of votes.\n" - "\nArguments:\n" - "1. \"proposal_hash\" (string, required) The proposal hash\n" - "2. \"command\" (string, required) 'yes' to vote yes, 'no' to vote no,\n" - " 'abs' to abstain, 'remove' to remove a proposal from the list\n" - ); + "\nAdds a proposal to the list of votes.\n" + "\nArguments:\n" + "1. \"proposal_hash\" (string, required) The proposal hash\n" + "2. \"command\" (string, required) 'yes' to vote yes, 'no' to vote no,\n" + " 'abs' to abstain, 'remove' to remove a proposal from the list\n" + ); LOCK(cs_main); @@ -5839,12 +5829,12 @@ UniValue paymentrequestvote(const UniValue& params, bool fHelp) (strCommand != "yes" && strCommand != "no" && strCommand != "abs" && strCommand != "remove")) throw std::runtime_error( "paymentrequestvote \"request_hash\" \"yes|no|abs|remove\"\n" - "\nAdds/removes a proposal to the list of votes.\n" - "\nArguments:\n" - "1. \"request_hash\" (string, required) The payment request hash\n" - "2. \"command\" (string, required) 'yes' to vote yes, 'no' to vote no,\n" - " 'abs' to abstain, 'remove' to remove a proposal from the list\n" - ); + "\nAdds/removes a proposal to the list of votes.\n" + "\nArguments:\n" + "1. \"request_hash\" (string, required) The payment request hash\n" + "2. \"command\" (string, required) 'yes' to vote yes, 'no' to vote no,\n" + " 'abs' to abstain, 'remove' to remove a proposal from the list\n" + ); LOCK(cs_main); @@ -5970,7 +5960,7 @@ UniValue listproposals(const UniValue& params, bool fHelp) if(showAll || (showMine && fIsMine) || (showPending && (fLastState == DAOFlags::NIL || fLastState == DAOFlags::PENDING_VOTING_PREQ - || fLastState == DAOFlags::PENDING_FUNDS)) + || fLastState == DAOFlags::PENDING_FUNDS)) || (showAccepted && (fLastState == DAOFlags::ACCEPTED)) || (showAcceptedExpired && (fLastState == DAOFlags::ACCEPTED_EXPIRED)) || (showRejected && (fLastState == DAOFlags::REJECTED)) @@ -5984,6 +5974,86 @@ UniValue listproposals(const UniValue& params, bool fHelp) return ret; } +UniValue listnames(const UniValue& params, bool fHelp) +{ + if (fHelp) + throw std::runtime_error( + "listnames\n" + "\nList your dotNav names.\n" + "\nArguments:\n" + "\n NOTE: Requires -nameindex to be enabled\n" + + + HelpExampleCli("listnames", "") + + HelpExampleCli("listnames", "true") + ); + + LOCK2(cs_main, pwalletMain->cs_wallet); + + UniValue ret(UniValue::VARR); + + // Check "mine" argument is boolean + if (params.size() == 1 && !params[0].isBool()) + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, argument 1 must be a boolean"); + + NameRecordNameMap mapNames; + CStateViewCache view(pcoinsTip); + + std::map expiryHeights; + + if(view.GetAllNameRecordNames(mapNames)) + { + auto activeHeight = chainActive.Tip()->nHeight; + + for (NameRecordNameMap::iterator it = mapNames.begin(); it != mapNames.end(); it++) + { + auto id = DotNav::GetHashName(it->second.domain); + + if (expiryHeights.count(id) == 0) { + if (!view.HaveNameData(id)) { + expiryHeights.insert(std::make_pair(id, 0)); + continue; + } + + NameDataValues data; + + if (!view.GetNameData(DotNav::GetHashName(it->second.domain), data)) { + expiryHeights.insert(std::make_pair(id, 0)); + continue; + } + + for (auto &i: data) { + if (i.second.key == "_expiry") { + expiryHeights.insert(std::make_pair(id, stoll(i.second.value))); + } + } + } + + if (activeHeight >= expiryHeights[id]) + continue; + + std::string finalName = it->second.domain; + + if (it->second.subdomain != "") + finalName = it->second.subdomain + "." + finalName; + + blsctKey sk; + + if (!pwalletMain->GetBLSCTSpendKey(sk)) + throw JSONRPCError(RPC_TYPE_ERROR, "Wallet not available"); + + blsctKey pk = sk.PrivateChildHash(SerializeHash("name/"+DotNav::GetHashName(it->second.domain).ToString())); + bls::G1Element pkg1 = pk.GetG1Element(); + + if (!view.HaveNameRecord(DotNav::GetHashIdName(it->second.domain, pkg1))) + continue; + + ret.push_back(finalName); + } + } + + return ret; +} + UniValue listtokens(const UniValue& params, bool fHelp) { if (fHelp) @@ -6296,107 +6366,104 @@ extern UniValue removeprunedfunds(const UniValue& params, bool fHelp); static const CRPCCommand commands[] = { // category name actor (function) okSafeMode - // --------------------- ------------------------ ----------------------- ---------- - { "wallet", "getnewprivateaddress", &getnewprivateaddress, true }, - { "wallet", "listprivateunspent", &listprivateunspent, false }, - { "wallet", "privatesendtoaddress", &privatesendtoaddress, false }, - { "wallet", "privatesendmixtoaddress", &privatesendmixtoaddress, false }, - { "rawtransactions", "fundrawtransaction", &fundrawtransaction, false }, - { "hidden", "resendwallettransactions", &resendwallettransactions, true }, - { "wallet", "abandontransaction", &abandontransaction, false }, - { "wallet", "addmultisigaddress", &addmultisigaddress, true }, - { "wallet", "addwitnessaddress", &addwitnessaddress, true }, - { "wallet", "backupwallet", &backupwallet, true }, - { "wallet", "createrawscriptaddress", &createrawscriptaddress, true }, - { "wallet", "dumpprivkey", &dumpprivkey, true }, - { "wallet", "dumpmasterprivkey", &dumpmasterprivkey, true }, - { "wallet", "dumpmnemonic", &dumpmnemonic, true }, - { "wallet", "dumpwallet", &dumpwallet, true }, - { "wallet", "burntoken", &burntoken, true }, - { "wallet", "minttoken", &minttoken, true }, - { "wallet", "mintnft", &mintnft, true }, - { "wallet", "sendtoken", &sendtoken, true }, - { "wallet", "sendnft", &sendnft, true }, - { "wallet", "createtoken", &createtoken, true }, - { "wallet", "createnft", &createnft, true }, - { "wallet", "encryptwallet", &encryptwallet, true }, - { "wallet", "encrypttxdata", &encrypttxdata, true }, - { "wallet", "getaccountaddress", &getaccountaddress, true }, - { "wallet", "getaccount", &getaccount, true }, - { "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true }, - { "wallet", "listprivateaddresses", &listprivateaddresses, true }, - { "wallet", "listtokens", &listtokens, true }, - { "wallet", "listnfts", &listnfts, true }, - { "wallet", "gettoken", &gettoken, true }, - { "wallet", "getnft", &getnft, true }, - { "wallet", "getbalance", &getbalance, false }, - { "wallet", "getnewaddress", &getnewaddress, true }, - { "wallet", "getcoldstakingaddress", &getcoldstakingaddress, true }, - { "wallet", "getrawchangeaddress", &getrawchangeaddress, true }, - { "wallet", "getreceivedbyaccount", &getreceivedbyaccount, false }, - { "wallet", "getreceivedbyaddress", &getreceivedbyaddress, false }, - { "wallet", "getstakereport", &getstakereport, false }, - { "wallet", "gettransaction", &gettransaction, false }, - { "wallet", "getunconfirmedbalance", &getunconfirmedbalance, false }, - { "wallet", "getwalletinfo", &getwalletinfo, false }, - { "wallet", "importprivkey", &importprivkey, true }, - { "wallet", "importwallet", &importwallet, true }, - { "wallet", "importaddress", &importaddress, true }, - { "wallet", "importprunedfunds", &importprunedfunds, true }, - { "wallet", "importpubkey", &importpubkey, true }, - { "wallet", "keypoolrefill", &keypoolrefill, true }, - { "wallet", "listaccounts", &listaccounts, false }, - { "wallet", "listaddressgroupings", &listaddressgroupings, false }, - { "wallet", "listlockunspent", &listlockunspent, false }, - { "wallet", "listreceivedbyaccount", &listreceivedbyaccount, false }, - { "wallet", "listreceivedbyaddress", &listreceivedbyaddress, false }, - { "wallet", "listsinceblock", &listsinceblock, false }, - { "wallet", "listtransactions", &listtransactions, false }, - { "wallet", "listunspent", &listunspent, false }, - { "wallet", "lockunspent", &lockunspent, true }, - { "wallet", "move", &movecmd, false }, - { "wallet", "sendfrom", &sendfrom, false }, - { "wallet", "sendmany", &sendmany, false }, - { "wallet", "sendtoaddress", &sendtoaddress, false }, - { "communityfund", "donatefund", &donatefund, false }, - { "communityfund", "createpaymentrequest", &createpaymentrequest, false }, - { "communityfund", "createproposal", &createproposal, false }, - { "dao", "createconsultation", &createconsultation, false }, - { "dao", "createconsultationwithanswers", - &createconsultationwithanswers, - false }, - { "dao", "getstakervote", &getstakervote, false }, - { "dao", "proposeanswer", &proposeanswer, false }, - { "dao", "proposeconsensuschange", &proposeconsensuschange, false }, - { "dao", "proposecombinedconsensuschange", &proposecombinedconsensuschange, false }, - { "dao", "getconsensusparameters", &getconsensusparameters, false }, - { "dao", "setexclude", &setexclude, false }, - { "wallet", "stakervote", &stakervote, false }, - { "dao", "support", &support, false }, - { "dao", "supportlist", &supportlist, false }, - { "dao", "consultationvote", &consultationvote, false }, - { "dao", "consultationvotelist", &consultationvotelist, false }, - { "communityfund", "proposalvote", &proposalvote, false }, - { "communityfund", "proposalvotelist", &proposalvotelist, false }, - { "communityfund", "listproposals", &listproposals, true }, - { "communityfund", "paymentrequestvote", &paymentrequestvote, false }, - { "communityfund", "paymentrequestvotelist", &paymentrequestvotelist, false }, - { "communityfund", "proposalvote", &proposalvote, false }, - { "communityfund", "proposalvotelist", &proposalvotelist, false }, - { "wallet", "generateblsctkeys", &generateblsctkeys, true }, - { "wallet", "setaccount", &setaccount, true }, - { "wallet", "settxfee", &settxfee, true }, - { "wallet", "signmessage", &signmessage, true }, - { "wallet", "walletlock", &walletlock, true }, - { "wallet", "walletpassphrasechange", &walletpassphrasechange, true }, - { "wallet", "walletpassphrase", &walletpassphrase, true }, - { "wallet", "removeprunedfunds", &removeprunedfunds, true }, - { "wallet", "resolveopenalias", &resolveopenalias, true }, - { "dotnav", "registername", ®istername, true }, - { "dotnav", "renewname", &renewname, true }, - { "dotnav", "updatename", &updatename, true }, - { "dotnav", "resolvename", &resolvename, true }, - { "dotnav", "genkeyname", &genkeyname, true }, + // --------------------- ------------------------ ----------------------- ---------- + { "communityfund", "createpaymentrequest", &createpaymentrequest, false }, + { "communityfund", "createproposal", &createproposal, false }, + { "communityfund", "donatefund", &donatefund, false }, + { "communityfund", "listproposals", &listproposals, true }, + { "communityfund", "paymentrequestvote", &paymentrequestvote, false }, + { "communityfund", "paymentrequestvotelist", &paymentrequestvotelist, false }, + { "communityfund", "proposalvote", &proposalvote, false }, + { "communityfund", "proposalvotelist", &proposalvotelist, false }, + { "dao", "consultationvote", &consultationvote, false }, + { "dao", "consultationvotelist", &consultationvotelist, false }, + { "dao", "createconsultation", &createconsultation, false }, + { "dao", "createconsultationwithanswers", &createconsultationwithanswers, false }, + { "dao", "getconsensusparameters", &getconsensusparameters, false }, + { "dao", "getstakervote", &getstakervote, false }, + { "dao", "proposeanswer", &proposeanswer, false }, + { "dao", "proposecombinedconsensuschange", &proposecombinedconsensuschange, false }, + { "dao", "proposeconsensuschange", &proposeconsensuschange, false }, + { "dao", "setexclude", &setexclude, false }, + { "dao", "support", &support, false }, + { "dao", "supportlist", &supportlist, false }, + { "dotnav", "genkeyname", &genkeyname, true }, + { "dotnav", "registername", ®istername, true }, + { "dotnav", "renewname", &renewname, true }, + { "dotnav", "resolvename", &resolvename, true }, + { "dotnav", "updatename", &updatename, true }, + { "hidden", "resendwallettransactions", &resendwallettransactions, true }, + { "rawtransactions", "fundrawtransaction", &fundrawtransaction, false }, + { "wallet", "abandontransaction", &abandontransaction, false }, + { "wallet", "addmultisigaddress", &addmultisigaddress, true }, + { "wallet", "addwitnessaddress", &addwitnessaddress, true }, + { "wallet", "backupwallet", &backupwallet, true }, + { "wallet", "burntoken", &burntoken, true }, + { "wallet", "createnft", &createnft, true }, + { "wallet", "createrawscriptaddress", &createrawscriptaddress, true }, + { "wallet", "createtoken", &createtoken, true }, + { "wallet", "dumpmasterprivkey", &dumpmasterprivkey, true }, + { "wallet", "dumpmnemonic", &dumpmnemonic, true }, + { "wallet", "dumpprivkey", &dumpprivkey, true }, + { "wallet", "dumpwallet", &dumpwallet, true }, + { "wallet", "encrypttxdata", &encrypttxdata, true }, + { "wallet", "encryptwallet", &encryptwallet, true }, + { "wallet", "generateblsctkeys", &generateblsctkeys, true }, + { "wallet", "getaccount", &getaccount, true }, + { "wallet", "getaccountaddress", &getaccountaddress, true }, + { "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true }, + { "wallet", "getbalance", &getbalance, false }, + { "wallet", "getcoldstakingaddress", &getcoldstakingaddress, true }, + { "wallet", "getnewaddress", &getnewaddress, true }, + { "wallet", "getnewprivateaddress", &getnewprivateaddress, true }, + { "wallet", "getnft", &getnft, true }, + { "wallet", "getrawchangeaddress", &getrawchangeaddress, true }, + { "wallet", "getreceivedbyaccount", &getreceivedbyaccount, false }, + { "wallet", "getreceivedbyaddress", &getreceivedbyaddress, false }, + { "wallet", "getstakereport", &getstakereport, false }, + { "wallet", "gettoken", &gettoken, true }, + { "wallet", "gettransaction", &gettransaction, false }, + { "wallet", "getunconfirmedbalance", &getunconfirmedbalance, false }, + { "wallet", "getwalletinfo", &getwalletinfo, false }, + { "wallet", "importaddress", &importaddress, true }, + { "wallet", "importprivkey", &importprivkey, true }, + { "wallet", "importprunedfunds", &importprunedfunds, true }, + { "wallet", "importpubkey", &importpubkey, true }, + { "wallet", "importwallet", &importwallet, true }, + { "wallet", "keypoolrefill", &keypoolrefill, true }, + { "wallet", "listaccounts", &listaccounts, false }, + { "wallet", "listaddressgroupings", &listaddressgroupings, false }, + { "wallet", "listlockunspent", &listlockunspent, false }, + { "wallet", "listnames", &listnames, true }, + { "wallet", "listnfts", &listnfts, true }, + { "wallet", "listprivateaddresses", &listprivateaddresses, true }, + { "wallet", "listprivateunspent", &listprivateunspent, false }, + { "wallet", "listreceivedbyaccount", &listreceivedbyaccount, false }, + { "wallet", "listreceivedbyaddress", &listreceivedbyaddress, false }, + { "wallet", "listsinceblock", &listsinceblock, false }, + { "wallet", "listtokens", &listtokens, true }, + { "wallet", "listtransactions", &listtransactions, false }, + { "wallet", "listunspent", &listunspent, false }, + { "wallet", "lockunspent", &lockunspent, true }, + { "wallet", "mintnft", &mintnft, true }, + { "wallet", "minttoken", &minttoken, true }, + { "wallet", "move", &movecmd, false }, + { "wallet", "privatesendmixtoaddress", &privatesendmixtoaddress, false }, + { "wallet", "privatesendtoaddress", &privatesendtoaddress, false }, + { "wallet", "removeprunedfunds", &removeprunedfunds, true }, + { "wallet", "resolveopenalias", &resolveopenalias, true }, + { "wallet", "sendfrom", &sendfrom, false }, + { "wallet", "sendmany", &sendmany, false }, + { "wallet", "sendnft", &sendnft, true }, + { "wallet", "sendtoaddress", &sendtoaddress, false }, + { "wallet", "sendtoken", &sendtoken, true }, + { "wallet", "setaccount", &setaccount, true }, + { "wallet", "settxfee", &settxfee, true }, + { "wallet", "signmessage", &signmessage, true }, + { "wallet", "stakervote", &stakervote, false }, + { "wallet", "walletlock", &walletlock, true }, + { "wallet", "walletpassphrase", &walletpassphrase, true }, + { "wallet", "walletpassphrasechange", &walletpassphrasechange, true }, }; void RegisterWalletRPCCommands(CRPCTable &tableRPC)