src/blockchain/src/domain/service/BitcoinService.js
/**
   * (Imperative version)
   * Calculates the balance of the chain looking into all of the pending
   * transactions inside all the blocks in the chain
   *
   * @param {string}     address  Address to send reward to
   * @return {Money} Returns the user's total balance
   */
(Imperative version)
Calculates the balance of the chain looking into all of the pending
transactions inside all the blocks in the chain

@param {string}     address  Address to send reward to
@return {Money} Returns the user's total balance
( Imperative version ) Calculates the balance of the chain looking into all of the pending transactions inside all the blocks in the chain @param { string } address Address to send reward to @return { Money } Returns the user ' s total balance
function calculateBalanceOfWallet(address) {
    let balance = Money.zero()
    for (const block of ledger) {
      if (!block.isGenesis()) {
        for (const tx of block.data) {
          if (tx.sender === address) {
            balance = balance.minus(tx.funds)
          }
          if (tx.recipient === address) {
            balance = balance.plus(tx.funds)
          }
        }
      }
    }
    return balance.round()
  }
function calculateBalanceOfWallet ( address ) { let balance = Money . zero ( ) for ( const block of ledger ) { if ( ! block . isGenesis ( ) ) { for ( const tx of block . data ) { if ( tx . sender === address ) { balance = balance . minus ( tx . funds ) } if ( tx . recipient === address ) { balance = balance . plus ( tx . funds ) } } } } return balance . round ( ) }
(Imperative version)
 Calculates the balance of the chain looking into all of the pending
 transactions inside all the blocks in the chain
( Imperative version ) Calculates the balance of the chain looking into all of the pending transactions inside all the blocks in the chain