sanket1729
c252b36786
Add CHECKSIGADD and update classify API
2021-09-13 07:45:00 -07:00
Dr. Maxim Orlovsky
697e8f5194
Merge pull request #626 from visvirial/impl-vsize
...
Implement `Block.get_strippedsize()` and `Transaction.get_vsize()`
2021-09-11 00:09:22 +02:00
Dr Maxim Orlovsky
ecc400826c
Updating Script::is_witness_program to use new WitnessVersion
2021-08-10 10:34:15 +02:00
Dr Maxim Orlovsky
64c1ec0b76
WitnessVersion type
2021-08-10 10:34:15 +02:00
Dr. Maxim Orlovsky
4e3c2c32fc
Merge pull request #632 from tcharding/prefixes
2021-08-09 23:26:15 +02:00
Dr. Maxim Orlovsky
33393e0bf4
Merge pull request #621 from RCasatta/verify_with_amount
2021-08-09 23:23:09 +02:00
Dr. Maxim Orlovsky
808e1708c3
Merge pull request #596 from RCasatta/script_ser
2021-08-09 23:22:06 +02:00
Tobin Harding
adc1543e7c
Use consts for address prefix values
...
Instead of using magic numbers we can define constants for the address
prefix bytes. This makes it easier for future readers of the code to see
what these values are if they don't know them and/or see that they are
correct if they do know them.
2021-07-22 10:31:14 +10:00
Riccardo Casatta
15e3caf62d
[test] Test also sighash legacy API with legacy tests
2021-07-21 12:05:37 +02:00
Devrandom
4826d0c6cc
no_std support
...
Based on the original work by Justin Moon.
*MSRV unchanged from 1.29.0.*
When `std` is off, `no-std` must be on, and we use the [`alloc`](https://doc.rust-lang.org/alloc/ ) and core2 crates. The `alloc` crate requires the user define a global allocator.
* Import from `core` and `alloc` instead of `std`
* `alloc` only used if `no-std` is on
* Create `std` feature
* Create `no-std` feature which adds a core2 dependency to polyfill `std::io` features. This is an experimental feature and should be
used with caution.
* CI runs tests `no-std`
* MSRV for `no-std` is 1.51 or so
2021-07-15 09:04:49 +02:00
Vis Virial
cdf7be4765
Add extra checks for `test_segwit_transaction()`.
2021-06-29 07:59:22 +09:00
Vis Virial
2bda871628
Remove `#[inline]` from `Transaction.get_strippedsize()`.
2021-06-29 07:40:13 +09:00
Vis Virial
c9dead410a
Implement `Transaction.get_strippedsize()`.
...
`Block.get_strippedsize()` is also simplified and optimized.
2021-06-29 07:34:37 +09:00
Vis Virial
1bf9147a6e
Optimize `Transaction.get_vsize()` (thanks @TheBlueMatt).
2021-06-29 07:14:01 +09:00
Vis Virial
2085dc32a7
Refactoring: define `Block.get_base_size()`.
2021-06-28 20:07:07 +09:00
Vis Virial
4ac9cef9e9
Implement `Block.get_strippedsize()` and `Transaction.get_vsize()`.
2021-06-28 20:03:42 +09:00
Riccardo Casatta
a86bced568
use Amount type in verify
2021-06-21 14:43:09 +02:00
Sebastian
e334c9deea
Merge pull request #616 from sgeisler/2021-06-dust-value-amount
...
Use `Amount` type for dust value calculation
2021-06-16 20:51:23 +02:00
Riccardo Casatta
4a4460b1a3
Add test for script serialize/deserialize
2021-06-16 10:17:56 +02:00
Riccardo Casatta
fadd368911
use different ser/de for Script in case of non human readable format
2021-06-16 10:17:40 +02:00
Sebastian Geisler
9981da2ec8
Use `Amount` type for dust value calculation
2021-06-12 21:15:13 +02:00
Devrandom
95aa3bf153
std -> core
2021-06-11 17:28:04 +02:00
Sebastian
d7eb15c6f1
Merge pull request #584 from darosior/max_tx_weight_const
...
Introduce some policy constants from Bitcoin Core
2021-05-29 02:49:46 +02:00
Andrew Poelstra
052aaf1d80
Merge pull request #559 from LNP-BP/fix/error-derives-2
...
Fix/error derives 2
2021-05-19 15:02:10 +00:00
Antoine Poinsot
2e9d62a9c7
blockdata/script: use policy's constant in dust computation
...
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2021-05-18 14:52:58 +02:00
Antoine Poinsot
2b777485fa
policy: introduce p2p constants from the reference implementation
...
This introduces some constants defined by Bitcoin Core which as a
consequence define some network rules in a new 'policy' module.
Only some were picked, which are very unlikely to change. Nonetheless a
Warning has been put in the module documentation.
Script-level constants are left into rust-miniscript where they are
already defined (src/miniscript/limits.rs).
2021-05-18 14:52:56 +02:00
Andrew Poelstra
4620c640a9
Merge pull request #579 from TheBlueMatt/master
...
Fix Script::dust_value()'s calculation for non-P2*PKH script_pubkeys
2021-05-06 16:01:36 +00:00
Andrew Poelstra
3fd88d317f
Merge pull request #598 from RCasatta/verify_flags
...
Add verify_with_flags to Script and Transaction
2021-05-05 22:33:47 +00:00
Matt Corallo
fc6f23fb9b
Drop not-very-useful output dust threshold constants
...
It doesn't really make sense to have a constant for every common
script type's dust limit, instead we should just use the
`Script::dust_value()` function to have users calculate it.
2021-05-05 14:53:26 +00:00
Dr Maxim Orlovsky
c0b7defc86
More non-API breaking error derives depending on upstream PRs
2021-05-04 03:58:56 +02:00
Riccardo Casatta
c96f7ec71c
use markdown autolink syntax for urls with no text
2021-05-03 13:46:10 +02:00
Riccardo Casatta
ef471ccca7
Fix documentation, in particular link to code elements
2021-05-03 11:43:11 +02:00
Matt Corallo
15981c945a
Fix Script::dust_value()'s calculation for non-P2*PKH script_pubkeys
...
The dust calculations added were only valid for P2WPKH and P2PKH
outputs, and somehow this fact was missed in review, despite the
upstream Core code being linked to and looked at by two reviewers
and the author (me).
Someday I will grow eyeballs, but that day is not today.
2021-05-01 17:47:45 +00:00
Dr. Maxim Orlovsky
68096242d3
Merge pull request #594 from RCasatta/capped
...
Count bytes read in encoding
2021-05-01 16:28:57 +02:00
Riccardo Casatta
69117a1f63
Use Amount for verify_with_flags
2021-05-01 10:22:35 +02:00
Riccardo Casatta
d1f4c0a5c8
Remove Copy for flags parameter
2021-05-01 10:19:54 +02:00
Riccardo Casatta
3aaa5d6846
Add verify with flags
2021-04-30 18:56:35 +02:00
Andrew Poelstra
4db4e604cb
Merge pull request #589 from LNP-BP/taproot/key-1
...
Non-API breaking introduction of Schnorr keys
2021-04-29 20:30:54 +00:00
Riccardo Casatta
f692c4a938
Limit bytes read with Take
2021-04-28 09:33:37 +02:00
Andrew Poelstra
8231e25292
Merge pull request #586 from sanket1729/warn
...
fix warnings for sighashtype
2021-04-21 15:52:44 +00:00
Andrew Poelstra
da477f1041
Merge pull request #558 from LNP-BP/fix/error-derives-1
...
Non-API breaking derives for error & transaction types
2021-04-21 14:24:27 +00:00
Dr Maxim Orlovsky
b17d7fc31c
Moving keys under `util::ecdsa`, re-exporting them at `util::key`
...
This is the first step in introducing Schnorr key support as per #588
2021-04-12 14:17:42 +02:00
sanket1729
3545580bd9
fix warnings for sighashtype
2021-04-06 11:52:14 -07:00
Dr Maxim Orlovsky
7fe3c4a605
Non-API breaking derives for error types
2021-04-06 14:44:50 +02:00
Collins Muriuki
c4cfdbbd6a
doc: correct Transaction struct encode_signing_data_to doc comment
2021-04-03 23:52:09 +03:00
Steven Roose
851a3a15c0
Make Script::fmt_asm a static method and add Script::str_asm
...
This makes it convenient to print/construct the script assembly on
byte slices withoout having to clone them to copy them to create a
Script struct.
2021-03-13 22:16:20 +00:00
Steven Roose
96fa4b7d9b
Implement AsRef<[u8]> for Script
2021-03-13 22:13:39 +00:00
Andrew Poelstra
2414c5b0a9
Merge pull request #573 from darosior/standard_sighash
...
SigHashType: add a method to error on non-standard hashtypes
2021-02-21 15:34:58 +00:00
Antoine Poinsot
e36f3a38e4
transaction: deprecate SigHashType::from_u32 in favor of from_u32_consensus
...
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2021-02-19 11:36:44 +01:00
Antoine Poinsot
bf98d9fd60
transaction: add a method to err on non-standard types to SigHashType
...
Right now, any sighash type could be parsed without error, which matches
consensus rules. However most of them would be invalid by standardness,
so it's a bit footgun-y (even more so for pre-signed transactions
protocols for which standardness is critical).
This adds `from_u32_standard()`, which takes care to error if we are
passed an invalid-by-current-policy-rules SIGHASH type.
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2021-02-19 11:12:02 +01:00
Antoine Poinsot
466f161e0b
transaction: document why we mask sighash types with 0x9f
...
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
Co-Authored-by: sanket1729 <sanket1729@gmail.com>
2021-02-19 00:27:02 +01:00
Antoine Poinsot
7f73d5f7db
doc: correct SigHashType doc comment
...
Super nit, but a hashtype is not specific to a transaction but a
signature.
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2021-02-18 19:48:39 +01:00
Jeffrey Czyz
ade2bcee8e
Return BlockHash from BlockHeader::validate_pow
...
Validating a block's proof-of-work involves computing the block hash.
Returning it from BlockHeader::validate_pow avoids having callers
recompute the block hash if it is needed.
2021-02-17 17:40:17 -08:00
Sebastian
5bd61967b2
Merge pull request #566 from TheBlueMatt/2021-02-dust-value
...
Add Script:dust_value() to get minimum output value for a spk
2021-02-07 11:45:17 +01:00
Matt Corallo
6622de4041
Add Script:dust_value() to get minimum output value for a spk
2021-02-05 15:26:56 -05:00
Sebastian Geisler
e98f14387d
Add function to check RBF-ness of transactions
2021-02-04 22:15:26 +01:00
Steven Roose
61918dfe81
Change the signature of consensus_encode to return io::Error's
...
This is instead of encode::Errors because the encoders should
not be allowed to return errors that don't originate in the writer
they are writing into.
This is a part of the method definition that has been relied upon for a
while already.
2021-01-12 17:39:41 +00:00
Andrew Poelstra
ffe452ac0b
script: add FromHex and FromStr implementations
2021-01-05 18:45:14 +01:00
Max Giraldo
21b2f929c5
refactor(blockdata/transaction): use nested paths
...
Instead of using a wildcard path for the `hash_types` module,
be explicit about what types we're using by using nested paths.
There are many benefits to this, including not polluting the namespace
and clearly demarcating the types' location.
2021-01-04 00:01:59 +01:00
Max Giraldo
06dc0041c2
docs: fix quotes in Transaction#ntxid description
...
Insert double quotes instead of a combination of single quote
and backtick.
2021-01-01 05:52:23 -08:00
Steven Roose
94b7371424
Replace serde_struct_impl with derive-based impls
2020-12-30 16:32:52 +01:00
0xB10C
b7caf0110f
test: BlockHeader::difficulty()
...
https://github.com/rust-bitcoin/rust-bitcoin/issues/462
2020-12-26 11:33:54 +01:00
0xB10C
4eca40dcc1
test: BlockHeader::validate_pow()
...
https://github.com/rust-bitcoin/rust-bitcoin/issues/462#issuecomment-683916241
2020-12-26 11:33:39 +01:00
0xB10C
d5bf5c88a3
test: BlockHeader::work()
...
https://github.com/rust-bitcoin/rust-bitcoin/issues/462#issuecomment-683916241
2020-12-26 11:33:22 +01:00
Dawid Ciężarkiewicz
cf2c12a816
Add ability to pass `SigHashType` directly to `signature_hash`
2020-11-24 22:53:56 -08:00
Dawid Ciężarkiewicz
8773cb4a42
Document `sighash_u32` of `Transaction::signature_hash`
2020-11-24 22:50:06 -08:00
Andrew Poelstra
93df7cbd3e
Merge pull request #291 from kallewoof/2019-07-signet
...
add signet support
2020-10-26 19:46:10 +00:00
Steven Roose
ab9514983b
Add explanation to witness program version assertion
2020-10-23 21:28:16 +01:00
Dr Maxim Orlovsky
8e0b9921ae
No space- and case insensitivity for SigHashType string serialization
2020-10-14 16:46:48 +02:00
Dr Maxim Orlovsky
a4a7035a94
String and serde de/serialization for SigHashType
2020-10-14 16:31:24 +02:00
Steven Roose
e60bfe2f61
Revert the sighash method signatures
...
Hash engines don't product I/O errors, so encoding into them
shouldn't produce errors either.
2020-10-09 16:27:38 +02:00
Andrew Poelstra
3618d7a41d
Merge pull request #485 from ipaljak-tbtl/expose-tx-signature-data
...
Expose serialized data for transaction signatures
2020-10-09 13:24:51 +00:00
Andrew Poelstra
fc60a7fc25
Merge pull request #492 from RCasatta/fix_bench_names
...
fix bench fn names
2020-10-09 13:12:39 +00:00
Riccardo Casatta
9a5291c717
fix bench names
2020-10-08 18:21:30 +02:00
Ivan Paljak
e66caab956
Improve error handling, fix forgotten early return
2020-10-08 16:40:30 +02:00
Elichai Turkel
eda47c31c9
Remove redundant code / configurations
2020-10-08 17:11:18 +03:00
Elichai Turkel
2d70623356
Remove deprecated Error::description impl
2020-10-08 17:11:18 +03:00
Elichai Turkel
023fae1f65
Add the dyn keyword where appropriate
2020-10-08 17:11:16 +03:00
Elichai Turkel
46f4f8cf35
Add benchmarks for tx serialization and size
2020-10-08 16:29:26 +03:00
Elichai Turkel
609b9523b8
Add benchmarks for block serialization
2020-10-08 16:28:17 +03:00
Ivan Paljak
c21dabb824
Expose serialized data for transaction signatures
2020-10-08 01:21:10 +02:00
Steven Roose
9c90b39ebd
Add Block::coinbase and Block::bip34_block_height
2020-10-07 18:54:12 +02:00
Steven Roose
29a74a14ab
Move around impls in block module
...
So that an impl always succeeds the struct type definition.
2020-10-07 18:48:24 +02:00
Karl-Johan Alm
a3d9899cb1
add signet support
2020-09-18 16:32:33 +09:00
Dr Maxim Orlovsky
1342d73734
Script hash functions with non-allocating serialization
2020-09-11 15:10:57 +02:00
Dr Maxim Orlovsky
8363c76f5c
Script hash functions (normal and witness)
2020-09-11 15:10:57 +02:00
Dr Maxim Orlovsky
38a412c4d5
Fixing review comments for script generators refactoring
2020-09-10 14:44:44 +02:00
Dr Maxim Orlovsky
e33cdcca14
OP_RETURN script initializer
2020-09-10 12:09:04 +02:00
Dr Maxim Orlovsky
9143fd3888
All script generation functionality moved to standalone methods in Script
2020-09-10 12:09:04 +02:00
Andrew Poelstra
addb54ffc7
Merge pull request #458 from braydonf/version
...
Transaction and header version is signed int
2020-09-09 17:06:31 +00:00
Elichai Turkel
a44ba2d878
Merge pull request #397 from stevenroose/script-iter
...
Improve the Instructions iterator for scripts
2020-09-09 19:06:05 +03:00
Braydon Fuller
945db009b2
Add test for transaction and block version serialization
2020-08-19 14:12:03 -07:00
Braydon Fuller
e9f1f11c2c
Transaction and header version is signed int
2020-08-17 10:28:51 -07:00
Alexis Sellier
9cb5d2e711
Link type in rustdoc
2020-07-09 21:17:02 +02:00
Alexis Sellier
e8cecfe1d3
Add `BlockHeader::u256_from_compact_target` function
...
This implements the counterparty to BlockHeader::compact_target_from_u256,
to convert a compact u32 to a Uint256.
2020-07-09 21:17:02 +02:00
Andrew Poelstra
7efde3ae47
Merge pull request #419 from elichai/2020-03-description
...
Deprecate Error::description
2020-05-23 17:26:38 +00:00
Elichai Turkel
af31017eb1
Remove the cursor overhead, write is implemented on vec these days
2020-05-19 12:57:39 +03:00
Elichai Turkel
654232a3dc
Deprecate Error::description
2020-04-13 02:15:28 +03:00
Elichai Turkel
41e4471721
Remove alloc when hashing sighash
2020-04-12 19:04:12 +03:00
Steven Roose
fea09a0a94
Improve the Instructions iterator for scripts
...
- Rename the `iter` method to `instructions`.
- Add `instructions_minimal` for minimal-enforced iteration.
- Iterator has `Result<Instruction, Error>` as items.
2020-04-11 23:52:26 +01:00
Andrew Poelstra
c3a7d1b27c
Merge pull request #417 from shesek/202003-block-size-weight
...
Add Block::get_size() and Block::get_weight()
2020-04-07 14:12:15 +00:00
Elichai Turkel
a473d01b17
Made some idiomatic changes
2020-03-29 17:15:15 +03:00
Elichai Turkel
3f2d428706
Remove needless references
2020-03-29 17:15:14 +03:00
Nadav Ivgi
94032f6817
Add Block::get_size() and Block::get_weight()
2020-03-27 21:54:46 +03:00
Nadav Ivgi
f3b5a7187c
Add Transaction::get_size()
2020-03-23 19:48:41 +02:00
Andrew Poelstra
659f2edb3b
Merge pull request #381 from elichai/2020-01-hex
...
Remove the hex dependency
2020-01-24 19:14:20 +00:00
Steven Roose
930a6ca1dc
Merge pull request #390 from instagibbs/bip143_sighash_notall
...
Add bip143 sighash support for other flags
2020-01-21 23:26:17 +00:00
Gregory Sanders
908aff50bc
Add bip143 sighash support for other flags
2020-01-21 09:50:41 -05:00
Elichai Turkel
c19b736566
Remove the hex dependency
2020-01-20 18:50:02 +02:00
Elichai Turkel
5452260884
Merge pull request #392 from instagibbs/wit_scale
...
Add, use WITNESS_SCALE_FACTOR constant
2020-01-20 18:02:59 +02:00
Gregory Sanders
2916685ca6
small Transaction test cleanup
2020-01-14 11:14:23 -05:00
Gregory Sanders
3624ee82c8
Use witness scaling constant in get_weight
2020-01-14 11:14:23 -05:00
Gregory Sanders
09c0e7fbde
Add WITNESS_SCALE_FACTOR constant
2020-01-14 11:14:23 -05:00
Steven Roose
8e52b8ce4d
Remove the BitcoinHash trait
...
Replaced by a `block_hash` method on both `Block` and `BlockHeader`.
2020-01-10 11:34:16 +00:00
Dr Maxim Orlovsky
5fc24dea33
Multiple fixes for hash types and their computing
...
Unit test for wtxid and SegWit transactions
2020-01-01 13:54:23 +01:00
Dr Maxim Orlovsky
0abe15b1f6
Moving from BitcoinHash to Wtxid for Transactions
2020-01-01 13:52:20 +01:00
Dr Maxim Orlovsky
f5a8087105
New hash types: MerkleRoot/Branch, WitnessCommit, SigHash, FilterHash
2020-01-01 13:50:17 +01:00
Dr Maxim Orlovsky
4746ccb88e
Final work on Txid and other hashes
...
Fixing issue with external dependency and hash_newtype macro implementation
Reverting back to the bitcoin_hashes crate after new version release
2020-01-01 13:48:28 +01:00
Dr Maxim Orlovsky
d20ab1dbc4
Switching to XpubIdentifier
2020-01-01 13:46:44 +01:00
Dr Maxim Orlovsky
5f4f629bb1
Replaced all hash160, sha256 and sha256d with the new hash types throughout the code
...
Embedding Txid's in the doc exaples
2020-01-01 13:44:34 +01:00
Dr Maxim Orlovsky
5ef39e34fa
Implementing (W)Pubkey/ScriptHash and BlockHash
2020-01-01 13:42:22 +01:00
Dr Maxim Orlovsky
ec92a05682
New HashTypes defined according to #284 (WIP), Txid is completed
2020-01-01 13:41:42 +01:00
Steven Roose
5f4555bfac
Remove util::misc::hex_bytes in favor of bitcoin_hashes::hex
2019-12-09 14:19:09 +00:00
Andrew Poelstra
65cb18d583
Merge pull request #341 from ccdle12/txin-impl-default
...
Add default trait implementation for TxIn
2019-12-06 21:21:49 +00:00
Matt Corallo
acb43af981
Drop byteorder dependency
...
Taking an external dependency just to convert ints to byte arrays
is somewhat of a waste, especially when Rust isn't very aggressive
about doing cross-crate LTO.
Note that the latest LLVM pattern-matches this, and while I haven't
tested it, that should mean this means no loss of optimization.
2019-12-05 10:41:00 -05:00
Chris Coverdale
0586ed94c4
Add default trait implementation for TxIn
2019-11-17 16:41:14 +00:00
practicalswift
0b08978af2
Fix incorrect documentation for is_p2pk(...) ( #331 )
2019-09-21 13:33:44 +02:00
Tamas Blummer
38d5ae4e3f
enable serde serialization for block and blockheader
2019-08-24 14:26:18 +02:00
Tamás Blummer
f01568c85a
use lambda instead of a hash map to find spent outputs ( #319 )
...
* use lambda instead of a hash map to find spent outputs
* check for double use of an input
2019-08-23 18:49:31 +02:00
Elichai Turkel
52ff97cddc
Deny unused imports and remove unneeded
2019-08-19 13:29:43 -04:00
Steven Roose
48f4c1989f
Rename bitcoin_hashes dependency to hashes
2019-08-16 15:52:27 +01:00
Steven Roose
bfdcfee28e
Add Address::from_script constructor
2019-08-15 22:28:20 +01:00
practicalswift
8152ed758c
Fix typos
2019-08-04 19:27:36 +00:00
Steven Roose
fc6415d652
Add human-readable serde for OutPoint as `<txid>:<vout>`
2019-07-26 15:30:46 +02:00
Tamás Blummer
c93a70487f
Add client side block filter (BIP158) ( #281 )
...
* add client side block filters with code from murmel. use siphash from bitcoin_hashes pass Bitcoin Core tests upgrade to bitcoin_hashes 0.7
* add filter.filter_id() test use BlockFilter directly
* fixed edge cases of matching empty query sets or or using empty filter
2019-07-26 09:36:25 +02:00
Andrew Poelstra
3b9a94a178
eliminate type parameter from the `Decodable` trait
2019-07-11 17:23:01 +00:00
Andrew Poelstra
42960b959f
eliminate type parameter from `Encodable` trait
2019-07-11 17:21:19 +00:00
Andrew Poelstra
b734d6488a
make consensus_encode return the encoded length
2019-07-11 17:15:32 +00:00
Andrew Poelstra
abb9210c04
make `VarInt::len` and `Transaction::get_weight` return a usize
2019-07-11 17:14:05 +00:00
Andrew Poelstra
7e6ad7c893
rename Encoder to WriteExt and Decoder to ReadExt
2019-07-11 15:01:38 +00:00
John L. Jegutanis
56f98e00a0
Changed constants from `static` to `const` and added 2 new constants
2019-07-05 15:01:54 +02:00
Andrew Poelstra
1a4bb371a1
Merge pull request #286 from apoelstra/2019-06-builder-ext
...
script: give `Builder` ability to verify-ify opcodes
2019-07-03 21:50:57 +00:00
Andrew Poelstra
b2727b6ebe
Merge pull request #250 from stevenroose/no-strason
...
Remove Decimal and replace strason with serde_json
2019-07-03 17:30:21 +00:00
Andrew Poelstra
a11412862c
script: give `Builder` ability to verify-ify opcodes
2019-06-29 21:26:56 +00:00
Steven Roose
560a709faa
Add OutPoint::new() for one-liner construction ( #285 )
2019-06-24 18:49:20 +02:00
Steven Roose
d2923b7cce
Rename OP_NOP2 and OP_NOP3 to OP_CLTV and OP_CSV
2019-06-13 18:56:35 +01:00
Steven Roose
30201f3924
Remove Decimal and replace strason with serde_json
2019-06-13 18:29:16 +01:00
Jonas Nick
30f24a39d0
Remove confusing mentions of SPV
2019-06-07 13:12:07 +00:00
Steven Roose
093d60bf7f
Rename BlockHeader::spv_validate to validate_pow
2019-06-06 10:39:03 +01:00
Matt Corallo
4f96a87475
Drop LoneHeaders and just use BlockHeader
...
The protocol has a bug where a 0u8 is pushed at the end of each
block header on the wire in headers messages. WHy this bug came
about is unrealted and shouldn't impact API design.
2019-05-17 17:55:02 -04:00
Andrew Poelstra
049f75e502
script: add `push_key` function to Builder to allow serializing public keys more easily
2019-03-04 01:32:35 +00:00
Matt Corallo
084703cba9
Merge pull request #218 from tamasblummer/merkle_root_fix
...
Merkle root calculation and witness commitment check for Block
2019-02-16 19:05:42 -05:00
Carl Dong
560dfb7c01
Merge pull request #203 from stevenroose/asm
...
Extract the Script assembly creator from fmt::Debug
2019-02-11 17:24:03 -05:00
ariard
51971dd533
Fix typos and clarify some comment in blockdata, block, address ( #230 )
2019-02-04 07:30:41 +01:00
Tamas Blummer
d8c93d9935
Implement Witness commitment check for Block. Remove MerkleRoot implementations for types implementing BitcoinHash as
...
it is misleading. MerkleRoot is defined instead for a Block.
2019-02-01 17:46:26 +01:00
Carl Dong
99f63a8ca4
Convert codebase from util::hash to bitcoin_hashes
...
Also replace unsafe transmute with call to read_u64_into
2019-01-24 16:27:52 -05:00
Dimitris Apostolou
132ca5ea95
Fix typos
2019-01-23 14:17:29 -05:00
Antoine Riard
96c66292c8
Fix comment on transaction version
2019-01-10 18:29:50 -08:00
Steven Roose
a10d5e15b3
Extract the Script assembly creator from fmt::Debug
2018-12-19 21:17:00 +01:00
Andrew Poelstra
5a5158e120
Merge pull request #198 from sgeisler/safe-opcodes
...
Safe opcodes 1.14.0
2018-12-14 16:32:29 +00:00
Sebastian Geisler
a6d204cbda
Fix indentation in opcodes.rs
2018-12-13 15:35:29 -08:00
Andrew Poelstra
617406228a
add some opcode tests
2018-12-09 16:30:23 +00:00
Sebastian Geisler
9fee72cf20
make opcode PR work with 1.14.0
2018-12-04 15:56:18 -08:00
Sebastian Geisler
79a88e1612
Move fuzzing code out of utils
2018-12-03 16:31:13 -08:00
Kaz Wesley
6b67c8cdff
squashme: work around lack of associated constants
2018-11-11 14:58:33 -08:00
Kaz Wesley
45234eb09a
safe implementation of All -> Ordinary
2018-11-11 14:19:25 -08:00
Kaz Wesley
0bfef68851
newtype implementation of opcodes::All
...
Removes unsafety when converting u8 -> All
2018-11-11 14:11:06 -08:00
Nadav Ivgi
18fcab6715
Detect compressed p2pk in script.is_p2pk()
2018-11-08 02:37:27 +02:00
Andrew Poelstra
b8a72448df
Merge pull request #153 from rust-bitcoin/2018-08-segwit-ambiguity
...
transaction: make 0-input de/serialization always use Segwit
2018-11-03 15:29:51 +00:00
Steven Roose
fefd5d4fe2
Implement FromStr for OutPoint
2018-10-18 12:37:02 +01:00
Andrew Poelstra
11a2783235
add comment expanding on the segwit ambiguity
2018-10-10 02:45:09 +00:00
Andrew Poelstra
a181a523c6
remove special case for 0-input 0-output transaction deserialization
...
This creates two ways to encode an empty transaction; we should use only the
Segwit-enabled one because that's what we do for 0-input non-0-output transactions.
2018-10-10 02:03:08 +00:00
Andrew Poelstra
98e39b4383
transaction: make 0-input de/serialization always use Segwit
2018-09-27 13:50:35 +00:00
Carl Dong
0f42ca69b0
Move relevant names into consensus::encode
...
- Move network::encodable::* to consensus::encode::*
- Rename Consensus{En,De}codable to {En,De}codable (now under
consensus::encode)
- Move network::serialize::Error to consensus::encode::Error
- Remove Raw{En,De}coder, implement {En,De}coder for T: {Write,Read}
instead
- Move network::serialize::Simple{En,De}coder to
consensus::encode::{En,De}coder
- Rename util::Error::Serialize to util::Error::Encode
- Modify comments to refer to new names
- Modify files to refer to new names
- Expose {En,De}cod{able,er}, {de,}serialize, Params
- Do not return Result for serialize{,_hex} as serializing to a Vec
should never fail
2018-09-25 21:19:35 +08:00
Carl Dong
8e0e4eb55a
Move serialize::BitcoinHash to util: #️⃣ :BitcoinHash
...
- Use Sha256dEncoder for calculating merkle root
- Remove BitcoinHash implementation for Vec<u8>
2018-09-25 21:19:10 +08:00
Andrew Poelstra
fe99a88acf
Merge pull request #152 from rust-bitcoin/2018-08-script-ord
...
impl PartialOrd, Ord for Script
2018-08-26 15:38:43 +00:00
Andrew Poelstra
b33aa6fa6c
add unit test for script ordering
2018-08-25 22:09:22 +00:00
Andrew Poelstra
f0221fb79b
transaction: reject transactions with Segwit byte set but no witnesses
2018-08-24 19:57:58 +00:00
Andrew Poelstra
68413d306d
impl PartialOrd, Ord for Script
2018-08-24 02:20:37 +00:00
Andrew Poelstra
08db6fe29f
script: let Instructions iterator enforce minimal pushes; remove `IntoIter` impl to force users to choose
2018-08-22 19:55:31 +00:00
Carl Dong
0c172941af
Replace serialize::Error::Detail with variants
...
- Add serialize::Error::ParseFailed(&'static str) variant for
serialization errors without context
- Add appropriate variants to replace network::Error::Detail for
serialization error with context
- Remove error method from SimpleDecoders
2018-08-21 01:58:40 -07:00
Carl Dong
95303a1d28
Use full path in macros to to eliminate uses
2018-08-21 01:58:40 -07:00
Carl Dong
e5b5cbfadb
Fix Error type for SimpleDecoder and SimpleEncoder
...
- Separate serialize::Error and network::Error from util::Error
- Remove unneeded propagate_err and consume_err
- Change fuzzing code to ignore Err type
2018-08-21 01:58:40 -07:00
Jean Pierre Dudey
4dfb98bd70
Use `as_`,`to_`,`into_` conventions for array types.
...
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-20 17:20:43 -04:00
Andrew Poelstra
2d961412af
Merge pull request #139 from jeandudey/2018-08-18-outpoint
...
Rename `TxOutRef` to `OutPoint` and use it in `TxIn`.
2018-08-20 18:18:00 +00:00
Jean Pierre Dudey
32631e44ad
Rename `TxOutRef` to `OutPoint` and use it in `TxIn`.
...
Previously this structure was unused, it's now being used by the `TxIn`
structure to simplify the code a little bit and avoid confusions. Also
the rust-lightning source code has an `OutPoint` similar to this one
but with the `vout` index as an `u16` to avoid unsafe conversions.
I've added to new methods to `OutPoint`:
- `null`: Creates a new "null" `OutPoint`.
- `is_null`: Checks if the given `OutPoint` is null.
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-20 13:46:10 -04:00
Jean Pierre Dudey
1b4aba1d80
Update serde to 1.0 and strason to 0.4
...
The `serde_struct_impl!` macro has been modified to be compatible
with the serde 1.0 crate, we use this macro and not the `serde_derive`
crate because the latter doesn't support Rust 1.14.0 which is shipped
on Debian stable and we should remain compatible with it.
Two new features were added:
- "serde": enables serialization/deserialization for common types, it pulls
the serde 1.0 dependency.
- "serde-decimal": enables serialization/deserialization for `UDecimal`/`Decimal`,
this pulls the strason 0.4 depdendency and the serde 1.0 dependency.
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-20 13:42:34 -04:00
Carl Dong
9da96e1d46
Fix compilation warning when comparing usize and u64 on 32-bit arch
2018-08-17 10:08:56 -07:00
Andrew Poelstra
6c82001ead
Merge pull request #128 from jeandudey/2018-08-12-bitcoinconsenus
...
Remove unused "bitcoinconsenus" feature.
2018-08-15 20:55:51 +00:00
Andrew Poelstra
bc7125e955
Merge pull request #119 from jeandudey/2018-08-08-try-op
...
Remove `try!` macro usage and use the `?` operator instead.
2018-08-12 23:44:43 +00:00
Jean Pierre Dudey
f918311b8a
Remove unused "bitcoinconsenus" feature.
...
Also I've updated the feature name on the README.md, and fixed a typo in
src/blockdata/script.rs
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-12 16:06:06 -04:00
Jean Pierre Dudey
6e99d2d33c
Hidde `From<T>` implementations for error types in Rustdoc.
...
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-12 12:57:59 -04:00
Jean Pierre Dudey
b2594087db
Use the `?` (try) instead of the `try!` macro.
...
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-12 12:47:31 -04:00
Jean Pierre Dudey
77c185d9ec
Fix modules documentation title.
...
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-08 17:38:50 -04:00
Andrew Poelstra
45c699f005
Merge pull request #112 from TheBlueMatt/2018-07-p2wsh-name
...
Clarify to_v0_p2wsh docs a bit further
2018-07-28 18:28:00 +00:00
Matt Corallo
3686cd7201
Clarify to_v0_p2wsh docs a bit further
2018-07-26 15:13:44 -04:00
Savil Srivastava
933dcaeb82
[code hygiene] remove deprecated rustc-serialize
...
Addresses #96 .
Turns out it was being used for hex encoding/decoding, so replaced that with the `hex` crate.
i chose to import the `decode` method as:
```
use hex::decode as hex_decode
```
so that it is clear to the reader what is being decoded when it is called. "decode" is such a generic sounding function name that it would get confusing otherwise.
2018-07-26 09:49:15 -07:00
Carl Dong
db76a63669
Fix to_v0_p2wsh docs
2018-07-25 17:11:27 -07:00
Tamas Blummer
caeadb42be
check if output is OP_RETURN
2018-06-23 14:49:55 +02:00
Igor Aleksanov
14a920ab7d
Added method to convert target from Uint256 to compact form ( #86 )
...
Renamed method for getting compact from u256
Removed unnecessary asserts from convert function
2018-06-12 20:58:25 +02:00
Roman Zeyde
69ea2a760b
Fix 2 small typos in comments
2018-06-09 22:27:40 +03:00
Andrew Poelstra
62d080afc7
Merge pull request #83 from tamasblummer/is_coinbase
...
add is_coin_base
2018-06-04 18:46:03 +00:00
Tamas Blummer
3921899c65
add is_coin_base
...
add data access as copy
2018-06-01 21:39:51 +02:00
Igor Aleksanov
34e228c699
Added regtest
...
Completed regtest integration to the code
Added tests for regtest
Get rid of panics
2018-05-29 12:21:41 +03:00
Roman Zeyde
44d0ad90e9
block: fix a small typo in comment
2018-04-11 12:23:15 +03: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
3793b2859a
Add a Transaction.get_weight() method, check it in fuzzing
2018-04-02 12:23:05 -04:00
Matt Corallo
a33f00621b
Move witness inside of TxIn.
...
This is a rather large breaking API change, but is significantly
more sensible. In the "do not allow internal representation to
represent an invalid state" category, this ensures that witness
cannot have an length other than the number of inputs. Further,
it reduces vec propagation, which may help performance in some
cases by reducing allocs. Fianlly, this just makes more sense (tm).
Witness are a per-input field like the scriptSig, placing them
outside of the TxIn is just where they are serialized, not where
they logically belong.
2018-03-26 10:25:33 -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
21f2baf58e
remove script interpreter
2018-03-09 20:30:11 +00:00
Tamas Blummer
77ce6f18d0
Moved blockchain and patricia_tree to rust-memblocks
2018-03-09 17:22:31 +01:00
Andrew Poelstra
7dcca9157b
Merge branch 'master' into is_on_main_chain_public2
2018-03-09 15:09:21 +00:00
Tamas Blummer
5e510366cf
is_on_main_chain is a very useful function upstream, make it public
2018-03-03 18:15:05 +01:00
Tamas Blummer
50a9d0f51f
add get_best_tip_height to blokchain
2018-02-28 20:24:35 +01:00
Andrew Poelstra
047c0c149d
remove `num` crate dependency
2018-02-18 15:21:13 +00:00
Andrew Poelstra
71bce7b067
Merge pull request #44 from tamasblummer/add_difficulty2
...
Add difficulty calculation
2018-02-18 14:59:36 +00:00
Tamas Blummer
3efe511cc6
add difficulty calculation
2018-02-11 19:58:26 +01:00
Andrew Poelstra
f233fcac61
util: add `bip143` module to create BIP143 signature hashes
2018-01-15 17:54:32 +00:00
Andrew Poelstra
b3644b7b6d
add constants for OP_CLTV and OP_CSV
2017-12-21 01:10:00 +00:00
Andrew Poelstra
406160a386
transaction: add txid() function that does the right thing for segwit/nonsegwit
...
With Segwit transactions `bitcoin_hash()` is no longer sufficient to get a txid.
2017-12-09 19:52:09 +00:00
Andrew Poelstra
c691d0e382
util: add Sha256dEncoder to allow streaming data into a hash
...
This is needed to for a sane BIP143 implementation. Should be exactly equivalent to
serializing data into a vector then hashing that vector for all types.
2017-12-06 16:50:47 +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
c341e21dc6
remove unnecessary `mut` that nightly rustc has learned to detect
2017-10-06 19:56:50 +00:00
Andrew Poelstra
46439710d9
script: add `is_p2pkh()` function
2017-10-06 19:15:30 +00:00
Andrew Poelstra
af10b153be
segwit: add transaction/block serialization support for BIP141/BIP144; bump to 0.8
...
Do not yet support new sighash type
2016-08-24 16:24:55 +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
50b3e90912
Rename Transaction::scripthash to Transaction::signature_hash
...
Yes, this is a major release because I misspelled the name of a function :)
2016-06-13 21:25:47 +00:00
Andrew Poelstra
38b2cacf35
Add support for computing transaction sighashes, which is needed for signing
2016-06-12 18:25:23 +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
35832e3da0
Remove some unused trait imports
2016-05-27 18:36:42 +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
5f308887c9
Fix test added for serde transaction roundtrip
2016-02-18 18:02:04 +00:00
Andrew Poelstra
92c3b2459c
script: fix macro for future rustc changes
2016-02-18 17:56:51 +00:00
Andrew Poelstra
b88d04f0bc
Add serde impls for all Transaction types
...
Bump version number; introduce rust-jsonrpc dependency
2016-02-10 03:37:24 +00:00
Andrew Poelstra
56b7e7d3f4
Add ntxid support
2015-12-21 11:07:37 -06:00
Andrew Poelstra
16f5878a03
Add a bunch of Ord/PartialOrd impls for stuff
2015-12-20 15:38:02 -06:00
Andrew Poelstra
e05e6d2215
[BREAKING CHANGE] Drop UtxoSet
...
This code was unmaintained, is unlikely to work on the majority of systems
(since it holds the whole utxoset in RAM, and not in a terribly efficient
manner), and has a dependency on `eventual` which has been broken for a
long time.
The library no longer compiles on nightly because of this, and without any
known usecases for `UtxoSet`, nor good ability to test it, I'm simply
removing the code.
I recommend anyone who cares about this extracts the code from the previous
commit and creates a new crate. It should be more featureful anyway, e.g.
support a backing store.
2015-12-19 20:13:59 -06:00
Andrew Poelstra
5c69d44397
Add Hash derived impls for all the transaction types
2015-12-19 20:13:59 -06:00
Andrew Poelstra
52b4263539
Remove comment about refcounted pointers; there are no refcounted pointers
2015-12-19 20:13:59 -06:00
Andrew Poelstra
c1993a12c6
Add TxOutRef type to blockdata::transaction; don't use it anywhere in the library itself
...
This is just a convenience type for the (txid, vout) pairs that get produced
a lot in Bitcoin code. To the best of my knowledge there is nowhere this can
be used in the actual library (in particular, TxOutRef.index is a usize for
convenience while TxIn.prev_index is a u32 for correct consensus encoding,
so there is not redundancy here).
2015-12-19 20:13:59 -06: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