@ckb-ccc/core 0.0.10-alpha.4 → 0.0.10-alpha.6

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 (135) hide show
  1. package/dist/address/address.advanced.js +4 -2
  2. package/dist/ckb/transaction.d.ts.map +1 -1
  3. package/dist/ckb/transaction.js +1 -2
  4. package/dist/signer/ckb/signerCkbPrivateKey.d.ts +1 -0
  5. package/dist/signer/ckb/signerCkbPrivateKey.d.ts.map +1 -1
  6. package/dist/signer/ckb/signerCkbPrivateKey.js +7 -7
  7. package/dist/signer/signer/index.d.ts +0 -9
  8. package/dist/signer/signer/index.d.ts.map +1 -1
  9. package/dist/signer/signer/index.js +6 -13
  10. package/dist.commonjs/address/address.advanced.d.ts +24 -29
  11. package/dist.commonjs/address/address.advanced.js +91 -115
  12. package/dist.commonjs/address/advanced.d.ts +1 -1
  13. package/dist.commonjs/address/advanced.js +14 -30
  14. package/dist.commonjs/address/index.d.ts +44 -51
  15. package/dist.commonjs/address/index.js +65 -84
  16. package/dist.commonjs/advanced.d.ts +1 -1
  17. package/dist.commonjs/advanced.js +22 -47
  18. package/dist.commonjs/advancedBarrel.d.ts +1 -1
  19. package/dist.commonjs/advancedBarrel.js +14 -30
  20. package/dist.commonjs/barrel.d.ts +1 -1
  21. package/dist.commonjs/barrel.js +14 -30
  22. package/dist.commonjs/bytes/advanced.d.ts +2 -11
  23. package/dist.commonjs/bytes/index.d.ts +3 -9
  24. package/dist.commonjs/bytes/index.js +26 -28
  25. package/dist.commonjs/ckb/advanced.d.ts +1 -1
  26. package/dist.commonjs/ckb/advanced.js +22 -47
  27. package/dist.commonjs/ckb/index.d.ts +1 -1
  28. package/dist.commonjs/ckb/index.js +14 -30
  29. package/dist.commonjs/ckb/molecule.advanced/generated.d.ts +260 -420
  30. package/dist.commonjs/ckb/molecule.advanced/generated.js +1332 -1536
  31. package/dist.commonjs/ckb/molecule.advanced/index.d.ts +3 -3
  32. package/dist.commonjs/ckb/molecule.advanced/index.js +18 -34
  33. package/dist.commonjs/ckb/script.advanced.d.ts +1 -1
  34. package/dist.commonjs/ckb/script.advanced.js +9 -12
  35. package/dist.commonjs/ckb/script.d.ts +117 -121
  36. package/dist.commonjs/ckb/script.js +176 -220
  37. package/dist.commonjs/ckb/transaction.advanced.d.ts +1 -1
  38. package/dist.commonjs/ckb/transaction.advanced.js +4 -4
  39. package/dist.commonjs/ckb/transaction.d.ts +722 -806
  40. package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
  41. package/dist.commonjs/ckb/transaction.js +1190 -1424
  42. package/dist.commonjs/client/advanced.d.ts +1 -1
  43. package/dist.commonjs/client/advanced.js +14 -30
  44. package/dist.commonjs/client/client.advanced.d.ts +6 -23
  45. package/dist.commonjs/client/client.advanced.js +61 -89
  46. package/dist.commonjs/client/client.d.ts +54 -114
  47. package/dist.commonjs/client/client.js +182 -215
  48. package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts +4 -8
  49. package/dist.commonjs/client/clientPublicMainnet.advanced.js +189 -215
  50. package/dist.commonjs/client/clientPublicMainnet.d.ts +6 -8
  51. package/dist.commonjs/client/clientPublicMainnet.js +15 -17
  52. package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts +3 -6
  53. package/dist.commonjs/client/clientPublicTestnet.advanced.js +199 -227
  54. package/dist.commonjs/client/clientPublicTestnet.d.ts +6 -8
  55. package/dist.commonjs/client/clientPublicTestnet.js +13 -13
  56. package/dist.commonjs/client/clientTypes.advanced.d.ts +14 -14
  57. package/dist.commonjs/client/clientTypes.advanced.js +1 -1
  58. package/dist.commonjs/client/clientTypes.d.ts +26 -51
  59. package/dist.commonjs/client/clientTypes.js +22 -56
  60. package/dist.commonjs/client/index.d.ts +1 -1
  61. package/dist.commonjs/client/index.js +14 -30
  62. package/dist.commonjs/client/jsonRpc/advanced.d.ts +1 -1
  63. package/dist.commonjs/client/jsonRpc/advanced.js +14 -30
  64. package/dist.commonjs/client/jsonRpc/index.d.ts +75 -94
  65. package/dist.commonjs/client/jsonRpc/index.js +108 -135
  66. package/dist.commonjs/client/jsonRpc/transformers.d.ts +36 -76
  67. package/dist.commonjs/client/jsonRpc/transformers.js +152 -174
  68. package/dist.commonjs/client/jsonRpc/types.d.ts +38 -38
  69. package/dist.commonjs/fixedPoint/index.d.ts +3 -9
  70. package/dist.commonjs/fixedPoint/index.js +20 -26
  71. package/dist.commonjs/fixedPoint/index.test.d.ts +1 -1
  72. package/dist.commonjs/fixedPoint/index.test.js +36 -42
  73. package/dist.commonjs/hasher/advanced.d.ts +1 -1
  74. package/dist.commonjs/hasher/index.d.ts +37 -40
  75. package/dist.commonjs/hasher/index.js +48 -58
  76. package/dist.commonjs/hex/index.d.ts +1 -1
  77. package/dist.commonjs/hex/index.js +1 -1
  78. package/dist.commonjs/index.d.ts +1 -1
  79. package/dist.commonjs/index.js +22 -47
  80. package/dist.commonjs/num/index.d.ts +1 -1
  81. package/dist.commonjs/num/index.js +27 -39
  82. package/dist.commonjs/signer/btc/index.d.ts +1 -1
  83. package/dist.commonjs/signer/btc/index.js +14 -30
  84. package/dist.commonjs/signer/btc/signerBtc.d.ts +47 -47
  85. package/dist.commonjs/signer/btc/signerBtc.js +66 -89
  86. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts +45 -45
  87. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +52 -52
  88. package/dist.commonjs/signer/btc/verify.d.ts +2 -6
  89. package/dist.commonjs/signer/btc/verify.js +3 -10
  90. package/dist.commonjs/signer/ckb/index.d.ts +1 -1
  91. package/dist.commonjs/signer/ckb/index.js +14 -30
  92. package/dist.commonjs/signer/ckb/signerCkbPrivateKey.d.ts +6 -5
  93. package/dist.commonjs/signer/ckb/signerCkbPrivateKey.d.ts.map +1 -1
  94. package/dist.commonjs/signer/ckb/signerCkbPrivateKey.js +28 -42
  95. package/dist.commonjs/signer/ckb/signerCkbPublicKey.d.ts +11 -11
  96. package/dist.commonjs/signer/ckb/signerCkbPublicKey.js +35 -45
  97. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +45 -45
  98. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +56 -56
  99. package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.d.ts +3 -9
  100. package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.js +5 -13
  101. package/dist.commonjs/signer/ckb/verifyJoyId.d.ts +2 -6
  102. package/dist.commonjs/signer/ckb/verifyJoyId.js +8 -11
  103. package/dist.commonjs/signer/dummy/alwaysError.d.ts +4 -4
  104. package/dist.commonjs/signer/dummy/alwaysError.js +7 -7
  105. package/dist.commonjs/signer/dummy/dummy.d.ts +7 -7
  106. package/dist.commonjs/signer/dummy/dummy.js +16 -16
  107. package/dist.commonjs/signer/dummy/index.d.ts +1 -1
  108. package/dist.commonjs/signer/dummy/index.js +14 -30
  109. package/dist.commonjs/signer/dummy/openLink.d.ts +4 -4
  110. package/dist.commonjs/signer/dummy/openLink.js +7 -7
  111. package/dist.commonjs/signer/evm/index.d.ts +1 -1
  112. package/dist.commonjs/signer/evm/index.js +14 -30
  113. package/dist.commonjs/signer/evm/signerEvm.d.ts +38 -42
  114. package/dist.commonjs/signer/evm/signerEvm.js +70 -105
  115. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts +37 -37
  116. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +42 -42
  117. package/dist.commonjs/signer/evm/verify.d.ts +2 -6
  118. package/dist.commonjs/signer/evm/verify.js +2 -7
  119. package/dist.commonjs/signer/index.d.ts +1 -1
  120. package/dist.commonjs/signer/index.js +14 -30
  121. package/dist.commonjs/signer/nostr/index.d.ts +1 -1
  122. package/dist.commonjs/signer/nostr/index.js +14 -30
  123. package/dist.commonjs/signer/nostr/signerNostr.d.ts +57 -57
  124. package/dist.commonjs/signer/nostr/signerNostr.js +71 -100
  125. package/dist.commonjs/signer/nostr/verify.d.ts +3 -9
  126. package/dist.commonjs/signer/nostr/verify.js +39 -50
  127. package/dist.commonjs/signer/signer/index.d.ts +153 -171
  128. package/dist.commonjs/signer/signer/index.d.ts.map +1 -1
  129. package/dist.commonjs/signer/signer/index.js +191 -234
  130. package/dist.commonjs/utils/index.d.ts +9 -42
  131. package/dist.commonjs/utils/index.js +12 -18
  132. package/package.json +3 -3
  133. package/src/address/address.advanced.ts +4 -4
  134. package/src/signer/ckb/signerCkbPrivateKey.ts +8 -8
  135. package/src/signer/signer/index.ts +6 -14
