diff --git a/lib/address.js b/lib/address.js index f60fc42ac..88c8616a8 100644 --- a/lib/address.js +++ b/lib/address.js @@ -19,6 +19,7 @@ var JSUtil = require('./util/js'); * or `Address.PayToScriptHash` (the string `'scripthash'`). The network is an instance of {@link Network}. * * @example + * ```javascript * // validate that an input field is valid * var error = Address.getValidationError(input, 'testnet'); * if (!error) { @@ -30,6 +31,7 @@ var JSUtil = require('./util/js'); * * // get an address from a public key * var address = Address(publicKey, 'testnet').toString(); + * ``` * * @param {*} data - The encoded data in various formats * @param {Network|String|number} [network] - The network: 'livenet' or 'testnet' @@ -358,9 +360,11 @@ Address.fromJSON = function fromJSON(json) { * Will return a validation error if exists * * @example + * ```javascript * * var error = Address.getValidationError('15vkcKf7gB23wLAnZLmbVuMiiVDc1Nm4a2', 'testnet'); * // a network mismatch error + * ``` * * @param {String} data - The encoded data * @param {String} network - The network: 'livenet' or 'testnet' @@ -381,9 +385,11 @@ Address.getValidationError = function(data, network, type) { * Will return a boolean if an address is valid * * @example + * ```javascript * * var valid = Address.isValid('15vkcKf7gB23wLAnZLmbVuMiiVDc1Nm4a2', 'livenet'); * // true + * ``` * * @param {String} data - The encoded data * @param {String} network - The network: 'livenet' or 'testnet' diff --git a/lib/hdprivatekey.js b/lib/hdprivatekey.js index 69ed4155b..877f8803c 100644 --- a/lib/hdprivatekey.js +++ b/lib/hdprivatekey.js @@ -75,10 +75,12 @@ function HDPrivateKey(arg) { * derived. See the example usage for clarification. * * @example + * ```javascript * var parent = new HDPrivateKey('xprv...'); * var child_0_1_2h = parent.derive(0).derive(1).derive(2, true); * var copy_of_child_0_1_2h = parent.derive("m/0/1/2'"); * assert(child_0_1_2h.xprivkey === copy_of_child_0_1_2h); + * ``` * * @param {string|number} arg * @param {boolean?} hardened diff --git a/lib/hdpublickey.js b/lib/hdpublickey.js index 8599556ab..0dc3f50ed 100644 --- a/lib/hdpublickey.js +++ b/lib/hdpublickey.js @@ -78,10 +78,12 @@ function HDPublicKey(arg) { * derived. See the example usage for clarification. * * @example + * ```javascript * var parent = new HDPublicKey('xpub...'); * var child_0_1_2 = parent.derive(0).derive(1).derive(2); * var copy_of_child_0_1_2 = parent.derive("m/0/1/2"); * assert(child_0_1_2.xprivkey === copy_of_child_0_1_2); + * ``` * * @param {string|number} arg * @param {boolean?} hardened diff --git a/lib/privatekey.js b/lib/privatekey.js index eaecd00af..4a2cced7f 100644 --- a/lib/privatekey.js +++ b/lib/privatekey.js @@ -14,6 +14,7 @@ var Random = require('./crypto/random'); * Instantiate a PrivateKey from a BN, Buffer and WIF. * * @example + * ```javascript * * // generate a new random key * var key = PrivateKey(); @@ -26,6 +27,7 @@ var Random = require('./crypto/random'); * * // instantiate from the exported (and saved) private key * var imported = PrivateKey.fromWIF(exported); + * ``` * * @param {String} data - The encoded data in various formats * @param {String} [network] - Either "livenet" or "testnet" diff --git a/lib/publickey.js b/lib/publickey.js index 58e51b75b..26166c138 100644 --- a/lib/publickey.js +++ b/lib/publickey.js @@ -12,6 +12,7 @@ var $ = require('./util/preconditions'); * Instantiate a PublicKey from a 'PrivateKey', 'Point', 'string', 'Buffer'. * * @example + * ```javascript * * // instantiate from a private key * var key = PublicKey(privateKey, true); @@ -21,6 +22,7 @@ var $ = require('./util/preconditions'); * * // import the public key * var imported = PublicKey.fromString(exported); + * ``` * * @param {String} data - The encoded data in various formats * @param {Object} extra - additional options diff --git a/lib/transaction/transaction.js b/lib/transaction/transaction.js index 00a64e103..74bf16afc 100644 --- a/lib/transaction/transaction.js +++ b/lib/transaction/transaction.js @@ -224,6 +224,7 @@ Transaction.prototype._newTransaction = function() { * SIGHASH_SINGLE or SIGHASH_NONE signatures will not be reset). * * @example + * ```javascript * var transaction = new Transaction(); * * // From a pay to public key hash output from bitcoind's listunspent @@ -235,6 +236,7 @@ Transaction.prototype._newTransaction = function() { * // From a multisig P2SH output * transaction.from({'txId': '0000...', inputIndex: 0, satoshis: 1000, script: '... OP_HASH'}, * ['03000...', '02000...'], 2); + * ``` * * @param {Object} utxo * @param {Array=} pubkeys diff --git a/lib/transport/peer.js b/lib/transport/peer.js index aea73bdfb..1c10f1b39 100644 --- a/lib/transport/peer.js +++ b/lib/transport/peer.js @@ -16,12 +16,14 @@ var MAX_RECEIVE_BUFFER = 10000000; * with it using the standar messages of the bitcoin p2p protocol. * * @example + * ```javascript * * var peer = new Peer('127.0.0.1').setProxy('127.0.0.1', 9050); * peer.on('tx', function(tx) { * console.log('New transaction: ', tx.id); * }); * peer.connect(); + * ``` * * @param {String} host - IP address of the remote host * @param {Number} [port] - Port number of the remote host diff --git a/lib/transport/pool.js b/lib/transport/pool.js index d99033a09..ec2b64c4f 100644 --- a/lib/transport/pool.js +++ b/lib/transport/pool.js @@ -18,12 +18,14 @@ function now() { * ongoing peer connections. Peer events are relayed to the pool. * * @example + * ```javascript * * var pool = new Pool(Networks.livenet); * pool.on('peerinv', function(peer, message) { * // do something with the inventory announcement * }); * pool.connect(); + * ``` * * @param {Network|String} network - The network to connect * @returns {Pool} diff --git a/lib/transport/rpc.js b/lib/transport/rpc.js index 6fcee3f5c..b297ae52e 100644 --- a/lib/transport/rpc.js +++ b/lib/transport/rpc.js @@ -8,11 +8,13 @@ var https = require('https'); * server and enables simple and batch RPC calls. * * @example + * ```javascript * * var client = new RPC('user', 'pass'); * client.getInfo(function(err, info) { * // do something with the info * }); + * ``` * * @param {String} user - username used to connect bitcoind * @param {String} password - password used to connect bitcoind diff --git a/lib/unit.js b/lib/unit.js index ba6baac61..50c699629 100644 --- a/lib/unit.js +++ b/lib/unit.js @@ -14,10 +14,12 @@ var JSUtil = require('./util/js'); * the unit accessors. * * @example + * ```javascript * * var sats = Unit.fromBTC(1.3).toSatoshis(); * var mili = Unit.fromBits(1.3).to(Unit.mBTC); * var btc = new Unit(1.3, Unit.bits).BTC; + * ``` * * @param {Number} amount - The amount to be represented * @param {String} code - The unit of the amount diff --git a/lib/uri.js b/lib/uri.js index 54b4405b3..940c8138b 100644 --- a/lib/uri.js +++ b/lib/uri.js @@ -19,9 +19,11 @@ var JSUtil = require('./util/js'); * satoshis. Any other non-standard parameters can be found under the extra member. * * @example + * ```javascript * * var uri = new URI('bitcoin:12A1MyfXbW6RhdRAZEqofac5jCQQjwEPBu?amount=1.2'); * console.log(uri.address, uri.amount); + * ``` * * @param {string|Object} data - A bitcoin URI string or an Object * @param {Array.} [knownParams] - Required non-standard params @@ -79,9 +81,11 @@ URI.fromJSON = function fromJSON(json) { * Check if an bitcoin URI string is valid * * @example + * ```javascript * * var valid = URI.isValid('bitcoin:12A1MyfXbW6RhdRAZEqofac5jCQQjwEPBu'); * // true + * ``` * * @param {string|Object} data - A bitcoin URI string or an Object * @param {Array.} [knownParams] - Required non-standard params