@gardenfi/core 2.0.18 → 2.0.19

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/dist/index.js CHANGED
@@ -6343,7 +6343,9 @@ class ln {
6343
6343
  );
6344
6344
  const n = r ?? await this.signer.getAddress(), { tx: i, usedUtxos: s } = await this._tempBuildRawTx(
6345
6345
  n
6346
- ), o = this.leafHash(
6346
+ );
6347
+ console.log("utxos :", s);
6348
+ const o = this.leafHash(
6347
6349
  1
6348
6350
  /* REDEEM */
6349
6351
  ), a = s.map((p) => p.value), c = vr(this.getOutputScript(), s.length), l = re.Transaction.SIGHASH_DEFAULT;
@@ -9930,23 +9932,23 @@ Lr.ECPairFactory = Ud;
9930
9932
  const Cd = /* @__PURE__ */ ju(ef);
9931
9933
  class fi extends va {
9932
9934
  get isInitialized() {
9933
- return !!this.privKey;
9935
+ return !!this.digestKey;
9934
9936
  }
9935
9937
  constructor(t, r) {
9936
- super(), this.privKey = t, this.walletClient = r;
9938
+ super(), this.digestKey = t, this.walletClient = r;
9937
9939
  }
9938
- static fromPrivKey(t) {
9940
+ static fromDigestKey(t) {
9939
9941
  return new fi(er(t));
9940
9942
  }
9941
9943
  static fromWalletClient(t) {
9942
9944
  return new fi(void 0, t);
9943
9945
  }
9944
9946
  async initialize() {
9945
- if (this.privKey) return ne("Already initialized");
9946
- const t = await this.derivePrivKeyFromWalletClient();
9947
+ if (this.digestKey) return ne("Already initialized");
9948
+ const t = await this.deriveDigestKeyFromWalletClient();
9947
9949
  return t.error ? j(t.error) : (this.emit("initialized", !0), ne("Initialized"));
9948
9950
  }
9949
- async derivePrivKeyFromWalletClient() {
9951
+ async deriveDigestKeyFromWalletClient() {
9950
9952
  if (!this.walletClient) return j("No walletClient found");
9951
9953
  if (!this.walletClient.account) return j("No account found");
9952
9954
  try {
@@ -9974,20 +9976,20 @@ class fi extends va {
9974
9976
  Nonce: 1n
9975
9977
  }
9976
9978
  });
9977
- return this.privKey = er(kn(t)), this.emit("initialized", !0), ne(this.privKey);
9979
+ return this.digestKey = er(kn(t)), this.emit("initialized", !0), ne(this.digestKey);
9978
9980
  } catch (t) {
9979
9981
  return j("Failed to initialize: " + t);
9980
9982
  }
9981
9983
  }
9982
- async getMasterPrivKey() {
9983
- if (!this.privKey && !this.walletClient)
9984
+ async getDigestKey() {
9985
+ if (!this.digestKey && !this.walletClient)
9984
9986
  return j("No private key or wallet client found");
9985
- if (!this.privKey && this.walletClient) {
9986
- const t = await this.derivePrivKeyFromWalletClient();
9987
+ if (!this.digestKey && this.walletClient) {
9988
+ const t = await this.deriveDigestKeyFromWalletClient();
9987
9989
  if (t.error)
9988
9990
  return j(t.error);
9989
9991
  }
9990
- return this.privKey ? ne(this.privKey) : j("No private key found");
9992
+ return this.digestKey ? ne(this.digestKey) : j("No private key found");
9991
9993
  }
9992
9994
  async generateSecret(t) {
9993
9995
  const r = await this.signMessage(t);
@@ -9996,12 +9998,12 @@ class fi extends va {
9996
9998
  return ne({ secret: n, secretHash: i });
9997
9999
  }
9998
10000
  async signMessage(t) {
9999
- if (!this.privKey) {
10000
- const l = await this.getMasterPrivKey();
10001
+ if (!this.digestKey) {
10002
+ const l = await this.getDigestKey();
10001
10003
  if (l.error) return j(l.error);
10002
- this.privKey = l.val;
10004
+ this.digestKey = l.val;
10003
10005
  }
10004
- const r = Cd(ir), n = "Garden.fi" + t.toString(), i = Buffer.from(n, "utf8"), s = kn(i), o = Buffer.from(er(this.privKey), "hex");
10006
+ const r = Cd(ir), n = "Garden.fi" + t.toString(), i = Buffer.from(n, "utf8"), s = kn(i), o = Buffer.from(er(this.digestKey), "hex");
10005
10007
  if (o.length !== 32)
10006
10008
  return j("Invalid private key length. Expected 32 bytes.");
10007
10009
  const c = r.fromPrivateKey(o).sign(Buffer.from(er(s), "hex"));
@@ -10055,7 +10057,7 @@ class q1 extends va {
10055
10057
  async initializeSMandBTCWallet() {
10056
10058
  if (this._secretManager.isInitialized && this._btcWallet)
10057
10059
  return ne(this._btcWallet);
10058
- const t = await this._secretManager.getMasterPrivKey();
10060
+ const t = await this._secretManager.getDigestKey();
10059
10061
  if (t.error) return j(t.error);
10060
10062
  const r = new _u(Cu(this.environment));
10061
10063
  return this._btcWallet = vu.fromPrivateKey(t.val, r), ne(this._btcWallet);
@@ -3,15 +3,15 @@ import { EventBroker } from '@gardenfi/utils';
3
3
  import { ISecretManager, SecretManagerEvents } from './secretManager.types';
4
4
 
5
5
  export declare class SecretManager extends EventBroker<SecretManagerEvents> implements ISecretManager {
6
- private privKey?;
6
+ private digestKey?;
7
7
  private walletClient?;
8
8
  get isInitialized(): boolean;
9
9
  private constructor();
10
- static fromPrivKey(privKey: string): SecretManager;
10
+ static fromDigestKey(digestKey: string): SecretManager;
11
11
  static fromWalletClient(walletClient: WalletClient): SecretManager;
12
12
  initialize(): Promise<import('@catalogfi/utils').Result<never, string> | import('@catalogfi/utils').Result<string, never>>;
13
- private derivePrivKeyFromWalletClient;
14
- getMasterPrivKey(): Promise<import('@catalogfi/utils').Result<never, string> | import('@catalogfi/utils').Result<string, never>>;
13
+ private deriveDigestKeyFromWalletClient;
14
+ getDigestKey(): Promise<import('@catalogfi/utils').Result<never, string> | import('@catalogfi/utils').Result<string, never>>;
15
15
  generateSecret(nonce: string): Promise<import('@catalogfi/utils').Result<never, string> | import('@catalogfi/utils').Result<{
16
16
  secret: `0x${string}`;
17
17
  secretHash: `0x${string}`;
@@ -16,12 +16,12 @@ export interface ISecretManager extends EventBroker<SecretManagerEvents> {
16
16
  */
17
17
  initialize: () => AsyncResult<string, string>;
18
18
  /**
19
- * Generates a new master private key.
20
- * If the master private key already exists, it will return the existing master private key.
21
- * Else, it will generate a new master private key by hashing a signature generated by signing a message with the wallet client.
22
- * @returns Master private key
19
+ * Generates a new digest key.
20
+ * If the digest key already exists, it will return the existing digest key.
21
+ * Else, it will generate a new digest key by hashing a signature generated by signing a message with the wallet client.
22
+ * @returns digest key
23
23
  */
24
- getMasterPrivKey: () => AsyncResult<string, string>;
24
+ getDigestKey: () => AsyncResult<string, string>;
25
25
  /**
26
26
  * Generates secret and secretHash by signing the nonce.
27
27
  * Secret is generated by hashing the signature and secretHash is generated by hashing the secret.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gardenfi/core",
3
- "version": "2.0.18",
3
+ "version": "2.0.19",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "vite build",