# nip47

> A flexible library for sending and receiving payments via NWC.

Latest version **0.0.5** (published 2023-12-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install nip47
pnpm add nip47
yarn add nip47
bun add nip47
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2023-12-06 |
| First published | 2023-12-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 11.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | gudnuf |
| Maintainers | gudnuf |
| Keywords | nostr, nip47, nip-47, nwc, wallet connect, nostr wallet connect, lightning |

## Links

- npm: https://www.npmjs.com/package/nip47
- Repository: https://github.com/gudnuf/nip47
- Homepage: https://github.com/gudnuf/nip47#readme
- Issues: https://github.com/gudnuf/nip47/issues
- npm.io page: https://npm.io/package/nip47

## Dependencies (3)

- [mocha](https://npm.io/package/mocha.md) ^10.2.0
- [nostr-tools](https://npm.io/package/nostr-tools.md) ^1.17.0
- [@nostr-dev-kit/ndk](https://npm.io/package/@nostr-dev-kit/ndk.md) ^2.2.0

## Recent versions

- 0.0.5 (latest) — 2023-12-06
- 0.0.4 — 2023-12-06
- 0.0.3 — 2023-12-06
- 0.0.2 — 2023-12-06
- 0.0.1 — 2023-12-06

## README

# NIP-47

This is a very basic library that helps you construct payment requests and listen to responses.

You are expected to handle the actual broadcasting of the event and the subscription for the payment response.

There are two things you will need to create an `PaymentRequestEvent`.

1. An NWC Url with a secret.

2. An invoice you want to pay.

## Usage

```
import { PaymentRequestEvent } from 'nip-47';

const paymentRequest = await PaymentRequestEvent.create(nwcUrl, invoice);

const responseFilter = paymentRequest.responseFilter'

const relay = paymentRequest.relayToListenTo;
```

Now, you should:

1. create a subscription on the `relay` to the `responseFilter`

2. broadcast the `paymentRequest`

3. hear the response and handle it

## TODO

- Add ability to broadcast payment request

- Create a subscription manager to wait for all incoming payment responses

- Add the `getInfo` method

- Create some methods for handling different response errors

---
_Source: https://npm.io/package/nip47 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
