@@ -452,46 +452,6 @@ TransactionDb.prototype.removeFromTxId = function(txid, cb) {
452
452
453
453
} ;
454
454
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
-
495
455
TransactionDb . prototype . adaptTxObject = function ( txInfo ) {
496
456
var self = this ;
497
457
// adapt bitcore TX object to bitcoind JSON response
@@ -503,11 +463,11 @@ TransactionDb.prototype.adaptTxObject = function(txInfo) {
503
463
if ( tx . outs ) {
504
464
tx . outs . forEach ( function ( o ) {
505
465
var s = new Script ( o . s ) ;
506
- var addrs = self . getAddrStr ( s ) ;
466
+ var addrs = new Address . fromScriptPubKey ( s , config . network ) ;
507
467
508
468
// support only for p2pubkey p2pubkeyhash and p2sh
509
469
if ( addrs . length === 1 ) {
510
- tx . out [ to ] . addrStr = addrs [ 0 ] ;
470
+ tx . out [ to ] . addrStr = addrs [ 0 ] . toString ( ) ;
511
471
tx . out [ to ] . n = to ;
512
472
}
513
473
to ++ ;
0 commit comments