@ckb-ccc/core 0.0.5-alpha.1 → 0.0.5-alpha.10

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 (229) hide show
  1. package/dist/address/index.d.ts +1 -1
  2. package/dist/address/index.d.ts.map +1 -1
  3. package/dist/address/index.js +4 -4
  4. package/dist/ckb/transaction.d.ts +2 -2
  5. package/dist/ckb/transaction.d.ts.map +1 -1
  6. package/dist/ckb/transaction.js +2 -3
  7. package/dist/client/client.d.ts +2 -2
  8. package/dist/client/client.d.ts.map +1 -1
  9. package/dist/client/client.js +2 -1
  10. package/dist/client/clientPublicMainnet.d.ts +1 -1
  11. package/dist/client/clientPublicMainnet.d.ts.map +1 -1
  12. package/dist/client/clientPublicMainnet.js +1 -1
  13. package/dist/client/clientPublicTestnet.d.ts +1 -1
  14. package/dist/client/clientPublicTestnet.d.ts.map +1 -1
  15. package/dist/client/clientPublicTestnet.js +1 -1
  16. package/dist/client/jsonRpc/index.d.ts +3 -3
  17. package/dist/client/jsonRpc/index.d.ts.map +1 -1
  18. package/dist/client/jsonRpc/index.js +4 -4
  19. package/dist/signer/btc/index.d.ts +1 -0
  20. package/dist/signer/btc/index.d.ts.map +1 -1
  21. package/dist/signer/btc/index.js +1 -0
  22. package/dist/signer/btc/signerBtc.d.ts +9 -1
  23. package/dist/signer/btc/signerBtc.d.ts.map +1 -1
  24. package/dist/signer/btc/signerBtc.js +19 -3
  25. package/dist/signer/btc/signerBtcPublicKeyReadonly.d.ts +0 -6
  26. package/dist/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +1 -1
  27. package/dist/signer/btc/signerBtcPublicKeyReadonly.js +0 -8
  28. package/dist/signer/btc/verify.d.ts +3 -0
  29. package/dist/signer/btc/verify.d.ts.map +1 -0
  30. package/dist/signer/btc/verify.js +6 -0
  31. package/dist/signer/ckb/index.d.ts +1 -0
  32. package/dist/signer/ckb/index.d.ts.map +1 -1
  33. package/dist/signer/ckb/index.js +1 -0
  34. package/dist/signer/ckb/signerCkbScriptReadonly.d.ts +3 -7
  35. package/dist/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
  36. package/dist/signer/ckb/signerCkbScriptReadonly.js +8 -10
  37. package/dist/signer/ckb/verifyJoyId.d.ts +3 -0
  38. package/dist/signer/ckb/verifyJoyId.d.ts.map +1 -0
  39. package/dist/signer/ckb/verifyJoyId.js +12 -0
  40. package/dist/signer/dummy/alwaysError.d.ts +9 -0
  41. package/dist/signer/dummy/alwaysError.d.ts.map +1 -0
  42. package/dist/signer/dummy/alwaysError.js +10 -0
  43. package/dist/signer/dummy/dummy.d.ts +12 -0
  44. package/dist/signer/dummy/dummy.d.ts.map +1 -0
  45. package/dist/signer/dummy/dummy.js +19 -0
  46. package/dist/signer/dummy/index.d.ts +4 -0
  47. package/dist/signer/dummy/index.d.ts.map +1 -0
  48. package/dist/signer/dummy/index.js +3 -0
  49. package/dist/signer/dummy/openLink.d.ts +9 -0
  50. package/dist/signer/dummy/openLink.d.ts.map +1 -0
  51. package/dist/signer/dummy/openLink.js +10 -0
  52. package/dist/signer/evm/index.d.ts +1 -0
  53. package/dist/signer/evm/index.d.ts.map +1 -1
  54. package/dist/signer/evm/index.js +1 -0
  55. package/dist/signer/evm/signerEvm.d.ts +3 -1
  56. package/dist/signer/evm/signerEvm.d.ts.map +1 -1
  57. package/dist/signer/evm/signerEvm.js +10 -4
  58. package/dist/signer/evm/signerEvmAddressReadonly.d.ts +0 -6
  59. package/dist/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -1
  60. package/dist/signer/evm/signerEvmAddressReadonly.js +0 -8
  61. package/dist/signer/evm/verify.d.ts +3 -0
  62. package/dist/signer/evm/verify.d.ts.map +1 -0
  63. package/dist/signer/evm/verify.js +6 -0
  64. package/dist/signer/index.d.ts +1 -0
  65. package/dist/signer/index.d.ts.map +1 -1
  66. package/dist/signer/index.js +1 -0
  67. package/{dist.commonjs/signer/signer.d.ts → dist/signer/signer/index.d.ts} +69 -25
  68. package/dist/signer/signer/index.d.ts.map +1 -0
  69. package/dist/signer/{signer.js → signer/index.js} +101 -16
  70. package/dist/utils/index.d.ts +60 -0
  71. package/dist/utils/index.d.ts.map +1 -1
  72. package/dist/utils/index.js +20 -0
  73. package/dist.commonjs/address/address.advanced.d.ts +29 -24
  74. package/dist.commonjs/address/address.advanced.js +114 -92
  75. package/dist.commonjs/address/advanced.d.ts +1 -1
  76. package/dist.commonjs/address/advanced.js +30 -14
  77. package/dist.commonjs/address/index.d.ts +51 -44
  78. package/dist.commonjs/address/index.d.ts.map +1 -1
  79. package/dist.commonjs/address/index.js +87 -68
  80. package/dist.commonjs/advanced.d.ts +1 -1
  81. package/dist.commonjs/advanced.js +47 -22
  82. package/dist.commonjs/advancedBarrel.d.ts +1 -1
  83. package/dist.commonjs/advancedBarrel.js +30 -14
  84. package/dist.commonjs/barrel.d.ts +1 -1
  85. package/dist.commonjs/barrel.js +30 -14
  86. package/dist.commonjs/bytes/advanced.d.ts +11 -2
  87. package/dist.commonjs/bytes/index.d.ts +9 -3
  88. package/dist.commonjs/bytes/index.js +28 -26
  89. package/dist.commonjs/ckb/advanced.d.ts +1 -1
  90. package/dist.commonjs/ckb/advanced.js +47 -22
  91. package/dist.commonjs/ckb/index.d.ts +1 -1
  92. package/dist.commonjs/ckb/index.js +30 -14
  93. package/dist.commonjs/ckb/molecule.advanced/generated.d.ts +420 -260
  94. package/dist.commonjs/ckb/molecule.advanced/generated.js +1536 -1332
  95. package/dist.commonjs/ckb/molecule.advanced/index.d.ts +3 -3
  96. package/dist.commonjs/ckb/molecule.advanced/index.js +34 -18
  97. package/dist.commonjs/ckb/script.advanced.d.ts +1 -1
  98. package/dist.commonjs/ckb/script.advanced.js +12 -9
  99. package/dist.commonjs/ckb/script.d.ts +76 -76
  100. package/dist.commonjs/ckb/script.js +166 -126
  101. package/dist.commonjs/ckb/transaction.advanced.d.ts +1 -1
  102. package/dist.commonjs/ckb/transaction.advanced.js +4 -4
  103. package/dist.commonjs/ckb/transaction.d.ts +570 -532
  104. package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
  105. package/dist.commonjs/ckb/transaction.js +839 -723
  106. package/dist.commonjs/client/advanced.d.ts +1 -1
  107. package/dist.commonjs/client/advanced.js +30 -14
  108. package/dist.commonjs/client/client.d.ts +52 -21
  109. package/dist.commonjs/client/client.d.ts.map +1 -1
  110. package/dist.commonjs/client/client.js +67 -57
  111. package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts +5 -2
  112. package/dist.commonjs/client/clientPublicMainnet.advanced.js +30 -24
  113. package/dist.commonjs/client/clientPublicMainnet.d.ts +6 -4
  114. package/dist.commonjs/client/clientPublicMainnet.d.ts.map +1 -1
  115. package/dist.commonjs/client/clientPublicMainnet.js +9 -9
  116. package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts +5 -2
  117. package/dist.commonjs/client/clientPublicTestnet.advanced.js +30 -24
  118. package/dist.commonjs/client/clientPublicTestnet.d.ts +6 -4
  119. package/dist.commonjs/client/clientPublicTestnet.d.ts.map +1 -1
  120. package/dist.commonjs/client/clientPublicTestnet.js +9 -9
  121. package/dist.commonjs/client/clientTypes.d.ts +51 -36
  122. package/dist.commonjs/client/clientTypes.js +34 -19
  123. package/dist.commonjs/client/index.d.ts +1 -1
  124. package/dist.commonjs/client/index.js +30 -14
  125. package/dist.commonjs/client/jsonRpc/advanced.d.ts +1 -1
  126. package/dist.commonjs/client/jsonRpc/advanced.js +30 -14
  127. package/dist.commonjs/client/jsonRpc/index.d.ts +92 -75
  128. package/dist.commonjs/client/jsonRpc/index.d.ts.map +1 -1
  129. package/dist.commonjs/client/jsonRpc/index.js +135 -108
  130. package/dist.commonjs/client/jsonRpc/transformers.d.ts +78 -38
  131. package/dist.commonjs/client/jsonRpc/transformers.js +175 -150
  132. package/dist.commonjs/client/jsonRpc/types.d.ts +38 -38
  133. package/dist.commonjs/fixedPoint/index.d.ts +9 -3
  134. package/dist.commonjs/fixedPoint/index.js +26 -20
  135. package/dist.commonjs/fixedPoint/index.test.d.ts +1 -1
  136. package/dist.commonjs/fixedPoint/index.test.js +42 -36
  137. package/dist.commonjs/hasher/advanced.d.ts +1 -1
  138. package/dist.commonjs/hasher/index.d.ts +36 -36
  139. package/dist.commonjs/hasher/index.js +52 -45
  140. package/dist.commonjs/hex/index.d.ts +1 -1
  141. package/dist.commonjs/hex/index.js +1 -1
  142. package/dist.commonjs/index.d.ts +1 -1
  143. package/dist.commonjs/index.js +47 -22
  144. package/dist.commonjs/num/index.d.ts +1 -1
  145. package/dist.commonjs/num/index.js +30 -19
  146. package/dist.commonjs/signer/btc/index.d.ts +2 -1
  147. package/dist.commonjs/signer/btc/index.d.ts.map +1 -1
  148. package/dist.commonjs/signer/btc/index.js +31 -14
  149. package/dist.commonjs/signer/btc/signerBtc.d.ts +48 -40
  150. package/dist.commonjs/signer/btc/signerBtc.d.ts.map +1 -1
  151. package/dist.commonjs/signer/btc/signerBtc.js +85 -49
  152. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts +45 -51
  153. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +1 -1
  154. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +52 -60
  155. package/dist.commonjs/signer/btc/verify.d.ts +7 -0
  156. package/dist.commonjs/signer/btc/verify.d.ts.map +1 -0
  157. package/dist.commonjs/signer/btc/verify.js +13 -0
  158. package/dist.commonjs/signer/ckb/index.d.ts +2 -1
  159. package/dist.commonjs/signer/ckb/index.d.ts.map +1 -1
  160. package/dist.commonjs/signer/ckb/index.js +31 -14
  161. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +46 -50
  162. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
  163. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +56 -58
  164. package/dist.commonjs/signer/ckb/verifyJoyId.d.ts +7 -0
  165. package/dist.commonjs/signer/ckb/verifyJoyId.d.ts.map +1 -0
  166. package/dist.commonjs/signer/ckb/verifyJoyId.js +19 -0
  167. package/dist.commonjs/signer/dummy/alwaysError.d.ts +9 -0
  168. package/dist.commonjs/signer/dummy/alwaysError.d.ts.map +1 -0
  169. package/dist.commonjs/signer/dummy/alwaysError.js +14 -0
  170. package/dist.commonjs/signer/dummy/dummy.d.ts +12 -0
  171. package/dist.commonjs/signer/dummy/dummy.d.ts.map +1 -0
  172. package/dist.commonjs/signer/dummy/dummy.js +23 -0
  173. package/dist.commonjs/signer/dummy/index.d.ts +4 -0
  174. package/dist.commonjs/signer/dummy/index.d.ts.map +1 -0
  175. package/dist.commonjs/signer/dummy/index.js +35 -0
  176. package/dist.commonjs/signer/dummy/openLink.d.ts +9 -0
  177. package/dist.commonjs/signer/dummy/openLink.d.ts.map +1 -0
  178. package/dist.commonjs/signer/dummy/openLink.js +14 -0
  179. package/dist.commonjs/signer/evm/index.d.ts +2 -1
  180. package/dist.commonjs/signer/evm/index.d.ts.map +1 -1
  181. package/dist.commonjs/signer/evm/index.js +31 -14
  182. package/dist.commonjs/signer/evm/signerEvm.d.ts +43 -37
  183. package/dist.commonjs/signer/evm/signerEvm.d.ts.map +1 -1
  184. package/dist.commonjs/signer/evm/signerEvm.js +101 -63
  185. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts +37 -43
  186. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -1
  187. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +42 -50
  188. package/dist.commonjs/signer/evm/verify.d.ts +7 -0
  189. package/dist.commonjs/signer/evm/verify.d.ts.map +1 -0
  190. package/dist.commonjs/signer/evm/verify.js +15 -0
  191. package/dist.commonjs/signer/index.d.ts +2 -1
  192. package/dist.commonjs/signer/index.d.ts.map +1 -1
  193. package/dist.commonjs/signer/index.js +31 -14
  194. package/dist.commonjs/signer/signer/index.d.ts +190 -0
  195. package/dist.commonjs/signer/signer/index.d.ts.map +1 -0
  196. package/dist.commonjs/signer/signer/index.js +234 -0
  197. package/dist.commonjs/utils/index.d.ts +94 -6
  198. package/dist.commonjs/utils/index.d.ts.map +1 -1
  199. package/dist.commonjs/utils/index.js +33 -5
  200. package/package.json +6 -3
  201. package/src/address/index.ts +4 -7
  202. package/src/ckb/transaction.ts +4 -5
  203. package/src/client/client.ts +7 -6
  204. package/src/client/clientPublicMainnet.ts +1 -1
  205. package/src/client/clientPublicTestnet.ts +1 -1
  206. package/src/client/jsonRpc/index.ts +3 -3
  207. package/src/signer/btc/index.ts +1 -0
  208. package/src/signer/btc/signerBtc.ts +22 -7
  209. package/src/signer/btc/signerBtcPublicKeyReadonly.ts +0 -9
  210. package/src/signer/btc/verify.ts +14 -0
  211. package/src/signer/ckb/index.ts +1 -0
  212. package/src/signer/ckb/signerCkbScriptReadonly.ts +10 -11
  213. package/src/signer/ckb/verifyJoyId.ts +20 -0
  214. package/src/signer/dummy/alwaysError.ts +17 -0
  215. package/src/signer/dummy/dummy.ts +28 -0
  216. package/src/signer/dummy/index.ts +3 -0
  217. package/src/signer/dummy/openLink.ts +17 -0
  218. package/src/signer/evm/index.ts +1 -0
  219. package/src/signer/evm/signerEvm.ts +16 -10
  220. package/src/signer/evm/signerEvmAddressReadonly.ts +0 -9
  221. package/src/signer/evm/verify.ts +16 -0
  222. package/src/signer/index.ts +1 -0
  223. package/src/signer/{signer.ts → signer/index.ts} +135 -25
  224. package/src/utils/index.ts +108 -0
  225. package/dist/signer/signer.d.ts +0 -140
  226. package/dist/signer/signer.d.ts.map +0 -1
  227. package/dist.commonjs/signer/signer.d.ts.map +0 -1
  228. package/dist.commonjs/signer/signer.js +0 -125
  229. package/dist.commonjs/tsconfig.commonjs.tsbuildinfo +0 -1
