@caravan/psbt 1.0.1 → 1.2.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 +26 -14
- package/.turbo/turbo-test.log +44 -44
- package/CHANGELOG.md +12 -0
- package/README.md +86 -16
- package/dist/index.d.mts +94 -12
- package/dist/index.d.ts +94 -12
- package/dist/index.js +214 -13
- package/dist/index.mjs +214 -13
- package/package.json +1 -1
- package/src/psbtv2/psbtv2.test.ts +347 -1
- package/src/psbtv2/psbtv2.ts +335 -22
- package/src/psbtv2/types.ts +6 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @caravan/psbt@1.0
|
|
2
|
+
> @caravan/psbt@1.2.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
|
-
[32mESM[39m [1mdist/index.mjs [22m[
|
|
13
|
-
[32mESM[39m ⚡️ Build success in
|
|
14
|
-
[32mCJS[39m [1mdist/index.js [22m[
|
|
15
|
-
[32mCJS[39m ⚡️ Build success in
|
|
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
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 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
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @caravan/psbt@1.0
|
|
2
|
+
> @caravan/psbt@1.2.0 lint
|
|
3
3
|
> eslint src
|
|
4
4
|
|
|
5
5
|
|
|
@@ -12,19 +12,31 @@
|
|
|
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
|
|
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
|
|
19
33
|
|
|
20
34
|
/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
|
|
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
|
|
28
40
|
|
|
29
41
|
/home/runner/work/caravan/caravan/packages/caravan-psbt/src/psbtv2/types.ts
|
|
30
42
|
32:3 warning Duplicate enum member value 01 @typescript-eslint/no-duplicate-enum-values
|
|
@@ -44,6 +56,6 @@
|
|
|
44
56
|
65:3 warning Duplicate enum member value 07 @typescript-eslint/no-duplicate-enum-values
|
|
45
57
|
66:3 warning Duplicate enum member value fc @typescript-eslint/no-duplicate-enum-values
|
|
46
58
|
|
|
47
|
-
✖
|
|
48
|
-
0 errors and
|
|
59
|
+
✖ 45 problems (0 errors, 45 warnings)
|
|
60
|
+
0 errors and 7 warnings potentially fixable with the `--fix` option.
|
|
49
61
|
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @caravan/psbt@1.0
|
|
2
|
+
> @caravan/psbt@1.2.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
|
+
806 | );
|
|
13
|
+
807 | }
|
|
14
|
+
> 808 | console.warn("Dangerously setting PsbtV2.PSBT_GLOBAL_TX_VERSION to 1!");
|
|
15
15
|
| ^
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
809 | const bw = new BufferWriter();
|
|
17
|
+
810 | bw.writeI32(1);
|
|
18
|
+
811 | 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:808:13)
|
|
21
|
+
at Function.FromV0 (src/psbtv2/psbtv2.ts:1240: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
|
+
806 | );
|
|
31
|
+
807 | }
|
|
32
|
+
> 808 | console.warn("Dangerously setting PsbtV2.PSBT_GLOBAL_TX_VERSION to 1!");
|
|
33
33
|
| ^
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
809 | const bw = new BufferWriter();
|
|
35
|
+
810 | bw.writeI32(1);
|
|
36
|
+
811 | 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:808:13)
|
|
39
|
+
at Function.FromV0 (src/psbtv2/psbtv2.ts:1240: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
|
+
806 | );
|
|
49
|
+
807 | }
|
|
50
|
+
> 808 | console.warn("Dangerously setting PsbtV2.PSBT_GLOBAL_TX_VERSION to 1!");
|
|
51
51
|
| ^
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
809 | const bw = new BufferWriter();
|
|
53
|
+
810 | bw.writeI32(1);
|
|
54
|
+
811 | 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:808:13)
|
|
57
|
+
at Function.FromV0 (src/psbtv2/psbtv2.ts:1240: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:1078: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
|
+
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
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:1080: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: 197 passed, 197 total
|
|
97
97
|
Snapshots: 0 total
|
|
98
|
-
Time: 5.
|
|
98
|
+
Time: 5.325 s
|
|
99
99
|
Ran all test suites matching /src/i.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @caravan/psbt
|
|
2
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
|
+
|
|
3
15
|
## 1.0.1
|
|
4
16
|
|
|
5
17
|
### 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)
|
|
@@ -28,10 +34,9 @@ A set of utilities for working with PSBTs.
|
|
|
28
34
|
- [`public deleteOutput`](#public-deleteoutput)
|
|
29
35
|
- [`public addPartialSig`](#public-addpartialsig)
|
|
30
36
|
- [`public removePartialSig`](#public-removepartialsig)
|
|
37
|
+
- [`public setProprietaryValue`](#public-setproprietaryvalue)
|
|
31
38
|
- [`static PsbtV2.FromV0`](#static-psbtv2fromv0)
|
|
32
39
|
- [`function getPsbtVersionNumber`](#function-getpsbtversionnumber)
|
|
33
|
-
- [`abstract class PsbtV2Maps`](#abstract-class-psbtv2maps)
|
|
34
|
-
- [`public copy`](#public-copy)
|
|
35
40
|
- [Concepts](#concepts)
|
|
36
41
|
- [The operator role saga](#the-operator-role-saga)
|
|
37
42
|
- [TODO](#todo)
|
|
@@ -104,6 +109,56 @@ An object class representing a PSBTv2 and its current state. While not yet compl
|
|
|
104
109
|
|
|
105
110
|
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
111
|
|
|
112
|
+
##### `get isReadyForConstructor`
|
|
113
|
+
|
|
114
|
+
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).
|
|
115
|
+
|
|
116
|
+
Returns `true` if the PsbtV2 is ready for an operator taking the Constructor role.
|
|
117
|
+
|
|
118
|
+
This check assumes that the Creator used this class's constructor method to initialize the PsbtV2 without passing a psbt (constructor defaults were set).
|
|
119
|
+
|
|
120
|
+
##### `get isReadyForUpdater`
|
|
121
|
+
|
|
122
|
+
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).
|
|
123
|
+
|
|
124
|
+
Returns `true` if the PsbtV2 is ready for an operator taking the Updater role.
|
|
125
|
+
|
|
126
|
+
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.
|
|
127
|
+
|
|
128
|
+
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.
|
|
129
|
+
|
|
130
|
+
##### `get isReadyForSigner`
|
|
131
|
+
|
|
132
|
+
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).
|
|
133
|
+
|
|
134
|
+
Returns `true` if the PsbtV2 is ready for an operator taking the Signer role.
|
|
135
|
+
|
|
136
|
+
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.
|
|
137
|
+
|
|
138
|
+
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.
|
|
139
|
+
|
|
140
|
+
##### `get isReadyForCombiner`
|
|
141
|
+
|
|
142
|
+
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).
|
|
143
|
+
|
|
144
|
+
Returns `true` if the PsbtV2 is ready for an operator taking the Combiner role.
|
|
145
|
+
|
|
146
|
+
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.
|
|
147
|
+
|
|
148
|
+
##### `get isReadyForInputFinalizer`
|
|
149
|
+
|
|
150
|
+
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).
|
|
151
|
+
|
|
152
|
+
Callable, but unimplemented. Returns `undefined`.
|
|
153
|
+
|
|
154
|
+
##### `get isReadyForTransactionExtractor`
|
|
155
|
+
|
|
156
|
+
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).
|
|
157
|
+
|
|
158
|
+
Returns `true` if the PsbtV2 is ready for an operator taking the Transaction Extractor role.
|
|
159
|
+
|
|
160
|
+
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.
|
|
161
|
+
|
|
107
162
|
##### `get nLockTime`
|
|
108
163
|
|
|
109
164
|
Returns the `nLockTime` field for the psbt as if it were a bitcoin transaction.
|
|
@@ -114,7 +169,7 @@ From BIP 370:
|
|
|
114
169
|
|
|
115
170
|
##### `public dangerouslySetGlobalTxVersion1`
|
|
116
171
|
|
|
117
|
-
A helper method for compatibility
|
|
172
|
+
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
173
|
|
|
119
174
|
##### `public addGlobalXpub`
|
|
120
175
|
|
|
@@ -163,23 +218,27 @@ The Signer, when it creates a signature, must add the partial sig keypair to the
|
|
|
163
218
|
|
|
164
219
|
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
220
|
|
|
166
|
-
##### `
|
|
221
|
+
##### `public setProprietaryValue`
|
|
167
222
|
|
|
168
|
-
|
|
223
|
+
Sets values on the proprietary keytype for a global, input, or output map. BIP 174 allows for proprietary values to be set on all maps with the keytype `0xFC`. This method sets byte data to key values defined by the args.
|
|
169
224
|
|
|
170
|
-
|
|
225
|
+
Args:
|
|
171
226
|
|
|
172
|
-
|
|
227
|
+
- `mapSelector` selects which map to set the proprietary value. If this value is not `"global"`, then a tuple must be provided with `"inputs"` or `"outputs"` as the first element and the index `number` on the second element representing which input or output map to set the value to. An example looks like `["inputs", 0]`. If the map name doesn't match, the values will be set to the global map. If the index is missing on `"inputs"` or `"outputs"`, then it will throw.
|
|
228
|
+
- `identifier` should be the bytes identifier for the set of proprietary keytypes.
|
|
229
|
+
- `subkeyType` accepts bytes proprietary keytype.
|
|
230
|
+
- `subkeyData` accepts bytes proprietary keydata.
|
|
231
|
+
- `valueData` accepts bytes which will be written as the proprietary value.
|
|
173
232
|
|
|
174
|
-
|
|
233
|
+
From the provided args, a key with the following format will be generated: `0xFC<compact uint identifier length><bytes identifier><bytes subtype><bytes subkeydata>`
|
|
175
234
|
|
|
176
|
-
|
|
235
|
+
##### `static PsbtV2.FromV0`
|
|
177
236
|
|
|
178
|
-
|
|
237
|
+
Attempts to return a `PsbtV2` by converting from a PSBTv0 string or Buffer
|
|
179
238
|
|
|
180
|
-
|
|
239
|
+
#### `function getPsbtVersionNumber`
|
|
181
240
|
|
|
182
|
-
|
|
241
|
+
Attempts to extract the version number as uint32LE from raw psbt regardless of psbt validity.
|
|
183
242
|
|
|
184
243
|
## Concepts
|
|
185
244
|
|
|
@@ -189,9 +248,20 @@ The PSBT is a resource which may be passed between several operators or services
|
|
|
189
248
|
|
|
190
249
|
### TODO
|
|
191
250
|
|
|
192
|
-
|
|
251
|
+
#### PsbtV2
|
|
252
|
+
|
|
253
|
+
##### Operator role validation
|
|
254
|
+
|
|
255
|
+
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.
|
|
256
|
+
|
|
257
|
+
##### Class constructor
|
|
258
|
+
|
|
259
|
+
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()`.
|
|
260
|
+
|
|
261
|
+
##### Add input timelocks
|
|
262
|
+
|
|
263
|
+
The `public addInput` must be able to properly handle input locktimes which interact with the global value.
|
|
193
264
|
|
|
194
|
-
|
|
265
|
+
##### Add input sighash_single
|
|
195
266
|
|
|
196
|
-
|
|
197
|
-
- Check ready for Signer role on `addPartialSig`.
|
|
267
|
+
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
|
@@ -24,6 +24,8 @@ declare enum PsbtGlobalTxModifiableBits {
|
|
|
24
24
|
OUTPUTS = "OUTPUTS",// 0b00000010
|
|
25
25
|
SIGHASH_SINGLE = "SIGHASH_SINGLE"
|
|
26
26
|
}
|
|
27
|
+
type InputOutputIndexType = number;
|
|
28
|
+
type MapSelectorType = "global" | ["inputs", InputOutputIndexType] | ["outputs", InputOutputIndexType];
|
|
27
29
|
|
|
28
30
|
/**
|
|
29
31
|
* Attempts to extract the version number as uint32LE from raw psbt regardless
|
|
@@ -74,7 +76,7 @@ declare class PsbtV2 extends PsbtV2Maps {
|
|
|
74
76
|
/**
|
|
75
77
|
* Globals Getters/Setters
|
|
76
78
|
*/
|
|
77
|
-
get PSBT_GLOBAL_XPUB(): NonUniqueKeyTypeValue[]
|
|
79
|
+
get PSBT_GLOBAL_XPUB(): NonUniqueKeyTypeValue[];
|
|
78
80
|
get PSBT_GLOBAL_TX_VERSION(): number;
|
|
79
81
|
set PSBT_GLOBAL_TX_VERSION(version: number);
|
|
80
82
|
get PSBT_GLOBAL_FALLBACK_LOCKTIME(): number | null;
|
|
@@ -87,7 +89,7 @@ declare class PsbtV2 extends PsbtV2Maps {
|
|
|
87
89
|
set PSBT_GLOBAL_TX_MODIFIABLE(modifiable: PsbtGlobalTxModifiableBits[]);
|
|
88
90
|
get PSBT_GLOBAL_VERSION(): number;
|
|
89
91
|
set PSBT_GLOBAL_VERSION(version: number);
|
|
90
|
-
get PSBT_GLOBAL_PROPRIETARY(): NonUniqueKeyTypeValue[]
|
|
92
|
+
get PSBT_GLOBAL_PROPRIETARY(): NonUniqueKeyTypeValue[];
|
|
91
93
|
/**
|
|
92
94
|
* Input Getters/Setters
|
|
93
95
|
*/
|
|
@@ -97,23 +99,23 @@ declare class PsbtV2 extends PsbtV2Maps {
|
|
|
97
99
|
get PSBT_IN_SIGHASH_TYPE(): (number | null)[];
|
|
98
100
|
get PSBT_IN_REDEEM_SCRIPT(): (string | null)[];
|
|
99
101
|
get PSBT_IN_WITNESS_SCRIPT(): (string | null)[];
|
|
100
|
-
get PSBT_IN_BIP32_DERIVATION(): NonUniqueKeyTypeValue[]
|
|
102
|
+
get PSBT_IN_BIP32_DERIVATION(): NonUniqueKeyTypeValue[][];
|
|
101
103
|
get PSBT_IN_FINAL_SCRIPTSIG(): (string | null)[];
|
|
102
104
|
get PSBT_IN_FINAL_SCRIPTWITNESS(): (string | null)[];
|
|
103
105
|
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[]
|
|
106
|
+
get PSBT_IN_RIPEMD160(): NonUniqueKeyTypeValue[][];
|
|
107
|
+
get PSBT_IN_SHA256(): NonUniqueKeyTypeValue[][];
|
|
108
|
+
get PSBT_IN_HASH160(): NonUniqueKeyTypeValue[][];
|
|
109
|
+
get PSBT_IN_HASH256(): NonUniqueKeyTypeValue[][];
|
|
108
110
|
get PSBT_IN_PREVIOUS_TXID(): string[];
|
|
109
111
|
get PSBT_IN_OUTPUT_INDEX(): number[];
|
|
110
112
|
get PSBT_IN_SEQUENCE(): (number | null)[];
|
|
111
113
|
get PSBT_IN_REQUIRED_TIME_LOCKTIME(): (number | null)[];
|
|
112
114
|
get PSBT_IN_REQUIRED_HEIGHT_LOCKTIME(): (number | null)[];
|
|
113
115
|
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[]
|
|
116
|
+
get PSBT_IN_TAP_SCRIPT_SIG(): NonUniqueKeyTypeValue[][];
|
|
117
|
+
get PSBT_IN_TAP_LEAF_SCRIPT(): NonUniqueKeyTypeValue[][];
|
|
118
|
+
get PSBT_IN_TAP_BIP32_DERIVATION(): NonUniqueKeyTypeValue[][];
|
|
117
119
|
get PSBT_IN_TAP_INTERNAL_KEY(): (string | null)[];
|
|
118
120
|
get PSBT_IN_TAP_MERKLE_ROOT(): (string | null)[];
|
|
119
121
|
get PSBT_IN_PROPRIETARY(): NonUniqueKeyTypeValue[] | NonUniqueKeyTypeValue[][];
|
|
@@ -129,6 +131,57 @@ declare class PsbtV2 extends PsbtV2Maps {
|
|
|
129
131
|
get PSBT_OUT_TAP_TREE(): (string | null)[];
|
|
130
132
|
get PSBT_OUT_TAP_BIP32_DERIVATION(): NonUniqueKeyTypeValue[] | NonUniqueKeyTypeValue[][];
|
|
131
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;
|
|
132
185
|
/**
|
|
133
186
|
* Other Getters/Setters
|
|
134
187
|
*/
|
|
@@ -205,7 +258,7 @@ declare class PsbtV2 extends PsbtV2Maps {
|
|
|
205
258
|
*/
|
|
206
259
|
deleteOutput(index: number): void;
|
|
207
260
|
/**
|
|
208
|
-
* Checks that provided flags are present in PSBT_GLOBAL_TX_MODIFIABLE.
|
|
261
|
+
* Checks that all provided flags are present in PSBT_GLOBAL_TX_MODIFIABLE.
|
|
209
262
|
*/
|
|
210
263
|
private isModifiable;
|
|
211
264
|
/**
|
|
@@ -228,13 +281,42 @@ declare class PsbtV2 extends PsbtV2Maps {
|
|
|
228
281
|
* the pubkey exists.
|
|
229
282
|
*/
|
|
230
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;
|
|
231
309
|
/**
|
|
232
310
|
* Ensures the PSBT is in the proper state when adding a partial sig keypair.
|
|
233
311
|
* https://github.com/bitcoin/bips/blob/master/bip-0370.mediawiki#signer
|
|
234
312
|
*/
|
|
235
313
|
private handleSighashType;
|
|
236
314
|
/**
|
|
237
|
-
* Attempts to return a PsbtV2 by converting from a PsbtV0 string or Buffer
|
|
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.
|
|
238
320
|
*/
|
|
239
321
|
static FromV0(psbt: string | Buffer, allowTxnVersion1?: boolean): PsbtV2;
|
|
240
322
|
}
|