@btc-vision/bitcoin 7.0.0-alpha.1 → 7.0.0-alpha.3

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 (180) hide show
  1. package/README.md +334 -161
  2. package/browser/address.d.ts +5 -1
  3. package/browser/address.d.ts.map +1 -1
  4. package/browser/branded.d.ts +3 -14
  5. package/browser/branded.d.ts.map +1 -1
  6. package/browser/ecc/context.d.ts +22 -21
  7. package/browser/ecc/context.d.ts.map +1 -1
  8. package/browser/ecc/index.d.ts +1 -1
  9. package/browser/ecc/index.d.ts.map +1 -1
  10. package/browser/ecc/types.d.ts +10 -123
  11. package/browser/ecc/types.d.ts.map +1 -1
  12. package/browser/index.d.ts +3 -2
  13. package/browser/index.d.ts.map +1 -1
  14. package/browser/index.js +6465 -4692
  15. package/browser/opcodes.d.ts +11 -0
  16. package/browser/opcodes.d.ts.map +1 -1
  17. package/browser/payments/p2tr.d.ts.map +1 -1
  18. package/browser/psbt/PsbtCache.d.ts +54 -0
  19. package/browser/psbt/PsbtCache.d.ts.map +1 -0
  20. package/browser/psbt/PsbtFinalizer.d.ts +21 -0
  21. package/browser/psbt/PsbtFinalizer.d.ts.map +1 -0
  22. package/browser/psbt/PsbtSigner.d.ts +32 -0
  23. package/browser/psbt/PsbtSigner.d.ts.map +1 -0
  24. package/browser/psbt/PsbtTransaction.d.ts +25 -0
  25. package/browser/psbt/PsbtTransaction.d.ts.map +1 -0
  26. package/browser/psbt/types.d.ts +4 -70
  27. package/browser/psbt/types.d.ts.map +1 -1
  28. package/browser/psbt/validation.d.ts +1 -1
  29. package/browser/psbt/validation.d.ts.map +1 -1
  30. package/browser/psbt.d.ts +26 -40
  31. package/browser/psbt.d.ts.map +1 -1
  32. package/browser/script.d.ts.map +1 -1
  33. package/browser/transaction.d.ts +4 -4
  34. package/browser/transaction.d.ts.map +1 -1
  35. package/browser/types.d.ts +5 -3
  36. package/browser/types.d.ts.map +1 -1
  37. package/browser/workers/index.d.ts +3 -50
  38. package/browser/workers/index.d.ts.map +1 -1
  39. package/browser/workers/index.node.d.ts +24 -0
  40. package/browser/workers/index.node.d.ts.map +1 -0
  41. package/build/address.d.ts +5 -1
  42. package/build/address.d.ts.map +1 -1
  43. package/build/address.js +29 -17
  44. package/build/address.js.map +1 -1
  45. package/build/branded.d.ts +3 -14
  46. package/build/branded.d.ts.map +1 -1
  47. package/build/branded.js +0 -5
  48. package/build/branded.js.map +1 -1
  49. package/build/ecc/context.d.ts +22 -21
  50. package/build/ecc/context.d.ts.map +1 -1
  51. package/build/ecc/context.js +23 -95
  52. package/build/ecc/context.js.map +1 -1
  53. package/build/ecc/index.d.ts +1 -1
  54. package/build/ecc/index.d.ts.map +1 -1
  55. package/build/ecc/types.d.ts +7 -126
  56. package/build/ecc/types.d.ts.map +1 -1
  57. package/build/ecc/types.js +4 -1
  58. package/build/ecc/types.js.map +1 -1
  59. package/build/index.d.ts +3 -2
  60. package/build/index.d.ts.map +1 -1
  61. package/build/index.js +1 -1
  62. package/build/index.js.map +1 -1
  63. package/build/opcodes.d.ts +11 -0
  64. package/build/opcodes.d.ts.map +1 -1
  65. package/build/opcodes.js +19 -4
  66. package/build/opcodes.js.map +1 -1
  67. package/build/payments/p2tr.d.ts.map +1 -1
  68. package/build/payments/p2tr.js +2 -3
  69. package/build/payments/p2tr.js.map +1 -1
  70. package/build/psbt/PsbtCache.d.ts +54 -0
  71. package/build/psbt/PsbtCache.d.ts.map +1 -0
  72. package/build/psbt/PsbtCache.js +249 -0
  73. package/build/psbt/PsbtCache.js.map +1 -0
  74. package/build/psbt/PsbtFinalizer.d.ts +21 -0
  75. package/build/psbt/PsbtFinalizer.d.ts.map +1 -0
  76. package/build/psbt/PsbtFinalizer.js +157 -0
  77. package/build/psbt/PsbtFinalizer.js.map +1 -0
  78. package/build/psbt/PsbtSigner.d.ts +32 -0
  79. package/build/psbt/PsbtSigner.d.ts.map +1 -0
  80. package/build/psbt/PsbtSigner.js +192 -0
  81. package/build/psbt/PsbtSigner.js.map +1 -0
  82. package/build/psbt/PsbtTransaction.d.ts +25 -0
  83. package/build/psbt/PsbtTransaction.d.ts.map +1 -0
  84. package/build/psbt/PsbtTransaction.js +61 -0
  85. package/build/psbt/PsbtTransaction.js.map +1 -0
  86. package/build/psbt/types.d.ts +4 -70
  87. package/build/psbt/types.d.ts.map +1 -1
  88. package/build/psbt/validation.d.ts +1 -1
  89. package/build/psbt/validation.d.ts.map +1 -1
  90. package/build/psbt.d.ts +26 -40
  91. package/build/psbt.d.ts.map +1 -1
  92. package/build/psbt.js +177 -799
  93. package/build/psbt.js.map +1 -1
  94. package/build/script.d.ts.map +1 -1
  95. package/build/script.js +2 -2
  96. package/build/script.js.map +1 -1
  97. package/build/transaction.d.ts +4 -4
  98. package/build/transaction.d.ts.map +1 -1
  99. package/build/transaction.js +5 -4
  100. package/build/transaction.js.map +1 -1
  101. package/build/tsconfig.build.tsbuildinfo +1 -1
  102. package/build/types.d.ts +5 -3
  103. package/build/types.d.ts.map +1 -1
  104. package/build/types.js +9 -0
  105. package/build/types.js.map +1 -1
  106. package/build/workers/WorkerSigningPool.js +1 -1
  107. package/build/workers/WorkerSigningPool.js.map +1 -1
  108. package/build/workers/index.d.ts +3 -3
  109. package/build/workers/index.d.ts.map +1 -1
  110. package/build/workers/index.js +0 -3
  111. package/build/workers/index.js.map +1 -1
  112. package/build/workers/index.node.d.ts +24 -0
  113. package/build/workers/index.node.d.ts.map +1 -0
  114. package/build/workers/index.node.js +26 -0
  115. package/build/workers/index.node.js.map +1 -0
  116. package/package.json +27 -8
  117. package/src/address.ts +41 -18
  118. package/src/branded.ts +15 -13
  119. package/src/ecc/context.ts +30 -133
  120. package/src/ecc/index.ts +2 -2
  121. package/src/ecc/types.ts +7 -138
  122. package/src/index.ts +36 -2
  123. package/src/opcodes.ts +21 -4
  124. package/src/payments/p2tr.ts +2 -2
  125. package/src/psbt/PsbtCache.ts +325 -0
  126. package/src/psbt/PsbtFinalizer.ts +213 -0
  127. package/src/psbt/PsbtSigner.ts +302 -0
  128. package/src/psbt/PsbtTransaction.ts +82 -0
  129. package/src/psbt/types.ts +4 -86
  130. package/src/psbt/validation.ts +1 -1
  131. package/src/psbt.ts +348 -1197
  132. package/src/script.ts +2 -2
  133. package/src/transaction.ts +9 -8
  134. package/src/types.ts +14 -1
  135. package/src/workers/WorkerSigningPool.ts +1 -1
  136. package/src/workers/index.node.ts +27 -0
  137. package/src/workers/index.ts +7 -9
  138. package/test/address.spec.ts +2 -2
  139. package/test/bitcoin.core.spec.ts +5 -2
  140. package/test/browser/payments.spec.ts +151 -0
  141. package/test/browser/psbt.spec.ts +1510 -0
  142. package/test/browser/script.spec.ts +223 -0
  143. package/test/browser/setup.ts +13 -0
  144. package/test/browser/workers-signing.spec.ts +537 -0
  145. package/test/crypto.spec.ts +2 -2
  146. package/test/fixtures/core/base58_encode_decode.json +12 -48
  147. package/test/fixtures/core/base58_keys_invalid.json +50 -150
  148. package/test/fixtures/core/sighash.json +1 -3
  149. package/test/fixtures/core/tx_valid.json +133 -501
  150. package/test/fixtures/embed.json +3 -11
  151. package/test/fixtures/p2ms.json +21 -91
  152. package/test/fixtures/p2pk.json +5 -24
  153. package/test/fixtures/p2pkh.json +7 -36
  154. package/test/fixtures/p2sh.json +8 -54
  155. package/test/fixtures/p2tr.json +2 -6
  156. package/test/fixtures/p2wpkh.json +7 -36
  157. package/test/fixtures/p2wsh.json +14 -59
  158. package/test/fixtures/psbt.json +2 -6
  159. package/test/fixtures/script.json +12 -48
  160. package/test/integration/addresses.spec.ts +11 -5
  161. package/test/integration/bip32.spec.ts +1 -1
  162. package/test/integration/cltv.spec.ts +10 -6
  163. package/test/integration/csv.spec.ts +10 -9
  164. package/test/integration/payments.spec.ts +8 -4
  165. package/test/integration/taproot.spec.ts +26 -6
  166. package/test/integration/transactions.spec.ts +22 -8
  167. package/test/payments.spec.ts +1 -1
  168. package/test/payments.utils.ts +1 -1
  169. package/test/psbt.spec.ts +250 -64
  170. package/test/script_signature.spec.ts +1 -1
  171. package/test/transaction.spec.ts +18 -5
  172. package/test/tsconfig.json +6 -20
  173. package/test/workers-pool.spec.ts +22 -23
  174. package/test/workers-signing.spec.ts +7 -3
  175. package/test/workers.spec.ts +6 -7
  176. package/typedoc.json +11 -1
  177. package/vitest.config.browser.ts +68 -0
  178. package/browser/ecpair.d.ts +0 -99
  179. package/src/ecpair.d.ts +0 -99
  180. package/test/taproot-cache.spec.ts +0 -694
