From 19ff320d24ad4926a90b778d95ecbccb843d1d1d Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Sat, 18 Jan 2014 20:36:18 -0200 Subject: [PATCH] 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. --- src/clientversion.h | 2 +- src/main.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/clientversion.h b/src/clientversion.h index 3e26d08a..1f1cc80c 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -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 diff --git a/src/main.cpp b/src/main.cpp index 463adbff..a50eeb3f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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 &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"; }