File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -18,8 +18,8 @@ function fromBase58Check (address) {
1818function fromOutputScript ( scriptPubKey , network ) {
1919 network = network || networks . bitcoin
2020
21- if ( bscript . isPubKeyHashOutput ( scriptPubKey ) ) return toBase58Check ( scriptPubKey . slice ( 3 , 23 ) , network . pubKeyHash )
22- if ( bscript . isScriptHashOutput ( scriptPubKey ) ) return toBase58Check ( scriptPubKey . slice ( 2 , 22 ) , network . scriptHash )
21+ if ( bscript . isPubKeyHashOutput ( scriptPubKey ) ) return toBase58Check ( bscript . compile ( scriptPubKey ) . slice ( 3 , 23 ) , network . pubKeyHash )
22+ if ( bscript . isScriptHashOutput ( scriptPubKey ) ) return toBase58Check ( bscript . compile ( scriptPubKey ) . slice ( 2 , 22 ) , network . scriptHash )
2323
2424 throw new Error ( bscript . toASM ( scriptPubKey ) + ' has no matching Address' )
2525}
Original file line number Diff line number Diff line change @@ -36,6 +36,15 @@ describe('address', function () {
3636 } )
3737 } )
3838
39+ fixtures . valid . forEach ( function ( f ) {
40+ it ( 'parses (as chunks) ' + f . script . slice ( 0 , 30 ) + '... (' + f . network + ')' , function ( ) {
41+ var chunks = bscript . decompile ( bscript . fromASM ( f . script ) )
42+ var address = baddress . fromOutputScript ( chunks , networks [ f . network ] )
43+
44+ assert . strictEqual ( address , f . base58check )
45+ } )
46+ } )
47+
3948 fixtures . invalid . fromOutputScript . forEach ( function ( f ) {
4049 it ( 'throws when ' + f . script . slice ( 0 , 30 ) + '... ' + f . exception , function ( ) {
4150 var script = bscript . fromASM ( f . script )
You can’t perform that action at this time.
0 commit comments