Browse Source

Add .toScriptHashOut() to scripts

- Also sort gulpfile dependencies
patch-2
Esteban Ordano 10 years ago
parent
commit
26e688ae06
  1. 13
      gulpfile.js
  2. 7
      lib/script/script.js
  3. 4
      test/transaction/transaction.js

13
gulpfile.js

@ -32,19 +32,20 @@
'use strict'; 'use strict';
var gulp = require('gulp'); var gulp = require('gulp');
var bump = require('gulp-bump');
var coveralls = require('gulp-coveralls'); var coveralls = require('gulp-coveralls');
var git = require('gulp-git');
var gutil = require('gulp-util');
var jsdoc2md = require('jsdoc-to-markdown');
var jshint = require('gulp-jshint'); var jshint = require('gulp-jshint');
var mfs = require('more-fs');
var mocha = require('gulp-mocha'); var mocha = require('gulp-mocha');
var rename = require('gulp-rename');
var runSequence = require('run-sequence'); var runSequence = require('run-sequence');
var shell = require('gulp-shell'); var shell = require('gulp-shell');
var through = require('through2'); var through = require('through2');
var gutil = require('gulp-util');
var jsdoc2md = require('jsdoc-to-markdown');
var mfs = require('more-fs');
var uglify = require('gulp-uglify'); var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var bump = require('gulp-bump');
var git = require('gulp-git');
var files = ['lib/**/*.js']; var files = ['lib/**/*.js'];

7
lib/script/script.js

@ -715,6 +715,13 @@ Script.prototype.toAddress = function(network) {
throw new Error('The script type needs to be PayToPublicKeyHash or PayToScriptHash'); throw new Error('The script type needs to be PayToPublicKeyHash or PayToScriptHash');
}; };
/**
* @return {Script}
*/
Script.prototype.toScriptHashOut = function() {
return Script.buildScriptHashOut(this);
};
/** /**
* Analagous to bitcoind's FindAndDelete. Find and delete equivalent chunks, * Analagous to bitcoind's FindAndDelete. Find and delete equivalent chunks,
* typically used with push data chunks. Note that this will find and delete * typically used with push data chunks. Note that this will find and delete

4
test/transaction/transaction.js

@ -277,9 +277,9 @@ describe('Transaction', function() {
var public2 = new PrivateKey(private2).publicKey; var public2 = new PrivateKey(private2).publicKey;
var transaction = new Transaction() var transaction = new Transaction()
.from({ .from({
txId: private1, txId: '0000', // Not relevant
outputIndex: 0, outputIndex: 0,
script: Script.buildScriptHashOut(Script.buildMultisigOut([public1, public2], 2)), script: Script.buildMultisigOut([public1, public2], 2).toScriptHashOut(),
satoshis: 10000 satoshis: 10000
}, [public1, public2], 2); }, [public1, public2], 2);
var deserialized = new Transaction(transaction.toObject()); var deserialized = new Transaction(transaction.toObject());

Loading…
Cancel
Save