Compare commits

...

55 Commits
master ... v0.1

Author SHA1 Message Date
Matias Alejo Garcia
51c53b16ce Merge pull request #1299 from isocolsky/estimate_fee
Add estimatefee rpc call
2015-07-15 23:17:34 -03:00
Ivan Socolsky
29b11b1896 add estimatefee rpc call 2015-07-15 15:55:53 -03:00
Manuel Aráoz
e20df21449 Merge pull request #1023 from braydonf/bug/bn.js
v0.1.x: Upgrade bn.js and elliptic and limit node version to less than 0.10.36
2015-01-31 11:16:17 -03:00
Braydon Fuller
dc3f653fe2 Upgrade bn.js and elliptic and limit node version to less than 0.10.36 2015-01-30 23:44:35 -05:00
Manuel Aráoz
a868ec0ef4 Merge pull request #957 from eordano/update/bignum
Bump bignum version
2015-01-13 11:55:58 -03:00
Esteban Ordano
e2952b6e3a Bump bignum version 2015-01-13 11:38:59 -03:00
Manuel Aráoz
0d238f1165 Merge pull request #727 from thoatbk/master
enforce low S values on key signing
2014-12-12 13:05:20 -03:00
“thoatbk”
28bb0f4cfc enforce low S values for key signing, check BIP62 for details 2014-12-11 22:38:22 +01:00
“thoatbk”
684c306833 enforce low S values on key signing, read BIP62 for details (reverted from commit 722e2efeae) 2014-12-11 22:31:56 +01:00
“thoatbk”
722e2efeae enforce low S values on key signing, read BIP62 for details 2014-12-11 00:37:46 +01:00
Manuel Aráoz
100de8a9ba Merge pull request #653 from lukem512/patch-1
Allow SSL connections to bitcoind
2014-12-09 11:02:27 -03:00
Luke
5d2d5ef024 Include rejectUnauthorized in options 2014-12-09 13:44:07 +00:00
Luke
0d58557cac Allow SSL connections to bitcoind
This is required as, by default, self-signed certificates are rejected as was commented in #436
2014-12-02 23:49:17 +00:00
Yemel Jardi
26fb622cbe Merge pull request #628 from maraoz/version/0.1.41
v0.1.41
2014-12-01 14:11:46 -03:00
Manuel Araoz
2ff90b7ab9 v0.1.41 2014-12-01 13:46:21 -03:00
Manuel Aráoz
b1a7a9907c Merge pull request #589 from phutchins/master
Adding more detailed logging  with host and port when there are RPC conn...
2014-12-01 13:41:13 -03:00
Manuel Aráoz
38b69f4bfc Merge pull request #568 from heath/fix/language-identifiers
remove whitespace, add js language identifiers
2014-11-27 11:04:39 -03:00
Philip Hutchins
cd69983c31 Adding more detailed logging with host and port when there are RPC connection issues 2014-11-26 23:04:15 -05:00
Heath
bac81ce88e add lang identifiers to examples.md with gulp 2014-11-21 15:21:08 -05:00
Heath
fe4bbf3d72 remove whitespace, add js language identifiers 2014-11-21 14:52:41 -05:00
Manuel Aráoz
3e43d79b6e Merge pull request #562 from matiu/feature/txbuilder-utxos
serialize only the list of selected utxos, if available
2014-11-21 10:18:04 -03:00
Matias Alejo Garcia
4984d81284 serialize only the list of selected utxos, if available 2014-11-20 19:11:46 -03:00
Esteban Ordano
8c423d5cf1 Merge pull request #556 from maraoz/version/0.1.40
bump version
2014-11-10 12:54:12 -03:00
Manuel Araoz
9640cba354 bump version 2014-11-10 12:45:13 -03:00
Esteban Ordano
ebbf6b4ef7 Merge pull request #555 from maraoz/fix/browser-test
fix browser test
2014-11-10 12:42:40 -03:00
Manuel Araoz
8b451f2bb5 fix browser test 2014-11-10 12:30:16 -03:00
Manuel Aráoz
b18ee9a49d Merge pull request #552 from braydonf/bn-hex-padding
upgrade to new version of bn.js that includes hex padding
2014-11-10 11:29:24 -03:00
Manuel Aráoz
f76b184e48 Merge pull request #550 from eordano/fix/allowsignstring
allowing sign keys to be strings
2014-11-10 11:03:44 -03:00
Braydon Fuller
5986e9b887 upgrade to new version of bn.js that includes hex padding 2014-11-03 17:13:09 -05:00
Sagiv Ofek
9096fc4928 allowing sign keys to be strings
no need to pass array of one element to sign a transaction, you can simply pass the private key string (one or more separated by commas) and convert it to array. make user's life easier :)
2014-11-01 01:25:16 -03:00
Esteban Ordano
f21cb1d8b0 Merge pull request #544 from maraoz/v0.1.39
Bump version to 0.1.39
2014-10-27 13:32:58 -03:00
Manuel Araoz
bf54f79856 bump version to 0.1.39 2014-10-27 13:29:55 -03:00
Manuel Aráoz
21c5cff10d Merge pull request #543 from eordano/style/package
Leaner package distribution
2014-10-27 12:58:17 -03:00
Manuel Aráoz
c996f08040 Merge pull request #502 from felipecsl/master
Fixes unhandled exceptions in Transaction
2014-10-27 10:43:07 -03:00
Felipe Lima
b5219c7805 Merge pull request #1 from maraoz/improve/felipecsl
Improve felipecsl PR
2014-10-27 11:25:20 -02:00
Manuel Araoz
c9c49da658 refactor changes 2014-10-27 10:21:57 -03:00
Esteban Ordano
e154c205b3 Leaner package distribution 2014-10-26 18:42:03 -03:00
Esteban Ordano
c380e4698a Merge pull request #542 from maraoz/fix/ECIES-browser-example
Fixes accidental comment
2014-10-21 11:45:18 -03:00
Manuel Araoz
50d36d5b30 remove unwanted comment 2014-10-21 11:15:12 -03:00
Esteban Ordano
66b11a565f Merge pull request #541 from maraoz/add/ECIES-browser-example
add ECIES browser example
2014-10-21 11:12:39 -03:00
Manuel Araoz
acd86fdc43 add ECIES browser example 2014-10-21 11:08:18 -03:00
Esteban Ordano
586c8c0e20 Merge pull request #539 from maraoz/version/0.1.38
version 0.1.38
2014-10-20 15:31:06 -03:00
Manuel Araoz
f28d500b76 version bump 2014-10-20 15:22:22 -03:00
Manuel Aráoz
2fe70f9f52 Merge pull request #538 from braydonf/bug/browser-build-examples
fix examples on the browser build in readme
2014-10-20 14:58:04 -03:00
Braydon Fuller
c730eb5b3f fix examples on the browser build in readme 2014-10-20 13:48:30 -04:00
Esteban Ordano
df8e219a89 Merge pull request #536 from maraoz/complete/bundle
make default bundle have all submodules
2014-10-09 09:19:03 -03:00
Manuel Araoz
b0d1121165 make default bundle have all submodules 2014-10-08 16:44:51 -03:00
Esteban Ordano
fdea02e9a6 Merge pull request #527 from maraoz/version/0.1.37
Version 0.1.37
2014-10-06 15:58:12 -03:00
Manuel Araoz
212fa1498e remove test data bundle 2014-10-06 14:57:17 -03:00
Manuel Araoz
7f03d154dd remove test data bundle 2014-10-06 14:57:01 -03:00
Manuel Araoz
98056209a9 new version 2014-10-06 14:53:26 -03:00
Felipe Lima
693f2aac7b Fixes undefined check 2014-10-02 16:21:12 -03:00
Felipe Lima
ba9ff424c2 Fixes unhandled exceptions in Transaction 2014-10-02 16:21:12 -03:00
Manuel Aráoz
29dcf56262 Merge pull request #525 from eordano/fix/missingBuffertools
Add missing browser shim for buffertools
2014-10-02 12:57:48 -03:00
Esteban Ordano
36c164cb30 Add missing browser shim for buffertools 2014-10-02 12:47:00 -03:00
33 changed files with 1795 additions and 12175 deletions

