Commit graph

22 commits

Author SHA1 Message Date
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
Dave Collins
8e1973d865 Correct a couple of typos spotted while reviewing. 2014-12-20 01:55:27 -06:00
David Hill
def35f2cd4 Sync Bitcoin Core tests. 2014-12-08 17:34:03 -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
edb006c11c Changed TxIn.PreviousOutpoint to TxIn.PreviousOutPoint after btcwire API change. 2014-10-01 13:57:27 +01:00
Dave Collins
5beafbd2d8 goimports -w . 2014-07-02 19:37:49 -05:00
David Hill
e560b6d964 sync bitcoind test data. 2014-05-29 10:56:43 -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
Owain G. Ainsworth
8ec60d4678 Quick and dirty tests harnesses using some bitcoind test data.
Both the script tests (positive and negative) and tx texts (ditto) are
present.  Some of the tx tests in the negative section have been
replaced by a comment line explaining why that test is elided, to add in
diffing. The reasons were always that they test things handled by other
parts of the btcd stack (normally chain). For example MAX_MONEY, number
of outputs, coinbase sizes etc.

Much of the inital test logic from @dajohi using hand transcribed tables
for selected tests. The json parsers, script format parser and a lot of
cleaning up/bugfixing from your truly. @davecgh had some input too.
2014-03-19 01:06:19 +00: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
2005fae908 Change OP_CHECK_MULTISIG -> OP_CHECKMULTISIG.
This change was made to match the reference implementation.
2014-01-04 15:23:51 -06:00
Josh Rickmar
83a19b239d Replace ScriptToAddress with ScriptToAddrHash to return an address hash. 2013-10-08 13:01:51 -04:00
Owain G. Ainsworth
52a1488eaf bitcoind only fails on invalid (undefined) opcodes when they are executed.
So add entries for them that disassemble and parse ok, but will fail
when executed with the appropriate error. Add a full suite of tests to confirm
that this happens.

Found by a strange transaction in testnet.
2013-10-08 00:16: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
bedaddb790 add GetScriptClass to return the internal script type of a script.
To be used to tell which class a script is (multisig, scripthash, pubkey,
pkhash, or nonstandard)
2013-07-05 15:23:02 +01:00
Owain G. Ainsworth
c41330e772 Add basic test for if internal opcode definitions are buggy. 2013-06-28 00:46:34 +01:00
Owain G. Ainsworth
d6161f0d41 fix ScriptToAddress when called with 0 length script.
It did work by luck before, but now it works no matter what the template
tables say. Add tests for the other error cases and internal data
assertions.
2013-06-26 22:11:54 +01:00
Owain G. Ainsworth
8035de426b Check that the pc validation code works ok.
Add a testing only interface to set the pc and set it to a few invalid
settings to check that step and disasmPC all blow up correctly.
2013-06-19 23:31:44 +01:00
Dave Collins
1197770159 Initial implementation. 2013-06-13 14:59:46 -05:00