Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
({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);
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();
({
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);