forked from Kieran/snort
Catch invoice parsing errors
This commit is contained in:
parent
b8a6ad3f0c
commit
7f5974c4ea
@ -1,18 +1,20 @@
|
||||
import "./Invoice.css";
|
||||
import { decode as invoiceDecode } from "light-bolt11-decoder";
|
||||
import { useMemo } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
export default function Invoice(props) {
|
||||
const invoice = props.invoice;
|
||||
const navigate = useNavigate();
|
||||
|
||||
const info = useMemo(() => {
|
||||
let parsed = invoiceDecode(invoice);
|
||||
try {
|
||||
let parsed = invoiceDecode(invoice);
|
||||
|
||||
let amount = parseInt(parsed.sections.find(a => a.name === "amount")?.value);
|
||||
return {
|
||||
amount: !isNaN(amount) ? (amount / 1000) : null
|
||||
let amount = parseInt(parsed.sections.find(a => a.name === "amount")?.value);
|
||||
return {
|
||||
amount: !isNaN(amount) ? (amount / 1000) : null
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}, [invoice]);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user