lightning 5.4.1 → 5.6.1

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,6 +1,14 @@
1
1
  # Versions
2
2
 
3
- ## 5.4.1
3
+ ## 5.6.1
4
+
5
+ - `payViaRoutes`, `subscribeToPayViaRoutes`: Add support for relay messages
6
+
7
+ ## 5.5.0
8
+
9
+ - `partiallySignPsbt`: Add method to partially sign a PSBT
10
+
11
+ ## 5.4.2
4
12
 
5
13
  - `deletePendingChannel`: Add method to delete a stuck pending channel
6
14
  - `getInvoices`: Fill in type definition for `is_unconfirmed`
package/README.md CHANGED
@@ -206,8 +206,10 @@ To access unauthenticated methods like the wallet unlocker, use
206
206
  chosen to be spent.
207
207
  - [openChannel](https://github.com/alexbosworth/ln-service#openchannel): Create a new channel
208
208
  to another node.
209
- - [openChannels](https://github.com/alexbosworth/ln-service#openchannels): Open multiple
210
- channels in a single on-chain transaction batch.
209
+ - [openChannels](https://github.com/alexbosworth/ln-service#openchannels): Open
210
+ multiple channels in a single on-chain transaction batch.
211
+ - [partiallySignPsbt](https://github.com/alexbosworth/ln-service#partiallysignpsbt):
212
+ Add a partial signature to a PSBT
211
213
  - [pay](https://github.com/alexbosworth/ln-service#pay): Make an off-chain payment.
212
214
  - [payViaPaymentDetails](https://github.com/alexbosworth/ln-service#payviapaymentdetails): Pay
213
215
  off-chain using details about a destination invoice.
@@ -3751,6 +3751,9 @@ message PolicyUpdateRequest {
3751
3751
  // goes up to 6 decimal places, so 1e-6.
3752
3752
  double fee_rate = 4;
3753
3753
 
3754
+ // The effective fee rate in micro-satoshis (parts per million).
3755
+ uint32 fee_rate_ppm = 9;
3756
+
3754
3757
  // The required timelock delta for HTLCs forwarded over the channel.
3755
3758
  uint32 time_lock_delta = 5;
3756
3759
 
@@ -20,6 +20,7 @@
20
20
  "versions": {
21
21
  "0d5b0fefa4d9082f7964836f5e58c3a6bda8e471": "0.10.2-beta",
22
22
  "1a3194d302f33bb52823297d9d7f75cd37516053": "0.10.0-beta",
23
+ "1e511be523eb8e97c4e2d9c89a7a263963a3929f": "0.14.2-beta",
23
24
  "3ae46d81f4a2edad06ef778b2940d9b06386d93b": "0.11.0-beta",
24
25
  "4f567577db9d85b6f392f960b3aabddcad3cd02c": "0.13.3-beta",
25
26
  "52bb3f33707b81972c67937c7a89addcdf00991c": "0.10.1-beta",
@@ -293,6 +293,10 @@
293
293
  "method": "OpenChannel",
294
294
  "type": "default"
295
295
  },
296
+ "partiallySignPsbt": {
297
+ "method": "SignPsbt",
298
+ "type": "wallet"
299
+ },
296
300
  "payViaPaymentDetails": {
297
301
  "depends_on": ["subscribeToPayViaDetails"]
298
302
  },
@@ -27,6 +27,12 @@ export type PayViaRoutesArgs = AuthenticatedLightningArgs<{
27
27
  forward: number;
28
28
  /** Forward Millitokens */
29
29
  forward_mtokens: string;
30
+ messages?: {
31
+ /** Message Type number */
32
+ type: string;
33
+ /** Message Raw Value Hex Encoded */
34
+ value: string;
35
+ }[];
30
36
  /** Public Key Hex */
31
37
  public_key?: string;
32
38
  /** Timeout Block Height */
@@ -29,6 +29,10 @@ const notFound = -1;
29
29
  fee_mtokens: <Fee Millitokens String>
30
30
  forward: <Forward Tokens Number>
31
31
  forward_mtokens: <Forward Millitokens String>
32
+ [messages]: [{
33
+ type: <Message Type Number String>
34
+ value: <Message Raw Value Hex Encoded String>
35
+ }]
32
36
  [public_key]: <Public Key Hex String>
33
37
  timeout: <Timeout Block Height Number>
34
38
  }]
@@ -43,6 +43,10 @@ const unknownWireError = 'unknown wire error';
43
43
  fee_mtokens: <Fee Millitokens String>
44
44
  forward: <Forward Tokens Number>
45
45
  forward_mtokens: <Forward Millitokens String>
46
+ [messages]: [{
47
+ type: <Message Type Number String>
48
+ value: <Message Raw Value Hex Encoded String>
49
+ }]
46
50
  public_key: <Public Key Hex String>
47
51
  timeout: <Timeout Block Height Number>
48
52
  }]
@@ -14,6 +14,7 @@ export * from './get_utxos';
14
14
  export * from './lock_utxo';
15
15
  export * from './open_channel';
16
16
  export * from './open_channels';
17
+ export * from './partially_sign_psbt';
17
18
  export * from './prepare_for_channel_proposal';
18
19
  export * from './propose_channel';
19
20
  export * from './request_chain_fee_increase';
@@ -0,0 +1,28 @@
1
+ import {
2
+ AuthenticatedLightningArgs,
3
+ AuthenticatedLightningMethod,
4
+ } from '../../typescript';
5
+
6
+ export type PartiallySignPsbtArgs = AuthenticatedLightningArgs<{
7
+ /** Funded PSBT Hex String */
8
+ psbt: string;
9
+ }>;
10
+
11
+ export type PartiallySignPsbtResult = {
12
+ /** Partially Signed PSBT Hex String */
13
+ psbt: string;
14
+ };
15
+
16
+ /**
17
+ * Sign a PSBT to produce a partially signed PSBT
18
+ *
19
+ * Requires `onchain:write` permission
20
+ *
21
+ * Requires LND built with `walletrpc` tag
22
+ *
23
+ * This method is not supported in LND 0.14.2 and below
24
+ */
25
+ export const partiallySignPsbt: AuthenticatedLightningMethod<
26
+ PartiallySignPsbtArgs,
27
+ PartiallySignPsbtResult
28
+ >;
@@ -16,7 +16,7 @@ const type = 'wallet';
16
16
 
17
17
  Requires LND built with `walletrpc` tag
18
18
 
19
- This method is not supported in LND 0.14.1 and below
19
+ This method is not supported in LND 0.14.2 and below
20
20
 
21
21
  {
22
22
  lnd: <Authenticated LND API Object>
@@ -22,7 +22,7 @@ export type GetPeersResult = {
22
22
  /** Is Syncing Graph Data */
23
23
  is_sync_peer?: boolean;
24
24
  /** Peer Last Reconnected At ISO 8601 Date */
25
- last_reconnected?: string;
25
+ last_reconnection?: string;
26
26
  /** Ping Latency Milliseconds */
27
27
  ping_time: number;
28
28
  /** Node Identity Public Key */
@@ -31,7 +31,7 @@ const type = 'default';
31
31
  }]
32
32
  is_inbound: <Is Inbound Peer Bool>
33
33
  [is_sync_peer]: <Is Syncing Graph Data Bool>
34
- [last_reconnected]: <Peer Last Reconnected At ISO 8601 Date String>
34
+ [last_reconnection]: <Peer Last Reconnected At ISO 8601 Date String>
35
35
  ping_time: <Ping Latency Milliseconds Number>
36
36
  public_key: <Node Identity Public Key String>
37
37
  [reconnection_rate]: <Count of Reconnections Over Time Number>
@@ -12,9 +12,17 @@ export type CreateWalletArgs = UnauthenticatedLightningArgs<{
12
12
  seed: string;
13
13
  }>;
14
14
 
15
+ export type CreateWalletResult = {
16
+ /** Base64 Encoded Admin Macaroon String */
17
+ macaroon: string;
18
+ };
19
+
15
20
  /**
16
21
  * Create a wallet
17
22
  *
18
23
  * Requires unlocked lnd and unauthenticated LND
19
24
  */
20
- export const createWallet: UnauthenticatedLightningMethod<CreateWalletArgs>;
25
+ export const createWallet: UnauthenticatedLightningMethod<
26
+ CreateWalletArgs,
27
+ CreateWalletResult
28
+ >;
@@ -1,5 +1,6 @@
1
1
  const {chanNumber} = require('bolt07');
2
2
 
3
+ const hexAsBuffer = hex => Buffer.from(hex, 'hex');
3
4
  const isNumber = n => !isNaN(n);
4
5
  const millitokensAsTokens = n => Number(BigInt(n) / BigInt(1e3));
5
6
 
@@ -12,6 +13,10 @@ const millitokensAsTokens = n => Number(BigInt(n) / BigInt(1e3));
12
13
  fee_mtokens: <Fee Millitokens String>
13
14
  forward: <Forward Tokens Number>
14
15
  forward_mtokens: <Forward Millitokens String>
16
+ [messages]: [{
17
+ type: <Message Type Number String>
18
+ value: <Message Raw Value Hex Encoded String>
19
+ }]
15
20
  [public_key]: <Forward Edge Public Key Hex String>
16
21
  timeout: <Timeout Block Height Number>
17
22
  }
@@ -25,10 +30,12 @@ const millitokensAsTokens = n => Number(BigInt(n) / BigInt(1e3));
25
30
  amt_to_forward_msat: <Millitokens to Forward String>
26
31
  chan_id: <Numeric Format Channel Id String>
27
32
  chan_capacity: <Channel Capacity Number>
33
+ [custom_records]: {<TLV Type Number String>: <TLV Value Buffer Object>}
28
34
  expiry: <Timeout Chain Height Number>
29
35
  fee: <Fee in Tokens Number>
30
36
  fee_msat: <Fee in Millitokens String>
31
37
  [pub_key]: <Next Hop Public Key Hex String>
38
+ [tlv_payload]: <Has Extra TLV Data Bool>
32
39
  }
33
40
  */
34
41
  module.exports = args => {
@@ -44,7 +51,7 @@ module.exports = args => {
44
51
  throw new Error('ExpectedFeeMillitokensToMapRpcHopFromHop');
45
52
  }
46
53
 
47
- return {
54
+ const hop = {
48
55
  amt_to_forward: millitokensAsTokens(args.forward_mtokens).toString(),
49
56
  amt_to_forward_msat: args.forward_mtokens,
50
57
  chan_id: chanNumber({channel: args.channel}).number,
@@ -54,4 +61,21 @@ module.exports = args => {
54
61
  fee_msat: args.fee_mtokens,
55
62
  pub_key: args.public_key,
56
63
  };
64
+
65
+ // Exit early when there are no messages to encode in this hop
66
+ if (!args.messages || !args.messages.length) {
67
+ return hop;
68
+ }
69
+
70
+ // Set custom TLV payload records for this hop
71
+ hop.tlv_payload = true;
72
+
73
+ hop.custom_records = args.messages.reduce((tlv, n) => {
74
+ tlv[n.type] = hexAsBuffer(n.value);
75
+
76
+ return tlv;
77
+ },
78
+ {});
79
+
80
+ return hop;
57
81
  };
@@ -14,6 +14,10 @@ const isNumber = n => !isNaN(n);
14
14
  fee_mtokens: <Fee Millitokens String>
15
15
  forward: <Forward Tokens Number>
16
16
  forward_mtokens: <Forward Millitokens String>
17
+ [messages]: [{
18
+ type: <Message Type Number String>
19
+ value: <Message Raw Value Hex Encoded String>
20
+ }]
17
21
  [public_key]: <Forward Edge Public Key Hex String>
18
22
  timeout: <Timeout Block Height Number>
19
23
  }]
@@ -38,6 +42,7 @@ const isNumber = n => !isNaN(n);
38
42
  amt_to_forward_msat: <Millitokens to Forward String>
39
43
  chan_id: <Numeric Format Channel Id String>
40
44
  chan_capacity: <Channel Capacity Number>
45
+ [custom_records]: {<TLV Type Number String>: <TLV Value Buffer Object>}
41
46
  expiry: <Timeout Chain Height Number>
42
47
  fee: <Fee in Tokens Number>
43
48
  fee_msat: <Fee in Millitokens Number>
@@ -79,7 +84,7 @@ module.exports = args => {
79
84
  };
80
85
  }
81
86
 
82
- // Set custom TLV payload records
87
+ // Set custom TLV payload records on the final hop
83
88
  if (!!args.messages && !!args.messages.length) {
84
89
  hops[finalHopIndex].tlv_payload = true;
85
90
 
@@ -88,7 +93,7 @@ module.exports = args => {
88
93
 
89
94
  return tlv;
90
95
  },
91
- {});
96
+ hops[finalHopIndex].custom_records || {});
92
97
  }
