@caravan/psbt 1.0.1 → 1.1.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/.turbo/turbo-build.log +8 -8
- package/.turbo/turbo-lint.log +19 -14
- package/.turbo/turbo-test.log +44 -44
- package/CHANGELOG.md +6 -0
- package/README.md +71 -16
- package/dist/index.d.mts +67 -12
- package/dist/index.d.ts +67 -12
- package/dist/index.js +162 -13
- package/dist/index.mjs +162 -13
- package/package.json +1 -1
- package/src/psbtv2/psbtv2.test.ts +150 -1
- package/src/psbtv2/psbtv2.ts +268 -22
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @caravan/psbt@1.0
|
|
2
|
+
> @caravan/psbt@1.1.0 build
|
|
3
3
|
> tsup src/index.ts --format cjs,esm --dts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
[34mCLI[39m Target: esnext
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
11
|
[34mESM[39m Build start
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
12
|
+
[32mCJS[39m [1mdist/index.js [22m[32m36.78 KB[39m
|
|
13
|
+
[32mCJS[39m ⚡️ Build success in 59ms
|
|
14
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m35.12 KB[39m
|
|
15
|
+
[32mESM[39m ⚡️ Build success in 60ms
|
|
16
16
|
[34mDTS[39m Build start
|
|
17
|
-
[32mDTS[39m ⚡️ Build success in
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
19
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[
|
|
17
|
+
[32mDTS[39m ⚡️ Build success in 2379ms
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m11.83 KB[39m
|
|
19
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m11.83 KB[39m
|
package/.turbo/turbo-lint.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @caravan/psbt@1.0
|
|
2
|
+
> @caravan/psbt@1.1.0 lint
|
|
3
3
|
> eslint src
|
|
4
4
|
|
|
5
5
|
|
|
@@ -12,19 +12,24 @@
|
|
|
12
12
|
430:13 warning 'signature' is never reassigned. Use 'const' instead prefer-const
|
|
13
13
|
|
|
14
14
|
/home/runner/work/caravan/caravan/packages/caravan-psbt/src/psbtv2/psbtv2.test.ts
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
|
19
26
|
|
|
20
27
|
/home/runner/work/caravan/caravan/packages/caravan-psbt/src/psbtv2/psbtv2.ts
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
967:9 warning 'txOutputs' is never reassigned. Use 'const' instead prefer-const
|
|
27
|
-
967:20 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
28
|
+
132:9 warning 'modifiable' is never reassigned. Use 'const' instead prefer-const
|
|
29
|
+
676:9 warning 'heights' is never reassigned. Use 'const' instead prefer-const
|
|
30
|
+
677:9 warning 'times' is never reassigned. Use 'const' instead prefer-const
|
|
31
|
+
1189:21 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
32
|
+
1211:22 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
|
28
33
|
|
|
29
34
|
/home/runner/work/caravan/caravan/packages/caravan-psbt/src/psbtv2/types.ts
|
|
30
35
|
32:3 warning Duplicate enum member value 01 @typescript-eslint/no-duplicate-enum-values
|
|
@@ -44,6 +49,6 @@
|
|
|
44
49
|
65:3 warning Duplicate enum member value 07 @typescript-eslint/no-duplicate-enum-values
|
|
45
50
|
66:3 warning Duplicate enum member value fc @typescript-eslint/no-duplicate-enum-values
|
|
46
51
|
|
|
47
|
-
✖
|
|
48
|
-
0 errors and
|
|
52
|
+
✖ 38 problems (0 errors, 38 warnings)
|
|
53
|
+
0 errors and 7 warnings potentially fixable with the `--fix` option.
|
|
49
54
|
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @caravan/psbt@1.0
|
|
2
|
+
> @caravan/psbt@1.1.0 test
|
|
3
3
|
> jest src
|
|
4
4
|
|
|
5
5
|
PASS src/psbt.test.ts
|
|
@@ -9,62 +9,62 @@ PASS src/psbtv2/psbtv2.test.ts
|
|
|
9
9
|
console.warn
|
|
10
10
|
Dangerously setting PsbtV2.PSBT_GLOBAL_TX_VERSION to 1!
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
>
|
|
12
|
+
805 | );
|
|
13
|
+
806 | }
|
|
14
|
+
> 807 | console.warn("Dangerously setting PsbtV2.PSBT_GLOBAL_TX_VERSION to 1!");
|
|
15
15
|
| ^
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
808 | const bw = new BufferWriter();
|
|
17
|
+
809 | bw.writeI32(1);
|
|
18
|
+
810 | this.globalMap.set(KeyType.PSBT_GLOBAL_TX_VERSION, bw.render());
|
|
19
19
|
|
|
20
|
-
at PsbtV2.dangerouslySetGlobalTxVersion1 (src/psbtv2/psbtv2.ts:
|
|
21
|
-
at Function.FromV0 (src/psbtv2/psbtv2.ts:
|
|
22
|
-
at t (src/psbtv2/psbtv2.test.ts:
|
|
20
|
+
at PsbtV2.dangerouslySetGlobalTxVersion1 (src/psbtv2/psbtv2.ts:807:13)
|
|
21
|
+
at Function.FromV0 (src/psbtv2/psbtv2.ts:1173:14)
|
|
22
|
+
at t (src/psbtv2/psbtv2.test.ts:1091:34)
|
|
23
23
|
at Object.<anonymous> (../../node_modules/expect/build/toThrowMatchers.js:74:11)
|
|
24
24
|
at Object.throwingMatcher [as toThrow] (../../node_modules/expect/build/index.js:320:21)
|
|
25
|
-
at src/psbtv2/psbtv2.test.ts:
|
|
25
|
+
at src/psbtv2/psbtv2.test.ts:1092:25
|
|
26
26
|
|
|
27
27
|
console.warn
|
|
28
28
|
Dangerously setting PsbtV2.PSBT_GLOBAL_TX_VERSION to 1!
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
>
|
|
30
|
+
805 | );
|
|
31
|
+
806 | }
|
|
32
|
+
> 807 | console.warn("Dangerously setting PsbtV2.PSBT_GLOBAL_TX_VERSION to 1!");
|
|
33
33
|
| ^
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
808 | const bw = new BufferWriter();
|
|
35
|
+
809 | bw.writeI32(1);
|
|
36
|
+
810 | this.globalMap.set(KeyType.PSBT_GLOBAL_TX_VERSION, bw.render());
|
|
37
37
|
|
|
38
|
-
at PsbtV2.dangerouslySetGlobalTxVersion1 (src/psbtv2/psbtv2.ts:
|
|
39
|
-
at Function.FromV0 (src/psbtv2/psbtv2.ts:
|
|
40
|
-
at t (src/psbtv2/psbtv2.test.ts:
|
|
38
|
+
at PsbtV2.dangerouslySetGlobalTxVersion1 (src/psbtv2/psbtv2.ts:807:13)
|
|
39
|
+
at Function.FromV0 (src/psbtv2/psbtv2.ts:1173:14)
|
|
40
|
+
at t (src/psbtv2/psbtv2.test.ts:1091:34)
|
|
41
41
|
at Object.<anonymous> (../../node_modules/expect/build/toThrowMatchers.js:74:11)
|
|
42
42
|
at Object.throwingMatcher [as toThrow] (../../node_modules/expect/build/index.js:320:21)
|
|
43
|
-
at src/psbtv2/psbtv2.test.ts:
|
|
43
|
+
at src/psbtv2/psbtv2.test.ts:1092:25
|
|
44
44
|
|
|
45
45
|
console.warn
|
|
46
46
|
Dangerously setting PsbtV2.PSBT_GLOBAL_TX_VERSION to 1!
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
>
|
|
48
|
+
805 | );
|
|
49
|
+
806 | }
|
|
50
|
+
> 807 | console.warn("Dangerously setting PsbtV2.PSBT_GLOBAL_TX_VERSION to 1!");
|
|
51
51
|
| ^
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
808 | const bw = new BufferWriter();
|
|
53
|
+
809 | bw.writeI32(1);
|
|
54
|
+
810 | this.globalMap.set(KeyType.PSBT_GLOBAL_TX_VERSION, bw.render());
|
|
55
55
|
|
|
56
|
-
at PsbtV2.dangerouslySetGlobalTxVersion1 (src/psbtv2/psbtv2.ts:
|
|
57
|
-
at Function.FromV0 (src/psbtv2/psbtv2.ts:
|
|
58
|
-
at src/psbtv2/psbtv2.test.ts:
|
|
56
|
+
at PsbtV2.dangerouslySetGlobalTxVersion1 (src/psbtv2/psbtv2.ts:807:13)
|
|
57
|
+
at Function.FromV0 (src/psbtv2/psbtv2.ts:1173:14)
|
|
58
|
+
at src/psbtv2/psbtv2.test.ts:1103:25
|
|
59
59
|
|
|
60
60
|
console.error
|
|
61
61
|
Error:
|
|
62
|
-
at PsbtV2.<anonymous> (/home/runner/work/caravan/caravan/packages/caravan-psbt/src/psbtv2/psbtv2.test.ts:
|
|
62
|
+
at PsbtV2.<anonymous> (/home/runner/work/caravan/caravan/packages/caravan-psbt/src/psbtv2/psbtv2.test.ts:1193:13)
|
|
63
63
|
at /home/runner/work/caravan/caravan/node_modules/jest-mock/build/index.js:397:39
|
|
64
64
|
at PsbtV2.<anonymous> (/home/runner/work/caravan/caravan/node_modules/jest-mock/build/index.js:404:13)
|
|
65
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:
|
|
67
|
-
at Object.<anonymous> (/home/runner/work/caravan/caravan/packages/caravan-psbt/src/psbtv2/psbtv2.test.ts:
|
|
66
|
+
at PsbtV2.addPartialSig (/home/runner/work/caravan/caravan/packages/caravan-psbt/src/psbtv2/psbtv2.ts:1077:12)
|
|
67
|
+
at Object.<anonymous> (/home/runner/work/caravan/caravan/packages/caravan-psbt/src/psbtv2/psbtv2.test.ts:1198:10)
|
|
68
68
|
at Promise.then.completed (/home/runner/work/caravan/caravan/node_modules/jest-circus/build/utils.js:298:28)
|
|
69
69
|
at new Promise (<anonymous>)
|
|
70
70
|
at callAsyncCircusFn (/home/runner/work/caravan/caravan/node_modules/jest-circus/build/utils.js:231:10)
|
|
@@ -80,20 +80,20 @@ PASS src/psbtv2/psbtv2.test.ts
|
|
|
80
80
|
at runTest (/home/runner/work/caravan/caravan/node_modules/jest-runner/build/runTest.js:444:34)
|
|
81
81
|
at Object.worker (/home/runner/work/caravan/caravan/node_modules/jest-runner/build/testWorker.js:106:12)
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
>
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
83
|
+
1077 | this.handleSighashType(sig);
|
|
84
|
+
1078 | } catch (err) {
|
|
85
|
+
> 1079 | console.error(err);
|
|
86
|
+
| ^
|
|
87
|
+
1080 | // To remain atomic, attempt to reset everything to the way it was.
|
|
88
|
+
1081 | this.inputMaps[inputIndex].delete(key);
|
|
89
|
+
1082 | this.PSBT_GLOBAL_TX_MODIFIABLE = modBackup;
|
|
90
90
|
|
|
91
|
-
at PsbtV2.addPartialSig (src/psbtv2/psbtv2.ts:
|
|
92
|
-
at Object.<anonymous> (src/psbtv2/psbtv2.test.ts:
|
|
91
|
+
at PsbtV2.addPartialSig (src/psbtv2/psbtv2.ts:1079:15)
|
|
92
|
+
at Object.<anonymous> (src/psbtv2/psbtv2.test.ts:1198:10)
|
|
93
93
|
|
|
94
94
|
|
|
95
95
|
Test Suites: 2 passed, 2 total
|
|
96
|
-
Tests:
|
|
96
|
+
Tests: 192 passed, 192 total
|
|
97
97
|
Snapshots: 0 total
|
|
98
|
-
Time: 5.
|
|
98
|
+
Time: 5.211 s
|
|
99
99
|
Ran all test suites matching /src/i.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @caravan/psbt
|
|
2
2
|
|
|
3
|
+
## 1.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#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.
|
|
8
|
+
|
|
3
9
|
## 1.0.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -19,6 +19,12 @@ A set of utilities for working with PSBTs.
|
|
|
19
19
|
- [PSBTv2](#psbtv2)
|
|
20
20
|
- [Exports](#psbtv2-exports)
|
|
21
21
|
- [`class PsbtV2`](#class-psbtv2)
|
|
22
|
+
- [`get isReadyForConstructor`](#get-isreadyforconstructor)
|
|
23
|
+
- [`get isReadyForUpdater`](#get-isreadyforupdater)
|
|
24
|
+
- [`get isReadyForSigner`](#get-isreadyforsigner)
|
|
25
|
+
- [`get isReadyForCombiner`](#get-isreadyforcombiner)
|
|
26
|
+
- [`get isReadyForInputFinalizer`](#get-isreadyforinputfinalizer)
|
|
27
|
+
- [`get isReadyForTransactionExtractor`](#get-isreadyfortransactionextractor)
|
|
22
28
|
- [`get nLockTime`](#get-nlocktime)
|
|
23
29
|
- [`public dangerouslySetGlobalTxVersion1`](#public-dangerouslysetglobaltxversion1)
|
|
24
30
|
- [`public addGlobalXpub`](#public-addglobalxpub)
|
|
@@ -30,8 +36,6 @@ A set of utilities for working with PSBTs.
|
|
|
30
36
|
- [`public removePartialSig`](#public-removepartialsig)
|
|
31
37
|
- [`static PsbtV2.FromV0`](#static-psbtv2fromv0)
|
|
32
38
|
- [`function getPsbtVersionNumber`](#function-getpsbtversionnumber)
|
|
33
|
-
- [`abstract class PsbtV2Maps`](#abstract-class-psbtv2maps)
|
|
34
|
-
- [`public copy`](#public-copy)
|
|
35
39
|
- [Concepts](#concepts)
|
|
36
40
|
- [The operator role saga](#the-operator-role-saga)
|
|
37
41
|
- [TODO](#todo)
|
|
@@ -104,6 +108,56 @@ An object class representing a PSBTv2 and its current state. While not yet compl
|
|
|
104
108
|
|
|
105
109
|
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
110
|
|
|
111
|
+
##### `get isReadyForConstructor`
|
|
112
|
+
|
|
113
|
+
A getter to check readiness for an operator role. Operator roles are defined in [BIP 174](https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#user-content-Roles) and [BIP 370](https://github.com/bitcoin/bips/blob/master/bip-0370.mediawiki#user-content-Roles).
|
|
114
|
+
|
|
115
|
+
Returns `true` if the PsbtV2 is ready for an operator taking the Constructor role.
|
|
116
|
+
|
|
117
|
+
This check assumes that the Creator used this class's constructor method to initialize the PsbtV2 without passing a psbt (constructor defaults were set).
|
|
118
|
+
|
|
119
|
+
##### `get isReadyForUpdater`
|
|
120
|
+
|
|
121
|
+
A getter to check readiness for an operator role. Operator roles are defined in [BIP 174](https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#user-content-Roles) and [BIP 370](https://github.com/bitcoin/bips/blob/master/bip-0370.mediawiki#user-content-Roles).
|
|
122
|
+
|
|
123
|
+
Returns `true` if the PsbtV2 is ready for an operator taking the Updater role.
|
|
124
|
+
|
|
125
|
+
Before signatures are added, but after an input is added, a PsbtV2 is likely to be ready for Constructor, ready for Updater, and ready for Signer simultaneously.
|
|
126
|
+
|
|
127
|
+
According to BIP370, the Updater can modify the sequence number, but it is unclear if the Updater retains permissions provided in psbtv0 (BIP174). It is likely not the case that the Updater has the same permissions as previously because it seems to now be the realm of the Constructor to add inputs and outputs.
|
|
128
|
+
|
|
129
|
+
##### `get isReadyForSigner`
|
|
130
|
+
|
|
131
|
+
A getter to check readiness for an operator role. Operator roles are defined in [BIP 174](https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#user-content-Roles) and [BIP 370](https://github.com/bitcoin/bips/blob/master/bip-0370.mediawiki#user-content-Roles).
|
|
132
|
+
|
|
133
|
+
Returns `true` if the PsbtV2 is ready for an operator taking the Signer role.
|
|
134
|
+
|
|
135
|
+
Right now, this method only checks for two things: There is an input for signing and `this.isReadyForTransactionExtractor === false`. The point of the latter is to check that the PsbtV2 has not been finalized.
|
|
136
|
+
|
|
137
|
+
A future improvement to this method might be to more thoroughly check inputs to determine if the PsbtV2 does or does not need to collect more signatures.
|
|
138
|
+
|
|
139
|
+
##### `get isReadyForCombiner`
|
|
140
|
+
|
|
141
|
+
A getter to check readiness for an operator role. Operator roles are defined in [BIP 174](https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#user-content-Roles) and [BIP 370](https://github.com/bitcoin/bips/blob/master/bip-0370.mediawiki#user-content-Roles).
|
|
142
|
+
|
|
143
|
+
Returns `true` if the PsbtV2 is ready for an operator taking the Combiner role.
|
|
144
|
+
|
|
145
|
+
Since a Combiner can potentially provide everything needed to a mostly blank PsbtV2, instances of a PsbtV2 are likely to return true as long as inputs have not been finalized.
|
|
146
|
+
|
|
147
|
+
##### `get isReadyForInputFinalizer`
|
|
148
|
+
|
|
149
|
+
A getter to check readiness for an operator role. Operator roles are defined in [BIP 174](https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#user-content-Roles) and [BIP 370](https://github.com/bitcoin/bips/blob/master/bip-0370.mediawiki#user-content-Roles).
|
|
150
|
+
|
|
151
|
+
Callable, but unimplemented. Returns `undefined`.
|
|
152
|
+
|
|
153
|
+
##### `get isReadyForTransactionExtractor`
|
|
154
|
+
|
|
155
|
+
A getter to check readiness for an operator role. Operator roles are defined in [BIP 174](https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#user-content-Roles) and [BIP 370](https://github.com/bitcoin/bips/blob/master/bip-0370.mediawiki#user-content-Roles).
|
|
156
|
+
|
|
157
|
+
Returns `true` if the PsbtV2 is ready for an operator taking the Transaction Extractor role.
|
|
158
|
+
|
|
159
|
+
If all the inputs have been finalized, then the psbt is ready for the Transaction Extractor. According to BIP 174, it's the responsibility of the Input Finalizer to add scriptSigs or scriptWitnesses and then remove other details besides the UTXO. This getter checks that the Input Finalizer has finished its job.
|
|
160
|
+
|
|
107
161
|
##### `get nLockTime`
|
|
108
162
|
|
|
109
163
|
Returns the `nLockTime` field for the psbt as if it were a bitcoin transaction.
|
|
@@ -114,7 +168,7 @@ From BIP 370:
|
|
|
114
168
|
|
|
115
169
|
##### `public dangerouslySetGlobalTxVersion1`
|
|
116
170
|
|
|
117
|
-
A helper method for compatibility
|
|
171
|
+
A helper method for compatibility. Some devices require a psbtV2 configured with a transaction version of 1. BIP370 leaves room for this if the Creator is also the Constructor.
|
|
118
172
|
|
|
119
173
|
##### `public addGlobalXpub`
|
|
120
174
|
|
|
@@ -171,27 +225,28 @@ Attempts to return a `PsbtV2` by converting from a PSBTv0 string or Buffer
|
|
|
171
225
|
|
|
172
226
|
Attempts to extract the version number as uint32LE from raw psbt regardless of psbt validity.
|
|
173
227
|
|
|
174
|
-
|
|
228
|
+
## Concepts
|
|
175
229
|
|
|
176
|
-
|
|
230
|
+
### The operator role saga
|
|
177
231
|
|
|
178
|
-
|
|
232
|
+
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/)
|
|
179
233
|
|
|
180
|
-
|
|
234
|
+
### TODO
|
|
181
235
|
|
|
182
|
-
|
|
236
|
+
#### PsbtV2
|
|
183
237
|
|
|
184
|
-
|
|
238
|
+
##### Operator role validation
|
|
185
239
|
|
|
186
|
-
|
|
240
|
+
Work remains for determining readiness for operator roles Input Finalizer and Transaction Extractor. The getters responsible for these checks are `isReadyForInputFinalizer` and `isReadyForTransactionExtractor`. Work also remains to expand the PsbtV2 method functionality beyond the Signer role. A huge benefit might be gained from building methods aimed at the Combiner role.
|
|
187
241
|
|
|
188
|
-
|
|
242
|
+
##### Class constructor
|
|
189
243
|
|
|
190
|
-
|
|
244
|
+
The constructor must be able to handle values which the Creator role is responsible for. Currently, the constructor can only accept an optional psbt which it parses to configure itself. It would be ideal if a fresh PsbtV2 instance could be initialized with minimal arguments for which the Creator role is responsible. See `private create()`.
|
|
245
|
+
|
|
246
|
+
##### Add input timelocks
|
|
191
247
|
|
|
192
|
-
|
|
248
|
+
The `public addInput` must be able to properly handle input locktimes which interact with the global value.
|
|
193
249
|
|
|
194
|
-
|
|
250
|
+
##### Add input sighash_single
|
|
195
251
|
|
|
196
|
-
|
|
197
|
-
- Check ready for Signer role on `addPartialSig`.
|
|
252
|
+
The `public addInput` must be able to properly handle new inputs when the psbt has a `SIGHASH_SINGLE` flag on `PSBT_GLOBAL_TX_MODIFIABLE`.
|
package/dist/index.d.mts
CHANGED
|
@@ -74,7 +74,7 @@ declare class PsbtV2 extends PsbtV2Maps {
|
|
|
74
74
|
/**
|
|
75
75
|
* Globals Getters/Setters
|
|
76
76
|
*/
|
|
77
|
-
get PSBT_GLOBAL_XPUB(): NonUniqueKeyTypeValue[]
|
|
77
|
+
get PSBT_GLOBAL_XPUB(): NonUniqueKeyTypeValue[];
|
|
78
78
|
get PSBT_GLOBAL_TX_VERSION(): number;
|
|
79
79
|
set PSBT_GLOBAL_TX_VERSION(version: number);
|
|
80
80
|
get PSBT_GLOBAL_FALLBACK_LOCKTIME(): number | null;
|
|
@@ -87,7 +87,7 @@ declare class PsbtV2 extends PsbtV2Maps {
|
|
|
87
87
|
set PSBT_GLOBAL_TX_MODIFIABLE(modifiable: PsbtGlobalTxModifiableBits[]);
|
|
88
88
|
get PSBT_GLOBAL_VERSION(): number;
|
|
89
89
|
set PSBT_GLOBAL_VERSION(version: number);
|
|
90
|
-
get PSBT_GLOBAL_PROPRIETARY(): NonUniqueKeyTypeValue[]
|
|
90
|
+
get PSBT_GLOBAL_PROPRIETARY(): NonUniqueKeyTypeValue[];
|
|
91
91
|
/**
|
|
92
92
|
* Input Getters/Setters
|
|
93
93
|
*/
|
|
@@ -97,23 +97,23 @@ declare class PsbtV2 extends PsbtV2Maps {
|
|
|
97
97
|
get PSBT_IN_SIGHASH_TYPE(): (number | null)[];
|
|
98
98
|
get PSBT_IN_REDEEM_SCRIPT(): (string | null)[];
|
|
99
99
|
get PSBT_IN_WITNESS_SCRIPT(): (string | null)[];
|
|
100
|
-
get PSBT_IN_BIP32_DERIVATION(): NonUniqueKeyTypeValue[]
|
|
100
|
+
get PSBT_IN_BIP32_DERIVATION(): NonUniqueKeyTypeValue[][];
|
|
101
101
|
get PSBT_IN_FINAL_SCRIPTSIG(): (string | null)[];
|
|
102
102
|
get PSBT_IN_FINAL_SCRIPTWITNESS(): (string | null)[];
|
|
103
103
|
get PSBT_IN_POR_COMMITMENT(): (string | null)[];
|
|
104
|
-
get PSBT_IN_RIPEMD160(): NonUniqueKeyTypeValue[]
|
|
105
|
-
get PSBT_IN_SHA256(): NonUniqueKeyTypeValue[]
|
|
106
|
-
get PSBT_IN_HASH160(): NonUniqueKeyTypeValue[]
|
|
107
|
-
get PSBT_IN_HASH256(): NonUniqueKeyTypeValue[]
|
|
104
|
+
get PSBT_IN_RIPEMD160(): NonUniqueKeyTypeValue[][];
|
|
105
|
+
get PSBT_IN_SHA256(): NonUniqueKeyTypeValue[][];
|
|
106
|
+
get PSBT_IN_HASH160(): NonUniqueKeyTypeValue[][];
|
|
107
|
+
get PSBT_IN_HASH256(): NonUniqueKeyTypeValue[][];
|
|
108
108
|
get PSBT_IN_PREVIOUS_TXID(): string[];
|
|
109
109
|
get PSBT_IN_OUTPUT_INDEX(): number[];
|
|
110
110
|
get PSBT_IN_SEQUENCE(): (number | null)[];
|
|
111
111
|
get PSBT_IN_REQUIRED_TIME_LOCKTIME(): (number | null)[];
|
|
112
112
|
get PSBT_IN_REQUIRED_HEIGHT_LOCKTIME(): (number | null)[];
|
|
113
113
|
get PSBT_IN_TAP_KEY_SIG(): (string | null)[];
|
|
114
|
-
get PSBT_IN_TAP_SCRIPT_SIG(): NonUniqueKeyTypeValue[]
|
|
115
|
-
get PSBT_IN_TAP_LEAF_SCRIPT(): NonUniqueKeyTypeValue[]
|
|
116
|
-
get PSBT_IN_TAP_BIP32_DERIVATION(): NonUniqueKeyTypeValue[]
|
|
114
|
+
get PSBT_IN_TAP_SCRIPT_SIG(): NonUniqueKeyTypeValue[][];
|
|
115
|
+
get PSBT_IN_TAP_LEAF_SCRIPT(): NonUniqueKeyTypeValue[][];
|
|
116
|
+
get PSBT_IN_TAP_BIP32_DERIVATION(): NonUniqueKeyTypeValue[][];
|
|
117
117
|
get PSBT_IN_TAP_INTERNAL_KEY(): (string | null)[];
|
|
118
118
|
get PSBT_IN_TAP_MERKLE_ROOT(): (string | null)[];
|
|
119
119
|
get PSBT_IN_PROPRIETARY(): NonUniqueKeyTypeValue[] | NonUniqueKeyTypeValue[][];
|
|
@@ -129,6 +129,57 @@ declare class PsbtV2 extends PsbtV2Maps {
|
|
|
129
129
|
get PSBT_OUT_TAP_TREE(): (string | null)[];
|
|
130
130
|
get PSBT_OUT_TAP_BIP32_DERIVATION(): NonUniqueKeyTypeValue[] | NonUniqueKeyTypeValue[][];
|
|
131
131
|
get PSBT_OUT_PROPRIETARY(): NonUniqueKeyTypeValue[] | NonUniqueKeyTypeValue[][];
|
|
132
|
+
/**
|
|
133
|
+
* Operator Role Validation Getters
|
|
134
|
+
*/
|
|
135
|
+
/**
|
|
136
|
+
* Returns true if the PsbtV2 is ready for an operator taking the Constructor
|
|
137
|
+
* role.
|
|
138
|
+
*
|
|
139
|
+
* This check assumes that the Creator used this class's constructor method to
|
|
140
|
+
* initialize the PsbtV2 without passing a psbt (constructor defaults were
|
|
141
|
+
* set).
|
|
142
|
+
*/
|
|
143
|
+
get isReadyForConstructor(): boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Returns true if the PsbtV2 is ready for an operator taking the Updater
|
|
146
|
+
* role.
|
|
147
|
+
*
|
|
148
|
+
* Before signatures are added, but after an input is added, a PsbtV2 is
|
|
149
|
+
* likely to be ready for Constructor, ready for Updater, and ready for Signer
|
|
150
|
+
* simultaneously.
|
|
151
|
+
*
|
|
152
|
+
* According to BIP370, the Updater can modify the sequence number, but it is
|
|
153
|
+
* unclear if the Updater retains permissions provided in psbtv0 (BIP174). It
|
|
154
|
+
* is likely not the case that the Updater has the same permissions as
|
|
155
|
+
* previously because it seems to now be the realm of the Constructor to add
|
|
156
|
+
* inputs and outputs.
|
|
157
|
+
*/
|
|
158
|
+
get isReadyForUpdater(): boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Returns true if the PsbtV2 is ready for an operator taking the Signer role.
|
|
161
|
+
*/
|
|
162
|
+
get isReadyForSigner(): boolean;
|
|
163
|
+
/**
|
|
164
|
+
* Returns true if the PsbtV2 is ready for an operator taking the Combiner
|
|
165
|
+
* role.
|
|
166
|
+
*/
|
|
167
|
+
get isReadyForCombiner(): boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Unimplemented. Returns false.
|
|
170
|
+
*/
|
|
171
|
+
get isReadyForInputFinalizer(): boolean;
|
|
172
|
+
/**
|
|
173
|
+
* Returns true if the PsbtV2 is ready for an operator taking the Transaction
|
|
174
|
+
* Extractor role.
|
|
175
|
+
*
|
|
176
|
+
* If all the inputs have been finalized, then the psbt is ready for the
|
|
177
|
+
* Transaction Extractor. According to BIP 174, it's the responsibility of the
|
|
178
|
+
* Input Finalizer to add scriptSigs or scriptWitnesses and then remove other
|
|
179
|
+
* details besides the UTXO. This getter checks that the Input Finalizer has
|
|
180
|
+
* finished its job.
|
|
181
|
+
*/
|
|
182
|
+
get isReadyForTransactionExtractor(): boolean;
|
|
132
183
|
/**
|
|
133
184
|
* Other Getters/Setters
|
|
134
185
|
*/
|
|
@@ -205,7 +256,7 @@ declare class PsbtV2 extends PsbtV2Maps {
|
|
|
205
256
|
*/
|
|
206
257
|
deleteOutput(index: number): void;
|
|
207
258
|
/**
|
|
208
|
-
* Checks that provided flags are present in PSBT_GLOBAL_TX_MODIFIABLE.
|
|
259
|
+
* Checks that all provided flags are present in PSBT_GLOBAL_TX_MODIFIABLE.
|
|
209
260
|
*/
|
|
210
261
|
private isModifiable;
|
|
211
262
|
/**
|
|
@@ -234,7 +285,11 @@ declare class PsbtV2 extends PsbtV2Maps {
|
|
|
234
285
|
*/
|
|
235
286
|
private handleSighashType;
|
|
236
287
|
/**
|
|
237
|
-
* Attempts to return a PsbtV2 by converting from a PsbtV0 string or Buffer
|
|
288
|
+
* Attempts to return a PsbtV2 by converting from a PsbtV0 string or Buffer.
|
|
289
|
+
*
|
|
290
|
+
* This method first starts with a fresh PsbtV2 having just been created. It
|
|
291
|
+
* then takes the PsbtV2 through its operator saga through the Signer role. In
|
|
292
|
+
* this sense validation for each operator role will be performed.
|
|
238
293
|
*/
|
|
239
294
|
static FromV0(psbt: string | Buffer, allowTxnVersion1?: boolean): PsbtV2;
|
|
240
295
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -74,7 +74,7 @@ declare class PsbtV2 extends PsbtV2Maps {
|
|
|
74
74
|
/**
|
|
75
75
|
* Globals Getters/Setters
|
|
76
76
|
*/
|
|
77
|
-
get PSBT_GLOBAL_XPUB(): NonUniqueKeyTypeValue[]
|
|
77
|
+
get PSBT_GLOBAL_XPUB(): NonUniqueKeyTypeValue[];
|
|
78
78
|
get PSBT_GLOBAL_TX_VERSION(): number;
|
|
79
79
|
set PSBT_GLOBAL_TX_VERSION(version: number);
|
|
80
80
|
get PSBT_GLOBAL_FALLBACK_LOCKTIME(): number | null;
|
|
@@ -87,7 +87,7 @@ declare class PsbtV2 extends PsbtV2Maps {
|
|
|
87
87
|
set PSBT_GLOBAL_TX_MODIFIABLE(modifiable: PsbtGlobalTxModifiableBits[]);
|
|
88
88
|
get PSBT_GLOBAL_VERSION(): number;
|
|
89
89
|
set PSBT_GLOBAL_VERSION(version: number);
|
|
90
|
-
get PSBT_GLOBAL_PROPRIETARY(): NonUniqueKeyTypeValue[]
|
|
90
|
+
get PSBT_GLOBAL_PROPRIETARY(): NonUniqueKeyTypeValue[];
|
|
91
91
|
/**
|
|
92
92
|
* Input Getters/Setters
|
|
93
93
|
*/
|
|
@@ -97,23 +97,23 @@ declare class PsbtV2 extends PsbtV2Maps {
|
|
|
97
97
|
get PSBT_IN_SIGHASH_TYPE(): (number | null)[];
|
|
98
98
|
get PSBT_IN_REDEEM_SCRIPT(): (string | null)[];
|
|
99
99
|
get PSBT_IN_WITNESS_SCRIPT(): (string | null)[];
|
|
100
|
-
get PSBT_IN_BIP32_DERIVATION(): NonUniqueKeyTypeValue[]
|
|
100
|
+
get PSBT_IN_BIP32_DERIVATION(): NonUniqueKeyTypeValue[][];
|
|
101
101
|
get PSBT_IN_FINAL_SCRIPTSIG(): (string | null)[];
|
|
102
102
|
get PSBT_IN_FINAL_SCRIPTWITNESS(): (string | null)[];
|
|
103
103
|
get PSBT_IN_POR_COMMITMENT(): (string | null)[];
|
|
104
|
-
get PSBT_IN_RIPEMD160(): NonUniqueKeyTypeValue[]
|
|
105
|
-
get PSBT_IN_SHA256(): NonUniqueKeyTypeValue[]
|
|
106
|
-
get PSBT_IN_HASH160(): NonUniqueKeyTypeValue[]
|
|
107
|
-
get PSBT_IN_HASH256(): NonUniqueKeyTypeValue[]
|
|
104
|
+
get PSBT_IN_RIPEMD160(): NonUniqueKeyTypeValue[][];
|
|
105
|
+
get PSBT_IN_SHA256(): NonUniqueKeyTypeValue[][];
|
|
106
|
+
get PSBT_IN_HASH160(): NonUniqueKeyTypeValue[][];
|
|
107
|
+
get PSBT_IN_HASH256(): NonUniqueKeyTypeValue[][];
|
|
108
108
|
get PSBT_IN_PREVIOUS_TXID(): string[];
|
|
109
109
|
get PSBT_IN_OUTPUT_INDEX(): number[];
|
|
110
110
|
get PSBT_IN_SEQUENCE(): (number | null)[];
|
|
111
111
|
get PSBT_IN_REQUIRED_TIME_LOCKTIME(): (number | null)[];
|
|
112
112
|
get PSBT_IN_REQUIRED_HEIGHT_LOCKTIME(): (number | null)[];
|
|
113
113
|
get PSBT_IN_TAP_KEY_SIG(): (string | null)[];
|
|
114
|
-
get PSBT_IN_TAP_SCRIPT_SIG(): NonUniqueKeyTypeValue[]
|
|
115
|
-
get PSBT_IN_TAP_LEAF_SCRIPT(): NonUniqueKeyTypeValue[]
|
|
116
|
-
get PSBT_IN_TAP_BIP32_DERIVATION(): NonUniqueKeyTypeValue[]
|
|
114
|
+
get PSBT_IN_TAP_SCRIPT_SIG(): NonUniqueKeyTypeValue[][];
|
|
115
|
+
get PSBT_IN_TAP_LEAF_SCRIPT(): NonUniqueKeyTypeValue[][];
|
|
116
|
+
get PSBT_IN_TAP_BIP32_DERIVATION(): NonUniqueKeyTypeValue[][];
|
|
117
117
|
get PSBT_IN_TAP_INTERNAL_KEY(): (string | null)[];
|
|
118
118
|
get PSBT_IN_TAP_MERKLE_ROOT(): (string | null)[];
|
|
119
119
|
get PSBT_IN_PROPRIETARY(): NonUniqueKeyTypeValue[] | NonUniqueKeyTypeValue[][];
|
|
@@ -129,6 +129,57 @@ declare class PsbtV2 extends PsbtV2Maps {
|
|
|
129
129
|
get PSBT_OUT_TAP_TREE(): (string | null)[];
|
|
130
130
|
get PSBT_OUT_TAP_BIP32_DERIVATION(): NonUniqueKeyTypeValue[] | NonUniqueKeyTypeValue[][];
|
|
131
131
|
get PSBT_OUT_PROPRIETARY(): NonUniqueKeyTypeValue[] | NonUniqueKeyTypeValue[][];
|
|
132
|
+
/**
|
|
133
|
+
* Operator Role Validation Getters
|
|
134
|
+
*/
|
|
135
|
+
/**
|
|
136
|
+
* Returns true if the PsbtV2 is ready for an operator taking the Constructor
|
|
137
|
+
* role.
|
|
138
|
+
*
|
|
139
|
+
* This check assumes that the Creator used this class's constructor method to
|
|
140
|
+
* initialize the PsbtV2 without passing a psbt (constructor defaults were
|
|
141
|
+
* set).
|
|
142
|
+
*/
|
|
143
|
+
get isReadyForConstructor(): boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Returns true if the PsbtV2 is ready for an operator taking the Updater
|
|
146
|
+
* role.
|
|
147
|
+
*
|
|
148
|
+
* Before signatures are added, but after an input is added, a PsbtV2 is
|
|
149
|
+
* likely to be ready for Constructor, ready for Updater, and ready for Signer
|
|
150
|
+
* simultaneously.
|
|
151
|
+
*
|
|
152
|
+
* According to BIP370, the Updater can modify the sequence number, but it is
|
|
153
|
+
* unclear if the Updater retains permissions provided in psbtv0 (BIP174). It
|
|
154
|
+
* is likely not the case that the Updater has the same permissions as
|
|
155
|
+
* previously because it seems to now be the realm of the Constructor to add
|
|
156
|
+
* inputs and outputs.
|
|
157
|
+
*/
|
|
158
|
+
get isReadyForUpdater(): boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Returns true if the PsbtV2 is ready for an operator taking the Signer role.
|
|
161
|
+
*/
|
|
162
|
+
get isReadyForSigner(): boolean;
|
|
163
|
+
/**
|
|
164
|
+
* Returns true if the PsbtV2 is ready for an operator taking the Combiner
|
|
165
|
+
* role.
|
|
166
|
+
*/
|
|
167
|
+
get isReadyForCombiner(): boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Unimplemented. Returns false.
|
|
170
|
+
*/
|
|
171
|
+
get isReadyForInputFinalizer(): boolean;
|
|
172
|
+
/**
|
|
173
|
+
* Returns true if the PsbtV2 is ready for an operator taking the Transaction
|
|
174
|
+
* Extractor role.
|
|
175
|
+
*
|
|
176
|
+
* If all the inputs have been finalized, then the psbt is ready for the
|
|
177
|
+
* Transaction Extractor. According to BIP 174, it's the responsibility of the
|
|
178
|
+
* Input Finalizer to add scriptSigs or scriptWitnesses and then remove other
|
|
179
|
+
* details besides the UTXO. This getter checks that the Input Finalizer has
|
|
180
|
+
* finished its job.
|
|
181
|
+
*/
|
|
182
|
+
get isReadyForTransactionExtractor(): boolean;
|
|
132
183
|
/**
|
|
133
184
|
* Other Getters/Setters
|
|
134
185
|
*/
|
|
@@ -205,7 +256,7 @@ declare class PsbtV2 extends PsbtV2Maps {
|
|
|
205
256
|
*/
|
|
206
257
|
deleteOutput(index: number): void;
|
|
207
258
|
/**
|
|
208
|
-
* Checks that provided flags are present in PSBT_GLOBAL_TX_MODIFIABLE.
|
|
259
|
+
* Checks that all provided flags are present in PSBT_GLOBAL_TX_MODIFIABLE.
|
|
209
260
|
*/
|
|
210
261
|
private isModifiable;
|
|
211
262
|
/**
|
|
@@ -234,7 +285,11 @@ declare class PsbtV2 extends PsbtV2Maps {
|
|
|
234
285
|
*/
|
|
235
286
|
private handleSighashType;
|
|
236
287
|
/**
|
|
237
|
-
* Attempts to return a PsbtV2 by converting from a PsbtV0 string or Buffer
|
|
288
|
+
* Attempts to return a PsbtV2 by converting from a PsbtV0 string or Buffer.
|
|
289
|
+
*
|
|
290
|
+
* This method first starts with a fresh PsbtV2 having just been created. It
|
|
291
|
+
* then takes the PsbtV2 through its operator saga through the Signer role. In
|
|
292
|
+
* this sense validation for each operator role will be performed.
|
|
238
293
|
*/
|
|
239
294
|
static FromV0(psbt: string | Buffer, allowTxnVersion1?: boolean): PsbtV2;
|
|
240
295
|
}
|