aboutsummaryrefslogblamecommitdiffstats
path: root/test/keygen.go
blob: 5397bc269c48c7f10db9263bd3da680ba7e2ded4 (plain) (tree)
1
2
3
4
5
6
7




                      

                 




                                                  




                                              




                                                                             
                                                                                 










                                                                           
package main

import (
    "encoding/hex"
    "fmt"
    "os"
    "strconv"

    "github.com/dexon-foundation/dexon/crypto"
)

func main() {
    count, err := strconv.Atoi(os.Args[1])
    if err != nil {
        panic(err)
    }
    for i := 0; i < count; i++ {
        privKey, err := crypto.GenerateKey()
        if err != nil {
            panic(err)
        }
        address := crypto.PubkeyToAddress(privKey.PublicKey).String()
        pk := hex.EncodeToString(crypto.FromECDSAPub(&privKey.PublicKey))

        fmt.Printf(`
    "%s": {
      "balance": "1000000000000000000000",
      "staked": "500000000000000000000",
      "publicKey": "0x%s"
    },`, address, pk)

        crypto.SaveECDSA(fmt.Sprintf("test%d.nodekey", i), privKey)
    }
}