View File

@ -1 +1 @@
repo_token: lBB0wwrjIH3RkwvTjkv8g5r4aUjcIUreC
repo_token: 92KyB69bPowWlcfgXqc24kE5Qt60cCPba

1
.gitignore vendored
View File

@ -11,3 +11,4 @@ coverage
.DS_Store
docs
browser/bitcore-dev.js
browser/testdata.js

View File

@ -1,6 +1,6 @@
language: node_js
node_js:
- '0.10'
- '0.10.35'
notifications:
hipchat:
rooms:

View File

@ -104,7 +104,7 @@ node browser/build.js -a
To generate a customized bitcore bundle, you can specify which submodules you want to include in it with the -s option:
```
node browser/build.js -s Transaction,Address
node browser/build.js -s lib/Transaction,lib/Address
```
This will generate a `browser/bundle.js` containing only the Transaction and Address class, with all their dependencies. Use this option if you are not using the whole bitcore library, to optimize the bundle size, script loading time, and general resource usage.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,22 @@
<html>
<head>
<script src="../../browser/bundle.js"></script>
<script type="text/javascript">
var bitcore = require('bitcore');
var Buffer = bitcore.Buffer;
console.log('ECIES: Elliptic Curve Integrated Encryption Scheme');
console.log('A way of encrypting with a public key and decrypting with a private key.');
var key = bitcore.Key.generateSync();
console.log('Private key: ' + key.private.toString('hex'));
console.log('Public key: ' + key.public.toString('hex'));
var message = new Buffer('This is a message to be encrypt');
console.log('Message: "' + message.toString() + '"');
var encrypted = bitcore.ECIES.encrypt(key.public, message);
console.log('Encrypted (with public key): ' + encrypted.toString('hex'));
var decrypted = bitcore.ECIES.decrypt(key.private, encrypted);
console.log('Decrypted (with private key): "' + decrypted.toString() + '"');
</script>
</head>
</html>