@@ -1,50 +1,58 @@
1
1
  import { Address } from "../../address";
2
2
  import { Transaction, TransactionLike } from "../../ckb";
3
3
  import { HexLike } from "../../hex";
4
- import { Signer } from "../signer";
4
+ import { Signer, SignerSignType, SignerType } from "../signer";
5
5
  /**
6
6
  * An abstract class extending the Signer class for Bitcoin-like signing operations.
7
7
  * This class provides methods to get Bitcoin account, public key, and internal address,
8
8
  * as well as signing transactions.
9
9
  */
10
10
  export declare abstract class SignerBtc extends Signer {
11
- /**
12
- * Gets the Bitcoin account associated with the signer.
13
- *
14
- * @returns A promise that resolves to a string representing the Bitcoin account.
15
- */
16
- abstract getBtcAccount(): Promise<string>;
17
- /**
18
- * Gets the Bitcoin public key associated with the signer.
19
- *
20
- * @returns A promise that resolves to a HexLike value representing the Bitcoin public key.
21
- */
22
- abstract getBtcPublicKey(): Promise<HexLike>;
23
- /**
24
- * Gets the internal address, which is the Bitcoin account in this case.
25
- *
26
- * @returns A promise that resolves to a string representing the internal address.
27
- */
28
- getInternalAddress(): Promise<string>;
29
- /**
30
- * Gets an array of Address objects representing the known script addresses for the signer.
31
- *
32
- * @returns A promise that resolves to an array of Address objects.
33
- */
34
- getAddressObjs(): Promise<Address[]>;
35
- /**
36
- * prepare a transaction before signing. This method is not implemented and should be overridden by subclasses.
37
- *
38
- * @param txLike - The transaction to prepare, represented as a TransactionLike object.
39
- * @returns A promise that resolves to the prepared Transaction object.
40
- */
41
- prepareTransaction(txLike: TransactionLike): Promise<Transaction>;
42
- /**
43
- * Signs a transaction without modifying it.
44
- *
45
- * @param txLike - The transaction to sign, represented as a TransactionLike object.
46
- * @returns A promise that resolves to a signed Transaction object.
47
- */
48
- signOnlyTransaction(txLike: TransactionLike): Promise<Transaction>;
11
+ get type(): SignerType;
12
+ get signType(): SignerSignType;
13
+ /**
14
+ * Gets the Bitcoin account associated with the signer.
15
+ *
16
+ * @returns A promise that resolves to a string representing the Bitcoin account.
17
+ */
18
+ abstract getBtcAccount(): Promise<string>;
19
+ /**
20
+ * Gets the Bitcoin public key associated with the signer.
21
+ *
22
+ * @returns A promise that resolves to a HexLike value representing the Bitcoin public key.
23
+ */
24
+ abstract getBtcPublicKey(): Promise<HexLike>;
25
+ /**
26
+ * Gets the internal address, which is the Bitcoin account in this case.
27
+ *
28
+ * @returns A promise that resolves to a string representing the internal address.
29
+ */
30
+ getInternalAddress(): Promise<string>;
31
+ /**
32
+ * Gets the identity, which is the Bitcoin public key in this case.
33
+ *
34
+ * @returns A promise that resolves to a string representing the identity
35
+ */
36
+ getIdentity(): Promise<string>;
37
+ /**
38
+ * Gets an array of Address objects representing the known script addresses for the signer.
39
+ *
40
+ * @returns A promise that resolves to an array of Address objects.
41
+ */
42
+ getAddressObjs(): Promise<Address[]>;
43
+ /**
44
+ * prepare a transaction before signing. This method is not implemented and should be overridden by subclasses.
45
+ *
46
+ * @param txLike - The transaction to prepare, represented as a TransactionLike object.
47
+ * @returns A promise that resolves to the prepared Transaction object.
48
+ */
49
+ prepareTransaction(txLike: TransactionLike): Promise<Transaction>;
50
+ /**
51
+ * Signs a transaction without modifying it.
52
+ *
53
+ * @param txLike - The transaction to sign, represented as a TransactionLike object.
54
+ * @returns A promise that resolves to a signed Transaction object.
55
+ */
56
+ signOnlyTransaction(txLike: TransactionLike): Promise<Transaction>;
49
57
  }
