2023-04-12 08:24:27 -04:00
NIP-83
======
Wallet connect/bridge
--------------
2023-04-12 08:41:39 -04:00
`draft` `optional` `author:arcbtc` `author:blackcoffeexbt`
2023-04-12 08:24:27 -04:00
2023-04-12 08:59:24 -04:00
Useful for clients wanting to intergrate wallet features, could be custodial or non-custodial or both.
2023-04-12 08:24:27 -04:00
> Intended for use with bitcoin, but could be used with any invoice payment system that can pay invoices/create invoices/check payment status.
## Motivation
2023-04-12 09:08:16 -04:00
All bitcoin lightning wallet clients connected to nodes use http, they should also be able to use nostr.
2023-04-12 09:13:39 -04:00
Simple plugins/middleware/libraries could be easily made for existing nodes and lightning wallet software.
2023-04-12 08:24:27 -04:00
## Examples
2023-04-12 08:34:26 -04:00
There are two simple clients sending json over [NIP04 ](https://github.com/nostr-protocol/nips/blob/master/04.md ). These clients could be standalone or built into clients/services.
2023-04-12 08:24:27 -04:00
2023-04-12 08:34:26 -04:00
1. `funding source client` : Connected to the funding source.
2023-04-12 08:24:27 -04:00
2023-04-12 08:34:26 -04:00
2. `service client` : Built into service/client that wants wallet functions.
2023-04-12 08:24:27 -04:00
2023-04-12 08:39:33 -04:00
### Permissions
In `funding source client` nostr pubkeys used by `service client` are given and permissions granted (such as `read` /`create_invoice_only`/`pay_invoices`)
2023-04-12 08:24:27 -04:00
### Creating an invoice
`service client` sends `create_invoice` event:
```json
2023-04-12 08:27:24 -04:00
{
"create_invoice":{
"amount":"int",
"memo":"< Optional [ str ] > ",
"description_hash":"< Optional [ bytes ] > "
}
2023-04-12 08:24:27 -04:00
}
```
`funding source client` checks the pubkey has permission and sends `generated_invoice` event:
```json
2023-04-12 08:27:24 -04:00
{
"generated_invoice":{
"payment_hash":"< string > ",
"payment_request":"< string > "
}
2023-04-12 08:24:27 -04:00
}
```
### Paying an invoice
`service client` sends `pay_invoice` event:
```json
2023-04-12 08:27:24 -04:00
{
"pay_invoice":{
"invoice":"< string > ",
"note":"< Optional [ str ] > "
}
2023-04-12 08:24:27 -04:00
}
```
2023-04-12 08:39:33 -04:00
`funding source client` checks the pubkey has permission and attempts to pay the invoice.
2023-04-12 08:24:27 -04:00
### Checking a payment in/out
`service client` sends `check_payment` event:
```json
2023-04-12 08:27:24 -04:00
{
"check_payment":{
"payment_hash":"< string > "
}
2023-04-12 08:24:27 -04:00
}
```
`funding source client` checks the pubkey has permission, checks the payment status and sends `payment_status` event:
```json
2023-04-12 08:27:24 -04:00
{
"payment_status":{
"paid":"< bool > "
}
2023-04-12 08:24:27 -04:00
}
```