ln-service 52.15.0 → 52.16.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,10 @@
1
1
  # Versions
2
2
 
3
+ ## 52.16.0
4
+
5
+ - `subscribeToPayViaDetails`, `subscribeToPayViaRequest`: Add `paying`, and
6
+ `routing_failure` events to follow in-flight attempts and encountered routing failures
7
+
3
8
  ## 52.15.0
4
9
 
5
10
  - `getPayment`, `subscribeToPastPayment`: Add `pending` for pending payment details
package/README.md CHANGED
@@ -5360,7 +5360,61 @@ Requires `offchain:write` permission
5360
5360
  }
5361
5361
 
5362
5362
  @event 'paying'
5363
- {}
5363
+ {
5364
+ created_at: <Payment Created At ISO 8601 Date String>
5365
+ destination: <Payment Destination Hex String>
5366
+ id: <Payment Hash Hex String>
5367
+ mtokens: <Total Millitokens Pending String>
5368
+ paths: [{
5369
+ fee: <Total Fee Tokens Pending Number>
5370
+ fee_mtokens: <Total Fee Millitokens Pending String>
5371
+ hops: [{
5372
+ channel: <Standard Format Channel Id String>
5373
+ channel_capacity: <Channel Capacity Tokens Number>
5374
+ fee: <Fee Tokens Rounded Down Number>
5375
+ fee_mtokens: <Fee Millitokens String>
5376
+ forward: <Forward Tokens Number>
5377
+ forward_mtokens: <Forward Millitokens String>
5378
+ public_key: <Public Key Hex String>
5379
+ timeout: <Timeout Block Height Number>
5380
+ }]
5381
+ mtokens: <Total Millitokens Pending String>
5382
+ safe_fee: <Total Fee Tokens Pending Rounded Up Number>
5383
+ safe_tokens: <Total Tokens Pending, Rounded Up Number>
5384
+ timeout: <Expiration Block Height Number>
5385
+ }]
5386
+ safe_tokens: <Total Tokens Pending, Rounded Up Number>
5387
+ [timeout]: <Expiration Block Height Number>
5388
+ tokens: <Total Tokens Pending Rounded Down Number>
5389
+ }
5390
+
5391
+ @event 'routing_failure'
5392
+ {
5393
+ [channel]: <Standard Format Channel Id String>
5394
+ index: <Failure Index Number>
5395
+ [mtokens]: <Millitokens String>
5396
+ [public_key]: <Public Key Hex String>
5397
+ reason: <Failure Reason String>
5398
+ route: {
5399
+ fee: <Total Route Fee Tokens To Pay Number>
5400
+ fee_mtokens: <Total Route Fee Millitokens To Pay String>
5401
+ hops: [{
5402
+ channel: <Standard Format Channel Id String>
5403
+ channel_capacity: <Channel Capacity Tokens Number>
5404
+ fee: <Fee Number>
5405
+ fee_mtokens: <Fee Millitokens String>
5406
+ forward: <Forward Tokens Number>
5407
+ forward_mtokens: <Forward Millitokens String>
5408
+ public_key: <Public Key Hex String>
5409
+ timeout: <Timeout Block Height Number>
5410
+ }]
5411
+ mtokens: <Total Route Millitokens String>
5412
+ [payment]: <Payment Identifier Hex String>
5413
+ timeout: <Expiration Block Height Number>
5414
+ tokens: <Total Route Tokens Number>
5415
+ [total_mtokens]: <Total Millitokens String>
5416
+ }
5417
+ }
5364
5418
 
5365
5419
  Example:
5366
5420
 
@@ -5457,7 +5511,61 @@ Requires `offchain:write` permission
5457
5511
  }
5458
5512
 
5459
5513
  @event 'paying'
