Permalink
Browse files

Moved lib to bitcore-lib and added bitcore-cli.

  • Loading branch information...
1 parent 2f144d4 commit 2d7d7c4fcc7a34dc5aa9ff29baa5afaddaa1f538 Braydon Fuller committed Oct 16, 2015
Showing with 19 additions and 26,555 deletions.
  1. +0 −12 .zuul.yml
  2. +0 −1 benchmark/block-357238.json
  3. +0 −8 benchmark/package.json
  4. +0 −85 benchmark/script.js
  5. +0 −122 benchmark/serialization.js
  6. +5 −0 bin/bitcore
  7. +5 −0 bin/bitcored
  8. +0 −74 docs/address.md
  9. +0 −57 docs/block.md
  10. +0 −109 docs/browser.md
  11. +0 −29 docs/crypto.md
  12. +0 −17 docs/encoding.md
  13. +0 −113 docs/examples.md
  14. +0 −50 docs/hierarchical.md
  15. +0 −104 docs/index.md
  16. +0 −46 docs/networks.md
  17. +0 −56 docs/privatekey.md
  18. +0 −73 docs/publickey.md
  19. +0 −151 docs/script.md
  20. +0 −204 docs/transaction.md
  21. +0 −90 docs/unit.md
  22. +0 −40 docs/unspentoutput.md
  23. +0 −47 docs/uri.md
  24. +2 −67 index.js
  25. +0 −498 lib/address.js
  26. +0 −281 lib/block/block.js
  27. +0 −296 lib/block/blockheader.js
  28. +0 −4 lib/block/index.js
  29. +0 −272 lib/block/merkleblock.js
  30. +0 −202 lib/crypto/bn.js
  31. +0 −295 lib/crypto/ecdsa.js
  32. +0 −98 lib/crypto/hash.js
  33. +0 −145 lib/crypto/point.js
  34. +0 −57 lib/crypto/random.js
  35. +0 −312 lib/crypto/signature.js
  36. +0 −70 lib/encoding/base58.js
  37. +0 −95 lib/encoding/base58check.js
  38. +0 −192 lib/encoding/bufferreader.js
  39. +0 −152 lib/encoding/bufferwriter.js
  40. +0 −72 lib/encoding/varint.js
  41. +0 −61 lib/errors/index.js
  42. +0 −177 lib/errors/spec.js
  43. +0 −45 lib/hdkeycache.js
  44. +0 −577 lib/hdprivatekey.js
  45. +0 −464 lib/hdpublickey.js
  46. +0 −176 lib/networks.js
  47. +0 −247 lib/opcode.js
  48. +0 −387 lib/privatekey.js
  49. +0 −393 lib/publickey.js
  50. +0 −3 lib/script/index.js
  51. +0 −1,265 lib/script/interpreter.js
  52. +0 −1,027 lib/script/script.js
  53. +0 −6 lib/transaction/index.js
  54. +0 −5 lib/transaction/input/index.js
  55. +0 −193 lib/transaction/input/input.js
  56. +0 −166 lib/transaction/input/multisigscripthash.js
  57. +0 −89 lib/transaction/input/publickey.js
  58. +0 −95 lib/transaction/input/publickeyhash.js
  59. +0 −168 lib/transaction/output.js
  60. +0 −136 lib/transaction/sighash.js
  61. +0 −89 lib/transaction/signature.js
  62. +0 −1,190 lib/transaction/transaction.js
  63. +0 −100 lib/transaction/unspentoutput.js
  64. +0 −238 lib/unit.js
  65. +0 −223 lib/uri.js
  66. +0 −177 lib/util/buffer.js
  67. +0 −84 lib/util/js.js
  68. +0 −34 lib/util/preconditions.js
  69. +0 −53 npm-shrinkwrap.json
  70. +7 −9 package.json
  71. +0 −561 test/address.js
  72. +0 −268 test/block/block.js
  73. +0 −292 test/block/blockheader.js
  74. +0 −200 test/block/merkleblock.js
  75. +0 −153 test/crypto/bn.js
  76. +0 −316 test/crypto/ecdsa.js
  77. +0 −139 test/crypto/hash.js
  78. +0 −174 test/crypto/point.js
  79. +0 −36 test/crypto/random.js
  80. +0 −328 test/crypto/signature.js
  81. +0 −215 test/data/bip69.json
  82. +0 −152 test/data/bitcoind/base58_keys_invalid.json
  83. +0 −452 test/data/bitcoind/base58_keys_valid.json
  84. +0 −27 test/data/bitcoind/blocks.json
  85. +0 −672 test/data/bitcoind/script_invalid.json
  86. +0 −821 test/data/bitcoind/script_valid.json
  87. +0 −7 test/data/bitcoind/sig_canonical.json
  88. +0 −22 test/data/bitcoind/sig_noncanonical.json
  89. +0 −177 test/data/bitcoind/tx_invalid.json
  90. +0 −224 test/data/bitcoind/tx_valid.json
  91. BIN test/data/blk86756-testnet.dat
  92. +0 −12 test/data/blk86756-testnet.js
  93. +0 −684 test/data/blk86756-testnet.json
  94. +0 −230 test/data/ecdsa.json
  95. +0 −458 test/data/merkleblocks.js
  96. +0 −22 test/data/messages.json
  97. +0 −503 test/data/sighash.json
  98. +0 −85 test/data/tx_creation.json
  99. +0 −17 test/docs.js
  100. +0 −123 test/encoding/base58.js
  101. +0 −124 test/encoding/base58check.js
  102. +0 −360 test/encoding/bufferreader.js
  103. +0 −188 test/encoding/bufferwriter.js
  104. +0 −126 test/encoding/varint.js
  105. +0 −52 test/hdkeycache.js
  106. +0 −266 test/hdkeys.js
  107. +0 −311 test/hdprivatekey.js
  108. +0 −282 test/hdpublickey.js
  109. +0 −18 test/index.html
  110. +0 −16 test/index.js
  111. +0 −102 test/networks.js
  112. +0 −152 test/opcode.js
  113. +0 −434 test/privatekey.js
  114. +0 −430 test/publickey.js
  115. +0 −311 test/script/interpreter.js
  116. +0 −879 test/script/script.js
  117. +0 −34 test/transaction/deserialize.js
  118. +0 −99 test/transaction/input/input.js
  119. +0 −114 test/transaction/input/multisigscripthash.js
  120. +0 −71 test/transaction/input/publickey.js
  121. +0 −64 test/transaction/input/publickeyhash.js
  122. +0 −192 test/transaction/output.js
  123. +0 −37 test/transaction/sighash.js
  124. +0 −133 test/transaction/signature.js
  125. +0 −1,054 test/transaction/transaction.js
  126. +0 −94 test/transaction/unspentoutput.js
  127. +0 −193 test/unit.js
  128. +0 −257 test/uri.js
  129. +0 −156 test/util/buffer.js
  130. +0 −83 test/util/js.js
  131. +0 −80 test/util/preconditions.js
