-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add examples for make-invoice and get-balance
- Loading branch information
Showing
3 changed files
with
46 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import * as crypto from 'node:crypto'; // required in node.js | ||
global.crypto = crypto; // required in node.js | ||
import 'websocket-polyfill' // required in node.js | ||
|
||
import * as readline from 'node:readline/promises'; | ||
import { stdin as input, stdout as output } from 'node:process'; | ||
|
||
import { webln as providers } from "../../dist/index.module.js"; | ||
|
||
const rl = readline.createInterface({ input, output }); | ||
|
||
const nwcUrl = await rl.question('Nostr Wallet Connect URL (nostrwalletconnect://...): '); | ||
rl.close(); | ||
|
||
const webln = new providers.NostrWebLNProvider({ nostrWalletConnectUrl: nwcUrl }); | ||
await webln.enable(); | ||
const response = await webln.getBalance(); | ||
|
||
console.log(response); | ||
|
||
webln.close(); |
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,24 @@ | ||
import * as crypto from 'node:crypto'; // required in node.js | ||
global.crypto = crypto; // required in node.js | ||
import 'websocket-polyfill' // required in node.js | ||
|
||
import * as readline from 'node:readline/promises'; | ||
import { stdin as input, stdout as output } from 'node:process'; | ||
|
||
import { webln as providers } from "../../dist/index.module.js"; | ||
|
||
const rl = readline.createInterface({ input, output }); | ||
|
||
const nwcUrl = await rl.question('Nostr Wallet Connect URL (nostrwalletconnect://...): '); | ||
rl.close(); | ||
|
||
const webln = new providers.NostrWebLNProvider({ nostrWalletConnectUrl: nwcUrl }); | ||
await webln.enable(); | ||
const response = await webln.makeInvoice({ | ||
amount: 100, | ||
defaultMemo: "NWC WebLN example" | ||
}); | ||
|
||
console.log(response); | ||
|
||
webln.close(); |
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