From 2e9298fbc88cba939864f61ba01e7bdf84ab7f7a Mon Sep 17 00:00:00 2001 From: Esteban Ordano Date: Sat, 22 Nov 2014 17:29:10 -0300 Subject: [PATCH 1/5] Empty files for most classes --- docs/Block.md | 1 + docs/Blockheader.md | 1 + docs/Crypto.md | 1 + docs/Encoding.md | 0 docs/Hierarchical.md | 12 ++++++++++++ docs/Input.md | 1 + docs/Networks.md | 1 + docs/Opcode.md | 1 + docs/Output.md | 1 + docs/Script.md | 1 + docs/Signature.md | 1 + 11 files changed, 21 insertions(+) create mode 100644 docs/Block.md create mode 100644 docs/Blockheader.md create mode 100644 docs/Crypto.md create mode 100644 docs/Encoding.md create mode 100644 docs/Hierarchical.md create mode 100644 docs/Input.md create mode 100644 docs/Networks.md create mode 100644 docs/Opcode.md create mode 100644 docs/Output.md create mode 100644 docs/Script.md create mode 100644 docs/Signature.md diff --git a/docs/Block.md b/docs/Block.md new file mode 100644 index 0000000..2d45d23 --- /dev/null +++ b/docs/Block.md @@ -0,0 +1 @@ +# Block diff --git a/docs/Blockheader.md b/docs/Blockheader.md new file mode 100644 index 0000000..253fb3d --- /dev/null +++ b/docs/Blockheader.md @@ -0,0 +1 @@ +# Blockheader diff --git a/docs/Crypto.md b/docs/Crypto.md new file mode 100644 index 0000000..84e6304 --- /dev/null +++ b/docs/Crypto.md @@ -0,0 +1 @@ +# Crypto diff --git a/docs/Encoding.md b/docs/Encoding.md new file mode 100644 index 0000000..e69de29 diff --git a/docs/Hierarchical.md b/docs/Hierarchical.md new file mode 100644 index 0000000..44c0f6e --- /dev/null +++ b/docs/Hierarchical.md @@ -0,0 +1,12 @@ +# Hierarichically Derived Keys + +Bitcore provides full support for +[BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki), +allowing for many key management schemas that benefit from this property. +Please be sure to read and understand the basic concepts and the warnings on +that BIP before using these classes. + +## HDPrivateKey + +This class initially meant to share the interface of +[PrivateKey](http://missing-link) but add the ability to derive new keys. diff --git a/docs/Input.md b/docs/Input.md new file mode 100644 index 0000000..135b6af --- /dev/null +++ b/docs/Input.md @@ -0,0 +1 @@ +# Input diff --git a/docs/Networks.md b/docs/Networks.md new file mode 100644 index 0000000..1bb6593 --- /dev/null +++ b/docs/Networks.md @@ -0,0 +1 @@ +# Networks diff --git a/docs/Opcode.md b/docs/Opcode.md new file mode 100644 index 0000000..713d29c --- /dev/null +++ b/docs/Opcode.md @@ -0,0 +1 @@ +# Opcode diff --git a/docs/Output.md b/docs/Output.md new file mode 100644 index 0000000..22e0f66 --- /dev/null +++ b/docs/Output.md @@ -0,0 +1 @@ +# Output diff --git a/docs/Script.md b/docs/Script.md new file mode 100644 index 0000000..b151bef --- /dev/null +++ b/docs/Script.md @@ -0,0 +1 @@ +# Script diff --git a/docs/Signature.md b/docs/Signature.md new file mode 100644 index 0000000..e400025 --- /dev/null +++ b/docs/Signature.md @@ -0,0 +1 @@ +# Signature From 616e298ae076828d0259a73f0d464a8288b9dcb9 Mon Sep 17 00:00:00 2001 From: Esteban Ordano Date: Mon, 24 Nov 2014 11:08:02 -0300 Subject: [PATCH 2/5] Add content for Networks.md --- docs/Networks.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/Networks.md b/docs/Networks.md index 1bb6593..40dff2c 100644 --- a/docs/Networks.md +++ b/docs/Networks.md @@ -1 +1,23 @@ # Networks + +Bitcore provides support for both the main bitcoin network as well as for +`testnet3`, the current test blockchain. We encourage the use of +`Networks.livenet` and `Networks.testnet` as constants. Note that the library +sometimes may check for equality against this object. Avoid creating a deep +copy of this object and using that. + +## Setting the default network + +Most project will only need to work in one of either networks. The value of +`Networks.defaultNetwork` can be set to `Networks.testnet` if the project will +needs only to work on testnet (the default is `Networks.livenet`). + +## Network constants + +The functionality of testnet and livenet is mostly similar (except for some +relaxed block validation rules on testnet). They differ in the constants being +used for human representation of base58 encoded strings. These are sometimes +referred to as "version" constants. + +## Source +TODO: Include source here From 7c012eaa957108def0287abc27f6ac302dac2a53 Mon Sep 17 00:00:00 2001 From: Esteban Ordano Date: Mon, 24 Nov 2014 13:40:24 -0300 Subject: [PATCH 3/5] Block.md content. Remove blockheader doc --- docs/Block.md | 50 +++++++++++++++++++++++++++++++++++++++++++++ docs/Blockheader.md | 1 - docs/Transaction.md | 1 + 3 files changed, 51 insertions(+), 1 deletion(-) delete mode 100644 docs/Blockheader.md diff --git a/docs/Block.md b/docs/Block.md index 2d45d23..b35642e 100644 --- a/docs/Block.md +++ b/docs/Block.md @@ -1 +1,51 @@ # Block + +A Block instance represents the information on a block in the bitcoin network. +Note that creating it takes some computing power, as the tree of transactions +is created or verified. + +Given a hexa or base64 string representation of the serialization of a block +with its transactions, you can instantiate a Block instance. It will calculate +and check the merkle root hash (if enough data is provided), but transactions +won't neccesarily be valid spends, and this class won't validate them. A binary +representation as a `Buffer` instance is also valid input for a Block's +constructor. + +```javascript +assert(Block.isValidHeader(data); +assert(Block.isValidBlock(data); + +var block = new Block(hexaEncodedBlock); +assert(block.id && block.hash && block.id === block.hash); +assert(block.version === Block.CurrentVersion); +assert(block.prevHash); +assert(block.timestamp); +assert(block.nonce); +assert(block.size); +assert(block.transactions[0] instanceof Transaction); +``` + +## Navigating through transactions + +The set of transactions in a block can be explored by iterating on the block's +`transactions` member. + +```javascript +for (var transaction in block.transactions) { + // ... +} +``` + +It is also possible to explore a block's Merkle tree of transaction hashes. +Head to the [Merkle tree](./DataStructures.html#MerkleTree) documentation for +more information: + +```javascript +var root = block.tree.root; +assert(root instanceof bitcore.DataStructures.MerkleTree.Node); +assert(root.hash === block.id); +assert(root.isLeaf === false); +assert(root.left instanceof bitcore.DataStructures.MerkleTree.Node); +assert(root.right instanceof bitcore.DataStructures.MerkleTree.Node); +assert(root.left.left.left.left.content === block.transactions[0]); +``` diff --git a/docs/Blockheader.md b/docs/Blockheader.md deleted file mode 100644 index 253fb3d..0000000 --- a/docs/Blockheader.md +++ /dev/null @@ -1 +0,0 @@ -# Blockheader diff --git a/docs/Transaction.md b/docs/Transaction.md index cddee12..f8d6333 100644 --- a/docs/Transaction.md +++ b/docs/Transaction.md @@ -49,6 +49,7 @@ You can take a look at the javadocs for the [Transaction class here](link missing). This document will go over the expected high level use cases. * from(utxo) +* fromMultisig(utxo, pubkeys, threshold) * change(address) * fee(amount) * usingStrategy(strategy) From d3de4742b288364d1892996d3c325e5e3d7af0ca Mon Sep 17 00:00:00 2001 From: Esteban Ordano Date: Mon, 24 Nov 2014 13:52:53 -0300 Subject: [PATCH 4/5] Add docs for Crypto --- docs/Crypto.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/docs/Crypto.md b/docs/Crypto.md index 84e6304..86d5b63 100644 --- a/docs/Crypto.md +++ b/docs/Crypto.md @@ -1 +1,36 @@ # Crypto + +The cryptographic primitives (ECDSA and HMAC) implementations in this package +have been audited by: + +* The BitPay engineering team + +## random + +The `bitcore.Crypto.Random` namespace contains a single function, named +`getRandomBuffer(size)` that returns a `Buffer` instance with random bytes. It +may not work depending on the engine that bitcore is running on (doesn't work +with IE versions lesser than 11). + +## bn + +The `bitcore.Crypto.BN` class contains a wrapper around +[bn.js](https://github.com/indutny/bn.js), the bignum library used internally +in bitcore. + +## point + +The `bitcore.Crypto.Point` class contains a wrapper around the class Point of +[elliptic.js](https://github.com/indutny/elliptic.js), the elliptic curve +library used internally in bitcore. + +## hash + +The `bitcore.Crypto.Hash` namespace contains a set of hashes and utilities. +These are either the native `crypto` hash functions from `node.js` or their +respective browser shims as provided by the `browserify` library. + +## ecdsa + +`bitcore.Crypto.ECDSA` contains a pure javascript implementation of the +elliptic curve DSA signature scheme. From 50b3d15491d91cca5fe631fee53e4c9ea8f6c065 Mon Sep 17 00:00:00 2001 From: Esteban Ordano Date: Mon, 24 Nov 2014 14:14:58 -0300 Subject: [PATCH 5/5] Some words about encoding --- docs/Encoding.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/Encoding.md b/docs/Encoding.md index e69de29..565c7a7 100644 --- a/docs/Encoding.md +++ b/docs/Encoding.md @@ -0,0 +1,20 @@ +# Encoding + +The `bitcore.Encoding` namespace contains utilities for encoding information in +common formats in the bitcoin ecosystem. + +## Base58 + +Two classes are provided: `Base58` and `Base58Check`. The first one merely +encodes/decodes a set of bytes in base58 format. The second one will also take +the double `sha256` hash of the information and append the last 4 bytes of the +hash as a checksum when encoding, and checking this checksum when decoding. + +## BufferReader & BufferWriter + +These classes are used internally to write information in buffers. + +## Varint + +The bitcore implementation uses a quite complex way of compressing integers +representing the size of fields.