@gvnrdao/dh-lit-ops 0.0.33 → 0.0.35

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 (36) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +3 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/interfaces/chunks/authentication.d.ts +1 -0
  6. package/dist/interfaces/chunks/authentication.d.ts.map +1 -1
  7. package/dist/interfaces/chunks/lit-action-config.d.ts +2 -0
  8. package/dist/interfaces/chunks/lit-action-config.d.ts.map +1 -1
  9. package/dist/interfaces/chunks/lit-action-execution.d.ts +2 -0
  10. package/dist/interfaces/chunks/lit-action-execution.d.ts.map +1 -1
  11. package/dist/modules/action-executor.module.d.ts.map +1 -1
  12. package/dist/modules/action-executor.module.js +5 -3
  13. package/dist/modules/action-executor.module.js.map +1 -1
  14. package/dist/modules/auth-manager.module.d.ts.map +1 -1
  15. package/dist/modules/auth-manager.module.js +46 -32
  16. package/dist/modules/auth-manager.module.js.map +1 -1
  17. package/dist/modules/capacity-master.module.d.ts +1 -1
  18. package/dist/modules/capacity-master.module.d.ts.map +1 -1
  19. package/dist/modules/capacity-master.module.js +78 -23
  20. package/dist/modules/capacity-master.module.js.map +1 -1
  21. package/dist/modules/lit-ops.module.d.ts +45 -12
  22. package/dist/modules/lit-ops.module.d.ts.map +1 -1
  23. package/dist/modules/lit-ops.module.js +199 -29
  24. package/dist/modules/lit-ops.module.js.map +1 -1
  25. package/dist/modules/pkp-macros.module.d.ts +5 -3
  26. package/dist/modules/pkp-macros.module.d.ts.map +1 -1
  27. package/dist/modules/pkp-macros.module.js +36 -14
  28. package/dist/modules/pkp-macros.module.js.map +1 -1
  29. package/dist/modules/session-signature-manager.module.d.ts +1 -0
  30. package/dist/modules/session-signature-manager.module.d.ts.map +1 -1
  31. package/dist/modules/session-signature-manager.module.js +24 -17
  32. package/dist/modules/session-signature-manager.module.js.map +1 -1
  33. package/dist/utils/connection-helpers.d.ts.map +1 -1
  34. package/dist/utils/connection-helpers.js +9 -5
  35. package/dist/utils/connection-helpers.js.map +1 -1
  36. package/package.json +2 -2
