Skip to content

Commit

Permalink
chore: changes
Browse files Browse the repository at this point in the history
  • Loading branch information
im-adithya committed Jul 10, 2024
1 parent e62b2a7 commit f92613d
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ or for use without any build tools:

```html
<script type="module">
import { webln } from "https://esm.sh/@getalby/[email protected].0"; // jsdelivr.net, skypack.dev also work
import { webln } from "https://esm.sh/@getalby/[email protected].1"; // jsdelivr.net, skypack.dev also work
(async () => {
const client = new nwc.NWCClient({
Expand Down Expand Up @@ -112,25 +112,12 @@ const client = nwc.NWCClient.withNewSecret({
await client.initNWC();
```

#### sendPayment(invice: string)

Takes a bolt11 invoice and calls the NWC `pay_invoice` function.
It returns a promise object that is resolved with an object with the preimage or is rejected with an error

##### Example

```js
const client = new nwc.NWCClient({ nostrWalletConnectUrl: loadNWCUrl() });
const response = await client.payInvoice({ invoice });
console.log(response);
```

#### getNostrWalletConnectUrl()
#### `getNostrWalletConnectUrl()`

Returns the `nostr+walletconnect://` URL which includes all the connection information (`walletPubkey`, `relayUrl`, `secret`)
This can be used to get and persist the string for later use.

#### initNWC({name: string})
#### `initNWC({ name: string })`

Opens a new window prompt with the `getAuthorizationUrl()` (the user's NWC UI) to ask the user to authorize the app connection.
The promise resolves when the connection is authorized and the popup sends a `nwc:success` message or rejects when the prompt is closed.
Expand All @@ -153,6 +140,21 @@ try {
}
```

#### `payInvoice({ invoice: string })`

Takes a bolt11 invoice and calls the NWC `pay_invoice` function.
It returns a promise object that is resolved with an object with the preimage or is rejected with an error

##### Example

```js
const client = new nwc.NWCClient({ nostrWalletConnectUrl: loadNWCUrl() });
const response = await client.payInvoice({ invoice });
console.log(response);
```

See other [NIP-47 method examples](https://github.com/getAlby/js-sdk/tree/master/examples/nwc/client).

#### For Node.js

To use this on Node.js you first must install `websocket-polyfill` and import it:
Expand Down Expand Up @@ -273,7 +275,7 @@ const nwc = NostrWebLNProvider.withNewSecret();
await nwc.initNWC();
```
#### sendPayment(invice: string)
#### sendPayment(invoice: string)
Takes a bolt11 invoice and calls the NWC `pay_invoice` function.
It returns a promise object that is resolved with an object with the preimage or is rejected with an error
Expand Down

0 comments on commit f92613d

Please sign in to comment.