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

  • 1
    Could you clarify what you mean by conditional? When I use a normal transaction script, it includes two conditional statements: OP_EQUALVERIFY and OP_CHECKSIG.
    – Nick ODell
    Sep 2 '14 at 20:09
  • In most simplest form, if a condition is met by checking an outside "oracle", then pay out, if not then do not pay and continue to check until condition is met. Sep 2 '14 at 20:23
  • 2
    There isn't one - that's intentional. If it allowed an outside oracle, that oracle might tell one part of the network that the transaction is valid, and tell another that the transaction is invalid.
    – Nick ODell
    Sep 2 '14 at 20:30
  • 3
    Have a trusted server monitor the real-life event, then make it send the payment when it happens.
    – Nick ODell
    Sep 3 '14 at 1:37
  • 1
    @NickODell That seems to be a good start for an answer. :)
    – Murch
    Sep 3 '14 at 7:44

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.