diff options
| author | Adam Soltys <[email protected]> | 2025-02-10 00:48:55 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-02-10 00:51:20 -0800 |
| commit | 130290bdc79e3e51b9ba4f3631f92a5483a20721 (patch) | |
| tree | 3861e2ed2c7157f12b54c1a81a30e1f332f2c773 /lib | |
| parent | 00d9c43118ebc032031512f877bbb061c1bccfe7 (diff) | |
| download | coinos-server-130290bdc79e3e51b9ba4f3631f92a5483a20721.tar.gz coinos-server-130290bdc79e3e51b9ba4f3631f92a5483a20721.zip | |
freeze check
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/payments.ts | 16 |
1 files changed, 16 insertions, 0 deletions
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(); |
