Skip to content

Account Balance

Peter-Jan Brone requested to merge account-track-spending into master

MERGE REQUEST

MR Guidelines

Overview

This MR adds the basic methods on the account object that will allow keeping track of the account balance.

The account's balance is tracked using 3 state variables:

  • the balance
  • the pending deposits (these are fund EA RPC calls that have not yet been committed)
  • the pending withdrawals (these are payable RPC calls that have not yet been committed)

To reflect balance updates, there are four methods defined on the account object.

func (a *account) managedTrackDeposit(amount types.Currency)
func (a *account) managedCommitDeposit(amount types.Currency, success bool)
func (a *account) managedCommitWithdrawal(amount types.Currency, success bool)
func (a *account) managedTrackWithdrawal(amount types.Currency)

Tracking a deposit adds it to the pendingDeposits, after which committing it will subtract it and update the account's balance depending on whether the deposit was successful. The same goes for withdrawals. Using this track+commit scheme allows us to perfectly reflect the actual account balance and also allows us to easily extend it when we deal with refunds in the MDM.

Example for Visual Changes

N/A

Checklist

Review and complete the checklist to ensure that the MR is complete before assigned to an approver.

  • All new methods or updated methods have clear docstrings
  • Testing added or updated for new methods
  • Any new packages are added to Makefile and .gitlab-ci.yml
  • API documentation updated for API updates
  • Module README.md updated for changes to workflow
  • Issue added to Sia-UI repo for new supporting features
  • Changelog File Created

Issues Closed

N/A

Edited by Peter-Jan Brone

Merge request reports