Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Convert hash160 hex strings to bitcoin bae58 address
package main
import (
const hash160Length = 40
func main() {
if len(os.Args) < 2 {
log.Fatal("Please provide filename with one hash160 hex strings on each line")
arg := os.Args[1]
// Open the file.
file, err := os.Open(arg)
if err != nil {
// Create a new Scanner for the file.
scanner := bufio.NewScanner(file)
// Loop over all lines in the file
for scanner.Scan() {
line := scanner.Text()
// Check if length is correct
if len(line) != hash160Length {
// Decode, and ignore errors
decoded, err := hex.DecodeString(line)
if err != nil {
base58 := base58.CheckEncode(decoded, 0x00)
fmt.Printf("%s\n", base58)

This comment has been minimized.

Copy link

Uvname commented Sep 15, 2019

Hello, please tell me how to run it?


This comment has been minimized.

Copy link
Owner Author

mathiasrw commented Sep 15, 2019

Build it with go and run it with a filename as parameter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.