Skip to content

Commit

Permalink
Merge pull request #82 from getAlby/feat/nwc-balance-msat
Browse files Browse the repository at this point in the history
feat: convert balance from msat
  • Loading branch information
rolznz authored Sep 1, 2023
2 parents d4da195 + 21f6d99 commit c583f84
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/nwc/get-balance.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ const webln = new providers.NostrWebLNProvider({
await webln.enable();
const response = await webln.getBalance();

console.log(response);
console.info(response);

webln.close();
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"@types/node": "^18.11.0",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"@webbtc/webln-types": "^2.0.0",
"@webbtc/webln-types": "^2.0.1",
"browserify": "^17.0.0",
"eslint": "^8.46.0",
"eslint-config-prettier": "^9.0.0",
Expand Down
6 changes: 5 additions & 1 deletion src/webln/NostrWeblnProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,11 @@ export class NostrWebLNProvider implements WebLNProvider, Nip07Provider {
"get_balance",
undefined,
(result) => result.balance !== undefined,
(result) => result,
(result) => ({
// NWC uses msats - convert to sats for webln
balance: Math.floor(result.balance / 1000),
currency: "sats",
}),
);
}

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2119,10 +2119,10 @@
"@typescript-eslint/types" "6.4.0"
eslint-visitor-keys "^3.4.1"

"@webbtc/webln-types@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@webbtc/webln-types/-/webln-types-2.0.0.tgz#d0fae5d2bf253a77dccbd37b2c9752292b798686"
integrity sha512-tLYbKHDHUugArcw1nyAOelpMhno4FrCAcHiNm6Fzt4c9EqVbGpP9HSE9v4tSiWP+5oExecZ9cdWCAarDL/qoLw==
"@webbtc/webln-types@^2.0.1":
version "2.0.1"
resolved "https://registry.yarnpkg.com/@webbtc/webln-types/-/webln-types-2.0.1.tgz#760756e2a50e63392c8b3d129b59d172cd11d5dc"
integrity sha512-magyMAiN8u7PsECuj7PfFsStMne30E3QiyNfurL4mTTHse3lmG2Pkh3hDv3jh+D3PTWMfCgv1WFUKVmEgKbBkA==

JSONStream@^1.0.3, JSONStream@^1.3.5:
version "1.3.5"
Expand Down

0 comments on commit c583f84

Please sign in to comment.