mirror of
https://github.com/jwinterm/myriadcoin.git
synced 2026-10-25 05:58:42 +01:00
add new files, remove old
This commit is contained in:
@@ -0,0 +1 @@
|
||||
usr/local/bin/bitcoin-tx usr/bin
|
||||
@@ -0,0 +1,165 @@
|
||||
Bitcoin Core version 0.10.3 is now available from:
|
||||
|
||||
<https://bitcoin.org/bin/bitcoin-core-0.10.3/>
|
||||
|
||||
This is a new minor version release, bringing security fixes and translation
|
||||
updates. It is recommended to upgrade to this version as soon as possible.
|
||||
|
||||
Please report bugs using the issue tracker at github:
|
||||
|
||||
<https://github.com/bitcoin/bitcoin/issues>
|
||||
|
||||
Upgrading and downgrading
|
||||
=========================
|
||||
|
||||
How to Upgrade
|
||||
--------------
|
||||
|
||||
If you are running an older version, shut it down. Wait until it has completely
|
||||
shut down (which might take a few minutes for older versions), then run the
|
||||
installer (on Windows) or just copy over /Applications/Bitcoin-Qt (on Mac) or
|
||||
bitcoind/bitcoin-qt (on Linux).
|
||||
|
||||
Downgrade warning
|
||||
------------------
|
||||
|
||||
Because release 0.10.0 and later makes use of headers-first synchronization and
|
||||
parallel block download (see further), the block files and databases are not
|
||||
backwards-compatible with pre-0.10 versions of Bitcoin Core or other software:
|
||||
|
||||
* Blocks will be stored on disk out of order (in the order they are
|
||||
received, really), which makes it incompatible with some tools or
|
||||
other programs. Reindexing using earlier versions will also not work
|
||||
anymore as a result of this.
|
||||
|
||||
* The block index database will now hold headers for which no block is
|
||||
stored on disk, which earlier versions won't support.
|
||||
|
||||
If you want to be able to downgrade smoothly, make a backup of your entire data
|
||||
directory. Without this your node will need start syncing (or importing from
|
||||
bootstrap.dat) anew afterwards. It is possible that the data from a completely
|
||||
synchronised 0.10 node may be usable in older versions as-is, but this is not
|
||||
supported and may break as soon as the older version attempts to reindex.
|
||||
|
||||
This does not affect wallet forward or backward compatibility.
|
||||
|
||||
Notable changes
|
||||
===============
|
||||
|
||||
Fix buffer overflow in bundled upnp
|
||||
------------------------------------
|
||||
|
||||
Bundled miniupnpc was updated to 1.9.20151008. This fixes a buffer overflow in
|
||||
the XML parser during initial network discovery.
|
||||
|
||||
Details can be found here: http://talosintel.com/reports/TALOS-2015-0035/
|
||||
|
||||
This applies to the distributed executables only, not when building from source or
|
||||
using distribution provided packages.
|
||||
|
||||
Additionally, upnp has been disabled by default. This may result in a lower
|
||||
number of reachable nodes on IPv4, however this prevents future libupnpc
|
||||
vulnerabilities from being a structural risk to the network
|
||||
(see https://github.com/bitcoin/bitcoin/pull/6795).
|
||||
|
||||
Test for LowS signatures before relaying
|
||||
-----------------------------------------
|
||||
|
||||
Make the node require the canonical 'low-s' encoding for ECDSA signatures when
|
||||
relaying or mining. This removes a nuisance malleability vector.
|
||||
|
||||
Consensus behavior is unchanged.
|
||||
|
||||
If widely deployed this change would eliminate the last remaining known vector
|
||||
for nuisance malleability on SIGHASH_ALL P2PKH transactions. On the down-side
|
||||
it will block most transactions made by sufficiently out of date software.
|
||||
|
||||
Unlike the other avenues to change txids on transactions this
|
||||
one was randomly violated by all deployed bitcoin software prior to
|
||||
its discovery. So, while other malleability vectors where made
|
||||
non-standard as soon as they were discovered, this one has remained
|
||||
permitted. Even BIP62 did not propose applying this rule to
|
||||
old version transactions, but conforming implementations have become
|
||||
much more common since BIP62 was initially written.
|
||||
|
||||
Bitcoin Core has produced compatible signatures since a28fb70e in
|
||||
September 2013, but this didn't make it into a release until 0.9
|
||||
in March 2014; Bitcoinj has done so for a similar span of time.
|
||||
Bitcoinjs and electrum have been more recently updated.
|
||||
|
||||
This does not replace the need for BIP62 or similar, as miners can
|
||||
still cooperate to break transactions. Nor does it replace the
|
||||
need for wallet software to handle malleability sanely[1]. This
|
||||
only eliminates the cheap and irritating DOS attack.
|
||||
|
||||
[1] On the Malleability of Bitcoin Transactions
|
||||
Marcin Andrychowicz, Stefan Dziembowski, Daniel Malinowski, Łukasz Mazurek
|
||||
http://fc15.ifca.ai/preproceedings/bitcoin/paper_9.pdf
|
||||
|
||||
Minimum relay fee default increase
|
||||
-----------------------------------
|
||||
|
||||
The default for the `-minrelaytxfee` setting has been increased from `0.00001`
|
||||
to `0.00005`.
|
||||
|
||||
This is necessitated by the current transaction flooding, causing
|
||||
outrageous memory usage on nodes due to the mempool ballooning. This is a
|
||||
temporary measure, bridging the time until a dynamic method for determining
|
||||
this fee is merged (which will be in 0.12).
|
||||
|
||||
(see https://github.com/bitcoin/bitcoin/pull/6793, as well as the 0.11.0
|
||||
release notes, in which this value was suggested)
|
||||
|
||||
0.10.3 Change log
|
||||
=================
|
||||
|
||||
Detailed release notes follow. This overview includes changes that affect external
|
||||
behavior, not code moves, refactors or string updates.
|
||||
|
||||
- #6186 `e4a7d51` Fix two problems in CSubnet parsing
|
||||
- #6153 `ebd7d8d` Parameter interaction: disable upnp if -proxy set
|
||||
- #6203 `ecc96f5` Remove P2SH coinbase flag, no longer interesting
|
||||
- #6226 `181771b` json: fail read_string if string contains trailing garbage
|
||||
- #6244 `09334e0` configure: Detect (and reject) LibreSSL
|
||||
- #6276 `0fd8464` Fix getbalance * 0
|
||||
- #6274 `be64204` Add option `-alerts` to opt out of alert system
|
||||
- #6319 `3f55638` doc: update mailing list address
|
||||
- #6438 `7e66e9c` openssl: avoid config file load/race
|
||||
- #6439 `255eced` Updated URL location of netinstall for Debian
|
||||
- #6412 `0739e6e` Test whether created sockets are select()able
|
||||
- #6694 `f696ea1` [QT] fix thin space word wrap line brake issue
|
||||
- #6704 `743cc9e` Backport bugfixes to 0.10
|
||||
- #6769 `1cea6b0` Test LowS in standardness, removes nuisance malleability vector.
|
||||
- #6789 `093d7b5` Update miniupnpc to 1.9.20151008
|
||||
- #6795 `f2778e0` net: Disable upnp by default
|
||||
- #6797 `91ef4d9` Do not store more than 200 timedata samples
|
||||
- #6793 `842c48d` Bump minrelaytxfee default
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Thanks to everyone who directly contributed to this release:
|
||||
|
||||
- Adam Weiss
|
||||
- Alex Morcos
|
||||
- Casey Rodarmor
|
||||
- Cory Fields
|
||||
- fanquake
|
||||
- Gregory Maxwell
|
||||
- Jonas Schnelli
|
||||
- J Ross Nicoll
|
||||
- Luke Dashjr
|
||||
- Pavel Vasin
|
||||
- Pieter Wuille
|
||||
- randy-waterhouse
|
||||
- ฿tcDrak
|
||||
- Tom Harding
|
||||
- Veres Lajos
|
||||
- Wladimir J. van der Laan
|
||||
|
||||
And all those who contributed additional code review and/or security research:
|
||||
|
||||
- timothy on IRC for reporting the issue
|
||||
- Vulnerability in miniupnp discovered by Aleksandar Nikolic of Cisco Talos
|
||||
|
||||
As well as everyone that helped translating on [Transifex](https://www.transifex.com/projects/p/bitcoin/).
|
||||
@@ -0,0 +1,172 @@
|
||||
Bitcoin Core version 0.11.1 is now available from:
|
||||
|
||||
<https://bitcoin.org/bin/bitcoin-core-0.11.1/>
|
||||
|
||||
This is a new minor version release, bringing security fixes. It is recommended
|
||||
to upgrade to this version as soon as possible.
|
||||
|
||||
Please report bugs using the issue tracker at github:
|
||||
|
||||
<https://github.com/bitcoin/bitcoin/issues>
|
||||
|
||||
Upgrading and downgrading
|
||||
=========================
|
||||
|
||||
How to Upgrade
|
||||
--------------
|
||||
|
||||
If you are running an older version, shut it down. Wait until it has completely
|
||||
shut down (which might take a few minutes for older versions), then run the
|
||||
installer (on Windows) or just copy over /Applications/Bitcoin-Qt (on Mac) or
|
||||
bitcoind/bitcoin-qt (on Linux).
|
||||
|
||||
Downgrade warning
|
||||
------------------
|
||||
|
||||
Because release 0.10.0 and later makes use of headers-first synchronization and
|
||||
parallel block download (see further), the block files and databases are not
|
||||
backwards-compatible with pre-0.10 versions of Bitcoin Core or other software:
|
||||
|
||||
* Blocks will be stored on disk out of order (in the order they are
|
||||
received, really), which makes it incompatible with some tools or
|
||||
other programs. Reindexing using earlier versions will also not work
|
||||
anymore as a result of this.
|
||||
|
||||
* The block index database will now hold headers for which no block is
|
||||
stored on disk, which earlier versions won't support.
|
||||
|
||||
If you want to be able to downgrade smoothly, make a backup of your entire data
|
||||
directory. Without this your node will need start syncing (or importing from
|
||||
bootstrap.dat) anew afterwards. It is possible that the data from a completely
|
||||
synchronised 0.10 node may be usable in older versions as-is, but this is not
|
||||
supported and may break as soon as the older version attempts to reindex.
|
||||
|
||||
This does not affect wallet forward or backward compatibility. There are no
|
||||
known problems when downgrading from 0.11.x to 0.10.x.
|
||||
|
||||
Notable changes
|
||||
===============
|
||||
|
||||
Fix buffer overflow in bundled upnp
|
||||
------------------------------------
|
||||
|
||||
Bundled miniupnpc was updated to 1.9.20151008. This fixes a buffer overflow in
|
||||
the XML parser during initial network discovery.
|
||||
|
||||
Details can be found here: http://talosintel.com/reports/TALOS-2015-0035/
|
||||
|
||||
This applies to the distributed executables only, not when building from source or
|
||||
using distribution provided packages.
|
||||
|
||||
Additionally, upnp has been disabled by default. This may result in a lower
|
||||
number of reachable nodes on IPv4, however this prevents future libupnpc
|
||||
vulnerabilities from being a structural risk to the network
|
||||
(see https://github.com/bitcoin/bitcoin/pull/6795).
|
||||
|
||||
Test for LowS signatures before relaying
|
||||
-----------------------------------------
|
||||
|
||||
Make the node require the canonical 'low-s' encoding for ECDSA signatures when
|
||||
relaying or mining. This removes a nuisance malleability vector.
|
||||
|
||||
Consensus behavior is unchanged.
|
||||
|
||||
If widely deployed this change would eliminate the last remaining known vector
|
||||
for nuisance malleability on SIGHASH_ALL P2PKH transactions. On the down-side
|
||||
it will block most transactions made by sufficiently out of date software.
|
||||
|
||||
Unlike the other avenues to change txids on transactions this
|
||||
one was randomly violated by all deployed bitcoin software prior to
|
||||
its discovery. So, while other malleability vectors where made
|
||||
non-standard as soon as they were discovered, this one has remained
|
||||
permitted. Even BIP62 did not propose applying this rule to
|
||||
old version transactions, but conforming implementations have become
|
||||
much more common since BIP62 was initially written.
|
||||
|
||||
Bitcoin Core has produced compatible signatures since a28fb70e in
|
||||
September 2013, but this didn't make it into a release until 0.9
|
||||
in March 2014; Bitcoinj has done so for a similar span of time.
|
||||
Bitcoinjs and electrum have been more recently updated.
|
||||
|
||||
This does not replace the need for BIP62 or similar, as miners can
|
||||
still cooperate to break transactions. Nor does it replace the
|
||||
need for wallet software to handle malleability sanely[1]. This
|
||||
only eliminates the cheap and irritating DOS attack.
|
||||
|
||||
[1] On the Malleability of Bitcoin Transactions
|
||||
Marcin Andrychowicz, Stefan Dziembowski, Daniel Malinowski, Łukasz Mazurek
|
||||
http://fc15.ifca.ai/preproceedings/bitcoin/paper_9.pdf
|
||||
|
||||
Minimum relay fee default increase
|
||||
-----------------------------------
|
||||
|
||||
The default for the `-minrelaytxfee` setting has been increased from `0.00001`
|
||||
to `0.00005`.
|
||||
|
||||
This is necessitated by the current transaction flooding, causing
|
||||
outrageous memory usage on nodes due to the mempool ballooning. This is a
|
||||
temporary measure, bridging the time until a dynamic method for determining
|
||||
this fee is merged (which will be in 0.12).
|
||||
|
||||
(see https://github.com/bitcoin/bitcoin/pull/6793, as well as the 0.11
|
||||
release notes, in which this value was suggested)
|
||||
|
||||
0.11.1 Change log
|
||||
=================
|
||||
|
||||
Detailed release notes follow. This overview includes changes that affect
|
||||
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.
|
||||
|
||||
- #6438 `2531438` openssl: avoid config file load/race
|
||||
- #6439 `980f820` Updated URL location of netinstall for Debian
|
||||
- #6384 `8e5a969` qt: Force TLS1.0+ for SSL connections
|
||||
- #6471 `92401c2` Depends: bump to qt 5.5
|
||||
- #6224 `93b606a` Be even stricter in processing unrequested blocks
|
||||
- #6571 `100ac4e` libbitcoinconsensus: avoid a crash in multi-threaded environments
|
||||
- #6545 `649f5d9` Do not store more than 200 timedata samples.
|
||||
- #6694 `834e299` [QT] fix thin space word wrap line break issue
|
||||
- #6703 `1cd7952` Backport bugfixes to 0.11
|
||||
- #6750 `5ed8d0b` Recent rejects backport to v0.11
|
||||
- #6769 `71cc9d9` Test LowS in standardness, removes nuisance malleability vector.
|
||||
- #6789 `b4ad73f` Update miniupnpc to 1.9.20151008
|
||||
- #6785 `b4dc33e` Backport to v0.11: In (strCommand == "tx"), return if AlreadyHave()
|
||||
- #6412 `0095b9a` Test whether created sockets are select()able
|
||||
- #6795 `4dbcec0` net: Disable upnp by default
|
||||
- #6793 `e7bcc4a` Bump minrelaytxfee default
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Thanks to everyone who directly contributed to this release:
|
||||
|
||||
- Adam Weiss
|
||||
- Alex Morcos
|
||||
- Casey Rodarmor
|
||||
- Cory Fields
|
||||
- fanquake
|
||||
- Gregory Maxwell
|
||||
- Jonas Schnelli
|
||||
- J Ross Nicoll
|
||||
- Luke Dashjr
|
||||
- Pavel Janík
|
||||
- Pavel Vasin
|
||||
- Peter Todd
|
||||
- Pieter Wuille
|
||||
- randy-waterhouse
|
||||
- Ross Nicoll
|
||||
- Suhas Daftuar
|
||||
- tailsjoin
|
||||
- ฿tcDrak
|
||||
- Tom Harding
|
||||
- Veres Lajos
|
||||
- Wladimir J. van der Laan
|
||||
|
||||
And those who contributed additional code review and/or security research:
|
||||
|
||||
- timothy on IRC for reporting the issue
|
||||
- Vulnerability in miniupnp discovered by Aleksandar Nikolic of Cisco Talos
|
||||
|
||||
As well as everyone that helped translating on [Transifex](https://www.transifex.com/projects/p/bitcoin/).
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
#!/usr/bin/env python2
|
||||
#
|
||||
# Distributed under the MIT/X11 software license, see the accompanying
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
#
|
||||
|
||||
from test_framework.test_framework import ComparisonTestFramework
|
||||
from test_framework.util import *
|
||||
from test_framework.mininode import CTransaction, NetworkThread
|
||||
from test_framework.blocktools import create_coinbase, create_block
|
||||
from test_framework.comptool import TestInstance, TestManager
|
||||
from test_framework.script import CScript, OP_1NEGATE, OP_NOP2, OP_DROP
|
||||
from binascii import hexlify, unhexlify
|
||||
import cStringIO
|
||||
import time
|
||||
|
||||
def cltv_invalidate(tx):
|
||||
'''Modify the signature in vin 0 of the tx to fail CLTV
|
||||
|
||||
Prepends -1 CLTV DROP in the scriptSig itself.
|
||||
'''
|
||||
tx.vin[0].scriptSig = CScript([OP_1NEGATE, OP_NOP2, OP_DROP] +
|
||||
list(CScript(tx.vin[0].scriptSig)))
|
||||
|
||||
'''
|
||||
This test is meant to exercise BIP65 (CHECKLOCKTIMEVERIFY)
|
||||
Connect to a single node.
|
||||
Mine 2 (version 3) blocks (save the coinbases for later).
|
||||
Generate 98 more version 3 blocks, verify the node accepts.
|
||||
Mine 749 version 4 blocks, verify the node accepts.
|
||||
Check that the new CLTV rules are not enforced on the 750th version 4 block.
|
||||
Check that the new CLTV rules are enforced on the 751st version 4 block.
|
||||
Mine 199 new version blocks.
|
||||
Mine 1 old-version block.
|
||||
Mine 1 new version block.
|
||||
Mine 1 old version block, see that the node rejects.
|
||||
'''
|
||||
|
||||
class BIP65Test(ComparisonTestFramework):
|
||||
|
||||
def __init__(self):
|
||||
self.num_nodes = 1
|
||||
|
||||
def setup_network(self):
|
||||
# Must set the blockversion for this test
|
||||
self.nodes = start_nodes(1, self.options.tmpdir,
|
||||
extra_args=[['-debug', '-whitelist=127.0.0.1', '-blockversion=3']],
|
||||
binary=[self.options.testbinary])
|
||||
|
||||
def run_test(self):
|
||||
test = TestManager(self, self.options.tmpdir)
|
||||
test.add_all_connections(self.nodes)
|
||||
NetworkThread().start() # Start up network handling in another thread
|
||||
test.run()
|
||||
|
||||
def create_transaction(self, node, coinbase, to_address, amount):
|
||||
from_txid = node.getblock(coinbase)['tx'][0]
|
||||
inputs = [{ "txid" : from_txid, "vout" : 0}]
|
||||
outputs = { to_address : amount }
|
||||
rawtx = node.createrawtransaction(inputs, outputs)
|
||||
signresult = node.signrawtransaction(rawtx)
|
||||
tx = CTransaction()
|
||||
f = cStringIO.StringIO(unhexlify(signresult['hex']))
|
||||
tx.deserialize(f)
|
||||
return tx
|
||||
|
||||
def get_tests(self):
|
||||
|
||||
self.coinbase_blocks = self.nodes[0].generate(2)
|
||||
self.tip = int ("0x" + self.nodes[0].getbestblockhash() + "L", 0)
|
||||
self.nodeaddress = self.nodes[0].getnewaddress()
|
||||
self.last_block_time = time.time()
|
||||
|
||||
''' 98 more version 3 blocks '''
|
||||
test_blocks = []
|
||||
for i in xrange(98):
|
||||
block = create_block(self.tip, create_coinbase(2), self.last_block_time + 1)
|
||||
block.nVersion = 3
|
||||
block.rehash()
|
||||
block.solve()
|
||||
test_blocks.append([block, True])
|
||||
self.last_block_time += 1
|
||||
self.tip = block.sha256
|
||||
yield TestInstance(test_blocks, sync_every_block=False)
|
||||
|
||||
''' Mine 749 version 4 blocks '''
|
||||
test_blocks = []
|
||||
for i in xrange(749):
|
||||
block = create_block(self.tip, create_coinbase(2), self.last_block_time + 1)
|
||||
block.nVersion = 4
|
||||
block.rehash()
|
||||
block.solve()
|
||||
test_blocks.append([block, True])
|
||||
self.last_block_time += 1
|
||||
self.tip = block.sha256
|
||||
yield TestInstance(test_blocks, sync_every_block=False)
|
||||
|
||||
'''
|
||||
Check that the new CLTV rules are not enforced in the 750th
|
||||
version 3 block.
|
||||
'''
|
||||
spendtx = self.create_transaction(self.nodes[0],
|
||||
self.coinbase_blocks[0], self.nodeaddress, 1.0)
|
||||
cltv_invalidate(spendtx)
|
||||
spendtx.rehash()
|
||||
|
||||
block = create_block(self.tip, create_coinbase(2), self.last_block_time + 1)
|
||||
block.nVersion = 4
|
||||
block.vtx.append(spendtx)
|
||||
block.hashMerkleRoot = block.calc_merkle_root()
|
||||
block.rehash()
|
||||
block.solve()
|
||||
|
||||
self.last_block_time += 1
|
||||
self.tip = block.sha256
|
||||
yield TestInstance([[block, True]])
|
||||
|
||||
'''
|
||||
Check that the new CLTV rules are enforced in the 751st version 4
|
||||
block.
|
||||
'''
|
||||
spendtx = self.create_transaction(self.nodes[0],
|
||||
self.coinbase_blocks[1], self.nodeaddress, 1.0)
|
||||
cltv_invalidate(spendtx)
|
||||
spendtx.rehash()
|
||||
|
||||
block = create_block(self.tip, create_coinbase(1), self.last_block_time + 1)
|
||||
block.nVersion = 4
|
||||
block.vtx.append(spendtx)
|
||||
block.hashMerkleRoot = block.calc_merkle_root()
|
||||
block.rehash()
|
||||
block.solve()
|
||||
self.last_block_time += 1
|
||||
yield TestInstance([[block, False]])
|
||||
|
||||
''' Mine 199 new version blocks on last valid tip '''
|
||||
test_blocks = []
|
||||
for i in xrange(199):
|
||||
block = create_block(self.tip, create_coinbase(1), self.last_block_time + 1)
|
||||
block.nVersion = 4
|
||||
block.rehash()
|
||||
block.solve()
|
||||
test_blocks.append([block, True])
|
||||
self.last_block_time += 1
|
||||
self.tip = block.sha256
|
||||
yield TestInstance(test_blocks, sync_every_block=False)
|
||||
|
||||
''' Mine 1 old version block '''
|
||||
block = create_block(self.tip, create_coinbase(1), self.last_block_time + 1)
|
||||
block.nVersion = 3
|
||||
block.rehash()
|
||||
block.solve()
|
||||
self.last_block_time += 1
|
||||
self.tip = block.sha256
|
||||
yield TestInstance([[block, True]])
|
||||
|
||||
''' Mine 1 new version block '''
|
||||
block = create_block(self.tip, create_coinbase(1), self.last_block_time + 1)
|
||||
block.nVersion = 4
|
||||
block.rehash()
|
||||
block.solve()
|
||||
self.last_block_time += 1
|
||||
self.tip = block.sha256
|
||||
yield TestInstance([[block, True]])
|
||||
|
||||
''' Mine 1 old version block, should be invalid '''
|
||||
block = create_block(self.tip, create_coinbase(1), self.last_block_time + 1)
|
||||
block.nVersion = 3
|
||||
block.rehash()
|
||||
block.solve()
|
||||
self.last_block_time += 1
|
||||
yield TestInstance([[block, False]])
|
||||
|
||||
if __name__ == '__main__':
|
||||
BIP65Test().main()
|
||||
@@ -0,0 +1,89 @@
|
||||
#!/usr/bin/env python2
|
||||
# Copyright (c) 2015 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 the CHECKLOCKTIMEVERIFY (BIP65) soft-fork logic
|
||||
#
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import *
|
||||
import os
|
||||
import shutil
|
||||
|
||||
class BIP65Test(BitcoinTestFramework):
|
||||
|
||||
def setup_network(self):
|
||||
self.nodes = []
|
||||
self.nodes.append(start_node(0, self.options.tmpdir, []))
|
||||
self.nodes.append(start_node(1, self.options.tmpdir, ["-blockversion=3"]))
|
||||
self.nodes.append(start_node(2, self.options.tmpdir, ["-blockversion=4"]))
|
||||
connect_nodes(self.nodes[1], 0)
|
||||
connect_nodes(self.nodes[2], 0)
|
||||
self.is_network_split = False
|
||||
self.sync_all()
|
||||
|
||||
def run_test(self):
|
||||
cnt = self.nodes[0].getblockcount()
|
||||
|
||||
# Mine some old-version blocks
|
||||
self.nodes[1].generate(100)
|
||||
self.sync_all()
|
||||
if (self.nodes[0].getblockcount() != cnt + 100):
|
||||
raise AssertionError("Failed to mine 100 version=3 blocks")
|
||||
|
||||
# Mine 750 new-version blocks
|
||||
for i in xrange(15):
|
||||
self.nodes[2].generate(50)
|
||||
self.sync_all()
|
||||
if (self.nodes[0].getblockcount() != cnt + 850):
|
||||
raise AssertionError("Failed to mine 750 version=4 blocks")
|
||||
|
||||
# TODO: check that new CHECKLOCKTIMEVERIFY rules are not enforced
|
||||
|
||||
# Mine 1 new-version block
|
||||
self.nodes[2].generate(1)
|
||||
self.sync_all()
|
||||
if (self.nodes[0].getblockcount() != cnt + 851):
|
||||
raise AssertionFailure("Failed to mine a version=4 blocks")
|
||||
|
||||
# TODO: check that new CHECKLOCKTIMEVERIFY rules are enforced
|
||||
|
||||
# Mine 198 new-version blocks
|
||||
for i in xrange(2):
|
||||
self.nodes[2].generate(99)
|
||||
self.sync_all()
|
||||
if (self.nodes[0].getblockcount() != cnt + 1049):
|
||||
raise AssertionError("Failed to mine 198 version=4 blocks")
|
||||
|
||||
# Mine 1 old-version block
|
||||
self.nodes[1].generate(1)
|
||||
self.sync_all()
|
||||
if (self.nodes[0].getblockcount() != cnt + 1050):
|
||||
raise AssertionError("Failed to mine a version=3 block after 949 version=4 blocks")
|
||||
|
||||
# Mine 1 new-version blocks
|
||||
self.nodes[2].generate(1)
|
||||
self.sync_all()
|
||||
if (self.nodes[0].getblockcount() != cnt + 1051):
|
||||
raise AssertionError("Failed to mine a version=3 block")
|
||||
|
||||
# Mine 1 old-version blocks
|
||||
try:
|
||||
self.nodes[1].generate(1)
|
||||
raise AssertionError("Succeeded to mine a version=3 block after 950 version=4 blocks")
|
||||
except JSONRPCException:
|
||||
pass
|
||||
self.sync_all()
|
||||
if (self.nodes[0].getblockcount() != cnt + 1051):
|
||||
raise AssertionError("Accepted a version=3 block after 950 version=4 blocks")
|
||||
|
||||
# Mine 1 new-version blocks
|
||||
self.nodes[2].generate(1)
|
||||
self.sync_all()
|
||||
if (self.nodes[0].getblockcount() != cnt + 1052):
|
||||
raise AssertionError("Failed to mine a version=4 block")
|
||||
|
||||
if __name__ == '__main__':
|
||||
BIP65Test().main()
|
||||
@@ -1,147 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# 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 marking of spent outputs
|
||||
|
||||
# Create a transaction graph with four transactions,
|
||||
# A/B/C/D
|
||||
# C spends A
|
||||
# D spends B and C
|
||||
|
||||
# Then simulate C being mutated, to create C'
|
||||
# that is mined.
|
||||
# A is still (correctly) considered spent.
|
||||
# B should be treated as unspent
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Usage: $0 path_to_binaries"
|
||||
echo "e.g. $0 ../../src"
|
||||
echo "Env vars BITCOIND and BITCOINCLI may be used to specify the exact binaries used"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -f
|
||||
|
||||
BITCOIND=${BITCOIND:-${1}/bitcoind}
|
||||
CLI=${BITCOINCLI:-${1}/bitcoin-cli}
|
||||
|
||||
DIR="${BASH_SOURCE%/*}"
|
||||
SENDANDWAIT="${DIR}/send.sh"
|
||||
if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
|
||||
. "$DIR/util.sh"
|
||||
|
||||
D=$(mktemp -d test.XXXXX)
|
||||
|
||||
# Two nodes; one will play the part of merchant, the
|
||||
# other an evil transaction-mutating miner.
|
||||
|
||||
D1=${D}/node1
|
||||
CreateDataDir $D1 port=11000 rpcport=11001
|
||||
B1ARGS="-datadir=$D1 -debug=mempool"
|
||||
$BITCOIND $B1ARGS &
|
||||
B1PID=$!
|
||||
|
||||
D2=${D}/node2
|
||||
CreateDataDir $D2 port=11010 rpcport=11011
|
||||
B2ARGS="-datadir=$D2 -debug=mempool"
|
||||
$BITCOIND $B2ARGS &
|
||||
B2PID=$!
|
||||
|
||||
# Wait until both nodes are at the same block number
|
||||
function WaitBlocks {
|
||||
while :
|
||||
do
|
||||
sleep 1
|
||||
declare -i BLOCKS1=$( GetBlocks $B1ARGS )
|
||||
declare -i BLOCKS2=$( GetBlocks $B2ARGS )
|
||||
if (( BLOCKS1 == BLOCKS2 ))
|
||||
then
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Wait until node has $N peers
|
||||
function WaitPeers {
|
||||
while :
|
||||
do
|
||||
declare -i PEERS=$( $CLI $1 getconnectioncount )
|
||||
if (( PEERS == "$2" ))
|
||||
then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
echo "Generating test blockchain..."
|
||||
|
||||
# Start with B2 connected to B1:
|
||||
$CLI $B2ARGS addnode 127.0.0.1:11000 onetry
|
||||
WaitPeers "$B1ARGS" 1
|
||||
|
||||
# 2 block, 50 XBT each == 100 XBT
|
||||
# These will be transactions "A" and "B"
|
||||
$CLI $B1ARGS generate 2
|
||||
|
||||
WaitBlocks
|
||||
# 100 blocks, 0 mature == 0 XBT
|
||||
$CLI $B2ARGS generate 100
|
||||
WaitBlocks
|
||||
|
||||
CheckBalance "$B1ARGS" 100
|
||||
CheckBalance "$B2ARGS" 0
|
||||
|
||||
# restart B2 with no connection
|
||||
$CLI $B2ARGS stop > /dev/null 2>&1
|
||||
wait $B2PID
|
||||
$BITCOIND $B2ARGS &
|
||||
B2PID=$!
|
||||
|
||||
B1ADDRESS=$( $CLI $B1ARGS getnewaddress )
|
||||
B2ADDRESS=$( $CLI $B2ARGS getnewaddress )
|
||||
|
||||
# Transaction C: send-to-self, spend A
|
||||
TXID_C=$( $CLI $B1ARGS sendtoaddress $B1ADDRESS 50.0)
|
||||
|
||||
# Transaction D: spends B and C
|
||||
TXID_D=$( $CLI $B1ARGS sendtoaddress $B2ADDRESS 100.0)
|
||||
|
||||
CheckBalance "$B1ARGS" 0
|
||||
|
||||
# Mutate TXID_C and add it to B2's memory pool:
|
||||
RAWTX_C=$( $CLI $B1ARGS getrawtransaction $TXID_C )
|
||||
|
||||
# ... mutate C to create C'
|
||||
L=${RAWTX_C:82:2}
|
||||
NEWLEN=$( printf "%x" $(( 16#$L + 1 )) )
|
||||
MUTATEDTX_C=${RAWTX_C:0:82}${NEWLEN}4c${RAWTX_C:84}
|
||||
# ... give mutated tx1 to B2:
|
||||
MUTATEDTXID=$( $CLI $B2ARGS sendrawtransaction $MUTATEDTX_C )
|
||||
|
||||
echo "TXID_C: " $TXID_C
|
||||
echo "Mutated: " $MUTATEDTXID
|
||||
|
||||
# Re-connect nodes, and have both nodes mine some blocks:
|
||||
$CLI $B2ARGS addnode 127.0.0.1:11000 onetry
|
||||
WaitPeers "$B1ARGS" 1
|
||||
|
||||
# Having B2 mine the next block puts the mutated
|
||||
# transaction C in the chain:
|
||||
$CLI $B2ARGS generate 1
|
||||
WaitBlocks
|
||||
|
||||
# B1 should still be able to spend 100, because D is conflicted
|
||||
# so does not count as a spend of B
|
||||
CheckBalance "$B1ARGS" 100
|
||||
|
||||
$CLI $B2ARGS stop > /dev/null 2>&1
|
||||
wait $B2PID
|
||||
$CLI $B1ARGS stop > /dev/null 2>&1
|
||||
wait $B1PID
|
||||
|
||||
echo "Tests successful, cleaning up"
|
||||
rm -rf $D
|
||||
exit 0
|
||||
@@ -1,31 +0,0 @@
|
||||
#!/bin/bash
|
||||
# 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.
|
||||
TIMEOUT=10
|
||||
SIGNAL=HUP
|
||||
PIDFILE=.send.pid
|
||||
if [ $# -eq 0 ]; then
|
||||
echo -e "Usage:\t$0 <cmd>"
|
||||
echo -e "\tRuns <cmd> and wait ${TIMEOUT} seconds or until SIG${SIGNAL} is received."
|
||||
echo -e "\tReturns: 0 if SIG${SIGNAL} is received, 1 otherwise."
|
||||
echo -e "Or:\t$0 -STOP"
|
||||
echo -e "\tsends SIG${SIGNAL} to running send.sh"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ $1 = "-STOP" ]; then
|
||||
if [ -s ${PIDFILE} ]; then
|
||||
kill -s ${SIGNAL} $(<$PIDFILE 2>/dev/null) 2>/dev/null
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
trap '[[ ${PID} ]] && kill ${PID}' ${SIGNAL}
|
||||
trap 'rm -f ${PIDFILE}' EXIT
|
||||
echo $$ > ${PIDFILE}
|
||||
"$@"
|
||||
sleep ${TIMEOUT} & PID=$!
|
||||
wait ${PID} && exit 1
|
||||
|
||||
exit 0
|
||||
@@ -1,103 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# 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.
|
||||
|
||||
# Functions used by more than one test
|
||||
|
||||
function echoerr {
|
||||
echo "$@" 1>&2;
|
||||
}
|
||||
|
||||
# Usage: ExtractKey <key> "<json_object_string>"
|
||||
# Warning: this will only work for the very-well-behaved
|
||||
# JSON produced by bitcoind, do NOT use it to try to
|
||||
# parse arbitrary/nested/etc JSON.
|
||||
function ExtractKey {
|
||||
echo $2 | tr -d ' "{}\n' | awk -v RS=',' -F: "\$1 ~ /$1/ { print \$2}"
|
||||
}
|
||||
|
||||
function CreateDataDir {
|
||||
DIR=$1
|
||||
mkdir -p $DIR
|
||||
CONF=$DIR/bitcoin.conf
|
||||
echo "regtest=1" >> $CONF
|
||||
echo "keypool=2" >> $CONF
|
||||
echo "rpcuser=rt" >> $CONF
|
||||
echo "rpcpassword=rt" >> $CONF
|
||||
echo "rpcwait=1" >> $CONF
|
||||
echo "walletnotify=${SENDANDWAIT} -STOP" >> $CONF
|
||||
shift
|
||||
while (( "$#" )); do
|
||||
echo $1 >> $CONF
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
function AssertEqual {
|
||||
if (( $( echo "$1 == $2" | bc ) == 0 ))
|
||||
then
|
||||
echoerr "AssertEqual: $1 != $2"
|
||||
declare -f CleanUp > /dev/null 2>&1
|
||||
if [[ $? -eq 0 ]] ; then
|
||||
CleanUp
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# CheckBalance -datadir=... amount account minconf
|
||||
function CheckBalance {
|
||||
declare -i EXPECT="$2"
|
||||
B=$( $CLI $1 getbalance $3 $4 )
|
||||
if (( $( echo "$B == $EXPECT" | bc ) == 0 ))
|
||||
then
|
||||
echoerr "bad balance: $B (expected $2)"
|
||||
declare -f CleanUp > /dev/null 2>&1
|
||||
if [[ $? -eq 0 ]] ; then
|
||||
CleanUp
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Use: Address <datadir> [account]
|
||||
function Address {
|
||||
$CLI $1 getnewaddress $2
|
||||
}
|
||||
|
||||
# Send from to amount
|
||||
function Send {
|
||||
from=$1
|
||||
to=$2
|
||||
amount=$3
|
||||
address=$(Address $to)
|
||||
txid=$( ${SENDANDWAIT} $CLI $from sendtoaddress $address $amount )
|
||||
}
|
||||
|
||||
# Use: Unspent <datadir> <n'th-last-unspent> <var>
|
||||
function Unspent {
|
||||
local r=$( $CLI $1 listunspent | awk -F'[ |:,"]+' "\$2 ~ /$3/ { print \$3 }" | tail -n $2 | head -n 1)
|
||||
echo $r
|
||||
}
|
||||
|
||||
# Use: CreateTxn1 <datadir> <n'th-last-unspent> <destaddress>
|
||||
# produces hex from signrawtransaction
|
||||
function CreateTxn1 {
|
||||
TXID=$(Unspent $1 $2 txid)
|
||||
AMOUNT=$(Unspent $1 $2 amount)
|
||||
VOUT=$(Unspent $1 $2 vout)
|
||||
RAWTXN=$( $CLI $1 createrawtransaction "[{\"txid\":\"$TXID\",\"vout\":$VOUT}]" "{\"$3\":$AMOUNT}")
|
||||
ExtractKey hex "$( $CLI $1 signrawtransaction $RAWTXN )"
|
||||
}
|
||||
|
||||
# Use: SendRawTxn <datadir> <hex_txn_data>
|
||||
function SendRawTxn {
|
||||
${SENDANDWAIT} $CLI $1 sendrawtransaction $2
|
||||
}
|
||||
|
||||
# Use: GetBlocks <datadir>
|
||||
# returns number of blocks from getinfo
|
||||
function GetBlocks {
|
||||
$CLI $1 getblockcount
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// Copyright (c) 2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifndef BITCOIN_REVERSELOCK_H
|
||||
#define BITCOIN_REVERSELOCK_H
|
||||
|
||||
/**
|
||||
* An RAII-style reverse lock. Unlocks on construction and locks on destruction.
|
||||
*/
|
||||
template<typename Lock>
|
||||
class reverse_lock
|
||||
{
|
||||
public:
|
||||
|
||||
explicit reverse_lock(Lock& lock) : lock(lock) {
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
~reverse_lock() {
|
||||
lock.lock();
|
||||
}
|
||||
|
||||
private:
|
||||
reverse_lock(reverse_lock const&);
|
||||
reverse_lock& operator=(reverse_lock const&);
|
||||
|
||||
Lock& lock;
|
||||
};
|
||||
|
||||
#endif // BITCOIN_REVERSELOCK_H
|
||||
@@ -0,0 +1,64 @@
|
||||
// Copyright (c) 2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "reverselock.h"
|
||||
#include "test/test_bitcoin.h"
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(reverselock_tests, BasicTestingSetup)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(reverselock_basics)
|
||||
{
|
||||
boost::mutex mutex;
|
||||
boost::unique_lock<boost::mutex> lock(mutex);
|
||||
|
||||
BOOST_CHECK(lock.owns_lock());
|
||||
{
|
||||
reverse_lock<boost::unique_lock<boost::mutex> > rlock(lock);
|
||||
BOOST_CHECK(!lock.owns_lock());
|
||||
}
|
||||
BOOST_CHECK(lock.owns_lock());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(reverselock_errors)
|
||||
{
|
||||
boost::mutex mutex;
|
||||
boost::unique_lock<boost::mutex> lock(mutex);
|
||||
|
||||
// Make sure trying to reverse lock an unlocked lock fails
|
||||
lock.unlock();
|
||||
|
||||
BOOST_CHECK(!lock.owns_lock());
|
||||
|
||||
bool failed = false;
|
||||
try {
|
||||
reverse_lock<boost::unique_lock<boost::mutex> > rlock(lock);
|
||||
} catch(...) {
|
||||
failed = true;
|
||||
}
|
||||
|
||||
BOOST_CHECK(failed);
|
||||
BOOST_CHECK(!lock.owns_lock());
|
||||
|
||||
// Make sure trying to lock a lock after it has been reverse locked fails
|
||||
failed = false;
|
||||
bool locked = false;
|
||||
|
||||
lock.lock();
|
||||
BOOST_CHECK(lock.owns_lock());
|
||||
|
||||
try {
|
||||
reverse_lock<boost::unique_lock<boost::mutex> > rlock(lock);
|
||||
lock.lock();
|
||||
locked = true;
|
||||
} catch(...) {
|
||||
failed = true;
|
||||
}
|
||||
|
||||
BOOST_CHECK(locked && failed);
|
||||
BOOST_CHECK(lock.owns_lock());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
Reference in New Issue
Block a user