lightning 4.6.0 → 4.7.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 +9 -0
- package/lnd_methods/offchain/get_payment.d.ts +4 -0
- package/lnd_methods/offchain/get_payment.js +2 -0
- package/lnd_methods/offchain/subscribe_to_past_payment.d.ts +4 -0
- package/lnd_methods/offchain/subscribe_to_past_payment.js +2 -0
- package/lnd_methods/offchain/subscribe_to_past_payments.d.ts +4 -0
- package/lnd_methods/offchain/subscribe_to_past_payments.js +2 -0
- package/lnd_responses/confirmed_from_payment.js +9 -0
- package/package.json +1 -1
- package/test/lnd_methods/offchain/test_pay_via_payment_details.js +1 -1
- package/test/lnd_methods/offchain/test_subscribe_to_past_payments.js +2 -0
- package/test/lnd_responses/test_confirmed_from_payment.js +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
+
## 4.7.0
|
|
4
|
+
|
|
5
|
+
- `getPayment`: Add `created_at` to indicate the creation date of the payment
|
|
6
|
+
- `getPayment`: Add `request` to indicate serialized payment request
|
|
7
|
+
- `subscribeToPastPayment`: Add `created_at` to indicate the creation date of the payment
|
|
8
|
+
- `subscribeToPastPayment`: Add `request` to indicate serialized payment request
|
|
9
|
+
- `subscribeToPastPayments`: Add `created_at` to indicate the creation date of the payment
|
|
10
|
+
- `subscribeToPastPayments`: Add `request` to indicate serialized payment request
|
|
11
|
+
|
|
3
12
|
## 4.6.0
|
|
4
13
|
|
|
5
14
|
- `getPayment`: Add `destination` to indicate the destination of the payment
|
|
@@ -28,6 +28,8 @@ export type GetPaymentResult = {
|
|
|
28
28
|
payment?: {
|
|
29
29
|
/** Confirmed at ISO-8601 Date */
|
|
30
30
|
confirmed_at: string;
|
|
31
|
+
/** Created at ISO-8601 Date */
|
|
32
|
+
created_at: string;
|
|
31
33
|
/** Payment Destination Public Key Hex */
|
|
32
34
|
destination: string;
|
|
33
35
|
/** Total Fee Millitokens To Pay */
|
|
@@ -54,6 +56,8 @@ export type GetPaymentResult = {
|
|
|
54
56
|
id: string;
|
|
55
57
|
/** Total Millitokens Paid */
|
|
56
58
|
mtokens: string;
|
|
59
|
+
/** BOLT 11 Payment Request */
|
|
60
|
+
request?: string;
|
|
57
61
|
/** Payment Forwarding Fee Rounded Up Tokens */
|
|
58
62
|
safe_fee: number;
|
|
59
63
|
/** Payment Tokens Rounded Up */
|
|
@@ -30,6 +30,7 @@ const type = 'router';
|
|
|
30
30
|
[is_pending]: <Payment Is Pending Bool>
|
|
31
31
|
[payment]: {
|
|
32
32
|
confirmed_at: <Payment Confirmed At ISO 8601 Date String>
|
|
33
|
+
created_at: <Payment Created At ISO 8601 Date String>
|
|
33
34
|
destination: <Payment Destination Hex String>
|
|
34
35
|
fee: <Total Fees Paid Rounded Down Number>
|
|
35
36
|
fee_mtokens: <Total Fee Millitokens Paid String>
|
|
@@ -58,6 +59,7 @@ const type = 'router';
|
|
|
58
59
|
}]
|
|
59
60
|
mtokens: <Total Millitokens Paid String>
|
|
60
61
|
}]
|
|
62
|
+
[request]: <BOLT 11 Encoded Payment Request String>
|
|
61
63
|
safe_fee: <Payment Forwarding Fee Rounded Up Tokens Number>
|
|
62
64
|
safe_tokens: <Payment Tokens Rounded Up Number>
|
|
63
65
|
secret: <Payment Preimage Hex String>
|
|
@@ -11,6 +11,8 @@ export type SubscribeToPastPaymentArgs = AuthenticatedLightningArgs<{
|
|
|
11
11
|
export type SubscribeToPastPaymentConfirmedEvent = {
|
|
12
12
|
/** Confirmed at ISO-8601 Date */
|
|
13
13
|
confirmed: string;
|
|
14
|
+
/** Created at ISO-8601 Date */
|
|
15
|
+
created_at: string;
|
|
14
16
|
/** Payment Destination Public Key Hex */
|
|
15
17
|
destination: string;
|
|
16
18
|
/** Payment Forwarding Fee Rounded Down Tokens */
|
|
@@ -39,6 +41,8 @@ export type SubscribeToPastPaymentConfirmedEvent = {
|
|
|
39
41
|
id: string;
|
|
40
42
|
/** Total Millitokens Paid */
|
|
41
43
|
mtokens: string;
|
|
44
|
+
/** BOLT 11 Payment Request */
|
|
45
|
+
request?: string;
|
|
42
46
|
/** Payment Forwarding Fee Rounded Up Tokens */
|
|
43
47
|
safe_fee: number;
|
|
44
48
|
/** Payment Tokens Rounded Up */
|
|
@@ -41,6 +41,7 @@ const unknownServiceErr = 'unknown service verrpc.Versioner';
|
|
|
41
41
|
@event 'confirmed'
|
|
42
42
|
{
|
|
43
43
|
confirmed_at: <Payment Confirmed At ISO 8601 Date String>
|
|
44
|
+
created_at: <Payment Created At ISO 8601 Date String>
|
|
44
45
|
destination: <Payment Destination Hex String>
|
|
45
46
|
fee: <Total Fee Tokens Paid Rounded Down Number>
|
|
46
47
|
fee_mtokens: <Total Fee Millitokens Paid String>
|
|
@@ -64,6 +65,7 @@ const unknownServiceErr = 'unknown service verrpc.Versioner';
|
|
|
64
65
|
safe_tokens: <Total Tokens Paid, Rounded Up Number>
|
|
65
66
|
timeout: <Expiration Block Height Number>
|
|
66
67
|
}]
|
|
68
|
+
[request]: <BOLT 11 Encoded Payment Request String>
|
|
67
69
|
safe_fee: <Total Fee Tokens Paid Rounded Up Number>
|
|
68
70
|
safe_tokens: <Total Tokens Paid, Rounded Up Number>
|
|
69
71
|
secret: <Payment Preimage Hex String>
|
|
@@ -12,6 +12,8 @@ export type SubscribeToPastPaymentsErrorEvent = LightningError;
|
|
|
12
12
|
export type SubscribeToPastPaymentsPaymentEvent = {
|
|
13
13
|
/** Payment Confirmed At ISO 8601 Date String */
|
|
14
14
|
confirmed_at: string;
|
|
15
|
+
/** Created at ISO-8601 Date */
|
|
16
|
+
created_at: string;
|
|
15
17
|
/** Payment Destination Public Key Hex */
|
|
16
18
|
destination: string;
|
|
17
19
|
/** Paid Routing Fee Rounded Down Tokens Number */
|
|
@@ -48,6 +50,8 @@ export type SubscribeToPastPaymentsPaymentEvent = {
|
|
|
48
50
|
mtokens: string;
|
|
49
51
|
}
|
|
50
52
|
];
|
|
53
|
+
/** BOLT 11 Payment Request */
|
|
54
|
+
request?: string;
|
|
51
55
|
/** Total Fee Tokens Paid Rounded Up Number */
|
|
52
56
|
safe_fee: number;
|
|
53
57
|
/** Total Tokens Paid, Rounded Up Number */
|
|
@@ -41,6 +41,7 @@ const unknownFailureMessage = '2 UNKNOWN: unknown failure detail type: <nil>';
|
|
|
41
41
|
@event 'payment'
|
|
42
42
|
{
|
|
43
43
|
confirmed_at: <Payment Confirmed At ISO 8601 Date String>
|
|
44
|
+
created_at: <Payment Created At ISO 8601 Date String>
|
|
44
45
|
destination: <Payment Destination Hex String>
|
|
45
46
|
fee: <Paid Routing Fee Rounded Down Tokens Number>
|
|
46
47
|
fee_mtokens: <Paid Routing Fee in Millitokens String>
|
|
@@ -59,6 +60,7 @@ const unknownFailureMessage = '2 UNKNOWN: unknown failure detail type: <nil>';
|
|
|
59
60
|
}]
|
|
60
61
|
mtokens: <Total Millitokens Paid String>
|
|
61
62
|
}]
|
|
63
|
+
[request]: <BOLT 11 Encoded Payment Request String>
|
|
62
64
|
safe_fee: <Total Fee Tokens Paid Rounded Up Number>
|
|
63
65
|
safe_tokens: <Total Tokens Paid, Rounded Up Number>
|
|
64
66
|
secret: <Payment Preimage Hex String>
|
|
@@ -6,6 +6,7 @@ const {isArray} = Array;
|
|
|
6
6
|
const is256Hex = n => !!n && /^[0-9A-F]{64}$/i.test(n);
|
|
7
7
|
const {max} = Math;
|
|
8
8
|
const mtokensAsTokens = mtokens => safeTokens({mtokens}).tokens;
|
|
9
|
+
const nsAsDate = ns => new Date(Number(BigInt(ns) / BigInt(1e6)));
|
|
9
10
|
|
|
10
11
|
/** Calculate total payment details from RPC payment HTLC elements
|
|
11
12
|
|
|
@@ -65,6 +66,7 @@ const mtokensAsTokens = mtokens => safeTokens({mtokens}).tokens;
|
|
|
65
66
|
@returns
|
|
66
67
|
{
|
|
67
68
|
confirmed_at: <Payment Confirmed At ISO 8601 Date String>
|
|
69
|
+
created_at: <Payment Created At ISO 8601 Date String>
|
|
68
70
|
destination: <Payment Destination Public Key Hex String>
|
|
69
71
|
fee: <Total Fee Tokens Paid Rounded Down Number>
|
|
70
72
|
fee_mtokens: <Total Fee Millitokens Paid String>
|
|
@@ -98,6 +100,7 @@ const mtokensAsTokens = mtokens => safeTokens({mtokens}).tokens;
|
|
|
98
100
|
safe_tokens: <Total Tokens Paid, Rounded Up Number>
|
|
99
101
|
timeout: <Expiration Block Height Number>
|
|
100
102
|
}]
|
|
103
|
+
[request]: <BOLT 11 Encoded Payment Request String>
|
|
101
104
|
safe_fee: <Total Fee Tokens Paid Rounded Up Number>
|
|
102
105
|
safe_tokens: <Total Tokens Paid, Rounded Up Number>
|
|
103
106
|
secret: <Payment Preimage Hex String>
|
|
@@ -110,6 +113,10 @@ module.exports = payment => {
|
|
|
110
113
|
throw new Error('ExpectedConfirmedPaymentToDeriveConfirmationDetails');
|
|
111
114
|
}
|
|
112
115
|
|
|
116
|
+
if (!payment.creation_time_ns) {
|
|
117
|
+
throw new Error('ExpectedPaymentCreationDateToDerivePaymentDetails');
|
|
118
|
+
}
|
|
119
|
+
|
|
113
120
|
if (!payment.fee_msat) {
|
|
114
121
|
throw new Error('ExpectedPaymentFeeMillitokensAmountForPayment');
|
|
115
122
|
}
|
|
@@ -147,12 +154,14 @@ module.exports = payment => {
|
|
|
147
154
|
return {
|
|
148
155
|
destination,
|
|
149
156
|
confirmed_at: confirmedAt,
|
|
157
|
+
created_at: nsAsDate(payment.creation_time_ns).toISOString(),
|
|
150
158
|
fee: safeTokens({mtokens: payment.fee_msat}).tokens,
|
|
151
159
|
fee_mtokens: payment.fee_msat,
|
|
152
160
|
hops: success.route.hops,
|
|
153
161
|
id: payment.payment_hash,
|
|
154
162
|
mtokens: mtokens.toString(),
|
|
155
163
|
paths: successes.map(n => n.route),
|
|
164
|
+
request: payment.payment_request || undefined,
|
|
156
165
|
safe_fee: safeTokens({mtokens: payment.fee_msat}).safe,
|
|
157
166
|
safe_tokens: safeTokens({mtokens: mtokens.toString()}).safe,
|
|
158
167
|
secret: payment.payment_preimage,
|
package/package.json
CHANGED
|
@@ -306,7 +306,7 @@ const tests = [
|
|
|
306
306
|
{
|
|
307
307
|
args: makeArgs({lnd: makeLnd({data: {status: 'SUCCEEDED'}})}),
|
|
308
308
|
description: 'A payment attempt is in flight',
|
|
309
|
-
error: [503, '
|
|
309
|
+
error: [503, 'ExpectedPaymentCreationDateToDerivePaymentDetails'],
|
|
310
310
|
},
|
|
311
311
|
];
|
|
312
312
|
|
|
@@ -204,6 +204,7 @@ const tests = [
|
|
|
204
204
|
description: 'A past payment is emitted',
|
|
205
205
|
expected: {
|
|
206
206
|
confirmed_at: '1970-01-01T00:00:00.000Z',
|
|
207
|
+
created_at: '1970-01-01T00:00:00.000Z',
|
|
207
208
|
destination: '000000000000000000000000000000000000000000000000000000000000000000',
|
|
208
209
|
fee: 1,
|
|
209
210
|
fee_mtokens: '1000',
|
|
@@ -244,6 +245,7 @@ const tests = [
|
|
|
244
245
|
total_mtokens: '1000',
|
|
245
246
|
}
|
|
246
247
|
],
|
|
248
|
+
request: undefined,
|
|
247
249
|
safe_fee: 1,
|
|
248
250
|
safe_tokens: 2,
|
|
249
251
|
secret: '0000000000000000000000000000000000000000000000000000000000000000',
|
|
@@ -54,6 +54,7 @@ const makeArgs = overrides => {
|
|
|
54
54
|
const makeExpected = overrides => {
|
|
55
55
|
const expected = {
|
|
56
56
|
confirmed_at: '1970-01-01T00:00:00.000Z',
|
|
57
|
+
created_at: '1970-01-01T00:00:00.000Z',
|
|
57
58
|
destination: Buffer.alloc(33).toString('hex'),
|
|
58
59
|
fee: 1,
|
|
59
60
|
fee_mtokens: '1000',
|
|
@@ -88,6 +89,7 @@ const makeExpected = overrides => {
|
|
|
88
89
|
tokens: 1,
|
|
89
90
|
total_mtokens: '1000',
|
|
90
91
|
}],
|
|
92
|
+
request: undefined,
|
|
91
93
|
safe_fee: 1,
|
|
92
94
|
safe_tokens: 2,
|
|
93
95
|
secret: Buffer.alloc(32).toString('hex'),
|