mirror of
https://github.com/lumina-rocks/lumina.git
synced 2026-06-04 01:31:13 +02:00
fix: Add error handling for decoding bolt11 tags in ZapButton and ZapButtonListItem components
This commit is contained in:
@@ -126,8 +126,15 @@ export default function ZapButton({ event }: { event: any }) {
|
||||
events.forEach((event) => {
|
||||
event.tags.forEach((tag) => {
|
||||
if (tag[0] === 'bolt11') {
|
||||
let decoded = lightningPayReq.decode(tag[1]);
|
||||
sats = sats + decoded.satoshis;
|
||||
try {
|
||||
lightningPayReq.decode(tag[1]);
|
||||
let decoded = lightningPayReq.decode(tag[1]);
|
||||
sats = sats + decoded.satoshis;
|
||||
} catch (e) {
|
||||
console.error("Error decoding bolt11 tag:", e);
|
||||
console.log(tag[1]);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -49,9 +49,14 @@ export default function ZapButtonListItem({ event }: { event: NostrEvent }) {
|
||||
var lightningPayReq = require('bolt11');
|
||||
event.tags.forEach((tag) => {
|
||||
if (tag[0] === 'bolt11') {
|
||||
let decoded = lightningPayReq.decode(tag[1]);
|
||||
// console.log(decoded.satoshis);
|
||||
sats = decoded.satoshis;
|
||||
try {
|
||||
let decoded = lightningPayReq.decode(tag[1]);
|
||||
// console.log(decoded.satoshis);
|
||||
sats = decoded.satoshis;
|
||||
} catch (e) {
|
||||
console.error("Error decoding bolt11 tag:", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user