Skip to content

Commit e0ea644

Browse files
committed
Merge pull request #76 from matiu/bug/fix-unconfirmed-tx2
update to bitcore 0.1.19
2 parents dfddf83 + 3a6b90f commit e0ea644

File tree

1 file changed

+2
-42
lines changed

1 file changed

+2
-42
lines changed

lib/TransactionDb.js

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -452,46 +452,6 @@ TransactionDb.prototype.removeFromTxId = function(txid, cb) {
452452

453453
};
454454

455-
456-
// TODO. replace with
457-
// Script.prototype.getAddrStrs if that one get merged in bitcore
458-
TransactionDb.prototype.getAddrStr = function(s) {
459-
var self = this;
460-
461-
var addrStrs = [];
462-
var type = s.classify();
463-
var addr;
464-
465-
switch (type) {
466-
case Script.TX_PUBKEY:
467-
var chunk = s.captureOne();
468-
addr = new Address(self.network.addressVersion, bitcore.util.sha256ripe160(chunk));
469-
addrStrs.push(addr.toString());
470-
break;
471-
case Script.TX_PUBKEYHASH:
472-
addr = new Address(self.network.addressVersion, s.captureOne());
473-
addrStrs.push(addr.toString());
474-
break;
475-
case Script.TX_SCRIPTHASH:
476-
addr = new Address(self.network.addressVersion, s.captureOne());
477-
addrStrs.push(addr.toString());
478-
break;
479-
case Script.TX_MULTISIG:
480-
var chunks = s.capture();
481-
chunks.forEach(function(chunk) {
482-
if (chunk && Buffer.isBuffer(chunk)) {
483-
var a = new Address(self.network.addressVersion, bitcore.util.sha256ripe160(chunk));
484-
addrStrs.push(a.toString());
485-
}
486-
});
487-
break;
488-
case Script.TX_UNKNOWN:
489-
break;
490-
}
491-
492-
return addrStrs;
493-
};
494-
495455
TransactionDb.prototype.adaptTxObject = function(txInfo) {
496456
var self = this;
497457
// adapt bitcore TX object to bitcoind JSON response
@@ -503,11 +463,11 @@ TransactionDb.prototype.adaptTxObject = function(txInfo) {
503463
if (tx.outs) {
504464
tx.outs.forEach(function(o) {
505465
var s = new Script(o.s);
506-
var addrs = self.getAddrStr(s);
466+
var addrs = new Address.fromScriptPubKey(s, config.network);
507467

508468
// support only for p2pubkey p2pubkeyhash and p2sh
509469
if (addrs.length === 1) {
510-
tx.out[to].addrStr = addrs[0];
470+
tx.out[to].addrStr = addrs[0].toString();
511471
tx.out[to].n = to;
512472
}
513473
to++;

0 commit comments

Comments
 (0)