bcoin: use util.revHex again.
This commit is contained in:
parent
f2abdf68cb
commit
3c82ac0486
@ -12,7 +12,6 @@ const path = require('path');
|
|||||||
const AsyncEmitter = require('bevent');
|
const AsyncEmitter = require('bevent');
|
||||||
const Logger = require('blgr');
|
const Logger = require('blgr');
|
||||||
const {Lock} = require('bmutex');
|
const {Lock} = require('bmutex');
|
||||||
const {encoding} = require('bufio');
|
|
||||||
const Network = require('../protocol/network');
|
const Network = require('../protocol/network');
|
||||||
const ChainDB = require('./chaindb');
|
const ChainDB = require('./chaindb');
|
||||||
const common = require('./common');
|
const common = require('./common');
|
||||||
@ -1562,7 +1561,7 @@ class Chain extends AsyncEmitter {
|
|||||||
|
|
||||||
if (hash === checkpoint) {
|
if (hash === checkpoint) {
|
||||||
this.logger.debug('Hit checkpoint block %s (%d).',
|
this.logger.debug('Hit checkpoint block %s (%d).',
|
||||||
encoding.revHex(hash), height);
|
util.revHex(hash), height);
|
||||||
this.emit('checkpoint', hash, height);
|
this.emit('checkpoint', hash, height);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1574,8 +1573,8 @@ class Chain extends AsyncEmitter {
|
|||||||
this.logger.warning(
|
this.logger.warning(
|
||||||
'Checkpoint mismatch at height %d: expected=%s received=%s',
|
'Checkpoint mismatch at height %d: expected=%s received=%s',
|
||||||
height,
|
height,
|
||||||
encoding.revHex(checkpoint),
|
util.revHex(checkpoint),
|
||||||
encoding.revHex(hash)
|
util.revHex(hash)
|
||||||
);
|
);
|
||||||
|
|
||||||
this.purgeOrphans();
|
this.purgeOrphans();
|
||||||
|
|||||||
@ -16,6 +16,7 @@ const CoinView = require('../coins/coinview');
|
|||||||
const UndoCoins = require('../coins/undocoins');
|
const UndoCoins = require('../coins/undocoins');
|
||||||
const layout = require('./layout');
|
const layout = require('./layout');
|
||||||
const LRU = require('../utils/lru');
|
const LRU = require('../utils/lru');
|
||||||
|
const util = require('../utils/util');
|
||||||
const Block = require('../primitives/block');
|
const Block = require('../primitives/block');
|
||||||
const Outpoint = require('../primitives/outpoint');
|
const Outpoint = require('../primitives/outpoint');
|
||||||
const Address = require('../primitives/address');
|
const Address = require('../primitives/address');
|
||||||
@ -1275,7 +1276,7 @@ class ChainDB {
|
|||||||
if (typeof start === 'number')
|
if (typeof start === 'number')
|
||||||
this.logger.info('Scanning from height %d.', start);
|
this.logger.info('Scanning from height %d.', start);
|
||||||
else
|
else
|
||||||
this.logger.info('Scanning from block %s.', encoding.revHex(start));
|
this.logger.info('Scanning from block %s.', util.revHex(start));
|
||||||
|
|
||||||
let entry = await this.getEntry(start);
|
let entry = await this.getEntry(start);
|
||||||
|
|
||||||
@ -2135,7 +2136,7 @@ class ChainState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rhash() {
|
rhash() {
|
||||||
return encoding.revHex(this.tip);
|
return util.revHex(this.tip);
|
||||||
}
|
}
|
||||||
|
|
||||||
clone() {
|
clone() {
|
||||||
|
|||||||
@ -12,6 +12,7 @@ const bio = require('bufio');
|
|||||||
const BN = require('bcrypto/lib/bn');
|
const BN = require('bcrypto/lib/bn');
|
||||||
const consensus = require('../protocol/consensus');
|
const consensus = require('../protocol/consensus');
|
||||||
const hash256 = require('bcrypto/lib/hash256');
|
const hash256 = require('bcrypto/lib/hash256');
|
||||||
|
const util = require('../utils/util');
|
||||||
const Headers = require('../primitives/headers');
|
const Headers = require('../primitives/headers');
|
||||||
const InvItem = require('../primitives/invitem');
|
const InvItem = require('../primitives/invitem');
|
||||||
const {encoding} = bio;
|
const {encoding} = bio;
|
||||||
@ -177,7 +178,7 @@ class ChainEntry {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
rhash() {
|
rhash() {
|
||||||
return encoding.revHex(this.hash);
|
return util.revHex(this.hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -274,10 +275,10 @@ class ChainEntry {
|
|||||||
|
|
||||||
toJSON() {
|
toJSON() {
|
||||||
return {
|
return {
|
||||||
hash: encoding.revHex(this.hash),
|
hash: util.revHex(this.hash),
|
||||||
version: this.version,
|
version: this.version,
|
||||||
prevBlock: encoding.revHex(this.prevBlock),
|
prevBlock: util.revHex(this.prevBlock),
|
||||||
merkleRoot: encoding.revHex(this.merkleRoot),
|
merkleRoot: util.revHex(this.merkleRoot),
|
||||||
time: this.time,
|
time: this.time,
|
||||||
bits: this.bits,
|
bits: this.bits,
|
||||||
nonce: this.nonce,
|
nonce: this.nonce,
|
||||||
@ -303,10 +304,10 @@ class ChainEntry {
|
|||||||
assert((json.nonce >>> 0) === json.nonce);
|
assert((json.nonce >>> 0) === json.nonce);
|
||||||
assert(typeof json.chainwork === 'string');
|
assert(typeof json.chainwork === 'string');
|
||||||
|
|
||||||
this.hash = encoding.revHex(json.hash);
|
this.hash = util.revHex(json.hash);
|
||||||
this.version = json.version;
|
this.version = json.version;
|
||||||
this.prevBlock = encoding.revHex(json.prevBlock);
|
this.prevBlock = util.revHex(json.prevBlock);
|
||||||
this.merkleRoot = encoding.revHex(json.merkleRoot);
|
this.merkleRoot = util.revHex(json.merkleRoot);
|
||||||
this.time = json.time;
|
this.time = json.time;
|
||||||
this.bits = json.bits;
|
this.bits = json.bits;
|
||||||
this.nonce = json.nonce;
|
this.nonce = json.nonce;
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const bio = require('bufio');
|
const bio = require('bufio');
|
||||||
const Logger = require('blgr');
|
const Logger = require('blgr');
|
||||||
|
const util = require('../utils/util');
|
||||||
const binary = require('../utils/binary');
|
const binary = require('../utils/binary');
|
||||||
const consensus = require('../protocol/consensus');
|
const consensus = require('../protocol/consensus');
|
||||||
const policy = require('../protocol/policy');
|
const policy = require('../protocol/policy');
|
||||||
@ -488,7 +489,7 @@ class PolicyEstimator {
|
|||||||
const item = this.map.get(hash);
|
const item = this.map.get(hash);
|
||||||
|
|
||||||
if (!item) {
|
if (!item) {
|
||||||
this.logger.spam('Mempool tx %s not found.', encoding.revHex(hash));
|
this.logger.spam('Mempool tx %s not found.', util.revHex(hash));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1661,7 +1661,7 @@ class Mempool extends EventEmitter {
|
|||||||
assert(hash);
|
assert(hash);
|
||||||
|
|
||||||
this.logger.debug('Removing orphan %s from mempool.',
|
this.logger.debug('Removing orphan %s from mempool.',
|
||||||
encoding.revHex(hash));
|
util.revHex(hash));
|
||||||
|
|
||||||
this.removeOrphan(hash);
|
this.removeOrphan(hash);
|
||||||
|
|
||||||
@ -2518,7 +2518,7 @@ class MempoolCache {
|
|||||||
|
|
||||||
this.logger.info(
|
this.logger.info(
|
||||||
'Mempool cache is empty. Writing tip %s.',
|
'Mempool cache is empty. Writing tip %s.',
|
||||||
encoding.revHex(tip));
|
util.revHex(tip));
|
||||||
|
|
||||||
await this.init(tip);
|
await this.init(tip);
|
||||||
}
|
}
|
||||||
@ -2538,7 +2538,7 @@ class MempoolCache {
|
|||||||
if (tip !== this.chain.tip.hash) {
|
if (tip !== this.chain.tip.hash) {
|
||||||
this.logger.warning(
|
this.logger.warning(
|
||||||
'Mempool tip not consistent with chain tip (%s != %s)!',
|
'Mempool tip not consistent with chain tip (%s != %s)!',
|
||||||
encoding.revHex(tip),
|
util.revHex(tip),
|
||||||
this.chain.tip.rhash());
|
this.chain.tip.rhash());
|
||||||
this.logger.warning('Invalidating mempool cache.');
|
this.logger.warning('Invalidating mempool cache.');
|
||||||
await this.wipe();
|
await this.wipe();
|
||||||
|
|||||||
@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const EventEmitter = require('events');
|
const EventEmitter = require('events');
|
||||||
const {encoding} = require('bufio');
|
|
||||||
const {Lock} = require('bmutex');
|
const {Lock} = require('bmutex');
|
||||||
const util = require('../utils/util');
|
const util = require('../utils/util');
|
||||||
const mine = require('./mine');
|
const mine = require('./mine');
|
||||||
@ -402,7 +401,7 @@ class CPUMiner extends EventEmitter {
|
|||||||
|
|
||||||
sendStatus(job, nonce) {
|
sendStatus(job, nonce) {
|
||||||
const attempt = job.attempt;
|
const attempt = job.attempt;
|
||||||
const tip = encoding.revHex(attempt.prevBlock);
|
const tip = util.revHex(attempt.prevBlock);
|
||||||
const hashes = job.getHashes(nonce);
|
const hashes = job.getHashes(nonce);
|
||||||
const hashrate = job.getRate(nonce);
|
const hashrate = job.getRate(nonce);
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,7 @@ const assert = require('assert');
|
|||||||
const bio = require('bufio');
|
const bio = require('bufio');
|
||||||
const hash256 = require('bcrypto/lib/hash256');
|
const hash256 = require('bcrypto/lib/hash256');
|
||||||
const merkle = require('bcrypto/lib/merkle');
|
const merkle = require('bcrypto/lib/merkle');
|
||||||
|
const util = require('../utils/util');
|
||||||
const Address = require('../primitives/address');
|
const Address = require('../primitives/address');
|
||||||
const TX = require('../primitives/tx');
|
const TX = require('../primitives/tx');
|
||||||
const Block = require('../primitives/block');
|
const Block = require('../primitives/block');
|
||||||
@ -677,7 +678,7 @@ class BlockProof {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rhash() {
|
rhash() {
|
||||||
return encoding.revHex(this.hash.toString('hex'));
|
return util.revHex(this.hash.toString('hex'));
|
||||||
}
|
}
|
||||||
|
|
||||||
verify(target) {
|
verify(target) {
|
||||||
|
|||||||
@ -1557,7 +1557,7 @@ class RejectPacket extends Packet {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
rhash() {
|
rhash() {
|
||||||
return this.hash ? encoding.revHex(this.hash) : null;
|
return this.hash ? util.revHex(this.hash) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1741,7 +1741,7 @@ class RejectPacket extends Packet {
|
|||||||
|
|
||||||
inspect() {
|
inspect() {
|
||||||
const code = RejectPacket.codesByVal[this.code] || this.code;
|
const code = RejectPacket.codesByVal[this.code] || this.code;
|
||||||
const hash = this.hash ? encoding.revHex(this.hash) : null;
|
const hash = this.hash ? util.revHex(this.hash) : null;
|
||||||
return '<Reject:'
|
return '<Reject:'
|
||||||
+ ` msg=${this.message}`
|
+ ` msg=${this.message}`
|
||||||
+ ` code=${code}`
|
+ ` code=${code}`
|
||||||
|
|||||||
@ -13,8 +13,8 @@ const {Lock} = require('bmutex');
|
|||||||
const {format} = require('util');
|
const {format} = require('util');
|
||||||
const tcp = require('btcp');
|
const tcp = require('btcp');
|
||||||
const Logger = require('blgr');
|
const Logger = require('blgr');
|
||||||
const {encoding} = require('bufio');
|
|
||||||
const {RollingFilter} = require('bfilter');
|
const {RollingFilter} = require('bfilter');
|
||||||
|
const util = require('../utils/util');
|
||||||
const Parser = require('./parser');
|
const Parser = require('./parser');
|
||||||
const Framer = require('./framer');
|
const Framer = require('./framer');
|
||||||
const packets = require('./packets');
|
const packets = require('./packets');
|
||||||
@ -1923,11 +1923,11 @@ class Peer extends EventEmitter {
|
|||||||
|
|
||||||
let hash = null;
|
let hash = null;
|
||||||
if (packet.locator.length > 0)
|
if (packet.locator.length > 0)
|
||||||
hash = encoding.revHex(packet.locator[0]);
|
hash = util.revHex(packet.locator[0]);
|
||||||
|
|
||||||
let end = null;
|
let end = null;
|
||||||
if (stop)
|
if (stop)
|
||||||
end = encoding.revHex(stop);
|
end = util.revHex(stop);
|
||||||
|
|
||||||
this.logger.debug(
|
this.logger.debug(
|
||||||
'Requesting headers packet from peer with getheaders (%s).',
|
'Requesting headers packet from peer with getheaders (%s).',
|
||||||
@ -1951,11 +1951,11 @@ class Peer extends EventEmitter {
|
|||||||
|
|
||||||
let hash = null;
|
let hash = null;
|
||||||
if (packet.locator.length > 0)
|
if (packet.locator.length > 0)
|
||||||
hash = encoding.revHex(packet.locator[0]);
|
hash = util.revHex(packet.locator[0]);
|
||||||
|
|
||||||
let end = null;
|
let end = null;
|
||||||
if (stop)
|
if (stop)
|
||||||
end = encoding.revHex(stop);
|
end = util.revHex(stop);
|
||||||
|
|
||||||
this.logger.debug(
|
this.logger.debug(
|
||||||
'Requesting inv packet from peer with getblocks (%s).',
|
'Requesting inv packet from peer with getblocks (%s).',
|
||||||
@ -2003,7 +2003,7 @@ class Peer extends EventEmitter {
|
|||||||
|
|
||||||
if (msg) {
|
if (msg) {
|
||||||
this.logger.debug('Rejecting %s %s (%s): code=%s reason=%s.',
|
this.logger.debug('Rejecting %s %s (%s): code=%s reason=%s.',
|
||||||
msg, encoding.revHex(hash), this.hostname(), code, reason);
|
msg, util.revHex(hash), this.hostname(), code, reason);
|
||||||
} else {
|
} else {
|
||||||
this.logger.debug('Rejecting packet from %s: code=%s reason=%s.',
|
this.logger.debug('Rejecting packet from %s: code=%s reason=%s.',
|
||||||
this.hostname(), code, reason);
|
this.hostname(), code, reason);
|
||||||
|
|||||||
@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const EventEmitter = require('events');
|
const EventEmitter = require('events');
|
||||||
const {encoding} = require('bufio');
|
|
||||||
const {Lock} = require('bmutex');
|
const {Lock} = require('bmutex');
|
||||||
const IP = require('binet');
|
const IP = require('binet');
|
||||||
const dns = require('bdns');
|
const dns = require('bdns');
|
||||||
@ -227,7 +226,7 @@ class Pool extends EventEmitter {
|
|||||||
this.headerChain.push(new HeaderEntry(tip.hash, tip.height));
|
this.headerChain.push(new HeaderEntry(tip.hash, tip.height));
|
||||||
this.logger.info(
|
this.logger.info(
|
||||||
'Initialized header chain to height %d (checkpoint=%s).',
|
'Initialized header chain to height %d (checkpoint=%s).',
|
||||||
tip.height, encoding.revHex(this.headerTip.hash));
|
tip.height, util.revHex(this.headerTip.hash));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2285,8 +2284,8 @@ class Pool extends EventEmitter {
|
|||||||
if (hash !== node.hash) {
|
if (hash !== node.hash) {
|
||||||
this.logger.warning(
|
this.logger.warning(
|
||||||
'Header hash mismatch %s != %s (%s).',
|
'Header hash mismatch %s != %s (%s).',
|
||||||
encoding.revHex(hash),
|
util.revHex(hash),
|
||||||
encoding.revHex(node.hash),
|
util.revHex(node.hash),
|
||||||
peer.hostname());
|
peer.hostname());
|
||||||
|
|
||||||
peer.destroy();
|
peer.destroy();
|
||||||
@ -2298,7 +2297,7 @@ class Pool extends EventEmitter {
|
|||||||
if (node.height === this.headerTip.height) {
|
if (node.height === this.headerTip.height) {
|
||||||
this.logger.info(
|
this.logger.info(
|
||||||
'Received checkpoint %s (%d).',
|
'Received checkpoint %s (%d).',
|
||||||
encoding.revHex(node.hash), node.height);
|
util.revHex(node.hash), node.height);
|
||||||
|
|
||||||
this.headerTip = this.getNextTip(node.height);
|
this.headerTip = this.getNextTip(node.height);
|
||||||
|
|
||||||
@ -2355,7 +2354,7 @@ class Pool extends EventEmitter {
|
|||||||
if (!peer) {
|
if (!peer) {
|
||||||
this.logger.warning(
|
this.logger.warning(
|
||||||
'Could not find offending peer for orphan: %s (%d).',
|
'Could not find offending peer for orphan: %s (%d).',
|
||||||
encoding.revHex(err.hash), id);
|
util.revHex(err.hash), id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3443,7 +3442,7 @@ class Pool extends EventEmitter {
|
|||||||
|
|
||||||
// If we recently rejected this item. Ignore.
|
// If we recently rejected this item. Ignore.
|
||||||
if (this.mempool.hasReject(hash)) {
|
if (this.mempool.hasReject(hash)) {
|
||||||
this.logger.spam('Saw known reject of %s.', encoding.revHex(hash));
|
this.logger.spam('Saw known reject of %s.', util.revHex(hash));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4336,7 +4335,7 @@ class BroadcastItem extends EventEmitter {
|
|||||||
|
|
||||||
inspect() {
|
inspect() {
|
||||||
const type = this.type === invTypes.TX ? 'tx' : 'block';
|
const type = this.type === invTypes.TX ? 'tx' : 'block';
|
||||||
const hash = encoding.revHex(this.hash);
|
const hash = util.revHex(this.hash);
|
||||||
return `<BroadcastItem: type=${type} hash=${hash}>`;
|
return `<BroadcastItem: type=${type} hash=${hash}>`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,6 @@ const path = require('path');
|
|||||||
const {Server} = require('bweb');
|
const {Server} = require('bweb');
|
||||||
const Validator = require('bval');
|
const Validator = require('bval');
|
||||||
const {base58} = require('bstring');
|
const {base58} = require('bstring');
|
||||||
const {encoding} = require('bufio');
|
|
||||||
const {BloomFilter} = require('bfilter');
|
const {BloomFilter} = require('bfilter');
|
||||||
const sha256 = require('bcrypto/lib/sha256');
|
const sha256 = require('bcrypto/lib/sha256');
|
||||||
const random = require('bcrypto/lib/random');
|
const random = require('bcrypto/lib/random');
|
||||||
@ -296,7 +295,7 @@ class HTTP extends Server {
|
|||||||
const result = [];
|
const result = [];
|
||||||
|
|
||||||
for (const hash of hashes)
|
for (const hash of hashes)
|
||||||
result.push(encoding.revHex(hash));
|
result.push(util.revHex(hash));
|
||||||
|
|
||||||
res.json(200, result);
|
res.json(200, result);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -464,7 +464,7 @@ class RPC extends RPCBase {
|
|||||||
offset = 0;
|
offset = 0;
|
||||||
|
|
||||||
for (const hash in peer.blockMap.keys()) {
|
for (const hash in peer.blockMap.keys()) {
|
||||||
const str = encoding.revHex(hash);
|
const str = util.revHex(hash);
|
||||||
hashes.push(str);
|
hashes.push(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -490,7 +490,7 @@ class RPC extends RPCBase {
|
|||||||
subver: peer.agent,
|
subver: peer.agent,
|
||||||
inbound: !peer.outbound,
|
inbound: !peer.outbound,
|
||||||
startingheight: peer.height,
|
startingheight: peer.height,
|
||||||
besthash: peer.bestHash ? encoding.revHex(peer.bestHash) : null,
|
besthash: peer.bestHash ? util.revHex(peer.bestHash) : null,
|
||||||
bestheight: peer.bestHeight,
|
bestheight: peer.bestHeight,
|
||||||
banscore: peer.banScore,
|
banscore: peer.banScore,
|
||||||
inflight: hashes,
|
inflight: hashes,
|
||||||
@ -694,7 +694,7 @@ class RPC extends RPCBase {
|
|||||||
if (!hash)
|
if (!hash)
|
||||||
throw new RPCError(errs.MISC_ERROR, 'Not found.');
|
throw new RPCError(errs.MISC_ERROR, 'Not found.');
|
||||||
|
|
||||||
return encoding.revHex(hash);
|
return util.revHex(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getBlockHeader(args, help) {
|
async getBlockHeader(args, help) {
|
||||||
@ -878,7 +878,7 @@ class RPC extends RPCBase {
|
|||||||
|
|
||||||
const hashes = this.mempool.getSnapshot();
|
const hashes = this.mempool.getSnapshot();
|
||||||
|
|
||||||
return hashes.map(encoding.revHex);
|
return hashes.map(util.revHex);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getTXOut(args, help) {
|
async getTXOut(args, help) {
|
||||||
@ -1017,7 +1017,7 @@ class RPC extends RPCBase {
|
|||||||
const out = [];
|
const out = [];
|
||||||
|
|
||||||
for (const hash of tree.matches)
|
for (const hash of tree.matches)
|
||||||
out.push(encoding.revHex(hash.toString('hex')));
|
out.push(util.revHex(hash.toString('hex')));
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@ -1461,8 +1461,8 @@ class RPC extends RPCBase {
|
|||||||
vbavailable: vbavailable,
|
vbavailable: vbavailable,
|
||||||
vbrequired: 0,
|
vbrequired: 0,
|
||||||
height: attempt.height,
|
height: attempt.height,
|
||||||
previousblockhash: encoding.revHex(attempt.prevBlock),
|
previousblockhash: util.revHex(attempt.prevBlock),
|
||||||
target: encoding.revHex(attempt.target.toString('hex')),
|
target: util.revHex(attempt.target.toString('hex')),
|
||||||
bits: hex32(attempt.bits),
|
bits: hex32(attempt.bits),
|
||||||
noncerange: '00000000ffffffff',
|
noncerange: '00000000ffffffff',
|
||||||
curtime: attempt.time,
|
curtime: attempt.time,
|
||||||
@ -2286,7 +2286,7 @@ class RPC extends RPCBase {
|
|||||||
if ((lastTX >>> 0) !== lastTX)
|
if ((lastTX >>> 0) !== lastTX)
|
||||||
throw new RPCError(errs.INVALID_PARAMETER, 'Invalid longpoll ID.');
|
throw new RPCError(errs.INVALID_PARAMETER, 'Invalid longpoll ID.');
|
||||||
|
|
||||||
const hash = encoding.revHex(watched);
|
const hash = util.revHex(watched);
|
||||||
|
|
||||||
if (this.chain.tip.hash !== hash)
|
if (this.chain.tip.hash !== hash)
|
||||||
return;
|
return;
|
||||||
@ -2699,16 +2699,16 @@ class RPC extends RPCBase {
|
|||||||
height: entry.height,
|
height: entry.height,
|
||||||
version: entry.version,
|
version: entry.version,
|
||||||
versionHex: hex32(entry.version),
|
versionHex: hex32(entry.version),
|
||||||
merkleroot: encoding.revHex(entry.merkleRoot),
|
merkleroot: util.revHex(entry.merkleRoot),
|
||||||
time: entry.time,
|
time: entry.time,
|
||||||
mediantime: mtp,
|
mediantime: mtp,
|
||||||
bits: entry.bits,
|
bits: entry.bits,
|
||||||
difficulty: toDifficulty(entry.bits),
|
difficulty: toDifficulty(entry.bits),
|
||||||
chainwork: entry.chainwork.toString('hex', 64),
|
chainwork: entry.chainwork.toString('hex', 64),
|
||||||
previousblockhash: entry.prevBlock !== encoding.NULL_HASH
|
previousblockhash: entry.prevBlock !== encoding.NULL_HASH
|
||||||
? encoding.revHex(entry.prevBlock)
|
? util.revHex(entry.prevBlock)
|
||||||
: null,
|
: null,
|
||||||
nextblockhash: next ? encoding.revHex(next) : null
|
nextblockhash: next ? util.revHex(next) : null
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2735,7 +2735,7 @@ class RPC extends RPCBase {
|
|||||||
height: entry.height,
|
height: entry.height,
|
||||||
version: entry.version,
|
version: entry.version,
|
||||||
versionHex: hex32(entry.version),
|
versionHex: hex32(entry.version),
|
||||||
merkleroot: encoding.revHex(entry.merkleRoot),
|
merkleroot: util.revHex(entry.merkleRoot),
|
||||||
coinbase: block.txs[0].inputs[0].script.toJSON(),
|
coinbase: block.txs[0].inputs[0].script.toJSON(),
|
||||||
tx: txs,
|
tx: txs,
|
||||||
time: entry.time,
|
time: entry.time,
|
||||||
@ -2744,9 +2744,9 @@ class RPC extends RPCBase {
|
|||||||
difficulty: toDifficulty(entry.bits),
|
difficulty: toDifficulty(entry.bits),
|
||||||
chainwork: entry.chainwork.toString('hex', 64),
|
chainwork: entry.chainwork.toString('hex', 64),
|
||||||
previousblockhash: entry.prevBlock !== encoding.NULL_HASH
|
previousblockhash: entry.prevBlock !== encoding.NULL_HASH
|
||||||
? encoding.revHex(entry.prevBlock)
|
? util.revHex(entry.prevBlock)
|
||||||
: null,
|
: null,
|
||||||
nextblockhash: next ? encoding.revHex(next) : null
|
nextblockhash: next ? util.revHex(next) : null
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2765,7 +2765,7 @@ class RPC extends RPCBase {
|
|||||||
ancestorcount: this.mempool.countAncestors(entry),
|
ancestorcount: this.mempool.countAncestors(entry),
|
||||||
ancestorsize: 0,
|
ancestorsize: 0,
|
||||||
ancestorfees: 0,
|
ancestorfees: 0,
|
||||||
depends: this.mempool.getDepends(entry.tx).map(encoding.revHex)
|
depends: this.mempool.getDepends(entry.tx).map(util.revHex)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const hash256 = require('bcrypto/lib/hash256');
|
const hash256 = require('bcrypto/lib/hash256');
|
||||||
const bio = require('bufio');
|
const bio = require('bufio');
|
||||||
|
const util = require('../utils/util');
|
||||||
const InvItem = require('./invitem');
|
const InvItem = require('./invitem');
|
||||||
const consensus = require('../protocol/consensus');
|
const consensus = require('../protocol/consensus');
|
||||||
const {encoding} = bio;
|
const {encoding} = bio;
|
||||||
@ -93,8 +94,8 @@ class AbstractBlock {
|
|||||||
assert((json.nonce >>> 0) === json.nonce);
|
assert((json.nonce >>> 0) === json.nonce);
|
||||||
|
|
||||||
this.version = json.version;
|
this.version = json.version;
|
||||||
this.prevBlock = encoding.revHex(json.prevBlock);
|
this.prevBlock = util.revHex(json.prevBlock);
|
||||||
this.merkleRoot = encoding.revHex(json.merkleRoot);
|
this.merkleRoot = util.revHex(json.merkleRoot);
|
||||||
this.time = json.time;
|
this.time = json.time;
|
||||||
this.bits = json.bits;
|
this.bits = json.bits;
|
||||||
this.nonce = json.nonce;
|
this.nonce = json.nonce;
|
||||||
@ -244,7 +245,7 @@ class AbstractBlock {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
rhash() {
|
rhash() {
|
||||||
return encoding.revHex(this.hash('hex'));
|
return util.revHex(this.hash('hex'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -540,10 +540,10 @@ class Block extends AbstractBlock {
|
|||||||
virtualSize: this.getVirtualSize(),
|
virtualSize: this.getVirtualSize(),
|
||||||
date: util.date(this.time),
|
date: util.date(this.time),
|
||||||
version: this.version.toString(16),
|
version: this.version.toString(16),
|
||||||
prevBlock: encoding.revHex(this.prevBlock),
|
prevBlock: util.revHex(this.prevBlock),
|
||||||
merkleRoot: encoding.revHex(this.merkleRoot),
|
merkleRoot: util.revHex(this.merkleRoot),
|
||||||
commitmentHash: commitmentHash
|
commitmentHash: commitmentHash
|
||||||
? encoding.revHex(commitmentHash)
|
? util.revHex(commitmentHash)
|
||||||
: null,
|
: null,
|
||||||
time: this.time,
|
time: this.time,
|
||||||
bits: this.bits,
|
bits: this.bits,
|
||||||
@ -583,8 +583,8 @@ class Block extends AbstractBlock {
|
|||||||
height: height,
|
height: height,
|
||||||
depth: depth,
|
depth: depth,
|
||||||
version: this.version,
|
version: this.version,
|
||||||
prevBlock: encoding.revHex(this.prevBlock),
|
prevBlock: util.revHex(this.prevBlock),
|
||||||
merkleRoot: encoding.revHex(this.merkleRoot),
|
merkleRoot: util.revHex(this.merkleRoot),
|
||||||
time: this.time,
|
time: this.time,
|
||||||
bits: this.bits,
|
bits: this.bits,
|
||||||
nonce: this.nonce,
|
nonce: this.nonce,
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const bio = require('bufio');
|
const bio = require('bufio');
|
||||||
|
const util = require('../utils/util');
|
||||||
const Amount = require('../btc/amount');
|
const Amount = require('../btc/amount');
|
||||||
const Output = require('./output');
|
const Output = require('./output');
|
||||||
const Network = require('../protocol/network');
|
const Network = require('../protocol/network');
|
||||||
@ -184,7 +185,7 @@ class Coin extends Output {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
rhash() {
|
rhash() {
|
||||||
return encoding.revHex(this.hash);
|
return util.revHex(this.hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -209,7 +210,7 @@ class Coin extends Output {
|
|||||||
value: Amount.btc(this.value),
|
value: Amount.btc(this.value),
|
||||||
script: this.script,
|
script: this.script,
|
||||||
coinbase: this.coinbase,
|
coinbase: this.coinbase,
|
||||||
hash: this.hash ? encoding.revHex(this.hash) : null,
|
hash: this.hash ? util.revHex(this.hash) : null,
|
||||||
index: this.index,
|
index: this.index,
|
||||||
address: this.getAddress()
|
address: this.getAddress()
|
||||||
};
|
};
|
||||||
@ -280,7 +281,7 @@ class Coin extends Output {
|
|||||||
assert(typeof json.hash === 'string', 'Hash must be a string.');
|
assert(typeof json.hash === 'string', 'Hash must be a string.');
|
||||||
assert(json.hash.length === 64, 'Hash must be a string.');
|
assert(json.hash.length === 64, 'Hash must be a string.');
|
||||||
assert((json.index >>> 0) === json.index, 'Index must be a uint32.');
|
assert((json.index >>> 0) === json.index, 'Index must be a uint32.');
|
||||||
this.hash = encoding.revHex(json.hash);
|
this.hash = util.revHex(json.hash);
|
||||||
this.index = json.index;
|
this.index = json.index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,6 @@
|
|||||||
const bio = require('bufio');
|
const bio = require('bufio');
|
||||||
const util = require('../utils/util');
|
const util = require('../utils/util');
|
||||||
const AbstractBlock = require('./abstractblock');
|
const AbstractBlock = require('./abstractblock');
|
||||||
const {encoding} = bio;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Headers
|
* Headers
|
||||||
@ -199,8 +198,8 @@ class Headers extends AbstractBlock {
|
|||||||
hash: this.rhash(),
|
hash: this.rhash(),
|
||||||
height: height,
|
height: height,
|
||||||
version: this.version,
|
version: this.version,
|
||||||
prevBlock: encoding.revHex(this.prevBlock),
|
prevBlock: util.revHex(this.prevBlock),
|
||||||
merkleRoot: encoding.revHex(this.merkleRoot),
|
merkleRoot: util.revHex(this.merkleRoot),
|
||||||
time: this.time,
|
time: this.time,
|
||||||
bits: this.bits,
|
bits: this.bits,
|
||||||
nonce: this.nonce
|
nonce: this.nonce
|
||||||
@ -252,8 +251,8 @@ class Headers extends AbstractBlock {
|
|||||||
height: height != null ? height : -1,
|
height: height != null ? height : -1,
|
||||||
date: util.date(this.time),
|
date: util.date(this.time),
|
||||||
version: this.version.toString(16),
|
version: this.version.toString(16),
|
||||||
prevBlock: encoding.revHex(this.prevBlock),
|
prevBlock: util.revHex(this.prevBlock),
|
||||||
merkleRoot: encoding.revHex(this.merkleRoot),
|
merkleRoot: util.revHex(this.merkleRoot),
|
||||||
time: this.time,
|
time: this.time,
|
||||||
bits: this.bits,
|
bits: this.bits,
|
||||||
nonce: this.nonce
|
nonce: this.nonce
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const bio = require('bufio');
|
const bio = require('bufio');
|
||||||
const {encoding} = bio;
|
const util = require('../utils/util');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inv Item
|
* Inv Item
|
||||||
@ -152,7 +152,7 @@ class InvItem {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
rhash() {
|
rhash() {
|
||||||
return encoding.revHex(this.hash);
|
return util.revHex(this.hash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -306,8 +306,8 @@ class MerkleBlock extends AbstractBlock {
|
|||||||
height: height != null ? height : -1,
|
height: height != null ? height : -1,
|
||||||
date: util.date(this.time),
|
date: util.date(this.time),
|
||||||
version: this.version.toString(16),
|
version: this.version.toString(16),
|
||||||
prevBlock: encoding.revHex(this.prevBlock),
|
prevBlock: util.revHex(this.prevBlock),
|
||||||
merkleRoot: encoding.revHex(this.merkleRoot),
|
merkleRoot: util.revHex(this.merkleRoot),
|
||||||
time: this.time,
|
time: this.time,
|
||||||
bits: this.bits,
|
bits: this.bits,
|
||||||
nonce: this.nonce,
|
nonce: this.nonce,
|
||||||
@ -448,14 +448,14 @@ class MerkleBlock extends AbstractBlock {
|
|||||||
hash: this.rhash(),
|
hash: this.rhash(),
|
||||||
height: height,
|
height: height,
|
||||||
version: this.version,
|
version: this.version,
|
||||||
prevBlock: encoding.revHex(this.prevBlock),
|
prevBlock: util.revHex(this.prevBlock),
|
||||||
merkleRoot: encoding.revHex(this.merkleRoot),
|
merkleRoot: util.revHex(this.merkleRoot),
|
||||||
time: this.time,
|
time: this.time,
|
||||||
bits: this.bits,
|
bits: this.bits,
|
||||||
nonce: this.nonce,
|
nonce: this.nonce,
|
||||||
totalTX: this.totalTX,
|
totalTX: this.totalTX,
|
||||||
hashes: this.hashes.map((hash) => {
|
hashes: this.hashes.map((hash) => {
|
||||||
return encoding.revHex(hash.toString('hex'));
|
return util.revHex(hash.toString('hex'));
|
||||||
}),
|
}),
|
||||||
flags: this.flags.toString('hex')
|
flags: this.flags.toString('hex')
|
||||||
};
|
};
|
||||||
@ -476,7 +476,7 @@ class MerkleBlock extends AbstractBlock {
|
|||||||
this.parseJSON(json);
|
this.parseJSON(json);
|
||||||
|
|
||||||
for (let hash of json.hashes) {
|
for (let hash of json.hashes) {
|
||||||
hash = encoding.revHex(hash);
|
hash = util.revHex(hash);
|
||||||
this.hashes.push(Buffer.from(hash, 'hex'));
|
this.hashes.push(Buffer.from(hash, 'hex'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const bio = require('bufio');
|
const bio = require('bufio');
|
||||||
|
const util = require('../utils/util');
|
||||||
const {encoding} = bio;
|
const {encoding} = bio;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -120,7 +121,7 @@ class Outpoint {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
rhash() {
|
rhash() {
|
||||||
return encoding.revHex(this.hash);
|
return util.revHex(this.hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -247,7 +248,7 @@ class Outpoint {
|
|||||||
assert(json, 'Outpoint data is required.');
|
assert(json, 'Outpoint data is required.');
|
||||||
assert(typeof json.hash === 'string', 'Hash must be a string.');
|
assert(typeof json.hash === 'string', 'Hash must be a string.');
|
||||||
assert((json.index >>> 0) === json.index, 'Index must be a uint32.');
|
assert((json.index >>> 0) === json.index, 'Index must be a uint32.');
|
||||||
this.hash = encoding.revHex(json.hash);
|
this.hash = util.revHex(json.hash);
|
||||||
this.index = json.index;
|
this.index = json.index;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -262,7 +263,7 @@ class Outpoint {
|
|||||||
|
|
||||||
toJSON() {
|
toJSON() {
|
||||||
return {
|
return {
|
||||||
hash: encoding.revHex(this.hash),
|
hash: util.revHex(this.hash),
|
||||||
index: this.index
|
index: this.index
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2012,7 +2012,7 @@ class TX {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
rhash() {
|
rhash() {
|
||||||
return encoding.revHex(this.hash('hex'));
|
return util.revHex(this.hash('hex'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2021,7 +2021,7 @@ class TX {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
rwhash() {
|
rwhash() {
|
||||||
return encoding.revHex(this.witnessHash('hex'));
|
return util.revHex(this.witnessHash('hex'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2089,7 +2089,7 @@ class TX {
|
|||||||
|
|
||||||
if (entry) {
|
if (entry) {
|
||||||
height = entry.height;
|
height = entry.height;
|
||||||
block = encoding.revHex(entry.hash);
|
block = util.revHex(entry.hash);
|
||||||
time = entry.time;
|
time = entry.time;
|
||||||
date = util.date(time);
|
date = util.date(time);
|
||||||
}
|
}
|
||||||
@ -2157,7 +2157,7 @@ class TX {
|
|||||||
|
|
||||||
if (entry) {
|
if (entry) {
|
||||||
height = entry.height;
|
height = entry.height;
|
||||||
block = encoding.revHex(entry.hash);
|
block = util.revHex(entry.hash);
|
||||||
time = entry.time;
|
time = entry.time;
|
||||||
date = util.date(time);
|
date = util.date(time);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,6 @@ const assert = require('assert');
|
|||||||
const bio = require('bufio');
|
const bio = require('bufio');
|
||||||
const util = require('../utils/util');
|
const util = require('../utils/util');
|
||||||
const TX = require('./tx');
|
const TX = require('./tx');
|
||||||
const {encoding} = bio;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TXMeta
|
* TXMeta
|
||||||
@ -132,7 +131,7 @@ class TXMeta {
|
|||||||
const data = this.tx.format(view, null, this.index);
|
const data = this.tx.format(view, null, this.index);
|
||||||
data.mtime = this.mtime;
|
data.mtime = this.mtime;
|
||||||
data.height = this.height;
|
data.height = this.height;
|
||||||
data.block = this.block ? encoding.revHex(this.block) : null;
|
data.block = this.block ? util.revHex(this.block) : null;
|
||||||
data.time = this.time;
|
data.time = this.time;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@ -158,7 +157,7 @@ class TXMeta {
|
|||||||
const json = this.tx.getJSON(network, view, null, this.index);
|
const json = this.tx.getJSON(network, view, null, this.index);
|
||||||
json.mtime = this.mtime;
|
json.mtime = this.mtime;
|
||||||
json.height = this.height;
|
json.height = this.height;
|
||||||
json.block = this.block ? encoding.revHex(this.block) : null;
|
json.block = this.block ? util.revHex(this.block) : null;
|
||||||
json.time = this.time;
|
json.time = this.time;
|
||||||
json.confirmations = 0;
|
json.confirmations = 0;
|
||||||
|
|
||||||
@ -185,7 +184,7 @@ class TXMeta {
|
|||||||
|
|
||||||
this.mtime = json.mtime;
|
this.mtime = json.mtime;
|
||||||
this.height = json.height;
|
this.height = json.height;
|
||||||
this.block = encoding.revHex(json.block);
|
this.block = util.revHex(json.block);
|
||||||
this.index = json.index;
|
this.index = json.index;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@ -14,7 +14,6 @@ const sha1 = require('bcrypto/lib/sha1');
|
|||||||
const sha256 = require('bcrypto/lib/sha256');
|
const sha256 = require('bcrypto/lib/sha256');
|
||||||
const hash160 = require('bcrypto/lib/hash160');
|
const hash160 = require('bcrypto/lib/hash160');
|
||||||
const hash256 = require('bcrypto/lib/hash256');
|
const hash256 = require('bcrypto/lib/hash256');
|
||||||
const merkle = require('bcrypto/lib/merkle');
|
|
||||||
const secp256k1 = require('bcrypto/lib/secp256k1');
|
const secp256k1 = require('bcrypto/lib/secp256k1');
|
||||||
const consensus = require('../protocol/consensus');
|
const consensus = require('../protocol/consensus');
|
||||||
const policy = require('../protocol/policy');
|
const policy = require('../protocol/policy');
|
||||||
|
|||||||
@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @exports utils/util
|
* @exports utils/util
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -8,8 +8,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const {encoding} = require('bufio');
|
|
||||||
const {NodeClient} = require('bclient');
|
const {NodeClient} = require('bclient');
|
||||||
|
const util = require('../utils/util');
|
||||||
const TX = require('../primitives/tx');
|
const TX = require('../primitives/tx');
|
||||||
const hash256 = require('bcrypto/lib/hash256');
|
const hash256 = require('bcrypto/lib/hash256');
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ class WalletClient extends NodeClient {
|
|||||||
|
|
||||||
async getEntry(block) {
|
async getEntry(block) {
|
||||||
if (typeof block === 'string')
|
if (typeof block === 'string')
|
||||||
block = encoding.revHex(block);
|
block = util.revHex(block);
|
||||||
|
|
||||||
return parseEntry(await super.getEntry(block));
|
return parseEntry(await super.getEntry(block));
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ class WalletClient extends NodeClient {
|
|||||||
|
|
||||||
async rescan(start) {
|
async rescan(start) {
|
||||||
if (typeof start === 'string')
|
if (typeof start === 'string')
|
||||||
start = encoding.revHex(start);
|
start = util.revHex(start);
|
||||||
|
|
||||||
return super.rescan(start);
|
return super.rescan(start);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -149,7 +149,7 @@ class BlockMeta {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
fromJSON(json) {
|
fromJSON(json) {
|
||||||
this.hash = encoding.revHex(json.hash);
|
this.hash = util.revHex(json.hash);
|
||||||
this.height = json.height;
|
this.height = json.height;
|
||||||
this.time = json.time;
|
this.time = json.time;
|
||||||
return this;
|
return this;
|
||||||
@ -220,7 +220,7 @@ class BlockMeta {
|
|||||||
|
|
||||||
toJSON() {
|
toJSON() {
|
||||||
return {
|
return {
|
||||||
hash: encoding.revHex(this.hash),
|
hash: util.revHex(this.hash),
|
||||||
height: this.height,
|
height: this.height,
|
||||||
time: this.time
|
time: this.time
|
||||||
};
|
};
|
||||||
|
|||||||
@ -316,7 +316,7 @@ class RPC extends RPCBase {
|
|||||||
format('# Wallet Dump created by Bcoin %s', pkg.version),
|
format('# Wallet Dump created by Bcoin %s', pkg.version),
|
||||||
format('# * Created on %s', time),
|
format('# * Created on %s', time),
|
||||||
format('# * Best block at time of backup was %d (%s).',
|
format('# * Best block at time of backup was %d (%s).',
|
||||||
tip.height, encoding.revHex(tip.hash)),
|
tip.height, util.revHex(tip.hash)),
|
||||||
format('# * File: %s', file),
|
format('# * File: %s', file),
|
||||||
''
|
''
|
||||||
];
|
];
|
||||||
@ -632,10 +632,10 @@ class RPC extends RPCBase {
|
|||||||
return {
|
return {
|
||||||
amount: Amount.btc(receive ? received : -sent, true),
|
amount: Amount.btc(receive ? received : -sent, true),
|
||||||
confirmations: details.confirmations,
|
confirmations: details.confirmations,
|
||||||
blockhash: details.block ? encoding.revHex(details.block) : null,
|
blockhash: details.block ? util.revHex(details.block) : null,
|
||||||
blockindex: details.index,
|
blockindex: details.index,
|
||||||
blocktime: details.time,
|
blocktime: details.time,
|
||||||
txid: encoding.revHex(details.hash),
|
txid: util.revHex(details.hash),
|
||||||
walletconflicts: [],
|
walletconflicts: [],
|
||||||
time: details.mtime,
|
time: details.mtime,
|
||||||
timereceived: details.mtime,
|
timereceived: details.mtime,
|
||||||
@ -1063,7 +1063,7 @@ class RPC extends RPCBase {
|
|||||||
return {
|
return {
|
||||||
transactions: out,
|
transactions: out,
|
||||||
lastblock: highest && highest.block
|
lastblock: highest && highest.block
|
||||||
? encoding.revHex(highest.block)
|
? util.revHex(highest.block)
|
||||||
: encoding.NULL_HASH
|
: encoding.NULL_HASH
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -1129,10 +1129,10 @@ class RPC extends RPCBase {
|
|||||||
label: member.path ? member.path.name : undefined,
|
label: member.path ? member.path.name : undefined,
|
||||||
vout: index,
|
vout: index,
|
||||||
confirmations: details.getDepth(),
|
confirmations: details.getDepth(),
|
||||||
blockhash: details.block ? encoding.revHex(details.block) : null,
|
blockhash: details.block ? util.revHex(details.block) : null,
|
||||||
blockindex: details.index,
|
blockindex: details.index,
|
||||||
blocktime: details.time,
|
blocktime: details.time,
|
||||||
txid: encoding.revHex(details.hash),
|
txid: util.revHex(details.hash),
|
||||||
walletconflicts: [],
|
walletconflicts: [],
|
||||||
time: details.mtime,
|
time: details.mtime,
|
||||||
timereceived: details.mtime,
|
timereceived: details.mtime,
|
||||||
|
|||||||
@ -2525,9 +2525,9 @@ class Details {
|
|||||||
const rate = this.getRate(fee);
|
const rate = this.getRate(fee);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
hash: encoding.revHex(this.hash),
|
hash: util.revHex(this.hash),
|
||||||
height: this.height,
|
height: this.height,
|
||||||
block: this.block ? encoding.revHex(this.block) : null,
|
block: this.block ? util.revHex(this.block) : null,
|
||||||
time: this.time,
|
time: this.time,
|
||||||
mtime: this.mtime,
|
mtime: this.mtime,
|
||||||
date: util.date(this.time),
|
date: util.date(this.time),
|
||||||
@ -2723,10 +2723,10 @@ class BlockRecord {
|
|||||||
|
|
||||||
toJSON() {
|
toJSON() {
|
||||||
return {
|
return {
|
||||||
hash: encoding.revHex(this.hash),
|
hash: util.revHex(this.hash),
|
||||||
height: this.height,
|
height: this.height,
|
||||||
time: this.time,
|
time: this.time,
|
||||||
hashes: this.toArray().map(encoding.revHex)
|
hashes: this.toArray().map(util.revHex)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,6 +17,7 @@ const BDB = require('bdb');
|
|||||||
const Logger = require('blgr');
|
const Logger = require('blgr');
|
||||||
const ccmp = require('bcrypto/lib/ccmp');
|
const ccmp = require('bcrypto/lib/ccmp');
|
||||||
const aes = require('bcrypto/lib/aes');
|
const aes = require('bcrypto/lib/aes');
|
||||||
|
const util = require('../utils/util');
|
||||||
const Network = require('../protocol/network');
|
const Network = require('../protocol/network');
|
||||||
const Path = require('./path');
|
const Path = require('./path');
|
||||||
const common = require('./common');
|
const common = require('./common');
|
||||||
@ -1748,7 +1749,7 @@ class WalletDB extends EventEmitter {
|
|||||||
|
|
||||||
if (total > 0) {
|
if (total > 0) {
|
||||||
this.logger.info('Connected WalletDB block %s (tx=%d).',
|
this.logger.info('Connected WalletDB block %s (tx=%d).',
|
||||||
encoding.revHex(tip.hash), total);
|
util.revHex(tip.hash), total);
|
||||||
}
|
}
|
||||||
|
|
||||||
return total;
|
return total;
|
||||||
@ -1816,7 +1817,7 @@ class WalletDB extends EventEmitter {
|
|||||||
await this.setTip(prev);
|
await this.setTip(prev);
|
||||||
|
|
||||||
this.logger.warning('Disconnected wallet block %s (tx=%d).',
|
this.logger.warning('Disconnected wallet block %s (tx=%d).',
|
||||||
encoding.revHex(tip.hash), total);
|
util.revHex(tip.hash), total);
|
||||||
|
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,6 +20,7 @@ const BDB = require('bdb');
|
|||||||
const hash256 = require('bcrypto/lib/hash256');
|
const hash256 = require('bcrypto/lib/hash256');
|
||||||
const BN = require('bcrypto/lib/bn');
|
const BN = require('bcrypto/lib/bn');
|
||||||
const bio = require('bufio');
|
const bio = require('bufio');
|
||||||
|
const util = require('../lib/utils/util');
|
||||||
const OldCoins = require('./coins/coins');
|
const OldCoins = require('./coins/coins');
|
||||||
const OldUndoCoins = require('./coins/undocoins');
|
const OldUndoCoins = require('./coins/undocoins');
|
||||||
const CoinEntry = require('../lib/coins/coinentry');
|
const CoinEntry = require('../lib/coins/coinentry');
|
||||||
@ -131,7 +132,7 @@ async function reserializeUndo(hash) {
|
|||||||
tip = await getEntry(hash);
|
tip = await getEntry(hash);
|
||||||
|
|
||||||
console.log('Reserializing undo coins from tip %s.',
|
console.log('Reserializing undo coins from tip %s.',
|
||||||
encoding.revHex(tip.hash));
|
util.revHex(tip.hash));
|
||||||
|
|
||||||
let batch = db.batch();
|
let batch = db.batch();
|
||||||
let pruning = false;
|
let pruning = false;
|
||||||
@ -142,7 +143,7 @@ async function reserializeUndo(hash) {
|
|||||||
if (shouldPrune) {
|
if (shouldPrune) {
|
||||||
if (tip.height < height - 288) {
|
if (tip.height < height - 288) {
|
||||||
console.log('Pruning block %s (%d).',
|
console.log('Pruning block %s (%d).',
|
||||||
encoding.revHex(tip.hash), tip.height);
|
util.revHex(tip.hash), tip.height);
|
||||||
|
|
||||||
batch.del(pair('u', tip.hash));
|
batch.del(pair('u', tip.hash));
|
||||||
batch.del(pair('b', tip.hash));
|
batch.del(pair('b', tip.hash));
|
||||||
@ -185,7 +186,7 @@ async function reserializeUndo(hash) {
|
|||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
'Reserializing coins for block %s (%d).',
|
'Reserializing coins for block %s (%d).',
|
||||||
encoding.revHex(tip.hash), tip.height);
|
util.revHex(tip.hash), tip.height);
|
||||||
|
|
||||||
for (let i = block.txs.length - 1; i >= 1; i--) {
|
for (let i = block.txs.length - 1; i >= 1; i--) {
|
||||||
const tx = block.txs[i];
|
const tx = block.txs[i];
|
||||||
@ -313,7 +314,7 @@ async function reserializeCoins(hash) {
|
|||||||
start = false;
|
start = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Reserializing coins from %s.', encoding.revHex(hash));
|
console.log('Reserializing coins from %s.', util.revHex(hash));
|
||||||
|
|
||||||
let batch = db.batch();
|
let batch = db.batch();
|
||||||
let total = 0;
|
let total = 0;
|
||||||
@ -388,7 +389,7 @@ async function reserializeEntries(hash) {
|
|||||||
assert(item.key.equals(pair('e', hash)));
|
assert(item.key.equals(pair('e', hash)));
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Reserializing entries from %s.', encoding.revHex(hash));
|
console.log('Reserializing entries from %s.', util.revHex(hash));
|
||||||
|
|
||||||
const tip = await getTipHash();
|
const tip = await getTipHash();
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,7 @@ const BDB = require('bdb');
|
|||||||
const bio = require('bufio');
|
const bio = require('bufio');
|
||||||
const hash256 = require('bcrypto/lib/hash256');
|
const hash256 = require('bcrypto/lib/hash256');
|
||||||
const BN = require('bcrypto/lib/bn');
|
const BN = require('bcrypto/lib/bn');
|
||||||
|
const util = require('../lib/utils/util');
|
||||||
const {encoding} = bio;
|
const {encoding} = bio;
|
||||||
|
|
||||||
const DUMMY = Buffer.from([0]);
|
const DUMMY = Buffer.from([0]);
|
||||||
@ -114,7 +115,7 @@ async function indexTips() {
|
|||||||
|
|
||||||
for (let i = 0; i < tips.length; i++) {
|
for (let i = 0; i < tips.length; i++) {
|
||||||
const tip = tips[i];
|
const tip = tips[i];
|
||||||
console.log('Indexing chain tip: %s.', encoding.revHex(tip));
|
console.log('Indexing chain tip: %s.', util.revHex(tip));
|
||||||
batch.put(pair('p', tip), DUMMY);
|
batch.put(pair('p', tip), DUMMY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
const assert = require('./util/assert');
|
const assert = require('./util/assert');
|
||||||
const consensus = require('../lib/protocol/consensus');
|
const consensus = require('../lib/protocol/consensus');
|
||||||
const {encoding} = require('bufio');
|
|
||||||
const Coin = require('../lib/primitives/coin');
|
const Coin = require('../lib/primitives/coin');
|
||||||
const Script = require('../lib/script/script');
|
const Script = require('../lib/script/script');
|
||||||
const Chain = require('../lib/blockchain/chain');
|
const Chain = require('../lib/blockchain/chain');
|
||||||
|
|||||||
@ -4,10 +4,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const bio = require('bufio');
|
const bio = require('bufio');
|
||||||
|
const util = require('../lib/utils/util');
|
||||||
const Input = require('../lib/primitives/input');
|
const Input = require('../lib/primitives/input');
|
||||||
const assert = require('./util/assert');
|
const assert = require('./util/assert');
|
||||||
const common = require('./util/common');
|
const common = require('./util/common');
|
||||||
const {encoding} = bio;
|
|
||||||
|
|
||||||
// Take input rawbytes from the raw data format
|
// Take input rawbytes from the raw data format
|
||||||
// p2pkh
|
// p2pkh
|
||||||
@ -236,7 +236,7 @@ describe('Input', function() {
|
|||||||
const inputs = test.inputs.map((prevout, i) => {
|
const inputs = test.inputs.map((prevout, i) => {
|
||||||
const input = Input.fromOptions({
|
const input = Input.fromOptions({
|
||||||
prevout: {
|
prevout: {
|
||||||
hash: encoding.revHex(prevout.txId),
|
hash: util.revHex(prevout.txId),
|
||||||
index: prevout.vout
|
index: prevout.vout
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,7 +4,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const assert = require('./util/assert');
|
const assert = require('./util/assert');
|
||||||
const {encoding} = require('bufio');
|
|
||||||
const random = require('bcrypto/lib/random');
|
const random = require('bcrypto/lib/random');
|
||||||
const MempoolEntry = require('../lib/mempool/mempoolentry');
|
const MempoolEntry = require('../lib/mempool/mempoolentry');
|
||||||
const Mempool = require('../lib/mempool/mempool');
|
const Mempool = require('../lib/mempool/mempool');
|
||||||
|
|||||||
@ -7,6 +7,7 @@ const {inspect} = require('util');
|
|||||||
const {encoding} = require('bufio');
|
const {encoding} = require('bufio');
|
||||||
const assert = require('./util/assert');
|
const assert = require('./util/assert');
|
||||||
const random = require('bcrypto/lib/random');
|
const random = require('bcrypto/lib/random');
|
||||||
|
const util = require('../lib/utils/util');
|
||||||
const consensus = require('../lib/protocol/consensus');
|
const consensus = require('../lib/protocol/consensus');
|
||||||
const TX = require('../lib/primitives/tx');
|
const TX = require('../lib/primitives/tx');
|
||||||
const Output = require('../lib/primitives/output');
|
const Output = require('../lib/primitives/output');
|
||||||
@ -65,7 +66,7 @@ function parseTXTest(data) {
|
|||||||
const view = new CoinView();
|
const view = new CoinView();
|
||||||
|
|
||||||
for (const [txid, index, str, amount] of coins) {
|
for (const [txid, index, str, amount] of coins) {
|
||||||
const hash = encoding.revHex(txid);
|
const hash = util.revHex(txid);
|
||||||
const script = Script.fromString(str);
|
const script = Script.fromString(str);
|
||||||
const value = parseInt(amount || '0', 10);
|
const value = parseInt(amount || '0', 10);
|
||||||
|
|
||||||
@ -102,7 +103,7 @@ function parseSighashTest(data) {
|
|||||||
const tx = TX.fromRaw(txHex, 'hex');
|
const tx = TX.fromRaw(txHex, 'hex');
|
||||||
const script = Script.fromRaw(scriptHex, 'hex');
|
const script = Script.fromRaw(scriptHex, 'hex');
|
||||||
|
|
||||||
const expected = encoding.revHex(hash);
|
const expected = util.revHex(hash);
|
||||||
|
|
||||||
let hex = type & 3;
|
let hex = type & 3;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user