Skip to content

Commit

Permalink
Proofread Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Braydon Fuller committed Dec 19, 2014
1 parent 7d015b1 commit 3e1ca2b
Show file tree
Hide file tree
Showing 23 changed files with 53 additions and 118 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ coverage
node_modules
browser/bitcore.js
browser/tests.js
docs/api

lib/errors/index.js

Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Contributing to Bitcore
=======

We're working hard to make *bitcore* the easiest and most powerful javascript library for working with bitcoin. Our goal is to have *bitcore* be a library that can be used by anyone interested in bitcoin, and level the expertise differences with agreat design and documentation.
We're working hard to make *bitcore* the most powerful JavaScript library for working with bitcoin. Our goal is to have *bitcore* be a library that can be used by anyone interested in bitcoin, and to level expertise differences with great design and documentation.

## Quick checklist
## Quick Checklist

Make sure:

Expand Down Expand Up @@ -41,7 +41,7 @@ Consistency on the way classes are used is paramount to allow an easier understa

## Style Guidelines

The design guidelines have quite a high abstraction level. These style guidelines are more concreate and easier to apply, and also more opinionated. The design guidelines mentioned above are the way we think about general software development and we believe they should be present in any software project.
The design guidelines have quite a high abstraction level. These style guidelines are more concrete and easier to apply, and also more opinionated. The design guidelines mentioned above are the way we think about general software development and we believe they should be present in any software project.

