aboutsummaryrefslogtreecommitdiffstats
path: root/routes/lightning/channelRequest.js
blob: 530fad48e639901b87c444940d2f42fe1d49f51f (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 "$routes/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.code(500).send(e.message);
  }
};