24

Bitcoin protocol supports scripts.

  • How do they work?
  • How are those implemented?
  • What are their intended usages?
  • When are they planned to be used?
2
  • I asked this as one question, if you think it's more appropriate as separate questions let me know.
    – ripper234
    Sep 4, 2011 at 14:46
  • 1
    Related question providing script references: bitcoin.stackexchange.com/q/547/117
    – Gary
    Sep 5, 2011 at 14:12

1 Answer 1

35

Scripts are one of Bitcoin's more clever features. The most obvious way to implement a crypto-currency is to make a transfer be to a public key. To claim the transfer, you sign with the corresponding private key. This is not the way Bitcoin works.

When you send Bitcoins (the out of a transaction), you send them to a script. When you claim Bitcoins (the in) of a transaction) you claim them with a script. To determine if a transaction input correctly claims a transaction output, the two scripts are combined and the result is executed. If the result is true, then the input claims the output. The scripting language is stack-based and roughly similar to Forth.

The transaction input (the script trying to claim the Bitcoins) runs first. It will typically put a public key and a signature onto the stack. Then the output (the script whose Bitcoins are being claimed) runs. It will typically confirm that the public key is the correct one and that the signature signs the transaction with the corresponding private key.

Thus, you get the same effect as if you just specified a public key and signature, but you have the option of specifying more complex scripts. Unfortunately, this kind of simple script is pretty much the only kind of script supported right now. The original developer(s) imagined much more interesting scripts including things like contracts, multi-party signatures, and so on.

M of N signatures are planned. This way, you could list, say 3 public keys such that any 2 of them could claim the Bitcoins.

Unfortunately, some of the scripting components are feared to have security risks, so many of them are disabled currently.

1
  • Coolness. I never knew how integrated scripts were to the protocol.
    – ripper234
    Sep 4, 2011 at 17:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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