Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

Commit

Permalink
Litecoin: Modify for Litecoin
Browse files Browse the repository at this point in the history
  • Loading branch information
Charlie Lee committed Sep 13, 2016
1 parent 047fe81 commit 015aad5
Show file tree
Hide file tree
Showing 30 changed files with 209 additions and 209 deletions.
2 changes: 1 addition & 1 deletion .jsdoc.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"lenient": true
},
"templates": {
"systemName": "bitcore",
"systemName": "litecore",
"copyright": "© 2013-2015, BitPay Inc.",
"navType": "vertical",
"theme": "journal",
Expand Down
32 changes: 16 additions & 16 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Contributing to Bitcore
Contributing to Litecore
=======

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.
We're working hard to make *litecore* the most powerful JavaScript library for working with litecoin. Our goal is to have *litecore* be a library that can be used by anyone interested in litecoin, and to level expertise differences with great design and documentation.

## Community

Expand All @@ -20,7 +20,7 @@ Ideally, please make sure to run:

## Design Guidelines

These are some global design goals in bitcore that any change must adhere.
These are some global design goals in litecore that any change must adhere.

### D1 - Naming Matters

Expand All @@ -40,7 +40,7 @@ Write a test for all your code. We encourage Test Driven Development so we know

Interfaces should accept as many types of arguments as possible, so there's no mental tax on using them: we want to avoid questions such as "should I use a string here or a buffer?", "what happens if I'm not sure if the type of this variable is an Address instance or a string with it encoded in base-58?" or "what kind of object will I receive after calling this function?".

Accept a wide variety of use cases and arguments, always return an internal form of an object. For example, the class `PublicKey` can accept strings or buffers with a DER encoded public key (either compressed or uncompressed), another PublicKey, a PrivateKey, or a Point, an instance of the `elliptic.js` library with the point in bitcoin's elliptic curve that represents the public key.
Accept a wide variety of use cases and arguments, always return an internal form of an object. For example, the class `PublicKey` can accept strings or buffers with a DER encoded public key (either compressed or uncompressed), another PublicKey, a PrivateKey, or a Point, an instance of the `elliptic.js` library with the point in litecoin's elliptic curve that represents the public key.

### D4 - Consistency Everywhere

Expand Down Expand Up @@ -91,7 +91,7 @@ var bufferUtil = require('./util/buffer');

#### G7 - Standard Methods

When possible, bitcore objects should have standard methods on an instance prototype:
When possible, litecore objects should have standard methods on an instance prototype:
* `toObject/toJSON` - A plain JavaScript object that `JSON.stringify` can call
* `toString` - A string representation of the instance
* `toBuffer` - A hex Buffer
Expand All @@ -101,7 +101,7 @@ These should have a matching static method that can be used for instantiation:
* `fromString` - Should be able to instantiate with output from `toString`
* `fromBuffer` - Should likewise be able to instantiate from output from `toBuffer`

`JSON.stringify` and `JSON.parse` are expected to be handled outside of the scope of Bitcore methods. For example, calling `JSON.stringify` on an Bitcore object will behave as expected and call `transaction.toJSON()` and then stringify it:
`JSON.stringify` and `JSON.parse` are expected to be handled outside of the scope of Litecore methods. For example, calling `JSON.stringify` on a Litecore object will behave as expected and call `transaction.toJSON()` and then stringify it:

```javascript
var transactionString = JSON.stringify(transaction);
Expand All @@ -116,7 +116,7 @@ var tx = new Transaction(data);

### Errors

#### E1 - Use bitcore.Errors
#### E1 - Use litecore.Errors

We've designed a structure for Errors to follow and are slowly migrating to it.

Expand Down Expand Up @@ -206,14 +206,14 @@ Don't write long tests, write helper functions to make them be as short and conc

Inputs for tests should not be generated randomly. Also, the type and structure of outputs should be checked.

#### T3 - Require 'bitcore' and Look up Classes from There
#### T3 - Require 'litecore' and Look up Classes from There

This helps to make tests more useful as examples, and more independent of where they are placed. This also helps prevent forgetting to include all submodules in the bitcore object.
This helps to make tests more useful as examples, and more independent of where they are placed. This also helps prevent forgetting to include all submodules in the litecore object.

DO:
```javascript
var bitcore = require('../');
var PublicKey = bitcore.PublicKey;
var litecore = require('../');
var PublicKey = litecore.PublicKey;
```
DON'T:
```javascript
Expand Down Expand Up @@ -246,8 +246,8 @@ git checkout -b remove/some-file

We expect pull requests to be rebased to the master branch before merging:
```sh
git remote add bitpay git@github.com:bitpay/bitcore.git
git pull --rebase bitpay master
git remote add litecoin-project git@github.com:litecoin-project/litecore.git
git pull --rebase litecoin-project master
```

Note that we require rebasing your branch instead of merging it, for commit readability reasons.
Expand All @@ -258,11 +258,11 @@ git push origin your_branch_name
git push origin feature/some-new-stuff
git push origin fix/some-bug
```
Finally go to [github.com/bitpay/bitcore](https://github.com/bitpay/bitcore) in your web browser and issue a new pull request.
Finally go to [github.com/litecoin-project/litecore](https://github.com/litecoin-project/litecore) in your web browser and issue a new pull request.

Main contributors will review your code and possibly ask for changes before your code is pulled in to the main repository. We'll check that all tests pass, review the coding style, and check for general code correctness. If everything is OK, we'll merge your pull request and your code will be part of bitcore.
Main contributors will review your code and possibly ask for changes before your code is pulled in to the main repository. We'll check that all tests pass, review the coding style, and check for general code correctness. If everything is OK, we'll merge your pull request and your code will be part of litecore.

If you have any questions feel free to post them to
[github.com/bitpay/bitcore/issues](https://github.com/bitpay/bitcore/issues).
[github.com/litecoin-project/litecore/issues](https://github.com/litecoin-project/litecore/issues).

Thanks for your time and code!
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ bower install litecore-lib

## Documentation

The complete docs are hosted here: [litecore documentation](http://bitcore.io/guide/). There's also a [litecore API reference](http://bitcore.io/api/) available generated from the JSDocs of the project, where you'll find low-level details on each litecore utility.
The complete docs are hosted here: [litecore documentation](http://litecore.io/guide/). There's also a [litecore API reference](http://litecore.io/api/) available generated from the JSDocs of the project, where you'll find low-level details on each litecore utility.

- [Read the Developer Guide](http://bitcore.io/guide/)
- [Read the API Reference](http://bitcore.io/api/)
- [Read the Developer Guide](http://litecore.io/guide/)
- [Read the API Reference](http://litecore.io/api/)

To get community assistance and ask for help with implementation questions, please use our [community forums](https://forum.bitcore.io/).
To get community assistance and ask for help with implementation questions, please use our [community forums](https://forum.litecore.io/).

## Examples

Expand All @@ -45,7 +45,7 @@ To get community assistance and ask for help with implementation questions, plea

## Security

We're using Litecore in production, as are [many others](http://bitcore.io#projects), but please use common sense when doing anything related to finances! We take no responsibility for your implementation decisions.
We're using Litecore in production, as are [many others](http://litecore.io#projects), but please use common sense when doing anything related to finances! We take no responsibility for your implementation decisions.

If you find a security issue, please email security@bitpay.com.

Expand Down
4 changes: 2 additions & 2 deletions benchmark/script.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

var benchmark = require('benchmark');
var bitcore = require('..');
var litecore = require('..');
var async = require('async');
var blockData = require('./block-357238.json');

Expand All @@ -15,7 +15,7 @@ async.series([

var c = 0;
var scripts = [];
var block = bitcore.Block.fromString(blockData);
var block = litecore.Block.fromString(blockData);
for (var i = 0; i < block.transactions.length; i++) {
var tx = block.transactions[i];
for (var j = 0; j < tx.inputs.length; j++) {
Expand Down
18 changes: 9 additions & 9 deletions benchmark/serialization.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

var benchmark = require('benchmark');
var bitcore = require('..');
var litecore = require('..');
var bitcoinjs = require('bitcoinjs-lib');
var bcoin = require('bcoin');
var async = require('async');
Expand All @@ -22,13 +22,13 @@ async.series([
for (var i = 0; i < 100; i++) {

// uint64le
var br = new bitcore.encoding.BufferWriter();
var br = new litecore.encoding.BufferWriter();
var num = Math.round(Math.random() * 10000000000000);
br.writeUInt64LEBN(new bitcore.crypto.BN(num));
br.writeUInt64LEBN(new litecore.crypto.BN(num));
buffers.push(br.toBuffer());

// hashes
var data = bitcore.crypto.Hash.sha256sha256(new Buffer(32));
var data = litecore.crypto.Hash.sha256sha256(new Buffer(32));
hashBuffers.push(data);
}

Expand All @@ -40,7 +40,7 @@ async.series([
c = 0;
}
var buf = buffers[c];
var br = new bitcore.encoding.BufferReader(buf);
var br = new litecore.encoding.BufferReader(buf);
bn = br.readUInt64LEBN();
c++;
}
Expand All @@ -52,7 +52,7 @@ async.series([
c = 0;
}
var buf = hashBuffers[c];
var br = new bitcore.encoding.BufferReader(buf);
var br = new litecore.encoding.BufferReader(buf);
reversed = br.readReverse();
c++;
}
Expand All @@ -79,8 +79,8 @@ async.series([
var block2;
var block3;

function bitcoreTest() {
block1 = bitcore.Block.fromString(blockData);
function litecoreTest() {
block1 = litecore.Block.fromString(blockData);
}

function bitcoinJSTest() {
Expand All @@ -102,7 +102,7 @@ async.series([
}

var suite = new benchmark.Suite();
suite.add('bitcore', bitcoreTest, {maxTime: maxTime});
suite.add('litecore', litecoreTest, {maxTime: maxTime});
suite.add('bitcoinjs', bitcoinJSTest, {maxTime: maxTime});
suite.add('bcoin', bcoinTest, {maxTime: maxTime});
suite.add('fullnode', fullnodeTest, {maxTime: maxTime});
Expand Down
12 changes: 6 additions & 6 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "bitcore-lib",
"main": "./bitcore-lib.min.js",
"name": "litecore-lib",
"main": "./litecore-lib.min.js",
"version": "0.13.19",
"homepage": "http://bitcore.io",
"homepage": "http://litecore.io",
"authors": [
"BitPay, Inc."
],
"description": "A pure, powerful core for your bitcoin project.",
"description": "A pure, powerful core for your litecoin project.",
"moduleType": [
"globals"
],
"keywords": [
"bitcoin",
"bitcore",
"litecoin",
"litecore",
"btc",
"satoshi"
],
Expand Down
6 changes: 3 additions & 3 deletions docs/address.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
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. Please 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();
Expand Down Expand Up @@ -34,7 +34,7 @@ var p2shAddress = new Address([publicKey1, publicKey2, publicKey3], 2);
```

## 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 Litecore 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 Expand Up @@ -62,4 +62,4 @@ var error = Address.getValidationError(input, Networks.testnet);
}
```
The errors are listed in the generated file in the [errors folder](https://github.com/bitpay/bitcore/tree/master/lib/errors). There's a structure to errors defined in the [spec.js file](https://github.com/bitpay/bitcore/tree/master/lib/errors/spec.js).
The errors are listed in the generated file in the [errors folder](https://github.com/litecoin-project/litecore/tree/master/lib/errors). There's a structure to errors defined in the [spec.js file](https://github.com/litecoin-project/litecore/tree/master/lib/errors/spec.js).
16 changes: 8 additions & 8 deletions docs/browser.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Browser Builds
Bitcore and most official submodules work in the browser, thanks to [browserify](http://browserify.org/) (some modules are not fully compatible with web browsers).
Litecore and most official submodules work in the browser, thanks to [browserify](http://browserify.org/) (some modules are not fully compatible with web browsers).

The easiest and recommended way to use them, is via [Bower](http://bower.io/), a browser package manager, and get the release bundles. For example, when building an app that uses `bitcore` and `bitcore-mnemonic`, you do:
The easiest and recommended way to use them, is via [Bower](http://bower.io/), a browser package manager, and get the release bundles. For example, when building an app that uses `litecore` and `bitcore-mnemonic`, you do:

```sh
bower install bitcore-lib
bower install litecore-lib
bower install bitcore-mnemonic
```

Expand All @@ -16,7 +16,7 @@ You can also use a `bower.json` file to store the dependencies of your project:
"version": "0.0.1",
"license": "MIT",
"dependencies": {
"bitcore-lib": "^0.13.7",
"litecore-lib": "^0.13.7",
"bitcore-mnemonic": "^1.0.1"
}
}
Expand All @@ -32,14 +32,14 @@ After this, you can include the bundled release versions in your HTML file:

<head>
<meta charset="utf-8">
<script src="bower_components/bitcore/bitcore-lib.min.js"></script>
<script src="bower_components/litecore/litecore-lib.min.js"></script>
<script src="bower_components/bitcore-mnemonic/bitcore-mnemonic.min.js"></script>
</head>

<body>

<script type="text/javascript">
var bitcore = require('bitcore-lib');
var litecore = require('litecore-lib');
var Mnemonic = require('bitcore-mnemonic');
// etc...
</script>
Expand All @@ -53,11 +53,11 @@ After this, you can include the bundled release versions in your HTML file:
If you want to use a specific version of a module, instead of a release version (not recommended), you must run browserify yourself. You can get a minified browser bundle by running the following on the project root folder.

```sh
browserify --require ./index.js:bitcore-lib | uglifyjs > bitcore-lib.min.js
browserify --require ./index.js:litecore-lib | uglifyjs > litecore-lib.min.js
```

```sh
browserify --require ./index.js:bitcore-mnemonic --external bitcore-lib | uglifyjs > bitcore-mnemonic.min.js
browserify --require ./index.js:bitcore-mnemonic --external litecore-lib | uglifyjs > bitcore-mnemonic.min.js
```

In many of the modules you can also run the command to build a browser bundle:
Expand Down
10 changes: 5 additions & 5 deletions docs/crypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
The cryptographic primitives (ECDSA and HMAC) implementations in this package have been reviewed by the BitPay engineering team. More audits and reviews are welcomed.

## 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 `litecore.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 litecore 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.
The `litecore.Crypto.BN` class contains a wrapper around [bn.js](https://github.com/indutny/bn.js), the bignum library used internally in litecore.

## Point
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.
The `litecore.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 litecore.

## 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.
The `litecore.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 based on [elliptic.js](https://github.com/indutny/elliptic).
`litecore.Crypto.ECDSA` contains a pure JavaScript implementation of the elliptic curve DSA signature scheme based on [elliptic.js](https://github.com/indutny/elliptic).
2 changes: 1 addition & 1 deletion docs/encoding.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Encoding
The `bitcore.Encoding` namespace contains utilities for encoding information in common formats in the bitcoin ecosystem.
The `litecore.Encoding` namespace contains utilities for encoding information in common formats in the bitcoin ecosystem.

## 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.
Expand Down

0 comments on commit 015aad5

Please sign in to comment.