utxo-lib 1.1.5 → 8.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of utxo-lib might be problematic. Click here for more details.

Files changed (250) hide show
  1. package/index.js +47 -0
  2. package/package.json +6 -80
  3. package/LICENSE +0 -21
  4. package/README.md +0 -59
  5. package/dist/src/address.d.ts +0 -11
  6. package/dist/src/address.d.ts.map +0 -1
  7. package/dist/src/address.js +0 -37
  8. package/dist/src/addressFormat.d.ts +0 -53
  9. package/dist/src/addressFormat.d.ts.map +0 -1
  10. package/dist/src/addressFormat.js +0 -110
  11. package/dist/src/bitgo/Musig2.d.ts +0 -51
  12. package/dist/src/bitgo/Musig2.d.ts.map +0 -1
  13. package/dist/src/bitgo/Musig2.js +0 -175
  14. package/dist/src/bitgo/Unspent.d.ts +0 -95
  15. package/dist/src/bitgo/Unspent.d.ts.map +0 -1
  16. package/dist/src/bitgo/Unspent.js +0 -138
  17. package/dist/src/bitgo/UtxoPsbt.d.ts +0 -132
  18. package/dist/src/bitgo/UtxoPsbt.d.ts.map +0 -1
  19. package/dist/src/bitgo/UtxoPsbt.js +0 -469
  20. package/dist/src/bitgo/UtxoTransaction.d.ts +0 -22
  21. package/dist/src/bitgo/UtxoTransaction.d.ts.map +0 -1
  22. package/dist/src/bitgo/UtxoTransaction.js +0 -97
  23. package/dist/src/bitgo/UtxoTransactionBuilder.d.ts +0 -26
  24. package/dist/src/bitgo/UtxoTransactionBuilder.d.ts.map +0 -1
  25. package/dist/src/bitgo/UtxoTransactionBuilder.js +0 -67
  26. package/dist/src/bitgo/bbc/DashPsbt.d.ts +0 -12
  27. package/dist/src/bitgo/bbc/DashPsbt.d.ts.map +0 -1
  28. package/dist/src/bitgo/bbc/DashPsbt.js +0 -27
  29. package/dist/src/bitgo/bbc/DashTransaction.d.ts +0 -39
  30. package/dist/src/bitgo/bbc/DashTransaction.d.ts.map +0 -1
  31. package/dist/src/bitgo/bbc/DashTransaction.js +0 -109
  32. package/dist/src/bitgo/bbc/DashTransactionBuilder.d.ts +0 -14
  33. package/dist/src/bitgo/bbc/DashTransactionBuilder.d.ts.map +0 -1
  34. package/dist/src/bitgo/bbc/DashTransactionBuilder.js +0 -28
  35. package/dist/src/bitgo/bbc/index.d.ts +0 -4
  36. package/dist/src/bitgo/bbc/index.d.ts.map +0 -1
  37. package/dist/src/bitgo/bbc/index.js +0 -16
  38. package/dist/src/bitgo/bitcoincash/address.d.ts +0 -35
  39. package/dist/src/bitgo/bitcoincash/address.d.ts.map +0 -1
  40. package/dist/src/bitgo/bitcoincash/address.js +0 -151
  41. package/dist/src/bitgo/bitcoincash/index.d.ts +0 -2
  42. package/dist/src/bitgo/bitcoincash/index.d.ts.map +0 -1
  43. package/dist/src/bitgo/bitcoincash/index.js +0 -14
  44. package/dist/src/bitgo/dash/DashPsbt.d.ts +0 -12
  45. package/dist/src/bitgo/dash/DashPsbt.d.ts.map +0 -1
  46. package/dist/src/bitgo/dash/DashPsbt.js +0 -27
  47. package/dist/src/bitgo/dash/DashTransaction.d.ts +0 -39
  48. package/dist/src/bitgo/dash/DashTransaction.d.ts.map +0 -1
  49. package/dist/src/bitgo/dash/DashTransaction.js +0 -109
  50. package/dist/src/bitgo/dash/DashTransactionBuilder.d.ts +0 -14
  51. package/dist/src/bitgo/dash/DashTransactionBuilder.d.ts.map +0 -1
  52. package/dist/src/bitgo/dash/DashTransactionBuilder.js +0 -28
  53. package/dist/src/bitgo/dash/index.d.ts +0 -4
  54. package/dist/src/bitgo/dash/index.d.ts.map +0 -1
  55. package/dist/src/bitgo/dash/index.js +0 -16
  56. package/dist/src/bitgo/index.d.ts +0 -17
  57. package/dist/src/bitgo/index.d.ts.map +0 -1
  58. package/dist/src/bitgo/index.js +0 -30
  59. package/dist/src/bitgo/keyutil.d.ts +0 -17
  60. package/dist/src/bitgo/keyutil.d.ts.map +0 -1
  61. package/dist/src/bitgo/keyutil.js +0 -37
  62. package/dist/src/bitgo/nonStandardHalfSigned.d.ts +0 -7
  63. package/dist/src/bitgo/nonStandardHalfSigned.d.ts.map +0 -1
  64. package/dist/src/bitgo/nonStandardHalfSigned.js +0 -56
  65. package/dist/src/bitgo/outputScripts.d.ts +0 -84
  66. package/dist/src/bitgo/outputScripts.d.ts.map +0 -1
  67. package/dist/src/bitgo/outputScripts.js +0 -297
  68. package/dist/src/bitgo/parseInput.d.ts +0 -92
  69. package/dist/src/bitgo/parseInput.d.ts.map +0 -1
  70. package/dist/src/bitgo/parseInput.js +0 -344
  71. package/dist/src/bitgo/psbt/fromHalfSigned.d.ts +0 -24
  72. package/dist/src/bitgo/psbt/fromHalfSigned.d.ts.map +0 -1
  73. package/dist/src/bitgo/psbt/fromHalfSigned.js +0 -91
  74. package/dist/src/bitgo/psbt/scriptTypes.d.ts +0 -6
  75. package/dist/src/bitgo/psbt/scriptTypes.d.ts.map +0 -1
  76. package/dist/src/bitgo/psbt/scriptTypes.js +0 -23
  77. package/dist/src/bitgo/signature.d.ts +0 -84
  78. package/dist/src/bitgo/signature.d.ts.map +0 -1
  79. package/dist/src/bitgo/signature.js +0 -222
  80. package/dist/src/bitgo/tnumber.d.ts +0 -9
  81. package/dist/src/bitgo/tnumber.d.ts.map +0 -1
  82. package/dist/src/bitgo/tnumber.js +0 -31
  83. package/dist/src/bitgo/transaction.d.ts +0 -29
  84. package/dist/src/bitgo/transaction.d.ts.map +0 -1
  85. package/dist/src/bitgo/transaction.js +0 -231
  86. package/dist/src/bitgo/types.d.ts +0 -5
  87. package/dist/src/bitgo/types.d.ts.map +0 -1
  88. package/dist/src/bitgo/types.js +0 -12
  89. package/dist/src/bitgo/wallet/Psbt.d.ts +0 -47
  90. package/dist/src/bitgo/wallet/Psbt.d.ts.map +0 -1
  91. package/dist/src/bitgo/wallet/Psbt.js +0 -232
  92. package/dist/src/bitgo/wallet/Unspent.d.ts +0 -47
  93. package/dist/src/bitgo/wallet/Unspent.d.ts.map +0 -1
  94. package/dist/src/bitgo/wallet/Unspent.js +0 -154
  95. package/dist/src/bitgo/wallet/WalletKeys.d.ts +0 -72
  96. package/dist/src/bitgo/wallet/WalletKeys.d.ts.map +0 -1
  97. package/dist/src/bitgo/wallet/WalletKeys.js +0 -104
  98. package/dist/src/bitgo/wallet/WalletOutput.d.ts +0 -18
  99. package/dist/src/bitgo/wallet/WalletOutput.d.ts.map +0 -1
  100. package/dist/src/bitgo/wallet/WalletOutput.js +0 -69
  101. package/dist/src/bitgo/wallet/WalletScripts.d.ts +0 -7
  102. package/dist/src/bitgo/wallet/WalletScripts.d.ts.map +0 -1
  103. package/dist/src/bitgo/wallet/WalletScripts.js +0 -15
  104. package/dist/src/bitgo/wallet/WalletUnspentSigner.d.ts +0 -19
  105. package/dist/src/bitgo/wallet/WalletUnspentSigner.d.ts.map +0 -1
  106. package/dist/src/bitgo/wallet/WalletUnspentSigner.js +0 -47
  107. package/dist/src/bitgo/wallet/chains.d.ts +0 -57
  108. package/dist/src/bitgo/wallet/chains.d.ts.map +0 -1
  109. package/dist/src/bitgo/wallet/chains.js +0 -106
  110. package/dist/src/bitgo/wallet/index.d.ts +0 -8
  111. package/dist/src/bitgo/wallet/index.d.ts.map +0 -1
  112. package/dist/src/bitgo/wallet/index.js +0 -20
  113. package/dist/src/bitgo/zcash/ZcashBufferutils.d.ts +0 -26
  114. package/dist/src/bitgo/zcash/ZcashBufferutils.d.ts.map +0 -1
  115. package/dist/src/bitgo/zcash/ZcashBufferutils.js +0 -157
  116. package/dist/src/bitgo/zcash/ZcashPsbt.d.ts +0 -36
  117. package/dist/src/bitgo/zcash/ZcashPsbt.d.ts.map +0 -1
  118. package/dist/src/bitgo/zcash/ZcashPsbt.js +0 -146
  119. package/dist/src/bitgo/zcash/ZcashTransaction.d.ts +0 -61
  120. package/dist/src/bitgo/zcash/ZcashTransaction.d.ts.map +0 -1
  121. package/dist/src/bitgo/zcash/ZcashTransaction.js +0 -341
  122. package/dist/src/bitgo/zcash/ZcashTransactionBuilder.d.ts +0 -21
  123. package/dist/src/bitgo/zcash/ZcashTransactionBuilder.d.ts.map +0 -1
  124. package/dist/src/bitgo/zcash/ZcashTransactionBuilder.js +0 -105
  125. package/dist/src/bitgo/zcash/address.d.ts +0 -8
  126. package/dist/src/bitgo/zcash/address.d.ts.map +0 -1
  127. package/dist/src/bitgo/zcash/address.js +0 -57
  128. package/dist/src/bitgo/zcash/hashZip0244.d.ts +0 -27
  129. package/dist/src/bitgo/zcash/hashZip0244.d.ts.map +0 -1
  130. package/dist/src/bitgo/zcash/hashZip0244.js +0 -184
  131. package/dist/src/bitgo/zcash/index.d.ts +0 -4
  132. package/dist/src/bitgo/zcash/index.d.ts.map +0 -1
  133. package/dist/src/bitgo/zcash/index.js +0 -16
  134. package/dist/src/classify.d.ts +0 -19
  135. package/dist/src/classify.d.ts.map +0 -1
  136. package/dist/src/classify.js +0 -89
  137. package/dist/src/index.d.ts +0 -13
  138. package/dist/src/index.d.ts.map +0 -1
  139. package/dist/src/index.js +0 -36
  140. package/dist/src/networks.d.ts +0 -115
  141. package/dist/src/networks.d.ts.map +0 -1
  142. package/dist/src/networks.js +0 -458
  143. package/dist/src/noble_ecc.d.ts +0 -28
  144. package/dist/src/noble_ecc.d.ts.map +0 -1
  145. package/dist/src/noble_ecc.js +0 -168
  146. package/dist/src/payments/index.d.ts +0 -4
  147. package/dist/src/payments/index.d.ts.map +0 -1
  148. package/dist/src/payments/index.js +0 -8
  149. package/dist/src/payments/p2tr.d.ts +0 -3
  150. package/dist/src/payments/p2tr.d.ts.map +0 -1
  151. package/dist/src/payments/p2tr.js +0 -348
  152. package/dist/src/payments/p2tr_ns.d.ts +0 -3
  153. package/dist/src/payments/p2tr_ns.d.ts.map +0 -1
  154. package/dist/src/payments/p2tr_ns.js +0 -134
  155. package/dist/src/taproot.d.ts +0 -141
  156. package/dist/src/taproot.d.ts.map +0 -1
  157. package/dist/src/taproot.js +0 -384
  158. package/dist/src/templates/multisig/index.d.ts +0 -4
  159. package/dist/src/templates/multisig/index.d.ts.map +0 -1
  160. package/dist/src/templates/multisig/index.js +0 -8
  161. package/dist/src/templates/multisig/input.d.ts +0 -7
  162. package/dist/src/templates/multisig/input.d.ts.map +0 -1
  163. package/dist/src/templates/multisig/input.js +0 -25
  164. package/dist/src/templates/multisig/output.d.ts +0 -7
  165. package/dist/src/templates/multisig/output.d.ts.map +0 -1
  166. package/dist/src/templates/multisig/output.js +0 -38
  167. package/dist/src/templates/nulldata.d.ts +0 -10
  168. package/dist/src/templates/nulldata.d.ts.map +0 -1
  169. package/dist/src/templates/nulldata.js +0 -17
  170. package/dist/src/templates/pubkey/index.d.ts +0 -4
  171. package/dist/src/templates/pubkey/index.d.ts.map +0 -1
  172. package/dist/src/templates/pubkey/index.js +0 -8
  173. package/dist/src/templates/pubkey/input.d.ts +0 -7
  174. package/dist/src/templates/pubkey/input.d.ts.map +0 -1
  175. package/dist/src/templates/pubkey/input.js +0 -14
  176. package/dist/src/templates/pubkey/output.d.ts +0 -7
  177. package/dist/src/templates/pubkey/output.d.ts.map +0 -1
  178. package/dist/src/templates/pubkey/output.js +0 -15
  179. package/dist/src/templates/pubkeyhash/index.d.ts +0 -4
  180. package/dist/src/templates/pubkeyhash/index.d.ts.map +0 -1
  181. package/dist/src/templates/pubkeyhash/index.js +0 -8
  182. package/dist/src/templates/pubkeyhash/input.d.ts +0 -7
  183. package/dist/src/templates/pubkeyhash/input.d.ts.map +0 -1
  184. package/dist/src/templates/pubkeyhash/input.js +0 -16
  185. package/dist/src/templates/pubkeyhash/output.d.ts +0 -6
  186. package/dist/src/templates/pubkeyhash/output.d.ts.map +0 -1
  187. package/dist/src/templates/pubkeyhash/output.js +0 -20
  188. package/dist/src/templates/scripthash/index.d.ts +0 -4
  189. package/dist/src/templates/scripthash/index.d.ts.map +0 -1
  190. package/dist/src/templates/scripthash/index.js +0 -8
  191. package/dist/src/templates/scripthash/input.d.ts +0 -6
  192. package/dist/src/templates/scripthash/input.d.ts.map +0 -1
  193. package/dist/src/templates/scripthash/input.js +0 -43
  194. package/dist/src/templates/scripthash/output.d.ts +0 -6
  195. package/dist/src/templates/scripthash/output.d.ts.map +0 -1
  196. package/dist/src/templates/scripthash/output.js +0 -15
  197. package/dist/src/templates/taproot/index.d.ts +0 -4
  198. package/dist/src/templates/taproot/index.d.ts.map +0 -1
  199. package/dist/src/templates/taproot/index.js +0 -8
  200. package/dist/src/templates/taproot/input.d.ts +0 -6
  201. package/dist/src/templates/taproot/input.d.ts.map +0 -1
  202. package/dist/src/templates/taproot/input.js +0 -23
  203. package/dist/src/templates/taproot/output.d.ts +0 -6
  204. package/dist/src/templates/taproot/output.d.ts.map +0 -1
  205. package/dist/src/templates/taproot/output.js +0 -15
  206. package/dist/src/templates/taprootnofn/index.d.ts +0 -4
  207. package/dist/src/templates/taprootnofn/index.d.ts.map +0 -1
  208. package/dist/src/templates/taprootnofn/index.js +0 -8
  209. package/dist/src/templates/taprootnofn/input.d.ts +0 -7
  210. package/dist/src/templates/taprootnofn/input.d.ts.map +0 -1
  211. package/dist/src/templates/taprootnofn/input.js +0 -24
  212. package/dist/src/templates/taprootnofn/output.d.ts +0 -7
  213. package/dist/src/templates/taprootnofn/output.d.ts.map +0 -1
  214. package/dist/src/templates/taprootnofn/output.js +0 -28
  215. package/dist/src/templates/witnesscommitment/index.d.ts +0 -3
  216. package/dist/src/templates/witnesscommitment/index.d.ts.map +0 -1
  217. package/dist/src/templates/witnesscommitment/index.js +0 -6
  218. package/dist/src/templates/witnesscommitment/output.d.ts +0 -8
  219. package/dist/src/templates/witnesscommitment/output.d.ts.map +0 -1
  220. package/dist/src/templates/witnesscommitment/output.js +0 -31
  221. package/dist/src/templates/witnesspubkeyhash/index.d.ts +0 -4
  222. package/dist/src/templates/witnesspubkeyhash/index.d.ts.map +0 -1
  223. package/dist/src/templates/witnesspubkeyhash/index.js +0 -8
  224. package/dist/src/templates/witnesspubkeyhash/input.d.ts +0 -7
  225. package/dist/src/templates/witnesspubkeyhash/input.d.ts.map +0 -1
  226. package/dist/src/templates/witnesspubkeyhash/input.js +0 -19
  227. package/dist/src/templates/witnesspubkeyhash/output.d.ts +0 -6
  228. package/dist/src/templates/witnesspubkeyhash/output.d.ts.map +0 -1
  229. package/dist/src/templates/witnesspubkeyhash/output.js +0 -15
  230. package/dist/src/templates/witnessscripthash/index.d.ts +0 -4
  231. package/dist/src/templates/witnessscripthash/index.d.ts.map +0 -1
  232. package/dist/src/templates/witnessscripthash/index.js +0 -8
  233. package/dist/src/templates/witnessscripthash/input.d.ts +0 -6
  234. package/dist/src/templates/witnessscripthash/input.d.ts.map +0 -1
  235. package/dist/src/templates/witnessscripthash/input.js +0 -35
  236. package/dist/src/templates/witnessscripthash/output.d.ts +0 -6
  237. package/dist/src/templates/witnessscripthash/output.d.ts.map +0 -1
  238. package/dist/src/templates/witnessscripthash/output.js +0 -15
  239. package/dist/src/testutil/index.d.ts +0 -3
  240. package/dist/src/testutil/index.d.ts.map +0 -1
  241. package/dist/src/testutil/index.js +0 -15
  242. package/dist/src/testutil/keys.d.ts +0 -10
  243. package/dist/src/testutil/keys.d.ts.map +0 -1
  244. package/dist/src/testutil/keys.js +0 -40
  245. package/dist/src/testutil/mock.d.ts +0 -21
  246. package/dist/src/testutil/mock.d.ts.map +0 -1
  247. package/dist/src/testutil/mock.js +0 -86
  248. package/dist/src/transaction_builder.d.ts +0 -47
  249. package/dist/src/transaction_builder.d.ts.map +0 -1
  250. package/dist/src/transaction_builder.js +0 -1084
