Correct log trace for failed script execution.

The function needs to be wrapped by a newLogClosure for the logger to be
able to log it.
Correct handling for multi-sig zero signatures.

It is possible for a multisignature transaction to require zero
signatures.  For example, input 2 of testnet transaction
b2d93dfd0b2c1a380e55e76a8d9cb3075dec9f4474e9485be008c337fd62c1f7
in block number 185117.

Previously the code was pushing a false to the stack when no
valid signatures were found.  This commit remedies that by pushing true
when no valid signatures were found, but none are required.  Otherwise it
still pushes false when no valid signatures were found, but some are
required.

Fixes #7.

ok @owainga
Allow multi-sig scripts with zero signatures.

This commit builds off the previous commit which fixed the execution of
multi-signature scripts with zero required signatures.

It introduces the concept of a "small int" which is one of OP_0 or OP_1 -
OP_16.  All areas of code that deal with multi-sig transactions now make
use of these to ensure consistent handling.

This fixes a few issues surrounding multi-sig zero required signature
transactions included proper detection as a multi-sig script, signature
counting for script statistics, and

ok @owainga
Add tests for multisig with zero required sigs.
Add new ScriptBuilder for building custom scripts.

This commit adds a new ScriptBuilder interface that can be used to build
custom scripts.  It currently is fairly basic, but it allows you to push
raw opcodes, ints, and data while respecting canonical encoding.  These
primitives are sufficient to build any script.

This could be improved upon with quite a few things. One example would be
functions for certain opcodes that take properly typed parameters to make
it harder to create invalid scripts.

For now though, it is already quite useful since it handles all of the
opcode selection for canonical data pushes and integer encoding.

The initial discussion took place in #5.
Add HasCanonicalPushes

Closes #6.

ok @davecgh
Allow push of 0 via new ScriptBuilder PushInt64.

Nothing was being pushed for 0 to the new ScriptBuilder due to the fact Go
big integers when set to 0 have no bytes.
Add 100% test coverage for new ScriptBuilder code.
Fix a few comment typos.
convert internal script generation to use ScriptBuilder.

Also, unexport the functions to generate script types. Everything should
(and is) be using PayToAddrScript() with an address type instead of
throwing bytes around.

discussed with #@davecgh
Convert builder.Push* to builder.Add* we think this is clearer.

Also, shorter!  Discussed with @davecgh.
Add support for pay to pubkey addresses to PayToAddrScript

Based on some initial code from @davecgh, finished by me.
Add MultiSigScript to provide a canonical script for a multisig transaction.
Go fmt.
Tighten the check for pay-to-pubkey scripts.

This commit tightens the check for a pay-to-pubkey script by ensuring the
length of the pubkey is one of the two valid values of 33 or 65.  This
mirrors the checks in the multisig script type check as well.

ok @owainga
Fix tests after IsForNet addition to btcutil.Address interface.

dhill pointed this out to me.
Encountering OP_VERIF and OP_VERNOTIF in execution is always an error.

I honestly thought we already handled this, but some tests dhill is
working on shows that we didn't.
Conditionals must not straddle two scripts.

Found by tests dhill is working on. We checked that ifs were closed at the end
of execution but not at script switching time, we now move this to just after
finishing a single script.
Disabled opcodes are `fail if pc passes' not fail if execute.

Detected by bitcoind negative tests.
Alt stack should be purged between scripts.

Found by bitcoind negative scripts.