From 5fb16543f1bb48c70aec597314793b70be5703ca Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 17 Dec 2016 14:40:03 -0800 Subject: [PATCH] chain: expose coins methods. --- lib/blockchain/chain.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/blockchain/chain.js b/lib/blockchain/chain.js index 5986c874..9b07b33b 100644 --- a/lib/blockchain/chain.js +++ b/lib/blockchain/chain.js @@ -1739,6 +1739,21 @@ Chain.prototype.getOrphan = function getOrphan(hash) { return this.orphan.bmap[hash] || null; }; +/** + * Get coin viewpoint. + * @param {TX} tx + * @returns {Promise} - Returns {@link CoinView}. + */ + +Chain.prototype.getCoinView = co(function* getCoinView(tx) { + var unlock = yield this.locker.lock(); + try { + return yield this.db.getCoinView(tx); + } finally { + unlock(); + } +}); + /** * Test the chain to see if it is synced. * @returns {Boolean}