Commit graph

88 commits

Author SHA1 Message Date
Dave Collins
eb02adfada Update btcec import paths to new location. 2015-01-16 18:05:06 -06:00
Dave Collins
f513a56a62 Update btcnet import paths to new location. 2015-01-16 17:29:53 -06:00
Dave Collins
5c52f67b4f Update btcwire import paths to new location. 2015-01-16 15:18:22 -06:00
Dave Collins
c4f1ed69d2 Update btcutil import paths to new location. 2015-01-15 10:42:26 -06:00
Guilherme Salgado
2f902a5880 Rename signTxOutput to RawTxInSignature 2014-12-20 01:51:54 -06:00
Jonathan Gillham
a61c0f06cf Removed unnecessary signTxOutputCustomReader. 2014-10-13 13:47:44 +01:00
Jimmy Song
d5cc72dc27 use btcec structs instead of ecdsa structs 2014-10-12 23:47:09 -05:00
Dave Collins
ce0a334329 Comment ScriptInfo struct according to standards.
Found by golint.
2014-10-12 19:39:01 -05:00
Dave Collins
c0c3d860d6 Convert all StackErrX to ErrStackX.
This commit changes all stack errors from the form of StackErrX to
ErrStackX which is the expected form for standard Go code.
2014-10-12 17:24:00 -05:00
Jonathan Gillham
37ad7042b6 Made hashType typed as SigHashType. 2014-10-11 20:55:28 +01:00
Jonathan Gillham
9f47e9369c Fixed SignTxOutput doc spelling error. 2014-10-10 20:17:20 -05:00
kac-
b89cabfb29 comment:script.go: ScriptDB->KeyDB 2014-10-05 10:19:29 +02:00
David Hill
2803ea17c2 Remove the use of go-spew. 2014-08-29 16:06:17 -04:00
Jonathan Gillham
516db23576 Replaced privkey in entire codebase. 2014-08-25 21:14:19 +01:00
Jonathan Gillham
da080e1598 Changed privkey to privKey for consistency. 2014-08-25 21:09:23 +01:00
Dave Collins
5beafbd2d8 goimports -w . 2014-07-02 19:37:49 -05:00
David Hill
a591c7ec03 Add new ScriptFlag ScriptStrictMultiSig.
ScriptStrictMultiSig verifies that the stack item used by CHECKMULTISIG
is zero length.
2014-05-29 10:55:35 -04:00
Josh Rickmar
be325b9d9c Update API for btcnet and btcutil changes.
ok @davecgh
2014-05-27 17:42:01 -05:00
David Hill
27e1ad758b Add new function PushedData.
PushedData returns an array of byte slices containing any pushed data
found in the passed script.  This includes OP_0, but not OP_1 - OP_16.

help from and ok @owainga
2014-05-20 12:24:23 -04:00
Owain G. Ainsworth
6e2ba386dd Add an entypoint to sign and verify a transaction input.
This handles merging in of previous scripts, also. Add tests for the important
paths. ok @davecgh
2014-05-07 16:05:55 +01:00
David Hill
76e8fa9766 Reduce OP_RETURN standard relay bytes to 40.
This matches commit 8175c790eb12f0b0ca3197895a6d1d479b340b67 of
the reference software.
2014-05-01 09:42:15 -04:00
Owain G. Ainsworth
1b1fef7369 Make removeOpcodeByData only search canonical pushes.
Matches bitcoind behaviour. Pointed out by one of their tx_invalid tests.
2014-03-18 18:28:09 +00:00
Owain G. Ainsworth
76339baf6c Make removeOpcodeByData in line with bitcoind behaviour.
It should remove the opcode and data is the data is contained within the data
pushed, not just if it is equal to it. Found by bitcoind tx tests.
2014-03-18 00:49:24 +00:00
Dave Collins
c8332cc9a7 Correct num expected inputs calc for multisig.
This commit corrects the number of expected inputs for a multi-sig script
to include the additional item that is popped from the stack due to the
OP_CHECKMULTISIG consensus bug (which is required and properly performed).

Note this issue did NOT affect the consensus critical code and hence would
not cause a chain fork.  It did however, cause standard p2sh multisig txns
to be rejected from the mempool as nonstandard.

The tx rejected as non-standard which prompted this was spotted by
@mbelshe on IRC.

