Skip to content

feat: add simpler LNClient class#344

Merged
rolznz merged 31 commits into
masterfrom
feat/lnclient
Apr 11, 2025
Merged

feat: add simpler LNClient class#344
rolznz merged 31 commits into
masterfrom
feat/lnclient

Conversation

@rolznz

@rolznz rolznz commented Mar 20, 2025

Copy link
Copy Markdown
Member

Closes #343 and #342

This PR adds a simpler way for new developers to interact with a lightning wallet. You only need a couple lines to do cool stuff. Unlike the NWCClient, the LNClient uses satoshi values (is this confusing?)

Alby JS SDK is now dependent on the lightning tools package. (Pros: devs don't need to install both and could have some of the functions easily available here)

Most of the README is now moved into separate readme files (see docs)

Separate components (NWC, WebLN, LNClient, OAuth) are now in separate folders. This is an update to 5.0.0 as some of the imports are breaking changes.

OAuth examples are now moved into a subfolder.

I haven't proxied all the methods yet, I wonder if it's better to just make the internal nwcClient publicly accesible (as it is now)

TODOs:

Comment thread src/LNClient.ts Outdated
Comment thread src/LNClient.ts Outdated
Comment thread docs/ln.md Outdated
Comment thread src/LNClient.ts Outdated
Comment thread src/LNClient.ts Outdated
Comment thread docs/ln.md Outdated
Comment thread src/LNClient.ts Outdated
Comment thread src/LNClient.ts Outdated
Comment thread src/LNClient.ts Outdated
Comment thread src/LNClient.ts Outdated
Comment thread src/LNClient.ts Outdated

@bumi bumi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is great!

Comment thread docs/lnclient.md
Comment thread docs/nwc.md
import { nwc } from "@getalby/sdk";
const nwcClient = new nwc.NWCClient({
nostrWalletConnectUrl: loadNWCUrl(),
}); // loadNWCUrl is some function to get the NWC URL from some (encrypted) storage

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should sync the naming here.
connection URI vs. credentials vs. secret, ... 🙈

Comment thread examples/lnclient/paywall.js Outdated
Comment thread examples/lnclient/paywall.js Outdated
Comment thread src/lnclient/LNClient.ts
bumi added 2 commits April 6, 2025 13:08
This example shows how to receive a payment and split it to other recipients
@bumi

bumi commented Apr 6, 2025

Copy link
Copy Markdown
Contributor

maybe some more Money inspiration: https://www.npmjs.com/package/ts-money (not for here as a dependency though)

Comment thread src/lnclient/FiatAmount.ts
bumi and others added 2 commits April 6, 2025 14:56
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@bumi
bumi temporarily deployed to github-pages April 7, 2025 13:54 — with GitHub Actions Inactive
Co-authored-by: Michael Bumann <hello@michaelbumann.com>
Comment thread README.md
* feat: allow comment and payerdata in LNClient pay method

* fix: apply transaction metadata to all related transaction method types

* chore: update example and lnclient docs to pay ln address with extra metadata
* docs: add some comments to the examples

* docs: comments

* feat: add lnclient receive timeout for ReceiveInvoice class (#357)

* chore: remove unnecessary comment

* chore: remove unnecessary comment

---------

Co-authored-by: Roland <33993199+rolznz@users.noreply.github.com>
Comment thread src/lnclient/LNClient.ts
* @param args additional options, e.g. to set a description on the payment request, or store metadata for the received payment
* @returns the invoice to be paid, along with methods to easily listen for a payment and act upon it.
*/
async receive(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if the name receive is misleading since it actually returns an invoice which could be paid. But I can't think of a better name.

@rolznz
rolznz merged commit 03042df into master Apr 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simplify fiat amount usage

2 participants