├── .eslintrc.json
├── .gitignore
├── LICENSE
├── README.md
├── app
├── api
│ ├── getInvoice
│ │ └── [user]
│ │ │ └── route.js
│ ├── lnurlp
│ │ └── [user]
│ │ │ └── route.js
│ ├── notifier
│ │ └── [user]
│ │ │ └── route.js
│ └── phoenixd
│ │ └── [user]
│ │ └── route.js
├── favicon.ico
└── globals.css
├── files
└── lightning.proto
├── next.config.mjs
├── package-lock.json
├── package.json
├── public
├── next.svg
└── vercel.svg
└── push
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "next/core-web-vitals"
3 | }
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 | .yarn/install-state.gz
8 |
9 | # testing
10 | /coverage
11 |
12 | # next.js
13 | /.next/
14 | /out/
15 |
16 | # production
17 | /build
18 |
19 | # misc
20 | .DS_Store
21 | *.pem
22 |
23 | # debug
24 | npm-debug.log*
25 | yarn-debug.log*
26 | yarn-error.log*
27 |
28 | # local env files
29 | .env
30 | .env*.local
31 | .env.local
32 | .env.*.local
33 |
34 | # vercel
35 | .vercel
36 |
37 | # typescript
38 | *.tsbuildinfo
39 | next-env.d.ts
40 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | ## About
4 |
5 | No more invoicing! **Lightning Server** enables you to receive [Lightning Address](https://lightningaddress.com) payments to an address like you@yourdomain.com. Additionally, you'll get [zap receipts](https://github.com/nostr-protocol/nips/blob/master/57.md) on [Nostr](https://damus.io/), as well as **email** and **push notifications** sent to all your devices whenever you receive a Lightning payment of any kind. Never miss a payment alert!
6 |
7 | ## Features
8 |
9 | - Lightning Address
10 | - Email notifications
11 | - Push notifications
12 | - Nostr zap receipts
13 | - Easy Point of Sale (coming soon!)
14 |
15 | ## Prerequisites
16 |
17 | You'll need a Lightning node running [LND](https://github.com/lightningnetwork/lnd) and your own domain. Need a node? [Voltage](https://voltage.cloud) makes it easy and is a great place to get started! Make sure you have some key pieces of information handy, such as your node's REST and gRPC API endpoints, as well as your invoice macaroon.
18 |
19 | ## Deploying Lightning Server
20 |
21 | If you don't already have a VPS, the easiest way to deploy and host **Lightning Server** is on [DigitalOcean's App Platform](https://www.digitalocean.com/products/app-platform), which will cost approximately $5.00 per month at the time of this writing. If you choose to use [Vercel](https://vercel.com), functionality will be *limited to a working Lightning Address only* - you won't get the benefit of Nostr zap receipts, email notifications, or push notifications. [Heroku](https://www.heroku.com/) is not recommended.
22 |
23 | ## Lightning Server uses Next.js
24 |
25 | **Lightning Server** is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
26 |
27 | - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28 | - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
29 |
30 | ## Environment Variables
31 |
32 | To run this project, you will need to add the following environment variables:
33 |
34 | ```env
35 | ## REQUIRED VARIABLES #############################################################
36 | DOMAIN=yourdomain.com
37 | REST_HOST=lnd-node-address.com:8080
38 | GRPC_HOST=lnd-node-address.com:10009
39 | INVOICE_MACAROON=myInvoiceMacaroonInHex
40 | # For your push notifications! Install Pushover on your phone, then grab the
41 | # API information from https://pushover.net/api
42 | PUSHOVER_TOKEN=apiToken
43 | PUSHOVER_USER=userKey
44 | # This doesn't need to be your primary email; you can set up a new Gmail account
45 | # specifically for sending notifications. Once you do, create an "app password"
46 | # at https://myaccount.google.com/apppasswords
47 | EMAIL_SENDER=notifier.address@gmail.com
48 | EMAIL_PASSWORD=youCreatedAnAppPassword
49 | # Where the notifications will be sent to
50 | EMAIL_RECIPIENT=my.email@domain.com
51 |
52 | ## OPTIONAL VARIABLES #############################################################
53 | EMAIL_BCC=someone.else@domain.com
54 | # Set to "true" if you're using private channels to enable LND to automatically
55 | # add route hints to your invoices.
56 | PRIVATE_CHANNELS=true
57 | # This restricts your Lightning Addresses to usernames you define, e.g.
58 | # user1@yourdomain.com, etc. Users are separated by commas.
59 | USERS=user1,user2,user3
60 | # Set CATCH_ALL to "false" if you don't want any arbitrary username to be valid
61 | # e.g. if false, a payment to user4@yourdomain.com will fail.
62 | CATCH_ALL=true
63 | # This is what the sender sees in their wallet when they enter your address.
64 | META=Message to display to sender
65 | # This is a JSON string that will forward users to external Lightning
66 | # addresses, e.g. d@yourdomain.com will get forwarded to me@dplus.plus
67 | FORWARDS={"d":"me@dplus.plus","alby":"dread@getalby.com"}
68 | # If you want even more forwards, you can set USE_MONGO to "true" and add them
69 | # dynamically using MongoDB. See an example at https://dplus.plus/alias
70 | USE_MONGO=false
71 | MONGODB_USER=myMongoUser
72 | MONGODB_PASS=myMongoPassword
73 | MONGODB_URL=myMongoURL
74 | # Any key pair in hex (not npub/nsec) will do; no need to use your primary keys!
75 | # If no keys are provided, zap receipts will use Lightning Server's default keys.
76 | NOSTR_PUBLIC_KEY=anyNostrPublicKeyInHex
77 | NOSTR_PRIVATE_KEY=anyNostrPrivateKeyInHex
78 | ```
79 |
80 | ## Running the Notifier
81 |
82 | After you've deployed the project, you'll need to start the [Notifier](https://github.com/dplusplus1024/Lightning-Server/blob/main/app/api/notifier/%5Buser%5D/route.js) service at https://yourdomain.com/api/notifier/run in order for push, email, and Nostr notifications to work.
83 |
84 | In the root directory is a [bash script](https://github.com/dplusplus1024/Lightning-Server/blob/main/push) that can be run from the console using `./push` anytime you make changes. It will git add, commit, and push your changes to remote, then auto-run the Notifier. This script assumes you're using DigitalOcean and requires two local environment variables, `DIGITAL_OCEAN_APP_ID` and `DIGITAL_OCEAN_API`. That said, *I feel like I'm missing something, as there's got to be a better way of doing this. Help anyone?*
85 |
86 | ## Warning
87 |
88 | This is experimental software, currently still in beta. Use at your own risk!
89 |
90 | ## To Do
91 |
92 | - Continue refactoring, polishing, and optimizing code and documentation
93 | - Add enhanced error handling
94 | - Add Lightning Point of Sale
95 | - Find a better way to automatically start the [Notifier](https://github.com/dplusplus1024/Lightning-Server/blob/main/app/api/notifier/%5Buser%5D/route.js) service
96 | - Host an online workshop on how to run this server!
97 |
--------------------------------------------------------------------------------
/app/api/getInvoice/[user]/route.js:
--------------------------------------------------------------------------------
1 | import path from 'path';
2 | import { getEventHash, getSignature, finishEvent, relayInit } from 'nostr-tools';
3 | import crypto from 'crypto';
4 | import 'websocket-polyfill';
5 | import bolt11 from 'bolt11';
6 | import { NextResponse } from 'next/server';
7 | const grpc = require('@grpc/grpc-js');
8 | const protoLoader = require('@grpc/proto-loader');
9 | const relays = [
10 | "wss://relay.damus.io",
11 | "wss://nostr.mutinywallet.com",
12 | "wss://relay.nostr.band",
13 | "wss://nos.lol",
14 | "wss://nostr.fmt.wiz.biz",
15 | "wss://relay.nostr.bg",
16 | "wss://nostr.oxtr.dev",
17 | ];
18 |
19 | let startTime;
20 | const ZAP_TIMEOUT = 300000; // time to wait for zap to be paid - 5 minutes in milliseconds
21 | const DEFAULT_PRIVATE_KEY = "6be6e45ea4eb02d3cc9cda30771281ceb92aa8b972bbea50243d269919979b1e";
22 | const NOSTR_PRIVATE_KEY = process.env.NOSTR_PRIVATE_KEY || DEFAULT_PRIVATE_KEY;
23 |
24 | const loaderOptions = {
25 | keepCase: true,
26 | longs: String,
27 | enums: String,
28 | defaults: true,
29 | oneofs: true,
30 | };
31 | const packageDefinition = protoLoader.loadSync(
32 | path.join(process.cwd(), 'files/lightning.proto'),
33 | loaderOptions
34 | );
35 | const lnrpc = grpc.loadPackageDefinition(packageDefinition).lnrpc;
36 | const lndCert = null; // set to null if using Voltage
37 | const sslCreds = grpc.credentials.createSsl(lndCert);
38 | const macaroonCreds = grpc.credentials.createFromMetadataGenerator(function (args,callback) {
39 | let metadata = new grpc.Metadata();
40 | metadata.add('macaroon', process.env.INVOICE_MACAROON);
41 | callback(null, metadata);
42 | });
43 | const creds = grpc.credentials.combineChannelCredentials(sslCreds, macaroonCreds);
44 | const lightning = new lnrpc.Lightning(process.env.GRPC_HOST, creds);
45 |
46 | function sha256(data) {
47 | return crypto.createHash('sha256').update(data).digest('hex');
48 | }
49 |
50 | // get bolt 11 invoice from node in amount specified
51 | function createInvoice(user, address, amount, descriptionHash, comment) {
52 | comment = comment ? comment.slice(0, 64) : "";
53 | comment = comment ? `Sent to: ${address} | Comment: ${comment}` : `Sent to: ${address} | `;
54 |
55 | let requestInvoice = {
56 | memo: comment,
57 | description_hash: Buffer.from(descriptionHash, 'hex'),
58 | value_msat: amount, // in millisats
59 | // enable automatic route hints based on the environment variable
60 | private: (process.env.PRIVATE_CHANNELS || "").toLowerCase() == "true"
61 | }
62 |
63 | return new Promise(function(resolve, reject) {
64 | lightning.addInvoice(requestInvoice, function(err, response) {
65 | resolve(response.payment_request);
66 | });
67 | });
68 | }
69 |
70 | function createNostrInvoice(amount, description) {
71 | const memo = {};
72 | const data = JSON.parse(description);
73 | const descriptionHash = sha256(description);
74 | memo.type = "Nostr Zap!";
75 | memo.pubkey = data.pubkey;
76 | memo.content = data.content;
77 | memo.event = data.tags.find(tag => tag[0] === 'e')?.[1];
78 |
79 | let requestInvoice = {
80 | memo: JSON.stringify(memo),
81 | description_hash: Buffer.from(descriptionHash, 'hex'),
82 | value_msat: amount, // in millisats,
83 | // enable automatic route hints based on the environment variable
84 | private: (process.env.PRIVATE_CHANNELS || "").toLowerCase() == "true"
85 | }
86 |
87 | return new Promise(function(resolve, reject) {
88 | lightning.addInvoice(requestInvoice, function(err, response) {
89 | resolve(response.payment_request);
90 | });
91 | });
92 | }
93 |
94 | function logTime(message) {
95 | console.log(`${message} Time elapsed: ${new Date().getTime() - startTime} milliseconds.`);
96 | }
97 |
98 | function getStatus(hash) {
99 | let request = {
100 | r_hash_str: hash
101 | };
102 |
103 | return new Promise(function(resolve, reject) {
104 | lightning.lookupInvoice(request, function(error, response) {
105 | resolve(response?.state == 'SETTLED');
106 | });
107 | });
108 | }
109 |
110 | async function zapReceipt(data) {
111 | const note = JSON.parse(data.description);
112 | const e = note.tags.find(tag => tag[0] === 'e')?.[1];
113 | const p = note.tags.find(tag => tag[0] === 'p')?.[1];
114 |
115 | if (!p) {
116 | return;
117 | }
118 | let zap = {
119 | content: '', // leave this blank
120 | kind: 9735,
121 | pubkey: note.pubkey,
122 | created_at: Math.floor(Date.now() / 1000), // time of invoice paid
123 | tags: [
124 | ["bolt11", data.bolt11],
125 | ["description", data.description],
126 | ["p", p],
127 | ]
128 | };
129 | if (e) {
130 | zap.tags[zap.tags.length] = ["e", e];
131 | }
132 | zap.id = getEventHash(zap);
133 | zap.sig = getSignature(zap, NOSTR_PRIVATE_KEY);
134 | const signedEvent = finishEvent(zap, NOSTR_PRIVATE_KEY);
135 |
136 | let isPublished = false;
137 | for (let relayUrl of relays) {
138 | try {
139 | let relay = relayInit(relayUrl);
140 | await relay.connect();
141 | await relay.publish(signedEvent);
142 | console.log(`Published to ${relayUrl}`);
143 | isPublished = true;
144 | relay.close();
145 | } catch (error) {
146 | console.error(`Failed to publish to ${relayUrl}:`, error);
147 | }
148 | }
149 | if (!isPublished)
150 | console.log(`Could not publish note to any relay.`);
151 | }
152 |
153 | function pause(ms) {
154 | return new Promise(resolve => setTimeout(resolve, ms));
155 | }
156 |
157 | function getHash(invoice) {
158 | try {
159 | const decoded = bolt11.decode(invoice);
160 | const paymentHash = decoded.tags.find(tag => tag.tagName === 'payment_hash').data;
161 | return paymentHash;
162 | } catch (error) {
163 | console.error('Error decoding invoice:', error);
164 | return null;
165 | }
166 | }
167 |
168 | async function checkZap(bolt11, zap) {
169 | let hash = getHash(bolt11);
170 | console.log("New invoice generated. Waiting for payment...");
171 | pause(1000);
172 | // check status of invoice here... may want to eventually move this to notifier.js...
173 | while (await getStatus(hash) == false) {
174 | pause(1000);
175 | const currentTime = new Date().getTime();
176 | if (currentTime - startTime > ZAP_TIMEOUT) {
177 | console.log("Zap not paid in time.");
178 | return false; // check for five minutes and then stop...
179 | }
180 | }
181 | // successful zap! invoice settled.
182 | await zapReceipt({ bolt11: bolt11, description: zap });
183 | logTime("Nostr zap receipt success!");
184 | return true;
185 | }
186 |
187 | export async function GET(req, { params }) {
188 | startTime = new Date().getTime();
189 |
190 | const headers = {
191 | 'Access-Control-Allow-Origin': '*',
192 | 'Access-Control-Allow-Methods': 'GET, POST, PUT',
193 | 'Access-Control-Allow-Headers': 'Content-Type',
194 | };
195 |
196 | console.log("Welcome to getInvoice.js");
197 |
198 | const lnurl = {};
199 | const url = new URL(req.url);
200 | const amountParam = url.searchParams.get('amount');
201 | if (amountParam === null || amountParam.trim() === '')
202 | return NextResponse.json({ message: "No amount was provided." }, { headers });
203 | const amount = Number(amountParam);
204 | if (isNaN(amount))
205 | return NextResponse.json({ message: "Invalid amount provided." }, { headers });
206 | const zap = url.searchParams.get('nostr');
207 |
208 | // it's a nostr zap
209 | if (zap) {
210 | // get invoice
211 | let bolt11 = await createNostrInvoice(amount, zap);
212 |
213 | lnurl.pr = bolt11;
214 |
215 | logTime("Created an invoice for a nostr zap.");
216 |
217 | // give them 5 minutes to pay the invoice, polling our node every second...
218 | checkZap(bolt11, zap);
219 | return NextResponse.json(lnurl, { headers });
220 | }
221 |
222 | // not a nostr zap, just a regular invoice
223 | let user = params.user.toLowerCase() || "none";
224 | let comment = url.searchParams.get('comment');
225 | let address = `${user}@${process.env.DOMAIN}`;
226 | let meta;
227 |
228 | switch (user) {
229 | case "user1":
230 | meta = "Example 1";
231 | break;
232 | case "user2":
233 | meta = "Example 2";
234 | break;
235 | default:
236 | meta = process.env.META || `Pay to ${address}`;
237 | }
238 |
239 | user = encodeURIComponent(user.toLowerCase());
240 | const memo = JSON.stringify([["text/plain", meta], ["text/identifier", `${address}`]]);
241 | const hash = sha256(memo);
242 |
243 | lnurl.pr = await createInvoice(user, address, amount, hash, comment);
244 |
245 | logTime("Invoice creation success!");
246 | return NextResponse.json(lnurl, { headers });
247 | }
248 |
--------------------------------------------------------------------------------
/app/api/lnurlp/[user]/route.js:
--------------------------------------------------------------------------------
1 | const axios = require('axios');
2 | const { NextResponse } = require('next/server');
3 | const { MongoClient, ServerApiVersion, ObjectId } = require('mongodb');
4 |
5 | const DEFAULT_PUBLIC_KEY = "702ba902c99b28ee2d78dea4ae2105bd4b18dde901d88b8e5fd247d886ce57f5";
6 | const NOSTR_PUBLIC_KEY = process.env.NOSTR_PUBLIC_KEY || DEFAULT_PUBLIC_KEY;
7 | // list of valid users; not needed if process.env.CATCH_ALL is set to true
8 | const users = process.env.USERS.split(/\s*,\s*/);
9 | // redirects that forward to external Lightning Addresses
10 | const forwards = JSON.parse(process.env.FORWARDS);
11 |
12 | let lnurl = {};
13 | let user, startTime;
14 |
15 | function myNode() {
16 | let meta;
17 | let address = `${user}@${process.env.DOMAIN}`;
18 |
19 | switch (user) {
20 | case "user1":
21 | meta = "Example 1";
22 | break;
23 | case "user2":
24 | meta = "Example 2";
25 | break;
26 | default:
27 | meta = process.env.META || `Pay to ${address}`;
28 | }
29 |
30 | lnurl.callback = `https://${process.env.DOMAIN}/api/getInvoice/${user}`;
31 | lnurl.maxSendable = 1000000000000; // values are in millisats
32 | lnurl.minSendable = 1000;
33 | lnurl.metadata = JSON.stringify([["text/plain", meta],["text/identifier", `${address}`]]);
34 | lnurl.commentAllowed = 32;
35 | lnurl.tag = "payRequest";
36 | // this is the Nostr pubkey that signs and publishes zap receipts
37 | lnurl.nostrPubkey = NOSTR_PUBLIC_KEY;
38 | lnurl.allowsNostr = true;
39 | }
40 |
41 | // optional if you'd like to dynamically add new forwards to your database, e.g. see https://dplus.plus/alias
42 | async function getMongoUser() {
43 | const uri = `mongodb+srv://${process.env.MONGODB_USER}:${process.env.MONGODB_PASS}@${process.env.MONGODB_URL}`;
44 | const client = new MongoClient(uri, { useNewUrlParser: true, useUnifiedTopology: true, serverApi: ServerApiVersion.v1 });
45 |
46 | try {
47 | await client.connect();
48 | const collection = client.db("LNURL").collection("aliases");
49 | const cursor = await collection.findOne({ _id: user });
50 |
51 | if (!cursor) {
52 | console.log("User not found in MongoDB database.");
53 | return false;
54 | }
55 |
56 | console.log(`${cursor.lnAddress} found in MongoDB database.`);
57 | return cursor.lnAddress;
58 | } catch (err) {
59 | console.error('Error connecting to MongoDB: ', err);
60 | return false;
61 | } finally {
62 | await client.close();
63 | }
64 | }
65 |
66 | async function getLNURL(lnAddress) {
67 | const [name, address] = lnAddress.split("@");
68 | const url = `https://${address}/.well-known/lnurlp/${name}`;
69 |
70 | try {
71 | const response = await axios.get(url);
72 | console.log(`response.data: ${response.data}`);
73 | return response.data;
74 | } catch (error) {
75 | console.log("There was an error getting the LNURL.");
76 | return "There was an error fetching your LNURL.";
77 | }
78 | }
79 |
80 | function logTime() {
81 | console.log(`Time elapsed: ${new Date().getTime() - startTime} milliseconds.`);
82 | }
83 |
84 | export async function GET(req, { params }) {
85 | startTime = new Date().getTime();
86 | const headers = {
87 | 'Access-Control-Allow-Origin': '*',
88 | 'Access-Control-Allow-Methods': 'GET, POST, PUT',
89 | 'Access-Control-Allow-Headers': 'Content-Type',
90 | };
91 |
92 | const referer = req.headers.referer || "an unknown source";
93 | user = params.user.toLowerCase();
94 | console.log(user + ' visited from ' + referer + '.');
95 |
96 | if (!user)
97 | return NextResponse.json({ message: "No user was specified." }, { headers });
98 |
99 | // check the aliases first...
100 | if (users.includes(user)) {
101 | myNode();
102 | logTime(); // takes 0.0 seconds to return this
103 | return NextResponse.json(lnurl, { headers });
104 | }
105 | // next, check if they're set up as a forward...
106 | if (user in forwards) {
107 | let result = await getLNURL(forwards[user]);
108 | logTime();
109 | return NextResponse.json(result, { headers });
110 | }
111 | // check for user in external forwards database (MongoDB)...
112 | if ((process.env.USE_MONGO || "").toLowerCase() === "true") {
113 | let databaseUser = await getMongoUser(); // takes about .40 - .55 seconds
114 | if (databaseUser) {
115 | let result = await getLNURL(databaseUser);
116 | logTime();
117 | return NextResponse.json(result, { headers });
118 | }
119 | }
120 | // you can decide if you want any arbitrary username to be valid or not
121 | if ((process.env.CATCH_ALL || "").toLowerCase() === "false") {
122 | return NextResponse.json({ message: `User ${user} not found.` }, { headers });
123 | }
124 |
125 | myNode();
126 | logTime();
127 | return NextResponse.json(lnurl, { headers });
128 | }
129 |
--------------------------------------------------------------------------------
/app/api/notifier/[user]/route.js:
--------------------------------------------------------------------------------
1 | // This has to be run at https://${DOMAIN}/api/notifier/run after you've deployed your project
2 | // It will run automatically if you use the ./push bash script (but please help me find a better way...)
3 |
4 | import path from 'path';
5 | import crypto from 'crypto';
6 | import * as nostr from 'nostr-tools';
7 | import nodemailer from 'nodemailer';
8 | import { NextResponse } from 'next/server';
9 | const WebSocket = require('ws');
10 | const grpc = require('@grpc/grpc-js');
11 | const { bech32 } = require('bech32');
12 | const axios = require('axios');
13 | const protoLoader = require('@grpc/proto-loader');
14 |
15 | const zap = {};
16 | let connected = false;
17 | let errorEmailSent = false;
18 |
19 | const transporter = nodemailer.createTransport({
20 | service: 'gmail',
21 | // This doesn't need to be your primary email; you can set up a new Gmail account
22 | // specifically for sending notifications. Once you do, create an "app password"
23 | // at https://myaccount.google.com/apppasswords
24 | auth: {
25 | user: process.env.EMAIL_SENDER,
26 | pass: process.env.EMAIL_PASSWORD
27 | }
28 | });
29 |
30 | const loaderOptions = {
31 | keepCase: true,
32 | longs: String,
33 | enums: String,
34 | defaults: true,
35 | oneofs: true,
36 | };
37 |
38 | const packageDefinition = protoLoader.loadSync(
39 | path.join(process.cwd(), 'files/lightning.proto'),
40 | loaderOptions
41 | );
42 | const lnrpc = grpc.loadPackageDefinition(packageDefinition).lnrpc;
43 | const sslCreds = grpc.credentials.createSsl(null);
44 | const macaroonCreds = grpc.credentials.createFromMetadataGenerator(function (args,callback) {
45 | let metadata = new grpc.Metadata();
46 | metadata.add('macaroon', process.env.INVOICE_MACAROON);
47 | callback(null, metadata);
48 | });
49 | const creds = grpc.credentials.combineChannelCredentials(sslCreds, macaroonCreds);
50 | const lightning = new lnrpc.Lightning(process.env.GRPC_HOST, creds);
51 |
52 | function send(mailOptions) {
53 | transporter.sendMail(mailOptions, function(error, info) {
54 | if (error)
55 | console.log(`Mail error: ${error}`);
56 | else
57 | console.log(`Email sent: ${info.response}`);
58 | });
59 | }
60 |
61 | function capitalize(string) {
62 | if (string.length === 0) return string;
63 | return string.charAt(0).toUpperCase() + string.slice(1);
64 | }
65 |
66 | function sendEmail(invoice) {
67 | let sats = "sat";
68 | let amount = Number(invoice.amt_paid_sat);
69 | if (amount == 0) {
70 | amount = Number(invoice.amt_paid_msat);
71 | sats = "millisat";
72 | }
73 | let plural = amount > 1 ? 's' : '';
74 | let verb = zap.on ? "zapped" : "paid";
75 | let memo;
76 | let type;
77 | let keysend = "";
78 | let user = "You";
79 | amount = amount.toLocaleString();
80 |
81 | if (zap.on) {
82 | type = "Zap";
83 | const npub = nostr.nip19.npubEncode(zap.data.pubkey);
84 | if (zap.data.event) {
85 | // they zapped a note
86 | const buffer = Buffer.from(zap.data.event, 'hex');
87 | const words = bech32.toWords(buffer);
88 | const note = bech32.encode("note", words);
89 | memo = `From: ${npub}
Note: ${note}`;
90 | }
91 | else {
92 | // they zapped your profile
93 | memo = `${npub} zapped your profile.`;
94 | if (zap.data.content)
95 | memo += `
Message: ${zap.data.content}`;
96 | }
97 | }
98 | else {
99 | // not a zap - it's a regular BOLT11, LN Address, or keysend payment
100 | memo = invoice.memo;
101 | keysend = invoice.is_keysend ? " via keysend" : "";
102 | type = memo.includes("Sent to: ") ? "LN Address" : (invoice.is_keysend ? "Keysend" : "Invoice");
103 | if (type == "LN Address") {
104 | let note = memo.split(' | ')[1];
105 | let address = decodeURIComponent(memo.split(' | ')[0]);
106 | user = address.split('@')[0];
107 | user = capitalize(user.split("Sent to: ")[1]) + ", you";
108 | address = `${address}`;
109 | memo = note ? `${address}
220 | If all goes well, you won't have to re-run notifier.js!
221 |
222 | Triggered ${note}
223 | `
224 | };
225 | send(mailOptions);
226 | errorEmailSent = true;
227 |
228 | if (note.includes("Pong"))
229 | pushNotification(`Lightning node unreachable.`, `Pong not received in the last 2 minutes!`);
230 | }
231 |
232 | function messageEmail(subject, html) {
233 | const mailOptions = {
234 | from: `"Node Notifier" <${process.env.EMAIL_SENDER}>`,
235 | to: process.env.EMAIL_RECIPIENT,
236 | subject: subject,
237 | html: html
238 | };
239 | send(mailOptions);
240 | }
241 |
242 | function pushNotification(subject, body) {
243 | axios.post('https://api.pushover.net/1/messages.json', {
244 | token: process.env.PUSHOVER_TOKEN,
245 | user: process.env.PUSHOVER_USER,
246 | title: subject,
247 | message: body,
248 | html: 1
249 | })
250 | .then(response => {
251 | console.log("Push notification sent:", response.data);
252 | })
253 | .catch(error => {
254 | console.error("Error sending push notification:", error);
255 | });
256 | }
257 |
258 | function notify() {
259 | let requestBody = {};
260 | let lastPongTimestamp = Date.now();
261 | let checkPongInterval, reconnectInterval;
262 |
263 | const PING_INTERVAL = 10000; // ping every 10 seconds
264 | const RECONNECT_INTERVAL = 60000; // attempt to reconnect every minute when disconnected
265 | const PONG_TIMEOUT = 120000; // email after we don't receive a pong in two minutes
266 |
267 | function connect() {
268 | if (connected)
269 | return; // don't create multiple connections
270 |
271 | let ws = new WebSocket(`wss://${process.env.REST_HOST}/v1/invoices/subscribe?method=GET`, {
272 | // Work-around for self-signed certificates.
273 | rejectUnauthorized: false,
274 | headers: {
275 | 'Grpc-Metadata-Macaroon': process.env.INVOICE_MACAROON,
276 | },
277 | });
278 |
279 | // set interval to reconnect after disconnecting
280 | clearInterval(reconnectInterval);
281 | reconnectInterval = setInterval(() => {
282 | if (connected == false) {
283 | connect();
284 | }
285 | }, RECONNECT_INTERVAL);
286 |
287 | ws.on('open', function() {
288 | console.log('WebSocket connected');
289 | connected = true;
290 |
291 | setTimeout(() => {
292 | if (connected) {
293 | // don't send welcome message unless we've established a lasting connection!
294 | errorEmailSent = false;
295 | let message = "Successfully connected websocket."
296 | messageEmail(message, message);
297 | console.log("Made a lasting connection!");
298 | }
299 | }, 2000);
300 |
301 | ws.send(JSON.stringify(requestBody));
302 |
303 | // send error email if we don't get a pong after a while
304 | setInterval(() => ws.ping('Are you there?'), PING_INTERVAL);
305 | clearInterval(checkPongInterval);
306 | checkPongInterval = setInterval(() => {
307 | const timeSinceLastPong = Date.now() - lastPongTimestamp;
308 | if (timeSinceLastPong >= PONG_TIMEOUT) {
309 | errorEmail("inside checkPongInterval");
310 | console.error('Pong not received in time, connection might be lost.');
311 | clearInterval(checkPongInterval);
312 | }
313 | }, PING_INTERVAL);
314 | });
315 |
316 | ws.on('message', async function(body) {
317 | zap.on = false;
318 | let invoice = JSON.parse(body.toString()).result;
319 | if (invoice?.state == "SETTLED") {
320 | console.log("Paid invoice detected!");
321 | // if it's a zap, include information about who zapped you!
322 | if (invoice.memo.includes("Nostr Zap!")) {
323 | zap.data = JSON.parse(invoice.memo);
324 | zap.on = true;
325 | }
326 | sendEmail(invoice);
327 | }
328 | else {
329 | if (invoice)
330 | console.log("New invoice was added!");
331 | else {
332 | // node is locked or the invoice macaroon isn't working
333 | connected = false;
334 | let errorMessage = `The websocket returned an undefined message. Your node may need to be unlocked, or there may be an issue with your macaroon.`;
335 | errorEmail(`by ${errorMessage}`);
336 | console.log(errorMessage);
337 | }
338 | }
339 | });
340 |
341 | ws.on('pong', function(data) {
342 | lastPongTimestamp = Date.now();
343 | });
344 |
345 | ws.on('close', function() {
346 | connected = false;
347 | errorEmail("inside ws.on('close').");
348 | console.log('WebSocket closed.');
349 | });
350 |
351 | ws.on('error', function(err) {
352 | connected = false;
353 | errorEmail("inside ws.on('error').");
354 | console.log('Error connecting to WebSocket: ' + err);
355 | });
356 | }
357 |
358 | connect();
359 | }
360 |
361 | export async function GET(req) {
362 | const headers = {
363 | 'Access-Control-Allow-Origin': '*',
364 | 'Access-Control-Allow-Methods': 'GET, POST, PUT',
365 | 'Access-Control-Allow-Headers': 'Content-Type',
366 | };
367 |
368 | console.log("Starting notifier.js...");
369 |
370 | notify();
371 |
372 | return NextResponse.json({ message: "Starting notifier.js..." }, { headers });
373 | }
374 |
--------------------------------------------------------------------------------
/app/api/phoenixd/[user]/route.js:
--------------------------------------------------------------------------------
1 | // This endpoint serves as the notifier for phoenixd webhooks!
2 | // Be sure to place your webhook-secret in env.PHOENIXD_WEBHOOK_SECRET
3 | // In phoenix.conf, add the following line to turn on webhooks:
4 | // webhook=https://youdomain.com/api/phoenixd/route
5 |
6 | const crypto = require('crypto');
7 | const axios = require('axios');
8 | import { NextResponse } from 'next/server';
9 |
10 | function pushNotification(subject, body) {
11 | axios.post('https://api.pushover.net/1/messages.json', {
12 | token: process.env.PUSHOVER_TOKEN,
13 | user: process.env.PUSHOVER_USER,
14 | title: subject,
15 | message: body,
16 | html: 1
17 | })
18 | .then(response => {
19 | console.log('Push notification sent:', response.data);
20 | })
21 | .catch(error => {
22 | console.error('Error sending push notification:', error);
23 | });
24 | }
25 |
26 | export async function POST(req) {
27 | console.log("Welcome to the phoenixd webhook route!");
28 |
29 | try {
30 | const bodyRaw = await req.text();
31 | const bodyJSON = JSON.parse(bodyRaw);
32 | console.log('Webhook received:', bodyJSON);
33 |
34 | // Calculate the HMAC SHA256 hash
35 | const secret = Buffer.from(process.env.PHOENIXD_WEBHOOK_SECRET, 'utf8');
36 | const signature = req.headers.get('x-phoenix-signature');
37 | const hash = crypto.createHmac('sha256', secret)
38 | .update(bodyRaw)
39 | .digest('hex');
40 |
41 | if (crypto.timingSafeEqual(Buffer.from(signature, 'hex'), Buffer.from(hash, 'hex'))) {
42 | // Signature was valid!
43 | let type = bodyJSON?.type;
44 | let amount = Number(bodyJSON?.amountSat);
45 | let plural = amount > 1 ? 's' : '';
46 | amount = amount.toLocaleString();
47 |
48 | if (type == 'payment_received') {
49 | let subject = `You got paid ${amount} sat${plural} via phoenixd!`;
50 | let message = `Amount: ${amount} sat${plural}
Received via phoenixd 🪽`;
51 | pushNotification(subject, message);
52 | }
53 | } else {
54 | console.log('Invalid signature.');
55 | }
56 | } catch (error) {
57 | console.error('Error processing webhook:', error);
58 | return NextResponse.json({ message: 'Error processing webhook.', error: error.message });
59 | }
60 |
61 | return NextResponse.json({ message: 'Webhook received loud and clear!' });
62 | }
63 |
--------------------------------------------------------------------------------
/app/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dplusplus1024/lightning-server/605260fe3f012bf0e6418cc9126341dc27da1d26/app/favicon.ico
--------------------------------------------------------------------------------
/app/globals.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dplusplus1024/lightning-server/605260fe3f012bf0e6418cc9126341dc27da1d26/app/globals.css
--------------------------------------------------------------------------------
/files/lightning.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package lnrpc;
4 |
5 | option go_package = "github.com/lightningnetwork/lnd/lnrpc";
6 |
7 | /*
8 | * Comments in this file will be directly parsed into the API
9 | * Documentation as descriptions of the associated method, message, or field.
10 | * These descriptions should go right above the definition of the object, and
11 | * can be in either block or // comment format.
12 | *
13 | * An RPC method can be matched to an lncli command by placing a line in the
14 | * beginning of the description in exactly the following format:
15 | * lncli: `methodname`
16 | *
17 | * Failure to specify the exact name of the command will cause documentation
18 | * generation to fail.
19 | *
20 | * More information on how exactly the gRPC documentation is generated from
21 | * this proto file can be found here:
22 | * https://github.com/lightninglabs/lightning-api
23 | */
24 |
25 | // Lightning is the main RPC server of the daemon.
26 | service Lightning {
27 | /* lncli: `walletbalance`
28 | WalletBalance returns total unspent outputs(confirmed and unconfirmed), all
29 | confirmed unspent outputs and all unconfirmed unspent outputs under control
30 | of the wallet.
31 | */
32 | rpc WalletBalance (WalletBalanceRequest) returns (WalletBalanceResponse);
33 |
34 | /* lncli: `channelbalance`
35 | ChannelBalance returns a report on the total funds across all open channels,
36 | categorized in local/remote, pending local/remote and unsettled local/remote
37 | balances.
38 | */
39 | rpc ChannelBalance (ChannelBalanceRequest) returns (ChannelBalanceResponse);
40 |
41 | /* lncli: `listchaintxns`
42 | GetTransactions returns a list describing all the known transactions
43 | relevant to the wallet.
44 | */
45 | rpc GetTransactions (GetTransactionsRequest) returns (TransactionDetails);
46 |
47 | /* lncli: `estimatefee`
48 | EstimateFee asks the chain backend to estimate the fee rate and total fees
49 | for a transaction that pays to multiple specified outputs.
50 | When using REST, the `AddrToAmount` map type can be set by appending
51 | `&AddrToAmount[]=` to the URL. Unfortunately this
52 | map type doesn't appear in the REST API documentation because of a bug in
53 | the grpc-gateway library.
54 | */
55 | rpc EstimateFee (EstimateFeeRequest) returns (EstimateFeeResponse);
56 |
57 | /* lncli: `sendcoins`
58 | SendCoins executes a request to send coins to a particular address. Unlike
59 | SendMany, this RPC call only allows creating a single output at a time. If
60 | neither target_conf, or sat_per_vbyte are set, then the internal wallet will
61 | consult its fee model to determine a fee for the default confirmation
62 | target.
63 | */
64 | rpc SendCoins (SendCoinsRequest) returns (SendCoinsResponse);
65 |
66 | /* lncli: `listunspent`
67 | Deprecated, use walletrpc.ListUnspent instead.
68 | ListUnspent returns a list of all utxos spendable by the wallet with a
69 | number of confirmations between the specified minimum and maximum.
70 | */
71 | rpc ListUnspent (ListUnspentRequest) returns (ListUnspentResponse);
72 |
73 | /*
74 | SubscribeTransactions creates a uni-directional stream from the server to
75 | the client in which any newly discovered transactions relevant to the
76 | wallet are sent over.
77 | */
78 | rpc SubscribeTransactions (GetTransactionsRequest)
79 | returns (stream Transaction);
80 |
81 | /* lncli: `sendmany`
82 | SendMany handles a request for a transaction that creates multiple specified
83 | outputs in parallel. If neither target_conf, or sat_per_vbyte are set, then
84 | the internal wallet will consult its fee model to determine a fee for the
85 | default confirmation target.
86 | */
87 | rpc SendMany (SendManyRequest) returns (SendManyResponse);
88 |
89 | /* lncli: `newaddress`
90 | NewAddress creates a new address under control of the local wallet.
91 | */
92 | rpc NewAddress (NewAddressRequest) returns (NewAddressResponse);
93 |
94 | /* lncli: `signmessage`
95 | SignMessage signs a message with this node's private key. The returned
96 | signature string is `zbase32` encoded and pubkey recoverable, meaning that
97 | only the message digest and signature are needed for verification.
98 | */
99 | rpc SignMessage (SignMessageRequest) returns (SignMessageResponse);
100 |
101 | /* lncli: `verifymessage`
102 | VerifyMessage verifies a signature over a msg. The signature must be
103 | zbase32 encoded and signed by an active node in the resident node's
104 | channel database. In addition to returning the validity of the signature,
105 | VerifyMessage also returns the recovered pubkey from the signature.
106 | */
107 | rpc VerifyMessage (VerifyMessageRequest) returns (VerifyMessageResponse);
108 |
109 | /* lncli: `connect`
110 | ConnectPeer attempts to establish a connection to a remote peer. This is at
111 | the networking level, and is used for communication between nodes. This is
112 | distinct from establishing a channel with a peer.
113 | */
114 | rpc ConnectPeer (ConnectPeerRequest) returns (ConnectPeerResponse);
115 |
116 | /* lncli: `disconnect`
117 | DisconnectPeer attempts to disconnect one peer from another identified by a
118 | given pubKey. In the case that we currently have a pending or active channel
119 | with the target peer, then this action will be not be allowed.
120 | */
121 | rpc DisconnectPeer (DisconnectPeerRequest) returns (DisconnectPeerResponse);
122 |
123 | /* lncli: `listpeers`
124 | ListPeers returns a verbose listing of all currently active peers.
125 | */
126 | rpc ListPeers (ListPeersRequest) returns (ListPeersResponse);
127 |
128 | /*
129 | SubscribePeerEvents creates a uni-directional stream from the server to
130 | the client in which any events relevant to the state of peers are sent
131 | over. Events include peers going online and offline.
132 | */
133 | rpc SubscribePeerEvents (PeerEventSubscription) returns (stream PeerEvent);
134 |
135 | /* lncli: `getinfo`
136 | GetInfo returns general information concerning the lightning node including
137 | it's identity pubkey, alias, the chains it is connected to, and information
138 | concerning the number of open+pending channels.
139 | */
140 | rpc GetInfo (GetInfoRequest) returns (GetInfoResponse);
141 |
142 | /** lncli: `getrecoveryinfo`
143 | GetRecoveryInfo returns information concerning the recovery mode including
144 | whether it's in a recovery mode, whether the recovery is finished, and the
145 | progress made so far.
146 | */
147 | rpc GetRecoveryInfo (GetRecoveryInfoRequest)
148 | returns (GetRecoveryInfoResponse);
149 |
150 | // TODO(roasbeef): merge with below with bool?
151 | /* lncli: `pendingchannels`
152 | PendingChannels returns a list of all the channels that are currently
153 | considered "pending". A channel is pending if it has finished the funding
154 | workflow and is waiting for confirmations for the funding txn, or is in the
155 | process of closure, either initiated cooperatively or non-cooperatively.
156 | */
157 | rpc PendingChannels (PendingChannelsRequest)
158 | returns (PendingChannelsResponse);
159 |
160 | /* lncli: `listchannels`
161 | ListChannels returns a description of all the open channels that this node
162 | is a participant in.
163 | */
164 | rpc ListChannels (ListChannelsRequest) returns (ListChannelsResponse);
165 |
166 | /*
167 | SubscribeChannelEvents creates a uni-directional stream from the server to
168 | the client in which any updates relevant to the state of the channels are
169 | sent over. Events include new active channels, inactive channels, and closed
170 | channels.
171 | */
172 | rpc SubscribeChannelEvents (ChannelEventSubscription)
173 | returns (stream ChannelEventUpdate);
174 |
175 | /* lncli: `closedchannels`
176 | ClosedChannels returns a description of all the closed channels that
177 | this node was a participant in.
178 | */
179 | rpc ClosedChannels (ClosedChannelsRequest) returns (ClosedChannelsResponse);
180 |
181 | /*
182 | OpenChannelSync is a synchronous version of the OpenChannel RPC call. This
183 | call is meant to be consumed by clients to the REST proxy. As with all
184 | other sync calls, all byte slices are intended to be populated as hex
185 | encoded strings.
186 | */
187 | rpc OpenChannelSync (OpenChannelRequest) returns (ChannelPoint);
188 |
189 | /* lncli: `openchannel`
190 | OpenChannel attempts to open a singly funded channel specified in the
191 | request to a remote peer. Users are able to specify a target number of
192 | blocks that the funding transaction should be confirmed in, or a manual fee
193 | rate to us for the funding transaction. If neither are specified, then a
194 | lax block confirmation target is used. Each OpenStatusUpdate will return
195 | the pending channel ID of the in-progress channel. Depending on the
196 | arguments specified in the OpenChannelRequest, this pending channel ID can
197 | then be used to manually progress the channel funding flow.
198 | */
199 | rpc OpenChannel (OpenChannelRequest) returns (stream OpenStatusUpdate);
200 |
201 | /* lncli: `batchopenchannel`
202 | BatchOpenChannel attempts to open multiple single-funded channels in a
203 | single transaction in an atomic way. This means either all channel open
204 | requests succeed at once or all attempts are aborted if any of them fail.
205 | This is the safer variant of using PSBTs to manually fund a batch of
206 | channels through the OpenChannel RPC.
207 | */
208 | rpc BatchOpenChannel (BatchOpenChannelRequest)
209 | returns (BatchOpenChannelResponse);
210 |
211 | /*
212 | FundingStateStep is an advanced funding related call that allows the caller
213 | to either execute some preparatory steps for a funding workflow, or
214 | manually progress a funding workflow. The primary way a funding flow is
215 | identified is via its pending channel ID. As an example, this method can be
216 | used to specify that we're expecting a funding flow for a particular
217 | pending channel ID, for which we need to use specific parameters.
218 | Alternatively, this can be used to interactively drive PSBT signing for
219 | funding for partially complete funding transactions.
220 | */
221 | rpc FundingStateStep (FundingTransitionMsg) returns (FundingStateStepResp);
222 |
223 | /*
224 | ChannelAcceptor dispatches a bi-directional streaming RPC in which
225 | OpenChannel requests are sent to the client and the client responds with
226 | a boolean that tells LND whether or not to accept the channel. This allows
227 | node operators to specify their own criteria for accepting inbound channels
228 | through a single persistent connection.
229 | */
230 | rpc ChannelAcceptor (stream ChannelAcceptResponse)
231 | returns (stream ChannelAcceptRequest);
232 |
233 | /* lncli: `closechannel`
234 | CloseChannel attempts to close an active channel identified by its channel
235 | outpoint (ChannelPoint). The actions of this method can additionally be
236 | augmented to attempt a force close after a timeout period in the case of an
237 | inactive peer. If a non-force close (cooperative closure) is requested,
238 | then the user can specify either a target number of blocks until the
239 | closure transaction is confirmed, or a manual fee rate. If neither are
240 | specified, then a default lax, block confirmation target is used.
241 | */
242 | rpc CloseChannel (CloseChannelRequest) returns (stream CloseStatusUpdate);
243 |
244 | /* lncli: `abandonchannel`
245 | AbandonChannel removes all channel state from the database except for a
246 | close summary. This method can be used to get rid of permanently unusable
247 | channels due to bugs fixed in newer versions of lnd. This method can also be
248 | used to remove externally funded channels where the funding transaction was
249 | never broadcast. Only available for non-externally funded channels in dev
250 | build.
251 | */
252 | rpc AbandonChannel (AbandonChannelRequest) returns (AbandonChannelResponse);
253 |
254 | /* lncli: `sendpayment`
255 | Deprecated, use routerrpc.SendPaymentV2. SendPayment dispatches a
256 | bi-directional streaming RPC for sending payments through the Lightning
257 | Network. A single RPC invocation creates a persistent bi-directional
258 | stream allowing clients to rapidly send payments through the Lightning
259 | Network with a single persistent connection.
260 | */
261 | rpc SendPayment (stream SendRequest) returns (stream SendResponse) {
262 | option deprecated = true;
263 | }
264 |
265 | /*
266 | SendPaymentSync is the synchronous non-streaming version of SendPayment.
267 | This RPC is intended to be consumed by clients of the REST proxy.
268 | Additionally, this RPC expects the destination's public key and the payment
269 | hash (if any) to be encoded as hex strings.
270 | */
271 | rpc SendPaymentSync (SendRequest) returns (SendResponse);
272 |
273 | /* lncli: `sendtoroute`
274 | Deprecated, use routerrpc.SendToRouteV2. SendToRoute is a bi-directional
275 | streaming RPC for sending payment through the Lightning Network. This
276 | method differs from SendPayment in that it allows users to specify a full
277 | route manually. This can be used for things like rebalancing, and atomic
278 | swaps.
279 | */
280 | rpc SendToRoute (stream SendToRouteRequest) returns (stream SendResponse) {
281 | option deprecated = true;
282 | }
283 |
284 | /*
285 | SendToRouteSync is a synchronous version of SendToRoute. It Will block
286 | until the payment either fails or succeeds.
287 | */
288 | rpc SendToRouteSync (SendToRouteRequest) returns (SendResponse);
289 |
290 | /* lncli: `addinvoice`
291 | AddInvoice attempts to add a new invoice to the invoice database. Any
292 | duplicated invoices are rejected, therefore all invoices *must* have a
293 | unique payment preimage.
294 | */
295 | rpc AddInvoice (Invoice) returns (AddInvoiceResponse);
296 |
297 | /* lncli: `listinvoices`
298 | ListInvoices returns a list of all the invoices currently stored within the
299 | database. Any active debug invoices are ignored. It has full support for
300 | paginated responses, allowing users to query for specific invoices through
301 | their add_index. This can be done by using either the first_index_offset or
302 | last_index_offset fields included in the response as the index_offset of the
303 | next request. By default, the first 100 invoices created will be returned.
304 | Backwards pagination is also supported through the Reversed flag.
305 | */
306 | rpc ListInvoices (ListInvoiceRequest) returns (ListInvoiceResponse);
307 |
308 | /* lncli: `lookupinvoice`
309 | LookupInvoice attempts to look up an invoice according to its payment hash.
310 | The passed payment hash *must* be exactly 32 bytes, if not, an error is
311 | returned.
312 | */
313 | rpc LookupInvoice (PaymentHash) returns (Invoice);
314 |
315 | /*
316 | SubscribeInvoices returns a uni-directional stream (server -> client) for
317 | notifying the client of newly added/settled invoices. The caller can
318 | optionally specify the add_index and/or the settle_index. If the add_index
319 | is specified, then we'll first start by sending add invoice events for all
320 | invoices with an add_index greater than the specified value. If the
321 | settle_index is specified, the next, we'll send out all settle events for
322 | invoices with a settle_index greater than the specified value. One or both
323 | of these fields can be set. If no fields are set, then we'll only send out
324 | the latest add/settle events.
325 | */
326 | rpc SubscribeInvoices (InvoiceSubscription) returns (stream Invoice);
327 |
328 | /* lncli: `decodepayreq`
329 | DecodePayReq takes an encoded payment request string and attempts to decode
330 | it, returning a full description of the conditions encoded within the
331 | payment request.
332 | */
333 | rpc DecodePayReq (PayReqString) returns (PayReq);
334 |
335 | /* lncli: `listpayments`
336 | ListPayments returns a list of all outgoing payments.
337 | */
338 | rpc ListPayments (ListPaymentsRequest) returns (ListPaymentsResponse);
339 |
340 | /*
341 | DeletePayment deletes an outgoing payment from DB. Note that it will not
342 | attempt to delete an In-Flight payment, since that would be unsafe.
343 | */
344 | rpc DeletePayment (DeletePaymentRequest) returns (DeletePaymentResponse);
345 |
346 | /*
347 | DeleteAllPayments deletes all outgoing payments from DB. Note that it will
348 | not attempt to delete In-Flight payments, since that would be unsafe.
349 | */
350 | rpc DeleteAllPayments (DeleteAllPaymentsRequest)
351 | returns (DeleteAllPaymentsResponse);
352 |
353 | /* lncli: `describegraph`
354 | DescribeGraph returns a description of the latest graph state from the
355 | point of view of the node. The graph information is partitioned into two
356 | components: all the nodes/vertexes, and all the edges that connect the
357 | vertexes themselves. As this is a directed graph, the edges also contain
358 | the node directional specific routing policy which includes: the time lock
359 | delta, fee information, etc.
360 | */
361 | rpc DescribeGraph (ChannelGraphRequest) returns (ChannelGraph);
362 |
363 | /* lncli: `getnodemetrics`
364 | GetNodeMetrics returns node metrics calculated from the graph. Currently
365 | the only supported metric is betweenness centrality of individual nodes.
366 | */
367 | rpc GetNodeMetrics (NodeMetricsRequest) returns (NodeMetricsResponse);
368 |
369 | /* lncli: `getchaninfo`
370 | GetChanInfo returns the latest authenticated network announcement for the
371 | given channel identified by its channel ID: an 8-byte integer which
372 | uniquely identifies the location of transaction's funding output within the
373 | blockchain.
374 | */
375 | rpc GetChanInfo (ChanInfoRequest) returns (ChannelEdge);
376 |
377 | /* lncli: `getnodeinfo`
378 | GetNodeInfo returns the latest advertised, aggregated, and authenticated
379 | channel information for the specified node identified by its public key.
380 | */
381 | rpc GetNodeInfo (NodeInfoRequest) returns (NodeInfo);
382 |
383 | /* lncli: `queryroutes`
384 | QueryRoutes attempts to query the daemon's Channel Router for a possible
385 | route to a target destination capable of carrying a specific amount of
386 | satoshis. The returned route contains the full details required to craft and
387 | send an HTLC, also including the necessary information that should be
388 | present within the Sphinx packet encapsulated within the HTLC.
389 | When using REST, the `dest_custom_records` map type can be set by appending
390 | `&dest_custom_records[]=`
391 | to the URL. Unfortunately this map type doesn't appear in the REST API
392 | documentation because of a bug in the grpc-gateway library.
393 | */
394 | rpc QueryRoutes (QueryRoutesRequest) returns (QueryRoutesResponse);
395 |
396 | /* lncli: `getnetworkinfo`
397 | GetNetworkInfo returns some basic stats about the known channel graph from
398 | the point of view of the node.
399 | */
400 | rpc GetNetworkInfo (NetworkInfoRequest) returns (NetworkInfo);
401 |
402 | /* lncli: `stop`
403 | StopDaemon will send a shutdown request to the interrupt handler, triggering
404 | a graceful shutdown of the daemon.
405 | */
406 | rpc StopDaemon (StopRequest) returns (StopResponse);
407 |
408 | /*
409 | SubscribeChannelGraph launches a streaming RPC that allows the caller to
410 | receive notifications upon any changes to the channel graph topology from
411 | the point of view of the responding node. Events notified include: new
412 | nodes coming online, nodes updating their authenticated attributes, new
413 | channels being advertised, updates in the routing policy for a directional
414 | channel edge, and when channels are closed on-chain.
415 | */
416 | rpc SubscribeChannelGraph (GraphTopologySubscription)
417 | returns (stream GraphTopologyUpdate);
418 |
419 | /* lncli: `debuglevel`
420 | DebugLevel allows a caller to programmatically set the logging verbosity of
421 | lnd. The logging can be targeted according to a coarse daemon-wide logging
422 | level, or in a granular fashion to specify the logging for a target
423 | sub-system.
424 | */
425 | rpc DebugLevel (DebugLevelRequest) returns (DebugLevelResponse);
426 |
427 | /* lncli: `feereport`
428 | FeeReport allows the caller to obtain a report detailing the current fee
429 | schedule enforced by the node globally for each channel.
430 | */
431 | rpc FeeReport (FeeReportRequest) returns (FeeReportResponse);
432 |
433 | /* lncli: `updatechanpolicy`
434 | UpdateChannelPolicy allows the caller to update the fee schedule and
435 | channel policies for all channels globally, or a particular channel.
436 | */
437 | rpc UpdateChannelPolicy (PolicyUpdateRequest)
438 | returns (PolicyUpdateResponse);
439 |
440 | /* lncli: `fwdinghistory`
441 | ForwardingHistory allows the caller to query the htlcswitch for a record of
442 | all HTLCs forwarded within the target time range, and integer offset
443 | within that time range, for a maximum number of events. If no maximum number
444 | of events is specified, up to 100 events will be returned. If no time-range
445 | is specified, then events will be returned in the order that they occured.
446 | A list of forwarding events are returned. The size of each forwarding event
447 | is 40 bytes, and the max message size able to be returned in gRPC is 4 MiB.
448 | As a result each message can only contain 50k entries. Each response has
449 | the index offset of the last entry. The index offset can be provided to the
450 | request to allow the caller to skip a series of records.
451 | */
452 | rpc ForwardingHistory (ForwardingHistoryRequest)
453 | returns (ForwardingHistoryResponse);
454 |
455 | /* lncli: `exportchanbackup`
456 | ExportChannelBackup attempts to return an encrypted static channel backup
457 | for the target channel identified by it channel point. The backup is
458 | encrypted with a key generated from the aezeed seed of the user. The
459 | returned backup can either be restored using the RestoreChannelBackup
460 | method once lnd is running, or via the InitWallet and UnlockWallet methods
461 | from the WalletUnlocker service.
462 | */
463 | rpc ExportChannelBackup (ExportChannelBackupRequest)
464 | returns (ChannelBackup);
465 |
466 | /*
467 | ExportAllChannelBackups returns static channel backups for all existing
468 | channels known to lnd. A set of regular singular static channel backups for
469 | each channel are returned. Additionally, a multi-channel backup is returned
470 | as well, which contains a single encrypted blob containing the backups of
471 | each channel.
472 | */
473 | rpc ExportAllChannelBackups (ChanBackupExportRequest)
474 | returns (ChanBackupSnapshot);
475 |
476 | /*
477 | VerifyChanBackup allows a caller to verify the integrity of a channel backup
478 | snapshot. This method will accept either a packed Single or a packed Multi.
479 | Specifying both will result in an error.
480 | */
481 | rpc VerifyChanBackup (ChanBackupSnapshot)
482 | returns (VerifyChanBackupResponse);
483 |
484 | /* lncli: `restorechanbackup`
485 | RestoreChannelBackups accepts a set of singular channel backups, or a
486 | single encrypted multi-chan backup and attempts to recover any funds
487 | remaining within the channel. If we are able to unpack the backup, then the
488 | new channel will be shown under listchannels, as well as pending channels.
489 | */
490 | rpc RestoreChannelBackups (RestoreChanBackupRequest)
491 | returns (RestoreBackupResponse);
492 |
493 | /*
494 | SubscribeChannelBackups allows a client to sub-subscribe to the most up to
495 | date information concerning the state of all channel backups. Each time a
496 | new channel is added, we return the new set of channels, along with a
497 | multi-chan backup containing the backup info for all channels. Each time a
498 | channel is closed, we send a new update, which contains new new chan back
499 | ups, but the updated set of encrypted multi-chan backups with the closed
500 | channel(s) removed.
501 | */
502 | rpc SubscribeChannelBackups (ChannelBackupSubscription)
503 | returns (stream ChanBackupSnapshot);
504 |
505 | /* lncli: `bakemacaroon`
506 | BakeMacaroon allows the creation of a new macaroon with custom read and
507 | write permissions. No first-party caveats are added since this can be done
508 | offline.
509 | */
510 | rpc BakeMacaroon (BakeMacaroonRequest) returns (BakeMacaroonResponse);
511 |
512 | /* lncli: `listmacaroonids`
513 | ListMacaroonIDs returns all root key IDs that are in use.
514 | */
515 | rpc ListMacaroonIDs (ListMacaroonIDsRequest)
516 | returns (ListMacaroonIDsResponse);
517 |
518 | /* lncli: `deletemacaroonid`
519 | DeleteMacaroonID deletes the specified macaroon ID and invalidates all
520 | macaroons derived from that ID.
521 | */
522 | rpc DeleteMacaroonID (DeleteMacaroonIDRequest)
523 | returns (DeleteMacaroonIDResponse);
524 |
525 | /* lncli: `listpermissions`
526 | ListPermissions lists all RPC method URIs and their required macaroon
527 | permissions to access them.
528 | */
529 | rpc ListPermissions (ListPermissionsRequest)
530 | returns (ListPermissionsResponse);
531 |
532 | /*
533 | CheckMacaroonPermissions checks whether a request follows the constraints
534 | imposed on the macaroon and that the macaroon is authorized to follow the
535 | provided permissions.
536 | */
537 | rpc CheckMacaroonPermissions (CheckMacPermRequest)
538 | returns (CheckMacPermResponse);
539 |
540 | /*
541 | RegisterRPCMiddleware adds a new gRPC middleware to the interceptor chain. A
542 | gRPC middleware is software component external to lnd that aims to add
543 | additional business logic to lnd by observing/intercepting/validating
544 | incoming gRPC client requests and (if needed) replacing/overwriting outgoing
545 | messages before they're sent to the client. When registering the middleware
546 | must identify itself and indicate what custom macaroon caveats it wants to
547 | be responsible for. Only requests that contain a macaroon with that specific
548 | custom caveat are then sent to the middleware for inspection. The other
549 | option is to register for the read-only mode in which all requests/responses
550 | are forwarded for interception to the middleware but the middleware is not
551 | allowed to modify any responses. As a security measure, _no_ middleware can
552 | modify responses for requests made with _unencumbered_ macaroons!
553 | */
554 | rpc RegisterRPCMiddleware (stream RPCMiddlewareResponse)
555 | returns (stream RPCMiddlewareRequest);
556 |
557 | /* lncli: `sendcustom`
558 | SendCustomMessage sends a custom peer message.
559 | */
560 | rpc SendCustomMessage (SendCustomMessageRequest)
561 | returns (SendCustomMessageResponse);
562 |
563 | /* lncli: `subscribecustom`
564 | SubscribeCustomMessages subscribes to a stream of incoming custom peer
565 | messages.
566 | */
567 | rpc SubscribeCustomMessages (SubscribeCustomMessagesRequest)
568 | returns (stream CustomMessage);
569 |
570 | /* lncli: `listaliases`
571 | ListAliases returns the set of all aliases that have ever existed with
572 | their confirmed SCID (if it exists) and/or the base SCID (in the case of
573 | zero conf).
574 | */
575 | rpc ListAliases (ListAliasesRequest) returns (ListAliasesResponse);
576 |
577 | rpc LookupHtlc (LookupHtlcRequest) returns (LookupHtlcResponse);
578 | }
579 |
580 | message LookupHtlcRequest {
581 | uint64 chan_id = 1;
582 |
583 | uint64 htlc_index = 2;
584 | }
585 |
586 | message LookupHtlcResponse {
587 | bool settled = 1;
588 |
589 | bool offchain = 2;
590 | }
591 |
592 | message SubscribeCustomMessagesRequest {
593 | }
594 |
595 | message CustomMessage {
596 | // Peer from which the message originates
597 | bytes peer = 1;
598 |
599 | // Message type. This value will be in the custom range (>= 32768).
600 | uint32 type = 2;
601 |
602 | // Raw message data
603 | bytes data = 3;
604 | }
605 |
606 | message SendCustomMessageRequest {
607 | // Peer to send the message to
608 | bytes peer = 1;
609 |
610 | // Message type. This value needs to be in the custom range (>= 32768).
611 | uint32 type = 2;
612 |
613 | // Raw message data.
614 | bytes data = 3;
615 | }
616 |
617 | message SendCustomMessageResponse {
618 | }
619 |
620 | message Utxo {
621 | // The type of address
622 | AddressType address_type = 1;
623 |
624 | // The address
625 | string address = 2;
626 |
627 | // The value of the unspent coin in satoshis
628 | int64 amount_sat = 3;
629 |
630 | // The pkscript in hex
631 | string pk_script = 4;
632 |
633 | // The outpoint in format txid:n
634 | OutPoint outpoint = 5;
635 |
636 | // The number of confirmations for the Utxo
637 | int64 confirmations = 6;
638 | }
639 |
640 | enum OutputScriptType {
641 | SCRIPT_TYPE_PUBKEY_HASH = 0;
642 | SCRIPT_TYPE_SCRIPT_HASH = 1;
643 | SCRIPT_TYPE_WITNESS_V0_PUBKEY_HASH = 2;
644 | SCRIPT_TYPE_WITNESS_V0_SCRIPT_HASH = 3;
645 | SCRIPT_TYPE_PUBKEY = 4;
646 | SCRIPT_TYPE_MULTISIG = 5;
647 | SCRIPT_TYPE_NULLDATA = 6;
648 | SCRIPT_TYPE_NON_STANDARD = 7;
649 | SCRIPT_TYPE_WITNESS_UNKNOWN = 8;
650 | SCRIPT_TYPE_WITNESS_V1_TAPROOT = 9;
651 | }
652 |
653 | message OutputDetail {
654 | // The type of the output
655 | OutputScriptType output_type = 1;
656 |
657 | // The address
658 | string address = 2;
659 |
660 | // The pkscript in hex
661 | string pk_script = 3;
662 |
663 | // The output index used in the raw transaction
664 | int64 output_index = 4;
665 |
666 | // The value of the output coin in satoshis
667 | int64 amount = 5;
668 |
669 | // Denotes if the output is controlled by the internal wallet
670 | bool is_our_address = 6;
671 | }
672 |
673 | message Transaction {
674 | // The transaction hash
675 | string tx_hash = 1;
676 |
677 | // The transaction amount, denominated in satoshis
678 | int64 amount = 2;
679 |
680 | // The number of confirmations
681 | int32 num_confirmations = 3;
682 |
683 | // The hash of the block this transaction was included in
684 | string block_hash = 4;
685 |
686 | // The height of the block this transaction was included in
687 | int32 block_height = 5;
688 |
689 | // Timestamp of this transaction
690 | int64 time_stamp = 6;
691 |
692 | // Fees paid for this transaction
693 | int64 total_fees = 7;
694 |
695 | // Addresses that received funds for this transaction. Deprecated as it is
696 | // now incorporated in the output_details field.
697 | repeated string dest_addresses = 8 [deprecated = true];
698 |
699 | // Outputs that received funds for this transaction
700 | repeated OutputDetail output_details = 11;
701 |
702 | // The raw transaction hex.
703 | string raw_tx_hex = 9;
704 |
705 | // A label that was optionally set on transaction broadcast.
706 | string label = 10;
707 |
708 | // PreviousOutpoints/Inputs of this transaction.
709 | repeated PreviousOutPoint previous_outpoints = 12;
710 | }
711 |
712 | message GetTransactionsRequest {
713 | /*
714 | The height from which to list transactions, inclusive. If this value is
715 | greater than end_height, transactions will be read in reverse.
716 | */
717 | int32 start_height = 1;
718 |
719 | /*
720 | The height until which to list transactions, inclusive. To include
721 | unconfirmed transactions, this value should be set to -1, which will
722 | return transactions from start_height until the current chain tip and
723 | unconfirmed transactions. If no end_height is provided, the call will
724 | default to this option.
725 | */
726 | int32 end_height = 2;
727 |
728 | // An optional filter to only include transactions relevant to an account.
729 | string account = 3;
730 | }
731 |
732 | message TransactionDetails {
733 | // The list of transactions relevant to the wallet.
734 | repeated Transaction transactions = 1;
735 | }
736 |
737 | message FeeLimit {
738 | oneof limit {
739 | /*
740 | The fee limit expressed as a fixed amount of satoshis.
741 | The fields fixed and fixed_msat are mutually exclusive.
742 | */
743 | int64 fixed = 1;
744 |
745 | /*
746 | The fee limit expressed as a fixed amount of millisatoshis.
747 | The fields fixed and fixed_msat are mutually exclusive.
748 | */
749 | int64 fixed_msat = 3;
750 |
751 | // The fee limit expressed as a percentage of the payment amount.
752 | int64 percent = 2;
753 | }
754 | }
755 |
756 | message SendRequest {
757 | /*
758 | The identity pubkey of the payment recipient. When using REST, this field
759 | must be encoded as base64.
760 | */
761 | bytes dest = 1;
762 |
763 | /*
764 | The hex-encoded identity pubkey of the payment recipient. Deprecated now
765 | that the REST gateway supports base64 encoding of bytes fields.
766 | */
767 | string dest_string = 2 [deprecated = true];
768 |
769 | /*
770 | The amount to send expressed in satoshis.
771 | The fields amt and amt_msat are mutually exclusive.
772 | */
773 | int64 amt = 3;
774 |
775 | /*
776 | The amount to send expressed in millisatoshis.
777 | The fields amt and amt_msat are mutually exclusive.
778 | */
779 | int64 amt_msat = 12;
780 |
781 | /*
782 | The hash to use within the payment's HTLC. When using REST, this field
783 | must be encoded as base64.
784 | */
785 | bytes payment_hash = 4;
786 |
787 | /*
788 | The hex-encoded hash to use within the payment's HTLC. Deprecated now
789 | that the REST gateway supports base64 encoding of bytes fields.
790 | */
791 | string payment_hash_string = 5 [deprecated = true];
792 |
793 | /*
794 | A bare-bones invoice for a payment within the Lightning Network. With the
795 | details of the invoice, the sender has all the data necessary to send a
796 | payment to the recipient.
797 | */
798 | string payment_request = 6;
799 |
800 | /*
801 | The CLTV delta from the current height that should be used to set the
802 | timelock for the final hop.
803 | */
804 | int32 final_cltv_delta = 7;
805 |
806 | /*
807 | The maximum number of satoshis that will be paid as a fee of the payment.
808 | This value can be represented either as a percentage of the amount being
809 | sent, or as a fixed amount of the maximum fee the user is willing the pay to
810 | send the payment. If not specified, lnd will use a default value of 100%
811 | fees for small amounts (<=1k sat) or 5% fees for larger amounts.
812 | */
813 | FeeLimit fee_limit = 8;
814 |
815 | /*
816 | The channel id of the channel that must be taken to the first hop. If zero,
817 | any channel may be used.
818 | */
819 | uint64 outgoing_chan_id = 9 [jstype = JS_STRING];
820 |
821 | /*
822 | The pubkey of the last hop of the route. If empty, any hop may be used.
823 | */
824 | bytes last_hop_pubkey = 13;
825 |
826 | /*
827 | An optional maximum total time lock for the route. This should not exceed
828 | lnd's `--max-cltv-expiry` setting. If zero, then the value of
829 | `--max-cltv-expiry` is enforced.
830 | */
831 | uint32 cltv_limit = 10;
832 |
833 | /*
834 | An optional field that can be used to pass an arbitrary set of TLV records
835 | to a peer which understands the new records. This can be used to pass
836 | application specific data during the payment attempt. Record types are
837 | required to be in the custom range >= 65536. When using REST, the values
838 | must be encoded as base64.
839 | */
840 | map dest_custom_records = 11;
841 |
842 | // If set, circular payments to self are permitted.
843 | bool allow_self_payment = 14;
844 |
845 | /*
846 | Features assumed to be supported by the final node. All transitive feature
847 | dependencies must also be set properly. For a given feature bit pair, either
848 | optional or remote may be set, but not both. If this field is nil or empty,
849 | the router will try to load destination features from the graph as a
850 | fallback.
851 | */
852 | repeated FeatureBit dest_features = 15;
853 |
854 | /*
855 | The payment address of the generated invoice.
856 | */
857 | bytes payment_addr = 16;
858 | }
859 |
860 | message SendResponse {
861 | string payment_error = 1;
862 | bytes payment_preimage = 2;
863 | Route payment_route = 3;
864 | bytes payment_hash = 4;
865 | }
866 |
867 | message SendToRouteRequest {
868 | /*
869 | The payment hash to use for the HTLC. When using REST, this field must be
870 | encoded as base64.
871 | */
872 | bytes payment_hash = 1;
873 |
874 | /*
875 | An optional hex-encoded payment hash to be used for the HTLC. Deprecated now
876 | that the REST gateway supports base64 encoding of bytes fields.
877 | */
878 | string payment_hash_string = 2 [deprecated = true];
879 |
880 | reserved 3;
881 |
882 | // Route that should be used to attempt to complete the payment.
883 | Route route = 4;
884 | }
885 |
886 | message ChannelAcceptRequest {
887 | // The pubkey of the node that wishes to open an inbound channel.
888 | bytes node_pubkey = 1;
889 |
890 | // The hash of the genesis block that the proposed channel resides in.
891 | bytes chain_hash = 2;
892 |
893 | // The pending channel id.
894 | bytes pending_chan_id = 3;
895 |
896 | // The funding amount in satoshis that initiator wishes to use in the
897 | // channel.
898 | uint64 funding_amt = 4;
899 |
900 | // The push amount of the proposed channel in millisatoshis.
901 | uint64 push_amt = 5;
902 |
903 | // The dust limit of the initiator's commitment tx.
904 | uint64 dust_limit = 6;
905 |
906 | // The maximum amount of coins in millisatoshis that can be pending in this
907 | // channel.
908 | uint64 max_value_in_flight = 7;
909 |
910 | // The minimum amount of satoshis the initiator requires us to have at all
911 | // times.
912 | uint64 channel_reserve = 8;
913 |
914 | // The smallest HTLC in millisatoshis that the initiator will accept.
915 | uint64 min_htlc = 9;
916 |
917 | // The initial fee rate that the initiator suggests for both commitment
918 | // transactions.
919 | uint64 fee_per_kw = 10;
920 |
921 | /*
922 | The number of blocks to use for the relative time lock in the pay-to-self
923 | output of both commitment transactions.
924 | */
925 | uint32 csv_delay = 11;
926 |
927 | // The total number of incoming HTLC's that the initiator will accept.
928 | uint32 max_accepted_htlcs = 12;
929 |
930 | // A bit-field which the initiator uses to specify proposed channel
931 | // behavior.
932 | uint32 channel_flags = 13;
933 |
934 | // The commitment type the initiator wishes to use for the proposed channel.
935 | CommitmentType commitment_type = 14;
936 |
937 | // Whether the initiator wants to open a zero-conf channel via the channel
938 | // type.
939 | bool wants_zero_conf = 15;
940 |
941 | // Whether the initiator wants to use the scid-alias channel type. This is
942 | // separate from the feature bit.
943 | bool wants_scid_alias = 16;
944 | }
945 |
946 | message ChannelAcceptResponse {
947 | // Whether or not the client accepts the channel.
948 | bool accept = 1;
949 |
950 | // The pending channel id to which this response applies.
951 | bytes pending_chan_id = 2;
952 |
953 | /*
954 | An optional error to send the initiating party to indicate why the channel
955 | was rejected. This field *should not* contain sensitive information, it will
956 | be sent to the initiating party. This field should only be set if accept is
957 | false, the channel will be rejected if an error is set with accept=true
958 | because the meaning of this response is ambiguous. Limited to 500
959 | characters.
960 | */
961 | string error = 3;
962 |
963 | /*
964 | The upfront shutdown address to use if the initiating peer supports option
965 | upfront shutdown script (see ListPeers for the features supported). Note
966 | that the channel open will fail if this value is set for a peer that does
967 | not support this feature bit.
968 | */
969 | string upfront_shutdown = 4;
970 |
971 | /*
972 | The csv delay (in blocks) that we require for the remote party.
973 | */
974 | uint32 csv_delay = 5;
975 |
976 | /*
977 | The reserve amount in satoshis that we require the remote peer to adhere to.
978 | We require that the remote peer always have some reserve amount allocated to
979 | them so that there is always a disincentive to broadcast old state (if they
980 | hold 0 sats on their side of the channel, there is nothing to lose).
981 | */
982 | uint64 reserve_sat = 6;
983 |
984 | /*
985 | The maximum amount of funds in millisatoshis that we allow the remote peer
986 | to have in outstanding htlcs.
987 | */
988 | uint64 in_flight_max_msat = 7;
989 |
990 | /*
991 | The maximum number of htlcs that the remote peer can offer us.
992 | */
993 | uint32 max_htlc_count = 8;
994 |
995 | /*
996 | The minimum value in millisatoshis for incoming htlcs on the channel.
997 | */
998 | uint64 min_htlc_in = 9;
999 |
1000 | /*
1001 | The number of confirmations we require before we consider the channel open.
1002 | */
1003 | uint32 min_accept_depth = 10;
1004 |
1005 | /*
1006 | Whether the responder wants this to be a zero-conf channel. This will fail
1007 | if either side does not have the scid-alias feature bit set. The minimum
1008 | depth field must be zero if this is true.
1009 | */
1010 | bool zero_conf = 11;
1011 | }
1012 |
1013 | message ChannelPoint {
1014 | oneof funding_txid {
1015 | /*
1016 | Txid of the funding transaction. When using REST, this field must be
1017 | encoded as base64.
1018 | */
1019 | bytes funding_txid_bytes = 1;
1020 |
1021 | /*
1022 | Hex-encoded string representing the byte-reversed hash of the funding
1023 | transaction.
1024 | */
1025 | string funding_txid_str = 2;
1026 | }
1027 |
1028 | // The index of the output of the funding transaction
1029 | uint32 output_index = 3;
1030 | }
1031 |
1032 | message OutPoint {
1033 | // Raw bytes representing the transaction id.
1034 | bytes txid_bytes = 1;
1035 |
1036 | // Reversed, hex-encoded string representing the transaction id.
1037 | string txid_str = 2;
1038 |
1039 | // The index of the output on the transaction.
1040 | uint32 output_index = 3;
1041 | }
1042 |
1043 | message PreviousOutPoint {
1044 | // The outpoint in format txid:n.
1045 | string outpoint = 1;
1046 |
1047 | // Denotes if the outpoint is controlled by the internal wallet.
1048 | // The flag will only detect p2wkh, np2wkh and p2tr inputs as its own.
1049 | bool is_our_output = 2;
1050 | }
1051 |
1052 | message LightningAddress {
1053 | // The identity pubkey of the Lightning node.
1054 | string pubkey = 1;
1055 |
1056 | // The network location of the lightning node, e.g. `69.69.69.69:1337` or
1057 | // `localhost:10011`.
1058 | string host = 2;
1059 | }
1060 |
1061 | message EstimateFeeRequest {
1062 | // The map from addresses to amounts for the transaction.
1063 | map AddrToAmount = 1;
1064 |
1065 | // The target number of blocks that this transaction should be confirmed
1066 | // by.
1067 | int32 target_conf = 2;
1068 |
1069 | // The minimum number of confirmations each one of your outputs used for
1070 | // the transaction must satisfy.
1071 | int32 min_confs = 3;
1072 |
1073 | // Whether unconfirmed outputs should be used as inputs for the transaction.
1074 | bool spend_unconfirmed = 4;
1075 | }
1076 |
1077 | message EstimateFeeResponse {
1078 | // The total fee in satoshis.
1079 | int64 fee_sat = 1;
1080 |
1081 | // Deprecated, use sat_per_vbyte.
1082 | // The fee rate in satoshi/vbyte.
1083 | int64 feerate_sat_per_byte = 2 [deprecated = true];
1084 |
1085 | // The fee rate in satoshi/vbyte.
1086 | uint64 sat_per_vbyte = 3;
1087 | }
1088 |
1089 | message SendManyRequest {
1090 | // The map from addresses to amounts
1091 | map AddrToAmount = 1;
1092 |
1093 | // The target number of blocks that this transaction should be confirmed
1094 | // by.
1095 | int32 target_conf = 3;
1096 |
1097 | // A manual fee rate set in sat/vbyte that should be used when crafting the
1098 | // transaction.
1099 | uint64 sat_per_vbyte = 4;
1100 |
1101 | // Deprecated, use sat_per_vbyte.
1102 | // A manual fee rate set in sat/vbyte that should be used when crafting the
1103 | // transaction.
1104 | int64 sat_per_byte = 5 [deprecated = true];
1105 |
1106 | // An optional label for the transaction, limited to 500 characters.
1107 | string label = 6;
1108 |
1109 | // The minimum number of confirmations each one of your outputs used for
1110 | // the transaction must satisfy.
1111 | int32 min_confs = 7;
1112 |
1113 | // Whether unconfirmed outputs should be used as inputs for the transaction.
1114 | bool spend_unconfirmed = 8;
1115 | }
1116 | message SendManyResponse {
1117 | // The id of the transaction
1118 | string txid = 1;
1119 | }
1120 |
1121 | message SendCoinsRequest {
1122 | // The address to send coins to
1123 | string addr = 1;
1124 |
1125 | // The amount in satoshis to send
1126 | int64 amount = 2;
1127 |
1128 | // The target number of blocks that this transaction should be confirmed
1129 | // by.
1130 | int32 target_conf = 3;
1131 |
1132 | // A manual fee rate set in sat/vbyte that should be used when crafting the
1133 | // transaction.
1134 | uint64 sat_per_vbyte = 4;
1135 |
1136 | // Deprecated, use sat_per_vbyte.
1137 | // A manual fee rate set in sat/vbyte that should be used when crafting the
1138 | // transaction.
1139 | int64 sat_per_byte = 5 [deprecated = true];
1140 |
1141 | /*
1142 | If set, then the amount field will be ignored, and lnd will attempt to
1143 | send all the coins under control of the internal wallet to the specified
1144 | address.
1145 | */
1146 | bool send_all = 6;
1147 |
1148 | // An optional label for the transaction, limited to 500 characters.
1149 | string label = 7;
1150 |
1151 | // The minimum number of confirmations each one of your outputs used for
1152 | // the transaction must satisfy.
1153 | int32 min_confs = 8;
1154 |
1155 | // Whether unconfirmed outputs should be used as inputs for the transaction.
1156 | bool spend_unconfirmed = 9;
1157 | }
1158 | message SendCoinsResponse {
1159 | // The transaction ID of the transaction
1160 | string txid = 1;
1161 | }
1162 |
1163 | message ListUnspentRequest {
1164 | // The minimum number of confirmations to be included.
1165 | int32 min_confs = 1;
1166 |
1167 | // The maximum number of confirmations to be included.
1168 | int32 max_confs = 2;
1169 |
1170 | // An optional filter to only include outputs belonging to an account.
1171 | string account = 3;
1172 | }
1173 | message ListUnspentResponse {
1174 | // A list of utxos
1175 | repeated Utxo utxos = 1;
1176 | }
1177 |
1178 | /*
1179 | `AddressType` has to be one of:
1180 | - `p2wkh`: Pay to witness key hash (`WITNESS_PUBKEY_HASH` = 0)
1181 | - `np2wkh`: Pay to nested witness key hash (`NESTED_PUBKEY_HASH` = 1)
1182 | - `p2tr`: Pay to taproot pubkey (`TAPROOT_PUBKEY` = 4)
1183 | */
1184 | enum AddressType {
1185 | WITNESS_PUBKEY_HASH = 0;
1186 | NESTED_PUBKEY_HASH = 1;
1187 | UNUSED_WITNESS_PUBKEY_HASH = 2;
1188 | UNUSED_NESTED_PUBKEY_HASH = 3;
1189 | TAPROOT_PUBKEY = 4;
1190 | UNUSED_TAPROOT_PUBKEY = 5;
1191 | }
1192 |
1193 | message NewAddressRequest {
1194 | // The type of address to generate.
1195 | AddressType type = 1;
1196 |
1197 | /*
1198 | The name of the account to generate a new address for. If empty, the
1199 | default wallet account is used.
1200 | */
1201 | string account = 2;
1202 | }
1203 | message NewAddressResponse {
1204 | // The newly generated wallet address
1205 | string address = 1;
1206 | }
1207 |
1208 | message SignMessageRequest {
1209 | /*
1210 | The message to be signed. When using REST, this field must be encoded as
1211 | base64.
1212 | */
1213 | bytes msg = 1;
1214 |
1215 | /*
1216 | Instead of the default double-SHA256 hashing of the message before signing,
1217 | only use one round of hashing instead.
1218 | */
1219 | bool single_hash = 2;
1220 | }
1221 | message SignMessageResponse {
1222 | // The signature for the given message
1223 | string signature = 1;
1224 | }
1225 |
1226 | message VerifyMessageRequest {
1227 | /*
1228 | The message over which the signature is to be verified. When using REST,
1229 | this field must be encoded as base64.
1230 | */
1231 | bytes msg = 1;
1232 |
1233 | // The signature to be verified over the given message
1234 | string signature = 2;
1235 | }
1236 | message VerifyMessageResponse {
1237 | // Whether the signature was valid over the given message
1238 | bool valid = 1;
1239 |
1240 | // The pubkey recovered from the signature
1241 | string pubkey = 2;
1242 | }
1243 |
1244 | message ConnectPeerRequest {
1245 | /*
1246 | Lightning address of the peer to connect to.
1247 | */
1248 | LightningAddress addr = 1;
1249 |
1250 | /*
1251 | If set, the daemon will attempt to persistently connect to the target
1252 | peer. Otherwise, the call will be synchronous.
1253 | */
1254 | bool perm = 2;
1255 |
1256 | /*
1257 | The connection timeout value (in seconds) for this request. It won't affect
1258 | other requests.
1259 | */
1260 | uint64 timeout = 3;
1261 | }
1262 | message ConnectPeerResponse {
1263 | }
1264 |
1265 | message DisconnectPeerRequest {
1266 | // The pubkey of the node to disconnect from
1267 | string pub_key = 1;
1268 | }
1269 | message DisconnectPeerResponse {
1270 | }
1271 |
1272 | message HTLC {
1273 | bool incoming = 1;
1274 | int64 amount = 2;
1275 | bytes hash_lock = 3;
1276 | uint32 expiration_height = 4;
1277 |
1278 | // Index identifying the htlc on the channel.
1279 | uint64 htlc_index = 5;
1280 |
1281 | // If this HTLC is involved in a forwarding operation, this field indicates
1282 | // the forwarding channel. For an outgoing htlc, it is the incoming channel.
1283 | // For an incoming htlc, it is the outgoing channel. When the htlc
1284 | // originates from this node or this node is the final destination,
1285 | // forwarding_channel will be zero. The forwarding channel will also be zero
1286 | // for htlcs that need to be forwarded but don't have a forwarding decision
1287 | // persisted yet.
1288 | uint64 forwarding_channel = 6;
1289 |
1290 | // Index identifying the htlc on the forwarding channel.
1291 | uint64 forwarding_htlc_index = 7;
1292 | }
1293 |
1294 | enum CommitmentType {
1295 | /*
1296 | Returned when the commitment type isn't known or unavailable.
1297 | */
1298 | UNKNOWN_COMMITMENT_TYPE = 0;
1299 |
1300 | /*
1301 | A channel using the legacy commitment format having tweaked to_remote
1302 | keys.
1303 | */
1304 | LEGACY = 1;
1305 |
1306 | /*
1307 | A channel that uses the modern commitment format where the key in the
1308 | output of the remote party does not change each state. This makes back
1309 | up and recovery easier as when the channel is closed, the funds go
1310 | directly to that key.
1311 | */
1312 | STATIC_REMOTE_KEY = 2;
1313 |
1314 | /*
1315 | A channel that uses a commitment format that has anchor outputs on the
1316 | commitments, allowing fee bumping after a force close transaction has
1317 | been broadcast.
1318 | */
1319 | ANCHORS = 3;
1320 |
1321 | /*
1322 | A channel that uses a commitment type that builds upon the anchors
1323 | commitment format, but in addition requires a CLTV clause to spend outputs
1324 | paying to the channel initiator. This is intended for use on leased channels
1325 | to guarantee that the channel initiator has no incentives to close a leased
1326 | channel before its maturity date.
1327 | */
1328 | SCRIPT_ENFORCED_LEASE = 4;
1329 | }
1330 |
1331 | message ChannelConstraints {
1332 | /*
1333 | The CSV delay expressed in relative blocks. If the channel is force closed,
1334 | we will need to wait for this many blocks before we can regain our funds.
1335 | */
1336 | uint32 csv_delay = 1;
1337 |
1338 | // The minimum satoshis this node is required to reserve in its balance.
1339 | uint64 chan_reserve_sat = 2;
1340 |
1341 | // The dust limit (in satoshis) of the initiator's commitment tx.
1342 | uint64 dust_limit_sat = 3;
1343 |
1344 | // The maximum amount of coins in millisatoshis that can be pending in this
1345 | // channel.
1346 | uint64 max_pending_amt_msat = 4;
1347 |
1348 | // The smallest HTLC in millisatoshis that the initiator will accept.
1349 | uint64 min_htlc_msat = 5;
1350 |
1351 | // The total number of incoming HTLC's that the initiator will accept.
1352 | uint32 max_accepted_htlcs = 6;
1353 | }
1354 |
1355 | message Channel {
1356 | // Whether this channel is active or not
1357 | bool active = 1;
1358 |
1359 | // The identity pubkey of the remote node
1360 | string remote_pubkey = 2;
1361 |
1362 | /*
1363 | The outpoint (txid:index) of the funding transaction. With this value, Bob
1364 | will be able to generate a signature for Alice's version of the commitment
1365 | transaction.
1366 | */
1367 | string channel_point = 3;
1368 |
1369 | /*
1370 | The unique channel ID for the channel. The first 3 bytes are the block
1371 | height, the next 3 the index within the block, and the last 2 bytes are the
1372 | output index for the channel.
1373 | */
1374 | uint64 chan_id = 4 [jstype = JS_STRING];
1375 |
1376 | // The total amount of funds held in this channel
1377 | int64 capacity = 5;
1378 |
1379 | // This node's current balance in this channel
1380 | int64 local_balance = 6;
1381 |
1382 | // The counterparty's current balance in this channel
1383 | int64 remote_balance = 7;
1384 |
1385 | /*
1386 | The amount calculated to be paid in fees for the current set of commitment
1387 | transactions. The fee amount is persisted with the channel in order to
1388 | allow the fee amount to be removed and recalculated with each channel state
1389 | update, including updates that happen after a system restart.
1390 | */
1391 | int64 commit_fee = 8;
1392 |
1393 | // The weight of the commitment transaction
1394 | int64 commit_weight = 9;
1395 |
1396 | /*
1397 | The required number of satoshis per kilo-weight that the requester will pay
1398 | at all times, for both the funding transaction and commitment transaction.
1399 | This value can later be updated once the channel is open.
1400 | */
1401 | int64 fee_per_kw = 10;
1402 |
1403 | // The unsettled balance in this channel
1404 | int64 unsettled_balance = 11;
1405 |
1406 | /*
1407 | The total number of satoshis we've sent within this channel.
1408 | */
1409 | int64 total_satoshis_sent = 12;
1410 |
1411 | /*
1412 | The total number of satoshis we've received within this channel.
1413 | */
1414 | int64 total_satoshis_received = 13;
1415 |
1416 | /*
1417 | The total number of updates conducted within this channel.
1418 | */
1419 | uint64 num_updates = 14;
1420 |
1421 | /*
1422 | The list of active, uncleared HTLCs currently pending within the channel.
1423 | */
1424 | repeated HTLC pending_htlcs = 15;
1425 |
1426 | /*
1427 | Deprecated. The CSV delay expressed in relative blocks. If the channel is
1428 | force closed, we will need to wait for this many blocks before we can regain
1429 | our funds.
1430 | */
1431 | uint32 csv_delay = 16 [deprecated = true];
1432 |
1433 | // Whether this channel is advertised to the network or not.
1434 | bool private = 17;
1435 |
1436 | // True if we were the ones that created the channel.
1437 | bool initiator = 18;
1438 |
1439 | // A set of flags showing the current state of the channel.
1440 | string chan_status_flags = 19;
1441 |
1442 | // Deprecated. The minimum satoshis this node is required to reserve in its
1443 | // balance.
1444 | int64 local_chan_reserve_sat = 20 [deprecated = true];
1445 |
1446 | /*
1447 | Deprecated. The minimum satoshis the other node is required to reserve in
1448 | its balance.
1449 | */
1450 | int64 remote_chan_reserve_sat = 21 [deprecated = true];
1451 |
1452 | // Deprecated. Use commitment_type.
1453 | bool static_remote_key = 22 [deprecated = true];
1454 |
1455 | // The commitment type used by this channel.
1456 | CommitmentType commitment_type = 26;
1457 |
1458 | /*
1459 | The number of seconds that the channel has been monitored by the channel
1460 | scoring system. Scores are currently not persisted, so this value may be
1461 | less than the lifetime of the channel [EXPERIMENTAL].
1462 | */
1463 | int64 lifetime = 23;
1464 |
1465 | /*
1466 | The number of seconds that the remote peer has been observed as being online
1467 | by the channel scoring system over the lifetime of the channel
1468 | [EXPERIMENTAL].
1469 | */
1470 | int64 uptime = 24;
1471 |
1472 | /*
1473 | Close address is the address that we will enforce payout to on cooperative
1474 | close if the channel was opened utilizing option upfront shutdown. This
1475 | value can be set on channel open by setting close_address in an open channel
1476 | request. If this value is not set, you can still choose a payout address by
1477 | cooperatively closing with the delivery_address field set.
1478 | */
1479 | string close_address = 25;
1480 |
1481 | /*
1482 | The amount that the initiator of the channel optionally pushed to the remote
1483 | party on channel open. This amount will be zero if the channel initiator did
1484 | not push any funds to the remote peer. If the initiator field is true, we
1485 | pushed this amount to our peer, if it is false, the remote peer pushed this
1486 | amount to us.
1487 | */
1488 | uint64 push_amount_sat = 27;
1489 |
1490 | /*
1491 | This uint32 indicates if this channel is to be considered 'frozen'. A
1492 | frozen channel doest not allow a cooperative channel close by the
1493 | initiator. The thaw_height is the height that this restriction stops
1494 | applying to the channel. This field is optional, not setting it or using a
1495 | value of zero will mean the channel has no additional restrictions. The
1496 | height can be interpreted in two ways: as a relative height if the value is
1497 | less than 500,000, or as an absolute height otherwise.
1498 | */
1499 | uint32 thaw_height = 28;
1500 |
1501 | // List constraints for the local node.
1502 | ChannelConstraints local_constraints = 29;
1503 |
1504 | // List constraints for the remote node.
1505 | ChannelConstraints remote_constraints = 30;
1506 |
1507 | /*
1508 | This lists out the set of alias short channel ids that exist for a channel.
1509 | This may be empty.
1510 | */
1511 | repeated uint64 alias_scids = 31;
1512 |
1513 | // Whether or not this is a zero-conf channel.
1514 | bool zero_conf = 32;
1515 |
1516 | // This is the confirmed / on-chain zero-conf SCID.
1517 | uint64 zero_conf_confirmed_scid = 33;
1518 | }
1519 |
1520 | message ListChannelsRequest {
1521 | bool active_only = 1;
1522 | bool inactive_only = 2;
1523 | bool public_only = 3;
1524 | bool private_only = 4;
1525 |
1526 | /*
1527 | Filters the response for channels with a target peer's pubkey. If peer is
1528 | empty, all channels will be returned.
1529 | */
1530 | bytes peer = 5;
1531 | }
1532 | message ListChannelsResponse {
1533 | // The list of active channels
1534 | repeated Channel channels = 11;
1535 | }
1536 |
1537 | message AliasMap {
1538 | /*
1539 | For non-zero-conf channels, this is the confirmed SCID. Otherwise, this is
1540 | the first assigned "base" alias.
1541 | */
1542 | uint64 base_scid = 1;
1543 |
1544 | // The set of all aliases stored for the base SCID.
1545 | repeated uint64 aliases = 2;
1546 | }
1547 | message ListAliasesRequest {
1548 | }
1549 | message ListAliasesResponse {
1550 | repeated AliasMap alias_maps = 1;
1551 | }
1552 |
1553 | enum Initiator {
1554 | INITIATOR_UNKNOWN = 0;
1555 | INITIATOR_LOCAL = 1;
1556 | INITIATOR_REMOTE = 2;
1557 | INITIATOR_BOTH = 3;
1558 | }
1559 |
1560 | message ChannelCloseSummary {
1561 | // The outpoint (txid:index) of the funding transaction.
1562 | string channel_point = 1;
1563 |
1564 | // The unique channel ID for the channel.
1565 | uint64 chan_id = 2 [jstype = JS_STRING];
1566 |
1567 | // The hash of the genesis block that this channel resides within.
1568 | string chain_hash = 3;
1569 |
1570 | // The txid of the transaction which ultimately closed this channel.
1571 | string closing_tx_hash = 4;
1572 |
1573 | // Public key of the remote peer that we formerly had a channel with.
1574 | string remote_pubkey = 5;
1575 |
1576 | // Total capacity of the channel.
1577 | int64 capacity = 6;
1578 |
1579 | // Height at which the funding transaction was spent.
1580 | uint32 close_height = 7;
1581 |
1582 | // Settled balance at the time of channel closure
1583 | int64 settled_balance = 8;
1584 |
1585 | // The sum of all the time-locked outputs at the time of channel closure
1586 | int64 time_locked_balance = 9;
1587 |
1588 | enum ClosureType {
1589 | COOPERATIVE_CLOSE = 0;
1590 | LOCAL_FORCE_CLOSE = 1;
1591 | REMOTE_FORCE_CLOSE = 2;
1592 | BREACH_CLOSE = 3;
1593 | FUNDING_CANCELED = 4;
1594 | ABANDONED = 5;
1595 | }
1596 |
1597 | // Details on how the channel was closed.
1598 | ClosureType close_type = 10;
1599 |
1600 | /*
1601 | Open initiator is the party that initiated opening the channel. Note that
1602 | this value may be unknown if the channel was closed before we migrated to
1603 | store open channel information after close.
1604 | */
1605 | Initiator open_initiator = 11;
1606 |
1607 | /*
1608 | Close initiator indicates which party initiated the close. This value will
1609 | be unknown for channels that were cooperatively closed before we started
1610 | tracking cooperative close initiators. Note that this indicates which party
1611 | initiated a close, and it is possible for both to initiate cooperative or
1612 | force closes, although only one party's close will be confirmed on chain.
1613 | */
1614 | Initiator close_initiator = 12;
1615 |
1616 | repeated Resolution resolutions = 13;
1617 |
1618 | /*
1619 | This lists out the set of alias short channel ids that existed for the
1620 | closed channel. This may be empty.
1621 | */
1622 | repeated uint64 alias_scids = 14;
1623 |
1624 | // The confirmed SCID for a zero-conf channel.
1625 | uint64 zero_conf_confirmed_scid = 15 [jstype = JS_STRING];
1626 | }
1627 |
1628 | enum ResolutionType {
1629 | TYPE_UNKNOWN = 0;
1630 |
1631 | // We resolved an anchor output.
1632 | ANCHOR = 1;
1633 |
1634 | /*
1635 | We are resolving an incoming htlc on chain. This if this htlc is
1636 | claimed, we swept the incoming htlc with the preimage. If it is timed
1637 | out, our peer swept the timeout path.
1638 | */
1639 | INCOMING_HTLC = 2;
1640 |
1641 | /*
1642 | We are resolving an outgoing htlc on chain. If this htlc is claimed,
1643 | the remote party swept the htlc with the preimage. If it is timed out,
1644 | we swept it with the timeout path.
1645 | */
1646 | OUTGOING_HTLC = 3;
1647 |
1648 | // We force closed and need to sweep our time locked commitment output.
1649 | COMMIT = 4;
1650 | }
1651 |
1652 | enum ResolutionOutcome {
1653 | // Outcome unknown.
1654 | OUTCOME_UNKNOWN = 0;
1655 |
1656 | // An output was claimed on chain.
1657 | CLAIMED = 1;
1658 |
1659 | // An output was left unclaimed on chain.
1660 | UNCLAIMED = 2;
1661 |
1662 | /*
1663 | ResolverOutcomeAbandoned indicates that an output that we did not
1664 | claim on chain, for example an anchor that we did not sweep and a
1665 | third party claimed on chain, or a htlc that we could not decode
1666 | so left unclaimed.
1667 | */
1668 | ABANDONED = 3;
1669 |
1670 | /*
1671 | If we force closed our channel, our htlcs need to be claimed in two
1672 | stages. This outcome represents the broadcast of a timeout or success
1673 | transaction for this two stage htlc claim.
1674 | */
1675 | FIRST_STAGE = 4;
1676 |
1677 | // A htlc was timed out on chain.
1678 | TIMEOUT = 5;
1679 | }
1680 |
1681 | message Resolution {
1682 | // The type of output we are resolving.
1683 | ResolutionType resolution_type = 1;
1684 |
1685 | // The outcome of our on chain action that resolved the outpoint.
1686 | ResolutionOutcome outcome = 2;
1687 |
1688 | // The outpoint that was spent by the resolution.
1689 | OutPoint outpoint = 3;
1690 |
1691 | // The amount that was claimed by the resolution.
1692 | uint64 amount_sat = 4;
1693 |
1694 | // The hex-encoded transaction ID of the sweep transaction that spent the
1695 | // output.
1696 | string sweep_txid = 5;
1697 | }
1698 |
1699 | message ClosedChannelsRequest {
1700 | bool cooperative = 1;
1701 | bool local_force = 2;
1702 | bool remote_force = 3;
1703 | bool breach = 4;
1704 | bool funding_canceled = 5;
1705 | bool abandoned = 6;
1706 | }
1707 |
1708 | message ClosedChannelsResponse {
1709 | repeated ChannelCloseSummary channels = 1;
1710 | }
1711 |
1712 | message Peer {
1713 | // The identity pubkey of the peer
1714 | string pub_key = 1;
1715 |
1716 | // Network address of the peer; eg `127.0.0.1:10011`
1717 | string address = 3;
1718 |
1719 | // Bytes of data transmitted to this peer
1720 | uint64 bytes_sent = 4;
1721 |
1722 | // Bytes of data transmitted from this peer
1723 | uint64 bytes_recv = 5;
1724 |
1725 | // Satoshis sent to this peer
1726 | int64 sat_sent = 6;
1727 |
1728 | // Satoshis received from this peer
1729 | int64 sat_recv = 7;
1730 |
1731 | // A channel is inbound if the counterparty initiated the channel
1732 | bool inbound = 8;
1733 |
1734 | // Ping time to this peer
1735 | int64 ping_time = 9;
1736 |
1737 | enum SyncType {
1738 | /*
1739 | Denotes that we cannot determine the peer's current sync type.
1740 | */
1741 | UNKNOWN_SYNC = 0;
1742 |
1743 | /*
1744 | Denotes that we are actively receiving new graph updates from the peer.
1745 | */
1746 | ACTIVE_SYNC = 1;
1747 |
1748 | /*
1749 | Denotes that we are not receiving new graph updates from the peer.
1750 | */
1751 | PASSIVE_SYNC = 2;
1752 |
1753 | /*
1754 | Denotes that this peer is pinned into an active sync.
1755 | */
1756 | PINNED_SYNC = 3;
1757 | }
1758 |
1759 | // The type of sync we are currently performing with this peer.
1760 | SyncType sync_type = 10;
1761 |
1762 | // Features advertised by the remote peer in their init message.
1763 | map features = 11;
1764 |
1765 | /*
1766 | The latest errors received from our peer with timestamps, limited to the 10
1767 | most recent errors. These errors are tracked across peer connections, but
1768 | are not persisted across lnd restarts. Note that these errors are only
1769 | stored for peers that we have channels open with, to prevent peers from
1770 | spamming us with errors at no cost.
1771 | */
1772 | repeated TimestampedError errors = 12;
1773 |
1774 | /*
1775 | The number of times we have recorded this peer going offline or coming
1776 | online, recorded across restarts. Note that this value is decreased over
1777 | time if the peer has not recently flapped, so that we can forgive peers
1778 | with historically high flap counts.
1779 | */
1780 | int32 flap_count = 13;
1781 |
1782 | /*
1783 | The timestamp of the last flap we observed for this peer. If this value is
1784 | zero, we have not observed any flaps for this peer.
1785 | */
1786 | int64 last_flap_ns = 14;
1787 |
1788 | /*
1789 | The last ping payload the peer has sent to us.
1790 | */
1791 | bytes last_ping_payload = 15;
1792 | }
1793 |
1794 | message TimestampedError {
1795 | // The unix timestamp in seconds when the error occurred.
1796 | uint64 timestamp = 1;
1797 |
1798 | // The string representation of the error sent by our peer.
1799 | string error = 2;
1800 | }
1801 |
1802 | message ListPeersRequest {
1803 | /*
1804 | If true, only the last error that our peer sent us will be returned with
1805 | the peer's information, rather than the full set of historic errors we have
1806 | stored.
1807 | */
1808 | bool latest_error = 1;
1809 | }
1810 | message ListPeersResponse {
1811 | // The list of currently connected peers
1812 | repeated Peer peers = 1;
1813 | }
1814 |
1815 | message PeerEventSubscription {
1816 | }
1817 |
1818 | message PeerEvent {
1819 | // The identity pubkey of the peer.
1820 | string pub_key = 1;
1821 |
1822 | enum EventType {
1823 | PEER_ONLINE = 0;
1824 | PEER_OFFLINE = 1;
1825 | }
1826 |
1827 | EventType type = 2;
1828 | }
1829 |
1830 | message GetInfoRequest {
1831 | }
1832 | message GetInfoResponse {
1833 | // The version of the LND software that the node is running.
1834 | string version = 14;
1835 |
1836 | // The SHA1 commit hash that the daemon is compiled with.
1837 | string commit_hash = 20;
1838 |
1839 | // The identity pubkey of the current node.
1840 | string identity_pubkey = 1;
1841 |
1842 | // If applicable, the alias of the current node, e.g. "bob"
1843 | string alias = 2;
1844 |
1845 | // The color of the current node in hex code format
1846 | string color = 17;
1847 |
1848 | // Number of pending channels
1849 | uint32 num_pending_channels = 3;
1850 |
1851 | // Number of active channels
1852 | uint32 num_active_channels = 4;
1853 |
1854 | // Number of inactive channels
1855 | uint32 num_inactive_channels = 15;
1856 |
1857 | // Number of peers
1858 | uint32 num_peers = 5;
1859 |
1860 | // The node's current view of the height of the best block
1861 | uint32 block_height = 6;
1862 |
1863 | // The node's current view of the hash of the best block
1864 | string block_hash = 8;
1865 |
1866 | // Timestamp of the block best known to the wallet
1867 | int64 best_header_timestamp = 13;
1868 |
1869 | // Whether the wallet's view is synced to the main chain
1870 | bool synced_to_chain = 9;
1871 |
1872 | // Whether we consider ourselves synced with the public channel graph.
1873 | bool synced_to_graph = 18;
1874 |
1875 | /*
1876 | Whether the current node is connected to testnet. This field is
1877 | deprecated and the network field should be used instead
1878 | **/
1879 | bool testnet = 10 [deprecated = true];
1880 |
1881 | reserved 11;
1882 |
1883 | // A list of active chains the node is connected to
1884 | repeated Chain chains = 16;
1885 |
1886 | // The URIs of the current node.
1887 | repeated string uris = 12;
1888 |
1889 | /*
1890 | Features that our node has advertised in our init message, node
1891 | announcements and invoices.
1892 | */
1893 | map features = 19;
1894 |
1895 | /*
1896 | Indicates whether the HTLC interceptor API is in always-on mode.
1897 | */
1898 | bool require_htlc_interceptor = 21;
1899 | }
1900 |
1901 | message GetRecoveryInfoRequest {
1902 | }
1903 | message GetRecoveryInfoResponse {
1904 | // Whether the wallet is in recovery mode
1905 | bool recovery_mode = 1;
1906 |
1907 | // Whether the wallet recovery progress is finished
1908 | bool recovery_finished = 2;
1909 |
1910 | // The recovery progress, ranging from 0 to 1.
1911 | double progress = 3;
1912 | }
1913 |
1914 | message Chain {
1915 | // The blockchain the node is on (eg bitcoin, litecoin)
1916 | string chain = 1;
1917 |
1918 | // The network the node is on (eg regtest, testnet, mainnet)
1919 | string network = 2;
1920 | }
1921 |
1922 | message ConfirmationUpdate {
1923 | bytes block_sha = 1;
1924 | int32 block_height = 2;
1925 |
1926 | uint32 num_confs_left = 3;
1927 | }
1928 |
1929 | message ChannelOpenUpdate {
1930 | ChannelPoint channel_point = 1;
1931 | }
1932 |
1933 | message ChannelCloseUpdate {
1934 | bytes closing_txid = 1;
1935 |
1936 | bool success = 2;
1937 | }
1938 |
1939 | message CloseChannelRequest {
1940 | /*
1941 | The outpoint (txid:index) of the funding transaction. With this value, Bob
1942 | will be able to generate a signature for Alice's version of the commitment
1943 | transaction.
1944 | */
1945 | ChannelPoint channel_point = 1;
1946 |
1947 | // If true, then the channel will be closed forcibly. This means the
1948 | // current commitment transaction will be signed and broadcast.
1949 | bool force = 2;
1950 |
1951 | // The target number of blocks that the closure transaction should be
1952 | // confirmed by.
1953 | int32 target_conf = 3;
1954 |
1955 | // Deprecated, use sat_per_vbyte.
1956 | // A manual fee rate set in sat/vbyte that should be used when crafting the
1957 | // closure transaction.
1958 | int64 sat_per_byte = 4 [deprecated = true];
1959 |
1960 | /*
1961 | An optional address to send funds to in the case of a cooperative close.
1962 | If the channel was opened with an upfront shutdown script and this field
1963 | is set, the request to close will fail because the channel must pay out
1964 | to the upfront shutdown addresss.
1965 | */
1966 | string delivery_address = 5;
1967 |
1968 | // A manual fee rate set in sat/vbyte that should be used when crafting the
1969 | // closure transaction.
1970 | uint64 sat_per_vbyte = 6;
1971 |
1972 | // The maximum fee rate the closer is willing to pay.
1973 | //
1974 | // NOTE: This field is only respected if we're the initiator of the channel.
1975 | uint64 max_fee_per_vbyte = 7;
1976 | }
1977 |
1978 | message CloseStatusUpdate {
1979 | oneof update {
1980 | PendingUpdate close_pending = 1;
1981 | ChannelCloseUpdate chan_close = 3;
1982 | }
1983 | }
1984 |
1985 | message PendingUpdate {
1986 | bytes txid = 1;
1987 | uint32 output_index = 2;
1988 | }
1989 |
1990 | message ReadyForPsbtFunding {
1991 | /*
1992 | The P2WSH address of the channel funding multisig address that the below
1993 | specified amount in satoshis needs to be sent to.
1994 | */
1995 | string funding_address = 1;
1996 |
1997 | /*
1998 | The exact amount in satoshis that needs to be sent to the above address to
1999 | fund the pending channel.
2000 | */
2001 | int64 funding_amount = 2;
2002 |
2003 | /*
2004 | A raw PSBT that contains the pending channel output. If a base PSBT was
2005 | provided in the PsbtShim, this is the base PSBT with one additional output.
2006 | If no base PSBT was specified, this is an otherwise empty PSBT with exactly
2007 | one output.
2008 | */
2009 | bytes psbt = 3;
2010 | }
2011 |
2012 | message BatchOpenChannelRequest {
2013 | // The list of channels to open.
2014 | repeated BatchOpenChannel channels = 1;
2015 |
2016 | // The target number of blocks that the funding transaction should be
2017 | // confirmed by.
2018 | int32 target_conf = 2;
2019 |
2020 | // A manual fee rate set in sat/vByte that should be used when crafting the
2021 | // funding transaction.
2022 | int64 sat_per_vbyte = 3;
2023 |
2024 | // The minimum number of confirmations each one of your outputs used for
2025 | // the funding transaction must satisfy.
2026 | int32 min_confs = 4;
2027 |
2028 | // Whether unconfirmed outputs should be used as inputs for the funding
2029 | // transaction.
2030 | bool spend_unconfirmed = 5;
2031 |
2032 | // An optional label for the batch transaction, limited to 500 characters.
2033 | string label = 6;
2034 | }
2035 |
2036 | message BatchOpenChannel {
2037 | // The pubkey of the node to open a channel with. When using REST, this
2038 | // field must be encoded as base64.
2039 | bytes node_pubkey = 1;
2040 |
2041 | // The number of satoshis the wallet should commit to the channel.
2042 | int64 local_funding_amount = 2;
2043 |
2044 | // The number of satoshis to push to the remote side as part of the initial
2045 | // commitment state.
2046 | int64 push_sat = 3;
2047 |
2048 | // Whether this channel should be private, not announced to the greater
2049 | // network.
2050 | bool private = 4;
2051 |
2052 | // The minimum value in millisatoshi we will require for incoming HTLCs on
2053 | // the channel.
2054 | int64 min_htlc_msat = 5;
2055 |
2056 | // The delay we require on the remote's commitment transaction. If this is
2057 | // not set, it will be scaled automatically with the channel size.
2058 | uint32 remote_csv_delay = 6;
2059 |
2060 | /*
2061 | Close address is an optional address which specifies the address to which
2062 | funds should be paid out to upon cooperative close. This field may only be
2063 | set if the peer supports the option upfront feature bit (call listpeers
2064 | to check). The remote peer will only accept cooperative closes to this
2065 | address if it is set.
2066 | Note: If this value is set on channel creation, you will *not* be able to
2067 | cooperatively close out to a different address.
2068 | */
2069 | string close_address = 7;
2070 |
2071 | /*
2072 | An optional, unique identifier of 32 random bytes that will be used as the
2073 | pending channel ID to identify the channel while it is in the pre-pending
2074 | state.
2075 | */
2076 | bytes pending_chan_id = 8;
2077 |
2078 | /*
2079 | The explicit commitment type to use. Note this field will only be used if
2080 | the remote peer supports explicit channel negotiation.
2081 | */
2082 | CommitmentType commitment_type = 9;
2083 | }
2084 |
2085 | message BatchOpenChannelResponse {
2086 | repeated PendingUpdate pending_channels = 1;
2087 | }
2088 |
2089 | message OpenChannelRequest {
2090 | // A manual fee rate set in sat/vbyte that should be used when crafting the
2091 | // funding transaction.
2092 | uint64 sat_per_vbyte = 1;
2093 |
2094 | /*
2095 | The pubkey of the node to open a channel with. When using REST, this field
2096 | must be encoded as base64.
2097 | */
2098 | bytes node_pubkey = 2;
2099 |
2100 | /*
2101 | The hex encoded pubkey of the node to open a channel with. Deprecated now
2102 | that the REST gateway supports base64 encoding of bytes fields.
2103 | */
2104 | string node_pubkey_string = 3 [deprecated = true];
2105 |
2106 | // The number of satoshis the wallet should commit to the channel
2107 | int64 local_funding_amount = 4;
2108 |
2109 | // The number of satoshis to push to the remote side as part of the initial
2110 | // commitment state
2111 | int64 push_sat = 5;
2112 |
2113 | // The target number of blocks that the funding transaction should be
2114 | // confirmed by.
2115 | int32 target_conf = 6;
2116 |
2117 | // Deprecated, use sat_per_vbyte.
2118 | // A manual fee rate set in sat/vbyte that should be used when crafting the
2119 | // funding transaction.
2120 | int64 sat_per_byte = 7 [deprecated = true];
2121 |
2122 | // Whether this channel should be private, not announced to the greater
2123 | // network.
2124 | bool private = 8;
2125 |
2126 | // The minimum value in millisatoshi we will require for incoming HTLCs on
2127 | // the channel.
2128 | int64 min_htlc_msat = 9;
2129 |
2130 | // The delay we require on the remote's commitment transaction. If this is
2131 | // not set, it will be scaled automatically with the channel size.
2132 | uint32 remote_csv_delay = 10;
2133 |
2134 | // The minimum number of confirmations each one of your outputs used for
2135 | // the funding transaction must satisfy.
2136 | int32 min_confs = 11;
2137 |
2138 | // Whether unconfirmed outputs should be used as inputs for the funding
2139 | // transaction.
2140 | bool spend_unconfirmed = 12;
2141 |
2142 | /*
2143 | Close address is an optional address which specifies the address to which
2144 | funds should be paid out to upon cooperative close. This field may only be
2145 | set if the peer supports the option upfront feature bit (call listpeers
2146 | to check). The remote peer will only accept cooperative closes to this
2147 | address if it is set.
2148 | Note: If this value is set on channel creation, you will *not* be able to
2149 | cooperatively close out to a different address.
2150 | */
2151 | string close_address = 13;
2152 |
2153 | /*
2154 | Funding shims are an optional argument that allow the caller to intercept
2155 | certain funding functionality. For example, a shim can be provided to use a
2156 | particular key for the commitment key (ideally cold) rather than use one
2157 | that is generated by the wallet as normal, or signal that signing will be
2158 | carried out in an interactive manner (PSBT based).
2159 | */
2160 | FundingShim funding_shim = 14;
2161 |
2162 | /*
2163 | The maximum amount of coins in millisatoshi that can be pending within
2164 | the channel. It only applies to the remote party.
2165 | */
2166 | uint64 remote_max_value_in_flight_msat = 15;
2167 |
2168 | /*
2169 | The maximum number of concurrent HTLCs we will allow the remote party to add
2170 | to the commitment transaction.
2171 | */
2172 | uint32 remote_max_htlcs = 16;
2173 |
2174 | /*
2175 | Max local csv is the maximum csv delay we will allow for our own commitment
2176 | transaction.
2177 | */
2178 | uint32 max_local_csv = 17;
2179 |
2180 | /*
2181 | The explicit commitment type to use. Note this field will only be used if
2182 | the remote peer supports explicit channel negotiation.
2183 | */
2184 | CommitmentType commitment_type = 18;
2185 |
2186 | /*
2187 | If this is true, then a zero-conf channel open will be attempted.
2188 | */
2189 | bool zero_conf = 19;
2190 |
2191 | /*
2192 | If this is true, then an option-scid-alias channel-type open will be
2193 | attempted.
2194 | */
2195 | bool scid_alias = 20;
2196 |
2197 | /*
2198 | The base fee charged regardless of the number of milli-satoshis sent.
2199 | */
2200 | uint64 base_fee = 21;
2201 |
2202 | /*
2203 | The fee rate in ppm (parts per million) that will be charged in
2204 | proportion of the value of each forwarded HTLC.
2205 | */
2206 | uint64 fee_rate = 22;
2207 |
2208 | /*
2209 | If use_base_fee is true the open channel announcement will update the
2210 | channel base fee with the value specified in base_fee. In the case of
2211 | a base_fee of 0 use_base_fee is needed downstream to distinguish whether
2212 | to use the default base fee value specified in the config or 0.
2213 | */
2214 | bool use_base_fee = 23;
2215 |
2216 | /*
2217 | If use_fee_rate is true the open channel announcement will update the
2218 | channel fee rate with the value specified in fee_rate. In the case of
2219 | a fee_rate of 0 use_fee_rate is needed downstream to distinguish whether
2220 | to use the default fee rate value specified in the config or 0.
2221 | */
2222 | bool use_fee_rate = 24;
2223 |
2224 | /*
2225 | The number of satoshis we require the remote peer to reserve. This value,
2226 | if specified, must be above the dust limit and below 20% of the channel
2227 | capacity.
2228 | */
2229 | uint64 remote_chan_reserve_sat = 25;
2230 | }
2231 | message OpenStatusUpdate {
2232 | oneof update {
2233 | /*
2234 | Signals that the channel is now fully negotiated and the funding
2235 | transaction published.
2236 | */
2237 | PendingUpdate chan_pending = 1;
2238 |
2239 | /*
2240 | Signals that the channel's funding transaction has now reached the
2241 | required number of confirmations on chain and can be used.
2242 | */
2243 | ChannelOpenUpdate chan_open = 3;
2244 |
2245 | /*
2246 | Signals that the funding process has been suspended and the construction
2247 | of a PSBT that funds the channel PK script is now required.
2248 | */
2249 | ReadyForPsbtFunding psbt_fund = 5;
2250 | }
2251 |
2252 | /*
2253 | The pending channel ID of the created channel. This value may be used to
2254 | further the funding flow manually via the FundingStateStep method.
2255 | */
2256 | bytes pending_chan_id = 4;
2257 | }
2258 |
2259 | message KeyLocator {
2260 | // The family of key being identified.
2261 | int32 key_family = 1;
2262 |
2263 | // The precise index of the key being identified.
2264 | int32 key_index = 2;
2265 | }
2266 |
2267 | message KeyDescriptor {
2268 | /*
2269 | The raw bytes of the key being identified.
2270 | */
2271 | bytes raw_key_bytes = 1;
2272 |
2273 | /*
2274 | The key locator that identifies which key to use for signing.
2275 | */
2276 | KeyLocator key_loc = 2;
2277 | }
2278 |
2279 | message ChanPointShim {
2280 | /*
2281 | The size of the pre-crafted output to be used as the channel point for this
2282 | channel funding.
2283 | */
2284 | int64 amt = 1;
2285 |
2286 | // The target channel point to refrence in created commitment transactions.
2287 | ChannelPoint chan_point = 2;
2288 |
2289 | // Our local key to use when creating the multi-sig output.
2290 | KeyDescriptor local_key = 3;
2291 |
2292 | // The key of the remote party to use when creating the multi-sig output.
2293 | bytes remote_key = 4;
2294 |
2295 | /*
2296 | If non-zero, then this will be used as the pending channel ID on the wire
2297 | protocol to initate the funding request. This is an optional field, and
2298 | should only be set if the responder is already expecting a specific pending
2299 | channel ID.
2300 | */
2301 | bytes pending_chan_id = 5;
2302 |
2303 | /*
2304 | This uint32 indicates if this channel is to be considered 'frozen'. A frozen
2305 | channel does not allow a cooperative channel close by the initiator. The
2306 | thaw_height is the height that this restriction stops applying to the
2307 | channel. The height can be interpreted in two ways: as a relative height if
2308 | the value is less than 500,000, or as an absolute height otherwise.
2309 | */
2310 | uint32 thaw_height = 6;
2311 | }
2312 |
2313 | message PsbtShim {
2314 | /*
2315 | A unique identifier of 32 random bytes that will be used as the pending
2316 | channel ID to identify the PSBT state machine when interacting with it and
2317 | on the wire protocol to initiate the funding request.
2318 | */
2319 | bytes pending_chan_id = 1;
2320 |
2321 | /*
2322 | An optional base PSBT the new channel output will be added to. If this is
2323 | non-empty, it must be a binary serialized PSBT.
2324 | */
2325 | bytes base_psbt = 2;
2326 |
2327 | /*
2328 | If a channel should be part of a batch (multiple channel openings in one
2329 | transaction), it can be dangerous if the whole batch transaction is
2330 | published too early before all channel opening negotiations are completed.
2331 | This flag prevents this particular channel from broadcasting the transaction
2332 | after the negotiation with the remote peer. In a batch of channel openings
2333 | this flag should be set to true for every channel but the very last.
2334 | */
2335 | bool no_publish = 3;
2336 | }
2337 |
2338 | message FundingShim {
2339 | oneof shim {
2340 | /*
2341 | A channel shim where the channel point was fully constructed outside
2342 | of lnd's wallet and the transaction might already be published.
2343 | */
2344 | ChanPointShim chan_point_shim = 1;
2345 |
2346 | /*
2347 | A channel shim that uses a PSBT to fund and sign the channel funding
2348 | transaction.
2349 | */
2350 | PsbtShim psbt_shim = 2;
2351 | }
2352 | }
2353 |
2354 | message FundingShimCancel {
2355 | // The pending channel ID of the channel to cancel the funding shim for.
2356 | bytes pending_chan_id = 1;
2357 | }
2358 |
2359 | message FundingPsbtVerify {
2360 | /*
2361 | The funded but not yet signed PSBT that sends the exact channel capacity
2362 | amount to the PK script returned in the open channel message in a previous
2363 | step.
2364 | */
2365 | bytes funded_psbt = 1;
2366 |
2367 | // The pending channel ID of the channel to get the PSBT for.
2368 | bytes pending_chan_id = 2;
2369 |
2370 | /*
2371 | Can only be used if the no_publish flag was set to true in the OpenChannel
2372 | call meaning that the caller is solely responsible for publishing the final
2373 | funding transaction. If skip_finalize is set to true then lnd will not wait
2374 | for a FundingPsbtFinalize state step and instead assumes that a transaction
2375 | with the same TXID as the passed in PSBT will eventually confirm.
2376 | IT IS ABSOLUTELY IMPERATIVE that the TXID of the transaction that is
2377 | eventually published does have the _same TXID_ as the verified PSBT. That
2378 | means no inputs or outputs can change, only signatures can be added. If the
2379 | TXID changes between this call and the publish step then the channel will
2380 | never be created and the funds will be in limbo.
2381 | */
2382 | bool skip_finalize = 3;
2383 | }
2384 |
2385 | message FundingPsbtFinalize {
2386 | /*
2387 | The funded PSBT that contains all witness data to send the exact channel
2388 | capacity amount to the PK script returned in the open channel message in a
2389 | previous step. Cannot be set at the same time as final_raw_tx.
2390 | */
2391 | bytes signed_psbt = 1;
2392 |
2393 | // The pending channel ID of the channel to get the PSBT for.
2394 | bytes pending_chan_id = 2;
2395 |
2396 | /*
2397 | As an alternative to the signed PSBT with all witness data, the final raw
2398 | wire format transaction can also be specified directly. Cannot be set at the
2399 | same time as signed_psbt.
2400 | */
2401 | bytes final_raw_tx = 3;
2402 | }
2403 |
2404 | message FundingTransitionMsg {
2405 | oneof trigger {
2406 | /*
2407 | The funding shim to register. This should be used before any
2408 | channel funding has began by the remote party, as it is intended as a
2409 | preparatory step for the full channel funding.
2410 | */
2411 | FundingShim shim_register = 1;
2412 |
2413 | // Used to cancel an existing registered funding shim.
2414 | FundingShimCancel shim_cancel = 2;
2415 |
2416 | /*
2417 | Used to continue a funding flow that was initiated to be executed
2418 | through a PSBT. This step verifies that the PSBT contains the correct
2419 | outputs to fund the channel.
2420 | */
2421 | FundingPsbtVerify psbt_verify = 3;
2422 |
2423 | /*
2424 | Used to continue a funding flow that was initiated to be executed
2425 | through a PSBT. This step finalizes the funded and signed PSBT, finishes
2426 | negotiation with the peer and finally publishes the resulting funding
2427 | transaction.
2428 | */
2429 | FundingPsbtFinalize psbt_finalize = 4;
2430 | }
2431 | }
2432 |
2433 | message FundingStateStepResp {
2434 | }
2435 |
2436 | message PendingHTLC {
2437 | // The direction within the channel that the htlc was sent
2438 | bool incoming = 1;
2439 |
2440 | // The total value of the htlc
2441 | int64 amount = 2;
2442 |
2443 | // The final output to be swept back to the user's wallet
2444 | string outpoint = 3;
2445 |
2446 | // The next block height at which we can spend the current stage
2447 | uint32 maturity_height = 4;
2448 |
2449 | /*
2450 | The number of blocks remaining until the current stage can be swept.
2451 | Negative values indicate how many blocks have passed since becoming
2452 | mature.
2453 | */
2454 | int32 blocks_til_maturity = 5;
2455 |
2456 | // Indicates whether the htlc is in its first or second stage of recovery
2457 | uint32 stage = 6;
2458 | }
2459 |
2460 | message PendingChannelsRequest {
2461 | }
2462 | message PendingChannelsResponse {
2463 | message PendingChannel {
2464 | string remote_node_pub = 1;
2465 | string channel_point = 2;
2466 |
2467 | int64 capacity = 3;
2468 |
2469 | int64 local_balance = 4;
2470 | int64 remote_balance = 5;
2471 |
2472 | // The minimum satoshis this node is required to reserve in its
2473 | // balance.
2474 | int64 local_chan_reserve_sat = 6;
2475 |
2476 | /*
2477 | The minimum satoshis the other node is required to reserve in its
2478 | balance.
2479 | */
2480 | int64 remote_chan_reserve_sat = 7;
2481 |
2482 | // The party that initiated opening the channel.
2483 | Initiator initiator = 8;
2484 |
2485 | // The commitment type used by this channel.
2486 | CommitmentType commitment_type = 9;
2487 |
2488 | // Total number of forwarding packages created in this channel.
2489 | int64 num_forwarding_packages = 10;
2490 |
2491 | // A set of flags showing the current state of the channel.
2492 | string chan_status_flags = 11;
2493 |
2494 | // Whether this channel is advertised to the network or not.
2495 | bool private = 12;
2496 | }
2497 |
2498 | message PendingOpenChannel {
2499 | // The pending channel
2500 | PendingChannel channel = 1;
2501 |
2502 | /*
2503 | The amount calculated to be paid in fees for the current set of
2504 | commitment transactions. The fee amount is persisted with the channel
2505 | in order to allow the fee amount to be removed and recalculated with
2506 | each channel state update, including updates that happen after a system
2507 | restart.
2508 | */
2509 | int64 commit_fee = 4;
2510 |
2511 | // The weight of the commitment transaction
2512 | int64 commit_weight = 5;
2513 |
2514 | /*
2515 | The required number of satoshis per kilo-weight that the requester will
2516 | pay at all times, for both the funding transaction and commitment
2517 | transaction. This value can later be updated once the channel is open.
2518 | */
2519 | int64 fee_per_kw = 6;
2520 |
2521 | // Previously used for confirmation_height. Do not reuse.
2522 | reserved 2;
2523 | }
2524 |
2525 | message WaitingCloseChannel {
2526 | // The pending channel waiting for closing tx to confirm
2527 | PendingChannel channel = 1;
2528 |
2529 | // The balance in satoshis encumbered in this channel
2530 | int64 limbo_balance = 2;
2531 |
2532 | /*
2533 | A list of valid commitment transactions. Any of these can confirm at
2534 | this point.
2535 | */
2536 | Commitments commitments = 3;
2537 |
2538 | // The transaction id of the closing transaction
2539 | string closing_txid = 4;
2540 | }
2541 |
2542 | message Commitments {
2543 | // Hash of the local version of the commitment tx.
2544 | string local_txid = 1;
2545 |
2546 | // Hash of the remote version of the commitment tx.
2547 | string remote_txid = 2;
2548 |
2549 | // Hash of the remote pending version of the commitment tx.
2550 | string remote_pending_txid = 3;
2551 |
2552 | /*
2553 | The amount in satoshis calculated to be paid in fees for the local
2554 | commitment.
2555 | */
2556 | uint64 local_commit_fee_sat = 4;
2557 |
2558 | /*
2559 | The amount in satoshis calculated to be paid in fees for the remote
2560 | commitment.
2561 | */
2562 | uint64 remote_commit_fee_sat = 5;
2563 |
2564 | /*
2565 | The amount in satoshis calculated to be paid in fees for the remote
2566 | pending commitment.
2567 | */
2568 | uint64 remote_pending_commit_fee_sat = 6;
2569 | }
2570 |
2571 | message ClosedChannel {
2572 | // The pending channel to be closed
2573 | PendingChannel channel = 1;
2574 |
2575 | // The transaction id of the closing transaction
2576 | string closing_txid = 2;
2577 | }
2578 |
2579 | message ForceClosedChannel {
2580 | // The pending channel to be force closed
2581 | PendingChannel channel = 1;
2582 |
2583 | // The transaction id of the closing transaction
2584 | string closing_txid = 2;
2585 |
2586 | // The balance in satoshis encumbered in this pending channel
2587 | int64 limbo_balance = 3;
2588 |
2589 | // The height at which funds can be swept into the wallet
2590 | uint32 maturity_height = 4;
2591 |
2592 | /*
2593 | Remaining # of blocks until the commitment output can be swept.
2594 | Negative values indicate how many blocks have passed since becoming
2595 | mature.
2596 | */
2597 | int32 blocks_til_maturity = 5;
2598 |
2599 | // The total value of funds successfully recovered from this channel
2600 | int64 recovered_balance = 6;
2601 |
2602 | repeated PendingHTLC pending_htlcs = 8;
2603 |
2604 | /*
2605 | There are three resolution states for the anchor:
2606 | limbo, lost and recovered. Derive the current state
2607 | from the limbo and recovered balances.
2608 | */
2609 | enum AnchorState {
2610 | // The recovered_balance is zero and limbo_balance is non-zero.
2611 | LIMBO = 0;
2612 | // The recovered_balance is non-zero.
2613 | RECOVERED = 1;
2614 | // A state that is neither LIMBO nor RECOVERED.
2615 | LOST = 2;
2616 | }
2617 |
2618 | AnchorState anchor = 9;
2619 | }
2620 |
2621 | // The balance in satoshis encumbered in pending channels
2622 | int64 total_limbo_balance = 1;
2623 |
2624 | // Channels pending opening
2625 | repeated PendingOpenChannel pending_open_channels = 2;
2626 |
2627 | /*
2628 | Deprecated: Channels pending closing previously contained cooperatively
2629 | closed channels with a single confirmation. These channels are now
2630 | considered closed from the time we see them on chain.
2631 | */
2632 | repeated ClosedChannel pending_closing_channels = 3 [deprecated = true];
2633 |
2634 | // Channels pending force closing
2635 | repeated ForceClosedChannel pending_force_closing_channels = 4;
2636 |
2637 | // Channels waiting for closing tx to confirm
2638 | repeated WaitingCloseChannel waiting_close_channels = 5;
2639 | }
2640 |
2641 | message ChannelEventSubscription {
2642 | }
2643 |
2644 | message ChannelEventUpdate {
2645 | oneof channel {
2646 | Channel open_channel = 1;
2647 | ChannelCloseSummary closed_channel = 2;
2648 | ChannelPoint active_channel = 3;
2649 | ChannelPoint inactive_channel = 4;
2650 | PendingUpdate pending_open_channel = 6;
2651 | ChannelPoint fully_resolved_channel = 7;
2652 | }
2653 |
2654 | enum UpdateType {
2655 | OPEN_CHANNEL = 0;
2656 | CLOSED_CHANNEL = 1;
2657 | ACTIVE_CHANNEL = 2;
2658 | INACTIVE_CHANNEL = 3;
2659 | PENDING_OPEN_CHANNEL = 4;
2660 | FULLY_RESOLVED_CHANNEL = 5;
2661 | }
2662 |
2663 | UpdateType type = 5;
2664 | }
2665 |
2666 | message WalletAccountBalance {
2667 | // The confirmed balance of the account (with >= 1 confirmations).
2668 | int64 confirmed_balance = 1;
2669 |
2670 | // The unconfirmed balance of the account (with 0 confirmations).
2671 | int64 unconfirmed_balance = 2;
2672 | }
2673 |
2674 | message WalletBalanceRequest {
2675 | }
2676 |
2677 | message WalletBalanceResponse {
2678 | // The balance of the wallet
2679 | int64 total_balance = 1;
2680 |
2681 | // The confirmed balance of a wallet(with >= 1 confirmations)
2682 | int64 confirmed_balance = 2;
2683 |
2684 | // The unconfirmed balance of a wallet(with 0 confirmations)
2685 | int64 unconfirmed_balance = 3;
2686 |
2687 | // The total amount of wallet UTXOs held in outputs that are locked for
2688 | // other usage.
2689 | int64 locked_balance = 5;
2690 |
2691 | // The amount of reserve required.
2692 | int64 reserved_balance_anchor_chan = 6;
2693 |
2694 | // A mapping of each wallet account's name to its balance.
2695 | map account_balance = 4;
2696 | }
2697 |
2698 | message Amount {
2699 | // Value denominated in satoshis.
2700 | uint64 sat = 1;
2701 |
2702 | // Value denominated in milli-satoshis.
2703 | uint64 msat = 2;
2704 | }
2705 |
2706 | message ChannelBalanceRequest {
2707 | }
2708 | message ChannelBalanceResponse {
2709 | // Deprecated. Sum of channels balances denominated in satoshis
2710 | int64 balance = 1 [deprecated = true];
2711 |
2712 | // Deprecated. Sum of channels pending balances denominated in satoshis
2713 | int64 pending_open_balance = 2 [deprecated = true];
2714 |
2715 | // Sum of channels local balances.
2716 | Amount local_balance = 3;
2717 |
2718 | // Sum of channels remote balances.
2719 | Amount remote_balance = 4;
2720 |
2721 | // Sum of channels local unsettled balances.
2722 | Amount unsettled_local_balance = 5;
2723 |
2724 | // Sum of channels remote unsettled balances.
2725 | Amount unsettled_remote_balance = 6;
2726 |
2727 | // Sum of channels pending local balances.
2728 | Amount pending_open_local_balance = 7;
2729 |
2730 | // Sum of channels pending remote balances.
2731 | Amount pending_open_remote_balance = 8;
2732 | }
2733 |
2734 | message QueryRoutesRequest {
2735 | // The 33-byte hex-encoded public key for the payment destination
2736 | string pub_key = 1;
2737 |
2738 | /*
2739 | The amount to send expressed in satoshis.
2740 | The fields amt and amt_msat are mutually exclusive.
2741 | */
2742 | int64 amt = 2;
2743 |
2744 | /*
2745 | The amount to send expressed in millisatoshis.
2746 | The fields amt and amt_msat are mutually exclusive.
2747 | */
2748 | int64 amt_msat = 12;
2749 |
2750 | reserved 3;
2751 |
2752 | /*
2753 | An optional CLTV delta from the current height that should be used for the
2754 | timelock of the final hop. Note that unlike SendPayment, QueryRoutes does
2755 | not add any additional block padding on top of final_ctlv_delta. This
2756 | padding of a few blocks needs to be added manually or otherwise failures may
2757 | happen when a block comes in while the payment is in flight.
2758 | */
2759 | int32 final_cltv_delta = 4;
2760 |
2761 | /*
2762 | The maximum number of satoshis that will be paid as a fee of the payment.
2763 | This value can be represented either as a percentage of the amount being
2764 | sent, or as a fixed amount of the maximum fee the user is willing the pay to
2765 | send the payment. If not specified, lnd will use a default value of 100%
2766 | fees for small amounts (<=1k sat) or 5% fees for larger amounts.
2767 | */
2768 | FeeLimit fee_limit = 5;
2769 |
2770 | /*
2771 | A list of nodes to ignore during path finding. When using REST, these fields
2772 | must be encoded as base64.
2773 | */
2774 | repeated bytes ignored_nodes = 6;
2775 |
2776 | /*
2777 | Deprecated. A list of edges to ignore during path finding.
2778 | */
2779 | repeated EdgeLocator ignored_edges = 7 [deprecated = true];
2780 |
2781 | /*
2782 | The source node where the request route should originated from. If empty,
2783 | self is assumed.
2784 | */
2785 | string source_pub_key = 8;
2786 |
2787 | /*
2788 | If set to true, edge probabilities from mission control will be used to get
2789 | the optimal route.
2790 | */
2791 | bool use_mission_control = 9;
2792 |
2793 | /*
2794 | A list of directed node pairs that will be ignored during path finding.
2795 | */
2796 | repeated NodePair ignored_pairs = 10;
2797 |
2798 | /*
2799 | An optional maximum total time lock for the route. If the source is empty or
2800 | ourselves, this should not exceed lnd's `--max-cltv-expiry` setting. If
2801 | zero, then the value of `--max-cltv-expiry` is used as the limit.
2802 | */
2803 | uint32 cltv_limit = 11;
2804 |
2805 | /*
2806 | An optional field that can be used to pass an arbitrary set of TLV records
2807 | to a peer which understands the new records. This can be used to pass
2808 | application specific data during the payment attempt. If the destination
2809 | does not support the specified records, an error will be returned.
2810 | Record types are required to be in the custom range >= 65536. When using
2811 | REST, the values must be encoded as base64.
2812 | */
2813 | map dest_custom_records = 13;
2814 |
2815 | /*
2816 | The channel id of the channel that must be taken to the first hop. If zero,
2817 | any channel may be used.
2818 | */
2819 | uint64 outgoing_chan_id = 14 [jstype = JS_STRING];
2820 |
2821 | /*
2822 | The pubkey of the last hop of the route. If empty, any hop may be used.
2823 | */
2824 | bytes last_hop_pubkey = 15;
2825 |
2826 | /*
2827 | Optional route hints to reach the destination through private channels.
2828 | */
2829 | repeated lnrpc.RouteHint route_hints = 16;
2830 |
2831 | /*
2832 | Features assumed to be supported by the final node. All transitive feature
2833 | dependencies must also be set properly. For a given feature bit pair, either
2834 | optional or remote may be set, but not both. If this field is nil or empty,
2835 | the router will try to load destination features from the graph as a
2836 | fallback.
2837 | */
2838 | repeated lnrpc.FeatureBit dest_features = 17;
2839 |
2840 | /*
2841 | The time preference for this payment. Set to -1 to optimize for fees
2842 | only, to 1 to optimize for reliability only or a value inbetween for a mix.
2843 | */
2844 | double time_pref = 18;
2845 | }
2846 |
2847 | message NodePair {
2848 | /*
2849 | The sending node of the pair. When using REST, this field must be encoded as
2850 | base64.
2851 | */
2852 | bytes from = 1;
2853 |
2854 | /*
2855 | The receiving node of the pair. When using REST, this field must be encoded
2856 | as base64.
2857 | */
2858 | bytes to = 2;
2859 | }
2860 |
2861 | message EdgeLocator {
2862 | // The short channel id of this edge.
2863 | uint64 channel_id = 1 [jstype = JS_STRING];
2864 |
2865 | /*
2866 | The direction of this edge. If direction_reverse is false, the direction
2867 | of this edge is from the channel endpoint with the lexicographically smaller
2868 | pub key to the endpoint with the larger pub key. If direction_reverse is
2869 | is true, the edge goes the other way.
2870 | */
2871 | bool direction_reverse = 2;
2872 | }
2873 |
2874 | message QueryRoutesResponse {
2875 | /*
2876 | The route that results from the path finding operation. This is still a
2877 | repeated field to retain backwards compatibility.
2878 | */
2879 | repeated Route routes = 1;
2880 |
2881 | /*
2882 | The success probability of the returned route based on the current mission
2883 | control state. [EXPERIMENTAL]
2884 | */
2885 | double success_prob = 2;
2886 | }
2887 |
2888 | message Hop {
2889 | /*
2890 | The unique channel ID for the channel. The first 3 bytes are the block
2891 | height, the next 3 the index within the block, and the last 2 bytes are the
2892 | output index for the channel.
2893 | */
2894 | uint64 chan_id = 1 [jstype = JS_STRING];
2895 | int64 chan_capacity = 2 [deprecated = true];
2896 | int64 amt_to_forward = 3 [deprecated = true];
2897 | int64 fee = 4 [deprecated = true];
2898 | uint32 expiry = 5;
2899 | int64 amt_to_forward_msat = 6;
2900 | int64 fee_msat = 7;
2901 |
2902 | /*
2903 | An optional public key of the hop. If the public key is given, the payment
2904 | can be executed without relying on a copy of the channel graph.
2905 | */
2906 | string pub_key = 8;
2907 |
2908 | /*
2909 | If set to true, then this hop will be encoded using the new variable length
2910 | TLV format. Note that if any custom tlv_records below are specified, then
2911 | this field MUST be set to true for them to be encoded properly.
2912 | */
2913 | bool tlv_payload = 9 [deprecated = true];
2914 |
2915 | /*
2916 | An optional TLV record that signals the use of an MPP payment. If present,
2917 | the receiver will enforce that the same mpp_record is included in the final
2918 | hop payload of all non-zero payments in the HTLC set. If empty, a regular
2919 | single-shot payment is or was attempted.
2920 | */
2921 | MPPRecord mpp_record = 10;
2922 |
2923 | /*
2924 | An optional TLV record that signals the use of an AMP payment. If present,
2925 | the receiver will treat all received payments including the same
2926 | (payment_addr, set_id) pair as being part of one logical payment. The
2927 | payment will be settled by XORing the root_share's together and deriving the
2928 | child hashes and preimages according to BOLT XX. Must be used in conjunction
2929 | with mpp_record.
2930 | */
2931 | AMPRecord amp_record = 12;
2932 |
2933 | /*
2934 | An optional set of key-value TLV records. This is useful within the context
2935 | of the SendToRoute call as it allows callers to specify arbitrary K-V pairs
2936 | to drop off at each hop within the onion.
2937 | */
2938 | map custom_records = 11;
2939 |
2940 | // The payment metadata to send along with the payment to the payee.
2941 | bytes metadata = 13;
2942 | }
2943 |
2944 | message MPPRecord {
2945 | /*
2946 | A unique, random identifier used to authenticate the sender as the intended
2947 | payer of a multi-path payment. The payment_addr must be the same for all
2948 | subpayments, and match the payment_addr provided in the receiver's invoice.
2949 | The same payment_addr must be used on all subpayments.
2950 | */
2951 | bytes payment_addr = 11;
2952 |
2953 | /*
2954 | The total amount in milli-satoshis being sent as part of a larger multi-path
2955 | payment. The caller is responsible for ensuring subpayments to the same node
2956 | and payment_hash sum exactly to total_amt_msat. The same
2957 | total_amt_msat must be used on all subpayments.
2958 | */
2959 | int64 total_amt_msat = 10;
2960 | }
2961 |
2962 | message AMPRecord {
2963 | bytes root_share = 1;
2964 |
2965 | bytes set_id = 2;
2966 |
2967 | uint32 child_index = 3;
2968 | }
2969 |
2970 | /*
2971 | A path through the channel graph which runs over one or more channels in
2972 | succession. This struct carries all the information required to craft the
2973 | Sphinx onion packet, and send the payment along the first hop in the path. A
2974 | route is only selected as valid if all the channels have sufficient capacity to
2975 | carry the initial payment amount after fees are accounted for.
2976 | */
2977 | message Route {
2978 | /*
2979 | The cumulative (final) time lock across the entire route. This is the CLTV
2980 | value that should be extended to the first hop in the route. All other hops
2981 | will decrement the time-lock as advertised, leaving enough time for all
2982 | hops to wait for or present the payment preimage to complete the payment.
2983 | */
2984 | uint32 total_time_lock = 1;
2985 |
2986 | /*
2987 | The sum of the fees paid at each hop within the final route. In the case
2988 | of a one-hop payment, this value will be zero as we don't need to pay a fee
2989 | to ourselves.
2990 | */
2991 | int64 total_fees = 2 [deprecated = true];
2992 |
2993 | /*
2994 | The total amount of funds required to complete a payment over this route.
2995 | This value includes the cumulative fees at each hop. As a result, the HTLC
2996 | extended to the first-hop in the route will need to have at least this many
2997 | satoshis, otherwise the route will fail at an intermediate node due to an
2998 | insufficient amount of fees.
2999 | */
3000 | int64 total_amt = 3 [deprecated = true];
3001 |
3002 | /*
3003 | Contains details concerning the specific forwarding details at each hop.
3004 | */
3005 | repeated Hop hops = 4;
3006 |
3007 | /*
3008 | The total fees in millisatoshis.
3009 | */
3010 | int64 total_fees_msat = 5;
3011 |
3012 | /*
3013 | The total amount in millisatoshis.
3014 | */
3015 | int64 total_amt_msat = 6;
3016 | }
3017 |
3018 | message NodeInfoRequest {
3019 | // The 33-byte hex-encoded compressed public of the target node
3020 | string pub_key = 1;
3021 |
3022 | // If true, will include all known channels associated with the node.
3023 | bool include_channels = 2;
3024 | }
3025 |
3026 | message NodeInfo {
3027 | /*
3028 | An individual vertex/node within the channel graph. A node is
3029 | connected to other nodes by one or more channel edges emanating from it. As
3030 | the graph is directed, a node will also have an incoming edge attached to
3031 | it for each outgoing edge.
3032 | */
3033 | LightningNode node = 1;
3034 |
3035 | // The total number of channels for the node.
3036 | uint32 num_channels = 2;
3037 |
3038 | // The sum of all channels capacity for the node, denominated in satoshis.
3039 | int64 total_capacity = 3;
3040 |
3041 | // A list of all public channels for the node.
3042 | repeated ChannelEdge channels = 4;
3043 | }
3044 |
3045 | /*
3046 | An individual vertex/node within the channel graph. A node is
3047 | connected to other nodes by one or more channel edges emanating from it. As the
3048 | graph is directed, a node will also have an incoming edge attached to it for
3049 | each outgoing edge.
3050 | */
3051 | message LightningNode {
3052 | uint32 last_update = 1;
3053 | string pub_key = 2;
3054 | string alias = 3;
3055 | repeated NodeAddress addresses = 4;
3056 | string color = 5;
3057 | map features = 6;
3058 |
3059 | // Custom node announcement tlv records.
3060 | map custom_records = 7;
3061 | }
3062 |
3063 | message NodeAddress {
3064 | string network = 1;
3065 | string addr = 2;
3066 | }
3067 |
3068 | message RoutingPolicy {
3069 | uint32 time_lock_delta = 1;
3070 | int64 min_htlc = 2;
3071 | int64 fee_base_msat = 3;
3072 | int64 fee_rate_milli_msat = 4;
3073 | bool disabled = 5;
3074 | uint64 max_htlc_msat = 6;
3075 | uint32 last_update = 7;
3076 |
3077 | // Custom channel update tlv records.
3078 | map custom_records = 8;
3079 | }
3080 |
3081 | /*
3082 | A fully authenticated channel along with all its unique attributes.
3083 | Once an authenticated channel announcement has been processed on the network,
3084 | then an instance of ChannelEdgeInfo encapsulating the channels attributes is
3085 | stored. The other portions relevant to routing policy of a channel are stored
3086 | within a ChannelEdgePolicy for each direction of the channel.
3087 | */
3088 | message ChannelEdge {
3089 | /*
3090 | The unique channel ID for the channel. The first 3 bytes are the block
3091 | height, the next 3 the index within the block, and the last 2 bytes are the
3092 | output index for the channel.
3093 | */
3094 | uint64 channel_id = 1 [jstype = JS_STRING];
3095 | string chan_point = 2;
3096 |
3097 | uint32 last_update = 3 [deprecated = true];
3098 |
3099 | string node1_pub = 4;
3100 | string node2_pub = 5;
3101 |
3102 | int64 capacity = 6;
3103 |
3104 | RoutingPolicy node1_policy = 7;
3105 | RoutingPolicy node2_policy = 8;
3106 |
3107 | // Custom channel announcement tlv records.
3108 | map custom_records = 9;
3109 | }
3110 |
3111 | message ChannelGraphRequest {
3112 | /*
3113 | Whether unannounced channels are included in the response or not. If set,
3114 | unannounced channels are included. Unannounced channels are both private
3115 | channels, and public channels that are not yet announced to the network.
3116 | */
3117 | bool include_unannounced = 1;
3118 | }
3119 |
3120 | // Returns a new instance of the directed channel graph.
3121 | message ChannelGraph {
3122 | // The list of `LightningNode`s in this channel graph
3123 | repeated LightningNode nodes = 1;
3124 |
3125 | // The list of `ChannelEdge`s in this channel graph
3126 | repeated ChannelEdge edges = 2;
3127 | }
3128 |
3129 | enum NodeMetricType {
3130 | UNKNOWN = 0;
3131 | BETWEENNESS_CENTRALITY = 1;
3132 | }
3133 |
3134 | message NodeMetricsRequest {
3135 | // The requested node metrics.
3136 | repeated NodeMetricType types = 1;
3137 | }
3138 |
3139 | message NodeMetricsResponse {
3140 | /*
3141 | Betweenness centrality is the sum of the ratio of shortest paths that pass
3142 | through the node for each pair of nodes in the graph (not counting paths
3143 | starting or ending at this node).
3144 | Map of node pubkey to betweenness centrality of the node. Normalized
3145 | values are in the [0,1] closed interval.
3146 | */
3147 | map betweenness_centrality = 1;
3148 | }
3149 |
3150 | message FloatMetric {
3151 | // Arbitrary float value.
3152 | double value = 1;
3153 |
3154 | // The value normalized to [0,1] or [-1,1].
3155 | double normalized_value = 2;
3156 | }
3157 |
3158 | message ChanInfoRequest {
3159 | /*
3160 | The unique channel ID for the channel. The first 3 bytes are the block
3161 | height, the next 3 the index within the block, and the last 2 bytes are the
3162 | output index for the channel.
3163 | */
3164 | uint64 chan_id = 1 [jstype = JS_STRING];
3165 | }
3166 |
3167 | message NetworkInfoRequest {
3168 | }
3169 | message NetworkInfo {
3170 | uint32 graph_diameter = 1;
3171 | double avg_out_degree = 2;
3172 | uint32 max_out_degree = 3;
3173 |
3174 | uint32 num_nodes = 4;
3175 | uint32 num_channels = 5;
3176 |
3177 | int64 total_network_capacity = 6;
3178 |
3179 | double avg_channel_size = 7;
3180 | int64 min_channel_size = 8;
3181 | int64 max_channel_size = 9;
3182 | int64 median_channel_size_sat = 10;
3183 |
3184 | // The number of edges marked as zombies.
3185 | uint64 num_zombie_chans = 11;
3186 |
3187 | // TODO(roasbeef): fee rate info, expiry
3188 | // * also additional RPC for tracking fee info once in
3189 | }
3190 |
3191 | message StopRequest {
3192 | }
3193 | message StopResponse {
3194 | }
3195 |
3196 | message GraphTopologySubscription {
3197 | }
3198 | message GraphTopologyUpdate {
3199 | repeated NodeUpdate node_updates = 1;
3200 | repeated ChannelEdgeUpdate channel_updates = 2;
3201 | repeated ClosedChannelUpdate closed_chans = 3;
3202 | }
3203 | message NodeUpdate {
3204 | /*
3205 | Deprecated, use node_addresses.
3206 | */
3207 | repeated string addresses = 1 [deprecated = true];
3208 |
3209 | string identity_key = 2;
3210 |
3211 | /*
3212 | Deprecated, use features.
3213 | */
3214 | bytes global_features = 3 [deprecated = true];
3215 |
3216 | string alias = 4;
3217 | string color = 5;
3218 | repeated NodeAddress node_addresses = 7;
3219 |
3220 | /*
3221 | Features that the node has advertised in the init message, node
3222 | announcements and invoices.
3223 | */
3224 | map features = 6;
3225 | }
3226 | message ChannelEdgeUpdate {
3227 | /*
3228 | The unique channel ID for the channel. The first 3 bytes are the block
3229 | height, the next 3 the index within the block, and the last 2 bytes are the
3230 | output index for the channel.
3231 | */
3232 | uint64 chan_id = 1 [jstype = JS_STRING];
3233 |
3234 | ChannelPoint chan_point = 2;
3235 |
3236 | int64 capacity = 3;
3237 |
3238 | RoutingPolicy routing_policy = 4;
3239 |
3240 | string advertising_node = 5;
3241 | string connecting_node = 6;
3242 | }
3243 | message ClosedChannelUpdate {
3244 | /*
3245 | The unique channel ID for the channel. The first 3 bytes are the block
3246 | height, the next 3 the index within the block, and the last 2 bytes are the
3247 | output index for the channel.
3248 | */
3249 | uint64 chan_id = 1 [jstype = JS_STRING];
3250 | int64 capacity = 2;
3251 | uint32 closed_height = 3;
3252 | ChannelPoint chan_point = 4;
3253 | }
3254 |
3255 | message HopHint {
3256 | // The public key of the node at the start of the channel.
3257 | string node_id = 1;
3258 |
3259 | // The unique identifier of the channel.
3260 | uint64 chan_id = 2 [jstype = JS_STRING];
3261 |
3262 | // The base fee of the channel denominated in millisatoshis.
3263 | uint32 fee_base_msat = 3;
3264 |
3265 | /*
3266 | The fee rate of the channel for sending one satoshi across it denominated in
3267 | millionths of a satoshi.
3268 | */
3269 | uint32 fee_proportional_millionths = 4;
3270 |
3271 | // The time-lock delta of the channel.
3272 | uint32 cltv_expiry_delta = 5;
3273 | }
3274 |
3275 | message SetID {
3276 | bytes set_id = 1;
3277 | }
3278 |
3279 | message RouteHint {
3280 | /*
3281 | A list of hop hints that when chained together can assist in reaching a
3282 | specific destination.
3283 | */
3284 | repeated HopHint hop_hints = 1;
3285 | }
3286 |
3287 | message AMPInvoiceState {
3288 | // The state the HTLCs associated with this setID are in.
3289 | InvoiceHTLCState state = 1;
3290 |
3291 | // The settle index of this HTLC set, if the invoice state is settled.
3292 | uint64 settle_index = 2;
3293 |
3294 | // The time this HTLC set was settled expressed in unix epoch.
3295 | int64 settle_time = 3;
3296 |
3297 | // The total amount paid for the sub-invoice expressed in milli satoshis.
3298 | int64 amt_paid_msat = 5;
3299 | }
3300 |
3301 | message Invoice {
3302 | /*
3303 | An optional memo to attach along with the invoice. Used for record keeping
3304 | purposes for the invoice's creator, and will also be set in the description
3305 | field of the encoded payment request if the description_hash field is not
3306 | being used.
3307 | */
3308 | string memo = 1;
3309 |
3310 | reserved 2;
3311 |
3312 | /*
3313 | The hex-encoded preimage (32 byte) which will allow settling an incoming
3314 | HTLC payable to this preimage. When using REST, this field must be encoded
3315 | as base64.
3316 | */
3317 | bytes r_preimage = 3;
3318 |
3319 | /*
3320 | The hash of the preimage. When using REST, this field must be encoded as
3321 | base64.
3322 | Note: Output only, don't specify for creating an invoice.
3323 | */
3324 | bytes r_hash = 4;
3325 |
3326 | /*
3327 | The value of this invoice in satoshis
3328 | The fields value and value_msat are mutually exclusive.
3329 | */
3330 | int64 value = 5;
3331 |
3332 | /*
3333 | The value of this invoice in millisatoshis
3334 | The fields value and value_msat are mutually exclusive.
3335 | */
3336 | int64 value_msat = 23;
3337 |
3338 | /*
3339 | Whether this invoice has been fulfilled
3340 | The field is deprecated. Use the state field instead (compare to SETTLED).
3341 | */
3342 | bool settled = 6 [deprecated = true];
3343 |
3344 | /*
3345 | When this invoice was created.
3346 | Note: Output only, don't specify for creating an invoice.
3347 | */
3348 | int64 creation_date = 7;
3349 |
3350 | /*
3351 | When this invoice was settled.
3352 | Note: Output only, don't specify for creating an invoice.
3353 | */
3354 | int64 settle_date = 8;
3355 |
3356 | /*
3357 | A bare-bones invoice for a payment within the Lightning Network. With the
3358 | details of the invoice, the sender has all the data necessary to send a
3359 | payment to the recipient.
3360 | Note: Output only, don't specify for creating an invoice.
3361 | */
3362 | string payment_request = 9;
3363 |
3364 | /*
3365 | Hash (SHA-256) of a description of the payment. Used if the description of
3366 | payment (memo) is too long to naturally fit within the description field
3367 | of an encoded payment request. When using REST, this field must be encoded
3368 | as base64.
3369 | */
3370 | bytes description_hash = 10;
3371 |
3372 | // Payment request expiry time in seconds. Default is 3600 (1 hour).
3373 | int64 expiry = 11;
3374 |
3375 | // Fallback on-chain address.
3376 | string fallback_addr = 12;
3377 |
3378 | // Delta to use for the time-lock of the CLTV extended to the final hop.
3379 | uint64 cltv_expiry = 13;
3380 |
3381 | /*
3382 | Route hints that can each be individually used to assist in reaching the
3383 | invoice's destination.
3384 | */
3385 | repeated RouteHint route_hints = 14;
3386 |
3387 | // Whether this invoice should include routing hints for private channels.
3388 | // Note: When enabled, if value and value_msat are zero, a large number of
3389 | // hints with these channels can be included, which might not be desirable.
3390 | bool private = 15;
3391 |
3392 | /*
3393 | The "add" index of this invoice. Each newly created invoice will increment
3394 | this index making it monotonically increasing. Callers to the
3395 | SubscribeInvoices call can use this to instantly get notified of all added
3396 | invoices with an add_index greater than this one.
3397 | Note: Output only, don't specify for creating an invoice.
3398 | */
3399 | uint64 add_index = 16;
3400 |
3401 | /*
3402 | The "settle" index of this invoice. Each newly settled invoice will
3403 | increment this index making it monotonically increasing. Callers to the
3404 | SubscribeInvoices call can use this to instantly get notified of all
3405 | settled invoices with an settle_index greater than this one.
3406 | Note: Output only, don't specify for creating an invoice.
3407 | */
3408 | uint64 settle_index = 17;
3409 |
3410 | // Deprecated, use amt_paid_sat or amt_paid_msat.
3411 | int64 amt_paid = 18 [deprecated = true];
3412 |
3413 | /*
3414 | The amount that was accepted for this invoice, in satoshis. This will ONLY
3415 | be set if this invoice has been settled. We provide this field as if the
3416 | invoice was created with a zero value, then we need to record what amount
3417 | was ultimately accepted. Additionally, it's possible that the sender paid
3418 | MORE that was specified in the original invoice. So we'll record that here
3419 | as well.
3420 | Note: Output only, don't specify for creating an invoice.
3421 | */
3422 | int64 amt_paid_sat = 19;
3423 |
3424 | /*
3425 | The amount that was accepted for this invoice, in millisatoshis. This will
3426 | ONLY be set if this invoice has been settled. We provide this field as if
3427 | the invoice was created with a zero value, then we need to record what
3428 | amount was ultimately accepted. Additionally, it's possible that the sender
3429 | paid MORE that was specified in the original invoice. So we'll record that
3430 | here as well.
3431 | Note: Output only, don't specify for creating an invoice.
3432 | */
3433 | int64 amt_paid_msat = 20;
3434 |
3435 | enum InvoiceState {
3436 | OPEN = 0;
3437 | SETTLED = 1;
3438 | CANCELED = 2;
3439 | ACCEPTED = 3;
3440 | }
3441 |
3442 | /*
3443 | The state the invoice is in.
3444 | Note: Output only, don't specify for creating an invoice.
3445 | */
3446 | InvoiceState state = 21;
3447 |
3448 | /*
3449 | List of HTLCs paying to this invoice [EXPERIMENTAL].
3450 | Note: Output only, don't specify for creating an invoice.
3451 | */
3452 | repeated InvoiceHTLC htlcs = 22;
3453 |
3454 | /*
3455 | List of features advertised on the invoice.
3456 | Note: Output only, don't specify for creating an invoice.
3457 | */
3458 | map features = 24;
3459 |
3460 | /*
3461 | Indicates if this invoice was a spontaneous payment that arrived via keysend
3462 | [EXPERIMENTAL].
3463 | Note: Output only, don't specify for creating an invoice.
3464 | */
3465 | bool is_keysend = 25;
3466 |
3467 | /*
3468 | The payment address of this invoice. This value will be used in MPP
3469 | payments, and also for newer invoices that always require the MPP payload
3470 | for added end-to-end security.
3471 | Note: Output only, don't specify for creating an invoice.
3472 | */
3473 | bytes payment_addr = 26;
3474 |
3475 | /*
3476 | Signals whether or not this is an AMP invoice.
3477 | */
3478 | bool is_amp = 27;
3479 |
3480 | /*
3481 | [EXPERIMENTAL]:
3482 | Maps a 32-byte hex-encoded set ID to the sub-invoice AMP state for the
3483 | given set ID. This field is always populated for AMP invoices, and can be
3484 | used along side LookupInvoice to obtain the HTLC information related to a
3485 | given sub-invoice.
3486 | Note: Output only, don't specify for creating an invoice.
3487 | */
3488 | map amp_invoice_state = 28;
3489 | }
3490 |
3491 | enum InvoiceHTLCState {
3492 | ACCEPTED = 0;
3493 | SETTLED = 1;
3494 | CANCELED = 2;
3495 | }
3496 |
3497 | // Details of an HTLC that paid to an invoice
3498 | message InvoiceHTLC {
3499 | // Short channel id over which the htlc was received.
3500 | uint64 chan_id = 1 [jstype = JS_STRING];
3501 |
3502 | // Index identifying the htlc on the channel.
3503 | uint64 htlc_index = 2;
3504 |
3505 | // The amount of the htlc in msat.
3506 | uint64 amt_msat = 3;
3507 |
3508 | // Block height at which this htlc was accepted.
3509 | int32 accept_height = 4;
3510 |
3511 | // Time at which this htlc was accepted.
3512 | int64 accept_time = 5;
3513 |
3514 | // Time at which this htlc was settled or canceled.
3515 | int64 resolve_time = 6;
3516 |
3517 | // Block height at which this htlc expires.
3518 | int32 expiry_height = 7;
3519 |
3520 | // Current state the htlc is in.
3521 | InvoiceHTLCState state = 8;
3522 |
3523 | // Custom tlv records.
3524 | map custom_records = 9;
3525 |
3526 | // The total amount of the mpp payment in msat.
3527 | uint64 mpp_total_amt_msat = 10;
3528 |
3529 | // Details relevant to AMP HTLCs, only populated if this is an AMP HTLC.
3530 | AMP amp = 11;
3531 | }
3532 |
3533 | // Details specific to AMP HTLCs.
3534 | message AMP {
3535 | // An n-of-n secret share of the root seed from which child payment hashes
3536 | // and preimages are derived.
3537 | bytes root_share = 1;
3538 |
3539 | // An identifier for the HTLC set that this HTLC belongs to.
3540 | bytes set_id = 2;
3541 |
3542 | // A nonce used to randomize the child preimage and child hash from a given
3543 | // root_share.
3544 | uint32 child_index = 3;
3545 |
3546 | // The payment hash of the AMP HTLC.
3547 | bytes hash = 4;
3548 |
3549 | // The preimage used to settle this AMP htlc. This field will only be
3550 | // populated if the invoice is in InvoiceState_ACCEPTED or
3551 | // InvoiceState_SETTLED.
3552 | bytes preimage = 5;
3553 | }
3554 |
3555 | message AddInvoiceResponse {
3556 | bytes r_hash = 1;
3557 |
3558 | /*
3559 | A bare-bones invoice for a payment within the Lightning Network. With the
3560 | details of the invoice, the sender has all the data necessary to send a
3561 | payment to the recipient.
3562 | */
3563 | string payment_request = 2;
3564 |
3565 | /*
3566 | The "add" index of this invoice. Each newly created invoice will increment
3567 | this index making it monotonically increasing. Callers to the
3568 | SubscribeInvoices call can use this to instantly get notified of all added
3569 | invoices with an add_index greater than this one.
3570 | */
3571 | uint64 add_index = 16;
3572 |
3573 | /*
3574 | The payment address of the generated invoice. This value should be used
3575 | in all payments for this invoice as we require it for end to end
3576 | security.
3577 | */
3578 | bytes payment_addr = 17;
3579 | }
3580 | message PaymentHash {
3581 | /*
3582 | The hex-encoded payment hash of the invoice to be looked up. The passed
3583 | payment hash must be exactly 32 bytes, otherwise an error is returned.
3584 | Deprecated now that the REST gateway supports base64 encoding of bytes
3585 | fields.
3586 | */
3587 | string r_hash_str = 1 [deprecated = true];
3588 |
3589 | /*
3590 | The payment hash of the invoice to be looked up. When using REST, this field
3591 | must be encoded as base64.
3592 | */
3593 | bytes r_hash = 2;
3594 | }
3595 |
3596 | message ListInvoiceRequest {
3597 | /*
3598 | If set, only invoices that are not settled and not canceled will be returned
3599 | in the response.
3600 | */
3601 | bool pending_only = 1;
3602 |
3603 | /*
3604 | The index of an invoice that will be used as either the start or end of a
3605 | query to determine which invoices should be returned in the response.
3606 | */
3607 | uint64 index_offset = 4;
3608 |
3609 | // The max number of invoices to return in the response to this query.
3610 | uint64 num_max_invoices = 5;
3611 |
3612 | /*
3613 | If set, the invoices returned will result from seeking backwards from the
3614 | specified index offset. This can be used to paginate backwards.
3615 | */
3616 | bool reversed = 6;
3617 | }
3618 | message ListInvoiceResponse {
3619 | /*
3620 | A list of invoices from the time slice of the time series specified in the
3621 | request.
3622 | */
3623 | repeated Invoice invoices = 1;
3624 |
3625 | /*
3626 | The index of the last item in the set of returned invoices. This can be used
3627 | to seek further, pagination style.
3628 | */
3629 | uint64 last_index_offset = 2;
3630 |
3631 | /*
3632 | The index of the last item in the set of returned invoices. This can be used
3633 | to seek backwards, pagination style.
3634 | */
3635 | uint64 first_index_offset = 3;
3636 | }
3637 |
3638 | message InvoiceSubscription {
3639 | /*
3640 | If specified (non-zero), then we'll first start by sending out
3641 | notifications for all added indexes with an add_index greater than this
3642 | value. This allows callers to catch up on any events they missed while they
3643 | weren't connected to the streaming RPC.
3644 | */
3645 | uint64 add_index = 1;
3646 |
3647 | /*
3648 | If specified (non-zero), then we'll first start by sending out
3649 | notifications for all settled indexes with an settle_index greater than
3650 | this value. This allows callers to catch up on any events they missed while
3651 | they weren't connected to the streaming RPC.
3652 | */
3653 | uint64 settle_index = 2;
3654 | }
3655 |
3656 | enum PaymentFailureReason {
3657 | /*
3658 | Payment isn't failed (yet).
3659 | */
3660 | FAILURE_REASON_NONE = 0;
3661 |
3662 | /*
3663 | There are more routes to try, but the payment timeout was exceeded.
3664 | */
3665 | FAILURE_REASON_TIMEOUT = 1;
3666 |
3667 | /*
3668 | All possible routes were tried and failed permanently. Or were no
3669 | routes to the destination at all.
3670 | */
3671 | FAILURE_REASON_NO_ROUTE = 2;
3672 |
3673 | /*
3674 | A non-recoverable error has occured.
3675 | */
3676 | FAILURE_REASON_ERROR = 3;
3677 |
3678 | /*
3679 | Payment details incorrect (unknown hash, invalid amt or
3680 | invalid final cltv delta)
3681 | */
3682 | FAILURE_REASON_INCORRECT_PAYMENT_DETAILS = 4;
3683 |
3684 | /*
3685 | Insufficient local balance.
3686 | */
3687 | FAILURE_REASON_INSUFFICIENT_BALANCE = 5;
3688 | }
3689 |
3690 | message Payment {
3691 | // The payment hash
3692 | string payment_hash = 1;
3693 |
3694 | // Deprecated, use value_sat or value_msat.
3695 | int64 value = 2 [deprecated = true];
3696 |
3697 | // Deprecated, use creation_time_ns
3698 | int64 creation_date = 3 [deprecated = true];
3699 |
3700 | reserved 4;
3701 |
3702 | // Deprecated, use fee_sat or fee_msat.
3703 | int64 fee = 5 [deprecated = true];
3704 |
3705 | // The payment preimage
3706 | string payment_preimage = 6;
3707 |
3708 | // The value of the payment in satoshis
3709 | int64 value_sat = 7;
3710 |
3711 | // The value of the payment in milli-satoshis
3712 | int64 value_msat = 8;
3713 |
3714 | // The optional payment request being fulfilled.
3715 | string payment_request = 9;
3716 |
3717 | enum PaymentStatus {
3718 | UNKNOWN = 0;
3719 | IN_FLIGHT = 1;
3720 | SUCCEEDED = 2;
3721 | FAILED = 3;
3722 | }
3723 |
3724 | // The status of the payment.
3725 | PaymentStatus status = 10;
3726 |
3727 | // The fee paid for this payment in satoshis
3728 | int64 fee_sat = 11;
3729 |
3730 | // The fee paid for this payment in milli-satoshis
3731 | int64 fee_msat = 12;
3732 |
3733 | // The time in UNIX nanoseconds at which the payment was created.
3734 | int64 creation_time_ns = 13;
3735 |
3736 | // The HTLCs made in attempt to settle the payment.
3737 | repeated HTLCAttempt htlcs = 14;
3738 |
3739 | /*
3740 | The creation index of this payment. Each payment can be uniquely identified
3741 | by this index, which may not strictly increment by 1 for payments made in
3742 | older versions of lnd.
3743 | */
3744 | uint64 payment_index = 15;
3745 |
3746 | PaymentFailureReason failure_reason = 16;
3747 | }
3748 |
3749 | message HTLCAttempt {
3750 | // The unique ID that is used for this attempt.
3751 | uint64 attempt_id = 7;
3752 |
3753 | enum HTLCStatus {
3754 | IN_FLIGHT = 0;
3755 | SUCCEEDED = 1;
3756 | FAILED = 2;
3757 | }
3758 |
3759 | // The status of the HTLC.
3760 | HTLCStatus status = 1;
3761 |
3762 | // The route taken by this HTLC.
3763 | Route route = 2;
3764 |
3765 | // The time in UNIX nanoseconds at which this HTLC was sent.
3766 | int64 attempt_time_ns = 3;
3767 |
3768 | /*
3769 | The time in UNIX nanoseconds at which this HTLC was settled or failed.
3770 | This value will not be set if the HTLC is still IN_FLIGHT.
3771 | */
3772 | int64 resolve_time_ns = 4;
3773 |
3774 | // Detailed htlc failure info.
3775 | Failure failure = 5;
3776 |
3777 | // The preimage that was used to settle the HTLC.
3778 | bytes preimage = 6;
3779 | }
3780 |
3781 | message ListPaymentsRequest {
3782 | /*
3783 | If true, then return payments that have not yet fully completed. This means
3784 | that pending payments, as well as failed payments will show up if this
3785 | field is set to true. This flag doesn't change the meaning of the indices,
3786 | which are tied to individual payments.
3787 | */
3788 | bool include_incomplete = 1;
3789 |
3790 | /*
3791 | The index of a payment that will be used as either the start or end of a
3792 | query to determine which payments should be returned in the response. The
3793 | index_offset is exclusive. In the case of a zero index_offset, the query
3794 | will start with the oldest payment when paginating forwards, or will end
3795 | with the most recent payment when paginating backwards.
3796 | */
3797 | uint64 index_offset = 2;
3798 |
3799 | // The maximal number of payments returned in the response to this query.
3800 | uint64 max_payments = 3;
3801 |
3802 | /*
3803 | If set, the payments returned will result from seeking backwards from the
3804 | specified index offset. This can be used to paginate backwards. The order
3805 | of the returned payments is always oldest first (ascending index order).
3806 | */
3807 | bool reversed = 4;
3808 |
3809 | /*
3810 | If set, all payments (complete and incomplete, independent of the
3811 | max_payments parameter) will be counted. Note that setting this to true will
3812 | increase the run time of the call significantly on systems that have a lot
3813 | of payments, as all of them have to be iterated through to be counted.
3814 | */
3815 | bool count_total_payments = 5;
3816 | }
3817 |
3818 | message ListPaymentsResponse {
3819 | // The list of payments
3820 | repeated Payment payments = 1;
3821 |
3822 | /*
3823 | The index of the first item in the set of returned payments. This can be
3824 | used as the index_offset to continue seeking backwards in the next request.
3825 | */
3826 | uint64 first_index_offset = 2;
3827 |
3828 | /*
3829 | The index of the last item in the set of returned payments. This can be used
3830 | as the index_offset to continue seeking forwards in the next request.
3831 | */
3832 | uint64 last_index_offset = 3;
3833 |
3834 | /*
3835 | Will only be set if count_total_payments in the request was set. Represents
3836 | the total number of payments (complete and incomplete, independent of the
3837 | number of payments requested in the query) currently present in the payments
3838 | database.
3839 | */
3840 | uint64 total_num_payments = 4;
3841 | }
3842 |
3843 | message DeletePaymentRequest {
3844 | // Payment hash to delete.
3845 | bytes payment_hash = 1;
3846 |
3847 | /*
3848 | Only delete failed HTLCs from the payment, not the payment itself.
3849 | */
3850 | bool failed_htlcs_only = 2;
3851 | }
3852 |
3853 | message DeleteAllPaymentsRequest {
3854 | // Only delete failed payments.
3855 | bool failed_payments_only = 1;
3856 |
3857 | /*
3858 | Only delete failed HTLCs from payments, not the payment itself.
3859 | */
3860 | bool failed_htlcs_only = 2;
3861 | }
3862 |
3863 | message DeletePaymentResponse {
3864 | }
3865 |
3866 | message DeleteAllPaymentsResponse {
3867 | }
3868 |
3869 | message AbandonChannelRequest {
3870 | ChannelPoint channel_point = 1;
3871 |
3872 | bool pending_funding_shim_only = 2;
3873 |
3874 | /*
3875 | Override the requirement for being in dev mode by setting this to true and
3876 | confirming the user knows what they are doing and this is a potential foot
3877 | gun to lose funds if used on active channels.
3878 | */
3879 | bool i_know_what_i_am_doing = 3;
3880 | }
3881 |
3882 | message AbandonChannelResponse {
3883 | }
3884 |
3885 | message DebugLevelRequest {
3886 | bool show = 1;
3887 | string level_spec = 2;
3888 | }
3889 | message DebugLevelResponse {
3890 | string sub_systems = 1;
3891 | }
3892 |
3893 | message PayReqString {
3894 | // The payment request string to be decoded
3895 | string pay_req = 1;
3896 | }
3897 | message PayReq {
3898 | string destination = 1;
3899 | string payment_hash = 2;
3900 | int64 num_satoshis = 3;
3901 | int64 timestamp = 4;
3902 | int64 expiry = 5;
3903 | string description = 6;
3904 | string description_hash = 7;
3905 | string fallback_addr = 8;
3906 | int64 cltv_expiry = 9;
3907 | repeated RouteHint route_hints = 10;
3908 | bytes payment_addr = 11;
3909 | int64 num_msat = 12;
3910 | map features = 13;
3911 | }
3912 |
3913 | enum FeatureBit {
3914 | DATALOSS_PROTECT_REQ = 0;
3915 | DATALOSS_PROTECT_OPT = 1;
3916 | INITIAL_ROUING_SYNC = 3;
3917 | UPFRONT_SHUTDOWN_SCRIPT_REQ = 4;
3918 | UPFRONT_SHUTDOWN_SCRIPT_OPT = 5;
3919 | GOSSIP_QUERIES_REQ = 6;
3920 | GOSSIP_QUERIES_OPT = 7;
3921 | TLV_ONION_REQ = 8;
3922 | TLV_ONION_OPT = 9;
3923 | EXT_GOSSIP_QUERIES_REQ = 10;
3924 | EXT_GOSSIP_QUERIES_OPT = 11;
3925 | STATIC_REMOTE_KEY_REQ = 12;
3926 | STATIC_REMOTE_KEY_OPT = 13;
3927 | PAYMENT_ADDR_REQ = 14;
3928 | PAYMENT_ADDR_OPT = 15;
3929 | MPP_REQ = 16;
3930 | MPP_OPT = 17;
3931 | WUMBO_CHANNELS_REQ = 18;
3932 | WUMBO_CHANNELS_OPT = 19;
3933 | ANCHORS_REQ = 20;
3934 | ANCHORS_OPT = 21;
3935 | ANCHORS_ZERO_FEE_HTLC_REQ = 22;
3936 | ANCHORS_ZERO_FEE_HTLC_OPT = 23;
3937 | AMP_REQ = 30;
3938 | AMP_OPT = 31;
3939 | }
3940 |
3941 | message Feature {
3942 | string name = 2;
3943 | bool is_required = 3;
3944 | bool is_known = 4;
3945 | }
3946 |
3947 | message FeeReportRequest {
3948 | }
3949 | message ChannelFeeReport {
3950 | // The short channel id that this fee report belongs to.
3951 | uint64 chan_id = 5 [jstype = JS_STRING];
3952 |
3953 | // The channel that this fee report belongs to.
3954 | string channel_point = 1;
3955 |
3956 | // The base fee charged regardless of the number of milli-satoshis sent.
3957 | int64 base_fee_msat = 2;
3958 |
3959 | // The amount charged per milli-satoshis transferred expressed in
3960 | // millionths of a satoshi.
3961 | int64 fee_per_mil = 3;
3962 |
3963 | // The effective fee rate in milli-satoshis. Computed by dividing the
3964 | // fee_per_mil value by 1 million.
3965 | double fee_rate = 4;
3966 | }
3967 | message FeeReportResponse {
3968 | // An array of channel fee reports which describes the current fee schedule
3969 | // for each channel.
3970 | repeated ChannelFeeReport channel_fees = 1;
3971 |
3972 | // The total amount of fee revenue (in satoshis) the switch has collected
3973 | // over the past 24 hrs.
3974 | uint64 day_fee_sum = 2;
3975 |
3976 | // The total amount of fee revenue (in satoshis) the switch has collected
3977 | // over the past 1 week.
3978 | uint64 week_fee_sum = 3;
3979 |
3980 | // The total amount of fee revenue (in satoshis) the switch has collected
3981 | // over the past 1 month.
3982 | uint64 month_fee_sum = 4;
3983 | }
3984 |
3985 | message PolicyUpdateRequest {
3986 | oneof scope {
3987 | // If set, then this update applies to all currently active channels.
3988 | bool global = 1;
3989 |
3990 | // If set, this update will target a specific channel.
3991 | ChannelPoint chan_point = 2;
3992 | }
3993 |
3994 | // The base fee charged regardless of the number of milli-satoshis sent.
3995 | int64 base_fee_msat = 3;
3996 |
3997 | // The effective fee rate in milli-satoshis. The precision of this value
3998 | // goes up to 6 decimal places, so 1e-6.
3999 | double fee_rate = 4;
4000 |
4001 | // The effective fee rate in micro-satoshis (parts per million).
4002 | uint32 fee_rate_ppm = 9;
4003 |
4004 | // The required timelock delta for HTLCs forwarded over the channel.
4005 | uint32 time_lock_delta = 5;
4006 |
4007 | // If set, the maximum HTLC size in milli-satoshis. If unset, the maximum
4008 | // HTLC will be unchanged.
4009 | uint64 max_htlc_msat = 6;
4010 |
4011 | // The minimum HTLC size in milli-satoshis. Only applied if
4012 | // min_htlc_msat_specified is true.
4013 | uint64 min_htlc_msat = 7;
4014 |
4015 | // If true, min_htlc_msat is applied.
4016 | bool min_htlc_msat_specified = 8;
4017 | }
4018 | enum UpdateFailure {
4019 | UPDATE_FAILURE_UNKNOWN = 0;
4020 | UPDATE_FAILURE_PENDING = 1;
4021 | UPDATE_FAILURE_NOT_FOUND = 2;
4022 | UPDATE_FAILURE_INTERNAL_ERR = 3;
4023 | UPDATE_FAILURE_INVALID_PARAMETER = 4;
4024 | }
4025 |
4026 | message FailedUpdate {
4027 | // The outpoint in format txid:n
4028 | OutPoint outpoint = 1;
4029 |
4030 | // Reason for the policy update failure.
4031 | UpdateFailure reason = 2;
4032 |
4033 | // A string representation of the policy update error.
4034 | string update_error = 3;
4035 | }
4036 |
4037 | message PolicyUpdateResponse {
4038 | // List of failed policy updates.
4039 | repeated FailedUpdate failed_updates = 1;
4040 | }
4041 |
4042 | message ForwardingHistoryRequest {
4043 | // Start time is the starting point of the forwarding history request. All
4044 | // records beyond this point will be included, respecting the end time, and
4045 | // the index offset.
4046 | uint64 start_time = 1;
4047 |
4048 | // End time is the end point of the forwarding history request. The
4049 | // response will carry at most 50k records between the start time and the
4050 | // end time. The index offset can be used to implement pagination.
4051 | uint64 end_time = 2;
4052 |
4053 | // Index offset is the offset in the time series to start at. As each
4054 | // response can only contain 50k records, callers can use this to skip
4055 | // around within a packed time series.
4056 | uint32 index_offset = 3;
4057 |
4058 | // The max number of events to return in the response to this query.
4059 | uint32 num_max_events = 4;
4060 |
4061 | // Informs the server if the peer alias should be looked up for each
4062 | // forwarding event.
4063 | bool peer_alias_lookup = 5;
4064 | }
4065 | message ForwardingEvent {
4066 | // Timestamp is the time (unix epoch offset) that this circuit was
4067 | // completed. Deprecated by timestamp_ns.
4068 | uint64 timestamp = 1 [deprecated = true];
4069 |
4070 | // The incoming channel ID that carried the HTLC that created the circuit.
4071 | uint64 chan_id_in = 2 [jstype = JS_STRING];
4072 |
4073 | // The outgoing channel ID that carried the preimage that completed the
4074 | // circuit.
4075 | uint64 chan_id_out = 4 [jstype = JS_STRING];
4076 |
4077 | // The total amount (in satoshis) of the incoming HTLC that created half
4078 | // the circuit.
4079 | uint64 amt_in = 5;
4080 |
4081 | // The total amount (in satoshis) of the outgoing HTLC that created the
4082 | // second half of the circuit.
4083 | uint64 amt_out = 6;
4084 |
4085 | // The total fee (in satoshis) that this payment circuit carried.
4086 | uint64 fee = 7;
4087 |
4088 | // The total fee (in milli-satoshis) that this payment circuit carried.
4089 | uint64 fee_msat = 8;
4090 |
4091 | // The total amount (in milli-satoshis) of the incoming HTLC that created
4092 | // half the circuit.
4093 | uint64 amt_in_msat = 9;
4094 |
4095 | // The total amount (in milli-satoshis) of the outgoing HTLC that created
4096 | // the second half of the circuit.
4097 | uint64 amt_out_msat = 10;
4098 |
4099 | // The number of nanoseconds elapsed since January 1, 1970 UTC when this
4100 | // circuit was completed.
4101 | uint64 timestamp_ns = 11;
4102 |
4103 | // The peer alias of the incoming channel.
4104 | string peer_alias_in = 12;
4105 |
4106 | // The peer alias of the outgoing channel.
4107 | string peer_alias_out = 13;
4108 |
4109 | // TODO(roasbeef): add settlement latency?
4110 | // * use FPE on the chan id?
4111 | // * also list failures?
4112 | }
4113 | message ForwardingHistoryResponse {
4114 | // A list of forwarding events from the time slice of the time series
4115 | // specified in the request.
4116 | repeated ForwardingEvent forwarding_events = 1;
4117 |
4118 | // The index of the last time in the set of returned forwarding events. Can
4119 | // be used to seek further, pagination style.
4120 | uint32 last_offset_index = 2;
4121 | }
4122 |
4123 | message ExportChannelBackupRequest {
4124 | // The target channel point to obtain a back up for.
4125 | ChannelPoint chan_point = 1;
4126 | }
4127 |
4128 | message ChannelBackup {
4129 | /*
4130 | Identifies the channel that this backup belongs to.
4131 | */
4132 | ChannelPoint chan_point = 1;
4133 |
4134 | /*
4135 | Is an encrypted single-chan backup. this can be passed to
4136 | RestoreChannelBackups, or the WalletUnlocker Init and Unlock methods in
4137 | order to trigger the recovery protocol. When using REST, this field must be
4138 | encoded as base64.
4139 | */
4140 | bytes chan_backup = 2;
4141 | }
4142 |
4143 | message MultiChanBackup {
4144 | /*
4145 | Is the set of all channels that are included in this multi-channel backup.
4146 | */
4147 | repeated ChannelPoint chan_points = 1;
4148 |
4149 | /*
4150 | A single encrypted blob containing all the static channel backups of the
4151 | channel listed above. This can be stored as a single file or blob, and
4152 | safely be replaced with any prior/future versions. When using REST, this
4153 | field must be encoded as base64.
4154 | */
4155 | bytes multi_chan_backup = 2;
4156 | }
4157 |
4158 | message ChanBackupExportRequest {
4159 | }
4160 | message ChanBackupSnapshot {
4161 | /*
4162 | The set of new channels that have been added since the last channel backup
4163 | snapshot was requested.
4164 | */
4165 | ChannelBackups single_chan_backups = 1;
4166 |
4167 | /*
4168 | A multi-channel backup that covers all open channels currently known to
4169 | lnd.
4170 | */
4171 | MultiChanBackup multi_chan_backup = 2;
4172 | }
4173 |
4174 | message ChannelBackups {
4175 | /*
4176 | A set of single-chan static channel backups.
4177 | */
4178 | repeated ChannelBackup chan_backups = 1;
4179 | }
4180 |
4181 | message RestoreChanBackupRequest {
4182 | oneof backup {
4183 | /*
4184 | The channels to restore as a list of channel/backup pairs.
4185 | */
4186 | ChannelBackups chan_backups = 1;
4187 |
4188 | /*
4189 | The channels to restore in the packed multi backup format. When using
4190 | REST, this field must be encoded as base64.
4191 | */
4192 | bytes multi_chan_backup = 2;
4193 | }
4194 | }
4195 | message RestoreBackupResponse {
4196 | }
4197 |
4198 | message ChannelBackupSubscription {
4199 | }
4200 |
4201 | message VerifyChanBackupResponse {
4202 | }
4203 |
4204 | message MacaroonPermission {
4205 | // The entity a permission grants access to.
4206 | string entity = 1;
4207 |
4208 | // The action that is granted.
4209 | string action = 2;
4210 | }
4211 | message BakeMacaroonRequest {
4212 | // The list of permissions the new macaroon should grant.
4213 | repeated MacaroonPermission permissions = 1;
4214 |
4215 | // The root key ID used to create the macaroon, must be a positive integer.
4216 | uint64 root_key_id = 2;
4217 |
4218 | /*
4219 | Informs the RPC on whether to allow external permissions that LND is not
4220 | aware of.
4221 | */
4222 | bool allow_external_permissions = 3;
4223 | }
4224 | message BakeMacaroonResponse {
4225 | // The hex encoded macaroon, serialized in binary format.
4226 | string macaroon = 1;
4227 | }
4228 |
4229 | message ListMacaroonIDsRequest {
4230 | }
4231 | message ListMacaroonIDsResponse {
4232 | // The list of root key IDs that are in use.
4233 | repeated uint64 root_key_ids = 1;
4234 | }
4235 |
4236 | message DeleteMacaroonIDRequest {
4237 | // The root key ID to be removed.
4238 | uint64 root_key_id = 1;
4239 | }
4240 | message DeleteMacaroonIDResponse {
4241 | // A boolean indicates that the deletion is successful.
4242 | bool deleted = 1;
4243 | }
4244 |
4245 | message MacaroonPermissionList {
4246 | // A list of macaroon permissions.
4247 | repeated MacaroonPermission permissions = 1;
4248 | }
4249 |
4250 | message ListPermissionsRequest {
4251 | }
4252 | message ListPermissionsResponse {
4253 | /*
4254 | A map between all RPC method URIs and their required macaroon permissions to
4255 | access them.
4256 | */
4257 | map method_permissions = 1;
4258 | }
4259 |
4260 | message Failure {
4261 | enum FailureCode {
4262 | /*
4263 | The numbers assigned in this enumeration match the failure codes as
4264 | defined in BOLT #4. Because protobuf 3 requires enums to start with 0,
4265 | a RESERVED value is added.
4266 | */
4267 | RESERVED = 0;
4268 |
4269 | INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS = 1;
4270 | INCORRECT_PAYMENT_AMOUNT = 2;
4271 | FINAL_INCORRECT_CLTV_EXPIRY = 3;
4272 | FINAL_INCORRECT_HTLC_AMOUNT = 4;
4273 | FINAL_EXPIRY_TOO_SOON = 5;
4274 | INVALID_REALM = 6;
4275 | EXPIRY_TOO_SOON = 7;
4276 | INVALID_ONION_VERSION = 8;
4277 | INVALID_ONION_HMAC = 9;
4278 | INVALID_ONION_KEY = 10;
4279 | AMOUNT_BELOW_MINIMUM = 11;
4280 | FEE_INSUFFICIENT = 12;
4281 | INCORRECT_CLTV_EXPIRY = 13;
4282 | CHANNEL_DISABLED = 14;
4283 | TEMPORARY_CHANNEL_FAILURE = 15;
4284 | REQUIRED_NODE_FEATURE_MISSING = 16;
4285 | REQUIRED_CHANNEL_FEATURE_MISSING = 17;
4286 | UNKNOWN_NEXT_PEER = 18;
4287 | TEMPORARY_NODE_FAILURE = 19;
4288 | PERMANENT_NODE_FAILURE = 20;
4289 | PERMANENT_CHANNEL_FAILURE = 21;
4290 | EXPIRY_TOO_FAR = 22;
4291 | MPP_TIMEOUT = 23;
4292 | INVALID_ONION_PAYLOAD = 24;
4293 |
4294 | /*
4295 | An internal error occurred.
4296 | */
4297 | INTERNAL_FAILURE = 997;
4298 |
4299 | /*
4300 | The error source is known, but the failure itself couldn't be decoded.
4301 | */
4302 | UNKNOWN_FAILURE = 998;
4303 |
4304 | /*
4305 | An unreadable failure result is returned if the received failure message
4306 | cannot be decrypted. In that case the error source is unknown.
4307 | */
4308 | UNREADABLE_FAILURE = 999;
4309 | }
4310 |
4311 | // Failure code as defined in the Lightning spec
4312 | FailureCode code = 1;
4313 |
4314 | reserved 2;
4315 |
4316 | // An optional channel update message.
4317 | ChannelUpdate channel_update = 3;
4318 |
4319 | // A failure type-dependent htlc value.
4320 | uint64 htlc_msat = 4;
4321 |
4322 | // The sha256 sum of the onion payload.
4323 | bytes onion_sha_256 = 5;
4324 |
4325 | // A failure type-dependent cltv expiry value.
4326 | uint32 cltv_expiry = 6;
4327 |
4328 | // A failure type-dependent flags value.
4329 | uint32 flags = 7;
4330 |
4331 | /*
4332 | The position in the path of the intermediate or final node that generated
4333 | the failure message. Position zero is the sender node.
4334 | **/
4335 | uint32 failure_source_index = 8;
4336 |
4337 | // A failure type-dependent block height.
4338 | uint32 height = 9;
4339 | }
4340 |
4341 | message ChannelUpdate {
4342 | /*
4343 | The signature that validates the announced data and proves the ownership
4344 | of node id.
4345 | */
4346 | bytes signature = 1;
4347 |
4348 | /*
4349 | The target chain that this channel was opened within. This value
4350 | should be the genesis hash of the target chain. Along with the short
4351 | channel ID, this uniquely identifies the channel globally in a
4352 | blockchain.
4353 | */
4354 | bytes chain_hash = 2;
4355 |
4356 | /*
4357 | The unique description of the funding transaction.
4358 | */
4359 | uint64 chan_id = 3 [jstype = JS_STRING];
4360 |
4361 | /*
4362 | A timestamp that allows ordering in the case of multiple announcements.
4363 | We should ignore the message if timestamp is not greater than the
4364 | last-received.
4365 | */
4366 | uint32 timestamp = 4;
4367 |
4368 | /*
4369 | The bitfield that describes whether optional fields are present in this
4370 | update. Currently, the least-significant bit must be set to 1 if the
4371 | optional field MaxHtlc is present.
4372 | */
4373 | uint32 message_flags = 10;
4374 |
4375 | /*
4376 | The bitfield that describes additional meta-data concerning how the
4377 | update is to be interpreted. Currently, the least-significant bit must be
4378 | set to 0 if the creating node corresponds to the first node in the
4379 | previously sent channel announcement and 1 otherwise. If the second bit
4380 | is set, then the channel is set to be disabled.
4381 | */
4382 | uint32 channel_flags = 5;
4383 |
4384 | /*
4385 | The minimum number of blocks this node requires to be added to the expiry
4386 | of HTLCs. This is a security parameter determined by the node operator.
4387 | This value represents the required gap between the time locks of the
4388 | incoming and outgoing HTLC's set to this node.
4389 | */
4390 | uint32 time_lock_delta = 6;
4391 |
4392 | /*
4393 | The minimum HTLC value which will be accepted.
4394 | */
4395 | uint64 htlc_minimum_msat = 7;
4396 |
4397 | /*
4398 | The base fee that must be used for incoming HTLC's to this particular
4399 | channel. This value will be tacked onto the required for a payment
4400 | independent of the size of the payment.
4401 | */
4402 | uint32 base_fee = 8;
4403 |
4404 | /*
4405 | The fee rate that will be charged per millionth of a satoshi.
4406 | */
4407 | uint32 fee_rate = 9;
4408 |
4409 | /*
4410 | The maximum HTLC value which will be accepted.
4411 | */
4412 | uint64 htlc_maximum_msat = 11;
4413 |
4414 | /*
4415 | The set of data that was appended to this message, some of which we may
4416 | not actually know how to iterate or parse. By holding onto this data, we
4417 | ensure that we're able to properly validate the set of signatures that
4418 | cover these new fields, and ensure we're able to make upgrades to the
4419 | network in a forwards compatible manner.
4420 | */
4421 | bytes extra_opaque_data = 12;
4422 | }
4423 |
4424 | message MacaroonId {
4425 | bytes nonce = 1;
4426 | bytes storageId = 2;
4427 | repeated Op ops = 3;
4428 | }
4429 |
4430 | message Op {
4431 | string entity = 1;
4432 | repeated string actions = 2;
4433 | }
4434 |
4435 | message CheckMacPermRequest {
4436 | bytes macaroon = 1;
4437 | repeated MacaroonPermission permissions = 2;
4438 | string fullMethod = 3;
4439 | }
4440 |
4441 | message CheckMacPermResponse {
4442 | bool valid = 1;
4443 | }
4444 |
4445 | message RPCMiddlewareRequest {
4446 | /*
4447 | The unique ID of the intercepted original gRPC request. Useful for mapping
4448 | request to response when implementing full duplex message interception. For
4449 | streaming requests, this will be the same ID for all incoming and outgoing
4450 | middleware intercept messages of the _same_ stream.
4451 | */
4452 | uint64 request_id = 1;
4453 |
4454 | /*
4455 | The raw bytes of the complete macaroon as sent by the gRPC client in the
4456 | original request. This might be empty for a request that doesn't require
4457 | macaroons such as the wallet unlocker RPCs.
4458 | */
4459 | bytes raw_macaroon = 2;
4460 |
4461 | /*
4462 | The parsed condition of the macaroon's custom caveat for convenient access.
4463 | This field only contains the value of the custom caveat that the handling
4464 | middleware has registered itself for. The condition _must_ be validated for
4465 | messages of intercept_type stream_auth and request!
4466 | */
4467 | string custom_caveat_condition = 3;
4468 |
4469 | /*
4470 | There are three types of messages that will be sent to the middleware for
4471 | inspection and approval: Stream authentication, request and response
4472 | interception. The first two can only be accepted (=forward to main RPC
4473 | server) or denied (=return error to client). Intercepted responses can also
4474 | be replaced/overwritten.
4475 | */
4476 | oneof intercept_type {
4477 | /*
4478 | Intercept stream authentication: each new streaming RPC call that is
4479 | initiated against lnd and contains the middleware's custom macaroon
4480 | caveat can be approved or denied based upon the macaroon in the stream
4481 | header. This message will only be sent for streaming RPCs, unary RPCs
4482 | must handle the macaroon authentication in the request interception to
4483 | avoid an additional message round trip between lnd and the middleware.
4484 | */
4485 | StreamAuth stream_auth = 4;
4486 |
4487 | /*
4488 | Intercept incoming gRPC client request message: all incoming messages,
4489 | both on streaming and unary RPCs, are forwarded to the middleware for
4490 | inspection. For unary RPC messages the middleware is also expected to
4491 | validate the custom macaroon caveat of the request.
4492 | */
4493 | RPCMessage request = 5;
4494 |
4495 | /*
4496 | Intercept outgoing gRPC response message: all outgoing messages, both on
4497 | streaming and unary RPCs, are forwarded to the middleware for inspection
4498 | and amendment. The response in this message is the original response as
4499 | it was generated by the main RPC server. It can either be accepted
4500 | (=forwarded to the client), replaced/overwritten with a new message of
4501 | the same type, or replaced by an error message.
4502 | */
4503 | RPCMessage response = 6;
4504 |
4505 | /*
4506 | This is used to indicate to the client that the server has successfully
4507 | registered the interceptor. This is only used in the very first message
4508 | that the server sends to the client after the client sends the server
4509 | the middleware registration message.
4510 | */
4511 | bool reg_complete = 8;
4512 | }
4513 |
4514 | /*
4515 | The unique message ID of this middleware intercept message. There can be
4516 | multiple middleware intercept messages per single gRPC request (one for the
4517 | incoming request and one for the outgoing response) or gRPC stream (one for
4518 | each incoming message and one for each outgoing response). This message ID
4519 | must be referenced when responding (accepting/rejecting/modifying) to an
4520 | intercept message.
4521 | */
4522 | uint64 msg_id = 7;
4523 | }
4524 |
4525 | message StreamAuth {
4526 | /*
4527 | The full URI (in the format /./MethodName, for
4528 | example /lnrpc.Lightning/GetInfo) of the streaming RPC method that was just
4529 | established.
4530 | */
4531 | string method_full_uri = 1;
4532 | }
4533 |
4534 | message RPCMessage {
4535 | /*
4536 | The full URI (in the format /./MethodName, for
4537 | example /lnrpc.Lightning/GetInfo) of the RPC method the message was sent
4538 | to/from.
4539 | */
4540 | string method_full_uri = 1;
4541 |
4542 | /*
4543 | Indicates whether the message was sent over a streaming RPC method or not.
4544 | */
4545 | bool stream_rpc = 2;
4546 |
4547 | /*
4548 | The full canonical gRPC name of the message type (in the format
4549 | .TypeName, for example lnrpc.GetInfoRequest). In case of an
4550 | error being returned from lnd, this simply contains the string "error".
4551 | */
4552 | string type_name = 3;
4553 |
4554 | /*
4555 | The full content of the gRPC message, serialized in the binary protobuf
4556 | format.
4557 | */
4558 | bytes serialized = 4;
4559 |
4560 | /*
4561 | Indicates that the response from lnd was an error, not a gRPC response. If
4562 | this is set to true then the type_name contains the string "error" and
4563 | serialized contains the error string.
4564 | */
4565 | bool is_error = 5;
4566 | }
4567 |
4568 | message RPCMiddlewareResponse {
4569 | /*
4570 | The request message ID this response refers to. Must always be set when
4571 | giving feedback to an intercept but is ignored for the initial registration
4572 | message.
4573 | */
4574 | uint64 ref_msg_id = 1;
4575 |
4576 | /*
4577 | The middleware can only send two types of messages to lnd: The initial
4578 | registration message that identifies the middleware and after that only
4579 | feedback messages to requests sent to the middleware.
4580 | */
4581 | oneof middleware_message {
4582 | /*
4583 | The registration message identifies the middleware that's being
4584 | registered in lnd. The registration message must be sent immediately
4585 | after initiating the RegisterRpcMiddleware stream, otherwise lnd will
4586 | time out the attempt and terminate the request. NOTE: The middleware
4587 | will only receive interception messages for requests that contain a
4588 | macaroon with the custom caveat that the middleware declares it is
4589 | responsible for handling in the registration message! As a security
4590 | measure, _no_ middleware can intercept requests made with _unencumbered_
4591 | macaroons!
4592 | */
4593 | MiddlewareRegistration register = 2;
4594 |
4595 | /*
4596 | The middleware received an interception request and gives feedback to
4597 | it. The request_id indicates what message the feedback refers to.
4598 | */
4599 | InterceptFeedback feedback = 3;
4600 | }
4601 | }
4602 |
4603 | message MiddlewareRegistration {
4604 | /*
4605 | The name of the middleware to register. The name should be as informative
4606 | as possible and is logged on registration.
4607 | */
4608 | string middleware_name = 1;
4609 |
4610 | /*
4611 | The name of the custom macaroon caveat that this middleware is responsible
4612 | for. Only requests/responses that contain a macaroon with the registered
4613 | custom caveat are forwarded for interception to the middleware. The
4614 | exception being the read-only mode: All requests/responses are forwarded to
4615 | a middleware that requests read-only access but such a middleware won't be
4616 | allowed to _alter_ responses. As a security measure, _no_ middleware can
4617 | change responses to requests made with _unencumbered_ macaroons!
4618 | NOTE: Cannot be used at the same time as read_only_mode.
4619 | */
4620 | string custom_macaroon_caveat_name = 2;
4621 |
4622 | /*
4623 | Instead of defining a custom macaroon caveat name a middleware can register
4624 | itself for read-only access only. In that mode all requests/responses are
4625 | forwarded to the middleware but the middleware isn't allowed to alter any of
4626 | the responses.
4627 | NOTE: Cannot be used at the same time as custom_macaroon_caveat_name.
4628 | */
4629 | bool read_only_mode = 3;
4630 | }
4631 |
4632 | message InterceptFeedback {
4633 | /*
4634 | The error to return to the user. If this is non-empty, the incoming gRPC
4635 | stream/request is aborted and the error is returned to the gRPC client. If
4636 | this value is empty, it means the middleware accepts the stream/request/
4637 | response and the processing of it can continue.
4638 | */
4639 | string error = 1;
4640 |
4641 | /*
4642 | A boolean indicating that the gRPC message should be replaced/overwritten.
4643 | This boolean is needed because in protobuf an empty message is serialized as
4644 | a 0-length or nil byte slice and we wouldn't be able to distinguish between
4645 | an empty replacement message and the "don't replace anything" case.
4646 | */
4647 | bool replace_response = 2;
4648 |
4649 | /*
4650 | If the replace_response field is set to true, this field must contain the
4651 | binary serialized gRPC message in the protobuf format.
4652 | */
4653 | bytes replacement_serialized = 3;
4654 | }
4655 |
--------------------------------------------------------------------------------
/next.config.mjs:
--------------------------------------------------------------------------------
1 | /** @type {import('next').NextConfig} */
2 | const nextConfig = {
3 | async rewrites() {
4 | return [
5 | {
6 | source: '/.well-known/lnurlp/:user',
7 | destination: '/api/lnurlp/:user',
8 | }
9 | ]
10 | },
11 | async redirects() {
12 | return [
13 | ];
14 | },
15 | };
16 |
17 | export default nextConfig;
18 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "nextjs",
3 | "version": "0.1.0",
4 | "private": true,
5 | "scripts": {
6 | "dev": "next dev",
7 | "build": "next build",
8 | "start": "next start",
9 | "lint": "next lint"
10 | },
11 | "dependencies": {
12 | "@grpc/grpc-js": "^1.10.10",
13 | "axios": "^1.7.2",
14 | "bech32": "^2.0.0",
15 | "bolt11": "^1.4.1",
16 | "micro": "^10.0.1",
17 | "mongodb": "^6.7.0",
18 | "next": "^14.2.17",
19 | "nodemailer": "^6.9.14",
20 | "nostr-tools": "^1.17.0",
21 | "react": "^18",
22 | "react-dom": "^18",
23 | "websocket-polyfill": "^1.0.0"
24 | },
25 | "devDependencies": {
26 | "@types/node": "^20",
27 | "@types/react": "^18",
28 | "@types/react-dom": "^18",
29 | "eslint": "^8",
30 | "eslint-config-next": "14.2.4",
31 | "typescript": "^5"
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/public/next.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/public/vercel.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/push:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # If you're reading this please help; there's gotta be a better way to do this, lol.
3 |
4 | source .env
5 | git add .
6 | git commit -m "updated"
7 | output=$(git push 2>&1)
8 | echo "$output"
9 |
10 | if [[ "$output" == *"Everything up-to-date"* ]]; then
11 | echo -e "\nNothing was changed! No need to run https://$DOMAIN/api/notifier/run"
12 | exit 0
13 | fi
14 |
15 | echo ""
16 | echo "**************************************************************"
17 | echo " Waiting to run https://$DOMAIN/api/notifier/run..."
18 | echo "**************************************************************"
19 |
20 | sleep 10
21 |
22 | recent_deployment_id=$(curl -s -X GET "https://api.digitalocean.com/v2/apps/$DIGITAL_OCEAN_APP_ID/deployments" \
23 | -H "Authorization: Bearer $DIGITAL_OCEAN_API" \
24 | -H "Content-Type: application/json" |
25 | jq -r '.deployments[0].id')
26 |
27 | prev_status=""
28 |
29 | while :; do
30 | deployment_status=$(curl -s -X GET "https://api.digitalocean.com/v2/apps/$DIGITAL_OCEAN_APP_ID/deployments/$recent_deployment_id" \
31 | -H "Authorization: Bearer $DIGITAL_OCEAN_API" \
32 | -H "Content-Type: application/json" |
33 | jq -r '.deployment.phase')
34 |
35 | if [[ "$deployment_status" == "$prev_status" ]]; then
36 | echo -n ". "
37 | else
38 | echo -e "\nCurrent deployment status: $deployment_status"
39 | prev_status=$deployment_status
40 | fi
41 |
42 | if [[ "$deployment_status" == "ACTIVE" ]]; then
43 | sleep 5
44 | curl -s https://$DOMAIN/api/notifier/run
45 | break
46 | fi
47 |
48 | if [[ "$deployment_status" == "ERROR" ]]; then
49 | exit 0
50 | fi
51 |
52 | sleep 2
53 | done
54 |
--------------------------------------------------------------------------------