ok @owainga
2014-03-17 10:47:02 -05:00
Owain G. Ainsworth
9375c8dc48 move data extraction fof OP_PUSHDATA into main function.
This allows us to centralise the error checking to simplify things a bit.
2014-03-14 22:46:41 +00:00
Owain G. Ainsworth
299dcc2fad PushDataN with a 0 length is valid, we were too tight here.
Found by bitcoind positive tests. (but of course that is noncanonical
anyway, it should be OP_0 ;).
2014-03-14 22:46:14 +00:00
Owain G. Ainsworth
42f6576b02 Enforce max script length of 10000.
Detected by bitcoind negative script tests. Note that this length is only for
*executing* scripts, this is why it is in NewScript.
2014-03-14 22:45:14 +00:00
Owain G. Ainsworth
dec16d7ff2 Enforce a combined max stack depth of 1000 after every opcode.
This limit is for the sum of main and alt stacks. Found by bitcoind
negative tests.
2014-03-14 21:06:08 +00:00
Owain G. Ainsworth
d6d755e411 Always return reserved opcode for always-illegal ops. 2014-03-14 21:06:08 +00:00
Owain G. Ainsworth
8beb0dec54 Make opcode.Exec run a bunch of unconditional checks
Add push length and number of operations to this to match bitcoind behaviour.
found that we differed here by their negative tests.
2014-03-14 21:06:05 +00:00
Owain G. Ainsworth
c7d5102954 Alt stack should be purged between scripts.
Found by bitcoind negative scripts.
2014-03-14 21:05:25 +00:00
Owain G. Ainsworth
a5e7e9ebb6 Disabled opcodes are `fail if pc passes' not fail if execute.
Detected by bitcoind negative tests.
2014-03-14 21:04:59 +00:00
Owain G. Ainsworth
c1a6e47f38 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.
2014-03-14 21:04:37 +00:00
Owain G. Ainsworth
8df0af32d6 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.
2014-03-14 20:28:23 +00:00
Dave Collins
da1fcc6dbd 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
2014-02-21 12:18:43 -06:00
Dave Collins
982f282e10 Go fmt. 2014-02-21 02:10:38 -06:00
Owain G. Ainsworth
88f3c73ad1 Add MultiSigScript to provide a canonical script for a multisig transaction. 2014-02-21 00:20:24 +00:00
Owain G. Ainsworth
2b0b512a83 Add support for pay to pubkey addresses to PayToAddrScript
Based on some initial code from @davecgh, finished by me.
2014-02-20 19:26:34 +00:00
Owain G. Ainsworth
5171cb803c Convert builder.Push* to builder.Add* we think this is clearer.
Also, shorter!  Discussed with @davecgh.
2014-02-20 18:42:58 +00:00
Owain G. Ainsworth
1566366346 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
2014-02-20 17:52:46 +00:00
Dave Collins
cff7f9704b Fix a few comment typos. 2014-02-20 11:20:53 -06:00
David Hill
61d270957e Add HasCanonicalPushes
Closes #6.

ok @davecgh
2014-02-20 01:20:47 -06:00
Dave Collins
37a45ec683 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
2014-02-19 16:34:50 -06:00
Dave Collins
fcd73f75ea 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.
2014-02-19 13:22:33 -06:00
David Hill
971fbf8b28 gofmt 2014-02-04 16:18:37 -05:00
Dave Collins
565f11409c Add 2014 to copyright dates. 2014-01-08 23:47:47 -06:00
Dave Collins
6c8003b064 Refactor and improve address extraction code.
This commit significantly changes the address extraction code.  The
original code was written before some of the other newer code was written
and as a result essentially duplicated some of the logic for handling
standard scripts which is used elsewhere in the package.

The following is a summary of what has changed:

- CalcPkScriptAddrHashes, ScriptToAddrHash, and ScriptToAddrHashes have
  been replaced by ExtractPkScriptAddresses
- The ScriptType type has been removed in favor of the existing
  ScriptClass type
- The new function returns a slice of btcutil.Addresses instead of raw
  hashes that the caller then needs to figure out what to do with to
  convert them to proper addressses
- The new function makes use of the existing ScriptClass instead of an
  nearly duplicate ScriptType
- The new function hooks into the existing infrastructure for parsing
  scripts and identifying scripts of standard forms
- The new function only works with pkscripts to match the behavior of the
  reference implementation - do note that the redeeming script from a p2sh
  script is still considered a pkscript
- The logic combines extraction for all script types instead of using a
  separate function for multi-signature transactions
- The new function ignores addresses which are invalid for some reason
  such as invalid public keys
2014-01-07 17:48:18 -06:00
Dave Collins
e2f14e2cfa Fix comment typo. 2014-01-06 12:14:43 -06:00
Dave Collins
2005fae908 Change OP_CHECK_MULTISIG -> OP_CHECKMULTISIG.
This change was made to match the reference implementation.
2014-01-04 15:23:51 -06:00
Dave Collins
b713590902 Group the StackErrX definitions.
This improves the godoc display and provides a cleaner separation of the
error definitions from other variables.
2014-01-04 09:58:22 -06:00