update_balances_if_needed

function update_balances_if_needed(sender: account, recipient: account, asset: asset, amount: big_integer)(source)

For a transfer going from an account to another, this function checks whether any balances need to be updated, then does so. This function should only be used in the context of crosschain transfers.

A balance does not need to be updated if it pertains to a blockchain that is marked as asset_origin for the asset being transferred. This is because the asset origin chain's balance does not need to be tracked.

Can only be called from an operation.

Throws "SELF TRANSFER" if sender and recipient are the same account

Throws "INVALID BLOCKCHAIN SENDER" if sender is a blockchain account with this blockchain's RID

Throws "INVALID BLOCKCHAIN RECIPIENT" if recipient is a blockchain account with this blockchain's RID

Throws if the required assets cannot be transferred. Common cases include:

  • the amount to transfer is not in the accepted range (0, 2^256) (exclusive)

  • the sender account's balance is lower than amount

Parameters

sender

the account the assets are coming from

recipient

the account the assets are going to

asset

the asset being transferred

amount

the amount being transferred

See also

asset_origin

for more information on asset origin chains and balance tracking