lib: use TX instead of Tx everywhere
This commit is contained in:
parent
f139ce2d91
commit
cdd3dbefb1
@ -12,7 +12,7 @@ function Block(data) {
|
|||||||
this.ts = data.ts;
|
this.ts = data.ts;
|
||||||
this.bits = data.bits;
|
this.bits = data.bits;
|
||||||
this.nonce = data.nonce;
|
this.nonce = data.nonce;
|
||||||
this.totalTx = data.totalTx;
|
this.totalTX = data.totalTX;
|
||||||
this.hashes = data.hashes.map(function(hash) {
|
this.hashes = data.hashes.map(function(hash) {
|
||||||
return utils.toHex(hash);
|
return utils.toHex(hash);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -54,7 +54,7 @@ function Pool(options) {
|
|||||||
// Minimum verification depth
|
// Minimum verification depth
|
||||||
minDepth: options.minValidateDepth || 0,
|
minDepth: options.minValidateDepth || 0,
|
||||||
|
|
||||||
// getTx map
|
// getTX map
|
||||||
map: {}
|
map: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -443,7 +443,7 @@ Pool.prototype._doRequests = function _doRequests() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Pool.prototype.getTx = function getTx(hash, range, cb) {
|
Pool.prototype.getTX = function getTX(hash, range, cb) {
|
||||||
hash = utils.toHex(hash);
|
hash = utils.toHex(hash);
|
||||||
|
|
||||||
if (typeof range === 'function') {
|
if (typeof range === 'function') {
|
||||||
@ -503,7 +503,7 @@ Pool.prototype.getTx = function getTx(hash, range, cb) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Pool.prototype.sendTx = function sendTx(tx) {
|
Pool.prototype.sendTX = function sendTX(tx) {
|
||||||
var e = new EventEmitter();
|
var e = new EventEmitter();
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|||||||
@ -98,7 +98,7 @@ Parser.prototype.parsePayload = function parsePayload(cmd, p) {
|
|||||||
else if (cmd === 'block')
|
else if (cmd === 'block')
|
||||||
return this.parseBlock(p);
|
return this.parseBlock(p);
|
||||||
else if (cmd === 'tx')
|
else if (cmd === 'tx')
|
||||||
return this.parseTx(p);
|
return this.parseTX(p);
|
||||||
else if (cmd === 'reject')
|
else if (cmd === 'reject')
|
||||||
return this.parseReject(p);
|
return this.parseReject(p);
|
||||||
else
|
else
|
||||||
@ -204,7 +204,7 @@ Parser.prototype.parseMerkleBlock = function parseMerkleBlock(p) {
|
|||||||
ts: readU32(p, 68),
|
ts: readU32(p, 68),
|
||||||
bits: readU32(p, 72),
|
bits: readU32(p, 72),
|
||||||
nonce: readU32(p, 76),
|
nonce: readU32(p, 76),
|
||||||
totalTx: readU32(p, 80),
|
totalTX: readU32(p, 80),
|
||||||
hashes: hashes,
|
hashes: hashes,
|
||||||
flags: flags
|
flags: flags
|
||||||
};
|
};
|
||||||
@ -221,11 +221,11 @@ Parser.prototype.parseBlock = function parseBlock(p) {
|
|||||||
ts: readU32(p, 68),
|
ts: readU32(p, 68),
|
||||||
bits: readU32(p, 72),
|
bits: readU32(p, 72),
|
||||||
nonce: readU32(p, 76),
|
nonce: readU32(p, 76),
|
||||||
totalTx: readU32(p, 80)
|
totalTX: readU32(p, 80)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
Parser.prototype.parseTxIn = function parseTxIn(p) {
|
Parser.prototype.parseTXIn = function parseTXIn(p) {
|
||||||
if (p.length < 41)
|
if (p.length < 41)
|
||||||
return this._error('Invalid tx_in size');
|
return this._error('Invalid tx_in size');
|
||||||
|
|
||||||
@ -246,7 +246,7 @@ Parser.prototype.parseTxIn = function parseTxIn(p) {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
Parser.prototype.parseTxOut = function parseTxOut(p) {
|
Parser.prototype.parseTXOut = function parseTXOut(p) {
|
||||||
if (p.length < 9)
|
if (p.length < 9)
|
||||||
return this._error('Invalid tx_out size');
|
return this._error('Invalid tx_out size');
|
||||||
|
|
||||||
@ -263,7 +263,7 @@ Parser.prototype.parseTxOut = function parseTxOut(p) {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
Parser.prototype.parseTx = function parseTx(p) {
|
Parser.prototype.parseTX = function parseTX(p) {
|
||||||
if (p.length < 60)
|
if (p.length < 60)
|
||||||
return this._error('Invalid tx size');
|
return this._error('Invalid tx size');
|
||||||
|
|
||||||
@ -277,7 +277,7 @@ Parser.prototype.parseTx = function parseTx(p) {
|
|||||||
|
|
||||||
var txIn = new Array(inCount);
|
var txIn = new Array(inCount);
|
||||||
for (var i = 0; i < inCount; i++) {
|
for (var i = 0; i < inCount; i++) {
|
||||||
var tx = this.parseTxIn(p.slice(off));
|
var tx = this.parseTXIn(p.slice(off));
|
||||||
if (!tx)
|
if (!tx)
|
||||||
return;
|
return;
|
||||||
txIn[i] = tx;
|
txIn[i] = tx;
|
||||||
@ -297,7 +297,7 @@ Parser.prototype.parseTx = function parseTx(p) {
|
|||||||
|
|
||||||
var txOut = new Array(outCount);
|
var txOut = new Array(outCount);
|
||||||
for (var i = 0; i < outCount; i++) {
|
for (var i = 0; i < outCount; i++) {
|
||||||
var tx = this.parseTxOut(p.slice(off));
|
var tx = this.parseTXOut(p.slice(off));
|
||||||
if (!tx)
|
if (!tx)
|
||||||
return;
|
return;
|
||||||
txOut[i] = tx;
|
txOut[i] = tx;
|
||||||
|
|||||||
@ -42,13 +42,13 @@ describe('TX', function() {
|
|||||||
'2e88ac00000000';
|
'2e88ac00000000';
|
||||||
|
|
||||||
it('should decode/encode with parser/framer', function() {
|
it('should decode/encode with parser/framer', function() {
|
||||||
var tx = bcoin.tx(parser.parseTx(bcoin.utils.toArray(raw, 'hex')));
|
var tx = bcoin.tx(parser.parseTX(bcoin.utils.toArray(raw, 'hex')));
|
||||||
assert.equal(bcoin.utils.toHex(tx.render()), raw);
|
assert.equal(bcoin.utils.toHex(tx.render()), raw);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be verifiable', function() {
|
it('should be verifiable', function() {
|
||||||
var tx = bcoin.tx(parser.parseTx(bcoin.utils.toArray(raw, 'hex')));
|
var tx = bcoin.tx(parser.parseTX(bcoin.utils.toArray(raw, 'hex')));
|
||||||
tx.input(bcoin.tx(parser.parseTx(bcoin.utils.toArray(inp, 'hex'))), 0);
|
tx.input(bcoin.tx(parser.parseTX(bcoin.utils.toArray(inp, 'hex'))), 0);
|
||||||
|
|
||||||
assert(tx.verify());
|
assert(tx.verify());
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user