93
98
 
94
99
  return {
@@ -49,7 +49,7 @@ const microPerMilli = 1e3;
49
49
  }]
50
50
  is_inbound: <Is Inbound Peer Bool>
51
51
  [is_sync_peer]: <Is Syncing Graph Data Bool>
52
- [last_reconnected]: <Peer Last Reconnected At ISO 8601 Date String>
52
+ [last_reconnection]: <Peer Last Reconnected At ISO 8601 Date String>
53
53
  ping_time: <Milliseconds Number>
54
54
  public_key: <Public Key String>
55
55
  [reconnection_rate]: <Count of Reconnections Over Time Number>
package/package.json CHANGED
@@ -7,10 +7,10 @@
7
7
  "url": "https://github.com/alexbosworth/lightning/issues"
8
8
  },
9
9
  "dependencies": {
10
- "@grpc/grpc-js": "1.5.3",
10
+ "@grpc/grpc-js": "1.5.4",
11
11
  "@grpc/proto-loader": "0.6.9",
12
12
  "@types/express": "4.17.13",
13
- "@types/node": "17.0.12",
13
+ "@types/node": "17.0.14",
14
14
  "@types/request": "2.48.8",
15
15
  "@types/ws": "8.2.2",
16
16
  "async": "3.2.3",
@@ -24,7 +24,7 @@
24
24
  "express": "4.17.2",
25
25
  "invoices": "2.0.3",
26
26
  "psbt": "1.1.11",
27
- "type-fest": "2.10.0"
27
+ "type-fest": "2.11.1"
28
28
  },
