Code Monkey home page Code Monkey logo

lnurld's Introduction

LNURL Daemon

LNURL Daemon is a minimalistic Lightning Address and LNURL self-hosted HTTP server. It is intended to run on your node and connect directly to your LND. You may test it by sending some sats to ⚡[email protected] or by scanning the following QR code:
LNURL-pay QR code

Supported features

Installation

LND is expected to run on the same machine and user bitcoin is assumed. You also need Go installed.

Build from source

$ git clone https://github.com/yanascz/lnurld.git
$ cd lnurld
$ go install
$ go build

Create config file

$ sudo mkdir /etc/lnurld
$ sudo chown bitcoin:bitcoin /etc/lnurld
$ sudo -u bitcoin vim /etc/lnurld/config.yaml

Example configuration with one admin, one user with restricted access, one donate account and one raffle account:

credentials:
  admin: 4dm!nS3cr3t
  guest: S3cr3t
access-control:
  guest: [raffle]
accounts:
  satoshi:
    min-sendable: 1
    max-sendable: 1_000_000
    description: Sats for Satoshi
    is-also-email: true
    comment-allowed: 210
  raffle:
    description: Raffle ticket
    thumbnail: raffle.png
    raffle:
      ticket-price: 21_000
      prizes:
        - Trezor Model T
        - Trezor Model One
        - Trezor Lanyard

(Create image raffle.png in /etc/lnurld/thumbnails if you want it served by lnurld.)

Available configuration properties:

Property Description Default value
listen Host and port to listen on. 127.0.0.1:8088
thumbnail-dir Directory where to look for thumbnails. /etc/lnurld/thumbnails
data-dir Directory where invoice payment hashes per account will be stored. /var/lib/lnurld
lnd Configuration of your LND node. see below
lnd.address Host and port of gRPC API interface. 127.0.0.1:10009
lnd.cert-file Path to TLS certificate. /var/lib/lnd/tls.cert
lnd.macaroon-file Path to invoice macaroon. /var/lib/lnd/data/chain/bitcoin/mainnet/invoice.macaroon
credentials Map of users authorized to access the admin user interface. none
access-control Map of accounts accessible by non-admin users. none, i.e. all users have full admin access
accounts Map of available accounts. none
accounts.*.currency Terminal currency; cad, chf, czk, eur, gbp and usd supported. eur
accounts.*.max-sendable Maximum sendable amount in sats. (not available for raffle) none
accounts.*.min-sendable Minimum sendable amount in sats. (not available for raffle) none
accounts.*.description Description of the account. none
accounts.*.thumbnail Name of PNG/JPEG thumbnail to use; 256×256 pixels recommended. (optional) none
accounts.*.is-also-email Does the account match an email address? false
accounts.*.comment-allowed Maximum length of invoice comment. 0
accounts.*.raffle Raffle configuration. (optional) none
accounts.*.raffle.ticket-price Price of a ticket in sats. none
accounts.*.raffle.prizes List of prizes. none

If a property is marked as optional or has a default value, you don’t have to specify it explicitly.

Create data directory

$ sudo mkdir -m 710 /var/lib/lnurld
$ sudo chown bitcoin:bitcoin /var/lib/lnurld

Payment hashes of invoices per account will be stored there.

Run the server

$ ./lnurld

Alternatively with a custom config file path:

$ ./lnurld --config=/home/satoshi/.lnurld/cfg.yaml

Don’t forget to stop the server before setting up systemd service!

Setup systemd service

$ sudo cp lnurld /usr/local/bin
$ sudo cp systemd/lnurld.service /lib/systemd/system
$ sudo systemctl start lnurld.service
$ sudo systemctl enable lnurld.service

Now the service should be up and running, listening on configured host and port.

Setup reverse proxy

Example nginx configuration for domain nakamoto.example (replace with your own) with Let’s Encrypt SSL certificate:

http {
    #
    # general configuration omitted
    # 

    upstream lnurld {
        server 127.0.0.1:8088;
    }

    server {
        listen       443 ssl http2;
        listen       [::]:443 ssl http2;
        server_name  nakamoto.example;

        ssl_certificate      "/etc/letsencrypt/live/nakamoto.example/fullchain.pem";
        ssl_certificate_key  "/etc/letsencrypt/live/nakamoto.example/privkey.pem";
        ssl_session_cache    shared:lnurld:1m;

        proxy_set_header  X-Forwarded-Proto $scheme;
        proxy_set_header  X-Forwarded-Host $host;

        location /.well-known/lnurlp/ {
            proxy_pass http://lnurld;
        }
        location /ln/ {
            proxy_pass http://lnurld;
        }
    }
}

If you don’t have an SSL certificate, you can get one using Certbot.

Usage

Once configured and deployed, you shall be able to send sats to ⚡[email protected] from your LN wallet. If you need to display a QR code, simply navigate to or share https://nakamoto.example/ln/pay/satoshi/qr-code. For a smaller/larger QR code, feel free to append desired size in pixels to the URL, e.g ?size=1024.

Same applies to ⚡[email protected] and https://nakamoto.example/ln/pay/raffle/qr-code with raffle configured. These allow anyone to purchase as many raffle tickets for the configured price as they wish, increasing their chances. Once enough tickets are sold, i.e. at least the same number as there are prizes, you may start drawing winning tickets from the account’s detail page.

To see amount of received sats or raffle for accessible accounts, navigate to https://nakamoto.example/ln/accounts. You’ll need to authenticate using one of the configured username/password pairs. Account stats, QR code and/or payment terminal are accessible from the account’s detail page.

The raffle is stateless so refreshing its page restarts the draw and may produce different winning tickets!

Update

$ cd lnurld
$ git pull
$ ./systemd/deploy.sh

Alternatively checkout a specific branch/tag.

lnurld's People

Contributors

yanascz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.