REF: lnurl class to ts

This commit is contained in:
overtorment 2024-09-08 15:32:55 +01:00
parent a61f8fcb29
commit ff6b412219
2 changed files with 6 additions and 3 deletions

View file

@ -3,7 +3,7 @@ import bolt11 from 'bolt11';
import createHash from 'create-hash';
import { createHmac } from 'crypto';
import CryptoJS from 'crypto-js';
// @ts-ignore
// @ts-ignore theres no types for secp256k1
import secp256k1 from 'secp256k1';
import { parse } from 'url'; // eslint-disable-line n/no-deprecated-api
@ -62,8 +62,8 @@ export default class Lnurl {
private _AsyncStorage: any;
private _preimage: string | false;
constructor(url: string, AsyncStorage?: any) {
this._lnurl = url;
constructor(url: string | false, AsyncStorage?: any) {
this._lnurl = url || '';
this._lnurlPayServiceBolt11Payload = false;
this._lnurlPayServicePayload = false;
this._AsyncStorage = AsyncStorage;

View file

@ -43,6 +43,9 @@ const LnurlPaySuccess: React.FC = () => {
switch (successAction.tag) {
case 'aes': {
const preimage = lnurl.getPreimage();
if (!preimage) {
break;
}
setMessage(Lnurl.decipherAES(successAction.ciphertext, preimage, successAction.iv));
setPreamble(successAction.description);
break;