Merge pull request #342 from ethcore/docs
documentation cleanup and generation script
This commit is contained in:
commit
47fab21c5c
|
@ -221,6 +221,6 @@ Once released, `pbtc` documentation will be available [here][doc-url]. Meanwhile
|
||||||
|
|
||||||
```
|
```
|
||||||
cd parity-bitcoin
|
cd parity-bitcoin
|
||||||
cargo doc
|
./tools/doc.sh
|
||||||
open target/doc/pbtc/index.html
|
open target/doc/pbtc/index.html
|
||||||
```
|
```
|
||||||
|
|
|
@ -764,7 +764,7 @@ mod tests {
|
||||||
use chain::Block;
|
use chain::Block;
|
||||||
use super::super::{BlockRef, BlockLocation};
|
use super::super::{BlockRef, BlockLocation};
|
||||||
use test_data;
|
use test_data;
|
||||||
use primitives::Compact;
|
use primitives::compact::Compact;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn open_store() {
|
fn open_store() {
|
||||||
|
|
|
@ -25,6 +25,7 @@ impl Iterator for BlkFile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Creates iterator over bitcoind database blocks
|
||||||
pub fn open_blk_dir<P>(path: P) -> Result<BlkDir, io::Error> where P: AsRef<path::Path> {
|
pub fn open_blk_dir<P>(path: P) -> Result<BlkDir, io::Error> where P: AsRef<path::Path> {
|
||||||
let files = read_blk_dir(path)?.collect::<Result<BTreeSet<_>, _>>()?;
|
let files = read_blk_dir(path)?.collect::<Result<BTreeSet<_>, _>>()?;
|
||||||
|
|
||||||
|
@ -41,6 +42,7 @@ pub fn open_blk_dir<P>(path: P) -> Result<BlkDir, io::Error> where P: AsRef<path
|
||||||
Ok(blk_dir)
|
Ok(blk_dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Bitcoind database blocks iterator
|
||||||
pub struct BlkDir {
|
pub struct BlkDir {
|
||||||
iter: Box<Iterator<Item = Result<Block, ReaderError>>>,
|
iter: Box<Iterator<Item = Result<Block, ReaderError>>>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
//! Bitcoind blockchain database importer
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
extern crate primitives;
|
extern crate primitives;
|
||||||
|
@ -10,4 +12,4 @@ mod fs;
|
||||||
|
|
||||||
pub use primitives::{hash, bytes};
|
pub use primitives::{hash, bytes};
|
||||||
|
|
||||||
pub use blk::{open_blk_file, open_blk_dir};
|
pub use blk::{open_blk_dir, BlkDir};
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
//! `AddressHash` with network identifier and format type
|
||||||
|
//!
|
||||||
//! A Bitcoin address, or simply address, is an identifier of 26-35 alphanumeric characters, beginning with the number 1
|
//! A Bitcoin address, or simply address, is an identifier of 26-35 alphanumeric characters, beginning with the number 1
|
||||||
//! or 3, that represents a possible destination for a bitcoin payment.
|
//! or 3, that represents a possible destination for a bitcoin payment.
|
||||||
//!
|
//!
|
||||||
|
@ -25,6 +27,7 @@ pub enum Type {
|
||||||
P2SH,
|
P2SH,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// `AddressHash` with network identifier and format type
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct Address {
|
pub struct Address {
|
||||||
/// The type of the address.
|
/// The type of the address.
|
||||||
|
|
|
@ -1,10 +1,4 @@
|
||||||
//! Bitcoin keys.
|
//! Bitcoin keys.
|
||||||
//!
|
|
||||||
//! `Secret` - 32 bytes
|
|
||||||
//! `Public` - 65 bytes (TODO: make it optionally compressed)
|
|
||||||
//! `Private` - secret with additional network identifier (and compressed flag?)
|
|
||||||
//! `AddressHash` - 20 bytes derived from public
|
|
||||||
//! `Address` - addressh ash with network identifier and format type
|
|
||||||
|
|
||||||
extern crate rand;
|
extern crate rand;
|
||||||
extern crate rustc_serialize;
|
extern crate rustc_serialize;
|
||||||
|
@ -15,10 +9,10 @@ extern crate secp256k1;
|
||||||
extern crate bitcrypto as crypto;
|
extern crate bitcrypto as crypto;
|
||||||
extern crate primitives;
|
extern crate primitives;
|
||||||
|
|
||||||
mod address;
|
|
||||||
pub mod display;
|
|
||||||
pub mod generator;
|
pub mod generator;
|
||||||
pub mod keypair;
|
mod address;
|
||||||
|
mod display;
|
||||||
|
mod keypair;
|
||||||
mod error;
|
mod error;
|
||||||
mod network;
|
mod network;
|
||||||
mod private;
|
mod private;
|
||||||
|
@ -28,19 +22,22 @@ mod signature;
|
||||||
pub use rustc_serialize::hex;
|
pub use rustc_serialize::hex;
|
||||||
pub use primitives::{hash, bytes};
|
pub use primitives::{hash, bytes};
|
||||||
|
|
||||||
pub use self::address::{Type, Address};
|
pub use address::{Type, Address};
|
||||||
pub use self::display::DisplayLayout;
|
pub use display::DisplayLayout;
|
||||||
pub use self::keypair::KeyPair;
|
pub use keypair::KeyPair;
|
||||||
pub use self::error::Error;
|
pub use error::Error;
|
||||||
pub use self::private::Private;
|
pub use private::Private;
|
||||||
pub use self::public::Public;
|
pub use public::Public;
|
||||||
pub use self::signature::{Signature, CompactSignature};
|
pub use signature::{Signature, CompactSignature};
|
||||||
pub use self::network::Network;
|
pub use network::Network;
|
||||||
|
|
||||||
use hash::{H160, H256};
|
use hash::{H160, H256};
|
||||||
|
|
||||||
|
/// 20 bytes long hash derived from public `ripemd160(sha256(public))`
|
||||||
pub type AddressHash = H160;
|
pub type AddressHash = H160;
|
||||||
|
/// 32 bytes long secret key
|
||||||
pub type Secret = H256;
|
pub type Secret = H256;
|
||||||
|
/// 32 bytes long signable message
|
||||||
pub type Message = H256;
|
pub type Message = H256;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
//! Secret with additional network identifier and format type
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use secp256k1::key;
|
use secp256k1::key;
|
||||||
|
@ -9,6 +11,7 @@ use hash::H520;
|
||||||
use network::Network;
|
use network::Network;
|
||||||
use {Secret, DisplayLayout, Error, Message, Signature, CompactSignature, SECP256K1};
|
use {Secret, DisplayLayout, Error, Message, Signature, CompactSignature, SECP256K1};
|
||||||
|
|
||||||
|
/// Secret with additional network identifier and format type
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
pub struct Private {
|
pub struct Private {
|
||||||
/// The network on which this key should be used.
|
/// The network on which this key should be used.
|
||||||
|
|
|
@ -6,8 +6,11 @@ use crypto::dhash160;
|
||||||
use hash::{H264, H520};
|
use hash::{H264, H520};
|
||||||
use {AddressHash, Error, CompactSignature, Signature, Message, SECP256K1};
|
use {AddressHash, Error, CompactSignature, Signature, Message, SECP256K1};
|
||||||
|
|
||||||
|
/// Secret public key
|
||||||
pub enum Public {
|
pub enum Public {
|
||||||
|
/// Normal version of public key
|
||||||
Normal(H520),
|
Normal(H520),
|
||||||
|
/// Compressed version of public key
|
||||||
Compressed(H264),
|
Compressed(H264),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,7 @@ pub use verification::constants::{MAX_BLOCK_SIZE, MAX_BLOCK_SIGOPS};
|
||||||
const BLOCK_VERSION: u32 = 0x20000000;
|
const BLOCK_VERSION: u32 = 0x20000000;
|
||||||
const BLOCK_HEADER_SIZE: u32 = 4 + 32 + 32 + 4 + 4 + 4;
|
const BLOCK_HEADER_SIZE: u32 = 4 + 32 + 32 + 4 + 4 + 4;
|
||||||
|
|
||||||
/// Block template as described in BIP0022
|
/// Block template as described in [BIP0022](https://github.com/bitcoin/bips/blob/master/bip-0022.mediawiki#block-template-request)
|
||||||
/// Minimal version
|
|
||||||
/// [BIP0022](https://github.com/bitcoin/bips/blob/master/bip-0022.mediawiki#block-template-request)
|
|
||||||
pub struct BlockTemplate {
|
pub struct BlockTemplate {
|
||||||
/// Version
|
/// Version
|
||||||
pub version: u32,
|
pub version: u32,
|
||||||
|
|
|
@ -85,6 +85,7 @@ pub struct Solution {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Simple bitcoin cpu miner.
|
/// Simple bitcoin cpu miner.
|
||||||
|
///
|
||||||
/// First it tries to find solution by changing block header nonce.
|
/// First it tries to find solution by changing block header nonce.
|
||||||
/// Once all nonce values have been tried, it increases extranonce.
|
/// Once all nonce values have been tried, it increases extranonce.
|
||||||
/// Once all of them have been tried (quite unlikely on cpu ;),
|
/// Once all of them have been tried (quite unlikely on cpu ;),
|
||||||
|
|
|
@ -15,8 +15,7 @@ const MAX_BITS_MAINNET: u32 = 0x1d00ffff;
|
||||||
const MAX_BITS_TESTNET: u32 = 0x1d00ffff;
|
const MAX_BITS_TESTNET: u32 = 0x1d00ffff;
|
||||||
const MAX_BITS_REGTEST: u32 = 0x207fffff;
|
const MAX_BITS_REGTEST: u32 = 0x207fffff;
|
||||||
|
|
||||||
/// Bitcoin network
|
/// Bitcoin [network](https://bitcoin.org/en/glossary/mainnet)
|
||||||
/// https://bitcoin.org/en/glossary/mainnet
|
|
||||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||||
pub enum Magic {
|
pub enum Magic {
|
||||||
/// The original and main network for Bitcoin transactions, where satoshis have real economic value.
|
/// The original and main network for Bitcoin transactions, where satoshis have real economic value.
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
|
//! Wrapper around `Vec<u8>`
|
||||||
|
|
||||||
use std::{ops, str, fmt, io, marker};
|
use std::{ops, str, fmt, io, marker};
|
||||||
use hex::{ToHex, FromHex, FromHexError};
|
use hex::{ToHex, FromHex, FromHexError};
|
||||||
|
|
||||||
|
/// Wrapper around `Vec<u8>`
|
||||||
#[derive(Default, PartialEq, Clone)]
|
#[derive(Default, PartialEq, Clone)]
|
||||||
pub struct Bytes(Vec<u8>);
|
pub struct Bytes(Vec<u8>);
|
||||||
|
|
||||||
|
@ -92,6 +95,7 @@ impl AsMut<[u8]> for Bytes {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Wrapper around `Vec<u8>` which represent associated type
|
||||||
#[derive(Default, PartialEq, Clone)]
|
#[derive(Default, PartialEq, Clone)]
|
||||||
pub struct TaggedBytes<T> {
|
pub struct TaggedBytes<T> {
|
||||||
bytes: Bytes,
|
bytes: Bytes,
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
|
//! Compact representation of `U256`
|
||||||
|
|
||||||
use uint::U256;
|
use uint::U256;
|
||||||
|
|
||||||
|
/// Compact representation of `U256`
|
||||||
#[derive(Debug, PartialEq, Clone, Copy)]
|
#[derive(Debug, PartialEq, Clone, Copy)]
|
||||||
pub struct Compact(u32);
|
pub struct Compact(u32);
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
//! Fixed-size hashes
|
||||||
|
|
||||||
use std::{fmt, ops, cmp, str};
|
use std::{fmt, ops, cmp, str};
|
||||||
use hex::{ToHex, FromHex, FromHexError};
|
use hex::{ToHex, FromHex, FromHexError};
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
|
|
|
@ -10,8 +10,3 @@ pub mod hash;
|
||||||
pub mod uint;
|
pub mod uint;
|
||||||
|
|
||||||
pub use rustc_serialize::hex;
|
pub use rustc_serialize::hex;
|
||||||
|
|
||||||
pub use uint::U256;
|
|
||||||
pub use hash::{H160, H256};
|
|
||||||
pub use bytes::Bytes;
|
|
||||||
pub use compact::Compact;
|
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
|
//! Script builder
|
||||||
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use {Opcode, Script, Num};
|
use {Opcode, Script, Num};
|
||||||
use keys::AddressHash;
|
use keys::AddressHash;
|
||||||
|
|
||||||
|
/// Script builder
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Builder {
|
pub struct Builder {
|
||||||
data: Bytes,
|
data: Bytes,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Builder {
|
impl Builder {
|
||||||
|
/// Builds p2pkh script pubkey
|
||||||
pub fn build_p2pkh(address: &AddressHash) -> Script {
|
pub fn build_p2pkh(address: &AddressHash) -> Script {
|
||||||
Builder::default()
|
Builder::default()
|
||||||
.push_opcode(Opcode::OP_DUP)
|
.push_opcode(Opcode::OP_DUP)
|
||||||
|
@ -18,6 +22,7 @@ impl Builder {
|
||||||
.into_script()
|
.into_script()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Builds p2sh script pubkey
|
||||||
pub fn build_p2sh(address: &AddressHash) -> Script {
|
pub fn build_p2sh(address: &AddressHash) -> Script {
|
||||||
Builder::default()
|
Builder::default()
|
||||||
.push_opcode(Opcode::OP_HASH160)
|
.push_opcode(Opcode::OP_HASH160)
|
||||||
|
@ -26,11 +31,13 @@ impl Builder {
|
||||||
.into_script()
|
.into_script()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Pushes opcode to the end of script
|
||||||
pub fn push_opcode(mut self, opcode: Opcode) -> Self {
|
pub fn push_opcode(mut self, opcode: Opcode) -> Self {
|
||||||
self.data.push(opcode as u8);
|
self.data.push(opcode as u8);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Appends bool push operation to the end of script
|
||||||
pub fn push_bool(mut self, value: bool) -> Self {
|
pub fn push_bool(mut self, value: bool) -> Self {
|
||||||
if value {
|
if value {
|
||||||
self.data.push(Opcode::OP_1 as u8);
|
self.data.push(Opcode::OP_1 as u8);
|
||||||
|
@ -40,10 +47,12 @@ impl Builder {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Appends num push operation to the end of script
|
||||||
pub fn push_num(self, num: Num) -> Self {
|
pub fn push_num(self, num: Num) -> Self {
|
||||||
self.push_data(&num.to_bytes())
|
self.push_data(&num.to_bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Appends bytes push operation to the end od script
|
||||||
pub fn push_bytes(mut self, bytes: &[u8]) -> Self {
|
pub fn push_bytes(mut self, bytes: &[u8]) -> Self {
|
||||||
let len = bytes.len();
|
let len = bytes.len();
|
||||||
if len < 1 || len > 75 {
|
if len < 1 || len > 75 {
|
||||||
|
@ -57,6 +66,7 @@ impl Builder {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Appends data push operation to the end of script
|
||||||
pub fn push_data(mut self, data: &[u8]) -> Self {
|
pub fn push_data(mut self, data: &[u8]) -> Self {
|
||||||
let len = data.len();
|
let len = data.len();
|
||||||
if len < Opcode::OP_PUSHDATA1 as usize {
|
if len < Opcode::OP_PUSHDATA1 as usize {
|
||||||
|
@ -82,17 +92,20 @@ impl Builder {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Appends `OP_RETURN` operation to the end of script
|
||||||
pub fn return_bytes(mut self, bytes: &[u8]) -> Self {
|
pub fn return_bytes(mut self, bytes: &[u8]) -> Self {
|
||||||
self.data.push(Opcode::OP_RETURN as u8);
|
self.data.push(Opcode::OP_RETURN as u8);
|
||||||
self.data.extend_from_slice(bytes);
|
self.data.extend_from_slice(bytes);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Pushes invalid opcode to the end of script
|
||||||
pub fn push_invalid_opcode(mut self) -> Self {
|
pub fn push_invalid_opcode(mut self) -> Self {
|
||||||
self.data.push(0xff);
|
self.data.push(0xff);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Builds final script
|
||||||
pub fn into_script(self) -> Script {
|
pub fn into_script(self) -> Script {
|
||||||
Script::new(self.data)
|
Script::new(self.data)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
|
//! Interpreter errors
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use Opcode;
|
use Opcode;
|
||||||
|
|
||||||
|
/// Interpreter errors
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
Unknown,
|
Unknown,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
//! Script verification flags.
|
//! Script interpreter verification flags
|
||||||
|
|
||||||
|
/// Script interpreter verification flags
|
||||||
#[derive(Default, Debug, PartialEq)]
|
#[derive(Default, Debug, PartialEq)]
|
||||||
pub struct VerificationFlags {
|
pub struct VerificationFlags {
|
||||||
pub none: bool,
|
pub none: bool,
|
||||||
|
|
|
@ -3,9 +3,9 @@ use bytes::Bytes;
|
||||||
use keys::{Signature, Public};
|
use keys::{Signature, Public};
|
||||||
use chain::constants::SEQUENCE_LOCKTIME_DISABLE_FLAG;
|
use chain::constants::SEQUENCE_LOCKTIME_DISABLE_FLAG;
|
||||||
use crypto::{sha1, sha256, dhash160, dhash256, ripemd160};
|
use crypto::{sha1, sha256, dhash160, dhash256, ripemd160};
|
||||||
|
use sign::{SignatureVersion, Sighash};
|
||||||
use {
|
use {
|
||||||
script, Script, Num, VerificationFlags, Opcode, Error,
|
script, Script, Num, VerificationFlags, Opcode, Error, SignatureChecker, Stack
|
||||||
Sighash, SignatureChecker, SignatureVersion, Stack
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Helper function.
|
/// Helper function.
|
||||||
|
@ -225,6 +225,7 @@ fn cast_to_bool(data: &[u8]) -> bool {
|
||||||
!(last == 0 || last == 0x80)
|
!(last == 0 || last == 0x80)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Verifies script signature and pubkey
|
||||||
pub fn verify_script(
|
pub fn verify_script(
|
||||||
script_sig: &Script,
|
script_sig: &Script,
|
||||||
script_pubkey: &Script,
|
script_pubkey: &Script,
|
||||||
|
@ -286,6 +287,7 @@ pub fn verify_script(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Evaluautes the script
|
||||||
#[cfg_attr(feature="cargo-clippy", allow(match_same_arms))]
|
#[cfg_attr(feature="cargo-clippy", allow(match_same_arms))]
|
||||||
pub fn eval_script(
|
pub fn eval_script(
|
||||||
stack: &mut Stack<Bytes>,
|
stack: &mut Stack<Bytes>,
|
||||||
|
@ -892,9 +894,10 @@ pub fn eval_script(
|
||||||
mod tests {
|
mod tests {
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use chain::Transaction;
|
use chain::Transaction;
|
||||||
|
use sign::SignatureVersion;
|
||||||
use {
|
use {
|
||||||
Opcode, Script, VerificationFlags, Builder, Error, Num, TransactionInputSigner,
|
Opcode, Script, VerificationFlags, Builder, Error, Num, TransactionInputSigner,
|
||||||
NoopSignatureChecker, SignatureVersion, TransactionSignatureChecker, Stack
|
NoopSignatureChecker, TransactionSignatureChecker, Stack
|
||||||
};
|
};
|
||||||
use super::{eval_script, verify_script, is_public_key};
|
use super::{eval_script, verify_script, is_public_key};
|
||||||
|
|
||||||
|
|
|
@ -26,10 +26,7 @@ pub use self::interpreter::{eval_script, verify_script};
|
||||||
pub use self::opcode::Opcode;
|
pub use self::opcode::Opcode;
|
||||||
pub use self::num::Num;
|
pub use self::num::Num;
|
||||||
pub use self::script::{Script, ScriptType, ScriptAddress};
|
pub use self::script::{Script, ScriptType, ScriptAddress};
|
||||||
pub use self::sign::{
|
pub use self::sign::{TransactionInputSigner, UnsignedTransactionInput};
|
||||||
TransactionInputSigner, UnsignedTransactionInput,
|
|
||||||
Sighash, SighashBase, SignatureVersion
|
|
||||||
};
|
|
||||||
pub use self::stack::Stack;
|
pub use self::stack::Stack;
|
||||||
pub use self::verify::{SignatureChecker, NoopSignatureChecker, TransactionSignatureChecker};
|
pub use self::verify::{SignatureChecker, NoopSignatureChecker, TransactionSignatureChecker};
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
//! Script numeric.
|
//! Script numeric
|
||||||
|
|
||||||
use std::ops;
|
use std::ops;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use Error;
|
use Error;
|
||||||
|
|
||||||
|
/// Script numeric
|
||||||
|
///
|
||||||
/// Numeric opcodes (`OP_1ADD`, etc) are restricted to operating on 4-byte integers.
|
/// Numeric opcodes (`OP_1ADD`, etc) are restricted to operating on 4-byte integers.
|
||||||
/// The semantics are subtle, though: operands must be in the range [-2^31 +1...2^31 -1],
|
/// The semantics are subtle, though: operands must be in the range [-2^31 +1...2^31 -1],
|
||||||
/// but results may overflow (and are valid as long as they are not used in a subsequent
|
/// but results may overflow (and are valid as long as they are not used in a subsequent
|
||||||
|
|
|
@ -17,6 +17,7 @@ pub const MAX_PUBKEYS_PER_MULTISIG: usize = 20;
|
||||||
/// Maximum script length in bytes
|
/// Maximum script length in bytes
|
||||||
pub const MAX_SCRIPT_SIZE: usize = 10000;
|
pub const MAX_SCRIPT_SIZE: usize = 10000;
|
||||||
|
|
||||||
|
/// Classified script type
|
||||||
#[derive(PartialEq, Debug)]
|
#[derive(PartialEq, Debug)]
|
||||||
pub enum ScriptType {
|
pub enum ScriptType {
|
||||||
NonStandard,
|
NonStandard,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
//! Transaction signer
|
||||||
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use keys::KeyPair;
|
use keys::KeyPair;
|
||||||
use crypto::dhash256;
|
use crypto::dhash256;
|
||||||
|
@ -27,8 +29,7 @@ impl From<SighashBase> for u32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature="cargo-clippy", allow(doc_markdown))]
|
#[cfg_attr(feature="cargo-clippy", allow(doc_markdown))]
|
||||||
/// Documentation
|
/// Signature hash type. [Documentation](https://en.bitcoin.it/wiki/OP_CHECKSIG#Procedure_for_Hashtype_SIGHASH_SINGLE)
|
||||||
/// https://en.bitcoin.it/wiki/OP_CHECKSIG#Procedure_for_Hashtype_SIGHASH_SINGLE
|
|
||||||
#[derive(Debug, PartialEq, Clone, Copy)]
|
#[derive(Debug, PartialEq, Clone, Copy)]
|
||||||
pub struct Sighash {
|
pub struct Sighash {
|
||||||
pub base: SighashBase,
|
pub base: SighashBase,
|
||||||
|
|
|
@ -3,8 +3,10 @@ use chain::constants::{
|
||||||
SEQUENCE_FINAL, SEQUENCE_LOCKTIME_DISABLE_FLAG,
|
SEQUENCE_FINAL, SEQUENCE_LOCKTIME_DISABLE_FLAG,
|
||||||
SEQUENCE_LOCKTIME_MASK, SEQUENCE_LOCKTIME_TYPE_FLAG, LOCKTIME_THRESHOLD
|
SEQUENCE_LOCKTIME_MASK, SEQUENCE_LOCKTIME_TYPE_FLAG, LOCKTIME_THRESHOLD
|
||||||
};
|
};
|
||||||
use {SignatureVersion, Script, TransactionInputSigner, Num};
|
use sign::SignatureVersion;
|
||||||
|
use {Script, TransactionInputSigner, Num};
|
||||||
|
|
||||||
|
/// Checks transaction signature
|
||||||
pub trait SignatureChecker {
|
pub trait SignatureChecker {
|
||||||
fn check_signature(
|
fn check_signature(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
//! A type of variable-length integer commonly used in the Bitcoin P2P protocol and Bitcoin serialized data structures.
|
//! Variable-length integer commonly used in the Bitcoin [P2P protocol](https://bitcoin.org/en/developer-reference#compactsize-unsigned-integers)
|
||||||
//! https://bitcoin.org/en/developer-reference#compactsize-unsigned-integers
|
|
||||||
|
|
||||||
use std::{fmt, io};
|
use std::{fmt, io};
|
||||||
use {
|
use {
|
||||||
|
|
|
@ -3,11 +3,11 @@ extern crate primitives;
|
||||||
|
|
||||||
mod compact_integer;
|
mod compact_integer;
|
||||||
mod impls;
|
mod impls;
|
||||||
pub mod reader;
|
mod reader;
|
||||||
pub mod stream;
|
mod stream;
|
||||||
|
|
||||||
pub use primitives::{hash, bytes, compact};
|
pub use primitives::{hash, bytes, compact};
|
||||||
|
|
||||||
pub use compact_integer::CompactInteger;
|
pub use compact_integer::CompactInteger;
|
||||||
pub use self::reader::{Reader, Deserializable, deserialize, deserialize_iterator, ReadIterator, Error};
|
pub use reader::{Reader, Deserializable, deserialize, deserialize_iterator, ReadIterator, Error};
|
||||||
pub use self::stream::{Stream, Serializable, serialize, serialized_list_size};
|
pub use stream::{Stream, Serializable, serialize, serialized_list_size};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//! Stream used for serialization.
|
//! Stream used for serialization of Bitcoin structures
|
||||||
use std::io::{self, Write};
|
use std::io::{self, Write};
|
||||||
use std::borrow::Borrow;
|
use std::borrow::Borrow;
|
||||||
use compact_integer::CompactInteger;
|
use compact_integer::CompactInteger;
|
||||||
|
@ -26,7 +26,7 @@ pub trait Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Stream used for serialization.
|
/// Stream used for serialization of Bitcoin structures
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Stream {
|
pub struct Stream {
|
||||||
buffer: Vec<u8>,
|
buffer: Vec<u8>,
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cargo doc --no-deps\
|
||||||
|
-p bitcrypto\
|
||||||
|
-p chain\
|
||||||
|
-p db\
|
||||||
|
-p ethcore-devtools\
|
||||||
|
-p import\
|
||||||
|
-p keys\
|
||||||
|
-p message\
|
||||||
|
-p miner\
|
||||||
|
-p network\
|
||||||
|
-p pbtc\
|
||||||
|
-p p2p\
|
||||||
|
-p primitives\
|
||||||
|
-p rpc\
|
||||||
|
-p script\
|
||||||
|
-p serialization\
|
||||||
|
-p sync\
|
||||||
|
-p verification
|
|
@ -1,4 +1,5 @@
|
||||||
use primitives::{H256, Compact};
|
use primitives::hash::H256;
|
||||||
|
use primitives::compact::Compact;
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
/// All possible verification errors
|
/// All possible verification errors
|
||||||
|
|
Loading…
Reference in New Issue