dash-cli
dash-cli -datadir=/tmp/cache/node01 help
== Addressindex ==
getaddressbalance
getaddressdeltas
getaddressmempool
getaddresstxids
getaddressutxos
== Blockchain ==
getbestblockhash
getblock "hash" ( verbose )
getblockchaininfo
getblockcount
getblockhash index
getblockhashes timestamp
getblockheader "hash" ( verbose )
getblockheaders "hash" ( count verbose )
getchaintips ( count branchlen )
getdifficulty
getmempoolinfo
getrawmempool ( verbose )
getspentinfo
gettxout "txid" n ( includemempool )
gettxoutproof ["txid",...] ( blockhash )
gettxoutsetinfo
verifychain ( checklevel numblocks )
verifytxoutproof "proof"
== Control ==
debug ( 0|1|addrman|alert|bench|coindb|db|lock|rand|rpc|selectcoins|mempool|mempoolrej|net|proxy|prune|http|libevent|tor|zmq|dash|privatesend|instantsend|masternode|spork|keepass|mnpayments|gobject )
getinfo
help ( "command" )
stop
== Dash ==
getgovernanceinfo
getpoolinfo
getsuperblockbudget index
gobject "command"...
masternode "command"...
masternodebroadcast "command"...
masternodelist ( "mode" "filter" )
mnsync [status|next|reset]
privatesend "command"
spork <name> [<value>]
voteraw <masternode-tx-hash> <masternode-tx-index> <governance-hash> <vote-signal> [yes|no|abstain] <time> <vote-sig>
== Generating ==
generate numblocks
getgenerate
setgenerate generate ( genproclimit )
== Mining ==
getblocktemplate ( "jsonrequestobject" )
getmininginfo
getnetworkhashps ( blocks height )
prioritisetransaction <txid> <priority delta> <fee delta>
submitblock "hexdata" ( "jsonparametersobject" )
== Network ==
addnode "node" "add|remove|onetry"
clearbanned
disconnectnode "node"
getaddednodeinfo dns ( "node" )
getconnectioncount
getnettotals
getnetworkinfo
getpeerinfo
listbanned
ping
setban "ip(/netmask)" "add|remove" (bantime) (absolute)
== Rawtransactions ==
createrawtransaction [{"txid":"id","vout":n},...] {"address":amount,"data":"hex",...} ( locktime )
decoderawtransaction "hexstring"
decodescript "hex"
fundrawtransaction "hexstring" includeWatching
getrawtransaction "txid" ( verbose )
sendrawtransaction "hexstring" ( allowhighfees instantsend )
signrawtransaction "hexstring" ( [{"txid":"id","vout":n,"scriptPubKey":"hex","redeemScript":"hex"},...] ["privatekey1",...] sighashtype )
== Util ==
createmultisig nrequired ["key",...]
estimatefee nblocks
estimatepriority nblocks
estimatesmartfee nblocks
estimatesmartpriority nblocks
validateaddress "dashaddress"
verifymessage "dashaddress" "signature" "message"
== Wallet ==
abandontransaction "txid"
addmultisigaddress nrequired ["key",...] ( "account" )
backupwallet "destination"
dumpprivkey "dashaddress"
dumpwallet "filename"
encryptwallet "passphrase"
getaccount "dashaddress"
getaccountaddress "account"
getaddressesbyaccount "account"
getbalance ( "account" minconf includeWatchonly )
getnewaddress ( "account" )
getrawchangeaddress
getreceivedbyaccount "account" ( minconf )
getreceivedbyaddress "dashaddress" ( minconf )
gettransaction "txid" ( includeWatchonly )
getunconfirmedbalance
getwalletinfo
importaddress "address" ( "label" rescan p2sh )
importelectrumwallet "filename" index
importprivkey "dashprivkey" ( "label" rescan )
importpubkey "pubkey" ( "label" rescan )
importwallet "filename"
instantsendtoaddress "dashaddress" amount ( "comment" "comment-to" subtractfeefromamount )
keepass <genkey|init|setpassphrase>
keypoolrefill ( newsize )
listaccounts ( minconf includeWatchonly)
listaddressgroupings
listlockunspent
listreceivedbyaccount ( minconf includeempty includeWatchonly)
listreceivedbyaddress ( minconf includeempty includeWatchonly)
listsinceblock ( "blockhash" target-confirmations includeWatchonly)
listtransactions ( "account" count from includeWatchonly)
listunspent ( minconf maxconf ["address",...] )
lockunspent unlock [{"txid":"txid","vout":n},...]
move "fromaccount" "toaccount" amount ( minconf "comment" )
sendfrom "fromaccount" "todashaddress" amount ( minconf "comment" "comment-to" )
sendmany "fromaccount" {"address":amount,...} ( minconf "comment" ["address",...] subtractfeefromamount use_is use_ps )
sendtoaddress "dashaddress" amount ( "comment" "comment-to" subtractfeefromamount use_is use_ps )
setaccount "dashaddress" "account"
settxfee amount
signmessage "dashaddress" "message"
Dash 專屬功能
getgovernanceinfo
getpoolinfo
getsuperblockbudget index
gobject "command"...
masternode "command"...
masternodebroadcast "command"...
masternodelist ( "mode" "filter" )
mnsync [status|next|reset]
privatesend "command"
spork <name> [<value>]
voteraw <masternode-tx-hash> <masternode-tx-index> <governance-hash> <vote-signal> [yes|no|abstain] <time> <vote-sig>
debug ( 0|1|addrman|alert|bench|coindb|db|lock|rand|rpc|selectcoins|mempool|mempoolrej|net|proxy|prune|http|libevent|tor|zmq|dash|privatesend|instantsend|masternode|spork|keepass|mnpayments|gobject )
sendrawtransaction "hexstring" ( allowhighfees instantsend )
instantsendtoaddress "dashaddress" amount ( "comment" "comment-to" subtractfeefromamount )
getgovernanceinfo
getgovernanceinfo
Returns an object containing governance parameters.
Result:
{
"governanceminquorum": xxxxx, (numeric) the absolute minimum number of votes needed to trigger a governance action
"masternodewatchdogmaxseconds": xxxxx, (numeric) sentinel watchdog expiration time in seconds
"proposalfee": xxx.xx, (numeric) the collateral transaction fee which must be paid to create a proposal in DASH
"superblockcycle": xxxxx, (numeric) the number of blocks between superblocks
"lastsuperblock": xxxxx, (numeric) the block number of the last superblock
"nextsuperblock": xxxxx, (numeric) the block number of the next superblock
}
Examples:
> dash-cli getgovernanceinfo
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getgovernanceinfo", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:9998/
getpoolinfo
Returns an object containing mixing pool related information.
getsuperblockbudget index
getsuperblockbudget index
Returns the absolute maximum sum of superblock payments allowed.
Arguments:
1. index (numeric, required) The block index
Result:
n (numeric) The absolute maximum sum of superblock payments allowed, in DASH
Examples:
> dash-cli getsuperblockbudget 1000
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getsuperblockbudget", "params": [1000] }' -H 'content-type: text/plain;' http://127.0.0.1:9998/
gobject "command"...
gobject "command"...
Manage governance objects
Available commands:
prepare - Prepare governance object by signing and creating tx
submit - Submit governance object to network
deserialize - Deserialize governance object from hex string to JSON
count - Count governance objects and votes
get - Get governance object by hash
getvotes - Get all votes for a governance object hash (including old votes)
getcurrentvotes - Get only current (tallying) votes for a governance object hash (does not include old votes)
list - List governance objects (can be filtered by validity and/or object type)
diff - List differences since last diff
vote-alias - Vote on a governance object by masternode alias (using masternode.conf setup)
vote-conf - Vote on a governance object by masternode configured in dash.conf
vote-many - Vote on a governance object by all masternodes (using masternode.conf setup)
masternode "command"...
masternode "command"...
Set of commands to execute masternode related actions
Arguments:
1. "command" (string or set of strings, required) The command to execute
Available commands:
count - Print number of all known masternodes (optional: 'ps', 'enabled', 'all', 'qualify')
current - Print info on current masternode winner to be paid the next block (calculated locally)
debug - Print masternode status
genkey - Generate new masternodeprivkey
outputs - Print masternode compatible outputs
start - Start local Hot masternode configured in dash.conf
start-alias - Start single remote masternode by assigned alias configured in masternode.conf
start-<mode> - Start remote masternodes configured in masternode.conf (<mode>: 'all', 'missing', 'disabled')
status - Print masternode status information
list - Print list of all known masternodes (see masternodelist for more info)
list-conf - Print masternode.conf in JSON format
winner - Print info on next masternode winner to vote for
winners - Print list of masternode winners
masternodebroadcast "command"...
masternodebroadcast "command"...
Set of commands to create and relay masternode broadcast messages
Arguments:
1. "command" (string or set of strings, required) The command to execute
Available commands:
create-alias - Create single remote masternode broadcast message by assigned alias configured in masternode.conf
create-all - Create remote masternode broadcast messages for all masternodes configured in masternode.conf
decode - Decode masternode broadcast message
relay - Relay masternode broadcast message to the network
masternodelist ( "mode" "filter" )
masternodelist ( "mode" "filter" )
Get a list of masternodes in different modes
Arguments:
1. "mode" (string, optional/required to use filter, defaults = status) The mode to run list in
2. "filter" (string, optional) Filter results. Partial match by outpoint by default in all modes,
additional matches in some modes are also available
Available modes:
activeseconds - Print number of seconds masternode recognized by the network as enabled
(since latest issued "masternode start/start-many/start-alias")
addr - Print ip address associated with a masternode (can be additionally filtered, partial match)
full - Print info in format 'status protocol payee lastseen activeseconds lastpaidtime lastpaidblock IP'
(can be additionally filtered, partial match)
lastpaidblock - Print the last block height a node was paid on the network
lastpaidtime - Print the last time a node was paid on the network
lastseen - Print timestamp of when a masternode was last seen on the network
payee - Print Dash address associated with a masternode (can be additionally filtered,
partial match)
protocol - Print protocol of a masternode (can be additionally filtered, exact match))
rank - Print rank of a masternode based on current block
status - Print masternode status: PRE_ENABLED / ENABLED / EXPIRED / WATCHDOG_EXPIRED / NEW_START_REQUIRED /
UPDATE_REQUIRED / POSE_BAN / OUTPOINT_SPENT (can be additionally filtered, partial match)
mnsync [status|next|reset]
mnsync [status|next|reset]
Returns the sync status, updates to the next step or resets it entirely.
privatesend "command"
privatesend "command"
Arguments:
1. "command" (string or set of strings, required) The command to execute
Available commands:
start - Start mixing
stop - Stop mixing
reset - Reset mixing
spork <name> [<value>]
spork <name> [<value>]
<name> is the corresponding spork name, or 'show' to show all current spork settings, active to show which sporks are active<value> is a epoch datetime to enable or disable spork
voteraw [yes|no|abstain]
voteraw <masternode-tx-hash> <masternode-tx-index> <governance-hash> <vote-signal> [yes|no|abstain] <time> <vote-sig>
Compile and relay a governance vote with provided external signature instead of signing vote internally
debug
debug ( 0|1|addrman|alert|bench|coindb|db|lock|rand|rpc|selectcoins|mempool|mempoolrej|net|proxy|prune|http|libevent|tor|zmq|dash|privatesend|instantsend|masternode|spork|keepass|mnpayments|gobject )
Change debug category on the fly. Specify single category or use comma to specify many.
Examples:
> dash-cli debug dash
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "debug", "params": [dash,net] }' -H 'content-type: text/plain;' http://127.0.0.1:9998/
sendrawtransaction
sendrawtransaction "hexstring" ( allowhighfees instantsend )
Submits raw transaction (serialized, hex-encoded) to local node and network.
Also see createrawtransaction and signrawtransaction calls.
Arguments:
1. "hexstring" (string, required) The hex string of the raw transaction)
2. allowhighfees (boolean, optional, default=false) Allow high fees
3. instantsend (boolean, optional, default=false) Use InstantSend to send this transaction
Result:
"hex" (string) The transaction hash in hex
Examples:
Create a transaction
> dash-cli createrawtransaction "[{\"txid\" : \"mytxid\",\"vout\":0}]" "{\"myaddress\":0.01}"
Sign the transaction, and get back the hex
> dash-cli signrawtransaction "myhex"
Send the transaction (signed hex)
> dash-cli sendrawtransaction "signedhex"
As a json rpc call
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "sendrawtransaction", "params": ["signedhex"] }' -H 'content-type: text/plain;' http://127.0.0.1:9998/
instantsendtoaddress
instantsendtoaddress "dashaddress" amount ( "comment" "comment-to" subtractfeefromamount )
Send an amount to a given address. The amount is a real and is rounded to the nearest 0.00000001
Arguments:
1. "dashaddress" (string, required) The dash address to send to.
2. "amount" (numeric, required) The amount in btc to send. eg 0.1
3. "comment" (string, optional) A comment used to store what the transaction is for.
This is not part of the transaction, just kept in your wallet.
4. "comment-to" (string, optional) A comment to store the name of the person or organization
to which you're sending the transaction. This is not part of the
transaction, just kept in your wallet.
5. subtractfeefromamount (boolean, optional, default=false) The fee will be deducted from the amount being sent.
The recipient will receive less amount of Dash than you enter in the amount field.
Result:
"transactionid" (string) The transaction id.
Examples:
> dash-cli instantsendtoaddress "XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg" 0.1
> dash-cli instantsendtoaddress "XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg" 0.1 "donation" "seans outpost"
> dash-cli instantsendtoaddress "XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg" 0.1 "" "" true
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "instantsendtoaddress", "params": ["XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg", 0.1, "donation", "seans outpost"] }' -H 'content-type: text/plain;' http://127.0.0.1:9998/
Migrate Bitcoin 0.15 to Dash
Command: sendFrom
SelectCoins in wallet.cpp,
if(nCoinType == ONLY_DENOMINATED) {
CTxIn txin = CTxIn(out.tx->GetHash(),out.i);
int nRounds = GetInputPrivateSendRounds(txin);
// make sure it's actually anonymized
if(nRounds < nPrivateSendRounds) continue;
}
//if we're doing only denominated, we need to round up to the nearest smallest denomination
if(nCoinType == ONLY_DENOMINATED) {
CAmount nSmallestDenom = vecPrivateSendDenominations.back();
// Make outputs by looping through denominations, from large to small
BOOST_FOREACH(CAmount nDenom, vecPrivateSendDenominations)
{
BOOST_FOREACH(const COutput& out, vCoins)
{
//make sure it's the denom we're looking for, round the amount up to smallest denom
if(out.tx->vout[out.i].nValue == nDenom && nValueRet + nDenom < nTargetValue + nSmallestDenom) {
CTxIn txin = CTxIn(out.tx->GetHash(),out.i);
int nRounds = GetInputPrivateSendRounds(txin);
// make sure it's actually anonymized
if(nRounds < nPrivateSendRounds) continue;
nValueRet += nDenom;
setCoinsRet.insert(make_pair(out.tx, out.i));
}
}
}
return (nValueRet >= nTargetValue);
}
AvailableCoins in wallet.cpp,
bool found = false;
if(nCoinType == ONLY_DENOMINATED) {
found = IsDenominatedAmount(pcoin->vout[i].nValue);
} else if(nCoinType == ONLY_NOT1000IFMN) {
found = !(fMasterNode && pcoin->vout[i].nValue == 1000*COIN);
} else if(nCoinType == ONLY_NONDENOMINATED_NOT1000IFMN) {
if (IsCollateralAmount(pcoin->vout[i].nValue)) continue; // do not use collateral amounts
found = !IsDenominatedAmount(pcoin->vout[i].nValue);
if(found && fMasterNode) found = pcoin->vout[i].nValue != 1000*COIN; // do not use Hot MN funds
} else if(nCoinType == ONLY_1000) {
found = pcoin->vout[i].nValue == 1000*COIN;
} else if(nCoinType == ONLY_PRIVATESEND_COLLATERAL) {
found = IsCollateralAmount(pcoin->vout[i].nValue);
} else {
found = true;
}
if(!found) continue;
isminetype mine = IsMine(pcoin->vout[i]);
if (!(IsSpent(wtxid, i)) && mine != ISMINE_NO &&
(!IsLockedCoin((*it).first, i) || nCoinType == ONLY_1000) &&
(pcoin->vout[i].nValue > 0 || fIncludeZeroValue) &&
(!coinControl || !coinControl->HasSelected() || coinControl->fAllowOtherInputs || coinControl->IsSelected((*it).first, i)))
vCoins.push_back(COutput(pcoin, i, nDepth,
((mine & ISMINE_SPENDABLE) != ISMINE_NO) ||
(coinControl && coinControl->fAllowWatchOnly && (mine & ISMINE_WATCH_SOLVABLE) != ISMINE_NO)));
CreateTransaction in _wallet.cpp,
if (nCoinType == ONLY_NOT1000IFMN) {
strFailReason = _("Unable to locate enough funds for this transaction that are not equal 1000 DASH.");
} else if (nCoinType == ONLY_NONDENOMINATED_NOT1000IFMN) {
strFailReason = _("Unable to locate enough PrivateSend non-denominated funds for this transaction that are not equal 1000 DASH.");
} else if (nCoinType == ONLY_DENOMINATED) {
strFailReason = _("Unable to locate enough PrivateSend denominated funds for this transaction.");
strFailReason += " " + _("PrivateSend uses exact denominated amounts to send funds, you might simply need to anonymize some more coins.");
} else if (nValueIn < nValueToSelect) {
strFailReason = _("Insufficient funds.");
}
if (fUseInstantSend) {
if (nValueIn > sporkManager.GetSporkValue(SPORK_5_INSTANTSEND_MAX_VALUE)*COIN) {
strFailReason += " " + strprintf(_("InstantSend doesn't support sending values that high yet. Transactions are currently limited to %1 DASH."), sporkManager.GetSporkValue(SPORK_5_INSTANTSEND_MAX_VALUE));
} else {
// could be not true but most likely that's the reason
strFailReason += " " + strprintf(_("InstantSend requires inputs with at least %d confirmations, you might need to wait a few minutes and try again."), INSTANTSEND_CONFIRMATIONS_REQUIRED);
}
}
//over pay for denominated transactions
if (nCoinType == ONLY_DENOMINATED) {
nFeeRet += nChange;
wtxNew.mapValue["DS"] = "1";
// recheck skipped denominations during next mixing
darkSendPool.ClearSkippedDenominations();
} else {
txin.prevPubKey = coin.first->vout[coin.second].scriptPubKey;
[appended codes (to 0.12)] (Updated by BIP125 in 0.15??)
// BIP69 https://github.com/kristovatlas/bips/blob/master/bip-0069.mediawiki
sort(txNew.vin.begin(), txNew.vin.end());
sort(txNew.vout.begin(), txNew.vout.end());
// If there was change output added before, we must update its position now
if (nChangePosRet != -1) {
int i = 0;
BOOST_FOREACH(const CTxOut& txOut, txNew.vout)
{
if (txOut == newTxOut)
{
nChangePosRet = i;
break;
}
i++;
}
}
if(fUseInstantSend) {
nFeeNeeded = std::max(nFeeNeeded, CTxLockRequest(txNew).GetMinFee());
}
CommitTransaction in wallet.cpp
// notify only once
if(updated_hahes.find(txin.prevout.hash) != updated_hahes.end()) continue;
...
updated_hahes.insert(txin.prevout.hash);
masternode in rpcmasternode.cpp [appended codes]
UniValue masternode(const UniValue& params, bool fHelp)
{
std::string strCommand;
if (params.size() >= 1) {
strCommand = params[0].get_str();
}
if (strCommand == "start-many")
throw JSONRPCError(RPC_INVALID_PARAMETER, "DEPRECATED, please use start-all instead");
if (fHelp ||
(strCommand != "start" && strCommand != "start-alias" && strCommand != "start-all" && strCommand != "start-missing" &&
strCommand != "start-disabled" && strCommand != "list" && strCommand != "list-conf" && strCommand != "count" &&
strCommand != "debug" && strCommand != "current" && strCommand != "winner" && strCommand != "winners" && strCommand != "genkey" &&
strCommand != "connect" && strCommand != "outputs" && strCommand != "status"))
throw std::runtime_error(
"masternode \"command\"...\n"
"Set of commands to execute masternode related actions\n"
"\nArguments:\n"
"1. \"command\" (string or set of strings, required) The command to execute\n"
"\nAvailable commands:\n"
" count - Print number of all known masternodes (optional: 'ps', 'enabled', 'all', 'qualify')\n"
" current - Print info on current masternode winner to be paid the next block (calculated locally)\n"
" debug - Print masternode status\n"
" genkey - Generate new masternodeprivkey\n"
" outputs - Print masternode compatible outputs\n"
" start - Start local Hot masternode configured in dash.conf\n"
" start-alias - Start single remote masternode by assigned alias configured in masternode.conf\n"
" start-<mode> - Start remote masternodes configured in masternode.conf (<mode>: 'all', 'missing', 'disabled')\n"
" status - Print masternode status information\n"
" list - Print list of all known masternodes (see masternodelist for more info)\n"
" list-conf - Print masternode.conf in JSON format\n"
" winner - Print info on next masternode winner to vote for\n"
" winners - Print list of masternode winners\n"
);
if (strCommand == "list")
{
UniValue newParams(UniValue::VARR);
// forward params but skip "list"
for (unsigned int i = 1; i < params.size(); i++) {
newParams.push_back(params[i]);
}
return masternodelist(newParams, fHelp);
}
if(strCommand == "connect")
{
if (params.size() < 2)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Masternode address required");
std::string strAddress = params[1].get_str();
CService addr = CService(strAddress);
CNode *pnode = ConnectNode((CAddress)addr, NULL);
if(!pnode)
throw JSONRPCError(RPC_INTERNAL_ERROR, strprintf("Couldn't connect to masternode %s", strAddress));
return "successfully connected";
}
if (strCommand == "count")
{
if (params.size() > 2)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Too many parameters");
if (params.size() == 1)
return mnodeman.size();
std::string strMode = params[1].get_str();
if (strMode == "ps")
return mnodeman.CountEnabled(MIN_PRIVATESEND_PEER_PROTO_VERSION);
if (strMode == "enabled")
return mnodeman.CountEnabled();
int nCount;
mnodeman.GetNextMasternodeInQueueForPayment(true, nCount);
if (strMode == "qualify")
return nCount;
if (strMode == "all")
return strprintf("Total: %d (PS Compatible: %d / Enabled: %d / Qualify: %d)",
mnodeman.size(), mnodeman.CountEnabled(MIN_PRIVATESEND_PEER_PROTO_VERSION),
mnodeman.CountEnabled(), nCount);
}
if (strCommand == "current" || strCommand == "winner")
{
int nCount;
int nHeight;
CMasternode* winner = NULL;
{
LOCK(cs_main);
nHeight = chainActive.Height() + (strCommand == "current" ? 1 : 10);
}
mnodeman.UpdateLastPaid();
winner = mnodeman.GetNextMasternodeInQueueForPayment(nHeight, true, nCount);
if(!winner) return "unknown";
UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("height", nHeight));
obj.push_back(Pair("IP:port", winner->addr.ToString()));
obj.push_back(Pair("protocol", (int64_t)winner->nProtocolVersion));
obj.push_back(Pair("vin", winner->vin.prevout.ToStringShort()));
obj.push_back(Pair("payee", CBitcoinAddress(winner->pubKeyCollateralAddress.GetID()).ToString()));
obj.push_back(Pair("lastseen", (winner->lastPing == CMasternodePing()) ? winner->sigTime :
winner->lastPing.sigTime));
obj.push_back(Pair("activeseconds", (winner->lastPing == CMasternodePing()) ? 0 :
(winner->lastPing.sigTime - winner->sigTime)));
return obj;
}
if (strCommand == "debug")
{
if(activeMasternode.nState != ACTIVE_MASTERNODE_INITIAL || !masternodeSync.IsBlockchainSynced())
return activeMasternode.GetStatus();
CTxIn vin;
CPubKey pubkey;
CKey key;
if(!pwalletMain || !pwalletMain->GetMasternodeVinAndKeys(vin, pubkey, key))
throw JSONRPCError(RPC_INVALID_PARAMETER, "Missing masternode input, please look at the documentation for instructions on masternode creation");
return activeMasternode.GetStatus();
}
if (strCommand == "start")
{
if(!fMasterNode)
throw JSONRPCError(RPC_INTERNAL_ERROR, "You must set masternode=1 in the configuration");
{
LOCK(pwalletMain->cs_wallet);
EnsureWalletIsUnlocked();
}
if(activeMasternode.nState != ACTIVE_MASTERNODE_STARTED){
activeMasternode.nState = ACTIVE_MASTERNODE_INITIAL; // TODO: consider better way
activeMasternode.ManageState();
}
return activeMasternode.GetStatus();
}
if (strCommand == "start-alias")
{
if (params.size() < 2)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Please specify an alias");
{
LOCK(pwalletMain->cs_wallet);
EnsureWalletIsUnlocked();
}
std::string strAlias = params[1].get_str();
bool fFound = false;
UniValue statusObj(UniValue::VOBJ);
statusObj.push_back(Pair("alias", strAlias));
BOOST_FOREACH(CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) {
if(mne.getAlias() == strAlias) {
fFound = true;
std::string strError;
CMasternodeBroadcast mnb;
bool fResult = CMasternodeBroadcast::Create(mne.getIp(), mne.getPrivKey(), mne.getTxHash(), mne.getOutputIndex(), strError, mnb);
statusObj.push_back(Pair("result", fResult ? "successful" : "failed"));
if(fResult) {
mnodeman.UpdateMasternodeList(mnb);
mnb.Relay();
} else {
statusObj.push_back(Pair("errorMessage", strError));
}
mnodeman.NotifyMasternodeUpdates();
break;
}
}
if(!fFound) {
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("errorMessage", "Could not find alias in config. Verify with list-conf."));
}
return statusObj;
}
if (strCommand == "start-all" || strCommand == "start-missing" || strCommand == "start-disabled")
{
{
LOCK(pwalletMain->cs_wallet);
EnsureWalletIsUnlocked();
}
if((strCommand == "start-missing" || strCommand == "start-disabled") && !masternodeSync.IsMasternodeListSynced()) {
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "You can't use this command until masternode list is synced");
}
int nSuccessful = 0;
int nFailed = 0;
UniValue resultsObj(UniValue::VOBJ);
BOOST_FOREACH(CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) {
std::string strError;
CTxIn vin = CTxIn(uint256S(mne.getTxHash()), uint32_t(atoi(mne.getOutputIndex().c_str())));
CMasternode *pmn = mnodeman.Find(vin);
CMasternodeBroadcast mnb;
if(strCommand == "start-missing" && pmn) continue;
if(strCommand == "start-disabled" && pmn && pmn->IsEnabled()) continue;
bool fResult = CMasternodeBroadcast::Create(mne.getIp(), mne.getPrivKey(), mne.getTxHash(), mne.getOutputIndex(), strError, mnb);
UniValue statusObj(UniValue::VOBJ);
statusObj.push_back(Pair("alias", mne.getAlias()));
statusObj.push_back(Pair("result", fResult ? "successful" : "failed"));
if (fResult) {
nSuccessful++;
mnodeman.UpdateMasternodeList(mnb);
mnb.Relay();
} else {
nFailed++;
statusObj.push_back(Pair("errorMessage", strError));
}
resultsObj.push_back(Pair("status", statusObj));
}
mnodeman.NotifyMasternodeUpdates();
UniValue returnObj(UniValue::VOBJ);
returnObj.push_back(Pair("overall", strprintf("Successfully started %d masternodes, failed to start %d, total %d", nSuccessful, nFailed, nSuccessful + nFailed)));
returnObj.push_back(Pair("detail", resultsObj));
return returnObj;
}
if (strCommand == "genkey")
{
CKey secret;
secret.MakeNewKey(false);
return CBitcoinSecret(secret).ToString();
}
if (strCommand == "list-conf")
{
UniValue resultObj(UniValue::VOBJ);
BOOST_FOREACH(CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) {
CTxIn vin = CTxIn(uint256S(mne.getTxHash()), uint32_t(atoi(mne.getOutputIndex().c_str())));
CMasternode *pmn = mnodeman.Find(vin);
std::string strStatus = pmn ? pmn->GetStatus() : "MISSING";
UniValue mnObj(UniValue::VOBJ);
mnObj.push_back(Pair("alias", mne.getAlias()));
mnObj.push_back(Pair("address", mne.getIp()));
mnObj.push_back(Pair("privateKey", mne.getPrivKey()));
mnObj.push_back(Pair("txHash", mne.getTxHash()));
mnObj.push_back(Pair("outputIndex", mne.getOutputIndex()));
mnObj.push_back(Pair("status", strStatus));
resultObj.push_back(Pair("masternode", mnObj));
}
return resultObj;
}
if (strCommand == "outputs") {
// Find possible candidates
std::vector<COutput> vPossibleCoins;
pwalletMain->AvailableCoins(vPossibleCoins, true, NULL, false, ONLY_1000);
UniValue obj(UniValue::VOBJ);
BOOST_FOREACH(COutput& out, vPossibleCoins) {
obj.push_back(Pair(out.tx->GetHash().ToString(), strprintf("%d", out.i)));
}
return obj;
}
if (strCommand == "status")
{
if (!fMasterNode)
throw JSONRPCError(RPC_INTERNAL_ERROR, "This is not a masternode");
UniValue mnObj(UniValue::VOBJ);
mnObj.push_back(Pair("vin", activeMasternode.vin.ToString()));
mnObj.push_back(Pair("service", activeMasternode.service.ToString()));
CMasternode mn;
if(mnodeman.Get(activeMasternode.vin, mn)) {
mnObj.push_back(Pair("payee", CBitcoinAddress(mn.pubKeyCollateralAddress.GetID()).ToString()));
}
mnObj.push_back(Pair("status", activeMasternode.GetStatus()));
return mnObj;
}
if (strCommand == "winners")
{
int nHeight;
{
LOCK(cs_main);
CBlockIndex* pindex = chainActive.Tip();
if(!pindex) return NullUniValue;
nHeight = pindex->nHeight;
}
int nLast = 10;
std::string strFilter = "";
if (params.size() >= 2) {
nLast = atoi(params[1].get_str());
}
if (params.size() == 3) {
strFilter = params[2].get_str();
}
if (params.size() > 3)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'masternode winners ( \"count\" \"filter\" )'");
UniValue obj(UniValue::VOBJ);
for(int i = nHeight - nLast; i < nHeight + 20; i++) {
std::string strPayment = GetRequiredPaymentsString(i);
if (strFilter !="" && strPayment.find(strFilter) == std::string::npos) continue;
obj.push_back(Pair(strprintf("%d", i), strPayment));
}
return obj;
}
return NullUniValue;
}