How to determine right address from address hash I'm using private libbitcoin server and libbitcoin explorer.
When I use bx fetxh-transaction, it returns something like: 



I'm trying to figure out, how to get right address from address_hash.
When I use bx base58check-encode for input address_hash without version (or -v 0) it returns:



When I use bx base58check-encode -v 5 it returns:



Check by blockexplorer shows the second way is right.
My question is: How to determine base58check-encode version to generate right address?

Thank you.
Your address 32feVAD9Haq1CtfT6JCLTt4L5qef3UnVpY is a P2SH mainnet address, with a 05 address prefix and represents the base58 encoding of the following data:


[05][20-byte hash][4-byte checksum]


So, the [05] prefix tells your wallet that your address represents a P2SH embedded script presage (20B). 

On the other hand, a [00] prefix tells your wallet that the 20B digest represents a Public-Key-Hash, and that funds should be sent to a P2PKH (Pay-2-Public-Key-Hash) output.

The version number therefore gives your wallet the necessary information to produce the correct output type when sending funds, so that the recipient has the private keys (P2PKH) or presage (P2SH) to spend them. 

The 05 prefix translates to a 3 in base58 encoding, which is why your addresses begin with 3. I cannot comment on what the embedded script type is though, since the P2SH has is simply the 20B hash-digest thereof. Perhaps a P2SH(P2WPKH) script type.

Amended Answer:

To determine the address version appropriate for a specific output from a transaction, simply look at the output script in question.


P2PKH: "hash160 [20B] equal" -> version 5
P2SH: "dup hash160 [20B] equalverify checksig" -> version 0
P2WPKH: "[00] [20B]" -> bech32 address