@caravan/psbt 1.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/.eslintrc.cjs +6 -0
- package/.prettierrc +4 -0
- package/.turbo/turbo-build.log +20 -0
- package/.turbo/turbo-ci.log +258 -0
- package/.turbo/turbo-lint.log +49 -0
- package/.turbo/turbo-test$colon$watch.log +223 -0
- package/.turbo/turbo-test.log +196 -0
- package/CHANGELOG.md +10 -0
- package/README.md +197 -0
- package/dist/index.d.mts +150 -0
- package/dist/index.d.ts +150 -0
- package/dist/index.js +949 -0
- package/dist/index.mjs +924 -0
- package/jest.config.js +4 -0
- package/package.json +49 -0
- package/src/index.ts +2 -0
- package/src/psbt.test.ts +338 -0
- package/src/psbt.ts +440 -0
- package/src/psbtv2.test.ts +1241 -0
- package/src/psbtv2.ts +1352 -0
- package/tsconfig.json +3 -0
- package/tsup.config.ts +6 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
> @caravan/psbt@0.0.0 test
|
|
4
|
+
> jest src
|
|
5
|
+
|
|
6
|
+
[1m[2mDetermining test suites to run...[22m[22m[999D[K
|
|
7
|
+
|
|
8
|
+
[1mTest Suites: [22m0 of 2 total
|
|
9
|
+
[1mTests: [22m0 total
|
|
10
|
+
[1mSnapshots: [22m0 total
|
|
11
|
+
[1mTime:[22m 0 s, estimated 5 s
|
|
12
|
+
[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m
|
|
13
|
+
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [2msrc/[22m[1mpsbtv2.test.ts[22m
|
|
14
|
+
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [2msrc/[22m[1mpsbt.test.ts[22m
|
|
15
|
+
|
|
16
|
+
[1mTest Suites: [22m0 of 2 total
|
|
17
|
+
[1mTests: [22m0 total
|
|
18
|
+
[1mSnapshots: [22m0 total
|
|
19
|
+
[1mTime:[22m 0 s, estimated 5 s
|
|
20
|
+
[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m
|
|
21
|
+
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [2msrc/[22m[1mpsbtv2.test.ts[22m
|
|
22
|
+
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [2msrc/[22m[1mpsbt.test.ts[22m
|
|
23
|
+
|
|
24
|
+
[1mTest Suites: [22m0 of 2 total
|
|
25
|
+
[1mTests: [22m0 total
|
|
26
|
+
[1mSnapshots: [22m0 total
|
|
27
|
+
[1mTime:[22m 1 s, estimated 5 s
|
|
28
|
+
[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m
|
|
29
|
+
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [2msrc/[22m[1mpsbtv2.test.ts[22m
|
|
30
|
+
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [2msrc/[22m[1mpsbt.test.ts[22m
|
|
31
|
+
|
|
32
|
+
[1mTest Suites: [22m0 of 2 total
|
|
33
|
+
[1mTests: [22m0 total
|
|
34
|
+
[1mSnapshots: [22m0 total
|
|
35
|
+
[1mTime:[22m 2 s, estimated 5 s
|
|
36
|
+
[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m
|
|
37
|
+
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [2msrc/[22m[1mpsbtv2.test.ts[22m
|
|
38
|
+
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [2msrc/[22m[1mpsbt.test.ts[22m
|
|
39
|
+
|
|
40
|
+
[1mTest Suites: [22m0 of 2 total
|
|
41
|
+
[1mTests: [22m0 total
|
|
42
|
+
[1mSnapshots: [22m0 total
|
|
43
|
+
[1mTime:[22m 3 s, estimated 5 s
|
|
44
|
+
[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m
|
|
45
|
+
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [2msrc/[22m[1mpsbtv2.test.ts[22m
|
|
46
|
+
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [2msrc/[22m[1mpsbt.test.ts[22m
|
|
47
|
+
|
|
48
|
+
[1mTest Suites: [22m0 of 2 total
|
|
49
|
+
[1mTests: [22m[1m[32m67 passed[39m[22m, 67 total
|
|
50
|
+
[1mSnapshots: [22m0 total
|
|
51
|
+
[1mTime:[22m 3 s, estimated 5 s
|
|
52
|
+
[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m
|
|
53
|
+
|
|
54
|
+
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [2msrc/[22m[1mpsbtv2.test.ts[22m
|
|
55
|
+
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [2msrc/[22m[1mpsbt.test.ts[22m
|
|
56
|
+
|
|
57
|
+
[1mTest Suites: [22m0 of 2 total
|
|
58
|
+
[1mTests: [22m[1m[32m67 passed[39m[22m, 67 total
|
|
59
|
+
[1mSnapshots: [22m0 total
|
|
60
|
+
[1mTime:[22m 3 s, estimated 5 s
|
|
61
|
+
[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m
|
|
62
|
+
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [2msrc/[22m[1mpsbtv2.test.ts[22m
|
|
63
|
+
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [2msrc/[22m[1mpsbt.test.ts[22m
|
|
64
|
+
|
|
65
|
+
[1mTest Suites: [22m0 of 2 total
|
|
66
|
+
[1mTests: [22m[1m[32m67 passed[39m[22m, 67 total
|
|
67
|
+
[1mSnapshots: [22m0 total
|
|
68
|
+
[1mTime:[22m 3 s, estimated 5 s
|
|
69
|
+
[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m
|
|
70
|
+
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [2msrc/[22m[1mpsbtv2.test.ts[22m
|
|
71
|
+
|
|
72
|
+
[1mTest Suites: [22m[1m[32m1 passed[39m[22m, 1 of 2 total
|
|
73
|
+
[1mTests: [22m[1m[32m134 passed[39m[22m, 134 total
|
|
74
|
+
[1mSnapshots: [22m0 total
|
|
75
|
+
[1mTime:[22m 3 s, estimated 5 s
|
|
76
|
+
[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m
|
|
77
|
+
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [2msrc/[22m[1mpsbtv2.test.ts[22m
|
|
78
|
+
|
|
79
|
+
[1mTest Suites: [22m[1m[32m1 passed[39m[22m, 1 of 2 total
|
|
80
|
+
[1mTests: [22m[1m[32m156 passed[39m[22m, 156 total
|
|
81
|
+
[1mSnapshots: [22m0 total
|
|
82
|
+
[1mTime:[22m 3 s, estimated 5 s
|
|
83
|
+
[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m
|
|
84
|
+
|
|
85
|
+
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [2msrc/[22m[1mpsbtv2.test.ts[22m
|
|
86
|
+
|
|
87
|
+
[1mTest Suites: [22m[1m[32m1 passed[39m[22m, 1 of 2 total
|
|
88
|
+
[1mTests: [22m[1m[32m156 passed[39m[22m, 156 total
|
|
89
|
+
[1mSnapshots: [22m0 total
|
|
90
|
+
[1mTime:[22m 3 s, estimated 5 s
|
|
91
|
+
[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m
|
|
92
|
+
|
|
93
|
+
[2m[33mconsole.warn[39m[22m
|
|
94
|
+
[33m Dangerously setting PsbtV2.PSBT_GLOBAL_TX_VERSION to 1![39m
|
|
95
|
+
[2m[22m
|
|
96
|
+
[2m [0m [90m 892 |[39m [90m// lifecycle defined for PsbtV2.[39m[0m[22m
|
|
97
|
+
[2m [0m [90m 893 |[39m [36mpublic[39m dangerouslySetGlobalTxVersion1() {[0m[22m
|
|
98
|
+
[2m [0m[31m[1m>[22m[2m[39m[90m 894 |[39m console[33m.[39mwarn([32m"Dangerously setting PsbtV2.PSBT_GLOBAL_TX_VERSION to 1!"[39m)[33m;[39m[0m[22m
|
|
99
|
+
[2m [0m [90m |[39m [31m[1m^[22m[2m[39m[0m[22m
|
|
100
|
+
[2m [0m [90m 895 |[39m [36mconst[39m bw [33m=[39m [36mnew[39m [33mBufferWriter[39m()[33m;[39m[0m[22m
|
|
101
|
+
[2m [0m [90m 896 |[39m bw[33m.[39mwriteI32([35m1[39m)[33m;[39m[0m[22m
|
|
102
|
+
[2m [0m [90m 897 |[39m [36mthis[39m[33m.[39mglobalMap[33m.[39m[36mset[39m([33mKeyType[39m[33m.[39m[33mPSBT_GLOBAL_TX_VERSION[39m[33m,[39m bw[33m.[39mrender())[33m;[39m[0m[22m
|
|
103
|
+
[2m[22m
|
|
104
|
+
[2m [2mat PsbtV2.dangerouslySetGlobalTxVersion1 ([22m[2msrc/psbtv2.ts[2m:894:13)[22m[2m[22m
|
|
105
|
+
[2m [2mat Function.FromV0 ([22m[2msrc/psbtv2.ts[2m:1208:14)[22m[2m[22m
|
|
106
|
+
[2m [2mat t ([22m[2m[0m[36msrc/psbtv2.test.ts[39m[0m[2m:947:34)[22m[2m[22m
|
|
107
|
+
[2m [2mat Object.<anonymous> ([22m[2m../../node_modules/expect/build/toThrowMatchers.js[2m:74:11)[22m[2m[22m
|
|
108
|
+
[2m [2mat Object.throwingMatcher [as toThrow] ([22m[2m../../node_modules/expect/build/index.js[2m:320:21)[22m[2m[22m
|
|
109
|
+
[2m [2mat [22m[2m[0m[36msrc/psbtv2.test.ts[39m[0m[2m:948:25[22m[2m[22m
|
|
110
|
+
|
|
111
|
+
[2m[33mconsole.warn[39m[22m
|
|
112
|
+
[33m Dangerously setting PsbtV2.PSBT_GLOBAL_TX_VERSION to 1![39m
|
|
113
|
+
[2m[22m
|
|
114
|
+
[2m [0m [90m 892 |[39m [90m// lifecycle defined for PsbtV2.[39m[0m[22m
|
|
115
|
+
[2m [0m [90m 893 |[39m [36mpublic[39m dangerouslySetGlobalTxVersion1() {[0m[22m
|
|
116
|
+
[2m [0m[31m[1m>[22m[2m[39m[90m 894 |[39m console[33m.[39mwarn([32m"Dangerously setting PsbtV2.PSBT_GLOBAL_TX_VERSION to 1!"[39m)[33m;[39m[0m[22m
|
|
117
|
+
[2m [0m [90m |[39m [31m[1m^[22m[2m[39m[0m[22m
|
|
118
|
+
[2m [0m [90m 895 |[39m [36mconst[39m bw [33m=[39m [36mnew[39m [33mBufferWriter[39m()[33m;[39m[0m[22m
|
|
119
|
+
[2m [0m [90m 896 |[39m bw[33m.[39mwriteI32([35m1[39m)[33m;[39m[0m[22m
|
|
120
|
+
[2m [0m [90m 897 |[39m [36mthis[39m[33m.[39mglobalMap[33m.[39m[36mset[39m([33mKeyType[39m[33m.[39m[33mPSBT_GLOBAL_TX_VERSION[39m[33m,[39m bw[33m.[39mrender())[33m;[39m[0m[22m
|
|
121
|
+
[2m[22m
|
|
122
|
+
[2m [2mat PsbtV2.dangerouslySetGlobalTxVersion1 ([22m[2msrc/psbtv2.ts[2m:894:13)[22m[2m[22m
|
|
123
|
+
[2m [2mat Function.FromV0 ([22m[2msrc/psbtv2.ts[2m:1208:14)[22m[2m[22m
|
|
124
|
+
[2m [2mat t ([22m[2m[0m[36msrc/psbtv2.test.ts[39m[0m[2m:947:34)[22m[2m[22m
|
|
125
|
+
[2m [2mat Object.<anonymous> ([22m[2m../../node_modules/expect/build/toThrowMatchers.js[2m:74:11)[22m[2m[22m
|
|
126
|
+
[2m [2mat Object.throwingMatcher [as toThrow] ([22m[2m../../node_modules/expect/build/index.js[2m:320:21)[22m[2m[22m
|
|
127
|
+
[2m [2mat [22m[2m[0m[36msrc/psbtv2.test.ts[39m[0m[2m:948:25[22m[2m[22m
|
|
128
|
+
|
|
129
|
+
[2m[33mconsole.warn[39m[22m
|
|
130
|
+
[33m Dangerously setting PsbtV2.PSBT_GLOBAL_TX_VERSION to 1![39m
|
|
131
|
+
[2m[22m
|
|
132
|
+
[2m [0m [90m 892 |[39m [90m// lifecycle defined for PsbtV2.[39m[0m[22m
|
|
133
|
+
[2m [0m [90m 893 |[39m [36mpublic[39m dangerouslySetGlobalTxVersion1() {[0m[22m
|
|
134
|
+
[2m [0m[31m[1m>[22m[2m[39m[90m 894 |[39m console[33m.[39mwarn([32m"Dangerously setting PsbtV2.PSBT_GLOBAL_TX_VERSION to 1!"[39m)[33m;[39m[0m[22m
|
|
135
|
+
[2m [0m [90m |[39m [31m[1m^[22m[2m[39m[0m[22m
|
|
136
|
+
[2m [0m [90m 895 |[39m [36mconst[39m bw [33m=[39m [36mnew[39m [33mBufferWriter[39m()[33m;[39m[0m[22m
|
|
137
|
+
[2m [0m [90m 896 |[39m bw[33m.[39mwriteI32([35m1[39m)[33m;[39m[0m[22m
|
|
138
|
+
[2m [0m [90m 897 |[39m [36mthis[39m[33m.[39mglobalMap[33m.[39m[36mset[39m([33mKeyType[39m[33m.[39m[33mPSBT_GLOBAL_TX_VERSION[39m[33m,[39m bw[33m.[39mrender())[33m;[39m[0m[22m
|
|
139
|
+
[2m[22m
|
|
140
|
+
[2m [2mat PsbtV2.dangerouslySetGlobalTxVersion1 ([22m[2msrc/psbtv2.ts[2m:894:13)[22m[2m[22m
|
|
141
|
+
[2m [2mat Function.FromV0 ([22m[2msrc/psbtv2.ts[2m:1208:14)[22m[2m[22m
|
|
142
|
+
[2m [2mat [22m[2m[0m[36msrc/psbtv2.test.ts[39m[0m[2m:959:25[22m[2m[22m
|
|
143
|
+
|
|
144
|
+
[2m[31mconsole.error[39m[22m
|
|
145
|
+
[31m Error: [39m
|
|
146
|
+
[31m at PsbtV2.<anonymous> (/Users/atreides/repos/caravan-monorepo/packages/caravan-psbt/src/psbtv2.test.ts:1044:13)[39m
|
|
147
|
+
[31m at /Users/atreides/repos/caravan-monorepo/node_modules/jest-mock/build/index.js:397:39[39m
|
|
148
|
+
[31m at PsbtV2.<anonymous> (/Users/atreides/repos/caravan-monorepo/node_modules/jest-mock/build/index.js:404:13)[39m
|
|
149
|
+
[31m at PsbtV2.mockConstructor [as handleSighashType] (/Users/atreides/repos/caravan-monorepo/node_modules/jest-mock/build/index.js:148:19)[39m
|
|
150
|
+
[31m at PsbtV2.addPartialSig (/Users/atreides/repos/caravan-monorepo/packages/caravan-psbt/src/psbtv2.ts:1120:12)[39m
|
|
151
|
+
[31m at Object.<anonymous> (/Users/atreides/repos/caravan-monorepo/packages/caravan-psbt/src/psbtv2.test.ts:1049:10)[39m
|
|
152
|
+
[31m at Promise.then.completed (/Users/atreides/repos/caravan-monorepo/node_modules/jest-circus/build/utils.js:298:28)[39m
|
|
153
|
+
[31m at new Promise (<anonymous>)[39m
|
|
154
|
+
[31m at callAsyncCircusFn (/Users/atreides/repos/caravan-monorepo/node_modules/jest-circus/build/utils.js:231:10)[39m
|
|
155
|
+
[31m at _callCircusTest (/Users/atreides/repos/caravan-monorepo/node_modules/jest-circus/build/run.js:316:40)[39m
|
|
156
|
+
[31m at processTicksAndRejections (node:internal/process/task_queues:95:5)[39m
|
|
157
|
+
[31m at _runTest (/Users/atreides/repos/caravan-monorepo/node_modules/jest-circus/build/run.js:252:3)[39m
|
|
158
|
+
[31m at _runTestsForDescribeBlock (/Users/atreides/repos/caravan-monorepo/node_modules/jest-circus/build/run.js:126:9)[39m
|
|
159
|
+
[31m at _runTestsForDescribeBlock (/Users/atreides/repos/caravan-monorepo/node_modules/jest-circus/build/run.js:121:9)[39m
|
|
160
|
+
[31m at run (/Users/atreides/repos/caravan-monorepo/node_modules/jest-circus/build/run.js:71:3)[39m
|
|
161
|
+
[31m at runAndTransformResultsToJestFormat (/Users/atreides/repos/caravan-monorepo/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)[39m
|
|
162
|
+
[31m at jestAdapter (/Users/atreides/repos/caravan-monorepo/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)[39m
|
|
163
|
+
[31m at runTestInternal (/Users/atreides/repos/caravan-monorepo/node_modules/jest-runner/build/runTest.js:367:16)[39m
|
|
164
|
+
[31m at runTest (/Users/atreides/repos/caravan-monorepo/node_modules/jest-runner/build/runTest.js:444:34)[39m
|
|
165
|
+
[31m at Object.worker (/Users/atreides/repos/caravan-monorepo/node_modules/jest-runner/build/testWorker.js:106:12)[39m
|
|
166
|
+
[2m[22m
|
|
167
|
+
[2m [0m [90m 1120 |[39m [36mthis[39m[33m.[39mhandleSighashType(sig)[33m;[39m[0m[22m
|
|
168
|
+
[2m [0m [90m 1121 |[39m } [36mcatch[39m (err) {[0m[22m
|
|
169
|
+
[2m [0m[31m[1m>[22m[2m[39m[90m 1122 |[39m console[33m.[39merror(err)[33m;[39m[0m[22m
|
|
170
|
+
[2m [0m [90m |[39m [31m[1m^[22m[2m[39m[0m[22m
|
|
171
|
+
[2m [0m [90m 1123 |[39m [90m// To remain atomic, attempt to reset everything to the way it was.[39m[0m[22m
|
|
172
|
+
[2m [0m [90m 1124 |[39m [36mthis[39m[33m.[39minputMaps[inputIndex][33m.[39m[36mdelete[39m(key)[33m;[39m[0m[22m
|
|
173
|
+
[2m [0m [90m 1125 |[39m [36mthis[39m[33m.[39m[33mPSBT_GLOBAL_TX_MODIFIABLE[39m [33m=[39m modBackup[33m;[39m[0m[22m
|
|
174
|
+
[2m[22m
|
|
175
|
+
[2m [2mat PsbtV2.addPartialSig ([22m[2msrc/psbtv2.ts[2m:1122:15)[22m[2m[22m
|
|
176
|
+
[2m [2mat Object.<anonymous> ([22m[2m[0m[36msrc/psbtv2.test.ts[39m[0m[2m:1049:10)[22m[2m[22m
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
[0m[7m[33m[1m RUNS [22m[39m[27m[0m [2msrc/[22m[1mpsbtv2.test.ts[22m
|
|
180
|
+
|
|
181
|
+
[1mTest Suites: [22m[1m[32m1 passed[39m[22m, 1 of 2 total
|
|
182
|
+
[1mTests: [22m[1m[32m156 passed[39m[22m, 156 total
|
|
183
|
+
[1mSnapshots: [22m0 total
|
|
184
|
+
[1mTime:[22m 3 s, estimated 5 s
|
|
185
|
+
[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m
|
|
186
|
+
|
|
187
|
+
[1mTest Suites: [22m[1m[32m2 passed[39m[22m, 2 total
|
|
188
|
+
[1mTests: [22m[1m[32m177 passed[39m[22m, 177 total
|
|
189
|
+
[1mSnapshots: [22m0 total
|
|
190
|
+
[1mTime:[22m 3 s, estimated 5 s
|
|
191
|
+
[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[32m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m[37m█[39m
|
|
192
|
+
[1mTest Suites: [22m[1m[32m2 passed[39m[22m, 2 total
|
|
193
|
+
[1mTests: [22m[1m[32m177 passed[39m[22m, 177 total
|
|
194
|
+
[1mSnapshots: [22m0 total
|
|
195
|
+
[1mTime:[22m 3.973 s, estimated 5 s
|
|
196
|
+
[2mRan all test suites[22m[2m matching [22m/src/i[2m.[22m
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# @caravan/psbt
|
|
2
|
+
|
|
3
|
+
## 0.0.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#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
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`a39dfde`](https://github.com/caravan-bitcoin/caravan/commit/a39dfde2aab9908370bc5eea032960b1939f1e14)]:
|
|
10
|
+
- @caravan/bitcoin@0.0.1
|
package/README.md
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# Caravan PSBT
|
|
2
|
+
|
|
3
|
+
A set of utilities for working with PSBTs.
|
|
4
|
+
|
|
5
|
+
## Table of contents
|
|
6
|
+
|
|
7
|
+
- [PSBTv0](#psbtv0)
|
|
8
|
+
- [Exports](#psbtv0-exports)
|
|
9
|
+
- [`const PSBT_MAGIC_HEX`](#const-psbt_magic_hex)
|
|
10
|
+
- [`const PSBT_MAGIC_B64`](#const-psbt_magic_b64)
|
|
11
|
+
- [`const PSBT_MAGIC_BYTES`](#const-psbt_magic_bytes)
|
|
12
|
+
- [`function autoLoadPSBT`](#function-autoloadpsbt)
|
|
13
|
+
- [`function psbtInputFormatter`](#function-psbtinputformatter)
|
|
14
|
+
- [`function psbtOutputFormatter`](#function-psbtoutputformatter)
|
|
15
|
+
- [`function translatePSBT`](#function-translatepsbt)
|
|
16
|
+
- [`function addSignaturesToPSBT`](#function-addsignaturestopsbt)
|
|
17
|
+
- [`function parseSignaturesFromPSBT`](#function-parsesignaturesfrompsbt)
|
|
18
|
+
- [`function parseSignatureArrayFromPSBT`](#function-parsesignaturearrayfrompsbt)
|
|
19
|
+
- [PSBTv2](#psbtv2)
|
|
20
|
+
- [Exports](#psbtv2-exports)
|
|
21
|
+
- [`class PsbtV2`](#class-psbtv2)
|
|
22
|
+
- [`get nLockTime`](#get-nlocktime)
|
|
23
|
+
- [`public dangerouslySetGlobalTxVersion1`](#public-dangerouslysetglobaltxversion1)
|
|
24
|
+
- [`public addGlobalXpub`](#public-addglobalxpub)
|
|
25
|
+
- [`public addInput`](#public-addinput)
|
|
26
|
+
- [`public addOutput`](#public-addoutput)
|
|
27
|
+
- [`public deleteInput`](#public-deleteinput)
|
|
28
|
+
- [`public deleteOutput`](#public-deleteoutput)
|
|
29
|
+
- [`public addPartialSig`](#public-addpartialsig)
|
|
30
|
+
- [`public removePartialSig`](#public-removepartialsig)
|
|
31
|
+
- [`static PsbtV2.FromV0`](#static-psbtv2fromv0)
|
|
32
|
+
- [`function getPsbtVersionNumber`](#function-getpsbtversionnumber)
|
|
33
|
+
- [`abstract class PsbtV2Maps`](#abstract-class-psbtv2maps)
|
|
34
|
+
- [`public copy`](#public-copy)
|
|
35
|
+
- [Concepts](#concepts)
|
|
36
|
+
- [The operator role saga](#the-operator-role-saga)
|
|
37
|
+
- [TODO](#todo)
|
|
38
|
+
|
|
39
|
+
## PSBTv0
|
|
40
|
+
|
|
41
|
+
[BIP 174](https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki)
|
|
42
|
+
|
|
43
|
+
### Exports
|
|
44
|
+
|
|
45
|
+
#### `const PSBT_MAGIC_HEX`
|
|
46
|
+
|
|
47
|
+
A utility constant for hex encoded psbt magic bytes equal to `"70736274ff"`.
|
|
48
|
+
|
|
49
|
+
#### `const PSBT_MAGIC_B64`
|
|
50
|
+
|
|
51
|
+
A utility constant for base64 encoded psbt magic bytes equal to `"cHNidP8"`.
|
|
52
|
+
|
|
53
|
+
#### `const PSBT_MAGIC_BYTES`
|
|
54
|
+
|
|
55
|
+
A utility constant for `Buffer` instance of psbt magic bytes.
|
|
56
|
+
|
|
57
|
+
#### `function autoLoadPSBT`
|
|
58
|
+
|
|
59
|
+
Given a string, try to create a Psbt object based on MAGIC (hex or Base64).
|
|
60
|
+
|
|
61
|
+
#### `function psbtInputFormatter`
|
|
62
|
+
|
|
63
|
+
Take a `MultisigTransactionInput` and turn it into a `MultisigTransactionPSBTInput`.
|
|
64
|
+
|
|
65
|
+
#### `function psbtOutputFormatter`
|
|
66
|
+
|
|
67
|
+
Take a `MultisigTransactionOutput` and turn it into a `MultisigTransactionPSBTOutput`.
|
|
68
|
+
|
|
69
|
+
#### `function translatePSBT`
|
|
70
|
+
|
|
71
|
+
Translates a PSBT into inputs/outputs consumable by supported non-PSBT devices in the `@caravan/wallets` library.
|
|
72
|
+
|
|
73
|
+
#### `function addSignaturesToPSBT`
|
|
74
|
+
|
|
75
|
+
Given an unsigned PSBT, an array of signing public key(s) (one per input), an array of signature(s) (one per input) in the same order as the pubkey(s), adds partial signature object(s) to each input and returns the PSBT with partial signature(s) included.
|
|
76
|
+
|
|
77
|
+
#### `function parseSignaturesFromPSBT`
|
|
78
|
+
|
|
79
|
+
Extracts the signature(s) from a PSBT.
|
|
80
|
+
|
|
81
|
+
NOTE: there should be one signature per input, per signer.
|
|
82
|
+
|
|
83
|
+
ADDITIONAL NOTE: because of the restrictions we place on braids to march their multisig addresses (slices) forward at the _same_ index across each chain of the braid, we do not run into a possible collision with this data structure. BUT - to have this method accommodate the _most_ general form of signature parsing, it would be wise to wrap this one level deeper like:
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
address: [pubkey : [signature(s)]]
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
that way if your braid only advanced one chain's (member's) index so that a pubkey could be used in more than one address, everything would still function properly.
|
|
90
|
+
|
|
91
|
+
#### `function parseSignatureArrayFromPSBT`
|
|
92
|
+
|
|
93
|
+
Extracts signatures in order of inputs and returns as array (or array of arrays if multiple signature sets).
|
|
94
|
+
|
|
95
|
+
## PSBTv2
|
|
96
|
+
|
|
97
|
+
The `psbtv2` module provides utilities for working with v2 PSBTs and transformations or conversions between v0 and v2.
|
|
98
|
+
|
|
99
|
+
### Exports
|
|
100
|
+
|
|
101
|
+
#### `class PsbtV2`
|
|
102
|
+
|
|
103
|
+
An object class representing a PSBTv2 and its current state. While not yet complete, this class aims to also provide sufficient checking to ensure only valid PSBTs are represented and that only valid actions may be taken per operator role.
|
|
104
|
+
|
|
105
|
+
Getters and setters are provided for the keytypes defined in [BIP 174](https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki) and [BIP 370](https://github.com/bitcoin/bips/blob/master/bip-0370.mediawiki). These getters/setters are named after the keytype in ALL_CAPS_SNAKE like `PsbtV2.PSBT_GLOBAL_VERSION`. Additional getters/setters may be listed in the following API documentation.
|
|
106
|
+
|
|
107
|
+
##### `get nLockTime`
|
|
108
|
+
|
|
109
|
+
Returns the `nLockTime` field for the psbt as if it were a bitcoin transaction.
|
|
110
|
+
|
|
111
|
+
From BIP 370:
|
|
112
|
+
|
|
113
|
+
> The nLockTime field of a transaction is determined by inspecting the `PSBT_GLOBAL_FALLBACK_LOCKTIME` and each input's `PSBT_IN_REQUIRED_TIME_LOCKTIME` and `PSBT_IN_REQUIRED_HEIGHT_LOCKTIME` fields. If none of the inputs have a `PSBT_IN_REQUIRED_TIME_LOCKTIME` and \*(or) `PSBT_IN_REQUIRED_HEIGHT_LOCKTIME`, then `PSBT_GLOBAL_FALLBACK_LOCKTIME` must be used. If `PSBT_GLOBAL_FALLBACK_LOCKTIME` is not provided, then it is assumed to be 0. If one or more inputs have a `PSBT_IN_REQUIRED_TIME_LOCKTIME` or `PSBT_IN_REQUIRED_HEIGHT_LOCKTIME`, then the field chosen is the one which is supported by all of the inputs. This can be determined by looking at all of the inputs which specify a locktime in either of those fields, and choosing the field which is present in all of those inputs. Inputs not specifying a lock time field can take both types of lock times, as can those that specify both. The lock time chosen is then the maximum value of the chosen type of lock time. If a PSBT has both types of locktimes possible because one or more inputs specify both `PSBT_IN_REQUIRED_TIME_LOCKTIME` and `PSBT_IN_REQUIRED_HEIGHT_LOCKTIME`, then locktime determined by looking at the `PSBT_IN_REQUIRED_HEIGHT_LOCKTIME` fields of the inputs must be chosen.
|
|
114
|
+
|
|
115
|
+
##### `public dangerouslySetGlobalTxVersion1`
|
|
116
|
+
|
|
117
|
+
A helper method for compatibility, but seems to no-longer be required.
|
|
118
|
+
|
|
119
|
+
##### `public addGlobalXpub`
|
|
120
|
+
|
|
121
|
+
Adds an entry to the `PSBT_GLOBAL_XPUB` keytype given xpub, fingerprint, and derivation path.
|
|
122
|
+
|
|
123
|
+
##### `public addInput`
|
|
124
|
+
|
|
125
|
+
Adds an input to the PSBT. This method validates inputs modifiable on `PSBT_GLOBAL_TX_MODIFIABLE`, but other validation is incomplete. Adds details to the input map keytypes if present and increments the global input count. These keytypes include:
|
|
126
|
+
|
|
127
|
+
- `PSBT_GLOBAL_INPUT_COUNT`
|
|
128
|
+
- `PSBT_IN_BIP32_DERIVATION`
|
|
129
|
+
- `PSBT_IN_NON_WITNESS_UTXO`
|
|
130
|
+
- `PSBT_IN_OUTPUT_INDEX`
|
|
131
|
+
- `PSBT_IN_PREVIOUS_TXID`
|
|
132
|
+
- `PSBT_IN_REDEEM_SCRIPT`
|
|
133
|
+
- `PSBT_IN_SEQUENCE`
|
|
134
|
+
- `PSBT_IN_WITNESS_SCRIPT`
|
|
135
|
+
- `PSBT_IN_WITNESS_UTXO`
|
|
136
|
+
|
|
137
|
+
##### `public addOutput`
|
|
138
|
+
|
|
139
|
+
Adds an output to the PSBT. This method validates outputs modifiable on `PSBT_GLOBAL_TX_MODIFIABLE`, but other validation is incomplete. Adds details to the output map keytypes if present and increments the global output count. These keytypes include:
|
|
140
|
+
|
|
141
|
+
- `PSBT_GLOBAL_OUTPUT_COUNT`
|
|
142
|
+
- `PSBT_OUT_AMOUNT`
|
|
143
|
+
- `PSBT_OUT_BIP32_DERIVATION`
|
|
144
|
+
- `PSBT_OUT_REDEEM_SCRIPT`
|
|
145
|
+
- `PSBT_OUT_SCRIPT`
|
|
146
|
+
- `PSBT_OUT_WITNESS_SCRIPT`
|
|
147
|
+
|
|
148
|
+
##### `public deleteInput`
|
|
149
|
+
|
|
150
|
+
Removes an input from the PSBT. This method validates inputs modifiable on `PSBT_GLOBAL_TX_MODIFIABLE`, but other validation is incomplete. All keytype references to the input index in the input map are removed. `PSBT_GLOBAL_INPUT_COUNT` is decremented.
|
|
151
|
+
|
|
152
|
+
##### `public deleteOutput`
|
|
153
|
+
|
|
154
|
+
Removes an output from the PSBT. This method validates outputs modifiable on `PSBT_GLOBAL_TX_MODIFIABLE`, but other validation is incomplete. All keytype references to the output index in the output map are removed. `PSBT_GLOBAL_OUTPUT_COUNT` is decremented.
|
|
155
|
+
|
|
156
|
+
##### `public addPartialSig`
|
|
157
|
+
|
|
158
|
+
Adds a signature for an input. Validates that the input is mapped and does not already have a signature for the pubkey. Also validates for sighash. Other validation is incomplete.
|
|
159
|
+
|
|
160
|
+
The Signer, when it creates a signature, must add the partial sig keypair to the psbt for the input which it is signing. In the case that a particular signer does not, this method can be used to add a signature to the psbt. This method assumes the Signer did the validation outlined in BIP0174 before creating a signature. See [BIP 174](https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#signer).
|
|
161
|
+
|
|
162
|
+
##### `public removePartialSig`
|
|
163
|
+
|
|
164
|
+
Removes all sigs for an input unless a pubkey is specified. Validates that the input exists. When providing a pubkey, this validates that a sig for the pubkey exists.
|
|
165
|
+
|
|
166
|
+
##### `static PsbtV2.FromV0`
|
|
167
|
+
|
|
168
|
+
Attempts to return a `PsbtV2` by converting from a PSBTv0 string or Buffer
|
|
169
|
+
|
|
170
|
+
#### `function getPsbtVersionNumber`
|
|
171
|
+
|
|
172
|
+
Attempts to extract the version number as uint32LE from raw psbt regardless of psbt validity.
|
|
173
|
+
|
|
174
|
+
#### `abstract class PsbtV2Maps`
|
|
175
|
+
|
|
176
|
+
This is provided for utility for compatibility and to allow for mapping, map copying, and serialization operations for psbts. This does almost no validation, so do not rely on it for ensuring a valid psbt.
|
|
177
|
+
|
|
178
|
+
##### `public copy`
|
|
179
|
+
|
|
180
|
+
Copies the maps in this PsbtV2 object to another PsbtV2 object.
|
|
181
|
+
|
|
182
|
+
NOTE: This copy method is made available to achieve parity with the PSBT api required by `ledger-bitcoin` for creating merklized PSBTs. HOWEVER, it is not recommended to use this when avoidable as copying maps bypasses the validation defined in the constructor, so it could create a psbtv2 in an invalid psbt state. PsbtV2.serialize is preferable whenever possible.
|
|
183
|
+
|
|
184
|
+
## Concepts
|
|
185
|
+
|
|
186
|
+
### The operator role saga
|
|
187
|
+
|
|
188
|
+
The PSBT is a resource which may be passed between several operators or services. It's best to look at the operator roles as stages of a saga. The next valid operator role(s) can be determined by the state of the PSBT. The actions allowed for a PSBT are determined by which operator role the PSBT can be now and which role it could be next. See the following blog article at Unchained for a more detailed illustration: [Operator roles: Life stages in the saga of a PSBT](https://unchained.com/blog/operator-roles-life-stages-in-the-saga-of-a-psbt/)
|
|
189
|
+
|
|
190
|
+
### TODO
|
|
191
|
+
|
|
192
|
+
Work remains on PSBTv2 for determining the next valid operator role(s) and restricting actions based on PSBT state. In other words, if the state of the PSBT suggests the PSBT might be in role A and is ready for role B, it should only allow actions within the context of role A or B.
|
|
193
|
+
|
|
194
|
+
The following list is a non-comprehensive list of validation checks which must be performed:
|
|
195
|
+
|
|
196
|
+
- Check ready for Updater role on `addInput`, `addOutput`, `deleteInput`, and `deleteOuput`.
|
|
197
|
+
- Check ready for Signer role on `addPartialSig`.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The PsbtV2 class is intended to represent an easily modifiable and
|
|
3
|
+
* serializable psbt of version 2 conforming to BIP0174. Getters exist for all
|
|
4
|
+
* BIP-defined keytypes. Very few setters and modifier methods exist. As they
|
|
5
|
+
* are added, they should enforce implied and documented rules and limitations.
|
|
6
|
+
*
|
|
7
|
+
* Defining BIPs:
|
|
8
|
+
* https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki
|
|
9
|
+
* https://github.com/bitcoin/bips/blob/master/bip-0370.mediawiki
|
|
10
|
+
*/
|
|
11
|
+
type Key = string;
|
|
12
|
+
type Value = Buffer;
|
|
13
|
+
type NonUniqueKeyTypeValue = {
|
|
14
|
+
key: string;
|
|
15
|
+
value: string | null;
|
|
16
|
+
};
|
|
17
|
+
declare enum PsbtGlobalTxModifiableBits {
|
|
18
|
+
INPUTS = "INPUTS",// 0b00000001
|
|
19
|
+
OUTPUTS = "OUTPUTS",// 0b00000010
|
|
20
|
+
SIGHASH_SINGLE = "SIGHASH_SINGLE"
|
|
21
|
+
}
|
|
22
|
+
declare abstract class PsbtV2Maps {
|
|
23
|
+
protected globalMap: Map<Key, Value>;
|
|
24
|
+
protected inputMaps: Map<Key, Value>[];
|
|
25
|
+
protected outputMaps: Map<Key, Value>[];
|
|
26
|
+
constructor(psbt?: Buffer | string);
|
|
27
|
+
serialize(format?: "base64" | "hex"): string;
|
|
28
|
+
copy(to: PsbtV2): void;
|
|
29
|
+
private copyMaps;
|
|
30
|
+
private copyMap;
|
|
31
|
+
}
|
|
32
|
+
declare class PsbtV2 extends PsbtV2Maps {
|
|
33
|
+
constructor(psbt?: Buffer | string);
|
|
34
|
+
/**
|
|
35
|
+
* Globals Getters/Setters
|
|
36
|
+
*/
|
|
37
|
+
get PSBT_GLOBAL_XPUB(): NonUniqueKeyTypeValue[] | NonUniqueKeyTypeValue[][];
|
|
38
|
+
get PSBT_GLOBAL_TX_VERSION(): number;
|
|
39
|
+
set PSBT_GLOBAL_TX_VERSION(version: number);
|
|
40
|
+
get PSBT_GLOBAL_FALLBACK_LOCKTIME(): number | null;
|
|
41
|
+
set PSBT_GLOBAL_FALLBACK_LOCKTIME(locktime: number | null);
|
|
42
|
+
get PSBT_GLOBAL_INPUT_COUNT(): number;
|
|
43
|
+
set PSBT_GLOBAL_INPUT_COUNT(count: number);
|
|
44
|
+
get PSBT_GLOBAL_OUTPUT_COUNT(): number;
|
|
45
|
+
set PSBT_GLOBAL_OUTPUT_COUNT(count: number);
|
|
46
|
+
get PSBT_GLOBAL_TX_MODIFIABLE(): PsbtGlobalTxModifiableBits[];
|
|
47
|
+
set PSBT_GLOBAL_TX_MODIFIABLE(modifiable: PsbtGlobalTxModifiableBits[]);
|
|
48
|
+
get PSBT_GLOBAL_VERSION(): number;
|
|
49
|
+
set PSBT_GLOBAL_VERSION(version: number);
|
|
50
|
+
get PSBT_GLOBAL_PROPRIETARY(): NonUniqueKeyTypeValue[] | NonUniqueKeyTypeValue[][];
|
|
51
|
+
/**
|
|
52
|
+
* Input Getters/Setters
|
|
53
|
+
*/
|
|
54
|
+
get PSBT_IN_NON_WITNESS_UTXO(): (string | null)[];
|
|
55
|
+
get PSBT_IN_WITNESS_UTXO(): (string | null)[];
|
|
56
|
+
get PSBT_IN_PARTIAL_SIG(): NonUniqueKeyTypeValue[][];
|
|
57
|
+
get PSBT_IN_SIGHASH_TYPE(): (number | null)[];
|
|
58
|
+
get PSBT_IN_REDEEM_SCRIPT(): (string | null)[];
|
|
59
|
+
get PSBT_IN_WITNESS_SCRIPT(): (string | null)[];
|
|
60
|
+
get PSBT_IN_BIP32_DERIVATION(): NonUniqueKeyTypeValue[] | NonUniqueKeyTypeValue[][];
|
|
61
|
+
get PSBT_IN_FINAL_SCRIPTSIG(): (string | null)[];
|
|
62
|
+
get PSBT_IN_FINAL_SCRIPTWITNESS(): (string | null)[];
|
|
63
|
+
get PSBT_IN_POR_COMMITMENT(): (string | null)[];
|
|
64
|
+
get PSBT_IN_RIPEMD160(): NonUniqueKeyTypeValue[] | NonUniqueKeyTypeValue[][];
|
|
65
|
+
get PSBT_IN_SHA256(): NonUniqueKeyTypeValue[] | NonUniqueKeyTypeValue[][];
|
|
66
|
+
get PSBT_IN_HASH160(): NonUniqueKeyTypeValue[] | NonUniqueKeyTypeValue[][];
|
|
67
|
+
get PSBT_IN_HASH256(): NonUniqueKeyTypeValue[] | NonUniqueKeyTypeValue[][];
|
|
68
|
+
get PSBT_IN_PREVIOUS_TXID(): string[];
|
|
69
|
+
get PSBT_IN_OUTPUT_INDEX(): number[];
|
|
70
|
+
get PSBT_IN_SEQUENCE(): (number | null)[];
|
|
71
|
+
get PSBT_IN_REQUIRED_TIME_LOCKTIME(): (number | null)[];
|
|
72
|
+
get PSBT_IN_REQUIRED_HEIGHT_LOCKTIME(): (number | null)[];
|
|
73
|
+
get PSBT_IN_TAP_KEY_SIG(): (string | null)[];
|
|
74
|
+
get PSBT_IN_TAP_SCRIPT_SIG(): NonUniqueKeyTypeValue[] | NonUniqueKeyTypeValue[][];
|
|
75
|
+
get PSBT_IN_TAP_LEAF_SCRIPT(): NonUniqueKeyTypeValue[] | NonUniqueKeyTypeValue[][];
|
|
76
|
+
get PSBT_IN_TAP_BIP32_DERIVATION(): NonUniqueKeyTypeValue[] | NonUniqueKeyTypeValue[][];
|
|
77
|
+
get PSBT_IN_TAP_INTERNAL_KEY(): (string | null)[];
|
|
78
|
+
get PSBT_IN_TAP_MERKLE_ROOT(): (string | null)[];
|
|
79
|
+
get PSBT_IN_PROPRIETARY(): NonUniqueKeyTypeValue[] | NonUniqueKeyTypeValue[][];
|
|
80
|
+
/**
|
|
81
|
+
* Output Getters/Setters
|
|
82
|
+
*/
|
|
83
|
+
get PSBT_OUT_REDEEM_SCRIPT(): (string | null)[];
|
|
84
|
+
get PSBT_OUT_WITNESS_SCRIPT(): (string | null)[];
|
|
85
|
+
get PSBT_OUT_BIP32_DERIVATION(): NonUniqueKeyTypeValue[] | NonUniqueKeyTypeValue[][];
|
|
86
|
+
get PSBT_OUT_AMOUNT(): bigint[];
|
|
87
|
+
get PSBT_OUT_SCRIPT(): string[];
|
|
88
|
+
get PSBT_OUT_TAP_INTERNAL_KEY(): (string | null)[];
|
|
89
|
+
get PSBT_OUT_TAP_TREE(): (string | null)[];
|
|
90
|
+
get PSBT_OUT_TAP_BIP32_DERIVATION(): NonUniqueKeyTypeValue[] | NonUniqueKeyTypeValue[][];
|
|
91
|
+
get PSBT_OUT_PROPRIETARY(): NonUniqueKeyTypeValue[] | NonUniqueKeyTypeValue[][];
|
|
92
|
+
/**
|
|
93
|
+
* Other Getters/Setters
|
|
94
|
+
*/
|
|
95
|
+
get nLockTime(): number | null;
|
|
96
|
+
/**
|
|
97
|
+
* Creator/Constructor Methods
|
|
98
|
+
*/
|
|
99
|
+
private create;
|
|
100
|
+
private validate;
|
|
101
|
+
dangerouslySetGlobalTxVersion1(): void;
|
|
102
|
+
addGlobalXpub(xpub: Buffer, fingerprint: Buffer, path: string): void;
|
|
103
|
+
addInput({ previousTxId, outputIndex, sequence, nonWitnessUtxo, witnessUtxo, redeemScript, witnessScript, bip32Derivation, }: {
|
|
104
|
+
previousTxId: Buffer | string;
|
|
105
|
+
outputIndex: number;
|
|
106
|
+
sequence?: number;
|
|
107
|
+
nonWitnessUtxo?: Buffer;
|
|
108
|
+
witnessUtxo?: {
|
|
109
|
+
amount: number;
|
|
110
|
+
script: Buffer;
|
|
111
|
+
};
|
|
112
|
+
redeemScript?: Buffer;
|
|
113
|
+
witnessScript?: Buffer;
|
|
114
|
+
bip32Derivation?: {
|
|
115
|
+
pubkey: Buffer;
|
|
116
|
+
masterFingerprint: Buffer;
|
|
117
|
+
path: string;
|
|
118
|
+
}[];
|
|
119
|
+
}): void;
|
|
120
|
+
addOutput({ amount, script, redeemScript, witnessScript, bip32Derivation, }: {
|
|
121
|
+
amount: number;
|
|
122
|
+
script: Buffer;
|
|
123
|
+
redeemScript?: Buffer;
|
|
124
|
+
witnessScript?: Buffer;
|
|
125
|
+
bip32Derivation?: {
|
|
126
|
+
pubkey: Buffer;
|
|
127
|
+
masterFingerprint: Buffer;
|
|
128
|
+
path: string;
|
|
129
|
+
}[];
|
|
130
|
+
}): void;
|
|
131
|
+
/**
|
|
132
|
+
* Updater/Signer Methods
|
|
133
|
+
*/
|
|
134
|
+
deleteInput(index: number): void;
|
|
135
|
+
deleteOutput(index: number): void;
|
|
136
|
+
private isModifiable;
|
|
137
|
+
addPartialSig(inputIndex: number, pubkey: Buffer, sig: Buffer): void;
|
|
138
|
+
removePartialSig(inputIndex: number, pubkey?: Buffer): void;
|
|
139
|
+
private handleSighashType;
|
|
140
|
+
static FromV0(psbt: string | Buffer, allowTxnVersion1?: boolean): PsbtV2;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Attempts to extract the version number as uint32LE from raw psbt regardless
|
|
144
|
+
* of psbt validity.
|
|
145
|
+
* @param {string | Buffer} psbt - hex, base64 or buffer of psbt
|
|
146
|
+
* @returns {number} version number
|
|
147
|
+
*/
|
|
148
|
+
declare function getPsbtVersionNumber(psbt: string | Buffer): number;
|
|
149
|
+
|
|
150
|
+
export { PsbtV2, getPsbtVersionNumber };
|