lightning 4.12.2 → 4.13.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
+ ## 4.13.0
4
+
5
+ - Add `sendMessageToPeer` to send a peer to peer message to a connected peer
6
+ - Add `subscribeToPeerMessages` to listen to messages from connected peers
7
+
3
8
  ## 4.12.2
4
9
 
5
10
  - `probeForRoute`, `subscribeToProbeForRoute`, `subscribeToPayViaRoutes`,
package/README.md CHANGED
@@ -225,6 +225,8 @@ Methods exported by this library support typescript, but ln-service includes add
225
225
  Ask for a CPFP chain fee rate increase on a pending confirm UTXO.
226
226
  - [revokeAccess](https://github.com/alexbosworth/ln-service#revokeaccess): Remove the access
227
227
  privileges of a previously issued access token macaroon credential.
228
+ - [sendMessageToPeer](https://github.com/alexbosworth/ln-service#sendmessagetopeer): Send
229
+ message to a connected peer.
228
230
  - [sendToChainAddress](https://github.com/alexbosworth/ln-service#sendtochainaddress): Send
229
231
  funds on-chain to an address.
230
232
  - [sendToChainAddresses](https://github.com/alexbosworth/ln-service#sendtochainaddresses):
@@ -277,6 +279,8 @@ Methods exported by this library support typescript, but ln-service includes add
277
279
  Make an off-chain payment using a payment request and subscribe to the payment status.
278
280
  - [subscribeToPayViaRoutes](https://github.com/alexbosworth/ln-service#subscribetopayviaroutes):
279
281
  Start an off-chain payment using specific payment routes and subscribe to the payment result.
282
+ - [subscribeToPeerMessages](https://github.com/alexbosworth/ln-service#subscribetopeermessages):
283
+ Listen for incoming peer messages.
280
284
  - [subscribeToPeers](https://github.com/alexbosworth/ln-service#subscribetopeers): Listen to peer
281
285
  disconnect and connect events.
282
286
  - [subscribeToProbeForRoute](https://github.com/alexbosworth/ln-service#subscribetoprobeforroute):
package/index.js CHANGED
@@ -87,6 +87,7 @@ const {recoverFundsFromChannels} = require('./lnd_methods');
87
87
  const {removePeer} = require('./lnd_methods');
88
88
  const {requestChainFeeIncrease} = require('./lnd_methods');
89
89
  const {revokeAccess} = require('./lnd_methods');
90
+ const {sendMessageToPeer} = require('./lnd_methods');
90
91
  const {sendToChainAddress} = require('./lnd_methods');
91
92
  const {sendToChainAddresses} = require('./lnd_methods');
92
93
  const {sendToChainOutputScripts} = require('./lnd_methods');
@@ -113,6 +114,7 @@ const {subscribeToPastPayments} = require('./lnd_methods');
113
114
  const {subscribeToPayViaDetails} = require('./lnd_methods');
114
115
  const {subscribeToPayViaRequest} = require('./lnd_methods');
115
116
  const {subscribeToPayViaRoutes} = require('./lnd_methods');
117
+ const {subscribeToPeerMessages} = require('./lnd_methods');
116
118
  const {subscribeToPeers} = require('./lnd_methods');
117
119
  const {subscribeToProbeForRoute} = require('./lnd_methods');
118
120
  const {subscribeToRpcRequests} = require('./lnd_methods');
@@ -221,6 +223,7 @@ module.exports = {
221
223
  removePeer,
222
224
  requestChainFeeIncrease,
223
225
  revokeAccess,
226
+ sendMessageToPeer,
224
227
  sendToChainAddress,
225
228
  sendToChainAddresses,
226
229
  sendToChainOutputScripts,
@@ -247,6 +250,7 @@ module.exports = {
247
250
  subscribeToPayViaDetails,
248
251
  subscribeToPayViaRequest,
249
252
  subscribeToPayViaRoutes,
253
+ subscribeToPeerMessages,
250
254
  subscribeToPeers,
251
255
  subscribeToProbeForRoute,
252
256
  subscribeToRpcRequests,
@@ -32,6 +32,7 @@ export * from './pay';
32
32
  export * from './probe_for_route';
33
33
  export * from './recover_funds_from_channel';
34
34
  export * from './recover_funds_from_channels';
35
+ export * from './send_message_to_peer';
35
36
  export * from './subscribe_to_backups';
36
37
  export * from './subscribe_to_channels';
37
38
  export * from './subscribe_to_forward_requests';
@@ -42,6 +43,7 @@ export * from './subscribe_to_past_payments';
42
43
  export * from './subscribe_to_pay_via_details';
43
44
  export * from './subscribe_to_pay_via_request';
44
45
  export * from './subscribe_to_pay_via_routes';
46
+ export * from './subscribe_to_peer_messages';
45
47
  export * from './subscribe_to_probe_for_route';
46
48
  export * from './update_connected_watchtower';
47
49
  export * from './update_pathfinding_settings';
@@ -0,0 +1,28 @@
1
+ import {
2
+ AuthenticatedLightningArgs,
3
+ AuthenticatedLightningMethod,
4
+ } from '../../typescript';
5
+
6
+ export type LightningMessage = {
7
+ /** Message Hex String */
8
+ message: string;
9
+ /** To Peer Public Key Hex String */
10
+ public_key: string;
11
+ /** Message Type Number */
12
+ type?: number;
13
+ };
14
+
15
+ export type SendMessageToPeerArgs =
16
+ AuthenticatedLightningArgs<LightningMessage>;
17
+
18
+ /**
19
+ * Send a custom message to a connected peer
20
+ *
21
+ * If specified, message type is expected to be between 32768 and 65535
22
+ * Message data should not be larger than 65533 bytes
23
+ *
24
+ * Note: this method is not supported in LND versions 0.13.3 and below
25
+ *
26
+ * Requires `offchain:write` permission
27
+ */
28
+ export const sendMessageToPeer: AuthenticatedLightningMethod<SendMessageToPeerArgs>;
@@ -0,0 +1,18 @@
1
+ import {LightningMessage} from '.';
2
+ import {
3
+ AuthenticatedLightningArgs,
4
+ AuthenticatedLightningSubscription,
5
+ LightningError,
6
+ } from '../../typescript';
7
+
8
+ export type SubscribeToPeerMessagesMessageReceivedEvent =
9
+ Required<LightningMessage>;
10
+
11
+ /**
12
+ * Subscribe to incoming peer messages
13
+ *
14
+ * Requires `offchain:read` permission
15
+ *
16
+ * This method is not supported in LND 0.13.3 and below
17
+ */
18
+ export const subscribeToPeerMessages: AuthenticatedLightningSubscription;
package/package.json CHANGED
@@ -56,5 +56,5 @@
56
56
  "directory": "test/typescript"
57
57
  },
58
58
  "types": "index.d.ts",
59
- "version": "4.12.2"
59
+ "version": "4.13.0"
60
60
  }
@@ -0,0 +1,24 @@
1
+ import {expectError, expectType} from 'tsd';
2
+ import {AuthenticatedLnd} from '../../lnd_grpc';
3
+ import {sendMessageToPeer} from '../../lnd_methods';
4
+
5
+ const lnd = {} as AuthenticatedLnd;
6
+ const message = 'msg';
7
+ const public_key = 'pubkey';
8
+ const type = 2;
9
+
10
+ expectError(sendMessageToPeer());
11
+ expectError(sendMessageToPeer({}));
12
+ expectError(sendMessageToPeer({lnd}));
13
+ expectError(sendMessageToPeer({lnd, message}));
14
+ expectError(sendMessageToPeer({lnd, public_key}));
15
+
16
+ expectType<void>(await sendMessageToPeer({lnd, message, public_key}));
17
+ expectType<void>(await sendMessageToPeer({lnd, message, public_key, type}));
18
+
19
+ expectType<void>(
20
+ sendMessageToPeer({lnd, message, public_key}, (error, result) => {})
21
+ );
22
+ expectType<void>(
23
+ sendMessageToPeer({lnd, message, public_key, type}, (error, result) => {})
24
+ );
@@ -0,0 +1,11 @@
1
+ import * as events from 'events';
2
+ import {expectError, expectType} from 'tsd';
3
+ import {AuthenticatedLnd} from '../../lnd_grpc';
4
+ import {subscribeToPeerMessages} from '../../lnd_methods';
5
+
6
+ const lnd = {} as AuthenticatedLnd;
7
+
8
+ expectError(subscribeToPeerMessages());
9
+ expectError(subscribeToPeerMessages({}));
10
+
11
+ expectType<events.EventEmitter>(subscribeToPeerMessages({lnd}));