decred.org/dcrdex@v1.0.5/client/cmd/assetseed/main.go (about) 1 // This code is available on the terms of the project LICENSE.md file, 2 // also available online at https://blueoakcouncil.org/license/1.0.0. 3 4 package main 5 6 import ( 7 "encoding/hex" 8 "flag" 9 "fmt" 10 "os" 11 12 "decred.org/dcrdex/client/asset" 13 "decred.org/dcrdex/client/core" 14 ) 15 16 func main() { 17 var appSeed string 18 flag.StringVar(&appSeed, "seed", "", "Bison Wallet application seed (128 hexadecimal characters)") 19 var assetID uint 20 flag.UintVar(&assetID, "asset", 0, "Asset ID. BIP-0044 coin type (integer).\n"+ 21 "See https://github.com/satoshilabs/slips/blob/master/slip-0044.md") 22 flag.Parse() 23 24 if appSeed == "" { 25 flag.Usage() 26 os.Exit(1) 27 } 28 29 appSeedB, err := hex.DecodeString(appSeed) 30 if err != nil { 31 fmt.Fprintf(os.Stderr, "bad app seed: %v\n", err) 32 os.Exit(1) 33 } 34 35 if len(appSeedB) != 64 { 36 fmt.Fprintf(os.Stderr, "app seed is %d bytes, expected 64\n", len(appSeedB)) 37 os.Exit(1) 38 } 39 40 if tkn := asset.TokenInfo(uint32(assetID)); tkn != nil { 41 fmt.Fprintf(os.Stderr, "this is a token. did you want asset ID %d for %s?\n", tkn.ParentID, asset.Asset(tkn.ParentID).Info.Name) 42 os.Exit(1) 43 } 44 45 seed, _ := core.AssetSeedAndPass(uint32(assetID), appSeedB) 46 fmt.Printf("%x\n", seed) 47 48 os.Exit(0) 49 }