Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Revert "1.0.0" #171

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions lib/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,10 @@ Address._transformBuffer = function(buffer, network, type) {
throw new TypeError('Address buffers must be exactly 21 bytes.');
}

var networkObj = Networks.get(network);
network = Networks.get(network);
var bufferVersion = Address._classifyFromVersion(buffer);

if (network && !networkObj) {
throw new TypeError('Unknown network');
}

if (!bufferVersion.network || (networkObj && networkObj !== bufferVersion.network)) {
if (!bufferVersion.network || (network && network !== bufferVersion.network)) {
throw new TypeError('Address has mismatched network type.');
}

Expand Down
10 changes: 5 additions & 5 deletions lib/transaction/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,13 +393,13 @@ Transaction.prototype.fromObject = function fromObject(arg) {

Transaction.prototype._checkConsistency = function(arg) {
if (!_.isUndefined(this._changeIndex)) {
$.checkState(this._changeScript, 'Change script is expected.');
$.checkState(this.outputs[this._changeIndex], 'Change index points to undefined output.');
$.checkState(this._changeScript);
$.checkState(this.outputs[this._changeIndex]);
$.checkState(this.outputs[this._changeIndex].script.toString() ===
this._changeScript.toString(), 'Change output has an unexpected script.');
this._changeScript.toString());
}
if (arg && arg.hash) {
$.checkState(arg.hash === this.hash, 'Hash in object does not match transaction hash.');
$.checkState(arg.hash === this.hash, 'Hash in object does not match transaction hash');
}
};

Expand Down Expand Up @@ -1050,7 +1050,7 @@ Transaction.prototype.removeInput = function(txId, outputIndex) {
* @return {Transaction} this, for chaining
*/
Transaction.prototype.sign = function(privateKey, sigtype) {
$.checkState(this.hasAllUtxoInfo(), 'Not all utxo information is available to sign the transaction.');
$.checkState(this.hasAllUtxoInfo());
var self = this;
if (_.isArray(privateKey)) {
_.each(privateKey, function(privateKey) {
Expand Down
6 changes: 0 additions & 6 deletions test/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,6 @@ describe('Address', function() {
Address.fromString(str, Networks.livenet).toString().should.equal(str);
});

it('should throw with bad network param', function() {
(function(){
Address.fromString(str, 'somenet');
}).should.throw('Unknown network');
});

it('should error because of unrecognized data format', function() {
(function() {
return new Address(new Error());
Expand Down
5 changes: 1 addition & 4 deletions test/networks.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,7 @@ describe('Networks', function() {
networks.add(custom);
var network = networks.get(undefined);
should.not.exist(network);
var somenet = networks.get('somenet');
should.exist(somenet);
somenet.name.should.equal('somenet');
networks.remove(somenet);
networks.remove(custom);
});

var constants = ['name', 'alias', 'pubkeyhash', 'scripthash', 'xpubkey', 'xprivkey'];
Expand Down