aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--doc/Doxyfile2
-rw-r--r--doc/README.md2
-rw-r--r--doc/README_windows.txt2
-rw-r--r--doc/REST-interface.md4
-rw-r--r--doc/release-notes.md218
-rwxr-xr-xqa/pull-tester/rpc-tests.sh1
-rwxr-xr-xqa/rpc-tests/rest.py112
-rwxr-xr-xqa/rpc-tests/walletbackup.py4
-rw-r--r--src/main.cpp14
-rw-r--r--src/net.cpp4
-rw-r--r--src/netbase.cpp6
-rw-r--r--src/rest.cpp94
13 files changed, 138 insertions, 327 deletions
diff --git a/configure.ac b/configure.ac
index c5d08a0285..6dd03ea408 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,7 @@
dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 0)
-define(_CLIENT_VERSION_MINOR, 10)
+define(_CLIENT_VERSION_MINOR, 11)
define(_CLIENT_VERSION_REVISION, 99)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_IS_RELEASE, false)
diff --git a/doc/Doxyfile b/doc/Doxyfile
index 8a11d1e8d0..925a33ee89 100644
--- a/doc/Doxyfile
+++ b/doc/Doxyfile
@@ -34,7 +34,7 @@ PROJECT_NAME = Bitcoin
# This could be handy for archiving the generated documentation or
# if some version control system is used.
-PROJECT_NUMBER = 0.10.99
+PROJECT_NUMBER = 0.11.99
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer
diff --git a/doc/README.md b/doc/README.md
index e3be27d706..ecddf50d4b 100644
--- a/doc/README.md
+++ b/doc/README.md
@@ -1,4 +1,4 @@
-Bitcoin Core 0.10.99
+Bitcoin Core 0.11.99
=====================
Setup
diff --git a/doc/README_windows.txt b/doc/README_windows.txt
index c582941696..e4fd9bdf90 100644
--- a/doc/README_windows.txt
+++ b/doc/README_windows.txt
@@ -1,4 +1,4 @@
-Bitcoin Core 0.10.99
+Bitcoin Core 0.11.99
=====================
Intro
diff --git a/doc/REST-interface.md b/doc/REST-interface.md
index 0b718d664e..2219ceb65f 100644
--- a/doc/REST-interface.md
+++ b/doc/REST-interface.md
@@ -47,7 +47,7 @@ Only supports JSON as output format.
* chainwork : (string) total amount of work in active chain, in hexadecimal
####Query UTXO set
-`GET /rest/getutxos.<bin|hex|json>`
+`GET /rest/getutxos/<checkmempool>/<txid>-<n>/<txid>-<n>/.../<txid>-<n>.<bin|hex|json>`
The getutxo command allows querying of the UTXO set given a set of outpoints.
See BIP64 for input and output serialisation:
@@ -55,7 +55,7 @@ https://github.com/bitcoin/bips/blob/master/bip-0064.mediawiki
Example:
```
-$ curl --data '{"checkmempool":true,"outpoints":[{"txid":"b2cdfd7b89def827ff8af7cd9bff7627ff72e5e8b0f71210f92ea7a4000c5d75","n":0}]}' localhost:18332/rest/getutxos.json 2>/dev/null | json_pp
+$ curl localhost:18332/rest/getutxos/checkmempool/b2cdfd7b89def827ff8af7cd9bff7627ff72e5e8b0f71210f92ea7a4000c5d75-0.json 2>/dev/null | json_pp
{
"chaintipHash" : "00000000fb01a7f3745a717f8caebee056c484e6e0bfe4a9591c235bb70506fb",
"chainHeight" : 325347,
diff --git a/doc/release-notes.md b/doc/release-notes.md
index c5e41dfc66..6bb8587d78 100644
--- a/doc/release-notes.md
+++ b/doc/release-notes.md
@@ -4,240 +4,36 @@ release-notes at release time)
Notable changes
===============
-Block file pruning
+Example header
----------------------
-This release supports running a fully validating node without maintaining a copy
-of the raw block and undo data on disk. To recap, there are four types of data
-related to the blockchain in the bitcoin system: the raw blocks as received over
-the network (blk???.dat), the undo data (rev???.dat), the block index and the
-UTXO set (both LevelDB databases). The databases are built from the raw data.
+Example content.
-Block pruning allows Bitcoin Core to delete the raw block and undo data once
-it's been validated and used to build the databases. At that point, the raw data
-is used only to relay blocks to other nodes, to handle reorganizations, to look
-up old transactions (if -txindex is enabled or via the RPC/REST interfaces), or
-for rescanning the wallet. The block index continues to hold the metadata about
-all blocks in the blockchain.
-
-The user specifies how much space to allot for block & undo files. The minimum
-allowed is 550MB. Note that this is in addition to whatever is required for the
-block index and UTXO databases. The minimum was chosen so that Bitcoin Core will
-be able to maintain at least 288 blocks on disk (two days worth of blocks at 10
-minutes per block). In rare instances it is possible that the amount of space
-used will exceed the pruning target in order to keep the required last 288
-blocks on disk.
-
-Block pruning works during initial sync in the same way as during steady state,
-by deleting block files "as you go" whenever disk space is allocated. Thus, if
-the user specifies 550MB, once that level is reached the program will begin
-deleting the oldest block and undo files, while continuing to download the
-blockchain.
-
-For now, block pruning disables block relay. In the future, nodes with block
-pruning will at a minimum relay "new" blocks, meaning blocks that extend their
-active chain.
-
-Block pruning is currently incompatible with running a wallet due to the fact
-that block data is used for rescanning the wallet and importing keys or
-addresses (which require a rescan.) However, running the wallet with block
-pruning will be supported in the near future, subject to those limitations.
-
-Block pruning is also incompatible with -txindex and will automatically disable
-it.
-
-Once you have pruned blocks, going back to unpruned state requires
-re-downloading the entire blockchain. To do this, re-start the node with
--reindex. Note also that any problem that would cause a user to reindex (e.g.,
-disk corruption) will cause a pruned node to redownload the entire blockchain.
-Finally, note that when a pruned node reindexes, it will delete any blk???.dat
-and rev???.dat files in the data directory prior to restarting the download.
-
-To enable block pruning on the command line:
-
-- `-prune=N`: where N is the number of MB to allot for raw block & undo data.
-
-Modified RPC calls:
-
-- `getblockchaininfo` now includes whether we are in pruned mode or not.
-- `getblock` will check if the block's data has been pruned and if so, return an
-error.
-- `getrawtransaction` will no longer be able to locate a transaction that has a
-UTXO but where its block file has been pruned.
-
-Pruning is disabled by default.
-
-
-0.11.0 Change log
+0.12.0 Change log
=================
Detailed release notes follow. This overview includes changes that affect
-behavior, not code moves, refactors or string updates.
+behavior, not code moves, refactors and string updates. For convenience in locating
+the code changes and accompanying discussion, both the pull request and
+git merge commit are mentioned.
### RPC and REST
-- #5461 `5f7279a` signrawtransaction: validate private key
-- #5444 `103f66b` Add /rest/headers/<count>/<hash>.<ext>
-- #4964 `95ecc0a` Add scriptPubKey field to validateaddress RPC call
-- #5476 `c986972` Add time offset into getpeerinfo output
-- #5540 `84eba47` Add unconfirmed and immature balances to getwalletinfo
-- #5599 `40e96a3` Get rid of the internal miner's hashmeter
-- #5711 `87ecfb0` Push down RPC locks
-- #5754 `1c4e3f9` fix getblocktemplate lock issue
-- #5756 `5d901d8` Fix getblocktemplate_proposals test by mining one block
-- #5548 `d48ce48` Add /rest/chaininfos
-- #5992 `4c4f1b4` Push down RPC reqWallet flag
-- #6036 `585b5db` Show zero value txouts in listunspent
-- #5199 `6364408` Add RPC call `gettxoutproof` to generate and verify merkle blocks
-- #5418 `16341cc` Report missing inputs in sendrawtransaction
-- #5937 `40f5e8d` show script verification errors in signrawtransaction result
-- #5420 `1fd2d39` [REST] getutxos REST command (based on Bip64)
### Configuration and command-line options
-- #5636 `a353ad4` Add option `-allowselfsignedrootcertificate` to allow self signed root certs (for testing payment requests)
-- #5900 `3e8a1f2` Add a consistency check `-checkblockindex` for the block chain data structures
-- #5951 `7efc9cf` Make it possible to disable wallet transaction broadcast (using `-walletbroadcast=0`)
-- #5911 `b6ea3bc` privacy: Stream isolation for Tor (on by default, use `-proxyrandomize=0` to disable)
-- #5863 `c271304` Add autoprune functionality (`-prune=<size>`)
### Block and transaction handling
-- #5367 `dcc1304` Do all block index writes in a batch
-- #5253 `203632d` Check against MANDATORY flags prior to accepting to mempool
-- #5459 `4406c3e` Reject headers that build on an invalid parent
-- #5481 `055f3ae` Apply AreSane() checks to the fees from the network
-- #5580 `40d65eb` Preemptively catch a few potential bugs
-- #5349 `f55c5e9` Implement test for merkle tree malleability in CPartialMerkleTree
-- #5564 `a89b837` clarify obscure uses of EvalScript()
-- #5521 `8e4578a` Reject non-final txs even in testnet/regtest
-- #5707 `6af674e` Change hardcoded character constants to descriptive named constants for db keys
-- #5286 `fcf646c` Change the default maximum OP_RETURN size to 80 bytes
-- #5710 `175d86e` Add more information to errors in ReadBlockFromDisk
-- #5948 `b36f1ce` Use GetAncestor to compute new target
-- #5959 `a0bfc69` Add additional block index consistency checks
-- #6058 `7e0e7f8` autoprune minor post-merge improvements
-- #5159 `2cc1372` New fee estimation code
-- #6102 `6fb90d8` Implement accurate UTXO cache size accounting
-- #6129 `2a82298` Bug fix for clearing fCheckForPruning
-- #5947 `e9af4e6` Alert if it is very likely we are getting a bad chain
### P2P protocol and network code
-- #5507 `844ace9` Prevent DOS attacks on in-flight data structures
-- #5770 `32a8b6a` Sanitize command strings before logging them
-- #5859 `dd4ffce` Add correct bool combiner for net signals
-- #5876 `8e4fd0c` Add a NODE_GETUTXO service bit and document NODE_NETWORK.
-- #6028 `b9311fb` Move nLastTry from CAddress to CAddrInfo
-- #5662 `5048465` Change download logic to allow calling getdata on inbound peers
-- #5971 `18d2832` replace absolute sleep with conditional wait
-- #5918 `7bf5d5e` Use equivalent PoW for non-main-chain requests
-- #6059 `f026ab6` chainparams: use SeedSpec6's rather than CAddress's for fixed seeds
-- #6080 `31c0bf1` Add jonasschnellis dns seeder
-- #5976 `9f7809f` Reduce download timeouts as blocks arrive
### Validation
-- #5143 `48e1765` Implement BIP62 rule 6
-- #5713 `41e6e4c` Implement BIP66
### Build system
-- #5501 `c76c9d2` Add mips, mipsel and aarch64 to depends platforms
-- #5334 `cf87536` libbitcoinconsensus: Add pkg-config support
-- #5514 `ed11d53` Fix 'make distcheck'
-- #5505 `a99ef7d` Build winshutdownmonitor.cpp on Windows only
-- #5582 `e8a6639` Osx toolchain update
-- #5684 `ab64022` osx: bump build sdk to 10.9
-- #5695 `23ef5b7` depends: latest config.guess and config.sub
-- #5509 `31dedb4` Fixes when compiling in c++11 mode
-- #5819 `f8e68f7` release: use static libstdc++ and disable reduced exports by default
-- #5510 `7c3fbc3` Big endian support
-- #5149 `c7abfa5` Add script to verify all merge commits are signed
-- #6082 `7abbb7e` qt: disable qt tests when one of the checks for the gui fails
### Wallet
-- #2340 `811c71d` Discourage fee sniping with nLockTime
-- #5485 `d01bcc4` Enforce minRelayTxFee on wallet created tx and add a maxtxfee option.
-- #5508 `9a5cabf` Add RandAddSeedPerfmon to MakeNewKey
-- #4805 `8204e19` Do not flush the wallet in AddToWalletIfInvolvingMe(..)
-- #5319 `93b7544` Clean up wallet encryption code
-- #5831 `df5c246` Subtract fee from amount
-- #6076 `6c97fd1` wallet: fix boost::get usage with boost 1.58
-- #5511 `23c998d` Sort pending wallet transactions before reaccepting
-- #6126 `26e08a1` Change default nTxConfirmTarget to 2
### GUI
-- #5219 `f3af0c8` New icons
-- #5228 `bb3c75b` HiDPI (retina) support for splash screen
-- #5258 `73cbf0a` The RPC Console should be a QWidget to make window more independent
-- #5488 `851dfc7` Light blue icon color for regtest
-- #5547 `a39aa74` New icon for the debug window
-- #5493 `e515309` Adopt style colour for button icons
-- #5557 `70477a0` On close of splashscreen interrupt verifyDB
-- #5559 `83be8fd` Make the command-line-args dialog better
-- #5144 `c5380a9` Elaborate on signverify message dialog warning
-- #5489 `d1aa3c6` Optimize PNG files
-- #5649 `e0cd2f5` Use text-color icons for system tray Send/Receive menu entries
-- #5651 `848f55d` Coin Control: Use U+2248 "ALMOST EQUAL TO" rather than a simple tilde
-- #5626 `ab0d798` Fix icon sizes and column width
-- #5683 `c7b22aa` add new osx dmg background picture
-- #5620 `7823598` Payment request expiration bug fix
-- #5729 `9c4a5a5` Allow unit changes for read-only BitcoinAmountField
-- #5753 `0f44672` Add bitcoin logo to about screen
-- #5629 `a956586` Prevent amount overflow problem with payment requests
-- #5830 `215475a` Don't save geometry for options and about/help window
-- #5793 `d26f0b2` Honor current network when creating autostart link
-- #5847 `f238add` Startup script for centos, with documentation
-- #5915 `5bd3a92` Fix a static qt5 crash when using certain versions of libxcb
-- #5898 `bb56781` Fix rpc console font size to flexible metrics
-- #5467 `bc8535b` Payment request / server work - part 2
-- #6161 `180c164` Remove movable option for toolbar
-- #6160 `0d862c2` Overviewpage: make sure warning icons gets colored
### Tests
-- #5453 `2f2d337` Add ability to run single test manually to RPC tests
-- #5421 `886eb57` Test unexecuted OP_CODESEPARATOR
-- #5530 `565b300` Additional rpc tests
-- #5611 `37b185c` Fix spurious windows test failures after 012598880c
-- #5613 `2eda47b` Fix smartfees test for change to relay policy
-- #5612 `e3f5727` Fix zapwallettxes test
-- #5642 `30a5b5f` Prepare paymentservertests for new unit tests
-- #5784 `e3a3cd7` Fix usage of NegateSignatureS in script_tests
-- #5813 `ee9f2bf` Add unit tests for next difficulty calculations
-- #5855 `d7989c0` Travis: run unit tests in different orders
-- #5852 `cdae53e` Reinitialize state in between individual unit tests.
-- #5883 `164d7b6` tests: add a BasicTestingSetup and apply to all tests
-- #5940 `446bb70` Regression test for ResendWalletTransactions
-- #6052 `cf7adad` fix and enable bip32 unit test
-- #6039 `734f80a` tests: Error when setgenerate is used on regtest
-- #6074 `948beaf` Correct the PUSHDATA4 minimal encoding test in script_invalid.json
-- #6032 `e08886d` Stop nodes after RPC tests, even with --nocleanup
-- #6075 `df1609f` Add additional script edge condition tests
-- #5981 `da38dc6` Python P2P testing
-- #5958 `9ef00c3` Add multisig rpc tests
-- #6112 `fec5c0e` Add more script edge condition tests
### Miscellaneous
-- #5457, #5506, #5952, #6047 Update libsecp256k1
-- #5437 `84857e8` Add missing CAutoFile::IsNull() check in main
-- #5490 `ec20fd7` Replace uint256/uint160 with opaque blobs where possible
-- #5654, #5764 Adding jonasschnelli's GPG key
-- #5477 `5f04d1d` OS X 10.10: LSSharedFileListItemResolve() is deprecated
-- #5679 `beff11a` Get rid of DetectShutdownThread
-- #5787 `9bd8c9b` Add fanquake PGP key
-- #5366 `47a79bb` No longer check osx compatibility in RenameThread
-- #5689 `07f4386` openssl: abstract out OPENSSL_cleanse
-- #5708 `8b298ca` Add list of implemented BIPs
-- #5809 `46bfbe7` Add bitcoin-cli man page
-- #5839 `86eb461` keys: remove libsecp256k1 verification until it's actually supported
-- #5749 `d734d87` Help messages correctly formatted (79 chars)
-- #5884 `7077fe6` BUGFIX: Stack around the variable 'rv' was corrupted
-- #5849 `41259ca` contrib/init/bitcoind.openrc: Compatibility with previous OpenRC init script variables
-- #5950 `41113e3` Fix locale fallback and guard tests against invalid locale settings
-- #5965 `7c6bfb1` Add git-subtree-check.sh script
-- #6033 `1623f6e` FreeBSD, OpenBSD thread renaming
-- #6064 `b46e7c2` Several changes to mruset
-- #6104 `3e2559c` Show an init message while activating best chain
-- #6125 `351f73e` Clean up parsing of bool command line args
-- #5964 `b4c219b` Lightweight task scheduler
-- #6116 `30dc3c1` [OSX] rename Bitcoin-Qt.app to Bitcoin-Core.app
-- #6168 `b3024f0` contrib/linearize: Support linearization of testnet blocks
-- #6098 `7708fcd` Update Windows resource files (and add one for bitcoin-tx)
-- #6159 `e1412d3` Catch errors on datadir lock and pidfile delete
-
-[up to date until #5976]
+
diff --git a/qa/pull-tester/rpc-tests.sh b/qa/pull-tester/rpc-tests.sh
index 8ed942643b..88772a9c32 100755
--- a/qa/pull-tester/rpc-tests.sh
+++ b/qa/pull-tester/rpc-tests.sh
@@ -31,6 +31,7 @@ testScripts=(
'proxy_test.py'
'merkle_blocks.py'
'signrawtransactions.py'
+ 'walletbackup.py'
);
testScriptsExt=(
'bipdersig-p2p.py'
diff --git a/qa/rpc-tests/rest.py b/qa/rpc-tests/rest.py
index fdb2508f5e..6c51b2fcd9 100755
--- a/qa/rpc-tests/rest.py
+++ b/qa/rpc-tests/rest.py
@@ -55,78 +55,78 @@ class RESTTest (BitcoinTestFramework):
connect_nodes_bi(self.nodes,0,2)
self.is_network_split=False
self.sync_all()
-
+
def run_test(self):
url = urlparse.urlparse(self.nodes[0].url)
print "Mining blocks..."
-
+
self.nodes[0].generate(1)
self.sync_all()
self.nodes[2].generate(100)
self.sync_all()
-
+
assert_equal(self.nodes[0].getbalance(), 50)
-
+
txid = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.1)
self.sync_all()
self.nodes[2].generate(1)
self.sync_all()
bb_hash = self.nodes[0].getbestblockhash()
-
+
assert_equal(self.nodes[1].getbalance(), Decimal("0.1")) #balance now should be 0.1 on node 1
-
+
# load the latest 0.1 tx over the REST API
json_string = http_get_call(url.hostname, url.port, '/rest/tx/'+txid+self.FORMAT_SEPARATOR+"json")
json_obj = json.loads(json_string)
vintx = json_obj['vin'][0]['txid'] # get the vin to later check for utxo (should be spent by then)
- # get n of 0.1 outpoint
+ # get n of 0.1 outpoint
n = 0
for vout in json_obj['vout']:
if vout['value'] == 0.1:
n = vout['n']
-
-
+
+
######################################
# GETUTXOS: query a unspent outpoint #
######################################
- json_request = '{"checkmempool":true,"outpoints":[{"txid":"'+txid+'","n":'+str(n)+'}]}'
- json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'json', json_request)
+ json_request = '/checkmempool/'+txid+'-'+str(n)
+ json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json')
json_obj = json.loads(json_string)
-
+
#check chainTip response
assert_equal(json_obj['chaintipHash'], bb_hash)
-
+
#make sure there is one utxo
assert_equal(len(json_obj['utxos']), 1)
assert_equal(json_obj['utxos'][0]['value'], 0.1)
-
-
+
+
################################################
# GETUTXOS: now query a already spent outpoint #
################################################
- json_request = '{"checkmempool":true,"outpoints":[{"txid":"'+vintx+'","n":0}]}'
- json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'json', json_request)
+ json_request = '/checkmempool/'+vintx+'-0'
+ json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json')
json_obj = json.loads(json_string)
-
+
#check chainTip response
assert_equal(json_obj['chaintipHash'], bb_hash)
#make sure there is no utox in the response because this oupoint has been spent
assert_equal(len(json_obj['utxos']), 0)
-
+
#check bitmap
assert_equal(json_obj['bitmap'], "0")
-
-
+
+
##################################################
# GETUTXOS: now check both with the same request #
##################################################
- json_request = '{"checkmempool":true,"outpoints":[{"txid":"'+txid+'","n":'+str(n)+'},{"txid":"'+vintx+'","n":0}]}'
- json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'json', json_request)
+ json_request = '/checkmempool/'+txid+'-'+str(n)+'/'+vintx+'-0'
+ json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json')
json_obj = json.loads(json_string)
assert_equal(len(json_obj['utxos']), 1)
assert_equal(json_obj['bitmap'], "10")
-
+
#test binary response
bb_hash = self.nodes[0].getbestblockhash()
@@ -135,19 +135,18 @@ class RESTTest (BitcoinTestFramework):
binaryRequest += pack("i", n);
binaryRequest += binascii.unhexlify(vintx);
binaryRequest += pack("i", 0);
-
+
bin_response = http_get_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'bin', binaryRequest)
-
output = StringIO.StringIO()
output.write(bin_response)
output.seek(0)
chainHeight = unpack("i", output.read(4))[0]
hashFromBinResponse = hex(deser_uint256(output))[2:].zfill(65).rstrip("L")
-
+
assert_equal(bb_hash, hashFromBinResponse) #check if getutxo's chaintip during calculation was fine
assert_equal(chainHeight, 102) #chain height must be 102
-
-
+
+
############################
# GETUTXOS: mempool checks #
############################
@@ -157,55 +156,56 @@ class RESTTest (BitcoinTestFramework):
json_string = http_get_call(url.hostname, url.port, '/rest/tx/'+txid+self.FORMAT_SEPARATOR+"json")
json_obj = json.loads(json_string)
vintx = json_obj['vin'][0]['txid'] # get the vin to later check for utxo (should be spent by then)
- # get n of 0.1 outpoint
+ # get n of 0.1 outpoint
n = 0
for vout in json_obj['vout']:
if vout['value'] == 0.1:
n = vout['n']
-
- json_request = '{"checkmempool":false,"outpoints":[{"txid":"'+txid+'","n":'+str(n)+'}]}'
- json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'json', json_request)
+
+ json_request = '/'+txid+'-'+str(n)
+ json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json')
json_obj = json.loads(json_string)
assert_equal(len(json_obj['utxos']), 0) #there should be a outpoint because it has just added to the mempool
-
- json_request = '{"checkmempool":true,"outpoints":[{"txid":"'+txid+'","n":'+str(n)+'}]}'
- json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'json', json_request)
+
+ json_request = '/checkmempool/'+txid+'-'+str(n)
+ json_string = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json')
json_obj = json.loads(json_string)
assert_equal(len(json_obj['utxos']), 1) #there should be a outpoint because it has just added to the mempool
-
+
#do some invalid requests
json_request = '{"checkmempool'
response = http_get_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'json', json_request, True)
assert_equal(response.status, 500) #must be a 500 because we send a invalid json request
-
+
json_request = '{"checkmempool'
response = http_get_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'bin', json_request, True)
assert_equal(response.status, 500) #must be a 500 because we send a invalid bin request
-
+
+ response = http_get_call(url.hostname, url.port, '/rest/getutxos/checkmempool'+self.FORMAT_SEPARATOR+'bin', '', True)
+ assert_equal(response.status, 500) #must be a 500 because we send a invalid bin request
+
#test limits
- json_request = '{"checkmempool":true,"outpoints":['
- for x in range(0, 200):
- json_request += '{"txid":"'+txid+'","n":'+str(n)+'},'
- json_request = json_request.rstrip(",")
- json_request+="]}";
- response = http_get_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'json', json_request, True)
+ json_request = '/checkmempool/'
+ for x in range(0, 20):
+ json_request += txid+'-'+str(n)+'/'
+ json_request = json_request.rstrip("/")
+ response = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json', '', True)
assert_equal(response.status, 500) #must be a 500 because we exceeding the limits
-
- json_request = '{"checkmempool":true,"outpoints":['
- for x in range(0, 90):
- json_request += '{"txid":"'+txid+'","n":'+str(n)+'},'
- json_request = json_request.rstrip(",")
- json_request+="]}";
- response = http_get_call(url.hostname, url.port, '/rest/getutxos'+self.FORMAT_SEPARATOR+'json', json_request, True)
+
+ json_request = '/checkmempool/'
+ for x in range(0, 15):
+ json_request += txid+'-'+str(n)+'/'
+ json_request = json_request.rstrip("/");
+ response = http_get_call(url.hostname, url.port, '/rest/getutxos'+json_request+self.FORMAT_SEPARATOR+'json', '', True)
assert_equal(response.status, 200) #must be a 500 because we exceeding the limits
self.nodes[0].generate(1) #generate block to not affect upcomming tests
self.sync_all()
-
+
################
# /rest/block/ #
################
-
+
# check binary format
response = http_get_call(url.hostname, url.port, '/rest/block/'+bb_hash+self.FORMAT_SEPARATOR+"bin", "", True)
assert_equal(response.status, 200)
@@ -249,7 +249,7 @@ class RESTTest (BitcoinTestFramework):
hex_string = http_get_call(url.hostname, url.port, '/rest/tx/'+tx_hash+self.FORMAT_SEPARATOR+"hex", "", True)
assert_equal(hex_string.status, 200)
assert_greater_than(int(response.getheader('content-length')), 10)
-
+
# check block tx details
@@ -279,7 +279,7 @@ class RESTTest (BitcoinTestFramework):
#test rest bestblock
bb_hash = self.nodes[0].getbestblockhash()
-
+
json_string = http_get_call(url.hostname, url.port, '/rest/chaininfo.json')
json_obj = json.loads(json_string)
assert_equal(json_obj['bestblockhash'], bb_hash)
diff --git a/qa/rpc-tests/walletbackup.py b/qa/rpc-tests/walletbackup.py
index b9fc862234..da100d7fc0 100755
--- a/qa/rpc-tests/walletbackup.py
+++ b/qa/rpc-tests/walletbackup.py
@@ -33,8 +33,8 @@ Shutdown again, restore using importwallet,
and confirm again balances are correct.
"""
-from test_framework import BitcoinTestFramework
-from util import *
+from test_framework.test_framework import BitcoinTestFramework
+from test_framework.util import *
from random import randint
import logging
logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.INFO)
diff --git a/src/main.cpp b/src/main.cpp
index 651348300e..039092cd19 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -264,9 +264,9 @@ void UpdatePreferredDownload(CNode* node, CNodeState* state)
}
// Returns time at which to timeout block request (nTime in microseconds)
-int64_t GetBlockTimeout(int64_t nTime, int nValidatedQueuedBefore)
+int64_t GetBlockTimeout(int64_t nTime, int nValidatedQueuedBefore, const Consensus::Params &consensusParams)
{
- return nTime + 500000 * Params().GetConsensus().nPowTargetSpacing * (4 + nValidatedQueuedBefore);
+ return nTime + 500000 * consensusParams.nPowTargetSpacing * (4 + nValidatedQueuedBefore);
}
void InitializeNode(NodeId nodeid, const CNode *pnode) {
@@ -310,7 +310,7 @@ void MarkBlockAsReceived(const uint256& hash) {
}
// Requires cs_main.
-void MarkBlockAsInFlight(NodeId nodeid, const uint256& hash, CBlockIndex *pindex = NULL) {
+void MarkBlockAsInFlight(NodeId nodeid, const uint256& hash, const Consensus::Params& consensusParams, CBlockIndex *pindex = NULL) {
CNodeState *state = State(nodeid);
assert(state != NULL);
@@ -318,7 +318,7 @@ void MarkBlockAsInFlight(NodeId nodeid, const uint256& hash, CBlockIndex *pindex
MarkBlockAsReceived(hash);
int64_t nNow = GetTimeMicros();
- QueuedBlock newentry = {hash, pindex, nNow, pindex != NULL, GetBlockTimeout(nNow, nQueuedValidatedHeaders)};
+ QueuedBlock newentry = {hash, pindex, nNow, pindex != NULL, GetBlockTimeout(nNow, nQueuedValidatedHeaders, consensusParams)};
nQueuedValidatedHeaders += newentry.fValidatedHeaders;
list<QueuedBlock>::iterator it = state->vBlocksInFlight.insert(state->vBlocksInFlight.end(), newentry);
state->nBlocksInFlight++;
@@ -4183,7 +4183,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
vToFetch.push_back(inv);
// Mark block as in flight already, even though the actual "getdata" message only goes out
// later (within the same cs_main lock, though).
- MarkBlockAsInFlight(pfrom->GetId(), inv.hash);
+ MarkBlockAsInFlight(pfrom->GetId(), inv.hash, chainparams.GetConsensus());
}
LogPrint("net", "getheaders (%d) %s to peer=%d\n", pindexBestHeader->nHeight, inv.hash.ToString(), pfrom->id);
}
@@ -5036,7 +5036,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
// more quickly than once every 5 minutes, then we'll shorten the download window for this block).
if (!pto->fDisconnect && state.vBlocksInFlight.size() > 0) {
QueuedBlock &queuedBlock = state.vBlocksInFlight.front();
- int64_t nTimeoutIfRequestedNow = GetBlockTimeout(nNow, nQueuedValidatedHeaders - state.nBlocksInFlightValidHeaders);
+ int64_t nTimeoutIfRequestedNow = GetBlockTimeout(nNow, nQueuedValidatedHeaders - state.nBlocksInFlightValidHeaders, consensusParams);
if (queuedBlock.nTimeDisconnect > nTimeoutIfRequestedNow) {
LogPrint("net", "Reducing block download timeout for peer=%d block=%s, orig=%d new=%d\n", pto->id, queuedBlock.hash.ToString(), queuedBlock.nTimeDisconnect, nTimeoutIfRequestedNow);
queuedBlock.nTimeDisconnect = nTimeoutIfRequestedNow;
@@ -5057,7 +5057,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
FindNextBlocksToDownload(pto->GetId(), MAX_BLOCKS_IN_TRANSIT_PER_PEER - state.nBlocksInFlight, vToDownload, staller);
BOOST_FOREACH(CBlockIndex *pindex, vToDownload) {
vGetData.push_back(CInv(MSG_BLOCK, pindex->GetBlockHash()));
- MarkBlockAsInFlight(pto->GetId(), pindex->GetBlockHash(), pindex);
+ MarkBlockAsInFlight(pto->GetId(), pindex->GetBlockHash(), consensusParams, pindex);
LogPrint("net", "Requesting block %s (%d) peer=%d\n", pindex->GetBlockHash().ToString(),
pindex->nHeight, pto->id);
}
diff --git a/src/net.cpp b/src/net.cpp
index 6849d79263..3908be6824 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -1363,7 +1363,7 @@ bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOu
FindNode((CNetAddr)addrConnect) || CNode::IsBanned(addrConnect) ||
FindNode(addrConnect.ToStringIPPort()))
return false;
- } else if (FindNode(pszDest))
+ } else if (FindNode(std::string(pszDest)))
return false;
CNode* pnode = ConnectNode(addrConnect, pszDest);
@@ -1385,7 +1385,7 @@ void ThreadMessageHandler()
{
boost::mutex condition_mutex;
boost::unique_lock<boost::mutex> lock(condition_mutex);
-
+
SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL);
while (true)
{
diff --git a/src/netbase.cpp b/src/netbase.cpp
index 41cc18d3cd..e3cb4e706f 100644
--- a/src/netbase.cpp
+++ b/src/netbase.cpp
@@ -35,8 +35,6 @@
#define MSG_NOSIGNAL 0
#endif
-using namespace std;
-
// Settings
static proxyType proxyInfo[NET_MAX];
static proxyType nameProxy;
@@ -597,13 +595,13 @@ bool ConnectSocket(const CService &addrDest, SOCKET& hSocketRet, int nTimeout, b
bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest, int portDefault, int nTimeout, bool *outProxyConnectionFailed)
{
- string strDest;
+ std::string strDest;
int port = portDefault;
if (outProxyConnectionFailed)
*outProxyConnectionFailed = false;
- SplitHostPort(string(pszDest), port, strDest);
+ SplitHostPort(std::string(pszDest), port, strDest);
proxyType nameProxy;
GetNameProxy(nameProxy);
diff --git a/src/rest.cpp b/src/rest.cpp
index 1b7954bbf6..7c238d506d 100644
--- a/src/rest.cpp
+++ b/src/rest.cpp
@@ -19,7 +19,7 @@
using namespace std;
using namespace json_spirit;
-static const int MAX_GETUTXOS_OUTPOINTS = 100; //allow a max of 100 outpoints to be queried at once
+static const int MAX_GETUTXOS_OUTPOINTS = 15; //allow a max of 15 outpoints to be queried at once
enum RetFormat {
RF_UNDEF,
@@ -262,12 +262,12 @@ static bool rest_chaininfo(AcceptedConnection* conn,
{
vector<string> params;
const RetFormat rf = ParseDataFormat(params, strURIPart);
-
+
switch (rf) {
case RF_JSON: {
Array rpcParams;
Value chainInfoObject = getblockchaininfo(rpcParams, false);
-
+
string strJSON = write_string(chainInfoObject, false) + "\n";
conn->stream() << HTTPReply(HTTP_OK, strJSON, fRun) << std::flush;
return true;
@@ -276,7 +276,7 @@ static bool rest_chaininfo(AcceptedConnection* conn,
throw RESTERR(HTTP_NOT_FOUND, "output format not found (available: json)");
}
}
-
+
// not reached
return true; // continue to process further HTTP reqs on this cxn
}
@@ -342,18 +342,53 @@ static bool rest_getutxos(AcceptedConnection* conn,
vector<string> params;
enum RetFormat rf = ParseDataFormat(params, strURIPart);
+ vector<string> uriParts;
+ if (params.size() > 0 && params[0].length() > 1)
+ {
+ std::string strUriParams = params[0].substr(1);
+ boost::split(uriParts, strUriParams, boost::is_any_of("/"));
+ }
+
// throw exception in case of a empty request
- if (strRequest.length() == 0)
+ if (strRequest.length() == 0 && uriParts.size() == 0)
throw RESTERR(HTTP_INTERNAL_SERVER_ERROR, "Error: empty request");
+ bool fInputParsed = false;
bool fCheckMemPool = false;
vector<COutPoint> vOutPoints;
// parse/deserialize input
// input-format = output-format, rest/getutxos/bin requires binary input, gives binary output, ...
-
+
+ if (uriParts.size() > 0)
+ {
+
+ //inputs is sent over URI scheme (/rest/getutxos/checkmempool/txid1-n/txid2-n/...)
+ if (uriParts.size() > 0 && uriParts[0] == "checkmempool")
+ fCheckMemPool = true;
+
+ for (size_t i = (fCheckMemPool) ? 1 : 0; i < uriParts.size(); i++)
+ {
+ uint256 txid;
+ int32_t nOutput;
+ std::string strTxid = uriParts[i].substr(0, uriParts[i].find("-"));
+ std::string strOutput = uriParts[i].substr(uriParts[i].find("-")+1);
+
+ if (!ParseInt32(strOutput, &nOutput) || !IsHex(strTxid))
+ throw RESTERR(HTTP_INTERNAL_SERVER_ERROR, "Parse error");
+
+ txid.SetHex(strTxid);
+ vOutPoints.push_back(COutPoint(txid, (uint32_t)nOutput));
+ }
+
+ if (vOutPoints.size() > 0)
+ fInputParsed = true;
+ else
+ throw RESTERR(HTTP_INTERNAL_SERVER_ERROR, "Error: empty request");
+ }
+
string strRequestMutable = strRequest; //convert const string to string for allowing hex to bin converting
-
+
switch (rf) {
case RF_HEX: {
// convert hex to bin, continue then with bin part
@@ -363,11 +398,17 @@ static bool rest_getutxos(AcceptedConnection* conn,
case RF_BINARY: {
try {
- //deserialize
- CDataStream oss(SER_NETWORK, PROTOCOL_VERSION);
- oss << strRequestMutable;
- oss >> fCheckMemPool;
- oss >> vOutPoints;
+ //deserialize only if user sent a request
+ if (strRequestMutable.size() > 0)
+ {
+ if (fInputParsed) //don't allow sending input over URI and HTTP RAW DATA
+ throw RESTERR(HTTP_INTERNAL_SERVER_ERROR, "Combination of URI scheme inputs and raw post data is not allowed");
+
+ CDataStream oss(SER_NETWORK, PROTOCOL_VERSION);
+ oss << strRequestMutable;
+ oss >> fCheckMemPool;
+ oss >> vOutPoints;
+ }
} catch (const std::ios_base::failure& e) {
// abort in case of unreadable binary data
throw RESTERR(HTTP_INTERNAL_SERVER_ERROR, "Parse error");
@@ -376,33 +417,8 @@ static bool rest_getutxos(AcceptedConnection* conn,
}
case RF_JSON: {
- try {
- // parse json request
- Value valRequest;
- if (!read_string(strRequest, valRequest))
- throw RESTERR(HTTP_INTERNAL_SERVER_ERROR, "Parse error");
-
- Object jsonObject = valRequest.get_obj();
- const Value& checkMempoolValue = find_value(jsonObject, "checkmempool");
-
- if (!checkMempoolValue.is_null()) {
- fCheckMemPool = checkMempoolValue.get_bool();
- }
- const Value& outpointsValue = find_value(jsonObject, "outpoints");
- if (!outpointsValue.is_null()) {
- Array outPoints = outpointsValue.get_array();
- BOOST_FOREACH (const Value& outPoint, outPoints) {
- Object outpointObject = outPoint.get_obj();
- uint256 txid = ParseHashO(outpointObject, "txid");
- Value nValue = find_value(outpointObject, "n");
- int nOutput = nValue.get_int();
- vOutPoints.push_back(COutPoint(txid, nOutput));
- }
- }
- } catch (...) {
- // return HTTP 500 if there was a json parsing error
- throw RESTERR(HTTP_INTERNAL_SERVER_ERROR, "Parse error");
- }
+ if (!fInputParsed)
+ throw RESTERR(HTTP_INTERNAL_SERVER_ERROR, "Error: empty request");
break;
}
default: {