5460
- {}
5514
+ {
5515
+ created_at: <Payment Created At ISO 8601 Date String>
5516
+ destination: <Payment Destination Hex String>
5517
+ id: <Payment Hash Hex String>
5518
+ mtokens: <Total Millitokens Pending String>
5519
+ paths: [{
5520
+ fee: <Total Fee Tokens Pending Number>
5521
+ fee_mtokens: <Total Fee Millitokens Pending String>
5522
+ hops: [{
5523
+ channel: <Standard Format Channel Id String>
5524
+ channel_capacity: <Channel Capacity Tokens Number>
5525
+ fee: <Fee Tokens Rounded Down Number>
5526
+ fee_mtokens: <Fee Millitokens String>
5527
+ forward: <Forward Tokens Number>
5528
+ forward_mtokens: <Forward Millitokens String>
5529
+ public_key: <Public Key Hex String>
5530
+ timeout: <Timeout Block Height Number>
5531
+ }]
5532
+ mtokens: <Total Millitokens Pending String>
5533
+ safe_fee: <Total Fee Tokens Pending Rounded Up Number>
5534
+ safe_tokens: <Total Tokens Pending, Rounded Up Number>
5535
+ timeout: <Expiration Block Height Number>
5536
+ }]
5537
+ safe_tokens: <Total Tokens Pending, Rounded Up Number>
5538
+ [timeout]: <Expiration Block Height Number>
5539
+ tokens: <Total Tokens Pending Rounded Down Number>
5540
+ }
5541
+
5542
+ @event 'routing_failure'
5543
+ {
5544
+ [channel]: <Standard Format Channel Id String>
5545
+ index: <Failure Index Number>
5546
+ [mtokens]: <Millitokens String>
5547
+ [public_key]: <Public Key Hex String>
5548
+ reason: <Failure Reason String>
5549
+ route: {
5550
+ fee: <Total Route Fee Tokens To Pay Number>
5551
+ fee_mtokens: <Total Route Fee Millitokens To Pay String>
5552
+ hops: [{
5553
+ channel: <Standard Format Channel Id String>
5554
+ channel_capacity: <Channel Capacity Tokens Number>
5555
+ fee: <Fee Number>
5556
+ fee_mtokens: <Fee Millitokens String>
5557
+ forward: <Forward Tokens Number>
5558
+ forward_mtokens: <Forward Millitokens String>
5559
+ public_key: <Public Key Hex String>
5560
+ timeout: <Timeout Block Height Number>
5561
+ }]
5562
+ mtokens: <Total Route Millitokens String>
5563
+ [payment]: <Payment Identifier Hex String>
5564
+ timeout: <Expiration Block Height Number>
5565
+ tokens: <Total Route Tokens Number>
5566
+ [total_mtokens]: <Total Millitokens String>
5567
+ }
5568
+ }
5461
5569
 
5462
5570
  Example:
5463
5571
 
package/package.json CHANGED
@@ -10,8 +10,8 @@
10
10
  "bolt07": "1.7.4",
11
11
  "cors": "2.8.5",
12
12
  "express": "4.17.1",
13
- "invoices": "2.0.1",
14
- "lightning": "4.14.1",
13
+ "invoices": "2.0.2",
14
+ "lightning": "4.14.3",
15
15
  "macaroon": "3.0.4",
16
16
  "morgan": "1.10.0",
17
17
  "ws": "8.2.3"
@@ -23,8 +23,9 @@
23
23
  "async": "3.2.2",
24
24
  "asyncjs-util": "1.2.7",
25
25
  "bip66": "1.1.5",
26
- "bitcoinjs-lib": "5.2.0",
26
+ "bitcoinjs-lib": "6.0.0",
27
27
  "bn.js": "5.2.0",
28
+ "ecpair": "1.0.1",
28
29
  "portfinder": "1.0.28",
29
30
  "psbt": "1.1.10",
30
31
  "rimraf": "3.0.2",
@@ -61,5 +62,5 @@
61
62
  "tower_server-integration-tests": "tap --no-coverage test/tower_serverrpc-integration/*.js",
62
63
  "wallet-integration-tests": "tap --no-coverage test/walletrpc-integration/*.js"
63
64
  },
64
- "version": "52.15.0"
65
+ "version": "52.16.0"
65
66
  }
@@ -49,13 +49,15 @@ test(`Send peer message`, async ({end, equal, strictSame}) => {
49
49
  }
50
50
  });
51
51
 
52
+ const [message] = messages;
53
+
52
54
  strictSame(
53
- messages,
54
- [{
55
+ message,
56
+ {
55
57
  message: Buffer.from('message').toString('hex'),
56
58
  public_key: cluster.control.public_key,
57
59
  type: 32768,
58
- }],
60
+ },
59
61
  'Message successfully sent to peer'
60
62
  );
61
63
 
@@ -2,7 +2,7 @@ const {join} = require('path');
2
2
  const {spawn} = require('child_process');
3
3
 
4
4
  const asyncAuto = require('async/auto');
5
- const {ECPair} = require('bitcoinjs-lib');
5
+ const {ECPair} = require('ecpair');
6
6
  const openPortFinder = require('portfinder');
7
7
  const {networks} = require('bitcoinjs-lib');
8
8
  const {payments} = require('bitcoinjs-lib');
@@ -2,7 +2,7 @@ const {encode} = require('varuint-bitcoin');
2
2
 
3
3
  const {address} = require('bitcoinjs-lib');
4
4
  const {crypto} = require('bitcoinjs-lib');
5
- const {ECPair} = require('bitcoinjs-lib');
5
+ const {ECPair} = require('ecpair');
6
6
  const {networks} = require('bitcoinjs-lib');
7
7
  const {payments} = require('bitcoinjs-lib');
8
8
  const {script} = require('bitcoinjs-lib');
@@ -6,7 +6,7 @@ const {spawn} = require('child_process');
6
6
  const asyncAuto = require('async/auto');
7
7
  const asyncMapSeries = require('async/mapSeries');
8
8
  const asyncRetry = require('async/retry');
9
- const {ECPair} = require('bitcoinjs-lib');
9
+ const {ECPair} = require('ecpair');
10
10
  const {networks} = require('bitcoinjs-lib');
11
11
  const openPortFinder = require('portfinder');
12
12
 
@@ -2,7 +2,7 @@ const asyncAuto = require('async/auto');
2
2
  const asyncMap = require('async/map');
