diff options
-rw-r--r-- | src/bitcoinrpc.cpp | 4 | ||||
-rw-r--r-- | src/db.cpp | 7 | ||||
-rw-r--r-- | src/db.h | 1 | ||||
-rw-r--r-- | src/init.cpp | 8 | ||||
-rw-r--r-- | src/leveldb/port/port_posix.h | 11 | ||||
-rw-r--r-- | src/main.cpp | 58 | ||||
-rw-r--r-- | src/main.h | 21 | ||||
-rw-r--r-- | src/net.h | 6 | ||||
-rw-r--r-- | src/protocol.cpp | 6 | ||||
-rw-r--r-- | src/protocol.h | 6 | ||||
-rw-r--r-- | src/qt/bitcoinstrings.cpp | 38 | ||||
-rw-r--r-- | src/qt/locale/bitcoin_en.ts | 424 | ||||
-rw-r--r-- | src/qt/rpcconsole.cpp | 5 | ||||
-rw-r--r-- | src/rpcrawtransaction.cpp | 2 | ||||
-rw-r--r-- | src/rpcwallet.cpp | 4 | ||||
-rw-r--r-- | src/script.cpp | 31 | ||||
-rw-r--r-- | src/script.h | 13 | ||||
-rw-r--r-- | src/test/DoS_tests.cpp | 11 | ||||
-rw-r--r-- | src/test/multisig_tests.cpp | 22 | ||||
-rw-r--r-- | src/test/script_P2SH_tests.cpp | 6 | ||||
-rw-r--r-- | src/test/script_tests.cpp | 34 | ||||
-rw-r--r-- | src/test/transaction_tests.cpp | 4 | ||||
-rw-r--r-- | src/wallet.cpp | 10 | ||||
-rw-r--r-- | src/wallet.h | 2 |
24 files changed, 415 insertions, 319 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 8c04f577d1..07b616438e 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -748,7 +748,8 @@ void ThreadRPCServer2(void* parg) printf("ThreadRPCServer started\n"); strRPCUserColonPass = mapArgs["-rpcuser"] + ":" + mapArgs["-rpcpassword"]; - if (mapArgs["-rpcpassword"] == "") + if ((mapArgs["-rpcpassword"] == "") || + (mapArgs["-rpcuser"] == mapArgs["-rpcpassword"])) { unsigned char rand_pwd[32]; RAND_bytes(rand_pwd, 32); @@ -763,6 +764,7 @@ void ThreadRPCServer2(void* parg) "rpcuser=bitcoinrpc\n" "rpcpassword=%s\n" "(you do not need to remember this password)\n" + "The username and password MUST NOT be the same.\n" "If the file does not exist, create it with owner-readable-only file permissions.\n"), strWhatAmI.c_str(), GetConfigFile().string().c_str(), diff --git a/src/db.cpp b/src/db.cpp index 60e1f6f280..94629f3cad 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -38,11 +38,13 @@ void CDBEnv::EnvShutdown() if (ret != 0) printf("EnvShutdown exception: %s (%d)\n", DbEnv::strerror(ret), ret); if (!fMockDb) - DbEnv(0).remove(GetDataDir().string().c_str(), 0); + DbEnv(0).remove(strPath.c_str(), 0); } CDBEnv::CDBEnv() : dbenv(DB_CXX_NO_EXCEPTIONS) { + fDbEnvInit = false; + fMockDb = false; } CDBEnv::~CDBEnv() @@ -63,6 +65,7 @@ bool CDBEnv::Open(const boost::filesystem::path& path) if (fShutdown) return false; + strPath = path.string(); filesystem::path pathLogDir = path / "database"; filesystem::create_directory(pathLogDir); filesystem::path pathErrorFile = path / "db.log"; @@ -83,7 +86,7 @@ bool CDBEnv::Open(const boost::filesystem::path& path) dbenv.set_flags(DB_AUTO_COMMIT, 1); dbenv.set_flags(DB_TXN_WRITE_NOSYNC, 1); dbenv.log_set_config(DB_LOG_AUTO_REMOVE, 1); - int ret = dbenv.open(path.string().c_str(), + int ret = dbenv.open(strPath.c_str(), DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG | @@ -33,6 +33,7 @@ class CDBEnv private: bool fDbEnvInit; bool fMockDb; + std::string strPath; void EnvShutdown(); diff --git a/src/init.cpp b/src/init.cpp index f6df4055fc..06f7359f80 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -28,9 +28,9 @@ CClientUIInterface uiInterface; // Used to pass flags to the Bind() function enum BindFlags { - BF_NONE = 0, - BF_EXPLICIT = 1, - BF_REPORT_ERROR = 2 + BF_NONE = 0, + BF_EXPLICIT = (1U << 0), + BF_REPORT_ERROR = (1U << 1) }; ////////////////////////////////////////////////////////////////////////////// @@ -220,7 +220,7 @@ bool static InitWarning(const std::string &str) } -bool static Bind(const CService &addr, int flags) { +bool static Bind(const CService &addr, unsigned int flags) { if (!(flags & BF_EXPLICIT) && IsLimited(addr)) return false; std::string strError; diff --git a/src/leveldb/port/port_posix.h b/src/leveldb/port/port_posix.h index 654a4b9d3d..6ca352e2ca 100644 --- a/src/leveldb/port/port_posix.h +++ b/src/leveldb/port/port_posix.h @@ -21,13 +21,20 @@ #else #define PLATFORM_IS_LITTLE_ENDIAN false #endif -#elif defined(OS_FREEBSD) || defined(OS_OPENBSD) || defined(OS_NETBSD) ||\ +#elif defined(OS_FREEBSD) + #include <sys/types.h> + #include <sys/endian.h> + #define PLATFORM_IS_LITTLE_ENDIAN (_BYTE_ORDER == _LITTLE_ENDIAN) +#elif defined(OS_OPENBSD) || defined(OS_NETBSD) ||\ defined(OS_DRAGONFLYBSD) || defined(OS_ANDROID) #include <sys/types.h> #include <sys/endian.h> +#elif defined(OS_HPUX) + #define PLATFORM_IS_LITTLE_ENDIAN false #else #include <endian.h> #endif + #include <pthread.h> #ifdef SNAPPY #include <snappy.h> @@ -42,7 +49,7 @@ #if defined(OS_MACOSX) || defined(OS_SOLARIS) || defined(OS_FREEBSD) ||\ defined(OS_NETBSD) || defined(OS_OPENBSD) || defined(OS_DRAGONFLYBSD) ||\ - defined(OS_ANDROID) + defined(OS_ANDROID) || defined(OS_HPUX) // Use fread/fwrite/fflush on platforms without _unlocked variants #define fread_unlocked fread #define fwrite_unlocked fwrite diff --git a/src/main.cpp b/src/main.cpp index a75baf749f..4c2115688a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -719,7 +719,7 @@ bool CTxMemPool::accept(CTransaction &tx, bool fCheckInputs, // are the actual inputs available? if (!tx.HaveInputs(view)) return error("CTxMemPool::accept() : inputs already spent"); - + // Bring the best block into scope view.GetBestBlock(); @@ -771,7 +771,7 @@ bool CTxMemPool::accept(CTransaction &tx, bool fCheckInputs, // Check against previous transactions // This is done last to help prevent CPU exhaustion denial-of-service attacks. - if (!tx.CheckInputs(view, CS_ALWAYS, true, false)) + if (!tx.CheckInputs(view, CS_ALWAYS, SCRIPT_VERIFY_P2SH)) { return error("CTxMemPool::accept() : ConnectInputs failed %s", hash.ToString().substr(0,10).c_str()); } @@ -1163,11 +1163,11 @@ void static InvalidChainFound(CBlockIndex* pindexNew) uiInterface.NotifyBlocksChanged(); } printf("InvalidChainFound: invalid block=%s height=%d work=%s date=%s\n", - pindexNew->GetBlockHash().ToString().substr(0,20).c_str(), pindexNew->nHeight, + BlockHashStr(pindexNew->GetBlockHash()).c_str(), pindexNew->nHeight, pindexNew->bnChainWork.ToString().c_str(), DateTimeStrFormat("%x %H:%M:%S", pindexNew->GetBlockTime()).c_str()); printf("InvalidChainFound: current best=%s height=%d work=%s date=%s\n", - hashBestChain.ToString().substr(0,20).c_str(), nBestHeight, bnBestChainWork.ToString().c_str(), + BlockHashStr(hashBestChain).c_str(), nBestHeight, bnBestChainWork.ToString().c_str(), DateTimeStrFormat("%x %H:%M:%S", pindexBest->GetBlockTime()).c_str()); if (pindexBest && bnBestInvalidWork > bnBestChainWork + pindexBest->GetBlockWork() * 6) printf("InvalidChainFound: Warning: Displayed transactions may not be correct! You may need to upgrade, or other nodes may need to upgrade.\n"); @@ -1193,7 +1193,7 @@ bool ConnectBestBlock() { pindexNewBest = *it; } - if (pindexNewBest == pindexBest) + if (pindexNewBest == pindexBest || (pindexBest && pindexNewBest->bnChainWork == pindexBest->bnChainWork)) return true; // nothing to do // check ancestry @@ -1322,7 +1322,7 @@ bool CTransaction::HaveInputs(CCoinsViewCache &inputs) const return true; } -bool CTransaction::CheckInputs(CCoinsViewCache &inputs, enum CheckSig_mode csmode, bool fStrictPayToScriptHash, bool fStrictEncodings) const +bool CTransaction::CheckInputs(CCoinsViewCache &inputs, enum CheckSig_mode csmode, unsigned int flags) const { if (!IsCoinBase()) { @@ -1333,7 +1333,7 @@ bool CTransaction::CheckInputs(CCoinsViewCache &inputs, enum CheckSig_mode csmod // While checking, GetBestBlock() refers to the parent block. // This is also true for mempool checks. - int nSpendHeight = inputs.GetBestBlock()->nHeight + 1; + int nSpendHeight = inputs.GetBestBlock()->nHeight + 1; int64 nValueIn = 0; int64 nFees = 0; for (unsigned int i = 0; i < vin.size(); i++) @@ -1379,7 +1379,7 @@ bool CTransaction::CheckInputs(CCoinsViewCache &inputs, enum CheckSig_mode csmod const CCoins &coins = inputs.GetCoins(prevout.hash); // Verify signature - if (!VerifySignature(coins, *this, i, fStrictPayToScriptHash, fStrictEncodings, 0)) + if (!VerifySignature(coins, *this, i, flags, 0)) return DoS(100,error("CheckInputs() : %s VerifySignature failed", GetHash().ToString().substr(0,10).c_str())); } } @@ -1410,7 +1410,7 @@ bool CTransaction::ClientCheckInputs() const return false; // Verify signature - if (!VerifySignature(CCoins(txPrev, -1), *this, i, true, false, 0)) + if (!VerifySignature(CCoins(txPrev, -1), *this, i, SCRIPT_VERIFY_P2SH, 0)) return error("ConnectInputs() : VerifySignature failed"); ///// this is redundant with the mempool.mapNextTx stuff, @@ -1593,7 +1593,7 @@ bool CBlock::ConnectBlock(CBlockIndex* pindex, CCoinsViewCache &view, bool fJust nFees += tx.GetValueIn(view)-tx.GetValueOut(); - if (!tx.CheckInputs(view, CS_AFTER_CHECKPOINT, fStrictPayToScriptHash, false)) + if (!tx.CheckInputs(view, CS_AFTER_CHECKPOINT, fStrictPayToScriptHash ? SCRIPT_VERIFY_P2SH : SCRIPT_VERIFY_NONE)) return false; } @@ -1605,7 +1605,7 @@ bool CBlock::ConnectBlock(CBlockIndex* pindex, CCoinsViewCache &view, bool fJust } if (vtx[0].GetValueOut() > GetBlockValue(pindex->nHeight, nFees)) - return false; + return error("ConnectBlock() : coinbase pays too much (actual=%"PRI64d" vs limit=%"PRI64d")", vtx[0].GetValueOut(), GetBlockValue(pindex->nHeight, nFees)); if (fJustCheck) return true; @@ -1688,8 +1688,8 @@ bool SetBestChain(CBlockIndex* pindexNew) reverse(vConnect.begin(), vConnect.end()); if (vDisconnect.size() > 0) { - printf("REORGANIZE: Disconnect %"PRIszu" blocks; %s..%s\n", vDisconnect.size(), pfork->GetBlockHash().ToString().substr(0,20).c_str(), pindexBest->GetBlockHash().ToString().substr(0,20).c_str()); - printf("REORGANIZE: Connect %"PRIszu" blocks; %s..%s\n", vConnect.size(), pfork->GetBlockHash().ToString().substr(0,20).c_str(), pindexNew->GetBlockHash().ToString().substr(0,20).c_str()); + printf("REORGANIZE: Disconnect %"PRIszu" blocks; %s..%s\n", vDisconnect.size(), BlockHashStr(pfork->GetBlockHash()).c_str(), BlockHashStr(pindexBest->GetBlockHash()).c_str()); + printf("REORGANIZE: Connect %"PRIszu" blocks; %s..%s\n", vConnect.size(), BlockHashStr(pfork->GetBlockHash()).c_str(), BlockHashStr(pindexNew->GetBlockHash()).c_str()); } // Disconnect shorter branch @@ -1700,7 +1700,7 @@ bool SetBestChain(CBlockIndex* pindexNew) return error("SetBestBlock() : ReadFromDisk for disconnect failed"); CCoinsViewCache viewTemp(view, true); if (!block.DisconnectBlock(pindex, viewTemp)) - return error("SetBestBlock() : DisconnectBlock %s failed", pindex->GetBlockHash().ToString().substr(0,20).c_str()); + return error("SetBestBlock() : DisconnectBlock %s failed", BlockHashStr(pindex->GetBlockHash()).c_str()); if (!viewTemp.Flush()) return error("SetBestBlock() : Cache flush failed after disconnect"); @@ -1720,7 +1720,7 @@ bool SetBestChain(CBlockIndex* pindexNew) if (!block.ConnectBlock(pindex, viewTemp)) { InvalidChainFound(pindexNew); InvalidBlockFound(pindex); - return error("SetBestBlock() : ConnectBlock %s failed", pindex->GetBlockHash().ToString().substr(0,20).c_str()); + return error("SetBestBlock() : ConnectBlock %s failed", BlockHashStr(pindex->GetBlockHash()).c_str()); } if (!viewTemp.Flush()) return error("SetBestBlock() : Cache flush failed after connect"); @@ -1776,7 +1776,7 @@ bool SetBestChain(CBlockIndex* pindexNew) nTimeBestReceived = GetTime(); nTransactionsUpdated++; printf("SetBestChain: new best=%s height=%d work=%s tx=%lu date=%s\n", - hashBestChain.ToString().substr(0,20).c_str(), nBestHeight, bnBestChainWork.ToString().c_str(), (unsigned long)pindexNew->nChainTx, + BlockHashStr(hashBestChain).c_str(), nBestHeight, bnBestChainWork.ToString().c_str(), (unsigned long)pindexNew->nChainTx, DateTimeStrFormat("%x %H:%M:%S", pindexBest->GetBlockTime()).c_str()); // Check the version of the last 100 blocks to see if we need to upgrade: @@ -1814,7 +1814,7 @@ bool CBlock::AddToBlockIndex(const CDiskBlockPos &pos) // Check for duplicate uint256 hash = GetHash(); if (mapBlockIndex.count(hash)) - return error("AddToBlockIndex() : %s already exists", hash.ToString().substr(0,20).c_str()); + return error("AddToBlockIndex() : %s already exists", BlockHashStr(hash).c_str()); // Construct new block index object CBlockIndex* pindexNew = new CBlockIndex(*this); @@ -1894,8 +1894,8 @@ bool FindBlockPos(CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeigh if (file) { printf("Pre-allocating up to position 0x%x in blk%05u.dat\n", nNewChunks * BLOCKFILE_CHUNK_SIZE, pos.nFile); AllocateFileRange(file, pos.nPos, nNewChunks * BLOCKFILE_CHUNK_SIZE - pos.nPos); + fclose(file); } - fclose(file); } } @@ -1936,8 +1936,8 @@ bool FindUndoPos(int nFile, CDiskBlockPos &pos, unsigned int nAddSize) if (file) { printf("Pre-allocating up to position 0x%x in rev%05u.dat\n", nNewChunks * UNDOFILE_CHUNK_SIZE, pos.nFile); AllocateFileRange(file, pos.nPos, nNewChunks * UNDOFILE_CHUNK_SIZE - pos.nPos); + fclose(file); } - fclose(file); } return true; @@ -2106,9 +2106,9 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock, CDiskBlockPos *dbp) // Check for duplicate uint256 hash = pblock->GetHash(); if (mapBlockIndex.count(hash)) - return error("ProcessBlock() : already have block %d %s", mapBlockIndex[hash]->nHeight, hash.ToString().substr(0,20).c_str()); + return error("ProcessBlock() : already have block %d %s", mapBlockIndex[hash]->nHeight, BlockHashStr(hash).c_str()); if (mapOrphanBlocks.count(hash)) - return error("ProcessBlock() : already have block (orphan) %s", hash.ToString().substr(0,20).c_str()); + return error("ProcessBlock() : already have block (orphan) %s", BlockHashStr(hash).c_str()); // Preliminary checks if (!pblock->CheckBlock()) @@ -2141,7 +2141,7 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock, CDiskBlockPos *dbp) // If we don't already have its previous block, shunt it off to holding area until we get it if (pblock->hashPrevBlock != 0 && !mapBlockIndex.count(pblock->hashPrevBlock)) { - printf("ProcessBlock: ORPHAN BLOCK, prev=%s\n", pblock->hashPrevBlock.ToString().substr(0,20).c_str()); + printf("ProcessBlock: ORPHAN BLOCK, prev=%s\n", BlockHashStr(pblock->hashPrevBlock).c_str()); // Accept orphans as long as there is a node to request its parents from if (pfrom) { @@ -2313,7 +2313,7 @@ bool static LoadBlockIndexDB() pindex = pindexPrev; } printf("LoadBlockIndex(): hashBestChain=%s height=%d date=%s\n", - hashBestChain.ToString().substr(0,20).c_str(), nBestHeight, + BlockHashStr(hashBestChain).c_str(), nBestHeight, DateTimeStrFormat("%x %H:%M:%S", pindexBest->GetBlockTime()).c_str()); // Load bnBestInvalidWork, OK if it doesn't exist @@ -3023,12 +3023,12 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) if (pindex) pindex = pindex->pnext; int nLimit = 500; - printf("getblocks %d to %s limit %d\n", (pindex ? pindex->nHeight : -1), hashStop.ToString().substr(0,20).c_str(), nLimit); + printf("getblocks %d to %s limit %d\n", (pindex ? pindex->nHeight : -1), BlockHashStr(hashStop).c_str(), nLimit); for (; pindex; pindex = pindex->pnext) { if (pindex->GetBlockHash() == hashStop) { - printf(" getblocks stopping at %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString().substr(0,20).c_str()); + printf(" getblocks stopping at %d %s\n", pindex->nHeight, BlockHashStr(pindex->GetBlockHash()).c_str()); break; } pfrom->PushInventory(CInv(MSG_BLOCK, pindex->GetBlockHash())); @@ -3036,7 +3036,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) { // When this block is requested, we'll send an inv that'll make them // getblocks the next batch of inventory. - printf(" getblocks stopping at limit %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString().substr(0,20).c_str()); + printf(" getblocks stopping at limit %d %s\n", pindex->nHeight, BlockHashStr(pindex->GetBlockHash()).c_str()); pfrom->hashContinue = pindex->GetBlockHash(); break; } @@ -3070,7 +3070,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) // we must use CBlocks, as CBlockHeaders won't include the 0x00 nTx count at the end vector<CBlock> vHeaders; int nLimit = 2000; - printf("getheaders %d to %s\n", (pindex ? pindex->nHeight : -1), hashStop.ToString().substr(0,20).c_str()); + printf("getheaders %d to %s\n", (pindex ? pindex->nHeight : -1), BlockHashStr(hashStop).c_str()); for (; pindex; pindex = pindex->pnext) { vHeaders.push_back(pindex->GetBlockHeader()); @@ -3154,7 +3154,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) CBlock block; vRecv >> block; - printf("received block %s\n", block.GetHash().ToString().substr(0,20).c_str()); + printf("received block %s\n", BlockHashStr(block.GetHash()).c_str()); // block.print(); CInv inv(MSG_BLOCK, block.GetHash()); @@ -3859,7 +3859,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey) if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS) continue; - if (!tx.CheckInputs(viewTemp, CS_ALWAYS, true, false)) + if (!tx.CheckInputs(viewTemp, CS_ALWAYS, SCRIPT_VERIFY_P2SH)) continue; CTxUndo txundo; diff --git a/src/main.h b/src/main.h index 994d0bfb6c..a5f60fe945 100644 --- a/src/main.h +++ b/src/main.h @@ -174,6 +174,11 @@ CBlockIndex * InsertBlockIndex(uint256 hash); +static inline std::string BlockHashStr(const uint256& hash) +{ + return hash.ToString(); +} + bool GetWalletFile(CWallet* pwallet, std::string &strWalletFileOut); class CDiskBlockPos @@ -625,7 +630,7 @@ public: // Check whether all inputs of this transaction are valid (no double spends, scripts & sigs, amounts) // This does not modify the UTXO set - bool CheckInputs(CCoinsViewCache &view, enum CheckSig_mode csmode, bool fStrictPayToScriptHash=true, bool fStrictEncodings=true) const; + bool CheckInputs(CCoinsViewCache &view, enum CheckSig_mode csmode, unsigned int flags = SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC) const; // Apply the effects of this transaction on the UTXO set represented by view bool UpdateCoins(CCoinsViewCache &view, CTxUndo &txundo, int nHeight, const uint256 &txhash) const; @@ -733,7 +738,6 @@ public: bool WriteToDisk(CDiskBlockPos &pos) { - // Open history file to append CAutoFile fileout = CAutoFile(OpenUndoFile(pos), SER_DISK, CLIENT_VERSION); if (!fileout) @@ -746,7 +750,7 @@ public: // Write undo data long fileOutPos = ftell(fileout); if (fileOutPos < 0) - return error("CBlock::WriteToDisk() : ftell failed"); + return error("CBlockUndo::WriteToDisk() : ftell failed"); pos.nPos = (unsigned int)fileOutPos; fileout << *this; @@ -757,7 +761,6 @@ public: return true; } - }; /** pruned version of CTransaction: only retains metadata and unspent transaction outputs @@ -1274,9 +1277,9 @@ public: void print() const { printf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%"PRIszu")\n", - GetHash().ToString().substr(0,20).c_str(), + BlockHashStr(GetHash()).c_str(), nVersion, - hashPrevBlock.ToString().substr(0,20).c_str(), + BlockHashStr(hashPrevBlock).c_str(), hashMerkleRoot.ToString().substr(0,10).c_str(), nTime, nBits, nNonce, vtx.size()); @@ -1587,7 +1590,7 @@ public: return strprintf("CBlockIndex(pprev=%p, pnext=%p, nHeight=%d, merkle=%s, hashBlock=%s)", pprev, pnext, nHeight, hashMerkleRoot.ToString().substr(0,10).c_str(), - GetBlockHash().ToString().substr(0,20).c_str()); + BlockHashStr(GetBlockHash()).c_str()); } void print() const @@ -1668,7 +1671,7 @@ public: str += CBlockIndex::ToString(); str += strprintf("\n hashBlock=%s, hashPrev=%s)", GetBlockHash().ToString().c_str(), - hashPrev.ToString().substr(0,20).c_str()); + BlockHashStr(hashPrev).c_str()); return str; } @@ -1889,7 +1892,7 @@ public: virtual bool GetStats(CCoinsStats &stats); // As we use CCoinsViews polymorphically, have a virtual destructor - virtual ~CCoinsView() {}; + virtual ~CCoinsView() {} }; /** CCoinsView backed by another CCoinsView */ @@ -67,12 +67,6 @@ void SetReachable(enum Network net, bool fFlag = true); CAddress GetLocalAddress(const CNetAddr *paddrPeer = NULL); -enum -{ - MSG_TX = 1, - MSG_BLOCK, -}; - /** Thread types */ enum threadId { diff --git a/src/protocol.cpp b/src/protocol.cpp index d6e340e366..23969e5b97 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -6,6 +6,7 @@ #include "protocol.h" #include "util.h" #include "netbase.h" +#include "main.h" #ifndef WIN32 # include <arpa/inet.h> @@ -140,6 +141,11 @@ const char* CInv::GetCommand() const std::string CInv::ToString() const { + if (type == MSG_BLOCK) + return strprintf("%s %s", GetCommand(), BlockHashStr(hash).c_str()); + if (type == MSG_TX) + return strprintf("%s %s", GetCommand(), hash.ToString().substr(0,10).c_str()); + return strprintf("%s %s", GetCommand(), hash.ToString().substr(0,20).c_str()); } diff --git a/src/protocol.h b/src/protocol.h index 36f8b144cd..96fd197ecd 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -134,4 +134,10 @@ class CInv uint256 hash; }; +enum +{ + MSG_TX = 1, + MSG_BLOCK, +}; + #endif // __INCLUDED_PROTOCOL_H__ diff --git a/src/qt/bitcoinstrings.cpp b/src/qt/bitcoinstrings.cpp index 7e8e102ee7..497c05976b 100644 --- a/src/qt/bitcoinstrings.cpp +++ b/src/qt/bitcoinstrings.cpp @@ -13,26 +13,33 @@ QT_TRANSLATE_NOOP("bitcoin-core", "" "rpcuser=bitcoinrpc\n" "rpcpassword=%s\n" "(you do not need to remember this password)\n" +"The username and password MUST NOT be the same.\n" "If the file does not exist, create it with owner-readable-only file " "permissions.\n"), QT_TRANSLATE_NOOP("bitcoin-core", "" "Acceptable ciphers (default: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:" "@STRENGTH)"), QT_TRANSLATE_NOOP("bitcoin-core", "" +"An error occurred while setting up the RPC port %u for listening on IPv4: %s"), +QT_TRANSLATE_NOOP("bitcoin-core", "" "An error occurred while setting up the RPC port %u for listening on IPv6, " "falling back to IPv4: %s"), QT_TRANSLATE_NOOP("bitcoin-core", "" -"An error occurred while setting up the RPC port %u for listening on IPv4: %s"), +"Bind to given address and always listen on it. Use [host]:port notation for " +"IPv6"), QT_TRANSLATE_NOOP("bitcoin-core", "" -"Cannot obtain a lock on data directory %s. Bitcoin is probably already " +"Cannot obtain a lock on data directory %s. Bitcoin is probably already " "running."), QT_TRANSLATE_NOOP("bitcoin-core", "" -"Error: The transaction was rejected. This might happen if some of the coins " +"Error initializing database environment %s! To recover, BACKUP THAT " +"DIRECTORY, then remove everything from it except for wallet.dat."), +QT_TRANSLATE_NOOP("bitcoin-core", "" +"Error: The transaction was rejected! This might happen if some of the coins " "in your wallet were already spent, such as if you used a copy of wallet.dat " "and coins were spent in the copy but not marked as spent here."), QT_TRANSLATE_NOOP("bitcoin-core", "" "Error: This transaction requires a transaction fee of at least %s because of " -"its amount, complexity, or use of recently received funds "), +"its amount, complexity, or use of recently received funds!"), QT_TRANSLATE_NOOP("bitcoin-core", "" "Execute command when the best block changes (%s in cmd is replaced by block " "hash)"), @@ -45,6 +52,9 @@ QT_TRANSLATE_NOOP("bitcoin-core", "" "Set maximum size of high-priority/low-fee transactions in bytes (default: " "27000)"), QT_TRANSLATE_NOOP("bitcoin-core", "" +"This is a pre-release test build - use at your own risk - do not use for " +"mining or merchant applications"), +QT_TRANSLATE_NOOP("bitcoin-core", "" "Unable to bind to %s on this computer. Bitcoin is probably already running."), QT_TRANSLATE_NOOP("bitcoin-core", "" "Warning: -paytxfee is set very high! This is the transaction fee you will " @@ -56,6 +66,13 @@ QT_TRANSLATE_NOOP("bitcoin-core", "" "Warning: Please check that your computer's date and time are correct! If " "your clock is wrong Bitcoin will not work properly."), QT_TRANSLATE_NOOP("bitcoin-core", "" +"Warning: error reading wallet.dat! All keys read correctly, but transaction " +"data or address book entries might be missing or incorrect."), +QT_TRANSLATE_NOOP("bitcoin-core", "" +"Warning: wallet.dat corrupt, data salvaged! Original wallet.dat saved as " +"wallet.{timestamp}.bak in %s; if your balance or transactions are incorrect " +"you should restore from a backup."), +QT_TRANSLATE_NOOP("bitcoin-core", "" "You must set rpcpassword=<password> in the configuration file:\n" "%s\n" "If the file does not exist, create it with owner-readable-only file " @@ -65,7 +82,7 @@ QT_TRANSLATE_NOOP("bitcoin-core", "Accept connections from outside (default: 1 i QT_TRANSLATE_NOOP("bitcoin-core", "Add a node to connect to and attempt to keep the connection open"), QT_TRANSLATE_NOOP("bitcoin-core", "Allow DNS lookups for -addnode, -seednode and -connect"), QT_TRANSLATE_NOOP("bitcoin-core", "Allow JSON-RPC connections from specified IP address"), -QT_TRANSLATE_NOOP("bitcoin-core", "Bind to given address. Use [host]:port notation for IPv6"), +QT_TRANSLATE_NOOP("bitcoin-core", "Attempt to recover private keys from a corrupt wallet.dat"), QT_TRANSLATE_NOOP("bitcoin-core", "Bitcoin version"), QT_TRANSLATE_NOOP("bitcoin-core", "Bitcoin"), QT_TRANSLATE_NOOP("bitcoin-core", "Block creation options:"), @@ -85,8 +102,8 @@ QT_TRANSLATE_NOOP("bitcoin-core", "Error loading wallet.dat"), QT_TRANSLATE_NOOP("bitcoin-core", "Error loading wallet.dat: Wallet corrupted"), QT_TRANSLATE_NOOP("bitcoin-core", "Error loading wallet.dat: Wallet requires newer version of Bitcoin"), QT_TRANSLATE_NOOP("bitcoin-core", "Error"), -QT_TRANSLATE_NOOP("bitcoin-core", "Error: Transaction creation failed "), -QT_TRANSLATE_NOOP("bitcoin-core", "Error: Wallet locked, unable to create transaction "), +QT_TRANSLATE_NOOP("bitcoin-core", "Error: Transaction creation failed!"), +QT_TRANSLATE_NOOP("bitcoin-core", "Error: Wallet locked, unable to create transaction!"), QT_TRANSLATE_NOOP("bitcoin-core", "Error: could not start node"), QT_TRANSLATE_NOOP("bitcoin-core", "Failed to listen on any port. Use -listen=0 if you want this."), QT_TRANSLATE_NOOP("bitcoin-core", "Fee per KB to add to transactions you send"), @@ -96,8 +113,7 @@ QT_TRANSLATE_NOOP("bitcoin-core", "Generate coins"), QT_TRANSLATE_NOOP("bitcoin-core", "Get help for a command"), QT_TRANSLATE_NOOP("bitcoin-core", "How many blocks to check at startup (default: 2500, 0 = all)"), QT_TRANSLATE_NOOP("bitcoin-core", "How thorough the block verification is (0-6, default: 1)"), -QT_TRANSLATE_NOOP("bitcoin-core", "Importing blockchain data file."), -QT_TRANSLATE_NOOP("bitcoin-core", "Importing bootstrap blockchain data file."), +QT_TRANSLATE_NOOP("bitcoin-core", "Importing blocks from block database..."), QT_TRANSLATE_NOOP("bitcoin-core", "Imports blocks from external blk000?.dat file"), QT_TRANSLATE_NOOP("bitcoin-core", "Insufficient funds"), QT_TRANSLATE_NOOP("bitcoin-core", "Invalid -proxy address: '%s'"), @@ -118,6 +134,7 @@ QT_TRANSLATE_NOOP("bitcoin-core", "Output extra debugging information. Implies a QT_TRANSLATE_NOOP("bitcoin-core", "Output extra network debugging information"), QT_TRANSLATE_NOOP("bitcoin-core", "Password for JSON-RPC connections"), QT_TRANSLATE_NOOP("bitcoin-core", "Prepend debug output with timestamp"), +QT_TRANSLATE_NOOP("bitcoin-core", "Rebuild blockchain index from current blk000??.dat files"), QT_TRANSLATE_NOOP("bitcoin-core", "Rescan the block chain for missing wallet transactions"), QT_TRANSLATE_NOOP("bitcoin-core", "Rescanning..."), QT_TRANSLATE_NOOP("bitcoin-core", "Run in the background as a daemon and accept commands"), @@ -131,7 +148,6 @@ QT_TRANSLATE_NOOP("bitcoin-core", "Sending..."), QT_TRANSLATE_NOOP("bitcoin-core", "Server certificate file (default: server.cert)"), QT_TRANSLATE_NOOP("bitcoin-core", "Server private key (default: server.pem)"), QT_TRANSLATE_NOOP("bitcoin-core", "Set database cache size in megabytes (default: 25)"), -QT_TRANSLATE_NOOP("bitcoin-core", "Set database disk log size in megabytes (default: 100)"), QT_TRANSLATE_NOOP("bitcoin-core", "Set key pool size to <n> (default: 100)"), QT_TRANSLATE_NOOP("bitcoin-core", "Set maximum block size in bytes (default: 250000)"), QT_TRANSLATE_NOOP("bitcoin-core", "Set minimum block size in bytes (default: 0)"), @@ -155,7 +171,9 @@ QT_TRANSLATE_NOOP("bitcoin-core", "Use UPnP to map the listening port (default: QT_TRANSLATE_NOOP("bitcoin-core", "Use proxy to reach tor hidden services (default: same as -proxy)"), QT_TRANSLATE_NOOP("bitcoin-core", "Use the test network"), QT_TRANSLATE_NOOP("bitcoin-core", "Username for JSON-RPC connections"), +QT_TRANSLATE_NOOP("bitcoin-core", "Verifying database integrity..."), QT_TRANSLATE_NOOP("bitcoin-core", "Wallet needed to be rewritten: restart Bitcoin to complete"), QT_TRANSLATE_NOOP("bitcoin-core", "Warning: Disk space is low!"), QT_TRANSLATE_NOOP("bitcoin-core", "Warning: This version is obsolete, upgrade required!"), +QT_TRANSLATE_NOOP("bitcoin-core", "wallet.dat corrupt, salvage failed"), };
\ No newline at end of file diff --git a/src/qt/locale/bitcoin_en.ts b/src/qt/locale/bitcoin_en.ts index ee9967e15d..c70ea652de 100644 --- a/src/qt/locale/bitcoin_en.ts +++ b/src/qt/locale/bitcoin_en.ts @@ -300,17 +300,17 @@ This product includes software developed by the OpenSSL Project for use in the O <context> <name>BitcoinGUI</name> <message> - <location filename="../bitcoingui.cpp" line="+257"/> + <location filename="../bitcoingui.cpp" line="+266"/> <source>Sign &message...</source> <translation>Sign &message...</translation> </message> <message> - <location line="+237"/> + <location line="+241"/> <source>Synchronizing with network...</source> <translation>Synchronizing with network...</translation> </message> <message> - <location line="-299"/> + <location line="-309"/> <source>&Overview</source> <translation>&Overview</translation> </message> @@ -320,7 +320,7 @@ This product includes software developed by the OpenSSL Project for use in the O <translation>Show general overview of wallet</translation> </message> <message> - <location line="+17"/> + <location line="+20"/> <source>&Transactions</source> <translation>&Transactions</translation> </message> @@ -330,7 +330,7 @@ This product includes software developed by the OpenSSL Project for use in the O <translation>Browse transaction history</translation> </message> <message> - <location line="+5"/> + <location line="+6"/> <source>&Address Book</source> <translation>&Address Book</translation> </message> @@ -340,7 +340,7 @@ This product includes software developed by the OpenSSL Project for use in the O <translation>Edit the list of stored addresses and labels</translation> </message> <message> - <location line="-13"/> + <location line="-15"/> <source>&Receive coins</source> <translation>&Receive coins</translation> </message> @@ -350,12 +350,12 @@ This product includes software developed by the OpenSSL Project for use in the O <translation>Show the list of addresses for receiving payments</translation> </message> <message> - <location line="-7"/> + <location line="-8"/> <source>&Send coins</source> <translation>&Send coins</translation> </message> <message> - <location line="+35"/> + <location line="+39"/> <source>E&xit</source> <translation>E&xit</translation> </message> @@ -385,7 +385,7 @@ This product includes software developed by the OpenSSL Project for use in the O <translation>&Options...</translation> </message> <message> - <location line="+4"/> + <location line="+5"/> <source>&Encrypt Wallet...</source> <translation>&Encrypt Wallet...</translation> </message> @@ -399,8 +399,18 @@ This product includes software developed by the OpenSSL Project for use in the O <source>&Change Passphrase...</source> <translation>&Change Passphrase...</translation> </message> + <message> + <location line="+246"/> + <source>Importing blocks from disk...</source> + <translation>Importing blocks from disk...</translation> + </message> + <message> + <location line="+3"/> + <source>Reindexing blocks on disk...</source> + <translation>Reindexing blocks on disk...</translation> + </message> <message numerus="yes"> - <location line="+241"/> + <location line="+10"/> <source>~%n block(s) remaining</source> <translation> <numerusform>~%n block remaining</numerusform> @@ -408,37 +418,27 @@ This product includes software developed by the OpenSSL Project for use in the O </translation> </message> <message> - <location line="+6"/> - <source>Downloaded %1 of %2 blocks of transaction history (%3% done).</source> - <translation>Downloaded %1 of %2 blocks of transaction history (%3% done).</translation> - </message> - <message> - <location line="-242"/> + <location line="-252"/> <source>&Export...</source> <translation>&Export...</translation> </message> <message> - <location line="-58"/> + <location line="-65"/> <source>Send coins to a Bitcoin address</source> <translation>Send coins to a Bitcoin address</translation> </message> <message> - <location line="+45"/> + <location line="+49"/> <source>Modify configuration options for Bitcoin</source> <translation>Modify configuration options for Bitcoin</translation> </message> <message> - <location line="+14"/> + <location line="+17"/> <source>Export the data in the current tab to a file</source> <translation>Export the data in the current tab to a file</translation> </message> <message> - <location line="-10"/> - <source>Encrypt or decrypt wallet</source> - <translation>Encrypt or decrypt wallet</translation> - </message> - <message> - <location line="+3"/> + <location line="-9"/> <source>Backup wallet to another location</source> <translation>Backup wallet to another location</translation> </message> @@ -448,7 +448,7 @@ This product includes software developed by the OpenSSL Project for use in the O <translation>Change the passphrase used for wallet encryption</translation> </message> <message> - <location line="+6"/> + <location line="+9"/> <source>&Debug window</source> <translation>&Debug window</translation> </message> @@ -458,12 +458,12 @@ This product includes software developed by the OpenSSL Project for use in the O <translation>Open debugging and diagnostic console</translation> </message> <message> - <location line="-5"/> + <location line="-7"/> <source>&Verify message...</source> <translation>&Verify message...</translation> </message> <message> - <location line="-186"/> + <location line="-196"/> <source>Bitcoin</source> <translation>Bitcoin</translation> </message> @@ -473,7 +473,7 @@ This product includes software developed by the OpenSSL Project for use in the O <translation>Wallet</translation> </message> <message> - <location line="+168"/> + <location line="+176"/> <source>&About Bitcoin</source> <translation>&About Bitcoin</translation> </message> @@ -483,7 +483,27 @@ This product includes software developed by the OpenSSL Project for use in the O <translation>&Show / Hide</translation> </message> <message> - <location line="+39"/> + <location line="+1"/> + <source>Show or hide the main Window</source> + <translation>Show or hide the main Window</translation> + </message> + <message> + <location line="+2"/> + <source>Encrypt the private keys that belong to your wallet</source> + <translation>Encrypt the private keys that belong to your wallet</translation> + </message> + <message> + <location line="+7"/> + <source>Sign messages with your Bitcoin addresses to prove you own them</source> + <translation>Sign messages with your Bitcoin addresses to prove you own them</translation> + </message> + <message> + <location line="+2"/> + <source>Verify messages to ensure they were signed with specified Bitcoin addresses</source> + <translation>Verify messages to ensure they were signed with specified Bitcoin addresses</translation> + </message> + <message> + <location line="+31"/> <source>&File</source> <translation>&File</translation> </message> @@ -509,12 +529,11 @@ This product includes software developed by the OpenSSL Project for use in the O </message> <message> <location line="+13"/> - <location line="+9"/> + <location line="+10"/> <source>[testnet]</source> <translation>[testnet]</translation> </message> <message> - <location line="+0"/> <location line="+60"/> <source>Bitcoin client</source> <translation>Bitcoin client</translation> @@ -528,12 +547,22 @@ This product includes software developed by the OpenSSL Project for use in the O </translation> </message> <message> - <location line="+40"/> - <source>Downloaded %1 blocks of transaction history.</source> - <translation>Downloaded %1 blocks of transaction history.</translation> + <location line="+45"/> + <source>Processed %1 of %2 blocks of transaction history (%3% done).</source> + <translation>Processed %1 of %2 blocks of transaction history (%3% done).</translation> + </message> + <message> + <location line="+7"/> + <source>Processed %1 blocks of transaction history.</source> + <translation>Processed %1 blocks of transaction history.</translation> + </message> + <message> + <location line="+107"/> + <source>This transaction is over the size limit. You can still send it for a fee of %1, which goes to the nodes that process your transaction and helps to support the network. Do you want to pay the fee?</source> + <translation>This transaction is over the size limit. You can still send it for a fee of %1, which goes to the nodes that process your transaction and helps to support the network. Do you want to pay the fee?</translation> </message> <message numerus="yes"> - <location line="+22"/> + <location line="-93"/> <source>%n second(s) ago</source> <translation> <numerusform>%n second ago</numerusform> @@ -580,12 +609,7 @@ This product includes software developed by the OpenSSL Project for use in the O <translation>Last received block was generated %1.</translation> </message> <message> - <location line="+59"/> - <source>This transaction is over the size limit. You can still send it for a fee of %1, which goes to the nodes that process your transaction and helps to support the network. Do you want to pay the fee?</source> - <translation>This transaction is over the size limit. You can still send it for a fee of %1, which goes to the nodes that process your transaction and helps to support the network. Do you want to pay the fee?</translation> - </message> - <message> - <location line="+5"/> + <location line="+62"/> <source>Confirm transaction fee</source> <translation>Confirm transaction fee</translation> </message> @@ -614,13 +638,13 @@ Address: %4 </message> <message> <location line="+100"/> - <location line="+15"/> + <location line="+27"/> <source>URI handling</source> <translation>URI handling</translation> </message> <message> - <location line="-15"/> - <location line="+15"/> + <location line="-27"/> + <location line="+27"/> <source>URI can not be parsed! This can be caused by an invalid Bitcoin address or malformed URI parameters.</source> <translation>URI can not be parsed! This can be caused by an invalid Bitcoin address or malformed URI parameters.</translation> </message> @@ -813,16 +837,6 @@ Address: %4 <translation>&Start Bitcoin on system login</translation> </message> <message> - <location line="+7"/> - <source>Detach block and address databases at shutdown. This means they can be moved to another data directory, but it slows down shutdown. The wallet is always detached.</source> - <translation>Detach block and address databases at shutdown. This means they can be moved to another data directory, but it slows down shutdown. The wallet is always detached.</translation> - </message> - <message> - <location line="+3"/> - <source>&Detach databases at shutdown</source> - <translation>&Detach databases at shutdown</translation> - </message> - <message> <location line="+21"/> <source>&Network</source> <translation>&Network</translation> @@ -958,7 +972,7 @@ Address: %4 <translation>default</translation> </message> <message> - <location line="+147"/> + <location line="+146"/> <location line="+9"/> <source>Warning</source> <translation>Warning</translation> @@ -983,7 +997,7 @@ Address: %4 <translation>Form</translation> </message> <message> - <location line="+33"/> + <location line="+52"/> <location line="+183"/> <source>The displayed information may be out of date. Your wallet automatically synchronizes with the Bitcoin network after a connection is established, but this process has not completed yet.</source> <translation>The displayed information may be out of date. Your wallet automatically synchronizes with the Bitcoin network after a connection is established, but this process has not completed yet.</translation> @@ -1039,7 +1053,7 @@ Address: %4 <translation>Total number of transactions in wallet</translation> </message> <message> - <location filename="../overviewpage.cpp" line="+112"/> + <location filename="../overviewpage.cpp" line="+115"/> <location line="+1"/> <source>out of sync</source> <translation>out of sync</translation> @@ -1120,7 +1134,7 @@ Address: %4 <location line="+53"/> <location line="+23"/> <location line="+23"/> - <location filename="../rpcconsole.cpp" line="+348"/> + <location filename="../rpcconsole.cpp" line="+349"/> <source>N/A</source> <translation>N/A</translation> </message> @@ -1351,8 +1365,8 @@ Address: %4 </message> <message> <location line="+5"/> - <source>Error: Transaction creation failed.</source> - <translation>Error: Transaction creation failed.</translation> + <source>Error: Transaction creation failed!</source> + <translation>Error: Transaction creation failed!</translation> </message> <message> <location line="+5"/> @@ -1378,23 +1392,23 @@ Address: %4 <translation>Pay &To:</translation> </message> <message> - <location line="+24"/> + <location line="+34"/> + <source>The address to send the payment to (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)</source> + <translation>The address to send the payment to (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)</translation> + </message> + <message> + <location line="+60"/> <location filename="../sendcoinsentry.cpp" line="+25"/> <source>Enter a label for this address to add it to your address book</source> <translation>Enter a label for this address to add it to your address book</translation> </message> <message> - <location line="+9"/> + <location line="-78"/> <source>&Label:</source> <translation>&Label:</translation> </message> <message> - <location line="+18"/> - <source>The address to send the payment to (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)</source> - <translation>The address to send the payment to (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)</translation> - </message> - <message> - <location line="+10"/> + <location line="+28"/> <source>Choose address from address book</source> <translation>Choose address from address book</translation> </message> @@ -1757,7 +1771,7 @@ Address: %4 <translation>Transaction</translation> </message> <message> - <location line="+5"/> + <location line="+3"/> <source>Inputs</source> <translation>Inputs</translation> </message> @@ -1777,7 +1791,7 @@ Address: %4 <translation>false</translation> </message> <message> - <location line="-211"/> + <location line="-209"/> <source>, has not been successfully broadcast yet</source> <translation>, has not been successfully broadcast yet</translation> </message> @@ -2099,32 +2113,32 @@ Address: %4 <context> <name>bitcoin-core</name> <message> - <location filename="../bitcoinstrings.cpp" line="+71"/> + <location filename="../bitcoinstrings.cpp" line="+86"/> <source>Bitcoin version</source> <translation>Bitcoin version</translation> </message> <message> - <location line="+82"/> + <location line="+81"/> <source>Usage:</source> <translation>Usage:</translation> </message> <message> - <location line="-25"/> + <location line="-24"/> <source>Send command to -server or bitcoind</source> <translation>Send command to -server or bitcoind</translation> </message> <message> - <location line="-19"/> + <location line="-20"/> <source>List commands</source> <translation>List commands</translation> </message> <message> - <location line="-11"/> + <location line="-10"/> <source>Get help for a command</source> <translation>Get help for a command</translation> </message> <message> - <location line="+20"/> + <location line="+19"/> <source>Options:</source> <translation>Options:</translation> </message> @@ -2139,7 +2153,7 @@ Address: %4 <translation>Specify pid file (default: bitcoind.pid)</translation> </message> <message> - <location line="-47"/> + <location line="-46"/> <source>Generate coins</source> <translation>Generate coins</translation> </message> @@ -2149,21 +2163,16 @@ Address: %4 <translation>Don't generate coins</translation> </message> <message> - <location line="+60"/> + <location line="+59"/> <source>Specify data directory</source> <translation>Specify data directory</translation> </message> <message> - <location line="-8"/> + <location line="-7"/> <source>Set database cache size in megabytes (default: 25)</source> <translation>Set database cache size in megabytes (default: 25)</translation> </message> <message> - <location line="+1"/> - <source>Set database disk log size in megabytes (default: 100)</source> - <translation>Set database disk log size in megabytes (default: 100)</translation> - </message> - <message> <location line="-26"/> <source>Listen for connections on <port> (default: 8333 or testnet: 18333)</source> <translation>Listen for connections on <port> (default: 8333 or testnet: 18333)</translation> @@ -2174,86 +2183,116 @@ Address: %4 <translation>Maintain at most <n> connections to peers (default: 125)</translation> </message> <message> - <location line="-33"/> + <location line="-32"/> <source>Connect to a node to retrieve peer addresses, and disconnect</source> <translation>Connect to a node to retrieve peer addresses, and disconnect</translation> </message> <message> - <location line="+64"/> + <location line="+63"/> <source>Specify your own public address</source> <translation>Specify your own public address</translation> </message> <message> - <location line="-75"/> - <source>Bind to given address. Use [host]:port notation for IPv6</source> - <translation>Bind to given address. Use [host]:port notation for IPv6</translation> - </message> - <message> - <location line="+77"/> + <location line="+2"/> <source>Threshold for disconnecting misbehaving peers (default: 100)</source> <translation>Threshold for disconnecting misbehaving peers (default: 100)</translation> </message> <message> - <location line="-104"/> + <location line="-113"/> <source>Number of seconds to keep misbehaving peers from reconnecting (default: 86400)</source> <translation>Number of seconds to keep misbehaving peers from reconnecting (default: 86400)</translation> </message> <message> - <location line="-19"/> + <location line="-26"/> <source>An error occurred while setting up the RPC port %u for listening on IPv4: %s</source> <translation>An error occurred while setting up the RPC port %u for listening on IPv4: %s</translation> </message> <message> - <location line="+5"/> - <source>Detach block and address databases. Increases shutdown time (default: 0)</source> - <translation>Detach block and address databases. Increases shutdown time (default: 0)</translation> - </message> - <message> - <location line="+12"/> + <location line="+24"/> <source>Listen for JSON-RPC connections on <port> (default: 8332 or testnet: 18332)</source> <translation>Listen for JSON-RPC connections on <port> (default: 8332 or testnet: 18332)</translation> </message> <message> - <location line="+24"/> + <location line="+34"/> <source>Accept command line and JSON-RPC commands</source> <translation>Accept command line and JSON-RPC commands</translation> </message> <message> - <location line="+36"/> - <source>Importing blockchain data file.</source> - <translation>Importing blockchain data file.</translation> - </message> - <message> - <location line="+1"/> - <source>Importing bootstrap blockchain data file.</source> - <translation>Importing bootstrap blockchain data file.</translation> - </message> - <message> - <location line="+23"/> + <location line="+60"/> <source>Run in the background as a daemon and accept commands</source> <translation>Run in the background as a daemon and accept commands</translation> </message> <message> - <location line="+33"/> + <location line="+32"/> <source>Use the test network</source> <translation>Use the test network</translation> </message> <message> - <location line="-92"/> + <location line="-91"/> <source>Accept connections from outside (default: 1 if no -proxy or -connect)</source> <translation>Accept connections from outside (default: 1 if no -proxy or -connect)</translation> </message> <message> - <location line="-45"/> + <location line="-72"/> + <source>%s, you must set a rpcpassword in the configuration file: + %s +It is recommended you use the following random password: +rpcuser=bitcoinrpc +rpcpassword=%s +(you do not need to remember this password) +The username and password MUST NOT be the same. +If the file does not exist, create it with owner-readable-only file permissions. +</source> + <translation>%s, you must set a rpcpassword in the configuration file: + %s +It is recommended you use the following random password: +rpcuser=bitcoinrpc +rpcpassword=%s +(you do not need to remember this password) +The username and password MUST NOT be the same. +If the file does not exist, create it with owner-readable-only file permissions.</translation> + </message> + <message> + <location line="+15"/> <source>An error occurred while setting up the RPC port %u for listening on IPv6, falling back to IPv4: %s</source> <translation>An error occurred while setting up the RPC port %u for listening on IPv6, falling back to IPv4: %s</translation> </message> <message> - <location line="+25"/> + <location line="+3"/> + <source>Bind to given address and always listen on it. Use [host]:port notation for IPv6</source> + <translation>Bind to given address and always listen on it. Use [host]:port notation for IPv6</translation> + </message> + <message> + <location line="+3"/> + <source>Cannot obtain a lock on data directory %s. Bitcoin is probably already running.</source> + <translation>Cannot obtain a lock on data directory %s. Bitcoin is probably already running.</translation> + </message> + <message> + <location line="+3"/> + <source>Error initializing database environment %s! To recover, BACKUP THAT DIRECTORY, then remove everything from it except for wallet.dat.</source> + <translation>Error initializing database environment %s! To recover, BACKUP THAT DIRECTORY, then remove everything from it except for wallet.dat.</translation> + </message> + <message> + <location line="+3"/> + <source>Error: The transaction was rejected! This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here.</source> + <translation>Error: The transaction was rejected! This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here.</translation> + </message> + <message> + <location line="+4"/> + <source>Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds!</source> + <translation>Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds!</translation> + </message> + <message> + <location line="+11"/> <source>Set maximum size of high-priority/low-fee transactions in bytes (default: 27000)</source> <translation>Set maximum size of high-priority/low-fee transactions in bytes (default: 27000)</translation> </message> <message> + <location line="+3"/> + <source>This is a pre-release test build - use at your own risk - do not use for mining or merchant applications</source> + <translation>This is a pre-release test build - use at your own risk - do not use for mining or merchant applications</translation> + </message> + <message> <location line="+5"/> <source>Warning: -paytxfee is set very high! This is the transaction fee you will pay if you send a transaction.</source> <translation>Warning: -paytxfee is set very high! This is the transaction fee you will pay if you send a transaction.</translation> @@ -2269,7 +2308,22 @@ Address: %4 <translation>Warning: Please check that your computer's date and time are correct! If your clock is wrong Bitcoin will not work properly.</translation> </message> <message> - <location line="+16"/> + <location line="+3"/> + <source>Warning: error reading wallet.dat! All keys read correctly, but transaction data or address book entries might be missing or incorrect.</source> + <translation>Warning: error reading wallet.dat! All keys read correctly, but transaction data or address book entries might be missing or incorrect.</translation> + </message> + <message> + <location line="+3"/> + <source>Warning: wallet.dat corrupt, data salvaged! Original wallet.dat saved as wallet.{timestamp}.bak in %s; if your balance or transactions are incorrect you should restore from a backup.</source> + <translation>Warning: wallet.dat corrupt, data salvaged! Original wallet.dat saved as wallet.{timestamp}.bak in %s; if your balance or transactions are incorrect you should restore from a backup.</translation> + </message> + <message> + <location line="+14"/> + <source>Attempt to recover private keys from a corrupt wallet.dat</source> + <translation>Attempt to recover private keys from a corrupt wallet.dat</translation> + </message> + <message> + <location line="+3"/> <source>Block creation options:</source> <translation>Block creation options:</translation> </message> @@ -2284,7 +2338,17 @@ Address: %4 <translation>Discover own IP address (default: 1 when listening and no -externalip)</translation> </message> <message> - <location line="+11"/> + <location line="+8"/> + <source>Error: Transaction creation failed!</source> + <translation>Error: Transaction creation failed!</translation> + </message> + <message> + <location line="+1"/> + <source>Error: Wallet locked, unable to create transaction!</source> + <translation>Error: Wallet locked, unable to create transaction!</translation> + </message> + <message> + <location line="+2"/> <source>Failed to listen on any port. Use -listen=0 if you want this.</source> <translation>Failed to listen on any port. Use -listen=0 if you want this.</translation> </message> @@ -2294,7 +2358,12 @@ Address: %4 <translation>Find peers using DNS lookup (default: 1 unless -connect)</translation> </message> <message> - <location line="+11"/> + <location line="+6"/> + <source>Importing blocks from block database...</source> + <translation>Importing blocks from block database...</translation> + </message> + <message> + <location line="+4"/> <source>Invalid -tor address: '%s'</source> <translation>Invalid -tor address: '%s'</translation> </message> @@ -2329,6 +2398,11 @@ Address: %4 <translation>Prepend debug output with timestamp</translation> </message> <message> + <location line="+1"/> + <source>Rebuild blockchain index from current blk000??.dat files</source> + <translation>Rebuild blockchain index from current blk000??.dat files</translation> + </message> + <message> <location line="+4"/> <source>SSL options: (see the Bitcoin Wiki for SSL setup instructions)</source> <translation>SSL options: (see the Bitcoin Wiki for SSL setup instructions)</translation> @@ -2349,7 +2423,7 @@ Address: %4 <translation>Send trace/debug info to debugger</translation> </message> <message> - <location line="+7"/> + <location line="+6"/> <source>Set maximum block size in bytes (default: 250000)</source> <translation>Set maximum block size in bytes (default: 250000)</translation> </message> @@ -2389,6 +2463,11 @@ Address: %4 <translation>Username for JSON-RPC connections</translation> </message> <message> + <location line="+1"/> + <source>Verifying database integrity...</source> + <translation>Verifying database integrity...</translation> + </message> + <message> <location line="+2"/> <source>Warning: Disk space is low!</source> <translation>Warning: Disk space is low!</translation> @@ -2399,12 +2478,17 @@ Address: %4 <translation>Warning: This version is obsolete, upgrade required!</translation> </message> <message> - <location line="-41"/> + <location line="+1"/> + <source>wallet.dat corrupt, salvage failed</source> + <translation>wallet.dat corrupt, salvage failed</translation> + </message> + <message> + <location line="-43"/> <source>Password for JSON-RPC connections</source> <translation>Password for JSON-RPC connections</translation> </message> <message> - <location line="-52"/> + <location line="-51"/> <source>Allow JSON-RPC connections from specified IP address</source> <translation>Allow JSON-RPC connections from specified IP address</translation> </message> @@ -2414,12 +2498,12 @@ Address: %4 <translation>Send commands to node running on <ip> (default: 127.0.0.1)</translation> </message> <message> - <location line="-91"/> + <location line="-101"/> <source>Execute command when the best block changes (%s in cmd is replaced by block hash)</source> <translation>Execute command when the best block changes (%s in cmd is replaced by block hash)</translation> </message> <message> - <location line="+114"/> + <location line="+123"/> <source>Upgrade wallet to latest format</source> <translation>Upgrade wallet to latest format</translation> </message> @@ -2429,7 +2513,7 @@ Address: %4 <translation>Set key pool size to <n> (default: 100)</translation> </message> <message> - <location line="-14"/> + <location line="-13"/> <source>Rescan the block chain for missing wallet transactions</source> <translation>Rescan the block chain for missing wallet transactions</translation> </message> @@ -2444,7 +2528,7 @@ Address: %4 <translation>How thorough the block verification is (0-6, default: 1)</translation> </message> <message> - <location line="+3"/> + <location line="+2"/> <source>Imports blocks from external blk000?.dat file</source> <translation>Imports blocks from external blk000?.dat file</translation> </message> @@ -2454,7 +2538,7 @@ Address: %4 <translation>Use OpenSSL (https) for JSON-RPC connections</translation> </message> <message> - <location line="-21"/> + <location line="-20"/> <source>Server certificate file (default: server.cert)</source> <translation>Server certificate file (default: server.cert)</translation> </message> @@ -2464,32 +2548,27 @@ Address: %4 <translation>Server private key (default: server.pem)</translation> </message> <message> - <location line="-116"/> + <location line="-130"/> <source>Acceptable ciphers (default: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH)</source> <translation>Acceptable ciphers (default: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH)</translation> </message> <message> - <location line="+128"/> + <location line="+141"/> <source>This help message</source> <translation>This help message</translation> </message> <message> - <location line="-120"/> - <source>Cannot obtain a lock on data directory %s. Bitcoin is probably already running.</source> - <translation>Cannot obtain a lock on data directory %s. Bitcoin is probably already running.</translation> - </message> - <message> - <location line="+46"/> + <location line="-73"/> <source>Bitcoin</source> <translation>Bitcoin</translation> </message> <message> - <location line="+77"/> + <location line="+76"/> <source>Unable to bind to %s on this computer (bind returned error %d, %s)</source> <translation>Unable to bind to %s on this computer (bind returned error %d, %s)</translation> </message> <message> - <location line="-69"/> + <location line="-68"/> <source>Connect through socks proxy</source> <translation>Connect through socks proxy</translation> </message> @@ -2499,12 +2578,12 @@ Address: %4 <translation>Allow DNS lookups for -addnode, -seednode and -connect</translation> </message> <message> - <location line="+43"/> + <location line="+42"/> <source>Loading addresses...</source> <translation>Loading addresses...</translation> </message> <message> - <location line="-26"/> + <location line="-25"/> <source>Error loading blkindex.dat</source> <translation>Error loading blkindex.dat</translation> </message> @@ -2529,7 +2608,7 @@ Address: %4 <translation>Error loading wallet.dat</translation> </message> <message> - <location line="+19"/> + <location line="+18"/> <source>Invalid -proxy address: '%s'</source> <translation>Invalid -proxy address: '%s'</translation> </message> @@ -2544,7 +2623,7 @@ Address: %4 <translation>Unknown -socks proxy version requested: %i</translation> </message> <message> - <location line="-74"/> + <location line="-73"/> <source>Cannot resolve -bind address: '%s'</source> <translation>Cannot resolve -bind address: '%s'</translation> </message> @@ -2554,42 +2633,22 @@ Address: %4 <translation>Cannot resolve -externalip address: '%s'</translation> </message> <message> - <location line="+30"/> + <location line="+29"/> <source>Invalid amount for -paytxfee=<amount>: '%s'</source> <translation>Invalid amount for -paytxfee=<amount>: '%s'</translation> </message> <message> - <location line="-15"/> + <location line="-14"/> <source>Error: could not start node</source> <translation>Error: could not start node</translation> </message> <message> - <location line="-1"/> - <source>Error: Wallet locked, unable to create transaction </source> - <translation>Error: Wallet locked, unable to create transaction </translation> - </message> - <message> - <location line="-56"/> - <source>Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds </source> - <translation>Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds </translation> - </message> - <message> - <location line="+55"/> - <source>Error: Transaction creation failed </source> - <translation>Error: Transaction creation failed </translation> - </message> - <message> - <location line="+42"/> + <location line="+40"/> <source>Sending...</source> <translation>Sending...</translation> </message> <message> - <location line="-101"/> - <source>Error: The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here.</source> - <translation>Error: The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here.</translation> - </message> - <message> - <location line="+77"/> + <location line="-25"/> <source>Invalid amount</source> <translation>Invalid amount</translation> </message> @@ -2604,17 +2663,17 @@ Address: %4 <translation>Loading block index...</translation> </message> <message> - <location line="-45"/> + <location line="-44"/> <source>Add a node to connect to and attempt to keep the connection open</source> <translation>Add a node to connect to and attempt to keep the connection open</translation> </message> <message> - <location line="-18"/> + <location line="-25"/> <source>Unable to bind to %s on this computer. Bitcoin is probably already running.</source> <translation>Unable to bind to %s on this computer. Bitcoin is probably already running.</translation> </message> <message> - <location line="+47"/> + <location line="+54"/> <source>Find peers using internet relay chat (default: 0)</source> <translation>Find peers using internet relay chat (default: 0)</translation> </message> @@ -2624,12 +2683,12 @@ Address: %4 <translation>Fee per KB to add to transactions you send</translation> </message> <message> - <location line="+19"/> + <location line="+18"/> <source>Loading wallet...</source> <translation>Loading wallet...</translation> </message> <message> - <location line="-39"/> + <location line="-38"/> <source>Cannot downgrade wallet</source> <translation>Cannot downgrade wallet</translation> </message> @@ -2654,31 +2713,12 @@ Address: %4 <translation>Done loading</translation> </message> <message> - <location line="+64"/> + <location line="+63"/> <source>To use the %s option</source> <translation>To use the %s option</translation> </message> <message> - <location line="-139"/> - <source>%s, you must set a rpcpassword in the configuration file: - %s -It is recommended you use the following random password: -rpcuser=bitcoinrpc -rpcpassword=%s -(you do not need to remember this password) -If the file does not exist, create it with owner-readable-only file permissions. -</source> - <translation>%s, you must set a rpcpassword in the configuration file: - %s -It is recommended you use the following random password: -rpcuser=bitcoinrpc -rpcpassword=%s -(you do not need to remember this password) -If the file does not exist, create it with owner-readable-only file permissions. -</translation> - </message> - <message> - <location line="+80"/> + <location line="-58"/> <source>Error</source> <translation>Error</translation> </message> diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 2b8a0c049b..3dc32d0e47 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -15,12 +15,11 @@ #include <openssl/crypto.h> +// TODO: add a scrollback limit, as there is currently none // TODO: make it possible to filter out categories (esp debug messages when implemented) // TODO: receive errors and debug messages through ClientModel -const int CONSOLE_SCROLLBACK = 50; const int CONSOLE_HISTORY = 50; - const QSize ICON_SIZE(24, 24); const struct { @@ -289,6 +288,8 @@ static QString categoryClass(int category) void RPCConsole::clear() { ui->messagesWidget->clear(); + history.clear(); + historyPtr = 0; ui->lineEdit->clear(); ui->lineEdit->setFocus(); diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index e82f4ad91d..9531b12678 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -505,7 +505,7 @@ Value signrawtransaction(const Array& params, bool fHelp) { txin.scriptSig = CombineSignatures(prevPubKey, mergedTx, i, txin.scriptSig, txv.vin[i].scriptSig); } - if (!VerifyScript(txin.scriptSig, prevPubKey, mergedTx, i, true, true, 0)) + if (!VerifyScript(txin.scriptSig, prevPubKey, mergedTx, i, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC, 0)) fComplete = false; } diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index 29b3298b99..5ebab755b7 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -573,7 +573,7 @@ Value movecmd(const Array& params, bool fHelp) // Debit CAccountingEntry debit; - debit.nOrderPos = pwalletMain->IncOrderPosNext(); + debit.nOrderPos = pwalletMain->IncOrderPosNext(&walletdb); debit.strAccount = strFrom; debit.nCreditDebit = -nAmount; debit.nTime = nNow; @@ -583,7 +583,7 @@ Value movecmd(const Array& params, bool fHelp) // Credit CAccountingEntry credit; - credit.nOrderPos = pwalletMain->IncOrderPosNext(); + credit.nOrderPos = pwalletMain->IncOrderPosNext(&walletdb); credit.strAccount = strTo; credit.nCreditDebit = nAmount; credit.nTime = nNow; diff --git a/src/script.cpp b/src/script.cpp index 36d208c247..f65508aacc 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -314,7 +314,7 @@ bool IsCanonicalSignature(const valtype &vchSig) { return true; } -bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, const CTransaction& txTo, unsigned int nIn, bool fStrictEncodings, int nHashType) +bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType) { CAutoBN_CTX pctx; CScript::const_iterator pc = script.begin(); @@ -327,7 +327,7 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, co if (script.size() > 10000) return false; int nOpCount = 0; - + bool fStrictEncodings = flags & SCRIPT_VERIFY_STRICTENC; try { @@ -1637,14 +1637,14 @@ bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, vecto } bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, - bool fValidatePayToScriptHash, bool fStrictEncodings, int nHashType) + unsigned int flags, int nHashType) { vector<vector<unsigned char> > stack, stackCopy; - if (!EvalScript(stack, scriptSig, txTo, nIn, fStrictEncodings, nHashType)) + if (!EvalScript(stack, scriptSig, txTo, nIn, flags, nHashType)) return false; - if (fValidatePayToScriptHash) + if (flags & SCRIPT_VERIFY_P2SH) stackCopy = stack; - if (!EvalScript(stack, scriptPubKey, txTo, nIn, fStrictEncodings, nHashType)) + if (!EvalScript(stack, scriptPubKey, txTo, nIn, flags, nHashType)) return false; if (stack.empty()) return false; @@ -1653,16 +1653,21 @@ bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const C return false; // Additional validation for spend-to-script-hash transactions: - if (fValidatePayToScriptHash && scriptPubKey.IsPayToScriptHash()) + if ((flags & SCRIPT_VERIFY_P2SH) && scriptPubKey.IsPayToScriptHash()) { if (!scriptSig.IsPushOnly()) // scriptSig must be literals-only return false; // or validation fails + // stackCopy cannot be empty here, because if it was the + // P2SH HASH <> EQUAL scriptPubKey would be evaluated with + // an empty stack and the EvalScript above would return false. + assert(!stackCopy.empty()); + const valtype& pubKeySerialized = stackCopy.back(); CScript pubKey2(pubKeySerialized.begin(), pubKeySerialized.end()); popstack(stackCopy); - if (!EvalScript(stackCopy, pubKey2, txTo, nIn, fStrictEncodings, nHashType)) + if (!EvalScript(stackCopy, pubKey2, txTo, nIn, flags, nHashType)) return false; if (stackCopy.empty()) return false; @@ -1705,7 +1710,7 @@ bool SignSignature(const CKeyStore &keystore, const CScript& fromPubKey, CTransa } // Test solution - return VerifyScript(txin.scriptSig, fromPubKey, txTo, nIn, true, true, 0); + return VerifyScript(txin.scriptSig, fromPubKey, txTo, nIn, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC, 0); } bool SignSignature(const CKeyStore &keystore, const CTransaction& txFrom, CTransaction& txTo, unsigned int nIn, int nHashType) @@ -1718,7 +1723,7 @@ bool SignSignature(const CKeyStore &keystore, const CTransaction& txFrom, CTrans return SignSignature(keystore, txout.scriptPubKey, txTo, nIn, nHashType); } -bool VerifySignature(const CCoins& txFrom, const CTransaction& txTo, unsigned int nIn, bool fValidatePayToScriptHash, bool fStrictEncodings, int nHashType) +bool VerifySignature(const CCoins& txFrom, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType) { assert(nIn < txTo.vin.size()); const CTxIn& txin = txTo.vin[nIn]; @@ -1726,7 +1731,7 @@ bool VerifySignature(const CCoins& txFrom, const CTransaction& txTo, unsigned in return false; const CTxOut& txout = txFrom.vout[txin.prevout.n]; - return VerifyScript(txin.scriptSig, txout.scriptPubKey, txTo, nIn, fValidatePayToScriptHash, fStrictEncodings, nHashType); + return VerifyScript(txin.scriptSig, txout.scriptPubKey, txTo, nIn, flags, nHashType); } static CScript PushAll(const vector<valtype>& values) @@ -1844,9 +1849,9 @@ CScript CombineSignatures(CScript scriptPubKey, const CTransaction& txTo, unsign Solver(scriptPubKey, txType, vSolutions); vector<valtype> stack1; - EvalScript(stack1, scriptSig1, CTransaction(), 0, true, 0); + EvalScript(stack1, scriptSig1, CTransaction(), 0, SCRIPT_VERIFY_STRICTENC, 0); vector<valtype> stack2; - EvalScript(stack2, scriptSig2, CTransaction(), 0, true, 0); + EvalScript(stack2, scriptSig2, CTransaction(), 0, SCRIPT_VERIFY_STRICTENC, 0); return CombineSignatures(scriptPubKey, txTo, nIn, txType, vSolutions, stack1, stack2); } diff --git a/src/script.h b/src/script.h index f9df587ca3..7b0643f70a 100644 --- a/src/script.h +++ b/src/script.h @@ -26,6 +26,13 @@ enum SIGHASH_ANYONECANPAY = 0x80, }; +/** Script verification flags */ +enum +{ + SCRIPT_VERIFY_NONE = 0, + SCRIPT_VERIFY_P2SH = (1U << 0), + SCRIPT_VERIFY_STRICTENC = (1U << 1), +}; enum txnouttype { @@ -656,7 +663,7 @@ public: bool IsCanonicalPubKey(const std::vector<unsigned char> &vchPubKey); bool IsCanonicalSignature(const std::vector<unsigned char> &vchSig); -bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& script, const CTransaction& txTo, unsigned int nIn, bool fStrictEncodings, int nHashType); +bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& script, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType); bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<std::vector<unsigned char> >& vSolutionsRet); int ScriptSigArgsExpected(txnouttype t, const std::vector<std::vector<unsigned char> >& vSolutions); bool IsStandard(const CScript& scriptPubKey); @@ -667,8 +674,8 @@ bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, std:: bool SignSignature(const CKeyStore& keystore, const CScript& fromPubKey, CTransaction& txTo, unsigned int nIn, int nHashType=SIGHASH_ALL); bool SignSignature(const CKeyStore& keystore, const CTransaction& txFrom, CTransaction& txTo, unsigned int nIn, int nHashType=SIGHASH_ALL); bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, - bool fValidatePayToScriptHash, bool fStrictEncodings, int nHashType); -bool VerifySignature(const CCoins& txFrom, const CTransaction& txTo, unsigned int nIn, bool fValidatePayToScriptHash, bool fStrictEncodings, int nHashType); + unsigned int flags, int nHashType); +bool VerifySignature(const CCoins& txFrom, const CTransaction& txTo, unsigned int nIn, unsigned int flags, int nHashType); // Given two sets of signatures for scriptPubKey, possibly with OP_0 placeholders, // combine them intelligently and return the result. diff --git a/src/test/DoS_tests.cpp b/src/test/DoS_tests.cpp index 0db33dcd05..b1e98f65ed 100644 --- a/src/test/DoS_tests.cpp +++ b/src/test/DoS_tests.cpp @@ -230,6 +230,7 @@ BOOST_AUTO_TEST_CASE(DoS_checkSig) key.MakeNewKey(true); CBasicKeyStore keystore; keystore.AddKey(key); + unsigned int flags = SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC; // 100 orphan transactions: static const int NPREV=100; @@ -277,7 +278,7 @@ BOOST_AUTO_TEST_CASE(DoS_checkSig) mst1 = boost::posix_time::microsec_clock::local_time(); for (unsigned int i = 0; i < 5; i++) for (unsigned int j = 0; j < tx.vin.size(); j++) - BOOST_CHECK(VerifySignature(CCoins(orphans[j], MEMPOOL_HEIGHT), tx, j, true, true, SIGHASH_ALL)); + BOOST_CHECK(VerifySignature(CCoins(orphans[j], MEMPOOL_HEIGHT), tx, j, flags, SIGHASH_ALL)); mst2 = boost::posix_time::microsec_clock::local_time(); msdiff = mst2 - mst1; long nManyValidate = msdiff.total_milliseconds(); @@ -288,13 +289,13 @@ BOOST_AUTO_TEST_CASE(DoS_checkSig) // Empty a signature, validation should fail: CScript save = tx.vin[0].scriptSig; tx.vin[0].scriptSig = CScript(); - BOOST_CHECK(!VerifySignature(CCoins(orphans[0], MEMPOOL_HEIGHT), tx, 0, true, true, SIGHASH_ALL)); + BOOST_CHECK(!VerifySignature(CCoins(orphans[0], MEMPOOL_HEIGHT), tx, 0, flags, SIGHASH_ALL)); tx.vin[0].scriptSig = save; // Swap signatures, validation should fail: std::swap(tx.vin[0].scriptSig, tx.vin[1].scriptSig); - BOOST_CHECK(!VerifySignature(CCoins(orphans[0], MEMPOOL_HEIGHT), tx, 0, true, true, SIGHASH_ALL)); - BOOST_CHECK(!VerifySignature(CCoins(orphans[1], MEMPOOL_HEIGHT), tx, 1, true, true, SIGHASH_ALL)); + BOOST_CHECK(!VerifySignature(CCoins(orphans[0], MEMPOOL_HEIGHT), tx, 0, flags, SIGHASH_ALL)); + BOOST_CHECK(!VerifySignature(CCoins(orphans[1], MEMPOOL_HEIGHT), tx, 1, flags, SIGHASH_ALL)); std::swap(tx.vin[0].scriptSig, tx.vin[1].scriptSig); // Exercise -maxsigcachesize code: @@ -304,7 +305,7 @@ BOOST_AUTO_TEST_CASE(DoS_checkSig) BOOST_CHECK(SignSignature(keystore, orphans[0], tx, 0)); BOOST_CHECK(tx.vin[0].scriptSig != oldSig); for (unsigned int j = 0; j < tx.vin.size(); j++) - BOOST_CHECK(VerifySignature(CCoins(orphans[j], MEMPOOL_HEIGHT), tx, j, true, true, SIGHASH_ALL)); + BOOST_CHECK(VerifySignature(CCoins(orphans[j], MEMPOOL_HEIGHT), tx, j, flags, SIGHASH_ALL)); mapArgs.erase("-maxsigcachesize"); LimitOrphanTxSize(0); diff --git a/src/test/multisig_tests.cpp b/src/test/multisig_tests.cpp index aa6feb7201..7297bb9a75 100644 --- a/src/test/multisig_tests.cpp +++ b/src/test/multisig_tests.cpp @@ -20,8 +20,6 @@ using namespace boost::assign; typedef vector<unsigned char> valtype; extern uint256 SignatureHash(CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType); -extern bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, - bool fValidatePayToScriptHash, bool fStrictEncodings, int nHashType); BOOST_AUTO_TEST_SUITE(multisig_tests) @@ -44,6 +42,8 @@ sign_multisig(CScript scriptPubKey, vector<CKey> keys, CTransaction transaction, BOOST_AUTO_TEST_CASE(multisig_verify) { + unsigned int flags = SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC; + CKey key[4]; for (int i = 0; i < 4; i++) key[i].MakeNewKey(true); @@ -80,19 +80,19 @@ BOOST_AUTO_TEST_CASE(multisig_verify) keys.clear(); keys += key[0],key[1]; // magic operator+= from boost.assign s = sign_multisig(a_and_b, keys, txTo[0], 0); - BOOST_CHECK(VerifyScript(s, a_and_b, txTo[0], 0, true, true, 0)); + BOOST_CHECK(VerifyScript(s, a_and_b, txTo[0], 0, flags, 0)); for (int i = 0; i < 4; i++) { keys.clear(); keys += key[i]; s = sign_multisig(a_and_b, keys, txTo[0], 0); - BOOST_CHECK_MESSAGE(!VerifyScript(s, a_and_b, txTo[0], 0, true, true, 0), strprintf("a&b 1: %d", i)); + BOOST_CHECK_MESSAGE(!VerifyScript(s, a_and_b, txTo[0], 0, flags, 0), strprintf("a&b 1: %d", i)); keys.clear(); keys += key[1],key[i]; s = sign_multisig(a_and_b, keys, txTo[0], 0); - BOOST_CHECK_MESSAGE(!VerifyScript(s, a_and_b, txTo[0], 0, true, true, 0), strprintf("a&b 2: %d", i)); + BOOST_CHECK_MESSAGE(!VerifyScript(s, a_and_b, txTo[0], 0, flags, 0), strprintf("a&b 2: %d", i)); } // Test a OR b: @@ -102,16 +102,16 @@ BOOST_AUTO_TEST_CASE(multisig_verify) keys += key[i]; s = sign_multisig(a_or_b, keys, txTo[1], 0); if (i == 0 || i == 1) - BOOST_CHECK_MESSAGE(VerifyScript(s, a_or_b, txTo[1], 0, true, true, 0), strprintf("a|b: %d", i)); + BOOST_CHECK_MESSAGE(VerifyScript(s, a_or_b, txTo[1], 0, flags, 0), strprintf("a|b: %d", i)); else - BOOST_CHECK_MESSAGE(!VerifyScript(s, a_or_b, txTo[1], 0, true, true, 0), strprintf("a|b: %d", i)); + BOOST_CHECK_MESSAGE(!VerifyScript(s, a_or_b, txTo[1], 0, flags, 0), strprintf("a|b: %d", i)); } s.clear(); s << OP_0 << OP_0; - BOOST_CHECK(!VerifyScript(s, a_or_b, txTo[1], 0, true, true, 0)); + BOOST_CHECK(!VerifyScript(s, a_or_b, txTo[1], 0, flags, 0)); s.clear(); s << OP_0 << OP_1; - BOOST_CHECK(!VerifyScript(s, a_or_b, txTo[1], 0, true, true, 0)); + BOOST_CHECK(!VerifyScript(s, a_or_b, txTo[1], 0, flags, 0)); for (int i = 0; i < 4; i++) @@ -121,9 +121,9 @@ BOOST_AUTO_TEST_CASE(multisig_verify) keys += key[i],key[j]; s = sign_multisig(escrow, keys, txTo[2], 0); if (i < j && i < 3 && j < 3) - BOOST_CHECK_MESSAGE(VerifyScript(s, escrow, txTo[2], 0, true, true, 0), strprintf("escrow 1: %d %d", i, j)); + BOOST_CHECK_MESSAGE(VerifyScript(s, escrow, txTo[2], 0, flags, 0), strprintf("escrow 1: %d %d", i, j)); else - BOOST_CHECK_MESSAGE(!VerifyScript(s, escrow, txTo[2], 0, true, true, 0), strprintf("escrow 2: %d %d", i, j)); + BOOST_CHECK_MESSAGE(!VerifyScript(s, escrow, txTo[2], 0, flags, 0), strprintf("escrow 2: %d %d", i, j)); } } diff --git a/src/test/script_P2SH_tests.cpp b/src/test/script_P2SH_tests.cpp index 35069a3fdd..b5107193fd 100644 --- a/src/test/script_P2SH_tests.cpp +++ b/src/test/script_P2SH_tests.cpp @@ -13,8 +13,6 @@ using namespace std; // Test routines internal to script.cpp: extern uint256 SignatureHash(CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType); -extern bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, - bool fValidatePayToScriptHash, bool fStrictEncodings, int nHashType); // Helpers: static std::vector<unsigned char> @@ -40,7 +38,7 @@ Verify(const CScript& scriptSig, const CScript& scriptPubKey, bool fStrict) txTo.vin[0].scriptSig = scriptSig; txTo.vout[0].nValue = 1; - return VerifyScript(scriptSig, scriptPubKey, txTo, 0, fStrict, true, 0); + return VerifyScript(scriptSig, scriptPubKey, txTo, 0, fStrict ? SCRIPT_VERIFY_P2SH : SCRIPT_VERIFY_NONE, 0); } @@ -105,7 +103,7 @@ BOOST_AUTO_TEST_CASE(sign) { CScript sigSave = txTo[i].vin[0].scriptSig; txTo[i].vin[0].scriptSig = txTo[j].vin[0].scriptSig; - bool sigOK = VerifySignature(CCoins(txFrom, 0), txTo[i], 0, true, true, 0); + bool sigOK = VerifySignature(CCoins(txFrom, 0), txTo[i], 0, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC, 0); if (i == j) BOOST_CHECK_MESSAGE(sigOK, strprintf("VerifySignature %d %d", i, j)); else diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index 3f280ba947..5d5a1525f7 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -20,8 +20,8 @@ using namespace json_spirit; using namespace boost::algorithm; extern uint256 SignatureHash(CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType); -extern bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, - bool fValidatePayToScriptHash, bool fStrictEncodings, int nHashType); + +static const unsigned int flags = SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC; CScript ParseScript(string s) @@ -143,7 +143,7 @@ BOOST_AUTO_TEST_CASE(script_valid) CScript scriptPubKey = ParseScript(scriptPubKeyString); CTransaction tx; - BOOST_CHECK_MESSAGE(VerifyScript(scriptSig, scriptPubKey, tx, 0, true, true, SIGHASH_NONE), strTest); + BOOST_CHECK_MESSAGE(VerifyScript(scriptSig, scriptPubKey, tx, 0, flags, SIGHASH_NONE), strTest); } } @@ -167,7 +167,7 @@ BOOST_AUTO_TEST_CASE(script_invalid) CScript scriptPubKey = ParseScript(scriptPubKeyString); CTransaction tx; - BOOST_CHECK_MESSAGE(!VerifyScript(scriptSig, scriptPubKey, tx, 0, true, true, SIGHASH_NONE), strTest); + BOOST_CHECK_MESSAGE(!VerifyScript(scriptSig, scriptPubKey, tx, 0, flags, SIGHASH_NONE), strTest); } } @@ -250,15 +250,15 @@ BOOST_AUTO_TEST_CASE(script_CHECKMULTISIG12) txTo12.vout[0].nValue = 1; CScript goodsig1 = sign_multisig(scriptPubKey12, key1, txTo12); - BOOST_CHECK(VerifyScript(goodsig1, scriptPubKey12, txTo12, 0, true, true, 0)); + BOOST_CHECK(VerifyScript(goodsig1, scriptPubKey12, txTo12, 0, flags, 0)); txTo12.vout[0].nValue = 2; - BOOST_CHECK(!VerifyScript(goodsig1, scriptPubKey12, txTo12, 0, true, true, 0)); + BOOST_CHECK(!VerifyScript(goodsig1, scriptPubKey12, txTo12, 0, flags, 0)); CScript goodsig2 = sign_multisig(scriptPubKey12, key2, txTo12); - BOOST_CHECK(VerifyScript(goodsig2, scriptPubKey12, txTo12, 0, true, true, 0)); + BOOST_CHECK(VerifyScript(goodsig2, scriptPubKey12, txTo12, 0, flags, 0)); CScript badsig1 = sign_multisig(scriptPubKey12, key3, txTo12); - BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey12, txTo12, 0, true, true, 0)); + BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey12, txTo12, 0, flags, 0)); } BOOST_AUTO_TEST_CASE(script_CHECKMULTISIG23) @@ -286,46 +286,46 @@ BOOST_AUTO_TEST_CASE(script_CHECKMULTISIG23) std::vector<CKey> keys; keys.push_back(key1); keys.push_back(key2); CScript goodsig1 = sign_multisig(scriptPubKey23, keys, txTo23); - BOOST_CHECK(VerifyScript(goodsig1, scriptPubKey23, txTo23, 0, true, true, 0)); + BOOST_CHECK(VerifyScript(goodsig1, scriptPubKey23, txTo23, 0, flags, 0)); keys.clear(); keys.push_back(key1); keys.push_back(key3); CScript goodsig2 = sign_multisig(scriptPubKey23, keys, txTo23); - BOOST_CHECK(VerifyScript(goodsig2, scriptPubKey23, txTo23, 0, true, true, 0)); + BOOST_CHECK(VerifyScript(goodsig2, scriptPubKey23, txTo23, 0, flags, 0)); keys.clear(); keys.push_back(key2); keys.push_back(key3); CScript goodsig3 = sign_multisig(scriptPubKey23, keys, txTo23); - BOOST_CHECK(VerifyScript(goodsig3, scriptPubKey23, txTo23, 0, true, true, 0)); + BOOST_CHECK(VerifyScript(goodsig3, scriptPubKey23, txTo23, 0, flags, 0)); keys.clear(); keys.push_back(key2); keys.push_back(key2); // Can't re-use sig CScript badsig1 = sign_multisig(scriptPubKey23, keys, txTo23); - BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey23, txTo23, 0, true, true, 0)); + BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey23, txTo23, 0, flags, 0)); keys.clear(); keys.push_back(key2); keys.push_back(key1); // sigs must be in correct order CScript badsig2 = sign_multisig(scriptPubKey23, keys, txTo23); - BOOST_CHECK(!VerifyScript(badsig2, scriptPubKey23, txTo23, 0, true, true, 0)); + BOOST_CHECK(!VerifyScript(badsig2, scriptPubKey23, txTo23, 0, flags, 0)); keys.clear(); keys.push_back(key3); keys.push_back(key2); // sigs must be in correct order CScript badsig3 = sign_multisig(scriptPubKey23, keys, txTo23); - BOOST_CHECK(!VerifyScript(badsig3, scriptPubKey23, txTo23, 0, true, true, 0)); + BOOST_CHECK(!VerifyScript(badsig3, scriptPubKey23, txTo23, 0, flags, 0)); keys.clear(); keys.push_back(key4); keys.push_back(key2); // sigs must match pubkeys CScript badsig4 = sign_multisig(scriptPubKey23, keys, txTo23); - BOOST_CHECK(!VerifyScript(badsig4, scriptPubKey23, txTo23, 0, true, true, 0)); + BOOST_CHECK(!VerifyScript(badsig4, scriptPubKey23, txTo23, 0, flags, 0)); keys.clear(); keys.push_back(key1); keys.push_back(key4); // sigs must match pubkeys CScript badsig5 = sign_multisig(scriptPubKey23, keys, txTo23); - BOOST_CHECK(!VerifyScript(badsig5, scriptPubKey23, txTo23, 0, true, true, 0)); + BOOST_CHECK(!VerifyScript(badsig5, scriptPubKey23, txTo23, 0, flags, 0)); keys.clear(); // Must have signatures CScript badsig6 = sign_multisig(scriptPubKey23, keys, txTo23); - BOOST_CHECK(!VerifyScript(badsig6, scriptPubKey23, txTo23, 0, true, true, 0)); + BOOST_CHECK(!VerifyScript(badsig6, scriptPubKey23, txTo23, 0, flags, 0)); } BOOST_AUTO_TEST_CASE(script_combineSigs) diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index 4385b9ba37..23837c6c15 100644 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -76,7 +76,7 @@ BOOST_AUTO_TEST_CASE(tx_valid) break; } - BOOST_CHECK_MESSAGE(VerifyScript(tx.vin[i].scriptSig, mapprevOutScriptPubKeys[tx.vin[i].prevout], tx, i, test[2].get_bool(), false, 0), strTest); + BOOST_CHECK_MESSAGE(VerifyScript(tx.vin[i].scriptSig, mapprevOutScriptPubKeys[tx.vin[i].prevout], tx, i, test[2].get_bool() ? SCRIPT_VERIFY_P2SH : SCRIPT_VERIFY_NONE, 0), strTest); } } } @@ -143,7 +143,7 @@ BOOST_AUTO_TEST_CASE(tx_invalid) break; } - fValid = VerifyScript(tx.vin[i].scriptSig, mapprevOutScriptPubKeys[tx.vin[i].prevout], tx, i, test[2].get_bool(), true, 0); + fValid = VerifyScript(tx.vin[i].scriptSig, mapprevOutScriptPubKeys[tx.vin[i].prevout], tx, i, test[2].get_bool() ? SCRIPT_VERIFY_P2SH : SCRIPT_VERIFY_NONE, 0); } BOOST_CHECK_MESSAGE(!fValid, strTest); diff --git a/src/wallet.cpp b/src/wallet.cpp index fdb03431b1..1a74e7bb4c 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -291,10 +291,14 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase) return true; } -int64 CWallet::IncOrderPosNext() +int64 CWallet::IncOrderPosNext(CWalletDB *pwalletdb) { - int64 nRet = nOrderPosNext; - CWalletDB(strWalletFile).WriteOrderPosNext(++nOrderPosNext); + int64 nRet = nOrderPosNext++; + if (pwalletdb) { + pwalletdb->WriteOrderPosNext(nOrderPosNext); + } else { + CWalletDB(strWalletFile).WriteOrderPosNext(nOrderPosNext); + } return nRet; } diff --git a/src/wallet.h b/src/wallet.h index 5e2f8e0ba1..05d60056f4 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -149,7 +149,7 @@ public: /** Increment the next transaction order id @return next transaction order id */ - int64 IncOrderPosNext(); + int64 IncOrderPosNext(CWalletDB *pwalletdb = NULL); typedef std::pair<CWalletTx*, CAccountingEntry*> TxPair; typedef std::multimap<int64, TxPair > TxItems; |