This commit is contained in:
Evan Duffield 2015-01-02 17:13:53 -07:00
commit e633bc437b
10 changed files with 136 additions and 86 deletions

View File

@ -5,8 +5,7 @@ Please be consistent with the existing coding style.
Block style:
bool Function(char* psz, int n)
{
bool Function(char* psz, int n) {
// Comment summarising what this section of code does
for (int i = 0; i < n; i++)
{
@ -65,9 +64,11 @@ Threads
- StartNode : Starts other threads.
- ThreadCheckDarkSendPool : Builds and update Masternode list, starts auto-denomination
- ThreadGetMyExternalIP : Determines outside-the-firewall IP address, sends addr message to connected peers when it determines it.
- ThreadSocketHandler : Sends/Receives data from peers on port 8333.
- ThreadSocketHandler : Sends/Receives data from peers on port 9999.
- ThreadMessageHandler : Higher-level message handling (sending and receiving).
@ -83,9 +84,9 @@ Threads
- ThreadFlushWalletDB : Close the wallet.dat file if it hasn't been used in 500ms.
- ThreadRPCServer : Remote procedure call handler, listens on port 8332 for connections and services them.
- ThreadRPCServer : Remote procedure call handler, listens on port 9998 for connections and services them.
- ThreadBitcoinMiner : Generates bitcoins
- DarkcoinMiner : Generates darkcoins
- ThreadMapPort : Universal plug-and-play startup/shutdown

View File

@ -296,10 +296,12 @@ bool CActiveMasternode::GetMasterNodeVin(CTxIn& vin, CPubKey& pubkey, CKey& secr
if(!strTxHash.empty()) {
// Let's find it
uint256 txHash(strTxHash);
int outputIndex = boost::lexical_cast<int>(outputIndex);
int outputIndex = 0;
outputIndex = boost::lexical_cast<int>(outputIndex);
bool found = false;
BOOST_FOREACH(COutput& out, possibleCoins) {
if(true) {
if(out.tx->GetHash() == txHash && out.i == outputIndex)
{
selectedOutput = &out;
found = true;
break;

View File

@ -272,10 +272,10 @@ class CBitcoinAddress : public CBase58Data
public:
enum
{
PUBKEY_ADDRESS = 48+28, // DarkCoin addresses start with X
SCRIPT_ADDRESS = 5,
PUBKEY_ADDRESS_TEST = 111,
SCRIPT_ADDRESS_TEST = 196,
PUBKEY_ADDRESS = 76, // Darkcoin addresses start with 'X'
SCRIPT_ADDRESS = 16, // Darkcoin script addresses start with '7'
PUBKEY_ADDRESS_TEST = 139, // Testnet darkcoin addresses start with 'x' or 'y'
SCRIPT_ADDRESS_TEST = 19, // Testnet darkcoin script addresses start with '8' or '9'
};
bool Set(const CKeyID &id) {
@ -400,8 +400,8 @@ class CBitcoinSecret : public CBase58Data
public:
enum
{
PRIVKEY_ADDRESS = CBitcoinAddress::PUBKEY_ADDRESS + 128,
PRIVKEY_ADDRESS_TEST = CBitcoinAddress::PUBKEY_ADDRESS_TEST + 128,
PRIVKEY_ADDRESS = 204, // Darkcoin private keys start with '7' or 'X'
PRIVKEY_ADDRESS_TEST = 239, // Testnet private keys start with '9' or 'c' (Bitcoin defaults)
};
void SetKey(const CKey& vchSecret)

View File

@ -1180,6 +1180,7 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector<std::stri
if (strMethod == "listtransactions" && n > 2) ConvertTo<boost::int64_t>(params[2]);
if (strMethod == "listaccounts" && n > 0) ConvertTo<boost::int64_t>(params[0]);
if (strMethod == "walletpassphrase" && n > 1) ConvertTo<boost::int64_t>(params[1]);
if (strMethod == "walletpassphrase" && n > 2) ConvertTo<bool>(params[2]);
if (strMethod == "getblocktemplate" && n > 0) ConvertTo<Object>(params[0]);
if (strMethod == "listsinceblock" && n > 1) ConvertTo<boost::int64_t>(params[1]);
if (strMethod == "sendmany" && n > 1) ConvertTo<Object>(params[1]);

View File

@ -943,7 +943,7 @@ bool CTxMemPool::acceptable(CValidationState &state, CTransaction &tx, bool fChe
return false;
}
}
// Check for conflicts with in-memory transactions
for (unsigned int i = 0; i < tx.vin.size(); i++)
{
@ -980,7 +980,7 @@ bool CTxMemPool::acceptable(CValidationState &state, CTransaction &tx, bool fChe
// only helps filling in pfMissingInputs (to determine missing vs spent).
BOOST_FOREACH(const CTxIn txin, tx.vin) {
if (!view.HaveCoins(txin.prevout.hash)) {
if (pfMissingInputs)
if (pfMissingInputs)
*pfMissingInputs = true;
return false;
}
@ -1048,7 +1048,7 @@ bool CTransaction::AcceptToMemoryPool(CValidationState &state, bool fCheckInputs
bool CTransaction::IsAcceptable(CValidationState &state, bool fCheckInputs, bool fLimitFree, bool* pfMissingInputs, bool fScriptChecks)
{
return mempool.acceptable(state, *this, fCheckInputs, fLimitFree, pfMissingInputs, fScriptChecks);
return mempool.acceptable(state, *this, fCheckInputs, fLimitFree, pfMissingInputs, fScriptChecks);
}
bool CTransaction::AcceptableInputs(CValidationState &state, bool fLimitFree)
@ -1167,7 +1167,7 @@ int CMerkleTx::IsTransactionLocked() const
for (unsigned int b = 0; b < vout.size(); b++) {
for(it_ctxl it = mapTxLocks.begin(); it != mapTxLocks.end(); it++) {
for (unsigned int a = 0; a < it->second.tx.vout.size(); a++) {
if(vout[b] == it->second.tx.vout[a])
if(vout[b] == it->second.tx.vout[a])
found++;
}
if(found > 0) break;
@ -1387,7 +1387,7 @@ int64 static GetBlockValue(int nBits, int nHeight, int64 nFees)
/* fixed bug caused diff to not be correctly calculated */
if(nHeight > 4500 || fTestNet) dDiff = ConvertBitsToDouble(nBits);
int64 nSubsidy = 0;
int64 nSubsidy = 0;
if(nHeight >= 5465) {
if((nHeight >= 17000 && dDiff > 75) || nHeight >= 24000) { // GPU/ASIC difficulty calc
// 2222222/(((x+2600)/9)^2)
@ -1412,7 +1412,7 @@ int64 static GetBlockValue(int nBits, int nHeight, int64 nFees)
for(int i = 46200; i <= nHeight; i += 210240) nSubsidy -= nSubsidy/14;
} else {
// yearly decline of production by 7.1% per year, projected 21.3M coins max by year 2050.
for(int i = 210240; i <= nHeight; i += 210240) nSubsidy -= nSubsidy/14;
for(int i = 210240; i <= nHeight; i += 210240) nSubsidy -= nSubsidy/14;
}
return nSubsidy + nFees;
@ -1424,7 +1424,7 @@ int64 GetMasternodePayment(int nHeight, int64 blockValue)
if(fTestNet) {
if(nHeight > 46000) ret += blockValue / 20; //25% - 2014-10-07
if(nHeight > 46000+((576*1)*1)) ret += blockValue / 20; //30% - 2014-10-08
if(nHeight > 46000+((576*1)*1)) ret += blockValue / 20; //30% - 2014-10-08
if(nHeight > 46000+((576*1)*2)) ret += blockValue / 20; //35% - 2014-10-09
if(nHeight > 46000+((576*1)*3)) ret += blockValue / 20; //40% - 2014-10-10
if(nHeight > 46000+((576*1)*4)) ret += blockValue / 20; //45% - 2014-10-11
@ -1433,7 +1433,7 @@ int64 GetMasternodePayment(int nHeight, int64 blockValue)
if(nHeight > 46000+((576*1)*7)) ret += blockValue / 20; //60% - 2014-10-14
}
if(nHeight > 158000) ret += blockValue / 20; //25.0% - 2014-10-23
if(nHeight > 158000) ret += blockValue / 20; //25.0% - 2014-10-23
if(nHeight > 158000+((576*30)*1)) ret += blockValue / 20; //30.0% - 2014-11-23
if(nHeight > 158000+((576*30)*2)) ret += blockValue / 20; //35.0% - 2014-12-23
if(nHeight > 158000+((576*30)*3)) ret += blockValue / 40; //37.5% - 2015-01-23
@ -1562,17 +1562,17 @@ unsigned int static KimotoGravityWell(const CBlockIndex* pindexLast, const CBloc
double EventHorizonDeviation;
double EventHorizonDeviationFast;
double EventHorizonDeviationSlow;
if (BlockLastSolved == NULL || BlockLastSolved->nHeight == 0 || (uint64)BlockLastSolved->nHeight < PastBlocksMin) { return bnProofOfWorkLimit.GetCompact(); }
for (unsigned int i = 1; BlockReading && BlockReading->nHeight > 0; i++) {
if (PastBlocksMax > 0 && i > PastBlocksMax) { break; }
PastBlocksMass++;
if (i == 1) { PastDifficultyAverage.SetCompact(BlockReading->nBits); }
else { PastDifficultyAverage = ((CBigNum().SetCompact(BlockReading->nBits) - PastDifficultyAveragePrev) / i) + PastDifficultyAveragePrev; }
PastDifficultyAveragePrev = PastDifficultyAverage;
PastRateActualSeconds = BlockLastSolved->GetBlockTime() - BlockReading->GetBlockTime();
PastRateTargetSeconds = TargetBlocksSpacingSeconds * PastBlocksMass;
PastRateAdjustmentRatio = double(1);
@ -1583,14 +1583,14 @@ unsigned int static KimotoGravityWell(const CBlockIndex* pindexLast, const CBloc
EventHorizonDeviation = 1 + (0.7084 * pow((double(PastBlocksMass)/double(28.2)), -1.228));
EventHorizonDeviationFast = EventHorizonDeviation;
EventHorizonDeviationSlow = 1 / EventHorizonDeviation;
if (PastBlocksMass >= PastBlocksMin) {
if ((PastRateAdjustmentRatio <= EventHorizonDeviationSlow) || (PastRateAdjustmentRatio >= EventHorizonDeviationFast)) { assert(BlockReading); break; }
}
if (BlockReading->pprev == NULL) { assert(BlockReading); break; }
BlockReading = BlockReading->pprev;
}
CBigNum bnNew(PastDifficultyAverage);
if (PastRateActualSeconds != 0 && PastRateTargetSeconds != 0) {
bnNew *= PastRateActualSeconds;
@ -1598,9 +1598,9 @@ unsigned int static KimotoGravityWell(const CBlockIndex* pindexLast, const CBloc
}
if (bnNew > bnProofOfWorkLimit) {
bnNew = bnProofOfWorkLimit;
bnNew = bnProofOfWorkLimit;
}
return bnNew.GetCompact();
}
@ -1618,10 +1618,10 @@ unsigned int static DarkGravityWave3(const CBlockIndex* pindexLast, const CBlock
CBigNum PastDifficultyAverage;
CBigNum PastDifficultyAveragePrev;
if (BlockLastSolved == NULL || BlockLastSolved->nHeight == 0 || BlockLastSolved->nHeight < PastBlocksMin) {
return bnProofOfWorkLimit.GetCompact();
if (BlockLastSolved == NULL || BlockLastSolved->nHeight == 0 || BlockLastSolved->nHeight < PastBlocksMin) {
return bnProofOfWorkLimit.GetCompact();
}
for (unsigned int i = 1; BlockReading && BlockReading->nHeight > 0; i++) {
if (PastBlocksMax > 0 && i > PastBlocksMax) { break; }
CountBlocks++;
@ -1636,12 +1636,12 @@ unsigned int static DarkGravityWave3(const CBlockIndex* pindexLast, const CBlock
int64 Diff = (LastBlockTime - BlockReading->GetBlockTime());
nActualTimespan += Diff;
}
LastBlockTime = BlockReading->GetBlockTime();
LastBlockTime = BlockReading->GetBlockTime();
if (BlockReading->pprev == NULL) { assert(BlockReading); break; }
BlockReading = BlockReading->pprev;
}
CBigNum bnNew(PastDifficultyAverage);
int64 nTargetTimespan = CountBlocks*nTargetSpacing;
@ -1658,7 +1658,7 @@ unsigned int static DarkGravityWave3(const CBlockIndex* pindexLast, const CBlock
if (bnNew > bnProofOfWorkLimit){
bnNew = bnProofOfWorkLimit;
}
return bnNew.GetCompact();
}
@ -1670,14 +1670,14 @@ unsigned int static GetNextWorkRequired_V2(const CBlockIndex* pindexLast, const
int64 PastSecondsMax = TimeDaySeconds * 7;
uint64 PastBlocksMin = PastSecondsMin / BlocksTargetSpacing;
uint64 PastBlocksMax = PastSecondsMax / BlocksTargetSpacing;
return KimotoGravityWell(pindexLast, pblock, BlocksTargetSpacing, PastBlocksMin, PastBlocksMax);
}
unsigned int static GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock)
{
int DiffMode = 1;
if (fTestNet) {
if (pindexLast->nHeight+1 >= 256) DiffMode = 3;
}
@ -1821,7 +1821,7 @@ void CBlockHeader::UpdateTime(const CBlockIndex* pindexPrev)
}
uint256 CBlockHeader::GetHash() const
{
{
return HashX11(BEGIN(nVersion), END(nNonce));
}
@ -2807,16 +2807,19 @@ bool CBlock::CheckBlock(CValidationState &state, bool fCheckPOW, bool fCheckMerk
if(pindexBest->GetBlockHash() == hashPrevBlock){
int64 masternodePaymentAmount = GetMasternodePayment(pindexBest->nHeight+1, vtx[0].GetValueOut());
bool fIsInitialDownload = IsInitialBlockDownload();
// If we don't already have its previous block, skip masternode payment step
if (!fIsInitialDownload && pindexBest != NULL)
{
bool foundPaymentAmount = false;
bool foundPayee = false;
bool foundPaymentAndPayee = false;
CScript payee;
if(!masternodePayments.GetBlockPayee(pindexBest->nHeight+1, payee) || payee == CScript()){
foundPayee = true; //doesn't require a specific payee
foundPaymentAmount = true;
foundPaymentAndPayee = true;
}
for (unsigned int i = 0; i < vtx[0].vout.size(); i++) {
@ -2824,15 +2827,28 @@ bool CBlock::CheckBlock(CValidationState &state, bool fCheckPOW, bool fCheckMerk
foundPaymentAmount = true;
if(vtx[0].vout[i].scriptPubKey == payee )
foundPayee = true;
if(vtx[0].vout[i].nValue == masternodePaymentAmount && vtx[0].vout[i].scriptPubKey == payee)
foundPaymentAndPayee = true;
}
if(!foundPaymentAmount || !foundPayee) {
CTxDestination address1;
ExtractDestination(payee, address1);
CBitcoinAddress address2(address1);
if (GetBlockTime() < 1419207339){
if(!foundPaymentAmount || !foundPayee) {
CTxDestination address1;
ExtractDestination(payee, address1);
CBitcoinAddress address2(address1);
LogPrintf("CheckBlock() : Couldn't find masternode payment(%d|%"PRI64u") or payee(%d|%s) nHeight %d. \n", foundPaymentAmount, masternodePaymentAmount, foundPayee, address2.ToString().c_str(), pindexBest->nHeight+1);
if(EnforceMasternodePayments) return state.DoS(100, error("CheckBlock() : Couldn't find masternode payment or payee"));
LogPrintf("CheckBlock() : Couldn't find masternode payment(%d|%"PRI64u") or payee(%d|%s) nHeight %d. \n", foundPaymentAmount, masternodePaymentAmount, foundPayee, address2.ToString().c_str(), pindexBest->nHeight+1);
if(EnforceMasternodePayments) return state.DoS(100, error("CheckBlock() : Couldn't find masternode payment or payee"));
}
} else {
if(!foundPaymentAndPayee) {
CTxDestination address1;
ExtractDestination(payee, address1);
CBitcoinAddress address2(address1);
LogPrintf("CheckBlock() : Couldn't find masternode payment(%d|%"PRI64u") or payee(%d|%s) nHeight %d. \n", foundPaymentAmount, masternodePaymentAmount, foundPayee, address2.ToString().c_str(), pindexBest->nHeight+1);
if(EnforceMasternodePayments) return state.DoS(100, error("CheckBlock() : Couldn't find masternode payment or payee"));
}
}
}
} else {
@ -2905,7 +2921,7 @@ bool CBlock::AcceptBlock(CValidationState &state, CDiskBlockPos *dbp)
double n1 = ConvertBitsToDouble(nBits);
double n2 = ConvertBitsToDouble(nBitsNext);
if (abs(n1-n2) > n1*0.5)
if (abs(n1-n2) > n1*0.5)
return state.DoS(100, error("AcceptBlock() : incorrect proof of work (DGW pre-fork) - %f", abs(n1-n2)));
} else {
if (nBits != GetNextWorkRequired(pindexPrev, this))
@ -3506,7 +3522,7 @@ bool InitBlockIndex() {
if (pindexGenesisBlock != NULL) {
// Check whether the master checkpoint key has changed and reset the sync checkpoint if needed.
if (!CheckCheckpointPubKey())
return error("LoadBlockIndex() : failed to reset checkpoint master pubkey");
return error("LoadBlockIndex() : failed to reset checkpoint master pubkey");
return true;
}
@ -3524,7 +3540,7 @@ bool InitBlockIndex() {
// CTxOut(nValue=50.00000000, scriptPubKey=040184710fa689ad5023690c80f3a4)
// vMerkleTree: 97ddfbbae6
// Genesis block
// Genesis block
const char* pszTimestamp = "Wired 09/Jan/2014 The Grand Experiment Goes Live: Overstock.com Is Now Accepting Bitcoins";
CTransaction txNew;
txNew.vin.resize(1);
@ -3926,7 +3942,7 @@ void static ProcessGetData(CNode* pfrom)
{
// Send stream from relay memory
bool pushed = false;
if(!mapDarksendBroadcastTxes.count(inv.hash))
{
LOCK(cs_mapRelay);
@ -3942,10 +3958,10 @@ void static ProcessGetData(CNode* pfrom)
if(mapDarksendBroadcastTxes.count(inv.hash)){
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
ss.reserve(1000);
ss <<
mapDarksendBroadcastTxes[inv.hash].tx <<
mapDarksendBroadcastTxes[inv.hash].vin <<
mapDarksendBroadcastTxes[inv.hash].vchSig <<
ss <<
mapDarksendBroadcastTxes[inv.hash].tx <<
mapDarksendBroadcastTxes[inv.hash].vin <<
mapDarksendBroadcastTxes[inv.hash].vchSig <<
mapDarksendBroadcastTxes[inv.hash].sigTime;
pfrom->PushMessage("dstx", ss);
@ -4073,7 +4089,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
// Change version
pfrom->PushMessage("verack");
pfrom->ssSend.SetVersion(min(pfrom->nVersion, PROTOCOL_VERSION));
if (!pfrom->fInbound)
{
// Advertise our address
@ -4381,7 +4397,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
return true;
}
std::string strMessage = tx.GetHash().ToString() + boost::lexical_cast<std::string>(sigTime);
std::string strMessage = tx.GetHash().ToString() + boost::lexical_cast<std::string>(sigTime);
std::string errorMessage = "";
if(!darkSendSigner.VerifyMessage(mn.pubkey2, vchSig, strMessage, errorMessage)){
@ -4662,7 +4678,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
else
{
//probably one the extensions
//probably one the extensions
ProcessMessageDarksend(pfrom, strCommand, vRecv);
ProcessMessageMasternode(pfrom, strCommand, vRecv);
ProcessMessageInstantX(pfrom, strCommand, vRecv);
@ -5098,7 +5114,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
int payments = 1;
// Create coinbase tx
CTransaction txNew;
txNew.vin.resize(1);
txNew.vin.resize(1);
txNew.vin[0].prevout.SetNull();
txNew.vout.resize(1);
txNew.vout[0].scriptPubKey = scriptPubKeyIn;
@ -5116,13 +5132,13 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
bMasterNodePayment = true;
}
}
int64 nFees = 0;
{
LOCK2(cs_main, mempool.cs);
CCoinsViewCache view(*pcoinsTip, true);
CBlockIndex* pindexPrev = pindexBest;
if(bMasterNodePayment) {
bool hasPayment = true;
//spork
@ -5131,7 +5147,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
int winningNode = GetCurrentMasterNode(1);
if(winningNode >= 0){
pblock->payee.SetDestination(darkSendMasterNodes[winningNode].pubkey.GetID());
} else {
} else {
LogPrintf("CreateNewBlock: Failed to detect masternode to pay\n");
hasPayment = false;
}
@ -5357,7 +5373,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
int64 blockValue = GetBlockValue(pindexPrev->nBits, pindexPrev->nHeight, nFees);
int64 masternodePayment = GetMasternodePayment(pindexPrev->nHeight+1, blockValue);
//create masternode payment
if(payments > 1){
pblock->vtx[0].vout[payments-1].nValue = masternodePayment;
@ -5374,7 +5390,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
pblock->nNonce = 0;
pblock->vtx[0].vin[0].scriptSig = CScript() << OP_0 << OP_0;
pblocktemplate->vTxSigOps[0] = pblock->vtx[0].GetLegacySigOpCount();
CBlockIndex indexDummy(*pblock);
indexDummy.pprev = pindexPrev;

View File

@ -59,7 +59,7 @@ void ProcessMessageMasternode(CNode* pfrom, std::string& strCommand, CDataStream
return;
}
bool isLocal = false; // addr.IsRFC1918();
bool isLocal = addr.IsRFC1918();
std::string vchPubKey(pubkey.begin(), pubkey.end());
std::string vchPubKey2(pubkey2.begin(), pubkey2.end());

View File

@ -187,14 +187,30 @@ void SendCoinsDialog::on_sendButton_clicked()
return;
}
WalletModel::UnlockContext ctx(model->requestUnlock(true));
if(!ctx.isValid())
// request unlock only if was locked or unlocked for mixing:
// this way we let users unlock by walletpassphrase or by menu
// and make many transactions while unlocking through this dialog
// will call relock
WalletModel::EncryptionStatus encStatus = model->getEncryptionStatus();
if(encStatus == model->Locked ||
encStatus == model->UnlockedForAnonymizationOnly)
{
// Unlock wallet was cancelled
fNewRecipientAllowed = true;
WalletModel::UnlockContext ctx(model->requestUnlock(true));
if(!ctx.isValid())
{
// Unlock wallet was cancelled
fNewRecipientAllowed = true;
return;
}
send(recipients);
return;
}
// already unlocked or not encrypted at all
send(recipients);
}
void SendCoinsDialog::send(QList<SendCoinsRecipient> recipients)
{
WalletModel::SendCoinsReturn sendstatus;
if (!model->getOptionsModel() || !model->getOptionsModel()->getCoinControlFeatures())
sendstatus = model->sendCoins(recipients);

View File

@ -50,6 +50,7 @@ private:
bool fNewRecipientAllowed;
bool boolCheckedBalance;
int cachedNumBlocks;
void send(QList<SendCoinsRecipient> recipients);
private slots:
void on_sendButton_clicked();

View File

@ -23,10 +23,10 @@ Value darksend(const Array& params, bool fHelp)
"darkcoinaddress, reset, or auto (AutoDenominate)"
"<amount> is a real and is rounded to the nearest 0.00000001"
+ HelpRequiringPassphrase());
if(fMasterNode)
return "DarkSend is not supported from masternodes";
if (pwalletMain->IsLocked())
throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first.");
@ -89,9 +89,9 @@ Value masternode(const Array& params, bool fHelp)
if (fHelp ||
(strCommand != "start" && strCommand != "start-alias" && strCommand != "start-many" && strCommand != "stop" && strCommand != "stop-alias" && strCommand != "stop-many" && strCommand != "list" && strCommand != "list-conf" && strCommand != "count" && strCommand != "enforce"
&& strCommand != "debug" && strCommand != "current" && strCommand != "winners" && strCommand != "genkey" && strCommand != "connect"))
&& strCommand != "debug" && strCommand != "current" && strCommand != "winners" && strCommand != "genkey" && strCommand != "connect" && strCommand != "outputs"))
throw runtime_error(
"masternode <start|start-alias|start-many|stop|stop-alias|stop-many|list|list-conf|count|debug|current|winners|genkey|enforce> passphrase\n");
"masternode <start|start-alias|start-many|stop|stop-alias|stop-many|list|list-conf|count|debug|current|winners|genkey|enforce|outputs> [passphrase]\n");
if (strCommand == "stop")
{
@ -107,7 +107,7 @@ Value masternode(const Array& params, bool fHelp)
throw runtime_error(
"Your wallet is locked, passphrase is required\n");
}
if(!pwalletMain->Unlock(strWalletPass)){
return "incorrect passphrase";
}
@ -118,10 +118,10 @@ Value masternode(const Array& params, bool fHelp)
return "stop failed: " + errorMessage;
}
pwalletMain->Lock();
if(activeMasternode.status == MASTERNODE_STOPPED) return "successfully stopped masternode";
if(activeMasternode.status == MASTERNODE_NOT_CAPABLE) return "not capable masternode";
return "unknown";
}
@ -234,7 +234,7 @@ Value masternode(const Array& params, bool fHelp)
}
if (strCommand == "list")
{
{
std::string strCommand = "active";
if (params.size() == 2){
@ -248,7 +248,7 @@ Value masternode(const Array& params, bool fHelp)
Object obj;
BOOST_FOREACH(CMasterNode mn, darkSendMasterNodes) {
mn.Check();
mn.Check();
if(strCommand == "active"){
obj.push_back(Pair(mn.addr.ToString().c_str(), (int)mn.IsEnabled()));
@ -290,7 +290,7 @@ Value masternode(const Array& params, bool fHelp)
throw runtime_error(
"Your wallet is locked, passphrase is required\n");
}
if(!pwalletMain->Unlock(strWalletPass)){
return "incorrect passphrase";
}
@ -300,7 +300,7 @@ Value masternode(const Array& params, bool fHelp)
std::string errorMessage;
activeMasternode.ManageStatus();
pwalletMain->Lock();
if(activeMasternode.status == MASTERNODE_REMOTELY_ENABLED) return "masternode started remotely";
if(activeMasternode.status == MASTERNODE_INPUT_TOO_NEW) return "masternode input must have at least 15 confirmations";
if(activeMasternode.status == MASTERNODE_STOPPED) return "masternode is stopped";
@ -364,9 +364,9 @@ Value masternode(const Array& params, bool fHelp)
return statusObj;
}
if (strCommand == "start-many")
{
{
if(pwalletMain->IsLocked()) {
SecureString strWalletPass;
strWalletPass.reserve(100);
@ -442,9 +442,22 @@ Value masternode(const Array& params, bool fHelp)
}
}
if (strCommand == "outputs"){
// Find possible candidates
vector<COutput> possibleCoins = activeMasternode.SelectCoinsMasternode();
Object obj;
BOOST_FOREACH(COutput& out, possibleCoins) {
obj.push_back(Pair(out.tx->GetHash().ToString().c_str(), boost::lexical_cast<std::string>(out.i)));
}
return obj;
}
if (strCommand == "create")
{
return "Not implemented yet, please look at the documentation for instructions on masternode creation";
}
@ -459,7 +472,7 @@ Value masternode(const Array& params, bool fHelp)
}
if (strCommand == "genkey")
{
{
CKey secret;
secret.MakeNewKey(false);
@ -467,7 +480,7 @@ Value masternode(const Array& params, bool fHelp)
}
if (strCommand == "winners")
{
{
Object obj;
for(int nHeight = pindexBest->nHeight-10; nHeight < pindexBest->nHeight+20; nHeight++)
@ -499,7 +512,7 @@ Value masternode(const Array& params, bool fHelp)
} else {
throw runtime_error(
"Masternode address required\n");
}
}
CService addr = CService(strAddress);

View File

@ -1354,7 +1354,7 @@ Value walletpassphrase(const Array& params, bool fHelp)
{
if (pwalletMain->IsCrypted() && (fHelp || params.size() < 2 || params.size() > 3))
throw runtime_error(
"walletpassphrase <passphrase> <timeout> [anonymizenonly]\n"
"walletpassphrase <passphrase> <timeout> [anonymizenonly=false]\n"
"Stores the wallet decryption key in memory for <timeout> seconds.\n"
"if [anonymizeonly] is true sending functions are disabled.");
if (fHelp)
@ -1388,7 +1388,7 @@ Value walletpassphrase(const Array& params, bool fHelp)
}
else
throw runtime_error(
"walletpassphrase <passphrase> <timeout> [anonymizeonly]\n"
"walletpassphrase <passphrase> <timeout> [anonymizeonly=false]\n"
"Stores the wallet decryption key in memory for <timeout> seconds.\n"
"if [anonymizeonly] is true sending functions are disabled.");