@@ -8,51 +8,51 @@ import { Signer, SignerSignType, SignerType } from "../signer";
8
8
  * as well as signing transactions.
9
9
  */
10
10
  export declare abstract class SignerBtc extends Signer {
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>;
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>;
57
57
  }
58
- //# sourceMappingURL=signerBtc.d.ts.map
58
+ //# sourceMappingURL=signerBtc.d.ts.map
@@ -16,95 +16,72 @@ const signer_1 = require("../signer");
16
16
  * as well as signing transactions.
17
17
  */
18
18
  class SignerBtc extends signer_1.Signer {
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
- this.client,
54
- client_1.KnownScript.OmniLock,
55
- (0, hex_1.hexFrom)([0x04, ...hash, 0x00]),
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.addCellDepsOfKnownScripts(
69
- this.client,
70
- client_1.KnownScript.OmniLock,
71
- );
72
- await tx.prepareSighashAllWitness(script, 85, this.client);
73
- return tx;
74
- }
75
- /**
76
- * Signs a transaction without modifying it.
77
- *
78
- * @param txLike - The transaction to sign, represented as a TransactionLike object.
79
- * @returns A promise that resolves to a signed Transaction object.
80
- */
81
- async signOnlyTransaction(txLike) {
82
- const tx = ckb_1.Transaction.from(txLike);
83
- const { script } = await this.getRecommendedAddressObj();
84
- const info = await tx.getSignHashInfo(script, this.client);
85
- if (!info) {
86
- 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)((0, sha256_1.sha256)((0, bytes_1.bytesFrom)(publicKey)));
49
+ return [
50
+ await address_1.Address.fromKnownScript(this.client, client_1.KnownScript.OmniLock, (0, hex_1.hexFrom)([0x04, ...hash, 0x00])),
51
+ ];
52
+ }
53
+ /**
54
+ * prepare a transaction before signing. This method is not implemented and should be overridden by subclasses.
55
+ *
56
+ * @param txLike - The transaction to prepare, represented as a TransactionLike object.
57
+ * @returns A promise that resolves to the prepared Transaction object.
58
+ */
59
+ async prepareTransaction(txLike) {
60
+ const tx = ckb_1.Transaction.from(txLike);
61
+ const { script } = await this.getRecommendedAddressObj();
62
+ await tx.addCellDepsOfKnownScripts(this.client, client_1.KnownScript.OmniLock);
63
+ await tx.prepareSighashAllWitness(script, 85, this.client);
64
+ return tx;
65
+ }
66
+ /**
67
+ * Signs a transaction without modifying it.
68
+ *
69
+ * @param txLike - The transaction to sign, represented as a TransactionLike object.
70
+ * @returns A promise that resolves to a signed Transaction object.
71
+ */
72
+ async signOnlyTransaction(txLike) {
73
+ const tx = ckb_1.Transaction.from(txLike);
74
+ const { script } = await this.getRecommendedAddressObj();
75
+ const info = await tx.getSignHashInfo(script, this.client);
76
+ if (!info) {
77
+ return tx;
78
+ }
79
+ const signature = (0, bytes_1.bytesFrom)(await this.signMessageRaw(`CKB (Bitcoin Layer) transaction: ${info.message}`), "base64");
80
+ signature[0] = 31 + ((signature[0] - 27) % 4);
81
+ const witness = ckb_1.WitnessArgs.fromBytes(tx.witnesses[info.position]);
82
+ 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));
83
+ tx.setWitnessArgsAt(info.position, witness);
84
+ return tx;
87
85
  }
