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.
This commit is contained in:
Dave Collins 2014-02-20 01:46:56 -06:00
parent 61d270957e
commit 50173b865b

View file

@ -88,6 +88,10 @@ func (b *ScriptBuilder) PushData(data []byte) *ScriptBuilder {
// PushInt64 pushes the passed integer to the end of the script.
func (b *ScriptBuilder) PushInt64(val int64) *ScriptBuilder {
// Fast path for small integers and OP_1NEGATE.
if val == 0 {
b.script = append(b.script, OP_0)
return b
}
if val == -1 || (val >= 1 && val <= 16) {
b.script = append(b.script, byte((OP_1-1)+val))
return b