Just starting to learn bitcoin scripting. Can someone explain how to pay out based on some real-life event?
I currently test from the command line with bitcoind -regtest
Bitcoin can't directly check the outcome of real-life events. However, it is possible to make conditional transactions with the help of third parties. This can be achieved with multisignature addresses. A multisignature address is an address which is controlled by several different people. To spend the money from such address, signatures from specific number of those people is required. For example, to spend from a 2-of-3 multisignature address, at least two of the three owners must agree on a transaction.
How can this be used to make conditional payments? Well, there are three parties: the sender, the recipient and the party which determines the outcome of the event, which we will call the oracle. The oracle provides a public key which corresponds to the event which is the condition of the payment. If the event happens, the oracle would reveal the corresponding private key, so anyone would be able to use it to make signatures.
Now, suppose that the sender sends his money to a 2-of-3 multisignature address with the owners being himself, the recipient and the public key provided by the oracle. Until the oracle reveals his private key, the recipient can only spend the money with the assistance of the sender. Afterward, the recipient can use the key revealed by oracle to spend the money as he wishes.
This scheme, however, has a few problems. Firstly, if the event doesn't happen, the sender can only take his money back with the assistance of the recipient. Secondly, if the event does happen, the sender can take his money back if the recipient is not fast enough to move it first. The first problem can be solved by having the recipient sign a transaction returning money back to the sender before the sender broadcasts the first transaction. Here is an example of how this feature can be used. The second problem can be solved by using more complex script than 2-of-3. For example, it is possible to make a script which lets the money to be spent by sender+recipient and recipient+oracle, but not sender+oracle.
By the way, when doing research on this question, I found an actual website which offers to reveal private keys based on the outcome of real-life events.
OP_EQUALVERIFY
andOP_CHECKSIG
. – Nick ODell Sep 2 '14 at 20:09