The module ensures secure and customizable transaction controls for users by integrating features like whitelisting and time delays.
1. getCurrentPolicy
The getCurrentPolicy() method retrieves the current transaction policy configuration. This includes details about the whitelisted addresses, time limits, and whether the policy is enabled.
Example:
fun main() {
// Retrieve the current transaction policy
val resPolicy = getCurrentPolicy()
}
2. enablePolicy
The enablePolicy() method allows updating the settings of a transaction policy. This method supports enabling/disabling the policy - enabled: A flag to enable or disable the transaction policy. - force: A flag to enable the turning- off mode (default is false) Example:
fun main() {
val force = false
val enablePolicy = true
// Update the Transaction Policy
val updatedPolicy = enablePolicy(enabled, force)
// Handle the response
println("Transaction Policy Updated: $updatedPolicy")
}
3. disablePolicy
The disablePolicy() method allows updating the settings of a transaction policy. This method supports enabling/disabling the policy
Example:
fun main() {
// Update the Transaction Policy
val updatedPolicy = disablePolicy()
// Handle the response
println("Transaction Policy Updated: $updatedPolicy")
}
4. addWalletAddress
The addWalletAddress() method allows you to add a recipient’s wallet address to the whitelist. - address: The recipient's wallet address that you want to whitelist. - networkChain: the chain of wallet - labels: the alias of wallet
Example:
fun main() {
// Address to be added to the whitelist
val recipientAddress = "RecipientAddress"
val networkChain = "BTC"
val labels = ["alias0"]
// Add the address to the whitelist
val whitelistResult = addWalletAddress(recipientAddress, networkChain, labels)
// Handle the response
println("Whitelisted Address Result: $whitelistResult")
}
5. removeWalletAddress
The removeWalletAddress() method removes a specified address from the whitelist. - walletId: The whitelist wallet id
Example:
fun main() {
// Address to be added to the whitelist
val walletId = "recipientAddressId"
// Remove the address to the whitelist
val whitelistResult = removeWalletAddress(walletId)
// Handle the response
println("Whitelisted Address Result: $whitelistResult")
}
6. updateWalletAddress
The updateWalletAddress() method update a specified address from the whitelist. - walletId: The whitelist wallet id - labels: the alias of wallet
Example:
fun main() {
// Address to be added to the whitelist
val walletId = "recipientAddressId"
val labels = ["alias0"]
// Add the address to the whitelist
val whitelistResult = updateWalletAddress(walletId, labels)
// Handle the response
println("Whitelisted Address Result: $whitelistResult")
}
7. getTransactionAmountLimit
The getTransactionAmountLimit() method retrieves the current transaction limit policy.
Example:
fun main() {
// Retrieve the current transaction limit policy
val limitPolicy = getTransactionAmountLimit().first()
// Handle the response
println("Transaction Limit Policy: $limitPolicy")
}
8. updateTransactionAmountLimit
The updateTransactionAmountLimit() method updates the transaction amount limit with the specified parameters.
Example:
fun main() {
// Define the new transaction limits and whether they're enabled
val perTxLimit = 1000L
val dailyTxLimit = 5000L
val isLimitEnabled = true
// Update the transaction amount limit
val updateResult = updateTransactionAmountLimit(perTxLimit, dailyTxLimit, isLimitEnabled).first()
// Handle the response
println("Update Transaction Amount Limit Result: $updateResult")
}
9. updateTransactionLimitPolicyForSpecificAddress
The updateTransactionLimitPolicyForSpecificAddress() method sets or updates the transaction limits for a specific address. The new limits must adhere to the global limits, and increasing the limits may trigger a security delay (whitelisting process).
Parameters:
address: The wallet address for which the limits are being set.
networkChain: The blockchain network identifier.
perTransactionLimit: The maximum allowed amount for a single transaction for this address.
dailyLimit: The maximum allowed cumulative amount per day for this address.
enable: A flag indicating whether the limits for this address should be enabled.
Example:
fun main() {
// Define address-specific limits
val address = "0x1234567890123456789012345678901234567890"
val networkChain = "1"
val perTransactionLimit = 50000L
val dailyLimit = 200000L
val enable = true
// Update the transaction limits for the specific address
val updateResult = updateTransactionLimitPolicyForSpecificAddress(address, networkChain, perTransactionLimit, dailyLimit, enable).first()
// Handle the response
println("Updated Address-Specific Transaction Limit: $updateResult")
}
10. getTransactionCurrentUsage
The getTransactionCurrentUsage() method retrieves a snapshot of the current day's transaction usage, including both global totals and address-specific details.
Example:
fun main() {
// Retrieve the current transaction usage for today
val usageSnapshot = getTransactionCurrentUsage().first()
// Handle the response
println("Current Transaction Usage Snapshot: $usageSnapshot")
}
11. checkAmountWithPolicy
The checkAmountWithPolicy() method validates whether a given transaction amount (in USD) complies with the current transaction policy limits for a specific address.
Parameters:
amountInUsd: The transaction amount in USD.
address: The wallet address for the transaction.
networkChain: The blockchain network identifier.
Example:
fun main() {
val amountInUsd = 750L
val address = "0x1234567890123456789012345678901234567890"
val networkChain = "1"
// Check if the transaction amount is within policy limits
val isAllowed = checkAmountWithPolicy(amountInUsd, address, networkChain).first()
// Handle the response
println("Is the transaction amount allowed? $isAllowed")
}
12. recordTransactionDailyUsage
The recordTransactionDailyUsage() method records a transaction for daily usage tracking. It updates the cumulative total, records the status, and automatically resets if a new day begins.
Parameters:
address: The wallet address from which the transaction originated.
networkChain: The blockchain network identifier.
amount: The transaction amount.
status: The transaction status (e.g., SUCCESS, FAILED, or UNKNOWN).
Example:
fun main() {
val address = "0x1234567890123456789012345678901234567890"
val networkChain = "1"
val amount = 500L
val status = TransactionRecordStatus.SUCCESS // Enum or constant representing the status
// Record the transaction for daily usage tracking
val recordResponse = recordTransactionDailyUsage(address, networkChain, amount, status).first()
// Handle the response
println("Transaction Recorded: $recordResponse")
}