Schedule Account Balance Consolidation

When using the confidential payments feature, you must regularly schedule account balance consolidation.

To keep account balances accurate across the network, a Token Admin or Org Admin uses the scheduleTransactions REST API endpoint in Oracle Blockchain Platform to run the consolidateRunningBalanceInTransactions and processSendersAndReceivers methods periodically. For more information, see Schedule Transaction to Run.

consolidateRunningBalanceInTransactions

In confidential mode, the running balance of sender and receiver accounts is not stored in a transaction record; instead the running balance is periodically calculated and then the transaction records are updated. When the consolidateRunningBalanceInTransactions API runs, all transactions (both public and private) where a running balance has not been processed are identified and the running balances of the sender and receiver accounts are calculated and saved. Use the scheduleTransactions API endpoint in Oracle Blockchain Platform as shown below to schedule the consolidateRunningBalanceInTransactions API to run periodically.

Endpoint
/restproxy/api/v2/channels/{channelName}/scheduleTransactions
Request Body
curl --location '<rest_server_url:port>/restproxy/api/v2/channels/{channelName}/scheduleTransactions' \
--header 'Content-Type: application/json' \
--header 'Confidential-Transaction: true' \
--header 'Authorization: ••••••' \
--data '{
    "chaincode": "{ChaincodeName}",
    "args": [
        "consolidateRunningBalanceInTransactions"
    ],
    "timeout": 6000,
    "sync": true,
    "intervalType": {
        "time": 2
    },
    "expiry": "120M",
    "sameOrgEndorser": true
}'

processSendersAndReceivers

In confidential mode, transfers between organizations involve two private data collections. Instead of modifying the account key/value pair, for debits a sender object is created and for credits a receiver object is created. The balance is placed in the sender object. The credited amount is placed in the receiver object, which is assigned to the recipient. When the debit operation is complete, the sender object is no longer in use and can be deleted. Similarly, after the balance moves from the receiver object to the recipient's account, the receiver object can be deleted. The processSendersAndReceivers identifies all sender objects that have been processed and deletes them. It also identifies all receiver objects that contain a balance, moves the balance to the corresponding recipient's account key/value pair, and then deletes the receiver object. Use the scheduleTransactions API endpoint in Oracle Blockchain Platform as shown below to schedule the processSendersAndReceivers API to run periodically.

Endpoint
/restproxy/api/v2/channels/{channelName}/scheduleTransactions
Request Body
curl --location '<rest_server_url:port>/restproxy/api/v2/channels/<channel_name>/scheduleTransactions'\
--header 'Content-Type: application/json' \
--header 'Confidential-Transaction: true' \
--header 'Authorization: ••••••' \
--data '{
    "chaincode": "{ChaincodeName}",
    "args": [
        "processSendersAndReceivers"
    ],
    "timeout": 6000,
    "sync": true,
    "intervalType": {
        "time": 2
    },
    "expiry": "120M",
    "sameOrgEndorser": true
}'