Skip to content

Commit f3e6aa2

Browse files
grunchclaude
andauthored
feat: add DISABLE_LN_ADDRESS kill-switch for Lightning Address payouts (#830)
* feat: add DISABLE_LN_ADDRESS kill-switch for Lightning Address payouts Adds a temporary, reversible mitigation to disable Lightning Address auto-resolution as a security measure. When DISABLE_LN_ADDRESS=true, buyers are routed to the manual BOLT11 invoice flow instead of having their saved Lightning Address resolved automatically. - Guards all three resolvLightningAddress call sites (commands.ts and both addInvoice wizards in scenes.ts) - Saved Lightning Addresses are kept and ignored, so the change is fully reversible by unsetting the flag - Default (unset/empty) keeps Lightning Address enabled, no behavior change unless explicitly activated - Adds en/es locale strings for the user-facing notice Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * chore: sync package-lock.json version with package.json (0.15.1) The lockfile version was left at 0.15.0 while package.json is at 0.15.1, causing the ci_to_main format check (git diff --exit-code after npm install) to fail. Only the version field is updated; no dependencies change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 75bbb31 commit f3e6aa2

6 files changed

Lines changed: 34 additions & 3 deletions

File tree

.env-sample

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ BOT_HANDLER_TIMEOUT=60000
7070
# Attempts to pay the invoice again when the payment failed
7171
PAYMENT_ATTEMPTS=2
7272

73+
# Temporary kill-switch to disable Lightning Address payouts (security mitigation).
74+
# When set to "true", buyers must paste a regular BOLT11 invoice; saved Lightning
75+
# Addresses are kept and ignored. Leave empty/unset to keep Lightning Address enabled.
76+
DISABLE_LN_ADDRESS=
77+
7378
# Here will go the disputes from non community orders
7479
DISPUTE_CHANNEL='@p2plnbotDispute'
7580

bot/commands.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,19 @@ const addInvoice = async (
178178
const seller = await User.findOne({ _id: order.seller_id });
179179
if (seller === null) throw new Error('seller was not found');
180180

181-
if (buyer.lightning_address) {
181+
// Temporary mitigation: when DISABLE_LN_ADDRESS is enabled we skip the
182+
// Lightning Address auto-resolution and route the buyer to the manual
183+
// BOLT11 invoice flow. We do NOT delete the saved address, so this is
184+
// fully reversible by unsetting the flag.
185+
const lnAddressDisabled = process.env.DISABLE_LN_ADDRESS === 'true';
186+
if (buyer.lightning_address && lnAddressDisabled) {
187+
await bot.telegram.sendMessage(
188+
buyer.tg_id,
189+
ctx.i18n.t('ln_address_temporarily_disabled'),
190+
);
191+
}
192+
193+
if (buyer.lightning_address && !lnAddressDisabled) {
182194
const laRes = await resolvLightningAddress(
183195
buyer.lightning_address,
184196
order.amount * 1000,

bot/scenes.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ const addInvoiceWizard = new Scenes.WizardScene(
6161

6262
let lnInvoice = ctx.message.text.trim();
6363
const isValidLN = await validateLightningAddress(lnInvoice);
64+
// Temporary mitigation: Lightning Address payouts are disabled.
65+
// The buyer can still receive sats by pasting a regular BOLT11 invoice.
66+
if (isValidLN && process.env.DISABLE_LN_ADDRESS === 'true') {
67+
await ctx.reply(ctx.i18n.t('ln_address_temporarily_disabled'));
68+
return;
69+
}
6470
let res: InvoiceParseResult = {};
6571
if (isValidLN) {
6672
const laRes = await resolvLightningAddress(
@@ -128,6 +134,12 @@ const addInvoicePHIWizard = new Scenes.WizardScene(
128134

129135
let lnInvoice = ctx.message.text.trim();
130136
const isValidLN = await validateLightningAddress(lnInvoice);
137+
// Temporary mitigation: Lightning Address payouts are disabled.
138+
// The buyer can still receive sats by pasting a regular BOLT11 invoice.
139+
if (isValidLN && process.env.DISABLE_LN_ADDRESS === 'true') {
140+
await ctx.reply(ctx.i18n.t('ln_address_temporarily_disabled'));
141+
return;
142+
}
131143
let res: InvoiceParseResult = {};
132144
if (isValidLN) {
133145
const laRes = await resolvLightningAddress(

locales/en.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ must_be_valid_currency: 'Fiat_code must be a valid code, for example: USD, EUR.
243243
must_be_number_or_range: 'Fiat_amount must be a number or numeric range in the <minimum>-<maximum> format'
244244
invalid_lightning_address: Invalid lightning address
245245
unavailable_lightning_address: Unavailable lightning address ${la}
246+
ln_address_temporarily_disabled: ⚠️ Lightning Address payouts are temporarily disabled for maintenance. Please send a regular Lightning invoice (BOLT11) for the exact order amount to receive your sats.
246247
help: |
247248
/sell <_sats amount_> <_fiat amount_> <_fiat code_> <_payment method_> [premium/discount] - Creates a Sell order
248249
/buy <_sats amount_> <_fiat amount_> <_Fiat code_> <_payment method_> [premium/discount] - Creates a Purchase Order

locales/es.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ must_be_valid_currency: 'codigo_fiat debe ser un código de moneda válido, ejem
240240
must_be_number_or_range: 'monto_en_fiat debe ser un número o un rango numerico de la forma: <mínimo>-<máximo>.'
241241
invalid_lightning_address: Dirección lightning no válida
242242
unavailable_lightning_address: Dirección lightning ${la} no disponible
243+
ln_address_temporarily_disabled: ⚠️ Los pagos a Lightning Address están temporalmente deshabilitados por mantenimiento. Por favor envía una factura Lightning normal (BOLT11) por el monto exacto de la orden para recibir tus sats.
243244
help: |
244245
/sell <_monto en sats_> <_monto en fiat_> <_código fiat_> <_método de pago_> [prima/descuento] - Crea una orden de venta
245246
/buy <_monto en sats_> <_monto en fiat_> <_código fiat_> <_método de pago_> [prima/descuento] - Crea una orden de compra

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)