lightning 5.13.0 → 5.13.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
|
@@ -6,6 +6,7 @@ const {isLnd} = require('./../../lnd_requests');
|
|
|
6
6
|
const bufferAsHex = buffer => buffer.toString('hex');
|
|
7
7
|
const hexAsBuffer = hex => Buffer.from(hex, 'hex');
|
|
8
8
|
const {isArray} = Array;
|
|
9
|
+
const isV1 = scriptHex => scriptHex.length === 68 && /5120/.test(scriptHex);
|
|
9
10
|
const method = 'signOutputRaw';
|
|
10
11
|
const notFound = -1;
|
|
11
12
|
const type = 'signer';
|
|
@@ -64,13 +65,27 @@ module.exports = ({inputs, lnd, spending, transaction}, cbk) => {
|
|
|
64
65
|
return cbk();
|
|
65
66
|
},
|
|
66
67
|
|
|
68
|
+
// Derive the previous outputs set
|
|
69
|
+
previousOutputs: ['validate', ({}, cbk) => {
|
|
70
|
+
const outputs = [].concat(inputs).concat(spending || []).map(utxo => ({
|
|
71
|
+
pk_script: hexAsBuffer(utxo.output_script),
|
|
72
|
+
value: utxo.output_tokens,
|
|
73
|
+
}));
|
|
74
|
+
|
|
75
|
+
const v1Spends = outputs.filter(n => isV1(bufferAsHex(n.pk_script)));
|
|
76
|
+
|
|
77
|
+
// Exit early when there is no need to provide prev outs, non-taproot
|
|
78
|
+
if (!v1Spends.length) {
|
|
79
|
+
return cbk();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return cbk(null, outputs);
|
|
83
|
+
}],
|
|
84
|
+
|
|
67
85
|
// Get signatures
|
|
68
|
-
signTransaction: ['
|
|
86
|
+
signTransaction: ['previousOutputs', ({previousOutputs}, cbk) => {
|
|
69
87
|
return lnd[type][method]({
|
|
70
|
-
prev_outputs:
|
|
71
|
-
pk_script: hexAsBuffer(utxo.output_script),
|
|
72
|
-
value: utxo.output_tokens,
|
|
73
|
-
})),
|
|
88
|
+
prev_outputs: previousOutputs,
|
|
74
89
|
raw_tx_bytes: hexAsBuffer(transaction),
|
|
75
90
|
sign_descs: inputs.map(input => ({
|
|
76
91
|
input_index: input.vin,
|
package/package.json
CHANGED