@@ -52,18 +52,19 @@ UniValue getinfo(const UniValue& params, bool fHelp)
5252
5353 " \n Result:\n "
5454 " {\n "
55- " \" version\" : xxxxx, (numeric) the server version\n "
56- " \" protocolversion\" : xxxxx, (numeric) the protocol version\n "
57- " \" walletversion\" : xxxxx, (numeric) the wallet version\n "
58- " \" balance\" : xxxxxxx, (numeric) the total pivx balance of the wallet (excluding zerocoins)\n "
59- " \" zerocoinbalance\" : xxxxxxx, (numeric) the total zerocoin balance of the wallet\n "
60- " \" blocks\" : xxxxxx, (numeric) the current number of blocks processed in the server\n "
61- " \" timeoffset\" : xxxxx, (numeric) the time offset\n "
62- " \" connections\" : xxxxx, (numeric) the number of connections\n "
63- " \" proxy\" : \" host:port\" , (string, optional) the proxy used by the server\n "
64- " \" difficulty\" : xxxxxx, (numeric) the current difficulty\n "
65- " \" testnet\" : true|false, (boolean) if the server is using testnet or not\n "
66- " \" moneysupply\" : \" supply\" (numeric) The money supply when this block was added to the blockchain\n "
55+ " \" version\" : xxxxx, (numeric) the server version\n "
56+ " \" protocolversion\" : xxxxx, (numeric) the protocol version\n "
57+ " \" walletversion\" : xxxxx, (numeric) the wallet version\n "
58+ " \" balance\" : xxxxxxx, (numeric) the total pivx balance of the wallet (excluding zerocoins)\n "
59+ " \" zerocoinbalance\" : xxxxxxx, (numeric) the total zerocoin balance of the wallet\n "
60+ " \" staking status\" : true|false, (boolean) if the wallet is staking or not\n "
61+ " \" blocks\" : xxxxxx, (numeric) the current number of blocks processed in the server\n "
62+ " \" timeoffset\" : xxxxx, (numeric) the time offset\n "
63+ " \" connections\" : xxxxx, (numeric) the number of connections\n "
64+ " \" proxy\" : \" host:port\" , (string, optional) the proxy used by the server\n "
65+ " \" difficulty\" : xxxxxx, (numeric) the current difficulty\n "
66+ " \" testnet\" : true|false, (boolean) if the server is using testnet or not\n "
67+ " \" moneysupply\" : \" supply\" (numeric) The money supply when this block was added to the blockchain\n "
6768 " \" zPIVsupply\" :\n "
6869 " {\n "
6970 " \" 1\" : n, (numeric) supply of 1 zPIV denomination\n "
@@ -76,13 +77,12 @@ UniValue getinfo(const UniValue& params, bool fHelp)
7677 " \" 5000\" : n, (numeric) supply of 5000 zPIV denomination\n "
7778 " \" total\" : n, (numeric) The total supply of all zPIV denominations\n "
7879 " }\n "
79- " \" keypoololdest\" : xxxxxx, (numeric) the timestamp (seconds since GMT epoch) of the oldest pre-generated key in the key pool\n "
80- " \" keypoolsize\" : xxxx, (numeric) how many new keys are pre-generated\n "
81- " \" unlocked_until\" : ttt, (numeric) the timestamp in seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is unlocked for transfers, or 0 if the wallet is locked\n "
82- " \" paytxfee\" : x.xxxx, (numeric) the transaction fee set in pivx/kb\n "
83- " \" relayfee\" : x.xxxx, (numeric) minimum relay fee for non-free transactions in pivx/kb\n "
84- " \" staking status\" : true|false, (boolean) if the wallet is staking or not\n "
85- " \" errors\" : \" ...\" (string) any error messages\n "
80+ " \" keypoololdest\" : xxxxxx, (numeric) the timestamp (seconds since GMT epoch) of the oldest pre-generated key in the key pool\n "
81+ " \" keypoolsize\" : xxxx, (numeric) how many new keys are pre-generated\n "
82+ " \" unlocked_until\" : ttt, (numeric) the timestamp in seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is unlocked for transfers, or 0 if the wallet is locked\n "
83+ " \" paytxfee\" : x.xxxx, (numeric) the transaction fee set in pivx/kb\n "
84+ " \" relayfee\" : x.xxxx, (numeric) minimum relay fee for non-free transactions in pivx/kb\n "
85+ " \" errors\" : \" ...\" (string) any error messages\n "
8686 " }\n "
8787
8888 " \n Examples:\n " +
@@ -127,6 +127,9 @@ UniValue getinfo(const UniValue& params, bool fHelp)
127127 obj.push_back (Pair (" walletversion" , pwalletMain->GetVersion ()));
128128 obj.push_back (Pair (" balance" , ValueFromAmount (pwalletMain->GetBalance ())));
129129 obj.push_back (Pair (" zerocoinbalance" , ValueFromAmount (pwalletMain->GetZerocoinBalance (true ))));
130+ obj.push_back (Pair (" staking status" , (pwalletMain->pStakerStatus ->IsActive () ?
131+ " Staking Active" :
132+ " Staking Not Active" )));
130133 }
131134#endif
132135 obj.push_back (Pair (" blocks" , (int )chainActive.Height ()));
@@ -160,9 +163,6 @@ UniValue getinfo(const UniValue& params, bool fHelp)
160163 obj.push_back (Pair (" paytxfee" , ValueFromAmount (payTxFee.GetFeePerK ())));
161164#endif
162165 obj.push_back (Pair (" relayfee" , ValueFromAmount (::minRelayTxFee.GetFeePerK ())));
163- obj.push_back (Pair (" staking status" , (pwalletMain->pStakerStatus ->IsActive () ?
164- " Staking Active" :
165- " Staking Not Active" )));
166166 obj.push_back (Pair (" errors" , GetWarnings (" statusbar" )));
167167 return obj;
168168}
@@ -598,10 +598,10 @@ UniValue getstakingstatus(const UniValue& params, bool fHelp)
598598 " \" staking_enabled\" : true|false, (boolean) if staking is enabled/disabled in pivx.conf\n "
599599 " \" tiptime\" : n, (integer) chain tip blocktime\n "
600600 " \" haveconnections\" : true|false, (boolean) if network connections are present\n "
601+ " \" mnsync\" : true|false, (boolean) if masternode data is synced\n "
601602 " \" walletunlocked\" : true|false, (boolean) if the wallet is unlocked\n "
602603 " \" mintablecoins\" : true|false, (boolean) if the wallet has mintable coins\n "
603604 " \" enoughcoins\" : true|false, (boolean) if available coins are greater than reserve balance\n "
604- " \" mnsync\" : true|false, (boolean) if masternode data is synced\n "
605605 " \" hashLastStakeAttempt\" : xxx (hex string) hash of last block on top of which the miner attempted to stake\n "
606606 " \" heightLastStakeAttempt\" : n (integer) height of last block on top of which the miner attempted to stake\n "
607607 " \" timeLastStakeAttempt\" : n (integer) time of last attempted stake\n "
@@ -610,28 +610,28 @@ UniValue getstakingstatus(const UniValue& params, bool fHelp)
610610 " \n Examples:\n " +
611611 HelpExampleCli (" getstakingstatus" , " " ) + HelpExampleRpc (" getstakingstatus" , " " ));
612612
613- #ifdef ENABLE_WALLET
614- LOCK2 (cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL );
615- #else
616- LOCK (cs_main);
617- #endif
618613
619- UniValue obj (UniValue::VOBJ);
620- obj.push_back (Pair (" staking_status" , pwalletMain->pStakerStatus ->IsActive ()));
621- obj.push_back (Pair (" staking_enabled" , GetBoolArg (" -staking" , true )));
622- obj.push_back (Pair (" tiptime" , (int )chainActive.Tip ()->nTime ));
623- obj.push_back (Pair (" haveconnections" , !vNodes.empty ()));
624- if (pwalletMain) {
614+ if (!pwalletMain)
615+ throw JSONRPCError (RPC_IN_WARMUP, " Try again after active chain is loaded" );
616+ {
617+ LOCK2 (cs_main, &pwalletMain->cs_wallet );
618+ UniValue obj (UniValue::VOBJ);
619+ obj.push_back (Pair (" staking_status" , pwalletMain->pStakerStatus ->IsActive ()));
620+ obj.push_back (Pair (" staking_enabled" , GetBoolArg (" -staking" , true )));
621+ obj.push_back (Pair (" tiptime" , (int )chainActive.Tip ()->nTime ));
622+ obj.push_back (Pair (" haveconnections" , !vNodes.empty ()));
623+ obj.push_back (Pair (" mnsync" , masternodeSync.IsSynced ()));
625624 obj.push_back (Pair (" walletunlocked" , !pwalletMain->IsLocked ()));
626625 obj.push_back (Pair (" mintablecoins" , pwalletMain->MintableCoins ()));
627626 obj.push_back (Pair (" enoughcoins" , nReserveBalance <= pwalletMain->GetStakingBalance (GetBoolArg (" -coldstaking" , true ))));
627+ uint256 lastHash = pwalletMain->pStakerStatus ->GetLastHash ();
628+ obj.push_back (Pair (" hashLastStakeAttempt" , lastHash.GetHex ()));
629+ obj.push_back (Pair (" heightLastStakeAttempt" , (mapBlockIndex.count (lastHash) > 0 ?
630+ mapBlockIndex.at (lastHash)->nHeight : -1 )) );
631+ obj.push_back (Pair (" timeLastStakeAttempt" , pwalletMain->pStakerStatus ->GetLastTime ()));
632+ return obj;
628633 }
629- obj.push_back (Pair (" mnsync" , masternodeSync.IsSynced ()));
630- uint256 lastHash = pwalletMain->pStakerStatus ->GetLastHash ();
631- obj.push_back (Pair (" hashLastStakeAttempt" , lastHash.GetHex ()));
632- obj.push_back (Pair (" heightLastStakeAttempt" , (mapBlockIndex.count (lastHash) > 0 ?
633- mapBlockIndex.at (lastHash)->nHeight : -1 )) );
634- obj.push_back (Pair (" timeLastStakeAttempt" , pwalletMain->pStakerStatus ->GetLastTime ()));
635- return obj;
634+
635+
636636}
637637#endif // ENABLE_WALLET
0 commit comments