From 6d0abc546e6ed63ee46fa85af1eb9b2d3f758210 Mon Sep 17 00:00:00 2001 From: JP Kiser Date: Tue, 30 Aug 2022 17:41:34 -0400 Subject: [PATCH] Add bolt11 decode bin executable --- bin.js | 16 ++++++++++++++++ package.json | 3 +++ 2 files changed, 19 insertions(+) create mode 100755 bin.js diff --git a/bin.js b/bin.js new file mode 100755 index 0000000..23c3820 --- /dev/null +++ b/bin.js @@ -0,0 +1,16 @@ +#!/usr/bin/env node + +// Call bolt11 decode from the command line. + +const decode = require('./payreq').decode + +const [,, command, invoice] = process.argv + +if (command !== 'decode') { + throw new Error('Invalid command, expected "bolt11 decode "') +} + +const results = decode(invoice) + +console.log(JSON.stringify(results, null, 2)) + diff --git a/package.json b/package.json index 297dd4a..339e1cc 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,9 @@ "test": "npm run standard && npm run coverage", "unit": "tape test/*.js" }, + "bin": { + "bolt11": "./bin.js" + }, "devDependencies": { "nyc": "^15.0.0", "standard": "*",