
// myProofFunds provides functions to manage a user's payment proof provider account funds
// These are funds that are used to purchase payment proofs from payment proof providers
// Accounts exist inside of the payment proof provider servers
// Users interface with their accounts using their account private keys.
// This package provides functions to communicate with the payment proof provider servers to fund messages, profiles, identities, and reports
// It also provides functions to purchase funds

package myProofFunds

//TODO: Complete this package

import "seekia/internal/convertCurrencies"
import "seekia/internal/helpers"

import "time"
import "errors"

//Outputs:
//	-bool: Parameters exist
//	-float64: Specified currency balance
//	-error
func GetMyProofFundsAccountBalanceInAnyCurrency(myIdentityType string, networkType byte, currencyCode string)(bool, float64, error){

	isValid := helpers.VerifyNetworkType(networkType)
	if (isValid == false){
		networkTypeString := helpers.ConvertByteToString(networkType)
		return false, 0, errors.New("GetMyProofFundsAccountBalanceInAnyCurrency called with invalid networkType: " + networkTypeString)
	}

	//TODO
	totalAppCurrencyBalance := float64(0)

	cryptocurrencyNamesList := []string{"Ethereum", "Cardano"}

	for _, cryptocurrencyName := range cryptocurrencyNamesList{

		//TODO
		currentCryptoUnitsBalance := int64(100)

		parametersExist, accountFundsAppCurrencyBalance, err := convertCurrencies.ConvertCryptoAtomicUnitsToAnyCurrency(networkType, cryptocurrencyName, currentCryptoUnitsBalance, currencyCode)
		if (err != nil){ return false, 0, err }
		if (parametersExist == false){
			return false, 0, nil
		}

		totalAppCurrencyBalance += accountFundsAppCurrencyBalance
	}

	return true, totalAppCurrencyBalance, nil
}

//Outputs:
//	-bool: Parameters exist
//	-bool: Sufficient funds exist
//	-error
func FreezeFundsForMessage(messageIdentifier [20]byte, messageNetworkType byte, messageDuration int, messageSize int)(bool, bool, error){

	//TODO
	// Adjust amount of funds frozen as the cost of messages changes?

	return true, true, nil
}

//Outputs:
//	-bool: Frozen funds found
//	-error
func ReleaseFrozenFundsForMessage(messageIdentifier [20]byte)(bool, error){

	//TODO

	return true, nil
}


//TODO: Add payment proof as an output of this function?
//Outputs:
//	-bool: Funds are sufficient
//	-bool: Message fund is successful
//	-error
func FundMyMessageWithServer(messageIdentifier [20]byte, messageHash [26]byte, messageNetworkType byte, messageSizeInBytes int, messageDuration int)(bool, bool, error){

	//TODO
	// The function should contact payment proof provider and purchase a payment proof for the message
	// This function should unfreeze the funds associated with the message
	// If the funds are not sufficient, it should refreeze them

	time.Sleep(time.Second)

	return true, true, nil
}