View File

@ -9,7 +9,7 @@ var format = es.through(
if (file.isStream()) return this.emit('error', new Error('Streaming not supported'));
//add indentation
var contents = "\t" + file.contents.toString("utf8").split("\n").join("\n\t");
var contents = "\n```js\n\n" + file.contents.toString("utf8").split("\n").join("\n") + "```\n";
//add header
contents = ["#", path.basename(file.path), "\n", contents].join("");
file.contents = new Buffer(contents, "utf8");

View File

@ -189,7 +189,13 @@ Address.fromPubkeyHashScriptSig = function(scriptSig, network) {
//extract an address from scriptSig
Address.fromScriptSig = function(scriptSig, network) {
if (typeof scriptSig === 'string') {
scriptSig = new Script(new Buffer(scriptSig, 'hex'));
try {
var scriptSigBuf = new Buffer(scriptSig, 'hex')
} catch(err) {
// Error: Invalid public key
return null;
}
scriptSig = new Script(scriptSigBuf);
}
if (!network)
network = 'livenet';

View File

@ -1,8 +1,6 @@
var util = require('../util');
var Script = require('./Script');
var Bignum = require('bignum');
var Binary = require('binary');
var Step = require('step');
var buffertools = require('buffertools');
var Transaction = require('./Transaction');
var TransactionIn = Transaction.In;

View File

@ -1,5 +1,5 @@
var Net = require('net');
var Binary = require('binary');
var Put = require('bufferput');
var buffertools = require('buffertools');
function Peer(host, port, services) {
@ -45,7 +45,7 @@ Peer.prototype.toString = function() {
};
Peer.prototype.toBuffer = function() {
var put = Binary.put();
var put = new Put();
put.word32le(this.lastSeen);
put.word64le(this.services);
put.put(this.getHostAsBuffer());

View File

@ -15,6 +15,7 @@ function RpcClient(opts) {
this.protocol = (opts.protocol == 'http') ? http : https;
this.batchedCalls = null;
this.disableAgent = opts.disableAgent || false;
this.rejectUnauthorized = opts.rejectUnauthorized || false;
}
RpcClient.prototype.batch = function(batchCallback, resultCallback) {
@ -33,6 +34,7 @@ var callspec = {
decodeRawTransaction: '',
dumpPrivKey: '',
encryptWallet: '',
estimateFee: 'int',
getAccount: '',
getAccountAddress: 'str',
getAddedNodeInfo: '',
@ -163,6 +165,7 @@ function rpc(request, callback) {
path: '/',
method: 'POST',
port: self.port,
rejectUnauthorized: self.rejectUnauthorized,
agent: self.disableAgent ? false : undefined,
};
if (self.httpOptions) {
@ -204,7 +207,7 @@ function rpc(request, callback) {
});
});
req.on('error', function(e) {
var err = new Error('Could not connect to bitcoin via RPC: ' + e.message);
var err = new Error('Could not connect to bitcoin via RPC at host: ' + self.host + ' port: ' + self.port + ' Error: ' + e.message);
log.err(err);
callback(err);
});

View File

@ -7,7 +7,6 @@ var util = require('../util');
var bignum = require('bignum');
var Put = require('bufferput');
var Parser = require('../util/BinaryParser');
var Step = require('step');
var buffertools = require('buffertools');
var error = require('../util/error');
var WalletKey = require('./WalletKey');
@ -633,14 +632,19 @@ Transaction.prototype.getReceivingAddresses = function(networkName) {
ret = [];
for (var i = 0; i<this.outs.length; i++) {
var o = this.outs[i];
var addr = Address.fromScriptPubKey(o.getScript(), networkName)[0].toString();
ret.push(addr);
var addrs = Address.fromScriptPubKey(o.getScript(), networkName);
if (typeof addrs[0] !== 'undefined') {
ret.push(addrs[0].toString());
} else {
ret.push(null);
}
}
return ret;
};
Transaction.prototype.getSendingAddresses = function(networkName) {
var ret = [];
if (!networkName) networkName = 'livenet';
var ret = [];
for (var i = 0; i<this.ins.length; i++) {
var input = this.ins[i];
var scriptSig = input.getScript();

View File

@ -744,8 +744,9 @@ fnToSign[Script.TX_SCRIPTHASH] = TransactionBuilder.prototype._signScriptHash;
// sign
// ----
// Signs a transaction.
// `keys`: an array of strings representing private keys to sign the
// transaction in WIF private key format OR bitcore's `WalletKey` objects
// `keys`: an array of strings representing private keys to sign the transaction in WIF private key format
// OR bitcore's `WalletKey` objects
// OR string representing private keys to sign the transaction in WIF private key format separated by commas
//
// If multiple keys are given, each will be tested against the transaction's
// scriptPubKeys. Only the valid private keys will be used to sign.
@ -756,6 +757,7 @@ fnToSign[Script.TX_SCRIPTHASH] = TransactionBuilder.prototype._signScriptHash;
//
//
TransactionBuilder.prototype.sign = function(keys) {
if (typeof keys === "string") keys = keys.split(',');
if (!(keys instanceof Array))
throw new Error('parameter should be an array');
@ -819,10 +821,12 @@ TransactionBuilder.prototype.build = function() {
//
TransactionBuilder.prototype.toObj = function() {
var utxos = this.selectedUtxos && this.selectedUtxos[0] ? this.selectedUtxos : JSON.parse(this.vanilla.utxos);
var ret = {
version: TOOBJ_VERSION,
outs: JSON.parse(this.vanilla.outs),
utxos: JSON.parse(this.vanilla.utxos),
utxos: utxos,
opts: JSON.parse(this.vanilla.opts),
scriptSig: this.vanilla.scriptSig,
};

View File

@ -23,8 +23,6 @@ bnjs.fromBuffer = function(buf, opts) {
buf = nbuf;
}
var hex = buf.toString('hex');
if (hex.length % 2)
hex = "0" + hex;
var bn = new bnjs(hex, 16);
return bn;
};
@ -32,9 +30,7 @@ bnjs.fromBuffer = function(buf, opts) {
bnjs.prototype.toBuffer = function(opts) {
var buf;
if (opts && opts.size) {
var hex = this.toString(16);
if (hex.length % 2)
hex = "0" + hex;
var hex = this.toString(16, 2);
var natlen = hex.length/2;
buf = new Buffer(hex, 'hex');
@ -56,9 +52,7 @@ bnjs.prototype.toBuffer = function(opts) {
}
}
else {
var hex = this.toString(16);
if (hex.length % 2)
hex = "0" + hex;
var hex = this.toString(16, 2);
buf = new Buffer(hex, 'hex');
}

View File

@ -160,6 +160,12 @@ Key.sign = function(hash, priv, k) {
var Q = Point.multiply(G, k);
var r = Q.x.mod(n);
var s = k.invm(n).mul(e.add(d.mul(r))).mod(n);
//enforce low s
//see BIP 62, "low S values in signatures"
var n_half = bignum.fromBuffer(new Buffer("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0", 'hex'), {size: 32});
if (s.cmp(n_half) > 0) {
s = new bignum(n).sub(s);
}
} while (r.cmp(new bignum(0)) <= 0 || s.cmp(new bignum(0)) <= 0);
return {r: r, s: s};

View File

@ -1,4 +1,3 @@
var bignum = require('bignum');
var Point = require('../Point');
var SecureRandom = require('../SecureRandom');
var bignum = require('bignum');

View File

@ -1,7 +1,7 @@
{
"name": "bitcore",
"description": "Bitcoin Library",
"version": "0.1.36",
"version": "0.1.41",
"author": {
"name": "Stephen Pair",
"email": "stephen@bitpay.com"
@ -30,6 +30,10 @@
{
"name": "Gordon Hall",
"email": "gordon@bitpay.com"
},
{
"name": "Esteban Ordano",
"email": "eordano@gmail.com"
}
],
"keywords": [
@ -49,44 +53,27 @@
"install": "node-gyp rebuild",
"test": "node browser/build.js -a && node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --reporter spec test",
"prepublish": "node browser/build.js -m"
"prepublish": "node browser/build.js -a"
},
"dependencies": {
"grunt-browserify": "~2.0.0",
"grunt-contrib-watch": "~0.5.3",
"grunt-markdown": "~0.5.0",
"grunt-mocha-test": "~0.8.2",
"grunt-shell": "~0.6.4",
"protobufjs": "=3.0.0",
"coveralls": "^2.10.0",
"istanbul": "~0.2.6",
"commander": "~2.2.0",
"mocha": ">=1.15.1",
"sjcl": "=1.0.1",
"hash.js": "=0.3.1",
"bn.js": "=0.13.3",
"jsrsasign": "=0.0.3",
"elliptic": "=0.15.7",
"asn1.js": "0.4.1",
"async": "~0.2.10",
"bignum": "^0.9.0",
"binary": "^0.3.0",
"bindings": "=1.1.1",
"bn.js": "=1.0.0",
"brfs": "=1.0.0",
"browserify-buffertools": "git://github.com/maraoz/browserify-buffertools.git",
"bufferput": "git://github.com/bitpay/node-bufferput.git",
"bignum": "=0.6.2",
"binary": "=0.3.0",
"step": "=0.0.4",
"buffers": "=0.1.1",
"buffertools": "=2.1.2",
"browserify": "=3.40.0",
"browser-pack": "=2.0.1",
"browserify-buffertools": "git://github.com/maraoz/browserify-buffertools.git",
"socks5-client": "~0.3.6",
"brfs": "=1.0.0",
"chai": "=1.9.1",
"uglifyify": "=1.2.3",
"async": "~0.2.10",
"event-stream": "~3.1.5",
"gulp-concat": "~2.2.0",
"gulp": "~3.8.2",
"elliptic": "=1.0.0",
"hash.js": "=0.3.2",
"jsrsasign": "=0.0.3",
"preconditions": "^1.0.7",
"asn1.js": "0.4.1"
"protobufjs": "=3.0.0",
"sjcl": "=1.0.1",
"socks5-client": "~0.3.6"
},
"testling": {
"harness": "mocha-bdd",
@ -104,6 +91,7 @@
},
"browser": {
"bignum": "./lib/browser/Bignum.js",
"buffertools": "browserify-buffertools",
"./lib/Key.js": "./lib/browser/Key.js",
"./lib/Point.js": "./lib/browser/Point.js",
"./lib/ECIES.js": "./lib/browser/ECIES.js",
@ -112,12 +100,27 @@
},
"license": "MIT",
"engines": {
"node": ">=0.10"
"node": ">=0.10 <0.10.36"
},
"devDependencies": {
"sinon": "^1.10.3",
"browserify": "=3.40.0",
"chai": "=1.9.1",
"commander": "~2.2.0",
"coveralls": "^2.10.0",
"event-stream": "~3.1.5",
"express": "4.6.1",
"grunt-browserify": "~2.0.0",
"grunt-contrib-watch": "~0.5.3",
"grunt-markdown": "~0.5.0",
"grunt-mocha-test": "~0.8.2",
"grunt-shell": "~0.6.4",
"gulp": "~3.8.2",
"gulp-concat": "~2.2.0",
"istanbul": "~0.2.6",
"mocha": ">=1.15.1",
"optimist": "0.6.1",
"request": "2.39.0",
"optimist": "0.6.1"
"sinon": "^1.10.3",
"uglifyify": "=1.2.3"
}
}

View File

@ -934,8 +934,8 @@ describe('TransactionBuilder', function() {
it('should check sign parameters', function() {
var b = getP2shBuilder(1);
(function() {
b.sign(testdata.dataUnspentSign.keyStringsP2sh[0])
}).should.throw('array');
b.sign(testdata.dataUnspentSign.keyStringsP2sh[0]);
}).should.not.throw('array');
});