50
- //# sourceMappingURL=signerBtc.d.ts.map
58
+ //# sourceMappingURL=signerBtc.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"signerBtc.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/signerBtc.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAe,MAAM,WAAW,CAAC;AAEtE,OAAO,EAAE,OAAO,EAAW,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;;GAIG;AACH,8BAAsB,SAAU,SAAQ,MAAM;IAC5C;;;;OAIG;IACH,QAAQ,CAAC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAEzC;;;;OAIG;IACH,QAAQ,CAAC,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IAE5C;;;;OAIG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAa1C;;;;;OAKG;IACG,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IASvE;;;;;OAKG;IACG,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;CAgCzE"}
1
+ {"version":3,"file":"signerBtc.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/signerBtc.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAe,MAAM,WAAW,CAAC;AAEtE,OAAO,EAAE,OAAO,EAAW,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE/D;;;;GAIG;AACH,8BAAsB,SAAU,SAAQ,MAAM;IAC5C,IAAI,IAAI,IAAI,UAAU,CAErB;IAED,IAAI,QAAQ,IAAI,cAAc,CAE7B;IAED;;;;OAIG;IACH,QAAQ,CAAC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAEzC;;;;OAIG;IACH,QAAQ,CAAC,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IAE5C;;;;OAIG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAIpC;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAa1C;;;;;OAKG;IACG,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IAOvE;;;;;OAKG;IACG,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;CAgCzE"}
@@ -16,55 +16,91 @@ const signer_1 = require("../signer");
16
16
  * as well as signing transactions.
