Showing 407 changed files with 37,796 additions and 13,999 deletions.
18 changes: 9 additions & 9 deletions .gitignore
@@ -1,12 +1,12 @@
*.tar.gz

*.exe
src/bitcoin
src/bitcoind
src/bitcoin-cli
src/bitcoin-tx
src/test/test_bitcoin
src/qt/test/test_bitcoin-qt
src/alpha
src/alphad
src/alpha-cli
src/alpha-tx
src/test/test_alpha
src/qt/test/test_alpha-qt

# autoreconf
Makefile.in
Expand Down Expand Up @@ -74,12 +74,12 @@ src/qt/test/moc*.cpp
# Compilation and Qt preprocessor part
*.qm
Makefile
bitcoin-qt
Bitcoin-Qt.app
alpha-qt
Alpha-Qt.app

# Unit-tests
Makefile.test
bitcoin-qt_test
alpha-qt_test
src/test/buildenv.py

# Resources cpp
Expand Down
2 changes: 1 addition & 1 deletion COPYING
@@ -1,4 +1,4 @@
Copyright (c) 2009-2014 Bitcoin Developers
Copyright (c) 2009-2015 Bitcoin Developers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
140 changes: 39 additions & 101 deletions README.md
@@ -1,122 +1,60 @@
Bitcoin Core integration/staging tree
=====================================
The Elements Project
=================================
This is the integration and staging tree for the Elements Project, a series of
improvements and extensions to the Bitcoin protocol.

[![Build Status](https://travis-ci.org/bitcoin/bitcoin.svg?branch=master)](https://travis-ci.org/bitcoin/bitcoin)
What is the Elements Project?
-----------------
Elements is an open source collaborative project where we work on a collection
of experiments to more rapidly bring technical innovation to Bitcoin. Elements
are features that are proposed and developed in this technical community that in
arbitrary combinations can be fashioned into sidechains.

https://www.bitcoin.org
https://github.com/ElementsProject/elementsproject.github.io

Copyright (c) 2009-2014 Bitcoin Core Developers
Learn more on [the Elements Project website](https://www.elementsproject.org).

What is Bitcoin?
----------------
https://www.bitcoin.org

Bitcoin is an experimental new digital currency that 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. Bitcoin Core is the name of open source
out collectively by the network. Elements Alpha is the name of open source
software which enables the use of this currency.

For more information, as well as an immediately useable, binary version of
the Bitcoin Core software, see https://www.bitcoin.org/en/download.

License
-------

Bitcoin Core is released under the terms of the MIT license. See [COPYING](COPYING) for more
information or see http://opensource.org/licenses/MIT.

Development process
-------------------

Developers work in their own trees, then submit pull requests when they think
their feature or bug fix is ready.

If it is a simple/trivial/non-controversial change, then one of the Bitcoin
development team members simply pulls it.
What is Elements Alpha?
-----------------------
https://github.com/ElementsProject/elements/tree/alpha

If it is a *more complicated or potentially controversial* change, then the patch
submitter will be asked to start a discussion (if they haven't already) on the
[mailing list](http://sourceforge.net/mailarchive/forum.php?forum_name=bitcoin-development).
Elements Alpha is the Elements project's first experimental test chain.

The patch will be accepted if there is broad consensus that it is a good thing.
Developers should expect to rework and resubmit patches if the code doesn't
match the project's coding conventions (see [doc/coding.md](doc/coding.md)) or are
controversial.
Compared to Bitcoin itself, it adds the following features:
* [Confidential Transactions][confidential-transactions]
* [Segregated Witness][segregated-witness]
* [Relative Lock Time][relative-lock-time]
* [Schnorr Signatures][schnorr-signatures]
* [Additional opcodes][opcodes]
* [Deterministic Peg (pegged to Bitcoin's testnet currency).][deterministic-peg]
* [Signed Blocks][signed-blocks]

The `master` branch is regularly built and tested, but is not guaranteed to be
completely stable. [Tags](https://github.com/bitcoin/bitcoin/tags) are created
regularly to indicate new official, stable release versions of Bitcoin.
Getting Started
---------------
See alpha-README.md for build and use instructions.

Testing
License
-------
Elements Alpha is released under the terms of the MIT license. See [COPYING](COPYING) for more
information or see http://opensource.org/licenses/MIT.

Testing and code review is the bottleneck for development; we get more pull
requests than we can review and test on short notice. Please be patient and help out by testing
other people's pull requests, and remember this is a security-critical project where any mistake might cost people
lots of money.

### Automated Testing

Developers are strongly encouraged to write unit tests for new code, and to
submit new unit tests for old code. Unit tests can be compiled and run (assuming they weren't disabled in configure) with: `make check`

Every pull request is built for both Windows and Linux on a dedicated server,
and unit and sanity tests are automatically run. The binaries produced may be
used for manual QA testing — a link to them will appear in a comment on the
pull request posted by [BitcoinPullTester](https://github.com/BitcoinPullTester). See https://github.com/TheBlueMatt/test-scripts
for the build/test scripts.

### Manual Quality Assurance (QA) Testing

Large changes should have a test plan, and should be tested by somebody other
than the developer who wrote the code.
See https://github.com/bitcoin/QA/ for how to create a test plan.

Translations
------------

Changes to translations as well as new translations can be submitted to
[Bitcoin Core's Transifex page](https://www.transifex.com/projects/p/bitcoin/).

Translations are periodically pulled from Transifex and merged into the git repository. See the
[translation process](doc/translation_process.md) for details on how this works.

**Important**: We do not accept translation changes as GitHub pull requests because the next
pull from Transifex would automatically overwrite them again.

Translators should also subscribe to the [mailing list](https://groups.google.com/forum/#!forum/bitcoin-translators).

Development tips and tricks
---------------------------

**compiling for debugging**

Run configure with the --enable-debug option, then make. Or run configure with
CXXFLAGS="-g -ggdb -O0" or whatever debug flags you need.

**debug.log**

If the code is behaving strangely, take a look in the debug.log file in the data directory;
error and debugging messages are written there.

The -debug=... command-line option controls debugging; running with just -debug will turn
on all categories (and give you a very large debug.log file).

The Qt code routes qDebug() output to debug.log under category "qt": run with -debug=qt
to see it.

**testnet and regtest modes**

Run with the -testnet option to run with "play bitcoins" on the test network, if you
are testing multi-machine code that needs to operate across the internet.

If you are testing something that can run on one machine, run with the -regtest option.
In regression test mode, blocks can be created on-demand; see qa/rpc-tests/ for tests
that run in -regtest mode.

**DEBUG_LOCKORDER**

Bitcoin Core is a multithreaded application, and deadlocks or other multithreading bugs
can be very difficult to track down. Compiling with -DDEBUG_LOCKORDER (configure
CXXFLAGS="-DDEBUG_LOCKORDER -g") inserts run-time checks to keep track of which locks
are held, and adds warnings to the debug.log file if inconsistencies are detected.
[confidential-transactions]: https://www.elementsproject.org/elements/confidential-transactions
[segregated-witness]: https://www.elementsproject.org/elements/segregated-witness
[relative-lock-time]: https://www.elementsproject.org/elements/relative-lock-time
[schnorr-signatures]: https://www.elementsproject.org/elements/schnorr-signatures
[opcodes]: https://www.elementsproject.org/elements/opcodes
[deterministic-peg]: https://www.elementsproject.org/elements/deterministic-pegs
[signed-blocks]: https://www.elementsproject.org/elements/signed-blocks
99 changes: 99 additions & 0 deletions alpha-README.md
@@ -0,0 +1,99 @@
See https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md
for notes on dependencies that must be installed before beginning.

### To run alphad:

1\. Download/build bitcoind/alphad
```bash
git clone https://github.com/ElementsProject/elements
cd elements
git checkout mainchain
./autogen.sh && ./configure && make
mv src/bitcoin{d,-cli,-tx} ../
git checkout alpha
./autogen.sh && ./configure && make
mv src/alpha{d,-cli,-tx} ../
cd ..
```
2\. Run bitcoind/alphad
```bash
RPC_USER=user
RPC_PASS=pass
./bitcoind -rpcuser=$RPC_USER -rpcpassword=$RPC_PASS -testnet -txindex -daemon
./alphad -rpcuser=$RPC_USER -rpcpassword=$RPC_PASS -testnet -rpcconnect=127.0.0.1 -rpcconnectport=18332 -tracksidechain=all -txindex -blindtrust=true -daemon
```
Note that once bitcoind finishes syncing, you can set -blindtrust=false to check that transfers to Elements Alpha are from confirmed bitcoin blocks.

### To move money into Elements Alpha:

1\. See 1 and 2 in "To run alphad"
2\. Download secp256k1:
```bash
git clone https://github.com/bitcoin/secp256k1
cd secp256k1
./autogen.sh && ./configure --with-bignum=no && make
make DESTDIR=`pwd`/install install
cd ..
```
3\. Download contracthashtool
```bash
git clone https://github.com/blockstream/contracthashtool
cd contracthashtool
make CXXFLAGS="-I../secp256k1/install/usr/local/include -L../secp256k1/install/usr/local/lib -static"
cd ..
```
4\. Download python-bitcoinrpc
```bash
git clone https://github.com/jgarzik/python-bitcoinrpc
```
5\. Edit contrib/fedpeg/constants.py (replace `user:pass` with your RPC username and password):
```python
# VARIOUS SETTINGS...
sidechain_url = "http://user:pass@127.0.0.1:4241"
bitcoin_url = "http://user:pass@127.0.0.1:18332"
```
6\. Use sidechain-manipulation.py:
```bash
[matt@2ca87f82dd9a bitcoin]$ cd elements
[matt@2ca87f82dd9a bitcoin]$ ./contrib/sidechain-manipulation.py generate-one-of-one-multisig sidechain-wallet
One-of-one address: 22E8NxAdeYCatCFXFeLUbhfzBxUioGxP3dk9VH849exka9umWLkxzRmFFEwsLKR1pjPeE8UZRkVEQ7uab
P2SH address: 2NCs5ufweTL8VHKNT6wrZMTkrnnmpZCy99j
[matt@2ca87f82dd9a bitcoin]$ ./contrib/sidechain-manipulation.py send-to-sidechain 2NCs5ufweTL8VHKNT6wrZMTkrnnmpZCy99j 1
Sending 1 to 2N3zXjbwdTcPsJiy8sUK9FhWJhqQCxA8Jjr...
(nonce: 94ffbf32c1f1c0d3089b27c98fd991d5)
Sent tx with id bf01b88710b6023125379510ebd84b373bee88217c80739a1144e5e92b4ee2d0

--- 10 testnet blocks later ---

[matt@2ca87f82dd9a bitcoin]$ ./contrib/sidechain-manipulation.py claim-on-sidechain 2NCs5ufweTL8VHKNT6wrZMTkrnnmpZCy99j 94ffbf32c1f1c0d3089b27c98fd991d5 bf01b88710b6023125379510ebd84b373bee88217c80739a1144e5e92b4ee2d0
Redeeming from utxo 0377d218c36f5ee90244e660c387002296f3e4d5cac8fac8530b07e4d3241ccf:0 (value 21000000, refund 20999999)
Success!
Resulting txid: eabe26aba6286e1ee439baedeb75094ec0bcdaf54ed9481d9d2183e8a6424755

--- 144 sidechain blocks later ---
[matt@2ca87f82dd9a bitcoin]$ ./contrib/sidechain-manipulation.py spend-from-claim eabe26aba6286e1ee439baedeb75094ec0bcdaf54ed9481d9d2183e8a6424755 22E8NxAdeYCatCFXFeLUbhfzBxUioGxP3dk9VH849exka9umWLkxzRmFFEwsLKR1pjPeE8UZRkVEQ7uab
Submitting tx to mempool...
Success!
```

### To move money back out of Elements Alpha:

1\. See 1-5 of above.
2\. Use sidechain-manipulation.py:
```bash
[matt@2ca87f82dd9a bitcoin]$ cd elements
[matt@2ca87f82dd9a bitcoin]$ ./contrib/sidechain-manipulation.py generate-one-of-one-multisig mainchain-wallet
One-of-one address: mm8UW9YsjeHoVhXbHG4hEFKJt52P5iB7Vi
P2SH address: 2MzqiCCUwtKKEV9Kxiyvk8ZuNCFKbcbneva
[matt@2ca87f82dd9a bitcoin]$ ./contrib/sidechain-manipulation.py send-to-mainchain 2MzqiCCUwtKKEV9Kxiyvk8ZuNCFKbcbneva 1
```

### To run a fedpeg operator (for your own sidechain):
1. See 1 and 2 in "To run alphad" (Do not forget to append -blindtrust=false to the alphad command args once bitcoin syncs!)
2. See 2-5 of "To move money into Elements Alpha"
Note that the bitcoind/sidechaind wallets must be EMPTY of keys/transactions except for those created automatically by fedpeg scripts
3. Install python ZeroMQ.
4. Ensure your clock is reasonably accurate (within a second should suffice)
5. Edit bitcoin/contrib/fedpeg/constants.py with the neccessary information
6. As a daemon/in screen/etc, run both bitcoin/contrib/fedpeg/withdrawwatch.py and bitcoin/contrib/fedpeg/blocksign.py