bitcoin/bitcoin — pull request #669 by gavinandresen (2011-11-28 22:10:12+00:00)
Title: Multisignature and OP_EVAL support

This implements BIPS 11, 12, and 13 :

* OP_CHECKMULTISIG transactions supported, for up to 3 public keys, as 'standard' transactions
* OP_EVAL (same opcode as OP_NOP1) as a new opcode
* New OP_EVAL-based 'standard' transaction type and Bitcoin address
* Blocks mined with this patch will have the string "OP_EVAL" in the coinbase scriptSig, so we can tell when a majority of miners support it.
* New RPC command to add a multisignature-required address to the wallet: addmultisigaddress <'["key","key"]'> [account] (enabled only for use on the -testnet for now)
* The 'validateaddress' RPC command shows the full public key of addresses in your wallet
* Internal changes so if you own all the public keys of a multisignature transaction, then you are able to spend the transaction (and the amount shows up in your balance, and the transaction is listed in listtransactions output)

There is still a lot of work to be done to get multi-device transaction authorization or multi-party escrow; in particular, this pull doesn't include any support for gathering transaction signatures from multiple places or showing the user transactions that they are involved in but can't spend without getting more signatures from other devices/people. It just implements the lowest-level support, along with the bare minimum needed to test to make sure the lowest-level stuff is working properly.

To test / play with:

1. Run bitcoind -daemon -testnet
2. Get public keys from 2 or 3 new bitcoin addresses-- e.g. run this twice: ./bitcoind -testnet validateaddress $(./bitcoind getnewaddress)
3. Generate a new multisignature address using the public keys from validateaddress-- ./bitcoind addmultisigaddress 2 '["...public_key_1...","...public_key_2..."]
4. Send funds to that address -- ./bitcoind sendtoaddress ...result of addmultisigaddress... 11.11

Step (4) can be done from another ./bitcoind, either on another machine or same machine, different -datadir, as long as it is running this patch. The coins should show up in the wallet, be listed in listransactions, and you should be able to spend them as if they were single-signature transactions.