From b50cd7a67e71051db59199a4185e7c82b669c659 Mon Sep 17 00:00:00 2001 From: Alex Morcos Date: Mon, 7 Nov 2016 15:30:41 -0500 Subject: Fix dangerous condition in ModifyNewCoins. We were marking coins FRESH before being sure they were not overwriting dirty undo data. This condition was never reached in existing code because undo data was always flushed before UpdateCoins was called with new transactions, but could have been exposed in an otherwise safe refactor. Clarify in the comments the assumptions made in ModifyNewCoins. Add ability to undo transactions to UpdateCoins unit test. Thanks to Russ Yanofsky for suggestion on how to make logic clearer and fixing up the ccoins_modify_new test cases. --- src/validation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/validation.cpp') diff --git a/src/validation.cpp b/src/validation.cpp index bd60bbfdcd..744c228bb7 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1498,7 +1498,7 @@ bool AbortNode(CValidationState& state, const std::string& strMessage, const std * @param out The out point that corresponds to the tx input. * @return True on success. */ -static bool ApplyTxInUndo(const CTxInUndo& undo, CCoinsViewCache& view, const COutPoint& out) +bool ApplyTxInUndo(const CTxInUndo& undo, CCoinsViewCache& view, const COutPoint& out) { bool fClean = true; -- cgit v1.2.3