diff --git a/backend/api/account/accountController.js b/backend/api/account/accountController.js index 928a4fe..f36a56a 100644 --- a/backend/api/account/accountController.js +++ b/backend/api/account/accountController.js @@ -30,6 +30,20 @@ const payInvoice = async (req, res) => { } }; +const getAccountBalance = async (req, res) => { + try { + const response = await accountService.getAccountBalance(); + + debug.info(`Account Balance Response: ${JSON.stringify(response)}`); + if (!response.success) res.status(500).json(response); + else res.status(200).json(response); + + } catch (error) { + debug.error(error.stack); + res.status(500).json({ message: error.message, error: error.stack }); + } +}; + const createInvoice = async (req, res) => { try { const amountMillisats = req.body.amountMillisats; @@ -44,4 +58,4 @@ const createInvoice = async (req, res) => { } }; -module.exports = { getAccountAllowance, payInvoice, createInvoice }; +module.exports = { getAccountAllowance, payInvoice, createInvoice, getAccountBalance }; diff --git a/backend/api/account/index.js b/backend/api/account/index.js index 32a31c9..98ac1ff 100644 --- a/backend/api/account/index.js +++ b/backend/api/account/index.js @@ -1,11 +1,9 @@ const express = require('express'); const router = express(); -const { getAccountAllowance, payInvoice, createInvoice } = require('./accountController'); +const { getAccountAllowance, payInvoice, createInvoice, getAccountBalance } = require('./accountController'); -const { getBalance } = require('../../sensei/nodes'); - -router.get('/account/balance', getBalance); +router.get('/account/balance', getAccountBalance); router.get('/allowance', getAccountAllowance); router.get('/payment/send', payInvoice); router.get('/payment/receive', createInvoice);