This repository has been archived on 2024-04-07. You can view files and clone it, but cannot push or open issues or pull requests.
go-monero/pkg/monero/network.go
Ciro S. Costa 74a9dfbdca cmd: add address generation
here a new subcommand is added: `address`.

the idea here is to provide an example of how address-related
funcionality from `pkg/monero` can be used.

at the moment, the only available action is "generate", which
instantiates a new seed based on `crypto/rand` and then displaying on
stdout the result

	WARNING: DO NOT USE THIS FOR ANYTHING MEANINGFUL.
	you've been advised.

example:

	$ monero address generate

	Mnemonic:  dawn      repent   towel    taxi
		   cucumber  muzzle   romance  awesome
		   losing    yeti     dogs     biplane
		   foyer     hotel    tattoo   dilute
		   gearbox   later    afloat   purged
		   software  ashtray  cell     dangerous
		   biplane

	Primary Address:        49MYaXwy8K177bw9i1bBDvPuM...
	Private Spend Key:      455f1c286ff8db620e61ca6c6...
	Private View Key:       b5d26a403c6cec29c3ecc8d2f...
	Public Spend Key:       cc06a0f6e6c6b0248d5e2c3fd...
	Public View Key:        bcb8d3dc372efb9071c120b72...

	(output truncated to fit the commit message).

Signed-off-by: Ciro S. Costa <utxobr@protonmail.com>
2021-08-26 07:46:52 -04:00

30 lines
621 B
Go

package monero
import "fmt"
// Network denotes a type of Monero network to gather information about.
//
type Network string
const (
NetworkMainnet Network = "mainnet"
NetworkTestnet Network = "testnet"
NetworkStagenet Network = "stagenet"
NetworkFakechain Network = "fakechain"
)
func (n Network) PublicAddressBase58Prefix() []byte {
switch n {
case NetworkMainnet:
return []byte{18}
case NetworkTestnet:
return []byte{53}
case NetworkStagenet:
return []byte{24}
case NetworkFakechain:
return NetworkMainnet.PublicAddressBase58Prefix()
}
panic(fmt.Errorf("'%s' is not a valid netowrk", n))
}