@caravan/psbt 1.2.0 → 1.3.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/README.md +77 -54
- package/dist/index.d.ts +104 -1
- package/dist/index.js +92776 -42
- package/dist/index.mjs +92798 -64
- package/package.json +28 -7
- package/.eslintrc.cjs +0 -6
- package/.prettierrc +0 -4
- package/.turbo/turbo-build.log +0 -19
- package/.turbo/turbo-lint.log +0 -61
- package/.turbo/turbo-test.log +0 -99
- package/CHANGELOG.md +0 -28
- package/dist/index.d.mts +0 -324
- package/jest.config.js +0 -4
- package/src/index.ts +0 -2
- package/src/psbt.test.ts +0 -338
- package/src/psbt.ts +0 -440
- package/src/psbtv2/functions.ts +0 -169
- package/src/psbtv2/index.ts +0 -3
- package/src/psbtv2/psbtv2.test.ts +0 -1587
- package/src/psbtv2/psbtv2.ts +0 -1307
- package/src/psbtv2/psbtv2maps.ts +0 -111
- package/src/psbtv2/types.ts +0 -91
- package/src/psbtv2/values.ts +0 -4
- package/tsconfig.json +0 -3
- package/tsup.config.ts +0 -6
package/package.json
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caravan/psbt",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "typescript library for working with PSBTs",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"module": "./dist/index.mjs",
|
|
8
|
+
"files": [
|
|
9
|
+
"./dist/index.js",
|
|
10
|
+
"./dist/index.mjs",
|
|
11
|
+
"./dist/index.d.ts"
|
|
12
|
+
],
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": "./dist/index.mjs",
|
|
16
|
+
"require": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
8
20
|
"engines": {
|
|
9
21
|
"node": ">=20"
|
|
10
22
|
},
|
|
@@ -16,10 +28,10 @@
|
|
|
16
28
|
"scripts": {
|
|
17
29
|
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
18
30
|
"dev": "npm run build -- --watch",
|
|
19
|
-
"test": "jest src",
|
|
31
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules npx jest src",
|
|
20
32
|
"lint": "eslint src",
|
|
21
33
|
"ci": "npm run lint && npm run test",
|
|
22
|
-
"test:watch": "
|
|
34
|
+
"test:watch": "npm run test -- --watch",
|
|
23
35
|
"test:debug": "node --inspect-brk ../../node_modules/.bin/jest --runInBand"
|
|
24
36
|
},
|
|
25
37
|
"keywords": [
|
|
@@ -28,21 +40,30 @@
|
|
|
28
40
|
],
|
|
29
41
|
"dependencies": {
|
|
30
42
|
"@caravan/bitcoin": "*",
|
|
43
|
+
"@caravan/multisig": "*",
|
|
31
44
|
"bignumber.js": "^8.1.1",
|
|
32
|
-
"
|
|
45
|
+
"bip174": "^2.1.1",
|
|
46
|
+
"bitcoinjs-lib-v6": "npm:bitcoinjs-lib@^6.1.5",
|
|
33
47
|
"buffer": "^6.0.3",
|
|
34
48
|
"bufio": "^1.2.1",
|
|
35
|
-
"esbuild-plugin-polyfill-node": "^0.3.0"
|
|
49
|
+
"esbuild-plugin-polyfill-node": "^0.3.0",
|
|
50
|
+
"uint8array-tools": "^0.0.7"
|
|
36
51
|
},
|
|
37
52
|
"author": "unchained capital",
|
|
38
53
|
"license": "ISC",
|
|
39
54
|
"devDependencies": {
|
|
40
55
|
"@caravan/eslint-config": "*",
|
|
41
56
|
"@caravan/typescript-config": "*",
|
|
42
|
-
"@
|
|
57
|
+
"@inrupt/jest-jsdom-polyfills": "^3.2.1",
|
|
58
|
+
"@jest/globals": "^29.7.0",
|
|
59
|
+
"@types/jest": "^29.5.12",
|
|
43
60
|
"eslint-plugin-prettier": "^5.1.3",
|
|
44
61
|
"jest": "^29.4.1",
|
|
45
|
-
"
|
|
62
|
+
"jsdom": "24.0.0",
|
|
63
|
+
"jsdom-global": "3.0.2",
|
|
64
|
+
"react-silence": "^1.0.4",
|
|
65
|
+
"ts-jest": "^29.1.2",
|
|
66
|
+
"ts-node": "^10.9.2",
|
|
46
67
|
"tsup": "^7.2.0",
|
|
47
68
|
"typescript": "^5.2.2"
|
|
48
69
|
}
|
package/.eslintrc.cjs
DELETED
package/.prettierrc
DELETED
package/.turbo/turbo-build.log
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @caravan/psbt@1.2.0 build
|
|
3
|
-
> tsup src/index.ts --format cjs,esm --dts
|
|
4
|
-
|
|
5
|
-
[34mCLI[39m Building entry: src/index.ts
|
|
6
|
-
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
-
[34mCLI[39m tsup v7.2.0
|
|
8
|
-
[34mCLI[39m Using tsup config: /home/runner/work/caravan/caravan/packages/caravan-psbt/tsup.config.ts
|
|
9
|
-
[34mCLI[39m Target: esnext
|
|
10
|
-
[34mCJS[39m Build start
|
|
11
|
-
[34mESM[39m Build start
|
|
12
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m37.44 KB[39m
|
|
13
|
-
[32mESM[39m ⚡️ Build success in 58ms
|
|
14
|
-
[32mCJS[39m [1mdist/index.js [22m[32m39.13 KB[39m
|
|
15
|
-
[32mCJS[39m ⚡️ Build success in 58ms
|
|
16
|
-
[34mDTS[39m Build start
|
|
17
|
-
[32mDTS[39m ⚡️ Build success in 2355ms
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m13.38 KB[39m
|
|
19
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m13.38 KB[39m
|
package/.turbo/turbo-lint.log
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @caravan/psbt@1.2.0 lint
|
|
3
|
-
> eslint src
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/home/runner/work/caravan/caravan/packages/caravan-psbt/src/psbt.ts
|
|
7
|
-
43:54 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
8
|
-
113:23 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
9
|
-
268:7 warning 'localPSBT' is never reassigned. Use 'const' instead prefer-const
|
|
10
|
-
376:7 warning 'psbt' is never reassigned. Use 'const' instead prefer-const
|
|
11
|
-
415:7 warning 'psbt' is never reassigned. Use 'const' instead prefer-const
|
|
12
|
-
430:13 warning 'signature' is never reassigned. Use 'const' instead prefer-const
|
|
13
|
-
|
|
14
|
-
/home/runner/work/caravan/caravan/packages/caravan-psbt/src/psbtv2/psbtv2.test.ts
|
|
15
|
-
915:14 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
16
|
-
919:14 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
17
|
-
928:14 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
18
|
-
932:14 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
19
|
-
940:14 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
20
|
-
945:14 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
21
|
-
953:14 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
22
|
-
1169:42 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
23
|
-
1169:53 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
24
|
-
1231:45 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
25
|
-
1231:56 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
26
|
-
1450:19 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
27
|
-
1456:21 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
28
|
-
1457:21 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
29
|
-
1467:23 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
30
|
-
1479:29 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
31
|
-
1491:24 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
32
|
-
1503:30 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
33
|
-
|
|
34
|
-
/home/runner/work/caravan/caravan/packages/caravan-psbt/src/psbtv2/psbtv2.ts
|
|
35
|
-
133:9 warning 'modifiable' is never reassigned. Use 'const' instead prefer-const
|
|
36
|
-
677:9 warning 'heights' is never reassigned. Use 'const' instead prefer-const
|
|
37
|
-
678:9 warning 'times' is never reassigned. Use 'const' instead prefer-const
|
|
38
|
-
1256:21 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
39
|
-
1278:22 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
40
|
-
|
|
41
|
-
/home/runner/work/caravan/caravan/packages/caravan-psbt/src/psbtv2/types.ts
|
|
42
|
-
32:3 warning Duplicate enum member value 01 @typescript-eslint/no-duplicate-enum-values
|
|
43
|
-
33:3 warning Duplicate enum member value 02 @typescript-eslint/no-duplicate-enum-values
|
|
44
|
-
34:3 warning Duplicate enum member value 03 @typescript-eslint/no-duplicate-enum-values
|
|
45
|
-
35:3 warning Duplicate enum member value 04 @typescript-eslint/no-duplicate-enum-values
|
|
46
|
-
36:3 warning Duplicate enum member value 05 @typescript-eslint/no-duplicate-enum-values
|
|
47
|
-
37:3 warning Duplicate enum member value 06 @typescript-eslint/no-duplicate-enum-values
|
|
48
|
-
56:3 warning Duplicate enum member value fc @typescript-eslint/no-duplicate-enum-values
|
|
49
|
-
58:3 warning Duplicate enum member value 00 @typescript-eslint/no-duplicate-enum-values
|
|
50
|
-
59:3 warning Duplicate enum member value 01 @typescript-eslint/no-duplicate-enum-values
|
|
51
|
-
60:3 warning Duplicate enum member value 02 @typescript-eslint/no-duplicate-enum-values
|
|
52
|
-
61:3 warning Duplicate enum member value 03 @typescript-eslint/no-duplicate-enum-values
|
|
53
|
-
62:3 warning Duplicate enum member value 04 @typescript-eslint/no-duplicate-enum-values
|
|
54
|
-
63:3 warning Duplicate enum member value 05 @typescript-eslint/no-duplicate-enum-values
|
|
55
|
-
64:3 warning Duplicate enum member value 06 @typescript-eslint/no-duplicate-enum-values
|
|
56
|
-
65:3 warning Duplicate enum member value 07 @typescript-eslint/no-duplicate-enum-values
|
|
57
|
-
66:3 warning Duplicate enum member value fc @typescript-eslint/no-duplicate-enum-values
|
|
58
|
-
|
|
59
|
-
✖ 45 problems (0 errors, 45 warnings)
|
|
60
|
-
0 errors and 7 warnings potentially fixable with the `--fix` option.
|
|
61
|
-
|
package/.turbo/turbo-test.log
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @caravan/psbt@1.2.0 test
|
|
3
|
-
> jest src
|
|
4
|
-
|
|
5
|
-
PASS src/psbt.test.ts
|
|
6
|
-
PASS src/psbtv2/psbtv2.test.ts
|
|
7
|
-
● Console
|
|
8
|
-
|
|
9
|
-
console.warn
|
|
10
|
-
Dangerously setting PsbtV2.PSBT_GLOBAL_TX_VERSION to 1!
|
|
11
|
-
|
|
12
|
-
806 | );
|
|
13
|
-
807 | }
|
|
14
|
-
> 808 | console.warn("Dangerously setting PsbtV2.PSBT_GLOBAL_TX_VERSION to 1!");
|
|
15
|
-
| ^
|
|
16
|
-
809 | const bw = new BufferWriter();
|
|
17
|
-
810 | bw.writeI32(1);
|
|
18
|
-
811 | this.globalMap.set(KeyType.PSBT_GLOBAL_TX_VERSION, bw.render());
|
|
19
|
-
|
|
20
|
-
at PsbtV2.dangerouslySetGlobalTxVersion1 (src/psbtv2/psbtv2.ts:808:13)
|
|
21
|
-
at Function.FromV0 (src/psbtv2/psbtv2.ts:1240:14)
|
|
22
|
-
at t (src/psbtv2/psbtv2.test.ts:1091:34)
|
|
23
|
-
at Object.<anonymous> (../../node_modules/expect/build/toThrowMatchers.js:74:11)
|
|
24
|
-
at Object.throwingMatcher [as toThrow] (../../node_modules/expect/build/index.js:320:21)
|
|
25
|
-
at src/psbtv2/psbtv2.test.ts:1092:25
|
|
26
|
-
|
|
27
|
-
console.warn
|
|
28
|
-
Dangerously setting PsbtV2.PSBT_GLOBAL_TX_VERSION to 1!
|
|
29
|
-
|
|
30
|
-
806 | );
|
|
31
|
-
807 | }
|
|
32
|
-
> 808 | console.warn("Dangerously setting PsbtV2.PSBT_GLOBAL_TX_VERSION to 1!");
|
|
33
|
-
| ^
|
|
34
|
-
809 | const bw = new BufferWriter();
|
|
35
|
-
810 | bw.writeI32(1);
|
|
36
|
-
811 | this.globalMap.set(KeyType.PSBT_GLOBAL_TX_VERSION, bw.render());
|
|
37
|
-
|
|
38
|
-
at PsbtV2.dangerouslySetGlobalTxVersion1 (src/psbtv2/psbtv2.ts:808:13)
|
|
39
|
-
at Function.FromV0 (src/psbtv2/psbtv2.ts:1240:14)
|
|
40
|
-
at t (src/psbtv2/psbtv2.test.ts:1091:34)
|
|
41
|
-
at Object.<anonymous> (../../node_modules/expect/build/toThrowMatchers.js:74:11)
|
|
42
|
-
at Object.throwingMatcher [as toThrow] (../../node_modules/expect/build/index.js:320:21)
|
|
43
|
-
at src/psbtv2/psbtv2.test.ts:1092:25
|
|
44
|
-
|
|
45
|
-
console.warn
|
|
46
|
-
Dangerously setting PsbtV2.PSBT_GLOBAL_TX_VERSION to 1!
|
|
47
|
-
|
|
48
|
-
806 | );
|
|
49
|
-
807 | }
|
|
50
|
-
> 808 | console.warn("Dangerously setting PsbtV2.PSBT_GLOBAL_TX_VERSION to 1!");
|
|
51
|
-
| ^
|
|
52
|
-
809 | const bw = new BufferWriter();
|
|
53
|
-
810 | bw.writeI32(1);
|
|
54
|
-
811 | this.globalMap.set(KeyType.PSBT_GLOBAL_TX_VERSION, bw.render());
|
|
55
|
-
|
|
56
|
-
at PsbtV2.dangerouslySetGlobalTxVersion1 (src/psbtv2/psbtv2.ts:808:13)
|
|
57
|
-
at Function.FromV0 (src/psbtv2/psbtv2.ts:1240:14)
|
|
58
|
-
at src/psbtv2/psbtv2.test.ts:1103:25
|
|
59
|
-
|
|
60
|
-
console.error
|
|
61
|
-
Error:
|
|
62
|
-
at PsbtV2.<anonymous> (/home/runner/work/caravan/caravan/packages/caravan-psbt/src/psbtv2/psbtv2.test.ts:1193:13)
|
|
63
|
-
at /home/runner/work/caravan/caravan/node_modules/jest-mock/build/index.js:397:39
|
|
64
|
-
at PsbtV2.<anonymous> (/home/runner/work/caravan/caravan/node_modules/jest-mock/build/index.js:404:13)
|
|
65
|
-
at PsbtV2.mockConstructor [as handleSighashType] (/home/runner/work/caravan/caravan/node_modules/jest-mock/build/index.js:148:19)
|
|
66
|
-
at PsbtV2.addPartialSig (/home/runner/work/caravan/caravan/packages/caravan-psbt/src/psbtv2/psbtv2.ts:1078:12)
|
|
67
|
-
at Object.<anonymous> (/home/runner/work/caravan/caravan/packages/caravan-psbt/src/psbtv2/psbtv2.test.ts:1198:10)
|
|
68
|
-
at Promise.then.completed (/home/runner/work/caravan/caravan/node_modules/jest-circus/build/utils.js:298:28)
|
|
69
|
-
at new Promise (<anonymous>)
|
|
70
|
-
at callAsyncCircusFn (/home/runner/work/caravan/caravan/node_modules/jest-circus/build/utils.js:231:10)
|
|
71
|
-
at _callCircusTest (/home/runner/work/caravan/caravan/node_modules/jest-circus/build/run.js:316:40)
|
|
72
|
-
at processTicksAndRejections (node:internal/process/task_queues:95:5)
|
|
73
|
-
at _runTest (/home/runner/work/caravan/caravan/node_modules/jest-circus/build/run.js:252:3)
|
|
74
|
-
at _runTestsForDescribeBlock (/home/runner/work/caravan/caravan/node_modules/jest-circus/build/run.js:126:9)
|
|
75
|
-
at _runTestsForDescribeBlock (/home/runner/work/caravan/caravan/node_modules/jest-circus/build/run.js:121:9)
|
|
76
|
-
at run (/home/runner/work/caravan/caravan/node_modules/jest-circus/build/run.js:71:3)
|
|
77
|
-
at runAndTransformResultsToJestFormat (/home/runner/work/caravan/caravan/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
|
|
78
|
-
at jestAdapter (/home/runner/work/caravan/caravan/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
|
|
79
|
-
at runTestInternal (/home/runner/work/caravan/caravan/node_modules/jest-runner/build/runTest.js:367:16)
|
|
80
|
-
at runTest (/home/runner/work/caravan/caravan/node_modules/jest-runner/build/runTest.js:444:34)
|
|
81
|
-
at Object.worker (/home/runner/work/caravan/caravan/node_modules/jest-runner/build/testWorker.js:106:12)
|
|
82
|
-
|
|
83
|
-
1078 | this.handleSighashType(sig);
|
|
84
|
-
1079 | } catch (err) {
|
|
85
|
-
> 1080 | console.error(err);
|
|
86
|
-
| ^
|
|
87
|
-
1081 | // To remain atomic, attempt to reset everything to the way it was.
|
|
88
|
-
1082 | this.inputMaps[inputIndex].delete(key);
|
|
89
|
-
1083 | this.PSBT_GLOBAL_TX_MODIFIABLE = modBackup;
|
|
90
|
-
|
|
91
|
-
at PsbtV2.addPartialSig (src/psbtv2/psbtv2.ts:1080:15)
|
|
92
|
-
at Object.<anonymous> (src/psbtv2/psbtv2.test.ts:1198:10)
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
Test Suites: 2 passed, 2 total
|
|
96
|
-
Tests: 197 passed, 197 total
|
|
97
|
-
Snapshots: 0 total
|
|
98
|
-
Time: 5.325 s
|
|
99
|
-
Ran all test suites matching /src/i.
|
package/CHANGELOG.md
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# @caravan/psbt
|
|
2
|
-
|
|
3
|
-
## 1.2.0
|
|
4
|
-
|
|
5
|
-
### Minor Changes
|
|
6
|
-
|
|
7
|
-
- [#73](https://github.com/caravan-bitcoin/caravan/pull/73) [`c58f786`](https://github.com/caravan-bitcoin/caravan/commit/c58f786c3409795e12a17a4fe9a3ff4fbf7c6517) Thanks [@Shadouts](https://github.com/Shadouts)! - PsbtV2 public setProprietaryValue allows for proprietary value mapping on the psbt.
|
|
8
|
-
|
|
9
|
-
## 1.1.0
|
|
10
|
-
|
|
11
|
-
### Minor Changes
|
|
12
|
-
|
|
13
|
-
- [#65](https://github.com/caravan-bitcoin/caravan/pull/65) [`514b72f`](https://github.com/caravan-bitcoin/caravan/commit/514b72fe071ee39db833d4d6b6c4a95df288008e) Thanks [@Shadouts](https://github.com/Shadouts)! - PsbtV2 operator role validation getters are added to provide a way for validating role readiness. These getters are used in some Constructor and Signer methods. For example, an error will be thrown if `addPartialSig` is called when the PsbtV2 is not ready for a Signer.
|
|
14
|
-
|
|
15
|
-
## 1.0.1
|
|
16
|
-
|
|
17
|
-
### Patch Changes
|
|
18
|
-
|
|
19
|
-
- [#57](https://github.com/caravan-bitcoin/caravan/pull/57) [`0c6e919`](https://github.com/caravan-bitcoin/caravan/commit/0c6e91936724fa76651d0baf16f5a4e52d375718) Thanks [@Shadouts](https://github.com/Shadouts)! - psbtv2 module directory added and many types have been split into their own module files.
|
|
20
|
-
|
|
21
|
-
## 0.0.0
|
|
22
|
-
|
|
23
|
-
### Patch Changes
|
|
24
|
-
|
|
25
|
-
- [#15](https://github.com/caravan-bitcoin/caravan/pull/15) [`a39dfde`](https://github.com/caravan-bitcoin/caravan/commit/a39dfde2aab9908370bc5eea032960b1939f1e14) Thanks [@bucko13](https://github.com/bucko13)! - maintenance patch to cleanup dependencies
|
|
26
|
-
|
|
27
|
-
- Updated dependencies [[`a39dfde`](https://github.com/caravan-bitcoin/caravan/commit/a39dfde2aab9908370bc5eea032960b1939f1e14)]:
|
|
28
|
-
- @caravan/bitcoin@0.0.1
|
package/dist/index.d.mts
DELETED
|
@@ -1,324 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hex encoded string containing `<keytype><keydata>`. A string is needed for
|
|
3
|
-
* Map.get() since it matches by identity. Most commonly, a `Key` only contains a
|
|
4
|
-
* keytype byte, however, some with keydata can allow for multiple unique keys
|
|
5
|
-
* of the same type.
|
|
6
|
-
*/
|
|
7
|
-
type Key = string;
|
|
8
|
-
/**
|
|
9
|
-
* Values can be of various different types or formats. Here we leave them as
|
|
10
|
-
* Buffers so that getters can decide how they should be formatted.
|
|
11
|
-
*/
|
|
12
|
-
type Value = Buffer;
|
|
13
|
-
type NonUniqueKeyTypeValue = {
|
|
14
|
-
key: string;
|
|
15
|
-
value: string | null;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Provided to friendly-format the `PSBT_GLOBAL_TX_MODIFIABLE` bitmask from
|
|
19
|
-
* `PsbtV2.PSBT_GLOBAL_TX_MODIFIABLE` which returns
|
|
20
|
-
* `PsbtGlobalTxModifiableBits[]`.
|
|
21
|
-
*/
|
|
22
|
-
declare enum PsbtGlobalTxModifiableBits {
|
|
23
|
-
INPUTS = "INPUTS",// 0b00000001
|
|
24
|
-
OUTPUTS = "OUTPUTS",// 0b00000010
|
|
25
|
-
SIGHASH_SINGLE = "SIGHASH_SINGLE"
|
|
26
|
-
}
|
|
27
|
-
type InputOutputIndexType = number;
|
|
28
|
-
type MapSelectorType = "global" | ["inputs", InputOutputIndexType] | ["outputs", InputOutputIndexType];
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Attempts to extract the version number as uint32LE from raw psbt regardless
|
|
32
|
-
* of psbt validity.
|
|
33
|
-
*/
|
|
34
|
-
declare function getPsbtVersionNumber(psbt: string | Buffer): number;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* This abstract class is provided for utility to allow for mapping, map
|
|
38
|
-
* copying, and serialization operations for psbts. This does almost no
|
|
39
|
-
* validation, so do not rely on it for ensuring a valid psbt.
|
|
40
|
-
*/
|
|
41
|
-
declare abstract class PsbtV2Maps {
|
|
42
|
-
protected globalMap: Map<Key, Value>;
|
|
43
|
-
protected inputMaps: Map<Key, Value>[];
|
|
44
|
-
protected outputMaps: Map<Key, Value>[];
|
|
45
|
-
constructor(psbt?: Buffer | string);
|
|
46
|
-
/**
|
|
47
|
-
* Return the current state of the psbt as a string in the specified format.
|
|
48
|
-
*/
|
|
49
|
-
serialize(format?: "base64" | "hex"): string;
|
|
50
|
-
/**
|
|
51
|
-
* Copies the maps in this PsbtV2 object to another PsbtV2 object.
|
|
52
|
-
*
|
|
53
|
-
* NOTE: This copy method is made available to achieve parity with the PSBT
|
|
54
|
-
* api required by `ledger-bitcoin` for creating merklized PSBTs. HOWEVER, it
|
|
55
|
-
* is not recommended to use this when avoidable as copying maps bypasses the
|
|
56
|
-
* validation defined in the constructor, so it could create a psbtv2 in an
|
|
57
|
-
* invalid psbt state. PsbtV2.serialize is preferable whenever possible.
|
|
58
|
-
*/
|
|
59
|
-
copy(to: PsbtV2): void;
|
|
60
|
-
private copyMaps;
|
|
61
|
-
private copyMap;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* The PsbtV2 class is intended to represent an easily modifiable and
|
|
66
|
-
* serializable psbt of version 2 conforming to BIP0174. Getters exist for all
|
|
67
|
-
* BIP-defined keytypes. Very few setters and modifier methods exist. As they
|
|
68
|
-
* are added, they should enforce implied and documented rules and limitations.
|
|
69
|
-
*
|
|
70
|
-
* Defining BIPs:
|
|
71
|
-
* https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki
|
|
72
|
-
* https://github.com/bitcoin/bips/blob/master/bip-0370.mediawiki
|
|
73
|
-
*/
|
|
74
|
-
declare class PsbtV2 extends PsbtV2Maps {
|
|
75
|
-
constructor(psbt?: Buffer | string);
|
|
76
|
-
/**
|
|
77
|
-
* Globals Getters/Setters
|
|
78
|
-
*/
|
|
79
|
-
get PSBT_GLOBAL_XPUB(): NonUniqueKeyTypeValue[];
|
|
80
|
-
get PSBT_GLOBAL_TX_VERSION(): number;
|
|
81
|
-
set PSBT_GLOBAL_TX_VERSION(version: number);
|
|
82
|
-
get PSBT_GLOBAL_FALLBACK_LOCKTIME(): number | null;
|
|
83
|
-
set PSBT_GLOBAL_FALLBACK_LOCKTIME(locktime: number | null);
|
|
84
|
-
get PSBT_GLOBAL_INPUT_COUNT(): number;
|
|
85
|
-
set PSBT_GLOBAL_INPUT_COUNT(count: number);
|
|
86
|
-
get PSBT_GLOBAL_OUTPUT_COUNT(): number;
|
|
87
|
-
set PSBT_GLOBAL_OUTPUT_COUNT(count: number);
|
|
88
|
-
get PSBT_GLOBAL_TX_MODIFIABLE(): PsbtGlobalTxModifiableBits[];
|
|
89
|
-
set PSBT_GLOBAL_TX_MODIFIABLE(modifiable: PsbtGlobalTxModifiableBits[]);
|
|
90
|
-
get PSBT_GLOBAL_VERSION(): number;
|
|
91
|
-
set PSBT_GLOBAL_VERSION(version: number);
|
|
92
|
-
get PSBT_GLOBAL_PROPRIETARY(): NonUniqueKeyTypeValue[];
|
|
93
|
-
/**
|
|
94
|
-
* Input Getters/Setters
|
|
95
|
-
*/
|
|
96
|
-
get PSBT_IN_NON_WITNESS_UTXO(): (string | null)[];
|
|
97
|
-
get PSBT_IN_WITNESS_UTXO(): (string | null)[];
|
|
98
|
-
get PSBT_IN_PARTIAL_SIG(): NonUniqueKeyTypeValue[][];
|
|
99
|
-
get PSBT_IN_SIGHASH_TYPE(): (number | null)[];
|
|
100
|
-
get PSBT_IN_REDEEM_SCRIPT(): (string | null)[];
|
|
101
|
-
get PSBT_IN_WITNESS_SCRIPT(): (string | null)[];
|
|
102
|
-
get PSBT_IN_BIP32_DERIVATION(): NonUniqueKeyTypeValue[][];
|
|
103
|
-
get PSBT_IN_FINAL_SCRIPTSIG(): (string | null)[];
|
|
104
|
-
get PSBT_IN_FINAL_SCRIPTWITNESS(): (string | null)[];
|
|
105
|
-
get PSBT_IN_POR_COMMITMENT(): (string | null)[];
|
|
106
|
-
get PSBT_IN_RIPEMD160(): NonUniqueKeyTypeValue[][];
|
|
107
|
-
get PSBT_IN_SHA256(): NonUniqueKeyTypeValue[][];
|
|
108
|
-
get PSBT_IN_HASH160(): NonUniqueKeyTypeValue[][];
|
|
109
|
-
get PSBT_IN_HASH256(): NonUniqueKeyTypeValue[][];
|
|
110
|
-
get PSBT_IN_PREVIOUS_TXID(): string[];
|
|
111
|
-
get PSBT_IN_OUTPUT_INDEX(): number[];
|
|
112
|
-
get PSBT_IN_SEQUENCE(): (number | null)[];
|
|
113
|
-
get PSBT_IN_REQUIRED_TIME_LOCKTIME(): (number | null)[];
|
|
114
|
-
get PSBT_IN_REQUIRED_HEIGHT_LOCKTIME(): (number | null)[];
|
|
115
|
-
get PSBT_IN_TAP_KEY_SIG(): (string | null)[];
|
|
116
|
-
get PSBT_IN_TAP_SCRIPT_SIG(): NonUniqueKeyTypeValue[][];
|
|
117
|
-
get PSBT_IN_TAP_LEAF_SCRIPT(): NonUniqueKeyTypeValue[][];
|
|
118
|
-
get PSBT_IN_TAP_BIP32_DERIVATION(): NonUniqueKeyTypeValue[][];
|
|
119
|
-
get PSBT_IN_TAP_INTERNAL_KEY(): (string | null)[];
|
|
120
|
-
get PSBT_IN_TAP_MERKLE_ROOT(): (string | null)[];
|
|
121
|
-
get PSBT_IN_PROPRIETARY(): NonUniqueKeyTypeValue[] | NonUniqueKeyTypeValue[][];
|
|
122
|
-
/**
|
|
123
|
-
* Output Getters/Setters
|
|
124
|
-
*/
|
|
125
|
-
get PSBT_OUT_REDEEM_SCRIPT(): (string | null)[];
|
|
126
|
-
get PSBT_OUT_WITNESS_SCRIPT(): (string | null)[];
|
|
127
|
-
get PSBT_OUT_BIP32_DERIVATION(): NonUniqueKeyTypeValue[] | NonUniqueKeyTypeValue[][];
|
|
128
|
-
get PSBT_OUT_AMOUNT(): bigint[];
|
|
129
|
-
get PSBT_OUT_SCRIPT(): string[];
|
|
130
|
-
get PSBT_OUT_TAP_INTERNAL_KEY(): (string | null)[];
|
|
131
|
-
get PSBT_OUT_TAP_TREE(): (string | null)[];
|
|
132
|
-
get PSBT_OUT_TAP_BIP32_DERIVATION(): NonUniqueKeyTypeValue[] | NonUniqueKeyTypeValue[][];
|
|
133
|
-
get PSBT_OUT_PROPRIETARY(): NonUniqueKeyTypeValue[] | NonUniqueKeyTypeValue[][];
|
|
134
|
-
/**
|
|
135
|
-
* Operator Role Validation Getters
|
|
136
|
-
*/
|
|
137
|
-
/**
|
|
138
|
-
* Returns true if the PsbtV2 is ready for an operator taking the Constructor
|
|
139
|
-
* role.
|
|
140
|
-
*
|
|
141
|
-
* This check assumes that the Creator used this class's constructor method to
|
|
142
|
-
* initialize the PsbtV2 without passing a psbt (constructor defaults were
|
|
143
|
-
* set).
|
|
144
|
-
*/
|
|
145
|
-
get isReadyForConstructor(): boolean;
|
|
146
|
-
/**
|
|
147
|
-
* Returns true if the PsbtV2 is ready for an operator taking the Updater
|
|
148
|
-
* role.
|
|
149
|
-
*
|
|
150
|
-
* Before signatures are added, but after an input is added, a PsbtV2 is
|
|
151
|
-
* likely to be ready for Constructor, ready for Updater, and ready for Signer
|
|
152
|
-
* simultaneously.
|
|
153
|
-
*
|
|
154
|
-
* According to BIP370, the Updater can modify the sequence number, but it is
|
|
155
|
-
* unclear if the Updater retains permissions provided in psbtv0 (BIP174). It
|
|
156
|
-
* is likely not the case that the Updater has the same permissions as
|
|
157
|
-
* previously because it seems to now be the realm of the Constructor to add
|
|
158
|
-
* inputs and outputs.
|
|
159
|
-
*/
|
|
160
|
-
get isReadyForUpdater(): boolean;
|
|
161
|
-
/**
|
|
162
|
-
* Returns true if the PsbtV2 is ready for an operator taking the Signer role.
|
|
163
|
-
*/
|
|
164
|
-
get isReadyForSigner(): boolean;
|
|
165
|
-
/**
|
|
166
|
-
* Returns true if the PsbtV2 is ready for an operator taking the Combiner
|
|
167
|
-
* role.
|
|
168
|
-
*/
|
|
169
|
-
get isReadyForCombiner(): boolean;
|
|
170
|
-
/**
|
|
171
|
-
* Unimplemented. Returns false.
|
|
172
|
-
*/
|
|
173
|
-
get isReadyForInputFinalizer(): boolean;
|
|
174
|
-
/**
|
|
175
|
-
* Returns true if the PsbtV2 is ready for an operator taking the Transaction
|
|
176
|
-
* Extractor role.
|
|
177
|
-
*
|
|
178
|
-
* If all the inputs have been finalized, then the psbt is ready for the
|
|
179
|
-
* Transaction Extractor. According to BIP 174, it's the responsibility of the
|
|
180
|
-
* Input Finalizer to add scriptSigs or scriptWitnesses and then remove other
|
|
181
|
-
* details besides the UTXO. This getter checks that the Input Finalizer has
|
|
182
|
-
* finished its job.
|
|
183
|
-
*/
|
|
184
|
-
get isReadyForTransactionExtractor(): boolean;
|
|
185
|
-
/**
|
|
186
|
-
* Other Getters/Setters
|
|
187
|
-
*/
|
|
188
|
-
/**
|
|
189
|
-
* Returns the `nLockTime` field for the psbt as if it were a bitcoin
|
|
190
|
-
* transaction.
|
|
191
|
-
*/
|
|
192
|
-
get nLockTime(): number | null;
|
|
193
|
-
/**
|
|
194
|
-
* Creator/Constructor Methods
|
|
195
|
-
*/
|
|
196
|
-
/**
|
|
197
|
-
* Ensures that global fields have initial values required by a PsbtV2
|
|
198
|
-
* Creator. It is called by the constructor if constructed without a psbt.
|
|
199
|
-
*/
|
|
200
|
-
private create;
|
|
201
|
-
/**
|
|
202
|
-
* Checks initial construction of any valid PsbtV2. It is called when a psbt
|
|
203
|
-
* is passed to the constructor or when a new psbt is being created. If
|
|
204
|
-
* constructed with a psbt, this method acts outside of the Creator role to
|
|
205
|
-
* validate the current state of the psbt.
|
|
206
|
-
*/
|
|
207
|
-
private validate;
|
|
208
|
-
/**
|
|
209
|
-
* This method is provided for compatibility issues and probably shouldn't be
|
|
210
|
-
* used since a PsbtV2 with PSBT_GLOBAL_TX_VERSION = 1 is BIP0370
|
|
211
|
-
* non-compliant. No guarantees can be made here that a serialized PsbtV2
|
|
212
|
-
* which used this method will be compatible with outside consumers.
|
|
213
|
-
*
|
|
214
|
-
* One may wish to instance this class from a partially signed PSBTv0 with a
|
|
215
|
-
* txn version 1 by using the static PsbtV2.FromV0. This method provides a way
|
|
216
|
-
* to override validation logic for the txn version and roles lifecycle
|
|
217
|
-
* defined for PsbtV2.
|
|
218
|
-
*/
|
|
219
|
-
dangerouslySetGlobalTxVersion1(): void;
|
|
220
|
-
addGlobalXpub(xpub: Buffer, fingerprint: Buffer, path: string): void;
|
|
221
|
-
addInput({ previousTxId, outputIndex, sequence, nonWitnessUtxo, witnessUtxo, redeemScript, witnessScript, bip32Derivation, }: {
|
|
222
|
-
previousTxId: Buffer | string;
|
|
223
|
-
outputIndex: number;
|
|
224
|
-
sequence?: number;
|
|
225
|
-
nonWitnessUtxo?: Buffer;
|
|
226
|
-
witnessUtxo?: {
|
|
227
|
-
amount: number;
|
|
228
|
-
script: Buffer;
|
|
229
|
-
};
|
|
230
|
-
redeemScript?: Buffer;
|
|
231
|
-
witnessScript?: Buffer;
|
|
232
|
-
bip32Derivation?: {
|
|
233
|
-
pubkey: Buffer;
|
|
234
|
-
masterFingerprint: Buffer;
|
|
235
|
-
path: string;
|
|
236
|
-
}[];
|
|
237
|
-
}): void;
|
|
238
|
-
addOutput({ amount, script, redeemScript, witnessScript, bip32Derivation, }: {
|
|
239
|
-
amount: number;
|
|
240
|
-
script: Buffer;
|
|
241
|
-
redeemScript?: Buffer;
|
|
242
|
-
witnessScript?: Buffer;
|
|
243
|
-
bip32Derivation?: {
|
|
244
|
-
pubkey: Buffer;
|
|
245
|
-
masterFingerprint: Buffer;
|
|
246
|
-
path: string;
|
|
247
|
-
}[];
|
|
248
|
-
}): void;
|
|
249
|
-
/**
|
|
250
|
-
* Updater/Signer Methods
|
|
251
|
-
*/
|
|
252
|
-
/**
|
|
253
|
-
* Removes an input-map from inputMaps.
|
|
254
|
-
*/
|
|
255
|
-
deleteInput(index: number): void;
|
|
256
|
-
/**
|
|
257
|
-
* Removes an output-map from outputMaps.
|
|
258
|
-
*/
|
|
259
|
-
deleteOutput(index: number): void;
|
|
260
|
-
/**
|
|
261
|
-
* Checks that all provided flags are present in PSBT_GLOBAL_TX_MODIFIABLE.
|
|
262
|
-
*/
|
|
263
|
-
private isModifiable;
|
|
264
|
-
/**
|
|
265
|
-
* Adds a signature for an input. Validates that the input is mapped and does
|
|
266
|
-
* not already have a signature for the pubkey. Also validates for sighash.
|
|
267
|
-
* Other validation is incomplete. Also validates for required args in case
|
|
268
|
-
* typescript is not being used to call the method.
|
|
269
|
-
*
|
|
270
|
-
* The Signer, when it creates a signature, must add the partial sig keypair
|
|
271
|
-
* to the psbt for the input which it is signing. In the case that a
|
|
272
|
-
* particular signer does not, this method can be used to add a signature to
|
|
273
|
-
* the psbt. This method assumes the Signer did the validation outlined in
|
|
274
|
-
* BIP0174 before creating a signature.
|
|
275
|
-
* https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#signer
|
|
276
|
-
*/
|
|
277
|
-
addPartialSig(inputIndex: number, pubkey: Buffer, sig: Buffer): void;
|
|
278
|
-
/**
|
|
279
|
-
* Removes all sigs for an input unless a pubkey is specified. Validates that
|
|
280
|
-
* the input exists. When providing a pubkey, this validates that a sig for
|
|
281
|
-
* the pubkey exists.
|
|
282
|
-
*/
|
|
283
|
-
removePartialSig(inputIndex: number, pubkey?: Buffer): void;
|
|
284
|
-
/**
|
|
285
|
-
* Sets values on the proprietary keytype for a global, input, or output map.
|
|
286
|
-
* BIP 174 allows for proprietary values to be set on all maps with the
|
|
287
|
-
* keytype `0xFC`. This method sets byte data to key values defined by the
|
|
288
|
-
* args.
|
|
289
|
-
*
|
|
290
|
-
* Args:
|
|
291
|
-
* - `mapSelector` selects which map to set the proprietary value. If this
|
|
292
|
-
* value is not `"global"`, then a tuple must be provided with `"inputs"` or
|
|
293
|
-
* `"outputs"` as the first element and the index `number` on the second
|
|
294
|
-
* element representing which input or output map to set the value to. An
|
|
295
|
-
* example looks like `["inputs", 0]`. If the map name doesn't match, the
|
|
296
|
-
* values will be set to the global map. If the index is missing on
|
|
297
|
-
* `"inputs"` or `"outputs"`, then it will throw.
|
|
298
|
-
* - `identifier` should be the bytes identifier for the set of proprietary
|
|
299
|
-
* keytypes.
|
|
300
|
-
* - `subkeyType` accepts bytes proprietary keytype.
|
|
301
|
-
* - `subkeyData` accepts bytes proprietary keydata.
|
|
302
|
-
* - `valueData` accepts bytes which will be written as the proprietary value.
|
|
303
|
-
*
|
|
304
|
-
* From the provided args, a key with the following format will be generated:
|
|
305
|
-
* `0xFC<compact uint identifier length><bytes identifier><bytes
|
|
306
|
-
* subtype><bytes subkeydata>`
|
|
307
|
-
*/
|
|
308
|
-
setProprietaryValue(mapSelector: MapSelectorType, identifier: Buffer, subkeyType: Buffer, subkeyData: Buffer, valueData: Buffer): void;
|
|
309
|
-
/**
|
|
310
|
-
* Ensures the PSBT is in the proper state when adding a partial sig keypair.
|
|
311
|
-
* https://github.com/bitcoin/bips/blob/master/bip-0370.mediawiki#signer
|
|
312
|
-
*/
|
|
313
|
-
private handleSighashType;
|
|
314
|
-
/**
|
|
315
|
-
* Attempts to return a PsbtV2 by converting from a PsbtV0 string or Buffer.
|
|
316
|
-
*
|
|
317
|
-
* This method first starts with a fresh PsbtV2 having just been created. It
|
|
318
|
-
* then takes the PsbtV2 through its operator saga through the Signer role. In
|
|
319
|
-
* this sense validation for each operator role will be performed.
|
|
320
|
-
*/
|
|
321
|
-
static FromV0(psbt: string | Buffer, allowTxnVersion1?: boolean): PsbtV2;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
export { PsbtV2, getPsbtVersionNumber };
|
package/jest.config.js
DELETED
package/src/index.ts
DELETED