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