29
29
  "description": "Lightning Network client library",
30
30
  "devDependencies": {
@@ -57,5 +57,5 @@
57
57
  "directory": "test/typescript"
58
58
  },
59
59
  "types": "index.d.ts",
60
- "version": "5.4.1"
60
+ "version": "5.6.1"
61
61
  }
@@ -41,6 +41,32 @@ const tests = [
41
41
  pub_key: 'public_key',
42
42
  },
43
43
  },
44
+ {
45
+ args: {
46
+ channel: '0x0x1',
47
+ channel_capacity: 1,
48
+ fee: 1,
49
+ fee_mtokens: '1000',
50
+ forward: '1',
51
+ forward_mtokens: '1000',
52
+ messages: [{type: '12', value: '34'}],
53
+ public_key: 'public_key',
54
+ timeout: 1,
55
+ },
56
+ description: 'Hop is mapped to RPC hop',
57
+ expected: {
58
+ amt_to_forward: '1',
59
+ amt_to_forward_msat: '1000',
60
+ chan_id: '1',
61
+ chan_capacity: '1',
62
+ custom_records: {'12': Buffer.from('34', 'hex')},
63
+ expiry: 1,
64
+ fee: '1',
65
+ fee_msat: '1000',
66
+ pub_key: 'public_key',
67
+ tlv_payload: true,
68
+ },
69
+ },
44
70
  ];