17
17
  */
18
18
  class SignerBtc extends signer_1.Signer {
19
- /**
20
- * Gets the internal address, which is the Bitcoin account in this case.
21
- *
22
- * @returns A promise that resolves to a string representing the internal address.
23
- */
24
- async getInternalAddress() {
25
- return this.getBtcAccount();
26
- }
27
- /**
28
- * Gets an array of Address objects representing the known script addresses for the signer.
29
- *
30
- * @returns A promise that resolves to an array of Address objects.
31
- */
32
- async getAddressObjs() {
33
- const publicKey = await this.getBtcPublicKey();
34
- const hash = (0, ripemd160_1.ripemd160)((0, sha256_1.sha256)((0, bytes_1.bytesFrom)(publicKey)));
35
- return [
36
- await address_1.Address.fromKnownScript(client_1.KnownScript.OmniLock, (0, hex_1.hexFrom)([0x04, ...hash, 0x00]), this.client),
37
- ];
38
- }
39
- /**
40
- * prepare a transaction before signing. This method is not implemented and should be overridden by subclasses.
41
- *
42
- * @param txLike - The transaction to prepare, represented as a TransactionLike object.
43
- * @returns A promise that resolves to the prepared Transaction object.
44
- */
45
- async prepareTransaction(txLike) {
46
- const { script } = await this.getRecommendedAddressObj();
47
- return ckb_1.Transaction.from(txLike).prepareSighashAllWitness(script, 85, this.client);
48
- }
49
- /**
50
- * Signs a transaction without modifying it.
51
- *
52
- * @param txLike - The transaction to sign, represented as a TransactionLike object.
53
- * @returns A promise that resolves to a signed Transaction object.
54
- */
55
- async signOnlyTransaction(txLike) {
56
- const tx = ckb_1.Transaction.from(txLike);
57
- const { script } = await this.getRecommendedAddressObj();
58
- const info = await tx.getSignHashInfo(script, this.client);
59
- if (!info) {
60
- return tx;
61
- }
62
- const signature = (0, bytes_1.bytesFrom)(await this.signMessage(`CKB (Bitcoin Layer) transaction: ${info.message}`), "base64");
63
- signature[0] = 31 + ((signature[0] - 27) % 4);
64
- const witness = ckb_1.WitnessArgs.fromBytes(tx.witnesses[info.position]);
65
- witness.lock = (0, hex_1.hexFrom)((0, bytes_1.bytesConcat)((0, num_1.numToBytes)(5 * 4 + signature.length, 4), (0, num_1.numToBytes)(4 * 4, 4), (0, num_1.numToBytes)(5 * 4 + signature.length, 4), (0, num_1.numToBytes)(5 * 4 + signature.length, 4), (0, num_1.numToBytes)(signature.length, 4), signature));
66
- tx.witnesses[info.position] = (0, hex_1.hexFrom)(witness.toBytes());
67
- return tx;
19
+ get type() {
20
+ return signer_1.SignerType.BTC;
21
+ }
22
+ get signType() {
23
+ return signer_1.SignerSignType.BtcEcdsa;
24
+ }
25
+ /**
26
+ * Gets the internal address, which is the Bitcoin account in this case.
27
+ *
28
+ * @returns A promise that resolves to a string representing the internal address.
29
+ */
30
+ async getInternalAddress() {
31
+ return this.getBtcAccount();
32
+ }
33
+ /**
34
+ * Gets the identity, which is the Bitcoin public key in this case.
35
+ *
36
+ * @returns A promise that resolves to a string representing the identity
37
+ */
38
+ async getIdentity() {
39
+ return (0, hex_1.hexFrom)(await this.getBtcPublicKey()).slice(2);
40
+ }
41
+ /**
42
+ * Gets an array of Address objects representing the known script addresses for the signer.
43
+ *
44
+ * @returns A promise that resolves to an array of Address objects.
45
+ */
46
+ async getAddressObjs() {
47
+ const publicKey = await this.getBtcPublicKey();
48
+ const hash = (0, ripemd160_1.ripemd160)(
49
+ (0, sha256_1.sha256)((0, bytes_1.bytesFrom)(publicKey)),
50
+ );
51
+ return [
52
+ await address_1.Address.fromKnownScript(
53
+ client_1.KnownScript.OmniLock,
54
+ (0, hex_1.hexFrom)([0x04, ...hash, 0x00]),
55
+ this.client,
56
+ ),
57
+ ];
58
+ }
59
+ /**
60
+ * prepare a transaction before signing. This method is not implemented and should be overridden by subclasses.
61
+ *
62
+ * @param txLike - The transaction to prepare, represented as a TransactionLike object.
63
+ * @returns A promise that resolves to the prepared Transaction object.
64
+ */
65
+ async prepareTransaction(txLike) {
66
+ const tx = ckb_1.Transaction.from(txLike);
67
+ const { script } = await this.getRecommendedAddressObj();
68
+ await tx.prepareSighashAllWitness(script, 85, this.client);
69
+ return tx;
70
+ }
71
+ /**
72
+ * Signs a transaction without modifying it.
73
+ *
74
+ * @param txLike - The transaction to sign, represented as a TransactionLike object.
75
+ * @returns A promise that resolves to a signed Transaction object.
76
+ */
77
+ async signOnlyTransaction(txLike) {
78
+ const tx = ckb_1.Transaction.from(txLike);
79
+ const { script } = await this.getRecommendedAddressObj();
80
+ const info = await tx.getSignHashInfo(script, this.client);
81
+ if (!info) {
82
+ return tx;
68
83
  }
84
+ const signature = (0, bytes_1.bytesFrom)(
85
+ await this.signMessageRaw(
86
+ `CKB (Bitcoin Layer) transaction: ${info.message}`,
87
+ ),
88
+ "base64",
89
+ );
90
+ signature[0] = 31 + ((signature[0] - 27) % 4);
91
+ const witness = ckb_1.WitnessArgs.fromBytes(tx.witnesses[info.position]);
92
+ witness.lock = (0, hex_1.hexFrom)(
93
+ (0, bytes_1.bytesConcat)(
94
+ (0, num_1.numToBytes)(5 * 4 + signature.length, 4),
95
+ (0, num_1.numToBytes)(4 * 4, 4),
96
+ (0, num_1.numToBytes)(5 * 4 + signature.length, 4),
97
+ (0, num_1.numToBytes)(5 * 4 + signature.length, 4),
98
+ (0, num_1.numToBytes)(signature.length, 4),
99
+ signature,
100
+ ),
101
+ );
102
+ tx.witnesses[info.position] = (0, hex_1.hexFrom)(witness.toBytes());
103
+ return tx;
104
+ }
69
105
  }
70
106
  exports.SignerBtc = SignerBtc;
@@ -6,55 +6,49 @@ import { SignerBtc } from "./signerBtc";
6
6
  * This class does not support signing operations.
7
7
  */
8
8
  export declare class SignerBtcPublicKeyReadonly extends SignerBtc {
9
- private readonly account;
10
- private readonly publicKey;
11
- /**
12
- * Creates an instance of SignerBtcPublicKeyReadonly.
13
- *
14
- * @param client - The client instance used for communication.
15
- * @param account - The Bitcoin account associated with the signer.
16
- * @param publicKey - The public key associated with the signer.
17
- */
18
- constructor(client: Client, account: string, publicKey: HexLike);
19
- /**
20
- * Construct a new signer with the client replaced.
21
- *
22
- * @returns A promise that resolves the new Signer.
23
- */
24
- replaceClient(client: Client): Promise<SignerBtcPublicKeyReadonly>;
25
- /**
26
- * Connects to the client. This implementation does nothing as the class is read-only.
27
- *
28
- * @returns A promise that resolves when the connection is complete.
29
- */
30
- connect(): Promise<void>;
31
- /**
32
- * Check if the signer is connected.
33
- *
34
- * @returns A promise that resolves the connection status.
35
- */
36
- isConnected(): Promise<boolean>;
37
- /**
38
- * Gets the Bitcoin account associated with the signer.
39
- *
40
- * @returns A promise that resolves to a string representing the Bitcoin account.
41
- *
42
- * @example
43
- * ```typescript
44
- * const account = await signer.getBtcAccount(); // Outputs the Bitcoin account
45
- * ```
46
- */
47
- getBtcAccount(): Promise<string>;
48
- /**
49
- * Gets the Bitcoin public key associated with the signer.
50
- *
51
- * @returns A promise that resolves to a Hex string representing the Bitcoin public key.
52
- *
53
- * @example
54
- * ```typescript
55
- * const publicKey = await signer.getBtcPublicKey(); // Outputs the Bitcoin public key
56
- * ```
57
- */
58
- getBtcPublicKey(): Promise<Hex>;
9
+ private readonly account;
10
+ private readonly publicKey;
11
+ /**
12
+ * Creates an instance of SignerBtcPublicKeyReadonly.
13
+ *
14
+ * @param client - The client instance used for communication.
15
+ * @param account - The Bitcoin account associated with the signer.
16
+ * @param publicKey - The public key associated with the signer.
17
+ */
18
+ constructor(client: Client, account: string, publicKey: HexLike);
19
+ /**
20
+ * Connects to the client. This implementation does nothing as the class is read-only.
21
+ *
22
+ * @returns A promise that resolves when the connection is complete.
23
+ */
24
+ connect(): Promise<void>;
25
+ /**
26
+ * Check if the signer is connected.
27
+ *
28
+ * @returns A promise that resolves the connection status.
29
+ */
30
+ isConnected(): Promise<boolean>;
31
+ /**
32
+ * Gets the Bitcoin account associated with the signer.
33
+ *
34
+ * @returns A promise that resolves to a string representing the Bitcoin account.
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * const account = await signer.getBtcAccount(); // Outputs the Bitcoin account
39
+ * ```
40
+ */
41
+ getBtcAccount(): Promise<string>;
42
+ /**
43
+ * Gets the Bitcoin public key associated with the signer.
44
+ *
45
+ * @returns A promise that resolves to a Hex string representing the Bitcoin public key.
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * const publicKey = await signer.getBtcPublicKey(); // Outputs the Bitcoin public key
50
+ * ```
51
+ */
52
+ getBtcPublicKey(): Promise<Hex>;
59
53
  }
60
- //# sourceMappingURL=signerBtcPublicKeyReadonly.d.ts.map
54
+ //# sourceMappingURL=signerBtcPublicKeyReadonly.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"signerBtcPublicKeyReadonly.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/signerBtcPublicKeyReadonly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,SAAS;IAYrD,OAAO,CAAC,QAAQ,CAAC,OAAO;IAX1B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAM;IAEhC;;;;;;OAMG;gBAED,MAAM,EAAE,MAAM,EACG,OAAO,EAAE,MAAM,EAChC,SAAS,EAAE,OAAO;IAOpB;;;;OAIG;IACG,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAIxE;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAE9B;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAIrC;;;;;;;;;OASG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAItC;;;;;;;;;OASG;IACG,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC;CAGtC"}
1
+ {"version":3,"file":"signerBtcPublicKeyReadonly.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/signerBtcPublicKeyReadonly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAW,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,SAAS;IAYrD,OAAO,CAAC,QAAQ,CAAC,OAAO;IAX1B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAM;IAEhC;;;;;;OAMG;gBAED,MAAM,EAAE,MAAM,EACG,OAAO,EAAE,MAAM,EAChC,SAAS,EAAE,OAAO;IAOpB;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAE9B;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAIrC;;;;;;;;;OASG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAItC;;;;;;;;;OASG;IACG,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC;CAGtC"}
@@ -8,65 +8,57 @@ const signerBtc_1 = require("./signerBtc");
8
8
  * This class does not support signing operations.
9
9
  */
10
10
  class SignerBtcPublicKeyReadonly extends signerBtc_1.SignerBtc {
11
- /**
12
- * Creates an instance of SignerBtcPublicKeyReadonly.
13
- *
14
- * @param client - The client instance used for communication.
15
- * @param account - The Bitcoin account associated with the signer.
16
- * @param publicKey - The public key associated with the signer.
17
- */
18
- constructor(client, account, publicKey) {
19
- super(client);
20
- this.account = account;
21
- this.publicKey = (0, hex_1.hexFrom)(publicKey);
22
- }
23
- /**
24
- * Construct a new signer with the client replaced.
25
- *
26
- * @returns A promise that resolves the new Signer.
27
- */
28
- async replaceClient(client) {
29
- return new SignerBtcPublicKeyReadonly(client, this.account, this.publicKey);
30
- }
31
- /**
32
- * Connects to the client. This implementation does nothing as the class is read-only.
33
- *
34
- * @returns A promise that resolves when the connection is complete.
35
- */
36
- async connect() { }
37
- /**
38
- * Check if the signer is connected.
39
- *
40
- * @returns A promise that resolves the connection status.
41
- */
42
- async isConnected() {
43
- return true;
44
- }
45
- /**
46
- * Gets the Bitcoin account associated with the signer.
47
- *
48
- * @returns A promise that resolves to a string representing the Bitcoin account.
49
- *
50
- * @example
51
- * ```typescript
52
- * const account = await signer.getBtcAccount(); // Outputs the Bitcoin account
53
- * ```
54
- */
55
- async getBtcAccount() {
56
- return this.account;
57
- }
58
- /**
59
- * Gets the Bitcoin public key associated with the signer.
60
- *
61
- * @returns A promise that resolves to a Hex string representing the Bitcoin public key.
62
- *
63
- * @example
64
- * ```typescript
65
- * const publicKey = await signer.getBtcPublicKey(); // Outputs the Bitcoin public key
66
- * ```
67
- */
68
- async getBtcPublicKey() {
69
- return this.publicKey;
70
- }
11
+ /**
12
+ * Creates an instance of SignerBtcPublicKeyReadonly.
13
+ *
14
+ * @param client - The client instance used for communication.
15
+ * @param account - The Bitcoin account associated with the signer.
16
+ * @param publicKey - The public key associated with the signer.
17
+ */
18
+ constructor(client, account, publicKey) {
19
+ super(client);
20
+ this.account = account;
21
+ this.publicKey = (0, hex_1.hexFrom)(publicKey);
22
+ }
23
+ /**
24
+ * Connects to the client. This implementation does nothing as the class is read-only.
25
+ *
26
+ * @returns A promise that resolves when the connection is complete.
27
+ */
28
+ async connect() {}
29
+ /**
30
+ * Check if the signer is connected.
31
+ *
32
+ * @returns A promise that resolves the connection status.
33
+ */
34
+ async isConnected() {
35
+ return true;
36
+ }
37
+ /**
38
+ * Gets the Bitcoin account associated with the signer.
39
+ *
40
+ * @returns A promise that resolves to a string representing the Bitcoin account.
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * const account = await signer.getBtcAccount(); // Outputs the Bitcoin account
45
+ * ```
46
+ */
47
+ async getBtcAccount() {
48
+ return this.account;
49
+ }
50
+ /**
51
+ * Gets the Bitcoin public key associated with the signer.
52
+ *
53
+ * @returns A promise that resolves to a Hex string representing the Bitcoin public key.
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * const publicKey = await signer.getBtcPublicKey(); // Outputs the Bitcoin public key
58
+ * ```
59
+ */
60
+ async getBtcPublicKey() {
61
+ return this.publicKey;
62
+ }
71
63
  }
72
64
  exports.SignerBtcPublicKeyReadonly = SignerBtcPublicKeyReadonly;
@@ -0,0 +1,7 @@
1
+ import { BytesLike } from "../../bytes";
2
+ export declare function verifyMessageBtcEcdsa(
3
+ message: string | BytesLike,
4
+ signature: string,
5
+ publicKey: string,
6
+ ): boolean;
7
+ //# sourceMappingURL=verify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/verify.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,OAAO,CAKT"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.verifyMessageBtcEcdsa = void 0;
4
+ const wallet_utils_1 = require("@unisat/wallet-utils");
5
+ const hex_1 = require("../../hex");
6
+ function verifyMessageBtcEcdsa(message, signature, publicKey) {
7
+ const challenge =
8
+ typeof message === "string"
9
+ ? message
10
+ : (0, hex_1.hexFrom)(message).slice(2);
11
+ return (0, wallet_utils_1.verifyMessage)(publicKey, challenge, signature);
12
+ }
13
+ exports.verifyMessageBtcEcdsa = verifyMessageBtcEcdsa;
@@ -1,2 +1,3 @@
1
1
  export * from "./signerCkbScriptReadonly";
2
- //# sourceMappingURL=index.d.ts.map
2
+ export * from "./verifyJoyId";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/ckb/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/ckb/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC"}
@@ -1,17 +1,34 @@
1
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
- };
2
+ var __createBinding =
3
+ (this && this.__createBinding) ||
4
+ (Object.create
5
+ ? function (o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (
9
+ !desc ||
10
+ ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
11
+ ) {
12
+ desc = {
13
+ enumerable: true,
14
+ get: function () {
15
+ return m[k];
16
+ },
17
+ };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }
21
+ : function (o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k;
23
+ o[k2] = m[k];
24
+ });
25
+ var __exportStar =
26
+ (this && this.__exportStar) ||
27
+ function (m, exports) {
28
+ for (var p in m)
29
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p))
30
+ __createBinding(exports, m, p);
31
+ };
16
32
  Object.defineProperty(exports, "__esModule", { value: true });
17
33
  __exportStar(require("./signerCkbScriptReadonly"), exports);
34
+ __exportStar(require("./verifyJoyId"), exports);