Beispiel #1
0
func (kp *FromAddress) publicKey() *[32]byte {
	bytes := strkey.MustDecode(strkey.VersionByteAccountID, kp.address)
	var result [32]byte

	copy(result[:], bytes)

	return &result
}
Beispiel #2
0
func initFriendbot(app *App) {
	if app.config.FriendbotSecret == "" {
		return
	}

	// ensure its a seed if its not blank
	strkey.MustDecode(strkey.VersionByteSeed, app.config.FriendbotSecret)

	app.friendbot = &friendbot.Bot{
		Secret:    app.config.FriendbotSecret,
		Submitter: app.submitter,
		Network:   app.networkPassphrase,
	}

}
Beispiel #3
0
func makeAsset(typ xdr.AssetType, code string, issuer string) xdr.Asset {

	if typ == xdr.AssetTypeAssetTypeNative {
		result, _ := xdr.NewAsset(typ, nil)
		return result
	}

	an := xdr.AssetAlphaNum4{}
	copy(an.AssetCode[:], code[:])

	raw := strkey.MustDecode(strkey.VersionByteAccountID, issuer)
	var key xdr.Uint256
	copy(key[:], raw)

	an.Issuer, _ = xdr.NewAccountId(xdr.CryptoKeyTypeKeyTypeEd25519, key)

	result, _ := xdr.NewAsset(typ, an)
	return result
}
Beispiel #4
0
func (Api) SendUpgradeRequest(data MessageData, kp keypair.KP) (*UpgradeResponse, error) {
	dataJson, err := json.Marshal(data)
	if err != nil {
		return nil, err
	}

	signature, err := kp.Sign(dataJson)
	if err != nil {
		return nil, err
	}

	signatureBase64 := base64.StdEncoding.EncodeToString(signature[:])
	keyData := strkey.MustDecode(strkey.VersionByteAccountID, kp.Address())
	publicKeyBase64 := base64.StdEncoding.EncodeToString(keyData)

	message := Message{
		Data:      string(dataJson),
		PublicKey: publicKeyBase64,
		Signature: signatureBase64,
	}

	requestJson, err := json.Marshal(message)
	if err != nil {
		return nil, err
	}

	url := viper.GetString("ApiRoot") + "/upgrade/upgrade"
	req, err := http.NewRequest("POST", url, bytes.NewBuffer(requestJson))
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	body, _ := ioutil.ReadAll(resp.Body)
	var response UpgradeResponse
	err = json.Unmarshal(body, &response)
	return &response, err
}
Beispiel #5
0
func (kp *Full) rawSeed() []byte {
	return strkey.MustDecode(strkey.VersionByteSeed, kp.seed)
}