Esempio n. 1
0
//BitcoinRipeMD160ToAddress takes 20 byte RipeMD160 hash and returns the 25-byte address as well as updates the address representation of the output
func BitcoinRipeMD160ToAddress(hash160 []byte, address *block.Address) []byte {
	ret := append([]byte{0}, hash160[:]...) //append network byte of 0 (main network) as checksum
	sha2 := sha256.New()
	sha2.Write(ret) //sha256 on ripemd hash
	hash3 := sha2.Sum(nil)
	sha3 := sha256.New()
	sha3.Write(hash3) // compute second hash to get checksum to store at end of output
	hash4 := sha3.Sum(nil)
	ret = append(ret[:], hash4[0:4]...)
	address.Address = BitcoinToASCII(ret)
	address.RipeMD160 = hex.EncodeToString(hash160)
	address.PublicKey = hex.EncodeToString(hash160)
	return ret

}