### G0 - General: Default to Felixge's Style Guide

Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,19 @@ Bitcore
[![Build Status](https://img.shields.io/travis/bitpay/bitcore.svg?branch=master&style=flat-square)](https://travis-ci.org/bitpay/bitcore)
[![Coverage Status](https://img.shields.io/coveralls/bitpay/bitcore.svg?style=flat-square)](https://coveralls.io/r/bitpay/bitcore)

A pure and simple javascript bitcoin API.
A pure and simple JavaScript bitcoin API.

## Principles

Bitcoin is a powerful new peer-to-peer platform for the next generation of financial technology. The decentralized nature of the Bitcoin network allows for highly resilient bitcoin infrastructure, and the developer community needs reliable, open-source tools to implement bitcoin apps and services.

## Get Started

You can run bitcore on any javascript engine. It's distributed through npm, and you can also find compiled single files here: [bitcore.js](https://bitcore.io/bitcore/dist/bitcore.js) and [bitcore.min.js](https://bitcore.io/bitcore/dist/bitcore.min.js).

```
npm install bitcore
```

Using it on node.js:
Using it in Node.js:

```javascript
var bitcore = require('bitcore');
Expand All @@ -46,7 +44,7 @@ Bitcore is still under heavy development and not quite ready for "drop-in" produ

Please send pull requests for bug fixes, code optimization, and ideas for improvement.

## Building the browser bundle
## Building the Browser Bundle

To build bitcore full bundle for the browser:

Expand Down
6 changes: 3 additions & 3 deletions docs/guide/examples.md → docs/api/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Examples

## Create a private key
## Create a Private Key

```
var privKey = new bitcore.PrivateKey();
Expand All @@ -27,7 +27,7 @@ var paymentInfo = {
var uri = new bitcore.URI(paymentInfo).toString();
```

## Create a transaction
## Create a Transaction
```
var transaction = new Transaction()
.from(utxos) // Feed information about what unspend outputs one can use
Expand All @@ -36,7 +36,7 @@ var transaction = new Transaction()
.sign(privkeySet) // Signs all the inputs it can
```

## Connect to the network
## Connect to the Network
```
var peer = new Peer('5.9.85.34');
Expand Down
10 changes: 5 additions & 5 deletions docs/guide/address.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# > `bitcore.Address`
# Address

## Description

Represents a bitcoin Address. Addresses became the most popular way to make bitcoin transactions. See [the official Bitcoin Wiki](https://en.bitcoin.it/wiki/Address) for more information.
Represents a bitcoin Address. Addresses are the most popular way to make bitcoin transactions. See [the official Bitcoin Wiki](https://en.bitcoin.it/wiki/Address) for technical background information.

## Instantiate an Address

To be able to receive bitcoins an address is needed, but in order to spend them a private key is necessary. Take a look at the [`PrivateKey`](PrivateKey.md) docs for more information about exporting and saving a key.
To be able to receive bitcoins an address is needed, but in order to spend them a private key is necessary. Please take a look at the [`PrivateKey`](PrivateKey.md) docs for more information about exporting and saving a key.

```javascript
var privateKey = new PrivateKey();
var address = privateKey.toAddress();
```

You can also instantiate an address from a String, [PublicKey](PublicKey.md), or [HDPublicKey](Hierarchical.md), in case you are not the owner of the private key.
You can also instantiate an Address from a String, [PublicKey](PublicKey.md), or [HDPublicKey](Hierarchical.md), in case you are not the owner of the private key.

```javascript
// from a string
Expand All @@ -32,7 +32,7 @@ var address = new Address(publicKey, Networks.testnet);

## Validating an Address

The main use that we expect you'll have for the `Address` class in bitcore is validating that an address is a valid one, what type of address it is (you may be interested on knowing if the address is a simple "pay to public key hash" address or a "pay to script hash" address) and what network does the address belong to.
The main use that we expect you'll have for the `Address` class in Bitcore is validating that an address is a valid one, what type of address it is (you may be interested on knowing if the address is a simple "pay to public key hash" address or a "pay to script hash" address) and what network does the address belong to.

The code to do these validations looks like this:

Expand Down
4 changes: 2 additions & 2 deletions docs/guide/block.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# > `bitcore.Block`
# Block

## Description

A Block instance represents the information on a block in the bitcoin network. Given a hexa or base64 string representation of the serialization of a block with its transactions, you can instantiate a Block instance. Methods are provided to calculate and check the merkle root hash (if enough data is provided), but transactions won't necessarily 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.
A Block instance represents the information of a block in the bitcoin network. Given a hexa or base64 string representation of the serialization of a block with its transactions, you can instantiate a Block instance. Methods are provided to calculate and check the merkle root hash (if enough data is provided), but transactions won't necessarily 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

Expand Down
6 changes: 3 additions & 3 deletions docs/guide/crypto.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# > `bitcore.crypto`
# Crypto

## Description

Expand All @@ -14,12 +14,12 @@ The `bitcore.Crypto.BN` class contains a wrapper around [bn.js](https://github.c

## 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.
The `bitcore.Crypto.Point` class contains a wrapper around the class Point of [elliptic.js](https://github.com/indutny/elliptic), 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.
`bitcore.Crypto.ECDSA` contains a pure JavaScript implementation of the elliptic curve DSA signature scheme.
4 changes: 2 additions & 2 deletions docs/guide/ecies.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# > `bitcore-ecies`
# ECIES

## Description

Bitcore implements [Elliptic Curve Integrated Encryption Scheme (ECIES)](http://en.wikipedia.org/wiki/Integrated_Encryption_Scheme), which is a public key encryption system that performs bulk encryption on data usinc a symmetric cipher and a random key.
Bitcore implements [Elliptic Curve Integrated Encryption Scheme (ECIES)](http://en.wikipedia.org/wiki/Integrated_Encryption_Scheme), which is a public key encryption system that performs bulk encryption on data using a symmetric cipher and a random key.

For more information refer to the [bitcore-ecies](https://github.com/bitpay/bitcore-ecies) github repo.

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/encoding.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# > `bitcore.encoding`
# Encoding

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/hierarchical.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# > `bitcore.HDKeys`
# HDKeys

## Hierarichically Derived Keys

Expand Down
28 changes: 0 additions & 28 deletions docs/guide/index.md

This file was deleted.

4 changes: 2 additions & 2 deletions docs/guide/jsonrpc.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# > `bitcore.transport.RPC`
# JSON-RPC

## Description

Bitcoind provides a direct interface to the bitcoin network and it also exposes a `JSON-RPC` API. This class allows to connect to a local instance of a bitcoind server and make simple or batch RPC calls to it.
Bitcoind provides a direct interface to the bitcoin network and it also exposes a `JSON-RPC` API. This class will connect to a local instance of a bitcoind server and make simple or batch RPC calls to it.

## Connection to bitcoind

Expand Down
30 changes: 0 additions & 30 deletions docs/guide/navigation.md

This file was deleted.

8 changes: 4 additions & 4 deletions docs/guide/networks.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# > `bitcore.Networks`
# Networks

## Description

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.
Bitcore provides support for 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.

The `Network` namespace has a function, `get(...)` that returns an instance of a `Network` or `undefined`. The only argument to this function is some kind of identifier of the network: either its name, a reference to a Network object, or a number used as a magic constant to identify the network (for example, the value `0` that gives bitcoin addresses the distinctive `'1'` at its beginning on livenet, is a `0x6F` for testnet).

## Setting the default network
## 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`).
Most projects will only need to work with one of the networks. The value of `Networks.defaultNetwork` can be set to `Networks.testnet` if the project will need to only to work on testnet (the default is `Networks.livenet`).

## Network constants

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/paymentprotocol.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# > `bitcore.PaymentProtocol`
# Payment Protocol

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/peer.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# > `bitcore.transport.Peer`
# Peer

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/pool.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# > `bitcore.transport.Pool`
# Pool

## Pool

Expand Down
4 changes: 2 additions & 2 deletions docs/guide/privatekey.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# > `bitcore.PrivateKey`
# Private Key

## Description

Represents a bitcoin private key and is needed to be able to spend bitcoin and sign transactions. See the official [Bitcoin Wiki](https://en.bitcoin.it/wiki/Private_key) for more information about private keys. A PrivateKey in Bitcore is an immutable object that has methods to import and export into a variety of formats including [Wallet Import Format](https://en.bitcoin.it/wiki/Wallet_import_format).

## Instantiate a Private Key

Here is how to create a new private key. It will generate a new random number using `window.crypto` or the Node.js 'crypto' library.
Here is how to create a new private key. It will generate a new random number using `window.crypto` or the Node.js `crypto` library.

```javascript
var privateKey = new PrivateKey();
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/publickey.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# > `bitcore.PublicKey`
# Public Key

## Description

Expand Down
13 changes: 5 additions & 8 deletions docs/guide/script.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# > `bitcore.Script`
# Script

## Description

Expand Down Expand Up @@ -83,7 +83,7 @@ var script = Script.buildDataOut(data);
assert(script.toString() === 'OP_RETURN 14 0x68656c6c6f20776f726c64212121'
```
### Custom scripts
### Custom Scripts
To create a custom `Script` instance, you must rely on the lower-level methods `add` and `prepend`. Both methods accept the same parameter types, and insert an opcode or data at the beginning (`prepend`) or end (`add`) of the `Script`.
Expand All @@ -97,10 +97,9 @@ var script = Script()
assert(script.toString() === 'OP_2SWAP OP_IF OP_NOT 4 0xbacacafe');
```
## Script Parsing and Identification
## Script parsing and identification
`Script` has an easy interface to parse raw scripts from the newtwork or bitcoind, and to extract useful information. An illustrative example (for more options check the API reference)
`Script` has an easy interface to parse raw scripts from the network or bitcoind, and to extract useful information. An illustrative example (for more options check the API reference)
```javascript
var raw_script = new Buffer('5221022df8750480ad5b26950b25c7ba79d3e37d75f640f8e5d9bcd5b150a0f85014da2103e3818b65bcc73a7d64064106a859cc1a5a728c4345ff0b641209fba0d90de6e921021f2f6e1e50cb6a953935c3601284925decd3fd21bc445712576873fb8c6ebc1853ae', 'hex');
Expand All @@ -113,8 +112,7 @@ s.isScriptHashOut() // false
s.isMultisigOut() // true
```
## Script interpreting and validation
## Script Interpreting and Validation
To validate a transaction, the bitcoin network validates all of its inputs and outputs. To validate an input, the input's script is concatenated with the referenced output script, and the result is executed. If at the end of execution the stack contains a 'true' value, then the transaction is valid.
You can do this in `bitcore` by using the `Interpreter` class. The entry point (and probably the only interface you'll need for most applications) is the method `Interpreter#verify()`.
Expand Down Expand Up @@ -147,4 +145,3 @@ var scriptSig = Script.buildPublicKeyHashIn(publicKey, signature);
var flags = Interpreter.SCRIPT_VERIFY_P2SH | Interpreter.SCRIPT_VERIFY_STRICTENC;
var verified = Interpreter().verify(scriptSig, scriptPubkey, tx, inputIndex, flags);
```
15 changes: 6 additions & 9 deletions docs/guide/transaction.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# > `bitcore.Transaction`
# Transaction

## Description

Expand Down Expand Up @@ -34,15 +34,13 @@ var transaction = new Transaction().fee(1e8); // Generous fee of 1 BTC

## Transaction API

You can take a look at the javadocs for the [Transaction class here](link missing).

## Input

Transaction inputs are instances of either [Input](https://github.com/bitpay/bitcore/tree/master/lib/transaction/input) or its subclasses. The internal workings of it can be understood from the [API reference](link missing).
Transaction inputs are instances of either [Input](https://github.com/bitpay/bitcore/tree/master/lib/transaction/input) or its subclasses.

## Output

Transaction outputs are a very thin wrap around the information provided by a transaction output: its script and its output amount.
Transaction outputs are a very thin wrapper around the information provided by a transaction output: its script and its output amount.

## Multisig Transactions

Expand All @@ -57,13 +55,12 @@ To send a transaction to a multisig address, the API is the same as in the above
var serialized = multiSigTx.serialize();
```

This can be serialized and sent to another party, to complete with the needed
signatures:
This can be serialized and sent to another party, to complete with the needed signatures:

```javascript
var multiSigTx = new Transaction(serialized)
.from(utxo, publicKeys, threshold) // provide info about the multisig output
// (lost on serialization)
// (lost on serialization)
.sign(anotherSetOfKeys);

assert(multiSigTx.isFullySigned());
Expand All @@ -86,7 +83,7 @@ There are a number of data structures being stored internally in a `Transaction`

If you have a larger set of unspent outputs, only some of them will be selected to fulfill the amount. This is done by storing a cache of unspent outputs in a protected member called `_utxos`. When the `to()` method is called, some of these outputs will be selected to pay the requested amount to the appropriate address.

A nit that you should have in mind is that when the transaction is serialized, this cache can't be included in the serialized form.
A detail that you should have in mind is that when the transaction is serialized, this cache can't be included in the serialized form.

## Upcoming changes

Expand Down
Loading

0 comments on commit 3e1ca2b

Please sign in to comment.