@@ -1,4 +1,4 @@
1
- import { EccLib } from './types.js';
1
+ import { CryptoBackend } from '@btc-vision/ecpair';
2
2
  /**
3
3
  * Context class for managing the ECC library instance.
4
4
  * Uses dependency injection pattern instead of global singleton.
@@ -6,10 +6,11 @@ import { EccLib } from './types.js';
6
6
  * @example
7
7
  * ```typescript
8
8
  * import { EccContext } from '@btc-vision/bitcoin';
9
- * import * as secp256k1 from 'tiny-secp256k1';
9
+ * import { createNobleBackend } from '@btc-vision/ecpair';
10
10
  *
11
11
  * // Initialize once at app startup
12
- * EccContext.init(secp256k1);
12
+ * const backend = createNobleBackend();
13
+ * EccContext.init(backend);
13
14
  *
14
15
  * // Get instance anywhere in your code
15
16
  * const ecc = EccContext.get();
@@ -24,24 +25,24 @@ export declare class EccContext {
24
25
  /**
25
26
  * The underlying ECC library instance.
26
27
  */
27
- get lib(): EccLib;
28
+ get lib(): CryptoBackend;
28
29
  /**
29
30
  * Initializes the ECC context with the provided library.
30
31
  * The library is verified before being set as active.
31
32
  *
32
- * @param lib - The ECC library instance to initialize
33
+ * @param lib - The CryptoBackend instance to initialize
33
34
  * @returns The initialized EccContext instance
34
- * @throws Error if the ECC library fails verification
35
+ * @throws Error if the CryptoBackend fails verification
35
36
  *
36
37
  * @example
37
38
  * ```typescript
38
39
  * import { EccContext } from '@btc-vision/bitcoin';
39
- * import * as secp256k1 from 'tiny-secp256k1';
40
+ * import { createNobleBackend } from '@btc-vision/ecpair';
40
41
  *
41
- * const context = EccContext.init(secp256k1);
42
+ * const context = EccContext.init(createNobleBackend());
42
43
  * ```
43
44
  */
