コード例 #1
0
ファイル: main.go プロジェクト: stellar/bridge-server
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)
		}
	}
}
コード例 #2
0
ファイル: NewAccount.go プロジェクト: zzj882/go-StellarWallet
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
	}
}
コード例 #3
0
ファイル: account_id.go プロジェクト: nullstyle/coinop
// 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())
}
コード例 #4
0
// 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)
}
コード例 #5
0
ファイル: webhook.go プロジェクト: nullstyle/coinop
// 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
}
コード例 #6
0
ファイル: new_address.go プロジェクト: masonforest/stroopybot
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
}