How to use the ln-service.subscribeToProbe function in ln-service

To help you get started, we’ve selected a few ln-service examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alexbosworth / balanceofsatoshis / telegram / pay_command.js View on Github external
({decodeCommand, decodeRequest, maxTokens}, cbk) =>
      {
        let probeTimeout;

        const sub = subscribeToProbe({
          cltv_delta: decodeRequest.cltv_delta + cltvDeltaBuffer,
          destination: decodeRequest.destination,
          lnd: decodeCommand.lnd,
          path_timeout_ms: pathTimeoutMs,
          routes: decodeRequest.routes,
          tokens: decodeRequest.tokens,
        });

        const finished = (err, res) => {
          clearTimeout(probeTimeout);

          sub.removeAllListeners();

          // Switch and return the final result

          return cbk(err, res);
github alexbosworth / balanceofsatoshis / network / execute_probe.js View on Github external
probe: ['validate', ({}, cbk) => {
        const attemptedPaths = [];
        const start = now();

        const sub = subscribeToProbe({
          cltv_delta: args.cltv_delta,
          destination: args.destination,
          ignore: args.ignore,
          is_strict_hints: !!args.is_strict_hints,
          lnd: args.lnd,
          max_fee: !args.is_strict_max_fee ? undefined : args.max_fee,
          max_timeout_height: args.max_timeout_height,
          outgoing_channel: args.outgoing_channel,
          path_timeout_ms: pathTimeoutMs,
          routes: args.routes,
          tokens: args.tokens,
        });

        const finished = (err, res) => {
          sub.removeAllListeners();
github submarineswaps / swaps-service / service / complete_swap_transaction.js View on Github external
({
        getInvoiceChainTip,
        getSwapFee,
        lnd,
        parsedInvoice,
        swapParams,
      },
      cbk) =>
    {
      const date = new Date().toISOString();
      const result = {};

      const sub = subscribeToProbe({
        lnd,
        cltv_delta: parsedInvoice.cltv_delta,
        destination: parsedInvoice.destination,
        max_fee: getSwapFee.converted_fee,
        routes: parsedInvoice.routes,
        tokens: parsedInvoice.tokens,
      });

      const timeout = setTimeout(() => {
        sub.removeAllListeners();

        return cbk([503, 'FailedToFindRouteWhenCompletingSwapTransaction']);
      },
      pathfindingTimeoutMs);

      sub.on('error', err => result.err = err);