aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/README.md2
-rw-r--r--contrib/gitian-descriptors/boost-linux.yml1
-rw-r--r--qa/rpc-tests/README.md23
-rwxr-xr-xqa/rpc-tests/walletbackup.sh293
-rw-r--r--src/alert.cpp1
-rw-r--r--src/core.h4
-rw-r--r--src/db.cpp1
-rw-r--r--src/init.cpp1
-rw-r--r--src/main.cpp28
-rw-r--r--src/net.h1
-rw-r--r--src/qt/forms/overviewpage.ui4
-rw-r--r--src/qt/optionsmodel.cpp2
-rw-r--r--src/rpcnet.cpp2
-rw-r--r--src/rpcrawtransaction.cpp4
-rw-r--r--src/rpcwallet.cpp10
-rw-r--r--src/script.cpp4
-rw-r--r--src/test/transaction_tests.cpp4
-rw-r--r--src/txdb.h6
-rw-r--r--src/util.h27
-rw-r--r--src/wallet.cpp2
-rw-r--r--src/walletdb.cpp2
21 files changed, 376 insertions, 46 deletions
diff --git a/contrib/README.md b/contrib/README.md
index 167b5df4e1..cd0dd3b023 100644
--- a/contrib/README.md
+++ b/contrib/README.md
@@ -52,7 +52,7 @@ tests each pull and when master is tested using jenkins.
### [Verify SF Binaries](/contrib/verifysfbinaries) ###
This script attempts to download and verify the signature file SHA256SUMS.asc from SourceForge.
-### [Developer tools](/control/devtools) ###
+### [Developer tools](/contrib/devtools) ###
Specific tools for developers working on this repository.
Contains the script `github-merge.sh` for merging github pull requests securely and signing them using GPG.
diff --git a/contrib/gitian-descriptors/boost-linux.yml b/contrib/gitian-descriptors/boost-linux.yml
index a538ff30a8..bd35346337 100644
--- a/contrib/gitian-descriptors/boost-linux.yml
+++ b/contrib/gitian-descriptors/boost-linux.yml
@@ -13,6 +13,7 @@ packages:
- "faketime"
- "bsdmainutils"
- "zip"
+- "libz-dev"
reference_datetime: "2011-01-30 00:00:00"
remotes: []
files:
diff --git a/qa/rpc-tests/README.md b/qa/rpc-tests/README.md
index c8537247d9..ee9e8b35ca 100644
--- a/qa/rpc-tests/README.md
+++ b/qa/rpc-tests/README.md
@@ -1,6 +1,25 @@
Regression tests of RPC interface
=================================
-wallet.sh : Test wallet send/receive code (see comments for details)
+wallet.sh : Exercise wallet send/receive code.
-util.sh : useful re-usable functions
+walletbackup.sh : Exercise wallet backup / dump / import
+
+txnmall.sh : Test proper accounting of malleable transactions
+
+conflictedbalance.sh : More testing of malleable transaction handling
+
+util.sh : useful re-usable bash functions
+
+
+Tips for creating new tests
+===========================
+
+To cleanup after a failed or interrupted test:
+ killall bitcoind
+ rm -rf test.*
+
+The most difficult part of writing reproducible tests is
+keeping multiple nodes in sync. See WaitBlocks,
+WaitPeers, and WaitMemPools for how other tests
+deal with this.
diff --git a/qa/rpc-tests/walletbackup.sh b/qa/rpc-tests/walletbackup.sh
new file mode 100755
index 0000000000..9207243b62
--- /dev/null
+++ b/qa/rpc-tests/walletbackup.sh
@@ -0,0 +1,293 @@
+#!/usr/bin/env bash
+
+# Test wallet backup / dump / restore functionality
+
+# Test case is:
+# 4 nodes. 1 2 3 and send transactions between each other,
+# fourth node is a miner.
+# 1 2 3 and each mine a block to start, then
+# miner creates 100 blocks so 1 2 3 each have 50 mature
+# coins to spend.
+# Then 5 iterations of 1/2/3 sending coins amongst
+# themselves to get transactions in the wallets,
+# and the miner mining one block.
+#
+# Wallets are backed up using dumpwallet/backupwallet.
+# Then 5 more iterations of transactions, then block.
+#
+# Miner then generates 101 more blocks, so any
+# transaction fees paid mature.
+#
+# Sanity checks done:
+# Miner balance >= 150*50
+# Sum(1,2,3,4 balances) == 153*150
+#
+# 1/2/3 are shutdown, and their wallets erased.
+# Then restore using wallet.dat backup. And
+# confirm 1/2/3/4 balances are same as before.
+#
+# Shutdown again, restore using importwallet,
+# and confirm again balances are correct.
+#
+
+if [ $# -lt 1 ]; then
+ echo "Usage: $0 path_to_binaries"
+ echo "e.g. $0 ../../src"
+ exit 1
+fi
+
+BITCOIND=${1}/bitcoind
+CLI=${1}/bitcoin-cli
+
+DIR="${BASH_SOURCE%/*}"
+SENDANDWAIT="${DIR}/send.sh"
+if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
+. "$DIR/util.sh"
+
+D=$(mktemp -d test.XXXXX)
+
+echo "Starting nodes..."
+
+# "Miner":
+D4=${D}/node4
+CreateDataDir $D4 port=11030 rpcport=11031
+B4ARGS="-datadir=$D4"
+$BITCOIND $BITCOINDARGS $B4ARGS &
+B4PID=$!
+
+# Want default keypool for 1/2/3, and
+# don't need send-and-wait functionality,
+# so don't use CreateDataDir:
+function CreateConfDir {
+ DIR=$1
+ mkdir -p $DIR
+ CONF=$DIR/bitcoin.conf
+ echo "regtest=1" >> $CONF
+ echo "rpcuser=rt" >> $CONF
+ echo "rpcpassword=rt" >> $CONF
+ echo "rpcwait=1" >> $CONF
+ shift
+ while (( "$#" )); do
+ echo $1 >> $CONF
+ shift
+ done
+}
+
+# "Spenders" 1/2/3
+D1=${D}/node1
+CreateConfDir $D1 port=11000 rpcport=11001 addnode=127.0.0.1:11030
+B1ARGS="-datadir=$D1"
+$BITCOIND $B1ARGS &
+B1PID=$!
+D2=${D}/node2
+CreateConfDir $D2 port=11010 rpcport=11011 addnode=127.0.0.1:11030
+B2ARGS="-datadir=$D2"
+$BITCOIND $B2ARGS &
+B2PID=$!
+D3=${D}/node3
+CreateConfDir $D3 port=11020 rpcport=11021 addnode=127.0.0.1:11030 addnode=127.0.0.1:11000
+B3ARGS="-datadir=$D3"
+$BITCOIND $BITCOINDARGS $B3ARGS &
+B3PID=$!
+
+# Wait until all nodes are at the same block number
+function WaitBlocks {
+ while :
+ do
+ sleep 1
+ BLOCKS1=$( GetBlocks "$B1ARGS" )
+ BLOCKS2=$( GetBlocks "$B2ARGS" )
+ BLOCKS3=$( GetBlocks "$B3ARGS" )
+ BLOCKS4=$( GetBlocks "$B4ARGS" )
+ if (( BLOCKS1 == BLOCKS4 && BLOCKS2 == BLOCKS4 && BLOCKS3 == BLOCKS4 ))
+ then
+ break
+ fi
+ done
+}
+
+# Wait until all nodes have the same txns in
+# their memory pools
+function WaitMemPools {
+ while :
+ do
+ sleep 1
+ MEMPOOL1=$( $CLI "$B1ARGS" getrawmempool | sort | shasum )
+ MEMPOOL2=$( $CLI "$B2ARGS" getrawmempool | sort | shasum )
+ MEMPOOL3=$( $CLI "$B3ARGS" getrawmempool | sort | shasum )
+ MEMPOOL4=$( $CLI "$B4ARGS" getrawmempool | sort | shasum )
+ if [[ $MEMPOOL1 = $MEMPOOL4 && $MEMPOOL2 = $MEMPOOL4 && $MEMPOOL3 = $MEMPOOL4 ]]
+ then
+ break
+ fi
+ done
+}
+
+echo "Generating initial blockchain..."
+
+# 1 block, 50 XBT each == 50 BTC
+$CLI $B1ARGS setgenerate true 1
+WaitBlocks
+$CLI $B2ARGS setgenerate true 1
+WaitBlocks
+$CLI $B3ARGS setgenerate true 1
+WaitBlocks
+
+# 100 blocks, 0 mature
+$CLI $B4ARGS setgenerate true 100
+WaitBlocks
+
+CheckBalance "$B1ARGS" 50
+CheckBalance "$B2ARGS" 50
+CheckBalance "$B3ARGS" 50
+CheckBalance "$B4ARGS" 0
+
+echo "Creating transactions..."
+
+function S {
+ TXID=$( $CLI -datadir=${D}/node${1} sendtoaddress ${2} "${3}" 0 )
+ if [[ $TXID == "" ]] ; then
+ echoerr "node${1}: error sending ${3} btc"
+ echo -n "node${1} balance: "
+ $CLI -datadir=${D}/node${1} getbalance "*" 0
+ exit 1
+ fi
+}
+
+function OneRound {
+ A1=$( $CLI $B1ARGS getnewaddress )
+ A2=$( $CLI $B2ARGS getnewaddress )
+ A3=$( $CLI $B3ARGS getnewaddress )
+ if [[ $(( $RANDOM%2 )) < 1 ]] ; then
+ N=$(( $RANDOM % 9 + 1 ))
+ S 1 $A2 "0.$N"
+ fi
+ if [[ $(( $RANDOM%2 )) < 1 ]] ; then
+ N=$(( $RANDOM % 9 + 1 ))
+ S 1 $A3 "0.0$N"
+ fi
+ if [[ $(( $RANDOM%2 )) < 1 ]] ; then
+ N=$(( $RANDOM % 9 + 1 ))
+ S 2 $A1 "0.$N"
+ fi
+ if [[ $(( $RANDOM%2 )) < 1 ]] ; then
+ N=$(( $RANDOM % 9 + 1 ))
+ S 2 $A3 "0.$N"
+ fi
+ if [[ $(( $RANDOM%2 )) < 1 ]] ; then
+ N=$(( $RANDOM % 9 + 1 ))
+ S 3 $A1 "0.$N"
+ fi
+ if [[ $(( $RANDOM%2 )) < 1 ]] ; then
+ N=$(( $RANDOM % 9 + 1 ))
+ S 3 $A2 "0.0$N"
+ fi
+ $CLI "$B4ARGS" setgenerate true 1
+}
+
+for i in {1..5}; do OneRound ; done
+
+echo "Backing up..."
+
+$CLI "$B1ARGS" backupwallet "$D1/wallet.bak"
+$CLI "$B1ARGS" dumpwallet "$D1/wallet.dump"
+$CLI "$B2ARGS" backupwallet "$D2/wallet.bak"
+$CLI "$B2ARGS" dumpwallet "$D2/wallet.dump"
+$CLI "$B3ARGS" backupwallet "$D3/wallet.bak"
+$CLI "$B3ARGS" dumpwallet "$D3/wallet.dump"
+
+echo "More transactions..."
+for i in {1..5}; do OneRound ; done
+
+WaitMemPools
+
+# Generate 101 more blocks, so any fees paid
+# mature
+$CLI "$B4ARGS" setgenerate true 101
+
+BALANCE1=$( $CLI "$B1ARGS" getbalance )
+BALANCE2=$( $CLI "$B2ARGS" getbalance )
+BALANCE3=$( $CLI "$B3ARGS" getbalance )
+BALANCE4=$( $CLI "$B4ARGS" getbalance )
+
+TOTAL=$( dc -e "$BALANCE1 $BALANCE2 $BALANCE3 $BALANCE4 + + + p" )
+
+AssertEqual $TOTAL 5700.00000000
+
+function StopThree {
+ $CLI $B1ARGS stop > /dev/null 2>&1
+ $CLI $B2ARGS stop > /dev/null 2>&1
+ $CLI $B3ARGS stop > /dev/null 2>&1
+ wait $B1PID
+ wait $B2PID
+ wait $B3PID
+}
+function EraseThree {
+ rm $D1/regtest/wallet.dat
+ rm $D2/regtest/wallet.dat
+ rm $D3/regtest/wallet.dat
+}
+function StartThree {
+ $BITCOIND $BITCOINDARGS $B1ARGS &
+ B1PID=$!
+ $BITCOIND $BITCOINDARGS $B2ARGS &
+ B2PID=$!
+ $BITCOIND $BITCOINDARGS $B3ARGS &
+ B3PID=$!
+}
+
+echo "Restoring using wallet.dat"
+
+StopThree
+EraseThree
+
+# Start node3 with no chain
+rm -rf $D3/regtest/blocks
+rm -rf $D3/regtest/chainstate
+rm -rf $D3/regtest/database
+
+cp $D1/wallet.bak $D1/regtest/wallet.dat
+cp $D2/wallet.bak $D2/regtest/wallet.dat
+cp $D3/wallet.bak $D3/regtest/wallet.dat
+
+StartThree
+WaitBlocks
+
+AssertEqual $BALANCE1 $( $CLI "$B1ARGS" getbalance )
+AssertEqual $BALANCE2 $( $CLI "$B2ARGS" getbalance )
+AssertEqual $BALANCE3 $( $CLI "$B3ARGS" getbalance )
+
+echo "Restoring using dumped wallet"
+
+StopThree
+EraseThree
+
+# Start node3 with no chain
+rm -rf $D3/regtest/blocks
+rm -rf $D3/regtest/chainstate
+rm -rf $D3/regtest/database
+
+StartThree
+
+AssertEqual 0 $( $CLI "$B1ARGS" getbalance )
+AssertEqual 0 $( $CLI "$B2ARGS" getbalance )
+AssertEqual 0 $( $CLI "$B3ARGS" getbalance )
+
+$CLI "$B1ARGS" importwallet $D1/wallet.dump
+$CLI "$B2ARGS" importwallet $D2/wallet.dump
+$CLI "$B3ARGS" importwallet $D3/wallet.dump
+
+WaitBlocks
+
+AssertEqual $BALANCE1 $( $CLI "$B1ARGS" getbalance )
+AssertEqual $BALANCE2 $( $CLI "$B2ARGS" getbalance )
+AssertEqual $BALANCE3 $( $CLI "$B3ARGS" getbalance )
+
+StopThree
+$CLI $B4ARGS stop > /dev/null 2>&1
+wait $B4PID
+
+echo "Tests successful, cleaning up"
+trap "" EXIT
+rm -rf $D
+exit 0
diff --git a/src/alert.cpp b/src/alert.cpp
index 4dd3716e80..4429ecadce 100644
--- a/src/alert.cpp
+++ b/src/alert.cpp
@@ -11,7 +11,6 @@
#include "util.h"
#include <algorithm>
-#include <inttypes.h>
#include <map>
#include <boost/algorithm/string/classification.hpp>
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/db.cpp b/src/db.cpp
index 592512c947..591d4ed477 100644
--- a/src/db.cpp
+++ b/src/db.cpp
@@ -10,7 +10,6 @@
#include "protocol.h"
#include "util.h"
-#include <inttypes.h>
#include <stdint.h>
#ifndef WIN32
diff --git a/src/init.cpp b/src/init.cpp
index c05ed4356c..4cc04f5205 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -24,7 +24,6 @@
#include "walletdb.h"
#endif
-#include <inttypes.h>
#include <stdint.h>
#ifndef WIN32
diff --git a/src/main.cpp b/src/main.cpp
index 8e879c3169..53b99101d9 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -17,7 +17,6 @@
#include "ui_interface.h"
#include "util.h"
-#include <inttypes.h>
#include <sstream>
#include <boost/algorithm/string/replace.hpp>
@@ -53,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
@@ -2276,6 +2275,11 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CDiskBlockPos* dbp)
return state.DoS(100, error("AcceptBlock() : rejected by checkpoint lock-in at %d", nHeight),
REJECT_CHECKPOINT, "checkpoint mismatch");
+ // Don't accept any forks from the main chain prior to last checkpoint
+ CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(mapBlockIndex);
+ if (pcheckpoint && nHeight < pcheckpoint->nHeight)
+ return state.DoS(100, error("AcceptBlock() : forked chain older than last checkpoint (height %d)", nHeight));
+
// Reject block.nVersion=1 blocks when 95% (75% on testnet) of the network has upgraded:
if (block.nVersion < 2)
{
@@ -3133,10 +3137,28 @@ void static ProcessGetData(CNode* pfrom)
if (inv.type == MSG_BLOCK || inv.type == MSG_FILTERED_BLOCK)
{
- // Send block from disk
+ bool send = false;
map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(inv.hash);
if (mi != mapBlockIndex.end())
{
+ // If the requested block is at a height below our last
+ // checkpoint, only serve it if it's in the checkpointed chain
+ int nHeight = mi->second->nHeight;
+ CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(mapBlockIndex);
+ if (pcheckpoint && nHeight < pcheckpoint->nHeight) {
+ if (!chainActive.Contains(mi->second))
+ {
+ LogPrintf("ProcessGetData(): ignoring request for old block that isn't in the main chain\n");
+ } else {
+ send = true;
+ }
+ } else {
+ send = true;
+ }
+ }
+ if (send)
+ {
+ // Send block from disk
CBlock block;
ReadBlockFromDisk(block, (*mi).second);
if (inv.type == MSG_BLOCK)
diff --git a/src/net.h b/src/net.h
index 8995f70da4..da590f89e1 100644
--- a/src/net.h
+++ b/src/net.h
@@ -18,7 +18,6 @@
#include "util.h"
#include <deque>
-#include <inttypes.h>
#include <stdint.h>
#ifndef WIN32
diff --git a/src/qt/forms/overviewpage.ui b/src/qt/forms/overviewpage.ui
index d1ca969431..e662912781 100644
--- a/src/qt/forms/overviewpage.ui
+++ b/src/qt/forms/overviewpage.ui
@@ -105,7 +105,7 @@
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
- <string>Confirmed:</string>
+ <string>Available:</string>
</property>
</widget>
</item>
@@ -137,7 +137,7 @@
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
- <string>Unconfirmed:</string>
+ <string>Pending:</string>
</property>
</widget>
</item>
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index 1a460b9278..3b83a5ff62 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -85,7 +85,7 @@ void OptionsModel::Init()
#endif
if (!settings.contains("nDatabaseCache"))
- settings.setValue("nDatabaseCache", nDefaultDbCache);
+ settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache);
if (!SoftSetArg("-dbcache", settings.value("nDatabaseCache").toString().toStdString()))
strOverriddenByCommandLine += "-dbcache ";
diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp
index b764349338..738b966b8a 100644
--- a/src/rpcnet.cpp
+++ b/src/rpcnet.cpp
@@ -15,8 +15,6 @@
#include "wallet.h" // for getinfo
#endif
-#include <inttypes.h>
-
#include <boost/foreach.hpp>
#include "json/json_spirit_value.h"
diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp
index e2bdc80aef..837aee7eaa 100644
--- a/src/rpcrawtransaction.cpp
+++ b/src/rpcrawtransaction.cpp
@@ -522,7 +522,7 @@ Value signrawtransaction(const Array& params, bool fHelp)
"\nArguments:\n"
"1. \"hexstring\" (string, required) The transaction hex string\n"
"2. \"prevtxs\" (string, optional) An json array of previous dependent transaction outputs\n"
- " [ (json array of json objects)\n"
+ " [ (json array of json objects, or 'null' if none provided)\n"
" {\n"
" \"txid\":\"id\", (string, required) The transaction id\n"
" \"vout\":n, (numeric, required) The output number\n"
@@ -532,7 +532,7 @@ Value signrawtransaction(const Array& params, bool fHelp)
" ,...\n"
" ]\n"
"3. \"privatekeys\" (string, optional) A json array of base58-encoded private keys for signing\n"
- " [ (json array of strings)\n"
+ " [ (json array of strings, or 'null' if none provided)\n"
" \"privatekey\" (string) private key in base58-encoding\n"
" ,...\n"
" ]\n"
diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp
index 3b0c84e49e..7b605af589 100644
--- a/src/rpcwallet.cpp
+++ b/src/rpcwallet.cpp
@@ -1114,10 +1114,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
Object entry;
entry.push_back(Pair("account", strSentAccount));
MaybePushAddress(entry, s.first);
- if (wtx.GetDepthInMainChain() < 0)
- entry.push_back(Pair("category", "conflicted"));
- else
- entry.push_back(Pair("category", "send"));
+ entry.push_back(Pair("category", "send"));
entry.push_back(Pair("amount", ValueFromAmount(-s.second)));
entry.push_back(Pair("fee", ValueFromAmount(-nFee)));
if (fLong)
@@ -1150,10 +1147,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
}
else
{
- if (wtx.GetDepthInMainChain() < 0)
- entry.push_back(Pair("category", "conflicted"));
- else
- entry.push_back(Pair("category", "receive"));
+ entry.push_back(Pair("category", "receive"));
}
entry.push_back(Pair("amount", ValueFromAmount(r.second)));
if (fLong)
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/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/txdb.h b/src/txdb.h
index 0512396e97..5eb5731db3 100644
--- a/src/txdb.h
+++ b/src/txdb.h
@@ -19,11 +19,11 @@ class CCoins;
class uint256;
// -dbcache default (MiB)
-static const int nDefaultDbCache = 100;
+static const int64_t nDefaultDbCache = 100;
// max. -dbcache in (MiB)
-static const int nMaxDbCache = sizeof(void*) > 4 ? 4096 : 1024;
+static const int64_t nMaxDbCache = sizeof(void*) > 4 ? 4096 : 1024;
// min. -dbcache in (MiB)
-static const int nMinDbCache = 4;
+static const int64_t nMinDbCache = 4;
/** CCoinsView backed by the LevelDB coin database (chainstate/) */
class CCoinsViewDB : public CCoinsView
diff --git a/src/util.h b/src/util.h
index 6f7627e090..6ef93021fd 100644
--- a/src/util.h
+++ b/src/util.h
@@ -16,7 +16,6 @@
#include <cstdio>
#include <exception>
-#include <inttypes.h>
#include <map>
#include <stdarg.h>
#include <stdint.h>
@@ -45,13 +44,25 @@ static const int64_t CENT = 1000000;
#define UEND(a) ((unsigned char*)&((&(a))[1]))
#define ARRAYLEN(array) (sizeof(array)/sizeof((array)[0]))
-/* Format characters for (s)size_t and ptrdiff_t (C99 standard) */
-#define PRIszx "zx"
-#define PRIszu "zu"
-#define PRIszd "zd"
-#define PRIpdx "tx"
-#define PRIpdu "tu"
-#define PRIpdd "td"
+/* Format characters for (s)size_t, ptrdiff_t, uint64_t.
+ *
+ * As the tinyformat-based formatting system is type-safe, no special format
+ * characters are really needed to specify sizes. Tinyformat can support
+ * (ignores) the C99 prefixes such as "ll" but chokes on MSVC's inttypes
+ * defines prefixes such as "I64X". So don't include inttypes.h and define our
+ * own for compatibility.
+ * If you get a warning here about a redefine of PRI?64, make sure that
+ * inttypes.h is not included.
+ */
+#define PRIszx "x"
+#define PRIszu "u"
+#define PRIszd "d"
+#define PRIpdx "x"
+#define PRIpdu "u"
+#define PRIpdd "d"
+#define PRIx64 "x"
+#define PRIu64 "u"
+#define PRId64 "d"
// This is needed because the foreach macro can't get over the comma in pair<t1, t2>
#define PAIRTYPE(t1, t2) std::pair<t1, t2>
diff --git a/src/wallet.cpp b/src/wallet.cpp
index 82f71d24a5..5e24738b54 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -9,8 +9,6 @@
#include "coincontrol.h"
#include "net.h"
-#include <inttypes.h>
-
#include <boost/algorithm/string/replace.hpp>
#include <openssl/rand.h>
diff --git a/src/walletdb.cpp b/src/walletdb.cpp
index b3816a54b6..b5b523740b 100644
--- a/src/walletdb.cpp
+++ b/src/walletdb.cpp
@@ -11,8 +11,6 @@
#include "sync.h"
#include "wallet.h"
-#include <inttypes.h>
-
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>