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.id = this.wallet.id;
|
||||
|
||||
this.chainHeight = height;
|
||||
|
||||
this.hash = tx.hash('hex');
|
||||
this.tx = tx;
|
||||
|
||||
@ -3096,7 +3098,6 @@ function Details(txdb, tx, height) {
|
||||
this.height = tx.height;
|
||||
this.ts = tx.ts;
|
||||
this.index = tx.index;
|
||||
this.confirmations = tx.getConfirmations(height);
|
||||
|
||||
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
|
||||
* owns all inputs. Returns 0 otherwise.
|
||||
@ -3205,6 +3220,7 @@ Details.prototype.toJSON = function toJSON() {
|
||||
return {
|
||||
wid: this.wid,
|
||||
id: this.id,
|
||||
chainHeight: this.chainHeight,
|
||||
hash: utils.revHex(this.hash),
|
||||
height: this.height,
|
||||
block: this.block ? utils.revHex(this.block) : null,
|
||||
@ -3212,7 +3228,7 @@ Details.prototype.toJSON = function toJSON() {
|
||||
ps: this.ps,
|
||||
index: this.index,
|
||||
fee: utils.btc(this.getFee()),
|
||||
confirmations: this.confirmations,
|
||||
confirmations: this.getConfirmations(),
|
||||
inputs: this.inputs.map(function(input) {
|
||||
return input.toJSON(self.network);
|
||||
}),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user