Merge #16911: wallet: Only check the hash of transactions loaded from disk

cd68594dcd Only check the hash of transactions loaded from disk (Andrew Chow)

Pull request description:

  It feels unnecessary to do a full `CheckTransaction` for every transaction saved in the wallet. It should not be possible for an invalid transaction to get into the wallet in the first place, and if there is any disk corruption, the hash check will catch it.

ACKs for top commit:
  MarcoFalke:
    ACK cd68594dcd
  laanwj:
    ACK cd68594dcd
  promag:
    ACK cd68594dcd, AFAICT the check is not needed, hash comparison gives data integrity.

Tree-SHA512: 5b2e719f76097cfbf125392db6cc6c764355c81f0b7a5b60aee4b06af1afcca80cfd38a3cf5307fd9e2c1afc405f8321929a4552943099a8161e6762965451fb
This commit is contained in:
Wladimir J. van der Laan 2019-10-23 12:03:57 +02:00
commit a884b32854
No known key found for this signature in database
GPG key ID: 1E4AED62986CD25D

View file

@ -5,8 +5,6 @@
#include <wallet/walletdb.h>
#include <consensus/tx_check.h>
#include <consensus/validation.h>
#include <fs.h>
#include <key_io.h>
#include <protocol.h>
@ -218,8 +216,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
ssKey >> hash;
CWalletTx wtx(nullptr /* pwallet */, MakeTransactionRef());
ssValue >> wtx;
CValidationState state;
if (!(CheckTransaction(*wtx.tx, state) && (wtx.GetHash() == hash) && state.IsValid()))
if (wtx.GetHash() != hash)
return false;
// Undo serialize changes in 31600