Michael Bumann 436baeeccb Merge pull request #64 from getAlby/invoice-update-subscriptions
First draft to subscribe for LND invoice update
2022-01-23 00:22:46 +02:00
2022-01-16 00:49:19 +01:00
2022-01-17 22:37:40 +01:00
2022-01-17 13:18:14 +01:00
2022-01-20 15:17:35 +01:00
2022-01-18 10:42:53 +01:00
2022-01-04 16:23:50 +02:00
2022-01-22 13:30:13 +01:00
2022-01-22 14:33:23 +01:00
2022-01-16 00:49:19 +01:00
2022-01-22 15:22:41 +02:00

LndHub.go

Wrapper for Lightning Network Daemon (lnd). It provides separate accounts with minimum trust for end users.

LndHub compatible API implemented in Go using relational database backends

  • Using a relational database (PostgreSQL and SQLite)
  • Focussing only on Lightning (no onchain functionality)
  • No runtime dependencies (simple Go executable)

Status: WIP

Known Issues

  • Currently no fee handling (users are currently not charged for lightning transaction fees)

Configuration

All required configuration is done with environment variables and a .env file can be used. Check the .env_example for an example.

cp .env_example .env
vim .env # edit your config

Available configuration

  • DATABASE_URI: The URI for the database. If you want to use SQLite use for example: file:data.db
  • JWT_SECRET: We use JWT for access tokens. Configure your secret here
  • JWT_EXPIRY: How long the access tokens should be valid (in seconds)
  • LND_ADDRESS: LND address (with port)
  • LND_MACAROON_HEX: LND macaroon
  • LND_CERT_HEX: LND certificate
  • LOG_FILE_PATH: (optional) By default all logs are written to STDOUT. If you want to log to a file provide the log file path here
  • SENTRY_DSN: (optional) Sentry DSN for exception tracking

Developing

go run main.go

Building

To build an lndhub executable, run the following commands:

make

Database

LndHub.go supports PostgreSQL and SQLite as database backend. But SQLite does not support the same data consistency checks as PostgreSQL.

Ideas

  • Using low level database constraints to prevent data inconsistencies
  • Follow double-entry bookkeeping ideas (Every transaction is a debit of one account and a credit to another one)
  • Support multiple database backends (PostgreSQL for production, SQLite for development and personal/friend setups)

Data model

                                                               ┌─────────────┐                            
                                                               │    User     │                            
                                                               └─────────────┘                            
                                                                      │                                   
                                            ┌─────────────────┬───────┴─────────┬─────────────────┐       
                                            ▼                 ▼                 ▼                 ▼       
                 Accounts:          ┌──────────────┐  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐
                                    │   Incoming   │  │   Current    │  │   Outgoing   │  │     Fees     │
                 Every user has     └──────────────┘  └──────────────┘  └──────────────┘  └──────────────┘
                 four accounts                                                                            
                                                                                                          
                                     Every Transaction Entry is associated to one debit account and one   
                                                               credit account                             
                                                                                                          
                                                           ┌────────────────────────┐                     
                                                           │Transaction Entry       │                     
                                                           │                        │                     
                                                           │+ user_id               │                     
                             ┌────────────┐                │+ invoice_id            │                     
                             │  Invoice   │────────────────▶+ debit_account_id      │                     
                             └────────────┘                │+ credit_account_id     │                     
                                                           │+ amount                │                     
                            Invoice holds the              │+ ...                   │                     
                            lightning related              │                        │                     
                            data                           └────────────────────────┘                     
                                                                                                          
Description
No description provided
Readme GPL-3.0 2.6 MiB
Languages
Go 98%
CSS 1%
HTML 0.8%
Dockerfile 0.2%