ln-service 52.14.4 → 52.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Versions
2
2
 
3
+ ## 52.15.0
4
+
5
+ - `getPayment`, `subscribeToPastPayment`: Add `pending` for pending payment details
6
+
3
7
  ## 52.14.4
4
8
 
5
9
  - `probeForRoute`, `subscribeToProbeForRoute`, `subscribeToPayViaRoutes`,
package/README.md CHANGED
@@ -2324,6 +2324,30 @@ Requires `offchain:read` permission
2324
2324
  timeout: <Expiration Block Height Number>
2325
2325
  tokens: <Total Tokens Paid Number>
2326
2326
  }
2327
+ [pending]: {
2328
+ created_at: <Payment Created At ISO 8601 Date String>
2329
+ destination: <Payment Destination Hex String>
2330
+ id: <Payment Hash Hex String>
2331
+ mtokens: <Total Millitokens Pending String>
2332
+ paths: [{
2333
+ fee_mtokens: <Total Fee Millitokens Paid String>
2334
+ hops: [{
2335
+ channel: <Standard Format Channel Id String>
2336
+ channel_capacity: <Channel Capacity Tokens Number>
2337
+ fee: <Fee Tokens Rounded Down Number>
2338
+ fee_mtokens: <Fee Millitokens String>
2339
+ forward: <Forwarded Tokens Number>
2340
+ forward_mtokens: <Forward Millitokens String>
2341
+ public_key: <Public Key Hex String>
2342
+ timeout: <Timeout Block Height Number>
2343
+ }]
2344
+ mtokens: <Total Millitokens Pending String>
2345
+ }]
2346
+ [request]: <BOLT 11 Encoded Payment Request String>
2347
+ safe_tokens: <Payment Tokens Rounded Up Number>
2348
+ [timeout]: <Expiration Block Height Number>
2349
+ tokens: <Total Tokens Pending Number>
2350
+ }
2327
2351
  }
2328
2352
 
2329
2353
  Example:
@@ -5138,7 +5162,34 @@ Requires `offchain:read` permission
5138
5162
  }
5139
5163
 
5140
5164
  @event 'paying'
5141
- {}
5165
+ {
5166
+ created_at: <Payment Created At ISO 8601 Date String>
5167
+ destination: <Payment Destination Hex String>
5168
+ id: <Payment Hash Hex String>
5169
+ mtokens: <Total Millitokens Pending String>
5170
+ paths: [{
5171
+ fee: <Total Fee Tokens Pending Number>
5172
+ fee_mtokens: <Total Fee Millitokens Pending String>
5173
+ hops: [{
5174
+ channel: <Standard Format Channel Id String>
5175
+ channel_capacity: <Channel Capacity Tokens Number>
5176
+ fee: <Fee Tokens Rounded Down Number>
5177
+ fee_mtokens: <Fee Millitokens String>
5178
+ forward: <Forward Tokens Number>
5179
+ forward_mtokens: <Forward Millitokens String>
5180
+ public_key: <Public Key Hex String>
5181
+ timeout: <Timeout Block Height Number>
5182
+ }]
5183
+ mtokens: <Total Millitokens Pending String>
5184
+ safe_fee: <Total Fee Tokens Pending Rounded Up Number>
5185
+ safe_tokens: <Total Tokens Pending, Rounded Up Number>
5186
+ timeout: <Expiration Block Height Number>
5187
+ }]
5188
+ [request]: <BOLT 11 Encoded Payment Request String>
5189
+ safe_tokens: <Total Tokens Pending, Rounded Up Number>
5190
+ [timeout]: <Expiration Block Height Number>
5191
+ tokens: <Total Tokens Pending Rounded Down Number>
5192
+ }
5142
5193
 
5143
5194
  Example:
5144
5195
 
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "cors": "2.8.5",
12
12
  "express": "4.17.1",
13
13
  "invoices": "2.0.1",
14
- "lightning": "4.13.3",
14
+ "lightning": "4.14.1",
15
15
  "macaroon": "3.0.4",
16
16
  "morgan": "1.10.0",
17
17
  "ws": "8.2.3"
