aboutsummaryrefslogtreecommitdiff
path: root/src/miner.cpp
diff options
context:
space:
mode:
authorPeter Todd <pete@petertodd.org>2015-05-25 00:48:33 -0400
committerPeter Todd <pete@petertodd.org>2015-05-27 05:51:33 -0400
commit28bf06236d3b385e95fe26a7a742395b30efd6ee (patch)
treedb17592323b542a7979171d4ee4fa07204213638 /src/miner.cpp
parente1412d3e96ff11d05d727bebedcc42698853cccc (diff)
Fix off-by-one error w/ nLockTime in the wallet
Previously due to an off-by-one error the wallet ignored nLockTime-by-height transactions that would be valid in the next block even though they are accepted into the mempool. The transactions wouldn't show up until confirmed, nor would they be included in the unconfirmed balance. Similar to the mempool behavior fix in 665bdd3b, the wallet code was calling IsFinalTx() directly without taking into account the fact that doing so tells you if the transaction could have been mined in the *current* block, rather than the next block. To fix this we strip IsFinalTx() of non-consensus-critical functionality, removing the default arguments, and add CheckFinalTx() to check if a transaction will be final in the next block.
Diffstat (limited to 'src/miner.cpp')
-rw-r--r--src/miner.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/miner.cpp b/src/miner.cpp
index 804a688523..fb417ac628 100644
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -137,6 +137,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
LOCK2(cs_main, mempool.cs);
CBlockIndex* pindexPrev = chainActive.Tip();
const int nHeight = pindexPrev->nHeight + 1;
+ pblock->nTime = GetAdjustedTime();
CCoinsViewCache view(pcoinsTip);
// Priority order to process transactions
@@ -151,7 +152,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
mi != mempool.mapTx.end(); ++mi)
{
const CTransaction& tx = mi->second.GetTx();
- if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight))
+ if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight, pblock->nTime))
continue;
COrphan* porphan = NULL;