3
3
  const asyncTimesSeries = require('async/timesSeries');
4
4
  const asyncRetry = require('async/retry');
5
- const {ECPair} = require('bitcoinjs-lib');
5
+ const {ECPair} = require('ecpair');
6
6
  const {networks} = require('bitcoinjs-lib');
7
7
  const {payments} = require('bitcoinjs-lib');
8
8
  const {returnResult} = require('asyncjs-util');
@@ -7,7 +7,7 @@ const asyncAuto = require('async/auto');
7
7
  const asyncMap = require('async/map');
8
8
  const asyncMapSeries = require('async/mapSeries');
9
9
  const asyncRetry = require('async/retry');
10
- const {ECPair} = require('bitcoinjs-lib');
10
+ const {ECPair} = require('ecpair');
11
11
  const {networks} = require('bitcoinjs-lib');
12
12
  const openPortFinder = require('portfinder');
13
13
 
@@ -4,8 +4,6 @@ const {test} = require('@alexbosworth/tap');
4
4
  const {addPeer} = require('./../../');
5
5
  const {createCluster} = require('./../macros');
6
6
  const {createInvoice} = require('./../../');
7
- const {deleteForwardingReputations} = require('./../../');
8
- const {delay} = require('./../macros');
9
7
  const {getChannels} = require('./../../');
10
8
  const {getForwardingReputations} = require('./../../');
11
9
  const {payViaRoutes} = require('./../../');
@@ -1,3 +1,4 @@
1
+ const {once} = require('events');
1
2
  const {test} = require('@alexbosworth/tap');
2
3
 
3
4
  const {addPeer} = require('./../../');
@@ -10,6 +11,7 @@ const {getPayment} = require('./../../');
10
11
  const {getWalletVersion} = require('./../../');
11
12
  const {payViaPaymentRequest} = require('./../../');
12
13
  const {subscribeToForwardRequests} = require('./../../');
14
+ const {subscribeToPayViaRequest} = require('./../../');
13
15
  const {setupChannel} = require('./../macros');
14
16
  const {waitForRoute} = require('./../macros');
15
17
 
@@ -62,6 +64,67 @@ test(`Pay via payment request`, async ({end, equal, rejects, strictSame}) => {
62
64
  );
63
65
 
64
66
  sub.removeAllListeners();
67
+
68
+ await deleteForwardingReputations({lnd});
69
+
70
+ const sub2 = subscribeToForwardRequests({lnd: cluster.target.lnd});
71
+
72
+ sub2.on('forward_request', forward => forward.reject());
73
+
74
+ const failures = [];
75
+ const paying = [];
76
+
77
+ const pay = subscribeToPayViaRequest({lnd, request: invoice.request});
78
+
79
+ pay.on('paying', pending => paying.push(pending));
80
+ pay.on('routing_failure', failure => failures.push(failure));
81
+
82
+ await once(pay, 'failed');
83
+
84
+ strictSame(
85
+ failures,
86
+ [{
87
+ channel: channel.id,
88
+ index: 1,
89
+ mtokens: '101000',
90
+ public_key: cluster.target.public_key,
91
+ reason: 'TemporaryChannelFailure',
92
+ route: {
93
+ fee: 1,
94
+ fee_mtokens: '1000',
95
+ hops: [
96
+ {
97
+ channel: channel.id,
98
+ channel_capacity: 1e6,
99
+ fee: 1,
100
+ fee_mtokens: '1000',
101
+ forward: 100,
102
+ forward_mtokens: '100000',
103
+ public_key: cluster.target.public_key,
104
+ timeout: 497,
105
+ },
106
+ {
107
+ channel: remoteChan.id,
108
+ channel_capacity: 1e6,
109
+ fee: 0,
110
+ fee_mtokens: '0',
111
+ forward: 100,
112
+ forward_mtokens: '100000',
113
+ public_key: cluster.remote.public_key,
114
+ timeout: 497,
115
+ },
116
+ ],
117
+ mtokens: '101000',
118
+ payment: invoice.payment,
119
+ timeout: 537,
120
+ tokens: 101,
121
+ total_mtokens: '100000',
122
+ },
123
+ }],
124
+ 'Failure is emitted'
125
+ );
126
+
127
+ sub2.removeAllListeners();
65
128
  }
66
129
 
67
130
  await deleteForwardingReputations({lnd});
@@ -126,7 +189,7 @@ test(`Pay via payment request`, async ({end, equal, rejects, strictSame}) => {
126
189
  equal(forward.fee_mtokens, '1000', 'Forward has precise routing fee');
127
190
  equal(forward.hash, invoice.id, 'Forward has payment hash');
128
191
  equal(forward.in_channel, channel.id, 'Forward has inbound channel')
129
- equal(forward.in_payment, [invoice].length, 'Forward has payment index');
192
+ equal(forward.in_payment, 2, 'Forward has payment index');
130
193
  equal(forward.messages.length, [].length, 'Forward has no messages');
131
194
  equal(forward.mtokens, invoice.mtokens, 'Forward has tokens out');
132
195
  equal(forward.out_channel, remoteChan.id, 'Forward has outbound chan');