Skip to content

Instantly share code, notes, and snippets.

@lukechampine
Created October 4, 2017 16:05
Show Gist options
  • Save lukechampine/69b90ad627d76d434364ec647b10abec to your computer and use it in GitHub Desktop.
Save lukechampine/69b90ad627d76d434364ec647b10abec to your computer and use it in GitHub Desktop.
Cold wallet address generator
package main
import (
"bufio"
"fmt"
"log"
"os"
"strconv"
"github.com/NebulousLabs/Sia/crypto"
"github.com/NebulousLabs/Sia/modules"
"github.com/NebulousLabs/Sia/types"
"github.com/NebulousLabs/entropy-mnemonics"
)
func main() {
log.SetFlags(0)
if len(os.Args) != 2 {
log.Fatal("Usage: cold index")
}
n, err := strconv.Atoi(os.Args[1])
if err != nil {
log.Fatal("expected number, got", os.Args[1])
}
os.Stdout.WriteString("Seed: ")
s := bufio.NewScanner(os.Stdin)
s.Scan()
seed, err := modules.StringToSeed(s.Text(), mnemonics.English)
if err != nil {
log.Fatal(err)
}
_, pk := crypto.GenerateKeyPairDeterministic(crypto.HashAll(seed, uint64(n)))
fmt.Println(types.UnlockConditions{
PublicKeys: []types.SiaPublicKey{types.Ed25519PublicKey(pk)},
SignaturesRequired: 1,
}.UnlockHash())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment