Skip to content

Commit

Permalink
genseed: add tool to cmd that generates a seed
Browse files Browse the repository at this point in the history
A use case for this is testing verifyseed rpc.  Currently rpctest harness' memwallet does not allow for its seed to be changed.
  • Loading branch information
githubsands committed Apr 20, 2020
1 parent 0f87b66 commit f22a9d7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/genseed/generateseed.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ import (

var (
s = flag.Bool("mne", false, "Optional command line argument to print as seed as a mnemonic phrase rather then its hexadecimal form")
<<<<<<< HEAD
b = flag.Uint("size", 32, "Optional command line argument to print a seed as a certian size. The default size is 32 and recommended size is between 16 and 64. Anything under 16 or 64 will cause the program to crash")
m = flag.Bool("master", false, "Optional command line argument to print master key of the created seed.")
=======
b = flag.Uint("size", 32, "Optional command line argument to print a seed as a certain size. The default size is 32 and recommended size is between 16 and 64. Anything under 16 or 64 will cause the program to crash")
>>>>>>> 18c275e... genseed: add tool to cmd that generates a seed
)

func main() {
Expand Down
20 changes: 20 additions & 0 deletions cmd/genseed/generateseedtest.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
#!/usr/bin/env bash
<<<<<<< HEAD
=======
# ./genseed creates a seed in either mnemonic or its hexadecimal form.
# by default a hexidecimal seed is created
# form of the seed can be changed by setting --mne=true
# size of the seed can be changed by setting --size=<size>

FILE="genseed"
if [[ ! -f "$FILE" ]]; then
go build
fi
>>>>>>> 18c275e... genseed: add tool to cmd that generates a seed

# Test 1: generateseed with no options
SEED=$(./genseed)
if [[ ${#SEED} -gt 64 || ${#SEED} -lt 16 ]]; then
echo "test 1 failed"
exit 1
fi
<<<<<<< HEAD
=======
echo test 1 outcome "$SEED"
>>>>>>> 18c275e... genseed: add tool to cmd that generates a seed

# Test 2: generateseed with option --mne set as true, and --size as 64
PARAMS=$(echo \
Expand All @@ -18,3 +34,7 @@ if [[ $(echo ${#SEED2} | wc -c) -gt 500 ]]; then
echo "test 2 failed"
exit 1
fi
<<<<<<< HEAD
=======
echo "test 2 outcome: $SEED2"
>>>>>>> 18c275e... genseed: add tool to cmd that generates a seed
Binary file added cmd/genseed/genseed
Binary file not shown.

0 comments on commit f22a9d7

Please sign in to comment.