@bitgo-beta/utxo-core 0.0.0-semantic-release-managed

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.
Files changed (132) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +6 -0
  3. package/dist/src/Output.d.ts +43 -0
  4. package/dist/src/Output.d.ts.map +1 -0
  5. package/dist/src/Output.js +60 -0
  6. package/dist/src/bip322/index.d.ts +5 -0
  7. package/dist/src/bip322/index.d.ts.map +1 -0
  8. package/dist/src/bip322/index.js +21 -0
  9. package/dist/src/bip322/toSign.d.ts +25 -0
  10. package/dist/src/bip322/toSign.d.ts.map +1 -0
  11. package/dist/src/bip322/toSign.js +126 -0
  12. package/dist/src/bip322/toSpend.d.ts +22 -0
  13. package/dist/src/bip322/toSpend.d.ts.map +1 -0
  14. package/dist/src/bip322/toSpend.js +72 -0
  15. package/dist/src/bip322/utils.d.ts +18 -0
  16. package/dist/src/bip322/utils.d.ts.map +1 -0
  17. package/dist/src/bip322/utils.js +115 -0
  18. package/dist/src/bip322/verify.d.ts +12 -0
  19. package/dist/src/bip322/verify.d.ts.map +1 -0
  20. package/dist/src/bip322/verify.js +115 -0
  21. package/dist/src/bip32utils.d.ts +16 -0
  22. package/dist/src/bip32utils.d.ts.map +1 -0
  23. package/dist/src/bip32utils.js +71 -0
  24. package/dist/src/bip65/index.d.ts +2 -0
  25. package/dist/src/bip65/index.d.ts.map +1 -0
  26. package/dist/src/bip65/index.js +18 -0
  27. package/dist/src/bip65/locktime.d.ts +8 -0
  28. package/dist/src/bip65/locktime.d.ts.map +1 -0
  29. package/dist/src/bip65/locktime.js +37 -0
  30. package/dist/src/descriptor/DescriptorMap.d.ts +9 -0
  31. package/dist/src/descriptor/DescriptorMap.d.ts.map +1 -0
  32. package/dist/src/descriptor/DescriptorMap.js +9 -0
  33. package/dist/src/descriptor/Output.d.ts +23 -0
  34. package/dist/src/descriptor/Output.d.ts.map +1 -0
  35. package/dist/src/descriptor/Output.js +41 -0
  36. package/dist/src/descriptor/VirtualSize.d.ts +23 -0
  37. package/dist/src/descriptor/VirtualSize.d.ts.map +1 -0
  38. package/dist/src/descriptor/VirtualSize.js +100 -0
  39. package/dist/src/descriptor/address.d.ts +5 -0
  40. package/dist/src/descriptor/address.d.ts.map +1 -0
  41. package/dist/src/descriptor/address.js +48 -0
  42. package/dist/src/descriptor/derive.d.ts +13 -0
  43. package/dist/src/descriptor/derive.d.ts.map +1 -0
  44. package/dist/src/descriptor/derive.js +45 -0
  45. package/dist/src/descriptor/fromFixedScriptWallet.d.ts +16 -0
  46. package/dist/src/descriptor/fromFixedScriptWallet.d.ts.map +1 -0
  47. package/dist/src/descriptor/fromFixedScriptWallet.js +88 -0
  48. package/dist/src/descriptor/index.d.ts +11 -0
  49. package/dist/src/descriptor/index.d.ts.map +1 -0
  50. package/dist/src/descriptor/index.js +27 -0
  51. package/dist/src/descriptor/parse/PatternMatcher.d.ts +14 -0
  52. package/dist/src/descriptor/parse/PatternMatcher.d.ts.map +1 -0
  53. package/dist/src/descriptor/parse/PatternMatcher.js +60 -0
  54. package/dist/src/descriptor/psbt/assertSatisfiable.d.ts +20 -0
  55. package/dist/src/descriptor/psbt/assertSatisfiable.d.ts.map +1 -0
  56. package/dist/src/descriptor/psbt/assertSatisfiable.js +74 -0
  57. package/dist/src/descriptor/psbt/createPsbt.d.ts +23 -0
  58. package/dist/src/descriptor/psbt/createPsbt.d.ts.map +1 -0
  59. package/dist/src/descriptor/psbt/createPsbt.js +107 -0
  60. package/dist/src/descriptor/psbt/findDescriptors.d.ts +26 -0
  61. package/dist/src/descriptor/psbt/findDescriptors.d.ts.map +1 -0
  62. package/dist/src/descriptor/psbt/findDescriptors.js +98 -0
  63. package/dist/src/descriptor/psbt/index.d.ts +7 -0
  64. package/dist/src/descriptor/psbt/index.d.ts.map +1 -0
  65. package/dist/src/descriptor/psbt/index.js +23 -0
  66. package/dist/src/descriptor/psbt/parse.d.ts +27 -0
  67. package/dist/src/descriptor/psbt/parse.d.ts.map +1 -0
  68. package/dist/src/descriptor/psbt/parse.js +87 -0
  69. package/dist/src/descriptor/psbt/sign.d.ts +26 -0
  70. package/dist/src/descriptor/psbt/sign.d.ts.map +1 -0
  71. package/dist/src/descriptor/psbt/sign.js +42 -0
  72. package/dist/src/descriptor/psbt/wrap.d.ts +12 -0
  73. package/dist/src/descriptor/psbt/wrap.d.ts.map +1 -0
  74. package/dist/src/descriptor/psbt/wrap.js +76 -0
  75. package/dist/src/dustThreshold.d.ts +4 -0
  76. package/dist/src/dustThreshold.d.ts.map +1 -0
  77. package/dist/src/dustThreshold.js +134 -0
  78. package/dist/src/index.d.ts +10 -0
  79. package/dist/src/index.d.ts.map +1 -0
  80. package/dist/src/index.js +49 -0
  81. package/dist/src/paygo/attestation.d.ts +11 -0
  82. package/dist/src/paygo/attestation.d.ts.map +1 -0
  83. package/dist/src/paygo/attestation.js +58 -0
  84. package/dist/src/paygo/index.d.ts +3 -0
  85. package/dist/src/paygo/index.d.ts.map +1 -0
  86. package/dist/src/paygo/index.js +19 -0
  87. package/dist/src/paygo/parsePayGoAttestation.d.ts +16 -0
  88. package/dist/src/paygo/parsePayGoAttestation.d.ts.map +1 -0
  89. package/dist/src/paygo/parsePayGoAttestation.js +50 -0
  90. package/dist/src/paygo/psbt/Errors.d.ts +22 -0
  91. package/dist/src/paygo/psbt/Errors.d.ts.map +1 -0
  92. package/dist/src/paygo/psbt/Errors.js +44 -0
  93. package/dist/src/paygo/psbt/index.d.ts +2 -0
  94. package/dist/src/paygo/psbt/index.d.ts.map +1 -0
  95. package/dist/src/paygo/psbt/index.js +18 -0
  96. package/dist/src/paygo/psbt/payGoAddressProof.d.ts +29 -0
  97. package/dist/src/paygo/psbt/payGoAddressProof.d.ts.map +1 -0
  98. package/dist/src/paygo/psbt/payGoAddressProof.js +124 -0
  99. package/dist/src/testutil/descriptor/descriptors.d.ts +13 -0
  100. package/dist/src/testutil/descriptor/descriptors.d.ts.map +1 -0
  101. package/dist/src/testutil/descriptor/descriptors.js +162 -0
  102. package/dist/src/testutil/descriptor/index.d.ts +4 -0
  103. package/dist/src/testutil/descriptor/index.d.ts.map +1 -0
  104. package/dist/src/testutil/descriptor/index.js +20 -0
  105. package/dist/src/testutil/descriptor/mock.utils.d.ts +36 -0
  106. package/dist/src/testutil/descriptor/mock.utils.d.ts.map +1 -0
  107. package/dist/src/testutil/descriptor/mock.utils.js +92 -0
  108. package/dist/src/testutil/descriptor/psbt.utils.d.ts +4 -0
  109. package/dist/src/testutil/descriptor/psbt.utils.d.ts.map +1 -0
  110. package/dist/src/testutil/descriptor/psbt.utils.js +21 -0
  111. package/dist/src/testutil/fixtures.utils.d.ts +15 -0
  112. package/dist/src/testutil/fixtures.utils.d.ts.map +1 -0
  113. package/dist/src/testutil/fixtures.utils.js +127 -0
  114. package/dist/src/testutil/generatePayGoAttestationProof.utils.d.ts +12 -0
  115. package/dist/src/testutil/generatePayGoAttestationProof.utils.d.ts.map +1 -0
  116. package/dist/src/testutil/generatePayGoAttestationProof.utils.js +38 -0
  117. package/dist/src/testutil/index.d.ts +6 -0
  118. package/dist/src/testutil/index.d.ts.map +1 -0
  119. package/dist/src/testutil/index.js +22 -0
  120. package/dist/src/testutil/key.utils.d.ts +16 -0
  121. package/dist/src/testutil/key.utils.d.ts.map +1 -0
  122. package/dist/src/testutil/key.utils.js +59 -0
  123. package/dist/src/testutil/toPlainObject.utils.d.ts +11 -0
  124. package/dist/src/testutil/toPlainObject.utils.d.ts.map +1 -0
  125. package/dist/src/testutil/toPlainObject.utils.js +89 -0
  126. package/dist/src/testutil/trimMessagePrefix.d.ts +11 -0
  127. package/dist/src/testutil/trimMessagePrefix.d.ts.map +1 -0
  128. package/dist/src/testutil/trimMessagePrefix.js +60 -0
  129. package/dist/src/xOnlyPubkey.d.ts +2 -0
  130. package/dist/src/xOnlyPubkey.d.ts.map +1 -0
  131. package/dist/src/xOnlyPubkey.js +18 -0
  132. package/package.json +63 -0
package/LICENSE ADDED
@@ -0,0 +1,191 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ Copyright 2022 BitGo
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,6 @@
1
+ # utxo-core
2
+
3
+ This repository contains core types and functions for Bitcoin-like UTXO-based cryptocurrencies.
4
+
5
+ It is the glue between SDK-dependent modules like `abstract-utxo` and low-level libraries like `utxo-lib` and
6
+ `wasm-miniscript`.
@@ -0,0 +1,43 @@
1
+ export type Output<TValue = bigint> = {
2
+ script: Buffer;
3
+ value: TValue;
4
+ };
5
+ export type MaxOutput = Output<'max'>;
6
+ type ValueBigInt = {
7
+ value: bigint;
8
+ };
9
+ type ValueMax = {
10
+ value: 'max';
11
+ };
12
+ /**
13
+ * @return true if the output is a max output
14
+ */
15
+ export declare function isMaxOutput<A extends ValueBigInt, B extends ValueMax>(output: A | B): output is B;
16
+ /**
17
+ * @return the max output if there is one
18
+ * @throws if there are multiple max outputs
19
+ */
20
+ export declare function getMaxOutput<A extends ValueBigInt, B extends ValueMax>(outputs: (A | B)[]): B | undefined;
21
+ /**
22
+ * @return the sum of the outputs
23
+ */
24
+ export declare function getOutputSum(outputs: ValueBigInt[]): bigint;
25
+ /**
26
+ * @return the sum of the outputs that are not 'max'
27
+ */
28
+ export declare function getFixedOutputSum(outputs: (ValueBigInt | ValueMax)[]): bigint;
29
+ /**
30
+ * @param outputs
31
+ * @param params
32
+ * @return the outputs with the 'max' output replaced with the max amount
33
+ */
34
+ export declare function toFixedOutputs<A extends ValueBigInt, B extends ValueMax>(outputs: (A | B)[], params: {
35
+ maxAmount: bigint;
36
+ }): A[];
37
+ export type PrevOutput = {
38
+ hash: string;
39
+ index: number;
40
+ witnessUtxo: Output;
41
+ };
42
+ export {};
43
+ //# sourceMappingURL=Output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Output.d.ts","sourceRoot":"","sources":["../../src/Output.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,CAAC,MAAM,GAAG,MAAM,IAAI;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AACF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;AACtC,KAAK,WAAW,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AACrC,KAAK,QAAQ,GAAG;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AAEjC;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,WAAW,EAAE,CAAC,SAAS,QAAQ,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,CAAC,CAEjG;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,WAAW,EAAE,CAAC,SAAS,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,SAAS,CASzG;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,CAE3D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,CAAC,WAAW,GAAG,QAAQ,CAAC,EAAE,GAAG,MAAM,CAE7E;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,WAAW,EAAE,CAAC,SAAS,QAAQ,EACtE,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAClB,MAAM,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GAC5B,CAAC,EAAE,CAaL;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC"}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isMaxOutput = isMaxOutput;
4
+ exports.getMaxOutput = getMaxOutput;
5
+ exports.getOutputSum = getOutputSum;
6
+ exports.getFixedOutputSum = getFixedOutputSum;
7
+ exports.toFixedOutputs = toFixedOutputs;
8
+ /**
9
+ * @return true if the output is a max output
10
+ */
11
+ function isMaxOutput(output) {
12
+ return output.value === 'max';
13
+ }
14
+ /**
15
+ * @return the max output if there is one
16
+ * @throws if there are multiple max outputs
17
+ */
18
+ function getMaxOutput(outputs) {
19
+ const max = outputs.filter((isMaxOutput));
20
+ if (max.length === 0) {
21
+ return undefined;
22
+ }
23
+ if (max.length > 1) {
24
+ throw new Error('Multiple max outputs');
25
+ }
26
+ return max[0];
27
+ }
28
+ /**
29
+ * @return the sum of the outputs
30
+ */
31
+ function getOutputSum(outputs) {
32
+ return outputs.reduce((sum, output) => sum + output.value, 0n);
33
+ }
34
+ /**
35
+ * @return the sum of the outputs that are not 'max'
36
+ */
37
+ function getFixedOutputSum(outputs) {
38
+ return getOutputSum(outputs.filter((o) => !isMaxOutput(o)));
39
+ }
40
+ /**
41
+ * @param outputs
42
+ * @param params
43
+ * @return the outputs with the 'max' output replaced with the max amount
44
+ */
45
+ function toFixedOutputs(outputs, params) {
46
+ // assert that there is at most one max output
47
+ const maxOutput = getMaxOutput(outputs);
48
+ return outputs.map((output) => {
49
+ if (isMaxOutput(output)) {
50
+ if (output !== maxOutput) {
51
+ throw new Error('illegal state');
52
+ }
53
+ return { ...output, value: params.maxAmount };
54
+ }
55
+ else {
56
+ return output;
57
+ }
58
+ });
59
+ }
60
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiT3V0cHV0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL091dHB1dC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQVdBLGtDQUVDO0FBTUQsb0NBU0M7QUFLRCxvQ0FFQztBQUtELDhDQUVDO0FBT0Qsd0NBZ0JDO0FBekREOztHQUVHO0FBQ0gsU0FBZ0IsV0FBVyxDQUE0QyxNQUFhO0lBQ2xGLE9BQU8sTUFBTSxDQUFDLEtBQUssS0FBSyxLQUFLLENBQUM7QUFDaEMsQ0FBQztBQUVEOzs7R0FHRztBQUNILFNBQWdCLFlBQVksQ0FBNEMsT0FBa0I7SUFDeEYsTUFBTSxHQUFHLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxDQUFBLF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iB0b0ZpeGVkT3V0cHV0czxBIGV4dGVuZHMgVmFsdWVCaWdJbnQsIEIgZXh0ZW5kcyBWYWx1ZU1heD4oXG4gIG91dHB1dHM6IChBIHwgQilbXSxcbiAgcGFyYW1zOiB7IG1heEFtb3VudDogYmlnaW50IH1cbik6IEFbXSB7XG4gIC8vIGFzc2VydCB0aGF0IHRoZXJlIGlzIGF0IG1vc3Qgb25lIG1heCBvdXRwdXRcbiAgY29uc3QgbWF4T3V0cHV0ID0gZ2V0TWF4T3V0cHV0PEEsIEI+KG91dHB1dHMpO1xuICByZXR1cm4gb3V0cHV0cy5tYXAoKG91dHB1dCk6IEEgPT4ge1xuICAgIGlmIChpc01heE91dHB1dChvdXRwdXQpKSB7XG4gICAgICBpZiAob3V0cHV0ICE9PSBtYXhPdXRwdXQpIHtcbiAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdpbGxlZ2FsIHN0YXRlJyk7XG4gICAgICB9XG4gICAgICByZXR1cm4geyAuLi5vdXRwdXQsIHZhbHVlOiBwYXJhbXMubWF4QW1vdW50IH07XG4gICAgfSBlbHNlIHtcbiAgICAgIHJldHVybiBvdXRwdXQ7XG4gICAgfVxuICB9KTtcbn1cblxuZXhwb3J0IHR5cGUgUHJldk91dHB1dCA9IHtcbiAgaGFzaDogc3RyaW5nO1xuICBpbmRleDogbnVtYmVyO1xuICB3aXRuZXNzVXR4bzogT3V0cHV0O1xufTtcbiJdfQ==
@@ -0,0 +1,5 @@
1
+ export * from './toSpend';
2
+ export * from './toSign';
3
+ export * from './utils';
4
+ export * from './verify';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bip322/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./toSpend"), exports);
18
+ __exportStar(require("./toSign"), exports);
19
+ __exportStar(require("./utils"), exports);
20
+ __exportStar(require("./verify"), exports);
21
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvYmlwMzIyL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSw0Q0FBMEI7QUFDMUIsMkNBQXlCO0FBQ3pCLDBDQUF3QjtBQUN4QiwyQ0FBeUIiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgKiBmcm9tICcuL3RvU3BlbmQnO1xuZXhwb3J0ICogZnJvbSAnLi90b1NpZ24nO1xuZXhwb3J0ICogZnJvbSAnLi91dGlscyc7XG5leHBvcnQgKiBmcm9tICcuL3ZlcmlmeSc7XG4iXX0=
@@ -0,0 +1,25 @@
1
+ import { Psbt, bitgo } from '@bitgo-beta/utxo-lib';
2
+ export type AddressDetails = {
3
+ redeemScript?: Buffer;
4
+ witnessScript?: Buffer;
5
+ scriptPubKey: Buffer;
6
+ };
7
+ export declare const MAX_NUM_BIP322_INPUTS = 200;
8
+ /**
9
+ * Create the base PSBT for the to_sign transaction for BIP322 signing.
10
+ * There will be ever 1 output.
11
+ */
12
+ export declare function createBaseToSignPsbt(rootWalletKeys?: bitgo.RootWalletKeys, network?: import("@bitgo-beta/utxo-lib").Network): bitgo.UtxoPsbt;
13
+ /**
14
+ * Add a BIP322 input to the PSBT.
15
+ * Source implementation:
16
+ * https://github.com/bitcoin/bips/blob/master/bip-0322.mediawiki#full
17
+ *
18
+ * @param {string} message - The message that is hashed into the `to_spend` transaction.
19
+ * @param {AddressDetails} addressDetails - The details of the address, including redeemScript and/or witnessScript.
20
+ * @param {string} [tag=BIP322_TAG] - The tag to use for hashing, defaults to BIP322_TAG.
21
+ * @returns {Psbt} - The hex representation of the constructed PSBT.
22
+ */
23
+ export declare function addBip322Input(psbt: Psbt, message: string, addressDetails: AddressDetails, tag?: string): void;
24
+ export declare function addBip322InputWithChainAndIndex(psbt: bitgo.UtxoPsbt, message: string, rootWalletKeys: bitgo.RootWalletKeys, scriptId: bitgo.ScriptId): void;
25
+ //# sourceMappingURL=toSign.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toSign.d.ts","sourceRoot":"","sources":["../../../src/bip322/toSign.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAyB,MAAM,sBAAsB,CAAC;AAM1E,MAAM,MAAM,cAAc,GAAG;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AACF,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,cAAc,CAAC,EAAE,KAAK,CAAC,cAAc,EACrC,OAAO,yCAAmB,GACzB,KAAK,CAAC,QAAQ,CAmBhB;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,GAAG,SAAa,GAAG,IAAI,CA6BlH;AAED,wBAAgB,+BAA+B,CAC7C,IAAI,EAAE,KAAK,CAAC,QAAQ,EACpB,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,KAAK,CAAC,cAAc,EACpC,QAAQ,EAAE,KAAK,CAAC,QAAQ,GACvB,IAAI,CA0EN"}
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MAX_NUM_BIP322_INPUTS = void 0;
4
+ exports.createBaseToSignPsbt = createBaseToSignPsbt;
5
+ exports.addBip322Input = addBip322Input;
6
+ exports.addBip322InputWithChainAndIndex = addBip322InputWithChainAndIndex;
7
+ const utxo_lib_1 = require("@bitgo-beta/utxo-lib");
8
+ const outputScripts_1 = require("@bitgo-beta/utxo-lib/dist/src/bitgo/outputScripts");
9
+ const utils_1 = require("./utils");
10
+ const toSpend_1 = require("./toSpend");
11
+ exports.MAX_NUM_BIP322_INPUTS = 200;
12
+ /**
13
+ * Create the base PSBT for the to_sign transaction for BIP322 signing.
14
+ * There will be ever 1 output.
15
+ */
16
+ function createBaseToSignPsbt(rootWalletKeys, network = utxo_lib_1.networks.bitcoin) {
17
+ // Create PSBT object for constructing the transaction
18
+ const psbt = utxo_lib_1.bitgo.createPsbtForNetwork({ network });
19
+ // Set default value for nVersion and nLockTime
20
+ psbt.setVersion(0); // nVersion = 0
21
+ psbt.setLocktime(0); // nLockTime = 0
22
+ // Set the output
23
+ psbt.addOutput({
24
+ value: BigInt(0), // vout[0].nValue = 0
25
+ script: Buffer.from([0x6a]), // vout[0].scriptPubKey = OP_RETURN
26
+ });
27
+ // If rootWalletKeys are provided, add them to the PSBT as global xpubs
28
+ if (rootWalletKeys) {
29
+ utxo_lib_1.bitgo.addXpubsToPsbt(psbt, rootWalletKeys);
30
+ }
31
+ return psbt;
32
+ }
33
+ /**
34
+ * Add a BIP322 input to the PSBT.
35
+ * Source implementation:
36
+ * https://github.com/bitcoin/bips/blob/master/bip-0322.mediawiki#full
37
+ *
38
+ * @param {string} message - The message that is hashed into the `to_spend` transaction.
39
+ * @param {AddressDetails} addressDetails - The details of the address, including redeemScript and/or witnessScript.
40
+ * @param {string} [tag=BIP322_TAG] - The tag to use for hashing, defaults to BIP322_TAG.
41
+ * @returns {Psbt} - The hex representation of the constructed PSBT.
42
+ */
43
+ function addBip322Input(psbt, message, addressDetails, tag = toSpend_1.BIP322_TAG) {
44
+ const toSpendTx = (0, toSpend_1.buildToSpendTransaction)(addressDetails.scriptPubKey, message, tag);
45
+ if (psbt.data.inputs.length >= exports.MAX_NUM_BIP322_INPUTS) {
46
+ throw new Error(`Exceeded maximum number of BIP322 inputs (${exports.MAX_NUM_BIP322_INPUTS})`);
47
+ }
48
+ psbt.addInput({
49
+ hash: toSpendTx.getId(), // vin[0].prevout.hash = to_spend.txid
50
+ index: 0, // vin[0].prevout.n = 0
51
+ sequence: 0, // vin[0].nSequence = 0
52
+ nonWitnessUtxo: toSpendTx.toBuffer(), // previous transaction for us to rebuild later to verify
53
+ sighashType: utxo_lib_1.Transaction.SIGHASH_ALL,
54
+ });
55
+ const inputIndex = psbt.data.inputs.length - 1;
56
+ psbt.updateInput(inputIndex, {
57
+ witnessUtxo: { value: BigInt(0), script: addressDetails.scriptPubKey },
58
+ });
59
+ if (addressDetails.redeemScript) {
60
+ psbt.updateInput(inputIndex, { redeemScript: addressDetails.redeemScript });
61
+ }
62
+ if (addressDetails.witnessScript) {
63
+ psbt.updateInput(inputIndex, {
64
+ witnessScript: addressDetails.witnessScript,
65
+ });
66
+ }
67
+ // Add the message as a proprietary key value to the PSBT so we can verify it later
68
+ (0, utils_1.addBip322ProofMessage)(psbt, inputIndex, Buffer.from(message));
69
+ }
70
+ function addBip322InputWithChainAndIndex(psbt, message, rootWalletKeys, scriptId) {
71
+ const scriptType = utxo_lib_1.bitgo.scriptTypeForChain(scriptId.chain);
72
+ const walletKeys = rootWalletKeys.deriveForChainAndIndex(scriptId.chain, scriptId.index);
73
+ const output = utxo_lib_1.bitgo.outputScripts.createOutputScript2of3(walletKeys.publicKeys, utxo_lib_1.bitgo.scriptTypeForChain(scriptId.chain));
74
+ addBip322Input(psbt, message, {
75
+ scriptPubKey: output.scriptPubKey,
76
+ redeemScript: output.redeemScript,
77
+ witnessScript: output.witnessScript,
78
+ });
79
+ const inputIndex = psbt.data.inputs.length - 1;
80
+ // When adding the taproot metadata, we assume that we are NOT using the backup path
81
+ // For script type p2tr, it means that we are using signer and bitgo keys when creating the tap tree
82
+ // spending paths. For p2trMusig2, it means that we are using the taproot key path spending
83
+ const keyNames = ['user', 'bitgo'];
84
+ if (scriptType === 'p2tr') {
85
+ const { controlBlock, witnessScript, leafVersion, leafHash } = utxo_lib_1.bitgo.outputScripts.createSpendScriptP2tr(walletKeys.publicKeys, [walletKeys.user.publicKey, walletKeys.bitgo.publicKey]);
86
+ psbt.updateInput(inputIndex, {
87
+ tapLeafScript: [{ controlBlock, script: witnessScript, leafVersion }],
88
+ });
89
+ psbt.updateInput(inputIndex, {
90
+ tapBip32Derivation: keyNames.map((key) => ({
91
+ leafHashes: [leafHash],
92
+ pubkey: (0, outputScripts_1.toXOnlyPublicKey)(walletKeys[key].publicKey),
93
+ path: rootWalletKeys.getDerivationPath(rootWalletKeys[key], scriptId.chain, scriptId.index),
94
+ masterFingerprint: rootWalletKeys[key].fingerprint,
95
+ })),
96
+ });
97
+ }
98
+ else if (scriptType === 'p2trMusig2') {
99
+ const { internalPubkey: tapInternalKey, outputPubkey: tapOutputKey, taptreeRoot, } = utxo_lib_1.bitgo.outputScripts.createKeyPathP2trMusig2(walletKeys.publicKeys);
100
+ const participantsKeyValData = utxo_lib_1.bitgo.musig2.encodePsbtMusig2Participants({
101
+ tapOutputKey,
102
+ tapInternalKey,
103
+ participantPubKeys: [walletKeys.user.publicKey, walletKeys.bitgo.publicKey],
104
+ });
105
+ utxo_lib_1.bitgo.addProprietaryKeyValuesFromUnknownKeyValues(psbt, 'input', inputIndex, participantsKeyValData);
106
+ psbt.updateInput(inputIndex, {
107
+ tapInternalKey: tapInternalKey,
108
+ });
109
+ psbt.updateInput(inputIndex, {
110
+ tapMerkleRoot: taptreeRoot,
111
+ });
112
+ psbt.updateInput(inputIndex, {
113
+ tapBip32Derivation: keyNames.map((key) => ({
114
+ leafHashes: [],
115
+ pubkey: (0, outputScripts_1.toXOnlyPublicKey)(walletKeys[key].publicKey),
116
+ path: rootWalletKeys.getDerivationPath(rootWalletKeys[key], scriptId.chain, scriptId.index),
117
+ masterFingerprint: rootWalletKeys[key].fingerprint,
118
+ })),
119
+ });
120
+ }
121
+ else {
122
+ // Add bip32 derivation information for the input
123
+ psbt.updateInput(inputIndex, utxo_lib_1.bitgo.getPsbtBip32DerivationOutputUpdate(rootWalletKeys, walletKeys, utxo_lib_1.bitgo.scriptTypeForChain(scriptId.chain)));
124
+ }
125
+ }
126
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG9TaWduLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2JpcDMyMi90b1NpZ24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBaUJBLG9EQXNCQztBQVlELHdDQTZCQztBQUVELDBFQStFQztBQWpLRCxtREFBMEU7QUFDMUUscUZBQXFGO0FBRXJGLG1DQUFnRDtBQUNoRCx1Q0FBZ0U7QUFPbkQsUUFBQSxxQkFBcUIsR0FBRyxHQUFHLENBQUM7QUFFekM7OztHQUdHO0FBQ0gsU0FBZ0Isb0JBQW9CLENBQ2xDLGNBQXFDLEVBQ3JDLE9BQU8sR0FBRyxtQkFBUSxDQUFDLE9BQU87SUFFMUIsc0RBQXNEO0lBQ3RELE1BQU0sSUFBSSxHQUFHLGdCQUFLLENBQUMsb0JBQW9CLENBQUMsRUFBRSxPQUFPLEVBQUUsQ0FBQyxDQ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AgICB0YXBJbnRlcm5hbEtleTogdGFwSW50ZXJuYWxLZXksXG4gICAgfSk7XG5cbiAgICBwc2J0LnVwZGF0ZUlucHV0KGlucHV0SW5kZXgsIHtcbiAgICAgIHRhcE1lcmtsZVJvb3Q6IHRhcHRyZWVSb290LFxuICAgIH0pO1xuXG4gICAgcHNidC51cGRhdGVJbnB1dChpbnB1dEluZGV4LCB7XG4gICAgICB0YXBCaXAzMkRlcml2YXRpb246IGtleU5hbWVzLm1hcCgoa2V5KSA9PiAoe1xuICAgICAgICBsZWFmSGFzaGVzOiBbXSxcbiAgICAgICAgcHVia2V5OiB0b1hPbmx5UHVibGljS2V5KHdhbGxldEtleXNba2V5XS5wdWJsaWNLZXkpLFxuICAgICAgICBwYXRoOiByb290V2FsbGV0S2V5cy5nZXREZXJpdmF0aW9uUGF0aChyb290V2FsbGV0S2V5c1trZXldLCBzY3JpcHRJZC5jaGFpbiwgc2NyaXB0SWQuaW5kZXgpLFxuICAgICAgICBtYXN0ZXJGaW5nZXJwcmludDogcm9vdFdhbGxldEtleXNba2V5XS5maW5nZXJwcmludCxcbiAgICAgIH0pKSxcbiAgICB9KTtcbiAgfSBlbHNlIHtcbiAgICAvLyBBZGQgYmlwMzIgZGVyaXZhdGlvbiBpbmZvcm1hdGlvbiBmb3IgdGhlIGlucHV0XG4gICAgcHNidC51cGRhdGVJbnB1dChcbiAgICAgIGlucHV0SW5kZXgsXG4gICAgICBiaXRnby5nZXRQc2J0QmlwMzJEZXJpdmF0aW9uT3V0cHV0VXBkYXRlKHJvb3RXYWxsZXRLZXlzLCB3YWxsZXRLZXlzLCBiaXRnby5zY3JpcHRUeXBlRm9yQ2hhaW4oc2NyaXB0SWQuY2hhaW4pKVxuICAgICk7XG4gIH1cbn1cbiJdfQ==
@@ -0,0 +1,22 @@
1
+ import { Transaction, bitgo } from '@bitgo-beta/utxo-lib';
2
+ export declare const BIP322_TAG = "BIP0322-signed-message";
3
+ /**
4
+ * Perform a tagged hash
5
+ *
6
+ * @param {string | Buffer} message - The message to hash as a Buffer or utf-8 string
7
+ * @param {Buffer} [tag=BIP322_TAG] - The tag to use for hashing, defaults to BIP322_TAG.
8
+ * @returns {Buffer} - The resulting hash of the message with the tag.
9
+ */
10
+ export declare function hashMessageWithTag(message: string | Buffer, tag?: string): Buffer;
11
+ /**
12
+ * Build a BIP322 "to spend" transaction
13
+ * Source: https://github.com/bitcoin/bips/blob/master/bip-0322.mediawiki#full
14
+ *
15
+ * @param {Buffer} scriptPubKey - The scriptPubKey to use for the output
16
+ * @param {string | Buffer} message - The message to include in the transaction
17
+ * @param {Buffer} [tag=BIP322_TAG] - The tag to use for hashing, defaults to BIP322_TAG.
18
+ * @returns {Transaction} - The constructed transaction
19
+ */
20
+ export declare function buildToSpendTransaction(scriptPubKey: Buffer, message: string | Buffer, tag?: string): Transaction<bigint>;
21
+ export declare function buildToSpendTransactionFromChainAndIndex(rootWalletKeys: bitgo.RootWalletKeys, chain: bitgo.ChainCode, index: number, message: string | Buffer, tag?: string): Transaction<bigint>;
22
+ //# sourceMappingURL=toSpend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toSpend.d.ts","sourceRoot":"","sources":["../../../src/bip322/toSpend.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,WAAW,EAAE,KAAK,EAAY,MAAM,sBAAsB,CAAC;AAE1E,eAAO,MAAM,UAAU,2BAA2B,CAAC;AAEnD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAa,GAAG,MAAM,CAYrF;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,GAAG,SAAa,GACf,WAAW,CAAC,MAAM,CAAC,CA4BrB;AAED,wBAAgB,wCAAwC,CACtD,cAAc,EAAE,KAAK,CAAC,cAAc,EACpC,KAAK,EAAE,KAAK,CAAC,SAAS,EACtB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,GAAG,SAAa,GACf,WAAW,CAAC,MAAM,CAAC,CAOrB"}