From d1e56838dc067568cfce7bc85bdc228da58f2597 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Thu, 2 Feb 2012 17:27:44 -0500 Subject: Bugfix: Support building test_bitcoin with shared-object boost test framework Conflicts: src/makefile.unix --- src/makefile.unix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/makefile.unix b/src/makefile.unix index 6c48199546..9d97ae50ca 100644 --- a/src/makefile.unix +++ b/src/makefile.unix @@ -16,6 +16,8 @@ ifdef STATIC ifeq (${STATIC}, all) LMODE2 = static endif +else + TESTDEFS += -DBOOST_TEST_DYN_LINK endif # for boost 1.37, add -mt to the boost libraries @@ -140,14 +142,14 @@ bitcoind: $(OBJS:obj/%=obj/nogui/%) $(CXX) $(xCXXFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) obj/test/%.o: test/%.cpp - $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $< + $(CXX) -c $(TESTDEFS) $(xCXXFLAGS) -MMD -o $@ $< @cp $(@:%.o=%.d) $(@:%.o=%.P); \ sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \ rm -f $(@:%.o=%.d) test_bitcoin: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%)) - $(CXX) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-Bstatic -lboost_unit_test_framework $(LDFLAGS) $(LIBS) + $(CXX) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-B$(LMODE) -lboost_unit_test_framework $(LDFLAGS) $(LIBS) clean: -rm -f bitcoind test_bitcoin -- cgit v1.2.3 From 1677743fca631f8fb970fe917866dd982c6ddd40 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Mon, 23 Jan 2012 14:27:08 -0500 Subject: Rename src/obj/test to src/obj-test to workaround bug in older GNU Make --- src/makefile.unix | 10 +++++----- src/obj-test/.gitignore | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 src/obj-test/.gitignore (limited to 'src') diff --git a/src/makefile.unix b/src/makefile.unix index 9d97ae50ca..53948bcba6 100644 --- a/src/makefile.unix +++ b/src/makefile.unix @@ -129,7 +129,7 @@ all: bitcoind # auto-generated dependencies: -include obj/nogui/*.P --include obj/test/*.P +-include obj-test/*.P obj/nogui/%.o: %.cpp $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $< @@ -141,21 +141,21 @@ obj/nogui/%.o: %.cpp bitcoind: $(OBJS:obj/%=obj/nogui/%) $(CXX) $(xCXXFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) -obj/test/%.o: test/%.cpp +obj-test/%.o: test/%.cpp $(CXX) -c $(TESTDEFS) $(xCXXFLAGS) -MMD -o $@ $< @cp $(@:%.o=%.d) $(@:%.o=%.P); \ sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \ rm -f $(@:%.o=%.d) -test_bitcoin: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%)) +test_bitcoin: obj-test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%)) $(CXX) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-B$(LMODE) -lboost_unit_test_framework $(LDFLAGS) $(LIBS) clean: -rm -f bitcoind test_bitcoin -rm -f obj/*.o -rm -f obj/nogui/*.o - -rm -f obj/test/*.o + -rm -f obj-test/*.o -rm -f obj/*.P -rm -f obj/nogui/*.P - -rm -f obj/test/*.P + -rm -f obj-test/*.P diff --git a/src/obj-test/.gitignore b/src/obj-test/.gitignore new file mode 100644 index 0000000000..d6b7ef32c8 --- /dev/null +++ b/src/obj-test/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore -- cgit v1.2.3 From 22388eac08a4a543686c5402ca7ec22336e53468 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Mon, 23 Jan 2012 15:58:06 -0500 Subject: Support makefile.osx building test_bitcoin with dynamic boost --- src/makefile.osx | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/makefile.osx b/src/makefile.osx index de71887935..cbd51b049f 100644 --- a/src/makefile.osx +++ b/src/makefile.osx @@ -22,6 +22,8 @@ USE_UPNP:=1 LIBS= -dead_strip ifdef STATIC # Build STATIC if you are redistributing the bitcoind binary +TESTLIBS += \ + $(DEPSDIR)/lib/libboost_unit_test_framework-mt.a LIBS += \ $(DEPSDIR)/lib/db48/libdb_cxx-4.8.a \ $(DEPSDIR)/lib/libboost_system-mt.a \ @@ -29,8 +31,11 @@ LIBS += \ $(DEPSDIR)/lib/libboost_program_options-mt.a \ $(DEPSDIR)/lib/libboost_thread-mt.a \ $(DEPSDIR)/lib/libssl.a \ - $(DEPSDIR)/lib/libcrypto.a + $(DEPSDIR)/lib/libcrypto.a \ + -lz else +TESTLIBS += \ + -lboost_unit_test_framework-mt LIBS += \ -ldb_cxx-4.8 \ -lboost_system-mt \ @@ -38,7 +43,9 @@ LIBS += \ -lboost_program_options-mt \ -lboost_thread-mt \ -lssl \ - -lcrypto + -lcrypto \ + -lz +TESTDEFS += -DBOOST_TEST_DYN_LINK endif DEFS=-DMAC_OSX -DMSG_NOSIGNAL=0 -DUSE_SSL @@ -98,7 +105,7 @@ all: bitcoind # auto-generated dependencies: -include obj/nogui/*.P --include obj/test/*.P +-include obj-test/*.P obj/nogui/%.o: %.cpp $(CXX) -c $(CFLAGS) -MMD -o $@ $< @@ -111,20 +118,20 @@ bitcoind: $(OBJS:obj/%=obj/nogui/%) $(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) obj/test/%.o: test/%.cpp - $(CXX) -c $(CFLAGS) -MMD -o $@ $< + $(CXX) -c $(TESTDEFS) $(CFLAGS) -MMD -o $@ $< @cp $(@:%.o=%.d) $(@:%.o=%.P); \ sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \ rm -f $(@:%.o=%.d) test_bitcoin: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%)) - $(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) $(DEPSDIR)/lib/libboost_unit_test_framework-mt.a + $(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) $(TESTLIBS) clean: -rm -f bitcoind test_bitcoin -rm -f obj/*.o -rm -f obj/nogui/*.o - -rm -f obj/test/*.o + -rm -f obj-test/*.o -rm -f obj/*.P -rm -f obj/nogui/*.P - -rm -f obj/test/*.P + -rm -f obj-test/*.P -- cgit v1.2.3 From bccbc5f4c363692d3598c16614a875dc4cd6d389 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 7 Dec 2011 00:00:04 -0500 Subject: Automatically refocus on new SendCoinsEntrys and scroll to them. --- src/qt/sendcoinsdialog.cpp | 7 +++++++ src/qt/sendcoinsentry.cpp | 5 +++++ src/qt/sendcoinsentry.h | 2 ++ 3 files changed, 14 insertions(+) (limited to 'src') diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 762f27dfa6..6d32891172 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -11,6 +11,7 @@ #include #include #include +#include SendCoinsDialog::SendCoinsDialog(QWidget *parent) : QDialog(parent), @@ -188,6 +189,12 @@ SendCoinsEntry *SendCoinsDialog::addEntry() // Focus the field, so that entry can start immediately entry->clear(); + entry->setFocus(); + ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->sizeHint()); + QCoreApplication::instance()->processEvents(); + QScrollBar* bar = ui->scrollArea->verticalScrollBar(); + if (bar) + bar->setSliderPosition(bar->maximum()); return entry; } diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp index 23b11ccdde..ab5460f8c2 100644 --- a/src/qt/sendcoinsentry.cpp +++ b/src/qt/sendcoinsentry.cpp @@ -151,3 +151,8 @@ bool SendCoinsEntry::isClear() return ui->payTo->text().isEmpty(); } +void SendCoinsEntry::setFocus() +{ + ui->payTo->setFocus(); +} + diff --git a/src/qt/sendcoinsentry.h b/src/qt/sendcoinsentry.h index ccc223b5f5..2258706d59 100644 --- a/src/qt/sendcoinsentry.h +++ b/src/qt/sendcoinsentry.h @@ -30,6 +30,8 @@ public: // Hence we have to set it up manually QWidget *setupTabChain(QWidget *prev); + void setFocus(); + public slots: void setRemoveEnabled(bool enabled); void clear(); -- cgit v1.2.3 From edb563e8a5e6145cef6684e6e179b428a115ec62 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Mon, 5 Dec 2011 15:50:22 -0500 Subject: Testnet difficulty calculation changes, to take effect Feb 15 2012 Allow mining of min-difficulty blocks if 20 minutes have gone by without mining a regular-difficulty block. Normal rules apply every 2016 blocks, though, so there may be a very-slow-to-confirm block at the difficulty-adjustment blocks. --- src/main.cpp | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 03e133b63c..1c94090190 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -661,6 +661,11 @@ static const int64 nInterval = nTargetTimespan / nTargetSpacing; // unsigned int ComputeMinWork(unsigned int nBase, int64 nTime) { + // Testnet has min-difficulty blocks + // after nTargetSpacing*2 time between blocks: + if (fTestNet && nTime > nTargetSpacing*2) + return bnProofOfWorkLimit.GetCompact(); + CBigNum bnResult; bnResult.SetCompact(nBase); while (nTime > 0 && bnResult < bnProofOfWorkLimit) @@ -675,16 +680,36 @@ unsigned int ComputeMinWork(unsigned int nBase, int64 nTime) return bnResult.GetCompact(); } -unsigned int static GetNextWorkRequired(const CBlockIndex* pindexLast) +unsigned int static GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlock *pblock) { + unsigned int nProofOfWorkLimit = bnProofOfWorkLimit.GetCompact(); // Genesis block if (pindexLast == NULL) - return bnProofOfWorkLimit.GetCompact(); + return nProofOfWorkLimit; // Only change once per interval if ((pindexLast->nHeight+1) % nInterval != 0) + { + // Special rules for testnet after 15 Feb 2012: + if (fTestNet && pblock->nTime > 1329264000) + { + // If the new block's timestamp is more than 2* 10 minutes + // then allow mining of a min-difficulty block. + if (pblock->nTime - pindexLast->nTime > nTargetSpacing*2) + return nProofOfWorkLimit; + else + { + // Return the last non-special-min-difficulty-rules-block + const CBlockIndex* pindex = pindexLast; + while (pindex->pprev && pindex->nHeight % nInterval != 0 && pindex->nBits == nProofOfWorkLimit) + pindex = pindex->pprev; + return pindex->nBits; + } + } + return pindexLast->nBits; + } // Go back by what we want to be 14 days worth of blocks const CBlockIndex* pindexFirst = pindexLast; @@ -1289,7 +1314,7 @@ bool CBlock::AcceptBlock() int nHeight = pindexPrev->nHeight+1; // Check proof of work - if (nBits != GetNextWorkRequired(pindexPrev)) + if (nBits != GetNextWorkRequired(pindexPrev, this)) return error("AcceptBlock() : incorrect proof of work"); // Check timestamp against prev @@ -2812,7 +2837,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey) pblock->hashPrevBlock = pindexPrev->GetBlockHash(); pblock->hashMerkleRoot = pblock->BuildMerkleTree(); pblock->nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); - pblock->nBits = GetNextWorkRequired(pindexPrev); + pblock->nBits = GetNextWorkRequired(pindexPrev, pblock.get()); pblock->nNonce = 0; return pblock.release(); -- cgit v1.2.3 From e5b031f5d2a467fa28fbf7667101909a28e430bb Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 31 Jan 2012 17:36:25 -0500 Subject: Fix UPnP by reannouncing every 20 minutes. --- src/net.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/net.cpp b/src/net.cpp index b35a79deae..f995ea9c2a 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1105,11 +1105,11 @@ void ThreadMapPort2(void* parg) { string strDesc = "Bitcoin " + FormatFullVersion(); #ifndef UPNPDISCOVER_SUCCESS - /* miniupnpc 1.5 */ + /* miniupnpc 1.5 */ r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, port, port, lanaddr, strDesc.c_str(), "TCP", 0); #else - /* miniupnpc 1.6 */ + /* miniupnpc 1.6 */ r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, port, port, lanaddr, strDesc.c_str(), "TCP", 0, "0"); #endif @@ -1119,6 +1119,7 @@ void ThreadMapPort2(void* parg) port, port, lanaddr, r, strupnperror(r)); else printf("UPnP Port Mapping successful.\n"); + int i = 1; loop { if (fShutdown || !fUseUPnP) { @@ -1128,7 +1129,26 @@ void ThreadMapPort2(void* parg) FreeUPNPUrls(&urls); return; } + if (i % 600 == 0) // Refresh every 20 minutes + { +#ifndef UPNPDISCOVER_SUCCESS + /* miniupnpc 1.5 */ + r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, + port, port, lanaddr, strDesc.c_str(), "TCP", 0); +#else + /* miniupnpc 1.6 */ + r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, + port, port, lanaddr, strDesc.c_str(), "TCP", 0, "0"); +#endif + + if(r!=UPNPCOMMAND_SUCCESS) + printf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n", + port, port, lanaddr, r, strupnperror(r)); + else + printf("UPnP Port Mapping successful.\n");; + } Sleep(2000); + i++; } } else { printf("No valid UPnP IGDs found\n"); -- cgit v1.2.3 From 1b6d8f3fca6aef79ea0ccb26303d982d6da78cd1 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Wed, 1 Feb 2012 13:24:15 -0500 Subject: Allow -upnp to override setting in wallet (and simplify logic a bit) --- src/init.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/init.cpp b/src/init.cpp index d1332e0610..12e890cbb4 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -516,16 +516,11 @@ bool AppInit2(int argc, char* argv[]) fAllowDNS = GetBoolArg("-dns"); fNoListen = GetBoolArg("-nolisten"); - if (fHaveUPnP) - { -#if USE_UPNP - if (GetBoolArg("-noupnp")) - fUseUPnP = false; -#else - if (GetBoolArg("-upnp")) - fUseUPnP = true; -#endif - } + // Command-line args override in-wallet settings: + if (mapArgs.count("-upnp")) + fUseUPnP = GetBoolArg("-upnp"); + else if (mapArgs.count("-noupnp")) + fUseUPnP = !GetBoolArg("-noupnp"); if (!fNoListen) { -- cgit v1.2.3 From c1c6de6ad4f92c6628dccc271fe4c661e450d130 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Wed, 25 Jan 2012 03:05:16 +0100 Subject: Check consistency of private keys Reported by onlineproof on IRC: Bitcoin does not verify whether private keys and public keys correspond, when loading a wallet. --- src/db.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/db.cpp b/src/db.cpp index f9a7d6c90a..bd31bd7943 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -879,6 +879,8 @@ int CWalletDB::LoadWallet(CWallet* pwallet) CPrivKey pkey; ssValue >> pkey; key.SetPrivKey(pkey); + if (key.GetPubKey() != vchPubKey) + return DB_CORRUPT; } else { -- cgit v1.2.3 From c13d50d8617678c8696b1f33549ed9cc3a0b554e Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Tue, 17 Jan 2012 09:19:23 +0100 Subject: Revert to global progress indication (see #753) --- src/qt/bitcoingui.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 75d2a50a25..f80038c3fb 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -413,7 +413,6 @@ void BitcoinGUI::setNumBlocks(int count) { if(!clientModel) return; - int initTotal = clientModel->getNumBlocksAtStartup(); int total = clientModel->getNumBlocksOfPeers(); QString tooltip; @@ -424,8 +423,8 @@ void BitcoinGUI::setNumBlocks(int count) progressBarLabel->setVisible(true); progressBarLabel->setText(tr("Synchronizing with network...")); progressBar->setVisible(true); - progressBar->setMaximum(total - initTotal); - progressBar->setValue(count - initTotal); + progressBar->setMaximum(total); + progressBar->setValue(count); } else { -- cgit v1.2.3 From d841fc969a3a300ebeaa4279320235f2ff2b0533 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Thu, 26 Jan 2012 19:26:34 +0100 Subject: Full checking of all loaded keys --- src/db.cpp | 4 +++- src/key.h | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/db.cpp b/src/db.cpp index bd31bd7943..600afe383d 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -879,7 +879,7 @@ int CWalletDB::LoadWallet(CWallet* pwallet) CPrivKey pkey; ssValue >> pkey; key.SetPrivKey(pkey); - if (key.GetPubKey() != vchPubKey) + if (key.GetPubKey() != vchPubKey || !key.IsValid()) return DB_CORRUPT; } else @@ -887,6 +887,8 @@ int CWalletDB::LoadWallet(CWallet* pwallet) CWalletKey wkey; ssValue >> wkey; key.SetPrivKey(wkey.vchPrivKey); + if (key.GetPubKey() != vchPubKey || !key.IsValid()) + return DB_CORRUPT; } if (!pwallet->LoadKey(key)) return DB_CORRUPT; diff --git a/src/key.h b/src/key.h index d2e6689456..0d0b6d8bb4 100644 --- a/src/key.h +++ b/src/key.h @@ -233,6 +233,17 @@ public: { return CBitcoinAddress(GetPubKey()); } + + bool IsValid() + { + if (!fSet) + return false; + + CSecret secret = GetSecret(); + CKey key2; + key2.SetSecret(secret); + return GetPubKey() == key2.GetPubKey(); + } }; #endif -- cgit v1.2.3 From c11e2b8679e13f739a58faf2a3439d4aaed24364 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Wed, 18 Jan 2012 13:36:44 -0500 Subject: Only store transactions with missing inputs in the orphan pool. All previous versions of bitcoin could store some types of invalid transactions in the orphan-transaction list. --- src/main.cpp | 27 +++++++++++++++++++++------ src/main.h | 3 ++- 2 files changed, 23 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 1c94090190..dc8503d38f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -411,10 +411,11 @@ bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMi // Check against previous transactions map mapUnused; int64 nFees = 0; - if (!ConnectInputs(txdb, mapUnused, CDiskTxPos(1,1,1), pindexBest, nFees, false, false)) + bool fInvalid = false; + if (!ConnectInputs(txdb, mapUnused, CDiskTxPos(1,1,1), pindexBest, nFees, false, false, 0, fInvalid)) { - if (pfMissingInputs) - *pfMissingInputs = true; + if (fInvalid) + return error("AcceptToMemoryPool() : FetchInputs found invalid tx %s", hash.ToString().substr(0,10).c_str()); return error("AcceptToMemoryPool() : ConnectInputs failed %s", hash.ToString().substr(0,10).c_str()); } @@ -833,8 +834,15 @@ bool CTransaction::DisconnectInputs(CTxDB& txdb) bool CTransaction::ConnectInputs(CTxDB& txdb, map& mapTestPool, CDiskTxPos posThisTx, - CBlockIndex* pindexBlock, int64& nFees, bool fBlock, bool fMiner, int64 nMinFee) + CBlockIndex* pindexBlock, int64& nFees, bool fBlock, bool fMiner, int64 nMinFee, + bool& fInvalid) { + // FetchInputs can return false either because we just haven't seen some inputs + // (in which case the transaction should be stored as an orphan) + // or because the transaction is malformed (in which case the transaction should + // be dropped). If tx is definitely invalid, fInvalid will be set to true. + fInvalid = false; + // Take over previous transactions' spent pointers if (!IsCoinBase()) { @@ -881,7 +889,12 @@ bool CTransaction::ConnectInputs(CTxDB& txdb, map& mapTestPoo } if (prevout.n >= txPrev.vout.size() || prevout.n >= txindex.vSpent.size()) + { + // Revisit this if/when transaction replacement is implemented and allows + // adding inputs: + fInvalid = true; return error("ConnectInputs() : %s prevout.n out of range %d %d %d prev tx %s\n%s", GetHash().ToString().substr(0,10).c_str(), prevout.n, txPrev.vout.size(), txindex.vSpent.size(), prevout.hash.ToString().substr(0,10).c_str(), txPrev.ToString().c_str()); + } // If prev is coinbase, check that it's matured if (txPrev.IsCoinBase()) @@ -1025,7 +1038,8 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex) CDiskTxPos posThisTx(pindex->nFile, pindex->nBlockPos, nTxPos); nTxPos += ::GetSerializeSize(tx, SER_DISK); - if (!tx.ConnectInputs(txdb, mapQueuedChanges, posThisTx, pindex, nFees, true, false)) + bool fInvalid; + if (!tx.ConnectInputs(txdb, mapQueuedChanges, posThisTx, pindex, nFees, true, false, 0, fInvalid)) return false; } // Write queued txindex changes @@ -2806,7 +2820,8 @@ CBlock* CreateNewBlock(CReserveKey& reservekey) // Connecting shouldn't fail due to dependency on other memory pool transactions // because we're already processing them in order of dependency map mapTestPoolTmp(mapTestPool); - if (!tx.ConnectInputs(txdb, mapTestPoolTmp, CDiskTxPos(1,1,1), pindexPrev, nFees, false, true, nMinFee)) + bool fInvalid; + if (!tx.ConnectInputs(txdb, mapTestPoolTmp, CDiskTxPos(1,1,1), pindexPrev, nFees, false, true, nMinFee, fInvalid)) continue; swap(mapTestPool, mapTestPoolTmp); diff --git a/src/main.h b/src/main.h index 876a35d9cc..8a8b3870ec 100644 --- a/src/main.h +++ b/src/main.h @@ -631,7 +631,8 @@ public: bool ReadFromDisk(COutPoint prevout); bool DisconnectInputs(CTxDB& txdb); bool ConnectInputs(CTxDB& txdb, std::map& mapTestPool, CDiskTxPos posThisTx, - CBlockIndex* pindexBlock, int64& nFees, bool fBlock, bool fMiner, int64 nMinFee=0); + CBlockIndex* pindexBlock, int64& nFees, bool fBlock, bool fMiner, int64 nMinFee, + bool& fInvalid); bool ClientConnectInputs(); bool CheckTransaction() const; bool AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs=true, bool* pfMissingInputs=NULL); -- cgit v1.2.3