aboutsummaryrefslogtreecommitdiffstats
path: root/routes/lightning/channelRequest.js
blob: e89389295f895a04f7c07c7563904e9548809215 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { lnurlServer } from "$lnurl";

export default async (req, res) => {
  let { localAmt, pushAmt } = req.body;

  pushAmt = 0;

  try {
    if (localAmt < 20000)
      throw new Error("amount must be greater than 20000 SAT");
    if (localAmt > 1000000) throw new Error("amount must be <= 1000000");

    const result = await lnurlServer.generateNewUrl("channelRequest", {
      localAmt,
      pushAmt
    });

    res.send(result);
  } catch (e) {
    err("problem generating channel request", e.message);
    res.status(500).send(e.message);
  }
};