Created
October 12, 2019 00:08
-
-
Save tiero/b8ba1ea08dd03b0f8fc003cb3c144cb4 to your computer and use it in GitHub Desktop.
quick btc wallet in go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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