lightning 10.21.0 → 10.22.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
|
@@ -4,6 +4,8 @@ import type {
|
|
|
4
4
|
} from '../../typescript';
|
|
5
5
|
|
|
6
6
|
export type CreateFundedPsbtArgs = AuthenticatedLightningArgs<{
|
|
7
|
+
/** Change Address Address Format String */
|
|
8
|
+
change_format?: 'p2tr';
|
|
7
9
|
/** Chain Fee Tokens Per Virtual Byte Number */
|
|
8
10
|
fee_tokens_per_vbyte?: number;
|
|
9
11
|
inputs?: Array<{
|
|
@@ -29,7 +31,7 @@ export type CreateFundedPsbtArgs = AuthenticatedLightningArgs<{
|
|
|
29
31
|
/** Spendable Lock Time on Transaction Number */
|
|
30
32
|
timelock?: number;
|
|
31
33
|
/** Select Inputs Using Selection Methodology Type String */
|
|
32
|
-
utxo_selection?:
|
|
34
|
+
utxo_selection?: 'largest' | 'random';
|
|
33
35
|
/** Transaction Version Number */
|
|
34
36
|
version?: number;
|
|
35
37
|
}>;
|
|
@@ -46,6 +48,8 @@ export interface CreateFundedPsbtResult {
|
|
|
46
48
|
*
|
|
47
49
|
* `utxo_selection` methods: 'largest', 'random'
|
|
48
50
|
*
|
|
51
|
+
* `change_format` options: `p2tr` (only one change type is supported)
|
|
52
|
+
*
|
|
49
53
|
* Requires `onchain:write` permission
|
|
50
54
|
*
|
|
51
55
|
* Requires LND built with `walletrpc` tag
|
|
@@ -5,12 +5,13 @@ const {returnResult} = require('asyncjs-util');
|
|
|
5
5
|
const {isLnd} = require('./../../lnd_requests');
|
|
6
6
|
|
|
7
7
|
const bufferAsHex = buffer => buffer.toString('hex');
|
|
8
|
-
const defaultChangeType = 'CHANGE_ADDRESS_TYPE_P2TR';
|
|
8
|
+
const defaultChangeType = () => 'CHANGE_ADDRESS_TYPE_P2TR';
|
|
9
9
|
const defaultConfirmationTarget = 6;
|
|
10
10
|
const errorUnsupported = 'transaction template missing, need to specify either PSBT or raw TX template';
|
|
11
11
|
const hexAsBuffer = hex => Buffer.from(hex, 'hex');
|
|
12
12
|
const indexNotFound = -1;
|
|
13
13
|
const {isBuffer} = Buffer;
|
|
14
|
+
const isKnownChangeFormat = format => !format || format === 'p2tr';
|
|
14
15
|
const method = 'fundPsbt';
|
|
15
16
|
const strategy = type => !type ? undefined : `STRATEGY_${type.toUpperCase()}`;
|
|
16
17
|
const type = 'wallet';
|
|
@@ -20,6 +21,8 @@ const unconfirmedConfirmationsCount = 0;
|
|
|
20
21
|
|
|
21
22
|
When specifying local inputs, they must be locked before using
|
|
22
23
|
|
|
24
|
+
`change_format` options: `p2tr` (only one change type is supported)
|
|
25
|
+
|
|
23
26
|
`utxo_selection` methods: 'largest', 'random'
|
|
24
27
|
|
|
25
28
|
Requires `onchain:write` permission
|
|
@@ -29,6 +32,7 @@ const unconfirmedConfirmationsCount = 0;
|
|
|
29
32
|
This method is not supported on LND 0.17.5 or below
|
|
30
33
|
|
|
31
34
|
{
|
|
35
|
+
[change_format]: <Change Address Address Format String>
|
|
32
36
|
[fee_tokens_per_vbyte]: <Chain Fee Tokens Per Virtual Byte Number>
|
|
33
37
|
[inputs]: [{
|
|
34
38
|
[sequence]: <Sequence Number>
|
|
@@ -58,6 +62,10 @@ module.exports = (args, cbk) => {
|
|
|
58
62
|
return asyncAuto({
|
|
59
63
|
// Check arguments
|
|
60
64
|
validate: cbk => {
|
|
65
|
+
if (!isKnownChangeFormat(args.change_format)) {
|
|
66
|
+
return cbk([400, 'ExpectedKnownChangeFormatToFundPsbt']);
|
|
67
|
+
}
|
|
68
|
+
|
|
61
69
|
if (!isLnd({method, type, lnd: args.lnd})) {
|
|
62
70
|
return cbk([400, 'ExpectedAuthenticatedLndToCreateFundedPsbt']);
|
|
63
71
|
}
|
|
@@ -97,6 +105,7 @@ module.exports = (args, cbk) => {
|
|
|
97
105
|
// Construct the PSBT that is needed for coin select type funding
|
|
98
106
|
funding: ['validate', ({}, cbk) => {
|
|
99
107
|
const {psbt} = createPsbt({
|
|
108
|
+
change_type: defaultChangeType(args.change_type),
|
|
100
109
|
outputs: args.outputs || [],
|
|
101
110
|
timelock: args.timelock,
|
|
102
111
|
utxos: (args.inputs || []).map(input => ({
|
|
@@ -7,6 +7,8 @@ import {MergeExclusive} from 'type-fest';
|
|
|
7
7
|
|
|
8
8
|
export type FundPsbtArgs = AuthenticatedLightningArgs<
|
|
9
9
|
{
|
|
10
|
+
/** Change Address Address Format String */
|
|
11
|
+
change_format?: 'p2tr';
|
|
10
12
|
/** Chain Fee Tokens Per Virtual Byte */
|
|
11
13
|
fee_tokens_per_vbyte?: number;
|
|
12
14
|
inputs?: {
|
|
@@ -15,12 +17,12 @@ export type FundPsbtArgs = AuthenticatedLightningArgs<
|
|
|
15
17
|
/** Unspent Transaction Output Index */
|
|
16
18
|
transaction_vout: number;
|
|
17
19
|
}[];
|
|
18
|
-
|
|
19
20
|
/** Spend UTXOs With Minimum Confirmations */
|
|
20
21
|
min_confirmations?: number;
|
|
21
|
-
|
|
22
22
|
/** Confirmations To Wait */
|
|
23
23
|
target_confirmations?: number;
|
|
24
|
+
/** Select UTXOs Using Method String */
|
|
25
|
+
utxo_selection?: 'largest' | 'random';
|
|
24
26
|
} & MergeExclusive<
|
|
25
27
|
{
|
|
26
28
|
/** Existing PSBT Hex */
|
|
@@ -58,8 +60,6 @@ export type FundPsbtResult = {
|
|
|
58
60
|
}[];
|
|
59
61
|
/** Unsigned PSBT Hex */
|
|
60
62
|
psbt: string;
|
|
61
|
-
/** Select UTXOs Using Method String */
|
|
62
|
-
utxo_selection?: UtxoSelection;
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
/**
|
|
@@ -69,6 +69,10 @@ export type FundPsbtResult = {
|
|
|
69
69
|
*
|
|
70
70
|
* If there are no inputs passed, internal UTXOs will be selected and locked
|
|
71
71
|
*
|
|
72
|
+
* `utxo_selection` methods: 'largest', 'random'
|
|
73
|
+
*
|
|
74
|
+
* `change_format` options: `p2tr` (only one change type is supported)
|
|
75
|
+
*
|
|
72
76
|
* Requires `onchain:write` permission
|
|
73
77
|
*
|
|
74
78
|
* Requires LND built with `walletrpc` tag
|
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.12.
|
|
10
|
+
"@grpc/grpc-js": "1.12.2",
|
|
11
11
|
"@grpc/proto-loader": "0.7.13",
|
|
12
12
|
"@types/node": "22.7.5",
|
|
13
13
|
"@types/request": "2.48.12",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"description": "Lightning Network client library",
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"tsd": "0.31.2",
|
|
30
|
-
"typescript": "5.6.
|
|
30
|
+
"typescript": "5.6.3"
|
|
31
31
|
},
|
|
32
32
|
"engines": {
|
|
33
33
|
"node": ">=18"
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"directory": "test/typescript"
|
|
54
54
|
},
|
|
55
55
|
"types": "index.d.ts",
|
|
56
|
-
"version": "10.
|
|
56
|
+
"version": "10.22.1"
|
|
57
57
|
}
|
|
@@ -48,6 +48,11 @@ const makeExpected = overrides => {
|
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
const tests = [
|
|
51
|
+
{
|
|
52
|
+
args: makeArgs({change_format: 'change_format'}),
|
|
53
|
+
description: 'A valid change format is required',
|
|
54
|
+
error: [400, 'ExpectedKnownChangeFormatToFundPsbt'],
|
|
55
|
+
},
|
|
51
56
|
{
|
|
52
57
|
args: makeArgs({lnd: undefined}),
|
|
53
58
|
description: 'An LND object is required',
|