@@ -18,12 +18,67 @@ const FILE_NAME_MNEMONIC = "mnemonic-words"
1818const compress = true // generate a compressed public key
1919
2020var (
21- flag_number int = 1
22- flag_debug = false
21+ flag_number int
22+ flag_count int = 1
23+ flag_debug bool
24+ command string
25+ argsLength int
2326)
2427
28+ func init () {
29+ argsLength = len (os .Args )
30+ }
31+
32+ func hasNext (no int ) bool {
33+ if argsLength > no {
34+ return true
35+ }
36+ return false
37+ }
38+
39+ func getNext (no int ) string {
40+ return os .Args [no + 1 ]
41+ }
42+
43+ func getNextArgAsInt (no , varsayılan int ) int {
44+ if hasNext (no ) {
45+ if i , err := strconv .Atoi (getNext (no )); err == nil {
46+ return i
47+ } else {
48+ Warn .Println (err )
49+ }
50+ } else {
51+ Warn .Println ("Value expected, was not found" )
52+ }
53+ return varsayılan
54+ }
55+
2556func flag () {
2657
58+ if argsLength > 1 {
59+
60+ // check for commands
61+ switch os .Args [1 ] {
62+
63+ case "wof" :
64+ command = "wof"
65+ break
66+
67+ case "keyset" :
68+ command = "keyset"
69+ break
70+
71+ case "wif" :
72+ if hasNext (1 ) {
73+ fromWifInput (getNext (1 ))
74+ } else {
75+ fromWifInput ("" )
76+ }
77+ os .Exit (0 )
78+ }
79+ }
80+
81+ // check for options
2782 for no , arg := range os .Args {
2883 switch arg {
2984
@@ -39,46 +94,41 @@ func flag() {
3994 fmt .Printf ("%s\n " , build .Info ())
4095 os .Exit (0 )
4196
42- case "-mnemonic" :
43- var mnemonic = os .Args [no + 1 ]
44- os .Setenv (ENV_MNEMONIC , mnemonic )
45- Info .Printf ("Setting env veriable %s\n " , ENV_MNEMONIC )
97+ case "-d" , "--debug" :
98+ debug (true )
4699 continue
47100
48- case "-pass" :
49- var pass = os .Args [no + 1 ]
50- os .Setenv (ENV_PASSWORD , pass )
51- Info .Printf ("Setting env veriable %s\n " , ENV_PASSWORD )
101+ case "--verbose" :
102+ debug (true )
103+ verbose (true )
52104 continue
53105
54- case "-debug" :
55- debug (true )
106+ case "-no" :
107+ Debug .Println ("In case -n" )
108+ flag_number = getNextArgAsInt (no , 0 )
109+ Debug .Println ("113 flag_number: " , flag_number )
56110 continue
57111
58- case "-verbose" :
59- verbose (true )
112+ case "-mnemonic" :
113+ if hasNext (no ) {
114+ os .Setenv (ENV_MNEMONIC , getNext (no ))
115+ Info .Printf ("Setting env veriable %s\n " , ENV_MNEMONIC )
116+ }
60117 continue
61118
62- case "-n " :
63- if num , err := strconv . Atoi ( os . Args [ no + 1 ]); err == nil {
64- flag_number = num
65- Debug . Println ( "flag_number: " , flag_number )
119+ case "-pass" , "-password" , "-passphrase " :
120+ if hasNext ( no ) {
121+ os . Setenv ( ENV_PASSWORD , getNext ( no ))
122+ Info . Printf ( "Setting env veriable %s \n " , ENV_PASSWORD )
66123 } else {
67- Error .Println ("Flag -n needs a number. 1 is the default." )
68- Error .Fatal (err )
124+ Error .Println ("No passphrase provided on command line" )
69125 }
70126 continue
71127
72- case "wif" :
73- fromWifInput ()
74- os .Exit (0 )
75-
76- case "-wif" , "--wif" :
77- var a = os .Args [no + 1 ]
78- os .Setenv (ENV_WIF , a )
79- Info .Printf ("Setting env veriable %s\n " , ENV_WIF )
80- fromWifInput ()
81- os .Exit (0 )
128+ case "-count" :
129+ Debug .Println ("In case -count" )
130+ flag_count = getNextArgAsInt (no , 1 )
131+ continue
82132 }
83133 }
84134}
@@ -98,6 +148,10 @@ ENVIRONMENT VARIABLE OPTIONS
98148DESCRIPTION
99149hdkeys allows for the creation of mnemonic seeds, and Hierarchical Deterministic (HD) addresses.
100150
151+ - hdkeys supports BIP39 passphrase protection.
152+ - hdkeys creates Bitcoin and Nostr accounts from the same mnemonic seeds
153+ - hdkeys can create WIF (Wallet Import Format), and decode private keys from WIF
154+
101155 BIP32 - Hierarchical Deterministic Wallets
102156 BIP39 - Mnemonic code for generating deterministic keys
103157 BIP43 - Purpose Field for Deterministic Wallets
@@ -111,23 +165,32 @@ hdkeys allows for the creation of mnemonic seeds, and Hierarchical Deterministic
111165 ...
112166
113167COMMANDS
114- wif [prompt] or [Environment variable]
168+ wof
169+ Wall Of Fame, prints a whole set of keys
170+ COMMAND OPTIONS
171+ -count [int] (default = 1)
172+ Set number of keys to generate.
173+
174+ wif [string] or [Environment variable]
115175 Decode the private key from wif(Wallet Import Format), then generate the address.
116176
117- OPTIONS
118- -h or --help [bool]
119- Report usage information and exit.
177+ keyset
178+ Gets a Bitcoin and Nostr key set with the same WIF (Wallet Import Format) as JSON.
179+ COMMAND OPTIONS
180+ -no [int] (default = 0)
181+ Nostr Account number to generate
120182
121- -wif [string]
122- Decode the private key from wif(Wallet Import Format), then generate the address.
183+ OPTIONS
184+ -mnemonic [string]
185+ Mnemonic words
123186
124187 -pass [string]
125188 Protect bip39 mnemonic with a passphrase via flag,
126189 or use environment variable,
127190 or you will be asked to enter at a prompt.
128191
129- -n [int] (default = 1)
130- Set number of keys to generate .
192+ -h or --help [bool]
193+ Report usage information and exit .
131194
132195 -v [bool]
133196 Print version tag and exit.
0 commit comments