lightning 10.27.5 → 11.0.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 +6 -0
- package/lnd_methods/offchain/delete_pending_channel.js +15 -11
- package/lnd_methods/onchain/broadcast_chain_transaction.js +3 -4
- package/lnd_methods/onchain/fund_psbt.js +12 -14
- package/lnd_methods/onchain/get_pending_sweeps.js +0 -2
- package/lnd_methods/onchain/get_sweep_transactions.js +9 -13
- package/lnd_methods/onchain/script_from_chain_address.js +21 -16
- package/lnd_methods/onchain/send_to_chain_output_scripts.js +6 -5
- package/lnd_methods/onchain/subscribe_to_chain_address.js +1 -1
- package/package.json +5 -5
- package/test/lnd_methods/offchain/test_delete_pending_channel.js +7 -15
- package/test/lnd_methods/onchain/test_broadcast_chain_transaction.js +7 -7
- package/test/lnd_methods/onchain/test_get_sweep_transactions.js +3 -3
- package/test/lnd_methods/onchain/test_script_from_chain_address.js +15 -3
- package/test/lnd_methods/onchain/test_send_to_chain_output_scripts.js +3 -3
- package/test/lnd_methods/onchain/test_subscribe_to_chain_address.js +5 -5
- package/test/lnd_methods/onchain/test_subscribe_to_chain_spend.js +4 -8
- package/test-typescript/typescript/broadcast_chain_transaction.test-d.ts +1 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
const asyncAuto = require('async/auto');
|
|
2
|
+
const {componentsOfTransaction} = require('@alexbosworth/blockchain');
|
|
3
|
+
const {idForTransaction} = require('@alexbosworth/blockchain');
|
|
2
4
|
const {returnResult} = require('asyncjs-util');
|
|
3
|
-
const {Transaction} = require('bitcoinjs-lib');
|
|
4
5
|
|
|
5
|
-
const {fromHex} = Transaction;
|
|
6
6
|
const method = 'abandonChannel';
|
|
7
7
|
const methodUnsupported = 'AbandonChannel RPC call only available in dev builds';
|
|
8
8
|
const txIdAsHash = id => Buffer.from(id, 'hex').reverse();
|
|
9
|
+
const txComponents = transaction => componentsOfTransaction({transaction});
|
|
9
10
|
const type = 'default';
|
|
10
11
|
|
|
11
12
|
/** Delete a pending channel
|
|
@@ -34,7 +35,7 @@ module.exports = (args, cbk) => {
|
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
try {
|
|
37
|
-
|
|
38
|
+
txComponents(args.confirmed_transaction);
|
|
38
39
|
} catch (err) {
|
|
39
40
|
return cbk([400, 'ExpectedValidConfirmedTxToDeleteChannel']);
|
|
40
41
|
}
|
|
@@ -52,7 +53,7 @@ module.exports = (args, cbk) => {
|
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
try {
|
|
55
|
-
|
|
56
|
+
txComponents(args.pending_transaction);
|
|
56
57
|
} catch (err) {
|
|
57
58
|
return cbk([400, 'ExpectedValidPendingTxToDeleteChannel']);
|
|
58
59
|
}
|
|
@@ -66,16 +67,16 @@ module.exports = (args, cbk) => {
|
|
|
66
67
|
|
|
67
68
|
// Check for a conflicting input between the confirmed and pending txs
|
|
68
69
|
transactionId: ['validate', ({}, cbk) => {
|
|
69
|
-
const
|
|
70
|
-
const pending =
|
|
70
|
+
const confirmed = txComponents(args.confirmed_transaction);
|
|
71
|
+
const pending = txComponents(args.pending_transaction);
|
|
71
72
|
|
|
72
|
-
const conflictingInput = pending.
|
|
73
|
-
return
|
|
74
|
-
if (
|
|
73
|
+
const conflictingInput = pending.inputs.find(pendingInput => {
|
|
74
|
+
return confirmed.inputs.find(confirmedInput => {
|
|
75
|
+
if (confirmedInput.id !== pendingInput.id) {
|
|
75
76
|
return false;
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
return confirmedInput.
|
|
79
|
+
return confirmedInput.vout === pendingInput.vout;
|
|
79
80
|
});
|
|
80
81
|
});
|
|
81
82
|
|
|
@@ -83,8 +84,11 @@ module.exports = (args, cbk) => {
|
|
|
83
84
|
return cbk([400, 'FailedToFindConflictingInputInConfirmedTx']);
|
|
84
85
|
}
|
|
85
86
|
|
|
87
|
+
// Calculate the transaction ID to be sure we are deleting the conflict
|
|
88
|
+
const {id} = idForTransaction({transaction: args.pending_transaction});
|
|
89
|
+
|
|
86
90
|
// The pending transaction conflicts with the confirmed transaction
|
|
87
|
-
return cbk(null,
|
|
91
|
+
return cbk(null, id);
|
|
88
92
|
}],
|
|
89
93
|
|
|
90
94
|
// Delete the channel
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
const asyncAuto = require('async/auto');
|
|
2
|
+
const {idForTransaction} = require('@alexbosworth/blockchain');
|
|
2
3
|
const {returnResult} = require('asyncjs-util');
|
|
3
|
-
const {Transaction} = require('bitcoinjs-lib');
|
|
4
4
|
|
|
5
5
|
const {isLnd} = require('./../../lnd_requests');
|
|
6
6
|
|
|
7
7
|
const bufFromHex = hex => Buffer.from(hex, 'hex');
|
|
8
|
-
const {fromHex} = Transaction;
|
|
9
8
|
const method = 'publishTransaction';
|
|
10
9
|
const minRelayFeeError = /^unmatched backend error: -26: mempool min fee not met, (\d*) < (\d*)$/;
|
|
11
10
|
const type = 'wallet';
|
|
@@ -37,7 +36,7 @@ module.exports = ({description, lnd, transaction}, cbk) => {
|
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
try {
|
|
40
|
-
|
|
39
|
+
idForTransaction({transaction});
|
|
41
40
|
} catch (err) {
|
|
42
41
|
return cbk([400, 'ExpectedTransactionHexStringToBroadcastToPeers']);
|
|
43
42
|
}
|
|
@@ -77,7 +76,7 @@ module.exports = ({description, lnd, transaction}, cbk) => {
|
|
|
77
76
|
return cbk([503, 'FailedToBroadcastRawTransaction', {res}]);
|
|
78
77
|
}
|
|
79
78
|
|
|
80
|
-
return cbk(null, {id:
|
|
79
|
+
return cbk(null, {id: idForTransaction({transaction}).id});
|
|
81
80
|
});
|
|
82
81
|
}],
|
|
83
82
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const asyncAuto = require('async/auto');
|
|
2
|
+
const {componentsOfTransaction} = require('@alexbosworth/blockchain');
|
|
2
3
|
const {returnResult} = require('asyncjs-util');
|
|
3
|
-
const {
|
|
4
|
-
const {Transaction} = require('bitcoinjs-lib');
|
|
4
|
+
const {unsignedTxFromPsbt} = require('@alexbosworth/blockchain');
|
|
5
5
|
|
|
6
6
|
const {isLnd} = require('./../../lnd_requests');
|
|
7
7
|
|
|
@@ -9,18 +9,15 @@ const asOutpoint = n => `${n.transaction_id}:${n.transaction_vout}`;
|
|
|
9
9
|
const defaultChangeType = () => 'CHANGE_ADDRESS_TYPE_P2TR';
|
|
10
10
|
const defaultConfirmationTarget = 6;
|
|
11
11
|
const expirationAsDate = epoch => new Date(Number(epoch) * 1e3).toISOString();
|
|
12
|
-
const {fromBuffer} = Transaction;
|
|
13
12
|
const hexFromBuffer = buffer => buffer.toString('hex');
|
|
14
13
|
const {isArray} = Array;
|
|
15
14
|
const {isBuffer} = Buffer;
|
|
16
15
|
const isKnownChangeFormat = format => !format || format === 'p2tr';
|
|
17
16
|
const method = 'fundPsbt';
|
|
18
17
|
const notSupported = /unknown.*walletrpc.WalletKit/;
|
|
19
|
-
const psbtFromHex = hex => Psbt.fromBuffer(Buffer.from(hex, 'hex'));
|
|
20
18
|
const strategy = type => !type ? undefined : `STRATEGY_${type.toUpperCase()}`;
|
|
21
19
|
const type = 'wallet';
|
|
22
20
|
const txIdFromBuffer = buffer => buffer.slice().reverse().toString('hex');
|
|
23
|
-
const txIdFromHash = hash => hash.reverse().toString('hex');
|
|
24
21
|
|
|
25
22
|
/** Lock and optionally select inputs to a partially signed transaction
|
|
26
23
|
|
|
@@ -223,11 +220,12 @@ module.exports = (args, cbk) => {
|
|
|
223
220
|
const {psbt} = fund;
|
|
224
221
|
|
|
225
222
|
try {
|
|
226
|
-
const tx =
|
|
223
|
+
const tx = hexFromBuffer(unsignedTxFromPsbt({psbt}).transaction);
|
|
227
224
|
|
|
228
|
-
|
|
229
|
-
} catch (err) {
|
|
225
|
+
const {inputs, outputs} = componentsOfTransaction({transaction: tx});
|
|
230
226
|
|
|
227
|
+
return cbk(null, {inputs, outputs});
|
|
228
|
+
} catch (err) {
|
|
231
229
|
return cbk([503, 'FailedToDecodePsbtInFundPsbtResponse', {err}]);
|
|
232
230
|
}
|
|
233
231
|
}],
|
|
@@ -243,9 +241,9 @@ module.exports = (args, cbk) => {
|
|
|
243
241
|
}));
|
|
244
242
|
|
|
245
243
|
// The funding inputs are encoded in the PSBT's unsigned tx
|
|
246
|
-
const funding = tx.
|
|
247
|
-
transaction_id:
|
|
248
|
-
transaction_vout:
|
|
244
|
+
const funding = tx.inputs.map(({id, vout}) => ({
|
|
245
|
+
transaction_id: id,
|
|
246
|
+
transaction_vout: vout,
|
|
249
247
|
}));
|
|
250
248
|
|
|
251
249
|
// Include relevant UTXO locks with inputs
|
|
@@ -272,10 +270,10 @@ module.exports = (args, cbk) => {
|
|
|
272
270
|
{
|
|
273
271
|
return cbk(null, {
|
|
274
272
|
inputs: fundingInputs,
|
|
275
|
-
outputs: tx.
|
|
273
|
+
outputs: tx.outputs.map(({script, tokens}, index) => ({
|
|
274
|
+
tokens,
|
|
276
275
|
is_change: index === fund.change_output_index,
|
|
277
|
-
output_script:
|
|
278
|
-
tokens: value,
|
|
276
|
+
output_script: script,
|
|
279
277
|
})),
|
|
280
278
|
psbt: fund.psbt,
|
|
281
279
|
});
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
const asyncAuto = require('async/auto');
|
|
2
2
|
const {returnResult} = require('asyncjs-util');
|
|
3
|
-
const {Transaction} = require('bitcoinjs-lib');
|
|
4
3
|
|
|
5
4
|
const {isLnd} = require('./../../lnd_requests');
|
|
6
5
|
const {rpcSweepAsSweep} = require('./../../lnd_responses');
|
|
7
6
|
|
|
8
|
-
const {fromHex} = Transaction;
|
|
9
7
|
const {isArray} = Array;
|
|
10
8
|
const method = 'pendingSweeps';
|
|
11
9
|
const notSupportedError = 'unknown service walletrpc.WalletKit';
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
const asyncAuto = require('async/auto');
|
|
2
|
+
const {componentsOfTransaction} = require('@alexbosworth/blockchain');
|
|
2
3
|
const {returnResult} = require('asyncjs-util');
|
|
3
|
-
const {Transaction} = require('bitcoinjs-lib');
|
|
4
4
|
|
|
5
5
|
const getChainTransactions = require('./get_chain_transactions');
|
|
6
6
|
const {isLnd} = require('./../../lnd_requests');
|
|
7
7
|
|
|
8
|
-
const {fromHex} = Transaction;
|
|
9
8
|
const {isArray} = Array;
|
|
10
9
|
const method = 'listSweeps';
|
|
11
10
|
const notSupportedError = 'unknown service walletrpc.WalletKit';
|
|
11
|
+
const txComponents = transaction => componentsOfTransaction({transaction});
|
|
12
12
|
const type = 'wallet';
|
|
13
13
|
|
|
14
14
|
/** Get self-transfer spend transactions related to channel closes
|
|
@@ -100,14 +100,12 @@ module.exports = ({after, lnd}, cbk) => {
|
|
|
100
100
|
.filter(({id}) => getSweeps.includes(id))
|
|
101
101
|
.filter(({transaction}) => !!transaction)
|
|
102
102
|
.map(tx => {
|
|
103
|
-
const {
|
|
103
|
+
const {inputs} = txComponents(tx.transaction);
|
|
104
104
|
|
|
105
|
-
const spends =
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
};
|
|
110
|
-
});
|
|
105
|
+
const spends = inputs.map(input => ({
|
|
106
|
+
transaction_id: input.id,
|
|
107
|
+
transaction_vout: input.vout,
|
|
108
|
+
}));
|
|
111
109
|
|
|
112
110
|
const relatedUtxos = spends.map(spend => {
|
|
113
111
|
const spending = getTransactions.transactions.find(({id}) => {
|
|
@@ -122,12 +120,10 @@ module.exports = ({after, lnd}, cbk) => {
|
|
|
122
120
|
};
|
|
123
121
|
}
|
|
124
122
|
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
const {value} = fromHex(parentTx).outs[spend.transaction_vout];
|
|
123
|
+
const parentOutputs = txComponents(spending.transaction).outputs;
|
|
128
124
|
|
|
129
125
|
return {
|
|
130
|
-
tokens:
|
|
126
|
+
tokens: parentOutputs[spend.transaction_vout].tokens,
|
|
131
127
|
transaction_id: spend.transaction_id,
|
|
132
128
|
transaction_vout: spend.transaction_vout,
|
|
133
129
|
};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
const {
|
|
2
|
-
const {
|
|
1
|
+
const {decodeBase58Address} = require('@alexbosworth/blockchain');
|
|
2
|
+
const {decodeBech32Address} = require('@alexbosworth/blockchain');
|
|
3
|
+
const {p2pkhOutputScript} = require('@alexbosworth/blockchain');
|
|
4
|
+
const {p2shOutputScript} = require('@alexbosworth/blockchain');
|
|
5
|
+
const {p2wpkhOutputScript} = require('@alexbosworth/blockchain');
|
|
6
|
+
const {p2wshOutputScript} = require('@alexbosworth/blockchain');
|
|
3
7
|
|
|
4
|
-
const
|
|
5
|
-
const {fromBech32} = address;
|
|
6
|
-
const {p2pkh} = payments;
|
|
7
|
-
const {p2sh} = payments;
|
|
8
|
+
const bufferAsHex = buffer => buffer.toString('hex');
|
|
8
9
|
const p2wpkhAddressLength = 20;
|
|
9
|
-
const {p2wpkh} = payments;
|
|
10
|
-
const {p2wsh} = payments;
|
|
11
10
|
const p2wshAddressLength = 32;
|
|
12
11
|
|
|
13
12
|
/** Derive output script from on-chain address
|
|
@@ -30,9 +29,9 @@ module.exports = args => {
|
|
|
30
29
|
|
|
31
30
|
if (!!args.p2pkh_address) {
|
|
32
31
|
try {
|
|
33
|
-
const {hash} =
|
|
32
|
+
const {hash} = decodeBase58Address({address: args.p2pkh_address});
|
|
34
33
|
|
|
35
|
-
return {script:
|
|
34
|
+
return {script: bufferAsHex(p2pkhOutputScript({hash}).script)};
|
|
36
35
|
} catch (err) {
|
|
37
36
|
return {};
|
|
38
37
|
}
|
|
@@ -40,23 +39,29 @@ module.exports = args => {
|
|
|
40
39
|
|
|
41
40
|
if (!!args.p2sh_address) {
|
|
42
41
|
try {
|
|
43
|
-
const {hash} =
|
|
42
|
+
const {hash} = decodeBase58Address({address: args.p2sh_address});
|
|
44
43
|
|
|
45
|
-
return {script:
|
|
44
|
+
return {script: bufferAsHex(p2shOutputScript({hash}).script)};
|
|
46
45
|
} catch (err) {
|
|
47
46
|
return {};
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
|
|
51
50
|
try {
|
|
52
|
-
const {
|
|
51
|
+
const {program, version} = decodeBech32Address({
|
|
52
|
+
address: args.bech32_address,
|
|
53
|
+
});
|
|
53
54
|
|
|
54
|
-
|
|
55
|
+
if (!!version) {
|
|
56
|
+
throw new Error('ExpectedV0VersionForScriptFromChainAddress');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
switch (program.length) {
|
|
55
60
|
case p2wpkhAddressLength:
|
|
56
|
-
return {script:
|
|
61
|
+
return {script: bufferAsHex(p2wpkhOutputScript({hash: program}).script)};
|
|
57
62
|
|
|
58
63
|
case p2wshAddressLength:
|
|
59
|
-
return {script:
|
|
64
|
+
return {script: bufferAsHex(p2wshOutputScript({hash: program}).script)};
|
|
60
65
|
|
|
61
66
|
default:
|
|
62
67
|
break;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
const asyncAuto = require('async/auto');
|
|
2
|
+
const {idForTransaction} = require('@alexbosworth/blockchain');
|
|
2
3
|
const {returnResult} = require('asyncjs-util');
|
|
3
|
-
const {Transaction} = require('bitcoinjs-lib');
|
|
4
4
|
|
|
5
5
|
const {isLnd} = require('./../../lnd_requests');
|
|
6
6
|
|
|
7
7
|
const bufferAsHex = buffer => buffer.toString('hex');
|
|
8
|
-
const {fromBuffer} = Transaction;
|
|
9
8
|
const hexAsBuffer = hex => Buffer.from(hex, 'hex');
|
|
10
9
|
const initialConfirmationCount = 0;
|
|
11
10
|
const {isArray} = Array;
|
|
@@ -92,18 +91,20 @@ module.exports = (args, cbk) => {
|
|
|
92
91
|
}
|
|
93
92
|
|
|
94
93
|
try {
|
|
95
|
-
|
|
94
|
+
idForTransaction({transaction: bufferAsHex(res.raw_tx)});
|
|
96
95
|
} catch (err) {
|
|
97
96
|
return cbk([500, 'ExpectedRawTransactionInSendToOutputsResponse']);
|
|
98
97
|
}
|
|
99
98
|
|
|
99
|
+
const transaction = bufferAsHex(res.raw_tx);
|
|
100
|
+
|
|
100
101
|
const row = {
|
|
102
|
+
transaction,
|
|
101
103
|
confirmation_count: initialConfirmationCount,
|
|
102
|
-
id:
|
|
104
|
+
id: idForTransaction({transaction}).id,
|
|
103
105
|
is_confirmed: false,
|
|
104
106
|
is_outgoing: true,
|
|
105
107
|
tokens: args.send_to.reduce((sum, n) => sum + n.tokens, Number()),
|
|
106
|
-
transaction: bufferAsHex(res.raw_tx),
|
|
107
108
|
};
|
|
108
109
|
|
|
109
110
|
return cbk(null, row);
|
|
@@ -24,7 +24,7 @@ const type = 'chain';
|
|
|
24
24
|
Requires `onchain:read` permission
|
|
25
25
|
|
|
26
26
|
{
|
|
27
|
-
[bech32_address]: <Address String>
|
|
27
|
+
[bech32_address]: <Bech32 P2WPKH or P2WSH Address String>
|
|
28
28
|
lnd: <Authenticated LND API Object>
|
|
29
29
|
[min_confirmations]: <Minimum Confirmations Number>
|
|
30
30
|
min_height: <Minimum Transaction Inclusion Blockchain Height Number>
|
package/package.json
CHANGED
|
@@ -7,20 +7,20 @@
|
|
|
7
7
|
"url": "https://github.com/alexbosworth/lightning/issues"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
+
"@alexbosworth/blockchain": "3.2.0",
|
|
10
11
|
"@grpc/grpc-js": "1.14.3",
|
|
11
12
|
"@grpc/proto-loader": "0.8.0",
|
|
12
|
-
"@types/node": "25.0.
|
|
13
|
+
"@types/node": "25.0.10",
|
|
13
14
|
"@types/request": "2.48.13",
|
|
14
15
|
"@types/ws": "8.18.1",
|
|
15
16
|
"async": "3.2.6",
|
|
16
17
|
"asyncjs-util": "1.2.12",
|
|
17
|
-
"bitcoinjs-lib": "6.1.7",
|
|
18
18
|
"bn.js": "5.2.2",
|
|
19
19
|
"bolt07": "1.9.4",
|
|
20
20
|
"bolt09": "2.2.0",
|
|
21
21
|
"invoices": "4.0.0",
|
|
22
22
|
"psbt": "4.0.0",
|
|
23
|
-
"type-fest": "5.
|
|
23
|
+
"type-fest": "5.4.1"
|
|
24
24
|
},
|
|
25
25
|
"description": "Lightning Network client library",
|
|
26
26
|
"devDependencies": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"typescript": "5.9.3"
|
|
29
29
|
},
|
|
30
30
|
"engines": {
|
|
31
|
-
"node": ">=
|
|
31
|
+
"node": ">=20"
|
|
32
32
|
},
|
|
33
33
|
"keywords": [
|
|
34
34
|
"grpc",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"directory": "test-typescript/typescript"
|
|
52
52
|
},
|
|
53
53
|
"types": "index.d.ts",
|
|
54
|
-
"version": "
|
|
54
|
+
"version": "11.0.0"
|
|
55
55
|
}
|
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
const {rejects} = require('node:assert').strict;
|
|
2
2
|
const test = require('node:test');
|
|
3
3
|
|
|
4
|
-
const {Transaction} = require('bitcoinjs-lib');
|
|
5
|
-
|
|
6
4
|
const {deletePendingChannel} = require('./../../../lnd_methods');
|
|
7
5
|
|
|
8
|
-
const tx1 =
|
|
9
|
-
const tx2 =
|
|
10
|
-
const tx3 =
|
|
11
|
-
|
|
12
|
-
tx1.addInput(Buffer.alloc(32, 0), 0);
|
|
13
|
-
tx2.addInput(Buffer.alloc(32, 0), 0);
|
|
14
|
-
tx2.addInput(Buffer.alloc(32, 1), 0);
|
|
15
|
-
tx2.addOutput(Buffer.alloc(10), 1);
|
|
16
|
-
tx3.addInput(Buffer.alloc(32, 2), 0);
|
|
6
|
+
const tx1 = '010000000100000000000000000000000000000000000000000000000000000000000000000000000000ffffffff0000000000';
|
|
7
|
+
const tx2 = '010000000200000000000000000000000000000000000000000000000000000000000000000000000000ffffffff01010101010101010101010101010101010101010101010101010101010101010000000000ffffffff0101000000000000000a0000000000000000000000000000';
|
|
8
|
+
const tx3 = '010000000102020202020202020202020202020202020202020202020202020202020202020000000000ffffffff0000000000';
|
|
17
9
|
|
|
18
10
|
const makeArgs = overrides => {
|
|
19
11
|
const args = {
|
|
20
|
-
confirmed_transaction: tx1
|
|
12
|
+
confirmed_transaction: tx1,
|
|
21
13
|
lnd: {default: {abandonChannel: ({}, cbk) => cbk()}},
|
|
22
|
-
pending_transaction: tx2
|
|
14
|
+
pending_transaction: tx2,
|
|
23
15
|
pending_transaction_vout: 0,
|
|
24
16
|
};
|
|
25
17
|
|
|
@@ -40,7 +32,7 @@ const tests = [
|
|
|
40
32
|
error: [400, 'ExpectedValidConfirmedTxToDeleteChannel'],
|
|
41
33
|
},
|
|
42
34
|
{
|
|
43
|
-
args: makeArgs({confirmed_transaction: tx2
|
|
35
|
+
args: makeArgs({confirmed_transaction: tx2}),
|
|
44
36
|
description: 'Pending transaction must be different from confirmed tx',
|
|
45
37
|
error: [400, 'ExpectedConflictingTransactionToDeleteChannel'],
|
|
46
38
|
},
|
|
@@ -65,7 +57,7 @@ const tests = [
|
|
|
65
57
|
error: [400, 'ExpectedPendingChannelTxVoutToDeleteChannel'],
|
|
66
58
|
},
|
|
67
59
|
{
|
|
68
|
-
args: makeArgs({confirmed_transaction: tx3
|
|
60
|
+
args: makeArgs({confirmed_transaction: tx3}),
|
|
69
61
|
description: 'A conflicting tx is required',
|
|
70
62
|
error: [400, 'FailedToFindConflictingInputInConfirmedTx'],
|
|
71
63
|
},
|
|
@@ -2,10 +2,10 @@ const {rejects} = require('node:assert').strict;
|
|
|
2
2
|
const {strictEqual} = require('node:assert').strict;
|
|
3
3
|
const test = require('node:test');
|
|
4
4
|
|
|
5
|
-
const {Transaction} = require('bitcoinjs-lib');
|
|
6
|
-
|
|
7
5
|
const {broadcastChainTransaction} = require('./../../../lnd_methods');
|
|
8
6
|
|
|
7
|
+
const emptyTx = '01000000000000000000';
|
|
8
|
+
|
|
9
9
|
const tests = [
|
|
10
10
|
{
|
|
11
11
|
args: {},
|
|
@@ -20,7 +20,7 @@ const tests = [
|
|
|
20
20
|
{
|
|
21
21
|
args: {
|
|
22
22
|
lnd: {wallet: {publishTransaction: ({}, cbk) => cbk('err')}},
|
|
23
|
-
transaction:
|
|
23
|
+
transaction: emptyTx,
|
|
24
24
|
},
|
|
25
25
|
description: 'Expected error is returned',
|
|
26
26
|
error: [503, 'UnexpectedErrBroadcastingRawTx', {err: 'err'}],
|
|
@@ -28,7 +28,7 @@ const tests = [
|
|
|
28
28
|
{
|
|
29
29
|
args: {
|
|
30
30
|
lnd: {wallet: {publishTransaction: ({}, cbk) => cbk()}},
|
|
31
|
-
transaction:
|
|
31
|
+
transaction: emptyTx,
|
|
32
32
|
},
|
|
33
33
|
description: 'A result is required',
|
|
34
34
|
error: [503, 'ExpectedResultOfBroadcastRawTransaction'],
|
|
@@ -40,7 +40,7 @@ const tests = [
|
|
|
40
40
|
publishTransaction: ({}, cbk) => cbk(null, {publish_error: 'err'}),
|
|
41
41
|
},
|
|
42
42
|
},
|
|
43
|
-
transaction:
|
|
43
|
+
transaction: emptyTx,
|
|
44
44
|
},
|
|
45
45
|
description: 'Failure to broadcast error is returned',
|
|
46
46
|
error: [
|
|
@@ -58,7 +58,7 @@ const tests = [
|
|
|
58
58
|
}),
|
|
59
59
|
},
|
|
60
60
|
},
|
|
61
|
-
transaction:
|
|
61
|
+
transaction: emptyTx,
|
|
62
62
|
},
|
|
63
63
|
description: 'Minimum relay fee not met',
|
|
64
64
|
error: [
|
|
@@ -73,7 +73,7 @@ const tests = [
|
|
|
73
73
|
{
|
|
74
74
|
args: {
|
|
75
75
|
lnd: {wallet: {publishTransaction: ({}, cbk) => cbk(null, {})}},
|
|
76
|
-
transaction:
|
|
76
|
+
transaction: emptyTx,
|
|
77
77
|
},
|
|
78
78
|
description: 'A transaction is published',
|
|
79
79
|
expected: {
|
|
@@ -2,10 +2,10 @@ const {deepStrictEqual} = require('node:assert').strict;
|
|
|
2
2
|
const {rejects} = require('node:assert').strict;
|
|
3
3
|
const test = require('node:test');
|
|
4
4
|
|
|
5
|
-
const {Transaction} = require('bitcoinjs-lib');
|
|
6
|
-
|
|
7
5
|
const {getSweepTransactions} = require('./../../../lnd_methods');
|
|
8
6
|
|
|
7
|
+
const emptyTx = '01000000000000000000';
|
|
8
|
+
|
|
9
9
|
const makeDefault = overrides => {
|
|
10
10
|
const methods = {
|
|
11
11
|
getTransactions: ({}, cbk) => {
|
|
@@ -17,7 +17,7 @@ const makeDefault = overrides => {
|
|
|
17
17
|
dest_addresses: ['address'],
|
|
18
18
|
num_confirmations: 1,
|
|
19
19
|
previous_outpoints: [],
|
|
20
|
-
raw_tx_hex:
|
|
20
|
+
raw_tx_hex: emptyTx,
|
|
21
21
|
time_stamp: '1',
|
|
22
22
|
total_fees: '1',
|
|
23
23
|
tx_hash: Buffer.alloc(32).toString('hex'),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const {deepStrictEqual} = require('node:assert').strict;
|
|
2
2
|
const test = require('node:test');
|
|
3
|
+
const {throws} = require('node:assert').strict;
|
|
3
4
|
|
|
4
5
|
const scriptFromChainAddress = require('./../../../lnd_methods/onchain/script_from_chain_address');
|
|
5
6
|
|
|
@@ -61,13 +62,24 @@ const tests = [
|
|
|
61
62
|
description: 'Nothing returned for no recognized address',
|
|
62
63
|
expected: {},
|
|
63
64
|
},
|
|
65
|
+
{
|
|
66
|
+
args: {
|
|
67
|
+
bech32_address: 'bc1p5d7rjq7g6rdk2yhzks9smlaqtedr4dekq08ge8ztwac72sfr9rusxg3297',
|
|
68
|
+
},
|
|
69
|
+
description: 'Script not derived from p2tr address',
|
|
70
|
+
expected: {},
|
|
71
|
+
},
|
|
64
72
|
];
|
|
65
73
|
|
|
66
|
-
tests.forEach(({args, description, expected}) => {
|
|
74
|
+
tests.forEach(({args, description, error, expected}) => {
|
|
67
75
|
return test(description, (t, end) => {
|
|
68
|
-
|
|
76
|
+
if (!!error) {
|
|
77
|
+
throws(() => scriptFromChainAddress(args), new Error(error), 'Got error');
|
|
78
|
+
} else {
|
|
79
|
+
const {script} = scriptFromChainAddress(args);
|
|
69
80
|
|
|
70
|
-
|
|
81
|
+
deepStrictEqual(script, expected.script, 'Script derived from address');
|
|
82
|
+
}
|
|
71
83
|
|
|
72
84
|
return end();
|
|
73
85
|
});
|
|
@@ -2,16 +2,16 @@ const {deepStrictEqual} = require('node:assert').strict;
|
|
|
2
2
|
const {rejects} = require('node:assert').strict;
|
|
3
3
|
const test = require('node:test');
|
|
4
4
|
|
|
5
|
-
const {Transaction} = require('bitcoinjs-lib');
|
|
6
|
-
|
|
7
5
|
const {sendToChainOutputScripts} = require('./../../../lnd_methods');
|
|
8
6
|
|
|
7
|
+
const emptyTx = '01000000000000000000';
|
|
8
|
+
|
|
9
9
|
const makeArgs = overrides => {
|
|
10
10
|
const args = {
|
|
11
11
|
lnd: {
|
|
12
12
|
wallet: {
|
|
13
13
|
sendOutputs: ({}, cbk) => cbk(null, {
|
|
14
|
-
raw_tx:
|
|
14
|
+
raw_tx: Buffer.from(emptyTx, 'hex'),
|
|
15
15
|
}),
|
|
16
16
|
},
|
|
17
17
|
},
|
|
@@ -3,10 +3,10 @@ const {strictEqual} = require('node:assert').strict;
|
|
|
3
3
|
const test = require('node:test');
|
|
4
4
|
const {throws} = require('node:assert').strict;
|
|
5
5
|
|
|
6
|
-
const {Transaction} = require('bitcoinjs-lib');
|
|
7
|
-
|
|
8
6
|
const {subscribeToChainAddress} = require('./../../../lnd_methods');
|
|
9
7
|
|
|
8
|
+
const emptyTx = '01000000000000000000';
|
|
9
|
+
|
|
10
10
|
const tests = [
|
|
11
11
|
{
|
|
12
12
|
args: {
|
|
@@ -20,7 +20,7 @@ const tests = [
|
|
|
20
20
|
expected: {
|
|
21
21
|
block: Buffer.alloc(32).toString('hex'),
|
|
22
22
|
height: 200,
|
|
23
|
-
transaction:
|
|
23
|
+
transaction: emptyTx,
|
|
24
24
|
},
|
|
25
25
|
},
|
|
26
26
|
{
|
|
@@ -35,7 +35,7 @@ const tests = [
|
|
|
35
35
|
expected: {
|
|
36
36
|
block: Buffer.alloc(32).toString('hex'),
|
|
37
37
|
height: 200,
|
|
38
|
-
transaction:
|
|
38
|
+
transaction: emptyTx,
|
|
39
39
|
},
|
|
40
40
|
},
|
|
41
41
|
{
|
|
@@ -79,7 +79,7 @@ tests.forEach(({args, description, emitter, error, expected}) => {
|
|
|
79
79
|
conf: {
|
|
80
80
|
block_hash: Buffer.alloc(32),
|
|
81
81
|
block_height: 200,
|
|
82
|
-
raw_tx: (
|
|
82
|
+
raw_tx: Buffer.from(emptyTx, 'hex'),
|
|
83
83
|
},
|
|
84
84
|
});
|
|
85
85
|
|
|
@@ -3,10 +3,10 @@ const {strictEqual} = require('node:assert').strict;
|
|
|
3
3
|
const test = require('node:test');
|
|
4
4
|
const {throws} = require('node:assert').strict;
|
|
5
5
|
|
|
6
|
-
const {Transaction} = require('bitcoinjs-lib');
|
|
7
|
-
|
|
8
6
|
const {subscribeToChainSpend} = require('./../../../lnd_methods');
|
|
9
7
|
|
|
8
|
+
const emptyTx = '01000000000000000000';
|
|
9
|
+
|
|
10
10
|
const tests = [
|
|
11
11
|
{
|
|
12
12
|
args: {
|
|
@@ -16,11 +16,7 @@ const tests = [
|
|
|
16
16
|
transaction_vout: 0,
|
|
17
17
|
},
|
|
18
18
|
description: 'Confirmation emitted for chain spend',
|
|
19
|
-
expected: {
|
|
20
|
-
height: 200,
|
|
21
|
-
transaction: (new Transaction()).toHex(),
|
|
22
|
-
vin: 0,
|
|
23
|
-
},
|
|
19
|
+
expected: {height: 200, transaction: emptyTx, vin: 0},
|
|
24
20
|
},
|
|
25
21
|
{
|
|
26
22
|
args: {},
|
|
@@ -63,7 +59,7 @@ tests.forEach(({args, description, error, expected}) => {
|
|
|
63
59
|
|
|
64
60
|
emitter.emit('data', {
|
|
65
61
|
spend: {
|
|
66
|
-
raw_spending_tx: (
|
|
62
|
+
raw_spending_tx: Buffer.from(emptyTx, 'hex'),
|
|
67
63
|
spending_height: 200,
|
|
68
64
|
spending_input_index: 0,
|
|
69
65
|
},
|
|
@@ -4,10 +4,9 @@ import {
|
|
|
4
4
|
broadcastChainTransaction,
|
|
5
5
|
BroadcastChainTransactionResult,
|
|
6
6
|
} from '../../lnd_methods';
|
|
7
|
-
import {Transaction} from 'bitcoinjs-lib';
|
|
8
7
|
|
|
9
8
|
const lnd = {} as AuthenticatedLnd;
|
|
10
|
-
const transaction =
|
|
9
|
+
const transaction = '01000000000000000000';
|
|
11
10
|
const description = 'description';
|
|
12
11
|
|
|
13
12
|
expectError(broadcastChainTransaction());
|