From 130290bdc79e3e51b9ba4f3631f92a5483a20721 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 10 Feb 2025 00:48:55 -0800 Subject: freeze check --- lib/payments.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lib') diff --git a/lib/payments.ts b/lib/payments.ts index cdb3610f..c35c3795 100644 --- a/lib/payments.ts +++ b/lib/payments.ts @@ -860,3 +860,19 @@ const reverse = async (p) => { warn("reversed", p.id); }; + +const freezeCheck = async () => { + const funds = await ln.listfunds(); + const balance = Math.round( + funds.channels.reduce((a, b) => a + b.our_amount_msat, 0) / 1000, + ); + const threshold = await g("freezethreshold"); + if (balance < threshold) { + await s("hardfreeze", true); + } else { + await s("hardfreeze", false); + } + + setTimeout(freezeCheck, 5000); +}; +freezeCheck(); -- cgit v1.2.3