Skip to content

Commit

Permalink
bell and whistles
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardobl committed Jul 24, 2024
1 parent 299007e commit 88da075
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 108 deletions.
35 changes: 1 addition & 34 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,39 +1,6 @@
> Use any license you like, its your extension.

---

# DON'T BE A DICK PUBLIC LICENSE

> Version 1.1, December 2016

> Copyright (C) 2024 Alan Bits

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document.

> DON'T BE A DICK PUBLIC LICENSE
> TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

1. Do whatever you like with the original work, just don't be a dick.

Being a dick includes - but is not limited to - the following instances:

1a. Outright copyright infringement - Don't just copy this and change the name.
1b. Selling the unmodified original with no work done what-so-ever, that's REALLY being a dick.
1c. Modifying the original work to contain hidden harmful content. That would make you a PROPER dick.

2. If you become rich through modifications, related works/services, or supporting the original work,
share the love. Only a dick would make loads off this work and not buy the original work's
creator(s) a pint.

3. Code is provided with no warranty. Using somebody else's code and bitching when it goes wrong makes
you a DONKEY dick. Fix the problem yourself. A non-dick would submit the fix back.

---

# MIT License

> Copyright (c) 2024 Alan Bits
Copyright (c) 2024 Riccardo Balbo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
42 changes: 28 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
`The README.md typically serves as a guide for using the extension.`
# NWC Service Provider Extension for [LNbits](https://github.com/lnbits/lnbits)

