Commit Graph

474 Commits

Author SHA1 Message Date
Andrew Poelstra 4ba533514e Add Default impl to Script 2014-08-23 16:20:46 -07:00
Andrew Poelstra 6e6da2a756 Allow transaction inputs to be validated individually 2014-08-23 15:09:50 -07:00
Andrew Poelstra 7eadf72a1a Add serialize_hex method to do string conversion for serializations 2014-08-22 20:53:49 -07:00
Andrew Poelstra 18a61dd560 Add blockdata::constants::max_money 2014-08-22 20:29:16 -07:00
Andrew Poelstra e3445ebef7 Pull script tracing code out of Transcation so it can be used independently 2014-08-22 12:14:39 -07:00
Andrew Poelstra 611b1f57c9 Add a bunch of small hashtypes for cheap'n'collidey hashtables 2014-08-22 11:32:42 -07:00
Andrew Poelstra 1522ab841d Generalize consensus encode/decoders for HashMap 2014-08-18 19:49:09 -07:00
Andrew Poelstra e29fdb90c8 fix for upstream 2014-08-18 18:04:32 -07:00
Andrew Poelstra c54f0c36a3 Add `ldconfig` line to travis.yml 2014-08-17 18:42:11 -07:00
Andrew Poelstra d3ef264b44 Add txid to transaction trace 2014-08-17 17:25:47 -07:00
Andrew Poelstra 7059c21ef4 tx trace: add `executed` boolean, add a trace even for ops that fail 2014-08-17 13:35:57 -07:00
Andrew Poelstra 09679b8d9f Add a copy of the script to ScriptTrace 2014-08-16 19:21:07 -07:00
Andrew Poelstra 62dd2e7cee Add transaction trace capability for debugging scripts 2014-08-16 19:04:57 -07:00
Andrew Poelstra 8d1a3e1f7c Some error improvements 2014-08-16 13:33:13 -07:00
Andrew Poelstra 4c99653933 Move TX validation into Transaction, call from UtxoSet 2014-08-16 12:57:39 -07:00
Andrew Poelstra 8a814e4331 Add P2SH support 2014-08-15 17:37:40 -07:00
Andrew Poelstra fa859b3490 Fix VERIFY-op handling in provably-unspendable code 2014-08-14 20:32:36 -07:00
Andrew Poelstra 07c3d335aa Return proper errors from UtxoSet::update 2014-08-14 20:17:41 -07:00
Andrew Poelstra 61969ce6ee Fix overflow in script 2014-08-14 20:09:54 -07:00
Andrew Poelstra c28c261b74 utxoset: Fix parallel script checking to use only as many threads as CPUs 2014-08-14 17:20:43 -07:00
Andrew Poelstra fc04462682 Implement pruning 2014-08-14 17:05:07 -07:00
Andrew Poelstra d9d7416e32 Fixes for recent stdlib changes 2014-08-14 15:20:39 -07:00
Andrew Poelstra 6d4861b472 Fix typo in .travis.yml 2014-08-14 07:50:56 -07:00
Andrew Poelstra 8e7d763310 Parallelize transaction verification in utxoset
We no longer confirm that chained transactions occur in the correct order
in blocks, which is a minor consensus regression and should be dealt with
in future.
2014-08-13 23:42:01 -07:00
Andrew Poelstra cfe7d5eb26 Use slices rather than allocations in most parts of script 2014-08-13 20:25:28 -07:00
Andrew Poelstra 886dd68eb7 Minor correction to opcode docs 2014-08-12 22:50:40 -07:00
Andrew Poelstra 526f9fc574 Remove -all- CODESEPARATORS before serializing the script, even though only one has effect
I can validate the whole testnet chain now :) onto P2SH!
2014-08-12 21:34:46 -07:00
Andrew Poelstra 29d0701faa Fix off-by-one error handling OP_CODESEPARATOR 2014-08-11 22:43:24 -07:00
Andrew Poelstra c8f29b8d96 Add secp256k1 to travis 2014-08-11 22:05:16 -07:00
Andrew Poelstra 38593dd2ab Remove entire signature push operation, not just signature data, when hashing for checksig 2014-08-11 21:40:30 -07:00
Andrew Poelstra 2469820863 Merge pull request #3 from jkozera/patch-2
Use apoelstra's secp256k1
2014-08-11 20:15:22 -07:00
Jerzy Kozera 3d940a85fe Use apoelstra's secp256k1
dpc's version doesn't contain secp256k1:🔑:PublicKey which is used in blockdata/script.rs
2014-08-12 04:52:33 +02:00
Andrew Poelstra dea6d457f4 Clean up `read_uint` as in PR #2 (thanks @jkozera) 2014-08-11 19:20:39 -07:00
Andrew Poelstra 3e25134b2f Added unit tests for three more testnet failures, the latter of which I'm still working on 2014-08-11 19:17:58 -07:00
Andrew Poelstra a87dd0042b Get OP_MULTISIG working 2014-08-10 21:37:12 -07:00
Andrew Poelstra bf09ab2754 Fix script bugs (can now fully validate testnet up to multisig) 2014-08-10 19:35:58 -07:00
Andrew Poelstra e01e9ad3be Implement CHECKSIG and CHECKSIGVERIFY
Still need the multisig ops, and p2sh
2014-08-10 13:51:05 -07:00
Andrew Poelstra ecdb750148 Implement script except for crypto opcodes, replace zero_hash by Default
Looks like to implement the crypto opcodes I may need to switch from
rust-crypto to rust-openssl.. or implement RIPEMD-160 for rust-crypto.
In either case I will need to generalize the hash.rs stuff to support
other hashes, so I'm committing here as a checkpoint before doing all
that.
2014-08-05 19:08:06 -07:00
Andrew Poelstra 2986e1f983 Fix for new partial-move rules; swap hash le_hex_string and be_hex_string
I noticed that the little/big endian hex string functions for Sha256dHash
did not match my intuition. What we should have is that the raw bytes
correspond to a little-endian representation (since we convert to Uint256
by transmuting, and Uint256's have little-endian representation) while
the reversed raw bytes are big-endian.

This means that the output from `sha256sum` is "little-endian", while the
standard "zeros on the left" output from bitcoind is "big-endian". This
is correct since we think of blockhashes as being "below the target" when
they have lots of zeros on the left, and we also notice that when hashing
Bitcoin objects with sha256sum that the output hashes are always reversed.

These two functions le_hex_string and be_hex_string should really not be
used outside of the library; the Encodable trait should give access to a
"big endian" representation while ConsensusEncodable gives access to a
"little endian" representation. That way we describe the split in terms
of user-facing/consensus code rather than big/little endian code, which
is a better way of thinking about it. After all, a hash is a collection
of bytes, not a number --- it doesn't have an intrinsic endianness.

Oh, and by the way, to compute a sha256d hash from sha256sum, you do

  echo -n 'data' | sha256sum | xxd -r -p | sha256dsum
2014-08-03 14:52:59 -07:00
Andrew Poelstra 474d04d154 Manually implement Encodable/Decodable/Show for Network
Since TOML will not encode C-like enums as strings, we do it
ourselves. This is also worthwhile so that we can get the
lowercase "bitcoin" and "testnet" as encodings for the actual
enum values, which are more verbose and camel case.
2014-08-03 06:29:19 -07:00
Andrew Poelstra a6eb33efd0 Actually encode network message
A pretty serious oversight :) this was not noticed because I was
simultaneously dealing with a serious tcp connection bug in rustc,
and I had thought bitcoind's angry disconnects were a further
symptom of that.
2014-08-02 18:22:27 -07:00
Andrew Poelstra 275c93ab6b Add docs for SimpleDecoder and SimpleEncoder traits 2014-08-01 11:16:18 -07:00
Andrew Poelstra c80ec9bda8 Sha256dHash: add string encoder/decoder 2014-08-01 10:52:10 -07:00
Andrew Poelstra a2ce000b2b Revamp Serializable interface to be similar to Encoder/Encodable
This is a massive simplification, fixes a couple endianness bugs (though
not all of them I don't think), should give a speedup, gets rid of the
`serialize_iter` crap.
2014-08-01 09:01:39 -07:00
Andrew Poelstra 020295f8c9 Add a bunch of traits to Network so I can use it as a HashMap key 2014-07-29 15:55:25 -07:00
Andrew Poelstra 8cd8947cf3 Implement some more ToJson's 2014-07-29 10:19:21 -07:00
Andrew Poelstra a34f2642f1 Implement ToJson for BlockHeader
I think this is what I want to do for everything json-visible...perhaps
I will not be able to keep the macro for it though, since there are
some clever variations on it (e.g. blocks should have their header's
hash as a field, txes should appear as txids unless vebose output is
requested, etc.)
2014-07-28 20:12:10 -07:00
Andrew Poelstra 1938959017 Add `genesis_hash` function to Blockchain 2014-07-28 12:30:45 -07:00
Andrew Poelstra 6f7e73d6b4 Fix nu_select! macro for borrowck 2014-07-26 19:36:38 -07:00
Andrew Poelstra 322c937c3c Fixed borrowck problems with nu_select! in an evil way 2014-07-26 11:28:55 -07:00