Skip to content

Commit

Permalink
docs: provide docsify and improve documentation (#175)
Browse files Browse the repository at this point in the history
* chore: ignore whitespace trim on markdown docs

* docs: Address documentation docsified and improved

WIP

* docs: removed template file + readme update for badges

* docs(Address): fromScript, fromScriptHash, payingTo

* fix: jsdoc parameter

* docs: fixed Address

* docs: Block

* docs: BlockHeader

* docs: BloomFilter

* docs: HDPrivateKey

* docs: HDPublicKey

* docs: Message

* docs: Mnemonic

* docs: Transaction

* docs: URI

* docs: docsify sidebar update

* docs: added PrivateKey and PublicKey

* docs: added Opcode, Script, Input and Output

* docs: fixed jsdoc and typings for opcode

* docs(Address): added missing isValid  and getValidationError function

* docs: fixed typo

Co-authored-by: thephez <[email protected]>

* docs: fix various issues

* typo: fixed Transaction typo

Co-authored-by: thephez <[email protected]>

* docs: fixed sidebar

* fix: wrong description on docs

Co-authored-by: thephez <[email protected]>

* fix: typo

Co-authored-by: thephez <[email protected]>
  • Loading branch information
Alex-Werner and thephez committed Oct 1, 2020
1 parent 5b4afea commit a936787
Show file tree
Hide file tree
Showing 43 changed files with 2,782 additions and 23 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ root = true
[*]
end_of_line = lf
insert_final_newline = true

[*.{md,markdown}]
trim_trailing_whitespace = false
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ coverage

# ignore distribution files
dist/

# OS_X
.DS_Store
Empty file added docs/.nojekyll
Empty file.
35 changes: 35 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
## Dashcore-lib

[![NPM Version](https://img.shields.io/npm/v/@dashevo/dashcore-lib)](https://www.npmjs.com/package/@dashevo/dashcore-lib)
[![Build Status](https://travis-ci.com/dashevo/dashcore-lib.svg?branch=master)](https://travis-ci.com/dashevo/dashcore-lib)
[![Release Date](https://img.shields.io/github/release-date/dashevo/dashcore-lib)](https://github.com/dashevo/dashcore-lib/releases/latest)
[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen)](https://github.com/RichardLitt/standard-readme)

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

### Install

### ES5/ES6 via NPM

In order to use this library in Node, you will need to add it to your project as a dependency.

Having [NodeJS](https://nodejs.org/) installed, just type in your terminal :

```sh
npm install @dashevo/dashcore-lib
```

### CDN Standalone

For browser usage, you can also directly rely on unpkg :

```
<script src="https://unpkg.com/@dashevo/dashcore-lib"></script>
```


## Licence

[MIT](https://github.com/dashevo/dashcore-lib/blob/master/LICENCE.md) © Dash Core Group, Inc.
33 changes: 33 additions & 0 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
- Core Concepts
- [Address](core-concepts/Address.md)
- [Block](core-concepts/Block.md)
- [crypto](core-concepts/crypto.md)
- [encoding](core-concepts/encoding.md)
- [hierarchical](core-concepts/hierarchical.md)
- [Mnemonic](core-concepts/Mnemonic.md)
- [Networks](core-concepts/Networks.md)
- [PrivateKey](core-concepts/PrivateKey.md)
- [PublicKey](core-concepts/PublicKey.md)
- [Script](core-concepts/Script.md)
- [Transaction](core-concepts/Transaction.md)
- [Unit](core-concepts/Unit.md)
- [UnspentOutput](core-concepts/UnspentOutput.md)
- [Uri](core-concepts/Uri.md)
- [Examples](examples.md)
- Usage
- [Address](usage/Address.md)
- [Block](usage/Block.md)
- [BlockHeader](usage/BlockHeader.md)
- [BloomFilter](usage/BloomFilter.md)
- [HDPrivateKey](usage/HDPrivateKey.md)
- [HDPublicKey](usage/HDPublicKey.md)
- [PrivateKey](usage/PrivateKey.md)
- [PublicKey](usage/PublicKey.md)
- [Message](usage/Message.md)
- [Mnemonic](usage/Mnemonic.md)
- [Opcode](usage/Opcode.md)
- [Transaction](usage/Transaction.md)
- [Transaction.Input](usage/Transaction_Input.md)
- [Transaction.Output](usage/Transaction_Output.md)
- [URI](usage/URI.md)
- [License](https://github.com/dashevo/dashcore-lib/blob/master/LICENSE)
6 changes: 3 additions & 3 deletions docs/address.md → docs/core-concepts/Address.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
Represents a Dash address. Addresses are the most popular way to make Dash transactions. See [the Dash documentation](https://dash-docs.github.io/en/glossary/address) for technical background information.

## Instantiate an Address
To be able to receive some funds 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.
To be able to receive some funds 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 @@ -26,7 +26,7 @@ var publicKey = new PublicKey(privateKey);
var address = new Address(publicKey, Networks.testnet);
```

A pay-to-script-hash multisignature Address can be instantiated from an array of [PublicKeys](publickey.md).
A pay-to-script-hash multisignature Address can be instantiated from an array of [PublicKeys](PublicKey.md).

```javascript
// a 2-of-3 address from public keys
Expand Down
2 changes: 1 addition & 1 deletion docs/block.md → docs/core-concepts/Block.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ assert(block.header.nonce);
For more information about the specific properties of a block header please visit the [Block headers](https://dash-docs.github.io/en/developer-reference#block-headers) page on the Dash Developer Reference Wiki.

## Transactions
The set of transactions in a block is an array of instances of [Transaction](transaction.md) and can be explored by iterating on the block's `transactions` member.
The set of transactions in a block is an array of instances of [Transaction](Transaction.md) and can be explored by iterating on the block's `transactions` member.

```javascript
for (var i in block.transactions) {
Expand Down
8 changes: 4 additions & 4 deletions docs/mnemonic.md → docs/core-concepts/Mnemonic.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ code.toString(); // natal hada sutil año sólido papel jamón combate aula flot
var xpriv = code.toHDPrivateKey();
```

### Mnemonic generation
## Mnemonic generation

For creating a new random mnemonic code you just create a new instance.

Expand All @@ -22,7 +22,7 @@ var code = new Mnemonic();
code.toString(); // 'select scout crash enforce riot rival spring whale hollow radar rule sentence'
```

### Multi-language support
## Multi-language support

The `Mnemonic` class can use any list of 2048 unique words to generate the mnemonic code. For convenience the class provides default word lists for the following languages: English (default), Chinese, French, Japanese and Spanish. Those word list are published under `Mnemonic.Words.LANGUAGE`, take a look at the following example:

Expand All @@ -35,7 +35,7 @@ var myWordList = [ 'abandon', 'ability', 'able', 'about', 'above', ... ];
var customCode = new Mnemonic(myWordList);
```

### Validating a mnemonic
## Validating a mnemonic

The Mnemonic class provides a static method to check if a mnemonic string is valid. If you generated the mnemonic code using any of the default word list, the class will identify it, otherwise you must provide the word list used.

Expand All @@ -49,7 +49,7 @@ var valid = Mnemonic.isValid(code);
var validCutom = Mnemonic.isValid(code, customWordlist);
```

### Generating a private key
## Generating a private key

A mnemonic encodes entropy that can be used for creating a seed and later a [HDPrivateKey](hierarchical.md). During the seed generation process a passphrase can be used. The code for doing so looks like this:

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/publickey.md → docs/core-concepts/PublicKey.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Public Key
Represents a Dash public key and is needed to be able to receive funds, as is usually represented as a Dash [Address](address.md). See the official [Bitcoin Wiki](https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses).

A PublicKey in Dashcore is an immutable object and can be instantiated from a [Point](crypto.md), string, [PrivateKey](privatekey.md), Buffer or a [BN](crypto.md).
A PublicKey in Dashcore is an immutable object and can be instantiated from a [Point](crypto.md), string, [PrivateKey](PrivateKey.md), Buffer or a [BN](crypto.md).

## Instantiate a Public Key
Here is how to instantiate a public key:
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/transaction.md → docs/core-concepts/Transaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ transaction.applySignature(receivedSig);
```

## Adding inputs
Transaction inputs are instances of either [Input](lib/transaction/input) or its subclasses. `Input` has some abstract methods, as there is no actual concept of a "signed input" in the Dash scripting system (just valid signatures for <tt>OP_CHECKSIG</tt> and similar opcodes). They are stored in the `input` property of `Transaction` instances.
Transaction inputs are instances of either [Input](../../lib/transaction/input) or its subclasses. `Input` has some abstract methods, as there is no actual concept of a "signed input" in the Dash scripting system (just valid signatures for <tt>OP_CHECKSIG</tt> and similar opcodes). They are stored in the `input` property of `Transaction` instances.

Dashcore contains two implementations of `Input`, one for spending _Pay to Public Key Hash_ outputs (called `PublicKeyHashInput`) and another to spend _Pay to Script Hash_ outputs for which the redeem script is a Multisig script (called `MultisigScriptHashInput`).

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Create and derive extended public and private keys according to the BIP32 standa
Dashcore 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
An instance of a [PrivateKey](privatekey.md) that also contains information required to derive child keys.
An instance of a [PrivateKey](PrivateKey.md) that also contains information required to derive child keys.

Sample usage:

Expand Down
39 changes: 39 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Dashcore-Lib - A pure and powerful JavaScript Dash library</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="keywords" content="dashcore, dash, javascript, primitives, address, block, HDKeys, PublicKey, PrivateKey, Mnemonic">
<meta name="description" content="A pure and powerful JavaScript Dash library.">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css">
</head>
<body>
<div id="app"></div>
<script>
window.$docsify = {
name: 'Dashcore-lib',
repo: 'https://github.com/dashevo/dashcore-lib',
loadSidebar: "_sidebar.md",
maxLevel: 4,
subMaxLevel: 2,
search: {
noData: {
'/': 'No results!'
},
paths: 'auto',
placeholder: {
'/': 'Search'
}
},
// search: 'auto',
formatUpdated: '{MM}/{DD} {HH}:{mm}',
themeColor: '#008de4',
}
</script>
<script src="https://cdn.jsdelivr.net/npm/docsify@4"></script>
<script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/docsify-tabs@1"></script>
</body>
</html>
Loading

0 comments on commit a936787

Please sign in to comment.