add rblock and rhash helpers.

This commit is contained in:
Christopher Jeffrey 2015-12-22 02:15:33 -08:00
parent 52b653083c
commit 68c16b214a
3 changed files with 15 additions and 1 deletions

View File

@ -288,6 +288,10 @@ Block.prototype.getNextBlock = function getNextBlock(chain) {
return this._nextBlock = next;
};
Block.prototype.__defineGetter__('rblock', function() {
return utils.revHex(this.hash('hex'));
});
Block.prototype.toJSON = function toJSON() {
return {
v: '1',

View File

@ -607,7 +607,7 @@ Chain.prototype.getHeight = function getHeight(hash) {
i = this.index.hashes.indexOf(hash);
height = this.index.heights[i];
if (height === null)
if (height == null)
return -1;
return height;

View File

@ -1164,6 +1164,16 @@ TX.prototype.getConfirmations = function getConfirmations(chain) {
return top - height + 1;
};
TX.prototype.__defineGetter__('rblock', function() {
return this.block
? utils.revHex(this.block)
: null;
});
TX.prototype.__defineGetter__('rhash', function() {
return utils.revHex(this.hash('hex'));
});
TX.prototype.toJSON = function toJSON() {
// Compact representation
return {