@btc-vision/bitcoin 6.3.6 → 6.4.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/.mocharc.json +13 -0
- package/browser/address.d.ts +1 -1
- package/browser/index.js +1 -1
- package/browser/index.js.LICENSE.txt +3 -3
- package/browser/networks.d.ts +1 -0
- package/build/address.d.ts +2 -1
- package/build/address.js +68 -13
- package/build/block.js +2 -2
- package/build/bufferutils.js +5 -5
- package/build/networks.d.ts +1 -0
- package/build/networks.js +11 -0
- package/build/psbt/psbtutils.js +2 -2
- package/build/psbt.js +3 -7
- package/package.json +26 -26
- package/src/address.ts +91 -15
- package/src/block.ts +2 -2
- package/src/bufferutils.ts +15 -7
- package/src/index.ts +86 -86
- package/src/networks.ts +12 -0
- package/src/psbt/bip371.ts +441 -441
- package/src/psbt/psbtutils.ts +320 -319
- package/src/psbt.ts +8 -8
- package/test/address.spec.ts +55 -77
- package/test/bitcoin.core.spec.ts +47 -69
- package/test/block.spec.ts +23 -46
- package/test/bufferutils.spec.ts +32 -95
- package/test/crypto.spec.ts +9 -15
- package/test/fixtures/address.json +3 -3
- package/test/integration/addresses.spec.ts +12 -24
- package/test/integration/bip32.spec.ts +10 -31
- package/test/integration/blocks.spec.ts +2 -2
- package/test/integration/cltv.spec.ts +21 -63
- package/test/integration/csv.spec.ts +30 -105
- package/test/integration/payments.spec.ts +16 -41
- package/test/integration/taproot.spec.ts +31 -75
- package/test/integration/transactions.spec.ts +37 -138
- package/test/payments.spec.ts +95 -106
- package/test/payments.utils.ts +20 -63
- package/test/psbt.spec.ts +100 -229
- package/test/script.spec.ts +26 -50
- package/test/script_number.spec.ts +6 -9
- package/test/script_signature.spec.ts +7 -7
- package/test/transaction.spec.ts +46 -96
- package/test/ts-node-register.js +3 -1
- package/test/tsconfig.json +4 -1
- package/test/types.spec.ts +7 -12
- package/.nyc_output/6368a5b2-daa5-4821-8ed0-b742d6fc7eab.json +0 -1
- package/.nyc_output/processinfo/6368a5b2-daa5-4821-8ed0-b742d6fc7eab.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
- package/test/address.spec.js +0 -124
- package/test/bitcoin.core.spec.js +0 -170
- package/test/block.spec.js +0 -141
- package/test/bufferutils.spec.js +0 -427
- package/test/crypto.spec.js +0 -41
- package/test/integration/_regtest.js +0 -7
- package/test/integration/addresses.spec.js +0 -116
- package/test/integration/bip32.spec.js +0 -85
- package/test/integration/blocks.spec.js +0 -26
- package/test/integration/cltv.spec.js +0 -199
- package/test/integration/csv.spec.js +0 -362
- package/test/integration/payments.spec.js +0 -98
- package/test/integration/taproot.spec.js +0 -532
- package/test/integration/transactions.spec.js +0 -561
- package/test/payments.spec.js +0 -97
- package/test/payments.utils.js +0 -190
- package/test/psbt.spec.js +0 -1044
- package/test/script.spec.js +0 -151
- package/test/script_number.spec.js +0 -24
- package/test/script_signature.spec.js +0 -52
- package/test/transaction.spec.js +0 -269
- package/test/types.spec.js +0 -46
package/test/psbt.spec.ts
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import
|
|
2
|
-
import BIP32Factory from 'bip32';
|
|
1
|
+
import assert from 'assert';
|
|
2
|
+
import { BIP32Factory } from 'bip32';
|
|
3
3
|
import * as ecc from 'tiny-secp256k1';
|
|
4
4
|
import * as crypto from 'crypto';
|
|
5
|
-
import ECPairFactory from 'ecpair';
|
|
5
|
+
import { ECPairFactory } from 'ecpair';
|
|
6
6
|
import { describe, it } from 'mocha';
|
|
7
7
|
|
|
8
|
-
import { convertScriptTree } from './payments.utils';
|
|
9
|
-
import { LEAF_VERSION_TAPSCRIPT } from '../src/payments/bip341';
|
|
10
|
-
import { tapTreeFromList, tapTreeToList } from '../src/psbt/bip371';
|
|
11
|
-
import { Taptree } from '../src/types';
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
import { convertScriptTree } from './payments.utils.js';
|
|
9
|
+
import { LEAF_VERSION_TAPSCRIPT } from '../src/payments/bip341.js';
|
|
10
|
+
import { tapTreeFromList, tapTreeToList } from '../src/psbt/bip371.js';
|
|
11
|
+
import { Taptree } from '../src/types.js';
|
|
12
|
+
import {
|
|
13
|
+
initEccLib,
|
|
14
|
+
networks as NETWORKS,
|
|
15
|
+
payments,
|
|
16
|
+
Psbt,
|
|
17
|
+
Signer,
|
|
18
|
+
SignerAsync,
|
|
19
|
+
} from '../src/index.js';
|
|
20
|
+
|
|
21
|
+
import preFixtures from './fixtures/psbt.json' with { type: 'json' };
|
|
22
|
+
import taprootFixtures from './fixtures/p2tr.json' with { type: 'json' };
|
|
17
23
|
|
|
18
24
|
const bip32 = BIP32Factory(ecc);
|
|
19
25
|
const ECPair = ECPairFactory(ecc);
|
|
20
26
|
|
|
21
|
-
const validator = (
|
|
22
|
-
pubkey
|
|
23
|
-
msghash: Buffer,
|
|
24
|
-
signature: Buffer,
|
|
25
|
-
): boolean => ECPair.fromPublicKey(pubkey).verify(msghash, signature);
|
|
27
|
+
const validator = (pubkey: Buffer, msghash: Buffer, signature: Buffer): boolean =>
|
|
28
|
+
ECPair.fromPublicKey(pubkey).verify(msghash, signature);
|
|
26
29
|
|
|
27
|
-
const schnorrValidator = (
|
|
28
|
-
pubkey
|
|
29
|
-
msghash: Buffer,
|
|
30
|
-
signature: Buffer,
|
|
31
|
-
): boolean => ecc.verifySchnorr(msghash, pubkey, signature);
|
|
30
|
+
const schnorrValidator = (pubkey: Buffer, msghash: Buffer, signature: Buffer): boolean =>
|
|
31
|
+
ecc.verifySchnorr(msghash, pubkey, signature);
|
|
32
32
|
|
|
33
33
|
const initBuffers = (object: any): typeof preFixtures =>
|
|
34
34
|
JSON.parse(JSON.stringify(object), (_, value) => {
|
|
@@ -44,8 +44,7 @@ const initBuffers = (object: any): typeof preFixtures =>
|
|
|
44
44
|
|
|
45
45
|
const fixtures = initBuffers(preFixtures);
|
|
46
46
|
|
|
47
|
-
const upperCaseFirstLetter = (str: string): string =>
|
|
48
|
-
str.replace(/^./, s => s.toUpperCase());
|
|
47
|
+
const upperCaseFirstLetter = (str: string): string => str.replace(/^./, (s) => s.toUpperCase());
|
|
49
48
|
|
|
50
49
|
const toAsyncSigner = (signer: Signer): SignerAsync => {
|
|
51
50
|
return {
|
|
@@ -57,7 +56,7 @@ const toAsyncSigner = (signer: Signer): SignerAsync => {
|
|
|
57
56
|
const r = signer.sign(hash, lowerR);
|
|
58
57
|
resolve(r);
|
|
59
58
|
} catch (e) {
|
|
60
|
-
rejects(e);
|
|
59
|
+
rejects(e as Error);
|
|
61
60
|
}
|
|
62
61
|
}, 10);
|
|
63
62
|
});
|
|
@@ -84,7 +83,7 @@ describe(`Psbt`, () => {
|
|
|
84
83
|
initEccLib(undefined);
|
|
85
84
|
});
|
|
86
85
|
describe('BIP174 Test Vectors', () => {
|
|
87
|
-
fixtures.bip174.invalid.forEach(f => {
|
|
86
|
+
fixtures.bip174.invalid.forEach((f) => {
|
|
88
87
|
it(`Invalid: ${f.description}`, () => {
|
|
89
88
|
assert.throws(() => {
|
|
90
89
|
Psbt.fromBase64(f.psbt);
|
|
@@ -92,7 +91,7 @@ describe(`Psbt`, () => {
|
|
|
92
91
|
});
|
|
93
92
|
});
|
|
94
93
|
|
|
95
|
-
fixtures.bip174.valid.forEach(f => {
|
|
94
|
+
fixtures.bip174.valid.forEach((f) => {
|
|
96
95
|
it(`Valid: ${f.description}`, () => {
|
|
97
96
|
assert.doesNotThrow(() => {
|
|
98
97
|
Psbt.fromBase64(f.psbt);
|
|
@@ -100,7 +99,7 @@ describe(`Psbt`, () => {
|
|
|
100
99
|
});
|
|
101
100
|
});
|
|
102
101
|
|
|
103
|
-
fixtures.bip174.failSignChecks.forEach(f => {
|
|
102
|
+
fixtures.bip174.failSignChecks.forEach((f) => {
|
|
104
103
|
const keyPair = ECPair.makeRandom();
|
|
105
104
|
it(`Fails Signer checks: ${f.description}`, () => {
|
|
106
105
|
const psbt = Psbt.fromBase64(f.psbt);
|
|
@@ -110,7 +109,7 @@ describe(`Psbt`, () => {
|
|
|
110
109
|
});
|
|
111
110
|
});
|
|
112
111
|
|
|
113
|
-
fixtures.bip174.creator.forEach(f => {
|
|
112
|
+
fixtures.bip174.creator.forEach((f) => {
|
|
114
113
|
it('Creates expected PSBT', () => {
|
|
115
114
|
const psbt = new Psbt();
|
|
116
115
|
for (const input of f.inputs) {
|
|
@@ -124,7 +123,7 @@ describe(`Psbt`, () => {
|
|
|
124
123
|
});
|
|
125
124
|
});
|
|
126
125
|
|
|
127
|
-
fixtures.bip174.updater.forEach(f => {
|
|
126
|
+
fixtures.bip174.updater.forEach((f) => {
|
|
128
127
|
it('Updates PSBT to the expected result', () => {
|
|
129
128
|
if (f.isTaproot) initEccLib(ecc);
|
|
130
129
|
const psbt = Psbt.fromBase64(f.psbt);
|
|
@@ -143,7 +142,7 @@ describe(`Psbt`, () => {
|
|
|
143
142
|
});
|
|
144
143
|
});
|
|
145
144
|
|
|
146
|
-
fixtures.bip174.signer.forEach(f => {
|
|
145
|
+
fixtures.bip174.signer.forEach((f) => {
|
|
147
146
|
it('Signs PSBT to the expected result', () => {
|
|
148
147
|
if (f.isTaproot) initEccLib(ecc);
|
|
149
148
|
const psbt = Psbt.fromBase64(f.psbt);
|
|
@@ -165,9 +164,9 @@ describe(`Psbt`, () => {
|
|
|
165
164
|
});
|
|
166
165
|
});
|
|
167
166
|
|
|
168
|
-
fixtures.bip174.combiner.forEach(f => {
|
|
167
|
+
fixtures.bip174.combiner.forEach((f) => {
|
|
169
168
|
it('Combines two PSBTs to the expected result', () => {
|
|
170
|
-
const psbts = f.psbts.map(psbt => Psbt.fromBase64(psbt));
|
|
169
|
+
const psbts = f.psbts.map((psbt) => Psbt.fromBase64(psbt));
|
|
171
170
|
|
|
172
171
|
psbts[0].combine(psbts[1]);
|
|
173
172
|
|
|
@@ -179,7 +178,7 @@ describe(`Psbt`, () => {
|
|
|
179
178
|
});
|
|
180
179
|
});
|
|
181
180
|
|
|
182
|
-
fixtures.bip174.finalizer.forEach(f => {
|
|
181
|
+
fixtures.bip174.finalizer.forEach((f) => {
|
|
183
182
|
it('Finalizes inputs and gives the expected PSBT', () => {
|
|
184
183
|
if (f.isTaproot) initEccLib(ecc);
|
|
185
184
|
const psbt = Psbt.fromBase64(f.psbt);
|
|
@@ -190,7 +189,7 @@ describe(`Psbt`, () => {
|
|
|
190
189
|
});
|
|
191
190
|
});
|
|
192
191
|
|
|
193
|
-
fixtures.bip174.extractor.forEach(f => {
|
|
192
|
+
fixtures.bip174.extractor.forEach((f) => {
|
|
194
193
|
it('Extracts the expected transaction from a PSBT', () => {
|
|
195
194
|
const psbt1 = Psbt.fromBase64(f.psbt);
|
|
196
195
|
const transaction1 = psbt1.extractTransaction(true).toHex();
|
|
@@ -229,13 +228,11 @@ describe(`Psbt`, () => {
|
|
|
229
228
|
});
|
|
230
229
|
|
|
231
230
|
describe('signInputAsync', () => {
|
|
232
|
-
fixtures.signInput.checks.forEach(f => {
|
|
231
|
+
fixtures.signInput.checks.forEach((f) => {
|
|
233
232
|
it(f.description, async () => {
|
|
234
233
|
if (f.isTaproot) initEccLib(ecc);
|
|
235
234
|
if (f.shouldSign) {
|
|
236
|
-
const psbtThatShouldsign = Psbt.fromBase64(
|
|
237
|
-
f.shouldSign.psbt,
|
|
238
|
-
);
|
|
235
|
+
const psbtThatShouldsign = Psbt.fromBase64(f.shouldSign.psbt);
|
|
239
236
|
await assert.doesNotReject(async () => {
|
|
240
237
|
await psbtThatShouldsign.signInputAsync(
|
|
241
238
|
f.shouldSign.inputToCheck,
|
|
@@ -243,10 +240,7 @@ describe(`Psbt`, () => {
|
|
|
243
240
|
f.shouldSign.sighashTypes || undefined,
|
|
244
241
|
);
|
|
245
242
|
if (f.shouldSign.result) {
|
|
246
|
-
assert.strictEqual(
|
|
247
|
-
psbtThatShouldsign.toBase64(),
|
|
248
|
-
f.shouldSign.result,
|
|
249
|
-
);
|
|
243
|
+
assert.strictEqual(psbtThatShouldsign.toBase64(), f.shouldSign.result);
|
|
250
244
|
}
|
|
251
245
|
});
|
|
252
246
|
const failMessage = f.isTaproot
|
|
@@ -255,18 +249,14 @@ describe(`Psbt`, () => {
|
|
|
255
249
|
await assert.rejects(async () => {
|
|
256
250
|
await psbtThatShouldsign.signInputAsync(
|
|
257
251
|
f.shouldSign.inputToCheck,
|
|
258
|
-
failedAsyncSigner(
|
|
259
|
-
ECPair.fromWIF(f.shouldSign.WIF).publicKey,
|
|
260
|
-
),
|
|
252
|
+
failedAsyncSigner(ECPair.fromWIF(f.shouldSign.WIF).publicKey),
|
|
261
253
|
f.shouldSign.sighashTypes || undefined,
|
|
262
254
|
);
|
|
263
255
|
}, failMessage);
|
|
264
256
|
}
|
|
265
257
|
|
|
266
258
|
if (f.shouldThrow) {
|
|
267
|
-
const psbtThatShouldThrow = Psbt.fromBase64(
|
|
268
|
-
f.shouldThrow.psbt,
|
|
269
|
-
);
|
|
259
|
+
const psbtThatShouldThrow = Psbt.fromBase64(f.shouldThrow.psbt);
|
|
270
260
|
await assert.rejects(async () => {
|
|
271
261
|
await psbtThatShouldThrow.signInputAsync(
|
|
272
262
|
f.shouldThrow.inputToCheck,
|
|
@@ -292,13 +282,11 @@ describe(`Psbt`, () => {
|
|
|
292
282
|
});
|
|
293
283
|
|
|
294
284
|
describe('signInput', () => {
|
|
295
|
-
fixtures.signInput.checks.forEach(f => {
|
|
285
|
+
fixtures.signInput.checks.forEach((f) => {
|
|
296
286
|
it(f.description, () => {
|
|
297
287
|
if (f.isTaproot) initEccLib(ecc);
|
|
298
288
|
if (f.shouldSign) {
|
|
299
|
-
const psbtThatShouldsign = Psbt.fromBase64(
|
|
300
|
-
f.shouldSign.psbt,
|
|
301
|
-
);
|
|
289
|
+
const psbtThatShouldsign = Psbt.fromBase64(f.shouldSign.psbt);
|
|
302
290
|
assert.doesNotThrow(() => {
|
|
303
291
|
psbtThatShouldsign.signInput(
|
|
304
292
|
f.shouldSign.inputToCheck,
|
|
@@ -309,9 +297,7 @@ describe(`Psbt`, () => {
|
|
|
309
297
|
}
|
|
310
298
|
|
|
311
299
|
if (f.shouldThrow) {
|
|
312
|
-
const psbtThatShouldThrow = Psbt.fromBase64(
|
|
313
|
-
f.shouldThrow.psbt,
|
|
314
|
-
);
|
|
300
|
+
const psbtThatShouldThrow = Psbt.fromBase64(f.shouldThrow.psbt);
|
|
315
301
|
assert.throws(() => {
|
|
316
302
|
psbtThatShouldThrow.signInput(
|
|
317
303
|
f.shouldThrow.inputToCheck,
|
|
@@ -320,9 +306,7 @@ describe(`Psbt`, () => {
|
|
|
320
306
|
);
|
|
321
307
|
}, new RegExp(f.shouldThrow.errorMessage));
|
|
322
308
|
assert.throws(() => {
|
|
323
|
-
(psbtThatShouldThrow.signInput as any)(
|
|
324
|
-
f.shouldThrow.inputToCheck,
|
|
325
|
-
);
|
|
309
|
+
(psbtThatShouldThrow.signInput as any)(f.shouldThrow.inputToCheck);
|
|
326
310
|
}, new RegExp('Need Signer to sign input'));
|
|
327
311
|
}
|
|
328
312
|
});
|
|
@@ -330,14 +314,12 @@ describe(`Psbt`, () => {
|
|
|
330
314
|
});
|
|
331
315
|
|
|
332
316
|
describe('signAllInputsAsync', () => {
|
|
333
|
-
fixtures.signInput.checks.forEach(f => {
|
|
317
|
+
fixtures.signInput.checks.forEach((f) => {
|
|
334
318
|
if (f.description === 'checks the input exists') return;
|
|
335
319
|
it(f.description, async () => {
|
|
336
320
|
if (f.isTaproot) initEccLib(ecc);
|
|
337
321
|
if (f.shouldSign) {
|
|
338
|
-
const psbtThatShouldsign = Psbt.fromBase64(
|
|
339
|
-
f.shouldSign.psbt,
|
|
340
|
-
);
|
|
322
|
+
const psbtThatShouldsign = Psbt.fromBase64(f.shouldSign.psbt);
|
|
341
323
|
await assert.doesNotReject(async () => {
|
|
342
324
|
await psbtThatShouldsign.signAllInputsAsync(
|
|
343
325
|
ECPair.fromWIF(f.shouldSign.WIF),
|
|
@@ -347,9 +329,7 @@ describe(`Psbt`, () => {
|
|
|
347
329
|
}
|
|
348
330
|
|
|
349
331
|
if (f.shouldThrow) {
|
|
350
|
-
const psbtThatShouldThrow = Psbt.fromBase64(
|
|
351
|
-
f.shouldThrow.psbt,
|
|
352
|
-
);
|
|
332
|
+
const psbtThatShouldThrow = Psbt.fromBase64(f.shouldThrow.psbt);
|
|
353
333
|
await assert.rejects(async () => {
|
|
354
334
|
await psbtThatShouldThrow.signAllInputsAsync(
|
|
355
335
|
ECPair.fromWIF(f.shouldThrow.WIF),
|
|
@@ -365,14 +345,12 @@ describe(`Psbt`, () => {
|
|
|
365
345
|
});
|
|
366
346
|
|
|
367
347
|
describe('signAllInputs', () => {
|
|
368
|
-
fixtures.signInput.checks.forEach(f => {
|
|
348
|
+
fixtures.signInput.checks.forEach((f) => {
|
|
369
349
|
if (f.description === 'checks the input exists') return;
|
|
370
350
|
it(f.description, () => {
|
|
371
351
|
if (f.isTaproot) initEccLib(ecc);
|
|
372
352
|
if (f.shouldSign) {
|
|
373
|
-
const psbtThatShouldsign = Psbt.fromBase64(
|
|
374
|
-
f.shouldSign.psbt,
|
|
375
|
-
);
|
|
353
|
+
const psbtThatShouldsign = Psbt.fromBase64(f.shouldSign.psbt);
|
|
376
354
|
assert.doesNotThrow(() => {
|
|
377
355
|
psbtThatShouldsign.signAllInputs(
|
|
378
356
|
ECPair.fromWIF(f.shouldSign.WIF),
|
|
@@ -382,9 +360,7 @@ describe(`Psbt`, () => {
|
|
|
382
360
|
}
|
|
383
361
|
|
|
384
362
|
if (f.shouldThrow) {
|
|
385
|
-
const psbtThatShouldThrow = Psbt.fromBase64(
|
|
386
|
-
f.shouldThrow.psbt,
|
|
387
|
-
);
|
|
363
|
+
const psbtThatShouldThrow = Psbt.fromBase64(f.shouldThrow.psbt);
|
|
388
364
|
assert.throws(() => {
|
|
389
365
|
psbtThatShouldThrow.signAllInputs(
|
|
390
366
|
ECPair.fromWIF(f.shouldThrow.WIF),
|
|
@@ -400,12 +376,10 @@ describe(`Psbt`, () => {
|
|
|
400
376
|
});
|
|
401
377
|
|
|
402
378
|
describe('signInputHDAsync', () => {
|
|
403
|
-
fixtures.signInputHD.checks.forEach(f => {
|
|
379
|
+
fixtures.signInputHD.checks.forEach((f) => {
|
|
404
380
|
it(f.description, async () => {
|
|
405
381
|
if (f.shouldSign) {
|
|
406
|
-
const psbtThatShouldsign = Psbt.fromBase64(
|
|
407
|
-
f.shouldSign.psbt,
|
|
408
|
-
);
|
|
382
|
+
const psbtThatShouldsign = Psbt.fromBase64(f.shouldSign.psbt);
|
|
409
383
|
await assert.doesNotReject(async () => {
|
|
410
384
|
await psbtThatShouldsign.signInputHDAsync(
|
|
411
385
|
f.shouldSign.inputToCheck,
|
|
@@ -416,9 +390,7 @@ describe(`Psbt`, () => {
|
|
|
416
390
|
}
|
|
417
391
|
|
|
418
392
|
if (f.shouldThrow) {
|
|
419
|
-
const psbtThatShouldThrow = Psbt.fromBase64(
|
|
420
|
-
f.shouldThrow.psbt,
|
|
421
|
-
);
|
|
393
|
+
const psbtThatShouldThrow = Psbt.fromBase64(f.shouldThrow.psbt);
|
|
422
394
|
await assert.rejects(async () => {
|
|
423
395
|
await psbtThatShouldThrow.signInputHDAsync(
|
|
424
396
|
f.shouldThrow.inputToCheck,
|
|
@@ -437,12 +409,10 @@ describe(`Psbt`, () => {
|
|
|
437
409
|
});
|
|
438
410
|
|
|
439
411
|
describe('signInputHD', () => {
|
|
440
|
-
fixtures.signInputHD.checks.forEach(f => {
|
|
412
|
+
fixtures.signInputHD.checks.forEach((f) => {
|
|
441
413
|
it(f.description, () => {
|
|
442
414
|
if (f.shouldSign) {
|
|
443
|
-
const psbtThatShouldsign = Psbt.fromBase64(
|
|
444
|
-
f.shouldSign.psbt,
|
|
445
|
-
);
|
|
415
|
+
const psbtThatShouldsign = Psbt.fromBase64(f.shouldSign.psbt);
|
|
446
416
|
assert.doesNotThrow(() => {
|
|
447
417
|
psbtThatShouldsign.signInputHD(
|
|
448
418
|
f.shouldSign.inputToCheck,
|
|
@@ -453,9 +423,7 @@ describe(`Psbt`, () => {
|
|
|
453
423
|
}
|
|
454
424
|
|
|
455
425
|
if (f.shouldThrow) {
|
|
456
|
-
const psbtThatShouldThrow = Psbt.fromBase64(
|
|
457
|
-
f.shouldThrow.psbt,
|
|
458
|
-
);
|
|
426
|
+
const psbtThatShouldThrow = Psbt.fromBase64(f.shouldThrow.psbt);
|
|
459
427
|
assert.throws(() => {
|
|
460
428
|
psbtThatShouldThrow.signInputHD(
|
|
461
429
|
f.shouldThrow.inputToCheck,
|
|
@@ -464,9 +432,7 @@ describe(`Psbt`, () => {
|
|
|
464
432
|
);
|
|
465
433
|
}, new RegExp(f.shouldThrow.errorMessage));
|
|
466
434
|
assert.throws(() => {
|
|
467
|
-
(psbtThatShouldThrow.signInputHD as any)(
|
|
468
|
-
f.shouldThrow.inputToCheck,
|
|
469
|
-
);
|
|
435
|
+
(psbtThatShouldThrow.signInputHD as any)(f.shouldThrow.inputToCheck);
|
|
470
436
|
}, new RegExp('Need HDSigner to sign input'));
|
|
471
437
|
}
|
|
472
438
|
});
|
|
@@ -474,12 +440,10 @@ describe(`Psbt`, () => {
|
|
|
474
440
|
});
|
|
475
441
|
|
|
476
442
|
describe('signAllInputsHDAsync', () => {
|
|
477
|
-
fixtures.signInputHD.checks.forEach(f => {
|
|
443
|
+
fixtures.signInputHD.checks.forEach((f) => {
|
|
478
444
|
it(f.description, async () => {
|
|
479
445
|
if (f.shouldSign) {
|
|
480
|
-
const psbtThatShouldsign = Psbt.fromBase64(
|
|
481
|
-
f.shouldSign.psbt,
|
|
482
|
-
);
|
|
446
|
+
const psbtThatShouldsign = Psbt.fromBase64(f.shouldSign.psbt);
|
|
483
447
|
await assert.doesNotReject(async () => {
|
|
484
448
|
await psbtThatShouldsign.signAllInputsHDAsync(
|
|
485
449
|
bip32.fromBase58(f.shouldSign.xprv),
|
|
@@ -489,9 +453,7 @@ describe(`Psbt`, () => {
|
|
|
489
453
|
}
|
|
490
454
|
|
|
491
455
|
if (f.shouldThrow) {
|
|
492
|
-
const psbtThatShouldThrow = Psbt.fromBase64(
|
|
493
|
-
f.shouldThrow.psbt,
|
|
494
|
-
);
|
|
456
|
+
const psbtThatShouldThrow = Psbt.fromBase64(f.shouldThrow.psbt);
|
|
495
457
|
await assert.rejects(async () => {
|
|
496
458
|
await psbtThatShouldThrow.signAllInputsHDAsync(
|
|
497
459
|
bip32.fromBase58(f.shouldThrow.xprv),
|
|
@@ -499,9 +461,7 @@ describe(`Psbt`, () => {
|
|
|
499
461
|
);
|
|
500
462
|
}, new RegExp('No inputs were signed'));
|
|
501
463
|
await assert.rejects(async () => {
|
|
502
|
-
await (
|
|
503
|
-
psbtThatShouldThrow.signAllInputsHDAsync as any
|
|
504
|
-
)();
|
|
464
|
+
await (psbtThatShouldThrow.signAllInputsHDAsync as any)();
|
|
505
465
|
}, new RegExp('Need HDSigner to sign input'));
|
|
506
466
|
}
|
|
507
467
|
});
|
|
@@ -509,12 +469,10 @@ describe(`Psbt`, () => {
|
|
|
509
469
|
});
|
|
510
470
|
|
|
511
471
|
describe('signAllInputsHD', () => {
|
|
512
|
-
fixtures.signInputHD.checks.forEach(f => {
|
|
472
|
+
fixtures.signInputHD.checks.forEach((f) => {
|
|
513
473
|
it(f.description, () => {
|
|
514
474
|
if (f.shouldSign) {
|
|
515
|
-
const psbtThatShouldsign = Psbt.fromBase64(
|
|
516
|
-
f.shouldSign.psbt,
|
|
517
|
-
);
|
|
475
|
+
const psbtThatShouldsign = Psbt.fromBase64(f.shouldSign.psbt);
|
|
518
476
|
assert.doesNotThrow(() => {
|
|
519
477
|
psbtThatShouldsign.signAllInputsHD(
|
|
520
478
|
bip32.fromBase58(f.shouldSign.xprv),
|
|
@@ -524,9 +482,7 @@ describe(`Psbt`, () => {
|
|
|
524
482
|
}
|
|
525
483
|
|
|
526
484
|
if (f.shouldThrow) {
|
|
527
|
-
const psbtThatShouldThrow = Psbt.fromBase64(
|
|
528
|
-
f.shouldThrow.psbt,
|
|
529
|
-
);
|
|
485
|
+
const psbtThatShouldThrow = Psbt.fromBase64(f.shouldThrow.psbt);
|
|
530
486
|
assert.throws(() => {
|
|
531
487
|
psbtThatShouldThrow.signAllInputsHD(
|
|
532
488
|
bip32.fromBase58(f.shouldThrow.xprv),
|
|
@@ -556,10 +512,7 @@ describe(`Psbt`, () => {
|
|
|
556
512
|
const psbt = Psbt.fromBase64(f.psbt);
|
|
557
513
|
|
|
558
514
|
assert.throws(() => {
|
|
559
|
-
psbt.finalizeTaprootInput(
|
|
560
|
-
f.index,
|
|
561
|
-
Buffer.from(f.leafHash, 'hex').reverse(),
|
|
562
|
-
);
|
|
515
|
+
psbt.finalizeTaprootInput(f.index, Buffer.from(f.leafHash, 'hex').reverse());
|
|
563
516
|
}, new RegExp('Can not finalize taproot input #0. Signature for tapleaf script not found.'));
|
|
564
517
|
});
|
|
565
518
|
|
|
@@ -577,7 +530,7 @@ describe(`Psbt`, () => {
|
|
|
577
530
|
});
|
|
578
531
|
|
|
579
532
|
describe('finalizeAllInputs', () => {
|
|
580
|
-
fixtures.finalizeAllInputs.forEach(f => {
|
|
533
|
+
fixtures.finalizeAllInputs.forEach((f) => {
|
|
581
534
|
it(`Finalizes inputs of type "${f.type}"`, () => {
|
|
582
535
|
const psbt = Psbt.fromBase64(f.psbt);
|
|
583
536
|
|
|
@@ -597,10 +550,7 @@ describe(`Psbt`, () => {
|
|
|
597
550
|
}, new RegExp('No script found for input #0'));
|
|
598
551
|
psbt.updateInput(0, {
|
|
599
552
|
witnessUtxo: {
|
|
600
|
-
script: Buffer.from(
|
|
601
|
-
'0014d85c2b71d0060b09c9886aeb815e50991dda124d',
|
|
602
|
-
'hex',
|
|
603
|
-
),
|
|
553
|
+
script: Buffer.from('0014d85c2b71d0060b09c9886aeb815e50991dda124d', 'hex'),
|
|
604
554
|
value: 2e5,
|
|
605
555
|
},
|
|
606
556
|
});
|
|
@@ -611,7 +561,7 @@ describe(`Psbt`, () => {
|
|
|
611
561
|
});
|
|
612
562
|
|
|
613
563
|
describe('addInput', () => {
|
|
614
|
-
fixtures.addInput.checks.forEach(f => {
|
|
564
|
+
fixtures.addInput.checks.forEach((f) => {
|
|
615
565
|
it(f.description, () => {
|
|
616
566
|
const psbt = new Psbt();
|
|
617
567
|
|
|
@@ -638,7 +588,7 @@ describe(`Psbt`, () => {
|
|
|
638
588
|
});
|
|
639
589
|
|
|
640
590
|
describe('updateInput', () => {
|
|
641
|
-
fixtures.updateInput.checks.forEach(f => {
|
|
591
|
+
fixtures.updateInput.checks.forEach((f) => {
|
|
642
592
|
it(f.description, () => {
|
|
643
593
|
const psbt = Psbt.fromBase64(f.psbt);
|
|
644
594
|
|
|
@@ -652,7 +602,7 @@ describe(`Psbt`, () => {
|
|
|
652
602
|
});
|
|
653
603
|
|
|
654
604
|
describe('addOutput', () => {
|
|
655
|
-
fixtures.addOutput.checks.forEach(f => {
|
|
605
|
+
fixtures.addOutput.checks.forEach((f) => {
|
|
656
606
|
it(f.description, () => {
|
|
657
607
|
if (f.isTaproot) initEccLib(ecc);
|
|
658
608
|
const psbt = f.psbt ? Psbt.fromBase64(f.psbt) : new Psbt();
|
|
@@ -745,8 +695,7 @@ describe(`Psbt`, () => {
|
|
|
745
695
|
payments.p2wsh({
|
|
746
696
|
redeem: { output },
|
|
747
697
|
}).output!;
|
|
748
|
-
const p2shp2wshOut = (output: Buffer): Buffer =>
|
|
749
|
-
p2shOut(p2wshOut(output));
|
|
698
|
+
const p2shp2wshOut = (output: Buffer): Buffer => p2shOut(p2wshOut(output));
|
|
750
699
|
const noOuter = (output: Buffer): Buffer => output;
|
|
751
700
|
|
|
752
701
|
function getInputTypeTest({
|
|
@@ -765,16 +714,10 @@ describe(`Psbt`, () => {
|
|
|
765
714
|
script: outerScript(innerScript(publicKey)),
|
|
766
715
|
value: 2e3,
|
|
767
716
|
},
|
|
768
|
-
...(redeemGetter
|
|
769
|
-
|
|
770
|
-
: {}),
|
|
771
|
-
...(witnessGetter
|
|
772
|
-
? { witnessScript: witnessGetter(publicKey) }
|
|
773
|
-
: {}),
|
|
717
|
+
...(redeemGetter ? { redeemScript: redeemGetter(publicKey) } : {}),
|
|
718
|
+
...(witnessGetter ? { witnessScript: witnessGetter(publicKey) } : {}),
|
|
774
719
|
}).addOutput({
|
|
775
|
-
script: Buffer.from(
|
|
776
|
-
'0014d85c2b71d0060b09c9886aeb815e50991dda124d',
|
|
777
|
-
),
|
|
720
|
+
script: Buffer.from('0014d85c2b71d0060b09c9886aeb815e50991dda124d'),
|
|
778
721
|
value: 1800,
|
|
779
722
|
});
|
|
780
723
|
if (finalize) psbt.signInput(0, key).finalizeInput(0);
|
|
@@ -932,10 +875,7 @@ describe(`Psbt`, () => {
|
|
|
932
875
|
hash: '0000000000000000000000000000000000000000000000000000000000000000',
|
|
933
876
|
index: 0,
|
|
934
877
|
}).addOutput({
|
|
935
|
-
script: Buffer.from(
|
|
936
|
-
'0014000102030405060708090a0b0c0d0e0f00010203',
|
|
937
|
-
'hex',
|
|
938
|
-
),
|
|
878
|
+
script: Buffer.from('0014000102030405060708090a0b0c0d0e0f00010203', 'hex'),
|
|
939
879
|
value: 2000,
|
|
940
880
|
bip32Derivation: [
|
|
941
881
|
{
|
|
@@ -1020,10 +960,7 @@ describe(`Psbt`, () => {
|
|
|
1020
960
|
const notAClone = Object.assign(new Psbt(), psbt); // references still active
|
|
1021
961
|
const clone = psbt.clone();
|
|
1022
962
|
|
|
1023
|
-
assert.strictEqual(
|
|
1024
|
-
psbt.validateSignaturesOfAllInputs(validator),
|
|
1025
|
-
true,
|
|
1026
|
-
);
|
|
963
|
+
assert.strictEqual(psbt.validateSignaturesOfAllInputs(validator), true);
|
|
1027
964
|
|
|
1028
965
|
assert.strictEqual(clone.toBase64(), psbt.toBase64());
|
|
1029
966
|
assert.strictEqual(clone.toBase64(), notAClone.toBase64());
|
|
@@ -1050,10 +987,7 @@ describe(`Psbt`, () => {
|
|
|
1050
987
|
it('Correctly validates a signature', () => {
|
|
1051
988
|
const psbt = Psbt.fromBase64(f.psbt);
|
|
1052
989
|
|
|
1053
|
-
assert.strictEqual(
|
|
1054
|
-
psbt.validateSignaturesOfInput(f.index, validator),
|
|
1055
|
-
true,
|
|
1056
|
-
);
|
|
990
|
+
assert.strictEqual(psbt.validateSignaturesOfInput(f.index, validator), true);
|
|
1057
991
|
assert.throws(() => {
|
|
1058
992
|
psbt.validateSignaturesOfInput(f.nonExistantIndex, validator);
|
|
1059
993
|
}, new RegExp('No signatures to validate'));
|
|
@@ -1062,19 +996,11 @@ describe(`Psbt`, () => {
|
|
|
1062
996
|
it('Correctly validates a signature against a pubkey', () => {
|
|
1063
997
|
const psbt = Psbt.fromBase64(f.psbt);
|
|
1064
998
|
assert.strictEqual(
|
|
1065
|
-
psbt.validateSignaturesOfInput(
|
|
1066
|
-
f.index,
|
|
1067
|
-
validator,
|
|
1068
|
-
f.pubkey as any,
|
|
1069
|
-
),
|
|
999
|
+
psbt.validateSignaturesOfInput(f.index, validator, f.pubkey as any),
|
|
1070
1000
|
true,
|
|
1071
1001
|
);
|
|
1072
1002
|
assert.throws(() => {
|
|
1073
|
-
psbt.validateSignaturesOfInput(
|
|
1074
|
-
f.index,
|
|
1075
|
-
validator,
|
|
1076
|
-
f.incorrectPubkey as any,
|
|
1077
|
-
);
|
|
1003
|
+
psbt.validateSignaturesOfInput(f.index, validator, f.incorrectPubkey as any);
|
|
1078
1004
|
}, new RegExp('No signatures for this pubkey'));
|
|
1079
1005
|
});
|
|
1080
1006
|
});
|
|
@@ -1084,29 +1010,18 @@ describe(`Psbt`, () => {
|
|
|
1084
1010
|
it('Correctly validates all signatures', () => {
|
|
1085
1011
|
initEccLib(ecc);
|
|
1086
1012
|
const psbt = Psbt.fromBase64(f.psbt);
|
|
1087
|
-
assert.strictEqual(
|
|
1088
|
-
psbt.validateSignaturesOfInput(f.index, schnorrValidator),
|
|
1089
|
-
true,
|
|
1090
|
-
);
|
|
1013
|
+
assert.strictEqual(psbt.validateSignaturesOfInput(f.index, schnorrValidator), true);
|
|
1091
1014
|
});
|
|
1092
1015
|
|
|
1093
1016
|
it('Correctly validates a signature against a pubkey', () => {
|
|
1094
1017
|
initEccLib(ecc);
|
|
1095
1018
|
const psbt = Psbt.fromBase64(f.psbt);
|
|
1096
1019
|
assert.strictEqual(
|
|
1097
|
-
psbt.validateSignaturesOfInput(
|
|
1098
|
-
f.index,
|
|
1099
|
-
schnorrValidator,
|
|
1100
|
-
f.pubkey as any,
|
|
1101
|
-
),
|
|
1020
|
+
psbt.validateSignaturesOfInput(f.index, schnorrValidator, f.pubkey as any),
|
|
1102
1021
|
true,
|
|
1103
1022
|
);
|
|
1104
1023
|
assert.throws(() => {
|
|
1105
|
-
psbt.validateSignaturesOfInput(
|
|
1106
|
-
f.index,
|
|
1107
|
-
schnorrValidator,
|
|
1108
|
-
f.incorrectPubkey as any,
|
|
1109
|
-
);
|
|
1024
|
+
psbt.validateSignaturesOfInput(f.index, schnorrValidator, f.incorrectPubkey as any);
|
|
1110
1025
|
}, new RegExp('No signatures for this pubkey'));
|
|
1111
1026
|
});
|
|
1112
1027
|
});
|
|
@@ -1116,29 +1031,18 @@ describe(`Psbt`, () => {
|
|
|
1116
1031
|
it('Correctly validates all signatures', () => {
|
|
1117
1032
|
initEccLib(ecc);
|
|
1118
1033
|
const psbt = Psbt.fromBase64(f.psbt);
|
|
1119
|
-
assert.strictEqual(
|
|
1120
|
-
psbt.validateSignaturesOfInput(f.index, schnorrValidator),
|
|
1121
|
-
true,
|
|
1122
|
-
);
|
|
1034
|
+
assert.strictEqual(psbt.validateSignaturesOfInput(f.index, schnorrValidator), true);
|
|
1123
1035
|
});
|
|
1124
1036
|
|
|
1125
1037
|
it('Correctly validates a signature against a pubkey', () => {
|
|
1126
1038
|
initEccLib(ecc);
|
|
1127
1039
|
const psbt = Psbt.fromBase64(f.psbt);
|
|
1128
1040
|
assert.strictEqual(
|
|
1129
|
-
psbt.validateSignaturesOfInput(
|
|
1130
|
-
f.index,
|
|
1131
|
-
schnorrValidator,
|
|
1132
|
-
f.pubkey as any,
|
|
1133
|
-
),
|
|
1041
|
+
psbt.validateSignaturesOfInput(f.index, schnorrValidator, f.pubkey as any),
|
|
1134
1042
|
true,
|
|
1135
1043
|
);
|
|
1136
1044
|
assert.throws(() => {
|
|
1137
|
-
psbt.validateSignaturesOfInput(
|
|
1138
|
-
f.index,
|
|
1139
|
-
schnorrValidator,
|
|
1140
|
-
f.incorrectPubkey as any,
|
|
1141
|
-
);
|
|
1045
|
+
psbt.validateSignaturesOfInput(f.index, schnorrValidator, f.incorrectPubkey as any);
|
|
1142
1046
|
}, new RegExp('No signatures for this pubkey'));
|
|
1143
1047
|
});
|
|
1144
1048
|
});
|
|
@@ -1146,13 +1050,10 @@ describe(`Psbt`, () => {
|
|
|
1146
1050
|
describe('tapTreeToList/tapTreeFromList', () => {
|
|
1147
1051
|
it('Correctly converts a Taptree to a Tapleaf list and back', () => {
|
|
1148
1052
|
taprootFixtures.valid
|
|
1149
|
-
.filter(f => f.arguments.scriptTree)
|
|
1150
|
-
.map(f => f.arguments.scriptTree)
|
|
1151
|
-
.forEach(scriptTree => {
|
|
1152
|
-
const originalTree = convertScriptTree(
|
|
1153
|
-
scriptTree,
|
|
1154
|
-
LEAF_VERSION_TAPSCRIPT,
|
|
1155
|
-
);
|
|
1053
|
+
.filter((f) => f.arguments.scriptTree)
|
|
1054
|
+
.map((f) => f.arguments.scriptTree)
|
|
1055
|
+
.forEach((scriptTree) => {
|
|
1056
|
+
const originalTree = convertScriptTree(scriptTree, LEAF_VERSION_TAPSCRIPT);
|
|
1156
1057
|
const list = tapTreeToList(originalTree);
|
|
1157
1058
|
const treeFromList = tapTreeFromList(list);
|
|
1158
1059
|
|
|
@@ -1172,13 +1073,8 @@ describe(`Psbt`, () => {
|
|
|
1172
1073
|
});
|
|
1173
1074
|
|
|
1174
1075
|
it('Throws if taptree depth is exceeded', () => {
|
|
1175
|
-
let tree: Taptree = [
|
|
1176
|
-
|
|
1177
|
-
{ output: Buffer.from([]) },
|
|
1178
|
-
];
|
|
1179
|
-
Array.from({ length: 129 }).forEach(
|
|
1180
|
-
() => (tree = [tree, { output: Buffer.from([]) }]),
|
|
1181
|
-
);
|
|
1076
|
+
let tree: Taptree = [{ output: Buffer.from([]) }, { output: Buffer.from([]) }];
|
|
1077
|
+
Array.from({ length: 129 }).forEach(() => (tree = [tree, { output: Buffer.from([]) }]));
|
|
1182
1078
|
assert.throws(() => {
|
|
1183
1079
|
tapTreeToList(tree as Taptree);
|
|
1184
1080
|
}, new RegExp('Max taptree depth exceeded.'));
|
|
@@ -1226,9 +1122,7 @@ describe(`Psbt`, () => {
|
|
|
1226
1122
|
});
|
|
1227
1123
|
|
|
1228
1124
|
describe('create 1-to-1 transaction', () => {
|
|
1229
|
-
const alice = ECPair.fromWIF(
|
|
1230
|
-
'L2uPYXe17xSTqbCjZvL2DsyXPCbXspvcu5mHLDYUgzdUbZGSKrSr',
|
|
1231
|
-
);
|
|
1125
|
+
const alice = ECPair.fromWIF('L2uPYXe17xSTqbCjZvL2DsyXPCbXspvcu5mHLDYUgzdUbZGSKrSr');
|
|
1232
1126
|
const psbt = new Psbt();
|
|
1233
1127
|
psbt.addInput({
|
|
1234
1128
|
hash: '7d067b4a697a09d2c3cff7d4d9506c9955e93bff41bf82d439da7d030382bc3e',
|
|
@@ -1287,9 +1181,7 @@ describe(`Psbt`, () => {
|
|
|
1287
1181
|
assert.ok((psbt as any).__CACHE.__TX);
|
|
1288
1182
|
});
|
|
1289
1183
|
it('fromHex returns Psbt type (not base class)', () => {
|
|
1290
|
-
const psbt = Psbt.fromHex(
|
|
1291
|
-
'70736274ff01000a01000000000000000000000000',
|
|
1292
|
-
);
|
|
1184
|
+
const psbt = Psbt.fromHex('70736274ff01000a01000000000000000000000000');
|
|
1293
1185
|
assert.strictEqual(psbt instanceof Psbt, true);
|
|
1294
1186
|
assert.ok((psbt as any).__CACHE.__TX);
|
|
1295
1187
|
});
|
|
@@ -1312,24 +1204,15 @@ describe(`Psbt`, () => {
|
|
|
1312
1204
|
nonWitnessUtxo: f.nonWitnessUtxo as any,
|
|
1313
1205
|
});
|
|
1314
1206
|
const value = psbt.data.inputs[index].nonWitnessUtxo;
|
|
1207
|
+
assert.ok((psbt as any).__CACHE.__NON_WITNESS_UTXO_BUF_CACHE[index].equals(value));
|
|
1315
1208
|
assert.ok(
|
|
1316
|
-
(psbt as any).__CACHE.__NON_WITNESS_UTXO_BUF_CACHE[
|
|
1317
|
-
index
|
|
1318
|
-
].equals(value),
|
|
1319
|
-
);
|
|
1320
|
-
assert.ok(
|
|
1321
|
-
(psbt as any).__CACHE.__NON_WITNESS_UTXO_BUF_CACHE[
|
|
1322
|
-
index
|
|
1323
|
-
].equals(f.nonWitnessUtxo),
|
|
1209
|
+
(psbt as any).__CACHE.__NON_WITNESS_UTXO_BUF_CACHE[index].equals(f.nonWitnessUtxo),
|
|
1324
1210
|
);
|
|
1325
1211
|
|
|
1326
1212
|
// Cache is rebuilt from internal transaction object when cleared
|
|
1327
1213
|
psbt.data.inputs[index].nonWitnessUtxo = Buffer.from([1, 2, 3]);
|
|
1328
|
-
(psbt as any).__CACHE.__NON_WITNESS_UTXO_BUF_CACHE[index] =
|
|
1329
|
-
|
|
1330
|
-
assert.ok(
|
|
1331
|
-
(psbt as any).data.inputs[index].nonWitnessUtxo.equals(value),
|
|
1332
|
-
);
|
|
1214
|
+
(psbt as any).__CACHE.__NON_WITNESS_UTXO_BUF_CACHE[index] = undefined;
|
|
1215
|
+
assert.ok((psbt as any).data.inputs[index].nonWitnessUtxo.equals(value));
|
|
1333
1216
|
});
|
|
1334
1217
|
});
|
|
1335
1218
|
|
|
@@ -1338,34 +1221,22 @@ describe(`Psbt`, () => {
|
|
|
1338
1221
|
const psbt = new Psbt();
|
|
1339
1222
|
|
|
1340
1223
|
assert.strictEqual(psbt.version, 2);
|
|
1341
|
-
assert.strictEqual(
|
|
1342
|
-
psbt.version,
|
|
1343
|
-
(psbt as any).__CACHE.__TX.version,
|
|
1344
|
-
);
|
|
1224
|
+
assert.strictEqual(psbt.version, (psbt as any).__CACHE.__TX.version);
|
|
1345
1225
|
|
|
1346
1226
|
psbt.version = 1;
|
|
1347
1227
|
assert.strictEqual(psbt.version, 1);
|
|
1348
|
-
assert.strictEqual(
|
|
1349
|
-
psbt.version,
|
|
1350
|
-
(psbt as any).__CACHE.__TX.version,
|
|
1351
|
-
);
|
|
1228
|
+
assert.strictEqual(psbt.version, (psbt as any).__CACHE.__TX.version);
|
|
1352
1229
|
});
|
|
1353
1230
|
|
|
1354
1231
|
it('.locktime is exposed and is settable', () => {
|
|
1355
1232
|
const psbt = new Psbt();
|
|
1356
1233
|
|
|
1357
1234
|
assert.strictEqual(psbt.locktime, 0);
|
|
1358
|
-
assert.strictEqual(
|
|
1359
|
-
psbt.locktime,
|
|
1360
|
-
(psbt as any).__CACHE.__TX.locktime,
|
|
1361
|
-
);
|
|
1235
|
+
assert.strictEqual(psbt.locktime, (psbt as any).__CACHE.__TX.locktime);
|
|
1362
1236
|
|
|
1363
1237
|
psbt.locktime = 123;
|
|
1364
1238
|
assert.strictEqual(psbt.locktime, 123);
|
|
1365
|
-
assert.strictEqual(
|
|
1366
|
-
psbt.locktime,
|
|
1367
|
-
(psbt as any).__CACHE.__TX.locktime,
|
|
1368
|
-
);
|
|
1239
|
+
assert.strictEqual(psbt.locktime, (psbt as any).__CACHE.__TX.locktime);
|
|
1369
1240
|
});
|
|
1370
1241
|
|
|
1371
1242
|
it('.txInputs is exposed as a readonly clone', () => {
|