From 58b43345c02cac561fbce117d86d9ed82cfc43b2 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 4 Dec 2014 18:39:13 -0300 Subject: [PATCH] add docs --- lib/script.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/script.js b/lib/script.js index 4c9f313..df418f2 100644 --- a/lib/script.js +++ b/lib/script.js @@ -7,6 +7,15 @@ var PublicKey = require('./publickey'); var Hash = require('./crypto/hash'); var bu = require('./util/buffer'); +/** + * A bitcoin transaction script. Each transaction's inputs and outputs + * has a script that is evaluated to validate it's spending. + * + * See https://en.bitcoin.it/wiki/Script + * + * @constructor + * @param {Object|string|Buffer} [from] optional data to populate script + */ var Script = function Script(from) { if (!(this instanceof Script)) { return new Script(from); @@ -427,6 +436,8 @@ Script.prototype._addBuffer = function(buf, prepend) { /** * @returns a new Multisig output script for given public keys, * requiring m of those public keys to spend + * @param {PublicKey[]} pubkeys - list of all public keys controlling the output + * @param {number} m - amount of required signatures to spend the output */ Script.buildMultisigOut = function(pubkeys, m) { var s = new Script(); @@ -443,6 +454,7 @@ Script.buildMultisigOut = function(pubkeys, m) { /** * @returns a new pay to public key hash output for the given * address or public key + * @param {(Address|PublicKey)} to - destination address or public key */ Script.buildPublicKeyHashOut = function(to) { if (to instanceof PublicKey) { @@ -470,6 +482,7 @@ Script.buildPublicKeyOut = function(pubkey) { /** * @returns a new OP_RETURN script with data + * @param {(string|Buffer)} to - the data to embed in the output */ Script.buildDataOut = function(data) { if (typeof data === 'string') { @@ -483,6 +496,7 @@ Script.buildDataOut = function(data) { /** * @returns a new pay to script hash script for given script + * @param {Script} script - the redeemScript for the new p2sh output */ Script.buildScriptHashOut = function(script) { var s = new Script();