How to convert script hash to base58 address?

1

For example :

take a look at this 37d1d453311ea5682cdb31468826178db15fa731722a5dbb09525ea901f1c41c scripthash.

I need help converting it to base58 address.

Thank you.

sujoshi

Posted 2018-09-08T15:33:06.060

Reputation: 65

Answers

1

Take your choice using bitcoin explorer (bx):

echo 37d1d453311ea5682cdb31468826178db15fa731722a5dbb09525ea901f1c41c | bx ec-to-public | bx sha256 | bx ripemd160 | bx base58check-encode -v 5

32BcK7C6FBCzzyB617gwTQuaLdbQufuAcc

% echo 37d1d453311ea5682cdb31468826178db15fa731722a5dbb09525ea901f1c41c | bx ec-to-public | bx bitcoin160 | bx base58check-encode -v 5

32BcK7C6FBCzzyB617gwTQuaLdbQufuAcc

% echo 37d1d453311ea5682cdb31468826178db15fa731722a5dbb09525ea901f1c41c | bx ec-to-public | bx ec-to-address -v 5

32BcK7C6FBCzzyB617gwTQuaLdbQufuAcc

skaht

Posted 2018-09-08T15:33:06.060

Reputation: 2 588

Hello Skaht, the expected result looks like a multisig address but that script belongs to non multisig address. Thanks.sujoshi 2018-09-08T16:20:14.617

Bitcoin P2SH and BIP 49 P2WPKH-nested-in-P2SH addresses both start with the number 3. Take a look at https://github.com/bitcoin/bitcoin/blob/master/src/chainparams.cpp#L132 to see why the version is set to 5. Also look at column 5 of this Table.

skaht 2018-09-08T17:24:43.663

To provide more context, it would not hurt to share the original script that was encoded and hashed to 37d1d453311ea5682cdb31468826178db15fa731722a5dbb09525ea901f1c41c. I'm not 100% certain I properly answered your question.skaht 2018-09-08T18:03:33.317

The answer might be simpler: % echo 37d1d453311ea5682cdb31468826178db15fa731722a5dbb09525ea901f1c41c | bx bitcoin160 | bx address-encode -v 5

3GRerFiaihoo7mwMBix6Xojtff46HBNtnBskaht 2018-09-08T18:09:45.340

Or: % echo 37d1d453311ea5682cdb31468826178db15fa731722a5dbb09525ea901f1c41c | bx ripemd160 | bx address-encode -v 5 This is most likely the answer without knowing more. 3JSbrUCtDBzWGVWjZ5rFDxBh2Kzhszor9Uskaht 2018-09-08T18:17:28.067

Hello Skaht, thank you very much for understanding the issue. Heres an example: scripthash: 47e414636b2d5675ce1ef1459775792d9bee689f0b97b0a43f92a69cc3db4845 address : 19pTZUvpBt5EXPJSVjp56YA6AzUazNFGdi , i'm still trying to get that from your steps. :Dsujoshi 2018-09-08T19:16:29.087

What is the script before it gets hashed?skaht 2018-09-09T03:45:53.823