Commit graph

7 commits

Author SHA1 Message Date
Dale Rahn 003a41f66f Slightly cleaner fix. 2013-10-10 00:33:09 +01:00
Owain G. Ainsworth 53ca29efad fix multi-byte bug in previous.
Use the right offset when working out if we should mask off the sign bit.
Add more tests that would have caught this case.
2013-10-10 00:20:14 +01:00
Owain G. Ainsworth 4e608c115f Prevent asInt() from modifying stack data.
The stack data is normally sliced from the actual script and btcscript is not
supposed to ever change the tx passed into it.

Add a test (and fix the other leading zeros tests) to stop this happening again.
2013-10-09 23:59:23 +01:00
Josh Rickmar a5f81fc545 Add PayToPubKeyHashScript and SignatureScript functions.
PayToPubKeyHashScript generates a new pay to pubkey hash script to use
as the pkScript when creating new transactions.  If the passed pubkey
hash is an invalid size, StackErrInvalidOpcode will be returned as an
error.

SignatureScript returns the signature script necessary to validate a
single input of a transaction.

This also adds sanity checking for serializing scripts into byte
slices.  If the length of a serialized opcode does not equal the
expected length, StackErrInvalidOpcode will be returned when unparsing
a []parsedOpcode.

New internal tests were added to verify checks for valid and invalid
parsed opcodes.
2013-10-01 12:50:22 -04:00
Owain G. Ainsworth 0a3e7f682b Avoid the risk of leaking small amounts of memory.
Removing from the bottom of a stack (nipN(depth)) would leak the first
entry in the array by slicing [1:], leaving array[0] dangling an
inaccessible (but unable to be freed until the whole slice is gone). We
left it like this for a while, but best not to leak the memory. Happens
rarely so the performance hit shouldn't matter that much. Do the same
thing for condstack.
2013-09-26 01:53:11 +01:00
Owain G. Ainsworth 501b711301 int.Sign() in go will never return negative for zero.
So remove the -0 handling in fromInt, only toInt needs it.
2013-06-19 00:51:48 +01:00
Dave Collins 1197770159 Initial implementation. 2013-06-13 14:59:46 -05:00