-
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 pull request #164 from getAlby/task-nwc-transactions
feat: add NWC listTransactions method
- Loading branch information
Showing
6 changed files
with
130 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"editor.formatOnSave": true, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"prettier.trailingComma": "all" | ||
} |
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,37 @@ | ||
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 = | ||
process.env.NWC_URL || | ||
(await rl.question("Nostr Wallet Connect URL (nostr+walletconnect://...): ")); | ||
rl.close(); | ||
|
||
const webln = new providers.NostrWebLNProvider({ | ||
nostrWalletConnectUrl: nwcUrl, | ||
}); | ||
await webln.enable(); | ||
|
||
const ONE_WEEK_IN_SECONDS = 60 * 60 * 24 * 7; | ||
const response = await webln.listTransactions({ | ||
from: Math.floor(new Date().getTime() / 1000 - ONE_WEEK_IN_SECONDS), | ||
until: Math.ceil(new Date().getTime() / 1000), | ||
limit: 30, | ||
// type: "incoming", | ||
}); | ||
|
||
console.info( | ||
response.transactions.length + "transactions, ", | ||
response.transactions.filter((t) => t.type === "incoming").length + | ||
" incoming", | ||
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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"trailingComma": "es5" | ||
"trailingComma": "all" | ||
} |
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