Comparing version 0.12.9 to 0.12.10
{ | ||
"name": "bitcore", | ||
"main": "./bitcore.min.js", | ||
"version": "0.12.9", | ||
"version": "0.12.10", | ||
"homepage": "http://bitcore.io", | ||
@@ -6,0 +6,0 @@ "authors": [ |
@@ -160,7 +160,4 @@ 'use strict'; | ||
info.network = Networks.get(buf[0], 'privatekey'); | ||
if (buf[0] === Networks.livenet.privatekey) { | ||
info.network = Networks.livenet; | ||
} else if (buf[0] === Networks.testnet.privatekey) { | ||
info.network = Networks.testnet; | ||
} else { | ||
if (!info.network) { | ||
throw new Error('Invalid network'); | ||
@@ -167,0 +164,0 @@ } |
@@ -917,12 +917,14 @@ 'use strict'; | ||
Transaction.prototype._newOutputOrder = function(newOutputs) { | ||
var changeIndex = 0; | ||
var length = this.outputs.length; | ||
while (changeIndex < length && this.outputs[this._changeIndex] !== newOutputs[changeIndex]) { | ||
changeIndex++; | ||
} | ||
if (changeIndex === length) { | ||
var isInvalidSorting = (this.outputs.length !== newOutputs.length || | ||
_.difference(this.outputs, newOutputs).length !== 0); | ||
if (isInvalidSorting) { | ||
throw new errors.Transaction.InvalidSorting(); | ||
} | ||
if (!_.isUndefined(this._changeIndex)) { | ||
var changeOutput = this.outputs[this._changeIndex]; | ||
this._changeIndex = _.findIndex(newOutputs, changeOutput); | ||
} | ||
this.outputs = newOutputs; | ||
this._changeIndex = changeIndex; | ||
return this; | ||
@@ -929,0 +931,0 @@ }; |
{ | ||
"name": "bitcore", | ||
"version": "0.12.9", | ||
"version": "0.12.10", | ||
"description": "A pure and powerful JavaScript Bitcoin library.", | ||
@@ -5,0 +5,0 @@ "author": "BitPay <dev@bitpay.com>", |
@@ -51,3 +51,3 @@ 'use strict'; | ||
}); | ||
it('should not set a network map for an undefined value', function() { | ||
@@ -54,0 +54,0 @@ var custom = { |
@@ -25,2 +25,3 @@ 'use strict'; | ||
var wifLivenetUncompressed = '5JxgQaFM1FMd38cd14e3mbdxsdSa9iM2BV6DHBYsvGzxkTNQ7Un'; | ||
var wifNamecoin = '74pxNKNpByQ2kMow4d9kF6Z77BYeKztQNLq3dSyU4ES1K5KLNiz'; | ||
@@ -48,2 +49,27 @@ it('should create a new random private key', function() { | ||
it('should create a private key from a custom network WIF string', function() { | ||
var nmc = { | ||
name: 'namecoin', | ||
alias: 'namecoin', | ||
pubkeyhash: 0x34, | ||
privatekey: 0xB4, | ||
// these below aren't the real NMC version numbers | ||
scripthash: 0x08, | ||
xpubkey: 0x0278b20e, | ||
xprivkey: 0x0278ade4, | ||
networkMagic: 0xf9beb4fe, | ||
port: 20001, | ||
dnsSeeds: [ | ||
'localhost', | ||
'mynet.localhost' | ||
] | ||
}; | ||
Networks.add(nmc); | ||
var nmcNet = Networks.get('namecoin'); | ||
var a = new PrivateKey(wifNamecoin, nmcNet); | ||
should.exist(a); | ||
should.exist(a.bn); | ||
Networks.remove(nmcNet); | ||
}); | ||
it('should create a new random testnet private key with empty data', function() { | ||
@@ -119,2 +145,8 @@ var a = new PrivateKey(null, Networks.testnet); | ||
it('should not be able to instantiate private key WIF because of network mismatch', function() { | ||
expect(function(){ | ||
var a = new PrivateKey(wifNamecoin, 'testnet'); | ||
}).to.throw('Invalid network'); | ||
}); | ||
it('can be instantiated from a hex string', function() { | ||
@@ -121,0 +153,0 @@ var privhex = '906977a061af29276e40bf377042ffbde414e496ae2260bbf1fa9d085637bfff'; |
@@ -833,3 +833,3 @@ 'use strict'; | ||
var sorting = function(array) { | ||
return []; | ||
return [array[0], array[1], array[2]]; | ||
}; | ||
@@ -841,4 +841,9 @@ expect(function() { | ||
it('shuffle without change', function() { | ||
var tx = new Transaction(transaction.toObject()).to(toAddress, half); | ||
expect(tx.getChangeOutput()).to.be.null; | ||
expect(function() { | ||
tx.shuffleOutputs(); | ||
}).to.not.throw(errors.Transaction.InvalidSorting); | ||
}) | ||
}); | ||
@@ -845,0 +850,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12087477
322766