@ckb-ccc/core 0.1.0-alpha.7 → 0.1.1
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 +33 -0
- package/dist/ckb/transactionLumos.d.ts +2 -1
- package/dist/ckb/transactionLumos.d.ts.map +1 -1
- package/dist/client/client.js +1 -1
- package/dist/signer/btc/signerBtc.d.ts.map +1 -1
- package/dist/signer/btc/signerBtc.js +2 -3
- package/dist/signer/btc/verify.d.ts +14 -1
- package/dist/signer/btc/verify.d.ts.map +1 -1
- package/dist/signer/btc/verify.js +22 -1
- package/dist/signer/doge/index.d.ts +5 -0
- package/dist/signer/doge/index.d.ts.map +1 -0
- package/dist/signer/doge/index.js +4 -0
- package/dist/signer/doge/signerDoge.d.ts +52 -0
- package/dist/signer/doge/signerDoge.d.ts.map +1 -0
- package/dist/signer/doge/signerDoge.js +82 -0
- package/dist/signer/doge/signerDogeAddressReadonly.d.ts +41 -0
- package/dist/signer/doge/signerDogeAddressReadonly.d.ts.map +1 -0
- package/dist/signer/doge/signerDogeAddressReadonly.js +45 -0
- package/dist/signer/doge/signerDogePrivateKey.d.ts +52 -0
- package/dist/signer/doge/signerDogePrivateKey.d.ts.map +1 -0
- package/dist/signer/doge/signerDogePrivateKey.js +68 -0
- package/dist/signer/doge/verify.d.ts +6 -0
- package/dist/signer/doge/verify.d.ts.map +1 -0
- package/dist/signer/doge/verify.js +17 -0
- package/dist/signer/index.d.ts +1 -0
- package/dist/signer/index.d.ts.map +1 -1
- package/dist/signer/index.js +1 -0
- package/dist/signer/nostr/index.d.ts +1 -0
- package/dist/signer/nostr/index.d.ts.map +1 -1
- package/dist/signer/nostr/index.js +1 -0
- package/dist/signer/signer/index.d.ts +4 -2
- package/dist/signer/signer/index.d.ts.map +1 -1
- package/dist/signer/signer/index.js +5 -0
- package/dist.commonjs/address/address.advanced.js +23 -28
- package/dist.commonjs/address/advanced.js +1 -17
- package/dist.commonjs/address/index.js +11 -15
- package/dist.commonjs/advanced.js +2 -31
- package/dist.commonjs/advancedBarrel.js +5 -21
- package/dist.commonjs/barrel.js +12 -41
- package/dist.commonjs/bytes/advanced.js +1 -2
- package/dist.commonjs/bytes/index.js +7 -12
- package/dist.commonjs/ckb/advanced.js +3 -32
- package/dist.commonjs/ckb/index.js +3 -19
- package/dist.commonjs/ckb/molecule.advanced/generated.js +64 -131
- package/dist.commonjs/ckb/molecule.advanced/index.js +2 -19
- package/dist.commonjs/ckb/script.advanced.js +3 -6
- package/dist.commonjs/ckb/script.js +23 -53
- package/dist.commonjs/ckb/transaction.advanced.js +3 -6
- package/dist.commonjs/ckb/transaction.js +122 -163
- package/dist.commonjs/ckb/transactionLumos.d.ts +2 -1
- package/dist.commonjs/ckb/transactionLumos.d.ts.map +1 -1
- package/dist.commonjs/ckb/transactionLumos.js +1 -2
- package/dist.commonjs/client/advanced.js +6 -22
- package/dist.commonjs/client/cache/advanced.js +1 -17
- package/dist.commonjs/client/cache/cache.js +3 -7
- package/dist.commonjs/client/cache/index.js +2 -18
- package/dist.commonjs/client/cache/memory.advanced.js +21 -28
- package/dist.commonjs/client/cache/memory.js +19 -23
- package/dist.commonjs/client/client.js +22 -26
- package/dist.commonjs/client/clientPublicMainnet.advanced.js +22 -25
- package/dist.commonjs/client/clientPublicMainnet.js +8 -15
- package/dist.commonjs/client/clientPublicTestnet.advanced.js +22 -25
- package/dist.commonjs/client/clientPublicTestnet.js +8 -15
- package/dist.commonjs/client/clientTypes.advanced.js +3 -6
- package/dist.commonjs/client/clientTypes.js +29 -43
- package/dist.commonjs/client/index.js +6 -22
- package/dist.commonjs/client/jsonRpc/advanced.js +2 -18
- package/dist.commonjs/client/jsonRpc/index.js +37 -41
- package/dist.commonjs/client/jsonRpc/transformers.js +57 -61
- package/dist.commonjs/client/jsonRpc/types.js +1 -2
- package/dist.commonjs/client/transports/advanced.js +8 -25
- package/dist.commonjs/client/transports/http.js +1 -5
- package/dist.commonjs/client/transports/transport.js +1 -2
- package/dist.commonjs/client/transports/webSocket.js +3 -10
- package/dist.commonjs/fixedPoint/index.js +4 -9
- package/dist.commonjs/hasher/advanced.js +1 -4
- package/dist.commonjs/hasher/hasher.js +1 -2
- package/dist.commonjs/hasher/hasherCkb.js +14 -20
- package/dist.commonjs/hasher/hasherKeecak256.js +7 -11
- package/dist.commonjs/hasher/index.js +3 -19
- package/dist.commonjs/hex/index.js +3 -6
- package/dist.commonjs/index.js +2 -31
- package/dist.commonjs/keystore/index.js +21 -25
- package/dist.commonjs/molecule/codec.js +48 -63
- package/dist.commonjs/molecule/index.js +2 -18
- package/dist.commonjs/molecule/predefined.js +77 -103
- package/dist.commonjs/num/index.js +17 -29
- package/dist.commonjs/signer/btc/index.js +3 -19
- package/dist.commonjs/signer/btc/signerBtc.d.ts.map +1 -1
- package/dist.commonjs/signer/btc/signerBtc.js +20 -25
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +4 -8
- package/dist.commonjs/signer/btc/verify.d.ts +14 -1
- package/dist.commonjs/signer/btc/verify.d.ts.map +1 -1
- package/dist.commonjs/signer/btc/verify.js +29 -11
- package/dist.commonjs/signer/ckb/index.js +5 -21
- package/dist.commonjs/signer/ckb/signerCkbPrivateKey.js +16 -20
- package/dist.commonjs/signer/ckb/signerCkbPublicKey.js +20 -24
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +8 -12
- package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.js +12 -16
- package/dist.commonjs/signer/ckb/verifyJoyId.js +5 -8
- package/dist.commonjs/signer/doge/index.d.ts +5 -0
- package/dist.commonjs/signer/doge/index.d.ts.map +1 -0
- package/dist.commonjs/signer/doge/index.js +4 -0
- package/dist.commonjs/signer/doge/signerDoge.d.ts +52 -0
- package/dist.commonjs/signer/doge/signerDoge.d.ts.map +1 -0
- package/dist.commonjs/signer/doge/signerDoge.js +82 -0
- package/dist.commonjs/signer/doge/signerDogeAddressReadonly.d.ts +41 -0
- package/dist.commonjs/signer/doge/signerDogeAddressReadonly.d.ts.map +1 -0
- package/dist.commonjs/signer/doge/signerDogeAddressReadonly.js +45 -0
- package/dist.commonjs/signer/doge/signerDogePrivateKey.d.ts +52 -0
- package/dist.commonjs/signer/doge/signerDogePrivateKey.d.ts.map +1 -0
- package/dist.commonjs/signer/doge/signerDogePrivateKey.js +68 -0
- package/dist.commonjs/signer/doge/verify.d.ts +6 -0
- package/dist.commonjs/signer/doge/verify.d.ts.map +1 -0
- package/dist.commonjs/signer/doge/verify.js +17 -0
- package/dist.commonjs/signer/dummy/alwaysError.js +2 -6
- package/dist.commonjs/signer/dummy/dummy.js +3 -7
- package/dist.commonjs/signer/dummy/index.js +3 -19
- package/dist.commonjs/signer/dummy/openLink.js +2 -6
- package/dist.commonjs/signer/evm/index.js +3 -19
- package/dist.commonjs/signer/evm/signerEvm.js +31 -35
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +4 -8
- package/dist.commonjs/signer/evm/verify.js +4 -7
- package/dist.commonjs/signer/index.d.ts +1 -0
- package/dist.commonjs/signer/index.d.ts.map +1 -1
- package/dist.commonjs/signer/index.js +7 -22
- package/dist.commonjs/signer/nostr/index.d.ts +1 -0
- package/dist.commonjs/signer/nostr/index.d.ts.map +1 -1
- package/dist.commonjs/signer/nostr/index.js +2 -17
- package/dist.commonjs/signer/nostr/signerNostr.js +21 -25
- package/dist.commonjs/signer/nostr/verify.js +12 -16
- package/dist.commonjs/signer/signer/index.d.ts +4 -2
- package/dist.commonjs/signer/signer/index.d.ts.map +1 -1
- package/dist.commonjs/signer/signer/index.js +22 -23
- package/dist.commonjs/utils/index.js +6 -12
- package/package.json +8 -1
- package/src/ckb/transactionLumos.ts +2 -1
- package/src/client/client.ts +1 -1
- package/src/signer/btc/signerBtc.ts +2 -3
- package/src/signer/btc/verify.ts +31 -2
- package/src/signer/doge/index.ts +4 -0
- package/src/signer/doge/signerDoge.ts +116 -0
- package/src/signer/doge/signerDogeAddressReadonly.ts +52 -0
- package/src/signer/doge/signerDogePrivateKey.ts +97 -0
- package/src/signer/doge/verify.ts +38 -0
- package/src/signer/index.ts +1 -0
- package/src/signer/nostr/index.ts +1 -0
- package/src/signer/signer/index.ts +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @ckb-ccc/core
|
|
2
2
|
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#101](https://github.com/ckb-devrel/ccc/pull/101) [`d9affcc`](https://github.com/ckb-devrel/ccc/commit/d9affcc01c7b839b227e4d79bcb66e717577502a) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix: commonjs
|
|
8
|
+
|
|
9
|
+
## 0.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#74](https://github.com/ckb-devrel/ccc/pull/74) [`f21d7e4`](https://github.com/ckb-devrel/ccc/commit/f21d7e4cf422edab4a836ef6d678b620594fef8d) Thanks [@Hanssen0](https://github.com/Hanssen0)! - add spore package and some known scripts
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#72](https://github.com/ckb-devrel/ccc/pull/72) [`a3d5359`](https://github.com/ckb-devrel/ccc/commit/a3d53595f6dd11f2f59cdf0086b3d7ce558a2fdd) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix(core): reopen websocket
|
|
18
|
+
|
|
19
|
+
- [#69](https://github.com/ckb-devrel/ccc/pull/69) [`8824ff2`](https://github.com/ckb-devrel/ccc/commit/8824ff27af3b76186f1a7d6db8c907cd66f09d6a) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(core): Client.waitTransaction
|
|
20
|
+
|
|
21
|
+
- [#88](https://github.com/ckb-devrel/ccc/pull/88) [`f07a506`](https://github.com/ckb-devrel/ccc/commit/f07a506bd6fc27fe659a17d2f7baaeec54716d81) Thanks [@ashuralyk](https://github.com/ashuralyk)! - feat: molecule codec
|
|
22
|
+
feat: spore searcher
|
|
23
|
+
|
|
24
|
+
- [#70](https://github.com/ckb-devrel/ccc/pull/70) [`acfc050`](https://github.com/ckb-devrel/ccc/commit/acfc0502cd6beb48b9310dec8411dcd630507366) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix(core): websocket transport
|
|
25
|
+
|
|
26
|
+
- [#64](https://github.com/ckb-devrel/ccc/pull/64) [`1720d5a`](https://github.com/ckb-devrel/ccc/commit/1720d5a398543f1c6e24763eeaf15d84cd2214bf) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(core): ckb proxy locks
|
|
27
|
+
|
|
28
|
+
- [#96](https://github.com/ckb-devrel/ccc/pull/96) [`e63a06e`](https://github.com/ckb-devrel/ccc/commit/e63a06ee75ac8595208d216dec88a4228c465e23) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat: support doge signer
|
|
29
|
+
|
|
30
|
+
- [#67](https://github.com/ckb-devrel/ccc/pull/67) [`c092988`](https://github.com/ckb-devrel/ccc/commit/c092988e7765b9ac79498d6bd72a6a2f62859b6f) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(core): auto fee rate
|
|
31
|
+
|
|
32
|
+
- [`50f2ce0`](https://github.com/ckb-devrel/ccc/commit/50f2ce08e74cb3fbeae926267d42e28b426fd7f4) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix(core): missing mol types
|
|
33
|
+
|
|
34
|
+
- [#92](https://github.com/ckb-devrel/ccc/pull/92) [`4709384`](https://github.com/ckb-devrel/ccc/commit/4709384e37188991cb937b16f99f47ca82c912b8) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix: `epochFromHex` failed if the arg is not 7 bytes
|
|
35
|
+
|
|
3
36
|
## 0.1.0-alpha.7
|
|
4
37
|
|
|
5
38
|
### Patch Changes
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { CellDepLike, CellOutputLike,
|
|
1
|
+
import { CellDepLike, CellOutputLike, OutPointLike } from "../ckb/index.js";
|
|
2
|
+
import { HexLike } from "../hex/index.js";
|
|
2
3
|
export interface LumosTransactionSkeletonType {
|
|
3
4
|
cellDeps: {
|
|
4
5
|
toArray(): CellDepLike[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactionLumos.d.ts","sourceRoot":"","sources":["../../src/ckb/transactionLumos.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"transactionLumos.d.ts","sourceRoot":"","sources":["../../src/ckb/transactionLumos.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,EAAE;QACR,OAAO,IAAI,WAAW,EAAE,CAAC;KAC1B,CAAC;IACF,UAAU,EAAE;QACV,OAAO,IAAI,OAAO,EAAE,CAAC;KACtB,CAAC;IACF,MAAM,EAAE;QACN,OAAO,IAAI;YACT,QAAQ,CAAC,EAAE,YAAY,CAAC;YACxB,UAAU,EAAE,cAAc,CAAC;YAC3B,IAAI,EAAE,OAAO,CAAC;SACf,EAAE,CAAC;KACL,CAAC;IACF,WAAW,EAAE;QACX,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;KAC7C,CAAC;IACF,OAAO,EAAE;QACP,OAAO,IAAI;YAAE,UAAU,EAAE,cAAc,CAAC;YAAC,IAAI,EAAE,OAAO,CAAA;SAAE,EAAE,CAAC;KAC5D,CAAC;IACF,SAAS,EAAE;QACT,OAAO,IAAI,OAAO,EAAE,CAAC;KACtB,CAAC;CACH"}
|
package/dist/client/client.js
CHANGED
|
@@ -197,7 +197,7 @@ export class Client {
|
|
|
197
197
|
transaction: tx,
|
|
198
198
|
};
|
|
199
199
|
}
|
|
200
|
-
async waitTransaction(txHash, confirmations = 0, timeout =
|
|
200
|
+
async waitTransaction(txHash, confirmations = 0, timeout = 60000, interval = 2000) {
|
|
201
201
|
const startTime = Date.now();
|
|
202
202
|
let tx;
|
|
203
203
|
const getTx = async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signerBtc.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/signerBtc.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"signerBtc.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/signerBtc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAe,MAAM,oBAAoB,CAAC;AAE/E,OAAO,EAAE,OAAO,EAAW,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGxE;;;;;GAKG;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;IAQvE;;;;;OAKG;IACG,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;CA+BzE"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { ripemd160 } from "@noble/hashes/ripemd160";
|
|
2
|
-
import { sha256 } from "@noble/hashes/sha256";
|
|
3
1
|
import { Address } from "../../address/index.js";
|
|
4
2
|
import { bytesConcat, bytesFrom } from "../../bytes/index.js";
|
|
5
3
|
import { Transaction, WitnessArgs } from "../../ckb/index.js";
|
|
@@ -7,6 +5,7 @@ import { KnownScript } from "../../client/index.js";
|
|
|
7
5
|
import { hexFrom } from "../../hex/index.js";
|
|
8
6
|
import { numToBytes } from "../../num/index.js";
|
|
9
7
|
import { Signer, SignerSignType, SignerType } from "../signer/index.js";
|
|
8
|
+
import { btcEcdsaPublicKeyHash } from "./verify.js";
|
|
10
9
|
/**
|
|
11
10
|
* An abstract class extending the Signer class for Bitcoin-like signing operations.
|
|
12
11
|
* This class provides methods to get Bitcoin account, public key, and internal address,
|
|
@@ -43,7 +42,7 @@ export class SignerBtc extends Signer {
|
|
|
43
42
|
*/
|
|
44
43
|
async getAddressObjs() {
|
|
45
44
|
const publicKey = await this.getBtcPublicKey();
|
|
46
|
-
const hash =
|
|
45
|
+
const hash = btcEcdsaPublicKeyHash(publicKey);
|
|
47
46
|
return [
|
|
48
47
|
await Address.fromKnownScript(this.client, KnownScript.OmniLock, hexFrom([0x04, ...hash, 0x00])),
|
|
49
48
|
];
|
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
import { BytesLike } from "../../bytes/index.js";
|
|
1
|
+
import { Bytes, BytesLike } from "../../bytes/index.js";
|
|
2
|
+
import { Hex } from "../../hex/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export declare function btcEcdsaPublicKeyHash(publicKey: BytesLike): Bytes;
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export declare function btcP2pkhAddressFromPublicKey(publicKey: BytesLike, network: number): string;
|
|
11
|
+
/**
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export declare function btcPublicKeyFromP2pkhAddress(address: string): Hex;
|
|
2
15
|
/**
|
|
3
16
|
* @public
|
|
4
17
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/verify.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../src/signer/btc/verify.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,EAAE,SAAS,EAA0B,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,GAAG,EAAW,MAAM,oBAAoB,CAAC;AAElD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,SAAS,GAAG,KAAK,CAEjE;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,MAAM,GACd,MAAM,CAIR;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAEjE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,OAAO,CAOT"}
|
|
@@ -1,7 +1,28 @@
|
|
|
1
1
|
import { secp256k1 } from "@noble/curves/secp256k1";
|
|
2
|
+
import { ripemd160 } from "@noble/hashes/ripemd160";
|
|
3
|
+
import { sha256 } from "@noble/hashes/sha256";
|
|
2
4
|
import { magicHash } from "bitcoinjs-message";
|
|
3
|
-
import
|
|
5
|
+
import bs58check from "bs58check";
|
|
6
|
+
import { bytesConcat, bytesFrom } from "../../bytes/index.js";
|
|
4
7
|
import { hexFrom } from "../../hex/index.js";
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export function btcEcdsaPublicKeyHash(publicKey) {
|
|
12
|
+
return ripemd160(sha256(bytesFrom(publicKey)));
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export function btcP2pkhAddressFromPublicKey(publicKey, network) {
|
|
18
|
+
return bs58check.encode(bytesConcat([network], btcEcdsaPublicKeyHash(publicKey)));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export function btcPublicKeyFromP2pkhAddress(address) {
|
|
24
|
+
return hexFrom(bs58check.decode(address).slice(1));
|
|
25
|
+
}
|
|
5
26
|
/**
|
|
6
27
|
* @public
|
|
7
28
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/doge/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Address } from "../../address/index.js";
|
|
2
|
+
import { Transaction, TransactionLike } from "../../ckb/index.js";
|
|
3
|
+
import { Signer, SignerSignType, SignerType } from "../signer/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* An abstract class extending the Signer class for Dogecoin-like signing operations.
|
|
6
|
+
* This class provides methods to get Doge account, public key, and internal address,
|
|
7
|
+
* as well as signing transactions.
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export declare abstract class SignerDoge extends Signer {
|
|
11
|
+
get type(): SignerType;
|
|
12
|
+
get signType(): SignerSignType;
|
|
13
|
+
/**
|
|
14
|
+
* Gets the Doge address associated with the signer.
|
|
15
|
+
*
|
|
16
|
+
* @returns A promise that resolves to a string representing the Doge account.
|
|
17
|
+
*/
|
|
18
|
+
abstract getDogeAddress(): Promise<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Gets the internal address, which is the Doge account in this case.
|
|
21
|
+
*
|
|
22
|
+
* @returns A promise that resolves to a string representing the internal address.
|
|
23
|
+
*/
|
|
24
|
+
getInternalAddress(): Promise<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Gets the identity, which is the Doge address in this case.
|
|
27
|
+
*
|
|
28
|
+
* @returns A promise that resolves to a string representing the identity
|
|
29
|
+
*/
|
|
30
|
+
getIdentity(): Promise<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Gets an array of Address objects representing the known script addresses for the signer.
|
|
33
|
+
*
|
|
34
|
+
* @returns A promise that resolves to an array of Address objects.
|
|
35
|
+
*/
|
|
36
|
+
getAddressObjs(): Promise<Address[]>;
|
|
37
|
+
/**
|
|
38
|
+
* prepare a transaction before signing. This method is not implemented and should be overridden by subclasses.
|
|
39
|
+
*
|
|
40
|
+
* @param txLike - The transaction to prepare, represented as a TransactionLike object.
|
|
41
|
+
* @returns A promise that resolves to the prepared Transaction object.
|
|
42
|
+
*/
|
|
43
|
+
prepareTransaction(txLike: TransactionLike): Promise<Transaction>;
|
|
44
|
+
/**
|
|
45
|
+
* Signs a transaction without modifying it.
|
|
46
|
+
*
|
|
47
|
+
* @param txLike - The transaction to sign, represented as a TransactionLike object.
|
|
48
|
+
* @returns A promise that resolves to a signed Transaction object.
|
|
49
|
+
*/
|
|
50
|
+
signOnlyTransaction(txLike: TransactionLike): Promise<Transaction>;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=signerDoge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signerDoge.d.ts","sourceRoot":"","sources":["../../../src/signer/doge/signerDoge.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAe,MAAM,oBAAoB,CAAC;AAI/E,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAExE;;;;;GAKG;AACH,8BAAsB,UAAW,SAAQ,MAAM;IAC7C,IAAI,IAAI,IAAI,UAAU,CAErB;IAED,IAAI,QAAQ,IAAI,cAAc,CAE7B;IAED;;;;OAIG;IACH,QAAQ,CAAC,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;IAE1C;;;;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;IAY1C;;;;;OAKG;IACG,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IAQvE;;;;;OAKG;IACG,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;CA6BzE"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import bs58check from "bs58check";
|
|
2
|
+
import { Address } from "../../address/index.js";
|
|
3
|
+
import { bytesConcat, bytesFrom } from "../../bytes/index.js";
|
|
4
|
+
import { Transaction, WitnessArgs } from "../../ckb/index.js";
|
|
5
|
+
import { KnownScript } from "../../client/index.js";
|
|
6
|
+
import { hexFrom } from "../../hex/index.js";
|
|
7
|
+
import { numToBytes } from "../../num/index.js";
|
|
8
|
+
import { Signer, SignerSignType, SignerType } from "../signer/index.js";
|
|
9
|
+
/**
|
|
10
|
+
* An abstract class extending the Signer class for Dogecoin-like signing operations.
|
|
11
|
+
* This class provides methods to get Doge account, public key, and internal address,
|
|
12
|
+
* as well as signing transactions.
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export class SignerDoge extends Signer {
|
|
16
|
+
get type() {
|
|
17
|
+
return SignerType.Doge;
|
|
18
|
+
}
|
|
19
|
+
get signType() {
|
|
20
|
+
return SignerSignType.DogeEcdsa;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Gets the internal address, which is the Doge account in this case.
|
|
24
|
+
*
|
|
25
|
+
* @returns A promise that resolves to a string representing the internal address.
|
|
26
|
+
*/
|
|
27
|
+
async getInternalAddress() {
|
|
28
|
+
return this.getDogeAddress();
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Gets the identity, which is the Doge address in this case.
|
|
32
|
+
*
|
|
33
|
+
* @returns A promise that resolves to a string representing the identity
|
|
34
|
+
*/
|
|
35
|
+
async getIdentity() {
|
|
36
|
+
return this.getDogeAddress();
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Gets an array of Address objects representing the known script addresses for the signer.
|
|
40
|
+
*
|
|
41
|
+
* @returns A promise that resolves to an array of Address objects.
|
|
42
|
+
*/
|
|
43
|
+
async getAddressObjs() {
|
|
44
|
+
const hash = bs58check.decode(await this.getDogeAddress()).slice(1);
|
|
45
|
+
return [
|
|
46
|
+
await Address.fromKnownScript(this.client, KnownScript.OmniLock, hexFrom([0x05, ...hash, 0x00])),
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* prepare a transaction before signing. This method is not implemented and should be overridden by subclasses.
|
|
51
|
+
*
|
|
52
|
+
* @param txLike - The transaction to prepare, represented as a TransactionLike object.
|
|
53
|
+
* @returns A promise that resolves to the prepared Transaction object.
|
|
54
|
+
*/
|
|
55
|
+
async prepareTransaction(txLike) {
|
|
56
|
+
const tx = Transaction.from(txLike);
|
|
57
|
+
const { script } = await this.getRecommendedAddressObj();
|
|
58
|
+
await tx.addCellDepsOfKnownScripts(this.client, KnownScript.OmniLock);
|
|
59
|
+
await tx.prepareSighashAllWitness(script, 85, this.client);
|
|
60
|
+
return tx;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Signs a transaction without modifying it.
|
|
64
|
+
*
|
|
65
|
+
* @param txLike - The transaction to sign, represented as a TransactionLike object.
|
|
66
|
+
* @returns A promise that resolves to a signed Transaction object.
|
|
67
|
+
*/
|
|
68
|
+
async signOnlyTransaction(txLike) {
|
|
69
|
+
const tx = Transaction.from(txLike);
|
|
70
|
+
const { script } = await this.getRecommendedAddressObj();
|
|
71
|
+
const info = await tx.getSignHashInfo(script, this.client);
|
|
72
|
+
if (!info) {
|
|
73
|
+
return tx;
|
|
74
|
+
}
|
|
75
|
+
const signature = bytesFrom(await this.signMessageRaw(info.message.slice(2)), "base64");
|
|
76
|
+
signature[0] = 31 + ((signature[0] - 27) % 4);
|
|
77
|
+
const witness = WitnessArgs.fromBytes(tx.witnesses[info.position]);
|
|
78
|
+
witness.lock = hexFrom(bytesConcat(numToBytes(5 * 4 + signature.length, 4), numToBytes(4 * 4, 4), numToBytes(5 * 4 + signature.length, 4), numToBytes(5 * 4 + signature.length, 4), numToBytes(signature.length, 4), signature));
|
|
79
|
+
tx.setWitnessArgsAt(info.position, witness);
|
|
80
|
+
return tx;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Client } from "../../client/index.js";
|
|
2
|
+
import { SignerDoge } from "./signerDoge.js";
|
|
3
|
+
/**
|
|
4
|
+
* A class extending SignerDoge that provides read-only access to a Doge address.
|
|
5
|
+
* This class does not support signing operations.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare class SignerDogeAddressReadonly extends SignerDoge {
|
|
9
|
+
private readonly address;
|
|
10
|
+
/**
|
|
11
|
+
* Creates an instance of SignerDogeAddressReadonly.
|
|
12
|
+
*
|
|
13
|
+
* @param client - The client instance used for communication.
|
|
14
|
+
* @param address - The Doge address with the signer.
|
|
15
|
+
*/
|
|
16
|
+
constructor(client: Client, address: string);
|
|
17
|
+
/**
|
|
18
|
+
* Connects to the client. This implementation does nothing as the class is read-only.
|
|
19
|
+
*
|
|
20
|
+
* @returns A promise that resolves when the connection is complete.
|
|
21
|
+
*/
|
|
22
|
+
connect(): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Check if the signer is connected.
|
|
25
|
+
*
|
|
26
|
+
* @returns A promise that resolves the connection status.
|
|
27
|
+
*/
|
|
28
|
+
isConnected(): Promise<boolean>;
|
|
29
|
+
/**
|
|
30
|
+
* Gets the Doge address associated with the signer.
|
|
31
|
+
*
|
|
32
|
+
* @returns A promise that resolves to a string representing the Doge address.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const account = await signer.getDogeAddress(); // Outputs the Doge address
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
getDogeAddress(): Promise<string>;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=signerDogeAddressReadonly.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signerDogeAddressReadonly.d.ts","sourceRoot":"","sources":["../../../src/signer/doge/signerDogeAddressReadonly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;;;GAIG;AACH,qBAAa,yBAA0B,SAAQ,UAAU;IASrD,OAAO,CAAC,QAAQ,CAAC,OAAO;IAR1B;;;;;OAKG;gBAED,MAAM,EAAE,MAAM,EACG,OAAO,EAAE,MAAM;IAKlC;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAE9B;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAIrC;;;;;;;;;OASG;IACG,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;CAGxC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { SignerDoge } from "./signerDoge.js";
|
|
2
|
+
/**
|
|
3
|
+
* A class extending SignerDoge that provides read-only access to a Doge address.
|
|
4
|
+
* This class does not support signing operations.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export class SignerDogeAddressReadonly extends SignerDoge {
|
|
8
|
+
/**
|
|
9
|
+
* Creates an instance of SignerDogeAddressReadonly.
|
|
10
|
+
*
|
|
11
|
+
* @param client - The client instance used for communication.
|
|
12
|
+
* @param address - The Doge address with the signer.
|
|
13
|
+
*/
|
|
14
|
+
constructor(client, address) {
|
|
15
|
+
super(client);
|
|
16
|
+
this.address = address;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Connects to the client. This implementation does nothing as the class is read-only.
|
|
20
|
+
*
|
|
21
|
+
* @returns A promise that resolves when the connection is complete.
|
|
22
|
+
*/
|
|
23
|
+
async connect() { }
|
|
24
|
+
/**
|
|
25
|
+
* Check if the signer is connected.
|
|
26
|
+
*
|
|
27
|
+
* @returns A promise that resolves the connection status.
|
|
28
|
+
*/
|
|
29
|
+
async isConnected() {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Gets the Doge address associated with the signer.
|
|
34
|
+
*
|
|
35
|
+
* @returns A promise that resolves to a string representing the Doge address.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const account = await signer.getDogeAddress(); // Outputs the Doge address
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
async getDogeAddress() {
|
|
43
|
+
return this.address;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { BytesLike } from "../../bytes/index.js";
|
|
2
|
+
import { Client } from "../../client/index.js";
|
|
3
|
+
import { Hex } from "../../hex/index.js";
|
|
4
|
+
import { SignerDoge } from "./signerDoge.js";
|
|
5
|
+
/**
|
|
6
|
+
* A class extending SignerDoge that provides access to a Doge address.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare class SignerDogePrivateKey extends SignerDoge {
|
|
10
|
+
readonly dogeNetwork: number;
|
|
11
|
+
private readonly privateKey;
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of SignerDogePrivateKey
|
|
14
|
+
*
|
|
15
|
+
* @param client - The client instance used for communication.
|
|
16
|
+
* @param privateKey - The Doge private key with the signer.
|
|
17
|
+
*/
|
|
18
|
+
constructor(client: Client, privateKey: BytesLike, dogeNetwork?: number);
|
|
19
|
+
/**
|
|
20
|
+
* Connects to the client. This implementation does nothing as the class is always connected.
|
|
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
|
+
getDogePublicKey(): Promise<Hex>;
|
|
32
|
+
/**
|
|
33
|
+
* Gets the Doge address associated with the signer.
|
|
34
|
+
*
|
|
35
|
+
* @returns A promise that resolves to a string representing the Doge address.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const account = await signer.getDogeAddress(); // Outputs the Doge address
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
getDogeAddress(): Promise<string>;
|
|
43
|
+
/**
|
|
44
|
+
* Signs a message and returns signature only.
|
|
45
|
+
*
|
|
46
|
+
* @param msg - The message to sign, as a string or BytesLike object.
|
|
47
|
+
* @returns A promise that resolves to the signature as a string.
|
|
48
|
+
* @throws Will throw an error if not implemented.
|
|
49
|
+
*/
|
|
50
|
+
signMessageRaw(msg: string | BytesLike): Promise<string>;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=signerDogePrivateKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signerDogePrivateKey.d.ts","sourceRoot":"","sources":["../../../src/signer/doge/signerDogePrivateKey.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,SAAS,EAEV,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAW,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;;GAGG;AACH,qBAAa,oBAAqB,SAAQ,UAAU;aAYhC,WAAW;IAX7B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAQ;IAEnC;;;;;OAKG;gBAED,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,SAAS,EACL,WAAW,SAAO;IASpC;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAE9B;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAI/B,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC;IAItC;;;;;;;;;OASG;IACG,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;IAOvC;;;;;;OAMG;IACG,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;CAa/D"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { secp256k1 } from "@noble/curves/secp256k1";
|
|
2
|
+
import { magicHash } from "bitcoinjs-message";
|
|
3
|
+
import { bytesConcat, bytesFrom, bytesTo, } from "../../bytes/index.js";
|
|
4
|
+
import { hexFrom } from "../../hex/index.js";
|
|
5
|
+
import { btcP2pkhAddressFromPublicKey } from "../btc/verify.js";
|
|
6
|
+
import { SignerDoge } from "./signerDoge.js";
|
|
7
|
+
/**
|
|
8
|
+
* A class extending SignerDoge that provides access to a Doge address.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export class SignerDogePrivateKey extends SignerDoge {
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of SignerDogePrivateKey
|
|
14
|
+
*
|
|
15
|
+
* @param client - The client instance used for communication.
|
|
16
|
+
* @param privateKey - The Doge private key with the signer.
|
|
17
|
+
*/
|
|
18
|
+
constructor(client, privateKey, dogeNetwork = 0x1e) {
|
|
19
|
+
super(client);
|
|
20
|
+
this.dogeNetwork = dogeNetwork;
|
|
21
|
+
this.privateKey = bytesFrom(privateKey);
|
|
22
|
+
if (this.privateKey.length !== 32) {
|
|
23
|
+
throw new Error("Private key must be 32 bytes!");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Connects to the client. This implementation does nothing as the class is always connected.
|
|
28
|
+
*
|
|
29
|
+
* @returns A promise that resolves when the connection is complete.
|
|
30
|
+
*/
|
|
31
|
+
async connect() { }
|
|
32
|
+
/**
|
|
33
|
+
* Check if the signer is connected.
|
|
34
|
+
*
|
|
35
|
+
* @returns A promise that resolves the connection status.
|
|
36
|
+
*/
|
|
37
|
+
async isConnected() {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
async getDogePublicKey() {
|
|
41
|
+
return hexFrom(secp256k1.getPublicKey(this.privateKey, true));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Gets the Doge address associated with the signer.
|
|
45
|
+
*
|
|
46
|
+
* @returns A promise that resolves to a string representing the Doge address.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const account = await signer.getDogeAddress(); // Outputs the Doge address
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
async getDogeAddress() {
|
|
54
|
+
return btcP2pkhAddressFromPublicKey(await this.getDogePublicKey(), this.dogeNetwork);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Signs a message and returns signature only.
|
|
58
|
+
*
|
|
59
|
+
* @param msg - The message to sign, as a string or BytesLike object.
|
|
60
|
+
* @returns A promise that resolves to the signature as a string.
|
|
61
|
+
* @throws Will throw an error if not implemented.
|
|
62
|
+
*/
|
|
63
|
+
async signMessageRaw(msg) {
|
|
64
|
+
const challenge = typeof msg === "string" ? msg : hexFrom(msg).slice(2);
|
|
65
|
+
const signature = secp256k1.sign(magicHash(challenge, "\x19Dogecoin Signed Message:\n"), this.privateKey);
|
|
66
|
+
return bytesTo(bytesConcat([31 + signature.recovery], signature.toCompactRawBytes()), "base64");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../src/signer/doge/verify.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAO5D;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,OAAO,CAqBT"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { secp256k1 } from "@noble/curves/secp256k1";
|
|
2
|
+
import { magicHash } from "bitcoinjs-message";
|
|
3
|
+
import { bytesFrom } from "../../bytes/index.js";
|
|
4
|
+
import { hexFrom } from "../../hex/index.js";
|
|
5
|
+
import { btcEcdsaPublicKeyHash, btcPublicKeyFromP2pkhAddress, } from "../btc/verify.js";
|
|
6
|
+
/**
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export function verifyMessageDogeEcdsa(message, signature, address) {
|
|
10
|
+
const challenge = typeof message === "string" ? message : hexFrom(message).slice(2);
|
|
11
|
+
const [recoveryBit, ...rawSign] = bytesFrom(signature, "base64");
|
|
12
|
+
const sig = secp256k1.Signature.fromCompact(hexFrom(rawSign).slice(2)).addRecoveryBit(recoveryBit - 31);
|
|
13
|
+
return (btcPublicKeyFromP2pkhAddress(address) ===
|
|
14
|
+
hexFrom(btcEcdsaPublicKeyHash(sig
|
|
15
|
+
.recoverPublicKey(magicHash(challenge, "\x19Dogecoin Signed Message:\n"))
|
|
16
|
+
.toHex())));
|
|
17
|
+
}
|
package/dist/signer/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signer/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signer/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC"}
|
package/dist/signer/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/nostr/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/nostr/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC"}
|
|
@@ -14,7 +14,8 @@ export declare enum SignerSignType {
|
|
|
14
14
|
EvmPersonal = "EvmPersonal",
|
|
15
15
|
JoyId = "JoyId",
|
|
16
16
|
NostrEvent = "NostrEvent",
|
|
17
|
-
CkbSecp256k1 = "CkbSecp256k1"
|
|
17
|
+
CkbSecp256k1 = "CkbSecp256k1",
|
|
18
|
+
DogeEcdsa = "DogeEcdsa"
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
20
21
|
* An enumeration of signer display types in wallet.
|
|
@@ -24,7 +25,8 @@ export declare enum SignerType {
|
|
|
24
25
|
EVM = "EVM",
|
|
25
26
|
BTC = "BTC",
|
|
26
27
|
CKB = "CKB",
|
|
27
|
-
Nostr = "Nostr"
|
|
28
|
+
Nostr = "Nostr",
|
|
29
|
+
Doge = "Doge"
|
|
28
30
|
}
|
|
29
31
|
/**
|
|
30
32
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/signer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,oCAAoC,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EACL,MAAM,EACN,qCAAqC,EACrC,8BAA8B,EAC/B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/signer/signer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,oCAAoC,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EACL,MAAM,EACN,qCAAqC,EACrC,8BAA8B,EAC/B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAQzC;;GAEG;AACH,oBAAY,cAAc;IACxB,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,WAAW,gBAAgB;IAC3B,KAAK,UAAU;IACf,UAAU,eAAe;IACzB,YAAY,iBAAiB;IAC7B,SAAS,cAAc;CACxB;AAED;;;GAGG;AACH,oBAAY,UAAU;IACpB,GAAG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