txdb: fix conf calculation.
This commit is contained in:
parent
e9fc3c816a
commit
37e3219c4c
@ -3089,6 +3089,8 @@ function Details(txdb, tx, height) {
|
|||||||
this.wid = this.wallet.wid;
|
this.wid = this.wallet.wid;
|
||||||
this.id = this.wallet.id;
|
this.id = this.wallet.id;
|
||||||
|
|
||||||
|
this.chainHeight = height;
|
||||||
|
|
||||||
this.hash = tx.hash('hex');
|
this.hash = tx.hash('hex');
|
||||||
this.tx = tx;
|
this.tx = tx;
|
||||||
|
|
||||||
@ -3096,7 +3098,6 @@ function Details(txdb, tx, height) {
|
|||||||
this.height = tx.height;
|
this.height = tx.height;
|
||||||
this.ts = tx.ts;
|
this.ts = tx.ts;
|
||||||
this.index = tx.index;
|
this.index = tx.index;
|
||||||
this.confirmations = tx.getConfirmations(height);
|
|
||||||
|
|
||||||
this.ps = tx.ps;
|
this.ps = tx.ps;
|
||||||
|
|
||||||
@ -3167,6 +3168,20 @@ Details.prototype.setOutput = function setOutput(i, path) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate confirmations.
|
||||||
|
* @returns {Number}
|
||||||
|
*/
|
||||||
|
|
||||||
|
Details.prototype.getConfirmations = function getConfirmations() {
|
||||||
|
var depth = this.chainHeight - this.height;
|
||||||
|
|
||||||
|
if (depth < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return depth + 1;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate fee. Only works if wallet
|
* Calculate fee. Only works if wallet
|
||||||
* owns all inputs. Returns 0 otherwise.
|
* owns all inputs. Returns 0 otherwise.
|
||||||
@ -3205,6 +3220,7 @@ Details.prototype.toJSON = function toJSON() {
|
|||||||
return {
|
return {
|
||||||
wid: this.wid,
|
wid: this.wid,
|
||||||
id: this.id,
|
id: this.id,
|
||||||
|
chainHeight: this.chainHeight,
|
||||||
hash: utils.revHex(this.hash),
|
hash: utils.revHex(this.hash),
|
||||||
height: this.height,
|
height: this.height,
|
||||||
block: this.block ? utils.revHex(this.block) : null,
|
block: this.block ? utils.revHex(this.block) : null,
|
||||||
@ -3212,7 +3228,7 @@ Details.prototype.toJSON = function toJSON() {
|
|||||||
ps: this.ps,
|
ps: this.ps,
|
||||||
index: this.index,
|
index: this.index,
|
||||||
fee: utils.btc(this.getFee()),
|
fee: utils.btc(this.getFee()),
|
||||||
confirmations: this.confirmations,
|
confirmations: this.getConfirmations(),
|
||||||
inputs: this.inputs.map(function(input) {
|
inputs: this.inputs.map(function(input) {
|
||||||
return input.toJSON(self.network);
|
return input.toJSON(self.network);
|
||||||
}),
|
}),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user