Ejemplo n.º 1
0
func PublicKeyToBitcoinAddress(addrVersion byte, pubkey []byte) string {
	digest := Digest160(pubkey)

	bytes := append(make([]byte, 0, 21), addrVersion)
	bytes = append(bytes, digest...) // Prepend network id byte

	check := Digest256(bytes)

	return string(base58.EncodeBase58(append(bytes, check[0:4]...)))
}
Ejemplo n.º 2
0
func EncodeWIF(version byte, payload []byte) (string, error) {
	// Prepend version byte
	data := append(make([]byte, 0, len(payload)+5), version)
	data = append(data, payload...)

	check := Digest256(data)

	// append checksum
	data = append(data, check[0:4]...)
	return string(base58.EncodeBase58(data)), nil
}