-
Notifications
You must be signed in to change notification settings - Fork 10
/
unlock.go
60 lines (52 loc) · 1.29 KB
/
unlock.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright 2017 Factom Foundation
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
package main
import (
"flag"
"fmt"
"os"
"strconv"
"github.com/FactomProject/factom"
"github.com/posener/complete"
)
// unlockwallet creates a new transaction in the wallet.
var unlockwallet = func() *fctCmd {
cmd := new(fctCmd)
cmd.helpMsg = "factom-cli unlockwallet [-v] \"passphrase\" <seconds-to-unlock>"
cmd.description = "Unlock the wallet for some number of seconds; must be an encrypted wallet. -v verbose."
cmd.completion = complete.Command{
Flags: complete.Flags{
"-v": complete.PredictNothing,
},
}
cmd.execFunc = func(args []string) {
os.Args = args
vflag := flag.Bool("v", false, "verbose mode; print relock time in UTC epoch seconds when the unlock is successful")
flag.Parse()
args = flag.Args()
if len(args) != 2 {
fmt.Println(cmd.helpMsg)
return
}
seconds, err := strconv.ParseInt(args[1], 10, 64)
if err != nil {
errorln(err)
return
}
unix, err := factom.UnlockWallet(args[0], seconds)
if err != nil {
errorln(err)
return
}
// output
switch {
// verbose mode; print when wallet will re-lock
case *vflag:
fmt.Println(unix)
default:
}
}
help.Add("unlockwallet", cmd)
return cmd
}()