Exemple #1
0
func main() {

	if len(os.Args) != 2 {
		usage()
		os.Exit(1)
	}

	prefix = strings.ToUpper(os.Args[1])
	checkPlausible()

	for {
		kp, err := keypair.Random()

		if err != nil {
			log.Fatal(err)
		}

		// NOTE: the first letter of an address will always be G, and the second letter will be one of only a few
		// possibilities in the base32 alphabet, so we are actually searching for the vanity value after this 2
		// character prefix.
		if strings.HasPrefix(kp.Address()[2:], prefix) {
			fmt.Println("Found!")
			fmt.Printf("Secret seed: %s\n", kp.Seed())
			fmt.Printf("Public: %s\n", kp.Address())
			os.Exit(0)
		}
	}
}
func (this *CreateAccount) execute(isSync bool) {
	var input string

	kp, err := keypair.Random()

	if err == nil {
		keyp := kp.(*keypair.Full)
		fmt.Printf("\r\n"+this.infoStrings[this.languageIndex][CA_INFO_SECRET_SEED]+" %s\r\n", keyp.Seed())
		fmt.Printf(this.infoStrings[this.languageIndex][CA_INFO_PUBLIC_ADDR]+" %s\r\n", keyp.Address())
		fmt.Printf("\r\n" + this.infoStrings[this.languageIndex][CA_INFO_MEMO_TEXT])
		fmt.Scanf("%s\n", &input)

		if input == "s" {
			err = this.savefile("account_info.txt", keyp.Seed(), keyp.Address())
			if err == nil {
				ConsoleColor.Printf(ConsoleColor.C_YELLOW,
					"\r\n"+this.infoStrings[this.languageIndex][CA_INFO_MEMO_SAVEFILE]+"\r\n\r\n", "account_info.txt")
				// fmt.Printf("\r\n"+this.infoStrings[this.languageIndex][CA_INFO_MEMO_SAVEFILE]+"\r\n\r\n", "account_info.txt")
			} else {
				ConsoleColor.Println(ConsoleColor.C_RED,
					"\r\n", this.infoStrings[this.languageIndex][CA_INFO_MEMO_SAVEFILE_ERR], "\r\n", err, "\r\n\r\n")
				// fmt.Println("\r\n", this.infoStrings[this.languageIndex][CA_INFO_MEMO_SAVEFILE_ERR], "\r\n", err, "\r\n\r\n")
			}
		}
	} else {
		fmt.Println(err.Error())
		fmt.Scanf("%s\n", &input)
	}

	if !isSync {
		this.ASyncChan <- 0
	}
}
Exemple #3
0
// AccountID returns a new random account id
func AccountID() entity.AccountID {
	kp, err := keypair.Random()
	if err != nil {
		panic(err)
	}

	return entity.AccountID(kp.Address())
}
// CreateKeypair implements /create-keypair endpoint
func (rh *RequestHandler) CreateKeypair(w http.ResponseWriter, r *http.Request) {
	kp, err := keypair.Random()
	if err != nil {
		log.WithFields(log.Fields{"err": err}).Error("Error generating random keypair")
		server.Write(w, protocols.InternalServerError)
	}

	response, err := json.Marshal(KeyPair{kp.Address(), kp.Seed()})
	if err != nil {
		log.WithFields(log.Fields{"err": err}).Error("Error marshalling random keypair")
		server.Write(w, protocols.InternalServerError)
	}

	w.Write(response)
}
Exemple #5
0
// WebhookEntity returns a new random valid webhook
func WebhookEntity() (result entity.Webhook) {
	var err error
	result.URL, err = url.Parse("http://" + fake.DomainName())
	if err != nil {
		panic(err)
	}

	kp, err := keypair.Random()
	if err != nil {
		panic(err)
	}

	result.DestinationFilter = entity.AccountID(kp.Address())
	return
}
func NewAddress(r slackbot.Request) slackbot.Response {
	kp, err := keypair.Random()

	if err != nil {
		log.Fatal(err)
	}

	r.Respond(slackbot.Response{
		ResponseType: slackbot.IN_CHANNEL,
		Text:         fmt.Sprintf("%s generated a new stellar address: %s", r.Data.UserName, kp.Address()),
	})

	r.Respond(slackbot.Response{
		ResponseType: slackbot.EMPHEMERAL,
		Text:         fmt.Sprintf("Here is your private key. Keep it safe. Anyone who has access to you private key can access your funds: %s", kp.(*keypair.Full).Seed()),
	})

	return slackbot.EmptyResponse
}