-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into chore/rename-send-to-alby-account
- Loading branch information
Showing
4 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import * as readline from "node:readline/promises"; | ||
import { stdin as input, stdout as output } from "node:process"; | ||
import { auth, Client } from "../dist/index.module.js"; | ||
|
||
const rl = readline.createInterface({ input, output }); | ||
|
||
const paymentRequest = | ||
"lnbc10u1pj4t6w0pp54wm83znxp8xly6qzuff2z7u6585rnlcw9uduf2haa42qcz09f5wqdq023jhxapqd4jk6mccqzzsxqyz5vqsp5mlvjs8nktpz98s5dcrhsuelrz94kl2vjukvu789yzkewast6m00q9qyyssqupynqdv7e5y8nlul0trva5t97g7v3gwx7akhu2dvu4pn66eu2pr5zkcnegp8myz3wrpj9ht06pwyfn4dvpmnr96ejq6ygex43ymaffqq3gud4d"; | ||
|
||
const authClient = new auth.OAuth2User({ | ||
client_id: process.env.CLIENT_ID, | ||
client_secret: process.env.CLIENT_SECRET, | ||
callback: "http://localhost:8080", | ||
scopes: ["invoices:read"], // this scope isn't needed, but at least one scope is required to get an access token | ||
token: { | ||
access_token: undefined, | ||
refresh_token: undefined, | ||
expires_at: undefined, | ||
}, // initialize with existing token | ||
}); | ||
|
||
console.log(`Open the following URL and authenticate the app:`); | ||
console.log(authClient.generateAuthURL()); | ||
console.log("----\n"); | ||
|
||
const code = await rl.question("Code: (localhost:8080?code=[THIS CODE]: "); | ||
rl.close(); | ||
|
||
await authClient.requestAccessToken(code); | ||
console.log(authClient.token); | ||
const client = new Client(authClient); | ||
|
||
const response = await client.decodeInvoice(paymentRequest); | ||
|
||
console.log(JSON.stringify(response, null, 2)); |
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
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