rust-bitcoin/Cargo.toml

52 lines
1.1 KiB
TOML
Raw Normal View History

2014-07-18 06:56:17 -07:00
[package]
name = "bitcoin"
version = "0.18.0"
2014-07-18 06:56:17 -07:00
authors = ["Andrew Poelstra <apoelstra@wpsoftware.net>"]
license = "CC0-1.0"
homepage = "https://github.com/rust-bitcoin/rust-bitcoin/"
repository = "https://github.com/rust-bitcoin/rust-bitcoin/"
2018-04-11 12:13:43 -07:00
documentation = "https://docs.rs/bitcoin/"
description = "General purpose library for using and interoperating with Bitcoin and other cryptocurrencies."
keywords = [ "crypto", "bitcoin" ]
readme = "README.md"
2014-08-18 18:04:32 -07:00
[lib]
2014-07-18 06:56:17 -07:00
name = "bitcoin"
path = "src/lib.rs"
2018-03-10 06:35:49 -08:00
[features]
fuzztarget = ["secp256k1/fuzztarget", "bitcoin_hashes/fuzztarget"]
serde-decimal = ["use-serde", "strason"]
2019-01-07 13:43:23 -08:00
unstable = []
2019-03-19 07:49:27 -07:00
use-serde = ["serde", "serde_test", "bitcoin_hashes/serde"]
2018-03-10 06:35:49 -08:00
2015-03-26 08:44:49 -07:00
[dependencies]
bitcoin-bech32 = "0.9.0"
2018-12-06 19:45:43 -08:00
byteorder = "1.2"
rand = "0.3"
bitcoin_hashes = "0.3"
bitcoinconsensus = { version = "0.16", optional = true }
2015-03-26 08:44:49 -07:00
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 13:41:28 -08:00
[dev-dependencies]
tempfile = "3"
[dependencies.serde]
version = "1"
optional = true
2019-03-19 07:49:27 -07:00
[dependencies.serde_test]
version = "1"
optional = true
[dependencies.strason]
version = "0.4"
optional = true
default-features = false
[dependencies.hex]
version = "=0.3.2"
[dependencies.secp256k1]
2019-01-15 09:05:41 -08:00
version = "0.12"
2018-03-21 15:06:51 -07:00
features = [ "rand" ]