doc.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright (c) 2013-2017 The btcsuite developers
  2. // Use of this source code is governed by an ISC
  3. // license that can be found in the LICENSE file.
  4. /*
  5. Package txscript implements the bitcoin transaction script language.
  6. A complete description of the script language used by bitcoin can be found at
  7. https://en.bitcoin.it/wiki/Script. The following only serves as a quick
  8. overview to provide information on how to use the package.
  9. This package provides data structures and functions to parse and execute
  10. bitcoin transaction scripts.
  11. Script Overview
  12. Bitcoin transaction scripts are written in a stack-base, FORTH-like language.
  13. The bitcoin script language consists of a number of opcodes which fall into
  14. several categories such pushing and popping data to and from the stack,
  15. performing basic and bitwise arithmetic, conditional branching, comparing
  16. hashes, and checking cryptographic signatures. Scripts are processed from left
  17. to right and intentionally do not provide loops.
  18. The vast majority of Bitcoin scripts at the time of this writing are of several
  19. standard forms which consist of a spender providing a public key and a signature
  20. which proves the spender owns the associated private key. This information
  21. is used to prove the the spender is authorized to perform the transaction.
  22. One benefit of using a scripting language is added flexibility in specifying
  23. what conditions must be met in order to spend bitcoins.
  24. Errors
  25. Errors returned by this package are of type txscript.Error. This allows the
  26. caller to programmatically determine the specific error by examining the
  27. ErrorCode field of the type asserted txscript.Error while still providing rich
  28. error messages with contextual information. A convenience function named
  29. IsErrorCode is also provided to allow callers to easily check for a specific
  30. error code. See ErrorCode in the package documentation for a full list.
  31. */
  32. package txscript