Commit Graph

133 Commits

Author SHA1 Message Date
Tamas Blummer 3921899c65 add is_coin_base
add data access as copy
2018-06-01 21:39:51 +02:00
Matt Corallo 8aa6253a3b Correct consensus verify args, fix tests to catch error in travis 2018-04-02 15:38:43 -04:00
Matt Corallo bfe889904a Fix whitespace (s/\t/ /g) 2018-04-02 14:58:25 -04:00
Matt Corallo 6826d8f35c Stub out Sha2 calls when fuzzing to mask all but the first byte 2018-03-21 18:44:10 -04:00
Tamas Blummer 1a87244b2b Implement Segwit addresses 2018-03-20 18:26:51 +01:00
Tamas Blummer 755fb454eb integration with bitcoinconsenus 2018-03-12 17:17:16 +01:00
Andrew Poelstra f233fcac61 util: add `bip143` module to create BIP143 signature hashes 2018-01-15 17:54:32 +00:00
Andrew Poelstra e5f109221e script: add `to_p2wsh()` and `is_p2swsh()` functions to allow easy segwit output computation 2017-12-06 15:39:37 +00:00
Andrew Poelstra 46439710d9
script: add `is_p2pkh()` function 2017-10-06 19:15:30 +00:00
Andrew Poelstra 93f103bdb5 script: fix broken push_int in script::Builder 2016-07-14 15:15:34 +00:00
Andrew Poelstra 698a23e32d script: fix Debug impl bugs in Script, PUSHDATA1 not displayed correctly 2016-06-24 00:20:49 +00:00
Andrew Poelstra 1e47019221 cargo-clippy cleanups 2016-06-21 14:35:27 +00:00
Andrew Poelstra 220775015e [BREAKING CHANGE] [v0.5 -> v0.6] Move nasty script stuff into a feature-gated module 2016-06-12 00:36:46 +00:00
Andrew Poelstra 6ccd157775 Add `into_vec` method to Script 2016-06-02 23:47:29 +00:00
Andrew Poelstra 30904b67a7 Derive Eq and friends for script::Instruction 2016-05-04 14:03:58 +00:00
Andrew Poelstra f18157e774 Minor code changes for new rustc/clippy. No effects. Update minor version number 2016-02-18 19:44:29 +00:00
Andrew Poelstra 92c3b2459c script: fix macro for future rustc changes 2016-02-18 17:56:51 +00:00
Andrew Poelstra e393d0ec3b Add useful Debug/Display for Script 2015-12-19 20:13:59 -06:00
Andrew Poelstra a8ffce4904 Fix Script de/serialization (version -> 0.4.4) 2015-11-30 07:11:24 -06:00
Andrew Poelstra 66eb08aab5 [BREAKING CHANGE] Make `script::Builder` implement the actual Builder pattern
Rather than having methods taking &mut self, have them consume self
and return another Builder, so that methods can be chained.

Bump major version number.
2015-11-04 11:04:54 -06:00
Andrew Poelstra 5e03adc9aa Changes for cargo-clippy warnings 2015-10-28 11:27:23 -05:00
Andrew Poelstra 8daf06cc1d Update for latest libsecp: normalize signatures and use "lax DER" parsing 2015-10-26 14:39:25 -05:00
Andrew Poelstra 67c0b8fba7 More Error implementations 2015-10-25 12:55:48 -05:00
Andrew Poelstra fdc854edd9 Remove Script() from LowerHex impl of Script
This is easy for downstream to add, not easy for them to remove. Plus scripts
have a pretty recognizable form and are usually obvious from context anyway.
2015-10-14 22:31:12 -05:00
Andrew Poelstra ed34bb30f1 Add support for deserializing a script into a contracthash template
This is something Matt's contracthashtool does, so to copy its functionality
I need to support it. And it also seems generally useful.
2015-10-14 22:01:26 -05:00
Andrew Poelstra 16e2a3519b Implement basic contract-hash support
Does not do stuff like validating the form of contracts, since this seems like
more of an application thing. Does not even distinguish a "nonce", just assumes
the contract has whatever uniqueness is needed baked in.
2015-10-14 15:29:19 -05:00
Andrew Poelstra dba71d9253 [BREAKING CHANGE] Minor library updates
Breaking changes are:
    opcode::All::from_u8 is now From<u8>
    script::Builder::from_vec is now From<Vec<u8>>
    script::Script::from_vec is now From<Vec<u8>>
2015-10-14 09:14:09 -05:00
Andrew Poelstra 99a4845719 Get library building on stable 2015-09-20 12:22:39 -05:00
Andrew Poelstra 2320f099c1 Remove broken wallet components
This was a fairly small change and gets all unit tests to pass.
2015-09-19 13:39:39 -05:00
Andrew Poelstra adaf50a408 *** ALL TESTS PASS WITH RUSTC HEAD ***
There is still a lot of work to do modernizing the library, but the code
compiles cleanly with all unit tests passing now. Probably not much can
be done now until wizards-wallet is in better shape and the library is
actually in use.
2015-05-10 14:32:26 -05:00
Andrew Poelstra b21acd440e Get compiling for secp256k1 changes 2015-04-13 22:40:32 -05:00
Andrew Poelstra 17e27ec09f *** IT COMPILES ON RUSTC NIGHTLY ***
Many unit test failures, but this is progress.
2015-04-10 20:55:59 -05:00
Andrew Poelstra 3117f95b62 Checkpoint commit: into warnings! 2015-04-10 18:15:57 -05:00
Andrew Poelstra e658ffaeea Rename ScriptBuilder to Builder as per rustc rfc PR 1036 2015-04-09 23:23:56 -05:00
Andrew Poelstra e5a3e84c41 Checkpoint commit (nope, not yet to small commit sizes :))
This is mostly fixing compile errors in `cargo test`. We are down
to 3 in `cargo build` and 14 in `cargo test`, at least for this
round.
2015-04-08 17:23:45 -05:00
Andrew Poelstra 08a20f8764 Checkpoint commit
Work is stalled on some other library work (to give better lifetime
requirements on `eventual::Future` and avoid some unsafety), so
committing here.

There are only three errors left in this round :)

Also all the indenting is done, so there should be no more massive
rewrite commits. Depending how invasive the lifetime-error fixes
are, I may even be able to do sanely sized commits from here on.
2015-04-07 17:52:58 -05:00
Andrew Poelstra 200e0fe8e3 Checkpoint commit
27 files changed, 3944 insertions(+), 3812 deletions(-) :} I've
started doing whitespace changes as well, I want everything to
be 4-space tabs from now on.
2015-04-06 20:51:11 -05:00
Andrew Poelstra 811df8a713 Giant collection of fixes ... we are into lifetime errors now :) 2015-04-05 19:10:37 -05:00
Andrew Poelstra 7b89c15ed5 More changes, incl. dropping DumbHasher in favor of SipHasher
only json stuff left in this round of compiler errors :)
2015-04-05 14:43:44 -05:00
Andrew Poelstra 7738722ab5 Checkpoint commit; tons of disorganized changes for rustc
BTW after all this is done I'm gonna indent the entire codebase...
so `git blame` is gonna be totally broken anyway, hence my
capricious cadence of commits.
2015-04-05 12:58:49 -05:00
Andrew Poelstra 160f2f9ea6 Drop ThinVec, many other changes toward updating for librustc 2015-04-04 22:13:19 -05:00
Andrew Poelstra 11dbc717c4 Show -> Debug 2015-03-26 10:35:31 -05:00
Andrew Poelstra df065c143b fix attributes for compiler changes 2015-03-26 10:31:19 -05:00
Andrew Poelstra 2101e4a56d Rename bitcoin-secp256k1-rs to secp256k1 2015-03-26 10:08:36 -05:00
Andrew Poelstra c3377032f8 Many syntax changes for rustc, incomplete 2015-01-18 17:39:51 -06:00
Andrew Poelstra 97bfbe790b Add a `clone` to script sat-checker to satisfy new soundness rules
This was actually a soundness bug waiting to happen fwiw...but I'm
still not so happy about it.
2014-09-11 08:03:36 -05:00
Andrew Poelstra 331e555e4c Use `verify_raw` rather than `verify` to check signatures
`verify` cannot handle illegally padded signatures because it takes an object
of type `Signature`, which is a fixed-size type. This should have been part
of the previous commit --- an important lesson about running the unit tests
before every push!
2014-09-04 20:34:58 -05:00
Andrew Poelstra 20ce3721b7 Fix for upstream 2014-09-04 19:06:52 -05:00
Andrew Poelstra 6250f4fd9c Checkpoint commit -- prefix-filtered address indexing works 2014-09-01 21:37:00 -05:00
Andrew Poelstra f66b4ff6b3 Fix for upstream, add some address generation benchmarks 2014-09-01 09:24:17 -07:00
Andrew Poelstra 853d644649 Minor cleanup for script analyzer 2014-08-31 19:20:11 -07:00
Andrew Poelstra a8ecf00e35 Fix recursion to carry the execution state stack 2014-08-31 16:55:39 -07:00
Andrew Poelstra 9d283150c9 Fix GT/LT/GTEQ/LTEQ handling to not compare bools
I was trying to do something clever by making sure that the numeric
bounds were consistent with whatever ordering relation we were checking,
AND that the boolean values were also consistent...this is Wrong is the
case of negative numbers, and pointless anyway since I recently fixed
`set_bool_value`, `set_num_lo` and `set_num_hi` to update both numeric
and boolean information if possible, so they will always contain the
same info.
2014-08-31 16:43:26 -07:00
Andrew Poelstra d880bd1ccc Ensure execution state stack is empty at the start
We had a single `true` on the execution state stack, which would
allow scripts to have one more OP_ENDIF than they are allowed.
2014-08-31 16:23:47 -07:00
Andrew Poelstra 340b569c73 Add much more agressive provably-false checker
Now unspendable outs are determined by attempting to create a minimal
satisfying input script. If this can't be done, the output is unspendable.
(Unfortunately this "minimal satisfying script" is not (yet) something
that can be shown to the user, since it is more a bundle of constraints
than actual data pushes.)

Current limitations:
  - OP_ADD and friends mean the checker gives the script a free pass.
    There is no fundamental reason for this, I just didn't get to it
    yet.

  - Pubkeys are checked for DER encoding but signatures aren't. This
    is because secp256k1 exposes a method for pubkeys, but not one
    for sigs :). Signatures are loosely length checked.
2014-08-31 16:01:24 -07:00
Andrew Poelstra 4ab69b8a77 script tracer: add `op_count` a running opcode count 2014-08-25 21:39:16 -07:00
Andrew Poelstra 46bffa304c script tracer: Put an obvious "opcode failed" message in the pre-execute stack 2014-08-25 16:09:00 -07:00
Andrew Poelstra 4ba533514e Add Default impl to Script 2014-08-23 16:20:46 -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 e29fdb90c8 fix for upstream 2014-08-18 18:04:32 -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 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 61969ce6ee Fix overflow in script 2014-08-14 20:09:54 -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 cfe7d5eb26 Use slices rather than allocations in most parts of script 2014-08-13 20:25:28 -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 38593dd2ab Remove entire signature push operation, not just signature data, when hashing for checksig 2014-08-11 21:40:30 -07: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 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 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 c9ad7c0b58 Initial commit, move into Cargo 2014-07-18 06:56:17 -07:00