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

@ -2813,10 +2813,13 @@ bool CBlock::CheckBlock(CValidationState &state, bool fCheckPOW, bool fCheckMerk
{
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,8 +2827,11 @@ 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 (GetBlockTime() < 1419207339){
if(!foundPaymentAmount || !foundPayee) {
CTxDestination address1;
ExtractDestination(payee, address1);
@ -2834,6 +2840,16 @@ bool CBlock::CheckBlock(CValidationState &state, bool fCheckPOW, bool fCheckMerk
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 {
LogPrintf("CheckBlock() : Skipping masternode payment check - nHeight %d Hash %s\n", pindexBest->nHeight+1, GetHash().ToString().c_str());

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,6 +187,14 @@ void SendCoinsDialog::on_sendButton_clicked()
return;
}
// 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)
{
WalletModel::UnlockContext ctx(model->requestUnlock(true));
if(!ctx.isValid())
{
@ -194,7 +202,15 @@ void SendCoinsDialog::on_sendButton_clicked()
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

@ -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")
{
@ -442,6 +442,19 @@ 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")
{

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.");