2021-04-20 21:33:02 +02:00
// Copyright (c) 2014-2021 The Dash Core developers
2014-12-09 02:17:57 +01:00
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
2021-10-25 15:55:34 +02:00
# include <chainparams.h>
2020-03-19 23:46:56 +01:00
# include <evo/deterministicmns.h>
2021-10-01 21:19:08 +02:00
# include <governance/classes.h>
2021-05-25 12:48:04 +02:00
# include <index/txindex.h>
2022-04-05 11:09:41 +02:00
# include <node/context.h>
2021-10-01 21:19:08 +02:00
# include <masternode/node.h>
# include <masternode/payments.h>
2021-04-23 00:32:03 +02:00
# include <net.h>
# include <netbase.h>
2022-04-05 11:09:41 +02:00
# include <rpc/blockchain.h>
2020-03-19 23:46:56 +01:00
# include <rpc/server.h>
2021-10-25 15:55:34 +02:00
# include <rpc/util.h>
# include <univalue.h>
2021-04-23 00:32:03 +02:00
# include <validation.h>
2020-03-19 23:46:56 +01:00
# include <wallet/coincontrol.h>
# include <wallet/rpcwallet.h>
2017-12-01 19:53:34 +01:00
# ifdef ENABLE_WALLET
2020-03-19 23:46:56 +01:00
# include <wallet/wallet.h>
2017-12-01 19:53:34 +01:00
# endif // ENABLE_WALLET
2014-12-09 02:17:57 +01:00
2019-12-31 15:22:17 +01:00
# include <fstream>
# include <iomanip>
2016-11-21 21:40:56 +01:00
2018-05-04 22:42:39 +02:00
static UniValue masternodelist ( const JSONRPCRequest & request ) ;
2014-12-09 02:17:57 +01:00
2022-02-27 08:44:07 +01:00
static void masternode_list_help ( const JSONRPCRequest & request )
2018-08-29 13:36:35 +02:00
{
2022-02-27 08:44:07 +01:00
RPCHelpMan { " masternodelist " ,
" Get a list of masternodes in different modes. This call is identical to 'masternode list' call. \n "
" Available modes: \n "
" addr - Print ip address associated with a masternode (can be additionally filtered, partial match) \n "
" full - Print info in format 'status payee lastpaidtime lastpaidblock IP' \n "
" (can be additionally filtered, partial match) \n "
" info - Print info in format 'status payee IP' \n "
" (can be additionally filtered, partial match) \n "
" json - Print info in JSON format (can be additionally filtered, partial match) \n "
" lastpaidblock - Print the last block height a node was paid on the network \n "
" lastpaidtime - Print the last time a node was paid on the network \n "
" owneraddress - Print the masternode owner Dash address \n "
" payee - Print the masternode payout Dash address (can be additionally filtered, \n "
" partial match) \n "
" pubKeyOperator - Print the masternode operator public key \n "
" status - Print masternode status: ENABLED / POSE_BANNED \n "
" (can be additionally filtered, partial match) \n "
" votingaddress - Print the masternode voting Dash address \n " ,
{
{ " mode " , RPCArg : : Type : : STR , /* default */ " json " , " The mode to run list in " } ,
{ " filter " , RPCArg : : Type : : STR , /* default */ " " , " Filter results. Partial match by outpoint by default in all modes, additional matches in some modes are also available " } ,
} ,
RPCResults { } ,
RPCExamples { " " } ,
} . Check ( request ) ;
2018-08-29 13:36:35 +02:00
}
2014-12-06 20:41:53 +01:00
2022-02-27 08:44:07 +01:00
static void masternode_connect_help ( const JSONRPCRequest & request )
2018-08-29 13:36:35 +02:00
{
2022-02-27 08:44:07 +01:00
RPCHelpMan { " masternode connect " ,
" Connect to given masternode \n " ,
{
{ " address " , RPCArg : : Type : : STR , RPCArg : : Optional : : NO , " The address of the masternode to connect " } ,
} ,
RPCResults { } ,
RPCExamples { " " }
} . Check ( request ) ;
2018-08-29 13:36:35 +02:00
}
2014-12-09 02:17:57 +01:00
2018-05-04 22:42:39 +02:00
static UniValue masternode_connect ( const JSONRPCRequest & request )
2018-08-29 13:36:35 +02:00
{
2022-05-12 22:29:17 +02:00
masternode_connect_help ( request ) ;
2014-12-09 02:17:57 +01:00
2022-05-12 22:29:17 +02:00
std : : string strAddress = request . params [ 0 ] . get_str ( ) ;
2016-09-16 17:22:57 +02:00
2018-08-29 13:36:35 +02:00
CService addr ;
if ( ! Lookup ( strAddress . c_str ( ) , addr , 0 , false ) )
throw JSONRPCError ( RPC_INTERNAL_ERROR , strprintf ( " Incorrect masternode address %s " , strAddress ) ) ;
2015-07-18 21:17:17 +02:00
2018-08-29 13:36:35 +02:00
// TODO: Pass CConnman instance somehow and don't use global variable.
2022-04-23 09:46:44 +02:00
NodeContext & node = EnsureNodeContext ( request . context ) ;
node . connman - > OpenMasternodeConnection ( CAddress ( addr , NODE_NETWORK ) ) ;
if ( ! node . connman - > IsConnected ( CAddress ( addr , NODE_NETWORK ) , CConnman : : AllNodes ) )
2018-08-29 13:36:35 +02:00
throw JSONRPCError ( RPC_INTERNAL_ERROR , strprintf ( " Couldn't connect to masternode %s " , strAddress ) ) ;
2015-07-18 21:17:17 +02:00
2018-08-29 13:36:35 +02:00
return " successfully connected " ;
}
2016-09-16 17:22:57 +02:00
2022-02-27 08:44:07 +01:00
static void masternode_count_help ( const JSONRPCRequest & request )
2018-08-29 13:36:35 +02:00
{
2022-02-27 08:44:07 +01:00
RPCHelpMan { " masternode count " ,
" Get information about number of masternodes. \n " ,
{ } ,
RPCResults { } ,
RPCExamples { " " }
} . Check ( request ) ;
2018-08-29 13:36:35 +02:00
}
2015-07-18 21:17:17 +02:00
2018-05-04 22:42:39 +02:00
static UniValue masternode_count ( const JSONRPCRequest & request )
2018-08-29 13:36:35 +02:00
{
2022-05-12 22:29:17 +02:00
masternode_count_help ( request ) ;
2015-08-20 17:36:44 +02:00
2018-12-17 16:27:17 +01:00
auto mnList = deterministicMNManager - > GetListAtChainTip ( ) ;
int total = mnList . GetAllMNsCount ( ) ;
int enabled = mnList . GetValidMNsCount ( ) ;
2018-02-08 06:43:19 +01:00
2021-03-26 13:17:25 +01:00
UniValue obj ( UniValue : : VOBJ ) ;
obj . pushKV ( " total " , total ) ;
obj . pushKV ( " enabled " , enabled ) ;
return obj ;
2018-08-29 13:36:35 +02:00
}
2018-05-04 22:42:39 +02:00
static UniValue GetNextMasternodeForPayment ( int heightShift )
2018-08-29 13:36:35 +02:00
{
2018-12-17 13:15:13 +01:00
auto mnList = deterministicMNManager - > GetListAtChainTip ( ) ;
auto payees = mnList . GetProjectedMNPayees ( heightShift ) ;
if ( payees . empty ( ) )
return " unknown " ;
2019-03-21 21:47:05 +01:00
auto payee = payees . back ( ) ;
2018-12-17 13:15:13 +01:00
CScript payeeScript = payee - > pdmnState - > scriptPayout ;
2018-11-14 15:39:40 +01:00
CTxDestination payeeDest ;
Merge #11117: Prepare for non-Base58 addresses (#3294)
* Merge #11117: Prepare for non-Base58 addresses
864cd2787 Move CBitcoinAddress to base58.cpp (Pieter Wuille)
5c8ff0d44 Introduce wrappers around CBitcoinAddress (Pieter Wuille)
Pull request description:
This patch removes the need for the intermediary Base58 type `CBitcoinAddress`, by providing {`Encode`,`Decode`,`IsValid`}`Destination` functions that directly operate on the conversion between `std::string`s and `CTxDestination`.
As a side, it also fixes a number of indentation issues, and removes probably several unnecessary implicit `CTxDestination`<->`CBitcoinAddress` conversions.
This change is far from complete. In follow-ups I'd like to:
* Split off the specific address and key encoding logic from base58.h, and move it to a address.h or so.
* Replace `CTxDestination` with a non-`boost::variant` version (which can be more efficient as `boost::variant` allocates everything on the heap, and remove the need for `boost::get<...>` and `IsValidDestination` calls everywhere).
* Do the same for `CBitcoinSecret`, `CBitcoinExtKey`, and `CBitcoinExtPubKey`.
However, I've tried to keep this patch to be minimally invasive, but still enough to support non-Base58 addresses. Perhaps a smaller patch is possible to hack Bech32 support into `CBitcoinAddress`, but I would consider that a move in the wrong direction.
Tree-SHA512: c2c77ffb57caeadf2429b1c2562ce60e8c7be8aa9f8e51b591f354b6b441162625b2efe14c023a1ae485cf2ed417263afa35c892891dfaa7844e7fbabccab85e
* CBitcoinAddress -> EncodeDestination in providertx.h
Signed-off-by: Pasta <pasta@dashboost.org>
* more CBitcoinAddress -> EncodeDestination in providertx.h
Signed-off-by: Pasta <pasta@dashboost.org>
* more CBitcoinAddress -> EncodeDestination in providertx.h
Signed-off-by: Pasta <pasta@dashboost.org>
* more CBitcoinAddress -> EncodeDestination in providertx.h
Signed-off-by: Pasta <pasta@dashboost.org>
* fix CBitcoinAddress GetKeyID check
Signed-off-by: Pasta <pasta@dashboost.org>
* fix providertx.cpp
Signed-off-by: Pasta <pasta@dashboost.org>
* hopefully fix governance-classes.cpp
Signed-off-by: Pasta <pasta@dashboost.org>
* partially fix governance-validators.cpp, unable to resolve "address.IsScript()"
Signed-off-by: Pasta <pasta@dashboost.org>
* partially fix governance-classes.cpp, unable to resolve "address.IsScript()"
Signed-off-by: Pasta <pasta@dashboost.org>
* fix governance-classes.h
Signed-off-by: Pasta <pasta@dashboost.org>
* DecodeTransaction -> DecodeDestination, fix governance-validators.cpp
Signed-off-by: Pasta <pasta@dashboost.org>
* More fixes for 3294
* Move GetIndexKey into rpc/misc.cpp near getAddressesFromParams
No need to have it in base58.cpp anymore as this is only used in getAddressesFromParams
Co-authored-by: Wladimir J. van der Laan <laanwj@gmail.com>
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
Co-authored-by: Alexander Block <ablock84@gmail.com>
2020-01-22 11:35:04 +01:00
ExtractDestination ( payeeScript , payeeDest ) ;
2015-07-18 21:17:17 +02:00
2018-08-29 13:36:35 +02:00
UniValue obj ( UniValue : : VOBJ ) ;
2016-09-15 08:50:41 +02:00
2020-06-18 11:17:23 +02:00
obj . pushKV ( " height " , mnList . GetHeight ( ) + heightShift ) ;
obj . pushKV ( " IP:port " , payee - > pdmnState - > addr . ToString ( ) ) ;
obj . pushKV ( " proTxHash " , payee - > proTxHash . ToString ( ) ) ;
obj . pushKV ( " outpoint " , payee - > collateralOutpoint . ToStringShort ( ) ) ;
obj . pushKV ( " payee " , IsValidDestination ( payeeDest ) ? EncodeDestination ( payeeDest ) : " UNKNOWN " ) ;
2018-08-29 13:36:35 +02:00
return obj ;
}
2015-07-18 21:17:17 +02:00
2022-02-27 08:44:07 +01:00
static void masternode_winner_help ( const JSONRPCRequest & request )
2018-08-29 13:36:35 +02:00
{
2021-03-26 13:17:25 +01:00
if ( ! IsDeprecatedRPCEnabled ( " masternode_winner " ) ) {
throw std : : runtime_error ( " DEPRECATED: set -deprecatedrpc=masternode_winner to enable it " ) ;
}
2022-02-27 08:44:07 +01:00
RPCHelpMan { " masternode winner " ,
" Print info on next masternode winner to vote for \n " ,
{ } ,
RPCResults { } ,
RPCExamples { " " }
} . Check ( request ) ;
2018-08-29 13:36:35 +02:00
}
2018-03-01 14:18:46 +01:00
2018-05-04 22:42:39 +02:00
static UniValue masternode_winner ( const JSONRPCRequest & request )
2018-08-29 13:36:35 +02:00
{
2022-05-12 22:29:17 +02:00
masternode_winner_help ( request ) ;
2018-08-29 13:36:35 +02:00
return GetNextMasternodeForPayment ( 10 ) ;
}
2015-07-18 03:23:52 +02:00
2022-02-27 08:44:07 +01:00
static void masternode_current_help ( const JSONRPCRequest & request )
2018-08-29 13:36:35 +02:00
{
2021-03-26 13:17:25 +01:00
if ( ! IsDeprecatedRPCEnabled ( " masternode_current " ) ) {
throw std : : runtime_error ( " DEPRECATED: set -deprecatedrpc=masternode_current to enable it " ) ;
}
2022-02-27 08:44:07 +01:00
RPCHelpMan { " masternode current " ,
" Print info on current masternode winner to be paid the next block (calculated locally) \n " ,
{ } ,
RPCResults { } ,
RPCExamples { " " }
} . Check ( request ) ;
2018-08-29 13:36:35 +02:00
}
2014-12-06 20:41:53 +01:00
2018-05-04 22:42:39 +02:00
static UniValue masternode_current ( const JSONRPCRequest & request )
2018-08-29 13:36:35 +02:00
{
2022-05-12 22:29:17 +02:00
masternode_current_help ( request ) ;
2018-08-29 13:36:35 +02:00
return GetNextMasternodeForPayment ( 1 ) ;
}
2014-12-06 20:41:53 +01:00
2018-08-29 13:36:35 +02:00
# ifdef ENABLE_WALLET
2022-02-27 08:44:07 +01:00
static void masternode_outputs_help ( const JSONRPCRequest & request )
2018-08-29 13:36:35 +02:00
{
2022-02-27 08:44:07 +01:00
RPCHelpMan { " masternode outputs " ,
" Print masternode compatible outputs \n " ,
{ } ,
RPCResults { } ,
RPCExamples { " " }
} . Check ( request ) ;
2018-08-29 13:36:35 +02:00
}
2018-05-04 22:42:39 +02:00
static UniValue masternode_outputs ( const JSONRPCRequest & request )
2018-08-29 13:36:35 +02:00
{
2022-05-12 22:29:17 +02:00
masternode_outputs_help ( request ) ;
2021-04-27 16:12:12 +02:00
2022-03-13 04:11:13 +01:00
std : : shared_ptr < CWallet > const wallet = GetWalletForJSONRPCRequest ( request ) ;
if ( ! wallet ) return NullUniValue ;
CWallet * const pwallet = wallet . get ( ) ;
2020-07-07 08:06:59 +02:00
2018-08-29 13:36:35 +02:00
// Find possible candidates
std : : vector < COutput > vPossibleCoins ;
2019-10-23 09:56:44 +02:00
CCoinControl coin_control ;
2020-05-18 14:26:18 +02:00
coin_control . nCoinType = CoinType : : ONLY_MASTERNODE_COLLATERAL ;
2021-09-28 23:40:32 +02:00
{
2018-11-09 15:36:34 +01:00
LOCK ( pwallet - > cs_wallet ) ;
2022-05-07 17:46:33 +02:00
pwallet - > AvailableCoins ( vPossibleCoins , true , & coin_control ) ;
2021-09-28 23:40:32 +02:00
}
2018-08-29 13:36:35 +02:00
UniValue obj ( UniValue : : VOBJ ) ;
for ( const auto & out : vPossibleCoins ) {
2020-06-18 11:17:23 +02:00
obj . pushKV ( out . tx - > GetHash ( ) . ToString ( ) , strprintf ( " %d " , out . i ) ) ;
2014-12-26 21:00:56 +01:00
}
2018-08-29 13:36:35 +02:00
return obj ;
}
2017-12-01 19:53:34 +01:00
# endif // ENABLE_WALLET
2014-12-26 21:00:56 +01:00
2022-02-27 08:44:07 +01:00
static void masternode_status_help ( const JSONRPCRequest & request )
2018-08-29 13:36:35 +02:00
{
2022-02-27 08:44:07 +01:00
RPCHelpMan { " masternode status " ,
" Print masternode status information \n " ,
{ } ,
RPCResults { } ,
RPCExamples { " " }
} . Check ( request ) ;
2018-08-29 13:36:35 +02:00
}
2016-03-02 21:57:24 +01:00
2018-05-04 22:42:39 +02:00
static UniValue masternode_status ( const JSONRPCRequest & request )
2018-08-29 13:36:35 +02:00
{
2022-05-12 22:29:17 +02:00
masternode_status_help ( request ) ;
2015-07-21 00:09:42 +02:00
2018-08-29 13:36:35 +02:00
if ( ! fMasternodeMode )
throw JSONRPCError ( RPC_INTERNAL_ERROR , " This is not a masternode " ) ;
2015-07-21 00:09:42 +02:00
2018-08-29 13:36:35 +02:00
UniValue mnObj ( UniValue : : VOBJ ) ;
2016-03-06 17:44:21 +01:00
2021-07-26 17:52:52 +02:00
CDeterministicMNCPtr dmn ;
{
LOCK ( activeMasternodeInfoCs ) ;
// keep compatibility with legacy status for now (might get deprecated/removed later)
mnObj . pushKV ( " outpoint " , activeMasternodeInfo . outpoint . ToStringShort ( ) ) ;
mnObj . pushKV ( " service " , activeMasternodeInfo . service . ToString ( ) ) ;
dmn = deterministicMNManager - > GetListAtChainTip ( ) . GetMN ( activeMasternodeInfo . proTxHash ) ;
}
2019-01-03 10:17:43 +01:00
if ( dmn ) {
2020-06-18 11:17:23 +02:00
mnObj . pushKV ( " proTxHash " , dmn - > proTxHash . ToString ( ) ) ;
mnObj . pushKV ( " collateralHash " , dmn - > collateralOutpoint . hash . ToString ( ) ) ;
mnObj . pushKV ( " collateralIndex " , ( int ) dmn - > collateralOutpoint . n ) ;
2019-01-03 10:17:43 +01:00
UniValue stateObj ;
dmn - > pdmnState - > ToJson ( stateObj ) ;
2020-06-18 11:17:23 +02:00
mnObj . pushKV ( " dmnState " , stateObj ) ;
2018-02-23 13:30:36 +01:00
}
2020-06-18 11:17:23 +02:00
mnObj . pushKV ( " state " , activeMasternodeManager - > GetStateString ( ) ) ;
mnObj . pushKV ( " status " , activeMasternodeManager - > GetStatus ( ) ) ;
2019-01-03 10:17:43 +01:00
2018-08-29 13:36:35 +02:00
return mnObj ;
}
2015-07-18 21:17:17 +02:00
2018-05-04 22:42:39 +02:00
static std : : string GetRequiredPaymentsString ( int nBlockHeight , const CDeterministicMNCPtr & payee )
2020-12-11 23:38:08 +01:00
{
std : : string strPayments = " Unknown " ;
if ( payee ) {
CTxDestination dest ;
if ( ! ExtractDestination ( payee - > pdmnState - > scriptPayout , dest ) ) {
2022-02-27 11:16:35 +01:00
CHECK_NONFATAL ( false ) ;
2020-12-11 23:38:08 +01:00
}
strPayments = EncodeDestination ( dest ) ;
2020-12-24 00:24:06 +01:00
if ( payee - > nOperatorReward ! = 0 & & payee - > pdmnState - > scriptOperatorPayout ! = CScript ( ) ) {
if ( ! ExtractDestination ( payee - > pdmnState - > scriptOperatorPayout , dest ) ) {
2022-02-27 11:16:35 +01:00
CHECK_NONFATAL ( false ) ;
2020-12-24 00:24:06 +01:00
}
strPayments + = " , " + EncodeDestination ( dest ) ;
}
2020-12-11 23:38:08 +01:00
}
if ( CSuperblockManager : : IsSuperblockTriggered ( nBlockHeight ) ) {
std : : vector < CTxOut > voutSuperblock ;
if ( ! CSuperblockManager : : GetSuperblockPayments ( nBlockHeight , voutSuperblock ) ) {
return strPayments + " , error " ;
}
std : : string strSBPayees = " Unknown " ;
for ( const auto & txout : voutSuperblock ) {
CTxDestination dest ;
ExtractDestination ( txout . scriptPubKey , dest ) ;
if ( strSBPayees ! = " Unknown " ) {
strSBPayees + = " , " + EncodeDestination ( dest ) ;
} else {
strSBPayees = EncodeDestination ( dest ) ;
}
}
strPayments + = " , " + strSBPayees ;
}
return strPayments ;
}
2022-02-27 08:44:07 +01:00
static void masternode_winners_help ( const JSONRPCRequest & request )
2018-08-29 13:36:35 +02:00
{
2022-02-27 08:44:07 +01:00
RPCHelpMan { " masternode winners " ,
" Print list of masternode winners \n " ,
{
{ " count " , RPCArg : : Type : : NUM , /* default */ " " , " number of last winners to return " } ,
{ " filter " , RPCArg : : Type : : STR , /* default */ " " , " filter for returned winners " } ,
} ,
RPCResults { } ,
RPCExamples { " " }
} . Check ( request ) ;
2018-08-29 13:36:35 +02:00
}
2018-05-04 22:42:39 +02:00
static UniValue masternode_winners ( const JSONRPCRequest & request )
2018-08-29 13:36:35 +02:00
{
2022-05-12 22:29:17 +02:00
masternode_winners_help ( request ) ;
2018-08-29 13:36:35 +02:00
2020-12-11 23:38:08 +01:00
const CBlockIndex * pindexTip { nullptr } ;
2018-08-29 13:36:35 +02:00
{
LOCK ( cs_main ) ;
2021-10-16 12:54:22 +02:00
pindexTip = : : ChainActive ( ) . Tip ( ) ;
2020-12-11 23:38:08 +01:00
if ( ! pindexTip ) return NullUniValue ;
2015-07-18 21:17:17 +02:00
}
2020-12-11 23:38:08 +01:00
int nCount = 10 ;
2018-08-29 13:36:35 +02:00
std : : string strFilter = " " ;
2018-08-11 00:36:17 +02:00
2022-05-12 22:29:17 +02:00
if ( ! request . params [ 0 ] . isNull ( ) ) {
nCount = atoi ( request . params [ 0 ] . get_str ( ) ) ;
2018-08-29 13:36:35 +02:00
}
2018-08-11 00:36:17 +02:00
2022-05-12 22:29:17 +02:00
if ( ! request . params [ 1 ] . isNull ( ) ) {
strFilter = request . params [ 1 ] . get_str ( ) ;
2018-08-29 13:36:35 +02:00
}
2018-08-11 00:36:17 +02:00
2018-08-29 13:36:35 +02:00
UniValue obj ( UniValue : : VOBJ ) ;
2020-12-11 23:38:08 +01:00
int nChainTipHeight = pindexTip - > nHeight ;
int nStartHeight = std : : max ( nChainTipHeight - nCount , 1 ) ;
for ( int h = nStartHeight ; h < = nChainTipHeight ; h + + ) {
auto payee = deterministicMNManager - > GetListForBlock ( pindexTip - > GetAncestor ( h - 1 ) ) . GetMNPayee ( ) ;
std : : string strPayments = GetRequiredPaymentsString ( h , payee ) ;
if ( strFilter ! = " " & & strPayments . find ( strFilter ) = = std : : string : : npos ) continue ;
obj . pushKV ( strprintf ( " %d " , h ) , strPayments ) ;
}
auto projection = deterministicMNManager - > GetListForBlock ( pindexTip ) . GetProjectedMNPayees ( 20 ) ;
for ( size_t i = 0 ; i < projection . size ( ) ; i + + ) {
int h = nChainTipHeight + 1 + i ;
std : : string strPayments = GetRequiredPaymentsString ( h , projection [ i ] ) ;
if ( strFilter ! = " " & & strPayments . find ( strFilter ) = = std : : string : : npos ) continue ;
obj . pushKV ( strprintf ( " %d " , h ) , strPayments ) ;
2018-08-29 13:36:35 +02:00
}
return obj ;
}
2022-02-27 08:44:07 +01:00
static void masternode_payments_help ( const JSONRPCRequest & request )
2020-12-15 03:15:09 +01:00
{
2022-02-27 08:44:07 +01:00
RPCHelpMan { " masternode payments " ,
" \n Returns an array of deterministic masternodes and their payments for the specified block \n " ,
{
{ " blockhash " , RPCArg : : Type : : STR_HEX , /* default */ " tip " , " The hash of the starting block " } ,
{ " count " , RPCArg : : Type : : NUM , /* default */ " 1 " , " The number of blocks to return. Will return <count> previous blocks if <count> is negative. Both 1 and -1 correspond to the chain tip. " } ,
} ,
RPCResult {
2022-05-12 22:29:17 +02:00
RPCResult : : Type : : ARR , " " , " Blocks " ,
{
{ RPCResult : : Type : : OBJ , " " , " " ,
{
{ RPCResult : : Type : : NUM , " height " , " The height of the block " } ,
{ RPCResult : : Type : : STR_HEX , " blockhash " , " The hash of the block " } ,
{ RPCResult : : Type : : NUM , " amount " , " Amount received in this block by all masternodes " } ,
{ RPCResult : : Type : : ARR , " masternodes " , " Masternodes that received payments in this block " ,
{
{ RPCResult : : Type : : STR_HEX , " proTxHash " , " The hash of the corresponding ProRegTx " } ,
{ RPCResult : : Type : : NUM , " amount " , " Amount received by this masternode " } ,
{ RPCResult : : Type : : ARR , " payees " , " Payees who received a share of this payment " ,
{
{ RPCResult : : Type : : STR , " address " , " Payee address " } ,
{ RPCResult : : Type : : STR_HEX , " script " , " Payee scriptPubKey " } ,
{ RPCResult : : Type : : NUM , " amount " , " Amount received by this payee " } ,
} } ,
} } ,
} } ,
} ,
2022-02-27 08:44:07 +01:00
} ,
RPCExamples { " " }
} . Check ( request ) ;
2020-12-15 03:15:09 +01:00
}
2018-05-04 22:42:39 +02:00
static UniValue masternode_payments ( const JSONRPCRequest & request )
2020-12-15 03:15:09 +01:00
{
2022-05-12 22:29:17 +02:00
masternode_payments_help ( request ) ;
2020-12-15 03:15:09 +01:00
CBlockIndex * pindex { nullptr } ;
2021-05-25 12:48:04 +02:00
if ( g_txindex ) {
g_txindex - > BlockUntilSyncedToCurrentChain ( ) ;
}
2022-05-12 22:29:17 +02:00
if ( request . params [ 0 ] . isNull ( ) ) {
2020-12-15 03:15:09 +01:00
LOCK ( cs_main ) ;
2021-10-16 12:54:22 +02:00
pindex = : : ChainActive ( ) . Tip ( ) ;
2020-12-15 03:15:09 +01:00
} else {
LOCK ( cs_main ) ;
2022-05-12 22:29:17 +02:00
uint256 blockHash = ParseHashV ( request . params [ 0 ] , " blockhash " ) ;
2020-12-15 23:41:21 +01:00
pindex = LookupBlockIndex ( blockHash ) ;
if ( pindex = = nullptr ) {
2020-12-15 03:15:09 +01:00
throw JSONRPCError ( RPC_INVALID_ADDRESS_OR_KEY , " Block not found " ) ;
}
}
2022-05-12 22:29:17 +02:00
int64_t nCount = request . params . size ( ) > 1 ? ParseInt64V ( request . params [ 1 ] , " count " ) : 1 ;
2020-12-15 03:15:09 +01:00
// A temporary vector which is used to sort results properly (there is no "reverse" in/for UniValue)
std : : vector < UniValue > vecPayments ;
2022-02-11 17:15:26 +01:00
while ( vecPayments . size ( ) < uint64_t ( std : : abs ( nCount ) ) & & pindex ! = nullptr ) {
2020-12-15 03:15:09 +01:00
CBlock block ;
if ( ! ReadBlockFromDisk ( block , pindex , Params ( ) . GetConsensus ( ) ) ) {
throw JSONRPCError ( RPC_INTERNAL_ERROR , " Can't read block from disk " ) ;
}
// Note: we have to actually calculate block reward from scratch instead of simply querying coinbase vout
// because miners might collect less coins than they potentially could and this would break our calculations.
CAmount nBlockFees { 0 } ;
2022-05-21 17:00:44 +02:00
NodeContext & node = EnsureNodeContext ( request . context ) ;
2020-12-15 03:15:09 +01:00
for ( const auto & tx : block . vtx ) {
if ( tx - > IsCoinBase ( ) ) {
continue ;
}
CAmount nValueIn { 0 } ;
2022-02-11 17:15:26 +01:00
for ( const auto & txin : tx - > vin ) {
2020-12-15 03:15:09 +01:00
uint256 blockHashTmp ;
2022-05-21 17:00:44 +02:00
CTransactionRef txPrev = GetTransaction ( /* block_index */ nullptr , node . mempool , txin . prevout . hash , Params ( ) . GetConsensus ( ) , blockHashTmp ) ;
2020-12-15 03:15:09 +01:00
nValueIn + = txPrev - > vout [ txin . prevout . n ] . nValue ;
}
nBlockFees + = nValueIn - tx - > GetValueOut ( ) ;
}
std : : vector < CTxOut > voutMasternodePayments , voutDummy ;
CMutableTransaction dummyTx ;
CAmount blockReward = nBlockFees + GetBlockSubsidy ( pindex - > pprev - > nBits , pindex - > pprev - > nHeight , Params ( ) . GetConsensus ( ) ) ;
FillBlockPayments ( dummyTx , pindex - > nHeight , blockReward , voutMasternodePayments , voutDummy ) ;
UniValue blockObj ( UniValue : : VOBJ ) ;
CAmount payedPerBlock { 0 } ;
UniValue masternodeArr ( UniValue : : VARR ) ;
UniValue protxObj ( UniValue : : VOBJ ) ;
UniValue payeesArr ( UniValue : : VARR ) ;
CAmount payedPerMasternode { 0 } ;
for ( const auto & txout : voutMasternodePayments ) {
UniValue obj ( UniValue : : VOBJ ) ;
CTxDestination dest ;
ExtractDestination ( txout . scriptPubKey , dest ) ;
obj . pushKV ( " address " , EncodeDestination ( dest ) ) ;
obj . pushKV ( " script " , HexStr ( txout . scriptPubKey ) ) ;
obj . pushKV ( " amount " , txout . nValue ) ;
payedPerMasternode + = txout . nValue ;
payeesArr . push_back ( obj ) ;
}
const auto dmnPayee = deterministicMNManager - > GetListForBlock ( pindex ) . GetMNPayee ( ) ;
protxObj . pushKV ( " proTxHash " , dmnPayee = = nullptr ? " " : dmnPayee - > proTxHash . ToString ( ) ) ;
protxObj . pushKV ( " amount " , payedPerMasternode ) ;
protxObj . pushKV ( " payees " , payeesArr ) ;
payedPerBlock + = payedPerMasternode ;
masternodeArr . push_back ( protxObj ) ;
blockObj . pushKV ( " height " , pindex - > nHeight ) ;
blockObj . pushKV ( " blockhash " , pindex - > GetBlockHash ( ) . ToString ( ) ) ;
blockObj . pushKV ( " amount " , payedPerBlock ) ;
blockObj . pushKV ( " masternodes " , masternodeArr ) ;
vecPayments . push_back ( blockObj ) ;
if ( nCount > 0 ) {
LOCK ( cs_main ) ;
2021-10-16 12:54:22 +02:00
pindex = : : ChainActive ( ) . Next ( pindex ) ;
2020-12-15 03:15:09 +01:00
} else {
pindex = pindex - > pprev ;
}
}
if ( nCount < 0 ) {
std : : reverse ( vecPayments . begin ( ) , vecPayments . end ( ) ) ;
}
UniValue paymentsArr ( UniValue : : VARR ) ;
for ( const auto & payment : vecPayments ) {
paymentsArr . push_back ( payment ) ;
}
return paymentsArr ;
}
2018-08-29 13:36:35 +02:00
2018-05-04 22:42:39 +02:00
[[ noreturn ]] static void masternode_help ( )
2018-08-29 13:36:35 +02:00
{
2022-02-27 08:44:07 +01:00
RPCHelpMan { " masternode " ,
" Set of commands to execute masternode related actions \n "
" \n Available commands: \n "
" count - Get information about number of masternodes \n "
" current - DEPRECATED Print info on current masternode winner to be paid the next block (calculated locally) \n "
2018-08-29 13:36:35 +02:00
# ifdef ENABLE_WALLET
2022-02-27 08:44:07 +01:00
" outputs - Print masternode compatible outputs \n "
2018-08-29 13:36:35 +02:00
# endif // ENABLE_WALLET
2022-02-27 08:44:07 +01:00
" status - Print masternode status information \n "
" list - Print list of all known masternodes (see masternodelist for more info) \n "
" payments - Return information about masternode payments in a mined block \n "
" winner - DEPRECATED Print info on next masternode winner to vote for \n "
" winners - Print list of masternode winners \n " ,
{
{ " command " , RPCArg : : Type : : STR , RPCArg : : Optional : : NO , " The command to execute " } ,
} ,
RPCResults { } ,
RPCExamples { " " } ,
} . Throw ( ) ;
2018-08-29 13:36:35 +02:00
}
2018-05-04 22:42:39 +02:00
static UniValue masternode ( const JSONRPCRequest & request )
2018-08-29 13:36:35 +02:00
{
2022-05-12 22:29:17 +02:00
const JSONRPCRequest new_request { request . strMethod = = " masternode " ? request . squashed ( ) : request } ;
const std : : string command { new_request . strMethod } ;
if ( command = = " masternodeconnect " ) {
return masternode_connect ( new_request ) ;
} else if ( command = = " masternodecount " ) {
return masternode_count ( new_request ) ;
} else if ( command = = " masternodecurrent " ) {
return masternode_current ( new_request ) ;
} else if ( command = = " masternodewinner " ) {
return masternode_winner ( new_request ) ;
2018-08-29 13:36:35 +02:00
# ifdef ENABLE_WALLET
2022-05-12 22:29:17 +02:00
} else if ( command = = " masternodeoutputs " ) {
return masternode_outputs ( new_request ) ;
2018-08-29 13:36:35 +02:00
# endif // ENABLE_WALLET
2022-05-12 22:29:17 +02:00
} else if ( command = = " masternodestatus " ) {
return masternode_status ( new_request ) ;
} else if ( command = = " masternodepayments " ) {
return masternode_payments ( new_request ) ;
} else if ( command = = " masternodewinners " ) {
return masternode_winners ( new_request ) ;
} else if ( command = = " masternodelist " ) {
return masternodelist ( new_request ) ;
2018-09-10 12:23:42 +02:00
} else {
masternode_help ( ) ;
2018-08-29 13:36:35 +02:00
}
2014-12-09 02:17:57 +01:00
}
2018-05-04 22:42:39 +02:00
static UniValue masternodelist ( const JSONRPCRequest & request )
2015-02-23 21:26:23 +01:00
{
2018-03-08 13:22:13 +01:00
std : : string strMode = " json " ;
2015-02-23 21:26:23 +01:00
std : : string strFilter = " " ;
2017-08-22 09:24:31 +02:00
if ( ! request . params [ 0 ] . isNull ( ) ) strMode = request . params [ 0 ] . get_str ( ) ;
if ( ! request . params [ 1 ] . isNull ( ) ) strFilter = request . params [ 1 ] . get_str ( ) ;
2015-02-23 21:26:23 +01:00
2019-08-07 06:42:54 +02:00
strMode = ToLower ( strMode ) ;
2018-12-31 14:05:23 +01:00
2016-10-19 15:01:33 +02:00
if ( request . fHelp | | (
2018-12-17 13:20:16 +01:00
strMode ! = " addr " & & strMode ! = " full " & & strMode ! = " info " & & strMode ! = " json " & &
2019-01-11 11:05:58 +01:00
strMode ! = " owneraddress " & & strMode ! = " votingaddress " & &
2018-12-17 13:20:16 +01:00
strMode ! = " lastpaidtime " & & strMode ! = " lastpaidblock " & &
2018-12-31 14:05:23 +01:00
strMode ! = " payee " & & strMode ! = " pubkeyoperator " & &
2018-12-17 16:02:12 +01:00
strMode ! = " status " ) )
2015-02-23 21:26:23 +01:00
{
2022-02-27 08:44:07 +01:00
masternode_list_help ( request ) ;
2015-02-23 21:26:23 +01:00
}
2016-02-02 16:28:56 +01:00
UniValue obj ( UniValue : : VOBJ ) ;
2018-12-17 16:36:58 +01:00
auto mnList = deterministicMNManager - > GetListAtChainTip ( ) ;
refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed. (#4653)
* refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed.
Introduces ForEachMNShared, a version of ForEachMN that uses a shared_ptr, and may extend the lifetime of the underlying shared_ptr. This is not preferred, should prefer ForEachMN. See docs.
Adjusts ForEachMN to pass a reference. This is preferred for use over ForEachMNShared. See docs. A reference should be used since in usage we assume it's non-null anyway. Additionally, it allows us to know that the lifespan of the dmn is not being being extended (if lifespan needs to be extended, should use ForEachMNShared.
IsMNValid, IsMNPoSeBanned, UpdateMN, UpdateMN, AddUniqueProperty, DeleteUniqueProperty, UpdateUniqueProperty now take a const reference to CDeterministicMN instead of a const reference to shared_ptr<CDeterministicMN>. All of these functions previously assumed (or would've crashed) a non-null ptr, and non extended lifetime, as such converting to ref is appropriate.
CompareByLastPaid ptr overload now takes raw ptr instead of a const ref to shared. Since we simply dereference them, a raw ptr makes the most sense. This also avoids a potential expensive and implicit raw ptr -> shared ptr conversion if the function was called with raw ptrs.
rpcevo BuildDMNListEntry now takes a const ref for reasons as stated above
Signed-off-by: Pasta <pasta@dashboost.org>
* make stuff const
Signed-off-by: Pasta <pasta@dashboost.org>
* refactor/llmq: use ranges count_if
Signed-off-by: Pasta <pasta@dashboost.org>
2022-01-04 17:13:38 +01:00
auto dmnToStatus = [ & ] ( auto & dmn ) {
2018-12-17 16:36:58 +01:00
if ( mnList . IsMNValid ( dmn ) ) {
return " ENABLED " ;
}
if ( mnList . IsMNPoSeBanned ( dmn ) ) {
return " POSE_BANNED " ;
2018-12-17 16:02:12 +01:00
}
2018-12-17 16:36:58 +01:00
return " UNKNOWN " ;
} ;
refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed. (#4653)
* refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed.
Introduces ForEachMNShared, a version of ForEachMN that uses a shared_ptr, and may extend the lifetime of the underlying shared_ptr. This is not preferred, should prefer ForEachMN. See docs.
Adjusts ForEachMN to pass a reference. This is preferred for use over ForEachMNShared. See docs. A reference should be used since in usage we assume it's non-null anyway. Additionally, it allows us to know that the lifespan of the dmn is not being being extended (if lifespan needs to be extended, should use ForEachMNShared.
IsMNValid, IsMNPoSeBanned, UpdateMN, UpdateMN, AddUniqueProperty, DeleteUniqueProperty, UpdateUniqueProperty now take a const reference to CDeterministicMN instead of a const reference to shared_ptr<CDeterministicMN>. All of these functions previously assumed (or would've crashed) a non-null ptr, and non extended lifetime, as such converting to ref is appropriate.
CompareByLastPaid ptr overload now takes raw ptr instead of a const ref to shared. Since we simply dereference them, a raw ptr makes the most sense. This also avoids a potential expensive and implicit raw ptr -> shared ptr conversion if the function was called with raw ptrs.
rpcevo BuildDMNListEntry now takes a const ref for reasons as stated above
Signed-off-by: Pasta <pasta@dashboost.org>
* make stuff const
Signed-off-by: Pasta <pasta@dashboost.org>
* refactor/llmq: use ranges count_if
Signed-off-by: Pasta <pasta@dashboost.org>
2022-01-04 17:13:38 +01:00
auto dmnToLastPaidTime = [ & ] ( auto & dmn ) {
if ( dmn . pdmnState - > nLastPaidHeight = = 0 ) {
2018-12-17 16:36:58 +01:00
return ( int ) 0 ;
}
LOCK ( cs_main ) ;
refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed. (#4653)
* refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed.
Introduces ForEachMNShared, a version of ForEachMN that uses a shared_ptr, and may extend the lifetime of the underlying shared_ptr. This is not preferred, should prefer ForEachMN. See docs.
Adjusts ForEachMN to pass a reference. This is preferred for use over ForEachMNShared. See docs. A reference should be used since in usage we assume it's non-null anyway. Additionally, it allows us to know that the lifespan of the dmn is not being being extended (if lifespan needs to be extended, should use ForEachMNShared.
IsMNValid, IsMNPoSeBanned, UpdateMN, UpdateMN, AddUniqueProperty, DeleteUniqueProperty, UpdateUniqueProperty now take a const reference to CDeterministicMN instead of a const reference to shared_ptr<CDeterministicMN>. All of these functions previously assumed (or would've crashed) a non-null ptr, and non extended lifetime, as such converting to ref is appropriate.
CompareByLastPaid ptr overload now takes raw ptr instead of a const ref to shared. Since we simply dereference them, a raw ptr makes the most sense. This also avoids a potential expensive and implicit raw ptr -> shared ptr conversion if the function was called with raw ptrs.
rpcevo BuildDMNListEntry now takes a const ref for reasons as stated above
Signed-off-by: Pasta <pasta@dashboost.org>
* make stuff const
Signed-off-by: Pasta <pasta@dashboost.org>
* refactor/llmq: use ranges count_if
Signed-off-by: Pasta <pasta@dashboost.org>
2022-01-04 17:13:38 +01:00
const CBlockIndex * pindex = : : ChainActive ( ) [ dmn . pdmnState - > nLastPaidHeight ] ;
2018-12-17 16:36:58 +01:00
return ( int ) pindex - > nTime ;
} ;
2018-11-14 15:39:40 +01:00
refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed. (#4653)
* refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed.
Introduces ForEachMNShared, a version of ForEachMN that uses a shared_ptr, and may extend the lifetime of the underlying shared_ptr. This is not preferred, should prefer ForEachMN. See docs.
Adjusts ForEachMN to pass a reference. This is preferred for use over ForEachMNShared. See docs. A reference should be used since in usage we assume it's non-null anyway. Additionally, it allows us to know that the lifespan of the dmn is not being being extended (if lifespan needs to be extended, should use ForEachMNShared.
IsMNValid, IsMNPoSeBanned, UpdateMN, UpdateMN, AddUniqueProperty, DeleteUniqueProperty, UpdateUniqueProperty now take a const reference to CDeterministicMN instead of a const reference to shared_ptr<CDeterministicMN>. All of these functions previously assumed (or would've crashed) a non-null ptr, and non extended lifetime, as such converting to ref is appropriate.
CompareByLastPaid ptr overload now takes raw ptr instead of a const ref to shared. Since we simply dereference them, a raw ptr makes the most sense. This also avoids a potential expensive and implicit raw ptr -> shared ptr conversion if the function was called with raw ptrs.
rpcevo BuildDMNListEntry now takes a const ref for reasons as stated above
Signed-off-by: Pasta <pasta@dashboost.org>
* make stuff const
Signed-off-by: Pasta <pasta@dashboost.org>
* refactor/llmq: use ranges count_if
Signed-off-by: Pasta <pasta@dashboost.org>
2022-01-04 17:13:38 +01:00
mnList . ForEachMN ( false , [ & ] ( auto & dmn ) {
std : : string strOutpoint = dmn . collateralOutpoint . ToStringShort ( ) ;
2019-03-06 08:01:03 +01:00
Coin coin ;
std : : string collateralAddressStr = " UNKNOWN " ;
refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed. (#4653)
* refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed.
Introduces ForEachMNShared, a version of ForEachMN that uses a shared_ptr, and may extend the lifetime of the underlying shared_ptr. This is not preferred, should prefer ForEachMN. See docs.
Adjusts ForEachMN to pass a reference. This is preferred for use over ForEachMNShared. See docs. A reference should be used since in usage we assume it's non-null anyway. Additionally, it allows us to know that the lifespan of the dmn is not being being extended (if lifespan needs to be extended, should use ForEachMNShared.
IsMNValid, IsMNPoSeBanned, UpdateMN, UpdateMN, AddUniqueProperty, DeleteUniqueProperty, UpdateUniqueProperty now take a const reference to CDeterministicMN instead of a const reference to shared_ptr<CDeterministicMN>. All of these functions previously assumed (or would've crashed) a non-null ptr, and non extended lifetime, as such converting to ref is appropriate.
CompareByLastPaid ptr overload now takes raw ptr instead of a const ref to shared. Since we simply dereference them, a raw ptr makes the most sense. This also avoids a potential expensive and implicit raw ptr -> shared ptr conversion if the function was called with raw ptrs.
rpcevo BuildDMNListEntry now takes a const ref for reasons as stated above
Signed-off-by: Pasta <pasta@dashboost.org>
* make stuff const
Signed-off-by: Pasta <pasta@dashboost.org>
* refactor/llmq: use ranges count_if
Signed-off-by: Pasta <pasta@dashboost.org>
2022-01-04 17:13:38 +01:00
if ( GetUTXOCoin ( dmn . collateralOutpoint , coin ) ) {
2019-03-06 08:01:03 +01:00
CTxDestination collateralDest ;
if ( ExtractDestination ( coin . out . scriptPubKey , collateralDest ) ) {
Merge #11117: Prepare for non-Base58 addresses (#3294)
* Merge #11117: Prepare for non-Base58 addresses
864cd2787 Move CBitcoinAddress to base58.cpp (Pieter Wuille)
5c8ff0d44 Introduce wrappers around CBitcoinAddress (Pieter Wuille)
Pull request description:
This patch removes the need for the intermediary Base58 type `CBitcoinAddress`, by providing {`Encode`,`Decode`,`IsValid`}`Destination` functions that directly operate on the conversion between `std::string`s and `CTxDestination`.
As a side, it also fixes a number of indentation issues, and removes probably several unnecessary implicit `CTxDestination`<->`CBitcoinAddress` conversions.
This change is far from complete. In follow-ups I'd like to:
* Split off the specific address and key encoding logic from base58.h, and move it to a address.h or so.
* Replace `CTxDestination` with a non-`boost::variant` version (which can be more efficient as `boost::variant` allocates everything on the heap, and remove the need for `boost::get<...>` and `IsValidDestination` calls everywhere).
* Do the same for `CBitcoinSecret`, `CBitcoinExtKey`, and `CBitcoinExtPubKey`.
However, I've tried to keep this patch to be minimally invasive, but still enough to support non-Base58 addresses. Perhaps a smaller patch is possible to hack Bech32 support into `CBitcoinAddress`, but I would consider that a move in the wrong direction.
Tree-SHA512: c2c77ffb57caeadf2429b1c2562ce60e8c7be8aa9f8e51b591f354b6b441162625b2efe14c023a1ae485cf2ed417263afa35c892891dfaa7844e7fbabccab85e
* CBitcoinAddress -> EncodeDestination in providertx.h
Signed-off-by: Pasta <pasta@dashboost.org>
* more CBitcoinAddress -> EncodeDestination in providertx.h
Signed-off-by: Pasta <pasta@dashboost.org>
* more CBitcoinAddress -> EncodeDestination in providertx.h
Signed-off-by: Pasta <pasta@dashboost.org>
* more CBitcoinAddress -> EncodeDestination in providertx.h
Signed-off-by: Pasta <pasta@dashboost.org>
* fix CBitcoinAddress GetKeyID check
Signed-off-by: Pasta <pasta@dashboost.org>
* fix providertx.cpp
Signed-off-by: Pasta <pasta@dashboost.org>
* hopefully fix governance-classes.cpp
Signed-off-by: Pasta <pasta@dashboost.org>
* partially fix governance-validators.cpp, unable to resolve "address.IsScript()"
Signed-off-by: Pasta <pasta@dashboost.org>
* partially fix governance-classes.cpp, unable to resolve "address.IsScript()"
Signed-off-by: Pasta <pasta@dashboost.org>
* fix governance-classes.h
Signed-off-by: Pasta <pasta@dashboost.org>
* DecodeTransaction -> DecodeDestination, fix governance-validators.cpp
Signed-off-by: Pasta <pasta@dashboost.org>
* More fixes for 3294
* Move GetIndexKey into rpc/misc.cpp near getAddressesFromParams
No need to have it in base58.cpp anymore as this is only used in getAddressesFromParams
Co-authored-by: Wladimir J. van der Laan <laanwj@gmail.com>
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
Co-authored-by: Alexander Block <ablock84@gmail.com>
2020-01-22 11:35:04 +01:00
collateralAddressStr = EncodeDestination ( collateralDest ) ;
2019-03-06 08:01:03 +01:00
}
}
2018-12-17 16:36:58 +01:00
refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed. (#4653)
* refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed.
Introduces ForEachMNShared, a version of ForEachMN that uses a shared_ptr, and may extend the lifetime of the underlying shared_ptr. This is not preferred, should prefer ForEachMN. See docs.
Adjusts ForEachMN to pass a reference. This is preferred for use over ForEachMNShared. See docs. A reference should be used since in usage we assume it's non-null anyway. Additionally, it allows us to know that the lifespan of the dmn is not being being extended (if lifespan needs to be extended, should use ForEachMNShared.
IsMNValid, IsMNPoSeBanned, UpdateMN, UpdateMN, AddUniqueProperty, DeleteUniqueProperty, UpdateUniqueProperty now take a const reference to CDeterministicMN instead of a const reference to shared_ptr<CDeterministicMN>. All of these functions previously assumed (or would've crashed) a non-null ptr, and non extended lifetime, as such converting to ref is appropriate.
CompareByLastPaid ptr overload now takes raw ptr instead of a const ref to shared. Since we simply dereference them, a raw ptr makes the most sense. This also avoids a potential expensive and implicit raw ptr -> shared ptr conversion if the function was called with raw ptrs.
rpcevo BuildDMNListEntry now takes a const ref for reasons as stated above
Signed-off-by: Pasta <pasta@dashboost.org>
* make stuff const
Signed-off-by: Pasta <pasta@dashboost.org>
* refactor/llmq: use ranges count_if
Signed-off-by: Pasta <pasta@dashboost.org>
2022-01-04 17:13:38 +01:00
CScript payeeScript = dmn . pdmnState - > scriptPayout ;
2018-12-17 16:02:12 +01:00
CTxDestination payeeDest ;
2019-03-06 08:01:03 +01:00
std : : string payeeStr = " UNKNOWN " ;
2018-12-17 16:02:12 +01:00
if ( ExtractDestination ( payeeScript , payeeDest ) ) {
Merge #11117: Prepare for non-Base58 addresses (#3294)
* Merge #11117: Prepare for non-Base58 addresses
864cd2787 Move CBitcoinAddress to base58.cpp (Pieter Wuille)
5c8ff0d44 Introduce wrappers around CBitcoinAddress (Pieter Wuille)
Pull request description:
This patch removes the need for the intermediary Base58 type `CBitcoinAddress`, by providing {`Encode`,`Decode`,`IsValid`}`Destination` functions that directly operate on the conversion between `std::string`s and `CTxDestination`.
As a side, it also fixes a number of indentation issues, and removes probably several unnecessary implicit `CTxDestination`<->`CBitcoinAddress` conversions.
This change is far from complete. In follow-ups I'd like to:
* Split off the specific address and key encoding logic from base58.h, and move it to a address.h or so.
* Replace `CTxDestination` with a non-`boost::variant` version (which can be more efficient as `boost::variant` allocates everything on the heap, and remove the need for `boost::get<...>` and `IsValidDestination` calls everywhere).
* Do the same for `CBitcoinSecret`, `CBitcoinExtKey`, and `CBitcoinExtPubKey`.
However, I've tried to keep this patch to be minimally invasive, but still enough to support non-Base58 addresses. Perhaps a smaller patch is possible to hack Bech32 support into `CBitcoinAddress`, but I would consider that a move in the wrong direction.
Tree-SHA512: c2c77ffb57caeadf2429b1c2562ce60e8c7be8aa9f8e51b591f354b6b441162625b2efe14c023a1ae485cf2ed417263afa35c892891dfaa7844e7fbabccab85e
* CBitcoinAddress -> EncodeDestination in providertx.h
Signed-off-by: Pasta <pasta@dashboost.org>
* more CBitcoinAddress -> EncodeDestination in providertx.h
Signed-off-by: Pasta <pasta@dashboost.org>
* more CBitcoinAddress -> EncodeDestination in providertx.h
Signed-off-by: Pasta <pasta@dashboost.org>
* more CBitcoinAddress -> EncodeDestination in providertx.h
Signed-off-by: Pasta <pasta@dashboost.org>
* fix CBitcoinAddress GetKeyID check
Signed-off-by: Pasta <pasta@dashboost.org>
* fix providertx.cpp
Signed-off-by: Pasta <pasta@dashboost.org>
* hopefully fix governance-classes.cpp
Signed-off-by: Pasta <pasta@dashboost.org>
* partially fix governance-validators.cpp, unable to resolve "address.IsScript()"
Signed-off-by: Pasta <pasta@dashboost.org>
* partially fix governance-classes.cpp, unable to resolve "address.IsScript()"
Signed-off-by: Pasta <pasta@dashboost.org>
* fix governance-classes.h
Signed-off-by: Pasta <pasta@dashboost.org>
* DecodeTransaction -> DecodeDestination, fix governance-validators.cpp
Signed-off-by: Pasta <pasta@dashboost.org>
* More fixes for 3294
* Move GetIndexKey into rpc/misc.cpp near getAddressesFromParams
No need to have it in base58.cpp anymore as this is only used in getAddressesFromParams
Co-authored-by: Wladimir J. van der Laan <laanwj@gmail.com>
Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
Co-authored-by: Alexander Block <ablock84@gmail.com>
2020-01-22 11:35:04 +01:00
payeeStr = EncodeDestination ( payeeDest ) ;
2018-12-17 16:02:12 +01:00
}
2018-11-14 15:39:40 +01:00
2018-12-17 16:02:12 +01:00
if ( strMode = = " addr " ) {
refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed. (#4653)
* refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed.
Introduces ForEachMNShared, a version of ForEachMN that uses a shared_ptr, and may extend the lifetime of the underlying shared_ptr. This is not preferred, should prefer ForEachMN. See docs.
Adjusts ForEachMN to pass a reference. This is preferred for use over ForEachMNShared. See docs. A reference should be used since in usage we assume it's non-null anyway. Additionally, it allows us to know that the lifespan of the dmn is not being being extended (if lifespan needs to be extended, should use ForEachMNShared.
IsMNValid, IsMNPoSeBanned, UpdateMN, UpdateMN, AddUniqueProperty, DeleteUniqueProperty, UpdateUniqueProperty now take a const reference to CDeterministicMN instead of a const reference to shared_ptr<CDeterministicMN>. All of these functions previously assumed (or would've crashed) a non-null ptr, and non extended lifetime, as such converting to ref is appropriate.
CompareByLastPaid ptr overload now takes raw ptr instead of a const ref to shared. Since we simply dereference them, a raw ptr makes the most sense. This also avoids a potential expensive and implicit raw ptr -> shared ptr conversion if the function was called with raw ptrs.
rpcevo BuildDMNListEntry now takes a const ref for reasons as stated above
Signed-off-by: Pasta <pasta@dashboost.org>
* make stuff const
Signed-off-by: Pasta <pasta@dashboost.org>
* refactor/llmq: use ranges count_if
Signed-off-by: Pasta <pasta@dashboost.org>
2022-01-04 17:13:38 +01:00
std : : string strAddress = dmn . pdmnState - > addr . ToString ( false ) ;
2018-12-17 16:02:12 +01:00
if ( strFilter ! = " " & & strAddress . find ( strFilter ) = = std : : string : : npos & &
2018-12-17 16:36:58 +01:00
strOutpoint . find ( strFilter ) = = std : : string : : npos ) return ;
2020-06-18 11:17:23 +02:00
obj . pushKV ( strOutpoint , strAddress ) ;
2018-12-17 16:02:12 +01:00
} else if ( strMode = = " full " ) {
std : : ostringstream streamFull ;
streamFull < < std : : setw ( 18 ) < <
2018-12-17 16:36:58 +01:00
dmnToStatus ( dmn ) < < " " < <
2022-04-06 23:50:21 +02:00
dmn . pdmnState - > nPoSePenalty < < " " < <
2018-12-31 14:05:23 +01:00
payeeStr < < " " < < std : : setw ( 10 ) < <
2018-12-17 16:36:58 +01:00
dmnToLastPaidTime ( dmn ) < < " " < < std : : setw ( 6 ) < <
refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed. (#4653)
* refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed.
Introduces ForEachMNShared, a version of ForEachMN that uses a shared_ptr, and may extend the lifetime of the underlying shared_ptr. This is not preferred, should prefer ForEachMN. See docs.
Adjusts ForEachMN to pass a reference. This is preferred for use over ForEachMNShared. See docs. A reference should be used since in usage we assume it's non-null anyway. Additionally, it allows us to know that the lifespan of the dmn is not being being extended (if lifespan needs to be extended, should use ForEachMNShared.
IsMNValid, IsMNPoSeBanned, UpdateMN, UpdateMN, AddUniqueProperty, DeleteUniqueProperty, UpdateUniqueProperty now take a const reference to CDeterministicMN instead of a const reference to shared_ptr<CDeterministicMN>. All of these functions previously assumed (or would've crashed) a non-null ptr, and non extended lifetime, as such converting to ref is appropriate.
CompareByLastPaid ptr overload now takes raw ptr instead of a const ref to shared. Since we simply dereference them, a raw ptr makes the most sense. This also avoids a potential expensive and implicit raw ptr -> shared ptr conversion if the function was called with raw ptrs.
rpcevo BuildDMNListEntry now takes a const ref for reasons as stated above
Signed-off-by: Pasta <pasta@dashboost.org>
* make stuff const
Signed-off-by: Pasta <pasta@dashboost.org>
* refactor/llmq: use ranges count_if
Signed-off-by: Pasta <pasta@dashboost.org>
2022-01-04 17:13:38 +01:00
dmn . pdmnState - > nLastPaidHeight < < " " < <
dmn . pdmnState - > addr . ToString ( ) ;
2018-12-17 16:02:12 +01:00
std : : string strFull = streamFull . str ( ) ;
if ( strFilter ! = " " & & strFull . find ( strFilter ) = = std : : string : : npos & &
2018-12-17 16:36:58 +01:00
strOutpoint . find ( strFilter ) = = std : : string : : npos ) return ;
2020-06-18 11:17:23 +02:00
obj . pushKV ( strOutpoint , strFull ) ;
2018-12-17 16:02:12 +01:00
} else if ( strMode = = " info " ) {
std : : ostringstream streamInfo ;
streamInfo < < std : : setw ( 18 ) < <
2018-12-17 16:36:58 +01:00
dmnToStatus ( dmn ) < < " " < <
2022-04-06 23:50:21 +02:00
dmn . pdmnState - > nPoSePenalty < < " " < <
2018-12-17 16:02:12 +01:00
payeeStr < < " " < <
refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed. (#4653)
* refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed.
Introduces ForEachMNShared, a version of ForEachMN that uses a shared_ptr, and may extend the lifetime of the underlying shared_ptr. This is not preferred, should prefer ForEachMN. See docs.
Adjusts ForEachMN to pass a reference. This is preferred for use over ForEachMNShared. See docs. A reference should be used since in usage we assume it's non-null anyway. Additionally, it allows us to know that the lifespan of the dmn is not being being extended (if lifespan needs to be extended, should use ForEachMNShared.
IsMNValid, IsMNPoSeBanned, UpdateMN, UpdateMN, AddUniqueProperty, DeleteUniqueProperty, UpdateUniqueProperty now take a const reference to CDeterministicMN instead of a const reference to shared_ptr<CDeterministicMN>. All of these functions previously assumed (or would've crashed) a non-null ptr, and non extended lifetime, as such converting to ref is appropriate.
CompareByLastPaid ptr overload now takes raw ptr instead of a const ref to shared. Since we simply dereference them, a raw ptr makes the most sense. This also avoids a potential expensive and implicit raw ptr -> shared ptr conversion if the function was called with raw ptrs.
rpcevo BuildDMNListEntry now takes a const ref for reasons as stated above
Signed-off-by: Pasta <pasta@dashboost.org>
* make stuff const
Signed-off-by: Pasta <pasta@dashboost.org>
* refactor/llmq: use ranges count_if
Signed-off-by: Pasta <pasta@dashboost.org>
2022-01-04 17:13:38 +01:00
dmn . pdmnState - > addr . ToString ( ) ;
2018-12-17 16:02:12 +01:00
std : : string strInfo = streamInfo . str ( ) ;
if ( strFilter ! = " " & & strInfo . find ( strFilter ) = = std : : string : : npos & &
2018-12-17 16:36:58 +01:00
strOutpoint . find ( strFilter ) = = std : : string : : npos ) return ;
2020-06-18 11:17:23 +02:00
obj . pushKV ( strOutpoint , strInfo ) ;
2018-12-17 16:02:12 +01:00
} else if ( strMode = = " json " ) {
std : : ostringstream streamInfo ;
refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed. (#4653)
* refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed.
Introduces ForEachMNShared, a version of ForEachMN that uses a shared_ptr, and may extend the lifetime of the underlying shared_ptr. This is not preferred, should prefer ForEachMN. See docs.
Adjusts ForEachMN to pass a reference. This is preferred for use over ForEachMNShared. See docs. A reference should be used since in usage we assume it's non-null anyway. Additionally, it allows us to know that the lifespan of the dmn is not being being extended (if lifespan needs to be extended, should use ForEachMNShared.
IsMNValid, IsMNPoSeBanned, UpdateMN, UpdateMN, AddUniqueProperty, DeleteUniqueProperty, UpdateUniqueProperty now take a const reference to CDeterministicMN instead of a const reference to shared_ptr<CDeterministicMN>. All of these functions previously assumed (or would've crashed) a non-null ptr, and non extended lifetime, as such converting to ref is appropriate.
CompareByLastPaid ptr overload now takes raw ptr instead of a const ref to shared. Since we simply dereference them, a raw ptr makes the most sense. This also avoids a potential expensive and implicit raw ptr -> shared ptr conversion if the function was called with raw ptrs.
rpcevo BuildDMNListEntry now takes a const ref for reasons as stated above
Signed-off-by: Pasta <pasta@dashboost.org>
* make stuff const
Signed-off-by: Pasta <pasta@dashboost.org>
* refactor/llmq: use ranges count_if
Signed-off-by: Pasta <pasta@dashboost.org>
2022-01-04 17:13:38 +01:00
streamInfo < < dmn . proTxHash . ToString ( ) < < " " < <
dmn . pdmnState - > addr . ToString ( ) < < " " < <
2019-01-08 11:36:35 +01:00
payeeStr < < " " < <
2018-12-17 16:36:58 +01:00
dmnToStatus ( dmn ) < < " " < <
2022-04-06 23:50:21 +02:00
dmn . pdmnState - > nPoSePenalty < < " " < <
2018-12-17 16:36:58 +01:00
dmnToLastPaidTime ( dmn ) < < " " < <
refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed. (#4653)
* refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed.
Introduces ForEachMNShared, a version of ForEachMN that uses a shared_ptr, and may extend the lifetime of the underlying shared_ptr. This is not preferred, should prefer ForEachMN. See docs.
Adjusts ForEachMN to pass a reference. This is preferred for use over ForEachMNShared. See docs. A reference should be used since in usage we assume it's non-null anyway. Additionally, it allows us to know that the lifespan of the dmn is not being being extended (if lifespan needs to be extended, should use ForEachMNShared.
IsMNValid, IsMNPoSeBanned, UpdateMN, UpdateMN, AddUniqueProperty, DeleteUniqueProperty, UpdateUniqueProperty now take a const reference to CDeterministicMN instead of a const reference to shared_ptr<CDeterministicMN>. All of these functions previously assumed (or would've crashed) a non-null ptr, and non extended lifetime, as such converting to ref is appropriate.
CompareByLastPaid ptr overload now takes raw ptr instead of a const ref to shared. Since we simply dereference them, a raw ptr makes the most sense. This also avoids a potential expensive and implicit raw ptr -> shared ptr conversion if the function was called with raw ptrs.
rpcevo BuildDMNListEntry now takes a const ref for reasons as stated above
Signed-off-by: Pasta <pasta@dashboost.org>
* make stuff const
Signed-off-by: Pasta <pasta@dashboost.org>
* refactor/llmq: use ranges count_if
Signed-off-by: Pasta <pasta@dashboost.org>
2022-01-04 17:13:38 +01:00
dmn . pdmnState - > nLastPaidHeight < < " " < <
EncodeDestination ( dmn . pdmnState - > keyIDOwner ) < < " " < <
EncodeDestination ( dmn . pdmnState - > keyIDVoting ) < < " " < <
2019-03-06 08:01:03 +01:00
collateralAddressStr < < " " < <
refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed. (#4653)
* refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed.
Introduces ForEachMNShared, a version of ForEachMN that uses a shared_ptr, and may extend the lifetime of the underlying shared_ptr. This is not preferred, should prefer ForEachMN. See docs.
Adjusts ForEachMN to pass a reference. This is preferred for use over ForEachMNShared. See docs. A reference should be used since in usage we assume it's non-null anyway. Additionally, it allows us to know that the lifespan of the dmn is not being being extended (if lifespan needs to be extended, should use ForEachMNShared.
IsMNValid, IsMNPoSeBanned, UpdateMN, UpdateMN, AddUniqueProperty, DeleteUniqueProperty, UpdateUniqueProperty now take a const reference to CDeterministicMN instead of a const reference to shared_ptr<CDeterministicMN>. All of these functions previously assumed (or would've crashed) a non-null ptr, and non extended lifetime, as such converting to ref is appropriate.
CompareByLastPaid ptr overload now takes raw ptr instead of a const ref to shared. Since we simply dereference them, a raw ptr makes the most sense. This also avoids a potential expensive and implicit raw ptr -> shared ptr conversion if the function was called with raw ptrs.
rpcevo BuildDMNListEntry now takes a const ref for reasons as stated above
Signed-off-by: Pasta <pasta@dashboost.org>
* make stuff const
Signed-off-by: Pasta <pasta@dashboost.org>
* refactor/llmq: use ranges count_if
Signed-off-by: Pasta <pasta@dashboost.org>
2022-01-04 17:13:38 +01:00
dmn . pdmnState - > pubKeyOperator . Get ( ) . ToString ( ) ;
2018-12-17 16:02:12 +01:00
std : : string strInfo = streamInfo . str ( ) ;
if ( strFilter ! = " " & & strInfo . find ( strFilter ) = = std : : string : : npos & &
2018-12-17 16:36:58 +01:00
strOutpoint . find ( strFilter ) = = std : : string : : npos ) return ;
2018-12-17 16:02:12 +01:00
UniValue objMN ( UniValue : : VOBJ ) ;
refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed. (#4653)
* refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed.
Introduces ForEachMNShared, a version of ForEachMN that uses a shared_ptr, and may extend the lifetime of the underlying shared_ptr. This is not preferred, should prefer ForEachMN. See docs.
Adjusts ForEachMN to pass a reference. This is preferred for use over ForEachMNShared. See docs. A reference should be used since in usage we assume it's non-null anyway. Additionally, it allows us to know that the lifespan of the dmn is not being being extended (if lifespan needs to be extended, should use ForEachMNShared.
IsMNValid, IsMNPoSeBanned, UpdateMN, UpdateMN, AddUniqueProperty, DeleteUniqueProperty, UpdateUniqueProperty now take a const reference to CDeterministicMN instead of a const reference to shared_ptr<CDeterministicMN>. All of these functions previously assumed (or would've crashed) a non-null ptr, and non extended lifetime, as such converting to ref is appropriate.
CompareByLastPaid ptr overload now takes raw ptr instead of a const ref to shared. Since we simply dereference them, a raw ptr makes the most sense. This also avoids a potential expensive and implicit raw ptr -> shared ptr conversion if the function was called with raw ptrs.
rpcevo BuildDMNListEntry now takes a const ref for reasons as stated above
Signed-off-by: Pasta <pasta@dashboost.org>
* make stuff const
Signed-off-by: Pasta <pasta@dashboost.org>
* refactor/llmq: use ranges count_if
Signed-off-by: Pasta <pasta@dashboost.org>
2022-01-04 17:13:38 +01:00
objMN . pushKV ( " proTxHash " , dmn . proTxHash . ToString ( ) ) ;
objMN . pushKV ( " address " , dmn . pdmnState - > addr . ToString ( ) ) ;
2020-06-18 11:17:23 +02:00
objMN . pushKV ( " payee " , payeeStr ) ;
objMN . pushKV ( " status " , dmnToStatus ( dmn ) ) ;
2022-04-06 23:50:21 +02:00
objMN . pushKV ( " pospenaltyscore " , dmn . pdmnState - > nPoSePenalty ) ;
2020-06-18 11:17:23 +02:00
objMN . pushKV ( " lastpaidtime " , dmnToLastPaidTime ( dmn ) ) ;
refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed. (#4653)
* refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed.
Introduces ForEachMNShared, a version of ForEachMN that uses a shared_ptr, and may extend the lifetime of the underlying shared_ptr. This is not preferred, should prefer ForEachMN. See docs.
Adjusts ForEachMN to pass a reference. This is preferred for use over ForEachMNShared. See docs. A reference should be used since in usage we assume it's non-null anyway. Additionally, it allows us to know that the lifespan of the dmn is not being being extended (if lifespan needs to be extended, should use ForEachMNShared.
IsMNValid, IsMNPoSeBanned, UpdateMN, UpdateMN, AddUniqueProperty, DeleteUniqueProperty, UpdateUniqueProperty now take a const reference to CDeterministicMN instead of a const reference to shared_ptr<CDeterministicMN>. All of these functions previously assumed (or would've crashed) a non-null ptr, and non extended lifetime, as such converting to ref is appropriate.
CompareByLastPaid ptr overload now takes raw ptr instead of a const ref to shared. Since we simply dereference them, a raw ptr makes the most sense. This also avoids a potential expensive and implicit raw ptr -> shared ptr conversion if the function was called with raw ptrs.
rpcevo BuildDMNListEntry now takes a const ref for reasons as stated above
Signed-off-by: Pasta <pasta@dashboost.org>
* make stuff const
Signed-off-by: Pasta <pasta@dashboost.org>
* refactor/llmq: use ranges count_if
Signed-off-by: Pasta <pasta@dashboost.org>
2022-01-04 17:13:38 +01:00
objMN . pushKV ( " lastpaidblock " , dmn . pdmnState - > nLastPaidHeight ) ;
objMN . pushKV ( " owneraddress " , EncodeDestination ( dmn . pdmnState - > keyIDOwner ) ) ;
objMN . pushKV ( " votingaddress " , EncodeDestination ( dmn . pdmnState - > keyIDVoting ) ) ;
2020-06-18 11:17:23 +02:00
objMN . pushKV ( " collateraladdress " , collateralAddressStr ) ;
refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed. (#4653)
* refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed.
Introduces ForEachMNShared, a version of ForEachMN that uses a shared_ptr, and may extend the lifetime of the underlying shared_ptr. This is not preferred, should prefer ForEachMN. See docs.
Adjusts ForEachMN to pass a reference. This is preferred for use over ForEachMNShared. See docs. A reference should be used since in usage we assume it's non-null anyway. Additionally, it allows us to know that the lifespan of the dmn is not being being extended (if lifespan needs to be extended, should use ForEachMNShared.
IsMNValid, IsMNPoSeBanned, UpdateMN, UpdateMN, AddUniqueProperty, DeleteUniqueProperty, UpdateUniqueProperty now take a const reference to CDeterministicMN instead of a const reference to shared_ptr<CDeterministicMN>. All of these functions previously assumed (or would've crashed) a non-null ptr, and non extended lifetime, as such converting to ref is appropriate.
CompareByLastPaid ptr overload now takes raw ptr instead of a const ref to shared. Since we simply dereference them, a raw ptr makes the most sense. This also avoids a potential expensive and implicit raw ptr -> shared ptr conversion if the function was called with raw ptrs.
rpcevo BuildDMNListEntry now takes a const ref for reasons as stated above
Signed-off-by: Pasta <pasta@dashboost.org>
* make stuff const
Signed-off-by: Pasta <pasta@dashboost.org>
* refactor/llmq: use ranges count_if
Signed-off-by: Pasta <pasta@dashboost.org>
2022-01-04 17:13:38 +01:00
objMN . pushKV ( " pubkeyoperator " , dmn . pdmnState - > pubKeyOperator . Get ( ) . ToString ( ) ) ;
2020-06-18 11:17:23 +02:00
obj . pushKV ( strOutpoint , objMN ) ;
2018-12-17 16:02:12 +01:00
} else if ( strMode = = " lastpaidblock " ) {
2018-12-17 16:36:58 +01:00
if ( strFilter ! = " " & & strOutpoint . find ( strFilter ) = = std : : string : : npos ) return ;
refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed. (#4653)
* refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed.
Introduces ForEachMNShared, a version of ForEachMN that uses a shared_ptr, and may extend the lifetime of the underlying shared_ptr. This is not preferred, should prefer ForEachMN. See docs.
Adjusts ForEachMN to pass a reference. This is preferred for use over ForEachMNShared. See docs. A reference should be used since in usage we assume it's non-null anyway. Additionally, it allows us to know that the lifespan of the dmn is not being being extended (if lifespan needs to be extended, should use ForEachMNShared.
IsMNValid, IsMNPoSeBanned, UpdateMN, UpdateMN, AddUniqueProperty, DeleteUniqueProperty, UpdateUniqueProperty now take a const reference to CDeterministicMN instead of a const reference to shared_ptr<CDeterministicMN>. All of these functions previously assumed (or would've crashed) a non-null ptr, and non extended lifetime, as such converting to ref is appropriate.
CompareByLastPaid ptr overload now takes raw ptr instead of a const ref to shared. Since we simply dereference them, a raw ptr makes the most sense. This also avoids a potential expensive and implicit raw ptr -> shared ptr conversion if the function was called with raw ptrs.
rpcevo BuildDMNListEntry now takes a const ref for reasons as stated above
Signed-off-by: Pasta <pasta@dashboost.org>
* make stuff const
Signed-off-by: Pasta <pasta@dashboost.org>
* refactor/llmq: use ranges count_if
Signed-off-by: Pasta <pasta@dashboost.org>
2022-01-04 17:13:38 +01:00
obj . pushKV ( strOutpoint , dmn . pdmnState - > nLastPaidHeight ) ;
2018-12-17 16:02:12 +01:00
} else if ( strMode = = " lastpaidtime " ) {
2018-12-17 16:36:58 +01:00
if ( strFilter ! = " " & & strOutpoint . find ( strFilter ) = = std : : string : : npos ) return ;
2020-06-18 11:17:23 +02:00
obj . pushKV ( strOutpoint , dmnToLastPaidTime ( dmn ) ) ;
2018-12-17 16:02:12 +01:00
} else if ( strMode = = " payee " ) {
if ( strFilter ! = " " & & payeeStr . find ( strFilter ) = = std : : string : : npos & &
2018-12-17 16:36:58 +01:00
strOutpoint . find ( strFilter ) = = std : : string : : npos ) return ;
2020-06-18 11:17:23 +02:00
obj . pushKV ( strOutpoint , payeeStr ) ;
2019-01-11 11:05:58 +01:00
} else if ( strMode = = " owneraddress " ) {
2018-12-17 16:36:58 +01:00
if ( strFilter ! = " " & & strOutpoint . find ( strFilter ) = = std : : string : : npos ) return ;
refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed. (#4653)
* refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed.
Introduces ForEachMNShared, a version of ForEachMN that uses a shared_ptr, and may extend the lifetime of the underlying shared_ptr. This is not preferred, should prefer ForEachMN. See docs.
Adjusts ForEachMN to pass a reference. This is preferred for use over ForEachMNShared. See docs. A reference should be used since in usage we assume it's non-null anyway. Additionally, it allows us to know that the lifespan of the dmn is not being being extended (if lifespan needs to be extended, should use ForEachMNShared.
IsMNValid, IsMNPoSeBanned, UpdateMN, UpdateMN, AddUniqueProperty, DeleteUniqueProperty, UpdateUniqueProperty now take a const reference to CDeterministicMN instead of a const reference to shared_ptr<CDeterministicMN>. All of these functions previously assumed (or would've crashed) a non-null ptr, and non extended lifetime, as such converting to ref is appropriate.
CompareByLastPaid ptr overload now takes raw ptr instead of a const ref to shared. Since we simply dereference them, a raw ptr makes the most sense. This also avoids a potential expensive and implicit raw ptr -> shared ptr conversion if the function was called with raw ptrs.
rpcevo BuildDMNListEntry now takes a const ref for reasons as stated above
Signed-off-by: Pasta <pasta@dashboost.org>
* make stuff const
Signed-off-by: Pasta <pasta@dashboost.org>
* refactor/llmq: use ranges count_if
Signed-off-by: Pasta <pasta@dashboost.org>
2022-01-04 17:13:38 +01:00
obj . pushKV ( strOutpoint , EncodeDestination ( dmn . pdmnState - > keyIDOwner ) ) ;
2018-12-31 14:05:23 +01:00
} else if ( strMode = = " pubkeyoperator " ) {
2018-12-17 16:36:58 +01:00
if ( strFilter ! = " " & & strOutpoint . find ( strFilter ) = = std : : string : : npos ) return ;
refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed. (#4653)
* refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed.
Introduces ForEachMNShared, a version of ForEachMN that uses a shared_ptr, and may extend the lifetime of the underlying shared_ptr. This is not preferred, should prefer ForEachMN. See docs.
Adjusts ForEachMN to pass a reference. This is preferred for use over ForEachMNShared. See docs. A reference should be used since in usage we assume it's non-null anyway. Additionally, it allows us to know that the lifespan of the dmn is not being being extended (if lifespan needs to be extended, should use ForEachMNShared.
IsMNValid, IsMNPoSeBanned, UpdateMN, UpdateMN, AddUniqueProperty, DeleteUniqueProperty, UpdateUniqueProperty now take a const reference to CDeterministicMN instead of a const reference to shared_ptr<CDeterministicMN>. All of these functions previously assumed (or would've crashed) a non-null ptr, and non extended lifetime, as such converting to ref is appropriate.
CompareByLastPaid ptr overload now takes raw ptr instead of a const ref to shared. Since we simply dereference them, a raw ptr makes the most sense. This also avoids a potential expensive and implicit raw ptr -> shared ptr conversion if the function was called with raw ptrs.
rpcevo BuildDMNListEntry now takes a const ref for reasons as stated above
Signed-off-by: Pasta <pasta@dashboost.org>
* make stuff const
Signed-off-by: Pasta <pasta@dashboost.org>
* refactor/llmq: use ranges count_if
Signed-off-by: Pasta <pasta@dashboost.org>
2022-01-04 17:13:38 +01:00
obj . pushKV ( strOutpoint , dmn . pdmnState - > pubKeyOperator . Get ( ) . ToString ( ) ) ;
2018-12-17 16:02:12 +01:00
} else if ( strMode = = " status " ) {
2018-12-17 16:36:58 +01:00
std : : string strStatus = dmnToStatus ( dmn ) ;
2018-12-17 16:02:12 +01:00
if ( strFilter ! = " " & & strStatus . find ( strFilter ) = = std : : string : : npos & &
2018-12-17 16:36:58 +01:00
strOutpoint . find ( strFilter ) = = std : : string : : npos ) return ;
2020-06-18 11:17:23 +02:00
obj . pushKV ( strOutpoint , strStatus ) ;
2019-01-11 11:05:58 +01:00
} else if ( strMode = = " votingaddress " ) {
if ( strFilter ! = " " & & strOutpoint . find ( strFilter ) = = std : : string : : npos ) return ;
refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed. (#4653)
* refactor: numerous changes to avoid passing around a const ref to shared_ptr of CDeterministicMNC when not needed.
Introduces ForEachMNShared, a version of ForEachMN that uses a shared_ptr, and may extend the lifetime of the underlying shared_ptr. This is not preferred, should prefer ForEachMN. See docs.
Adjusts ForEachMN to pass a reference. This is preferred for use over ForEachMNShared. See docs. A reference should be used since in usage we assume it's non-null anyway. Additionally, it allows us to know that the lifespan of the dmn is not being being extended (if lifespan needs to be extended, should use ForEachMNShared.
IsMNValid, IsMNPoSeBanned, UpdateMN, UpdateMN, AddUniqueProperty, DeleteUniqueProperty, UpdateUniqueProperty now take a const reference to CDeterministicMN instead of a const reference to shared_ptr<CDeterministicMN>. All of these functions previously assumed (or would've crashed) a non-null ptr, and non extended lifetime, as such converting to ref is appropriate.
CompareByLastPaid ptr overload now takes raw ptr instead of a const ref to shared. Since we simply dereference them, a raw ptr makes the most sense. This also avoids a potential expensive and implicit raw ptr -> shared ptr conversion if the function was called with raw ptrs.
rpcevo BuildDMNListEntry now takes a const ref for reasons as stated above
Signed-off-by: Pasta <pasta@dashboost.org>
* make stuff const
Signed-off-by: Pasta <pasta@dashboost.org>
* refactor/llmq: use ranges count_if
Signed-off-by: Pasta <pasta@dashboost.org>
2022-01-04 17:13:38 +01:00
obj . pushKV ( strOutpoint , EncodeDestination ( dmn . pdmnState - > keyIDVoting ) ) ;
2015-02-24 00:48:11 +01:00
}
2018-12-17 16:36:58 +01:00
} ) ;
2018-12-17 16:02:12 +01:00
2015-02-24 00:48:11 +01:00
return obj ;
2016-03-16 16:30:22 +01:00
}
2018-09-10 18:13:11 +02:00
// clang-format off
2016-03-31 10:55:06 +02:00
static const CRPCCommand commands [ ] =
2017-09-05 18:43:07 +02:00
{ // category name actor (function) argNames
// --------------------- ------------------------ ----------------------- ----------
{ " dash " , " masternode " , & masternode , { } } ,
2022-05-12 22:29:17 +02:00
{ " dash " , " masternodelist " , & masternode , { } } ,
2016-03-31 10:55:06 +02:00
} ;
2018-09-10 18:13:11 +02:00
// clang-format on
2016-08-31 16:04:22 +02:00
void RegisterMasternodeRPCCommands ( CRPCTable & t )
2016-03-31 10:55:06 +02:00
{
for ( unsigned int vcidx = 0 ; vcidx < ARRAYLEN ( commands ) ; vcidx + + )
2016-08-31 16:04:22 +02:00
t . appendCommand ( commands [ vcidx ] . name , & commands [ vcidx ] ) ;
2018-05-13 22:57:12 +02:00
}