Compare commits

...

1 Commits

Author SHA1 Message Date
sairajzero
6fb8a4641a Updating the deprecated new Buffer
- replacing new Buffer(int) to Buffer.alloc(int)
- replacing new Buffer('string' [, 'encoding']) to Buffer.from('string' [, 'encoding'])
2021-05-14 16:56:12 +05:30
27 changed files with 185 additions and 185 deletions

View File

@ -12,7 +12,7 @@ var dbLocation = process.argv[2];
console.log('Using db location: ', dbLocation); console.log('Using db location: ', dbLocation);
var addressPrefix = new Buffer('0006', 'hex'); var addressPrefix = Buffer.from('0006', 'hex');
var startAddress = new Array(35).join('0'); var startAddress = new Array(35).join('0');
var endAddress = new Array(35).join('f'); var endAddress = new Array(35).join('f');

View File

@ -7,19 +7,19 @@ var dbPath = '/Users/chrisk/.bwdb/flocore-node.db';
var flocore = require('flocore-lib'); var flocore = require('flocore-lib');
var db = levelup(dbPath, {keyEncoding: 'binary', valueEncoding: 'binary'}); var db = levelup(dbPath, {keyEncoding: 'binary', valueEncoding: 'binary'});
var prefix = new Buffer('0002', 'hex'); var prefix = Buffer.from('0002', 'hex');
var encoding = new Encoding(prefix); var encoding = new Encoding(prefix);
var address = '1MfDRRVVKXUe5KNVZzu8CBzUZDHTTYZM94'; var address = '1MfDRRVVKXUe5KNVZzu8CBzUZDHTTYZM94';
var addressLength = new Buffer(1); var addressLength = Buffer.alloc(1);
addressLength.writeUInt8(address.length); addressLength.writeUInt8(address.length);
//var startBuffer = prefix; //var startBuffer = prefix;
//var endBuffer = Buffer.concat([prefix, new Buffer('ff', 'hex')]); //var endBuffer = Buffer.concat([prefix, Buffer.from('ff', 'hex')]);
//var startBuffer = Buffer.concat([prefix, addressLength, new Buffer(address, 'utf8'), new Buffer('00', 'hex')]); //var startBuffer = Buffer.concat([prefix, addressLength, Buffer.from(address, 'utf8'), Buffer.from('00', 'hex')]);
//var endBuffer = Buffer.concat([prefix, addressLength, new Buffer(address, 'utf8'), new Buffer('01', 'hex')]); //var endBuffer = Buffer.concat([prefix, addressLength, Buffer.from(address, 'utf8'), Buffer.from('01', 'hex')]);
var start = Buffer.concat([prefix, new Buffer('0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9', 'hex')]); var start = Buffer.concat([prefix, Buffer.from('0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9', 'hex')]);
var end = Buffer.concat([prefix, new Buffer('0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9', 'hex'), new Buffer('01', 'hex')]); var end = Buffer.concat([prefix, Buffer.from('0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9', 'hex'), Buffer.from('01', 'hex')]);
var stream = db.createReadStream({ var stream = db.createReadStream({
gte: start, gte: start,
lt: end lt: end

View File

@ -8,6 +8,6 @@ module.exports = {
testnet: '9b7bc86236c34b5e3a39367c036b7fe8807a966c22a7a1f0da2a198a27e03731', //this is testnet3 testnet: '9b7bc86236c34b5e3a39367c036b7fe8807a966c22a7a1f0da2a198a27e03731', //this is testnet3
testnet5: '000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943' //this is testnet5 testnet5: '000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943' //this is testnet5
}, },
DB_PREFIX: new Buffer('ffff', 'hex') DB_PREFIX: Buffer.from('ffff', 'hex')
}; };

View File

@ -5,33 +5,33 @@ function Encoding(servicePrefix) {
} }
Encoding.prototype.encodeAddressIndexKey = function(address, height, txid, index, input, timestamp) { Encoding.prototype.encodeAddressIndexKey = function(address, height, txid, index, input, timestamp) {
var prefix = new Buffer('00', 'hex'); var prefix = Buffer.from('00', 'hex');
var buffers = [this.servicePrefix, prefix]; var buffers = [this.servicePrefix, prefix];
var addressSizeBuffer = new Buffer(1); var addressSizeBuffer = Buffer.alloc(1);
addressSizeBuffer.writeUInt8(address.length); addressSizeBuffer.writeUInt8(address.length);
var addressBuffer = new Buffer(address, 'utf8'); var addressBuffer = Buffer.from(address, 'utf8');
buffers.push(addressSizeBuffer); buffers.push(addressSizeBuffer);
buffers.push(addressBuffer); buffers.push(addressBuffer);
var heightBuffer = new Buffer(4); var heightBuffer = Buffer.alloc(4);
heightBuffer.writeUInt32BE(height || 0); heightBuffer.writeUInt32BE(height || 0);
buffers.push(heightBuffer); buffers.push(heightBuffer);
var txidBuffer = new Buffer(txid || Array(65).join('0'), 'hex'); var txidBuffer = Buffer.from(txid || Array(65).join('0'), 'hex');
buffers.push(txidBuffer); buffers.push(txidBuffer);
var indexBuffer = new Buffer(4); var indexBuffer = Buffer.alloc(4);
indexBuffer.writeUInt32BE(index || 0); indexBuffer.writeUInt32BE(index || 0);
buffers.push(indexBuffer); buffers.push(indexBuffer);
// this is whether the address appears in an input (1) or output (0) // this is whether the address appears in an input (1) or output (0)
var inputBuffer = new Buffer(1); var inputBuffer = Buffer.alloc(1);
inputBuffer.writeUInt8(input || 0); inputBuffer.writeUInt8(input || 0);
buffers.push(inputBuffer); buffers.push(inputBuffer);
var timestampBuffer = new Buffer(4); var timestampBuffer = Buffer.alloc(4);
timestampBuffer.writeUInt32BE(timestamp || 0); timestampBuffer.writeUInt32BE(timestamp || 0);
buffers.push(timestampBuffer); buffers.push(timestampBuffer);
@ -58,20 +58,20 @@ Encoding.prototype.decodeAddressIndexKey = function(buffer) {
}; };
Encoding.prototype.encodeUtxoIndexKey = function(address, txid, outputIndex) { Encoding.prototype.encodeUtxoIndexKey = function(address, txid, outputIndex) {
var prefix = new Buffer('01', 'hex'); var prefix = Buffer.from('01', 'hex');
var buffers = [this.servicePrefix, prefix]; var buffers = [this.servicePrefix, prefix];
var addressSizeBuffer = new Buffer(1); var addressSizeBuffer = Buffer.alloc(1);
addressSizeBuffer.writeUInt8(address.length); addressSizeBuffer.writeUInt8(address.length);
var addressBuffer = new Buffer(address, 'utf8'); var addressBuffer = Buffer.from(address, 'utf8');
buffers.push(addressSizeBuffer); buffers.push(addressSizeBuffer);
buffers.push(addressBuffer); buffers.push(addressBuffer);
var txidBuffer = new Buffer(txid || new Array(65).join('0'), 'hex'); var txidBuffer = Buffer.from(txid || new Array(65).join('0'), 'hex');
buffers.push(txidBuffer); buffers.push(txidBuffer);
var outputIndexBuffer = new Buffer(4); var outputIndexBuffer = Buffer.alloc(4);
outputIndexBuffer.writeUInt32BE(outputIndex || 0); outputIndexBuffer.writeUInt32BE(outputIndex || 0);
buffers.push(outputIndexBuffer); buffers.push(outputIndexBuffer);
@ -92,11 +92,11 @@ Encoding.prototype.decodeUtxoIndexKey = function(buffer) {
}; };
Encoding.prototype.encodeUtxoIndexValue = function(height, satoshis, timestamp, scriptBuffer) { Encoding.prototype.encodeUtxoIndexValue = function(height, satoshis, timestamp, scriptBuffer) {
var heightBuffer = new Buffer(4); var heightBuffer = Buffer.alloc(4);
heightBuffer.writeUInt32BE(height); heightBuffer.writeUInt32BE(height);
var satoshisBuffer = new Buffer(8); var satoshisBuffer = Buffer.alloc(8);
satoshisBuffer.writeDoubleBE(satoshis); satoshisBuffer.writeDoubleBE(satoshis);
var timestampBuffer = new Buffer(4); var timestampBuffer = Buffer.alloc(4);
timestampBuffer.writeUInt32BE(timestamp || 0); timestampBuffer.writeUInt32BE(timestamp || 0);
return Buffer.concat([heightBuffer, satoshisBuffer, timestampBuffer, scriptBuffer]); return Buffer.concat([heightBuffer, satoshisBuffer, timestampBuffer, scriptBuffer]);
}; };

View File

@ -298,7 +298,7 @@ AddressService.prototype.getAddressUnspentOutputs = function(address, options, c
var results = []; var results = [];
var start = self._encoding.encodeUtxoIndexKey(address); var start = self._encoding.encodeUtxoIndexKey(address);
var final = new Buffer(new Array(73).join('f'), 'hex'); var final = Buffer.from(new Array(73).join('f'), 'hex');
var end = Buffer.concat([ start.slice(0, -36), final ]); var end = Buffer.concat([ start.slice(0, -36), final ]);
var criteria = { var criteria = {
@ -444,7 +444,7 @@ AddressService.prototype._getTxidStream = function(address, options) {
var end = Buffer.concat([ var end = Buffer.concat([
start.slice(0, address.length + 4), start.slice(0, address.length + 4),
options.endHeightBuf, options.endHeightBuf,
new Buffer(new Array(83).join('f'), 'hex') Buffer.from(new Array(83).join('f'), 'hex')
]); ]);
var criteria = { var criteria = {
@ -500,7 +500,7 @@ AddressService.prototype._getAddressTxidHistory = function(address, options, cal
var results = []; var results = [];
options.endHeightBuf = new Buffer(4); options.endHeightBuf = Buffer.alloc(4);
options.endHeightBuf.writeUInt32BE(options.end); options.endHeightBuf.writeUInt32BE(options.end);
if (_.isUndefined(options.queryMempool)) { if (_.isUndefined(options.queryMempool)) {

View File

@ -10,7 +10,7 @@ function Encoding(servicePrefix) {
// ---- hash --> rawblock // ---- hash --> rawblock
Encoding.prototype.encodeBlockKey = function(hash) { Encoding.prototype.encodeBlockKey = function(hash) {
return Buffer.concat([ this._servicePrefix, new Buffer(hash, 'hex') ]); return Buffer.concat([ this._servicePrefix, Buffer.from(hash, 'hex') ]);
}; };
Encoding.prototype.decodeBlockKey = function(buffer) { Encoding.prototype.decodeBlockKey = function(buffer) {

View File

@ -69,9 +69,9 @@ DB.prototype._setDataPath = function() {
}; };
DB.prototype._setVersion = function(callback) { DB.prototype._setVersion = function(callback) {
var versionBuffer = new Buffer(new Array(4)); var versionBuffer = Buffer.from(new Array(4));
versionBuffer.writeUInt32BE(this.version); versionBuffer.writeUInt32BE(this.version);
this.put(Buffer.concat([ this._dbPrefix, new Buffer('version', 'utf8') ]), versionBuffer, callback); this.put(Buffer.concat([ this._dbPrefix, Buffer.from('version', 'utf8') ]), versionBuffer, callback);
}; };
DB.prototype.start = function(callback) { DB.prototype.start = function(callback) {
@ -207,7 +207,7 @@ DB.prototype.getPublishEvents = function() {
DB.prototype.getServiceTip = function(serviceName, callback) { DB.prototype.getServiceTip = function(serviceName, callback) {
var keyBuf = Buffer.concat([ this._dbPrefix, new Buffer('tip-' + serviceName, 'utf8') ]); var keyBuf = Buffer.concat([ this._dbPrefix, Buffer.from('tip-' + serviceName, 'utf8') ]);
var self = this; var self = this;
self.get(keyBuf, function(err, tipBuf) { self.get(keyBuf, function(err, tipBuf) {
@ -242,8 +242,8 @@ DB.prototype.getServiceTip = function(serviceName, callback) {
DB.prototype.getPrefix = function(service, callback) { DB.prototype.getPrefix = function(service, callback) {
var self = this; var self = this;
var keyBuf = Buffer.concat([ self._dbPrefix, new Buffer('prefix-', 'utf8'), new Buffer(service, 'utf8') ]); var keyBuf = Buffer.concat([ self._dbPrefix, Buffer.from('prefix-', 'utf8'), Buffer.from(service, 'utf8') ]);
var unusedBuf = Buffer.concat([ self._dbPrefix, new Buffer('nextUnused', 'utf8') ]); var unusedBuf = Buffer.concat([ self._dbPrefix, Buffer.from('nextUnused', 'utf8') ]);
function getPrefix(next) { function getPrefix(next) {
@ -270,7 +270,7 @@ DB.prototype.getPrefix = function(service, callback) {
} }
if(!buffer) { if(!buffer) {
return next(null, new Buffer('0001', 'hex')); return next(null, Buffer.from('0001', 'hex'));
} }
next(null, buffer); next(null, buffer);
@ -294,7 +294,7 @@ DB.prototype.getPrefix = function(service, callback) {
function putUnused(buffer, next) { function putUnused(buffer, next) {
var prefix = buffer.readUInt16BE(); var prefix = buffer.readUInt16BE();
var nextUnused = new Buffer(2); var nextUnused = Buffer.alloc(2);
nextUnused.writeUInt16BE(prefix + 1); nextUnused.writeUInt16BE(prefix + 1);
self.put(unusedBuf, nextUnused, function(err) { self.put(unusedBuf, nextUnused, function(err) {

View File

@ -3,13 +3,13 @@
function Encoding(servicePrefix) { function Encoding(servicePrefix) {
this._servicePrefix = servicePrefix; this._servicePrefix = servicePrefix;
this._hashPrefix = new Buffer('00', 'hex'); this._hashPrefix = Buffer.from('00', 'hex');
this._heightPrefix = new Buffer('01', 'hex'); this._heightPrefix = Buffer.from('01', 'hex');
} }
// ---- hash --> header // ---- hash --> header
Encoding.prototype.encodeHeaderHashKey = function(hash) { Encoding.prototype.encodeHeaderHashKey = function(hash) {
var hashBuf = new Buffer(hash, 'hex'); var hashBuf = Buffer.from(hash, 'hex');
return Buffer.concat([ this._servicePrefix, this._hashPrefix, hashBuf ]); return Buffer.concat([ this._servicePrefix, this._hashPrefix, hashBuf ]);
}; };
@ -19,7 +19,7 @@ Encoding.prototype.decodeHeaderHashKey = function(buffer) {
// ---- height --> header // ---- height --> header
Encoding.prototype.encodeHeaderHeightKey = function(height) { Encoding.prototype.encodeHeaderHeightKey = function(height) {
var heightBuf = new Buffer(4); var heightBuf = Buffer.alloc(4);
heightBuf.writeUInt32BE(height); heightBuf.writeUInt32BE(height);
return Buffer.concat([ this._servicePrefix, this._heightPrefix, heightBuf ]); return Buffer.concat([ this._servicePrefix, this._heightPrefix, heightBuf ]);
}; };
@ -29,21 +29,21 @@ Encoding.prototype.decodeHeaderHeightKey = function(buffer) {
}; };
Encoding.prototype.encodeHeaderValue = function(header) { Encoding.prototype.encodeHeaderValue = function(header) {
var hashBuf = new Buffer(header.hash, 'hex'); var hashBuf = Buffer.from(header.hash, 'hex');
var versionBuf = new Buffer(4); var versionBuf = Buffer.alloc(4);
versionBuf.writeInt32BE(header.version); versionBuf.writeInt32BE(header.version);
var prevHash = new Buffer(header.prevHash, 'hex'); var prevHash = Buffer.from(header.prevHash, 'hex');
var merkleRoot = new Buffer(header.merkleRoot, 'hex'); var merkleRoot = Buffer.from(header.merkleRoot, 'hex');
var tsBuf = new Buffer(4); var tsBuf = Buffer.alloc(4);
tsBuf.writeUInt32BE(header.timestamp || header.time); tsBuf.writeUInt32BE(header.timestamp || header.time);
var bitsBuf = new Buffer(4); var bitsBuf = Buffer.alloc(4);
bitsBuf.writeUInt32BE(header.bits); bitsBuf.writeUInt32BE(header.bits);
var nonceBuf = new Buffer(4); var nonceBuf = Buffer.alloc(4);
nonceBuf.writeUInt32BE(header.nonce); nonceBuf.writeUInt32BE(header.nonce);
var heightBuf = new Buffer(4); var heightBuf = Buffer.alloc(4);
heightBuf.writeUInt32BE(header.height); heightBuf.writeUInt32BE(header.height);
var chainworkBuf = new Buffer(header.chainwork, 'hex'); var chainworkBuf = Buffer.from(header.chainwork, 'hex');
var nextHash = new Buffer(header.nextHash || new Array(65).join('0'), 'hex'); var nextHash = Buffer.from(header.nextHash || new Array(65).join('0'), 'hex');
return Buffer.concat([ return Buffer.concat([
hashBuf, hashBuf,
versionBuf, versionBuf,

View File

@ -1010,7 +1010,7 @@ HeaderService.prototype._adjustHeadersForCheckPointTip = function(callback) {
HeaderService.prototype._getChainwork = function(header, prevHeader) { HeaderService.prototype._getChainwork = function(header, prevHeader) {
var prevChainwork = new BN(new Buffer(prevHeader.chainwork, 'hex')); var prevChainwork = new BN(Buffer.from(prevHeader.chainwork, 'hex'));
return this._computeChainwork(header.bits, prevChainwork); return this._computeChainwork(header.bits, prevChainwork);
}; };

View File

@ -4,13 +4,13 @@ var tx = require('fcoin').TX;
function Encoding(servicePrefix) { function Encoding(servicePrefix) {
this.servicePrefix = servicePrefix; this.servicePrefix = servicePrefix;
this.txPrefix = new Buffer('00', 'hex'); this.txPrefix = Buffer.from('00', 'hex');
this.addressPrefix = new Buffer('01', 'hex'); this.addressPrefix = Buffer.from('01', 'hex');
} }
Encoding.prototype.encodeMempoolTransactionKey = function(txid) { Encoding.prototype.encodeMempoolTransactionKey = function(txid) {
var buffers = [this.servicePrefix, this.txPrefix]; var buffers = [this.servicePrefix, this.txPrefix];
var txidBuffer = new Buffer(txid, 'hex'); var txidBuffer = Buffer.from(txid, 'hex');
buffers.push(txidBuffer); buffers.push(txidBuffer);
return Buffer.concat(buffers); return Buffer.concat(buffers);
}; };
@ -30,22 +30,22 @@ Encoding.prototype.decodeMempoolTransactionValue = function(buffer) {
Encoding.prototype.encodeMempoolAddressKey = function(address, txid, index, input) { Encoding.prototype.encodeMempoolAddressKey = function(address, txid, index, input) {
var buffers = [this.servicePrefix, this.addressPrefix]; var buffers = [this.servicePrefix, this.addressPrefix];
var addressSizeBuffer = new Buffer(1); var addressSizeBuffer = Buffer.alloc(1);
addressSizeBuffer.writeUInt8(address.length); addressSizeBuffer.writeUInt8(address.length);
var addressBuffer = new Buffer(address, 'utf8'); var addressBuffer = Buffer.from(address, 'utf8');
buffers.push(addressSizeBuffer); buffers.push(addressSizeBuffer);
buffers.push(addressBuffer); buffers.push(addressBuffer);
var txidBuffer = new Buffer(txid || Array(65).join('0'), 'hex'); var txidBuffer = Buffer.from(txid || Array(65).join('0'), 'hex');
buffers.push(txidBuffer); buffers.push(txidBuffer);
var indexBuffer = new Buffer(4); var indexBuffer = Buffer.alloc(4);
indexBuffer.writeUInt32BE(index || 0); indexBuffer.writeUInt32BE(index || 0);
buffers.push(indexBuffer); buffers.push(indexBuffer);
// this is whether the address appears in an input (1) or output (0) // this is whether the address appears in an input (1) or output (0)
var inputBuffer = new Buffer(1); var inputBuffer = Buffer.alloc(1);
inputBuffer.writeUInt8(input || 0); inputBuffer.writeUInt8(input || 0);
buffers.push(inputBuffer); buffers.push(inputBuffer);

View File

@ -283,7 +283,7 @@ MempoolService.prototype.getTxidsByAddress = function(address, type, callback) {
var self = this; var self = this;
var results = []; var results = [];
var start = self._encoding.encodeMempoolAddressKey(address); var start = self._encoding.encodeMempoolAddressKey(address);
var end = Buffer.concat([ start.slice(0, -37), new Buffer(new Array(75).join('f'), 'hex') ]); var end = Buffer.concat([ start.slice(0, -37), Buffer.from(new Array(75).join('f'), 'hex') ]);
var criteria = { var criteria = {
gte: start, gte: start,

View File

@ -2,13 +2,13 @@
function Encoding(servicePrefix) { function Encoding(servicePrefix) {
this._servicePrefix = servicePrefix; this._servicePrefix = servicePrefix;
this._blockPrefix = new Buffer('00', 'hex'); this._blockPrefix = Buffer.from('00', 'hex');
this._timestampPrefix = new Buffer('01', 'hex'); this._timestampPrefix = Buffer.from('01', 'hex');
} }
// ---- block hash -> timestamp // ---- block hash -> timestamp
Encoding.prototype.encodeBlockTimestampKey = function(hash) { Encoding.prototype.encodeBlockTimestampKey = function(hash) {
return Buffer.concat([this._servicePrefix, this._blockPrefix, new Buffer(hash, 'hex')]); return Buffer.concat([this._servicePrefix, this._blockPrefix, Buffer.from(hash, 'hex')]);
}; };
Encoding.prototype.decodeBlockTimestampKey = function(buffer) { Encoding.prototype.decodeBlockTimestampKey = function(buffer) {
@ -16,7 +16,7 @@ Encoding.prototype.decodeBlockTimestampKey = function(buffer) {
}; };
Encoding.prototype.encodeBlockTimestampValue = function(timestamp) { Encoding.prototype.encodeBlockTimestampValue = function(timestamp) {
var timestampBuffer = new Buffer(4); var timestampBuffer = Buffer.alloc(4);
timestampBuffer.writeUInt32BE(timestamp); timestampBuffer.writeUInt32BE(timestamp);
return timestampBuffer; return timestampBuffer;
}; };
@ -28,7 +28,7 @@ Encoding.prototype.decodeBlockTimestampValue = function(buffer) {
// ---- timestamp -> block hash // ---- timestamp -> block hash
Encoding.prototype.encodeTimestampBlockKey = function(timestamp) { Encoding.prototype.encodeTimestampBlockKey = function(timestamp) {
var timestampBuffer = new Buffer(4); var timestampBuffer = Buffer.alloc(4);
timestampBuffer.writeUInt32BE(timestamp); timestampBuffer.writeUInt32BE(timestamp);
return Buffer.concat([this._servicePrefix, this._timestampPrefix, timestampBuffer]); return Buffer.concat([this._servicePrefix, this._timestampPrefix, timestampBuffer]);
}; };
@ -38,7 +38,7 @@ Encoding.prototype.decodeTimestampBlockKey = function(buffer) {
}; };
Encoding.prototype.encodeTimestampBlockValue = function(hash) { Encoding.prototype.encodeTimestampBlockValue = function(hash) {
return new Buffer(hash, 'hex'); return Buffer.from(hash, 'hex');
}; };
Encoding.prototype.decodeTimestampBlockValue = function(buffer) { Encoding.prototype.decodeTimestampBlockValue = function(buffer) {

View File

@ -4,13 +4,13 @@ var Tx = require('fcoin').TX;
function Encoding(servicePrefix) { function Encoding(servicePrefix) {
this.servicePrefix = servicePrefix; this.servicePrefix = servicePrefix;
this.txIndex = new Buffer('00', 'hex'); this.txIndex = Buffer.from('00', 'hex');
this.spentIndex = new Buffer('01', 'hex'); this.spentIndex = Buffer.from('01', 'hex');
this.doubleSpentIndex = new Buffer('02', 'hex'); this.doubleSpentIndex = Buffer.from('02', 'hex');
} }
Encoding.prototype.encodeTransactionKey = function(txid) { Encoding.prototype.encodeTransactionKey = function(txid) {
return Buffer.concat([this.servicePrefix, this.txIndex, new Buffer(txid, 'hex')]); return Buffer.concat([this.servicePrefix, this.txIndex, Buffer.from(txid, 'hex')]);
}; };
Encoding.prototype.decodeTransactionKey = function(buffer) { Encoding.prototype.decodeTransactionKey = function(buffer) {
@ -18,24 +18,24 @@ Encoding.prototype.decodeTransactionKey = function(buffer) {
}; };
Encoding.prototype.encodeTransactionValue = function(transaction) { Encoding.prototype.encodeTransactionValue = function(transaction) {
var heightBuffer = new Buffer(4); var heightBuffer = Buffer.alloc(4);
heightBuffer.writeUInt32BE(transaction.__height); heightBuffer.writeUInt32BE(transaction.__height);
var hashBuffer = new Buffer(transaction.__blockhash, 'hex'); var hashBuffer = Buffer.from(transaction.__blockhash, 'hex');
var timestampBuffer = new Buffer(4); var timestampBuffer = Buffer.alloc(4);
timestampBuffer.writeUInt32BE(transaction.__timestamp); timestampBuffer.writeUInt32BE(transaction.__timestamp);
var inputValues = transaction.__inputValues; var inputValues = transaction.__inputValues;
var inputValuesBuffer = new Buffer(8 * inputValues.length); var inputValuesBuffer = Buffer.alloc(8 * inputValues.length);
for(var i = 0; i < inputValues.length; i++) { for(var i = 0; i < inputValues.length; i++) {
inputValuesBuffer.writeDoubleBE(inputValues[i], i * 8); inputValuesBuffer.writeDoubleBE(inputValues[i], i * 8);
} }
var inputValuesLengthBuffer = new Buffer(2); var inputValuesLengthBuffer = Buffer.alloc(2);
inputValuesLengthBuffer.writeUInt16BE(inputValues.length); inputValuesLengthBuffer.writeUInt16BE(inputValues.length);
return new Buffer.concat([heightBuffer, hashBuffer, timestampBuffer, return Buffer.concat([heightBuffer, hashBuffer, timestampBuffer,
inputValuesLengthBuffer, inputValuesBuffer, transaction.toRaw()]); inputValuesLengthBuffer, inputValuesBuffer, transaction.toRaw()]);
}; };
@ -65,9 +65,9 @@ Encoding.prototype.decodeTransactionValue = function(buffer) {
// for every input we receive, we make an entry for what output it spends // for every input we receive, we make an entry for what output it spends
Encoding.prototype.encodeSpentKey = function(txid, outputIndex) { Encoding.prototype.encodeSpentKey = function(txid, outputIndex) {
var outputIndexBuffer = new Buffer(4); var outputIndexBuffer = Buffer.alloc(4);
outputIndexBuffer.writeUInt32BE(outputIndex); outputIndexBuffer.writeUInt32BE(outputIndex);
return Buffer.concat([this.servicePrefix, this.spentIndex, new Buffer(txid, 'hex'), outputIndexBuffer]); return Buffer.concat([this.servicePrefix, this.spentIndex, Buffer.from(txid, 'hex'), outputIndexBuffer]);
}; };
Encoding.prototype.decodeSpentKey = function(buffer) { Encoding.prototype.decodeSpentKey = function(buffer) {
@ -80,12 +80,12 @@ Encoding.prototype.decodeSpentKey = function(buffer) {
}; };
Encoding.prototype.encodeSpentValue = function(txid, inputIndex, blockHeight, blockHash) { Encoding.prototype.encodeSpentValue = function(txid, inputIndex, blockHeight, blockHash) {
var inputIndexBuffer = new Buffer(4); var inputIndexBuffer = Buffer.alloc(4);
inputIndexBuffer.writeUInt32BE(inputIndex); inputIndexBuffer.writeUInt32BE(inputIndex);
var blockHeightBuffer = new Buffer(4); var blockHeightBuffer = Buffer.alloc(4);
blockHeightBuffer.writeUInt32BE(blockHeight); blockHeightBuffer.writeUInt32BE(blockHeight);
var blockHashBuffer = new Buffer(blockHash, 'hex'); var blockHashBuffer = Buffer.from(blockHash, 'hex');
return Buffer.concat([new Buffer(txid, 'hex'), inputIndexBuffer, blockHeightBuffer, blockHashBuffer]); return Buffer.concat([Buffer.from(txid, 'hex'), inputIndexBuffer, blockHeightBuffer, blockHashBuffer]);
}; };
Encoding.prototype.decodeSpentValue = function(buffer) { Encoding.prototype.decodeSpentValue = function(buffer) {
@ -102,9 +102,9 @@ Encoding.prototype.decodeSpentValue = function(buffer) {
}; };
Encoding.prototype.encodeDoubleSpentKey = function(txid, outputIndex) { Encoding.prototype.encodeDoubleSpentKey = function(txid, outputIndex) {
var outputIndexBuffer = new Buffer(4); var outputIndexBuffer = Buffer.alloc(4);
outputIndexBuffer.writeUInt32BE(outputIndex); outputIndexBuffer.writeUInt32BE(outputIndex);
return Buffer.concat([this.servicePrefix, this.spentIndex, new Buffer(txid, 'hex'), outputIndexBuffer]); return Buffer.concat([this.servicePrefix, this.spentIndex, Buffer.from(txid, 'hex'), outputIndexBuffer]);
}; };
Encoding.prototype.decodeDoubleSpentKey = function(buffer) { Encoding.prototype.decodeDoubleSpentKey = function(buffer) {
@ -117,12 +117,12 @@ Encoding.prototype.decodeDoubleSpentKey = function(buffer) {
}; };
Encoding.prototype.encodeDoubleSpentValue = function(txid, inputIndex, blockHeight, blockHash) { Encoding.prototype.encodeDoubleSpentValue = function(txid, inputIndex, blockHeight, blockHash) {
var inputIndexBuffer = new Buffer(4); var inputIndexBuffer = Buffer.alloc(4);
inputIndexBuffer.writeUInt32BE(inputIndex); inputIndexBuffer.writeUInt32BE(inputIndex);
var blockHeightBuffer = new Buffer(4); var blockHeightBuffer = Buffer.alloc(4);
blockHeightBuffer.writeUInt32BE(inputIndex); blockHeightBuffer.writeUInt32BE(inputIndex);
var blockHashBuffer = new Buffer(blockHash, 'hex'); var blockHashBuffer = Buffer.from(blockHash, 'hex');
return Buffer.concat([new Buffer(txid, 'hex'), inputIndexBuffer, blockHeightBuffer, blockHashBuffer]); return Buffer.concat([Buffer.from(txid, 'hex'), inputIndexBuffer, blockHeightBuffer, blockHashBuffer]);
}; };
Encoding.prototype.decodeDoubleSpentValue = function(buffer) { Encoding.prototype.decodeDoubleSpentValue = function(buffer) {

View File

@ -58,12 +58,12 @@ utils.sendError = function(err, res) {
utils.encodeTip = function(tip, name) { utils.encodeTip = function(tip, name) {
var key = Buffer.concat([ constants.DB_PREFIX, var key = Buffer.concat([ constants.DB_PREFIX,
new Buffer('tip-' + name, 'utf8') ]); Buffer.from('tip-' + name, 'utf8') ]);
var heightBuf = new Buffer(4); var heightBuf = Buffer.alloc(4);
heightBuf.writeUInt32BE(tip.height); heightBuf.writeUInt32BE(tip.height);
var value = Buffer.concat([ heightBuf, new Buffer(tip.hash, 'hex') ]); var value = Buffer.concat([ heightBuf, Buffer.from(tip.hash, 'hex') ]);
return { key: key, value: value }; return { key: key, value: value };
}; };

View File

@ -6,27 +6,27 @@ var Encoding = require('../../../lib/services/address/encoding');
describe('Address service encoding', function() { describe('Address service encoding', function() {
var servicePrefix = new Buffer('0000', 'hex'); var servicePrefix = Buffer.from('0000', 'hex');
var encoding = new Encoding(servicePrefix); var encoding = new Encoding(servicePrefix);
var txid = '91b58f19b6eecba94ed0f6e463e8e334ec0bcda7880e2985c82a8f32e4d03add'; var txid = '91b58f19b6eecba94ed0f6e463e8e334ec0bcda7880e2985c82a8f32e4d03add';
var address = '1EZBqbJSHFKSkVPNKzc5v26HA6nAHiTXq6'; var address = '1EZBqbJSHFKSkVPNKzc5v26HA6nAHiTXq6';
var height = 1; var height = 1;
var addressSizeBuf = new Buffer(1); var addressSizeBuf = Buffer.alloc(1);
var prefix0 = new Buffer('00', 'hex'); var prefix0 = Buffer.from('00', 'hex');
var prefix1 = new Buffer('01', 'hex'); var prefix1 = Buffer.from('01', 'hex');
var ts = Math.floor(new Date('2017-02-28').getTime() / 1000); var ts = Math.floor(new Date('2017-02-28').getTime() / 1000);
var tsBuf = new Buffer(4); var tsBuf = Buffer.alloc(4);
tsBuf.writeUInt32BE(ts); tsBuf.writeUInt32BE(ts);
addressSizeBuf.writeUInt8(address.length); addressSizeBuf.writeUInt8(address.length);
var addressIndexKeyBuf = Buffer.concat([ var addressIndexKeyBuf = Buffer.concat([
servicePrefix, servicePrefix,
prefix0, prefix0,
addressSizeBuf, addressSizeBuf,
new Buffer(address), Buffer.from(address),
new Buffer('00000001', 'hex'), Buffer.from('00000001', 'hex'),
new Buffer(txid, 'hex'), Buffer.from(txid, 'hex'),
new Buffer('00000000', 'hex'), Buffer.from('00000000', 'hex'),
new Buffer('00', 'hex'), Buffer.from('00', 'hex'),
tsBuf tsBuf
]); ]);
var outputIndex = 5; var outputIndex = 5;
@ -34,15 +34,15 @@ describe('Address service encoding', function() {
servicePrefix, servicePrefix,
prefix1, prefix1,
addressSizeBuf, addressSizeBuf,
new Buffer(address), Buffer.from(address),
new Buffer(txid, 'hex'), Buffer.from(txid, 'hex'),
new Buffer('00000005', 'hex')]); Buffer.from('00000005', 'hex')]);
var txHex = '0100000001cc3ffe0638792c8b39328bb490caaefe2cf418f2ce0144956e0c22515f29724d010000006a473044022030ce9fa68d1a32abf0cd4adecf90fb998375b64fe887c6987278452b068ae74c022036a7d00d1c8af19e298e04f14294c807ebda51a20389ad751b4ff3c032cf8990012103acfcb348abb526526a9f63214639d79183871311c05b2eebc727adfdd016514fffffffff02f6ae7d04000000001976a9144455183e407ee4d3423858c8a3275918aedcd18e88aca99b9b08010000001976a9140beceae2c29bfde08d2b6d80b33067451c5887be88ac00000000'; var txHex = '0100000001cc3ffe0638792c8b39328bb490caaefe2cf418f2ce0144956e0c22515f29724d010000006a473044022030ce9fa68d1a32abf0cd4adecf90fb998375b64fe887c6987278452b068ae74c022036a7d00d1c8af19e298e04f14294c807ebda51a20389ad751b4ff3c032cf8990012103acfcb348abb526526a9f63214639d79183871311c05b2eebc727adfdd016514fffffffff02f6ae7d04000000001976a9144455183e407ee4d3423858c8a3275918aedcd18e88aca99b9b08010000001976a9140beceae2c29bfde08d2b6d80b33067451c5887be88ac00000000';
var tx = new flocore.Transaction(txHex); var tx = new flocore.Transaction(txHex);
var sats = tx.outputs[0].satoshis; var sats = tx.outputs[0].satoshis;
var satsBuf = new Buffer(8); var satsBuf = Buffer.alloc(8);
satsBuf.writeDoubleBE(sats); satsBuf.writeDoubleBE(sats);
var utxoValueBuf = Buffer.concat([new Buffer('00000001', 'hex'), satsBuf, tsBuf, tx.outputs[0]._scriptBuffer]); var utxoValueBuf = Buffer.concat([Buffer.from('00000001', 'hex'), satsBuf, tsBuf, tx.outputs[0]._scriptBuffer]);
it('should encode address key' , function() { it('should encode address key' , function() {
encoding.encodeAddressIndexKey(address, height, txid, 0, 0, ts).should.deep.equal(addressIndexKeyBuf); encoding.encodeAddressIndexKey(address, height, txid, 0, 0, ts).should.deep.equal(addressIndexKeyBuf);

View File

@ -24,7 +24,7 @@ describe('Address Service', function() {
services: [] services: []
} }
}); });
addressService._encoding = new Encoding(new Buffer('0000', 'hex')); addressService._encoding = new Encoding(Buffer.from('0000', 'hex'));
}); });
afterEach(function() { afterEach(function() {
@ -34,7 +34,7 @@ describe('Address Service', function() {
describe('#start', function() { describe('#start', function() {
it('should get prefix for database', function(done) { it('should get prefix for database', function(done) {
var getPrefix = sandbox.stub().callsArgWith(1, null, new Buffer('ffee', 'hex')); var getPrefix = sandbox.stub().callsArgWith(1, null, Buffer.from('ffee', 'hex'));
addressService._db = { getPrefix: getPrefix }; addressService._db = { getPrefix: getPrefix };
addressService.start(function() { addressService.start(function() {
expect(getPrefix.calledOnce).to.be.true; expect(getPrefix.calledOnce).to.be.true;
@ -355,7 +355,7 @@ describe('Address Service', function() {
describe('#getAddressUnspentOutputs', function() { describe('#getAddressUnspentOutputs', function() {
it('should get address utxos', function(done) { it('should get address utxos', function(done) {
var encoding = new Encoding(new Buffer('0001', 'hex')); var encoding = new Encoding(Buffer.from('0001', 'hex'));
addressService._encoding = encoding; addressService._encoding = encoding;
var address = 'a'; var address = 'a';

View File

@ -7,7 +7,7 @@ var Encoding = require('../../../lib/services/block/encoding');
describe('Block service encoding', function() { describe('Block service encoding', function() {
var servicePrefix = new Buffer('0000', 'hex'); var servicePrefix = Buffer.from('0000', 'hex');
var encoding = new Encoding(servicePrefix); var encoding = new Encoding(servicePrefix);
var hash = '91b58f19b6eecba94ed0f6e463e8e334ec0bcda7880e2985c82a8f32e4d03add'; var hash = '91b58f19b6eecba94ed0f6e463e8e334ec0bcda7880e2985c82a8f32e4d03add';
@ -19,14 +19,14 @@ describe('Block service encoding', function() {
it('should encode block key' , function() { it('should encode block key' , function() {
encoding.encodeBlockKey(hash).should.deep.equal(Buffer.concat([ encoding.encodeBlockKey(hash).should.deep.equal(Buffer.concat([
servicePrefix, servicePrefix,
new Buffer(hash, 'hex') Buffer.from(hash, 'hex')
])); ]));
}); });
it('should decode block key' , function() { it('should decode block key' , function() {
var buf = Buffer.concat([ var buf = Buffer.concat([
servicePrefix, servicePrefix,
new Buffer(hash, 'hex') Buffer.from(hash, 'hex')
]); ]);
var actual = encoding.decodeBlockKey(buf); var actual = encoding.decodeBlockKey(buf);

View File

@ -23,7 +23,7 @@ describe('Block Service', function() {
services: [] services: []
} }
}); });
blockService._encoding = new Encoding(new Buffer('0000', 'hex')); blockService._encoding = new Encoding(Buffer.from('0000', 'hex'));
}); });
afterEach(function() { afterEach(function() {

View File

@ -121,7 +121,7 @@ describe('DB', function() {
it('should put a value in the db', function(done) { it('should put a value in the db', function(done) {
var put = sandbox.stub().callsArgWith(2, null); var put = sandbox.stub().callsArgWith(2, null);
dbService._store = { put: put }; dbService._store = { put: put };
dbService.put(new Buffer('key'), new Buffer('value'), function(err) { dbService.put(Buffer.from('key'), Buffer.from('value'), function(err) {
if (err) { if (err) {
return done(err); return done(err);
} }
@ -132,7 +132,7 @@ describe('DB', function() {
it('should not allow an operation while the node is shutting down', function(done) { it('should not allow an operation while the node is shutting down', function(done) {
dbService._stopping = true; dbService._stopping = true;
dbService.put(new Buffer('key'), new Buffer('value'), function(err) { dbService.put(Buffer.from('key'), Buffer.from('value'), function(err) {
done(); done();
}); });
}); });
@ -256,7 +256,7 @@ describe('DB', function() {
describe('#getServiceTip', function() { describe('#getServiceTip', function() {
it('should get service tip for previously saved', function(done) { it('should get service tip for previously saved', function(done) {
var tipBuf = Buffer.concat([ new Buffer('deadbeef', 'hex'), new Buffer(tx.txid(), 'hex') ]); var tipBuf = Buffer.concat([ Buffer.from('deadbeef', 'hex'), Buffer.from(tx.txid(), 'hex') ]);
var get = sandbox.stub(dbService, 'get').callsArgWith(1, null, tipBuf); var get = sandbox.stub(dbService, 'get').callsArgWith(1, null, tipBuf);
dbService.getServiceTip('test', function(err, tip) { dbService.getServiceTip('test', function(err, tip) {
@ -293,7 +293,7 @@ describe('DB', function() {
describe('#getPrefix', function() { describe('#getPrefix', function() {
it('should get the db prefix for a service when one already exists', function(done) { it('should get the db prefix for a service when one already exists', function(done) {
var get = sandbox.stub(dbService, 'get').callsArgWith(1, null, new Buffer('0000', 'hex')); var get = sandbox.stub(dbService, 'get').callsArgWith(1, null, Buffer.from('0000', 'hex'));
dbService.getPrefix('test', function(err, prefix) { dbService.getPrefix('test', function(err, prefix) {
if(err) { if(err) {
@ -310,7 +310,7 @@ describe('DB', function() {
var put = sandbox.stub(dbService, 'put').callsArgWith(2, null); var put = sandbox.stub(dbService, 'put').callsArgWith(2, null);
var get = sandbox.stub(dbService, 'get'); var get = sandbox.stub(dbService, 'get');
get.onCall(0).callsArgWith(1, null, null); get.onCall(0).callsArgWith(1, null, null);
get.onCall(1).callsArgWith(1, null, new Buffer('eeee', 'hex')); get.onCall(1).callsArgWith(1, null, Buffer.from('eeee', 'hex'));
dbService.getPrefix('test', function(err, prefix) { dbService.getPrefix('test', function(err, prefix) {
if(err) { if(err) {

View File

@ -6,13 +6,13 @@ var Encoding = require('../../../lib/services/header/encoding');
describe('Header service encoding', function() { describe('Header service encoding', function() {
var servicePrefix = new Buffer('0000', 'hex'); var servicePrefix = Buffer.from('0000', 'hex');
var hashPrefix = new Buffer('00', 'hex'); var hashPrefix = Buffer.from('00', 'hex');
var heightPrefix = new Buffer('01', 'hex'); var heightPrefix = Buffer.from('01', 'hex');
var encoding = new Encoding(servicePrefix); var encoding = new Encoding(servicePrefix);
var hash = '91b58f19b6eecba94ed0f6e463e8e334ec0bcda7880e2985c82a8f32e4d03add'; var hash = '91b58f19b6eecba94ed0f6e463e8e334ec0bcda7880e2985c82a8f32e4d03add';
var hashBuf = new Buffer(hash, 'hex'); var hashBuf = Buffer.from(hash, 'hex');
var header = { var header = {
hash: hash, hash: hash,
prevHash: '91b58f19b6eecba94ed0f6e463e8e334ec0bcda7880e2985c82a8f32e4d03ade', prevHash: '91b58f19b6eecba94ed0f6e463e8e334ec0bcda7880e2985c82a8f32e4d03ade',
@ -25,15 +25,15 @@ describe('Header service encoding', function() {
chainwork: '0000000000000000000000000000000000000000000000000000000200020002', chainwork: '0000000000000000000000000000000000000000000000000000000200020002',
nextHash: '91b58f19b6eecba94ed0f6e463e8e334ec0bcda7880e2985c82a8f32e4d03ade' nextHash: '91b58f19b6eecba94ed0f6e463e8e334ec0bcda7880e2985c82a8f32e4d03ade'
}; };
var versionBuf = new Buffer(4); var versionBuf = Buffer.alloc(4);
var prevHashBuf = new Buffer(header.prevHash, 'hex'); var prevHashBuf = Buffer.from(header.prevHash, 'hex');
var nextHashBuf = new Buffer(header.nextHash, 'hex'); var nextHashBuf = Buffer.from(header.nextHash, 'hex');
var merkleRootBuf = new Buffer(header.merkleRoot, 'hex'); var merkleRootBuf = Buffer.from(header.merkleRoot, 'hex');
var tsBuf = new Buffer(4); var tsBuf = Buffer.alloc(4);
var bitsBuf = new Buffer(4); var bitsBuf = Buffer.alloc(4);
var nonceBuf = new Buffer(4); var nonceBuf = Buffer.alloc(4);
var heightBuf = new Buffer(4); var heightBuf = Buffer.alloc(4);
var chainBuf = new Buffer('0000000000000000000000000000000000000000000000000000000200020002', 'hex'); var chainBuf = Buffer.from('0000000000000000000000000000000000000000000000000000000200020002', 'hex');
heightBuf.writeUInt32BE(header.height); heightBuf.writeUInt32BE(header.height);
it('should encode header hash key' , function() { it('should encode header hash key' , function() {
@ -54,7 +54,7 @@ describe('Header service encoding', function() {
.should.deep.equal(header.height); .should.deep.equal(header.height);
}); });
it('should encode header value', function() { it('should encode header value', function() {
var prevHashBuf = new Buffer(header.prevHash, 'hex'); var prevHashBuf = Buffer.from(header.prevHash, 'hex');
versionBuf.writeInt32BE(header.version); // signed versionBuf.writeInt32BE(header.version); // signed
tsBuf.writeUInt32BE(header.timestamp); tsBuf.writeUInt32BE(header.timestamp);
bitsBuf.writeUInt32BE(header.bits); bitsBuf.writeUInt32BE(header.bits);

View File

@ -16,8 +16,8 @@ describe('Header Service', function() {
var headerService; var headerService;
var sandbox; var sandbox;
var prevHeader = new Block(new Buffer('01000000b25c0849b469983b4a5b90a49e4c0e4ba3853122ed141b5bd92d14000000000021a8aaa4995e4ce3b885677730b153741feda66a08492287a45c6a131671ba5a72ff504c5a0c011c456e4d060201000000010000000000000000000000000000000000000000000000000000000000000000ffffffff08045a0c011c028208ffffffff0100f2052a010000004341041994d910507ec4b2135dd32a4723caf00f8567f356ffbd5e703786d856b49a89d6597c280d8981238fbde81fa3767161bc3e994c17be41b42235a61c24c73459ac0000000001000000013b517d1aebd89b4034e0cf9b25ecbe82ef162ce71284e92a1f1adebf44ea1409000000008b483045022100c7ebc62e89740ddab42a64435c996e1c91a063f9f2cc004b4f023f7a1be5234402207608837faebec16049461d4ef7de807ce217040fd2a823a29da16ec07e463d440141048f108c0da4b5be3308e2e0b521d02d341de85b36a29285b47f00bc33e57a89cf4b6e76aa4a48ddc9a5e882620779e0f1b19dc98d478052fbd544167c745be1d8ffffffff010026e85a050000001976a914f760ef90462b0a4bde26d597c1f29324f5cd0fc488ac00000000', 'hex')).header.toObject(); var prevHeader = new Block(Buffer.from('01000000b25c0849b469983b4a5b90a49e4c0e4ba3853122ed141b5bd92d14000000000021a8aaa4995e4ce3b885677730b153741feda66a08492287a45c6a131671ba5a72ff504c5a0c011c456e4d060201000000010000000000000000000000000000000000000000000000000000000000000000ffffffff08045a0c011c028208ffffffff0100f2052a010000004341041994d910507ec4b2135dd32a4723caf00f8567f356ffbd5e703786d856b49a89d6597c280d8981238fbde81fa3767161bc3e994c17be41b42235a61c24c73459ac0000000001000000013b517d1aebd89b4034e0cf9b25ecbe82ef162ce71284e92a1f1adebf44ea1409000000008b483045022100c7ebc62e89740ddab42a64435c996e1c91a063f9f2cc004b4f023f7a1be5234402207608837faebec16049461d4ef7de807ce217040fd2a823a29da16ec07e463d440141048f108c0da4b5be3308e2e0b521d02d341de85b36a29285b47f00bc33e57a89cf4b6e76aa4a48ddc9a5e882620779e0f1b19dc98d478052fbd544167c745be1d8ffffffff010026e85a050000001976a914f760ef90462b0a4bde26d597c1f29324f5cd0fc488ac00000000', 'hex')).header.toObject();
var preObjectHeader = new Block(new Buffer('010000006a39821735ec18a366d95b391a7ff10dee181a198f1789b0550e0d00000000002b0c80fa52b669022c344c3e09e6bb9698ab90707bb4bb412af3fbf31cfd2163a601514c5a0c011c572aef0f0101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff08045a0c011c022003ffffffff0100f2052a01000000434104c5b694d72e601091fd733c6b18b94795c13e2db6b1474747e7be914b407854cad37cee3058f85373b9f9dbb0014e541c45851d5f85e83a1fd7c45e54423718f3ac00000000', 'hex')).header; var preObjectHeader = new Block(Buffer.from('010000006a39821735ec18a366d95b391a7ff10dee181a198f1789b0550e0d00000000002b0c80fa52b669022c344c3e09e6bb9698ab90707bb4bb412af3fbf31cfd2163a601514c5a0c011c572aef0f0101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff08045a0c011c022003ffffffff0100f2052a01000000434104c5b694d72e601091fd733c6b18b94795c13e2db6b1474747e7be914b407854cad37cee3058f85373b9f9dbb0014e541c45851d5f85e83a1fd7c45e54423718f3ac00000000', 'hex')).header;
var header = preObjectHeader.toObject(); var header = preObjectHeader.toObject();
beforeEach(function() { beforeEach(function() {
sandbox = sinon.sandbox.create(); sandbox = sinon.sandbox.create();
@ -26,7 +26,7 @@ describe('Header Service', function() {
services: [] services: []
} }
}); });
headerService._encoding = new Encoding(new Buffer('0000', 'hex')); headerService._encoding = new Encoding(Buffer.from('0000', 'hex'));
}); });
afterEach(function() { afterEach(function() {
@ -40,7 +40,7 @@ describe('Header Service', function() {
var getServiceTip = sandbox.stub().callsArgWith(1, null, { height: 123, hash: 'a' }); var getServiceTip = sandbox.stub().callsArgWith(1, null, { height: 123, hash: 'a' });
var setListeners = sandbox.stub(headerService, '_setListeners'); var setListeners = sandbox.stub(headerService, '_setListeners');
var getPrefix = sandbox.stub().callsArgWith(1, null, new Buffer('ffee', 'hex')); var getPrefix = sandbox.stub().callsArgWith(1, null, Buffer.from('ffee', 'hex'));
var adjustHeadersForCheckPointTip = sandbox.stub(headerService, '_adjustHeadersForCheckPointTip').callsArgWith(0, null); var adjustHeadersForCheckPointTip = sandbox.stub(headerService, '_adjustHeadersForCheckPointTip').callsArgWith(0, null);
var setGenesisBlock = sandbox.stub(headerService, '_setGenesisBlock').callsArgWith(0, null); var setGenesisBlock = sandbox.stub(headerService, '_setGenesisBlock').callsArgWith(0, null);
headerService.GENESIS_HASH = '00'; headerService.GENESIS_HASH = '00';
@ -159,8 +159,8 @@ describe('Header Service', function() {
describe('#_computeChainwork', function() { describe('#_computeChainwork', function() {
it('should calculate chain work correctly', function() { it('should calculate chain work correctly', function() {
var expected = new BN(new Buffer('000000000000000000000000000000000000000000677c7b8122f9902c79f4e0', 'hex')); var expected = new BN(Buffer.from('000000000000000000000000000000000000000000677c7b8122f9902c79f4e0', 'hex'));
var prev = new BN(new Buffer('000000000000000000000000000000000000000000677bd68118a98f8779ea90', 'hex')); var prev = new BN(Buffer.from('000000000000000000000000000000000000000000677bd68118a98f8779ea90', 'hex'));
var actual = headerService._computeChainwork(0x18018d30, prev); var actual = headerService._computeChainwork(0x18018d30, prev);
assert(actual.eq(expected), 'not equal: actual: ' + actual + ' expected: ' + expected); assert(actual.eq(expected), 'not equal: actual: ' + actual + ' expected: ' + expected);

View File

@ -7,36 +7,36 @@ var Encoding = require('../../../lib/services/mempool/encoding');
describe('Block service encoding', function() { describe('Block service encoding', function() {
var servicePrefix = new Buffer('0000', 'hex'); var servicePrefix = Buffer.from('0000', 'hex');
var txPrefix = new Buffer('00', 'hex'); var txPrefix = Buffer.from('00', 'hex');
var addressPrefix = new Buffer('01', 'hex'); var addressPrefix = Buffer.from('01', 'hex');
var encoding = new Encoding(servicePrefix); var encoding = new Encoding(servicePrefix);
var hash = '25e28f9fb0ada5353b7d98d85af5524b2f8df5b0b0e2d188f05968bceca603eb'; var hash = '25e28f9fb0ada5353b7d98d85af5524b2f8df5b0b0e2d188f05968bceca603eb';
var txString = '0100000004de9b4bb17f627096a9ee0b4528e4eae17df5b5c69edc29704c2e84a7371db29f010000006b483045022100f5b1a0d33b7be291c3953c25f8ae39d98601aa7099a8674daf638a08b86c7173022006ce372da5ad088a1cc6e5c49c2760a1b6f085eb1b51b502211b6bc9508661f9012102ec5e3731e54475dd2902326f43602a03ae3d62753324139163f81f20e787514cffffffff7a1d4e5fc2b8177ec738cd723a16cf2bf493791e55573445fc0df630fe5e2d64010000006b483045022100cf97f6cb8f126703e9768545dfb20ffb10ba78ae3d101aa46775f5a239b075fc02203150c4a89a11eaf5e404f4f96b62efa4455e9525765a025525c7105a7e47b6db012102c01e11b1d331f999bbdb83e8831de503cd52a01e3834a95ccafd615c67703d77ffffffff9e52447116415ca0d0567418a1a4ef8f27be3ff5a96bf87c922f3723d7db5d7c000000006b483045022100f6c117e536701be41a6b0b544d7c3b1091301e4e64a6265b6eb167b15d16959d022076916de4b115e700964194ce36a24cb9105f86482f4abbc63110c3f537cd5770012102ddf84cc7bee2d6a82ac09628a8ad4a26cd449fc528b81e7e6cc615707b8169dfffffffff5815d9750eb3572e30d6fd9df7afb4dbd76e042f3aa4988ac763b3fdf8397f80010000006a473044022028f4402b736066d93d2a32b28ccd3b7a21d84bb58fcd07fe392a611db94cdec5022018902ee0bf2c3c840c1b81ead4e6c87c88c48b2005bf5eea796464e561a620a8012102b6cdd1a6cd129ef796faeedb0b840fcd0ca00c57e16e38e46ee7028d59812ae7ffffffff0220a10700000000001976a914c342bcd1a7784d9842f7386b8b3b8a3d4171a06e88ac59611100000000001976a91449f8c749a9960dc29b5cbe7d2397cea7d26611bb88ac00000000'; var txString = '0100000004de9b4bb17f627096a9ee0b4528e4eae17df5b5c69edc29704c2e84a7371db29f010000006b483045022100f5b1a0d33b7be291c3953c25f8ae39d98601aa7099a8674daf638a08b86c7173022006ce372da5ad088a1cc6e5c49c2760a1b6f085eb1b51b502211b6bc9508661f9012102ec5e3731e54475dd2902326f43602a03ae3d62753324139163f81f20e787514cffffffff7a1d4e5fc2b8177ec738cd723a16cf2bf493791e55573445fc0df630fe5e2d64010000006b483045022100cf97f6cb8f126703e9768545dfb20ffb10ba78ae3d101aa46775f5a239b075fc02203150c4a89a11eaf5e404f4f96b62efa4455e9525765a025525c7105a7e47b6db012102c01e11b1d331f999bbdb83e8831de503cd52a01e3834a95ccafd615c67703d77ffffffff9e52447116415ca0d0567418a1a4ef8f27be3ff5a96bf87c922f3723d7db5d7c000000006b483045022100f6c117e536701be41a6b0b544d7c3b1091301e4e64a6265b6eb167b15d16959d022076916de4b115e700964194ce36a24cb9105f86482f4abbc63110c3f537cd5770012102ddf84cc7bee2d6a82ac09628a8ad4a26cd449fc528b81e7e6cc615707b8169dfffffffff5815d9750eb3572e30d6fd9df7afb4dbd76e042f3aa4988ac763b3fdf8397f80010000006a473044022028f4402b736066d93d2a32b28ccd3b7a21d84bb58fcd07fe392a611db94cdec5022018902ee0bf2c3c840c1b81ead4e6c87c88c48b2005bf5eea796464e561a620a8012102b6cdd1a6cd129ef796faeedb0b840fcd0ca00c57e16e38e46ee7028d59812ae7ffffffff0220a10700000000001976a914c342bcd1a7784d9842f7386b8b3b8a3d4171a06e88ac59611100000000001976a91449f8c749a9960dc29b5cbe7d2397cea7d26611bb88ac00000000';
var address = '1234567'; var address = '1234567';
var now = Math.floor(Date.now() / 1000); var now = Math.floor(Date.now() / 1000);
var nowBuf = new Buffer(4); var nowBuf = Buffer.alloc(4);
nowBuf.writeUInt32BE(now); nowBuf.writeUInt32BE(now);
describe('Mempool', function() { describe('Mempool', function() {
it('should encode mempool transaction key', function() { it('should encode mempool transaction key', function() {
encoding.encodeMempoolTransactionKey(hash).should.deep.equal(Buffer.concat([ servicePrefix, txPrefix, new Buffer(hash, 'hex') ])); encoding.encodeMempoolTransactionKey(hash).should.deep.equal(Buffer.concat([ servicePrefix, txPrefix, Buffer.from(hash, 'hex') ]));
}); });
it('should decode mempool transaction key', function() { it('should decode mempool transaction key', function() {
encoding.decodeMempoolTransactionKey(Buffer.concat([ servicePrefix, txPrefix, new Buffer(hash, 'hex') ])).should.deep.equal(hash); encoding.decodeMempoolTransactionKey(Buffer.concat([ servicePrefix, txPrefix, Buffer.from(hash, 'hex') ])).should.deep.equal(hash);
}); });
it('should encode mempool transaction value', function() { it('should encode mempool transaction value', function() {
var mytx = tx.fromRaw(txString, 'hex'); var mytx = tx.fromRaw(txString, 'hex');
mytx.__inputValues = [1012955, 447698, 446664, 391348]; mytx.__inputValues = [1012955, 447698, 446664, 391348];
encoding.encodeMempoolTransactionValue(mytx).should.deep.equal(new Buffer(txString, 'hex')); encoding.encodeMempoolTransactionValue(mytx).should.deep.equal(Buffer.from(txString, 'hex'));
}); });
it('should decode mempool transaction value', function() { it('should decode mempool transaction value', function() {
var mytx = encoding.decodeMempoolTransactionValue(new Buffer(txString, 'hex')); var mytx = encoding.decodeMempoolTransactionValue(Buffer.from(txString, 'hex'));
mytx.should.deep.equal(tx.fromRaw(txString, 'hex')); mytx.should.deep.equal(tx.fromRaw(txString, 'hex'));
}); });
@ -46,11 +46,11 @@ describe('Block service encoding', function() {
.should.deep.equal(Buffer.concat([ .should.deep.equal(Buffer.concat([
servicePrefix, servicePrefix,
addressPrefix, addressPrefix,
new Buffer('07', 'hex'), Buffer.from('07', 'hex'),
new Buffer(address), Buffer.from(address),
new Buffer(hash, 'hex'), Buffer.from(hash, 'hex'),
new Buffer('00000000', 'hex'), Buffer.from('00000000', 'hex'),
new Buffer('01', 'hex') Buffer.from('01', 'hex')
])); ]));
}); });
@ -58,11 +58,11 @@ describe('Block service encoding', function() {
encoding.decodeMempoolAddressKey(Buffer.concat([ encoding.decodeMempoolAddressKey(Buffer.concat([
servicePrefix, servicePrefix,
addressPrefix, addressPrefix,
new Buffer('07', 'hex'), Buffer.from('07', 'hex'),
new Buffer(address), Buffer.from(address),
new Buffer(hash, 'hex'), Buffer.from(hash, 'hex'),
new Buffer('00000000', 'hex'), Buffer.from('00000000', 'hex'),
new Buffer('01', 'hex') ])).should.deep.equal({ Buffer.from('01', 'hex') ])).should.deep.equal({
address: address, address: address,
txid: hash, txid: hash,
index: 0, index: 0,

View File

@ -21,7 +21,7 @@ describe('Mempool Service', function() {
services: [] services: []
} }
}); });
mempoolService._encoding = new Encoding(new Buffer('0000', 'hex')); mempoolService._encoding = new Encoding(Buffer.from('0000', 'hex'));
}); });
afterEach(function() { afterEach(function() {
@ -31,7 +31,7 @@ describe('Mempool Service', function() {
describe('#start', function() { describe('#start', function() {
it('should get the db prefix', function(done) { it('should get the db prefix', function(done) {
var getPrefix = sandbox.stub().callsArgWith(1, null, new Buffer('0001', 'hex')); var getPrefix = sandbox.stub().callsArgWith(1, null, Buffer.from('0001', 'hex'));
mempoolService._db = { getPrefix: getPrefix }; mempoolService._db = { getPrefix: getPrefix };
mempoolService.start(function() { mempoolService.start(function() {

View File

@ -5,21 +5,21 @@ var Encoding = require('../../../lib/services/timestamp/encoding');
describe('Timestamp service encoding', function() { describe('Timestamp service encoding', function() {
var servicePrefix = new Buffer('0000', 'hex'); var servicePrefix = Buffer.from('0000', 'hex');
var blockPrefix = new Buffer('00', 'hex'); var blockPrefix = Buffer.from('00', 'hex');
var timestampPrefix = new Buffer('01', 'hex'); var timestampPrefix = Buffer.from('01', 'hex');
var encoding = new Encoding(servicePrefix); var encoding = new Encoding(servicePrefix);
var blockhash = '00000000000000000115b92b1ff4377441049bff75c6c48b626eb99e8b744297'; var blockhash = '00000000000000000115b92b1ff4377441049bff75c6c48b626eb99e8b744297';
var timestamp = 5; var timestamp = 5;
var timestampBuf = new Buffer(4); var timestampBuf = Buffer.alloc(4);
timestampBuf.writeUInt32BE(timestamp); timestampBuf.writeUInt32BE(timestamp);
it('should encode block timestamp key' , function() { it('should encode block timestamp key' , function() {
encoding.encodeBlockTimestampKey(blockhash).should.deep.equal(Buffer.concat([servicePrefix, blockPrefix, new Buffer(blockhash, 'hex')])); encoding.encodeBlockTimestampKey(blockhash).should.deep.equal(Buffer.concat([servicePrefix, blockPrefix, Buffer.from(blockhash, 'hex')]));
}); });
it('should decode block timestamp key', function() { it('should decode block timestamp key', function() {
var blockTimestampKey = encoding.decodeBlockTimestampKey(Buffer.concat([servicePrefix, blockPrefix, new Buffer(blockhash, 'hex')])); var blockTimestampKey = encoding.decodeBlockTimestampKey(Buffer.concat([servicePrefix, blockPrefix, Buffer.from(blockhash, 'hex')]));
blockTimestampKey.should.equal(blockhash); blockTimestampKey.should.equal(blockhash);
}); });
@ -40,10 +40,10 @@ describe('Timestamp service encoding', function() {
}); });
it('should encode timestamp block value', function() { it('should encode timestamp block value', function() {
encoding.encodeTimestampBlockValue(blockhash).should.deep.equal(new Buffer(blockhash, 'hex')); encoding.encodeTimestampBlockValue(blockhash).should.deep.equal(Buffer.from(blockhash, 'hex'));
}); });
it('should decode timestamp block value', function() { it('should decode timestamp block value', function() {
encoding.decodeTimestampBlockValue(new Buffer(blockhash, 'hex')).should.equal(blockhash); encoding.decodeTimestampBlockValue(Buffer.from(blockhash, 'hex')).should.equal(blockhash);
}); });
}); });

View File

@ -6,24 +6,24 @@ var Encoding = require('../../../lib/services/transaction/encoding');
describe('Transaction service encoding', function() { describe('Transaction service encoding', function() {
var servicePrefix = new Buffer('0000', 'hex'); var servicePrefix = Buffer.from('0000', 'hex');
var encoding = new Encoding(servicePrefix); var encoding = new Encoding(servicePrefix);
var txid = '91b58f19b6eecba94ed0f6e463e8e334ec0bcda7880e2985c82a8f32e4d03add'; var txid = '91b58f19b6eecba94ed0f6e463e8e334ec0bcda7880e2985c82a8f32e4d03add';
var blockHash = txid; var blockHash = txid;
var txHex = '0100000001cc3ffe0638792c8b39328bb490caaefe2cf418f2ce0144956e0c22515f29724d010000006a473044022030ce9fa68d1a32abf0cd4adecf90fb998375b64fe887c6987278452b068ae74c022036a7d00d1c8af19e298e04f14294c807ebda51a20389ad751b4ff3c032cf8990012103acfcb348abb526526a9f63214639d79183871311c05b2eebc727adfdd016514fffffffff02f6ae7d04000000001976a9144455183e407ee4d3423858c8a3275918aedcd18e88aca99b9b08010000001976a9140beceae2c29bfde08d2b6d80b33067451c5887be88ac00000000'; var txHex = '0100000001cc3ffe0638792c8b39328bb490caaefe2cf418f2ce0144956e0c22515f29724d010000006a473044022030ce9fa68d1a32abf0cd4adecf90fb998375b64fe887c6987278452b068ae74c022036a7d00d1c8af19e298e04f14294c807ebda51a20389ad751b4ff3c032cf8990012103acfcb348abb526526a9f63214639d79183871311c05b2eebc727adfdd016514fffffffff02f6ae7d04000000001976a9144455183e407ee4d3423858c8a3275918aedcd18e88aca99b9b08010000001976a9140beceae2c29bfde08d2b6d80b33067451c5887be88ac00000000';
var tx = Tx.fromRaw(txHex, 'hex'); var tx = Tx.fromRaw(txHex, 'hex');
var txEncoded = Buffer.concat([new Buffer('00000002', 'hex'), new Buffer(blockHash, 'hex'), new Buffer('00000001', 'hex'), new Buffer('0002', 'hex'), new Buffer('40000000000000004008000000000000', 'hex'), tx.toRaw()]); var txEncoded = Buffer.concat([Buffer.from('00000002', 'hex'), Buffer.from(blockHash, 'hex'), Buffer.from('00000001', 'hex'), Buffer.from('0002', 'hex'), Buffer.from('40000000000000004008000000000000', 'hex'), tx.toRaw()]);
var indexBuf = new Buffer(4); var indexBuf = Buffer.alloc(4);
indexBuf.writeUInt32BE(3); indexBuf.writeUInt32BE(3);
it('should encode transaction key' , function() { it('should encode transaction key' , function() {
var txBuf = new Buffer(txid, 'hex'); var txBuf = Buffer.from(txid, 'hex');
encoding.encodeTransactionKey(txid).should.deep.equal(Buffer.concat([servicePrefix, new Buffer('00', 'hex'), txBuf])); encoding.encodeTransactionKey(txid).should.deep.equal(Buffer.concat([servicePrefix, Buffer.from('00', 'hex'), txBuf]));
}); });
it('should decode transaction key', function() { it('should decode transaction key', function() {
encoding.decodeTransactionKey(Buffer.concat([servicePrefix, new Buffer('00', 'hex'), new Buffer(txid, 'hex')])) encoding.decodeTransactionKey(Buffer.concat([servicePrefix, Buffer.from('00', 'hex'), Buffer.from(txid, 'hex')]))
.should.equal(txid); .should.equal(txid);
}); });
@ -47,21 +47,21 @@ describe('Transaction service encoding', function() {
it('should encode spent key', function() { it('should encode spent key', function() {
encoding.encodeSpentKey(txid, 3).should.deep.equal(Buffer.concat([servicePrefix, encoding.encodeSpentKey(txid, 3).should.deep.equal(Buffer.concat([servicePrefix,
new Buffer('01', 'hex'), new Buffer(txid, 'hex'), indexBuf])); Buffer.from('01', 'hex'), Buffer.from(txid, 'hex'), indexBuf]));
}); });
it('should decode spent key', function() { it('should decode spent key', function() {
encoding.decodeSpentKey(Buffer.concat([servicePrefix, encoding.decodeSpentKey(Buffer.concat([servicePrefix,
new Buffer('01', 'hex'), new Buffer(txid, 'hex'), indexBuf])).should.deep.equal({ txid: txid, outputIndex: 3 }); Buffer.from('01', 'hex'), Buffer.from(txid, 'hex'), indexBuf])).should.deep.equal({ txid: txid, outputIndex: 3 });
}); });
it('should encode spent value', function() { it('should encode spent value', function() {
encoding.encodeSpentValue(txid, 3, 3, txid).should.deep.equal(Buffer.concat([new Buffer(txid, 'hex'), indexBuf, indexBuf, new Buffer(blockHash, 'hex')])); encoding.encodeSpentValue(txid, 3, 3, txid).should.deep.equal(Buffer.concat([Buffer.from(txid, 'hex'), indexBuf, indexBuf, Buffer.from(blockHash, 'hex')]));
}); });
it('should decode spent value', function() { it('should decode spent value', function() {
encoding.decodeSpentValue(Buffer.concat([new Buffer(txid, 'hex'), indexBuf, encoding.decodeSpentValue(Buffer.concat([Buffer.from(txid, 'hex'), indexBuf,
indexBuf, new Buffer(blockHash, 'hex')])) indexBuf, Buffer.from(blockHash, 'hex')]))
.should.deep.equal({ txid: txid, inputIndex: 3, blockHeight: 3, blockHash: blockHash }); .should.deep.equal({ txid: txid, inputIndex: 3, blockHeight: 3, blockHash: blockHash });
}); });
}); });

View File

@ -21,7 +21,7 @@ describe('Transaction Service', function() {
services: [] services: []
} }
}); });
txService._encoding = new Encoding(new Buffer('0000', 'hex')); txService._encoding = new Encoding(Buffer.from('0000', 'hex'));
}); });
afterEach(function() { afterEach(function() {
@ -30,7 +30,7 @@ describe('Transaction Service', function() {
describe('#start', function() { describe('#start', function() {
it('should get the prefix and the service tip', function(done) { it('should get the prefix and the service tip', function(done) {
var getPrefix = sandbox.stub().callsArgWith(1, null, new Buffer('ffee', 'hex')); var getPrefix = sandbox.stub().callsArgWith(1, null, Buffer.from('ffee', 'hex'));
txService._db = { getPrefix: getPrefix }; txService._db = { getPrefix: getPrefix };
txService.start(function() { txService.start(function() {
getPrefix.calledOnce.should.be.true; getPrefix.calledOnce.should.be.true;

View File

@ -39,13 +39,13 @@ describe('Utils', function() {
describe('#getTerminalKey', function() { describe('#getTerminalKey', function() {
it('should get the terminal key for a buffer', function() { it('should get the terminal key for a buffer', function() {
utils.getTerminalKey(new Buffer('ffff', 'hex')) utils.getTerminalKey(Buffer.from('ffff', 'hex'))
.should.deep.equal(new Buffer('010000', 'hex')); .should.deep.equal(Buffer.from('010000', 'hex'));
}); });
it('should get the terminal key for a large buffer', function() { it('should get the terminal key for a large buffer', function() {
utils.getTerminalKey(Buffer.concat([ new Buffer(new Array(64).join('f'), 'hex'), new Buffer('fe', 'hex') ])) utils.getTerminalKey(Buffer.concat([ Buffer.from(new Array(64).join('f'), 'hex'), Buffer.from('fe', 'hex') ]))
.should.deep.equal(new Buffer('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 'hex')); .should.deep.equal(Buffer.from('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 'hex'));
}); });
}); });
@ -91,8 +91,8 @@ describe('Utils', function() {
it('should encode tip', function() { it('should encode tip', function() {
var res = utils.encodeTip({ height: 0xdeadbeef, hash: new Array(65).join('0') }, 'test'); var res = utils.encodeTip({ height: 0xdeadbeef, hash: new Array(65).join('0') }, 'test');
res.should.deep.equal({ res.should.deep.equal({
key: new Buffer('ffff7469702d74657374', 'hex'), key: Buffer.from('ffff7469702d74657374', 'hex'),
value: new Buffer('deadbeef00000000000000000000000000000000000000000000000000000000000000000', 'hex') value: Buffer.from('deadbeef00000000000000000000000000000000000000000000000000000000000000000', 'hex')
}); });
}); });
}); });