lightning 7.0.4 → 7.0.6

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,6 @@
1
1
  # Versions
2
2
 
3
- ## 7.0.4
3
+ ## 7.0.6
4
4
 
5
5
  - `getChainAddresses`: Add method to get the list of chain addresses
6
6
 
package/README.md CHANGED
@@ -8,6 +8,8 @@ Methods for working with the Lightning Network
8
8
 
9
9
  - [bitpay.com crypto-rpc](https://bitpay.com/) -
10
10
  https://github.com/bitpay/crypto-rpc
11
+ - [channel.ninja](https://channel.ninja/) -
12
+ https://github.com/channelninja/channel.ninja
11
13
  - [coinos.io](https://coinos.io/) - https://github.com/coinos/coinos-server
12
14
  - [Galoy](https://galoy.io/) - https://github.com/GaloyMoney/galoy
13
15
  - [Lightning Poker](https://lightning-poker.com/) -
@@ -18,8 +20,8 @@ Methods for working with the Lightning Network
18
20
  https://github.com/ibz/lightning-shell
19
21
  - [LNMarkets](https://twitter.com/lnmarkets) -
20
22
  https://github.com/lnmarkets/umbrel
21
- - [LNPingBot](https://github.com/swissrouting/lnpingbot) - https://github.com/swissrouting/lnpingbot
22
- - [mempool.space](https://mempool.space/) - https://github.com/mempool/mempool
23
+ - [LNPingBot](https://github.com/swissrouting/lnpingbot) -
24
+ https://github.com/swissrouting/lnpingbot
23
25
  - [p2plnbot](https://telegram.me/lnp2pbot) - https://github.com/grunch/p2plnbot
24
26
  - [rekr](https://rekr.app/) - https://github.com/ryan-lingle/rekr
25
27
  - [stackernews](https://stacker.news/) -
@@ -567,6 +567,10 @@ service Lightning {
567
567
  /* lncli: `subscribecustom`
568
568
  SubscribeCustomMessages subscribes to a stream of incoming custom peer
569
569
  messages.
570
+
571
+ To include messages with type outside of the custom range (>= 32768) lnd
572
+ needs to be compiled with the `dev` build tag, and the message type to
573
+ override should be specified in lnd's experimental protocol configuration.
570
574
  */
571
575
  rpc SubscribeCustomMessages (SubscribeCustomMessagesRequest)
572
576
  returns (stream CustomMessage);
@@ -612,6 +616,9 @@ message SendCustomMessageRequest {
612
616
  bytes peer = 1;
613
617
 
614
618
  // Message type. This value needs to be in the custom range (>= 32768).
619
+ // To send a type < custom range, lnd needs to be compiled with the `dev`
620
+ // build tag, and the message type to override should be specified in lnd's
621
+ // experimental protocol configuration.
615
622
  uint32 type = 2;
616
623
 
617
624
  // Raw message data.
@@ -1905,6 +1912,9 @@ message GetInfoResponse {
1905
1912
  Indicates whether the HTLC interceptor API is in always-on mode.
1906
1913
  */
1907
1914
  bool require_htlc_interceptor = 21;
1915
+
1916
+ // Indicates whether final htlc resolutions are stored on disk.
1917
+ bool store_final_htlc_resolutions = 22;
1908
1918
  }
1909
1919
 
1910
1920
  message GetRecoveryInfoRequest {
@@ -3387,7 +3397,7 @@ message Invoice {
3387
3397
  */
3388
3398
  bytes description_hash = 10;
3389
3399
 
3390
- // Payment request expiry time in seconds. Default is 3600 (1 hour).
3400
+ // Payment request expiry time in seconds. Default is 86400 (24 hours).
3391
3401
  int64 expiry = 11;
3392
3402
 
3393
3403
  // Fallback on-chain address.
@@ -22,8 +22,8 @@ service Signer {
22
22
  /*
23
23
  ComputeInputScript generates a complete InputIndex for the passed
24
24
  transaction with the signature as defined within the passed SignDescriptor.
25
- This method should be capable of generating the proper input script for
26
- both regular p2wkh output and p2wkh outputs nested within a regular p2sh
25
+ This method should be capable of generating the proper input script for both
26
+ regular p2wkh/p2tr outputs and p2wkh outputs nested within a regular p2sh
27
27
  output.
28
28
 
29
29
  Note that when using this method to sign inputs belonging to the wallet,
@@ -381,6 +381,7 @@ message VerifyMessageReq {
381
381
  */
382
382
  bool is_schnorr_sig = 4;
383
383
  }
384
+
384
385
  message VerifyMessageResp {
385
386
  // Whether the signature was valid over the given message.
386
387
  bool valid = 1;
@@ -443,12 +444,33 @@ message TaprootTweakDesc {
443
444
  bool key_spend_only = 2;
444
445
  }
445
446
 
447
+ enum MuSig2Version {
448
+ /*
449
+ The default value on the RPC is zero for enums so we need to represent an
450
+ invalid/undefined version by default to make sure clients upgrade their
451
+ software to set the version explicitly.
452
+ */
453
+ MUSIG2_VERSION_UNDEFINED = 0;
454
+
455
+ /*
456
+ The version of MuSig2 that lnd 0.15.x shipped with, which corresponds to the
457
+ version v0.4.0 of the MuSig2 BIP draft.
458
+ */
459
+ MUSIG2_VERSION_V040 = 1;
460
+
461
+ /*
462
+ The current version of MuSig2 which corresponds to the version v1.0.0rc2 of
463
+ the MuSig2 BIP draft.
464
+ */
465
+ MUSIG2_VERSION_V100RC2 = 2;
466
+ }
467
+
446
468
  message MuSig2CombineKeysRequest {
447
469
  /*
448
- A list of all public keys (serialized in 32-byte x-only format!)
449
- participating in the signing session. The list will always be sorted
450
- lexicographically internally. This must include the local key which is
451
- described by the above key_loc.
470
+ A list of all public keys (serialized in 32-byte x-only format for v0.4.0
471
+ and 33-byte compressed format for v1.0.0rc2!) participating in the signing
472
+ session. The list will always be sorted lexicographically internally. This
473
+ must include the local key which is described by the above key_loc.
452
474
  */
453
475
  repeated bytes all_signer_pubkeys = 1;
454
476
 
@@ -464,6 +486,14 @@ message MuSig2CombineKeysRequest {
464
486
  on-chain.
465
487
  */
466
488
  TaprootTweakDesc taproot_tweak = 3;
489
+
490
+ /*
491
+ The mandatory version of the MuSig2 BIP draft to use. This is necessary to
492
+ differentiate between the changes that were made to the BIP while this
493
+ experimental RPC was already released. Some of those changes affect how the
494
+ combined key and nonces are created.
495
+ */
496
+ MuSig2Version version = 4;
467
497
  }
468
498
 
469
499
  message MuSig2CombineKeysResponse {
@@ -481,6 +511,11 @@ message MuSig2CombineKeysResponse {
481
511
  is used.
482
512
  */
483
513
  bytes taproot_internal_key = 2;
514
+
515
+ /*
516
+ The version of the MuSig2 BIP that was used to combine the keys.
517
+ */
518
+ MuSig2Version version = 4;
484
519
  }
485
520
 
486
521
  message MuSig2SessionRequest {
@@ -490,10 +525,10 @@ message MuSig2SessionRequest {
490
525
  KeyLocator key_loc = 1;
491
526
 
492
527
  /*
493
- A list of all public keys (serialized in 32-byte x-only format!)
494
- participating in the signing session. The list will always be sorted
495
- lexicographically internally. This must include the local key which is
496
- described by the above key_loc.
528
+ A list of all public keys (serialized in 32-byte x-only format for v0.4.0
529
+ and 33-byte compressed format for v1.0.0rc2!) participating in the signing
530
+ session. The list will always be sorted lexicographically internally. This
531
+ must include the local key which is described by the above key_loc.
497
532
  */
498
533
  repeated bytes all_signer_pubkeys = 2;
499
534
 
@@ -515,6 +550,14 @@ message MuSig2SessionRequest {
515
550
  on-chain.
516
551
  */
517
552
  TaprootTweakDesc taproot_tweak = 5;
553
+
554
+ /*
555
+ The mandatory version of the MuSig2 BIP draft to use. This is necessary to
556
+ differentiate between the changes that were made to the BIP while this
557
+ experimental RPC was already released. Some of those changes affect how the
558
+ combined key and nonces are created.
559
+ */
560
+ MuSig2Version version = 6;
518
561
  }
519
562
 
520
563
  message MuSig2SessionResponse {
@@ -552,6 +595,11 @@ message MuSig2SessionResponse {
552
595
  now.
553
596
  */
554
597
  bool have_all_nonces = 5;
598
+
599
+ /*
600
+ The version of the MuSig2 BIP that was used to create the session.
601
+ */
602
+ MuSig2Version version = 6;
555
603
  }
556
604
 
557
605
  message MuSig2RegisterNoncesRequest {
@@ -79,6 +79,47 @@ service WalletKit {
79
79
  */
80
80
  rpc ListAddresses (ListAddressesRequest) returns (ListAddressesResponse);
81
81
 
82
+ /*
83
+ SignMessageWithAddr returns the compact signature (base64 encoded) created
84
+ with the private key of the provided address. This requires the address
85
+ to be solely based on a public key lock (no scripts). Obviously the internal
86
+ lnd wallet has to possess the private key of the address otherwise
87
+ an error is returned.
88
+
89
+ This method aims to provide full compatibility with the bitcoin-core and
90
+ btcd implementation. Bitcoin-core's algorithm is not specified in a
91
+ BIP and only applicable for legacy addresses. This method enhances the
92
+ signing for additional address types: P2WKH, NP2WKH, P2TR.
93
+ For P2TR addresses this represents a special case. ECDSA is used to create
94
+ a compact signature which makes the public key of the signature recoverable.
95
+ */
96
+ rpc SignMessageWithAddr (SignMessageWithAddrRequest)
97
+ returns (SignMessageWithAddrResponse);
98
+
99
+ /*
100
+ VerifyMessageWithAddr returns the validity and the recovered public key of
101
+ the provided compact signature (base64 encoded). The verification is
102
+ twofold. First the validity of the signature itself is checked and then
103
+ it is verified that the recovered public key of the signature equals
104
+ the public key of the provided address. There is no dependence on the
105
+ private key of the address therefore also external addresses are allowed
106
+ to verify signatures.
107
+ Supported address types are P2PKH, P2WKH, NP2WKH, P2TR.
108
+
109
+ This method is the counterpart of the related signing method
110
+ (SignMessageWithAddr) and aims to provide full compatibility to
111
+ bitcoin-core's implementation. Although bitcoin-core/btcd only provide
112
+ this functionality for legacy addresses this function enhances it to
113
+ the address types: P2PKH, P2WKH, NP2WKH, P2TR.
114
+
115
+ The verification for P2TR addresses is a special case and requires the
116
+ ECDSA compact signature to compare the reovered public key to the internal
117
+ taproot key. The compact ECDSA signature format was used because there
118
+ are still no known compact signature schemes for schnorr signatures.
119
+ */
120
+ rpc VerifyMessageWithAddr (VerifyMessageWithAddrRequest)
121
+ returns (VerifyMessageWithAddrResponse);
122
+
82
123
  /*
83
124
  ImportAccount imports an account backed by an account extended public key.
84
125
  The master key fingerprint denotes the fingerprint of the root key
@@ -497,6 +538,43 @@ message ListAddressesResponse {
497
538
  repeated AccountWithAddresses account_with_addresses = 1;
498
539
  }
499
540
 
541
+ message SignMessageWithAddrRequest {
542
+ // The message to be signed. When using REST, this field must be encoded as
543
+ // base64.
544
+ bytes msg = 1;
545
+
546
+ // The address which will be used to look up the private key and sign the
547
+ // corresponding message.
548
+ string addr = 2;
549
+ }
550
+
551
+ message SignMessageWithAddrResponse {
552
+ // The compact ECDSA signature for the given message encoded in base64.
553
+ string signature = 1;
554
+ }
555
+
556
+ message VerifyMessageWithAddrRequest {
557
+ // The message to be signed. When using REST, this field must be encoded as
558
+ // base64.
559
+ bytes msg = 1;
560
+
561
+ // The compact ECDSA signature to be verified over the given message
562
+ // ecoded in base64.
563
+ string signature = 2;
564
+
565
+ // The address which will be used to look up the public key and verify the
566
+ // the signature.
567
+ string addr = 3;
568
+ }
569
+
570
+ message VerifyMessageWithAddrResponse {
571
+ // Whether the signature was valid over the given message.
572
+ bool valid = 1;
573
+
574
+ // The pubkey recovered from the signature.
575
+ bytes pubkey = 2;
576
+ }
577
+
500
578
  message ImportAccountRequest {
501
579
  // A name to identify the account with.
502
580
  string name = 1;
@@ -917,6 +995,23 @@ message LabelTransactionRequest {
917
995
  message LabelTransactionResponse {
918
996
  }
919
997
 
998
+ // The possible change address types for default accounts and single imported
999
+ // public keys. By default, P2WPKH will be used. We don't provide the
1000
+ // possibility to choose P2PKH as it is a legacy key scope, nor NP2WPKH as
1001
+ // no key scope permits to do so. For custom accounts, no change type should
1002
+ // be provided as the coin selection key scope will always be used to generate
1003
+ // the change address.
1004
+ enum ChangeAddressType {
1005
+ // CHANGE_ADDRESS_TYPE_UNSPECIFIED indicates that no change address type is
1006
+ // provided. We will then use P2WPKH address type for change (BIP0084 key
1007
+ // scope).
1008
+ CHANGE_ADDRESS_TYPE_UNSPECIFIED = 0;
1009
+
1010
+ // CHANGE_ADDRESS_TYPE_P2TR indicates to use P2TR address for change output
1011
+ // (BIP0086 key scope).
1012
+ CHANGE_ADDRESS_TYPE_P2TR = 1;
1013
+ }
1014
+
920
1015
  message FundPsbtRequest {
921
1016
  oneof template {
922
1017
  /*
@@ -962,6 +1057,12 @@ message FundPsbtRequest {
962
1057
 
963
1058
  // Whether unconfirmed outputs should be used as inputs for the transaction.
964
1059
  bool spend_unconfirmed = 7;
1060
+
1061
+ // The address type for the change. If empty, P2WPKH addresses will be used
1062
+ // for default accounts and single imported public keys. For custom
1063
+ // accounts, no change type should be provided as the coin selection key
1064
+ // scope will always be used to generate the change address.
1065
+ ChangeAddressType change_type = 8;
965
1066
  }
966
1067
  message FundPsbtResponse {
967
1068
  /*
@@ -7,6 +7,7 @@ const {Transaction} = require('bitcoinjs-lib');
7
7
  const {isLnd} = require('./../../lnd_requests');
8
8
 
9
9
  const asOutpoint = n => `${n.transaction_id}:${n.transaction_vout}`;
10
+ const defaultChangeType = 'CHANGE_ADDRESS_TYPE_P2TR';
10
11
  const defaultConfirmationTarget = 6;
11
12
  const expirationAsDate = epoch => new Date(Number(epoch) * 1e3).toISOString();
12
13
  const {fromHex} = Transaction;
@@ -156,6 +157,7 @@ module.exports = (args, cbk) => {
156
157
  // Fund the PSBT
157
158
  fund: ['fee', 'funding', 'minConfs', ({fee, funding, minConfs}, cbk) => {
158
159
  return args.lnd[type][method]({
160
+ change_type: defaultChangeType,
159
161
  min_confs: minConfs !== undefined ? minConfs : undefined,
160
162
  psbt: !!args.psbt ? Buffer.from(args.psbt, 'hex') : undefined,
161
163
  raw: funding || undefined,
@@ -1,17 +1,21 @@
1
1
  const asyncAuto = require('async/auto');
2
+ const asyncReflect = require('async/reflect');
2
3
  const {returnResult} = require('asyncjs-util');
3
4
 
4
5
  const getPublicKey = require('./../address/get_public_key');
5
6
  const {isLnd} = require('./../../lnd_requests');
6
7
  const {rpcGroupSessionAsSession} = require('./../../lnd_responses');
7
8
 
9
+ const defaultVersion = 'MUSIG2_VERSION_V100RC2';
8
10
  const hexAsBuffer = hex => Buffer.from(hex, 'hex');
9
11
  const {isArray} = Array;
10
12
  const isHash = n => /^[0-9A-F]{64}$/i.test(n);
13
+ const messageErrorLegacyVersion = 'error parsing all signer public keys: error parsing signer public key 0 for v1.0.0rc2 (compressed format): malformed public key: invalid length: 32';
11
14
  const method = 'muSig2CreateSession';
12
15
  const type = 'signer';
13
16
  const uniq = arr => Array.from(new Set(arr));
14
17
  const unsupportedMessage = 'unknown method MuSig2CreateSession for service signrpc.Signer';
18
+ const versionLegacy = 'MUSIG2_VERSION_V040';
15
19
  const xOnlyPublicKeyHexLength = 64;
16
20
  const xOnlyPublicKey = hexKey => hexKey.slice(2);
17
21
 
@@ -97,6 +101,41 @@ module.exports = (args, cbk) => {
97
101
  return cbk();
98
102
  }],
99
103
 
104
+ // Create the signing session
105
+ create: [
106
+ 'getKey',
107
+ 'taprootTweak',
108
+ asyncReflect(({getKey, taprootTweak}, cbk) =>
109
+ {
110
+ const keys = [getKey.public_key].concat(args.public_keys);
111
+
112
+ return args.lnd[type][method]({
113
+ all_signer_pubkeys: keys.map(hexAsBuffer),
114
+ key_loc: {key_family: args.key_family, key_index: args.key_index},
115
+ taproot_tweak: taprootTweak,
116
+ version: defaultVersion,
117
+ },
118
+ (err, res) => {
119
+ if (!!err && err.details === messageErrorLegacyVersion) {
120
+ return cbk(messageErrorLegacyVersion);
121
+ }
122
+
123
+ if (!!err && err.details === unsupportedMessage) {
124
+ return cbk([501, 'MuSig2BeginSigningSessionNotSupported']);
125
+ }
126
+
127
+ if (!!err) {
128
+ return cbk([503, 'UnexpectedErrorCreatingMuSig2Session', {err}]);
129
+ }
130
+
131
+ try {
132
+ return cbk(null, rpcGroupSessionAsSession(res));
133
+ } catch (err) {
134
+ return cbk([503, err.message]);
135
+ }
136
+ });
137
+ })],
138
+
100
139
  // Collect all public keys taking part in the signing session
101
140
  publicKeys: ['getKey', ({getKey}, cbk) => {
102
141
  // Trim public keys as necessary
@@ -111,16 +150,23 @@ module.exports = (args, cbk) => {
111
150
  return cbk(null, uniq(keys));
112
151
  }],
113
152
 
114
- // Create the signing session
115
- create: [
153
+ // Create the signing session with the legacy create if necessary
154
+ finalCreate: [
155
+ 'create',
116
156
  'publicKeys',
117
157
  'taprootTweak',
118
- ({publicKeys, taprootTweak}, cbk) =>
158
+ ({create, publicKeys, taprootTweak}, cbk) =>
119
159
  {
160
+ // Exit early when there is no need to use the legacy API
161
+ if (!create.error || create.error !== messageErrorLegacyVersion) {
162
+ return cbk(create.error, create.value);
163
+ }
164
+
120
165
  return args.lnd[type][method]({
121
166
  all_signer_pubkeys: publicKeys.map(hexAsBuffer),
122
167
  key_loc: {key_family: args.key_family, key_index: args.key_index},
123
168
  taproot_tweak: taprootTweak,
169
+ version: versionLegacy,
124
170
  },
125
171
  (err, res) => {
126
172
  if (!!err && err.details === unsupportedMessage) {
@@ -139,6 +185,6 @@ module.exports = (args, cbk) => {
139
185
  });
140
186
  }],
141
187
  },
142
- returnResult({reject, resolve, of: 'create'}, cbk));
188
+ returnResult({reject, resolve, of: 'finalCreate'}, cbk));
143
189
  });
144
190
  };
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.8.2",
11
- "@grpc/proto-loader": "0.7.4",
12
- "@types/express": "4.17.15",
13
- "@types/node": "18.11.18",
10
+ "@grpc/grpc-js": "1.8.8",
11
+ "@grpc/proto-loader": "0.7.5",
12
+ "@types/express": "4.17.17",
13
+ "@types/node": "18.13.0",
14
14
  "@types/request": "2.48.8",
15
15
  "@types/ws": "8.5.4",
16
16
  "async": "3.2.4",
@@ -26,15 +26,15 @@
26
26
  "invoices": "2.2.3",
27
27
  "psbt": "2.7.2",
28
28
  "tiny-secp256k1": "2.2.1",
29
- "type-fest": "3.5.1"
29
+ "type-fest": "3.5.7"
30
30
  },
31
31
  "description": "Lightning Network client library",
32
32
  "devDependencies": {
33
33
  "@alexbosworth/node-fetch": "2.6.2",
34
34
  "@alexbosworth/tap": "15.0.12",
35
35
  "tsd": "0.25.0",
36
- "typescript": "4.9.4",
37
- "ws": "8.12.0"
36
+ "typescript": "4.9.5",
37
+ "ws": "8.12.1"
38
38
  },
39
39
  "engines": {
40
40
  "node": ">=14"
@@ -59,5 +59,5 @@
59
59
  "directory": "test/typescript"
60
60
  },
61
61
  "types": "index.d.ts",
62
- "version": "7.0.4"
62
+ "version": "7.0.6"
63
63
  }