Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 39 additions & 9 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,11 @@
[[constraint]]
branch = "master"
name = "golang.org/x/crypto"

[[constraint]]
name = "github.com/spf13/cobra"
version = "0.0.5"

[[constraint]]
branch = "master"
name = "github.com/tyler-smith/go-bip39"
41 changes: 41 additions & 0 deletions cmd/account/account.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package account

import (
"encoding/hex"

"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/tyler-smith/go-bip39"
"github.com/zoobc/zoobc-core/common/util"
)

func GenerateAccount(logger *logrus.Logger) *cobra.Command {
var accountCmd = &cobra.Command{
Use: "account",
Short: "account is a developer cli tools to generate account.",
Long: `account is a developer cli tools to generate account.
running 'zoobc account generate' will show create an account detail with its public key and
private key both in bytes and hex representation + the secret phrase
`,
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
if args[0] == "generate" {
entropy, _ := bip39.NewEntropy(128)
seed, _ := bip39.NewMnemonic(entropy)
privateKey, _ := util.GetPrivateKeyFromSeed(seed)
publicKey := privateKey[32:]
address, _ := util.GetAddressFromPublicKey(publicKey)
logger.Infof("seed: %s", seed)
logger.Infof("public key hex: %s", hex.EncodeToString(publicKey))
logger.Infof("public key bytes: %v", publicKey)
logger.Infof("private key bytes: %v", privateKey)
logger.Infof("private key hex: %v", hex.EncodeToString(privateKey))
logger.Infof("address: %s", address)

} else {
logger.Error("unknown command")
}
},
}
return accountCmd
}
14 changes: 14 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package main

import (
"github.com/spf13/cobra"
"github.com/zoobc/zoobc-core/cmd/account"
"github.com/zoobc/zoobc-core/common/util"
)

func main() {
var rootCmd = &cobra.Command{Use: "zoobc"}
logger, _ := util.InitLogger(".log/", "debug.log")
rootCmd.AddCommand(account.GenerateAccount(logger))
_ = rootCmd.Execute()
}
18 changes: 18 additions & 0 deletions cmd/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
### Zoobc - CMD

Command line interface to as a utility tools to develop the zoobc system.

### Structure

- main.go -> register all command
- package
- specific.go
- ...
- readme.md


### Run

- `go run main.go {command} {subcommand}`

- example: `go run main.go account generate` will generate account to use.
2 changes: 1 addition & 1 deletion common/database/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (m *Migration) Init(qe *query.Executor) error {
);`,
`
CREATE TABLE IF NOT EXISTS "transaction" (
"id" BLOB,
"id" INTEGER,
"block_id" INTEGER,
"block_height" INTEGER,
"sender_account_id" BLOB,
Expand Down
82 changes: 38 additions & 44 deletions common/model/account.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading