Browse Source

Merge pull request #104 from braydonf/tx-messages

Improve transaction assertion messages
patch-2
Matias Alejo Garcia 8 years ago
committed by GitHub
parent
commit
f1bbe66ece
  1. 10
      lib/transaction/transaction.js

10
lib/transaction/transaction.js

@ -393,13 +393,13 @@ Transaction.prototype.fromObject = function fromObject(arg) {
Transaction.prototype._checkConsistency = function(arg) { Transaction.prototype._checkConsistency = function(arg) {
if (!_.isUndefined(this._changeIndex)) { if (!_.isUndefined(this._changeIndex)) {
$.checkState(this._changeScript); $.checkState(this._changeScript, 'Change script is expected.');
$.checkState(this.outputs[this._changeIndex]); $.checkState(this.outputs[this._changeIndex], 'Change index points to undefined output.');
$.checkState(this.outputs[this._changeIndex].script.toString() === $.checkState(this.outputs[this._changeIndex].script.toString() ===
this._changeScript.toString()); this._changeScript.toString(), 'Change output has an unexpected script.');
} }
if (arg && arg.hash) { 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 * @return {Transaction} this, for chaining
*/ */
Transaction.prototype.sign = function(privateKey, sigtype) { 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; var self = this;
if (_.isArray(privateKey)) { if (_.isArray(privateKey)) {
_.each(privateKey, function(privateKey) { _.each(privateKey, function(privateKey) {

Loading…
Cancel
Save