func (api *API) StorePutValue(key bmcrypto.KeyPair, addr hash.Hash, path string, value string) error {
	// Calc parentPath
	parentPath, _ := filepath.Split(path)
	// correct "/foo/" to "/foo" from "/foo/bar"
	parentPath = strings.TrimRight(parentPath, "/")
	// correct "" to "/" from "/foo"
	if parentPath == "" {
		parentPath = "/"
	}

	pathHash := hash.New(addr.String() + path)
	parentHash := hash.New(addr.String() + parentPath)
	var ph *hash.Hash = &parentHash

	var parent interface{} = parentHash.String()
	if path == "/" {
		parent = nil
		ph = nil
	}

	encValue, err := bmcrypto.MessageEncrypt(deriveAesKey(key.PrivKey), []byte(value))
	if err != nil {
		return errNoSuccess
	}

	sig, err := generateSignature(key.PrivKey, pathHash, ph, encValue)
	if err != nil {
		return err
	}

	data, err := json.MarshalIndent(jsonOut{
		"path":       pathHash,
		"parent":     parent,
		"value":      encValue,
		"signature":  sig,
		"public_key": key.PubKey.String(),
	}, "", "  ")
	if err != nil {
		return err
	}

	_, statusCode, err := api.Post(fmt.Sprintf("/account/%s/store/%s", addr.String(), pathHash.String()), data)
	if err != nil {
		return err
	}

	if statusCode < 200 || statusCode > 299 {
		return errNoSuccess
	}

	return nil
}
// StorePutValue will store an value to a path
StorePutValue will store an value to a path
// StorePutValue will store an value to a path
func (api *API) StorePutValue(key bmcrypto.KeyPair, addr hash.Hash, path string, value string) error {
	parentPath, _ := filepath.Split(path)
	parentPath = strings.TrimRight(parentPath, "/")
	if parentPath == "" {
		parentPath = "/"
	}
	pathHash := hash.New(addr.String() + path)
	parentHash := hash.New(addr.String() + parentPath)
	var ph *hash.Hash = &parentHash
	var parent interface{} = parentHash.String()
	if path == "/" {
		parent = nil
		ph = nil
	}
	encValue, err := bmcrypto.MessageEncrypt(deriveAesKey(key.PrivKey), []byte(value))
	if err != nil {
		return errNoSuccess
	}
	sig, err := generateSignature(key.PrivKey, pathHash, ph, encValue)
	if err != nil {
		return err
	}
	data, err := json.MarshalIndent(jsonOut{
		"path":       pathHash,
		"parent":     parent,
		"value":      encValue,
		"signature":  sig,
		"public_key": key.PubKey.String(),
	}, "", "  ")
	if err != nil {
		return err
	}
	_, statusCode, err := api.Post(fmt.Sprintf("/account/%s/store/%s", addr.String(), pathHash.String()), data)
	if err != nil {
		return err
	}
	if statusCode < 200 || statusCode > 299 {
		return errNoSuccess
	}
	return nil
}
func ( api * API ) StorePutValue ( key bmcrypto . KeyPair , addr hash . Hash , path string , value string ) error { parentPath , _ := filepath . Split ( path ) parentPath = strings . TrimRight ( parentPath , " " ) if parentPath == " " { parentPath = " " } pathHash := hash . New ( addr . String ( ) + path ) parentHash := hash . New ( addr . String ( ) + parentPath ) var ph * hash . Hash = & parentHash var parent interface { } = parentHash . String ( ) if path == " " { parent = nil ph = nil } encValue , err := bmcrypto . MessageEncrypt ( deriveAesKey ( key . PrivKey ) , [ ] byte ( value ) ) if err != nil { return errNoSuccess } sig , err := generateSignature ( key . PrivKey , pathHash , ph , encValue ) if err != nil { return err } data , err := json . MarshalIndent ( jsonOut { " " : pathHash , " " : parent , " " : encValue , " " : sig , " " : key . PubKey . String ( ) , } , " " , " " ) if err != nil { return err } _ , statusCode , err := api . Post ( fmt . Sprintf ( " " , addr . String ( ) , pathHash . String ( ) ) , data ) if err != nil { return err } if statusCode < 200 || statusCode > 299 { return errNoSuccess } return nil }
StorePutValue will store an value to a path
StorePutValue will store an value to a path
// Calc parentPath // correct "/foo/" to "/foo" from "/foo/bar" // correct "" to "/" from "/foo"