Browse Source

Standardize optional parameters to Closure syntax

patch-2
eordano 10 years ago
parent
commit
575993967c
  1. 24
      lib/address.js
  2. 14
      lib/privatekey.js
  3. 2
      lib/script/interpreter.js
  4. 6
      lib/script/script.js
  5. 4
      lib/uri.js

24
lib/address.js

@ -36,8 +36,8 @@ var JSUtil = require('./util/js');
* ``` * ```
* *
* @param {*} data - The encoded data in various formats * @param {*} data - The encoded data in various formats
* @param {Network|String|number} [network] - The network: 'livenet' or 'testnet' * @param {Network|String|number=} network - The network: 'livenet' or 'testnet'
* @param {string} [type] - The type of address: 'script' or 'pubkey' * @param {string=} type - The type of address: 'script' or 'pubkey'
* @returns {Address} A new valid and frozen instance of an Address * @returns {Address} A new valid and frozen instance of an Address
* @constructor * @constructor
*/ */
@ -86,8 +86,8 @@ function Address(data, network, type) {
/** /**
* Internal function used to split different kinds of arguments of the constructor * Internal function used to split different kinds of arguments of the constructor
* @param {*} data - The encoded data in various formats * @param {*} data - The encoded data in various formats
* @param {Network|String|number} [network] - The network: 'livenet' or 'testnet' * @param {Network|String|number=} network - The network: 'livenet' or 'testnet'
* @param {string} [type] - The type of address: 'script' or 'pubkey' * @param {string=} type - The type of address: 'script' or 'pubkey'
* @returns {Object} An "info" object with "type", "network", and "hashBuffer" * @returns {Object} An "info" object with "type", "network", and "hashBuffer"
*/ */
Address.prototype._classifyArguments = function(data, network, type) { Address.prototype._classifyArguments = function(data, network, type) {
@ -186,8 +186,8 @@ Address._classifyFromVersion = function(buffer){
* Internal function to transform a bitcoin address buffer * Internal function to transform a bitcoin address buffer
* *
* @param {Buffer} buffer - An instance of a hex encoded address Buffer * @param {Buffer} buffer - An instance of a hex encoded address Buffer
* @param {string} [network] - The network: 'livenet' or 'testnet' * @param {string=} network - The network: 'livenet' or 'testnet'
* @param {string} [type] - The type: 'pubkeyhash' or 'scripthash' * @param {string=} type - The type: 'pubkeyhash' or 'scripthash'
* @returns {Object} An object with keys: hashBuffer, network and type * @returns {Object} An object with keys: hashBuffer, network and type
* @private * @private
*/ */
@ -285,8 +285,8 @@ Address.createMultisig = function(publicKeys, threshold, network) {
* Internal function to transform a bitcoin address string * Internal function to transform a bitcoin address string
* *
* @param {string} data * @param {string} data
* @param {String|Network} [network] - either a Network instance, 'livenet', or 'testnet' * @param {String|Network=} network - either a Network instance, 'livenet', or 'testnet'
* @param {string} [type] - The type: 'pubkeyhash' or 'scripthash' * @param {string=} type - The type: 'pubkeyhash' or 'scripthash'
* @returns {Object} An object with keys: hashBuffer, network and type * @returns {Object} An object with keys: hashBuffer, network and type
* @private * @private
*/ */
@ -352,8 +352,8 @@ Address.fromScript = function(script, network) {
* Instantiate an address from a buffer of the address * Instantiate an address from a buffer of the address
* *
* @param {Buffer} buffer - An instance of buffer of the address * @param {Buffer} buffer - An instance of buffer of the address
* @param {String|Network} [network] - either a Network instance, 'livenet', or 'testnet' * @param {String|Network=} network - either a Network instance, 'livenet', or 'testnet'
* @param {string} [type] - The type of address: 'script' or 'pubkey' * @param {string=} type - The type of address: 'script' or 'pubkey'
* @returns {Address} A new valid and frozen instance of an Address * @returns {Address} A new valid and frozen instance of an Address
*/ */
Address.fromBuffer = function(buffer, network, type) { Address.fromBuffer = function(buffer, network, type) {
@ -365,8 +365,8 @@ Address.fromBuffer = function(buffer, network, type) {
* Instantiate an address from an address string * Instantiate an address from an address string
* *
* @param {string} str - An string of the bitcoin address * @param {string} str - An string of the bitcoin address
* @param {String|Network} [network] - either a Network instance, 'livenet', or 'testnet' * @param {String|Network=} network - either a Network instance, 'livenet', or 'testnet'
* @param {string} [type] - The type of address: 'script' or 'pubkey' * @param {string=} type - The type of address: 'script' or 'pubkey'
* @returns {Address} A new valid and frozen instance of an Address * @returns {Address} A new valid and frozen instance of an Address
*/ */
Address.fromString = function(str, network, type) { Address.fromString = function(str, network, type) {

14
lib/privatekey.js

@ -29,7 +29,7 @@ var Random = require('./crypto/random');
* ``` * ```
* *
* @param {string} data - The encoded data in various formats * @param {string} data - The encoded data in various formats
* @param {Network|string} [network] - a {@link Network} object, or a string with the network name * @param {Network|string=} network - a {@link Network} object, or a string with the network name
* @returns {PrivateKey} A new valid instance of an PrivateKey * @returns {PrivateKey} A new valid instance of an PrivateKey
* @constructor * @constructor
*/ */
@ -78,7 +78,7 @@ var PrivateKey = function PrivateKey(data, network) {
* different kinds of arguments passed to the constructor. * different kinds of arguments passed to the constructor.
* *
* @param {*} data * @param {*} data
* @param {Network|string} [network] - a {@link Network} object, or a string with the network name * @param {Network|string=} network - a {@link Network} object, or a string with the network name
* @return {Object} * @return {Object}
*/ */
PrivateKey.prototype._classifyArguments = function(data, network) { PrivateKey.prototype._classifyArguments = function(data, network) {
@ -144,7 +144,7 @@ PrivateKey._isJSON = function(json) {
* Internal function to transform a WIF Buffer into a private key * Internal function to transform a WIF Buffer into a private key
* *
* @param {Buffer} buf - An WIF string * @param {Buffer} buf - An WIF string
* @param {Network|string} [network] - a {@link Network} object, or a string with the network name * @param {Network|string=} network - a {@link Network} object, or a string with the network name
* @returns {Object} An object with keys: bn, network and compressed * @returns {Object} An object with keys: bn, network and compressed
* @private * @private
*/ */
@ -186,7 +186,7 @@ PrivateKey._transformBuffer = function(buf, network) {
* Internal function to transform a BN buffer into a private key * Internal function to transform a BN buffer into a private key
* *
* @param {Buffer} buf * @param {Buffer} buf
* @param {Network|string} [network] - a {@link Network} object, or a string with the network name * @param {Network|string=} network - a {@link Network} object, or a string with the network name
* @returns {object} an Object with keys: bn, network, and compressed * @returns {object} an Object with keys: bn, network, and compressed
* @private * @private
*/ */
@ -267,7 +267,7 @@ PrivateKey.fromString = PrivateKey.fromWIF = function(str) {
/** /**
* Instantiate a PrivateKey from random bytes * Instantiate a PrivateKey from random bytes
* *
* @param {string} [network] - Either "livenet" or "testnet" * @param {string=} network - Either "livenet" or "testnet"
* @returns {PrivateKey} A new valid instance of PrivateKey * @returns {PrivateKey} A new valid instance of PrivateKey
*/ */
PrivateKey.fromRandom = function(network) { PrivateKey.fromRandom = function(network) {
@ -279,7 +279,7 @@ PrivateKey.fromRandom = function(network) {
* Check if there would be any errors when initializing a PrivateKey * Check if there would be any errors when initializing a PrivateKey
* *
* @param {string} data - The encoded data in various formats * @param {string} data - The encoded data in various formats
* @param {string} [network] - Either "livenet" or "testnet" * @param {string=} network - Either "livenet" or "testnet"
* @returns {null|Error} An error if exists * @returns {null|Error} An error if exists
*/ */
@ -298,7 +298,7 @@ PrivateKey.getValidationError = function(data, network) {
* Check if the parameters are valid * Check if the parameters are valid
* *
* @param {string} data - The encoded data in various formats * @param {string} data - The encoded data in various formats
* @param {string} [network] - Either "livenet" or "testnet" * @param {string=} network - Either "livenet" or "testnet"
* @returns {Boolean} If the private key is would be valid * @returns {Boolean} If the private key is would be valid
*/ */
PrivateKey.isValid = function(data, network){ PrivateKey.isValid = function(data, network){

2
lib/script/interpreter.js

@ -37,7 +37,7 @@ var Interpreter = function Interpreter(obj) {
* separately. * separately.
* @param {Script} scriptSig - the script's first part (corresponding to the tx input) * @param {Script} scriptSig - the script's first part (corresponding to the tx input)
* @param {Script} scriptPubkey - the script's last part (corresponding to the tx output) * @param {Script} scriptPubkey - the script's last part (corresponding to the tx output)
* @param {Transaction} [tx] - the Transaction containing the scriptSig in one input (used * @param {Transaction=} tx - the Transaction containing the scriptSig in one input (used
* to check signature validity for some opcodes like OP_CHECKSIG) * to check signature validity for some opcodes like OP_CHECKSIG)
* @param {number} nin - index of the transaction input containing the scriptSig verified. * @param {number} nin - index of the transaction input containing the scriptSig verified.
* @param {number} flags - evaluation flags. See Interpreter.SCRIPT_* constants * @param {number} flags - evaluation flags. See Interpreter.SCRIPT_* constants

6
lib/script/script.js

@ -24,7 +24,7 @@ var JSUtil = require('../util/js');
* See https://en.bitcoin.it/wiki/Script * See https://en.bitcoin.it/wiki/Script
* *
* @constructor * @constructor
* @param {Object|string|Buffer} [from] optional data to populate script * @param {Object|string|Buffer=} from optional data to populate script
*/ */
var Script = function Script(from) { var Script = function Script(from) {
if (!(this instanceof Script)) { if (!(this instanceof Script)) {
@ -540,7 +540,7 @@ Script.prototype.removeCodeseparators = function() {
* requiring m of those public keys to spend * requiring m of those public keys to spend
* @param {PublicKey[]} publicKeys - list of all public keys controlling the output * @param {PublicKey[]} publicKeys - list of all public keys controlling the output
* @param {number} threshold - amount of required signatures to spend the output * @param {number} threshold - amount of required signatures to spend the output
* @param {Object} [opts] - Several options: * @param {Object=} opts - Several options:
* - noSorting: defaults to false, if true, don't sort the given * - noSorting: defaults to false, if true, don't sort the given
* public keys before creating the script * public keys before creating the script
*/ */
@ -712,7 +712,7 @@ Script.fromAddress = function(address) {
}; };
/** /**
* @param {Network} [network] * @param {Network=} network
* @return {Address} the associated address for this script * @return {Address} the associated address for this script
*/ */
Script.prototype.toAddress = function(network) { Script.prototype.toAddress = function(network) {

4
lib/uri.js

@ -26,7 +26,7 @@ var JSUtil = require('./util/js');
* ``` * ```
* *
* @param {string|Object} data - A bitcoin URI string or an Object * @param {string|Object} data - A bitcoin URI string or an Object
* @param {Array.<string>} [knownParams] - Required non-standard params * @param {Array.<string>=} knownParams - Required non-standard params
* @throws {TypeError} Invalid bitcoin address * @throws {TypeError} Invalid bitcoin address
* @throws {TypeError} Invalid amount * @throws {TypeError} Invalid amount
* @throws {Error} Unknown required argument * @throws {Error} Unknown required argument
@ -92,7 +92,7 @@ URI.fromJSON = function fromJSON(json) {
* ``` * ```
* *
* @param {string|Object} data - A bitcoin URI string or an Object * @param {string|Object} data - A bitcoin URI string or an Object
* @param {Array.<string>} [knownParams] - Required non-standard params * @param {Array.<string>=} knownParams - Required non-standard params
* @returns {boolean} Result of uri validation * @returns {boolean} Result of uri validation
*/ */
URI.isValid = function(arg, knownParams) { URI.isValid = function(arg, knownParams) {

Loading…
Cancel
Save