File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 106106 return coinjs . base58encode ( r . concat ( checksum ) ) ;
107107 }
108108
109+ /* provide a redeemscript and return address */
110+ coinjs . redeemscript2address = function ( h ) {
111+ var r = ripemd160 ( Crypto . SHA256 ( Crypto . util . hexToBytes ( h ) , { asBytes : true } ) ) ;
112+ r . unshift ( coinjs . multisig ) ;
113+ var hash = Crypto . SHA256 ( Crypto . SHA256 ( r , { asBytes : true } ) , { asBytes : true } ) ;
114+ var checksum = hash . slice ( 0 , 4 ) ;
115+ return coinjs . base58encode ( r . concat ( checksum ) ) ;
116+ }
117+
109118 /* provide a scripthash and return address */
110119 coinjs . scripthash2address = function ( h ) {
111120 var x = Crypto . util . hexToBytes ( h ) ;
10371046 if ( utxo_script [ 'type' ] == 'scriptpubkey' ) {
10381047 address = coinjs . scripthash2address ( utxo_script [ 'script' ] . slice ( 6 , 46 ) ) ;
10391048 } else if ( utxo_script [ 'type' ] == 'multisig' ) {
1040- address = coinjs . pubkey2address ( utxo_script [ 'script' ] ) ; // hash the redeemscript
1049+ address = coinjs . redeemscript2address ( utxo_script [ 'script' ] ) ; // hash the redeemscript
10411050 } else if ( utxo_script [ 'type' ] == 'hodl' ) {
10421051 alert ( 'Bitcoin Cash hodl addresses not supported yet. Sorry.' ) ;
10431052 return false ;
You can’t perform that action at this time.
0 commit comments