@@ -1,84 +0,0 @@
1
- /// <reference types="node" />
2
- import { BIP32Interface } from 'bip32';
3
- import { TxOutput } from 'bitcoinjs-lib';
4
- import { UtxoTransaction } from './UtxoTransaction';
5
- import { UtxoTransactionBuilder } from './UtxoTransactionBuilder';
6
- import { ScriptType2Of3 } from './outputScripts';
7
- import { Triple } from './types';
8
- import { Network } from '../networks';
9
- /**
10
- * Constraints for signature verifications.
11
- * Parameters are conjunctive: if multiple parameters are set, a verification for an individual
12
- * signature must satisfy all of them.
13
- */
14
- export declare type VerificationSettings = {
15
- /**
16
- * The index of the signature to verify. Only iterates over non-empty signatures.
17
- */
18
- signatureIndex?: number;
19
- /**
20
- * The public key to verify.
21
- */
22
- publicKey?: Buffer;
23
- };
24
- /**
25
- * Result for a individual signature verification
26
- */
27
- export declare type SignatureVerification = {
28
- /** Set to the public key that signed for the signature */
29
- signedBy: Buffer;
30
- /** Set to the signature buffer */
31
- signature: Buffer;
32
- } | {
33
- signedBy: undefined;
34
- signature: undefined;
35
- };
36
- /**
37
- * @deprecated - use {@see verifySignaturesWithPublicKeys} instead
38
- * Get signature verifications for multsig transaction
39
- * @param transaction
40
- * @param inputIndex
41
- * @param amount - must be set for segwit transactions and BIP143 transactions
42
- * @param verificationSettings
43
- * @param prevOutputs - must be set for p2tr transactions
44
- * @returns SignatureVerification[] - in order of parsed non-empty signatures
45
- */
46
- export declare function getSignatureVerifications<TNumber extends number | bigint>(transaction: UtxoTransaction<TNumber>, inputIndex: number, amount: TNumber, verificationSettings?: VerificationSettings, prevOutputs?: TxOutput<TNumber>[]): SignatureVerification[];
47
- /**
48
- * @deprecated use {@see verifySignatureWithPublicKeys} instead
49
- * @param transaction
50
- * @param inputIndex
51
- * @param amount
52
- * @param verificationSettings - if publicKey is specified, returns true iff any signature is signed by publicKey.
53
- * @param prevOutputs - must be set for p2tr transactions
54
- */
55
- export declare function verifySignature<TNumber extends number | bigint>(transaction: UtxoTransaction<TNumber>, inputIndex: number, amount: TNumber, verificationSettings?: VerificationSettings, prevOutputs?: TxOutput<TNumber>[]): boolean;
56
- /**
57
- * @param transaction
58
- * @param inputIndex
59
- * @param prevOutputs
60
- * @param publicKeys
61
- * @return array with signature corresponding to n-th key, undefined if no match found
62
- */
63
- export declare function getSignaturesWithPublicKeys<TNumber extends number | bigint>(transaction: UtxoTransaction<TNumber>, inputIndex: number, prevOutputs: TxOutput<TNumber>[], publicKeys: Buffer[]): Array<Buffer | undefined>;
64
- /**
65
- * @param transaction
66
- * @param inputIndex
67
- * @param prevOutputs - transaction outputs for inputs
68
- * @param publicKeys - public keys to check signatures for
69
- * @return array of booleans indicating a valid signature for every pubkey in _publicKeys_
70
- */
71
- export declare function verifySignatureWithPublicKeys<TNumber extends number | bigint>(transaction: UtxoTransaction<TNumber>, inputIndex: number, prevOutputs: TxOutput<TNumber>[], publicKeys: Buffer[]): boolean[];
72
- /**
73
- * Wrapper for {@see verifySignatureWithPublicKeys} for single pubkey
74
- * @param transaction
75
- * @param inputIndex
76
- * @param prevOutputs
77
- * @param publicKey
78
- * @return true iff signature is valid
79
- */
80
- export declare function verifySignatureWithPublicKey<TNumber extends number | bigint>(transaction: UtxoTransaction<TNumber>, inputIndex: number, prevOutputs: TxOutput<TNumber>[], publicKey: Buffer): boolean;
81
- export declare function getDefaultSigHash(network: Network, scriptType?: ScriptType2Of3): number;
82
- export declare function signInputP2shP2pk<TNumber extends number | bigint>(txBuilder: UtxoTransactionBuilder<TNumber>, vin: number, keyPair: BIP32Interface): void;
83
- export declare function signInput2Of3<TNumber extends number | bigint>(txBuilder: UtxoTransactionBuilder<TNumber>, vin: number, scriptType: ScriptType2Of3, pubkeys: Triple<Buffer>, keyPair: BIP32Interface, cosigner: Buffer, amount: TNumber): void;
84
- //# sourceMappingURL=signature.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../../src/bitgo/signature.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAwB,QAAQ,EAAmB,MAAM,eAAe,CAAC;AAEhF,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAIL,cAAc,EAEf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAc,OAAO,EAAY,MAAM,aAAa,CAAC;AAI5D;;;;GAIG;AACH,oBAAY,oBAAoB,GAAG;IACjC;;OAEG;IACH,cAAc,CAAC,EAAE,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C,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,EAChC,UAAU,EAAE,MAAM,EAAE,GACnB,OAAO,EAAE,CAEX;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EAC1E,WAAW,EAAE,eAAe,CAAC,OAAO,CAAC,EACrC,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,EAChC,SAAS,EAAE,MAAM,GAChB,OAAO,CAET;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,EAAE,cAAc,GAAG,MAAM,CAUvF;AAED,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EAC/D,SAAS,EAAE,sBAAsB,CAAC,OAAO,CAAC,EAC1C,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,cAAc,GACtB,IAAI,CAcN;AAED,wBAAgB,aAAa,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EAC3D,SAAS,EAAE,sBAAsB,CAAC,OAAO,CAAC,EAC1C,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,cAAc,EAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EACvB,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,OAAO,GACd,IAAI,CAwBN"}
@@ -1,222 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.signInput2Of3 = exports.signInputP2shP2pk = exports.getDefaultSigHash = exports.verifySignatureWithPublicKey = exports.verifySignatureWithPublicKeys = exports.getSignaturesWithPublicKeys = exports.verifySignature = exports.getSignatureVerifications = void 0;
4
- const bitcoinjs_lib_1 = require("bitcoinjs-lib");
5
- const UtxoTransaction_1 = require("./UtxoTransaction");
6
- const outputScripts_1 = require("./outputScripts");
7
- const networks_1 = require("../networks");
8
- const noble_ecc_1 = require("../noble_ecc");
9
- const parseInput_1 = require("./parseInput");
10
- /**
11
- * @deprecated - use {@see verifySignaturesWithPublicKeys} instead
12
- * Get signature verifications for multsig transaction
13
- * @param transaction
14
- * @param inputIndex
15
- * @param amount - must be set for segwit transactions and BIP143 transactions
16
- * @param verificationSettings
17
- * @param prevOutputs - must be set for p2tr transactions
18
- * @returns SignatureVerification[] - in order of parsed non-empty signatures
19
- */
20
- function getSignatureVerifications(transaction, inputIndex, amount, verificationSettings = {}, prevOutputs) {
21
- /* istanbul ignore next */
22
- if (!transaction.ins) {
23
- throw new Error(`invalid transaction`);
24
- }
25
- const input = transaction.ins[inputIndex];
26
- /* istanbul ignore next */
27
- if (!input) {
28
- throw new Error(`no input at index ${inputIndex}`);
29
- }
30
- if ((!input.script || input.script.length === 0) && input.witness.length === 0) {
31
- // Unsigned input: no signatures.
32
- return [];
33
- }
34
- const parsedScript = parseInput_1.parseSignatureScript2Of3(input);
35
- const signatures = parsedScript.signatures
36
- .filter((s) => s && s.length)
37
- .filter((s, i) => verificationSettings.signatureIndex === undefined || verificationSettings.signatureIndex === i);
38
- const publicKeys = parsedScript.publicKeys.filter((buf) => verificationSettings.publicKey === undefined ||
39
- verificationSettings.publicKey.equals(buf) ||
40
- verificationSettings.publicKey.slice(1).equals(buf));
41
- return signatures.map((signatureBuffer) => {
42
- if (signatureBuffer === 0 || signatureBuffer.length === 0) {
43
- return { signedBy: undefined, signature: undefined };
44
- }
45
- let hashType = bitcoinjs_lib_1.Transaction.SIGHASH_DEFAULT;
46
- if (signatureBuffer.length === 65) {
47
- hashType = signatureBuffer[signatureBuffer.length - 1];
48
- signatureBuffer = signatureBuffer.slice(0, -1);
49
- }
50
- if (parsedScript.scriptType === 'p2tr') {
51
- if (verificationSettings.signatureIndex !== undefined) {
52
- throw new Error(`signatureIndex parameter not supported for p2tr`);
53
- }
54
- if (!prevOutputs) {
55
- throw new Error(`prevOutputs not set`);
56
- }
57
- if (prevOutputs.length !== transaction.ins.length) {
58
- throw new Error(`prevOutputs length ${prevOutputs.length}, expected ${transaction.ins.length}`);
59
- }
60
- if (!('controlBlock' in parsedScript)) {
61
- throw new Error('expected controlBlock');
62
- }
63
- const { controlBlock, pubScript } = parsedScript;
64
- const leafHash = bitcoinjs_lib_1.taproot.getTapleafHash(noble_ecc_1.ecc, controlBlock, pubScript);
65
- const signatureHash = transaction.hashForWitnessV1(inputIndex, prevOutputs.map(({ script }) => script), prevOutputs.map(({ value }) => value), hashType, leafHash);
66
- const signedBy = publicKeys.filter((k) => Buffer.isBuffer(signatureBuffer) && noble_ecc_1.ecc.verifySchnorr(signatureHash, k, signatureBuffer));
67
- if (signedBy.length === 0) {
68
- return { signedBy: undefined, signature: undefined };
69
- }
70
- if (signedBy.length === 1) {
71
- return { signedBy: signedBy[0], signature: signatureBuffer };
72
- }
73
- throw new Error(`illegal state: signed by multiple public keys`);
74
- }
75
- else {
76
- // slice the last byte from the signature hash input because it's the hash type
77
- const { signature, hashType } = bitcoinjs_lib_1.ScriptSignature.decode(signatureBuffer);
78
- const transactionHash = parsedScript.scriptType === 'p2shP2wsh' || parsedScript.scriptType === 'p2wsh'
79
- ? transaction.hashForWitnessV0(inputIndex, parsedScript.pubScript, amount, hashType)
80
- : transaction.hashForSignatureByNetwork(inputIndex, parsedScript.pubScript, amount, hashType);
81
- const signedBy = publicKeys.filter((publicKey) => noble_ecc_1.ecc.verify(transactionHash, publicKey, signature,
82
- /*
83
- Strict verification (require lower-S value), as required by BIP-0146
84
- https://github.com/bitcoin/bips/blob/master/bip-0146.mediawiki
85
- https://github.com/bitcoin-core/secp256k1/blob/ac83be33/include/secp256k1.h#L478-L508
86
- https://github.com/bitcoinjs/tiny-secp256k1/blob/v1.1.6/js.js#L231-L233
87
- */
88
- true));
89
- if (signedBy.length === 0) {
90
- return { signedBy: undefined, signature: undefined };
91
- }
92
- if (signedBy.length === 1) {
93
- return { signedBy: signedBy[0], signature: signatureBuffer };
94
- }
95
- throw new Error(`illegal state: signed by multiple public keys`);
96
- }
97
- });
98
- }
99
- exports.getSignatureVerifications = getSignatureVerifications;
100
- /**
101
- * @deprecated use {@see verifySignatureWithPublicKeys} instead
102
- * @param transaction
103
- * @param inputIndex
104
- * @param amount
105
- * @param verificationSettings - if publicKey is specified, returns true iff any signature is signed by publicKey.
106
- * @param prevOutputs - must be set for p2tr transactions
107
- */
108
- function verifySignature(transaction, inputIndex, amount, verificationSettings = {}, prevOutputs) {
109
- const signatureVerifications = getSignatureVerifications(transaction, inputIndex, amount, verificationSettings, prevOutputs).filter((v) =>
110
- // If no publicKey is set in verificationSettings, all signatures must be valid.
111
- // Otherwise, a single valid signature by the specified pubkey is sufficient.
112
- verificationSettings.publicKey === undefined ||
113
- (v.signedBy !== undefined &&
114
- (verificationSettings.publicKey.equals(v.signedBy) ||
115
- verificationSettings.publicKey.slice(1).equals(v.signedBy))));
116
- return signatureVerifications.length > 0 && signatureVerifications.every((v) => v.signedBy !== undefined);
117
- }
118
- exports.verifySignature = verifySignature;
119
- /**
120
- * @param v
121
- * @param publicKey
122
- * @return true iff signature is by publicKey (or xonly variant of publicKey)
123
- */
124
- function isSignatureByPublicKey(v, publicKey) {
125
- return (!!v.signedBy &&
126
- (v.signedBy.equals(publicKey) ||
127
- /* for p2tr signatures, we pass the pubkey in 33-byte format recover it from the signature in 32-byte format */
128
- (publicKey.length === 33 && isSignatureByPublicKey(v, publicKey.slice(1)))));
129
- }
130
- /**
131
- * @param transaction
132
- * @param inputIndex
133
- * @param prevOutputs
134
- * @param publicKeys
135
- * @return array with signature corresponding to n-th key, undefined if no match found
136
- */
137
- function getSignaturesWithPublicKeys(transaction, inputIndex, prevOutputs, publicKeys) {
138
- if (transaction.ins.length !== prevOutputs.length) {
139
- throw new Error(`input length must match prevOutputs length`);
140
- }
141
- const signatureVerifications = getSignatureVerifications(transaction, inputIndex, prevOutputs[inputIndex].value, {}, prevOutputs);
142
- return publicKeys.map((publicKey) => {
143
- const v = signatureVerifications.find((v) => isSignatureByPublicKey(v, publicKey));
144
- return v ? v.signature : undefined;
145
- });
146
- }
147
- exports.getSignaturesWithPublicKeys = getSignaturesWithPublicKeys;
148
- /**
149
- * @param transaction
150
- * @param inputIndex
151
- * @param prevOutputs - transaction outputs for inputs
152
- * @param publicKeys - public keys to check signatures for
153
- * @return array of booleans indicating a valid signature for every pubkey in _publicKeys_
154
- */
155
- function verifySignatureWithPublicKeys(transaction, inputIndex, prevOutputs, publicKeys) {
156
- return getSignaturesWithPublicKeys(transaction, inputIndex, prevOutputs, publicKeys).map((s) => s !== undefined);
157
- }
158
- exports.verifySignatureWithPublicKeys = verifySignatureWithPublicKeys;
159
- /**
160
- * Wrapper for {@see verifySignatureWithPublicKeys} for single pubkey
161
- * @param transaction
162
- * @param inputIndex
163
- * @param prevOutputs
164
- * @param publicKey
165
- * @return true iff signature is valid
166
- */
167
- function verifySignatureWithPublicKey(transaction, inputIndex, prevOutputs, publicKey) {
168
- return verifySignatureWithPublicKeys(transaction, inputIndex, prevOutputs, [publicKey])[0];
169
- }
170
- exports.verifySignatureWithPublicKey = verifySignatureWithPublicKey;
171
- function getDefaultSigHash(network, scriptType) {
172
- switch (networks_1.getMainnet(network)) {
173
- case networks_1.networks.bitcoincash:
174
- case networks_1.networks.bitcoinsv:
175
- case networks_1.networks.bitcoingold:
176
- case networks_1.networks.ecash:
177
- return bitcoinjs_lib_1.Transaction.SIGHASH_ALL | UtxoTransaction_1.UtxoTransaction.SIGHASH_FORKID;
178
- default:
179
- return scriptType === 'p2tr' ? bitcoinjs_lib_1.Transaction.SIGHASH_DEFAULT : bitcoinjs_lib_1.Transaction.SIGHASH_ALL;
180
- }
181
- }
182
- exports.getDefaultSigHash = getDefaultSigHash;
183
- function signInputP2shP2pk(txBuilder, vin, keyPair) {
184
- const prevOutScriptType = 'p2sh-p2pk';
185
- const { redeemScript, witnessScript } = outputScripts_1.createOutputScriptP2shP2pk(keyPair.publicKey);
186
- keyPair.network = txBuilder.network;
187
- txBuilder.sign({
188
- vin,
189
- prevOutScriptType,
190
- keyPair,
191
- hashType: getDefaultSigHash(txBuilder.network),
192
- redeemScript,
193
- witnessScript,
194
- witnessValue: undefined,
195
- });
196
- }
197
- exports.signInputP2shP2pk = signInputP2shP2pk;
198
- function signInput2Of3(txBuilder, vin, scriptType, pubkeys, keyPair, cosigner, amount) {
199
- let controlBlock;
200
- let redeemScript;
201
- let witnessScript;
202
- const prevOutScriptType = outputScripts_1.scriptType2Of3AsPrevOutType(scriptType);
203
- if (scriptType === 'p2tr') {
204
- ({ witnessScript, controlBlock } = outputScripts_1.createSpendScriptP2tr(pubkeys, [keyPair.publicKey, cosigner]));
205
- }
206
- else {
207
- ({ redeemScript, witnessScript } = outputScripts_1.createOutputScript2of3(pubkeys, scriptType));
208
- }
209
- keyPair.network = txBuilder.network;
210
- txBuilder.sign({
211
- vin,
212
- prevOutScriptType,
213
- keyPair,
214
- hashType: getDefaultSigHash(txBuilder.network, scriptType),
215
- redeemScript,
216
- witnessScript,
217
- witnessValue: amount,
218
- controlBlock,
219
- });
220
- }
221
- exports.signInput2Of3 = signInput2Of3;
222
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2lnbmF0dXJlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2JpdGdvL3NpZ25hdHVyZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFFQSxpREFBZ0Y7QUFFaEYsdURBQW9EO0FBRXBELG1EQU15QjtBQUV6QiwwQ0FBNEQ7QUFDNUQsNENBQTZDO0FBQzdDLDZDQUF3RDtBQThCeEQ7Ozs7Ozs7OztHQVNHO0FBQ0gsU0FBZ0IseUJBQXlCLENBQ3ZDLFdBQXFDLEVBQ3JDLFVBQWtCLEVBQ2xCLE1BQWUsRUFDZix1QkFBNkMsRUFBRSxFQUMvQyxXQUFpQztJQUVqQywwQkFBMEI7SUFDMUIsSUFB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25lcl0pKTtcbiAgfSBlbHNlIHtcbiAgICAoeyByZWRlZW1TY3JpcHQsIHdpdG5lc3NTY3JpcHQgfSA9IGNyZWF0ZU91dHB1dFNjcmlwdDJvZjMocHVia2V5cywgc2NyaXB0VHlwZSkpO1xuICB9XG5cbiAga2V5UGFpci5uZXR3b3JrID0gdHhCdWlsZGVyLm5ldHdvcms7XG5cbiAgdHhCdWlsZGVyLnNpZ24oe1xuICAgIHZpbixcbiAgICBwcmV2T3V0U2NyaXB0VHlwZSxcbiAgICBrZXlQYWlyLFxuICAgIGhhc2hUeXBlOiBnZXREZWZhdWx0U2lnSGFzaCh0eEJ1aWxkZXIubmV0d29yayBhcyBOZXR3b3JrLCBzY3JpcHRUeXBlKSxcbiAgICByZWRlZW1TY3JpcHQsXG4gICAgd2l0bmVzc1NjcmlwdCxcbiAgICB3aXRuZXNzVmFsdWU6IGFtb3VudCxcbiAgICBjb250cm9sQmxvY2ssXG4gIH0pO1xufVxuIl19
@@ -1,9 +0,0 @@
1
- /**
2
- * Convert input to bigint or number.
3
- * Throws error if input cannot be converted to a safe integer number.
4
- * @param value - input value
5
- * @param amountType - desired output type
6
- * @return value converted to amountType
7
- */
8
- export declare function toTNumber<TNumber extends number | bigint>(value: number | bigint | string, amountType: 'number' | 'bigint'): TNumber;
9
- //# sourceMappingURL=tnumber.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tnumber.d.ts","sourceRoot":"","sources":["../../../src/bitgo/tnumber.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EACvD,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC/B,UAAU,EAAE,QAAQ,GAAG,QAAQ,GAC9B,OAAO,CAkBT"}
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toTNumber = void 0;
4
- /**
5
- * Convert input to bigint or number.
6
- * Throws error if input cannot be converted to a safe integer number.
7
- * @param value - input value
8
- * @param amountType - desired output type
9
- * @return value converted to amountType
10
- */
11
- function toTNumber(value, amountType) {
12
- if (typeof value === amountType) {
13
- return value;
14
- }
15
- if (value === undefined) {
16
- throw new Error('input value cannot be undefined');
17
- }
18
- if (amountType === 'number') {
19
- const numberValue = Number(value);
20
- if (!Number.isSafeInteger(numberValue)) {
21
- throw new Error('input value cannot be converted to safe integer number');
22
- }
23
- return Number(value);
24
- }
25
- if (amountType === 'bigint') {
26
- return BigInt(value);
27
- }
28
- throw new Error('amountType must be either "number" or "bigint"');
29
- }
30
- exports.toTNumber = toTNumber;
31
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG51bWJlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9iaXRnby90bnVtYmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBOzs7Ozs7R0FNRztBQUNILFNBQWdCLFNBQVMsQ0FDdkIsS0FBK0IsRUFDL0IsVUFBK0I7SUFFL0IsSUFBSSxPQUFPLEtBQUssS0FBSyxVQUFVLEVBQUU7UUFDL0IsT0FBTyxLQUFnQixDQUFDO0tBQ3pCO0lBQ0QsSUFBSSxLQUFLLEtBQUssU0FBUyxFQUFFO1FBQ3ZCLE1BQU0sSUFBSSxLQUFLLENBQUMsaUNBQWlDLENBQUMsQ0FBQztLQUNwRDtJQUNELElBQUksVUFBVSxLQUFLLFFBQVEsRUFBRTtRQUMzQixNQUFNLFdBQVcsR0FBRyxNQUFNLENBQUMsS0FBSyxDQUFDLENBQUM7UUFDbEMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxhQUFhLENBQUMsV0FBVyxDQUFDLEVBQUU7WUFDdEMsTUFBTSxJQUFJLEtBQUssQ0FBQyx3REFBd0QsQ0FBQyxDQUFDO1NBQzNFO1FBQ0QsT0FBTyxNQUFNLENBQU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1NhZmVJbnRlZ2VyKG51bWJlclZhbHVlKSkge1xuICAgICAgdGhyb3cgbmV3IEVycm9yKCdpbnB1dCB2YWx1ZSBjYW5ub3QgYmUgY29udmVydGVkIHRvIHNhZmUgaW50ZWdlciBudW1iZXInKTtcbiAgICB9XG4gICAgcmV0dXJuIE51bWJlcih2YWx1ZSkgYXMgVE51bWJlcjtcbiAgfVxuICBpZiAoYW1vdW50VHlwZSA9PT0gJ2JpZ2ludCcpIHtcbiAgICByZXR1cm4gQmlnSW50KHZhbHVlKSBhcyBUTnVtYmVyO1xuICB9XG4gIHRocm93IG5ldyBFcnJvcignYW1vdW50VHlwZSBtdXN0IGJlIGVpdGhlciBcIm51bWJlclwiIG9yIFwiYmlnaW50XCInKTtcbn1cbiJdfQ==
@@ -1,29 +0,0 @@
1
- /// <reference types="node" />
2
- import { TxOutput } from 'bitcoinjs-lib';
3
- import { Network } from '../networks';
4
- import { UtxoPsbt, PsbtOpts } from './UtxoPsbt';
5
- import { UtxoTransaction } from './UtxoTransaction';
6
- import { UtxoTransactionBuilder } from './UtxoTransactionBuilder';
7
- export declare function createTransactionFromBuffer<TNumber extends number | bigint = number>(buf: Buffer, network: Network, { version, amountType }?: {
8
- version?: number;
9
- amountType?: 'number' | 'bigint';
10
- }, deprecatedAmountType?: 'number' | 'bigint'): UtxoTransaction<TNumber>;
11
- export declare function createPsbtFromBuffer(buf: Buffer, network: Network, bip32PathsAbsolute?: boolean): UtxoPsbt;
12
- export declare function createPsbtFromHex(hex: string, network: Network, bip32PathsAbsolute?: boolean): UtxoPsbt;
13
- export declare function createPsbtFromTransaction(tx: UtxoTransaction<bigint>, prevOuts: TxOutput<bigint>[]): UtxoPsbt;
14
- export declare function createTransactionFromHex<TNumber extends number | bigint = number>(hex: string, network: Network, amountType?: 'number' | 'bigint'): UtxoTransaction<TNumber>;
15
- export declare function getDefaultTransactionVersion(network: Network): number;
16
- export declare function setTransactionBuilderDefaults<TNumber extends number | bigint>(txb: UtxoTransactionBuilder<TNumber>, network: Network, { version }?: {
17
- version?: number;
18
- }): void;
19
- export declare function setPsbtDefaults(psbt: UtxoPsbt, network: Network, { version }?: {
20
- version?: number;
21
- }): void;
22
- export declare function createPsbtForNetwork(psbtOpts: PsbtOpts, { version }?: {
23
- version?: number;
24
- }): UtxoPsbt;
25
- export declare function createTransactionBuilderForNetwork<TNumber extends number | bigint = number>(network: Network, { version }?: {
26
- version?: number;
27
- }): UtxoTransactionBuilder<TNumber>;
28
- export declare function createTransactionBuilderFromTransaction<TNumber extends number | bigint>(tx: UtxoTransaction<TNumber>, prevOutputs?: TxOutput<TNumber>[]): UtxoTransactionBuilder<TNumber>;
29
- //# sourceMappingURL=transaction.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../src/bitgo/transaction.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAY,OAAO,EAAc,MAAM,aAAa,CAAC;AAE5D,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAQlE,wBAAgB,2BAA2B,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAClF,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,OAAO,EAChB,EAAE,OAAO,EAAE,UAAU,EAAE,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAA;CAAO,EACpF,oBAAoB,CAAC,EAAE,QAAQ,GAAG,QAAQ,GACzC,eAAe,CAAC,OAAO,CAAC,CA6B1B;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,kBAAkB,UAAQ,GAA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