-
Notifications
You must be signed in to change notification settings - Fork 13
/
main.go
45 lines (36 loc) · 843 Bytes
/
main.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
package main
import (
"fmt"
"io/ioutil"
"os"
"github.com/pkg/errors"
"github.com/kaspanet/kaspad/domain/dagconfig"
"github.com/svarogg/kaspaper/kaspaperlib"
)
func main() {
if len(os.Args) == 1 {
printUsage()
os.Exit(1)
}
filename := os.Args[1]
wallet, err := kaspaperlib.NewAPI(&dagconfig.MainnetParams).GenerateWallet()
if err != nil {
printErrorAndExit(err)
}
walletString, err := renderWallet(wallet)
if err != nil {
printErrorAndExit(err)
}
err = ioutil.WriteFile(filename, []byte(walletString), 0600)
if err != nil {
printErrorAndExit(errors.WithStack(err))
}
fmt.Printf("Paperwallet written to %s\n", filename)
}
func printErrorAndExit(err error) {
fmt.Fprintf(os.Stderr, "A critical error occured:\n%+v\n", err)
os.Exit(1)
}
func printUsage() {
fmt.Println("Usage: kaspaper [filename.html]")
}