aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core.h4
-rw-r--r--src/main.cpp2
-rw-r--r--src/script.cpp4
-rw-r--r--src/sync.cpp5
-rw-r--r--src/test/base58_tests.cpp6
-rw-r--r--src/test/bignum_tests.cpp36
-rw-r--r--src/test/transaction_tests.cpp4
-rw-r--r--src/wallet.cpp41
-rw-r--r--src/wallet.h2
9 files changed, 76 insertions, 28 deletions
diff --git a/src/core.h b/src/core.h
index e61cad90ec..5eb953610d 100644
--- a/src/core.h
+++ b/src/core.h
@@ -156,8 +156,8 @@ public:
// to spend something, then we consider it dust.
// A typical txout is 34 bytes big, and will
// need a CTxIn of at least 148 bytes to spend,
- // so dust is a txout less than 54 uBTC
- // (5460 satoshis) with default nMinRelayTxFee
+ // so dust is a txout less than 546 satoshis
+ // with default nMinRelayTxFee.
return ((nValue*1000)/(3*((int)GetSerializeSize(SER_DISK,0)+148)) < nMinRelayTxFee);
}
diff --git a/src/main.cpp b/src/main.cpp
index 4c98345d68..53b99101d9 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -52,7 +52,7 @@ unsigned int nCoinCacheSize = 5000;
/** Fees smaller than this (in satoshi) are considered zero fee (for transaction creation) */
int64_t CTransaction::nMinTxFee = 10000; // Override with -mintxfee
/** Fees smaller than this (in satoshi) are considered zero fee (for relaying) */
-int64_t CTransaction::nMinRelayTxFee = 10000;
+int64_t CTransaction::nMinRelayTxFee = 1000;
static CMedianFilter<int> cPeerBlockCounts(8, 0); // Amount of blocks that other nodes claim to have
diff --git a/src/script.cpp b/src/script.cpp
index 83fc91956c..f03a1e3cbb 100644
--- a/src/script.cpp
+++ b/src/script.cpp
@@ -1261,7 +1261,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector<vector<unsi
// Template matching opcodes:
if (opcode2 == OP_PUBKEYS)
{
- while (vch1.size() >= 33 && vch1.size() <= 120)
+ while (vch1.size() >= 33 && vch1.size() <= 65)
{
vSolutionsRet.push_back(vch1);
if (!script1.GetOp(pc1, opcode1, vch1))
@@ -1275,7 +1275,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector<vector<unsi
if (opcode2 == OP_PUBKEY)
{
- if (vch1.size() < 33 || vch1.size() > 120)
+ if (vch1.size() < 33 || vch1.size() > 65)
break;
vSolutionsRet.push_back(vch1);
}
diff --git a/src/sync.cpp b/src/sync.cpp
index 8f713807f7..e624a9ee84 100644
--- a/src/sync.cpp
+++ b/src/sync.cpp
@@ -140,8 +140,9 @@ void AssertLockHeldInternal(const char *pszName, const char* pszFile, int nLine,
{
BOOST_FOREACH(const PAIRTYPE(void*, CLockLocation)&i, *lockstack)
if (i.first == cs) return;
- LogPrintf("Lock %s not held in %s:%i; locks held:\n%s", pszName, pszFile, nLine, LocksHeld());
- assert(0);
+ fprintf(stderr, "Assertion failed: lock %s not held in %s:%i; locks held:\n%s",
+ pszName, pszFile, nLine, LocksHeld().c_str());
+ abort();
}
#endif /* DEBUG_LOCKORDER */
diff --git a/src/test/base58_tests.cpp b/src/test/base58_tests.cpp
index 84db99d816..94e84049be 100644
--- a/src/test/base58_tests.cpp
+++ b/src/test/base58_tests.cpp
@@ -63,6 +63,12 @@ BOOST_AUTO_TEST_CASE(base58_DecodeBase58)
}
BOOST_CHECK(!DecodeBase58("invalid", result));
+
+ // check that DecodeBase58 skips whitespace, but still fails with unexpected non-whitespace at the end.
+ BOOST_CHECK(!DecodeBase58(" \t\n\v\f\r skip \r\f\v\n\t a", result));
+ BOOST_CHECK( DecodeBase58(" \t\n\v\f\r skip \r\f\v\n\t ", result));
+ std::vector<unsigned char> expected = ParseHex("971a55");
+ BOOST_CHECK_EQUAL_COLLECTIONS(result.begin(), result.end(), expected.begin(), expected.end());
}
// Visitor to check address type
diff --git a/src/test/bignum_tests.cpp b/src/test/bignum_tests.cpp
index 9d67324c76..205b15adcf 100644
--- a/src/test/bignum_tests.cpp
+++ b/src/test/bignum_tests.cpp
@@ -135,6 +135,42 @@ BOOST_AUTO_TEST_CASE(bignum_SetCompact)
BOOST_CHECK_EQUAL(num.GetHex(), "0");
BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
+ num.SetCompact(0x01003456);
+ BOOST_CHECK_EQUAL(num.GetHex(), "0");
+ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
+
+ num.SetCompact(0x02000056);
+ BOOST_CHECK_EQUAL(num.GetHex(), "0");
+ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
+
+ num.SetCompact(0x03000000);
+ BOOST_CHECK_EQUAL(num.GetHex(), "0");
+ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
+
+ num.SetCompact(0x04000000);
+ BOOST_CHECK_EQUAL(num.GetHex(), "0");
+ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
+
+ num.SetCompact(0x00923456);
+ BOOST_CHECK_EQUAL(num.GetHex(), "0");
+ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
+
+ num.SetCompact(0x01803456);
+ BOOST_CHECK_EQUAL(num.GetHex(), "0");
+ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
+
+ num.SetCompact(0x02800056);
+ BOOST_CHECK_EQUAL(num.GetHex(), "0");
+ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
+
+ num.SetCompact(0x03800000);
+ BOOST_CHECK_EQUAL(num.GetHex(), "0");
+ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
+
+ num.SetCompact(0x04800000);
+ BOOST_CHECK_EQUAL(num.GetHex(), "0");
+ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
+
num.SetCompact(0x01123456);
BOOST_CHECK_EQUAL(num.GetHex(), "12");
BOOST_CHECK_EQUAL(num.GetCompact(), 0x01120000U);
diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp
index ad33184bc5..5212dfc70d 100644
--- a/src/test/transaction_tests.cpp
+++ b/src/test/transaction_tests.cpp
@@ -271,10 +271,10 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
string reason;
BOOST_CHECK(IsStandardTx(t, reason));
- t.vout[0].nValue = 5011; // dust
+ t.vout[0].nValue = 501; // dust
BOOST_CHECK(!IsStandardTx(t, reason));
- t.vout[0].nValue = 6011; // not dust
+ t.vout[0].nValue = 601; // not dust
BOOST_CHECK(IsStandardTx(t, reason));
t.vout[0].scriptPubKey = CScript() << OP_1;
diff --git a/src/wallet.cpp b/src/wallet.cpp
index 2119098595..5e24738b54 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -192,7 +192,7 @@ void CWallet::SetBestChain(const CBlockLocator& loc)
bool CWallet::SetMinVersion(enum WalletFeature nVersion, CWalletDB* pwalletdbIn, bool fExplicit)
{
- AssertLockHeld(cs_wallet); // nWalletVersion
+ LOCK(cs_wallet); // nWalletVersion
if (nWalletVersion >= nVersion)
return true;
@@ -219,7 +219,7 @@ bool CWallet::SetMinVersion(enum WalletFeature nVersion, CWalletDB* pwalletdbIn,
bool CWallet::SetMaxVersion(int nVersion)
{
- AssertLockHeld(cs_wallet); // nWalletVersion, nWalletMaxVersion
+ LOCK(cs_wallet); // nWalletVersion, nWalletMaxVersion
// cannot downgrade below current version
if (nWalletVersion > nVersion)
return false;
@@ -1621,14 +1621,17 @@ DBErrors CWallet::ZapWalletTx()
bool CWallet::SetAddressBook(const CTxDestination& address, const string& strName, const string& strPurpose)
{
- AssertLockHeld(cs_wallet); // mapAddressBook
- std::map<CTxDestination, CAddressBookData>::iterator mi = mapAddressBook.find(address);
- mapAddressBook[address].name = strName;
- if (!strPurpose.empty()) /* update purpose only if requested */
- mapAddressBook[address].purpose = strPurpose;
+ bool fUpdated = false;
+ {
+ LOCK(cs_wallet); // mapAddressBook
+ std::map<CTxDestination, CAddressBookData>::iterator mi = mapAddressBook.find(address);
+ fUpdated = mi != mapAddressBook.end();
+ mapAddressBook[address].name = strName;
+ if (!strPurpose.empty()) /* update purpose only if requested */
+ mapAddressBook[address].purpose = strPurpose;
+ }
NotifyAddressBookChanged(this, address, strName, ::IsMine(*this, address),
- mapAddressBook[address].purpose,
- (mi == mapAddressBook.end()) ? CT_NEW : CT_UPDATED);
+ strPurpose, (fUpdated ? CT_UPDATED : CT_NEW) );
if (!fFileBacked)
return false;
if (!strPurpose.empty() && !CWalletDB(strWalletFile).WritePurpose(CBitcoinAddress(address).ToString(), strPurpose))
@@ -1638,21 +1641,23 @@ bool CWallet::SetAddressBook(const CTxDestination& address, const string& strNam
bool CWallet::DelAddressBook(const CTxDestination& address)
{
-
- AssertLockHeld(cs_wallet); // mapAddressBook
-
- if(fFileBacked)
{
- // Delete destdata tuples associated with address
- std::string strAddress = CBitcoinAddress(address).ToString();
- BOOST_FOREACH(const PAIRTYPE(string, string) &item, mapAddressBook[address].destdata)
+ LOCK(cs_wallet); // mapAddressBook
+
+ if(fFileBacked)
{
- CWalletDB(strWalletFile).EraseDestData(strAddress, item.first);
+ // Delete destdata tuples associated with address
+ std::string strAddress = CBitcoinAddress(address).ToString();
+ BOOST_FOREACH(const PAIRTYPE(string, string) &item, mapAddressBook[address].destdata)
+ {
+ CWalletDB(strWalletFile).EraseDestData(strAddress, item.first);
+ }
}
+ mapAddressBook.erase(address);
}
- mapAddressBook.erase(address);
NotifyAddressBookChanged(this, address, "", ::IsMine(*this, address), "", CT_DELETED);
+
if (!fFileBacked)
return false;
CWalletDB(strWalletFile).ErasePurpose(CBitcoinAddress(address).ToString());
diff --git a/src/wallet.h b/src/wallet.h
index 95fb0ee9de..eb192f1ca6 100644
--- a/src/wallet.h
+++ b/src/wallet.h
@@ -363,7 +363,7 @@ public:
bool SetMaxVersion(int nVersion);
// get the current wallet format (the oldest client version guaranteed to understand this wallet)
- int GetVersion() { AssertLockHeld(cs_wallet); return nWalletVersion; }
+ int GetVersion() { LOCK(cs_wallet); return nWalletVersion; }
// Get wallet transactions that conflict with given transaction (spend same outputs)
std::set<uint256> GetConflicts(const uint256& txid) const;