88
- const signature = (0, bytes_1.bytesFrom)(
89
- await this.signMessageRaw(
90
- `CKB (Bitcoin Layer) transaction: ${info.message}`,
91
- ),
92
- "base64",
93
- );
94
- signature[0] = 31 + ((signature[0] - 27) % 4);
95
- const witness = ckb_1.WitnessArgs.fromBytes(tx.witnesses[info.position]);
96
- witness.lock = (0, hex_1.hexFrom)(
97
- (0, bytes_1.bytesConcat)(
98
- (0, num_1.numToBytes)(5 * 4 + signature.length, 4),
99
- (0, num_1.numToBytes)(4 * 4, 4),
100
- (0, num_1.numToBytes)(5 * 4 + signature.length, 4),
101
- (0, num_1.numToBytes)(5 * 4 + signature.length, 4),
102
- (0, num_1.numToBytes)(signature.length, 4),
103
- signature,
104
- ),
105
- );
106
- tx.setWitnessArgsAt(info.position, witness);
107
- return tx;
108
- }
109
86
  }
110
87
  exports.SignerBtc = SignerBtc;
@@ -6,49 +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
- * 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>;
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>;
53
53
  }
54
- //# sourceMappingURL=signerBtcPublicKeyReadonly.d.ts.map
54
+ //# sourceMappingURL=signerBtcPublicKeyReadonly.d.ts.map
@@ -8,57 +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
- * 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
- }
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
+ }
63
63
  }
