replace HaveTxIndex for GetTransaction. this is a more secure check since it also

verifies if tx is part of current main chain. old test may cause problems for people
trying to reregister their usernames in case of reversal attack since nodes might incorrectly
refuse to accept/retransmit the new transaction.
This commit is contained in:
Miguel Freitas 2014-01-18 20:36:18 -02:00
parent bfbe583ff4
commit 19ff320d24
2 changed files with 7 additions and 5 deletions

View File

@ -8,7 +8,7 @@
// These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR 0
#define CLIENT_VERSION_MINOR 9
#define CLIENT_VERSION_REVISION 05
#define CLIENT_VERSION_REVISION 06
#define CLIENT_VERSION_BUILD 0
// Set to true for release, false for prerelease or test build

View File

@ -493,8 +493,9 @@ bool CTxMemPool::accept(CValidationState &state, CTransaction &tx, bool fLimitFr
{
// do we already have it?
uint256 txid = SerializeHash(make_pair(tx.GetUsername(),-1));
if( pblocktree->HaveTxIndex(txid) &&
CTransaction txOld;
uint256 hashBlock = 0;
if( GetTransaction(tx.GetUsername(), txOld, hashBlock) &&
// duplicate should be discarded but replacement is allowed.
!verifyDuplicateOrReplacementTx(tx, false, true) ) {
return false;
@ -3608,8 +3609,9 @@ static bool CreateSpamMsgTx(CTransaction &txNew, std::vector<unsigned char> &sal
CKeyID keyID;
if( strSpamUser != "nobody" ) {
// check both wallet and block chain if they know about this user
uint256 txid = SerializeHash(make_pair(strSpamUser,-1));
if( !pblocktree->HaveTxIndex(txid) ||
CTransaction txOld;
uint256 hashBlock = 0;
if( !GetTransaction(strSpamUser, txOld, hashBlock) ||
!pwalletMain->GetKeyIdFromUsername(strSpamUser, keyID) ) {
strUsername = "nobody";
}