@@ -61,5 +61,5 @@
61
61
  "tower_server-integration-tests": "tap --no-coverage test/tower_serverrpc-integration/*.js",
62
62
  "wallet-integration-tests": "tap --no-coverage test/walletrpc-integration/*.js"
63
63
  },
64
- "version": "52.14.4"
64
+ "version": "52.15.0"
65
65
  }
@@ -123,6 +123,7 @@ test('Get failed payments', async ({end, equal, strictSame}) => {
123
123
  is_failed: true,
124
124
  is_pending: false,
125
125
  payment: undefined,
126
+ pending: undefined,
126
127
  },
127
128
  'Got failed state'
128
129
  );
@@ -60,7 +60,6 @@ test(`Pay private invoice`, async ({end, equal, strictSame}) => {
60
60
  to: cluster.remote,
61
61
  });
62
62
 
63
-
64
63
  await addPeer({
65
64
  lnd,
66
65
  public_key: cluster.remote.public_key,
@@ -6,6 +6,7 @@ const {createInvoice} = require('./../../');
6
6
  const {deleteForwardingReputations} = require('./../../');
7
7
  const {getHeight} = require('./../../');
8
8
  const {getInvoice} = require('./../../');
9
+ const {getPayment} = require('./../../');
9
10
  const {getWalletVersion} = require('./../../');
10
11
  const {payViaPaymentRequest} = require('./../../');
11
12
  const {subscribeToForwardRequests} = require('./../../');
@@ -15,7 +16,7 @@ const {waitForRoute} = require('./../macros');
15
16
  const tokens = 100;
16
17
 
17
18
  // Paying an invoice should settle the invoice
18
- test(`Pay via payment request`, async ({end, equal, rejects}) => {
19
+ test(`Pay via payment request`, async ({end, equal, rejects, strictSame}) => {
19
20
  const cluster = await createCluster({});
20
21
 
21
22
  const {lnd} = cluster.control;
@@ -71,6 +72,53 @@ test(`Pay via payment request`, async ({end, equal, rejects}) => {
71
72
  const sub = subscribeToForwardRequests({lnd: cluster.target.lnd});
72
73
 
73
74
  sub.once('forward_request', async forward => {
75
+ const {pending} = await getPayment({lnd, id: invoice.id});
76
+
77
+ equal(pending.destination, cluster.remote.public_key, 'Pending remote');
78
+ equal(!!pending.created_at, true, 'Has creation date');
79
+ equal(pending.id, invoice.id, 'Payment id is present');
80
+ equal(pending.mtokens, invoice.mtokens, 'Pending payment mtokens');
81
+
82
+ strictSame(
83
+ pending.paths,
84
+ [{
85
+ fee: 1,
86
+ fee_mtokens: '1000',
87
+ hops: [
88
+ {
89
+ channel: forward.in_channel,
90
+ channel_capacity: 1e6,
91
+ fee: 1,
92
+ fee_mtokens: '1000',
93
+ forward: 100,
94
+ forward_mtokens: '100000',
95
+ public_key: cluster.target.public_key,
96
+ timeout: 497,
97
+ },
98
+ {
99
+ channel: forward.out_channel,
100
+ channel_capacity: 1e6,
101
+ fee: 0,
102
+ fee_mtokens: '0',
103
+ forward: 100,
104
+ forward_mtokens: '100000',
105
+ public_key: cluster.remote.public_key,
106
+ timeout: 497,
107
+ },
108
+ ],
109
+ mtokens: '101000',
110
+ payment: invoice.payment,
111
+ timeout: 537,
112
+ tokens: 101,
113
+ total_mtokens: '100000',
114
+ }],
115
+ 'Paths are present'
116
+ );
117
+
118
+ equal(pending.request, invoice.request, 'Pending pay of request');
119
+ equal(pending.timeout, 537, 'Pending timeout');
120
+ equal(pending.tokens, invoice.tokens, 'Pending pay of invoice tokens');
121
+
74
122
  const info = await getHeight({lnd: cluster.target.lnd});
75
123
 
76
124
  equal(forward.cltv_delta, 40, 'Forward has CLTV delta');