64
64
  exports.SignerBtcPublicKeyReadonly = SignerBtcPublicKeyReadonly;
@@ -1,7 +1,3 @@
1
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
2
+ export declare function verifyMessageBtcEcdsa(message: string | BytesLike, signature: string, publicKey: string): boolean;
3
+ //# sourceMappingURL=verify.d.ts.map
@@ -6,15 +6,8 @@ const bitcoinjs_message_1 = require("bitcoinjs-message");
6
6
  const bytes_1 = require("../../bytes");
7
7
  const hex_1 = require("../../hex");
8
8
  function verifyMessageBtcEcdsa(message, signature, publicKey) {
9
- const challenge =
10
- typeof message === "string"
11
- ? message
12
- : (0, hex_1.hexFrom)(message).slice(2);
13
- const [_, ...rawSign] = (0, bytes_1.bytesFrom)(signature, "base64");
14
- return secp256k1_1.secp256k1.verify(
15
- (0, bytes_1.bytesFrom)(rawSign),
16
- (0, bitcoinjs_message_1.magicHash)(challenge),
17
- publicKey,
18
- );
9
+ const challenge = typeof message === "string" ? message : (0, hex_1.hexFrom)(message).slice(2);
10
+ const [_, ...rawSign] = (0, bytes_1.bytesFrom)(signature, "base64");
11
+ return secp256k1_1.secp256k1.verify((0, bytes_1.bytesFrom)(rawSign), (0, bitcoinjs_message_1.magicHash)(challenge), publicKey);
19
12
  }
