aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/debian/copyright4
-rw-r--r--depends/.gitignore4
-rwxr-xr-xdepends/config.guess27
-rwxr-xr-xdepends/config.sub13
-rw-r--r--doc/REST-interface.md2
-rw-r--r--doc/dnsseed-policy.md5
-rw-r--r--doc/gitian-building.md4
-rw-r--r--doc/img/bootstrap1.pngbin55028 -> 0 bytes
-rw-r--r--doc/img/bootstrap2.pngbin35195 -> 0 bytes
-rw-r--r--doc/img/bootstrap4.pngbin110060 -> 0 bytes
-rw-r--r--doc/img/bootstrap5.pngbin20825 -> 0 bytes
-rwxr-xr-xqa/rpc-tests/reindex.py34
-rw-r--r--src/arith_uint256.h2
-rw-r--r--src/bitcoind.cpp2
-rw-r--r--src/chainparams.cpp10
-rw-r--r--src/chainparams.h7
-rw-r--r--src/consensus/params.h6
-rw-r--r--src/init.cpp18
-rw-r--r--src/main.cpp65
-rw-r--r--src/miner.cpp22
-rw-r--r--src/miner.h3
-rw-r--r--src/qt/bitcoin.cpp1
-rw-r--r--src/qt/bitcoingui.cpp2
-rw-r--r--src/qt/coincontroldialog.cpp2
-rw-r--r--src/qt/forms/sendcoinsentry.ui8
-rw-r--r--src/qt/guiutil.cpp10
-rw-r--r--src/qt/paymentrequestplus.cpp13
-rw-r--r--src/qt/paymentrequestplus.h1
-rw-r--r--src/qt/paymentserver.cpp36
-rw-r--r--src/qt/paymentserver.h2
-rw-r--r--src/qt/recentrequeststablemodel.cpp3
-rw-r--r--src/qt/sendcoinsdialog.cpp6
-rw-r--r--src/qt/sendcoinsentry.cpp12
-rw-r--r--src/qt/splashscreen.cpp5
-rw-r--r--src/qt/transactiondesc.cpp1
-rw-r--r--src/qt/walletmodel.cpp1
-rw-r--r--src/rpcmining.cpp27
-rw-r--r--src/rpcrawtransaction.cpp113
-rw-r--r--src/rpcserver.cpp177
-rw-r--r--src/rpcserver.h1
-rw-r--r--src/support/allocators/secure.h6
-rw-r--r--src/support/allocators/zeroafterfree.h6
-rw-r--r--src/support/pagelocker.h6
-rw-r--r--src/sync.h23
-rw-r--r--src/wallet/crypter.h6
-rw-r--r--src/wallet/db.h6
-rw-r--r--src/wallet/rpcdump.cpp16
-rw-r--r--src/wallet/rpcwallet.cpp226
-rw-r--r--src/wallet/wallet.cpp2
-rw-r--r--src/wallet/wallet.h6
-rw-r--r--src/wallet/wallet_ismine.h6
-rw-r--r--src/wallet/walletdb.h6
52 files changed, 575 insertions, 389 deletions
diff --git a/contrib/debian/copyright b/contrib/debian/copyright
index a6ee201991..3741031f9c 100644
--- a/contrib/debian/copyright
+++ b/contrib/debian/copyright
@@ -15,10 +15,6 @@ Files: src/json/*
Copyright: 2007-2009, John W. Wilkinson
License: Expat
-Files: src/strlcpy.h
-Copyright: 1998, Todd C. Miller <Todd.Miller@courtesan.com>
-License: ISC
-
Files: debian/*
Copyright: 2010-2011, Jonas Smedegaard <dr@jones.dk>
2011, Matt Corallo <matt@bluematt.me>
diff --git a/depends/.gitignore b/depends/.gitignore
index 82c48638b0..1f163897b9 100644
--- a/depends/.gitignore
+++ b/depends/.gitignore
@@ -3,3 +3,7 @@ work/
built/
sources/
config.site
+x86_64*
+i686*
+mips*
+arm*
diff --git a/depends/config.guess b/depends/config.guess
index dbfb9786cb..f7eb141e75 100755
--- a/depends/config.guess
+++ b/depends/config.guess
@@ -2,7 +2,7 @@
# Attempt to guess a canonical system name.
# Copyright 1992-2015 Free Software Foundation, Inc.
-timestamp='2015-01-01'
+timestamp='2015-03-04'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@@ -168,20 +168,27 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# Note: NetBSD doesn't particularly care about the vendor
# portion of the name. We always set it to "unknown".
sysctl="sysctl -n hw.machine_arch"
- UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
- /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+ UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
+ /sbin/$sysctl 2>/dev/null || \
+ /usr/sbin/$sysctl 2>/dev/null || \
+ echo unknown)`
case "${UNAME_MACHINE_ARCH}" in
armeb) machine=armeb-unknown ;;
arm*) machine=arm-unknown ;;
sh3el) machine=shl-unknown ;;
sh3eb) machine=sh-unknown ;;
sh5el) machine=sh5le-unknown ;;
+ earmv*)
+ arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
+ endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'`
+ machine=${arch}${endian}-unknown
+ ;;
*) machine=${UNAME_MACHINE_ARCH}-unknown ;;
esac
# The Operating System including object format, if it has switched
# to ELF recently, or will in the future.
case "${UNAME_MACHINE_ARCH}" in
- arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+ arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax)
eval $set_cc_for_build
if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ELF__
@@ -197,6 +204,13 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
os=netbsd
;;
esac
+ # Determine ABI tags.
+ case "${UNAME_MACHINE_ARCH}" in
+ earm*)
+ expr='s/^earmv[0-9]/-eabi/;s/eb$//'
+ abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"`
+ ;;
+ esac
# The OS release
# Debian GNU/NetBSD machines have a different userland, and
# thus, need a distinct triplet. However, they do not need
@@ -213,7 +227,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
# contains redundant information, the shorter form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
- echo "${machine}-${os}${release}"
+ echo "${machine}-${os}${release}${abi}"
exit ;;
*:Bitrig:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
@@ -933,6 +947,9 @@ EOF
crisv32:Linux:*:*)
echo ${UNAME_MACHINE}-axis-linux-${LIBC}
exit ;;
+ e2k:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
frv:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
diff --git a/depends/config.sub b/depends/config.sub
index 6d2e94c8bf..8f1229c6f7 100755
--- a/depends/config.sub
+++ b/depends/config.sub
@@ -2,7 +2,7 @@
# Configuration validation subroutine script.
# Copyright 1992-2015 Free Software Foundation, Inc.
-timestamp='2015-01-01'
+timestamp='2015-03-08'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@@ -117,7 +117,7 @@ maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
- knetbsd*-gnu* | netbsd*-gnu* | \
+ knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
kopensolaris*-gnu* | \
storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
@@ -259,7 +259,7 @@ case $basic_machine in
| bfin \
| c4x | c8051 | clipper \
| d10v | d30v | dlx | dsp16xx \
- | epiphany \
+ | e2k | epiphany \
| fido | fr30 | frv | ft32 \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| hexagon \
@@ -381,7 +381,7 @@ case $basic_machine in
| c[123]* | c30-* | [cjt]90-* | c4x-* \
| c8051-* | clipper-* | craynv-* | cydra-* \
| d10v-* | d30v-* | dlx-* \
- | elxsi-* \
+ | e2k-* | elxsi-* \
| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
| h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
@@ -518,6 +518,9 @@ case $basic_machine in
basic_machine=i386-pc
os=-aros
;;
+ asmjs)
+ basic_machine=asmjs-unknown
+ ;;
aux)
basic_machine=m68k-apple
os=-aux
@@ -1373,7 +1376,7 @@ case $os in
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
| -sym* | -kopensolaris* | -plan9* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
- | -aos* | -aros* \
+ | -aos* | -aros* | -cloudabi* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
diff --git a/doc/REST-interface.md b/doc/REST-interface.md
index 23154ee903..f14aed7287 100644
--- a/doc/REST-interface.md
+++ b/doc/REST-interface.md
@@ -36,4 +36,4 @@ Only supports JSON as output format.
Risks
-------------
-Running a webbrowser on the same node with a REST enabled bitcoind can be a risk. Accessing prepared XSS websites could read out tx/block data of your node by placing links like `<script src="http://127.0.0.1:1234/tx/json/1234567890">` which might break the nodes privacy. \ No newline at end of file
+Running a webbrowser on the same node with a REST enabled bitcoind can be a risk. Accessing prepared XSS websites could read out tx/block data of your node by placing links like `<script src="http://127.0.0.1:8332/rest/tx/1234567890.json">` which might break the nodes privacy.
diff --git a/doc/dnsseed-policy.md b/doc/dnsseed-policy.md
index 66a1757ac5..f15ff44e5d 100644
--- a/doc/dnsseed-policy.md
+++ b/doc/dnsseed-policy.md
@@ -7,9 +7,8 @@ As such, DNS seeds must be run by entities which have some minimum
level of trust within the Bitcoin community.
Other implementations of Bitcoin software may also use the same
-seeds and may be more exposed. In light of this exposure this
-document establishes some basic expectations for the expectations
-for the operation of dnsseeds.
+seeds and may be more exposed. In light of this exposure, this
+document establishes some basic expectations for operating dnsseeds.
0. A DNS seed operating organization or person is expected
to follow good host security practices and maintain control of
diff --git a/doc/gitian-building.md b/doc/gitian-building.md
index 25d3b8390c..d285fffdbb 100644
--- a/doc/gitian-building.md
+++ b/doc/gitian-building.md
@@ -74,11 +74,11 @@ In the VirtualBox GUI click "Create" and choose the following parameters in the
- Disk size: at least 40GB; as low as 20GB *may* be possible, but better to err on the safe side
- Push the `Create` button
-Get the [Debian 7.7 net installer](http://cdimage.debian.org/debian-cd/7.7.0/amd64/iso-cd/debian-7.7.0-amd64-netinst.iso) (a more recent minor version should also work, see also [Debian Network installation](https://www.debian.org/CD/netinst/)).
+Get the [Debian 7.8 net installer](http://cdimage.debian.org/debian-cd/7.8.0/amd64/iso-cd/debian-7.8.0-amd64-netinst.iso) (a more recent minor version should also work, see also [Debian Network installation](https://www.debian.org/CD/netinst/)).
This DVD image can be validated using a SHA256 hashing tool, for example on
Unixy OSes by entering the following in a terminal:
- echo "d440e85b4121f94608748139f25dbce1ad36771348b002fe07d4d44b9d9e623f debian-7.7.0-amd64-netinst.iso" | sha256sum -c
+ echo "e39c36d6adc0fd86c6edb0e03e22919086c883b37ca194d063b8e3e8f6ff6a3a debian-7.8.0-amd64-netinst.iso" | sha256sum -c
# (must return OK)
After creating the VM, we need to configure it.
diff --git a/doc/img/bootstrap1.png b/doc/img/bootstrap1.png
deleted file mode 100644
index 075930791b..0000000000
--- a/doc/img/bootstrap1.png
+++ /dev/null
Binary files differ
diff --git a/doc/img/bootstrap2.png b/doc/img/bootstrap2.png
deleted file mode 100644
index 6461f81810..0000000000
--- a/doc/img/bootstrap2.png
+++ /dev/null
Binary files differ
diff --git a/doc/img/bootstrap4.png b/doc/img/bootstrap4.png
deleted file mode 100644
index ad69737922..0000000000
--- a/doc/img/bootstrap4.png
+++ /dev/null
Binary files differ
diff --git a/doc/img/bootstrap5.png b/doc/img/bootstrap5.png
deleted file mode 100644
index d8d9baaf37..0000000000
--- a/doc/img/bootstrap5.png
+++ /dev/null
Binary files differ
diff --git a/qa/rpc-tests/reindex.py b/qa/rpc-tests/reindex.py
new file mode 100755
index 0000000000..fe767586bb
--- /dev/null
+++ b/qa/rpc-tests/reindex.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python2
+# Copyright (c) 2014 The Bitcoin Core developers
+# Distributed under the MIT software license, see the accompanying
+# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#
+# Test -reindex with CheckBlockIndex
+#
+from test_framework import BitcoinTestFramework
+from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
+from util import *
+import os.path
+
+class ReindexTest(BitcoinTestFramework):
+
+ def setup_chain(self):
+ print("Initializing test directory "+self.options.tmpdir)
+ initialize_chain_clean(self.options.tmpdir, 1)
+
+ def setup_network(self):
+ self.nodes = []
+ self.is_network_split = False
+ self.nodes.append(start_node(0, self.options.tmpdir))
+
+ def run_test(self):
+ self.nodes[0].generate(3)
+ stop_node(self.nodes[0], 0)
+ wait_bitcoinds()
+ self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug", "-reindex", "-checkblockindex=1"])
+ assert_equal(self.nodes[0].getblockcount(), 3)
+ print "Success"
+
+if __name__ == '__main__':
+ ReindexTest().main()
diff --git a/src/arith_uint256.h b/src/arith_uint256.h
index b6ba3a1087..103c78bb8e 100644
--- a/src/arith_uint256.h
+++ b/src/arith_uint256.h
@@ -287,4 +287,4 @@ public:
uint256 ArithToUint256(const arith_uint256 &);
arith_uint256 UintToArith256(const uint256 &);
-#endif // BITCOIN_UINT256_H
+#endif // BITCOIN_ARITH_UINT256_H
diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp
index a0a96c2dfa..2172f4a21b 100644
--- a/src/bitcoind.cpp
+++ b/src/bitcoind.cpp
@@ -21,7 +21,7 @@
*
* \section intro_sec Introduction
*
- * This is the developer documentation of the reference client for an experimental new digital currency called Bitcoin (http://www.bitcoin.org/),
+ * This is the developer documentation of the reference client for an experimental new digital currency called Bitcoin (https://www.bitcoin.org/),
* which enables instant payments to anyone, anywhere in the world. Bitcoin uses peer-to-peer technology to operate
* with no central authority: managing transactions and issuing money are carried out collectively by the network.
*
diff --git a/src/chainparams.cpp b/src/chainparams.cpp
index 97312b366d..2d4fde2476 100644
--- a/src/chainparams.cpp
+++ b/src/chainparams.cpp
@@ -151,11 +151,11 @@ public:
assert(consensus.hashGenesisBlock == uint256S("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"));
assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));
- vSeeds.push_back(CDNSSeedData("bitcoin.sipa.be", "seed.bitcoin.sipa.be"));
- vSeeds.push_back(CDNSSeedData("bluematt.me", "dnsseed.bluematt.me"));
- vSeeds.push_back(CDNSSeedData("dashjr.org", "dnsseed.bitcoin.dashjr.org"));
- vSeeds.push_back(CDNSSeedData("bitcoinstats.com", "seed.bitcoinstats.com"));
- vSeeds.push_back(CDNSSeedData("xf2.org", "bitseed.xf2.org"));
+ vSeeds.push_back(CDNSSeedData("bitcoin.sipa.be", "seed.bitcoin.sipa.be")); // Pieter Wuille
+ vSeeds.push_back(CDNSSeedData("bluematt.me", "dnsseed.bluematt.me")); // Matt Corallo
+ vSeeds.push_back(CDNSSeedData("dashjr.org", "dnsseed.bitcoin.dashjr.org")); // Luke Dashjr
+ vSeeds.push_back(CDNSSeedData("bitcoinstats.com", "seed.bitcoinstats.com")); // Addy Yeow
+ vSeeds.push_back(CDNSSeedData("xf2.org", "bitseed.xf2.org")); // Jeff Garzik
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,0);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,5);
diff --git a/src/chainparams.h b/src/chainparams.h
index e5e691cc53..0692094478 100644
--- a/src/chainparams.h
+++ b/src/chainparams.h
@@ -40,11 +40,9 @@ public:
};
const Consensus::Params& GetConsensus() const { return consensus; }
- const uint256& HashGenesisBlock() const { return consensus.hashGenesisBlock; }
const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
const std::vector<unsigned char>& AlertKey() const { return vAlertPubKey; }
int GetDefaultPort() const { return nDefaultPort; }
- const uint256& ProofOfWorkLimit() const { return consensus.powLimit; }
int SubsidyHalvingInterval() const { return consensus.nSubsidyHalvingInterval; }
int EnforceBlockUpgradeMajority() const { return consensus.nMajorityEnforceBlockUpgrade; }
int RejectBlockOutdatedMajority() const { return consensus.nMajorityRejectBlockOutdated; }
@@ -58,13 +56,8 @@ public:
bool MiningRequiresPeers() const { return fMiningRequiresPeers; }
/** Default value for -checkmempool and -checkblockindex argument */
bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
- /** Allow mining of a min-difficulty block */
- bool AllowMinDifficultyBlocks() const { return consensus.fPowAllowMinDifficultyBlocks; }
/** Make standard checks */
bool RequireStandard() const { return fRequireStandard; }
- int64_t TargetTimespan() const { return consensus.nPowTargetTimespan; }
- int64_t TargetSpacing() const { return consensus.nPowTargetSpacing; }
- int64_t DifficultyAdjustmentInterval() const { return consensus.nPowTargetTimespan / consensus.nPowTargetSpacing; }
/** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
/** In the future use NetworkIDString() for RPC fields */
diff --git a/src/consensus/params.h b/src/consensus/params.h
index 35d447b712..c480a1cce1 100644
--- a/src/consensus/params.h
+++ b/src/consensus/params.h
@@ -3,8 +3,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#ifndef BITCOIN_CONSENSUS_CONSENSUS_PARAMS_H
-#define BITCOIN_CONSENSUS_CONSENSUS_PARAMS_H
+#ifndef BITCOIN_CONSENSUS_PARAMS_H
+#define BITCOIN_CONSENSUS_PARAMS_H
#include "uint256.h"
@@ -28,4 +28,4 @@ struct Params {
};
} // namespace Consensus
-#endif // BITCOIN_CONSENSUS_CONSENSUS_PARAMS_H
+#endif // BITCOIN_CONSENSUS_PARAMS_H
diff --git a/src/init.cpp b/src/init.cpp
index 53e521983f..1952d39da9 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -123,7 +123,7 @@ public:
LogPrintf("Error reading from database: %s\n", e.what());
// Starting the shutdown sequence and returning false to the caller would be
// interpreted as 'entry not found' (as opposed to unable to read data), and
- // could lead to invalid interpration. Just exit immediately, as we can't
+ // could lead to invalid interpretation. Just exit immediately, as we can't
// continue anyway, and all writes should be atomic.
abort();
}
@@ -242,11 +242,6 @@ void OnRPCStopped()
void OnRPCPreCommand(const CRPCCommand& cmd)
{
-#ifdef ENABLE_WALLET
- if (cmd.reqWallet && !pwalletMain)
- throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found (disabled)");
-#endif
-
// Observe safe mode
string strWarning = GetWarnings("rpc");
if (strWarning != "" && !GetBoolArg("-disablesafemode", false) &&
@@ -370,8 +365,8 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-logtimestamps", strprintf(_("Prepend debug output with timestamp (default: %u)"), 1));
if (GetBoolArg("-help-debug", false))
{
- strUsage += HelpMessageOpt("-limitfreerelay=<n>", strprintf(_("Continuously rate-limit free transactions to <n>*1000 bytes per minute (default:%u)"), 15));
- strUsage += HelpMessageOpt("-relaypriority", strprintf(_("Require high priority for relaying free or low-fee transactions (default:%u)"), 1));
+ strUsage += HelpMessageOpt("-limitfreerelay=<n>", strprintf(_("Continuously rate-limit free transactions to <n>*1000 bytes per minute (default: %u)"), 15));
+ strUsage += HelpMessageOpt("-relaypriority", strprintf(_("Require high priority for relaying free or low-fee transactions (default: %u)"), 1));
strUsage += HelpMessageOpt("-maxsigcachesize=<n>", strprintf(_("Limit size of signature cache to <n> entries (default: %u)"), 50000));
}
strUsage += HelpMessageOpt("-minrelaytxfee=<amt>", strprintf(_("Fees (in BTC/Kb) smaller than this are considered zero fee for relaying (default: %s)"), FormatMoney(::minRelayTxFee.GetFeePerK())));
@@ -607,6 +602,7 @@ bool AppInit2(boost::thread_group& threadGroup)
#endif
// ********************************************************* Step 2: parameter interactions
+ const CChainParams& chainparams = Params();
// Set this early so that parameter interactions go to console
fPrintToConsole = GetBoolArg("-printtoconsole", false);
@@ -699,8 +695,8 @@ bool AppInit2(boost::thread_group& threadGroup)
InitWarning(_("Warning: Unsupported argument -benchmark ignored, use -debug=bench."));
// Checkmempool and checkblockindex default to true in regtest mode
- mempool.setSanityCheck(GetBoolArg("-checkmempool", Params().DefaultConsistencyChecks()));
- fCheckBlockIndex = GetBoolArg("-checkblockindex", Params().DefaultConsistencyChecks());
+ mempool.setSanityCheck(GetBoolArg("-checkmempool", chainparams.DefaultConsistencyChecks()));
+ fCheckBlockIndex = GetBoolArg("-checkblockindex", chainparams.DefaultConsistencyChecks());
Checkpoints::fEnabled = GetBoolArg("-checkpoints", true);
// -par=0 means autodetect, but nScriptCheckThreads==0 means no concurrency
@@ -1043,7 +1039,7 @@ bool AppInit2(boost::thread_group& threadGroup)
// If the loaded chain has a wrong genesis, bail out immediately
// (we're likely using a testnet datadir, or the other way around).
- if (!mapBlockIndex.empty() && mapBlockIndex.count(Params().HashGenesisBlock()) == 0)
+ if (!mapBlockIndex.empty() && mapBlockIndex.count(chainparams.GetConsensus().hashGenesisBlock) == 0)
return InitError(_("Incorrect or no genesis block found. Wrong datadir for network?"));
// Initialize the block index (no-op if non-empty database was already loaded)
diff --git a/src/main.cpp b/src/main.cpp
index 6feebd24b4..4352c719a1 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1233,14 +1233,14 @@ void CheckForkWarningConditions()
}
if (pindexBestForkTip && pindexBestForkBase)
{
- LogPrintf("CheckForkWarningConditions: Warning: Large valid fork found\n forking the chain at height %d (%s)\n lasting to height %d (%s).\nChain state database corruption likely.\n",
+ LogPrintf("%s: Warning: Large valid fork found\n forking the chain at height %d (%s)\n lasting to height %d (%s).\nChain state database corruption likely.\n", __func__,
pindexBestForkBase->nHeight, pindexBestForkBase->phashBlock->ToString(),
pindexBestForkTip->nHeight, pindexBestForkTip->phashBlock->ToString());
fLargeWorkForkFound = true;
}
else
{
- LogPrintf("CheckForkWarningConditions: Warning: Found invalid chain at least ~6 blocks longer than our best chain.\nChain state database corruption likely.\n");
+ LogPrintf("%s: Warning: Found invalid chain at least ~6 blocks longer than our best chain.\nChain state database corruption likely.\n", __func__);
fLargeWorkInvalidChainFound = true;
}
}
@@ -1298,10 +1298,10 @@ void Misbehaving(NodeId pnode, int howmuch)
int banscore = GetArg("-banscore", 100);
if (state->nMisbehavior >= banscore && state->nMisbehavior - howmuch < banscore)
{
- LogPrintf("Misbehaving: %s (%d -> %d) BAN THRESHOLD EXCEEDED\n", state->name, state->nMisbehavior-howmuch, state->nMisbehavior);
+ LogPrintf("%s: %s (%d -> %d) BAN THRESHOLD EXCEEDED\n", __func__, state->name, state->nMisbehavior-howmuch, state->nMisbehavior);
state->fShouldBan = true;
} else
- LogPrintf("Misbehaving: %s (%d -> %d)\n", state->name, state->nMisbehavior-howmuch, state->nMisbehavior);
+ LogPrintf("%s: %s (%d -> %d)\n", __func__, state->name, state->nMisbehavior-howmuch, state->nMisbehavior);
}
void static InvalidChainFound(CBlockIndex* pindexNew)
@@ -1309,11 +1309,11 @@ void static InvalidChainFound(CBlockIndex* pindexNew)
if (!pindexBestInvalid || pindexNew->nChainWork > pindexBestInvalid->nChainWork)
pindexBestInvalid = pindexNew;
- LogPrintf("InvalidChainFound: invalid block=%s height=%d log2_work=%.8g date=%s\n",
+ LogPrintf("%s: invalid block=%s height=%d log2_work=%.8g date=%s\n", __func__,
pindexNew->GetBlockHash().ToString(), pindexNew->nHeight,
log(pindexNew->nChainWork.getdouble())/log(2.0), DateTimeStrFormat("%Y-%m-%d %H:%M:%S",
pindexNew->GetBlockTime()));
- LogPrintf("InvalidChainFound: current best=%s height=%d log2_work=%.8g date=%s\n",
+ LogPrintf("%s: current best=%s height=%d log2_work=%.8g date=%s\n", __func__,
chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(), log(chainActive.Tip()->nChainWork.getdouble())/log(2.0),
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()));
CheckForkWarningConditions();
@@ -1680,6 +1680,7 @@ static int64_t nTimeTotal = 0;
bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool fJustCheck)
{
+ const CChainParams& chainparams = Params();
AssertLockHeld(cs_main);
// Check it again in case a previous version let a bad block in
if (!CheckBlock(block, state, !fJustCheck, !fJustCheck))
@@ -1691,7 +1692,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
// Special case for the genesis block, skipping connection of its transactions
// (its coinbase is unspendable)
- if (block.GetHash() == Params().HashGenesisBlock()) {
+ if (block.GetHash() == chainparams.GetConsensus().hashGenesisBlock) {
if (!fJustCheck)
view.SetBestBlock(pindex->GetBlockHash());
return true;
@@ -1920,7 +1921,7 @@ void static UpdateTip(CBlockIndex *pindexNew) {
nTimeBestReceived = GetTime();
mempool.AddTransactionsUpdated(1);
- LogPrintf("UpdateTip: new best=%s height=%d log2_work=%.8g tx=%lu date=%s progress=%f cache=%u\n",
+ LogPrintf("%s: new best=%s height=%d log2_work=%.8g tx=%lu date=%s progress=%f cache=%u\n", __func__,
chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(), log(chainActive.Tip()->nChainWork.getdouble())/log(2.0), (unsigned long)chainActive.Tip()->nChainTx,
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()),
Checkpoints::GuessVerificationProgress(chainActive.Tip()), (unsigned int)pcoinsTip->GetCacheSize());
@@ -1940,7 +1941,7 @@ void static UpdateTip(CBlockIndex *pindexNew) {
pindex = pindex->pprev;
}
if (nUpgraded > 0)
- LogPrintf("SetBestChain: %d of last 100 blocks above version %d\n", nUpgraded, (int)CBlock::CURRENT_VERSION);
+ LogPrintf("%s: %d of last 100 blocks above version %d\n", __func__, nUpgraded, (int)CBlock::CURRENT_VERSION);
if (nUpgraded > 100/2)
{
// strMiscWarning is read by GetWarnings(), called by Qt and the JSON-RPC code to warn the user:
@@ -2541,8 +2542,9 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& state, CBlockIndex * const pindexPrev)
{
+ const Consensus::Params& consensusParams = Params().GetConsensus();
uint256 hash = block.GetHash();
- if (hash == Params().HashGenesisBlock())
+ if (hash == consensusParams.hashGenesisBlock)
return true;
assert(pindexPrev);
@@ -2612,6 +2614,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn
bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBlockIndex** ppindex)
{
+ const CChainParams& chainparams = Params();
AssertLockHeld(cs_main);
// Check for duplicate
uint256 hash = block.GetHash();
@@ -2632,7 +2635,7 @@ bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBloc
// Get prev block index
CBlockIndex* pindexPrev = NULL;
- if (hash != Params().HashGenesisBlock()) {
+ if (hash != chainparams.GetConsensus().hashGenesisBlock) {
BlockMap::iterator mi = mapBlockIndex.find(block.hashPrevBlock);
if (mi == mapBlockIndex.end())
return state.DoS(10, error("%s: prev block not found", __func__), 0, "bad-prevblk");
@@ -2933,7 +2936,7 @@ bool static LoadBlockIndexDB()
// Check whether we have a transaction index
pblocktree->ReadFlag("txindex", fTxIndex);
- LogPrintf("LoadBlockIndexDB(): transaction index %s\n", fTxIndex ? "enabled" : "disabled");
+ LogPrintf("%s: transaction index %s\n", __func__, fTxIndex ? "enabled" : "disabled");
// Load pointer to end of best chain
BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock());
@@ -2943,7 +2946,7 @@ bool static LoadBlockIndexDB()
PruneBlockIndexCandidates();
- LogPrintf("LoadBlockIndexDB(): hashBestChain=%s height=%d date=%s progress=%f\n",
+ LogPrintf("%s: hashBestChain=%s height=%d date=%s progress=%f\n", __func__,
chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(),
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()),
Checkpoints::GuessVerificationProgress(chainActive.Tip()));
@@ -3119,6 +3122,7 @@ bool InitBlockIndex() {
bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
{
+ const CChainParams& chainparams = Params();
// Map of disk positions for blocks with unknown parent (only used for reindex)
static std::multimap<uint256, CDiskBlockPos> mapBlocksUnknownParent;
int64_t nStart = GetTimeMillis();
@@ -3164,7 +3168,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
// detect out of order blocks, and store them for later
uint256 hash = block.GetHash();
- if (hash != Params().HashGenesisBlock() && mapBlockIndex.find(block.hashPrevBlock) == mapBlockIndex.end()) {
+ if (hash != chainparams.GetConsensus().hashGenesisBlock && mapBlockIndex.find(block.hashPrevBlock) == mapBlockIndex.end()) {
LogPrint("reindex", "%s: Out of order block %s, parent %s not known\n", __func__, hash.ToString(),
block.hashPrevBlock.ToString());
if (dbp)
@@ -3179,7 +3183,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
nLoaded++;
if (state.IsError())
break;
- } else if (hash != Params().HashGenesisBlock() && mapBlockIndex[hash]->nHeight % 1000 == 0) {
+ } else if (hash != chainparams.GetConsensus().hashGenesisBlock && mapBlockIndex[hash]->nHeight % 1000 == 0) {
LogPrintf("Block Import: already had block %s at height %d\n", hash.ToString(), mapBlockIndex[hash]->nHeight);
}
@@ -3221,12 +3225,21 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
void static CheckBlockIndex()
{
+ const Consensus::Params& consensusParams = Params().GetConsensus();
if (!fCheckBlockIndex) {
return;
}
LOCK(cs_main);
+ // During a reindex, we read the genesis block and call CheckBlockIndex before ActivateBestChain,
+ // so we have the genesis block in mapBlockIndex but no active chain. (A few of the tests when
+ // iterating the block tree require that chainActive has been initialized.)
+ if (chainActive.Height() < 0) {
+ assert(mapBlockIndex.size() <= 1);
+ return;
+ }
+
// Build forward-pointing map of the entire block tree.
std::multimap<CBlockIndex*,CBlockIndex*> forward;
for (BlockMap::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); it++) {
@@ -3263,7 +3276,7 @@ void static CheckBlockIndex()
// Begin: actual consistency checks.
if (pindex->pprev == NULL) {
// Genesis block checks.
- assert(pindex->GetBlockHash() == Params().HashGenesisBlock()); // Genesis block's hash must match.
+ assert(pindex->GetBlockHash() == consensusParams.hashGenesisBlock); // Genesis block's hash must match.
assert(pindex == chainActive.Genesis()); // The current active chain's genesis block must be this block.
}
// HAVE_DATA is equivalent to VALID_TRANSACTIONS and equivalent to nTx > 0 (we stored the number of transactions in the block)
@@ -3480,7 +3493,7 @@ void static ProcessGetData(CNode* pfrom)
send = mi->second->IsValid(BLOCK_VALID_SCRIPTS) && (pindexBestHeader != NULL) &&
(mi->second->GetBlockTime() > pindexBestHeader->GetBlockTime() - 30 * 24 * 60 * 60);
if (!send) {
- LogPrintf("ProcessGetData(): ignoring request from peer=%i for old block that isn't in the main chain\n", pfrom->GetId());
+ LogPrintf("%s: ignoring request from peer=%i for old block that isn't in the main chain\n", __func__, pfrom->GetId());
}
}
}
@@ -3578,6 +3591,7 @@ void static ProcessGetData(CNode* pfrom)
bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, int64_t nTimeReceived)
{
+ const CChainParams& chainparams = Params();
RandAddSeedPerfmon();
LogPrint("net", "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->id);
if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)
@@ -3837,7 +3851,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
// not a direct successor.
pfrom->PushMessage("getheaders", chainActive.GetLocator(pindexBestHeader), inv.hash);
CNodeState *nodestate = State(pfrom->GetId());
- if (chainActive.Tip()->GetBlockTime() > GetAdjustedTime() - Params().TargetSpacing() * 20 &&
+ if (chainActive.Tip()->GetBlockTime() > GetAdjustedTime() - chainparams.GetConsensus().nPowTargetSpacing * 20 &&
nodestate->nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) {
vToFetch.push_back(inv);
// Mark block as in flight already, even though the actual "getdata" message only goes out
@@ -4381,7 +4395,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
bool ProcessMessages(CNode* pfrom)
{
//if (fDebug)
- // LogPrintf("ProcessMessages(%u messages)\n", pfrom->vRecvMsg.size());
+ // LogPrintf("%s(%u messages)\n", __func__, pfrom->vRecvMsg.size());
//
// Message format
@@ -4409,7 +4423,7 @@ bool ProcessMessages(CNode* pfrom)
CNetMessage& msg = *it;
//if (fDebug)
- // LogPrintf("ProcessMessages(message %u msgsz, %u bytes, complete:%s)\n",
+ // LogPrintf("%s(message %u msgsz, %u bytes, complete:%s)\n", __func__,
// msg.hdr.nMessageSize, msg.vRecv.size(),
// msg.complete() ? "Y" : "N");
@@ -4445,7 +4459,7 @@ bool ProcessMessages(CNode* pfrom)
unsigned int nChecksum = ReadLE32((unsigned char*)&hash);
if (nChecksum != hdr.nChecksum)
{
- LogPrintf("ProcessMessages(%s, %u bytes): CHECKSUM ERROR nChecksum=%08x hdr.nChecksum=%08x\n",
+ LogPrintf("%s(%s, %u bytes): CHECKSUM ERROR nChecksum=%08x hdr.nChecksum=%08x\n", __func__,
SanitizeString(strCommand), nMessageSize, nChecksum, hdr.nChecksum);
continue;
}
@@ -4463,12 +4477,12 @@ bool ProcessMessages(CNode* pfrom)
if (strstr(e.what(), "end of data"))
{
// Allow exceptions from under-length message on vRecv
- LogPrintf("ProcessMessages(%s, %u bytes): Exception '%s' caught, normally caused by a message being shorter than its stated length\n", SanitizeString(strCommand), nMessageSize, e.what());
+ LogPrintf("%s(%s, %u bytes): Exception '%s' caught, normally caused by a message being shorter than its stated length\n", __func__, SanitizeString(strCommand), nMessageSize, e.what());
}
else if (strstr(e.what(), "size too large"))
{
// Allow exceptions from over-long size
- LogPrintf("ProcessMessages(%s, %u bytes): Exception '%s' caught\n", SanitizeString(strCommand), nMessageSize, e.what());
+ LogPrintf("%s(%s, %u bytes): Exception '%s' caught\n", __func__, SanitizeString(strCommand), nMessageSize, e.what());
}
else
{
@@ -4485,7 +4499,7 @@ bool ProcessMessages(CNode* pfrom)
}
if (!fRet)
- LogPrintf("ProcessMessage(%s, %u bytes) FAILED peer=%d\n", SanitizeString(strCommand), nMessageSize, pfrom->id);
+ LogPrintf("%s(%s, %u bytes) FAILED peer=%d\n", __func__, SanitizeString(strCommand), nMessageSize, pfrom->id);
break;
}
@@ -4500,6 +4514,7 @@ bool ProcessMessages(CNode* pfrom)
bool SendMessages(CNode* pto, bool fSendTrickle)
{
+ const Consensus::Params& consensusParams = Params().GetConsensus();
{
// Don't send anything until we get their version message
if (pto->nVersion == 0)
@@ -4687,7 +4702,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
// timeout. We compensate for in-flight blocks to prevent killing off peers due to our own downstream link
// being saturated. We only count validated in-flight blocks so peers can't advertize nonexisting block hashes
// to unreasonably increase our timeout.
- if (!pto->fDisconnect && state.vBlocksInFlight.size() > 0 && state.vBlocksInFlight.front().nTime < nNow - 500000 * Params().TargetSpacing() * (4 + state.vBlocksInFlight.front().nValidatedQueuedBefore)) {
+ if (!pto->fDisconnect && state.vBlocksInFlight.size() > 0 && state.vBlocksInFlight.front().nTime < nNow - 500000 * consensusParams.nPowTargetSpacing * (4 + state.vBlocksInFlight.front().nValidatedQueuedBefore)) {
LogPrintf("Timeout downloading block %s from peer=%d, disconnecting\n", state.vBlocksInFlight.front().hash.ToString(), pto->id);
pto->fDisconnect = true;
}
diff --git a/src/miner.cpp b/src/miner.cpp
index cf08b78229..3abd2d68e4 100644
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -6,11 +6,12 @@
#include "miner.h"
#include "amount.h"
-#include "primitives/transaction.h"
+#include "chainparams.h"
#include "hash.h"
#include "main.h"
#include "net.h"
#include "pow.h"
+#include "primitives/transaction.h"
#include "timedata.h"
#include "util.h"
#include "utilmoneystr.h"
@@ -78,13 +79,13 @@ public:
}
};
-void UpdateTime(CBlockHeader* pblock, const CBlockIndex* pindexPrev)
+void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev)
{
pblock->nTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
// Updating time can change work required on testnet:
- if (Params().AllowMinDifficultyBlocks())
- pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus());
+ if (consensusParams.fPowAllowMinDifficultyBlocks)
+ pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, consensusParams);
}
CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
@@ -325,7 +326,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
// Fill in header
pblock->hashPrevBlock = pindexPrev->GetBlockHash();
- UpdateTime(pblock, pindexPrev);
+ UpdateTime(pblock, Params().GetConsensus(), pindexPrev);
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus());
pblock->nNonce = 0;
pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]);
@@ -440,6 +441,7 @@ void static BitcoinMiner(CWallet *pwallet)
LogPrintf("BitcoinMiner started\n");
SetThreadPriority(THREAD_PRIORITY_LOWEST);
RenameThread("bitcoin-miner");
+ const CChainParams& chainparams = Params();
// Each thread has its own key and counter
CReserveKey reservekey(pwallet);
@@ -447,7 +449,7 @@ void static BitcoinMiner(CWallet *pwallet)
try {
while (true) {
- if (Params().MiningRequiresPeers()) {
+ if (chainparams.MiningRequiresPeers()) {
// Busy-wait for the network to come online so we don't waste time mining
// on an obsolete chain. In regtest mode we expect to fly solo.
while (vNodes.empty())
@@ -496,7 +498,7 @@ void static BitcoinMiner(CWallet *pwallet)
SetThreadPriority(THREAD_PRIORITY_LOWEST);
// In regression test mode, stop mining after a block is found.
- if (Params().MineBlocksOnDemand())
+ if (chainparams.MineBlocksOnDemand())
throw boost::thread_interrupted();
break;
@@ -506,7 +508,7 @@ void static BitcoinMiner(CWallet *pwallet)
// Check for stop or if block needs to be rebuilt
boost::this_thread::interruption_point();
// Regtest mode doesn't require peers
- if (vNodes.empty() && Params().MiningRequiresPeers())
+ if (vNodes.empty() && chainparams.MiningRequiresPeers())
break;
if (nNonce >= 0xffff0000)
break;
@@ -516,8 +518,8 @@ void static BitcoinMiner(CWallet *pwallet)
break;
// Update nTime every few seconds
- UpdateTime(pblock, pindexPrev);
- if (Params().AllowMinDifficultyBlocks())
+ UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev);
+ if (chainparams.GetConsensus().fPowAllowMinDifficultyBlocks)
{
// Changing pblock->nTime can change work required on testnet:
hashTarget.SetCompact(pblock->nBits);
diff --git a/src/miner.h b/src/miner.h
index 5d5c9c86c7..96a6b70ecd 100644
--- a/src/miner.h
+++ b/src/miner.h
@@ -14,6 +14,7 @@ class CBlockIndex;
class CReserveKey;
class CScript;
class CWallet;
+namespace Consensus { struct Params; };
struct CBlockTemplate
{
@@ -29,6 +30,6 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn);
CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey);
/** Modify the extranonce in a block */
void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce);
-void UpdateTime(CBlockHeader* block, const CBlockIndex* pindexPrev);
+void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev);
#endif // BITCOIN_MINER_H
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index 3ae780abfd..069601ab67 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -107,7 +107,6 @@ static QString GetLangTerritory()
/** Set up translations */
static void initTranslations(QTranslator &qtTranslatorBase, QTranslator &qtTranslator, QTranslator &translatorBase, QTranslator &translator)
{
-
// Remove old translators
QApplication::removeTranslator(&qtTranslatorBase);
QApplication::removeTranslator(&qtTranslator);
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index 198dd1fdf9..670d54c7e3 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -164,7 +164,7 @@ BitcoinGUI::BitcoinGUI(const NetworkStyle *networkStyle, QWidget *parent) :
// Create status bar
statusBar();
-
+
// Disable size grip because it looks ugly and nobody needs it
statusBar()->setSizeGripEnabled(false);
diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp
index e4e9015c85..0a60632bfa 100644
--- a/src/qt/coincontroldialog.cpp
+++ b/src/qt/coincontroldialog.cpp
@@ -8,12 +8,12 @@
#include "addresstablemodel.h"
#include "bitcoinunits.h"
#include "guiutil.h"
-#include "init.h"
#include "optionsmodel.h"
#include "scicon.h"
#include "walletmodel.h"
#include "coincontrol.h"
+#include "init.h"
#include "main.h"
#include "wallet/wallet.h"
diff --git a/src/qt/forms/sendcoinsentry.ui b/src/qt/forms/sendcoinsentry.ui
index b362928438..48d0dd093c 100644
--- a/src/qt/forms/sendcoinsentry.ui
+++ b/src/qt/forms/sendcoinsentry.ui
@@ -195,7 +195,7 @@
</item>
</layout>
</widget>
- <widget class="QFrame" name="SendCoins_InsecurePaymentRequest">
+ <widget class="QFrame" name="SendCoins_UnauthenticatedPaymentRequest">
<property name="palette">
<palette>
<active>
@@ -612,7 +612,7 @@
</palette>
</property>
<property name="toolTip">
- <string>This is an unverified payment request.</string>
+ <string>This is an unauthenticated payment request.</string>
</property>
<property name="autoFillBackground">
<bool>true</bool>
@@ -700,7 +700,7 @@
</item>
</layout>
</widget>
- <widget class="QFrame" name="SendCoins_SecurePaymentRequest">
+ <widget class="QFrame" name="SendCoins_AuthenticatedPaymentRequest">
<property name="palette">
<palette>
<active>
@@ -1144,7 +1144,7 @@
</palette>
</property>
<property name="toolTip">
- <string>This is a verified payment request.</string>
+ <string>This is an authenticated payment request.</string>
</property>
<property name="autoFillBackground">
<bool>true</bool>
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp
index a5ee81db6c..4a1f728e18 100644
--- a/src/qt/guiutil.cpp
+++ b/src/qt/guiutil.cpp
@@ -741,14 +741,14 @@ LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef
CFURLRef currentItemURL = NULL;
#if defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED >= 10100
- if(&LSSharedFileListItemCopyResolvedURL)
- currentItemURL = LSSharedFileListItemCopyResolvedURL(item, resolutionFlags, NULL);
+ if(&LSSharedFileListItemCopyResolvedURL)
+ currentItemURL = LSSharedFileListItemCopyResolvedURL(item, resolutionFlags, NULL);
#if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED < 10100
- else
- LSSharedFileListItemResolve(item, resolutionFlags, &currentItemURL, NULL);
+ else
+ LSSharedFileListItemResolve(item, resolutionFlags, &currentItemURL, NULL);
#endif
#else
- LSSharedFileListItemResolve(item, resolutionFlags, &currentItemURL, NULL);
+ LSSharedFileListItemResolve(item, resolutionFlags, &currentItemURL, NULL);
#endif
if(currentItemURL && CFEqual(currentItemURL, findUrl)) {
diff --git a/src/qt/paymentrequestplus.cpp b/src/qt/paymentrequestplus.cpp
index b69461ad9e..7e9729eeb9 100644
--- a/src/qt/paymentrequestplus.cpp
+++ b/src/qt/paymentrequestplus.cpp
@@ -59,12 +59,6 @@ bool PaymentRequestPlus::IsInitialized() const
return paymentRequest.IsInitialized();
}
-QString PaymentRequestPlus::getPKIType() const
-{
- if (!IsInitialized()) return QString("none");
- return QString::fromStdString(paymentRequest.pki_type());
-}
-
bool PaymentRequestPlus::getMerchant(X509_STORE* certStore, QString& merchant) const
{
merchant.clear();
@@ -124,7 +118,7 @@ bool PaymentRequestPlus::getMerchant(X509_STORE* certStore, QString& merchant) c
// The first cert is the signing cert, the rest are untrusted certs that chain
// to a valid root authority. OpenSSL needs them separately.
STACK_OF(X509) *chain = sk_X509_new_null();
- for (int i = certs.size()-1; i > 0; i--) {
+ for (int i = certs.size() - 1; i > 0; i--) {
sk_X509_push(chain, certs[i]);
}
X509 *signing_cert = certs[0];
@@ -172,9 +166,8 @@ bool PaymentRequestPlus::getMerchant(X509_STORE* certStore, QString& merchant) c
EVP_MD_CTX_init(&ctx);
if (!EVP_VerifyInit_ex(&ctx, digestAlgorithm, NULL) ||
!EVP_VerifyUpdate(&ctx, data_to_verify.data(), data_to_verify.size()) ||
- !EVP_VerifyFinal(&ctx, (const unsigned char*)paymentRequest.signature().data(), paymentRequest.signature().size(), pubkey)) {
-
- throw SSLVerifyError("Bad signature, invalid PaymentRequest.");
+ !EVP_VerifyFinal(&ctx, (const unsigned char*)paymentRequest.signature().data(), (unsigned int)paymentRequest.signature().size(), pubkey)) {
+ throw SSLVerifyError("Bad signature, invalid payment request.");
}
// OpenSSL API for getting human printable strings from certs is baroque.
diff --git a/src/qt/paymentrequestplus.h b/src/qt/paymentrequestplus.h
index 61f8a3415d..99a7186b85 100644
--- a/src/qt/paymentrequestplus.h
+++ b/src/qt/paymentrequestplus.h
@@ -29,7 +29,6 @@ public:
bool SerializeToString(std::string* output) const;
bool IsInitialized() const;
- QString getPKIType() const;
// Returns true if merchant's identity is authenticated, and
// returns human-readable merchant identity in merchant
bool getMerchant(X509_STORE* certStore, QString& merchant) const;
diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp
index ad489de343..09e9949b10 100644
--- a/src/qt/paymentserver.cpp
+++ b/src/qt/paymentserver.cpp
@@ -97,7 +97,11 @@ static QList<QString> savedPaymentRequests;
static void ReportInvalidCertificate(const QSslCertificate& cert)
{
- qDebug() << "ReportInvalidCertificate: Payment server found an invalid certificate: " << cert.subjectInfo(QSslCertificate::CommonName);
+#if QT_VERSION < 0x050000
+ qDebug() << QString("%1: Payment server found an invalid certificate: ").arg(__func__) << cert.serialNumber() << cert.subjectInfo(QSslCertificate::CommonName) << cert.subjectInfo(QSslCertificate::OrganizationalUnitName);
+#else
+ qDebug() << QString("%1: Payment server found an invalid certificate: ").arg(__func__) << cert.serialNumber() << cert.subjectInfo(QSslCertificate::CommonName) << cert.subjectInfo(QSslCertificate::DistinguishedNameQualifier) << cert.subjectInfo(QSslCertificate::OrganizationalUnitName);
+#endif
}
//
@@ -143,13 +147,20 @@ void PaymentServer::LoadRootCAs(X509_STORE* _store)
int nRootCerts = 0;
const QDateTime currentTime = QDateTime::currentDateTime();
- foreach (const QSslCertificate& cert, certList)
- {
+
+ foreach (const QSslCertificate& cert, certList) {
+ // Don't log NULL certificates
+ if (cert.isNull())
+ continue;
+
+ // Not yet active/valid, or expired certificate
if (currentTime < cert.effectiveDate() || currentTime > cert.expiryDate()) {
ReportInvalidCertificate(cert);
continue;
}
+
#if QT_VERSION >= 0x050000
+ // Blacklisted certificate
if (cert.isBlacklisted()) {
ReportInvalidCertificate(cert);
continue;
@@ -301,7 +312,7 @@ PaymentServer::PaymentServer(QObject* parent, bool startLocalServer) :
// Install global event filter to catch QFileOpenEvents
// on Mac: sent when you click bitcoin: links
- // other OSes: helpful when dealing with payment request files (in the future)
+ // other OSes: helpful when dealing with payment request files
if (parent)
parent->installEventFilter(this);
@@ -332,14 +343,13 @@ PaymentServer::~PaymentServer()
}
//
-// OSX-specific way of handling bitcoin: URIs and
-// PaymentRequest mime types
+// OSX-specific way of handling bitcoin: URIs and PaymentRequest mime types.
+// Also used by paymentservertests.cpp and when opening a payment request file
+// via "Open URI..." menu entry.
//
bool PaymentServer::eventFilter(QObject *object, QEvent *event)
{
- // clicking on bitcoin: URIs creates FileOpen events on the Mac
- if (event->type() == QEvent::FileOpen)
- {
+ if (event->type() == QEvent::FileOpen) {
QFileOpenEvent *fileEvent = static_cast<QFileOpenEvent*>(event);
if (!fileEvent->file().isEmpty())
handleURIOrFile(fileEvent->file());
@@ -515,7 +525,7 @@ bool PaymentServer::readPaymentRequestFromFile(const QString& filename, PaymentR
return request.parse(data);
}
-bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, SendCoinsRecipient& recipient)
+bool PaymentServer::processPaymentRequest(const PaymentRequestPlus& request, SendCoinsRecipient& recipient)
{
if (!optionsModel)
return false;
@@ -560,9 +570,9 @@ bool PaymentServer::processPaymentRequest(PaymentRequestPlus& request, SendCoins
addresses.append(QString::fromStdString(CBitcoinAddress(dest).ToString()));
}
else if (!recipient.authenticatedMerchant.isEmpty()) {
- // Insecure payments to custom bitcoin addresses are not supported
- // (there is no good way to tell the user where they are paying in a way
- // they'd have a chance of understanding).
+ // Unauthenticated payment requests to custom bitcoin addresses are not supported
+ // (there is no good way to tell the user where they are paying in a way they'd
+ // have a chance of understanding).
emit message(tr("Payment request rejected"),
tr("Unverified payment requests to custom payment scripts are unsupported."),
CClientUIInterface::MSG_ERROR);
diff --git a/src/qt/paymentserver.h b/src/qt/paymentserver.h
index 6bf5ac2eea..32ed27983e 100644
--- a/src/qt/paymentserver.h
+++ b/src/qt/paymentserver.h
@@ -131,7 +131,7 @@ protected:
bool eventFilter(QObject *object, QEvent *event);
private:
- bool processPaymentRequest(PaymentRequestPlus& request, SendCoinsRecipient& recipient);
+ bool processPaymentRequest(const PaymentRequestPlus& request, SendCoinsRecipient& recipient);
void fetchRequest(const QUrl& url);
// Setup networking
diff --git a/src/qt/recentrequeststablemodel.cpp b/src/qt/recentrequeststablemodel.cpp
index 5221ec3e24..543b977d8f 100644
--- a/src/qt/recentrequeststablemodel.cpp
+++ b/src/qt/recentrequeststablemodel.cpp
@@ -5,9 +5,10 @@
#include "recentrequeststablemodel.h"
#include "bitcoinunits.h"
-#include "clientversion.h"
#include "guiutil.h"
#include "optionsmodel.h"
+
+#include "clientversion.h"
#include "streams.h"
#include <boost/foreach.hpp>
diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp
index 774667d4ac..0360f160d8 100644
--- a/src/qt/sendcoinsdialog.cpp
+++ b/src/qt/sendcoinsdialog.cpp
@@ -274,11 +274,11 @@ void SendCoinsDialog::on_sendButton_clicked()
recipientElement = tr("%1 to %2").arg(amount, address);
}
}
- else if(!rcp.authenticatedMerchant.isEmpty()) // secure payment request
+ else if(!rcp.authenticatedMerchant.isEmpty()) // authenticated payment request
{
recipientElement = tr("%1 to %2").arg(amount, GUIUtil::HtmlEscape(rcp.authenticatedMerchant));
}
- else // insecure payment request
+ else // unauthenticated payment request
{
recipientElement = tr("%1 to %2").arg(amount, address);
}
@@ -531,7 +531,7 @@ void SendCoinsDialog::processSendCoinsReturn(const WalletModel::SendCoinsReturn
msgParams.first = tr("A fee higher than %1 is considered an absurdly high fee.").arg(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), 10000000));
break;
case WalletModel::PaymentRequestExpired:
- msgParams.first = tr("Payment request expired!");
+ msgParams.first = tr("Payment request expired.");
msgParams.second = CClientUIInterface::MSG_ERROR;
break;
// included to prevent a compiler warning.
diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp
index 6ac650e74f..ea35ed1d53 100644
--- a/src/qt/sendcoinsentry.cpp
+++ b/src/qt/sendcoinsentry.cpp
@@ -99,11 +99,11 @@ void SendCoinsEntry::clear()
ui->messageTextLabel->clear();
ui->messageTextLabel->hide();
ui->messageLabel->hide();
- // clear UI elements for insecure payment request
+ // clear UI elements for unauthenticated payment request
ui->payTo_is->clear();
ui->memoTextLabel_is->clear();
ui->payAmount_is->clear();
- // clear UI elements for secure payment request
+ // clear UI elements for authenticated payment request
ui->payTo_s->clear();
ui->memoTextLabel_s->clear();
ui->payAmount_s->clear();
@@ -190,21 +190,21 @@ void SendCoinsEntry::setValue(const SendCoinsRecipient &value)
if (recipient.paymentRequest.IsInitialized()) // payment request
{
- if (recipient.authenticatedMerchant.isEmpty()) // insecure
+ if (recipient.authenticatedMerchant.isEmpty()) // unauthenticated
{
ui->payTo_is->setText(recipient.address);
ui->memoTextLabel_is->setText(recipient.message);
ui->payAmount_is->setValue(recipient.amount);
ui->payAmount_is->setReadOnly(true);
- setCurrentWidget(ui->SendCoins_InsecurePaymentRequest);
+ setCurrentWidget(ui->SendCoins_UnauthenticatedPaymentRequest);
}
- else // secure
+ else // authenticated
{
ui->payTo_s->setText(recipient.authenticatedMerchant);
ui->memoTextLabel_s->setText(recipient.message);
ui->payAmount_s->setValue(recipient.amount);
ui->payAmount_s->setReadOnly(true);
- setCurrentWidget(ui->SendCoins_SecurePaymentRequest);
+ setCurrentWidget(ui->SendCoins_AuthenticatedPaymentRequest);
}
}
else // normal payment
diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp
index 414fe02ff9..8430e017c1 100644
--- a/src/qt/splashscreen.cpp
+++ b/src/qt/splashscreen.cpp
@@ -4,11 +4,12 @@
#include "splashscreen.h"
+#include "networkstyle.h"
+
#include "clientversion.h"
#include "init.h"
-#include "networkstyle.h"
-#include "ui_interface.h"
#include "util.h"
+#include "ui_interface.h"
#include "version.h"
#ifdef ENABLE_WALLET
diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp
index 9b235f9130..4a2c51477e 100644
--- a/src/qt/transactiondesc.cpp
+++ b/src/qt/transactiondesc.cpp
@@ -10,7 +10,6 @@
#include "transactionrecord.h"
#include "base58.h"
-#include "wallet/db.h"
#include "main.h"
#include "script/script.h"
#include "timedata.h"
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
index 09ed8ce9fd..9b8be76beb 100644
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -12,7 +12,6 @@
#include "transactiontablemodel.h"
#include "base58.h"
-#include "wallet/db.h"
#include "keystore.h"
#include "main.h"
#include "sync.h"
diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp
index 1e6531f68a..851d113f3b 100644
--- a/src/rpcmining.cpp
+++ b/src/rpcmining.cpp
@@ -45,7 +45,7 @@ Value GetNetworkHashPS(int lookup, int height) {
// If lookup is -1, then use blocks since last difficulty change.
if (lookup <= 0)
- lookup = pb->nHeight % Params().DifficultyAdjustmentInterval() + 1;
+ lookup = pb->nHeight % Params().GetConsensus().DifficultyAdjustmentInterval() + 1;
// If lookup is larger than chain, then set it to chain length.
if (lookup > pb->nHeight)
@@ -514,7 +514,7 @@ Value getblocktemplate(const Array& params, bool fHelp)
CBlock* pblock = &pblocktemplate->block; // pointer for convenience
// Update nTime
- UpdateTime(pblock, pindexPrev);
+ UpdateTime(pblock, Params().GetConsensus(), pindexPrev);
pblock->nNonce = 0;
static const Array aCaps = boost::assign::list_of("proposal");
@@ -629,14 +629,19 @@ Value submitblock(const Array& params, bool fHelp)
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block decode failed");
uint256 hash = block.GetHash();
- BlockMap::iterator mi = mapBlockIndex.find(hash);
- if (mi != mapBlockIndex.end()) {
- CBlockIndex *pindex = mi->second;
- if (pindex->IsValid(BLOCK_VALID_SCRIPTS))
- return "duplicate";
- if (pindex->nStatus & BLOCK_FAILED_MASK)
- return "duplicate-invalid";
- // Otherwise, we might only have the header - process the block before returning
+ bool fBlockPresent = false;
+ {
+ LOCK(cs_main);
+ BlockMap::iterator mi = mapBlockIndex.find(hash);
+ if (mi != mapBlockIndex.end()) {
+ CBlockIndex *pindex = mi->second;
+ if (pindex->IsValid(BLOCK_VALID_SCRIPTS))
+ return "duplicate";
+ if (pindex->nStatus & BLOCK_FAILED_MASK)
+ return "duplicate-invalid";
+ // Otherwise, we might only have the header - process the block before returning
+ fBlockPresent = true;
+ }
}
CValidationState state;
@@ -644,7 +649,7 @@ Value submitblock(const Array& params, bool fHelp)
RegisterValidationInterface(&sc);
bool fAccepted = ProcessNewBlock(state, NULL, &block);
UnregisterValidationInterface(&sc);
- if (mi != mapBlockIndex.end())
+ if (fBlockPresent)
{
if (fAccepted && !sc.found)
return "duplicate-inconclusive";
diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp
index a79b4e3394..8393a8502e 100644
--- a/src/rpcrawtransaction.cpp
+++ b/src/rpcrawtransaction.cpp
@@ -193,117 +193,6 @@ Value getrawtransaction(const Array& params, bool fHelp)
return result;
}
-#ifdef ENABLE_WALLET
-Value listunspent(const Array& params, bool fHelp)
-{
- if (fHelp || params.size() > 3)
- throw runtime_error(
- "listunspent ( minconf maxconf [\"address\",...] )\n"
- "\nReturns array of unspent transaction outputs\n"
- "with between minconf and maxconf (inclusive) confirmations.\n"
- "Optionally filter to only include txouts paid to specified addresses.\n"
- "Results are an array of Objects, each of which has:\n"
- "{txid, vout, scriptPubKey, amount, confirmations}\n"
- "\nArguments:\n"
- "1. minconf (numeric, optional, default=1) The minimum confirmations to filter\n"
- "2. maxconf (numeric, optional, default=9999999) The maximum confirmations to filter\n"
- "3. \"addresses\" (string) A json array of bitcoin addresses to filter\n"
- " [\n"
- " \"address\" (string) bitcoin address\n"
- " ,...\n"
- " ]\n"
- "\nResult\n"
- "[ (array of json object)\n"
- " {\n"
- " \"txid\" : \"txid\", (string) the transaction id \n"
- " \"vout\" : n, (numeric) the vout value\n"
- " \"address\" : \"address\", (string) the bitcoin address\n"
- " \"account\" : \"account\", (string) DEPRECATED. The associated account, or \"\" for the default account\n"
- " \"scriptPubKey\" : \"key\", (string) the script key\n"
- " \"amount\" : x.xxx, (numeric) the transaction amount in btc\n"
- " \"confirmations\" : n (numeric) The number of confirmations\n"
- " }\n"
- " ,...\n"
- "]\n"
-
- "\nExamples\n"
- + HelpExampleCli("listunspent", "")
- + HelpExampleCli("listunspent", "6 9999999 \"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\",\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"")
- + HelpExampleRpc("listunspent", "6, 9999999 \"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\",\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"")
- );
-
- RPCTypeCheck(params, boost::assign::list_of(int_type)(int_type)(array_type));
-
- int nMinDepth = 1;
- if (params.size() > 0)
- nMinDepth = params[0].get_int();
-
- int nMaxDepth = 9999999;
- if (params.size() > 1)
- nMaxDepth = params[1].get_int();
-
- set<CBitcoinAddress> setAddress;
- if (params.size() > 2) {
- Array inputs = params[2].get_array();
- BOOST_FOREACH(Value& input, inputs) {
- CBitcoinAddress address(input.get_str());
- if (!address.IsValid())
- throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid Bitcoin address: ")+input.get_str());
- if (setAddress.count(address))
- throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+input.get_str());
- setAddress.insert(address);
- }
- }
-
- Array results;
- vector<COutput> vecOutputs;
- assert(pwalletMain != NULL);
- LOCK2(cs_main, pwalletMain->cs_wallet);
- pwalletMain->AvailableCoins(vecOutputs, false);
- BOOST_FOREACH(const COutput& out, vecOutputs) {
- if (out.nDepth < nMinDepth || out.nDepth > nMaxDepth)
- continue;
-
- if (setAddress.size()) {
- CTxDestination address;
- if (!ExtractDestination(out.tx->vout[out.i].scriptPubKey, address))
- continue;
-
- if (!setAddress.count(address))
- continue;
- }
-
- CAmount nValue = out.tx->vout[out.i].nValue;
- const CScript& pk = out.tx->vout[out.i].scriptPubKey;
- Object entry;
- entry.push_back(Pair("txid", out.tx->GetHash().GetHex()));
- entry.push_back(Pair("vout", out.i));
- CTxDestination address;
- if (ExtractDestination(out.tx->vout[out.i].scriptPubKey, address)) {
- entry.push_back(Pair("address", CBitcoinAddress(address).ToString()));
- if (pwalletMain->mapAddressBook.count(address))
- entry.push_back(Pair("account", pwalletMain->mapAddressBook[address].name));
- }
- entry.push_back(Pair("scriptPubKey", HexStr(pk.begin(), pk.end())));
- if (pk.IsPayToScriptHash()) {
- CTxDestination address;
- if (ExtractDestination(pk, address)) {
- const CScriptID& hash = boost::get<const CScriptID&>(address);
- CScript redeemScript;
- if (pwalletMain->GetCScript(hash, redeemScript))
- entry.push_back(Pair("redeemScript", HexStr(redeemScript.begin(), redeemScript.end())));
- }
- }
- entry.push_back(Pair("amount",ValueFromAmount(nValue)));
- entry.push_back(Pair("confirmations",out.nDepth));
- entry.push_back(Pair("spendable", out.fSpendable));
- results.push_back(entry);
- }
-
- return results;
-}
-#endif
-
Value createrawtransaction(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 2)
@@ -530,7 +419,7 @@ Value signrawtransaction(const Array& params, bool fHelp)
"\nResult:\n"
"{\n"
" \"hex\": \"value\", (string) The raw transaction with signature(s) (hex-encoded string)\n"
- " \"complete\": n (numeric) if transaction has a complete set of signature (0 if not)\n"
+ " \"complete\": true|false (boolean) if transaction has a complete set of signature\n"
"}\n"
"\nExamples:\n"
diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp
index 0fd7769a19..e2df41fe21 100644
--- a/src/rpcserver.cpp
+++ b/src/rpcserver.cpp
@@ -193,11 +193,6 @@ string CRPCTable::help(string strCommand) const
continue;
if ((strCommand != "" || pcmd->category == "hidden") && strMethod != strCommand)
continue;
-#ifdef ENABLE_WALLET
- if (pcmd->reqWallet && !pwalletMain)
- continue;
-#endif
-
try
{
Array params;
@@ -271,114 +266,114 @@ Value stop(const Array& params, bool fHelp)
* Call Table
*/
static const CRPCCommand vRPCCommands[] =
-{ // category name actor (function) okSafeMode reqWallet
- // --------------------- ------------------------ ----------------------- ---------- ---------
+{ // category name actor (function) okSafeMode
+ // --------------------- ------------------------ ----------------------- ----------
/* Overall control/query calls */
- { "control", "getinfo", &getinfo, true, false }, /* uses wallet if enabled */
- { "control", "help", &help, true, false },
- { "control", "stop", &stop, true, false },
+ { "control", "getinfo", &getinfo, true }, /* uses wallet if enabled */
+ { "control", "help", &help, true },
+ { "control", "stop", &stop, true },
/* P2P networking */
- { "network", "getnetworkinfo", &getnetworkinfo, true, false },
- { "network", "addnode", &addnode, true, false },
- { "network", "getaddednodeinfo", &getaddednodeinfo, true, false },
- { "network", "getconnectioncount", &getconnectioncount, true, false },
- { "network", "getnettotals", &getnettotals, true, false },
- { "network", "getpeerinfo", &getpeerinfo, true, false },
- { "network", "ping", &ping, true, false },
+ { "network", "getnetworkinfo", &getnetworkinfo, true },
+ { "network", "addnode", &addnode, true },
+ { "network", "getaddednodeinfo", &getaddednodeinfo, true },
+ { "network", "getconnectioncount", &getconnectioncount, true },
+ { "network", "getnettotals", &getnettotals, true },
+ { "network", "getpeerinfo", &getpeerinfo, true },
+ { "network", "ping", &ping, true },
/* Block chain and UTXO */
- { "blockchain", "getblockchaininfo", &getblockchaininfo, true, false },
- { "blockchain", "getbestblockhash", &getbestblockhash, true, false },
- { "blockchain", "getblockcount", &getblockcount, true, false },
- { "blockchain", "getblock", &getblock, true, false },
- { "blockchain", "getblockhash", &getblockhash, true, false },
- { "blockchain", "getchaintips", &getchaintips, true, false },
- { "blockchain", "getdifficulty", &getdifficulty, true, false },
- { "blockchain", "getmempoolinfo", &getmempoolinfo, true, false },
- { "blockchain", "getrawmempool", &getrawmempool, true, false },
- { "blockchain", "gettxout", &gettxout, true, false },
- { "blockchain", "gettxoutsetinfo", &gettxoutsetinfo, true, false },
- { "blockchain", "verifychain", &verifychain, true, false },
+ { "blockchain", "getblockchaininfo", &getblockchaininfo, true },
+ { "blockchain", "getbestblockhash", &getbestblockhash, true },
+ { "blockchain", "getblockcount", &getblockcount, true },
+ { "blockchain", "getblock", &getblock, true },
+ { "blockchain", "getblockhash", &getblockhash, true },
+ { "blockchain", "getchaintips", &getchaintips, true },
+ { "blockchain", "getdifficulty", &getdifficulty, true },
+ { "blockchain", "getmempoolinfo", &getmempoolinfo, true },
+ { "blockchain", "getrawmempool", &getrawmempool, true },
+ { "blockchain", "gettxout", &gettxout, true },
+ { "blockchain", "gettxoutsetinfo", &gettxoutsetinfo, true },
+ { "blockchain", "verifychain", &verifychain, true },
/* Mining */
- { "mining", "getblocktemplate", &getblocktemplate, true, false },
- { "mining", "getmininginfo", &getmininginfo, true, false },
- { "mining", "getnetworkhashps", &getnetworkhashps, true, false },
- { "mining", "prioritisetransaction", &prioritisetransaction, true, false },
- { "mining", "submitblock", &submitblock, true, false },
+ { "mining", "getblocktemplate", &getblocktemplate, true },
+ { "mining", "getmininginfo", &getmininginfo, true },
+ { "mining", "getnetworkhashps", &getnetworkhashps, true },
+ { "mining", "prioritisetransaction", &prioritisetransaction, true },
+ { "mining", "submitblock", &submitblock, true },
#ifdef ENABLE_WALLET
/* Coin generation */
- { "generating", "getgenerate", &getgenerate, true, false },
- { "generating", "setgenerate", &setgenerate, true, false },
- { "generating", "generate", &generate, true, false },
+ { "generating", "getgenerate", &getgenerate, true },
+ { "generating", "setgenerate", &setgenerate, true },
+ { "generating", "generate", &generate, true },
#endif
/* Raw transactions */
- { "rawtransactions", "createrawtransaction", &createrawtransaction, true, false },
- { "rawtransactions", "decoderawtransaction", &decoderawtransaction, true, false },
- { "rawtransactions", "decodescript", &decodescript, true, false },
- { "rawtransactions", "getrawtransaction", &getrawtransaction, true, false },
- { "rawtransactions", "sendrawtransaction", &sendrawtransaction, false, false },
- { "rawtransactions", "signrawtransaction", &signrawtransaction, false, false }, /* uses wallet if enabled */
+ { "rawtransactions", "createrawtransaction", &createrawtransaction, true },
+ { "rawtransactions", "decoderawtransaction", &decoderawtransaction, true },
+ { "rawtransactions", "decodescript", &decodescript, true },
+ { "rawtransactions", "getrawtransaction", &getrawtransaction, true },
+ { "rawtransactions", "sendrawtransaction", &sendrawtransaction, false },
+ { "rawtransactions", "signrawtransaction", &signrawtransaction, false }, /* uses wallet if enabled */
/* Utility functions */
- { "util", "createmultisig", &createmultisig, true, false },
- { "util", "validateaddress", &validateaddress, true, false }, /* uses wallet if enabled */
- { "util", "verifymessage", &verifymessage, true, false },
- { "util", "estimatefee", &estimatefee, true, false },
- { "util", "estimatepriority", &estimatepriority, true, false },
+ { "util", "createmultisig", &createmultisig, true },
+ { "util", "validateaddress", &validateaddress, true }, /* uses wallet if enabled */
+ { "util", "verifymessage", &verifymessage, true },
+ { "util", "estimatefee", &estimatefee, true },
+ { "util", "estimatepriority", &estimatepriority, true },
/* Not shown in help */
- { "hidden", "invalidateblock", &invalidateblock, true, false },
- { "hidden", "reconsiderblock", &reconsiderblock, true, false },
- { "hidden", "setmocktime", &setmocktime, true, false },
+ { "hidden", "invalidateblock", &invalidateblock, true },
+ { "hidden", "reconsiderblock", &reconsiderblock, true },
+ { "hidden", "setmocktime", &setmocktime, true },
#ifdef ENABLE_WALLET
- { "hidden", "resendwallettransactions", &resendwallettransactions, true, true },
+ { "hidden", "resendwallettransactions", &resendwallettransactions, true},
#endif
#ifdef ENABLE_WALLET
/* Wallet */
- { "wallet", "addmultisigaddress", &addmultisigaddress, true, true },
- { "wallet", "backupwallet", &backupwallet, true, true },
- { "wallet", "dumpprivkey", &dumpprivkey, true, true },
- { "wallet", "dumpwallet", &dumpwallet, true, true },
- { "wallet", "encryptwallet", &encryptwallet, true, true },
- { "wallet", "getaccountaddress", &getaccountaddress, true, true },
- { "wallet", "getaccount", &getaccount, true, true },
- { "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true, true },
- { "wallet", "getbalance", &getbalance, false, true },
- { "wallet", "getnewaddress", &getnewaddress, true, true },
- { "wallet", "getrawchangeaddress", &getrawchangeaddress, true, true },
- { "wallet", "getreceivedbyaccount", &getreceivedbyaccount, false, true },
- { "wallet", "getreceivedbyaddress", &getreceivedbyaddress, false, true },
- { "wallet", "gettransaction", &gettransaction, false, true },
- { "wallet", "getunconfirmedbalance", &getunconfirmedbalance, false, true },
- { "wallet", "getwalletinfo", &getwalletinfo, false, true },
- { "wallet", "importprivkey", &importprivkey, true, true },
- { "wallet", "importwallet", &importwallet, true, true },
- { "wallet", "importaddress", &importaddress, true, true },
- { "wallet", "keypoolrefill", &keypoolrefill, true, true },
- { "wallet", "listaccounts", &listaccounts, false, true },
- { "wallet", "listaddressgroupings", &listaddressgroupings, false, true },
- { "wallet", "listlockunspent", &listlockunspent, false, true },
- { "wallet", "listreceivedbyaccount", &listreceivedbyaccount, false, true },
- { "wallet", "listreceivedbyaddress", &listreceivedbyaddress, false, true },
- { "wallet", "listsinceblock", &listsinceblock, false, true },
- { "wallet", "listtransactions", &listtransactions, false, true },
- { "wallet", "listunspent", &listunspent, false, true },
- { "wallet", "lockunspent", &lockunspent, true, true },
- { "wallet", "move", &movecmd, false, true },
- { "wallet", "sendfrom", &sendfrom, false, true },
- { "wallet", "sendmany", &sendmany, false, true },
- { "wallet", "sendtoaddress", &sendtoaddress, false, true },
- { "wallet", "setaccount", &setaccount, true, true },
- { "wallet", "settxfee", &settxfee, true, true },
- { "wallet", "signmessage", &signmessage, true, true },
- { "wallet", "walletlock", &walletlock, true, true },
- { "wallet", "walletpassphrasechange", &walletpassphrasechange, true, true },
- { "wallet", "walletpassphrase", &walletpassphrase, true, true },
+ { "wallet", "addmultisigaddress", &addmultisigaddress, true },
+ { "wallet", "backupwallet", &backupwallet, true },
+ { "wallet", "dumpprivkey", &dumpprivkey, true },
+ { "wallet", "dumpwallet", &dumpwallet, true },
+ { "wallet", "encryptwallet", &encryptwallet, true },
+ { "wallet", "getaccountaddress", &getaccountaddress, true },
+ { "wallet", "getaccount", &getaccount, true },
+ { "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true },
+ { "wallet", "getbalance", &getbalance, false },
+ { "wallet", "getnewaddress", &getnewaddress, true },
+ { "wallet", "getrawchangeaddress", &getrawchangeaddress, true },
+ { "wallet", "getreceivedbyaccount", &getreceivedbyaccount, false },
+ { "wallet", "getreceivedbyaddress", &getreceivedbyaddress, false },
+ { "wallet", "gettransaction", &gettransaction, false },
+ { "wallet", "getunconfirmedbalance", &getunconfirmedbalance, false },
+ { "wallet", "getwalletinfo", &getwalletinfo, false },
+ { "wallet", "importprivkey", &importprivkey, true },
+ { "wallet", "importwallet", &importwallet, true },
+ { "wallet", "importaddress", &importaddress, true },
+ { "wallet", "keypoolrefill", &keypoolrefill, true },
+ { "wallet", "listaccounts", &listaccounts, false },
+ { "wallet", "listaddressgroupings", &listaddressgroupings, false },
+ { "wallet", "listlockunspent", &listlockunspent, false },
+ { "wallet", "listreceivedbyaccount", &listreceivedbyaccount, false },
+ { "wallet", "listreceivedbyaddress", &listreceivedbyaddress, false },
+ { "wallet", "listsinceblock", &listsinceblock, false },
+ { "wallet", "listtransactions", &listtransactions, false },
+ { "wallet", "listunspent", &listunspent, false },
+ { "wallet", "lockunspent", &lockunspent, true },
+ { "wallet", "move", &movecmd, false },
+ { "wallet", "sendfrom", &sendfrom, false },
+ { "wallet", "sendmany", &sendmany, false },
+ { "wallet", "sendtoaddress", &sendtoaddress, false },
+ { "wallet", "setaccount", &setaccount, true },
+ { "wallet", "settxfee", &settxfee, true },
+ { "wallet", "signmessage", &signmessage, true },
+ { "wallet", "walletlock", &walletlock, true },
+ { "wallet", "walletpassphrasechange", &walletpassphrasechange, true },
+ { "wallet", "walletpassphrase", &walletpassphrase, true },
#endif // ENABLE_WALLET
};
diff --git a/src/rpcserver.h b/src/rpcserver.h
index e7aaed8bdf..c3200d8c35 100644
--- a/src/rpcserver.h
+++ b/src/rpcserver.h
@@ -98,7 +98,6 @@ public:
std::string name;
rpcfn_type actor;
bool okSafeMode;
- bool reqWallet;
};
/**
diff --git a/src/support/allocators/secure.h b/src/support/allocators/secure.h
index 7a74d87bb4..5e7bb66ea2 100644
--- a/src/support/allocators/secure.h
+++ b/src/support/allocators/secure.h
@@ -3,8 +3,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#ifndef BITCOIN_ALLOCATORS_SECURE_H
-#define BITCOIN_ALLOCATORS_SECURE_H
+#ifndef BITCOIN_SUPPORT_ALLOCATORS_SECURE_H
+#define BITCOIN_SUPPORT_ALLOCATORS_SECURE_H
#include "support/pagelocker.h"
@@ -59,4 +59,4 @@ struct secure_allocator : public std::allocator<T> {
// This is exactly like std::string, but with a custom allocator.
typedef std::basic_string<char, std::char_traits<char>, secure_allocator<char> > SecureString;
-#endif // BITCOIN_ALLOCATORS_SECURE_H
+#endif // BITCOIN_SUPPORT_ALLOCATORS_SECURE_H
diff --git a/src/support/allocators/zeroafterfree.h b/src/support/allocators/zeroafterfree.h
index b01fcd088b..41e23392e8 100644
--- a/src/support/allocators/zeroafterfree.h
+++ b/src/support/allocators/zeroafterfree.h
@@ -3,8 +3,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#ifndef BITCOIN_ALLOCATORS_ZEROAFTERFREE_H
-#define BITCOIN_ALLOCATORS_ZEROAFTERFREE_H
+#ifndef BITCOIN_SUPPORT_ALLOCATORS_ZEROAFTERFREE_H
+#define BITCOIN_SUPPORT_ALLOCATORS_ZEROAFTERFREE_H
#include "support/cleanse.h"
@@ -45,4 +45,4 @@ struct zero_after_free_allocator : public std::allocator<T> {
// Byte-vector that clears its contents before deletion.
typedef std::vector<char, zero_after_free_allocator<char> > CSerializeData;
-#endif // BITCOIN_ALLOCATORS_ZEROAFTERFREE_H
+#endif // BITCOIN_SUPPORT_ALLOCATORS_ZEROAFTERFREE_H
diff --git a/src/support/pagelocker.h b/src/support/pagelocker.h
index 964be1aec4..3fd793072f 100644
--- a/src/support/pagelocker.h
+++ b/src/support/pagelocker.h
@@ -3,8 +3,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#ifndef BITCOIN_ALLOCATORS_PAGELOCKER_H
-#define BITCOIN_ALLOCATORS_PAGELOCKER_H
+#ifndef BITCOIN_SUPPORT_PAGELOCKER_H
+#define BITCOIN_SUPPORT_PAGELOCKER_H
#include "support/cleanse.h"
@@ -175,4 +175,4 @@ void UnlockObject(const T& t)
LockedPageManager::Instance().UnlockRange((void*)(&t), sizeof(T));
}
-#endif // BITCOIN_ALLOCATORS_PAGELOCKER_H
+#endif // BITCOIN_SUPPORT_PAGELOCKER_H
diff --git a/src/sync.h b/src/sync.h
index 27e80e813b..78b9043477 100644
--- a/src/sync.h
+++ b/src/sync.h
@@ -21,9 +21,6 @@
////////////////////////////////////////////////
/*
-
-
-
CCriticalSection mutex;
boost::recursive_mutex mutex;
@@ -42,20 +39,18 @@ ENTER_CRITICAL_SECTION(mutex); // no RAII
LEAVE_CRITICAL_SECTION(mutex); // no RAII
mutex.unlock();
-
-
-
*/
-
///////////////////////////////
// //
// THE ACTUAL IMPLEMENTATION //
// //
///////////////////////////////
-// Template mixin that adds -Wthread-safety locking annotations to a
-// subset of the mutex API.
+/**
+ * Template mixin that adds -Wthread-safety locking
+ * annotations to a subset of the mutex API.
+ */
template <typename PARENT>
class LOCKABLE AnnotatedMixin : public PARENT
{
@@ -76,8 +71,10 @@ public:
}
};
-/** Wrapped boost mutex: supports recursive locking, but no waiting */
-// TODO: We should move away from using the recursive lock by default.
+/**
+ * Wrapped boost mutex: supports recursive locking, but no waiting
+ * TODO: We should move away from using the recursive lock by default.
+ */
typedef AnnotatedMixin<boost::recursive_mutex> CCriticalSection;
/** Wrapped boost mutex: supports waiting but not recursive locking */
@@ -92,9 +89,7 @@ void LeaveCritical();
std::string LocksHeld();
void AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine, void* cs);
#else
-void static inline EnterCritical(const char* pszName, const char* pszFile, int nLine, void* cs, bool fTry = false)
-{
-}
+void static inline EnterCritical(const char* pszName, const char* pszFile, int nLine, void* cs, bool fTry = false) {}
void static inline LeaveCritical() {}
void static inline AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine, void* cs) {}
#endif
diff --git a/src/wallet/crypter.h b/src/wallet/crypter.h
index 32746b00df..70aeb76723 100644
--- a/src/wallet/crypter.h
+++ b/src/wallet/crypter.h
@@ -2,8 +2,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#ifndef BITCOIN_CRYPTER_H
-#define BITCOIN_CRYPTER_H
+#ifndef BITCOIN_WALLET_CRYPTER_H
+#define BITCOIN_WALLET_CRYPTER_H
#include "keystore.h"
#include "serialize.h"
@@ -193,4 +193,4 @@ public:
boost::signals2::signal<void (CCryptoKeyStore* wallet)> NotifyStatusChanged;
};
-#endif // BITCOIN_CRYPTER_H
+#endif // BITCOIN_WALLET_CRYPTER_H
diff --git a/src/wallet/db.h b/src/wallet/db.h
index 790ae50413..9596723b21 100644
--- a/src/wallet/db.h
+++ b/src/wallet/db.h
@@ -3,8 +3,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#ifndef BITCOIN_DB_H
-#define BITCOIN_DB_H
+#ifndef BITCOIN_WALLET_DB_H
+#define BITCOIN_WALLET_DB_H
#include "clientversion.h"
#include "serialize.h"
@@ -307,4 +307,4 @@ public:
bool static Rewrite(const std::string& strFile, const char* pszSkip = NULL);
};
-#endif // BITCOIN_DB_H
+#endif // BITCOIN_WALLET_DB_H
diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp
index b9c92a06c5..ab951d1d7d 100644
--- a/src/wallet/rpcdump.cpp
+++ b/src/wallet/rpcdump.cpp
@@ -25,6 +25,7 @@ using namespace json_spirit;
using namespace std;
void EnsureWalletIsUnlocked();
+bool EnsureWalletIsAvailable(bool avoidException);
std::string static EncodeDumpTime(int64_t nTime) {
return DateTimeStrFormat("%Y-%m-%dT%H:%M:%SZ", nTime);
@@ -71,6 +72,9 @@ std::string DecodeDumpString(const std::string &str) {
Value importprivkey(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() < 1 || params.size() > 3)
throw runtime_error(
"importprivkey \"bitcoinprivkey\" ( \"label\" rescan )\n"
@@ -142,6 +146,9 @@ Value importprivkey(const Array& params, bool fHelp)
Value importaddress(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() < 1 || params.size() > 3)
throw runtime_error(
"importaddress \"address\" ( \"label\" rescan )\n"
@@ -212,6 +219,9 @@ Value importaddress(const Array& params, bool fHelp)
Value importwallet(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() != 1)
throw runtime_error(
"importwallet \"filename\"\n"
@@ -313,6 +323,9 @@ Value importwallet(const Array& params, bool fHelp)
Value dumpprivkey(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() != 1)
throw runtime_error(
"dumpprivkey \"bitcoinaddress\"\n"
@@ -348,6 +361,9 @@ Value dumpprivkey(const Array& params, bool fHelp)
Value dumpwallet(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() != 1)
throw runtime_error(
"dumpwallet \"filename\"\n"
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
index 29f3eda15d..e03cd5b84e 100644
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -37,6 +37,18 @@ std::string HelpRequiringPassphrase()
: "";
}
+bool EnsureWalletIsAvailable(bool avoidException)
+{
+ if (!pwalletMain)
+ {
+ if (!avoidException)
+ throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found (disabled)");
+ else
+ return false;
+ }
+ return true;
+}
+
void EnsureWalletIsUnlocked()
{
if (pwalletMain->IsLocked())
@@ -77,6 +89,9 @@ string AccountFromValue(const Value& value)
Value getnewaddress(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() > 1)
throw runtime_error(
"getnewaddress ( \"account\" )\n"
@@ -153,6 +168,9 @@ CBitcoinAddress GetAccountAddress(string strAccount, bool bForceNew=false)
Value getaccountaddress(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() != 1)
throw runtime_error(
"getaccountaddress \"account\"\n"
@@ -182,6 +200,9 @@ Value getaccountaddress(const Array& params, bool fHelp)
Value getrawchangeaddress(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() > 1)
throw runtime_error(
"getrawchangeaddress\n"
@@ -214,6 +235,9 @@ Value getrawchangeaddress(const Array& params, bool fHelp)
Value setaccount(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
"setaccount \"bitcoinaddress\" \"account\"\n"
@@ -257,6 +281,9 @@ Value setaccount(const Array& params, bool fHelp)
Value getaccount(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() != 1)
throw runtime_error(
"getaccount \"bitcoinaddress\"\n"
@@ -286,6 +313,9 @@ Value getaccount(const Array& params, bool fHelp)
Value getaddressesbyaccount(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() != 1)
throw runtime_error(
"getaddressesbyaccount \"account\"\n"
@@ -351,6 +381,9 @@ static void SendMoney(const CTxDestination &address, CAmount nValue, bool fSubtr
Value sendtoaddress(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() < 2 || params.size() > 5)
throw runtime_error(
"sendtoaddress \"bitcoinaddress\" amount ( \"comment\" \"comment-to\" subtractfeefromamount )\n"
@@ -404,6 +437,9 @@ Value sendtoaddress(const Array& params, bool fHelp)
Value listaddressgroupings(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp)
throw runtime_error(
"listaddressgroupings\n"
@@ -453,6 +489,9 @@ Value listaddressgroupings(const Array& params, bool fHelp)
Value signmessage(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() != 2)
throw runtime_error(
"signmessage \"bitcoinaddress\" \"message\"\n"
@@ -506,6 +545,9 @@ Value signmessage(const Array& params, bool fHelp)
Value getreceivedbyaddress(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
"getreceivedbyaddress \"bitcoinaddress\" ( minconf )\n"
@@ -561,6 +603,9 @@ Value getreceivedbyaddress(const Array& params, bool fHelp)
Value getreceivedbyaccount(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
"getreceivedbyaccount \"account\" ( minconf )\n"
@@ -647,6 +692,9 @@ CAmount GetAccountBalance(const string& strAccount, int nMinDepth, const isminef
Value getbalance(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() > 3)
throw runtime_error(
"getbalance ( \"account\" minconf includeWatchonly )\n"
@@ -719,6 +767,9 @@ Value getbalance(const Array& params, bool fHelp)
Value getunconfirmedbalance(const Array &params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() > 0)
throw runtime_error(
"getunconfirmedbalance\n"
@@ -732,6 +783,9 @@ Value getunconfirmedbalance(const Array &params, bool fHelp)
Value movecmd(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() < 3 || params.size() > 5)
throw runtime_error(
"move \"fromaccount\" \"toaccount\" amount ( minconf \"comment\" )\n"
@@ -799,6 +853,9 @@ Value movecmd(const Array& params, bool fHelp)
Value sendfrom(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() < 3 || params.size() > 6)
throw runtime_error(
"sendfrom \"fromaccount\" \"tobitcoinaddress\" amount ( minconf \"comment\" \"comment-to\" )\n"
@@ -859,6 +916,9 @@ Value sendfrom(const Array& params, bool fHelp)
Value sendmany(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() < 2 || params.size() > 5)
throw runtime_error(
"sendmany \"fromaccount\" {\"address\":amount,...} ( minconf \"comment\" [\"address\",...] )\n"
@@ -965,6 +1025,9 @@ extern CScript _createmultisig_redeemScript(const Array& params);
Value addmultisigaddress(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() < 2 || params.size() > 3)
{
string msg = "addmultisigaddress nrequired [\"key\",...] ( \"account\" )\n"
@@ -1143,6 +1206,9 @@ Value ListReceived(const Array& params, bool fByAccounts)
Value listreceivedbyaddress(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() > 3)
throw runtime_error(
"listreceivedbyaddress ( minconf includeempty includeWatchonly)\n"
@@ -1177,6 +1243,9 @@ Value listreceivedbyaddress(const Array& params, bool fHelp)
Value listreceivedbyaccount(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() > 3)
throw runtime_error(
"listreceivedbyaccount ( minconf includeempty includeWatchonly)\n"
@@ -1304,6 +1373,9 @@ void AcentryToJSON(const CAccountingEntry& acentry, const string& strAccount, Ar
Value listtransactions(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() > 4)
throw runtime_error(
"listtransactions ( \"account\" count from includeWatchonly)\n"
@@ -1415,6 +1487,9 @@ Value listtransactions(const Array& params, bool fHelp)
Value listaccounts(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() > 2)
throw runtime_error(
"listaccounts ( minconf includeWatchonly)\n"
@@ -1492,6 +1567,9 @@ Value listaccounts(const Array& params, bool fHelp)
Value listsinceblock(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp)
throw runtime_error(
"listsinceblock ( \"blockhash\" target-confirmations includeWatchonly)\n"
@@ -1580,6 +1658,9 @@ Value listsinceblock(const Array& params, bool fHelp)
Value gettransaction(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
"gettransaction \"txid\" ( includeWatchonly )\n"
@@ -1655,6 +1736,9 @@ Value gettransaction(const Array& params, bool fHelp)
Value backupwallet(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() != 1)
throw runtime_error(
"backupwallet \"destination\"\n"
@@ -1678,6 +1762,9 @@ Value backupwallet(const Array& params, bool fHelp)
Value keypoolrefill(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() > 1)
throw runtime_error(
"keypoolrefill ( newsize )\n"
@@ -1719,6 +1806,9 @@ static void LockWallet(CWallet* pWallet)
Value walletpassphrase(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (pwalletMain->IsCrypted() && (fHelp || params.size() != 2))
throw runtime_error(
"walletpassphrase \"passphrase\" timeout\n"
@@ -1776,6 +1866,9 @@ Value walletpassphrase(const Array& params, bool fHelp)
Value walletpassphrasechange(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (pwalletMain->IsCrypted() && (fHelp || params.size() != 2))
throw runtime_error(
"walletpassphrasechange \"oldpassphrase\" \"newpassphrase\"\n"
@@ -1819,6 +1912,9 @@ Value walletpassphrasechange(const Array& params, bool fHelp)
Value walletlock(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (pwalletMain->IsCrypted() && (fHelp || params.size() != 0))
throw runtime_error(
"walletlock\n"
@@ -1855,6 +1951,9 @@ Value walletlock(const Array& params, bool fHelp)
Value encryptwallet(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (!pwalletMain->IsCrypted() && (fHelp || params.size() != 1))
throw runtime_error(
"encryptwallet \"passphrase\"\n"
@@ -1909,6 +2008,9 @@ Value encryptwallet(const Array& params, bool fHelp)
Value lockunspent(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
"lockunspent unlock [{\"txid\":\"txid\",\"vout\":n},...]\n"
@@ -1990,6 +2092,9 @@ Value lockunspent(const Array& params, bool fHelp)
Value listlockunspent(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() > 0)
throw runtime_error(
"listlockunspent\n"
@@ -2036,6 +2141,9 @@ Value listlockunspent(const Array& params, bool fHelp)
Value settxfee(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() < 1 || params.size() > 1)
throw runtime_error(
"settxfee amount\n"
@@ -2062,6 +2170,9 @@ Value settxfee(const Array& params, bool fHelp)
Value getwalletinfo(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() != 0)
throw runtime_error(
"getwalletinfo\n"
@@ -2099,6 +2210,9 @@ Value getwalletinfo(const Array& params, bool fHelp)
Value resendwallettransactions(const Array& params, bool fHelp)
{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
if (fHelp || params.size() != 0)
throw runtime_error(
"resendwallettransactions\n"
@@ -2118,3 +2232,115 @@ Value resendwallettransactions(const Array& params, bool fHelp)
}
return result;
}
+
+Value listunspent(const Array& params, bool fHelp)
+{
+ if (!EnsureWalletIsAvailable(fHelp))
+ return Value::null;
+
+ if (fHelp || params.size() > 3)
+ throw runtime_error(
+ "listunspent ( minconf maxconf [\"address\",...] )\n"
+ "\nReturns array of unspent transaction outputs\n"
+ "with between minconf and maxconf (inclusive) confirmations.\n"
+ "Optionally filter to only include txouts paid to specified addresses.\n"
+ "Results are an array of Objects, each of which has:\n"
+ "{txid, vout, scriptPubKey, amount, confirmations}\n"
+ "\nArguments:\n"
+ "1. minconf (numeric, optional, default=1) The minimum confirmations to filter\n"
+ "2. maxconf (numeric, optional, default=9999999) The maximum confirmations to filter\n"
+ "3. \"addresses\" (string) A json array of bitcoin addresses to filter\n"
+ " [\n"
+ " \"address\" (string) bitcoin address\n"
+ " ,...\n"
+ " ]\n"
+ "\nResult\n"
+ "[ (array of json object)\n"
+ " {\n"
+ " \"txid\" : \"txid\", (string) the transaction id \n"
+ " \"vout\" : n, (numeric) the vout value\n"
+ " \"address\" : \"address\", (string) the bitcoin address\n"
+ " \"account\" : \"account\", (string) DEPRECATED. The associated account, or \"\" for the default account\n"
+ " \"scriptPubKey\" : \"key\", (string) the script key\n"
+ " \"amount\" : x.xxx, (numeric) the transaction amount in btc\n"
+ " \"confirmations\" : n (numeric) The number of confirmations\n"
+ " }\n"
+ " ,...\n"
+ "]\n"
+
+ "\nExamples\n"
+ + HelpExampleCli("listunspent", "")
+ + HelpExampleCli("listunspent", "6 9999999 \"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\",\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"")
+ + HelpExampleRpc("listunspent", "6, 9999999 \"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\",\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"")
+ );
+
+ RPCTypeCheck(params, boost::assign::list_of(int_type)(int_type)(array_type));
+
+ int nMinDepth = 1;
+ if (params.size() > 0)
+ nMinDepth = params[0].get_int();
+
+ int nMaxDepth = 9999999;
+ if (params.size() > 1)
+ nMaxDepth = params[1].get_int();
+
+ set<CBitcoinAddress> setAddress;
+ if (params.size() > 2) {
+ Array inputs = params[2].get_array();
+ BOOST_FOREACH(Value& input, inputs) {
+ CBitcoinAddress address(input.get_str());
+ if (!address.IsValid())
+ throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid Bitcoin address: ")+input.get_str());
+ if (setAddress.count(address))
+ throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+input.get_str());
+ setAddress.insert(address);
+ }
+ }
+
+ Array results;
+ vector<COutput> vecOutputs;
+ assert(pwalletMain != NULL);
+ LOCK2(cs_main, pwalletMain->cs_wallet);
+ pwalletMain->AvailableCoins(vecOutputs, false);
+ BOOST_FOREACH(const COutput& out, vecOutputs) {
+ if (out.nDepth < nMinDepth || out.nDepth > nMaxDepth)
+ continue;
+
+ if (setAddress.size()) {
+ CTxDestination address;
+ if (!ExtractDestination(out.tx->vout[out.i].scriptPubKey, address))
+ continue;
+
+ if (!setAddress.count(address))
+ continue;
+ }
+
+ CAmount nValue = out.tx->vout[out.i].nValue;
+ const CScript& pk = out.tx->vout[out.i].scriptPubKey;
+ Object entry;
+ entry.push_back(Pair("txid", out.tx->GetHash().GetHex()));
+ entry.push_back(Pair("vout", out.i));
+ CTxDestination address;
+ if (ExtractDestination(out.tx->vout[out.i].scriptPubKey, address)) {
+ entry.push_back(Pair("address", CBitcoinAddress(address).ToString()));
+ if (pwalletMain->mapAddressBook.count(address))
+ entry.push_back(Pair("account", pwalletMain->mapAddressBook[address].name));
+ }
+ entry.push_back(Pair("scriptPubKey", HexStr(pk.begin(), pk.end())));
+ if (pk.IsPayToScriptHash()) {
+ CTxDestination address;
+ if (ExtractDestination(pk, address)) {
+ const CScriptID& hash = boost::get<const CScriptID&>(address);
+ CScript redeemScript;
+ if (pwalletMain->GetCScript(hash, redeemScript))
+ entry.push_back(Pair("redeemScript", HexStr(redeemScript.begin(), redeemScript.end())));
+ }
+ }
+ entry.push_back(Pair("amount",ValueFromAmount(nValue)));
+ entry.push_back(Pair("confirmations",out.nDepth));
+ entry.push_back(Pair("spendable", out.fSpendable));
+ results.push_back(entry);
+ }
+
+ return results;
+} \ No newline at end of file
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 2566b2712b..0d40469393 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -2038,7 +2038,7 @@ DBErrors CWallet::LoadWallet(bool& fFirstRunRet)
setKeyPool.clear();
// Note: can't top-up keypool here, because wallet is locked.
// User will be prompted to unlock wallet the next operation
- // the requires a new key.
+ // that requires a new key.
}
}
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index 4dbb0e2e57..10969efee6 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -3,8 +3,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#ifndef BITCOIN_WALLET_H
-#define BITCOIN_WALLET_H
+#ifndef BITCOIN_WALLET_WALLET_H
+#define BITCOIN_WALLET_WALLET_H
#include "amount.h"
#include "key.h"
@@ -869,4 +869,4 @@ private:
std::vector<char> _ssExtra;
};
-#endif // BITCOIN_WALLET_H
+#endif // BITCOIN_WALLET_WALLET_H
diff --git a/src/wallet/wallet_ismine.h b/src/wallet/wallet_ismine.h
index 6293df8b10..5b9b0e0841 100644
--- a/src/wallet/wallet_ismine.h
+++ b/src/wallet/wallet_ismine.h
@@ -3,8 +3,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#ifndef BITCOIN_WALLET_ISMINE_H
-#define BITCOIN_WALLET_ISMINE_H
+#ifndef BITCOIN_WALLET_WALLET_ISMINE_H
+#define BITCOIN_WALLET_WALLET_ISMINE_H
#include "key.h"
#include "script/standard.h"
@@ -26,4 +26,4 @@ typedef uint8_t isminefilter;
isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey);
isminetype IsMine(const CKeyStore& keystore, const CTxDestination& dest);
-#endif // BITCOIN_WALLET_ISMINE_H
+#endif // BITCOIN_WALLET_WALLET_ISMINE_H
diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h
index e5f64ffaae..bc1a104b5b 100644
--- a/src/wallet/walletdb.h
+++ b/src/wallet/walletdb.h
@@ -3,8 +3,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#ifndef BITCOIN_WALLETDB_H
-#define BITCOIN_WALLETDB_H
+#ifndef BITCOIN_WALLET_WALLETDB_H
+#define BITCOIN_WALLET_WALLETDB_H
#include "amount.h"
#include "wallet/db.h"
@@ -140,4 +140,4 @@ private:
bool BackupWallet(const CWallet& wallet, const std::string& strDest);
void ThreadFlushWalletDB(const std::string& strFile);
-#endif // BITCOIN_WALLETDB_H
+#endif // BITCOIN_WALLET_WALLETDB_H