Base58check to decimal


(golangworld) #1

First Hello and thank you for any help you can give me .

here I have traveled google but I have not found my happiness . I would like to convert decimal number BASE58Check in my research but give nothing

example:
bitcoin address : 1HZwkjkeaoZfTSaJxDw6aKkxp45agDiEzN
In decimal : 1037542833334494436883955695059393877833907143043

Thank you in advance for your help.


Base58Check to Decimal
(Benjamin Radovsky) #2

Hey @golangworld, you can use a package such as https://github.com/tv42/base58 to encode and decode to and from base58. This was the first package I found on the https://golanglibs.com website, but I’m sure there are other ones available too.

Here’s an example for you:

package main

import (
	"fmt"
	"log"

	"github.com/tv42/base58"
)

func main() {
	// Address.
	addr := []byte("1HZwkjkeaoZfTSaJxDw6aKkxp45agDiEzN")

	// Encode addr to a big.Int.
	bigInt, err := base58.DecodeToBig(addr)
	if err != nil {
		log.Fatalln(err)
	}
	// Print the big.Int value.
	fmt.Println(bigInt)

	// Decode the bigInt value back to an address value.
	decoded := base58.EncodeBig(nil, bigInt)

	// Print the decoded addr.
	fmt.Printf("%s", decoded)
}

Base58Check to Decimal
(golangworld) #3

Thanks you very much hmmm

I have another concern of code :

Keys [i] = .decoded base58.CheckDecode (keys [i] .uncompressed )

result : multiple value base58.CheckDecode () in single- context value

source code https://github.com/saracen/directory.io/blob/master/directory.go

thanks


(Benjamin Radovsky) #4

I’m unsure exactly what you are asking and where exactly you are referring to, however I am thinking based on that error that you are only assigning 1 variable to a function/method that returns more than 1.

After Googling for base58.CheckDecode and finding this: https://godoc.org/github.com/btcsuite/btcutil/base58#CheckDecode, if this is what you are using, you’ll see that what I thought was correct since CheckDecode returns 3 values.


(golangworld) #5

First I thank you for having me cleared
by implenter against how your code in this application ?

to get this:

5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf 1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm 1037542833334494436883955695059393877833907143043

if you could help me I would be very grateful to you .


(Benjamin Radovsky) #6

I’m still not exactly sure what you are asking currently since I think language might be a barrier here…

I’m not sure if this is what you are looking for but I think you might want to just try and replace 1HZwkjkeaoZfTSaJxDw6aKkxp45agDiEzN with 1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm or 5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf in the code that I’ve posted above and you’ll probably get the output that you are looking for.

Just make sure you are have this package installed: https://github.com/tv42/base58, since you seemed to be using a different one in your reply to me before.


(golangworld) #7

I want to know how to add the decimal bitcoin address in the code github directory.io


(golangworld) #8

(golangworld) #9

and how to decode an address list ?


Write in file the result?
(system) closed #10

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.