move jsdoc types.
This commit is contained in:
parent
214a78acbf
commit
270feadf74
@ -599,14 +599,6 @@ Address.sha256 = function sha256(key) {
|
|||||||
return utils.sha256(key);
|
return utils.sha256(key);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Can be `pubkeyhash`, `scripthash`, `witnesspubkeyhash`,
|
|
||||||
* or `witnessscripthash`, or an address prefix
|
|
||||||
* (see {@link network.address}).
|
|
||||||
* @global
|
|
||||||
* @typedef {String|Number} AddressType
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compile a hash to an address.
|
* Compile a hash to an address.
|
||||||
* @param {Hash|Buffer} hash
|
* @param {Hash|Buffer} hash
|
||||||
@ -669,13 +661,6 @@ Address.compileData = function compileData(data, type, version) {
|
|||||||
return Address.compileHash(data, type, version);
|
return Address.compileHash(data, type, version);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} ParsedAddress
|
|
||||||
* @property {Number?} version - Witness program version (-1 if not present).
|
|
||||||
* @property {AddressType} type
|
|
||||||
* @property {Buffer} hash
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse a base58 address.
|
* Parse a base58 address.
|
||||||
* @param {Base58Address} address
|
* @param {Base58Address} address
|
||||||
|
|||||||
@ -2408,12 +2408,6 @@ Chain.prototype._getInitialState = function _getInitialState(callback) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* A bitfield containing locktime flags.
|
|
||||||
* @global
|
|
||||||
* @typedef {Number} LockFlags
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check transaction finality, taking into account MEDIAN_TIME_PAST
|
* Check transaction finality, taking into account MEDIAN_TIME_PAST
|
||||||
* if it is present in the lock flags.
|
* if it is present in the lock flags.
|
||||||
|
|||||||
@ -14,13 +14,6 @@ var assert = utils.assert;
|
|||||||
var constants = bcoin.protocol.constants;
|
var constants = bcoin.protocol.constants;
|
||||||
var network = bcoin.protocol.network;
|
var network = bcoin.protocol.network;
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} Seed
|
|
||||||
* @global
|
|
||||||
* @property {String} host
|
|
||||||
* @property {Number} port
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a remote peer.
|
* Represents a remote peer.
|
||||||
* @exports Peer
|
* @exports Peer
|
||||||
@ -284,13 +277,6 @@ Peer.prototype.createSocket = function createSocket(port, host) {
|
|||||||
return socket;
|
return socket;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {EventEmitter} BroadcastPromise
|
|
||||||
* @emits BroadcastPromise#ack
|
|
||||||
* @emits BroadcastPromise#timeout
|
|
||||||
* @emits BroadcastPromise#reject
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Broadcast items to peer (transactions or blocks).
|
* Broadcast items to peer (transactions or blocks).
|
||||||
* @param {TX|Block|TX[]|Block[]} items
|
* @param {TX|Block|TX[]|Block[]} items
|
||||||
|
|||||||
@ -92,12 +92,6 @@ exports.inv = {
|
|||||||
WITNESS_FILTERED_BLOCK: 3 | (1 << 30)
|
WITNESS_FILTERED_BLOCK: 3 | (1 << 30)
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* An inverse enum. Retrieves key by value.
|
|
||||||
* @global
|
|
||||||
* @typedef {Object} RevMap
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inv types by value.
|
* Inv types by value.
|
||||||
* @const {RevMap}
|
* @const {RevMap}
|
||||||
|
|||||||
@ -486,13 +486,6 @@ Framer._inv = function _inv(items, writer) {
|
|||||||
return p;
|
return p;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} InvItem
|
|
||||||
* @global
|
|
||||||
* @property {Number|String} type - Inv type. See {@link constants.inv}.
|
|
||||||
* @property {Hash|Buffer} hash
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an inv packet (without a header).
|
* Create an inv packet (without a header).
|
||||||
* @param {InvItem[]} items
|
* @param {InvItem[]} items
|
||||||
@ -1165,13 +1158,6 @@ Framer.getAddr = function getAddr() {
|
|||||||
return DUMMY;
|
return DUMMY;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} Outpoint
|
|
||||||
* @global
|
|
||||||
* @property {Hash} hash
|
|
||||||
* @property {Number} index
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a getutxos packet (without a header).
|
* Create a getutxos packet (without a header).
|
||||||
* @param {GetUTXOsPacket} data
|
* @param {GetUTXOsPacket} data
|
||||||
|
|||||||
@ -158,14 +158,6 @@ Parser.parseMempool = function parseMempool(p) {
|
|||||||
return {};
|
return {};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} SubmitOrderPacket
|
|
||||||
* @global
|
|
||||||
* @property {Hash} hash
|
|
||||||
* @property {NakedTX} tx
|
|
||||||
* @property {Number} _size
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse submitorder packet.
|
* Parse submitorder packet.
|
||||||
* @param {Buffer|BufferReader} p
|
* @param {Buffer|BufferReader} p
|
||||||
@ -193,15 +185,6 @@ Parser.parseCheckOrder = function parseCheckOrder(p) {
|
|||||||
return Parser.parseSubmitOrder(p);
|
return Parser.parseSubmitOrder(p);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} ReplyPacket
|
|
||||||
* @global
|
|
||||||
* @property {Hash} hash
|
|
||||||
* @property {Number} code
|
|
||||||
* @property {Buffer} publicKey
|
|
||||||
* @property {Number} _size
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse reply packet.
|
* Parse reply packet.
|
||||||
* @param {Buffer|BufferReader} p
|
* @param {Buffer|BufferReader} p
|
||||||
@ -250,17 +233,6 @@ Parser.parseGetAddr = function parseGetAddr(p) {
|
|||||||
return {};
|
return {};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} FilterLoadPacket
|
|
||||||
* @global
|
|
||||||
* @see Bloom
|
|
||||||
* @property {Buffer} filter - Serialized bloom filter.
|
|
||||||
* @property {Number} n - Number of hash functions.
|
|
||||||
* @property {Number} tweak - Bloom filter seed.
|
|
||||||
* @property {String|Number} update (See {@link constants.filterFlags}).
|
|
||||||
* @property {Number} _size
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse filterload packet.
|
* Parse filterload packet.
|
||||||
* @param {Buffer|BufferReader} p
|
* @param {Buffer|BufferReader} p
|
||||||
@ -289,14 +261,6 @@ Parser.parseFilterLoad = function parseFilterLoad(p) {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} FilterAddPacket
|
|
||||||
* @global
|
|
||||||
* @see Bloom
|
|
||||||
* @property {Buffer} data - Data to add to filter.
|
|
||||||
* @property {Number} _size
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse filteradd packet.
|
* Parse filteradd packet.
|
||||||
* @param {Buffer|BufferReader} p
|
* @param {Buffer|BufferReader} p
|
||||||
@ -393,14 +357,6 @@ Parser.prototype.parsePayload = function parsePayload(cmd, p) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} GetUTXOsPacket
|
|
||||||
* @global
|
|
||||||
* @property {Boolean} mempool - Check mempool.
|
|
||||||
* @property {Outpoint[]} prevout - Outpoints.
|
|
||||||
* @property {Number} _size
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse getutxos packet.
|
* Parse getutxos packet.
|
||||||
* @param {Buffer|BufferReader} p
|
* @param {Buffer|BufferReader} p
|
||||||
@ -431,31 +387,6 @@ Parser.parseGetUTXOs = function parseGetUTXOs(p) {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} NakedCoin
|
|
||||||
* @global
|
|
||||||
* @property {Number} version - Transaction version.
|
|
||||||
* @property {Number} height - Transaction height (-1 if unconfirmed).
|
|
||||||
* @property {BN} 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} UTXOsPacket
|
|
||||||
* @global
|
|
||||||
* @property {Array?} data.hits - Hits (array of
|
|
||||||
* 1s and 0s representing a bit mask).
|
|
||||||
* @property {Buffer?} data.map - Hit map.
|
|
||||||
* @property {Object} data.height - Chain height.
|
|
||||||
* @property {Hash} data.tip - Chain tip hash.
|
|
||||||
* @property {NakedCoin[]} data.coins
|
|
||||||
* @property {Number} _size
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse utxos packet.
|
* Parse utxos packet.
|
||||||
* @param {Buffer|BufferReader} p
|
* @param {Buffer|BufferReader} p
|
||||||
@ -504,13 +435,6 @@ Parser.parseUTXOs = function parseUTXOs(p) {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} PingPacket
|
|
||||||
* @global
|
|
||||||
* @property {BN} nonce
|
|
||||||
* @property {Number} _size
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse ping packet.
|
* Parse ping packet.
|
||||||
* @param {Buffer|BufferReader} p
|
* @param {Buffer|BufferReader} p
|
||||||
@ -543,37 +467,6 @@ Parser.parsePong = function parsePong(p) {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} NetworkAddress
|
|
||||||
* @global
|
|
||||||
* @property {Number?} ts - Timestamp.
|
|
||||||
* @property {Number?} services - Service bits.
|
|
||||||
* @property {Buffer?} ipv4 - IPv4 address.
|
|
||||||
* @property {Buffer?} ipv6 - IPv6 address.
|
|
||||||
* @property {Number?} port - Port.
|
|
||||||
* @property {Boolean?} network - Whether network services are enabled.
|
|
||||||
* @property {Boolean?} getutxo - Whether peer supports getutxos.
|
|
||||||
* @property {Boolean?} bloom - Whether peer supports serving FILTERED_BLOCKs.
|
|
||||||
* @property {Boolean?} witness - Whether peer supports segwit.
|
|
||||||
* @property {Number} _size
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} VersionPacket
|
|
||||||
* @global
|
|
||||||
* @property {Number} version - Protocol version.
|
|
||||||
* @property {Number} services - Service bits.
|
|
||||||
* @property {Number} ts - Timestamp of discovery.
|
|
||||||
* @property {NetworkAddress} local - Our address.
|
|
||||||
* @property {NetworkAddress} remote - Their address.
|
|
||||||
* @property {BN} nonce
|
|
||||||
* @property {String} agent - User agent string.
|
|
||||||
* @property {Number} height - Chain height.
|
|
||||||
* @property {Boolean} relay - Whether transactions
|
|
||||||
* should be relayed immediately.
|
|
||||||
* @property {Number} _size
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse version packet.
|
* Parse version packet.
|
||||||
* @param {Buffer|BufferReader} p
|
* @param {Buffer|BufferReader} p
|
||||||
@ -652,15 +545,6 @@ Parser.parseGetData = function parseGetData(p) {
|
|||||||
return Parser.parseInv(p);
|
return Parser.parseInv(p);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} GetBlocksPacket
|
|
||||||
* @global
|
|
||||||
* @property {Number} version - Protocol version.
|
|
||||||
* @property {Hash[]} locator - Chain locator.
|
|
||||||
* @property {Hash} stop - Hash to stop at.
|
|
||||||
* @property {Number} _size
|
|
||||||
*/
|
|
||||||
|
|
||||||
Parser._parseGetBlocks = function _parseGetBlocks(p) {
|
Parser._parseGetBlocks = function _parseGetBlocks(p) {
|
||||||
var version, count, locator, i, stop;
|
var version, count, locator, i, stop;
|
||||||
|
|
||||||
@ -878,26 +762,6 @@ Parser.parseBlock = function parseBlock(p) {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} NakedBlock
|
|
||||||
* @global
|
|
||||||
* @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} ts
|
|
||||||
* @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.
|
|
||||||
* @property {Number?} coinbaseHeight - Only present on compactblocks.
|
|
||||||
* @property {Number} _size
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse block packet.
|
* Parse block packet.
|
||||||
* @param {Buffer|BufferReader} p
|
* @param {Buffer|BufferReader} p
|
||||||
@ -959,16 +823,6 @@ Parser.parseBlockCompact = function parseBlockCompact(p) {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} NakedInput
|
|
||||||
* @global
|
|
||||||
* @property {Outpoint} prevout
|
|
||||||
* @property {NakedScript} script - Input script.
|
|
||||||
* @property {Number} sequence - nSequence.
|
|
||||||
* @property {NakedWitness} witness - Witness.
|
|
||||||
* @property {Number} _size
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse serialized input.
|
* Parse serialized input.
|
||||||
* @param {Buffer|BufferReader} p
|
* @param {Buffer|BufferReader} p
|
||||||
@ -998,14 +852,6 @@ Parser.parseInput = function parseInput(p) {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} NakedOutput
|
|
||||||
* @global
|
|
||||||
* @property {BN} value - Value in satoshis.
|
|
||||||
* @property {NakedScript} script - Output script.
|
|
||||||
* @property {Number} _size
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse serialized output.
|
* Parse serialized output.
|
||||||
* @param {Buffer|BufferReader} p
|
* @param {Buffer|BufferReader} p
|
||||||
@ -1028,20 +874,6 @@ Parser.parseOutput = function parseOutput(p) {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} NakedCoin
|
|
||||||
* @global
|
|
||||||
* @property {Number} version - Transaction version.
|
|
||||||
* @property {Number} height - Transaction height (-1 if unconfirmed).
|
|
||||||
* @property {BN} 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.
|
|
||||||
* @property {Number} _size
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse serialized coin.
|
* Parse serialized coin.
|
||||||
* @param {Buffer|BufferReader} p
|
* @param {Buffer|BufferReader} p
|
||||||
@ -1081,17 +913,6 @@ Parser.parseCoin = function parseCoin(p, extended) {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} NakedTX
|
|
||||||
* @global
|
|
||||||
* @property {Number} version
|
|
||||||
* @property {Number} flag
|
|
||||||
* @property {NakedInput[]} inputs
|
|
||||||
* @property {NakedOutput[]} outputs
|
|
||||||
* @property {Number} locktime
|
|
||||||
* @property {Number} _size
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse tx packet (will automatically switch to witness
|
* Parse tx packet (will automatically switch to witness
|
||||||
* parsing if a witness transaction is detected).
|
* parsing if a witness transaction is detected).
|
||||||
@ -1213,14 +1034,6 @@ Parser.parseWitnessTX = function parseWitnessTX(p) {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} NakedScript
|
|
||||||
* @global
|
|
||||||
* @property {Buffer} raw - Raw code.
|
|
||||||
* @property {Array} code - Parsed code.
|
|
||||||
* @property {Number} _size
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse serialized script (with varint length).
|
* Parse serialized script (with varint length).
|
||||||
* @param {Buffer|BufferReader} p
|
* @param {Buffer|BufferReader} p
|
||||||
@ -1241,13 +1054,6 @@ Parser.parseScript = function parseScript(p) {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} NakedWitness
|
|
||||||
* @global
|
|
||||||
* @param {Buffer[]} items - Stack items.
|
|
||||||
* @property {Number} _size
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse serialized witness.
|
* Parse serialized witness.
|
||||||
* @param {Buffer|BufferReader} p
|
* @param {Buffer|BufferReader} p
|
||||||
@ -1272,17 +1078,6 @@ Parser.parseWitness = function parseWitness(p) {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} RejectPacket
|
|
||||||
* @global
|
|
||||||
* @param {(Number|String)?} ccode - Code
|
|
||||||
* (see {@link constants.reject}).
|
|
||||||
* @param {String?} msg - Message.
|
|
||||||
* @param {String?} reason - Reason.
|
|
||||||
* @param {(Hash|Buffer)?} data - Transaction or block hash.
|
|
||||||
* @property {Number} _size
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse reject packet.
|
* Parse reject packet.
|
||||||
* @param {Buffer|BufferReader} p
|
* @param {Buffer|BufferReader} p
|
||||||
@ -1383,28 +1178,6 @@ Parser.parseMempool = function parseMempool(p) {
|
|||||||
return {};
|
return {};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} AlertPacket
|
|
||||||
* @global
|
|
||||||
* @property {Number} version
|
|
||||||
* @property {Number} relayUntil
|
|
||||||
* @property {Number} expiration
|
|
||||||
* @property {Number} id
|
|
||||||
* @property {Number} cancel
|
|
||||||
* @property {Number[]} cancels
|
|
||||||
* @property {Number} minVer
|
|
||||||
* @property {Number} maxVer
|
|
||||||
* @property {String[]} subVers
|
|
||||||
* @property {Number} priority
|
|
||||||
* @property {String} comment
|
|
||||||
* @property {String} statusBar
|
|
||||||
* @property {String?} reserved
|
|
||||||
* @property {Buffer?} payload - Payload.
|
|
||||||
* @property {Buffer?} signature - Payload signature.
|
|
||||||
* @property {Buffer?} key - Private key to sign with.
|
|
||||||
* @property {Number} _size
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse alert packet.
|
* Parse alert packet.
|
||||||
* @param {Buffer|BufferReader} p
|
* @param {Buffer|BufferReader} p
|
||||||
|
|||||||
@ -18,18 +18,6 @@ var STACK_TRUE = new Buffer([1]);
|
|||||||
var STACK_FALSE = new Buffer([]);
|
var STACK_FALSE = new Buffer([]);
|
||||||
var STACK_NEGATE = new Buffer([0x81]);
|
var STACK_NEGATE = new Buffer([0x81]);
|
||||||
|
|
||||||
/**
|
|
||||||
* A big number (bn.js)
|
|
||||||
* @global
|
|
||||||
* @typedef {Object} BN
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A bitfield containing script verify flags.
|
|
||||||
* @global
|
|
||||||
* @typedef {Number} VerifyFlags
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refers to the witness field of segregated witness transactions.
|
* Refers to the witness field of segregated witness transactions.
|
||||||
* @exports Witness
|
* @exports Witness
|
||||||
@ -2722,15 +2710,6 @@ Script.prototype.isWitnessProgram = function isWitnessProgram() {
|
|||||||
&& this.code[1].length >= 2 && this.code[1].length <= 32;
|
&& this.code[1].length >= 2 && this.code[1].length <= 32;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} Program
|
|
||||||
* @property {Number} version - Ranges from 0 to 16.
|
|
||||||
* @property {String|null} type - Null if malformed. `unknown` if unknown
|
|
||||||
* version (treated as anyone-can-spend). Otherwise one of `witnesspubkeyhash`
|
|
||||||
* or `witnessscripthash`.
|
|
||||||
* @property {Buffer} data - Usually the hash.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the witness program if present.
|
* Get the witness program if present.
|
||||||
* @returns {Program|null}
|
* @returns {Program|null}
|
||||||
|
|||||||
@ -58,27 +58,6 @@ TXDB.prototype._lock = function _lock(func, args, force) {
|
|||||||
return this.locker.lock(func, args, force);
|
return this.locker.lock(func, args, force);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* The wallet ID (when mapAddress is enabled)
|
|
||||||
* or a {@link Base58Address} otherwise.
|
|
||||||
* @typedef {String} WalletID
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Table of address->id.
|
|
||||||
* @global
|
|
||||||
* @typedef {Object} AddressTable
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} AddressMap
|
|
||||||
* @global
|
|
||||||
* @property {Object} table - Table of address->id.
|
|
||||||
* @property {String[]} input - Input IDs.
|
|
||||||
* @property {String[]} output - Output IDs.
|
|
||||||
* @property {String[]} all - Both input and output IDs.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map a transactions' addresses to wallet IDs.
|
* Map a transactions' addresses to wallet IDs.
|
||||||
* @param {TX} tx
|
* @param {TX} tx
|
||||||
@ -232,12 +211,6 @@ TXDB.prototype._addOrphan = function _addOrphan(key, hash, index, callback) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} Orphan
|
|
||||||
* @property {Hash} hash - Orphan TX hash.
|
|
||||||
* @property {Number} index - Orphan input index.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve orphan list by coin ID.
|
* Retrieve orphan list by coin ID.
|
||||||
* @private
|
* @private
|
||||||
|
|||||||
368
lib/bcoin/types.js
Normal file
368
lib/bcoin/types.js
Normal file
@ -0,0 +1,368 @@
|
|||||||
|
/**
|
||||||
|
* An inverse enum. Retrieves key by value.
|
||||||
|
* @global
|
||||||
|
* @typedef {Object} RevMap
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} InvItem
|
||||||
|
* @global
|
||||||
|
* @property {Number|String} type - Inv type. See {@link constants.inv}.
|
||||||
|
* @property {Hash|Buffer} hash
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} Outpoint
|
||||||
|
* @global
|
||||||
|
* @property {Hash} hash
|
||||||
|
* @property {Number} index
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Can be `pubkeyhash`, `scripthash`, `witnesspubkeyhash`,
|
||||||
|
* or `witnessscripthash`, or an address prefix
|
||||||
|
* (see {@link network.address}).
|
||||||
|
* @global
|
||||||
|
* @typedef {String|Number} AddressType
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} ParsedAddress
|
||||||
|
* @global
|
||||||
|
* @property {Number?} version - Witness program version (-1 if not present).
|
||||||
|
* @property {AddressType} type
|
||||||
|
* @property {Buffer} hash
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A bitfield containing locktime flags.
|
||||||
|
* @global
|
||||||
|
* @typedef {Number} LockFlags
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} Seed
|
||||||
|
* @global
|
||||||
|
* @property {String} host
|
||||||
|
* @property {Number} port
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {EventEmitter} BroadcastPromise
|
||||||
|
* @global
|
||||||
|
* @emits BroadcastPromise#ack
|
||||||
|
* @emits BroadcastPromise#timeout
|
||||||
|
* @emits BroadcastPromise#reject
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} ParsedURI
|
||||||
|
* @global
|
||||||
|
* @property {Base58Address} address
|
||||||
|
* @property {BN?} amount? - Amount in satoshis.
|
||||||
|
* @property {String?} label
|
||||||
|
* @property {String?} message
|
||||||
|
* @property {String?} request - Payment request URL.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wallet ID
|
||||||
|
* @global
|
||||||
|
* @typedef {String} WalletID
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base58 string.
|
||||||
|
* @global
|
||||||
|
* @typedef {String} Base58String
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base58 address.
|
||||||
|
* @global
|
||||||
|
* @typedef {String} Base58Address
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hex-string hash.
|
||||||
|
* @global
|
||||||
|
* @typedef {String} Hash
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reversed hex-string hash (uint256le).
|
||||||
|
* @global
|
||||||
|
* @typedef {String} ReversedHash
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signature hash type. One of `all`, `single`, `none`, or
|
||||||
|
* one of {@link constants.hashType}.
|
||||||
|
* @global
|
||||||
|
* @typedef {String|Number} SighashType
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wallet balance.
|
||||||
|
* @global
|
||||||
|
* @typedef {Object} Balance
|
||||||
|
* @property {BN} confirmed
|
||||||
|
* @property {BN} unconfirmed
|
||||||
|
* @property {BN} total
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A big number (bn.js)
|
||||||
|
* @global
|
||||||
|
* @typedef {Object} BN
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A bitfield containing script verify flags.
|
||||||
|
* @global
|
||||||
|
* @typedef {Number} VerifyFlags
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} Program
|
||||||
|
* @property {Number} version - Ranges from 0 to 16.
|
||||||
|
* @property {String|null} type - Null if malformed. `unknown` if unknown
|
||||||
|
* version (treated as anyone-can-spend). Otherwise one of `witnesspubkeyhash`
|
||||||
|
* or `witnessscripthash`.
|
||||||
|
* @property {Buffer} data - Usually the hash.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} Orphan
|
||||||
|
* @property {Hash} hash - Orphan TX hash.
|
||||||
|
* @property {Number} index - Orphan input index.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} SubmitOrderPacket
|
||||||
|
* @global
|
||||||
|
* @property {Hash} hash
|
||||||
|
* @property {NakedTX} tx
|
||||||
|
* @property {Number} _size
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} ReplyPacket
|
||||||
|
* @global
|
||||||
|
* @property {Hash} hash
|
||||||
|
* @property {Number} code
|
||||||
|
* @property {Buffer} publicKey
|
||||||
|
* @property {Number} _size
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} FilterLoadPacket
|
||||||
|
* @global
|
||||||
|
* @see Bloom
|
||||||
|
* @property {Buffer} filter - Serialized bloom filter.
|
||||||
|
* @property {Number} n - Number of hash functions.
|
||||||
|
* @property {Number} tweak - Bloom filter seed.
|
||||||
|
* @property {String|Number} update (See {@link constants.filterFlags}).
|
||||||
|
* @property {Number} _size
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} FilterAddPacket
|
||||||
|
* @global
|
||||||
|
* @see Bloom
|
||||||
|
* @property {Buffer} data - Data to add to filter.
|
||||||
|
* @property {Number} _size
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} GetUTXOsPacket
|
||||||
|
* @global
|
||||||
|
* @property {Boolean} mempool - Check mempool.
|
||||||
|
* @property {Outpoint[]} prevout - Outpoints.
|
||||||
|
* @property {Number} _size
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} NakedCoin
|
||||||
|
* @global
|
||||||
|
* @property {Number} version - Transaction version.
|
||||||
|
* @property {Number} height - Transaction height (-1 if unconfirmed).
|
||||||
|
* @property {BN} 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} UTXOsPacket
|
||||||
|
* @global
|
||||||
|
* @property {Array?} data.hits - Hits (array of
|
||||||
|
* 1s and 0s representing a bit mask).
|
||||||
|
* @property {Buffer?} data.map - Hit map.
|
||||||
|
* @property {Object} data.height - Chain height.
|
||||||
|
* @property {Hash} data.tip - Chain tip hash.
|
||||||
|
* @property {NakedCoin[]} data.coins
|
||||||
|
* @property {Number} _size
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} PingPacket
|
||||||
|
* @global
|
||||||
|
* @property {BN} nonce
|
||||||
|
* @property {Number} _size
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} NetworkAddress
|
||||||
|
* @global
|
||||||
|
* @property {Number?} ts - Timestamp.
|
||||||
|
* @property {Number?} services - Service bits.
|
||||||
|
* @property {Buffer?} ipv4 - IPv4 address.
|
||||||
|
* @property {Buffer?} ipv6 - IPv6 address.
|
||||||
|
* @property {Number?} port - Port.
|
||||||
|
* @property {Boolean?} network - Whether network services are enabled.
|
||||||
|
* @property {Boolean?} getutxo - Whether peer supports getutxos.
|
||||||
|
* @property {Boolean?} bloom - Whether peer supports serving FILTERED_BLOCKs.
|
||||||
|
* @property {Boolean?} witness - Whether peer supports segwit.
|
||||||
|
* @property {Number} _size
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} VersionPacket
|
||||||
|
* @global
|
||||||
|
* @property {Number} version - Protocol version.
|
||||||
|
* @property {Number} services - Service bits.
|
||||||
|
* @property {Number} ts - Timestamp of discovery.
|
||||||
|
* @property {NetworkAddress} local - Our address.
|
||||||
|
* @property {NetworkAddress} remote - Their address.
|
||||||
|
* @property {BN} nonce
|
||||||
|
* @property {String} agent - User agent string.
|
||||||
|
* @property {Number} height - Chain height.
|
||||||
|
* @property {Boolean} relay - Whether transactions
|
||||||
|
* should be relayed immediately.
|
||||||
|
* @property {Number} _size
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} GetBlocksPacket
|
||||||
|
* @global
|
||||||
|
* @property {Number} version - Protocol version.
|
||||||
|
* @property {Hash[]} locator - Chain locator.
|
||||||
|
* @property {Hash} stop - Hash to stop at.
|
||||||
|
* @property {Number} _size
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} NakedBlock
|
||||||
|
* @global
|
||||||
|
* @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} ts
|
||||||
|
* @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.
|
||||||
|
* @property {Number?} coinbaseHeight - Only present on compactblocks.
|
||||||
|
* @property {Number} _size
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} NakedInput
|
||||||
|
* @global
|
||||||
|
* @property {Outpoint} prevout
|
||||||
|
* @property {NakedScript} script - Input script.
|
||||||
|
* @property {Number} sequence - nSequence.
|
||||||
|
* @property {NakedWitness} witness - Witness.
|
||||||
|
* @property {Number} _size
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} NakedOutput
|
||||||
|
* @global
|
||||||
|
* @property {BN} value - Value in satoshis.
|
||||||
|
* @property {NakedScript} script - Output script.
|
||||||
|
* @property {Number} _size
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} NakedCoin
|
||||||
|
* @global
|
||||||
|
* @property {Number} version - Transaction version.
|
||||||
|
* @property {Number} height - Transaction height (-1 if unconfirmed).
|
||||||
|
* @property {BN} 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.
|
||||||
|
* @property {Number} _size
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} NakedTX
|
||||||
|
* @global
|
||||||
|
* @property {Number} version
|
||||||
|
* @property {Number} flag
|
||||||
|
* @property {NakedInput[]} inputs
|
||||||
|
* @property {NakedOutput[]} outputs
|
||||||
|
* @property {Number} locktime
|
||||||
|
* @property {Number} _size
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} NakedScript
|
||||||
|
* @global
|
||||||
|
* @property {Buffer} raw - Raw code.
|
||||||
|
* @property {Array} code - Parsed code.
|
||||||
|
* @property {Number} _size
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} NakedWitness
|
||||||
|
* @global
|
||||||
|
* @param {Buffer[]} items - Stack items.
|
||||||
|
* @property {Number} _size
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} RejectPacket
|
||||||
|
* @global
|
||||||
|
* @param {(Number|String)?} ccode - Code
|
||||||
|
* (see {@link constants.reject}).
|
||||||
|
* @param {String?} msg - Message.
|
||||||
|
* @param {String?} reason - Reason.
|
||||||
|
* @param {(Hash|Buffer)?} data - Transaction or block hash.
|
||||||
|
* @property {Number} _size
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} AlertPacket
|
||||||
|
* @global
|
||||||
|
* @property {Number} version
|
||||||
|
* @property {Number} relayUntil
|
||||||
|
* @property {Number} expiration
|
||||||
|
* @property {Number} id
|
||||||
|
* @property {Number} cancel
|
||||||
|
* @property {Number[]} cancels
|
||||||
|
* @property {Number} minVer
|
||||||
|
* @property {Number} maxVer
|
||||||
|
* @property {String[]} subVers
|
||||||
|
* @property {Number} priority
|
||||||
|
* @property {String} comment
|
||||||
|
* @property {String} statusBar
|
||||||
|
* @property {String?} reserved
|
||||||
|
* @property {Buffer?} payload - Payload.
|
||||||
|
* @property {Buffer?} signature - Payload signature.
|
||||||
|
* @property {Buffer?} key - Private key to sign with.
|
||||||
|
* @property {Number} _size
|
||||||
|
*/
|
||||||
@ -9,15 +9,6 @@ var url = require('url');
|
|||||||
var querystring = require('querystring');
|
var querystring = require('querystring');
|
||||||
var utils = require('./utils');
|
var utils = require('./utils');
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} ParsedURI
|
|
||||||
* @property {Base58Address} address
|
|
||||||
* @property {BN?} amount? - Amount in satoshis.
|
|
||||||
* @property {String?} label
|
|
||||||
* @property {String?} message
|
|
||||||
* @property {String?} request - Payment request URL.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse a bitcoin URI.
|
* Parse a bitcoin URI.
|
||||||
* @param {String} uri - Bitcoin URI.
|
* @param {String} uri - Bitcoin URI.
|
||||||
|
|||||||
@ -7,37 +7,6 @@
|
|||||||
|
|
||||||
module.exports = function(bcoin) {
|
module.exports = function(bcoin) {
|
||||||
|
|
||||||
/**
|
|
||||||
* Base58 string.
|
|
||||||
* @global
|
|
||||||
* @typedef {String} Base58String
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Base58 address.
|
|
||||||
* @global
|
|
||||||
* @typedef {String} Base58Address
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hex-string hash.
|
|
||||||
* @global
|
|
||||||
* @typedef {String} Hash
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reversed hex-string hash (uint256le).
|
|
||||||
* @global
|
|
||||||
* @typedef {String} ReversedHash
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Signature hash type. One of `all`, `single`, `none`, or
|
|
||||||
* one of {@link constants.hashType}.
|
|
||||||
* @global
|
|
||||||
* @typedef {String|Number} SighashType
|
|
||||||
*/
|
|
||||||
|
|
||||||
var EventEmitter = require('events').EventEmitter;
|
var EventEmitter = require('events').EventEmitter;
|
||||||
var utils = require('./utils');
|
var utils = require('./utils');
|
||||||
var assert = utils.assert;
|
var assert = utils.assert;
|
||||||
@ -1298,15 +1267,6 @@ Wallet.prototype.getUnconfirmed = function getUnconfirmed(callback) {
|
|||||||
return this.provider.getUnconfirmed(callback);
|
return this.provider.getUnconfirmed(callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Wallet balance.
|
|
||||||
* @global
|
|
||||||
* @typedef {Object} Balance
|
|
||||||
* @property {BN} confirmed
|
|
||||||
* @property {BN} unconfirmed
|
|
||||||
* @property {BN} total
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get wallet balance (accesses provider).
|
* Get wallet balance (accesses provider).
|
||||||
* @param {Function} callback - Returns [Error, {@link Balance}].
|
* @param {Function} callback - Returns [Error, {@link Balance}].
|
||||||
|
|||||||
@ -204,12 +204,6 @@ WalletDB.prototype.destroy = function destroy(callback) {
|
|||||||
this.db.close(callback);
|
this.db.close(callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Wallet ID
|
|
||||||
* @global
|
|
||||||
* @typedef {String} WalletID
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sync address depths based on a transaction's outputs.
|
* Sync address depths based on a transaction's outputs.
|
||||||
* This is used for deriving new addresses when
|
* This is used for deriving new addresses when
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user