@caravan/psbt 1.9.2 → 1.9.3
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/README.md +0 -16
- package/dist/index.d.ts +8 -2
- package/dist/index.js +23 -16
- package/dist/index.mjs +23 -16
- package/package.json +8 -14
package/README.md
CHANGED
|
@@ -253,22 +253,6 @@ Then copy the resulting built code (ends up in the lib directory) into the vendo
|
|
|
253
253
|
we just use the asmjs build to avoid wasm complications in
|
|
254
254
|
the build system.
|
|
255
255
|
|
|
256
|
-
### Experimental VM Modules
|
|
257
|
-
This is related to the tiny-secp256k1 library which has difficulties importing in different environments.
|
|
258
|
-
|
|
259
|
-
Note that the jest configs and the special prefix in the npm test scripts were needed
|
|
260
|
-
to let jest understand the esmodule imports from the tiny-secp256k1 library.
|
|
261
|
-
|
|
262
|
-
The npm script prefix in particular may result in a console warning when running tests:
|
|
263
|
-
|
|
264
|
-
```
|
|
265
|
-
ExperimentalWarning: VM Modules is an experimental feature and might change at any time
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
This can be safely ignored. See the [documentation in jest](https://jestjs.io/docs/ecmascript-modules)
|
|
269
|
-
for more information on running with `--experimental-vm-modules`.
|
|
270
|
-
|
|
271
|
-
|
|
272
256
|
### What's with the `bitcoinjs-lib-v6` dependency?
|
|
273
257
|
|
|
274
258
|
npm workspaces and maybe vite have issues with nested dependencies with
|
package/dist/index.d.ts
CHANGED
|
@@ -99,9 +99,7 @@ declare class PsbtV2 extends PsbtV2Maps {
|
|
|
99
99
|
get PSBT_GLOBAL_FALLBACK_LOCKTIME(): number | null;
|
|
100
100
|
set PSBT_GLOBAL_FALLBACK_LOCKTIME(locktime: number | null);
|
|
101
101
|
get PSBT_GLOBAL_INPUT_COUNT(): number;
|
|
102
|
-
set PSBT_GLOBAL_INPUT_COUNT(count: number);
|
|
103
102
|
get PSBT_GLOBAL_OUTPUT_COUNT(): number;
|
|
104
|
-
set PSBT_GLOBAL_OUTPUT_COUNT(count: number);
|
|
105
103
|
get PSBT_GLOBAL_TX_MODIFIABLE(): PsbtGlobalTxModifiableBits[];
|
|
106
104
|
set PSBT_GLOBAL_TX_MODIFIABLE(modifiable: PsbtGlobalTxModifiableBits[]);
|
|
107
105
|
get PSBT_GLOBAL_VERSION(): number;
|
|
@@ -402,6 +400,14 @@ declare class PsbtV2 extends PsbtV2Maps {
|
|
|
402
400
|
* this PSBTv2. Accepts optional desired format as a string (default base64).
|
|
403
401
|
*/
|
|
404
402
|
toV0(format?: "base64" | "hex"): string;
|
|
403
|
+
/**
|
|
404
|
+
* Updates the PSBT_GLOBAL_INPUT_COUNT field in the global map.
|
|
405
|
+
*/
|
|
406
|
+
private updateGlobalInputCount;
|
|
407
|
+
/**
|
|
408
|
+
* Updates the PSBT_GLOBAL_OUTPUT_COUNT field in the global map.
|
|
409
|
+
*/
|
|
410
|
+
private updateGlobalOutputCount;
|
|
405
411
|
}
|
|
406
412
|
|
|
407
413
|
interface PsbtInput {
|
package/dist/index.js
CHANGED
|
@@ -426,11 +426,6 @@ var PsbtV2 = class _PsbtV2 extends PsbtV2Maps {
|
|
|
426
426
|
}
|
|
427
427
|
return val.readUInt8(0);
|
|
428
428
|
}
|
|
429
|
-
set PSBT_GLOBAL_INPUT_COUNT(count) {
|
|
430
|
-
const bw = new import_bufio3.BufferWriter();
|
|
431
|
-
bw.writeU8(count);
|
|
432
|
-
this.globalMap.set("04" /* PSBT_GLOBAL_INPUT_COUNT */, bw.render());
|
|
433
|
-
}
|
|
434
429
|
get PSBT_GLOBAL_OUTPUT_COUNT() {
|
|
435
430
|
const val = this.globalMap.get("05" /* PSBT_GLOBAL_OUTPUT_COUNT */);
|
|
436
431
|
if (val === void 0) {
|
|
@@ -438,11 +433,6 @@ var PsbtV2 = class _PsbtV2 extends PsbtV2Maps {
|
|
|
438
433
|
}
|
|
439
434
|
return val.readUInt8(0);
|
|
440
435
|
}
|
|
441
|
-
set PSBT_GLOBAL_OUTPUT_COUNT(count) {
|
|
442
|
-
const bw = new import_bufio3.BufferWriter();
|
|
443
|
-
bw.writeU8(count);
|
|
444
|
-
this.globalMap.set("05" /* PSBT_GLOBAL_OUTPUT_COUNT */, bw.render());
|
|
445
|
-
}
|
|
446
436
|
get PSBT_GLOBAL_TX_MODIFIABLE() {
|
|
447
437
|
const val = this.globalMap.get("06" /* PSBT_GLOBAL_TX_MODIFIABLE */)?.readUInt8(0) || 0;
|
|
448
438
|
const modifiable = [];
|
|
@@ -874,8 +864,8 @@ var PsbtV2 = class _PsbtV2 extends PsbtV2Maps {
|
|
|
874
864
|
create() {
|
|
875
865
|
this.PSBT_GLOBAL_VERSION = 2;
|
|
876
866
|
this.PSBT_GLOBAL_TX_VERSION = 2;
|
|
877
|
-
this.
|
|
878
|
-
this.
|
|
867
|
+
this.updateGlobalInputCount();
|
|
868
|
+
this.updateGlobalOutputCount();
|
|
879
869
|
this.PSBT_GLOBAL_FALLBACK_LOCKTIME = 0;
|
|
880
870
|
this.PSBT_GLOBAL_TX_MODIFIABLE = [
|
|
881
871
|
"INPUTS" /* INPUTS */,
|
|
@@ -1102,7 +1092,8 @@ var PsbtV2 = class _PsbtV2 extends PsbtV2Maps {
|
|
|
1102
1092
|
bw.writeU32(sighashType);
|
|
1103
1093
|
map.set("03" /* PSBT_IN_SIGHASH_TYPE */, bw.render());
|
|
1104
1094
|
}
|
|
1105
|
-
this.
|
|
1095
|
+
this.inputMaps.push(map);
|
|
1096
|
+
this.updateGlobalInputCount();
|
|
1106
1097
|
}
|
|
1107
1098
|
addOutput({
|
|
1108
1099
|
amount,
|
|
@@ -1146,7 +1137,7 @@ var PsbtV2 = class _PsbtV2 extends PsbtV2Maps {
|
|
|
1146
1137
|
}
|
|
1147
1138
|
}
|
|
1148
1139
|
this.outputMaps.push(map);
|
|
1149
|
-
this.
|
|
1140
|
+
this.updateGlobalOutputCount();
|
|
1150
1141
|
}
|
|
1151
1142
|
/**
|
|
1152
1143
|
* Updater/Signer Methods
|
|
@@ -1167,7 +1158,7 @@ var PsbtV2 = class _PsbtV2 extends PsbtV2Maps {
|
|
|
1167
1158
|
}
|
|
1168
1159
|
const newInputs = this.inputMaps.filter((_4, i6) => i6 !== index);
|
|
1169
1160
|
this.inputMaps = newInputs;
|
|
1170
|
-
this.
|
|
1161
|
+
this.updateGlobalInputCount();
|
|
1171
1162
|
}
|
|
1172
1163
|
/**
|
|
1173
1164
|
* Removes an output-map from outputMaps.
|
|
@@ -1188,7 +1179,7 @@ var PsbtV2 = class _PsbtV2 extends PsbtV2Maps {
|
|
|
1188
1179
|
this.removePartialSig(index);
|
|
1189
1180
|
}
|
|
1190
1181
|
this.outputMaps = newOutputs;
|
|
1191
|
-
this.
|
|
1182
|
+
this.updateGlobalOutputCount();
|
|
1192
1183
|
}
|
|
1193
1184
|
/**
|
|
1194
1185
|
* Checks that all provided flags are present in PSBT_GLOBAL_TX_MODIFIABLE.
|
|
@@ -1442,6 +1433,22 @@ var PsbtV2 = class _PsbtV2 extends PsbtV2Maps {
|
|
|
1442
1433
|
converterMap.convertToV0();
|
|
1443
1434
|
return converterMap.serialize(format2);
|
|
1444
1435
|
}
|
|
1436
|
+
/**
|
|
1437
|
+
* Updates the PSBT_GLOBAL_INPUT_COUNT field in the global map.
|
|
1438
|
+
*/
|
|
1439
|
+
updateGlobalInputCount() {
|
|
1440
|
+
const bw = new import_bufio3.BufferWriter();
|
|
1441
|
+
bw.writeU8(this.inputMaps.length);
|
|
1442
|
+
this.globalMap.set("04" /* PSBT_GLOBAL_INPUT_COUNT */, bw.render());
|
|
1443
|
+
}
|
|
1444
|
+
/**
|
|
1445
|
+
* Updates the PSBT_GLOBAL_OUTPUT_COUNT field in the global map.
|
|
1446
|
+
*/
|
|
1447
|
+
updateGlobalOutputCount() {
|
|
1448
|
+
const bw = new import_bufio3.BufferWriter();
|
|
1449
|
+
bw.writeU8(this.outputMaps.length);
|
|
1450
|
+
this.globalMap.set("05" /* PSBT_GLOBAL_OUTPUT_COUNT */, bw.render());
|
|
1451
|
+
}
|
|
1445
1452
|
};
|
|
1446
1453
|
|
|
1447
1454
|
// src/psbtv0/psbt.ts
|
package/dist/index.mjs
CHANGED
|
@@ -385,11 +385,6 @@ var PsbtV2 = class _PsbtV2 extends PsbtV2Maps {
|
|
|
385
385
|
}
|
|
386
386
|
return val.readUInt8(0);
|
|
387
387
|
}
|
|
388
|
-
set PSBT_GLOBAL_INPUT_COUNT(count) {
|
|
389
|
-
const bw = new BufferWriter3();
|
|
390
|
-
bw.writeU8(count);
|
|
391
|
-
this.globalMap.set("04" /* PSBT_GLOBAL_INPUT_COUNT */, bw.render());
|
|
392
|
-
}
|
|
393
388
|
get PSBT_GLOBAL_OUTPUT_COUNT() {
|
|
394
389
|
const val = this.globalMap.get("05" /* PSBT_GLOBAL_OUTPUT_COUNT */);
|
|
395
390
|
if (val === void 0) {
|
|
@@ -397,11 +392,6 @@ var PsbtV2 = class _PsbtV2 extends PsbtV2Maps {
|
|
|
397
392
|
}
|
|
398
393
|
return val.readUInt8(0);
|
|
399
394
|
}
|
|
400
|
-
set PSBT_GLOBAL_OUTPUT_COUNT(count) {
|
|
401
|
-
const bw = new BufferWriter3();
|
|
402
|
-
bw.writeU8(count);
|
|
403
|
-
this.globalMap.set("05" /* PSBT_GLOBAL_OUTPUT_COUNT */, bw.render());
|
|
404
|
-
}
|
|
405
395
|
get PSBT_GLOBAL_TX_MODIFIABLE() {
|
|
406
396
|
const val = this.globalMap.get("06" /* PSBT_GLOBAL_TX_MODIFIABLE */)?.readUInt8(0) || 0;
|
|
407
397
|
const modifiable = [];
|
|
@@ -833,8 +823,8 @@ var PsbtV2 = class _PsbtV2 extends PsbtV2Maps {
|
|
|
833
823
|
create() {
|
|
834
824
|
this.PSBT_GLOBAL_VERSION = 2;
|
|
835
825
|
this.PSBT_GLOBAL_TX_VERSION = 2;
|
|
836
|
-
this.
|
|
837
|
-
this.
|
|
826
|
+
this.updateGlobalInputCount();
|
|
827
|
+
this.updateGlobalOutputCount();
|
|
838
828
|
this.PSBT_GLOBAL_FALLBACK_LOCKTIME = 0;
|
|
839
829
|
this.PSBT_GLOBAL_TX_MODIFIABLE = [
|
|
840
830
|
"INPUTS" /* INPUTS */,
|
|
@@ -1061,7 +1051,8 @@ var PsbtV2 = class _PsbtV2 extends PsbtV2Maps {
|
|
|
1061
1051
|
bw.writeU32(sighashType);
|
|
1062
1052
|
map.set("03" /* PSBT_IN_SIGHASH_TYPE */, bw.render());
|
|
1063
1053
|
}
|
|
1064
|
-
this.
|
|
1054
|
+
this.inputMaps.push(map);
|
|
1055
|
+
this.updateGlobalInputCount();
|
|
1065
1056
|
}
|
|
1066
1057
|
addOutput({
|
|
1067
1058
|
amount,
|
|
@@ -1105,7 +1096,7 @@ var PsbtV2 = class _PsbtV2 extends PsbtV2Maps {
|
|
|
1105
1096
|
}
|
|
1106
1097
|
}
|
|
1107
1098
|
this.outputMaps.push(map);
|
|
1108
|
-
this.
|
|
1099
|
+
this.updateGlobalOutputCount();
|
|
1109
1100
|
}
|
|
1110
1101
|
/**
|
|
1111
1102
|
* Updater/Signer Methods
|
|
@@ -1126,7 +1117,7 @@ var PsbtV2 = class _PsbtV2 extends PsbtV2Maps {
|
|
|
1126
1117
|
}
|
|
1127
1118
|
const newInputs = this.inputMaps.filter((_4, i6) => i6 !== index);
|
|
1128
1119
|
this.inputMaps = newInputs;
|
|
1129
|
-
this.
|
|
1120
|
+
this.updateGlobalInputCount();
|
|
1130
1121
|
}
|
|
1131
1122
|
/**
|
|
1132
1123
|
* Removes an output-map from outputMaps.
|
|
@@ -1147,7 +1138,7 @@ var PsbtV2 = class _PsbtV2 extends PsbtV2Maps {
|
|
|
1147
1138
|
this.removePartialSig(index);
|
|
1148
1139
|
}
|
|
1149
1140
|
this.outputMaps = newOutputs;
|
|
1150
|
-
this.
|
|
1141
|
+
this.updateGlobalOutputCount();
|
|
1151
1142
|
}
|
|
1152
1143
|
/**
|
|
1153
1144
|
* Checks that all provided flags are present in PSBT_GLOBAL_TX_MODIFIABLE.
|
|
@@ -1401,6 +1392,22 @@ var PsbtV2 = class _PsbtV2 extends PsbtV2Maps {
|
|
|
1401
1392
|
converterMap.convertToV0();
|
|
1402
1393
|
return converterMap.serialize(format2);
|
|
1403
1394
|
}
|
|
1395
|
+
/**
|
|
1396
|
+
* Updates the PSBT_GLOBAL_INPUT_COUNT field in the global map.
|
|
1397
|
+
*/
|
|
1398
|
+
updateGlobalInputCount() {
|
|
1399
|
+
const bw = new BufferWriter3();
|
|
1400
|
+
bw.writeU8(this.inputMaps.length);
|
|
1401
|
+
this.globalMap.set("04" /* PSBT_GLOBAL_INPUT_COUNT */, bw.render());
|
|
1402
|
+
}
|
|
1403
|
+
/**
|
|
1404
|
+
* Updates the PSBT_GLOBAL_OUTPUT_COUNT field in the global map.
|
|
1405
|
+
*/
|
|
1406
|
+
updateGlobalOutputCount() {
|
|
1407
|
+
const bw = new BufferWriter3();
|
|
1408
|
+
bw.writeU8(this.outputMaps.length);
|
|
1409
|
+
this.globalMap.set("05" /* PSBT_GLOBAL_OUTPUT_COUNT */, bw.render());
|
|
1410
|
+
}
|
|
1404
1411
|
};
|
|
1405
1412
|
|
|
1406
1413
|
// src/psbtv0/psbt.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caravan/psbt",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.3",
|
|
4
4
|
"description": "typescript library for working with PSBTs",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
],
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
15
16
|
"import": "./dist/index.mjs",
|
|
16
|
-
"require": "./dist/index.js"
|
|
17
|
-
"types": "./dist/index.d.ts"
|
|
17
|
+
"require": "./dist/index.js"
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"engines": {
|
|
@@ -28,11 +28,12 @@
|
|
|
28
28
|
"scripts": {
|
|
29
29
|
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
30
30
|
"dev": "npm run build -- --watch",
|
|
31
|
-
"test": "
|
|
32
|
-
"
|
|
31
|
+
"test": "vitest run",
|
|
32
|
+
"test:watch": "vitest watch",
|
|
33
|
+
"lint": "eslint src/",
|
|
34
|
+
"lint:fix": "eslint --fix src/",
|
|
33
35
|
"ci": "npm run lint && npm run test",
|
|
34
|
-
"test:
|
|
35
|
-
"test:debug": "node --inspect-brk ../../node_modules/.bin/jest --runInBand"
|
|
36
|
+
"test:debug": "node --inspect-brk ../../node_modules/.bin/vitest run"
|
|
36
37
|
},
|
|
37
38
|
"keywords": [
|
|
38
39
|
"bitcoin",
|
|
@@ -55,16 +56,9 @@
|
|
|
55
56
|
"@caravan/eslint-config": "*",
|
|
56
57
|
"@caravan/multisig": "*",
|
|
57
58
|
"@caravan/typescript-config": "*",
|
|
58
|
-
"@inrupt/jest-jsdom-polyfills": "^3.2.1",
|
|
59
|
-
"@jest/globals": "^29.7.0",
|
|
60
|
-
"@types/jest": "^29.5.12",
|
|
61
59
|
"eslint-plugin-prettier": "^5.1.3",
|
|
62
|
-
"jest": "^29.4.1",
|
|
63
|
-
"jsdom": "24.0.0",
|
|
64
|
-
"jsdom-global": "3.0.2",
|
|
65
60
|
"lodash": "^4.17.21",
|
|
66
61
|
"react-silence": "^1.0.4",
|
|
67
|
-
"ts-jest": "^29.1.2",
|
|
68
62
|
"ts-node": "^10.9.2",
|
|
69
63
|
"tsup": "^7.2.0",
|
|
70
64
|
"typescript": "^5.2.2"
|