Steven Roose
5373428510
Drop unused encode::Error::Secp256k1 variant
2019-12-09 14:17:41 +00:00
Steven Roose
725884bab5
Introduce key::Error
2019-12-09 14:17:39 +00:00
Steven Roose
fe3397399e
Add Copy to InvType enum
2019-12-08 20:58:52 +00:00
Steven Roose
671b3173c8
Make internals for CommandString private
...
The From traits and AsRef and Display implementations
let you do all you want.
2019-12-08 20:58:50 +00:00
Steven Roose
83f55b7f1d
Follow Rust std practice for RejectReason enum
2019-12-08 20:58:49 +00:00
Steven Roose
5c84e9671f
Optimize Reject message
2019-12-08 20:58:46 +00:00
Steven Roose
c30d6d12ab
Implement Encodable for Cow<'static, str>
2019-12-08 20:57:46 +00:00
Steven Roose
e37fdb7319
Also have getter for CommandString
2019-12-08 20:57:07 +00:00
Steven Roose
e2eed78964
nit: Reject is implemented
2019-12-08 20:57:05 +00:00
Steven Roose
50a37f415e
Implement From<String> and From<&'static str> for CommandString
2019-12-08 20:57:04 +00:00
Steven Roose
36838b7918
Make network::CommandString a Cow on 'static
2019-12-08 20:57:03 +00:00
Steven Roose
bac3e0308b
Add command method to NetworkMessage
...
Also make the return type an &'static str
2019-12-08 20:57:00 +00:00
Steven Roose
b4c4a9658d
Implement std: #️⃣ :Hash for Inventory
2019-12-08 17:49:11 +00:00
Andrew Poelstra
854718219e
Merge pull request #345 from stevenroose/serviceflags
...
Add ServiceFlags type
2019-12-06 21:31:46 +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
Steven Roose
3e1e4f92b7
Merge pull request #337 from TheBlueMatt/2019-10-less-deps
...
Drop hex and byteorder (non-test) deps (and disable useless lints)
2019-12-06 15:38:58 +00:00
Steven Roose
1edc436f8f
Add an extensive Display implementation for ServiceFlags
2019-12-05 20:13:45 +00:00
Matt Corallo
824d52fe87
Disable useless lints
2019-12-05 10:41:00 -05: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
Matt Corallo
f1f7718b6c
Drop (non-test/serde) hex dep in favor of bitcoin_hashes' fn's
2019-12-05 10:40:59 -05:00
Steven Roose
de18e926c1
Use ServiceFlags type in existing API
2019-12-04 23:28:25 +00:00
Steven Roose
fdf4b2f74e
Add ServiceFlags type
2019-12-04 23:28:23 +00:00
Steven Roose
33ba7eaa36
Nit in VersionMessage documentation
2019-11-19 22:58:49 +00:00
Chris Coverdale
0586ed94c4
Add default trait implementation for TxIn
2019-11-17 16:41:14 +00:00
Matt Corallo
fe917765c0
Drop message decode max length to 4_000_000
...
It has been a long time since Bitcoin's maximum network message
length was 32MB, so we should follow suit. This is also an important
DoS limit, so we should limit it as much as possible.
2019-11-06 16:29:21 -05:00
Carl Dong
242ce14cee
Add reject message ( #323 )
...
Add reject message
2019-09-30 14:52:19 +00:00
Dr. Maxim Orlovsky
4b1d4edc14
Improvements to `StreamReader` ( #318 )
...
* Generalizing StreamReader to support arbitrary data structures
* Using Read trait and adding test cases
2019-09-23 08:31:52 +02:00
practicalswift
0b08978af2
Fix incorrect documentation for is_p2pk(...) ( #331 )
2019-09-21 13:33:44 +02:00
Tamas Blummer
1b0e31c233
fixed typo
2019-09-21 13:31:03 +02:00
Tamas Blummer
960e3da75b
remove #repr on RejectReason
...
and typo fix
2019-09-10 20:11:25 +02:00
Tamas Blummer
c93b1ed8ce
add reverse mapping
2019-09-03 19:59:48 +02:00
Tamas Blummer
3266c192b6
add reject message
2019-08-27 13:42:46 +02:00
Tamas Blummer
38d5ae4e3f
enable serde serialization for block and blockheader
2019-08-24 14:26:18 +02:00
Carl Dong
24361dd2f1
Merge pull request #298 from tamasblummer/upgrade_secp_bitcoinconsensus
...
upgrade to secp256k1 0.15 and bitcoinconsensus 0.17
2019-08-23 14:18:05 -04: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
Tamas Blummer
9f3e355c5c
upgrade to secp256k1 0.15 and bitcoinconsensus 0.17
2019-08-21 19:04:40 +02:00
Elichai Turkel
52ff97cddc
Deny unused imports and remove unneeded
2019-08-19 13:29:43 -04:00
Elichai Turkel
747e9ce75c
Pinned serde version and re-export bech32
2019-08-16 16:08:14 -04:00
Steven Roose
c01172780b
Re-export bitcoin_hashes and secp256k1 dependency
2019-08-16 15:52:58 +01:00
Steven Roose
48f4c1989f
Rename bitcoin_hashes dependency to hashes
2019-08-16 15:52:27 +01:00
Steven Roose
09a65023a2
Add tests for p2shwpkh and p2shwsh
2019-08-15 22:29:09 +01:00
Steven Roose
170abaa82f
Use the new bech32 functions
2019-08-15 22:29:06 +01:00
Steven Roose
3a93f8522c
Format address module
2019-08-15 22:28:46 +01:00
Steven Roose
8de13a3915
Redo the BIP-173 test vectors
...
Before, non-version-zero segwit addresses were not included.
2019-08-15 22:28:27 +01:00
Steven Roose
e469fec839
address: Drop error::Error::description impl
2019-08-15 22:28:25 +01:00
Steven Roose
bfdcfee28e
Add Address::from_script constructor
2019-08-15 22:28:20 +01:00
Steven Roose
33e8ba3c7e
Extract roundtrip method from Address tests
2019-08-13 08:47:17 +01:00
Steven Roose
8804a41f1f
Add AddressType enum
2019-08-13 08:47:15 +01:00
Steven Roose
7e0d997150
Remove unused encode::Error variant
2019-08-13 08:47:13 +01:00
Steven Roose
385a657974
Refactor Address
...
- use AddressError instead of encode::Error
- replace using bech32-bitcoin with Payload::WitnessProgram variant
2019-08-13 08:47:10 +01:00
Andrew Poelstra
cc0f1143dc
Merge pull request #309 from elichai/2019-08-amount-precision
...
Check that the amount precision isn't more than the size of the amount
2019-08-12 17:20:18 +00:00
Riccardo Casatta
7d6687451a
use BTreeMap instead of HashMap to always serialize the same ( #310 )
...
* use BTreeMap instead of HashMap to always serialize the same
* fix rust 1.22 error
* psbt fuzz roundtrip
* psbt fuzz roundtrip on our ser
2019-08-09 17:03:12 +02:00
Tamás Blummer
4ddf6f80b9
Reduce blockfilter memory ( #302 )
...
* use same Error type in all methods of BlockFilter
* reduce Blockfilter memory footprint
* amend the example use
* remove unused constant
2019-08-09 16:58:02 +02:00
Elichai Turkel
a9e65f36d3
Check that the amount precision isn't more than the size of the amount
2019-08-09 10:41:21 -04:00
Elichai Turkel
4a1830c423
Replaced Read trait with a generic over Read ( #307 )
...
Removed tempfile usage from stream_reader
2019-08-07 17:35:22 +02:00
Andrew Poelstra
db8c8b497b
Merge pull request #303 from practicalswift/typos
...
Fix typos
2019-08-05 15:16:17 +00:00
Aleru
40c5a568fa
add TODOs
2019-08-04 22:27:59 -04:00
practicalswift
8152ed758c
Fix typos
2019-08-04 19:27:36 +00:00
Steven Roose
cc2ede7a80
Use `$crate::` prefix for uses in macros
2019-07-29 11:30:35 +02:00
Steven Roose
2c2d55d90a
bip32: Implement hex serialization for Fingerprint and ChainCode
2019-07-26 15:32:33 +02:00
Steven Roose
4530e403e0
Use collect_str instead of serialize_str in serde macros
2019-07-26 15:30:47 +02:00
Steven Roose
fc6415d652
Add human-readable serde for OutPoint as `<txid>:<vout>`
2019-07-26 15:30:46 +02:00
Steven Roose
3c66418f3a
bip32: Add serde for Extended(Priv|Pub)Key
2019-07-26 15:30:44 +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
b6c1266102
Merge pull request #293 from stevenroose/bip143-script-code
...
bip143: Rename witness_script to script_code
2019-07-24 22:43:58 +00:00
Andrew Poelstra
a041168205
Merge pull request #265 from apoelstra/2019-05-enc-dec-cleanup
...
clean up encoding/decoding traits
2019-07-24 19:30:21 +00:00
Tamas Blummer
ff2f5d9ec2
forbid unsafe
2019-07-23 23:29:45 +02:00
Steven Roose
b312c4de6a
bip143: Rename witness_script to script_code
...
For p2wsh the scriptCode is the witness script, but for p2wpkh, it's the
equivalent legacy p2pkh output script.
The name scriptCode is used in the BIP, so it's less confusing.
2019-07-15 17:33:23 +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
87e7ebcf1b
prevent compilation on 16-bit targets so we can use `usize` and assume it is 32 bits
2019-07-11 17:15:33 +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
Andrew Poelstra
24ebc29005
fix some recent rustc warnings
2019-07-11 15:01:38 +00:00
John L. Jegutanis
aae2937d11
Add a MerkleBlock construction
...
This is a port of the bitcoin-core CPartialMerkleTree and CMerkleBlock classes.
Here they are called PartialMerkleTree and MerkleBlock.
These are useful for SPV clients that wish to verify that a transaction is
present in a specific block in an authenticated way.
2019-07-05 20:44:31 +02: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
cded694381
Merge pull request #277 from jonasnick/rand
...
Remove unused rand dependency
2019-07-03 20:42:44 +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
94fba3aa88
Remove unused rand dependency
2019-06-10 13:59:31 +00:00
Jonas Nick
30f24a39d0
Remove confusing mentions of SPV
2019-06-07 13:12:07 +00:00
Matt Corallo
860e74ecb5
Merge pull request #273 from stevenroose/spv-validate
...
Rename BlockHeader::spv_validate to validate_pow
2019-06-07 08:24:47 -04:00
Andrew Poelstra
5d7e6bb7a4
Merge pull request #272 from TheBlueMatt/2019-05-net-cleanups
...
Fix DoS in RawNetworkMessage Deserialization
2019-06-07 11:53:31 +00:00
Andrew Poelstra
a6c1eacd70
Merge pull request #270 from stevenroose/signed-amount
...
Add Amount and SignedAmount
2019-06-07 09:16:02 +00:00
Steven Roose
093d60bf7f
Rename BlockHeader::spv_validate to validate_pow
2019-06-06 10:39:03 +01:00
Matt Corallo
98796576d2
Fix trivial DoS when deserializing messages from the network
2019-06-05 07:49:19 -04:00
Steven Roose
688d95b463
Add Amount and SignedAmount types
2019-05-31 10:18:59 +01:00
Steven Roose
d4282353c9
Two serde quirks from switching dependencies
2019-05-31 10:18:57 +01:00
Matt Corallo
fa1ec2028d
Speed up Vec<u8> [d]e[n]code operations by dropping the generic
2019-05-30 11:25:37 -04:00
Matt Corallo
ee827e4aa3
Drop some unused/not-needed Encodable impls
2019-05-30 11:25:37 -04:00
Matt Corallo
84835f244c
Support sendheaders network message decode
2019-05-30 11:25:37 -04:00
Matt Corallo
084f82be21
Swap a few more [d]encoders to slice emit/read functions
2019-05-30 11:25:37 -04:00
Matt Corallo
7015b064dd
Add slice consensus encode/decode functions and use for short arrays
2019-05-30 11:25:37 -04:00
Andrew Poelstra
4139f2a1ca
Merge pull request #258 from shesek/signed-msg-hash
...
Implement util::misc::signed_msg_hash()
2019-05-30 14:35:57 +00: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
Steven Roose
bb8520268e
bip32: Add DerivationPathIterator and related methods
...
Adds methods
- ChildNumber::increment
- DerivationPath::children_from
- DerivationPath::normal_children
- DerivationPath::hardened_children
2019-05-03 17:58:09 +01:00
Nadav Ivgi
473b491409
Implement util::misc::signed_msg_hash()
2019-04-28 09:01:42 +03:00
Andrew Poelstra
dc6189dbb2
contracthash: more cleanups
2019-03-21 21:27:26 +00:00
Andrew Poelstra
01a3a9263c
contracthash: use `PublicKey` and `PrivateKey` types; minor cleanups
2019-03-21 21:27:26 +00:00
Andrew Poelstra
3700d100eb
contracthash: add fixed test vector
2019-03-21 21:27:26 +00:00
Andrew Poelstra
9daf7fa9dc
util::key add serde de/serialization
2019-03-21 18:27:42 +00:00
Steven Roose
459059622f
util: 🔑 Provide to_bytes() methods for key types
...
These are mainly utility methods around the existing way to serialize
the key types.
2019-03-05 16:07:52 +00: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
Andrew Poelstra
4dbf431ecd
key: implement ToString and FromStr for PublicKey
2019-03-04 01:06:19 +00:00
Carl Dong
e5b59120c5
Add copyright notice to PSBT-related files
2019-02-28 11:11:55 -05:00
Carl Dong
bc73b315cb
Add test vectors from BIP174 specification
...
- Add macro for decoding and unwrapping PartiallySignedTransaction from
hex string
2019-02-28 11:11:55 -05:00
Carl Dong
39fd567b56
Add Partially Signed Transaction type
...
- Add merging logic for PartiallySignedTransactions
- Add (en)decoding logic for PartiallySignedTransaction
- Add converting constructor logic from Transaction for
PartiallySignedTransaction
- Add extracting constructor logic from PartiallySignedTransaction for
Transaction
Squashed in fixes from stevenroose <stevenroose@gmail.com>
- Prevent PSBT::extract_tx from panicking
- Make PartiallySignedTransaction fields public
2019-02-28 11:11:55 -05:00
Carl Dong
badb0f2a77
Add PSBT input data key-value map type
...
- Implement psbt::Map trait for psbt::Input
- Add (en)decoding logic for psbt::Input
- Implement PSBT (de)serialization trait for relevant psbt::Input types
2019-02-28 11:11:55 -05:00
Carl Dong
9c08dbae47
Add PSBT output data key-value map type
...
- Implement psbt::Map trait for psbt::Output
- Add (en)decoding logic for psbt::Output
- Implement PSBT (de)serialization trait for relevant psbt::Output types
- Add macro for merging fields for PSBT key-value maps
- Add macro for implementing decoding logic for PSBT key-value maps
- Add convenience macro for implementing both encoding and decoding
logic for PSBT key-value maps
- Add macro for inserting raw PSBT key-value pairs into PSBT key-value
maps
- Add macro for getting raw PSBT key-value pairs from PSBT key-value
maps
2019-02-28 10:54:53 -05:00
Carl Dong
115f8c043c
Add PSBT global data key-value map type
...
- Implement psbt::Map trait for psbt::Global
- Add converting constructor logic from Transaction for psbt::Global
- Add (en)decoding logic for psbt::Global
- Always deserialize unsigned_tx as non-witness
- Add trait for PSBT (de)serialization
- Implement PSBT (de)serialization trait for relevant psbt::Global types
- Add macros for consensus::encode-backed PSBT (de)serialization
implementations
- Add macro for implementing encoding logic for PSBT key-value maps
2019-02-28 10:54:53 -05:00
Carl Dong
2715a6e777
Add trait for PSBT key-value maps
2019-02-28 10:54:53 -05:00
Carl Dong
528e39334c
Add data types for raw PSBT key-value pairs
...
- Add (en)decoding logic for said data types
2019-02-28 10:54:53 -05:00
Carl Dong
4fa39c4a3e
Add PSBT-specific Error data type
...
- Implement psbt::Error data type
- Implement conversion from psbt::Error to util::Error
- Create util::psbt module
- Create non-public util::psbt::error module
2019-02-28 10:54:53 -05:00
Andrew Poelstra
919bbeae4a
Merge pull request #238 from apoelstra/2019-02-bip32-keys
...
Replace `secp256k1` keys with `util::key` keys in BIP32
2019-02-28 13:42:50 +00:00
Andrew Poelstra
4f74ae61c4
bip32: replace rust-secp key types with rust-bitcoin key types
...
We continue to support only compressed keys when doing key derivation,
but de/serialization of uncompressed keys will now work, and it will
be easier/more consistent to implement PSBT on top of this.
2019-02-27 22:21:40 +00:00
Dr. Maxim Orlovsky
3c21e301aa
Better RawNewtorkMessage deserealization from IO stream ( #231 )
...
Follow-up to https://github.com/rust-bitcoin/rust-bitcoin/pull/229
While working with remote peers over the network it is required to deserealize RawNetworkMessage from `TCPStream` to read the incoming messages. These messages can be partial – or one TCP packet can contain few of them. To make the library usable for such use cases, I have implemented the required functionality and covered it with unit tests.
Sample usage:
```rust
fn run() -> Result<(), Error> {
// Opening stream to the remote bitcoind peer
let mut stream = TcpStream::connect(SocketAddr::from(([37, 187, 0, 47], 8333));
let start = SystemTime::now();
// Constructing and sending `version` message to get some messages back from the remote peer
let since_the_epoch = start.duration_since(UNIX_EPOCH)
.expect("Time went backwards");
let version_msg = message::RawNetworkMessage {
magic: constants::Network::Bitcoin.magic(),
payload: message::NetworkMessage::Version(message_network::VersionMessage::new(
0,
since_the_epoch.as_secs() as i64,
address::Address::new(receiver, 0),
address::Address::new(receiver, 0),
0,
String::from("macx0r"),
0
))
};
stream.write(encode::serialize(&version_msg).as_slice())?;
// Receiving incoming messages
let mut buffer = vec![];
loop {
let result = StreamReader::new(&mut stream, None).read_messages();
if let Err(err) = result {
stream.shutdown(Shutdown::Both)?;
return Err(Error::DataError(err))
}
for msg in result.unwrap() {
println!("Received message: {:?}", msg.payload);
}
}
}
```
Sample output is the following:
```
Received message: Version(VersionMessage { version: 70015, services: 1037, timestamp: 1548637162, receiver: Address {services: 0, address: [0, 0, 0, 0, 0, 65535, 23536, 35968], port: 33716}, sender: Address {services: 1037, address: [0, 0, 0, 0, 0, 0, 0, 0], port: 0}, nonce: 1370726880972892633, user_agent: "/Satoshi:0.17.99/", start_height: 560412, relay: true })
Received message: Verack
Received message: Alert([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 127, 0, 0, 0, 0, 255, 255, 255, 127, 254, 255, 255, 127, 1, 255, 255, 255, 127, 0, 0, 0, 0, 255, 255, 255, 127, 0, 255, 255, 255, 127, 0, 47, 85, 82, 71, 69, 78, 84, 58, 32, 65, 108, 101, 114, 116, 32, 107, 101, 121, 32, 99, 111, 109, 112, 114, 111, 109, 105, 115, 101, 100, 44, 32, 117, 112, 103, 114, 97, 100, 101, 32, 114, 101, 113, 117, 105, 114, 101, 100, 0])
```
Working sample code can be found here: https://github.com/dr-orlovsky/bitcoinbigdata-netlistener
2019-02-27 16:41:28 -05:00
Andrew Poelstra
fc47c477ab
key: add some missing functionality
2019-02-27 01:56:38 +00:00
Carl Dong
4bf99e79f8
Merge pull request #236 from dongcarl/2019-02-remove-unused-option-decoding
...
Remove unused Option en/decoding
2019-02-22 10:14:37 -05:00
Carl Dong
04c7f2071d
Merge pull request #235 from dongcarl/2019-02-remove-extraneous-params-clone
...
Remove extraneous clones in consensus::params
2019-02-21 17:41:08 -05:00
Carl Dong
1ad1c11649
Forbid unsafe code
2019-02-20 17:16:21 -05:00
Carl Dong
17c0f4e784
Remove unused Option en/decoding
2019-02-20 17:08:36 -05:00
Carl Dong
2f70c3bc34
Remove extraneous clones in consensus::params
2019-02-20 15:47:31 -05: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
d5331e59ed
Merge pull request #233 from stevenroose/derivation-path
...
bip32: Add DerivationPath type
2019-02-15 09:52:59 -05:00
Steven Roose
dce81b623e
bip32: Add additional methods and traits to DerivationPath
...
- From<&[ChildNumber]> (cloning)
- AsRef<[ChildNumber]>
- std::iter::FromIterator<ChildNumber>
- std::iter::IntoIterator<ChildNumber>
- std::ops::Index (returning &[ChildNumber])
Also add two methods:
- child(&self, ChildNumber) -> DerivationPath
- into_child(self, ChildNumber) -> DerivationPath
2019-02-14 11:16:06 +00:00
Steven Roose
1373969805
bip32: Change test vectors to use DerivationPath
2019-02-14 11:09:39 +00:00
Steven Roose
b23de17d55
bip32: Introduce DerivationPath type
...
Implements Display and FromStr for easy usage with serialized types.
2019-02-14 11:09:34 +00:00
Steven Roose
a80cea270a
bip32: ChildNumber constructors return Result
...
They can produce an error if the index is out of range.
2019-02-14 11:08:13 +00: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
Carl Dong
a944c7fbd0
key: Use correct error for decoding
...
This change also moves the secp256k1::Error wrapper from util::Error to
consensus::encode::Error, since we do not use it anywhere else. We can
add it back to util::Error once we have instances of secp256k1::Error
that are not related to consensus::encode.
2019-02-11 15:15:03 -05:00
Carl Dong
fc448ba47c
key: Reword and clarify comments
2019-02-11 15:10:20 -05:00
Carl Dong
b3cc3d50ef
Integrate newly-added PublicKey with Address
...
- Switch util::address::Payload::Pubkey variant to wrap
util:🔑 :PublicKey
- Switch util::address::Address::p*k* constructors to use
util:🔑 :PublicKey
- Fix tests for aforementioned switch
- Add convenience methods for util:🔑 :PublicKey to
util:🔑 :PrivateKey conversion
- Switch BIP143 tests to use util:🔑 :PublicKey
2019-02-11 15:10:13 -05:00
Carl Dong
53a6efe33c
Add PublicKey struct encapsulating compressedness
...
- Move util::privkey to util::key
- Add PublicKey struct to util::key
- Implement de/serialization methods for util:🔑 :PublicKey
2019-02-11 14:56:55 -05:00
Carl Dong
60c93c387f
Cleanup util::privkey in preparation for PublicKey
...
- Rename privkey::PrivKey to privkey::PrivateKey
- Remove unnecessary methods for privkey::PrivateKey
- Modify tests to work with above changes
2019-02-11 14:56:49 -05:00
Tamás Blummer
1cd2782122
add BIP157 (Client Side Block Filtering) Messages ( #225 )
...
* add BIP57 (Client Side Block Filtering) Messages
* rabased after https://github.com/rust-bitcoin/rust-bitcoin/pull/215
2019-02-08 13:00:51 +01:00
Steven Roose
f80e882813
Remove Address::p2pk
...
There is no address format for p2pk.
2019-02-07 20:02:21 +00: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
ca72a04dd4
Remove rust-crypto dependency
...
We no longer need rust-crypto after integrating bitcoin_hashes.
2019-01-24 16:27:52 -05:00
Carl Dong
1bbeda87eb
Remove fuzz_util module
...
Not needed anymore as the bitcoin_hashes crate handles this.
2019-01-24 16:27:52 -05:00
Carl Dong
96f9c62b0e
Remove unused internal macro
2019-01-24 16:27:52 -05:00
Carl Dong
c830fb4629
Remove code deprecated by bitcoin_hashes from util::hash
2019-01-24 16:27:52 -05: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
Carl Dong
45aa709467
Implement En/Decodable for sha256d::Hash
2019-01-24 11:31:07 -05:00
Carl Dong
b88f00c698
Add bitcoin_hashes dependency, rename some features
...
Because features and dependencies share the same namespace, and we want
to pass down the optional dependence on serde to bitcoin_hashes, we need
to rename the feature to something other than serde. Right now only
features can be passed down to dependencies.
Note that we could have also renamed the dependency to something like
serde-dep and kept the same feature name, however, dependency renaming
has only been available since cargo 0.27.0
Features that represent optional dependencies have been prefixed with
'use-'. The travis file has also been modified to conform to this
change.
2019-01-24 11:31:07 -05:00
Carl Dong
b6ec6a0d62
Merge pull request #212 from TheBlueMatt/2019-01-travis-nightly-bench
...
Run cargo bench on rustc nightly in travis
2019-01-23 19:25:44 -05:00
Dimitris Apostolou
132ca5ea95
Fix typos
2019-01-23 14:17:29 -05:00
Tamas Blummer
96be35b1d3
it is annoying to have a difference between debug and print for hash
2019-01-23 14:14:29 -05:00
Matt Corallo
0d7e13b034
Run cargo bench on rustc nightly in travis, remote useless move
2019-01-15 14:06:24 -05:00
Matt Corallo
2ed4b1f246
Merge pull request #208 from sgeisler/hex_bytes
...
Use more performant hex_bytes function
2019-01-15 14:06:00 -05:00
Carl Dong
ff5c4a1806
Bump secp to 0.12
2019-01-15 12:58:54 -05:00
Carl Dong
b2e044f9db
Internalize unnecessarily exported macros
2019-01-15 11:53:31 -05:00
Antoine Riard
96c66292c8
Fix comment on transaction version
2019-01-10 18:29:50 -08:00
Sebastian Geisler
4c29fc0e8d
Add feature gated hex decode benchmark
2019-01-07 17:49:55 -08:00
Sebastian Geisler
7c7ec02ed2
Remove unused Pair iterator and util::iter module
2019-01-03 17:28:36 -08:00
Sebastian Geisler
c6a41651ab
Replace slow hex decoding function with optimized version
...
Fixes #207 .
2019-01-03 17:28:32 -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
bb7ca63776
Merge pull request #196 from sgeisler/separate-fuzzing
...
Move fuzzing code out of utils
2018-12-09 16:33:21 +00: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
Sebastian Geisler
e88612d617
add test case and cleanup
2018-12-03 14:51:55 -08:00
Sebastian Geisler
4a27c1369a
avoid heap use when encoding base58
2018-12-03 14:51:53 -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
Andrew Poelstra
c2146e1bbc
Merge pull request #181 from stevenroose/export-network
...
Export network::constants::Network
2018-10-23 16:18:30 +00:00
Andrew Poelstra
7813c0ae3d
Merge pull request #178 from stevenroose/wif
...
Add explicit WIF methods for Privkey
2018-10-22 15:28:09 +00:00
Steven Roose
5f912bdeae
Implement Debug for PrivKey
...
It returns a fixed string to prevent accidental data leakage.
2018-10-22 00:06:46 +01:00
Steven Roose
f7b95c7533
Add explicit WIF methods for Privkey
2018-10-22 00:05:59 +01:00
Steven Roose
6f4bfe68f3
Export network::constants::Network
2018-10-21 23:28:27 +01:00
Andrew Poelstra
0764673c38
Merge pull request #177 from stevenroose/outpoint-fromstr
...
Implement FromStr for OutPoint
2018-10-18 23:12:47 +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
Jeff Barg
1c2564fc08
Added example for creating an address from a public key
...
Added an example to the address rustdoc (addresses https://github.com/rust-bitcoin/rust-bitcoin/issues/160 )
2018-09-29 17:43:28 -04:00
evgeniy.scherbina
bc41772f89
added p2wkh, p2sh-p2wkh tests
2018-09-27 18:54:20 +03:00
Andrew Poelstra
98e39b4383
transaction: make 0-input de/serialization always use Segwit
2018-09-27 13:50:35 +00:00
Carl Dong
c42252c1da
Use default impl for Encoder for Sha256dEncoder
2018-09-25 21:20:24 +08: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
Carl Dong
97937b1b5f
Move network::consensus_params to consensus::params
2018-09-25 21:13:34 +08:00
Carl Dong
7e9d393d03
Remove low-level networking support
...
- Modify VersionMessage constructor to take in parameters directly that
would have otherwise been extracted from a Socket (now removed)
2018-09-25 21:13:34 +08:00
Carl Dong
7f11766c65
Remove nu_select macro
2018-09-25 21:13:34 +08:00
Thomas Eizinger
50e3a4abf2
Add FromStr for Sha256dHash
...
The FromStr implementation just delegates to the `from_hex` method for
the actual parsing.
2018-09-20 12:18:45 +10:00
Steven Roose
8edfbec1cb
Implement serde serialiation for Address
2018-09-11 18:37:36 +01:00
Andrew Poelstra
849674651f
Merge pull request #157 from rust-bitcoin/2018-08-pub-use
...
`pub use` a ton of stuff at the top level
2018-08-28 17:13:40 +00:00
Andrew Poelstra
97c1773ec9
`pub use` a ton of stuff at the top level
2018-08-28 15:57:46 +00: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
ef642295c5
encodable: reject non-compact VarInts on Vec and Box<[T]> lengths
2018-08-24 20:31:46 +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
Andrew Poelstra
dbefaef25c
Merge pull request #142 from jeandudey/2018-08-decimal-fromstr
...
Implement `FromStr` for `UDecimal`/`Decimal`.
2018-08-22 19:00:02 +00:00
Jean Pierre Dudey
9cdc75a930
Forbid exponents larger than 18.
...
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-22 14:00:30 -04:00
Jean Pierre Dudey
6902bf826c
Fix negative symbol bug in `FromStr` display implementation.
...
The negative symbol wasn't there when `int_part` was equal to zero.
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-22 11:26:05 -04:00
Jean Pierre Dudey
a915bc194d
Fix multiplication logic in decimal parsing functions.
...
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-22 07:22:47 -04:00
Jean Pierre Dudey
e48e559740
Fix `UDecimal::parse_udecimal` identation.
...
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-21 21:31:02 -04:00
Jean Pierre Dudey
455bc66d3c
Fix parsing for numbers that are too big to fit in a `Decimal`/`UDecimal`.
...
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-21 21:29:07 -04:00
Andrew Poelstra
a61ad5d382
Merge pull request #137 from dongcarl/2018-8-better-errors
...
Fix Error type for SimpleDecoder and SimpleEncoder
2018-08-22 00:55:54 +00:00
Jean Pierre Dudey
07838568f9
Implement `FromStr` for `Decimal`/`UDecimal`.
...
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-21 16:13:58 -04:00
Andrew Poelstra
d16fdd63d3
Merge pull request #141 from jeandudey/2018-08-display
...
Implement `Display` instead of `ToString` for `Address` and `PrivKey`.
2018-08-21 16:41:58 +00:00
Carl Dong
bccdd06794
Replace catch-all match arms with specific ones
2018-08-21 01:58:40 -07: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
d12a861f85
Remove unnecessary network::Error::Detail variant
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
df7f084e96
Implement `Display` instead of `ToString` for `Address` and `PrivKey`.
...
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-20 19:46:56 -04:00
Andrew Poelstra
77e2fe3dda
Merge pull request #144 from jeandudey/2018-08-address-starts-with
...
trivial: Use `str::starts_with` method to check bech32 address prefixes.
2018-08-20 23:12:03 +00:00
Jean Pierre Dudey
b78d7a7428
Use `str::starts_with` method to check bech32 address prefixes.
...
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-20 18:11:14 -04: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
Andrew Poelstra
94f3d4b0f9
update to secp256k1 0.10.0
2018-08-20 15:28:43 +00:00
Andrew Poelstra
85ddb66be0
Merge pull request #138 from dongcarl/2018-8-usize-fix
...
Fix compilation warning when comparing usize and u64 on 32-bit arch
2018-08-20 14:11:26 +00:00
Aleksei
356d13e465
Add some useful standard trait implementations
2018-08-20 12:11:17 +03: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
Roman Zeyde
fdbccf055d
Remove variable shadowing in listener.rs
2018-08-15 09:43:35 +03:00
Carl Dong
70203831d6
Make deserialize error if input bytes not consumed
...
- Adjust tests in encodable.rs to account for this change
2018-08-14 16:50:33 -07:00
Carl Dong
60577f286d
Add derive_* methods to Extended*Key
...
- Add derive_pub to ExtendedPubKey
- Add derive_priv to ExtendedPrivKey
- Removed from_path from ExtendedPrivKey as it is superseded by
derive_priv
- Add checking of derive_pub and derive_priv to test_path
- Add checking of correct error when invoking ckd_pub on a hardened
ChildNumber
- Add test vector 3 from BIP32 specification
2018-08-12 17:16:33 -07: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
Andrew Poelstra
24c0f1a3fc
Merge pull request #118 from jeandudey/2018-08-08-bip32-tostring
...
Implement `Display` trait instead of implementing `ToString` directly.
2018-08-12 13:48:39 +00:00
Carl Dong
c485a74c09
Add helper methods is_normal, is_hardened
...
- Fix documentation links
2018-08-11 13:29:10 -07:00
Carl Dong
4a5bf52ed9
Improve consistency for bip32::ChildNumber
...
There seemed to be some confusion as to whether the internal
represenation of a ChildNumber is supposed to be the index (0..2^31-1
for _both_ Normal and Hardened) or the actual number (0..2^31-1 for
Normal and 2^31..2^32-1 for Hardened). This commits fixes this
confusion.
- Make clear that the internal representation is the index rather
than the actual number
- Make the internal representation non-public
- Provide methods for creating valid ChildNumbers
- Change relevant callers and tests to conform to this new ChildNumber
My rationale for using index rather than the actual number as internal
representation is that the difference between the two enum variants
already encode wether a ChildNumber is a normal one or a hardened one,
so the only bit of extra information left to be encoded is its index.
2018-08-11 12:46:46 -07:00
Andrew Poelstra
ebe5133d1a
Merge pull request #110 from D4nte/regtest
...
Regtest bech32 address support
2018-08-11 17:21:12 +00:00
Andrew Poelstra
259c5902f1
Merge pull request #116 from jeandudey/2018-08-08-module-docs
...
Fix modules documentation title.
2018-08-11 17:12:50 +00:00
Andrew Poelstra
ee9802d813
Merge pull request #120 from dpc/from_secret_key-doc-fix
...
Simple doc fix for `from_secret_key`
2018-08-11 17:05:29 +00:00
Andrew Poelstra
e17c280e4f
Merge pull request #121 from jeandudey/2018-08-10-network
...
Refactor and add more documentation for the `Network` type.
2018-08-11 16:52:52 +00:00
Carl Dong
d4f28b6785
Add conversion between u32 and ChildNumber, fix docs
2018-08-10 13:49:45 -07:00
Jean Pierre Dudey
7ecb6b9dea
Refactor and add more documentation for the `Network` type.
...
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-10 14:56:19 -04:00
Dawid Ciężarkiewicz
1646a80f77
Simple doc fix for `from_secret_key`
2018-08-09 15:41:48 -07:00
Jean Pierre Dudey
0225b530cc
Implement `Display` trait instead of implementing `ToString` directly.
...
ExtendedPubKey and ExtendedPrivKey implemented `ToString` directly but
Rust documentation says to implement `Display` and get the `ToString`
implementation for free.
Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-08-08 19:11:16 -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
Franck Royer
f05f831569
Regtest has a longer hrp, need to adjust length safety check
2018-07-26 17:06:35 +10:00
Franck Royer
0f31608796
Add support for bech32 regtest address format
2018-07-26 10:51:37 +10:00
Franck Royer
ba2879cfac
Add test for regtest network
2018-07-26 10:51:15 +10:00
Carl Dong
db76a63669
Fix to_v0_p2wsh docs
2018-07-25 17:11:27 -07:00
Sebastian Geisler
00cca03edd
use bitcoin-bech32 v0.8.0 and adapt internal API usage
2018-07-25 21:09:46 +02:00
Tamas Blummer
caeadb42be
check if output is OP_RETURN
2018-06-23 14:49:55 +02:00
Igor Aleksanov
2ff5f8e51e
Added module with consensus parameters ( #93 )
2018-06-23 10:23:34 +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
Andrew Poelstra
dd176b4177
Merge pull request #84 from popzxc/add-regtest
...
Added regtest network
2018-06-04 18:42:05 +00:00
Andrew Poelstra
fb0c782df6
Merge pull request #89 from tamasblummer/wittness_block
...
add witness inv types
2018-06-04 18:34:28 +00:00
Andrew Poelstra
33261c7a12
Merge pull request #91 from TheBlueMatt/master
...
Check in fuzz inputs for all current targets
2018-06-04 18:32:19 +00:00
Matt Corallo
e2403a37fa
Don't try to do a base58 checksum if an address is excessively long
2018-06-04 10:23:55 -04:00
Matt Corallo
dab2f0b6b6
Switch fuzztarget SHA256 to simply XOR'ing all input bytes
2018-06-04 10:23:26 -04:00
Tamás Blummer
47b2364554
Merge branch 'master' into wittness_block
2018-06-04 04:24:51 +02:00
Matt Corallo
b78ab0f60b
Expose merkleroot(Vec<Sha256dHash>) publicly
...
In a project of mine I needed to check the merkle root before
moving some Vec<Transaction>s around, so need to be able to
calculate the merkle root on a Vec<Sha256dHash> directly.
2018-06-01 18:50:31 -04:00
Tamas Blummer
3921899c65
add is_coin_base
...
add data access as copy
2018-06-01 21:39:51 +02:00
Igor Aleksanov
97908ea058
Merge branch 'master' into add-regtest
2018-05-29 12:21:56 +03: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
Igor Aleksanov
881972b2a5
Fix multiplication for uint256 ( #88 )
2018-05-28 20:41:07 +02:00
Tamas Blummer
9f2d737045
add witness inv types
2018-05-28 15:24:35 +02:00
Tamás Blummer
cf4024beb4
Merge branch 'master' into hotfix-network-from-str-err
2018-05-20 11:32:19 +02:00
Andrew Poelstra
ab96df162a
Merge branch 'master' into data-method-in-impl-array-newtype
2018-05-19 17:29:53 +00:00
Aleksey Sidorov
5771841144
Replace serde error with the io error.
2018-05-18 12:08:11 +03:00
Igor Aleksanov
13f1fe1f08
Merge branch 'master' into data-method-in-impl-array-newtype
2018-05-17 19:07:08 +03:00
Andrew Poelstra
cc23f09b10
Merge branch 'master' into improve-network-constant
2018-05-17 15:00:35 +00:00
Igor Aleksanov
582afb1611
Added impl display for uint
2018-05-16 13:13:48 +03:00
Igor Aleksanov
539a74de12
Added test for Sha256dHash::data()
2018-05-16 12:44:30 +03:00
Igor Aleksanov
5df8893ea1
Macro impl_array_newtype now generates method for representing data as array
2018-05-16 12:34:36 +03:00
Aleksei Sidorov
3224cf2b18
Implement `FromStr` for Network constant
2018-05-16 12:22:07 +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
0e1d927b47
Only provide the required TxIn to bip143 sighash_all.
...
This resolves an very unergonomic API by allowing iteration over a
Transaction being signed's inputs without needing to take a
conflicting reference to the transaction.
The API is still relateively unsafe in that its very easy to
generate bogus sighashes with it, but this is much better than it
was, and its not clear how to fix it further.
2018-04-02 12:42:59 -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
f859dc8b26
Expose VarInt's encoded length
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
Tamas Blummer
ae708447a2
create Address message with SocketAddr, get SocketAddr from Address message.
2018-03-23 15:12:06 +01:00
Matt Corallo
855b377d51
Fix crash in Address::from_str if input isn't long enough
2018-03-21 18:44:10 -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
Andrew Poelstra
64987e349c
minor nits to get compilation to work on rustc 1.14 (currently shipping Debian version)
2018-03-21 18:49:46 +00:00
Tamas Blummer
1a87244b2b
Implement Segwit addresses
2018-03-20 18:26:51 +01:00
Andrew Poelstra
65d8df08b8
address: implement Bech32 support
2018-03-13 14:48:01 +00:00
Andrew Poelstra
9884bec577
add docs indicating change in Sha256dHash debug output
2018-03-12 21:50:35 +00:00
Andrew Poelstra
8968b081ca
util: add Debug output for Sha256d and Hash160 which don't reverse the bytes
2018-03-12 21:27:09 +00:00
Andrew Poelstra
ee1dfcf4a2
base58: remove Base58 traits, replace with encode/decode functions
2018-03-12 21:27:07 +00: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
Tamás Blummer
e530aa98c9
Merge branch 'master' into is_on_main_chain_public2
2018-03-09 16:03:06 +01:00
Andrew Poelstra
ab72eabd59
Merge branch 'master' into get_tip_height
2018-03-09 15:01:15 +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
3351f35583
add documentation
2018-02-28 20:27:52 +01:00
Tamas Blummer
50a9d0f51f
add get_best_tip_height to blokchain
2018-02-28 20:24:35 +01:00
Tamas Blummer
f1503866d7
RawNetworkMessage::command should be public. no harm and useful for debug messages.
2018-02-28 10:42:23 +01:00
Andrew Poelstra
066c49305f
update secp256k1 to latest version with minimized dependencies
2018-02-20 16:19:29 +00:00
Andrew Poelstra
23a2c6bc9a
remove `jsonrpc` dependency by copying the macro we need into the source
2018-02-18 15:28:39 +00:00
Andrew Poelstra
047c0c149d
remove `num` crate dependency
2018-02-18 15:21:13 +00:00
Andrew Poelstra
9562d8afac
Merge pull request #41 from tamasblummer/minimal_alert_message
...
minimal implementation of alert message
2018-02-18 15:00:55 +00:00
Andrew Poelstra
71bce7b067
Merge pull request #44 from tamasblummer/add_difficulty2
...
Add difficulty calculation
2018-02-18 14:59:36 +00:00
Andrew Poelstra
91a786d22c
Merge pull request #42 from tamasblummer/add_low_u64
...
add low_u64 to Uint256 and Uit128 types
2018-02-18 14:57:37 +00:00
Andrew Poelstra
3547d27430
Merge pull request #40 from tamasblummer/unit_debug_fix
...
fixing debug output for Uint256 and Uint128
2018-02-18 14:57:00 +00:00
Andrew Poelstra
7930d14124
Merge pull request #38 from apoelstra/bip143
...
util: add `bip143` module to create BIP143 signature hashes
2018-02-16 22:13:55 +00:00
Andrew Poelstra
9f092a6f31
remove all use of mem::uninitialized and mem::copy_nonoverlapping
2018-02-14 16:53:49 +00:00
Matt Corallo
9052f3b5a2
Fix argument to copy_nonoverlapping in internal_macros
...
This resolves a segfault due to unsafe code.
2018-02-13 19:08:10 -05:00
Tamas Blummer
3efe511cc6
add difficulty calculation
2018-02-11 19:58:26 +01:00
Tamas Blummer
19f96fe62c
add low_u64 to Uint256 and Uit128 types
2018-02-11 14:19:58 +01:00
Tamas Blummer
9fbe941621
minimal implementation of alert message
2018-02-11 14:08:33 +01:00
Tamas Blummer
e05f45beb0
fixing debug output for Uint256 and Uint128
2018-02-11 14:04:35 +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
8f7bd858fb
update byteorder to 1.1 from 0.3
2017-07-28 16:19:44 +00:00
Andrew Poelstra
2e7be81ea4
add unit test for overflow panic
2017-06-07 16:09:40 +00:00
Daniel Lockyer
a74efe6f8c
Sanity checks for vector length
2017-06-05 18:06:30 +01:00
Andrew Poelstra
cdb452f79f
Sanity-check vector length when deserializing
2017-04-17 00:54:38 +00:00
Andrew Poelstra
4b73c3223c
Merge pull request #18 from rotwatsb/GetAddr
...
Add GetAddr message
2016-10-12 11:26:48 +00:00
Steve Bradley
f7fed8339d
Add GetAddr message
2016-10-10 11:14:12 -04:00
Andrew Poelstra
02718be82f
Remove unused `num_cpus` dep
2016-10-10 13:09:40 +00:00
Andrew Poelstra
e3c793f702
uint: bugfix in trailing_zeroes()
2016-08-26 16:20:26 +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
Demur Rumed
5dda3e2602
Replace time with std::time
2016-07-17 04:02:57 +00:00
Andrew Poelstra
93f103bdb5
script: fix broken push_int in script::Builder
2016-07-14 15:15:34 +00:00
Andrew Poelstra
9d2826d5d1
bip32: error API cleanups
2016-06-24 19:45:42 +00:00
Andrew Poelstra
f7d4ae8265
bip32: add accessor for the tweak used in public key derivation
2016-06-24 19:25:47 +00:00
Andrew Poelstra
14af175a11
Resurrect BIP32 support
2016-06-24 19:15:57 +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
1dbd1c28dc
Implement stdlib Error trait for util::Error type
2016-06-20 01:25:54 +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
46681bbcac
contracthash: expose key tweak in new function
...
Needed for applications where the tweak and the secret key material are on different
devices (and the one with the secret material does not want to know how to compute
the tweak itself).
2016-06-10 18:36:15 +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
96b4b050fd
Serialize Sha256Hash without allocations
2016-05-03 20:16:30 +00:00
Andrew Poelstra
f906c2fddd
Add `first_push_as_number` function to contracthash templates
...
This is a bit of a hack to let users of the contracthash API to determine
how many sigs are required when signing a multisig contract.
2016-03-29 17:24:34 +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
45ef239a34
Add unsigned Decimal type
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
Nicholas Alan Cardin
e72e01dfa3
Fix decoding of Pong message
2015-12-17 23:47:40 -05:00
Andrew Poelstra
a7c2dc6bb6
Add some accessors to the `Privkey` structure
2015-12-02 10:58:18 -06:00
Andrew Poelstra
1bbd492da6
Add nonnegative() utility function to Decimal
2015-11-30 14:23:15 -06:00
Andrew Poelstra
2962eb9d44
Add Display impl for Decimal
2015-11-30 14:08:45 -06:00
Andrew Poelstra
a9cd31ccba
Add addition and subtraction impls to Decimal
2015-11-30 14:03:57 -06:00
Andrew Poelstra
21ccd713ba
Add helper from_hex() function for Sha256dHash
2015-11-30 11:03:04 -06:00
Andrew Poelstra
950e756316
Add formatters for Sha256dHash
2015-11-30 09:19:53 -06:00
Andrew Poelstra
76729f33ca
Fix `Decimal` serialization of negative numbers
2015-11-30 09:13:48 -06:00
Andrew Poelstra
a8ffce4904
Fix Script de/serialization (version -> 0.4.4)
2015-11-30 07:11:24 -06:00
Julius Naperkowski
8c707c5bef
Added support for mempool messages
2015-11-23 00:58:09 +01:00
Andrew Poelstra
e58f536c31
Add `Decimal` type for de/serializing values
2015-11-22 10:51:19 -06:00
Andrew Poelstra
c3c6983789
Replace serde_json with strason in tests
2015-11-22 09:46:05 -06:00
Wladimir J. van der Laan
404176a5ee
Fix data leak in CommandString::consensus_encode
...
A fixed buffer of 12 bytes was unsafely copied from the bytes of a
string - if the string was shorter than that, memory from outside would
leak into the packet.
Replace the unsafe copy by a safe loop. Also add a panic if
an attempt is made to use a command string longer than 12 bytes.
2015-11-08 01:14:10 +01: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
34edf48b93
Implement Error for base58 error type
2015-10-25 10:16:05 -05:00
Andrew Poelstra
3491c5057e
Make contracthashtool check that the number of keys matches the template's requirement
...
This is easy to satisfy given that the template-to-script code takes a
slice of keys. Just do &keys[..n_keys] if you have too many keys. (If
you have too few you're SOL no matter what.) This way we can catch
likely configuration errors without putting much of a burden on users
who legitimately have more keys than the template requires.
Also add a method required_keys() to Template so that users can check
how many keys they ought to have.
2015-10-25 08:37:32 -05:00
Andrew Poelstra
8defba2fb3
Expose ability to tweak secret keys for contract hash
2015-10-14 22:50:06 -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
38d2ef5d73
Add `from_script` method to Address for generating P2SH addresses
2015-10-14 22:24:09 -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
c1f81ea3c3
Add support for WIF private keys as well as addresses
2015-10-14 19:25:43 -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
eeb4655886
More updates for RFC 1214
2015-09-20 16:44:05 -05:00
Andrew Poelstra
c67608a435
Remove `Sized` requirement from ConsensusEncodable
2015-09-20 15:34:13 -05:00
Andrew Poelstra
14db7ee902
Fix for rustc RFC 1214; also add missing docs
2015-09-20 15:30:18 -05:00
Andrew Poelstra
00421970a1
Fix for serde changes
2015-09-20 13:10:20 -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
4b1b1c4a74
Fix endianness problems with new librustc ipv6 addresses
2015-05-10 13:08:38 -05:00
Andrew Poelstra
2975c91e37
Remove pile of undefined (and bitrotted) code
2015-05-10 11:12:37 -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
1d78dccb9e
Checkpoint commit -- we're onto move errors :D
2015-04-10 13:34:31 -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
5350207ff3
Remove hamcrest; add rust-serde (not compiling right now)
2015-04-09 23:23:53 -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
7a2cfe95e7
Minor fixes to namespaces
2015-04-04 13:56:30 -05:00
Andrew Poelstra
a62a7d736c
Several more changes for librustc changes
2015-04-04 13:08:49 -05:00
Andrew Poelstra
467f76a37d
MemReader/MemWriter become Cursor, other rustc changes
2015-04-04 12:56:40 -05:00
Andrew Poelstra
f1aed644c6
More misc cleanup for rustc changes
2015-03-26 14:21:48 -05:00
Andrew Poelstra
0bf5809674
Add time crate
2015-03-26 11:53:49 -05:00
Andrew Poelstra
6db25db975
Bunch of error type changes
2015-03-26 11:52:20 -05:00
Andrew Poelstra
719f616218
Some more renames for librustc changes
2015-03-26 10:44:49 -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
e0c9844ff2
Make UtxoSet store (height, txo) pairs rather than just the raw txo
...
Will take some experimentation to see if this is what I want the API
to be, if the memory usage is acceptable, etc.
This will force a total reindex for wizards-wallet users.
[breaking-change]
2014-09-10 19:58:58 -05:00
Andrew Poelstra
184721db61
Add wallet balance-checking support
2014-09-10 07:19:12 -05:00
Andrew Poelstra
ef11e8273b
Destroy socket listener on error rather than trying to reconnect; add #derivings
...
Reconnecting an existing socket simply was not working; the Rust socket
did not expose any methods for reconnection, so I simply tried calling
connect() again. As near as I can tell, this was a no-op --- which makes
sense because both the sending and receiving threads had their own copy
of the Socket, and it's not clear what the synchronization behaviour
should have been.
Instead if the connection fails, we relay this information to the main
thread, wait for an acknowledgement, then simply destroy the listening
thread. The caller can then simply call `start()` again.
2014-09-10 07:15:48 -05:00
Andrew Poelstra
1f41a67194
Make Address public
2014-09-06 11:47:18 -05:00
Andrew Poelstra
2aeb373e73
Fix encode/decode of ChildNumber so that hardened keys do not become normal ones
2014-09-06 11:35:36 -05:00
Andrew Poelstra
a240d25611
Wallet support for address creation
2014-09-06 10:30:11 -05:00
Andrew Poelstra
9f56b9c57f
Fix wallet serialization to not use "" as a key anywhere
...
Turns out TOML does not support tables named "", so we instead encode
the accounts list as an array rather than a name-keyed hashmap. This
is fine since the account name is in the account structure itself
anyway.
2014-09-05 11:55:25 -05:00
Andrew Poelstra
bc7077fac4
Encodable/Decodable improvements; add `user_enum` macro for string enums
2014-09-05 09:16:22 -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
c25862a107
Change UtxoSet to use full TXID as key
...
Sorry, this is needed to enable proper txid/vout lookups for the address index.
This means any users of wizards-wallet need to rebuild their utxo sets, and
will also mean an increase in RAM usage.
2014-09-02 09:37:31 -05:00
Andrew Poelstra
6250f4fd9c
Checkpoint commit -- prefix-filtered address indexing works
2014-09-01 21:37:00 -05:00
Andrew Poelstra
4629472d69
Block in wallet support
2014-09-01 15:11:38 -05:00
Andrew Poelstra
f66b4ff6b3
Fix for upstream, add some address generation benchmarks
2014-09-01 09:24:17 -07:00
Andrew Poelstra
931df9f68d
Add Address support
2014-08-31 19:24:31 -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
1515f68748
Minor cleanup of utxoset input checking
2014-08-31 16:35:30 -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
8f5c28a533
Fixes for rustc changes
2014-08-30 16:08:38 -07:00
Andrew Poelstra
38f8132067
Fix for upstream
2014-08-28 11:13:33 -07:00
Andrew Poelstra
6bf553c6fe
Add BIP32 key support; unify array newtyping; improve base58 trait
...
Sorry for so many things in one commit ... it was an iterative
process depending as I worked on BIP32 to get the other stuff
working. (And I was too lazy to separate it out after the fact.)
A breaking change by the array newtyping is that Show for Sha256dHash
now outputs the slice Show. You have to use `{:x}` to get the old hex
output.
2014-08-28 09:49:03 -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
47c346be71
Add base58 decode/encode functionality
2014-08-24 23:03:47 -07:00
Andrew Poelstra
688a77ef38
Rename Hash->Uint functions to denote endianness
2014-08-24 12:28:02 -07:00
Andrew Poelstra
3a921e6b9c
Add support for `tx` messages
2014-08-23 16:37:01 -07:00
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
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
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
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
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
Andrew Poelstra
b5b7a6b080
Another workaround for https://github.com/rust-lang/rust/issues/15763
2014-07-25 16:50:58 -07:00
Andrew Poelstra
cc942a47f3
Workaround for rustc hiccup in `for` loop restructuring, remove assert from deserialization code
...
Thanks to the assert change there is a segfault happening :(
2014-07-25 15:52:48 -07:00
Andrew Poelstra
128ebcc6d5
Fix comment in UTXOset for stxo cache ordering
2014-07-25 14:35:46 -07:00
Andrew Poelstra
44dc29f013
Fix BIP30 rewind handling; add unsafe annotations to ThinVec::reserve
2014-07-25 12:44:54 -07:00
Andrew Poelstra
fe9ca39736
Send new handshake on reconnect
2014-07-24 12:52:28 -07:00
Andrew Poelstra
809bad5ff5
Reconnect on network errors; use Mutexes to control Socket access more precisely
2014-07-24 08:27:40 -07:00
Andrew Poelstra
9be493eeaf
Move Local::take() into a scope where it is guaranteed to be used
...
This was causing a mystery crash. Fixed.
2014-07-23 15:19:44 -07:00
Andrew Poelstra
1be45395da
Store TxOuts directly in UtxoSet rather than in Boxes
...
This gives a significant speedup during deserialization since we
don't have to allocate for every output.
2014-07-23 11:27:03 -07:00
Andrew Poelstra
b5c25ff768
Distinguish between network/decode errors in network message decode
...
It is now visible that EOF (i.e. peer hung up) is interpreted
as a message decode error. Probably what we want to do is reset
the connection on any error. TODO
2014-07-23 11:22:35 -07:00
Andrew Poelstra
9cb86dd21b
Change InvalidInput to EndOfFile in several cases
2014-07-22 10:59:58 -07:00
Andrew Poelstra
ca6d4cdde4
Workaround for https://github.com/rust-lang/rust/issues/15763
2014-07-21 19:40:29 -07:00
Andrew Poelstra
46969b3396
Replace PatriciaTree with HashMap for UTXO set
...
We get a speed up (~5%) and memory savings (~10%) on initial sync from
using a HashMap, though it's hard to tell precisely how much savings
because it's quite nonlinear.
I haven't tested de/serialization. Some work needs to be done there to
split up the UTXO set since it takes forever to saveload.
2014-07-20 16:52:00 -07:00
Andrew Poelstra
54e4ea4586
Rename Serializable::hash() to Serializable::bitcoin_hash()
...
We were conflicting with the Rust stdlib trait Hash, which is used
by various datastructures which need a general hash. Also implement
Hash for Sha256dHash so that we can use bitcoin hashes as keys for
such data structures.
2014-07-19 16:11:55 -07:00
Andrew Poelstra
a3846965e3
blockchain: replace Rc mess with internal raw pointers
2014-07-19 15:23:04 -07:00
Andrew Poelstra
93dadd6a6e
Add iterators to patricia tree
2014-07-19 13:02:25 -07:00
Andrew Poelstra
73e8b542c0
Add testnet blockspacing rule
2014-07-18 16:41:09 -07:00
Andrew Poelstra
51038f5810
Add alternate network support to `Blockchain`, `UtxoSet`, `Socket`
...
Still need to do alternate diffchange rules..
2014-07-18 14:38:35 -07:00
Andrew Poelstra
8f826a959d
Introduce `BitcoinResult`, use it instead of boolean returns in blockchain
2014-07-18 12:40:04 -07:00
Andrew Poelstra
b5fd47b334
Allow user to change network magic, add constant for testnet
...
We need to add a "difficulty back to 1 after 20 minutes" difficulty
rule to actually support testnet, but this is a start.
2014-07-18 12:03:38 -07:00
Andrew Poelstra
c9ad7c0b58
Initial commit, move into Cargo
2014-07-18 06:56:17 -07:00