From 98fae6c9aeafd650996b911dd9d7598e6d8433c9 Mon Sep 17 00:00:00 2001 From: k00b Date: Wed, 11 Dec 2024 15:38:38 -0600 Subject: [PATCH] prioritize payment reliability --- api/payingAction/index.js | 5 +++-- lib/constants.js | 1 + worker/paidAction.js | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/api/payingAction/index.js b/api/payingAction/index.js index 0d276537..2ff7117a 100644 --- a/api/payingAction/index.js +++ b/api/payingAction/index.js @@ -1,4 +1,4 @@ -import { LND_PATHFINDING_TIMEOUT_MS } from '@/lib/constants' +import { LND_PATHFINDING_TIME_PREF_PPM, LND_PATHFINDING_TIMEOUT_MS } from '@/lib/constants' import { msatsToSats, satsToMsats, toPositiveBigInt } from '@/lib/format' import { Prisma } from '@prisma/client' import { parsePaymentRequest, payViaPaymentRequest } from 'ln-service' @@ -44,7 +44,8 @@ export default async function performPayingAction ({ bolt11, maxFee, walletId }, lnd, request: withdrawal.bolt11, max_fee: msatsToSats(withdrawal.msatsFeePaying), - pathfinding_timeout: LND_PATHFINDING_TIMEOUT_MS + pathfinding_timeout: LND_PATHFINDING_TIMEOUT_MS, + confidence: LND_PATHFINDING_TIME_PREF_PPM }).catch(console.error) return withdrawal diff --git a/lib/constants.js b/lib/constants.js index 978343ea..995253dc 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -79,6 +79,7 @@ export const ANON_FEE_MULTIPLIER = 100 export const SSR = typeof window === 'undefined' export const MAX_FORWARDS = 5 export const LND_PATHFINDING_TIMEOUT_MS = 30000 +export const LND_PATHFINDING_TIME_PREF_PPM = 1e6 // optimize for reliability over fees export const LNURLP_COMMENT_MAX_LENGTH = 1000 // https://github.com/lightning/bolts/issues/236 export const MAX_INVOICE_DESCRIPTION_LENGTH = 640 diff --git a/worker/paidAction.js b/worker/paidAction.js index 70396ddb..fa000b3a 100644 --- a/worker/paidAction.js +++ b/worker/paidAction.js @@ -1,7 +1,7 @@ import { getPaymentFailureStatus, hodlInvoiceCltvDetails, getPaymentOrNotSent } from '@/api/lnd' import { paidActions } from '@/api/paidAction' import { walletLogger } from '@/api/resolvers/wallet' -import { LND_PATHFINDING_TIMEOUT_MS, PAID_ACTION_TERMINAL_STATES } from '@/lib/constants' +import { LND_PATHFINDING_TIME_PREF_PPM, LND_PATHFINDING_TIMEOUT_MS, PAID_ACTION_TERMINAL_STATES } from '@/lib/constants' import { formatMsats, formatSats, msatsToSats, toPositiveNumber } from '@/lib/format' import { datePivot } from '@/lib/time' import { Prisma } from '@prisma/client' @@ -270,6 +270,7 @@ export async function paidActionForwarding ({ data: { invoiceId, ...args }, mode request: bolt11, max_fee_mtokens: String(maxFeeMsats), pathfinding_timeout: LND_PATHFINDING_TIMEOUT_MS, + confidence: LND_PATHFINDING_TIME_PREF_PPM, max_timeout_height: maxTimeoutHeight }).catch(console.error) }