44
- static init(lib: EccLib): EccContext;
45
+ static init(lib: CryptoBackend): EccContext;
45
46
  /**
46
47
  * Gets the initialized ECC context.
47
48
  *
@@ -53,7 +54,7 @@ export declare class EccContext {
53
54
  * import { EccContext } from '@btc-vision/bitcoin';
54
55
  *
55
56
  * const context = EccContext.get();
56
- * const isValid = context.lib.isXOnlyPoint(someKey);
57
+ * const tweaked = context.lib.xOnlyPointAddTweak(key, tweak);
57
58
  * ```
58
59
  */
59
60
  static get(): EccContext;
@@ -80,7 +81,7 @@ export declare class EccContext {
80
81
  * import { EccContext } from '@btc-vision/bitcoin';
81
82
  *
82
83
  * if (!EccContext.isInitialized()) {
83
- * EccContext.init(secp256k1);
84
+ * EccContext.init(createNobleBackend());
84
85
  * }
85
86
  * ```
86
87
  */
@@ -91,39 +92,39 @@ export declare class EccContext {
91
92
  * This is a convenience function that wraps EccContext.init().
92
93
  * Pass `undefined` to clear the library.
93
94
  *
94
- * @param eccLib - The ECC library instance to initialize, or undefined to clear
95
- * @throws Error if the ECC library fails verification
95
+ * @param eccLib - The CryptoBackend instance to initialize, or undefined to clear
96
+ * @throws Error if the CryptoBackend fails verification
96
97
  *
97
98
  * @example
98
99
  * ```typescript
99
100
  * import { initEccLib } from '@btc-vision/bitcoin';
100
- * import * as secp256k1 from 'tiny-secp256k1';
101
+ * import { createNobleBackend } from '@btc-vision/ecpair';
101
102
  *
102
103
  * // Initialize the ECC library
103
- * initEccLib(secp256k1);
104
+ * initEccLib(createNobleBackend());
104
105
  *
105
106
  * // Clear the library
106
107
  * initEccLib(undefined);
107
108
  * ```
108
109
  */
109
- export declare function initEccLib(eccLib: EccLib | undefined): void;
110
+ export declare function initEccLib(eccLib: CryptoBackend | undefined): void;
110
111
  /**
111
112
  * Retrieves the initialized ECC library instance.
112
113
  * This is a convenience function that wraps EccContext.get().lib.
113
114
  *
114
- * @returns The ECC library instance
115
+ * @returns The CryptoBackend instance
115
116
  * @throws Error if the ECC library has not been initialized
116
117
  *
117
118
  * @example
118
119
  * ```typescript
119
120
  * import { getEccLib, initEccLib } from '@btc-vision/bitcoin';
120
- * import * as secp256k1 from 'tiny-secp256k1';
121
+ * import { createNobleBackend } from '@btc-vision/ecpair';
121
122
  *
122
- * initEccLib(secp256k1);
123
+ * initEccLib(createNobleBackend());
123
124
  *
124
125
  * const ecc = getEccLib();
125
- * const isValid = ecc.isXOnlyPoint(somePublicKey);
126
+ * const tweaked = ecc.xOnlyPointAddTweak(pubkey, tweak);
126
127
  * ```
127
128
  */
128
- export declare function getEccLib(): EccLib;
129
+ export declare function getEccLib(): CryptoBackend;
129
130
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/ecc/context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAIzC;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,UAAU;;IAInB,OAAO;IAIP;;OAEG;IACH,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU;IAMpC;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,GAAG,IAAI,UAAU;IASxB;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,KAAK,IAAI,IAAI;IAIpB;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,aAAa,IAAI,OAAO;CAGlC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAM3D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAElC"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/ecc/context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,UAAU;;IAInB,OAAO;IAIP;;OAEG;IACH,IAAI,GAAG,IAAI,aAAa,CAEvB;IAED;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,aAAa,GAAG,UAAU;IAU3C;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,GAAG,IAAI,UAAU;IASxB;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,KAAK,IAAI,IAAI;IAIpB;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,aAAa,IAAI,OAAO;CAGlC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,SAAS,GAAG,IAAI,CAMlE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,IAAI,aAAa,CAEzC"}
@@ -6,6 +6,6 @@
6
6
  *
7
7
  * @packageDocumentation
8
8
  */
9
- export type { EccLib, XOnlyPointAddTweakResult, Parity } from './types.js';
9
+ export type { CryptoBackend, EccLib, XOnlyPointAddTweakResult, Parity } from './types.js';
10
10
  export { EccContext, initEccLib, getEccLib } from './context.js';
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ecc/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,YAAY,EAAE,MAAM,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAG3E,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ecc/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAG1F,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
@@ -1,128 +1,15 @@
1
- import { Bytes32, PrivateKey, PublicKey, SchnorrSignature, Signature, XOnlyPublicKey } from '../branded.js';
2
1
  /**
3
- * Parity of the y-coordinate for an x-only public key.
4
- * - 0: even y-coordinate
5
- * - 1: odd y-coordinate
6
- */
7
- export type Parity = 0 | 1;
8
- /**
9
- * Result of x-only point addition with tweak.
10
- */
11
- export interface XOnlyPointAddTweakResult {
12
- /** Parity of the resulting y-coordinate (0 = even, 1 = odd) */
13
- readonly parity: Parity;
14
- /** The resulting x-only public key */
15
- readonly xOnlyPubkey: XOnlyPublicKey;
16
- }
17
- /**
18
- * Interface for the ECC library used by this library.
19
- * This is compatible with tiny-secp256k1 and @noble/secp256k1.
2
+ * ECC (Elliptic Curve Cryptography) type definitions.
20
3
  *
21
- * @example
22
- * ```typescript
23
- * import { EccLib, initEccLib } from '@btc-vision/bitcoin';
24
- * import * as secp256k1 from 'tiny-secp256k1';
4
+ * Re-exports {@link CryptoBackend} from `@btc-vision/ecpair` as the canonical
5
+ * interface for secp256k1 operations. The legacy `EccLib` name is kept as a
6
+ * type alias for backward compatibility.
25
7
  *
26
- * // tiny-secp256k1 implements EccLib
27
- * const ecc: EccLib = secp256k1;
28
- * initEccLib(ecc);
29
- * ```
8
+ * @packageDocumentation
9
+ */
10
+ export type { CryptoBackend, XOnlyPointAddTweakResult, Parity } from '@btc-vision/ecpair';
11
+ /**
12
+ * @deprecated Use {@link CryptoBackend} from `@btc-vision/ecpair` instead.
30
13
  */
31
- export interface EccLib {
32
- /**
33
- * Checks if a 32-byte value is a valid x-only public key.
34
- *
35
- * @param p - 32-byte x-coordinate
36
- * @returns True if the point is valid on the secp256k1 curve
37
- */
38
- isXOnlyPoint(p: Uint8Array): boolean;
39
- /**
40
- * Adds a tweak to an x-only public key.
41
- *
42
- * @param p - 32-byte x-only public key
43
- * @param tweak - 32-byte scalar to add
44
- * @returns The tweaked public key with parity, or null if result is invalid
45
- */
46
- xOnlyPointAddTweak(p: XOnlyPublicKey, tweak: Bytes32): XOnlyPointAddTweakResult | null;
47
- /**
48
- * Signs a 32-byte message hash with a private key (ECDSA).
49
- * Optional - only needed for signing operations.
50
- *
51
- * @param hash - 32-byte message hash
52
- * @param privateKey - 32-byte private key
53
- * @returns DER-encoded signature
54
- */
55
- sign?(hash: Bytes32, privateKey: PrivateKey): Signature;
56
- /**
57
- * Signs a 32-byte message hash with a private key (Schnorr/BIP340).
58
- * Optional - only needed for Taproot key-path signing.
59
- *
60
- * @param hash - 32-byte message hash
61
- * @param privateKey - 32-byte private key
62
- * @returns 64-byte Schnorr signature
63
- */
64
- signSchnorr?(hash: Bytes32, privateKey: PrivateKey): SchnorrSignature;
65
- /**
66
- * Verifies an ECDSA signature.
67
- * Optional - only needed for signature verification.
68
- *
69
- * @param hash - 32-byte message hash
70
- * @param publicKey - 33 or 65-byte public key
71
- * @param signature - DER-encoded signature
72
- * @returns True if signature is valid
73
- */
74
- verify?(hash: Bytes32, publicKey: PublicKey, signature: Signature): boolean;
75
- /**
76
- * Verifies a Schnorr/BIP340 signature.
77
- * Optional - only needed for Taproot signature verification.
78
- *
79
- * @param hash - 32-byte message hash
80
- * @param publicKey - 32-byte x-only public key
81
- * @param signature - 64-byte Schnorr signature
82
- * @returns True if signature is valid
83
- */
84
- verifySchnorr?(hash: Bytes32, publicKey: XOnlyPublicKey, signature: SchnorrSignature): boolean;
85
- /**
86
- * Derives a public key from a private key.
87
- * Optional - only needed for key derivation.
88
- *
89
- * @param privateKey - 32-byte private key
90
- * @param compressed - Whether to return compressed (33-byte) or uncompressed (65-byte)
91
- * @returns The public key, or null if private key is invalid
92
- */
93
- pointFromScalar?(privateKey: PrivateKey, compressed?: boolean): PublicKey | null;
94
- /**
95
- * Computes the x-only public key from a private key.
96
- * Optional - only needed for Taproot key derivation.
97
- *
98
- * @param privateKey - 32-byte private key
99
- * @returns 32-byte x-only public key, or null if private key is invalid
100
- */
101
- xOnlyPointFromScalar?(privateKey: PrivateKey): XOnlyPublicKey | null;
102
- /**
103
- * Converts a full public key to x-only format.
104
- * Optional - only needed when working with x-only keys.
105
- *
106
- * @param pubkey - 33 or 65-byte public key
107
- * @returns 32-byte x-only public key
108
- */
109
- xOnlyPointFromPoint?(pubkey: PublicKey): XOnlyPublicKey;
110
- /**
111
- * Adds a scalar to a private key.
112
- * Optional - only needed for key tweaking.
113
- *
114
- * @param privateKey - 32-byte private key
115
- * @param tweak - 32-byte scalar to add
116
- * @returns The tweaked private key, or null if result is invalid
117
- */
118
- privateAdd?(privateKey: PrivateKey, tweak: Bytes32): PrivateKey | null;
119
- /**
120
- * Negates a private key.
121
- * Optional - only needed for Taproot parity handling.
122
- *
123
- * @param privateKey - 32-byte private key
124
- * @returns The negated private key
125
- */
126
- privateNegate?(privateKey: PrivateKey): PrivateKey;
127
- }
14
+ export type { CryptoBackend as EccLib } from '@btc-vision/ecpair';
128
15
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ecc/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,gBAAgB,EAAE,SAAS,EAAE,cAAc,EAAG,MAAM,eAAe,CAAC;AAElH;;;;GAIG;AACH,MAAM,MAAM,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC;AAE3B;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACrC,+DAA+D;IAC/D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,sCAAsC;IACtC,QAAQ,CAAC,WAAW,EAAE,cAAc,CAAC;CACxC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,MAAM;IACnB;;;;;OAKG;IACH,YAAY,CAAC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,wBAAwB,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE1F;;GAEG;AACH,YAAY,EAAE,aAAa,IAAI,MAAM,EAAE,MAAM,oBAAoB,CAAC"}
@@ -14,7 +14,8 @@ export * as script from './script.js';
14
14
  export { Block } from './block.js';
15
15
  /** @hidden */
16
16
  export * from './crypto.js';
17
- export * from './psbt.js';
17
+ export { Psbt, PsbtCache, PsbtSigner, PsbtFinalizer, PsbtTransaction, transactionFromBuffer, getFinalScripts, prepareFinalScripts, } from './psbt.js';
18
+ export type { TransactionInput, PsbtTxInput, TransactionOutput, PsbtTxOutput, ValidateSigFunction, PsbtBaseExtended, PsbtOptsOptional, PsbtOpts, PsbtInputExtended, PsbtOutputExtended, PsbtOutputExtendedScript, HDSigner, HDSignerAsync, Signer, SignerAsync, TaprootHashCheckSigner, PsbtCacheInterface, TxCacheNumberKey, ScriptType, AllScriptType, GetScriptReturn, FinalScriptsFunc, FinalTaprootScriptsFunc, } from './psbt.js';
18
19
  /** @hidden */
19
20
  export { opcodes } from './opcodes.js';
20
21
  export { Transaction } from './transaction.js';
@@ -23,7 +24,7 @@ export type { TaprootHashCache } from './transaction.js';
23
24
  export type { Network } from './networks.js';
24
25
  /** @hidden */
25
26
  export { initEccLib, getEccLib, EccContext } from './ecc/context.js';
26
- export type { EccLib } from './ecc/types.js';
27
+ export type { CryptoBackend, EccLib } from './ecc/types.js';
27
28
  export { PaymentType } from './payments/index.js';
28
29
  export type { Payment, PaymentCreator, PaymentOpts, P2WSHPayment, P2PKPayment, BasePayment, P2SHPayment, P2TRPayment, P2WPKHPayment, P2PKHPayment, P2MSPayment, EmbedPayment, P2OPPayment, P2OPPaymentParams, } from './payments/index.js';
29
30
  export type { Stack, StackElement, StackFunction } from './types.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,SAAS,IAAI,UAAU,EACvB,eAAe,IAAI,gB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