diff --git a/frontend/react-material-admin/src/pages/lightning/Lightning.js b/frontend/react-material-admin/src/pages/lightning/Lightning.js index 153e99ef..e34adc88 100644 --- a/frontend/react-material-admin/src/pages/lightning/Lightning.js +++ b/frontend/react-material-admin/src/pages/lightning/Lightning.js @@ -25,7 +25,7 @@ import PageTitle from "../../components/PageTitle"; import Widget from "../../components/Widget"; import { Typography } from "../../components/Wrappers"; -import { GetInfoRequest } from "../../proto/lnd_pb" +import { GetInfoRequest, WalletBalanceRequest } from "../../proto/lnd_pb" import { SqueakAdminClient } from "../../proto/squeak_admin_grpc_web_pb" var client = new SqueakAdminClient('http://' + window.location.hostname + ':8080') @@ -35,6 +35,7 @@ export default function LightningPage() { var theme = useTheme(); const [lndInfo, setLndInfo] = useState(null); + const [walletBalance, setWalletBalance] = useState(null); const getLndInfo = () => { console.log("called getLndInfo"); @@ -48,10 +49,24 @@ export default function LightningPage() { setLndInfo(response); }); }; + const getWalletBalance = () => { + console.log("called getWalletBalance"); + + var walletBalanceRequest = new WalletBalanceRequest() + console.log(walletBalanceRequest); + + client.lndWalletBalance(walletBalanceRequest, {}, (err, response) => { + console.log(response); + setWalletBalance(response); + }); + }; useEffect(()=>{ getLndInfo() },[]); + useEffect(()=>{ + getWalletBalance() + },[]); function NoInfoContent() { return ( @@ -81,38 +96,43 @@ export default function LightningPage() { function InfoContent() { return ( <> - {PubkeyGridItem()} - {StatusGridItem()} + + {PubkeyGridItem()} + + + {StatusGridItem()} + {ChannelsGridItem()} + {BalanceGridItem()} + > ) } function PubkeyGridItem() { return ( - - - - - - {lndInfo.getIdentityPubkey()} - - - - - + + + + + pubkey + + + {lndInfo.getIdentityPubkey()} + + + ) } function StatusGridItem() { return ( - - + ) + } + + function ChannelsGridItem() { + return ( + + + + + + num_pending_channels + + {lndInfo.getNumPendingChannels()} + + + + num_active_channels + + {lndInfo.getNumActiveChannels()} + + + + num_inactive_channels + + {lndInfo.getNumInactiveChannels()} + + + + + ) + } + + function BalanceGridItem() { + return ( + + + + + + total balance + + {walletBalance.getTotalBalance()} + + + + confirmed balance + + {walletBalance.getConfirmedBalance()} + + + + unconfirmed balance + + {walletBalance.getUnconfirmedBalance()} + + + + ) } return ( <> - {lndInfo + {(lndInfo && walletBalance) ? InfoContent() : NoInfoContent() }