aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/Avatar.svelte
blob: 09b6c0374bd758cc3d50745c99d067f65fd08486 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
generated by cgit v1.2.3 (git 2.51.0) at 2026-10-19 06:13:18 +0000
 


 class="nx">user) {
    return res.status(500).send("Couldn't find the user you're trying to pay");
  }
  let err = m => res.status(500).send(m);

  let invoice;
  try {
    invoice = await lnb.addInvoice({ value: amount });
  } catch (e) {
    return err(e.message);
  }

  let hash = invoice.payment_request;

  await db.Payment.create({
    user_id: user.id,
    hash,
    amount,
    rate: app.get("rates")[req.user.currency],
    currency: req.user.currency,
    tip: 0,
    confirmed: true,
    received: false,
    asset: 'LNBTC',
  });

  req.url = "/sendPayment";
  let payreq = bolt11.decode(hash);
  const { routes } = await lna.queryRoutes({ "pub_key": payreq.payeeNodeKey, "amt": payreq.satoshis });
  if (routes.length) req.body.route = routes[0];
  else return res.status(500).send("No route available");
  req.body.payreq = hash;

  return app._router.handle(req, res);
};