@@ -36,7 +36,8 @@ export declare class LitOps {
36
36
  /**
37
37
  * Execute a LIT Action from CID
38
38
  */
39
- executeActionFromCID(cid: string, pkpPublicKey: string, params: Record<string, any>, signer?: ethers5.Signer, pkpTokenId?: string): Promise<import("../interfaces").LitActionExecutionResult>;
39
+ executeActionFromCID(cid: string, pkpPublicKey: string, params: Record<string, any>, signer?: ethers5.Signer, pkpTokenId?: string, // Optional PKP token ID for session signature scoping
40
+ pkpEthAddress?: string): Promise<import("../interfaces").LitActionExecutionResult>;
40
41
  /**
41
42
  * Execute a LIT Action from code
42
43
  */
@@ -67,7 +68,7 @@ export declare class LitOps {
67
68
  * @param signer - The wallet to use for PKP creation and transactions
68
69
  * @returns Complete PKP data including tokenId, publicKey, ethAddress, etc.
69
70
  */
70
- createProductionPKP(litActionCid: string, signer: ethers5.Signer): Promise<import("./pkp-macros.module").PKPCompleteWorkflowResult>;
71
+ createProductionPKP(litActionCids: string | string[], signer: ethers5.Signer): Promise<import("./pkp-macros.module").PKPCompleteWorkflowResult>;
71
72
  /**
72
73
  * Sign message with existing PKP data
73
74
  * This method takes the result from createProductionPKP and signs a message.
@@ -151,7 +152,7 @@ export declare class LitOps {
151
152
  * @param signer - Optional signer (required for standalone mode, not used in service mode)
152
153
  * @returns Complete PKP creation and validation result with audit trail
153
154
  */
154
- createAndValidatePkpToLitAction(litActionCid: string, signer?: ethers5.Signer): Promise<{
155
+ createAndValidatePkpToLitAction(litActionCids: string | string[], signer?: ethers5.Signer): Promise<{
155
156
  success: boolean;
156
157
  error?: string;
157
158
  timestamp: number;
@@ -275,23 +276,55 @@ export declare class LitOps {
275
276
  requestMintAuthorization(request: {
276
277
  authMessage: {
277
278
  positionId: string;
278
- requestedAmount: string;
279
- quantumTimestamp: number;
279
+ timestamp: number;
280
280
  chainId: number;
281
- btcAddress: string;
282
- positionManagerAddress: string;
283
- loanOpsManagerAddress: string;
281
+ amount: string;
282
+ action: string;
283
+ mode: "dev" | "prod";
284
+ contracts?: {
285
+ PositionManager: string;
286
+ LoanOperationsManagerModule: string;
287
+ TermManagerModule: string;
288
+ UCDController: string;
289
+ };
284
290
  };
285
291
  userSignature: string;
292
+ customRpcUrl?: string;
293
+ customBitcoinRpcUrl?: string;
286
294
  }): Promise<{
287
- success: boolean;
288
- pkpSignature?: string;
295
+ approved: boolean;
296
+ signature?: string;
289
297
  mintAmount?: string;
290
298
  mintFee?: string;
291
299
  newDebt?: string;
292
- quantumTimestamp?: number;
300
+ timestamp?: number;
301
+ reason?: string;
302
+ failedStep?: string;
303
+ }>;
304
+ /**
305
+ * Get trustless BTC price from Price Oracle LIT Action
306
+ *
307
+ * Fetches the current BTC price in USD using the decentralized price oracle.
308
+ * Supports two modes:
309
+ * - fast: Single source (faster, less secure)
310
+ * - full: Consensus across multiple sources (slower, more secure)
311
+ *
312
+ * @param options - Price fetch options
313
+ * @returns BTC price data with optional signature
314
+ */
315
+ getBTCPrice(options: {
316
+ mode?: "fast" | "full";
317
+ sign?: boolean;
318
+ signer?: ethers5.Signer;
319
+ }): Promise<{
320
+ success: boolean;
321
+ priceE8?: string;
322
+ price?: number;
323
+ timestamp?: number;
324
+ source?: string;
325
+ signature?: string;
326
+ signer?: string;
293
327
  error?: string;
294
- details?: any;
295
328
  }>;
296
329
  /**
297
330
  * Cleanup - disconnect all clients
@@ -1 +1 @@
1
- {"version":3,"file":"lit-ops.module.d.ts","sourceRoot":"","sources":["../../src/modules/lit-ops.module.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AASH,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAEL,UAAU,EACV,YAAY,EAEb,MAAM,eAAe,CAAC;AAYvB,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAA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CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IA8FF;;OAEG;IACH;;;;;OAKG;IACG,mBAAmB,CACvB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC;QACT,OAAO,EAAE,OAAO,CAAC;QACjB,OAAO,EAAE,KAAK,CAAC;YACb,GAAG,EAAE,MAAM,CAAC;YACZ,OAAO,EAAE,OAAO,CAAC;YACjB,WAAW,EAAE,OAAO,CAAC;YACrB,eAAe,CAAC,EAAE,MAAM,CAAC;YACzB,KAAK,CAAC,EAAE,MAAM,CAAC;SAChB,CAAC,CAAC;KACJ,CAAC;IAqDI,UAAU;CAoBjB"}
@@ -289,7 +289,8 @@ class LitOps {
289
289
  /**
290
290
  * Execute a LIT Action from CID
291
291
  */
292
- async executeActionFromCID(cid, pkpPublicKey, params, signer, pkpTokenId // Optional PKP token ID for session signature scoping
292
+ async executeActionFromCID(cid, pkpPublicKey, params, signer, pkpTokenId, // Optional PKP token ID for session signature scoping
293
+ pkpEthAddress // Optional PKP Ethereum address for capacity credit delegation
293
294
  ) {
294
295
  const litClient = await this.clientManager.getClient({
295
296
  litNetwork: this.config.network,
@@ -301,6 +302,7 @@ class LitOps {
301
302
  params,
302
303
  signer,
303
304
  pkpTokenId, // Pass through pkpTokenId for session signature scoping
305
+ pkpEthAddress, // Pass through pkpEthAddress for capacity delegation
304
306
  };
305
307
  return this.actionExecutor.executeAction(request, litClient);
306
308
  }
@@ -505,15 +507,18 @@ class LitOps {
505
507
  * @param signer - The wallet to use for PKP creation and transactions
506
508
  * @returns Complete PKP data including tokenId, publicKey, ethAddress, etc.
507
509
  */
508
- async createProductionPKP(litActionCid, signer) {
510
+ async createProductionPKP(litActionCids, signer) {
511
+ // Normalize to array
512
+ const cids = Array.isArray(litActionCids) ? litActionCids : [litActionCids];
509
513
  if (this.config.debug) {
510
514
  console.log("\n🏗️ LitOps.createProductionPKP called");
511
- console.log(` LIT Action CID: ${litActionCid}`);
515
+ console.log(` LIT Action CIDs (${cids.length}):`);
516
+ cids.forEach((cid, idx) => console.log(` ${idx + 1}. ${cid}`));
512
517
  console.log(` Network: ${this.config.network}`);
513
518
  }
514
- // Create PKP with authorization and burn for immutability
519
+ // Create PKP with authorization of ALL actions and burn for immutability
515
520
  const pkpResult = await this.pkpMacroUtils.quickCreatePkpAuthorizeDhActionAndBurn(signer, {
516
- litActionCid: litActionCid,
521
+ litActionCid: cids, // Pass array to authorize all actions before burn
517
522
  });
518
523
  if (this.config.debug) {
519
524
  console.log(" ✅ Production PKP created successfully!");
@@ -594,6 +599,14 @@ class LitOps {
594
599
  * @returns PKP validation result with signature verification
595
600
  */
596
601
  async validatePKPSecurity(targetPkpTokenId, expectedCid, signerPkp, signer) {
602
+ console.log(`🔍 LIT-OPS TRACE: validatePKPSecurity ENTRY`);
603
+ console.log(` - targetPkpTokenId: "${targetPkpTokenId}"`);
604
+ console.log(` - targetPkpTokenId type: ${typeof targetPkpTokenId}`);
605
+ console.log(` - targetPkpTokenId length: ${targetPkpTokenId.length}`);
606
+ console.log(` - targetPkpTokenId startsWith '0x': ${targetPkpTokenId.startsWith('0x')}`);
607
+ console.log(` - expectedCid (WILL BE PASSED TO LIT ACTION): "${expectedCid}"`);
608
+ console.log(` - signerPkp.tokenId: "${signerPkp.tokenId}"`);
609
+ console.log(` - signerPkp.ethAddress: "${signerPkp.ethAddress}"`);
597
610
  if (this.config.debug) {
598
611
  console.log("\n🔍 LitOps.validatePKPSecurity");
599
612
  console.log(` Target PKP: ${targetPkpTokenId}`);
@@ -613,6 +626,9 @@ class LitOps {
613
626
  // performs READ-ONLY operations (no signing). Passing undefined for pkpTokenId
614
627
  // will skip adding LitPKPResource to the session signature, which is correct
615
628
  // for burned/immutable validator PKPs that can't sign via session signatures.
629
+ console.log(`\n🔍 LIT-OPS TRACE: About to call executeActionFromCID with jsParams:`);
630
+ console.log(` - targetPkpTokenId: "${targetPkpTokenId}"`);
631
+ console.log(` - expectedCid: "${expectedCid}"`);
616
632
  const litResult = await this.executeActionFromCID(pkpValidatorCid, signerPkp.publicKey, {
617
633
  targetPkpTokenId,
618
634
  expectedCid, // Expected to be in hex format
@@ -791,13 +807,16 @@ class LitOps {
791
807
  * @param signer - Optional signer (required for standalone mode, not used in service mode)
792
808
  * @returns Complete PKP creation and validation result with audit trail
793
809
  */
794
- async createAndValidatePkpToLitAction(litActionCid, signer) {
810
+ async createAndValidatePkpToLitAction(litActionCids, signer) {
795
811
  const startTime = Date.now();
796
812
  const auditSteps = [];
813
+ // Normalize to array for processing
814
+ const cids = Array.isArray(litActionCids) ? litActionCids : [litActionCids];
797
815
  if (this.config.debug) {
798
816
  console.log("\n🎯 LitOps.createAndValidatePkpToLitAction");
799
817
  console.log(" ULTIMATE PKP SECURITY MACRO");
800
- console.log(` Target LIT Action CID: ${litActionCid}`);
818
+ console.log(` Target LIT Action CIDs (${cids.length}):`);
819
+ cids.forEach((cid, idx) => console.log(` ${idx + 1}. ${cid}`));
801
820
  console.log(` Mode: ${this.config.mode}`);
802
821
  }
803
822
  // Service mode: Call the service endpoint directly
@@ -821,7 +840,7 @@ class LitOps {
821
840
  "Content-Type": "application/json",
822
841
  },
823
842
  body: JSON.stringify({
824
- litActionCid: litActionCid,
843
+ litActionCids: litActionCids,
825
844
  }),
826
845
  }, timeoutMs);
827
846
  if (!response.ok) {
@@ -872,7 +891,9 @@ class LitOps {
872
891
  error: message,
873
892
  timestamp: startTime,
874
893
  duration,
875
- targetCid: litActionCid,
894
+ targetCid: Array.isArray(litActionCids)
895
+ ? litActionCids[0]
896
+ : litActionCids,
876
897
  pkpData: {},
877
898
  validationResult: {},
878
899
  auditTrail: {
@@ -907,7 +928,7 @@ class LitOps {
907
928
  if (this.config.debug) {
908
929
  console.log("\n Step 1: Creating production PKP...");
909
930
  }
910
- const pkpData = await this.createProductionPKP(litActionCid, signer);
931
+ const pkpData = await this.createProductionPKP(cids, signer);
911
932
  const step1Duration = Date.now() - step1Start;
912
933
  auditSteps.push({
913
934
  step: 1,
@@ -993,10 +1014,14 @@ class LitOps {
993
1014
  if (!validatorPkp) {
994
1015
  throw new Error("PKP validator PKP not found in dh-lit-actions package");
995
1016
  }
996
- // Convert IPFS CID to hex format for validation
997
- const litActionCidHex = (0, dh_lit_actions_1.cidToHex)(litActionCid);
1017
+ // Convert IPFS CID to hex format for validation (using first CID)
1018
+ const firstCid = cids[0];
1019
+ console.log(`🔍 LIT-OPS TRACE: firstCid (cids[0]) = "${firstCid}"`);
1020
+ console.log(`🔍 LIT-OPS TRACE: All cids array:`, cids);
1021
+ const litActionCidHex = (0, dh_lit_actions_1.cidToHex)(firstCid);
1022
+ console.log(`🔍 LIT-OPS TRACE: litActionCidHex after cidToHex() = "${litActionCidHex}"`);
998
1023
  if (this.config.debug) {
999
- console.log(` Converting CID: ${litActionCid} → ${litActionCidHex}`);
1024
+ console.log(` Converting CID: ${firstCid} → ${litActionCidHex}`);
1000
1025
  }
1001
1026
  // Attempt validation with retry logic for network propagation issues
1002
1027
  let validationResult;
@@ -1007,6 +1032,12 @@ class LitOps {
1007
1032
  if (this.config.debug && attempt > 1) {
1008
1033
  console.log(`\n 🔄 Validation retry attempt ${attempt}/${maxValidationRetries}`);
1009
1034
  }
1035
+ console.log(`🔍 LIT-OPS TRACE: validatePKPSecurity call parameters:`);
1036
+ console.log(` - pkpTokenId: "${pkpData.tokenId}"`);
1037
+ console.log(` - pkpTokenId type: ${typeof pkpData.tokenId}`);
1038
+ console.log(` - pkpTokenId startsWith '0x': ${pkpData.tokenId.startsWith("0x")}`);
1039
+ console.log(` - litActionCidHex (expectedCid): "${litActionCidHex}"`);
1040
+ console.log(` - validatorPkp: "${validatorPkp}"`);
1010
1041
  validationResult = await this.validatePKPSecurity(pkpData.tokenId, litActionCidHex, // Pass hex format CID
1011
1042
  validatorPkp, signer);
1012
1043
  // If validation succeeds, break out of retry loop
@@ -1087,7 +1118,9 @@ class LitOps {
1087
1118
  success: true,
1088
1119
  timestamp: startTime,
1089
1120
  duration: totalDuration,
1090
- targetCid: litActionCid,
1121
+ targetCid: Array.isArray(litActionCids)
1122
+ ? litActionCids[0]
1123
+ : litActionCids,
1091
1124
  pkpData,
1092
1125
  validationResult,
1093
1126
  auditTrail: {
@@ -1122,7 +1155,9 @@ class LitOps {
1122
1155
  error: errorMessage,
1123
1156
  timestamp: startTime,
1124
1157
  duration: totalDuration,
1125
- targetCid: litActionCid,
1158
+ targetCid: Array.isArray(litActionCids)
1159
+ ? litActionCids[0]
1160
+ : litActionCids,
1126
1161
  pkpData: {}, // Empty PKP data on failure
1127
1162
  validationResult: {
1128
1163
  success: false,
@@ -1172,9 +1207,13 @@ class LitOps {
1172
1207
  if (this.config.mode === "standalone" && !effectiveSigner) {
1173
1208
  throw new Error("Signer is required for standalone mode");
1174
1209
  }
1175
- return this.createAndValidatePkpToLitAction(((networkOverride ?? this.config.network) === "datil"
1210
+ const selectedNetwork = networkOverride ?? this.config.network;
1211
+ const authDummyCid = (selectedNetwork === "datil"
1176
1212
  ? dh_lit_actions_1.DH_LIT_ACTIONS_DATIL
1177
- : dh_lit_actions_1.DH_LIT_ACTIONS_DATIL_TEST).authorizationDummy.cid, effectiveSigner);
1213
+ : dh_lit_actions_1.DH_LIT_ACTIONS_DATIL_TEST).authorizationDummy.cid;
1214
+ console.log(`🔍 LIT-OPS TRACE: getNewDiamondHandsLoanPkp - selectedNetwork = "${selectedNetwork}"`);
1215
+ console.log(`🔍 LIT-OPS TRACE: getNewDiamondHandsLoanPkp - authorizationDummy.cid = "${authDummyCid}"`);
1216
+ return this.createAndValidatePkpToLitAction(authDummyCid, effectiveSigner);
1178
1217
  }
1179
1218
  /**
1180
1219
  * Request mint authorization from UCD Mint Validator LIT Action
@@ -1200,24 +1239,69 @@ class LitOps {
1200
1239
  console.log(" Network:", this.config.network);
1201
1240
  console.log(" CID:", litActionInfo.cid);
1202
1241
  console.log(" Position:", request.authMessage.positionId);
1203
- console.log(" Amount:", request.authMessage.requestedAmount);
1204
- console.log(" Quantum:", request.authMessage.quantumTimestamp);
1242
+ console.log(" Amount:", request.authMessage.amount);
1243
+ console.log(" Timestamp:", request.authMessage.timestamp);
1205
1244
  }
1206
1245
  // Get LIT client for execution
1207
1246
  const litClient = await this.clientManager.getClient({
1208
1247
  litNetwork: this.config.network,
1209
1248
  debug: this.config.debug,
1210
1249
  });
1250
+ // Determine chain and Bitcoin provider from chainId in authMessage
1251
+ let chain;
1252
+ let bitcoinProviderUrl;
1253
+ switch (request.authMessage.chainId) {
1254
+ case 1: // Ethereum mainnet
1255
+ chain = "ethereum";
1256
+ bitcoinProviderUrl = process.env.BITCOIN_PROVIDER_URL || "https://mempool.space/api";
1257
+ break;
1258
+ case 11155111: // Sepolia testnet
1259
+ chain = "sepolia";
1260
+ bitcoinProviderUrl = process.env.BITCOIN_PROVIDER_URL || "https://diamond-hands-btc-faucet-6b39a1072059.herokuapp.com/api";
1261
+ break;
1262
+ case 31337: // Hardhat local testnet
1263
+ chain = "hardhat"; // Use hardhat identifier for local testing
1264
+ bitcoinProviderUrl = process.env.BITCOIN_PROVIDER_URL || "http://127.0.0.1:18443"; // Local Bitcoin regtest
1265
+ break;
1266
+ default:
1267
+ throw new Error(`Unsupported chainId: ${request.authMessage.chainId}`);
1268
+ }
1269
+ // Override with custom Bitcoin RPC URL if provided (for local development)
1270
+ if (request.customBitcoinRpcUrl) {
1271
+ bitcoinProviderUrl = request.customBitcoinRpcUrl;
1272
+ if (this.config.debug) {
1273
+ console.log(" Custom Bitcoin RPC URL:", request.customBitcoinRpcUrl);
1274
+ }
1275
+ }
1211
1276
  // Execute LIT Action
1212
- // authMessage already contains quantumTimestamp calculated by SDK
1277
+ // authMessage already contains timestamp calculated by SDK
1213
1278
  // lit-ops just forwards - no business logic
1279
+ const litActionParams = {
1280
+ chain,
1281
+ bitcoinProviderUrl,
1282
+ auth: {
1283
+ positionId: request.authMessage.positionId,
1284
+ timestamp: request.authMessage.timestamp,
1285
+ chainId: request.authMessage.chainId,
1286
+ amount: request.authMessage.amount,
1287
+ action: request.authMessage.action,
1288
+ signature: request.userSignature,
1289
+ mode: request.authMessage.mode,
1290
+ ...(request.authMessage.contracts && { contracts: request.authMessage.contracts }),
1291
+ },
1292
+ amount: request.authMessage.amount,
1293
+ };
1294
+ // Add custom RPC URL for local development (ngrok tunnels)
1295
+ if (request.customRpcUrl) {
1296
+ litActionParams.customRpcUrl = request.customRpcUrl;
1297
+ if (this.config.debug) {
1298
+ console.log(" Custom RPC URL:", request.customRpcUrl);
1299
+ }
1300
+ }
1214
1301
  const result = await this.actionExecutor.executeAction({
1215
1302
  cid: litActionInfo.cid,
1216
1303
  pkpPublicKey: litActionInfo.pkp.publicKey,
1217
- params: {
1218
- authMessage: request.authMessage,
1219
- userSignature: request.userSignature,
1220
- },
1304
+ params: litActionParams,
1221
1305
  signer: this.config.signer,
1222
1306
  }, litClient);
1223
1307
  if (this.config.debug) {
@@ -1229,18 +1313,104 @@ class LitOps {
1229
1313
  }
1230
1314
  // Return standardized response
1231
1315
  return {
1232
- success: result.success,
1233
- pkpSignature: result.signatures
1316
+ approved: result.response?.approved ?? false,
1317
+ signature: result.signatures
1234
1318
  ? JSON.stringify(result.signatures)
1235
1319
  : undefined,
1236
1320
  mintAmount: result.response?.mintAmount,
1237
1321
  mintFee: result.response?.mintFee,
1238
1322
  newDebt: result.response?.newDebt,
1239
- quantumTimestamp: result.response?.quantumTimestamp,
1240
- error: result.error,
1241
- details: result.response,
1323
+ timestamp: result.response?.timestamp,
1324
+ reason: result.response?.reason,
1325
+ failedStep: result.response?.failedStep,
1242
1326
  };
1243
1327
  }
1328
+ /**
1329
+ * Get trustless BTC price from Price Oracle LIT Action
1330
+ *
1331
+ * Fetches the current BTC price in USD using the decentralized price oracle.
1332
+ * Supports two modes:
1333
+ * - fast: Single source (faster, less secure)
1334
+ * - full: Consensus across multiple sources (slower, more secure)
1335
+ *
1336
+ * @param options - Price fetch options
1337
+ * @returns BTC price data with optional signature
1338
+ */
1339
+ async getBTCPrice(options) {
1340
+ const { mode = "fast", sign = false, signer } = options;
1341
+ // Get LIT Action info from registry
1342
+ const litActions = (this.config.network === "datil"
1343
+ ? dh_lit_actions_1.DH_LIT_ACTIONS_DATIL
1344
+ : dh_lit_actions_1.DH_LIT_ACTIONS_DATIL_TEST);
1345
+ console.log("litActions in getActions", litActions);
1346
+ const litActionInfo = litActions.priceOracle;
1347
+ if (!litActionInfo || !litActionInfo.cid) {
1348
+ return {
1349
+ success: false,
1350
+ error: "Price oracle LIT Action not found in registry",
1351
+ };
1352
+ }
1353
+ if (this.config.debug) {
1354
+ console.log("💰 Calling Price Oracle LIT Action:");
1355
+ console.log(" Network:", this.config.network);
1356
+ console.log(" CID:", litActionInfo.cid);
1357
+ console.log(" Mode:", mode);
1358
+ console.log(" Sign:", sign);
1359
+ }
1360
+ try {
1361
+ // Get LIT client for execution
1362
+ const litClient = await this.clientManager.getClient({
1363
+ litNetwork: this.config.network,
1364
+ debug: this.config.debug,
1365
+ });
1366
+ // Execute LIT Action
1367
+ const result = await this.actionExecutor.executeAction({
1368
+ cid: litActionInfo.cid,
1369
+ pkpPublicKey: litActionInfo.pkp?.publicKey || "",
1370
+ params: {
1371
+ mode,
1372
+ sign,
1373
+ },
1374
+ signer: signer || this.config.signer,
1375
+ }, litClient);
1376
+ if (this.config.debug) {
1377
+ console.log("📥 Price Oracle response:", {
1378
+ success: result.success,
1379
+ response: result.response,
1380
+ error: result.error,
1381
+ });
1382
+ }
1383
+ // Parse response
1384
+ if (result.success && result.response) {
1385
+ const responseData = typeof result.response === "string"
1386
+ ? JSON.parse(result.response)
1387
+ : result.response;
1388
+ return {
1389
+ success: true,
1390
+ priceE8: responseData.priceE8,
1391
+ price: responseData.price,
1392
+ timestamp: responseData.timestamp,
1393
+ source: responseData.source,
1394
+ signature: responseData.signature,
1395
+ signer: responseData.signer,
1396
+ };
1397
+ }
1398
+ return {
1399
+ success: false,
1400
+ error: result.error || "Price oracle execution failed",
1401
+ };
1402
+ }
1403
+ catch (error) {
1404
+ const errorMessage = error instanceof Error ? error.message : "Unknown error";
1405
+ if (this.config.debug) {
1406
+ console.error("❌ Price oracle failed:", error);
1407
+ }
1408
+ return {
1409
+ success: false,
1410
+ error: errorMessage,
1411
+ };
1412
+ }
1413
+ }
1244
1414
  /**
1245
1415
  * Cleanup - disconnect all clients
1246
1416
  */