-
-
Save wbobeirne/a0f8e587887d615648f906aac993febf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
initNode().then(() => { | |
/* ... */ | |
// Subscribe to all invoices, mark posts as paid | |
const stream = node.subscribeInvoices() as any as Readable<Invoice>; | |
stream.on('data', chunk => { | |
// Skip unpaid / irrelevant invoice updates | |
if (!chunk.settled || !chunk.amtPaidSat || !chunk.memo) return; | |
// Extract post id from memo, skip if we can't find an id | |
const id = parseInt(chunk.memo.replace('Lightning Posts post #', ''), 10); | |
if (!id) return; | |
// Mark the invoice as paid! | |
postsManager.markPostPaid(id); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment