@ckb-ccc/core 1.11.5 → 1.12.0
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.
- package/CHANGELOG.md +24 -0
- package/dist/ckb/transaction.d.ts +160 -29
- package/dist/ckb/transaction.d.ts.map +1 -1
- package/dist/ckb/transaction.js +185 -39
- package/dist/client/jsonRpc/client.d.ts +1 -1
- package/dist/client/jsonRpc/client.d.ts.map +1 -1
- package/dist/client/jsonRpc/client.js +4 -1
- package/dist/client/jsonRpc/transformers.d.ts +1 -1
- package/dist/client/jsonRpc/transformers.d.ts.map +1 -1
- package/dist/client/jsonRpc/transformers.js +2 -1
- package/dist/jsonRpc/requestor.js +1 -1
- package/dist/signer/btc/verify.d.ts +21 -0
- package/dist/signer/btc/verify.d.ts.map +1 -1
- package/dist/signer/btc/verify.js +38 -2
- package/dist/signer/doge/signerDogePrivateKey.d.ts.map +1 -1
- package/dist/signer/doge/signerDogePrivateKey.js +2 -2
- package/dist/signer/doge/verify.d.ts +12 -1
- package/dist/signer/doge/verify.d.ts.map +1 -1
- package/dist/signer/doge/verify.js +15 -5
- package/dist/signer/signer/index.d.ts +14 -5
- package/dist/signer/signer/index.d.ts.map +1 -1
- package/dist/signer/signer/index.js +19 -11
- package/dist.commonjs/ckb/transaction.d.ts +160 -29
- package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
- package/dist.commonjs/ckb/transaction.js +187 -40
- package/dist.commonjs/client/jsonRpc/client.d.ts +1 -1
- package/dist.commonjs/client/jsonRpc/client.d.ts.map +1 -1
- package/dist.commonjs/client/jsonRpc/client.js +4 -1
- package/dist.commonjs/client/jsonRpc/transformers.d.ts +1 -1
- package/dist.commonjs/client/jsonRpc/transformers.d.ts.map +1 -1
- package/dist.commonjs/client/jsonRpc/transformers.js +2 -1
- package/dist.commonjs/jsonRpc/requestor.js +1 -1
- package/dist.commonjs/signer/btc/verify.d.ts +21 -0
- package/dist.commonjs/signer/btc/verify.d.ts.map +1 -1
- package/dist.commonjs/signer/btc/verify.js +40 -2
- package/dist.commonjs/signer/doge/signerDogePrivateKey.d.ts.map +1 -1
- package/dist.commonjs/signer/doge/signerDogePrivateKey.js +2 -2
- package/dist.commonjs/signer/doge/verify.d.ts +12 -1
- package/dist.commonjs/signer/doge/verify.d.ts.map +1 -1
- package/dist.commonjs/signer/doge/verify.js +15 -4
- package/dist.commonjs/signer/signer/index.d.ts +14 -5
- package/dist.commonjs/signer/signer/index.d.ts.map +1 -1
- package/dist.commonjs/signer/signer/index.js +21 -13
- package/package.json +3 -4
- package/{prettier.config.mjs → prettier.config.cjs} +2 -4
- package/src/ckb/transaction.ts +254 -80
- package/src/client/jsonRpc/client.ts +5 -2
- package/src/client/jsonRpc/transformers.ts +6 -1
- package/src/jsonRpc/requestor.ts +2 -2
- package/src/signer/btc/verify.ts +52 -3
- package/src/signer/doge/signerDogePrivateKey.ts +2 -2
- package/src/signer/doge/verify.ts +23 -7
- package/src/signer/signer/index.ts +20 -10
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
import { secp256k1 } from "@noble/curves/secp256k1";
|
|
2
|
-
import {
|
|
3
|
-
import { bytesFrom, BytesLike } from "../../bytes/index.js";
|
|
2
|
+
import { Bytes, bytesFrom, BytesLike } from "../../bytes/index.js";
|
|
4
3
|
import { hexFrom } from "../../hex/index.js";
|
|
5
4
|
import {
|
|
6
5
|
btcEcdsaPublicKeyHash,
|
|
7
6
|
btcPublicKeyFromP2pkhAddress,
|
|
7
|
+
messageHashBtcEcdsa,
|
|
8
8
|
} from "../btc/verify.js";
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Computes the message hash for Dogecoin ECDSA signatures.
|
|
12
|
+
* This function follows the Dogecoin message signing standard, which involves
|
|
13
|
+
* prefixing the message with a magic string and its length, then double SHA256 hashing the result.
|
|
14
|
+
*
|
|
15
|
+
* @param message - The message to be hashed. Can be a string or BytesLike.
|
|
16
|
+
* @param messagePrefix - Optional. A custom prefix to use instead of the default "\x19Dogecoin Signed Message:\n".
|
|
17
|
+
* @returns The Dogecoin hash of the prefixed message as Bytes.
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export function messageHashDogeEcdsa(
|
|
21
|
+
message: string | BytesLike,
|
|
22
|
+
messagePrefix?: string | BytesLike,
|
|
23
|
+
): Bytes {
|
|
24
|
+
return messageHashBtcEcdsa(
|
|
25
|
+
message,
|
|
26
|
+
messagePrefix ?? "\x19Dogecoin Signed Message:\n",
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
10
30
|
/**
|
|
11
31
|
* @public
|
|
12
32
|
*/
|
|
@@ -29,11 +49,7 @@ export function verifyMessageDogeEcdsa(
|
|
|
29
49
|
btcPublicKeyFromP2pkhAddress(address) ===
|
|
30
50
|
hexFrom(
|
|
31
51
|
btcEcdsaPublicKeyHash(
|
|
32
|
-
sig
|
|
33
|
-
.recoverPublicKey(
|
|
34
|
-
magicHash(challenge, "\x19Dogecoin Signed Message:\n"),
|
|
35
|
-
)
|
|
36
|
-
.toHex(),
|
|
52
|
+
sig.recoverPublicKey(messageHashDogeEcdsa(challenge)).toHex(),
|
|
37
53
|
),
|
|
38
54
|
)
|
|
39
55
|
);
|
|
@@ -96,11 +96,12 @@ export abstract class Signer {
|
|
|
96
96
|
): NetworkPreference | undefined {
|
|
97
97
|
if (
|
|
98
98
|
currentNetwork !== undefined &&
|
|
99
|
-
preferences.some(
|
|
100
|
-
signerType
|
|
99
|
+
preferences.some(
|
|
100
|
+
({ signerType, addressPrefix, network }) =>
|
|
101
|
+
signerType === this.type &&
|
|
101
102
|
addressPrefix === this.client.addressPrefix &&
|
|
102
|
-
network === currentNetwork
|
|
103
|
-
|
|
103
|
+
network === currentNetwork,
|
|
104
|
+
)
|
|
104
105
|
) {
|
|
105
106
|
return;
|
|
106
107
|
}
|
|
@@ -459,14 +460,23 @@ export abstract class Signer {
|
|
|
459
460
|
}
|
|
460
461
|
|
|
461
462
|
/**
|
|
462
|
-
*
|
|
463
|
+
* Prepares a transaction before signing.
|
|
464
|
+
* This method can be overridden by subclasses to perform any necessary steps,
|
|
465
|
+
* such as adding cell dependencies or witnesses, before the transaction is signed.
|
|
466
|
+
* The default implementation converts the {@link TransactionLike} object to a {@link Transaction} object
|
|
467
|
+
* without modification.
|
|
463
468
|
*
|
|
464
|
-
* @
|
|
465
|
-
*
|
|
466
|
-
*
|
|
469
|
+
* @remarks
|
|
470
|
+
* Note that this default implementation does not add any cell dependencies or dummy witnesses.
|
|
471
|
+
* This may lead to an underestimation of transaction size and fees if used with methods
|
|
472
|
+
* like `Transaction.completeFee`. Subclasses for signers that are intended to sign
|
|
473
|
+
* transactions should override this method to perform necessary preparations.
|
|
474
|
+
*
|
|
475
|
+
* @param tx - The transaction to prepare.
|
|
476
|
+
* @returns A promise that resolves to the prepared {@link Transaction} object.
|
|
467
477
|
*/
|
|
468
|
-
prepareTransaction(
|
|
469
|
-
|
|
478
|
+
async prepareTransaction(tx: TransactionLike): Promise<Transaction> {
|
|
479
|
+
return Transaction.from(tx);
|
|
470
480
|
}
|
|
471
481
|
|
|
472
482
|
/**
|