types: cleanup types.
This commit is contained in:
parent
5b448b5bce
commit
f1672a8b86
@ -39,7 +39,7 @@ const ZERO = new BN(0);
|
||||
* @property {Number} nonce
|
||||
* @property {Number} height
|
||||
* @property {BN} chainwork
|
||||
* @property {ReversedHash} rhash
|
||||
* @property {Hash} rhash
|
||||
*/
|
||||
|
||||
class ChainEntry {
|
||||
|
||||
@ -1777,7 +1777,7 @@ RejectPacket.codes = {
|
||||
|
||||
/**
|
||||
* Reject codes by value.
|
||||
* @const {RevMap}
|
||||
* @const {Object}
|
||||
*/
|
||||
|
||||
RejectPacket.codesByVal = {
|
||||
|
||||
@ -3250,7 +3250,7 @@ class Pool extends EventEmitter {
|
||||
|
||||
/**
|
||||
* Add an address to the bloom filter (SPV-only).
|
||||
* @param {Address|Base58Address} address
|
||||
* @param {Address|AddressString} address
|
||||
*/
|
||||
|
||||
watchAddress(address) {
|
||||
|
||||
@ -50,7 +50,7 @@ class AbstractBlock {
|
||||
/**
|
||||
* Inject properties from options object.
|
||||
* @private
|
||||
* @param {NakedBlock} options
|
||||
* @param {Object} options
|
||||
*/
|
||||
|
||||
parseOptions(options) {
|
||||
|
||||
@ -202,7 +202,7 @@ class Address {
|
||||
/**
|
||||
* Compile the address object to a base58 address.
|
||||
* @param {{NetworkType|Network)?} network
|
||||
* @returns {Base58Address}
|
||||
* @returns {AddressString}
|
||||
* @throws Error on bad hash/prefix.
|
||||
*/
|
||||
|
||||
@ -271,7 +271,7 @@ class Address {
|
||||
/**
|
||||
* Convert the Address to a string.
|
||||
* @param {(Network|NetworkType)?} network
|
||||
* @returns {Base58Address}
|
||||
* @returns {AddressString}
|
||||
*/
|
||||
|
||||
toString(network) {
|
||||
@ -343,7 +343,7 @@ class Address {
|
||||
/**
|
||||
* Inject properties from base58 address.
|
||||
* @private
|
||||
* @param {Base58Address} data
|
||||
* @param {AddressString} data
|
||||
* @param {Network?} network
|
||||
* @throws Parse error
|
||||
*/
|
||||
@ -359,7 +359,7 @@ class Address {
|
||||
|
||||
/**
|
||||
* Create an address object from a base58 address.
|
||||
* @param {Base58Address} data
|
||||
* @param {AddressString} data
|
||||
* @param {Network?} network
|
||||
* @returns {Address}
|
||||
* @throws Parse error.
|
||||
@ -867,7 +867,7 @@ Address.types = {
|
||||
|
||||
/**
|
||||
* Address types by value.
|
||||
* @const {RevMap}
|
||||
* @const {Object}
|
||||
*/
|
||||
|
||||
Address.typesByVal = [
|
||||
|
||||
@ -69,7 +69,7 @@ class Input {
|
||||
|
||||
/**
|
||||
* Instantiate an Input from options object.
|
||||
* @param {NakedInput} options
|
||||
* @param {Object} options
|
||||
* @returns {Input}
|
||||
*/
|
||||
|
||||
|
||||
@ -174,7 +174,7 @@ InvItem.types = {
|
||||
|
||||
/**
|
||||
* Inv types by value.
|
||||
* @const {RevMap}
|
||||
* @const {Object}
|
||||
*/
|
||||
|
||||
InvItem.typesByVal = {
|
||||
|
||||
@ -424,7 +424,7 @@ class KeyRing {
|
||||
/**
|
||||
* Get address' scripthash address for witness program.
|
||||
* @param {String?} enc - `"base58"` or `null`.
|
||||
* @returns {Address|Base58Address}
|
||||
* @returns {Address|AddressString}
|
||||
*/
|
||||
|
||||
getNestedAddress(enc, network) {
|
||||
@ -497,7 +497,7 @@ class KeyRing {
|
||||
/**
|
||||
* Get scripthash address.
|
||||
* @param {String?} enc - `"base58"` or `null`.
|
||||
* @returns {Address|Base58Address}
|
||||
* @returns {Address|AddressString}
|
||||
*/
|
||||
|
||||
getScriptAddress(enc, network) {
|
||||
@ -543,7 +543,7 @@ class KeyRing {
|
||||
/**
|
||||
* Get pubkeyhash address.
|
||||
* @param {String?} enc - `"base58"` or `null`.
|
||||
* @returns {Address|Base58Address}
|
||||
* @returns {Address|AddressString}
|
||||
*/
|
||||
|
||||
getKeyAddress(enc, network) {
|
||||
@ -587,7 +587,7 @@ class KeyRing {
|
||||
/**
|
||||
* Get base58 address.
|
||||
* @param {String?} enc - `"base58"` or `null`.
|
||||
* @returns {Address|Base58Address}
|
||||
* @returns {Address|AddressString}
|
||||
*/
|
||||
|
||||
getAddress(enc, network) {
|
||||
|
||||
@ -48,7 +48,7 @@ class MerkleBlock extends AbstractBlock {
|
||||
/**
|
||||
* Inject properties from options object.
|
||||
* @private
|
||||
* @param {NakedBlock} options
|
||||
* @param {Object} options
|
||||
*/
|
||||
|
||||
fromOptions(options) {
|
||||
@ -83,7 +83,7 @@ class MerkleBlock extends AbstractBlock {
|
||||
|
||||
/**
|
||||
* Instantiate merkle block from options object.
|
||||
* @param {NakedBlock} options
|
||||
* @param {Object} options
|
||||
* @returns {MerkleBlock}
|
||||
*/
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ class Output {
|
||||
/**
|
||||
* Inject properties from options object.
|
||||
* @private
|
||||
* @param {NakedOutput} options
|
||||
* @param {Object} options
|
||||
*/
|
||||
|
||||
fromOptions(options) {
|
||||
@ -64,7 +64,7 @@ class Output {
|
||||
|
||||
/**
|
||||
* Instantiate output from options object.
|
||||
* @param {NakedOutput} options
|
||||
* @param {Object} options
|
||||
* @returns {Output}
|
||||
*/
|
||||
|
||||
|
||||
@ -70,7 +70,7 @@ class TX {
|
||||
/**
|
||||
* Inject properties from options object.
|
||||
* @private
|
||||
* @param {NakedTX} options
|
||||
* @param {Object} options
|
||||
*/
|
||||
|
||||
fromOptions(options) {
|
||||
@ -105,7 +105,7 @@ class TX {
|
||||
|
||||
/**
|
||||
* Instantiate TX from options object.
|
||||
* @param {NakedTX} options
|
||||
* @param {Object} options
|
||||
* @returns {TX}
|
||||
*/
|
||||
|
||||
|
||||
@ -121,7 +121,7 @@ main.halvingInterval = 210000;
|
||||
|
||||
/**
|
||||
* Genesis block header.
|
||||
* @const {NakedBlock}
|
||||
* @const {Object}
|
||||
*/
|
||||
|
||||
main.genesis = {
|
||||
|
||||
@ -159,7 +159,7 @@ exports.opcodes = {
|
||||
|
||||
/**
|
||||
* Opcodes by value.
|
||||
* @const {RevMap}
|
||||
* @const {Object}
|
||||
*/
|
||||
|
||||
exports.opcodesByVal = {
|
||||
@ -423,7 +423,7 @@ exports.hashType = {
|
||||
|
||||
/**
|
||||
* Sighash types by value.
|
||||
* @const {RevMap}
|
||||
* @const {Object}
|
||||
*/
|
||||
|
||||
exports.hashTypeByVal = {
|
||||
@ -452,7 +452,7 @@ exports.types = {
|
||||
|
||||
/**
|
||||
* Output script types by value.
|
||||
* @const {RevMap}
|
||||
* @const {Object}
|
||||
*/
|
||||
|
||||
exports.typesByVal = {
|
||||
|
||||
@ -1611,7 +1611,7 @@ class Script {
|
||||
/**
|
||||
* Inject properties from an address.
|
||||
* @private
|
||||
* @param {Address|Base58Address} address
|
||||
* @param {Address|AddressString} address
|
||||
*/
|
||||
|
||||
fromAddress(address) {
|
||||
@ -1634,7 +1634,7 @@ class Script {
|
||||
|
||||
/**
|
||||
* Create an output script from an address.
|
||||
* @param {Address|Base58Address} address
|
||||
* @param {Address|AddressString} address
|
||||
* @returns {Script}
|
||||
*/
|
||||
|
||||
|
||||
104
lib/types.js
104
lib/types.js
@ -1,8 +1,4 @@
|
||||
/**
|
||||
* An inverse enum. Retrieves key by value.
|
||||
* @typedef {Object} RevMap
|
||||
* @global
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* One of {@link module:constants.inv}.
|
||||
@ -36,18 +32,6 @@
|
||||
* @global
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unix time (seconds).
|
||||
* @typedef {Number} Seconds
|
||||
* @global
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unix time (milliseconds).
|
||||
* @typedef {Number} Milliseconds
|
||||
* @global
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base58 string.
|
||||
* @typedef {String} Base58String
|
||||
@ -55,8 +39,14 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base58 address.
|
||||
* @typedef {String} Base58Address
|
||||
* Bech32 string.
|
||||
* @typedef {String} Bech32String
|
||||
* @global
|
||||
*/
|
||||
|
||||
/**
|
||||
* Serialized address.
|
||||
* @typedef {Base58String|Bech32String} AddressString
|
||||
* @global
|
||||
*/
|
||||
|
||||
@ -66,12 +56,6 @@
|
||||
* @global
|
||||
*/
|
||||
|
||||
/**
|
||||
* Reversed hex-string hash (uint256le).
|
||||
* @typedef {String} ReversedHash
|
||||
* @global
|
||||
*/
|
||||
|
||||
/**
|
||||
* Signature hash type. One of `all`, `single`, `none`, or
|
||||
* one of {@link constants.hashType}.
|
||||
@ -107,76 +91,6 @@
|
||||
* @global
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} NakedCoin
|
||||
* @property {Number} version - Transaction version.
|
||||
* @property {Number} height - Transaction height (-1 if unconfirmed).
|
||||
* @property {Amount} value - Output value in satoshis.
|
||||
* @property {Script} script - Output script.
|
||||
* @property {Boolean} coinbase - Whether the containing
|
||||
* transaction is a coinbase.
|
||||
* @property {Hash} hash - Transaction hash.
|
||||
* @property {Number} index - Output index.
|
||||
* @global
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} NakedBlock
|
||||
* @property {Number} version - Transaction version. Note that BCoin reads
|
||||
* versions as unsigned even though they are signed at the protocol level.
|
||||
* This value will never be negative.
|
||||
* @property {Hash} prevBlock
|
||||
* @property {Hash} merkleRoot
|
||||
* @property {Number} time
|
||||
* @property {Number} bits
|
||||
* @property {Number} nonce
|
||||
* @property {Number} height
|
||||
* @property {Number} totalTX
|
||||
* @property {NakedTX[]?} txs - Only present on blocks.
|
||||
* @property {Hash[]?} hashes - Only present on merkleblocks.
|
||||
* @property {Buffer?} flags - Only present on merkleblocks.
|
||||
* @global
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} NakedInput
|
||||
* @property {Outpoint} prevout
|
||||
* @property {NakedScript} script - Input script.
|
||||
* @property {Number} sequence - nSequence.
|
||||
* @property {NakedWitness} witness - Witness.
|
||||
* @global
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} NakedOutput
|
||||
* @property {Amount} value - Value in satoshis.
|
||||
* @property {NakedScript} script - Output script.
|
||||
* @global
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} NakedTX
|
||||
* @property {Number} version
|
||||
* @property {Number} flag
|
||||
* @property {NakedInput[]} inputs
|
||||
* @property {NakedOutput[]} outputs
|
||||
* @property {Number} locktime
|
||||
* @global
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} NakedScript
|
||||
* @property {Buffer} raw - Raw code.
|
||||
* @property {Array} code - Parsed code.
|
||||
* @global
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} NakedWitness
|
||||
* @property {Buffer[]} items - Stack items.
|
||||
* @global
|
||||
*/
|
||||
|
||||
/**
|
||||
* One of `main`, `testnet`, `regtest`, `segnet3`, `segnet4`.
|
||||
* @typedef {String} NetworkType
|
||||
|
||||
@ -950,7 +950,7 @@ Account.types = {
|
||||
|
||||
/**
|
||||
* Account types by value.
|
||||
* @const {RevMap}
|
||||
* @const {Object}
|
||||
*/
|
||||
|
||||
Account.typesByVal = [
|
||||
|
||||
Loading…
Reference in New Issue
Block a user