lightning 5.9.1 → 5.10.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
|
@@ -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>
|
|
@@ -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
|
},
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
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.2",
|
|
11
11
|
"@grpc/proto-loader": "0.6.9",
|
|
12
12
|
"@types/express": "4.17.13",
|
|
13
13
|
"@types/node": "17.0.23",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"directory": "test/typescript"
|
|
60
60
|
},
|
|
61
61
|
"types": "index.d.ts",
|
|
62
|
-
"version": "5.
|
|
62
|
+
"version": "5.10.0"
|
|
63
63
|
}
|