Files

26 lines
437 B
Go

package chain
import (
"crypto/ed25519"
"crypto/rand"
"encoding/hex"
)
type Wallet struct {
PrivateKey ed25519.PrivateKey
PublicKey ed25519.PublicKey
}
func NewWallet() *Wallet {
pub, priv, _ := ed25519.GenerateKey(rand.Reader)
return &Wallet{PrivateKey: priv, PublicKey: pub}
}
func (w *Wallet) Address() string {
return hex.EncodeToString(w.PublicKey)
}
func (w *Wallet) ShortAddress() string {
return w.Address()[:7]
}