20
13
  exports.verifyMessageBtcEcdsa = verifyMessageBtcEcdsa;
@@ -3,4 +3,4 @@ export * from "./signerCkbPublicKey";
3
3
  export * from "./signerCkbScriptReadonly";
4
4
  export * from "./verifyCkbSecp256k1";
5
5
  export * from "./verifyJoyId";
6
- //# sourceMappingURL=index.d.ts.map
6
+ //# sourceMappingURL=index.d.ts.map
@@ -1,34 +1,18 @@
1
1
  "use strict";
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
- };
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
+ };
32
16
  Object.defineProperty(exports, "__esModule", { value: true });
33
17
  __exportStar(require("./signerCkbPrivateKey"), exports);
34
18
  __exportStar(require("./signerCkbPublicKey"), exports);
@@ -4,9 +4,10 @@ import { Client } from "../../client";
4
4
  import { Hex, HexLike } from "../../hex";
5
5
  import { SignerCkbPublicKey } from "./signerCkbPublicKey";
6
6
  export declare class SignerCkbPrivateKey extends SignerCkbPublicKey {
7
- readonly privateKey: Hex;
8
- constructor(client: Client, privateKey: HexLike);
9
- signMessageRaw(message: string | BytesLike): Promise<Hex>;
10
- signOnlyTransaction(txLike: TransactionLike): Promise<Transaction>;
7
+ readonly privateKey: Hex;
8
+ constructor(client: Client, privateKey: HexLike);
9
+ _signMessage(message: HexLike): Promise<Hex>;
10
+ signMessageRaw(message: string | BytesLike): Promise<Hex>;
11
+ signOnlyTransaction(txLike: TransactionLike): Promise<Transaction>;
11
12
  }
12
- //# sourceMappingURL=signerCkbPrivateKey.d.ts.map
13
+ //# sourceMappingURL=signerCkbPrivateKey.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"signerCkbPrivateKey.d.ts","sourceRoot":"","sources":["../../../src/signer/ckb/signerCkbPrivateKey.ts"],"names":[],"mappings":"AACA,OAAO,EAA0B,SAAS,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAe,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,GAAG,EAAW,OAAO,EAAE,MAAM,WAAW,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,qBAAa,mBAAoB,SAAQ,kBAAkB;IACzD,SAAgB,UAAU,EAAE,GAAG,CAAC;gBAEpB,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO;IAUzC,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC;IAoBzD,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;CAezE"}
1
+ {"version":3,"file":"signerCkbPrivateKey.d.ts","sourceRoot":"","sources":["../../../src/signer/ckb/signerCkbPrivateKey.ts"],"names":[],"mappings":"AACA,OAAO,EAA0B,SAAS,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAe,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,GAAG,EAAW,OAAO,EAAE,MAAM,WAAW,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,qBAAa,mBAAoB,SAAQ,kBAAkB;IACzD,SAAgB,UAAU,EAAE,GAAG,CAAC;gBAEpB,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO;IAUzC,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC;IAgB5C,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC;IAIzD,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;CAezE"}