lightning 5.9.1 → 5.11.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 +13 -0
- package/README.md +12 -12
- package/grpc/grpc_services.json +3 -0
- package/grpc/protos/peers.proto +94 -0
- package/index.js +4 -0
- package/lnd_grpc/authenticated_lnd_grpc.js +1 -0
- package/lnd_methods/index.js +4 -0
- package/lnd_methods/info/get_wallet_info.js +2 -0
- package/lnd_methods/macaroon/methods.json +11 -3
- package/lnd_methods/onchain/partially_sign_psbt.d.ts +1 -1
- package/lnd_methods/onchain/partially_sign_psbt.js +1 -1
- package/lnd_methods/onchain/subscribe_to_chain_address.js +1 -1
- package/lnd_methods/peers/index.js +10 -1
- package/lnd_methods/peers/update_alias.js +58 -0
- package/lnd_methods/peers/update_color.js +58 -0
- package/lnd_methods/signer/sign_transaction.d.ts +8 -0
- package/lnd_methods/signer/sign_transaction.js +23 -9
- package/lnd_requests/rpc_hop_from_hop.js +1 -3
- package/package.json +4 -4
- package/test/lnd_grpc/test_authenticated_lnd_grpc.js +1 -0
- package/test/lnd_methods/peers/test_update_alias.js +56 -0
- package/test/lnd_methods/peers/test_update_color.js +56 -0
- package/test/lnd_requests/test_rpc_hop_from_hop.js +1 -0
- package/test/typescript/sign_transaction.test-d.ts +19 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
+
## 5.11.0
|
|
4
|
+
|
|
5
|
+
- `updateAlias`: Add method to update the node graph announcement alias
|
|
6
|
+
- `updateColor`: Add method to update the node graph announcement color
|
|
7
|
+
|
|
8
|
+
## 5.10.1
|
|
9
|
+
|
|
10
|
+
- Always use TLV when paying along routes
|
|
11
|
+
|
|
12
|
+
## 5.10.0
|
|
13
|
+
|
|
14
|
+
- `signTransaction`: Add `spending` attribute for specifying external inputs
|
|
15
|
+
|
|
3
16
|
## 5.9.1
|
|
4
17
|
|
|
5
18
|
- `createChainAddress`: Add support for creating P2TR addresses
|
package/README.md
CHANGED
|
@@ -9,28 +9,28 @@ Methods for working with the Lightning Network
|
|
|
9
9
|
- [bitpay.com crypto-rpc](https://bitpay.com/) -
|
|
10
10
|
https://github.com/bitpay/crypto-rpc
|
|
11
11
|
- [coinos.io](https://coinos.io/) - https://github.com/coinos/coinos-server
|
|
12
|
+
- [Galoy](https://galoy.io/) - https://github.com/GaloyMoney/galoy
|
|
13
|
+
- [Lightning Poker](https://lightning-poker.com/) -
|
|
14
|
+
https://github.com/igreshev/lightning-poker
|
|
15
|
+
- [Lightning Roulette](https://lightning-roulette.com/) -
|
|
16
|
+
https://github.com/igreshev/lightning-roulette
|
|
12
17
|
- [Lightning Shell](https://lightningshell.app/) -
|
|
13
18
|
https://github.com/ibz/lightning-shell
|
|
14
19
|
- [LNMarkets](https://twitter.com/lnmarkets) -
|
|
15
20
|
https://github.com/lnmarkets/umbrel
|
|
16
|
-
- [Galoy](https://galoy.io/) - https://github.com/GaloyMoney/galoy
|
|
17
|
-
- [Tarnhelm](https://www.tarnhelm.app/) - https://github.com/bkiac/tarnhelm
|
|
18
|
-
- [tbtcswaps](https://tbtcswaps.com/) -
|
|
19
|
-
https://github.com/keep-community/tbtcswaps
|
|
20
|
-
- [stackernews](https://stacker.news/) -
|
|
21
|
-
https://github.com/stackernews/stacker.news
|
|
22
|
-
- [Thunderhub](https://www.thunderhub.io/) -
|
|
23
|
-
https://github.com/apotdevin/thunderhub
|
|
24
|
-
- [Lightning Roulette](https://lightning-roulette.com/) -
|
|
25
|
-
https://github.com/igreshev/lightning-roulette
|
|
26
|
-
- [Lightning Poker](https://lightning-poker.com/) -
|
|
27
|
-
https://github.com/igreshev/lightning-poker
|
|
28
21
|
- [p2plnbot](https://telegram.me/lnp2pbot) - https://github.com/grunch/p2plnbot
|
|
29
22
|
- [rekr](https://rekr.app/) - https://github.com/ryan-lingle/rekr
|
|
23
|
+
- [stackernews](https://stacker.news/) -
|
|
24
|
+
https://github.com/stackernews/stacker.news
|
|
30
25
|
- [Suredbits API](https://suredbits.com/) -
|
|
31
26
|
https://github.com/Suredbits/sb-api-lnd
|
|
32
27
|
- [Synonym demo server](https://synonym.to) -
|
|
33
28
|
https://github.com/synonymdev/slash-pay-demo-server
|
|
29
|
+
- [Tarnhelm](https://www.tarnhelm.app/) - https://github.com/bkiac/tarnhelm
|
|
30
|
+
- [tbtcswaps](https://tbtcswaps.com/) -
|
|
31
|
+
https://github.com/keep-community/tbtcswaps
|
|
32
|
+
- [Thunderhub](https://www.thunderhub.io/) -
|
|
33
|
+
https://github.com/apotdevin/thunderhub
|
|
34
34
|
|
|
35
35
|
## LND Authentication
|
|
36
36
|
|
package/grpc/grpc_services.json
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
"ChainNotifier": "chainrpc",
|
|
8
8
|
"Invoices": "invoicesrpc",
|
|
9
9
|
"Lightning": "lnrpc",
|
|
10
|
+
"Peers": "peersrpc",
|
|
10
11
|
"Router": "routerrpc",
|
|
11
12
|
"Signer": "signrpc",
|
|
12
13
|
"State": "lnrpc",
|
|
@@ -21,6 +22,7 @@
|
|
|
21
22
|
"ChainNotifier": "chainnotifier.proto",
|
|
22
23
|
"Invoices": "invoices.proto",
|
|
23
24
|
"Lightning": "lightning.proto",
|
|
25
|
+
"Peers": "peers.proto",
|
|
24
26
|
"Router": "router.proto",
|
|
25
27
|
"Signer": "signer.proto",
|
|
26
28
|
"State": "stateservice.proto",
|
|
@@ -36,6 +38,7 @@
|
|
|
36
38
|
"chain": "ChainNotifier",
|
|
37
39
|
"default": "Lightning",
|
|
38
40
|
"invoices": "Invoices",
|
|
41
|
+
"peers": "Peers",
|
|
39
42
|
"router": "Router",
|
|
40
43
|
"signer": "Signer",
|
|
41
44
|
"tower_client": "WatchtowerClient",
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
import "lightning.proto";
|
|
4
|
+
|
|
5
|
+
package peersrpc;
|
|
6
|
+
|
|
7
|
+
option go_package = "github.com/lightningnetwork/lnd/lnrpc/peersrpc";
|
|
8
|
+
|
|
9
|
+
// Peers is a service that can be used to get information and interact
|
|
10
|
+
// with the other nodes of the newtwork.
|
|
11
|
+
service Peers {
|
|
12
|
+
/* lncli: peers updatenodeannouncement
|
|
13
|
+
UpdateNodeAnnouncement allows the caller to update the node parameters
|
|
14
|
+
and broadcasts a new version of the node announcement to its peers.
|
|
15
|
+
*/
|
|
16
|
+
rpc UpdateNodeAnnouncement (NodeAnnouncementUpdateRequest)
|
|
17
|
+
returns (NodeAnnouncementUpdateResponse);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// UpdateAction is used to determine the kind of action we are referring to.
|
|
21
|
+
enum UpdateAction {
|
|
22
|
+
// ADD indicates this is an "insertion" kind of action.
|
|
23
|
+
ADD = 0;
|
|
24
|
+
|
|
25
|
+
// REMOVE indicates this is a "deletion" kind of action.
|
|
26
|
+
REMOVE = 1;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
enum FeatureSet {
|
|
30
|
+
/*
|
|
31
|
+
SET_INIT identifies features that should be sent in an Init message to
|
|
32
|
+
a remote peer.
|
|
33
|
+
*/
|
|
34
|
+
SET_INIT = 0;
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
SET_LEGACY_GLOBAL identifies features that should be set in the legacy
|
|
38
|
+
GlobalFeatures field of an Init message, which maintains backwards
|
|
39
|
+
compatibility with nodes that haven't implemented flat features.
|
|
40
|
+
*/
|
|
41
|
+
SET_LEGACY_GLOBAL = 1;
|
|
42
|
+
|
|
43
|
+
/*
|
|
44
|
+
SET_NODE_ANN identifies features that should be advertised on node
|
|
45
|
+
announcements.
|
|
46
|
+
*/
|
|
47
|
+
SET_NODE_ANN = 2;
|
|
48
|
+
|
|
49
|
+
/*
|
|
50
|
+
SET_INVOICE identifies features that should be advertised on invoices
|
|
51
|
+
generated by the daemon.
|
|
52
|
+
*/
|
|
53
|
+
SET_INVOICE = 3;
|
|
54
|
+
|
|
55
|
+
/*
|
|
56
|
+
SET_INVOICE_AMP identifies the features that should be advertised on
|
|
57
|
+
AMP invoices generated by the daemon.
|
|
58
|
+
*/
|
|
59
|
+
SET_INVOICE_AMP = 4;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
message UpdateAddressAction {
|
|
63
|
+
// Determines the kind of action.
|
|
64
|
+
UpdateAction action = 1;
|
|
65
|
+
|
|
66
|
+
// The address used to apply the update action.
|
|
67
|
+
string address = 2;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
message UpdateFeatureAction {
|
|
71
|
+
// Determines the kind of action.
|
|
72
|
+
UpdateAction action = 1;
|
|
73
|
+
|
|
74
|
+
// The feature bit used to apply the update action.
|
|
75
|
+
lnrpc.FeatureBit feature_bit = 2;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
message NodeAnnouncementUpdateRequest {
|
|
79
|
+
// Set of changes for the features that the node supports.
|
|
80
|
+
repeated UpdateFeatureAction feature_updates = 1;
|
|
81
|
+
|
|
82
|
+
// Color is the node's color in hex code format.
|
|
83
|
+
string color = 2;
|
|
84
|
+
|
|
85
|
+
// Alias or nick name of the node.
|
|
86
|
+
string alias = 3;
|
|
87
|
+
|
|
88
|
+
// Set of changes for the node's known addresses.
|
|
89
|
+
repeated UpdateAddressAction address_updates = 4;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
message NodeAnnouncementUpdateResponse {
|
|
93
|
+
repeated lnrpc.Op ops = 1;
|
|
94
|
+
}
|
package/index.js
CHANGED
|
@@ -127,7 +127,9 @@ const {subscribeToWalletStatus} = require('./lnd_methods');
|
|
|
127
127
|
const {unauthenticatedLndGrpc} = require('./lnd_grpc');
|
|
128
128
|
const {unlockUtxo} = require('./lnd_methods');
|
|
129
129
|
const {unlockWallet} = require('./lnd_methods');
|
|
130
|
+
const {updateAlias} = require('./lnd_methods');
|
|
130
131
|
const {updateChainTransaction} = require('./lnd_methods');
|
|
132
|
+
const {updateColor} = require('./lnd_methods');
|
|
131
133
|
const {updateConnectedWatchtower} = require('./lnd_methods');
|
|
132
134
|
const {updatePathfindingSettings} = require('./lnd_methods');
|
|
133
135
|
const {updateRoutingFees} = require('./lnd_methods');
|
|
@@ -267,6 +269,8 @@ module.exports = {
|
|
|
267
269
|
unauthenticatedLndGrpc,
|
|
268
270
|
unlockUtxo,
|
|
269
271
|
unlockWallet,
|
|
272
|
+
updateAlias,
|
|
273
|
+
updateColor,
|
|
270
274
|
updateChainTransaction,
|
|
271
275
|
updateConnectedWatchtower,
|
|
272
276
|
updatePathfindingSettings,
|
|
@@ -37,6 +37,7 @@ const pathForProto = proto => join(__dirname, protosDir, proto);
|
|
|
37
37
|
chain: <ChainNotifier API Methods Object>
|
|
38
38
|
default: <Default API Methods Object>
|
|
39
39
|
invoices: <Invoices API Methods Object>
|
|
40
|
+
peers: <Peers API Methods Object>
|
|
40
41
|
router: <Router API Methods Object>
|
|
41
42
|
signer: <Signer Methods API Object>
|
|
42
43
|
tower_client: <Watchtower Client Methods Object>
|
package/lnd_methods/index.js
CHANGED
|
@@ -123,7 +123,9 @@ const {subscribeToTransactions} = require('./onchain');
|
|
|
123
123
|
const {subscribeToWalletStatus} = require('./unauthenticated');
|
|
124
124
|
const {unlockUtxo} = require('./onchain');
|
|
125
125
|
const {unlockWallet} = require('./unauthenticated');
|
|
126
|
+
const {updateAlias} = require('./peers');
|
|
126
127
|
const {updateChainTransaction} = require('./onchain');
|
|
128
|
+
const {updateColor} = require('./peers');
|
|
127
129
|
const {updateConnectedWatchtower} = require('./offchain');
|
|
128
130
|
const {updatePathfindingSettings} = require('./offchain');
|
|
129
131
|
const {updateRoutingFees} = require('./offchain');
|
|
@@ -259,7 +261,9 @@ module.exports = {
|
|
|
259
261
|
subscribeToWalletStatus,
|
|
260
262
|
unlockUtxo,
|
|
261
263
|
unlockWallet,
|
|
264
|
+
updateAlias,
|
|
262
265
|
updateChainTransaction,
|
|
266
|
+
updateColor,
|
|
263
267
|
updateConnectedWatchtower,
|
|
264
268
|
updatePathfindingSettings,
|
|
265
269
|
updateRoutingFees,
|
|
@@ -490,14 +490,22 @@
|
|
|
490
490
|
"method": "releaseOutput",
|
|
491
491
|
"type": "wallet"
|
|
492
492
|
},
|
|
493
|
-
"
|
|
494
|
-
"
|
|
495
|
-
"type": "
|
|
493
|
+
"updateAlias": {
|
|
494
|
+
"method": "updateNodeAnnouncement",
|
|
495
|
+
"type": "peers"
|
|
496
496
|
},
|
|
497
497
|
"updateChainTransaction": {
|
|
498
498
|
"method": "LabelTransaction",
|
|
499
499
|
"type": "wallet"
|
|
500
500
|
},
|
|
501
|
+
"updateColor": {
|
|
502
|
+
"method": "updateNodeAnnouncement",
|
|
503
|
+
"type": "peers"
|
|
504
|
+
},
|
|
505
|
+
"updateConnectedWatchtower": {
|
|
506
|
+
"methods": ["AddTower", "RemoveTower"],
|
|
507
|
+
"type": "tower_client"
|
|
508
|
+
},
|
|
501
509
|
"updatePathfindingSettings": {
|
|
502
510
|
"method": "SetMissionControlConfig",
|
|
503
511
|
"type": "router"
|
|
@@ -20,7 +20,7 @@ export type PartiallySignPsbtResult = {
|
|
|
20
20
|
*
|
|
21
21
|
* Requires LND built with `walletrpc` tag
|
|
22
22
|
*
|
|
23
|
-
* This method is not supported in LND 0.14.
|
|
23
|
+
* This method is not supported in LND 0.14.1 and below
|
|
24
24
|
*/
|
|
25
25
|
export const partiallySignPsbt: AuthenticatedLightningMethod<
|
|
26
26
|
PartiallySignPsbtArgs,
|
|
@@ -25,7 +25,7 @@ const type = 'chain';
|
|
|
25
25
|
|
|
26
26
|
{
|
|
27
27
|
[bech32_address]: <Address String>
|
|
28
|
-
lnd: <
|
|
28
|
+
lnd: <Authenticated LND API Object>
|
|
29
29
|
[min_confirmations]: <Minimum Confirmations Number>
|
|
30
30
|
min_height: <Minimum Transaction Inclusion Blockchain Height Number>
|
|
31
31
|
[output_script]: <Output Script Hex String>
|
|
@@ -2,5 +2,14 @@ const addPeer = require('./add_peer');
|
|
|
2
2
|
const getPeers = require('./get_peers');
|
|
3
3
|
const removePeer = require('./remove_peer');
|
|
4
4
|
const subscribeToPeers = require('./subscribe_to_peers');
|
|
5
|
+
const updateAlias = require('./update_alias');
|
|
6
|
+
const updateColor = require('./update_color');
|
|
5
7
|
|
|
6
|
-
module.exports = {
|
|
8
|
+
module.exports = {
|
|
9
|
+
addPeer,
|
|
10
|
+
getPeers,
|
|
11
|
+
removePeer,
|
|
12
|
+
subscribeToPeers,
|
|
13
|
+
updateAlias,
|
|
14
|
+
updateColor,
|
|
15
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const asyncAuto = require('async/auto');
|
|
2
|
+
const {returnResult} = require('asyncjs-util');
|
|
3
|
+
|
|
4
|
+
const {isLnd} = require('./../../lnd_requests');
|
|
5
|
+
|
|
6
|
+
const errorUnimplemented = 'unknown service peersrpc.Peers';
|
|
7
|
+
const method = 'updateNodeAnnouncement';
|
|
8
|
+
const type = 'peers';
|
|
9
|
+
|
|
10
|
+
/** Update the node alias as advertised in the graph
|
|
11
|
+
|
|
12
|
+
Note: this method is not supported in LND versions 0.14.3 and below
|
|
13
|
+
|
|
14
|
+
Requires LND built with `peersrpc` build tag
|
|
15
|
+
|
|
16
|
+
Requires `peers:write` permissions
|
|
17
|
+
|
|
18
|
+
{
|
|
19
|
+
color: <Node Color #000000 String>
|
|
20
|
+
lnd: <Authenticated LND API Object>
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@returns via cbk or Promise
|
|
24
|
+
*/
|
|
25
|
+
module.exports = ({alias, lnd}, cbk) => {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
return asyncAuto({
|
|
28
|
+
// Check arguments
|
|
29
|
+
validate: cbk => {
|
|
30
|
+
if (alias === undefined) {
|
|
31
|
+
return cbk([400, 'ExpectedAliasToUpdateNodeAnnouncementAlias']);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!isLnd({lnd, method, type})) {
|
|
35
|
+
return cbk([400, 'ExpectedLndToUpdateNodeAnnouncementAlias']);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return cbk();
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
// Update the node alias with the updated alias
|
|
42
|
+
updateAlias: ['validate', ({}, cbk) => {
|
|
43
|
+
return lnd[type][method]({alias}, (err, res) => {
|
|
44
|
+
if (!!err && err.details === errorUnimplemented) {
|
|
45
|
+
return cbk([400, 'ExpectedPeersRpcLndBuildTagToUpdateAlias']);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (!!err) {
|
|
49
|
+
return cbk([503, 'UnexpectedErrorUpdatingNodeAlias', {err}]);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return cbk();
|
|
53
|
+
});
|
|
54
|
+
}],
|
|
55
|
+
},
|
|
56
|
+
returnResult({reject, resolve}, cbk));
|
|
57
|
+
});
|
|
58
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const asyncAuto = require('async/auto');
|
|
2
|
+
const {returnResult} = require('asyncjs-util');
|
|
3
|
+
|
|
4
|
+
const {isLnd} = require('./../../lnd_requests');
|
|
5
|
+
|
|
6
|
+
const errorUnimplemented = 'unknown service peersrpc.Peers';
|
|
7
|
+
const method = 'updateNodeAnnouncement';
|
|
8
|
+
const type = 'peers';
|
|
9
|
+
|
|
10
|
+
/** Update the node color as advertised in the graph
|
|
11
|
+
|
|
12
|
+
Note: this method is not supported in LND versions 0.14.3 and below
|
|
13
|
+
|
|
14
|
+
Requires LND built with `signrpc` build tag
|
|
15
|
+
|
|
16
|
+
Requires `peers:write` permissions
|
|
17
|
+
|
|
18
|
+
{
|
|
19
|
+
color: <Node Color String>
|
|
20
|
+
lnd: <Authenticated LND API Object>
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@returns via cbk or Promise
|
|
24
|
+
*/
|
|
25
|
+
module.exports = ({color, lnd}, cbk) => {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
return asyncAuto({
|
|
28
|
+
// Check arguments
|
|
29
|
+
validate: cbk => {
|
|
30
|
+
if (!color) {
|
|
31
|
+
return cbk([400, 'ExpectedColorToUpdateNodeAnnouncementColor']);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!isLnd({lnd, method, type})) {
|
|
35
|
+
return cbk([400, 'ExpectedLndToUpdateNodeAnnouncementColor']);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return cbk();
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
// Update the node alias with the updated alias
|
|
42
|
+
updateAlias: ['validate', ({}, cbk) => {
|
|
43
|
+
return lnd[type][method]({color}, (err, res) => {
|
|
44
|
+
if (!!err && err.details === errorUnimplemented) {
|
|
45
|
+
return cbk([400, 'ExpectedPeersRpcLndBuildTagToUpdateColor']);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (!!err) {
|
|
49
|
+
return cbk([503, 'UnexpectedErrorUpdatingNodeColor', {err}]);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return cbk();
|
|
53
|
+
});
|
|
54
|
+
}],
|
|
55
|
+
},
|
|
56
|
+
returnResult({reject, resolve}, cbk));
|
|
57
|
+
});
|
|
58
|
+
};
|
|
@@ -20,6 +20,12 @@ export type SignTransactionArgs = AuthenticatedLightningArgs<{
|
|
|
20
20
|
/** Witness Script Hex String */
|
|
21
21
|
witness_script: string;
|
|
22
22
|
}[];
|
|
23
|
+
spending?: {
|
|
24
|
+
/** Non-Internal Spend Output Script Hex String */
|
|
25
|
+
output_script: string;
|
|
26
|
+
/** Non-Internal Spend Output Tokens Number */
|
|
27
|
+
output_tokens: number;
|
|
28
|
+
}[];
|
|
23
29
|
/** Unsigned Transaction Hex String */
|
|
24
30
|
transaction: string;
|
|
25
31
|
}>;
|
|
@@ -35,6 +41,8 @@ export type SignTransactionResult = {
|
|
|
35
41
|
* Requires LND built with `signrpc` build tag
|
|
36
42
|
*
|
|
37
43
|
* Requires `signer:generate` permission
|
|
44
|
+
*
|
|
45
|
+
* `spending` is not supported in LND 0.14.3 and below
|
|
38
46
|
*/
|
|
39
47
|
export const signTransaction: AuthenticatedLightningMethod<
|
|
40
48
|
SignTransactionArgs,
|
|
@@ -3,16 +3,24 @@ const {returnResult} = require('asyncjs-util');
|
|
|
3
3
|
|
|
4
4
|
const {isLnd} = require('./../../lnd_requests');
|
|
5
5
|
|
|
6
|
+
const bufferAsHex = buffer => buffer.toString('hex');
|
|
7
|
+
const hexAsBuffer = hex => Buffer.from(hex, 'hex');
|
|
6
8
|
const {isArray} = Array;
|
|
9
|
+
const method = 'signOutputRaw';
|
|
7
10
|
const notFound = -1;
|
|
11
|
+
const type = 'signer';
|
|
8
12
|
const unimplementedError = '12 UNIMPLEMENTED: unknown service signrpc.Signer';
|
|
9
13
|
|
|
10
14
|
/** Sign transaction
|
|
11
15
|
|
|
16
|
+
`spending` is required for non-internal inputs for a Taproot signature
|
|
17
|
+
|
|
12
18
|
Requires LND built with `signrpc` build tag
|
|
13
19
|
|
|
14
20
|
Requires `signer:generate` permission
|
|
15
21
|
|
|
22
|
+
`spending` is not supported in LND 0.14.3 and below
|
|
23
|
+
|
|
16
24
|
{
|
|
17
25
|
inputs: [{
|
|
18
26
|
key_family: <Key Family Number>
|
|
@@ -24,6 +32,10 @@ const unimplementedError = '12 UNIMPLEMENTED: unknown service signrpc.Signer';
|
|
|
24
32
|
witness_script: <Witness Script Hex String>
|
|
25
33
|
}]
|
|
26
34
|
lnd: <Authenticated LND API Object>
|
|
35
|
+
[spending]: [{
|
|
36
|
+
output_script: <Non-Internal Spend Output Script Hex String>
|
|
37
|
+
output_tokens: <Non-Internal Spend Output Tokens Number>
|
|
38
|
+
}]
|
|
27
39
|
transaction: <Unsigned Transaction Hex String>
|
|
28
40
|
}
|
|
29
41
|
|
|
@@ -32,7 +44,7 @@ const unimplementedError = '12 UNIMPLEMENTED: unknown service signrpc.Signer';
|
|
|
32
44
|
signatures: [<Signature Hex String>]
|
|
33
45
|
}
|
|
34
46
|
*/
|
|
35
|
-
module.exports = ({inputs, lnd, transaction}, cbk) => {
|
|
47
|
+
module.exports = ({inputs, lnd, spending, transaction}, cbk) => {
|
|
36
48
|
return new Promise((resolve, reject) => {
|
|
37
49
|
return asyncAuto({
|
|
38
50
|
// Check arguments
|
|
@@ -41,7 +53,7 @@ module.exports = ({inputs, lnd, transaction}, cbk) => {
|
|
|
41
53
|
return cbk([400, 'ExpectedInputsToSignTransaction']);
|
|
42
54
|
}
|
|
43
55
|
|
|
44
|
-
if (!isLnd({lnd, method
|
|
56
|
+
if (!isLnd({lnd, method, type})) {
|
|
45
57
|
return cbk([400, 'ExpectedAuthenticatedLndToSignTransaction']);
|
|
46
58
|
}
|
|
47
59
|
|
|
@@ -54,8 +66,12 @@ module.exports = ({inputs, lnd, transaction}, cbk) => {
|
|
|
54
66
|
|
|
55
67
|
// Get signatures
|
|
56
68
|
signTransaction: ['validate', ({}, cbk) => {
|
|
57
|
-
return lnd
|
|
58
|
-
|
|
69
|
+
return lnd[type][method]({
|
|
70
|
+
prev_outputs: [].concat(inputs).concat(spending || []).map(utxo => ({
|
|
71
|
+
pk_script: hexAsBuffer(utxo.output_script),
|
|
72
|
+
value: utxo.output_tokens,
|
|
73
|
+
})),
|
|
74
|
+
raw_tx_bytes: hexAsBuffer(transaction),
|
|
59
75
|
sign_descs: inputs.map(input => ({
|
|
60
76
|
input_index: input.vin,
|
|
61
77
|
key_desc: {
|
|
@@ -65,11 +81,11 @@ module.exports = ({inputs, lnd, transaction}, cbk) => {
|
|
|
65
81
|
},
|
|
66
82
|
},
|
|
67
83
|
output: {
|
|
68
|
-
pk_script:
|
|
84
|
+
pk_script: hexAsBuffer(input.output_script),
|
|
69
85
|
value: input.output_tokens,
|
|
70
86
|
},
|
|
71
87
|
sighash: input.sighash,
|
|
72
|
-
witness_script:
|
|
88
|
+
witness_script: hexAsBuffer(input.witness_script),
|
|
73
89
|
})),
|
|
74
90
|
},
|
|
75
91
|
(err, res) => {
|
|
@@ -93,9 +109,7 @@ module.exports = ({inputs, lnd, transaction}, cbk) => {
|
|
|
93
109
|
return cbk([503, 'ExpectedSignatureBuffersInSignResponse']);
|
|
94
110
|
}
|
|
95
111
|
|
|
96
|
-
return cbk(null, {
|
|
97
|
-
signatures: res.raw_sigs.map(n => n.toString('hex'))
|
|
98
|
-
});
|
|
112
|
+
return cbk(null, {signatures: res.raw_sigs.map(bufferAsHex)});
|
|
99
113
|
});
|
|
100
114
|
}],
|
|
101
115
|
},
|
|
@@ -60,6 +60,7 @@ module.exports = args => {
|
|
|
60
60
|
fee: millitokensAsTokens(args.fee_mtokens).toString(),
|
|
61
61
|
fee_msat: args.fee_mtokens,
|
|
62
62
|
pub_key: args.public_key,
|
|
63
|
+
tlv_payload: true,
|
|
63
64
|
};
|
|
64
65
|
|
|
65
66
|
// Exit early when there are no messages to encode in this hop
|
|
@@ -67,9 +68,6 @@ module.exports = args => {
|
|
|
67
68
|
return hop;
|
|
68
69
|
}
|
|
69
70
|
|
|
70
|
-
// Set custom TLV payload records for this hop
|
|
71
|
-
hop.tlv_payload = true;
|
|
72
|
-
|
|
73
71
|
hop.custom_records = args.messages.reduce((tlv, n) => {
|
|
74
72
|
tlv[n.type] = hexAsBuffer(n.value);
|
|
75
73
|
|
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.6.
|
|
10
|
+
"@grpc/grpc-js": "1.6.6",
|
|
11
11
|
"@grpc/proto-loader": "0.6.9",
|
|
12
12
|
"@types/express": "4.17.13",
|
|
13
|
-
"@types/node": "17.0.
|
|
13
|
+
"@types/node": "17.0.25",
|
|
14
14
|
"@types/request": "2.48.8",
|
|
15
15
|
"@types/ws": "8.5.3",
|
|
16
16
|
"async": "3.2.3",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"cbor": "8.1.0",
|
|
24
24
|
"ecpair": "2.0.1",
|
|
25
25
|
"express": "4.17.3",
|
|
26
|
-
"invoices": "2.0.
|
|
26
|
+
"invoices": "2.0.6",
|
|
27
27
|
"psbt": "2.0.1",
|
|
28
28
|
"tiny-secp256k1": "2.2.1",
|
|
29
29
|
"type-fest": "2.12.2"
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"directory": "test/typescript"
|
|
60
60
|
},
|
|
61
61
|
"types": "index.d.ts",
|
|
62
|
-
"version": "5.
|
|
62
|
+
"version": "5.11.0"
|
|
63
63
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const {test} = require('@alexbosworth/tap');
|
|
2
|
+
|
|
3
|
+
const {updateAlias} = require('./../../../');
|
|
4
|
+
|
|
5
|
+
const makeLnd = ({err}) => {
|
|
6
|
+
return {peers: {updateNodeAnnouncement: (args, cbk) => cbk(err)}};
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const makeArgs = overrides => {
|
|
10
|
+
const args = {alias: 'alias', lnd: makeLnd({})};
|
|
11
|
+
|
|
12
|
+
Object.keys(overrides).forEach(key => args[key] = overrides[key]);
|
|
13
|
+
|
|
14
|
+
return args;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const tests = [
|
|
18
|
+
{
|
|
19
|
+
args: makeArgs({alias: undefined}),
|
|
20
|
+
description: 'An alias is required to update alias to',
|
|
21
|
+
error: [400, 'ExpectedAliasToUpdateNodeAnnouncementAlias'],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
args: makeArgs({lnd: undefined}),
|
|
25
|
+
description: 'LND is required to update alias',
|
|
26
|
+
error: [400, 'ExpectedLndToUpdateNodeAnnouncementAlias'],
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
args: makeArgs({
|
|
30
|
+
lnd: makeLnd({err: {details: 'unknown service peersrpc.Peers'}}),
|
|
31
|
+
}),
|
|
32
|
+
description: 'LND with peersrpc is required to update alias',
|
|
33
|
+
error: [400, 'ExpectedPeersRpcLndBuildTagToUpdateAlias'],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
args: makeArgs({lnd: makeLnd({err: 'err'})}),
|
|
37
|
+
description: 'LND error is returned',
|
|
38
|
+
error: [503, 'UnexpectedErrorUpdatingNodeAlias', {err: 'err'}],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
args: makeArgs({}),
|
|
42
|
+
description: 'Alias updated successfully',
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
tests.forEach(({args, description, error, expected}) => {
|
|
47
|
+
return test(description, async ({deepEqual, end, equal, rejects}) => {
|
|
48
|
+
if (!!error) {
|
|
49
|
+
await rejects(() => updateAlias(args), error, 'Got error');
|
|
50
|
+
} else {
|
|
51
|
+
await updateAlias(args);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return end();
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const {test} = require('@alexbosworth/tap');
|
|
2
|
+
|
|
3
|
+
const {updateColor} = require('./../../../');
|
|
4
|
+
|
|
5
|
+
const makeLnd = ({err}) => {
|
|
6
|
+
return {peers: {updateNodeAnnouncement: (args, cbk) => cbk(err)}};
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const makeArgs = overrides => {
|
|
10
|
+
const args = {color: '#012345', lnd: makeLnd({})};
|
|
11
|
+
|
|
12
|
+
Object.keys(overrides).forEach(key => args[key] = overrides[key]);
|
|
13
|
+
|
|
14
|
+
return args;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const tests = [
|
|
18
|
+
{
|
|
19
|
+
args: makeArgs({color: undefined}),
|
|
20
|
+
description: 'A color is required to update color to',
|
|
21
|
+
error: [400, 'ExpectedColorToUpdateNodeAnnouncementColor'],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
args: makeArgs({lnd: undefined}),
|
|
25
|
+
description: 'LND is required to update color',
|
|
26
|
+
error: [400, 'ExpectedLndToUpdateNodeAnnouncementColor'],
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
args: makeArgs({
|
|
30
|
+
lnd: makeLnd({err: {details: 'unknown service peersrpc.Peers'}}),
|
|
31
|
+
}),
|
|
32
|
+
description: 'LND with peersrpc is required to update color',
|
|
33
|
+
error: [400, 'ExpectedPeersRpcLndBuildTagToUpdateColor'],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
args: makeArgs({lnd: makeLnd({err: 'err'})}),
|
|
37
|
+
description: 'LND error is returned',
|
|
38
|
+
error: [503, 'UnexpectedErrorUpdatingNodeColor', {err: 'err'}],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
args: makeArgs({}),
|
|
42
|
+
description: 'Color updated successfully',
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
tests.forEach(({args, description, error, expected}) => {
|
|
47
|
+
return test(description, async ({deepEqual, end, equal, rejects}) => {
|
|
48
|
+
if (!!error) {
|
|
49
|
+
await rejects(() => updateColor(args), error, 'Got error');
|
|
50
|
+
} else {
|
|
51
|
+
await updateColor(args);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return end();
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -14,6 +14,12 @@ const inputs = [
|
|
|
14
14
|
witness_script: '00',
|
|
15
15
|
},
|
|
16
16
|
];
|
|
17
|
+
const spending = [
|
|
18
|
+
{
|
|
19
|
+
output_script: 'script',
|
|
20
|
+
output_tokens: 0,
|
|
21
|
+
},
|
|
22
|
+
];
|
|
17
23
|
const transaction = '00';
|
|
18
24
|
|
|
19
25
|
expectError(signTransaction());
|
|
@@ -32,9 +38,22 @@ expectType<SignTransactionResult>(
|
|
|
32
38
|
transaction,
|
|
33
39
|
})
|
|
34
40
|
);
|
|
41
|
+
expectType<SignTransactionResult>(
|
|
42
|
+
await signTransaction({
|
|
43
|
+
lnd,
|
|
44
|
+
inputs,
|
|
45
|
+
transaction,
|
|
46
|
+
spending,
|
|
47
|
+
})
|
|
48
|
+
);
|
|
35
49
|
|
|
36
50
|
expectType<void>(
|
|
37
51
|
signTransaction({lnd, inputs, transaction}, (error, result) => {
|
|
38
52
|
expectType<SignTransactionResult>(result);
|
|
39
53
|
})
|
|
40
54
|
);
|
|
55
|
+
expectType<void>(
|
|
56
|
+
signTransaction({lnd, inputs, transaction, spending}, (error, result) => {
|
|
57
|
+
expectType<SignTransactionResult>(result);
|
|
58
|
+
})
|
|
59
|
+
);
|