View
@@ -1,12 +0,0 @@
-ui: mocha-bdd
-browsers:
- - name: chrome
- version: 30..latest
- - name: firefox
- version: 30..latest
- - name: ie
- version: latest
- - name: safari
- version: latest
-browserify:
- - transform: brfs
Oops, something went wrong.
@@ -1,8 +0,0 @@
-{
- "devDependencies": {
- "bcoin": "0.15.0",
- "bitcoinjs-lib": "^1.5.7",
- "fullnode": "^0.9.0",
- "benchmark": "^1.0.0"
- }
-}
View
@@ -1,85 +0,0 @@
-'use strict';
-
-var benchmark = require('benchmark');
-var bitcore = require('..');
-var async = require('async');
-var blockData = require('./block-357238.json');
-
-var maxTime = 10;
-
-console.log('Benchmarking Script');
-console.log('---------------------------------------');
-
-async.series([
- function(next) {
-
- var c = 0;
- var scripts = [];
- var block = bitcore.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++) {
- var input = tx.inputs[j];
- if (input.script) {
- scripts.push(input.script);
- }
- }
- for (var k = 0; k < tx.outputs.length; k++) {
- var output = tx.outputs[k];
- if (output.script) {
- scripts.push(output.script);
- }
- }
- }
-
- function isPublicKeyOut() {
- if (c >= scripts.length) {
- c = 0;
- }
- scripts[c].isPublicKeyOut();
- c++;
- }
-
- function isPublicKeyHashIn() {
- if (c >= scripts.length) {
- c = 0;
- }
- scripts[c].isPublicKeyHashIn();
- c++;
- }
-
- function toAddress() {
- if (c >= scripts.length) {
- c = 0;
- }
- scripts[c].toAddress();
- c++;
- }
-
- function getAddressInfo() {
- if (c >= scripts.length) {
- c = 0;
- }
- scripts[c].getAddressInfo();
- c++;
- }
-
- var suite = new benchmark.Suite();
- suite.add('isPublicKeyHashIn', isPublicKeyHashIn, {maxTime: maxTime});
- suite.add('isPublicKeyOut', isPublicKeyOut, {maxTime: maxTime});
- suite.add('toAddress', toAddress, {maxTime: maxTime});
- suite.add('getAddressInfo', getAddressInfo, {maxTime: maxTime});
- suite
- .on('cycle', function(event) {
- console.log(String(event.target));
- })
- .on('complete', function() {
- console.log('Done');
- console.log('----------------------------------------------------------------------');
- next();
- })
- .run();
- }
-], function(err) {
- console.log('Finished');
-});
@@ -1,122 +0,0 @@
-'use strict';
-
-var benchmark = require('benchmark');
-var bitcore = require('..');
-var bitcoinjs = require('bitcoinjs-lib');
-var bcoin = require('bcoin');
-var async = require('async');
-var fullnode = require('fullnode');
-var blockData = require('./block-357238.json');
-
-var maxTime = 20;
-
-console.log('Benchmarking Block/Transaction Serialization');
-console.log('---------------------------------------');
-
-async.series([
- function(next) {
-
- var buffers = [];
- var hashBuffers = [];
- console.log('Generating Random Test Data...');
- for (var i = 0; i < 100; i++) {
-
- // uint64le
- var br = new bitcore.encoding.BufferWriter();
- var num = Math.round(Math.random() * 10000000000000);
- br.writeUInt64LEBN(new bitcore.crypto.BN(num));
- buffers.push(br.toBuffer());
-
- // hashes
- var data = bitcore.crypto.Hash.sha256sha256(new Buffer(32));
- hashBuffers.push(data);
- }
-
- var c = 0;
- var bn;
-
- function readUInt64LEBN() {
- if (c >= buffers.length) {
- c = 0;
- }
- var buf = buffers[c];
- var br = new bitcore.encoding.BufferReader(buf);
- bn = br.readUInt64LEBN();
- c++;
- }
-
- var reversed;
-
- function readReverse() {
- if (c >= hashBuffers.length) {
- c = 0;
- }
- var buf = hashBuffers[c];
- var br = new bitcore.encoding.BufferReader(buf);
- reversed = br.readReverse();
- c++;
- }
-
- console.log('Starting benchmark...');
-
- var suite = new benchmark.Suite();
- suite.add('bufferReader.readUInt64LEBN()', readUInt64LEBN, {maxTime: maxTime});
- suite.add('bufferReader.readReverse()', readReverse, {maxTime: maxTime});
- suite
- .on('cycle', function(event) {
- console.log(String(event.target));
- })
- .on('complete', function() {
- console.log('Done');
- console.log('----------------------------------------------------------------------');
- next();
- })
- .run();
- },
- function(next) {
-
- var block1;
- var block2;
- var block3;
-
- function bitcoreTest() {
- block1 = bitcore.Block.fromString(blockData);
- }
-
- function bitcoinJSTest() {
- block2 = bitcoinjs.Block.fromHex(blockData);
- }
-
- var parser = new bcoin.protocol.parser();
-
- function bcoinTest() {
- var raw = bcoin.utils.toArray(blockData, 'hex');
- var data = parser.parseBlock(raw);
- block3 = new bcoin.block(data, 'block');
- }
-
- var blockDataMessage = '0000000000000000' + blockData; // add mock leading magic and size
-
- function fullnodeTest() {
- fullnode.Block().fromHex(blockDataMessage);
- }
-
- var suite = new benchmark.Suite();
- suite.add('bitcore', bitcoreTest, {maxTime: maxTime});
- suite.add('bitcoinjs', bitcoinJSTest, {maxTime: maxTime});
- suite.add('bcoin', bcoinTest, {maxTime: maxTime});
- suite.add('fullnode', fullnodeTest, {maxTime: maxTime});
- suite
- .on('cycle', function(event) {
- console.log(String(event.target));
- })
- .on('complete', function() {
- console.log('Fastest is ' + this.filter('fastest').pluck('name'));
- console.log('----------------------------------------------------------------------');
- next();
- })
- .run();
- }
-], function(err) {
- console.log('Finished');
-});
View
@@ -0,0 +1,5 @@
+#!/usr/bin/env node
+// vi: ft=javascript -*- mode: JavaScript; -*-
+
+var cli = require('bitcore-cli');
+cli.bitcore();
View
@@ -0,0 +1,5 @@
+#!/usr/bin/env node
+// vi: ft=javascript -*- mode: JavaScript; -*-
+
+var cli = require('bitcore-cli');
+cli.bitcored();
View
@@ -1,74 +0,0 @@
----
-title: Address
-description: A simple interface to generate and validate a bitcoin address.
----
-# Address
-
-## Description
-
-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.
-
-```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.
-
-```javascript
-// from a string
-var address = Address.fromString('mwkXG8NnB2snbqWTcpNiK6qqGHm1LebHDc');
-
-// a default network address from a public key
-var publicKey = PublicKey(privateKey);
-var address = new Address(publicKey);
-// alternative interface
-var address = Address.fromPublicKey(publicKey);
-
-// a testnet address from a public key
-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).
-
-```javascript
-// a 2-of-3 address from public keys
-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 code to do these validations looks like this:
-
-```javascript
-// validate an address
-if (Address.isValid(input){
- ...
-}
-
-// validate that an input field is a valid testnet address
-if (Address.isValid(input, Networks.testnet){
- ...
-}
-
-// validate that an input field is a valid livenet pubkeyhash
-if (Address.isValid(input, Networks.livenet, Address.Pay2PubKeyHash){
- ...
-}
-
-// get the specific validation error that can occurred
-var error = Address.getValidationError(input, Networks.testnet);
- if (error) {
- // handle the error
- }
-}
-```
-
-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).
View
@@ -1,57 +0,0 @@
----
-title: Block
-description: A simple interface to parse and validate a bitcoin blocks.
----
-# Block
-
-## Description
-
-A Block instance represents the information of a block in the bitcoin network. Given a hexadecimal 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
-// instantiate a new block instance
-var block = new Block(hexaEncodedBlock);
-
-// will verify that the corresponding block transactions match the header
-assert(block.validMerkleRoot());
-
-// blocks have several properties
-assert(block.header); // an instance of block header, more info below
-assert(block.transactions); // an array of transactions, more info below
-
-```
-
-For detailed technical information about a block please visit [Blocks](https://en.bitcoin.it/wiki/Blocks#Block_structure) on the Bitcoin Wiki.
-
-## Block Header
-
-Each instance of Block has a BlockHeader *(which can be instantiated separately)*. The header has validation methods, to verify that the block.
-
-```javascript
-// will verify that the nonce demonstrates enough proof of work
-assert(block.header.validProofOfWork());
-
-// will verify that timestamp is not too far in the future
-assert(block.header.validTimestamp());
-
-// each header has the following properties
-assert(block.header.version);
-assert(block.header.prevHash);
-assert(block.header.merkleRoot);
-assert(block.header.time);
-assert(block.header.bits);
-assert(block.header.nonce);
-
-```
-For more information about the specific properties of a block header please visit the [Block hashing algorithm](https://en.bitcoin.it/wiki/Block_hashing_algorithm) page on the Bitcoin 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.
-
-```javascript
-for (var i in block.transactions) {
- var transaction = block.transactions[i];
-}
-```
-
Oops, something went wrong.

0 comments on commit 2d7d7c4

Please sign in to comment.