Skip to content

Instantly share code, notes, and snippets.

@pseudozach
Created November 3, 2021 16:41
Show Gist options
  • Save pseudozach/e28e62aa5185599139ebe182edd6ada7 to your computer and use it in GitHub Desktop.
Save pseudozach/e28e62aa5185599139ebe182edd6ada7 to your computer and use it in GitHub Desktop.
Get HTLCs that are about to timeout
var shell = require('shelljs');
let deltablock = 13
// finds the lowest expiration_height across all pending HTLCs
let nearesttimeout = shell.exec("lncli listchannels | jq '.[][] | .pending_htlcs[] | .expiration_height ' | sort -n | head -1").stdout.trim();
let currentblockheight = shell.exec("lncli getinfo | jq '.block_height'").stdout.trim();
console.log(`nearesttimeout, currentblockheight `,nearesttimeout, currentblockheight);
if(nearesttimeout - currentblockheight < deltablock) {
console.log(`timeout is within ${deltablock}`)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment