From 3a6b90f1dddb1bc87a74156ab7b1ed5001ef72d5 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Tue, 13 May 2014 17:31:35 -0300 Subject: [PATCH] update to bitcore 0.1.19 --- lib/TransactionDb.js | 44 ++------------------------------------------ 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/lib/TransactionDb.js b/lib/TransactionDb.js index dfa7ef2a..bbc56225 100644 --- a/lib/TransactionDb.js +++ b/lib/TransactionDb.js @@ -452,46 +452,6 @@ TransactionDb.prototype.removeFromTxId = function(txid, cb) { }; - -// TODO. replace with -// Script.prototype.getAddrStrs if that one get merged in bitcore -TransactionDb.prototype.getAddrStr = function(s) { - var self = this; - - var addrStrs = []; - var type = s.classify(); - var addr; - - switch (type) { - case Script.TX_PUBKEY: - var chunk = s.captureOne(); - addr = new Address(self.network.addressVersion, bitcore.util.sha256ripe160(chunk)); - addrStrs.push(addr.toString()); - break; - case Script.TX_PUBKEYHASH: - addr = new Address(self.network.addressVersion, s.captureOne()); - addrStrs.push(addr.toString()); - break; - case Script.TX_SCRIPTHASH: - addr = new Address(self.network.addressVersion, s.captureOne()); - addrStrs.push(addr.toString()); - break; - case Script.TX_MULTISIG: - var chunks = s.capture(); - chunks.forEach(function(chunk) { - if (chunk && Buffer.isBuffer(chunk)) { - var a = new Address(self.network.addressVersion, bitcore.util.sha256ripe160(chunk)); - addrStrs.push(a.toString()); - } - }); - break; - case Script.TX_UNKNOWN: - break; - } - - return addrStrs; -}; - TransactionDb.prototype.adaptTxObject = function(txInfo) { var self = this; // adapt bitcore TX object to bitcoind JSON response @@ -503,11 +463,11 @@ TransactionDb.prototype.adaptTxObject = function(txInfo) { if (tx.outs) { tx.outs.forEach(function(o) { var s = new Script(o.s); - var addrs = self.getAddrStr(s); + var addrs = new Address.fromScriptPubKey(s, config.network); // support only for p2pubkey p2pubkeyhash and p2sh if (addrs.length === 1) { - tx.out[to].addrStr = addrs[0]; + tx.out[to].addrStr = addrs[0].toString(); tx.out[to].n = to; } to++;