diff --git a/docs/config.json b/docs/config.json new file mode 100644 index 0000000..76f478a --- /dev/null +++ b/docs/config.json @@ -0,0 +1,6 @@ +{ + "useSideMenu": true, + "lineBreaks": "gfm", + "additionalFooterText": "Bitcore™ © 2013-2014 BitPay, Inc. Bitcore is released under the MIT license. ", + "anchorCharacter": "#" +} \ No newline at end of file diff --git a/docs/examples.md b/docs/examples.md new file mode 100644 index 0000000..2e659c5 --- /dev/null +++ b/docs/examples.md @@ -0,0 +1,43 @@ +# Examples + +## Create a private key + +``` +var privKey = new bitcore.PrivateKey(); +``` + +## Create an Address +``` +var privKey = new bitcore.PrivateKey(); +var address = privKey.toAddress(); +``` + +## Create a Multisig Address +``` +??? +``` + +## Request a Payment +``` +var paymentInfo = { + address: '1DNtTk4PUCGAdiNETAzQFWZiy2fCHtGnPx', + amount: 120000 //satoshis +}; +var uri = new bitcore.URI(paymentInfo).toString(); +``` + +## Create a transaction +``` +??? +``` + +## Connect to the network +``` +var peer = new Peer('5.9.85.34'); + +peer.on('inv', function(message) { + // new invetory +}); + +peer.connect(); +``` diff --git a/docs/Crypto.md b/docs/helpers/Crypto.md similarity index 88% rename from docs/Crypto.md rename to docs/helpers/Crypto.md index f1566f3..858e769 100644 --- a/docs/Crypto.md +++ b/docs/helpers/Crypto.md @@ -1,23 +1,25 @@ -# Crypto +# > `bitcore.crypto` + +## Description The cryptographic primitives (ECDSA and HMAC) implementations in this package have been audited bythe BitPay engineering team. More review and certifications are always welcomed. -## random +## 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). +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 +## 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 +## 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 +## 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 +## ECDSA `bitcore.Crypto.ECDSA` contains a pure javascript implementation of the elliptic curve DSA signature scheme. diff --git a/docs/Encoding.md b/docs/helpers/Encoding.md similarity index 89% rename from docs/Encoding.md rename to docs/helpers/Encoding.md index 932369b..bb86d78 100644 --- a/docs/Encoding.md +++ b/docs/helpers/Encoding.md @@ -1,8 +1,10 @@ -# Encoding +# > `bitcore.encoding` + +## Description The `bitcore.Encoding` namespace contains utilities for encoding information in common formats in the bitcoin ecosystem. -## Base58 +## Base58 & Base58Check 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 check this checksum when decoding. diff --git a/docs/Networks.md b/docs/helpers/Networks.md similarity index 97% rename from docs/Networks.md rename to docs/helpers/Networks.md index 59f053c..3c66807 100644 --- a/docs/Networks.md +++ b/docs/helpers/Networks.md @@ -1,4 +1,6 @@ -# Networks +# > `bitcore.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. diff --git a/docs/URI.md b/docs/helpers/URI.md similarity index 84% rename from docs/URI.md rename to docs/helpers/URI.md index 5bcc7f7..33c03a0 100644 --- a/docs/URI.md +++ b/docs/helpers/URI.md @@ -1,4 +1,6 @@ -# URI +# > `bitcore.URI` + +## Description Represents a bitcoin payment uri. Bitcoin URI strings became the most popular way to share payment request, sometimes as a bitcoin link and others using a QR code. @@ -9,6 +11,8 @@ bitcoin:12A1MyfXbW6RhdRAZEqofac5jCQQjwEPBu?amount=1.2 bitcoin:12A1MyfXbW6RhdRAZEqofac5jCQQjwEPBu?amount=1.2&message=Payment&label=Satoshi&extra=other-param ``` +## URI Validation + The main use that we expect you'll have for the `URI` class in bitcore is validating and parsing bitcoin URIs. A `URI` instance exposes the address as a bitcore `Address` object and the amount in Satoshis, if present. The code for validating uris looks like this: @@ -19,11 +23,14 @@ var uri = new URI(uriString); console.log(uri.address.network, uri.amount); // 'livenet', 120000000 ``` +## URI Parameters All standard parameters can be found as members of the `URI` instance. However a bitcoin uri may contain other non-standard parameters, all those can be found under the `extra` namespace. See [the official BIP21 spec](https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki) for more information. -Other usecase important usecase for the `URI` class is creating a bitcoin URI for sharing a payment request. That can be acomplished by using an Object to create an instance of URI. +## Create URI + +Another important usecase for the `URI` class is creating a bitcoin URI for sharing a payment request. That can be acomplished by using a dictionary to create an instance of URI. The code for creating an URI from an Object looks like this: ```javascript diff --git a/docs/Unit.md b/docs/helpers/Unit.md similarity index 87% rename from docs/Unit.md rename to docs/helpers/Unit.md index 2639148..05d4ea9 100644 --- a/docs/Unit.md +++ b/docs/helpers/Unit.md @@ -1,8 +1,12 @@ -# Unit +# > `bitcore.Unit` + +## Description Unit is an utility for handling and converting bitcoins units. We strongly recommend you to always use satoshis to represent amount inside your application and only convert them to other units in the front-end. -The supported units are BTC, mBTC, bits and satoshis. The codes for each unit can be found as members of the Unit class. +## Supported units + +The supported units are BTC, mBTC, bits (micro BTCs, uBTC) and satoshis. The codes for each unit can be found as members of the Unit class. ```javascript var btcCode = Unit.BTC; @@ -12,6 +16,8 @@ var bitsCode = Unit.bits; var satsCode = Unit.satoshis; ``` +## Creating units + There are two ways for creating a unit instance. You can instanciate the class using a value and a unit code; alternatively if the unit it's fixed you could you some of the static methods. Check some examples below: ```javascript @@ -29,6 +35,8 @@ unit = Unit.fromBits(amount); unit = Unit.fromSatoshis(amount); ``` +## Conversion + Once you have a unit instance, you can check it's representantion in all the available units. For your convinience the classes expose three ways to acomplish this. Using the `.to(unitCode)` method, using a fixed unit like `.toSatoshis()` or by using the accessors. ```javascript diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..c0b0f69 --- /dev/null +++ b/docs/index.html @@ -0,0 +1,212 @@ + + + +
+