|
|
@ -3524,25 +3524,19 @@ public: |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
CBlockTemplate* CreateNewBlock(CReserveKey& reservekey) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Create new block
|
|
|
|
|
|
|
|
auto_ptr<CBlockTemplate> pblocktemplate(new CBlockTemplate()); |
|
|
|
|
|
|
|
if(!pblocktemplate.get()) |
|
|
|
|
|
|
|
return NULL; |
|
|
|
|
|
|
|
CBlock *pblock = &pblocktemplate->block; // pointer for convenience
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create coinbase tx
|
|
|
|
static bool CreateSpamMsgTx(CTransaction &txNew) |
|
|
|
CTransaction txNew; |
|
|
|
{ |
|
|
|
txNew.message = CScript() << vector<unsigned char>((const unsigned char*)strSpamMessage.data(), (const unsigned char*)strSpamMessage.data() + strSpamMessage.size()); |
|
|
|
txNew.message = CScript() << vector<unsigned char>((const unsigned char*)strSpamMessage.data(), (const unsigned char*)strSpamMessage.data() + strSpamMessage.size()); |
|
|
|
|
|
|
|
|
|
|
|
// get keyid from wallet (hopefully this is pubkey of strSpamUser)
|
|
|
|
// get keyid from wallet (hopefully this is pubkey of strSpamUser)
|
|
|
|
CKeyID defaultKeyId( pwalletMain->vchDefaultKey.GetID() ); |
|
|
|
CKeyID defaultKeyId( pwalletMain->vchDefaultKey.GetID() ); |
|
|
|
|
|
|
|
printf("CreateSpamMsgTx: keyId = %s\n", defaultKeyId.ToString().c_str() ); |
|
|
|
CKey key; |
|
|
|
CKey key; |
|
|
|
// get privkey from pubkey
|
|
|
|
// get privkey from pubkey
|
|
|
|
if( !pwalletMain->GetKey(defaultKeyId, key) ) { |
|
|
|
if( !pwalletMain->GetKey(defaultKeyId, key) ) { |
|
|
|
printf("CreateNewBlock: Failed to get privKey to sign SpamMessage\n"); |
|
|
|
printf("CreateNewBlock: Failed to get privKey to sign SpamMessage\n"); |
|
|
|
return NULL; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
// compute message hash and sign it
|
|
|
|
// compute message hash and sign it
|
|
|
|
CHashWriter msgHash(SER_GETHASH, PROTOCOL_VERSION); |
|
|
|
CHashWriter msgHash(SER_GETHASH, PROTOCOL_VERSION); |
|
|
@ -3553,12 +3547,31 @@ CBlockTemplate* CreateNewBlock(CReserveKey& reservekey) |
|
|
|
printf("CreateNewBlock: Failed to sign SpamMessage\n"); |
|
|
|
printf("CreateNewBlock: Failed to sign SpamMessage\n"); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
printf("CreateSpamMsgTx: msg = %s hash = %s signed = %s\n", txNew.message.ToString().c_str(), |
|
|
|
|
|
|
|
msgHash.GetHash().ToString().c_str(), vchSig.data() ); |
|
|
|
// add username and signature
|
|
|
|
// add username and signature
|
|
|
|
txNew.userName = CScript() << vector<unsigned char>((const unsigned char*)strSpamUser.data(), (const unsigned char*)strSpamUser.data() + strSpamUser.size()) |
|
|
|
txNew.userName = CScript() << vector<unsigned char>((const unsigned char*)strSpamUser.data(), (const unsigned char*)strSpamUser.data() + strSpamUser.size()) |
|
|
|
<< vector<unsigned char>((const unsigned char*)vchSig.data(), (const unsigned char*)vchSig.data() + vchSig.size()); |
|
|
|
<< vector<unsigned char>((const unsigned char*)vchSig.data(), (const unsigned char*)vchSig.data() + vchSig.size()); |
|
|
|
txNew.pubKey.clear(); // pubKey will be updated to include extranonce
|
|
|
|
txNew.pubKey.clear(); // pubKey will be updated to include extranonce
|
|
|
|
txNew.nNonce = 0; // no update needed for spamMessage's nonce.
|
|
|
|
txNew.nNonce = 0; // no update needed for spamMessage's nonce.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// [MF] FIXME: reservekey gives uniqueness to this worker thread, but it's not being used in twister.
|
|
|
|
|
|
|
|
CBlockTemplate* CreateNewBlock(CReserveKey& reservekey) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Create new block
|
|
|
|
|
|
|
|
auto_ptr<CBlockTemplate> pblocktemplate(new CBlockTemplate()); |
|
|
|
|
|
|
|
if(!pblocktemplate.get()) |
|
|
|
|
|
|
|
return NULL; |
|
|
|
|
|
|
|
CBlock *pblock = &pblocktemplate->block; // pointer for convenience
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create coinbase tx
|
|
|
|
|
|
|
|
CTransaction txNew; |
|
|
|
|
|
|
|
if( !CreateSpamMsgTx(txNew) ) |
|
|
|
|
|
|
|
return NULL; |
|
|
|
|
|
|
|
|
|
|
|
// Add our coinbase tx as first transaction
|
|
|
|
// Add our coinbase tx as first transaction
|
|
|
|
pblock->vtx.push_back(txNew); |
|
|
|
pblock->vtx.push_back(txNew); |
|
|
|
|
|
|
|
|
|
|
|