From 6f1c7827376f4b9332e4a2126408854dd21d7c75 Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Tue, 20 Sep 2016 11:18:45 -0400 Subject: [PATCH] Improve transaction assertion messages --- lib/transaction/transaction.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/transaction/transaction.js b/lib/transaction/transaction.js index 97660242a..612d481c9 100644 --- a/lib/transaction/transaction.js +++ b/lib/transaction/transaction.js @@ -393,13 +393,13 @@ Transaction.prototype.fromObject = function fromObject(arg) { Transaction.prototype._checkConsistency = function(arg) { if (!_.isUndefined(this._changeIndex)) { - $.checkState(this._changeScript); - $.checkState(this.outputs[this._changeIndex]); + $.checkState(this._changeScript, 'Change script is expected.'); + $.checkState(this.outputs[this._changeIndex], 'Change index points to undefined output.'); $.checkState(this.outputs[this._changeIndex].script.toString() === - this._changeScript.toString()); + this._changeScript.toString(), 'Change output has an unexpected script.'); } 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.'); } }; @@ -1050,7 +1050,7 @@ Transaction.prototype.removeInput = function(txId, outputIndex) { * @return {Transaction} this, for chaining */ Transaction.prototype.sign = function(privateKey, sigtype) { - $.checkState(this.hasAllUtxoInfo()); + $.checkState(this.hasAllUtxoInfo(), 'Not all utxo information is available to sign the transaction.'); var self = this; if (_.isArray(privateKey)) { _.each(privateKey, function(privateKey) {