* Returns the balance of a given wallet address. * * @param {string} address * @returns {number} The balance of the wallet
(address)
| 250 | * @returns {number} The balance of the wallet |
| 251 | */ |
| 252 | getBalanceOfAddress(address) { |
| 253 | let balance = 0; |
| 254 | |
| 255 | for (const block of this.chain) { |
| 256 | for (const trans of block.transactions) { |
| 257 | if (trans.fromAddress === address) { |
| 258 | balance -= trans.amount; |
| 259 | } |
| 260 | |
| 261 | if (trans.toAddress === address) { |
| 262 | balance += trans.amount; |
| 263 | } |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | debug('getBalanceOfAdrees: %s', balance); |
| 268 | return balance; |
| 269 | } |
| 270 | |
| 271 | /** |
| 272 | * Returns a list of all transactions that happened |
no outgoing calls
no test coverage detected