# NWCService - An [LNbits](https://github.com/lnbits/lnbits) Extension
Easily connect your LNbits wallets via [NWC](https://nwc.dev/).

## A Starter Template for Your Own Extension
## Installation

Ready to start hacking? Once you've forked this extension, you can incorporate functions from other extensions as needed.
Install the extension via the .env file or through the admin UI on your LNbits server. More details can be found [here](https://github.com/lnbits/lnbits/wiki/LNbits-Extensions).

### How to Use This Template
> This guide assumes you're using this extension as a base for a new one, and have installed LNbits using https://github.com/lnbits/lnbits/blob/main/docs/guide/installation.md#option-1-recommended-poetry.
## Configuration

1. Install and enable the extension either through the official LNbits manifest or by adding https://raw.githubusercontent.com/lnbits/nwcservice/main/manifest.json to `"Server"/"Server"/"Extension Sources"`. ![Extension Sources](https://i.imgur.com/MUGwAU3.png) ![image](https://github.com/lnbits/nwcservice/assets/33088785/4133123b-c747-4458-ba6c-5cc7c0f124d8)
Configure the extension from the "Settings" page in the top right menu when logged in as admin inside the extension page.

2. `Ctrl c` shut down your LNbits installation.
3. Download the extension files from https://github.com/lnbits/nwcservice to a folder outside of `/lnbits`, and initialize the folder with `git`. Alternatively, create a repo, copy the nwcservice extension files into it, then `git clone` the extension to a location outside of `/lnbits`.
4. Remove the installed extension from `lnbits/lnbits/extensions`.
5. Create a symbolic link using `ln -s /home/ben/Projects/<name of your extension> /home/ben/Projects/lnbits/lnbits/extensions`.
6. Restart your LNbits installation. You can now modify your extension and `git push` changes to a repo.
7. When you're ready to share your manifest so others can install it, edit `/lnbits/nwcservice/manifest.json` to include the git credentials of your extension.
8. IMPORTANT: If you want your extension to be added to the official LNbits manifest, please follow the guidelines here: https://github.com/lnbits/lnbits-extensions#important
### Configuration Options:

| Key | Description | Default |
|---------------|------------------------------------------------------------------------------------------------------------------------------------|--------------------------------|
| relay | URL of the nostr relay for dispatching and receiving NWC events. Use public relays or a custom one. Specify `nostrclient` to connect to the [nostrclient extension](https://github.com/lnbits/nostrclient). | nostrclient |
| provider_key | Nostr secret key of the NWC Service Provider. | Random key generated on install |
| relay_alias | Relay URL to display in pairing URLs. Set if different from `relay`. | Empty (uses the `relay` value) |

### Using Nostrclient

The extension is preconfigured to connect to the nostrclient extension. Install it on the same LNbits instance and configure it to expose public websocket endpoints. Refer to the [nostrclient documentation](https://github.com/lnbits/nostrclient) for more information.

### Using a Custom Relay

To use a custom relay, set the `relay` key to the relay URL (e.g., `wss://nostr.wine`) in the extension's Settings page.

## Usage

1. Go to the extension page.
2. Select a wallet and click the plus button to create a new NWC connection.
3. Configure expiration, limits, and permissions.
4. A pairing URL will be generated for you to open, copy, or scan with the NWC app. Note that the pairing URL is shown only once, but you can delete and recreate the connection to get a new one.
13 changes: 0 additions & 13 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,5 @@
"role": "Dev"
}
],
"images": [
{
"uri": "https://raw.githubusercontent.com/riccardobl/nwcprovider/main/static/image/1.png"
},
{
"uri": "https://raw.githubusercontent.com/riccardobl/nwcprovider/main/static/image/2.png"
},
{
"uri": "https://raw.githubusercontent.com/riccardobl/nwcprovider/main/static/image/3.png"
}
],
"description_md": "https://raw.githubusercontent.com/riccardobl/nwcprovider/main/description.md",
"terms_and_conditions_md": "https://raw.githubusercontent.com/riccardobl/nwcprovider/main/toc.md",
"license": "MIT"
}
Binary file removed static/image/1.png
Binary file not shown.
Binary file removed static/image/2.png
Binary file not shown.
Binary file removed static/image/3.png
Binary file not shown.
2 changes: 0 additions & 2 deletions templates/nwcprovider/admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ <h5 class="text-subtitle1 q-my-none">NWC Service Provider - Config</h5>
try {
const response = await LNbits.api
.request('POST', '/nwcprovider/api/v1/config', this.g.user.wallets[0].adminkey, data)


this.$q.notify({
message: 'Config saved, please restart the server',
color: 'positive',
Expand Down
50 changes: 5 additions & 45 deletions templates/nwcprovider/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,8 @@
<div class="col-12 col-md-8 col-lg-7 q-gutter-y-md">
<q-card>
<q-card-section>
<!-- <div class="q-gutter-x-md row items-center"> -->
<!-- <div class="col"> -->
<q-select v-model="selectedWallet" filled dense emit-value :options="g.user.walletOptions"
label="Wallet *"></q-select>
<!-- </div>
<div class="col">
<q-btn unelevated color="primary" icon="add" @click="formDialog.show = true">Connect app</q-btn>
</div> -->
<!-- </div> -->
</q-card-section>
</q-card>

Expand All @@ -27,8 +20,6 @@
<h5 class="text-subtitle1">Connected Apps</h5>
</div>
<q-btn @click="showConnectDialog()" aria-label="Connect" icon="add" color="primary" size="sm" round />


</div>
<q-table dense flat :data="nwcEntries" row-key="id" :columns="nwcsTable.columns"
:pagination.sync="nwcsTable.pagination">
Expand Down Expand Up @@ -69,9 +60,9 @@ <h5 class="text-subtitle1">Connected Apps</h5>
<div class="col-12 col-md-4 col-lg-5 q-gutter-y-md">
<q-card>
<q-card-section>
<h6 class="text-subtitle1 q-my-none">{{SITE_TITLE}} NWC Service provider extension</h6>
<h6 class="text-subtitle1 q-my-none">NWC Service provider</h6>
<p>
An extension that turns LNBits into a Nostr Wallet Connect service provider.
Nostr Wallet Connect (NWC) are a way for applications to connect to a remote lightning wallet.
</p>
</q-card-section>
<q-card-section class="q-pa-none">
Expand All @@ -89,30 +80,13 @@ <h6 class="text-subtitle1 q-my-none">{{SITE_TITLE}} NWC Service provider extensi
<q-icon name="settings" class="q-mr-md"></q-icon>
<q-item-section>Settings</q-item-section>
</q-item>
<!-- <q-expansion-item v-if="this.g.user.admin" group="extras" icon="admin" label="Admin">
<q-card>
<q-card-section>
<p>
Manage wallets using NWC
</p>
<small>Created by
<a class="text-secondary" href="https://github.com/riccardobl" target="_blank">Riccardo Balbo</a>.</small>
<small>Repo
<a class="text-secondary" href="https://github.com/riccardobl/nwcprovider" target="_blank">NWC Service
Providers</a>.</small>
</q-card-section>
</q-card>
</q-expansion-item> -->

</q-list>
</q-card-section>
</q-card>
</div>

<!--/////////////////////////////////////////////////-->
<!--//////////////FORM DIALOG////////////////////////-->
<!--/////////////////////////////////////////////////-->



<q-dialog v-model="connectionInfoDialog.show" @hide="closeConnectionInfoDialog">
<q-card class="q-pa-lg q-pt-xl" style="width: 500px">
<q-card-section class="q-ma-none">
Expand Down Expand Up @@ -152,8 +126,6 @@ <h3 class="q-ma-none q-mb-md text-center">Info</h3>
<q-th>
Budget (sats)
<div style="font-size: smaller;">used/max</div>


</q-th>
<q-th>Refresh</q-th>
</q-tr>
Expand All @@ -168,14 +140,10 @@ <h3 class="q-ma-none q-mb-md text-center">Info</h3>
</q-tr>
</tbody>
</q-markup-table>


</q-item-section>
</q-item>
</q-list>

<q-card-actions class="q-mt-md">

<q-btn v-close-popup flat color="grey" class="q-ml-auto full-width " @click="closePairingDialog">Close</q-btn>
</q-card-actions>

Expand All @@ -186,7 +154,6 @@ <h3 class="q-ma-none q-mb-md text-center">Info</h3>

<q-dialog v-model="pairingQrDialog.show" @hide="closePairingQrDialog">
<q-card class="q-pa-lg q-pt-xl" style="width: 500px">

<q-card-section class="q-ma-none">
<q-responsive :ratio="1" class="q-mx-xl q-mb-md">
<lnbits-qrcode :value="pairingQrDialog.data.pairingUrl"></lnbits-qrcode>
Expand All @@ -195,29 +162,22 @@ <h3 class="q-ma-none q-mb-md text-center">Info</h3>
<q-card-section class="q-ma-none">
<p class=" q-ma-none text-center">Please scan this QR code with a supported app</p>
<p class=" q-ma-none text-center text-caption ">Connect only with app you trust!</p>

</q-card-section>

<q-card-actions>
<q-btn label="Close" flat color="grey" class="full-width
" @click="closePairingQrDialog"></q-btn>
<q-btn label="Close" flat color="grey" class="full-width" @click="closePairingQrDialog"></q-btn>
</q-card-actions>

</q-card>
</q-dialog>

<q-dialog v-model="pairingDialog.show" @hide="closePairingDialog">

<q-card class="q-pa-lg q-pt-xl" style="width: 500px">

<q-card-section class="q-ma-none">
<h3 class="q-ma-none q-mb-md text-center">Pairing</h3>
<p class=" q-ma-none text-center">Complete the last step of the setup by pasting or scanning your connection's
pairing secret in the desired
app to
finalise the connection.</p>
<p class=" q-ma-none text-center text-caption ">Connect only with app you trust!</p>

</q-card-section>
<q-card-actions>
<q-btn label="Open in Supported App" color="primary" class="full-width" icon="launch"
Expand Down

0 comments on commit 88da075

Please sign in to comment.