Skip to content

Instantly share code, notes, and snippets.

@tiero
Created October 12, 2019 00:08
Show Gist options
  • Save tiero/b8ba1ea08dd03b0f8fc003cb3c144cb4 to your computer and use it in GitHub Desktop.
Save tiero/b8ba1ea08dd03b0f8fc003cb3c144cb4 to your computer and use it in GitHub Desktop.
quick btc wallet in go
package wallet
import (
"github.com/btcsuite/btcd/btcec"
)
// Wallet define wallet structure
type Wallet struct {
PrivateKey *btcec.PrivateKey
PublicKey *btcec.PublicKey
}
// CreateWallet create new Wallet instance
//
// @return (*Wallet, error)
func CreateWallet() (Wallet, error) {
wallet := Wallet{}
privateKey, err := btcec.NewPrivateKey(btcec.S256())
if err != nil {
return wallet, err
}
wallet.PrivateKey = privateKey
wallet.PublicKey = privateKey.PubKey()
return wallet, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment