Skip to content

Commit

Permalink
lnurl/lnurl-pay: convert js to ts
Browse files Browse the repository at this point in the history
I had to change the '|', otherwise typescript would
complain this error msg:
```
The '|' operator is not allowed for boolean types.
Consider using '||' instead.
```
  • Loading branch information
Mersho committed Oct 25, 2023
1 parent 6b004a3 commit 22f726b
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions lnurl/lnurl-pay.js → lnurl/lnurl-pay.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const axios = require('axios').default;
const logger = require('../logger');
import axios from 'axios';
import logger from "../logger";

// {
// pr: String, // bech32-serialized lightning invoice
// routes: [], // an empty array
// }
const resolvLightningAddress = async (address, amountMsat) => {
const resolvLightningAddress = async (address: string, amountMsat: number) => {
const [user, domain] = address.split('@');
const lnAddressQuery = `https://${domain}/.well-known/lnurlp/${user}`;

Expand All @@ -17,7 +17,7 @@ const resolvLightningAddress = async (address, amountMsat) => {
}

if (
(lnAddressRes.minSendable > amountMsat) |
(lnAddressRes.minSendable > amountMsat) ||
(lnAddressRes.maxSendable < amountMsat)
) {
logger.info('lnAddress invalid amount');
Expand All @@ -31,7 +31,7 @@ const resolvLightningAddress = async (address, amountMsat) => {
return res;
};

const existLightningAddress = async address => {
const existLightningAddress = async (address: string) => {
const [user, domain] = address.split('@');
const lnAddressQuery = `https://${domain}/.well-known/lnurlp/${user}`;

Expand All @@ -49,7 +49,4 @@ const existLightningAddress = async address => {
}
};

module.exports = {
resolvLightningAddress,
existLightningAddress,
};
export { resolvLightningAddress, existLightningAddress }

0 comments on commit 22f726b

Please sign in to comment.