- Bitcore
- Get Started ( /docs/index.html )
- Address ( /docs/address.html )
- Block ( /docs/block.html )
- HD Keys ( /docs/hierarchical.html )
- Private Key ( /docs/privatekey.html )
- Public Key ( /docs/publickey.html )
- Script ( /docs/script.html )
var inherits = require('inherits'); | |
var Point = function(){}; | |
Point.Errors = {}; | |
var defineErrors = function(base, specs){ | |
specs.forEach(function(spec){ | |
var e = function(message){ | |
this.message = message || spec.message; | |
}; |
'use strict'; | |
var interations = 10000000; | |
console.log('\n\n','Running ', interations, ' interations for each:'); | |
console.log(' ===================================================', '\n'); | |
var throwAnError = function(){ | |
throw new Error('Ooops...'); | |
}; |
Running 10000000 interations for each: | |
=================================================== | |
Try/Catch Error: 34.292 seconds | |
Return Error: 32.326 seconds | |
Return a String: 0.075 seconds | |
Return a Number: 0.056 seconds | |
Return an Object: 0.076 seconds | |
Return a new Object: 0.263 seconds | |
Try/Catch a new Object: 0.274 seconds |
AssertionError: expected [Function] to throw error including 'Address must be an instance of PublicKey.' but got 'Object doesn\'t support property or method \'toBuffer\'' | |
at Assertion.prototype.assert (http://braydon.bp/bitcore/browser/tests.js:32764:7) | |
at assertThrows (http://braydon.bp/bitcore/browser/tests.js:33988:9) | |
at ctx[name] (http://braydon.bp/bitcore/browser/tests.js:35508:5) | |
at Anonymous function (http://braydon.bp/bitcore/browser/tests.js:61073:8) | |
at callFn (http://braydon.bp/bitcore/node_modules/mocha/mocha.js:4428:5) | |
at Runnable.prototype.run (http://braydon.bp/bitcore/node_modules/mocha/mocha.js:4421:7) | |
at Runner.prototype.runTest (http://braydon.bp/bitcore/node_modules/mocha/mocha.js:4823:5) | |
at Anonymous function (http://braydon.bp/bitcore/node_modules/mocha/mocha.js:4901:7) | |
at next (http://braydon.bp/bitcore/node_modules/mocha/mocha.js:4748:7) |
// elliptic.js | |
var EC = require('elliptic').ec | |
var ec = new EC('secp256k1') | |
var point = ec.g.mul('f2cc9d2b008927db94b89e04e2f6e70c180e547b3e5e564b06b8215d1c264b53') | |
// <EC Point x: 495f99aa21d7e60ff3f065f2a14e67612b29b1cb5af7b7fc4738cede6f2d9eba y: 41a2d4539b40a914e755a3a24367ce731195c354480dad4f2ce9e9c8f8003bce> | |
var point1 = e.curve.pointFromX(true, '495f99aa21d7e60ff3f065f2a14e67612b29b1cb5af7b7fc4738cede6f2d9eba') | |
// <EC Point x: 495f99aa21d7e60ff3f065f2a14e67612b29b1cb5af7b7fc4738cede6f2d9eba y: 3dc9318f0a7ae59bafbccef98692931dc6a8c28208333e88de5c031766f70777> |
// updated version with bcoin at https://gist.github.com/braydonf/528a51785f0f5641464d172696cd2112 | |
var bitcore = require('bitcore'); | |
var fs = require('fs'); | |
var glob = require('glob'); | |
var async = require('async'); | |
var Block = bitcore.Block; | |
glob('./blk*.dat', null, function(err, files) { |
var RpcClient = require('bitcoind-rpc'); | |
var async = require('async'); | |
var config = { | |
protocol: 'http', | |
user: 'bitcoin', | |
pass: 'local321', | |
host: '127.0.0.1', | |
port: '8332' | |
}; |
Before you begin you'll need to have about 100GB of disk space available to store the Bitcoin blockchain plus additional database information. Both 64bit Mac OS X and GNU/Linux are currently supported. The process of downloading the blocks and indexing can take upwards of 4 hours, depending on Internet connection and other factors. So it's suggested to plan accordingly and let the node syncronize while you're away. It's also possible to use an existing Bitcoin data directory, which will speed up the process.
It's recommended to install the Node Version Manager, as this makes it simple to switch between different Node.js versions. We will specifically need to install and run v0.12. Please follow the directions at https://github.com/creationix/nvm#install-script and then run:
nvm install v0.12.7
'use strict'; | |
var Transform = require('stream').Transform; | |
var inherits = require('util').inherits; | |
var crypto = require('crypto'); | |
var levelup = require('levelup'); | |
var async = require('async'); | |
var maxNumber = 1500000; |