45
71
 
46
72
  tests.forEach(({args, description, error, expected}) => {
@@ -1,6 +1,6 @@
1
1
  import {expectError, expectType} from 'tsd';
2
2
  import {UnauthenticatedLnd} from '../../lnd_grpc';
3
- import {createWallet} from '../../lnd_methods';
3
+ import {createWallet, CreateWalletResult} from '../../lnd_methods';
4
4
 
5
5
  const lnd = {} as UnauthenticatedLnd;
6
6
 
@@ -20,8 +20,14 @@ expectError(createWallet({lnd, seed}));
20
20
  expectError(createWallet({lnd, passphrase, password}));
21
21
  expectError(createWallet({lnd, passphrase, seed}));
22
22
 
23
- expectType<void>(await createWallet({lnd, password, seed}));
24
- expectType<void>(await createWallet({lnd, passphrase, password, seed}));
23
+ expectType<CreateWalletResult>(await createWallet({lnd, password, seed}));
24
+ expectType<CreateWalletResult>(
25
+ await createWallet({lnd, passphrase, password, seed})
26
+ );
25
27
 
26
- expectType<void>(createWallet({lnd, password, seed}, () => {}));
27
- expectType<void>(createWallet({lnd, passphrase, password, seed}, () => {}));
28
+ createWallet({lnd, password, seed}, (err, res) => {
29
+ expectType<CreateWalletResult>(res);
30
+ });
31
+ createWallet({lnd, passphrase, password, seed}, (err, res) => {
32
+ expectType<CreateWalletResult>(res);
33
+ });
@@ -0,0 +1,18 @@
1
+ import {expectError, expectType} from 'tsd';
2
+ import {AuthenticatedLnd} from '../../lnd_grpc';
3
+ import {partiallySignPsbt, PartiallySignPsbtResult} from '../../lnd_methods';
4
+
5
+ const lnd = {} as AuthenticatedLnd;
6
+ const psbt = 'psbt';
7
+
8
+ expectError(partiallySignPsbt());
9
+ expectError(partiallySignPsbt({}));
10
+ expectError(partiallySignPsbt({lnd}));
11
+
12
+ expectType<PartiallySignPsbtResult>(await partiallySignPsbt({lnd, psbt}));
13
+
14
+ expectType<void>(
15
+ partiallySignPsbt({lnd, psbt}, (error, result) => {
16
+ expectType<PartiallySignPsbtResult>(result);
17
+ })
18
+ );