@gvnrdao/dh-sdk 0.0.278 → 0.0.280

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
@@ -31375,10 +31375,10 @@ var require_pkg_src = __commonJS({
31375
31375
  deployedAt: 1781116572961,
31376
31376
  size: 4110,
31377
31377
  hash: "c3b121afcdc0d7d7ed7ca3be5b185fc502ffad99bf83cdf166769bbfa5194687",
31378
- validatorWalletAddress: "0x9ee56687f7a984d5df7ab79330271a619ef56ddd",
31378
+ validatorWalletAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
31379
31379
  pkp: {
31380
31380
  publicKey: "0x04ec0e3acc40884e3f366ca469d08899eb640ad5259fa196b0238075086208a9f8732a3175704f35f0bcc28e07406cfb24c254efd1e7355640577330f0d2dd755f",
31381
- ethAddress: "0x9eE56687F7a984D5DF7aB79330271a619ef56DdD"
31381
+ ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
31382
31382
  }
31383
31383
  },
31384
31384
  btcTransactionSigner: {
@@ -31409,7 +31409,7 @@ var require_pkg_src = __commonJS({
31409
31409
  validatorWalletAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
31410
31410
  pkp: {
31411
31411
  publicKey: "0x041ab17cd91fc5c0b761eea6092d032807561b621b82c488826776e04a9158d61ba64d809a4729f0501289d980732cb06d8dfd06999dd9c8efd2f495dad78b31bb",
31412
- ethAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236"
31412
+ ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
31413
31413
  }
31414
31414
  },
31415
31415
  processPaymentValidator: {
@@ -31427,7 +31427,7 @@ var require_pkg_src = __commonJS({
31427
31427
  validatorWalletAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
31428
31428
  pkp: {
31429
31429
  publicKey: "0x04cfccb9b6c7addc79469c0e9fafebef4c70801302c62cdb26b610723a9b8527d23f98a40158c7340d83fd0e62d02b5ec74c12f7a86d98e8c6973b4811110f19ad",
31430
- ethAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236"
31430
+ ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
31431
31431
  }
31432
31432
  },
31433
31433
  extendPositionValidator: {
@@ -31445,7 +31445,7 @@ var require_pkg_src = __commonJS({
31445
31445
  validatorWalletAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
31446
31446
  pkp: {
31447
31447
  publicKey: "0x04e52338f6a0c3362800f1a94c4c8f08be5030dde0fa217388c53d1c1a4790f4443c9f2886b2d2d8f4b75a9a156e9b028011b1a1cf7648da0e556aa980ec692836",
31448
- ethAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236"
31448
+ ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
31449
31449
  }
31450
31450
  },
31451
31451
  btcWithdrawal: {
@@ -31463,7 +31463,7 @@ var require_pkg_src = __commonJS({
31463
31463
  validatorWalletAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
31464
31464
  pkp: {
31465
31465
  publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
31466
- ethAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236"
31466
+ ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
31467
31467
  }
31468
31468
  },
31469
31469
  liquidationValidator: {
@@ -31481,7 +31481,7 @@ var require_pkg_src = __commonJS({
31481
31481
  validatorWalletAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
31482
31482
  pkp: {
31483
31483
  publicKey: "0x041a241de58976c13e3d7ca5a18e494f7330151e3818706135d50176e78ffb673e58b11f0b67a87c73fade6c6b27d6e7a7377ea9f4c10bf31880f1d725f18cc6f8",
31484
- ethAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236"
31484
+ ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
31485
31485
  }
31486
31486
  },
31487
31487
  priceOracle: {
@@ -31496,10 +31496,10 @@ var require_pkg_src = __commonJS({
31496
31496
  deployedAt: 1781116663270,
31497
31497
  size: 8695,
31498
31498
  hash: "ba20ade60a7fa5acd80dadfafa179c507388cfe6ce48a22a672d70b317ffcc74",
31499
- validatorWalletAddress: "0x831ddf3048547b983efe3ccbbb35a45a53191651",
31499
+ validatorWalletAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
31500
31500
  pkp: {
31501
31501
  publicKey: "0x043beaa1da47875601a8d6f430b1438ee2d4732eefd06e5c63a474bbdaf9e7df1797b1b951e041b627c2bf839788164825324c9cbd1e2d6f740fdd4bff69b1900b",
31502
- ethAddress: "0x831DdF3048547B983EFE3ccBBB35a45a53191651"
31502
+ ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
31503
31503
  }
31504
31504
  },
31505
31505
  loanVaultBtcBalance: {
@@ -31517,7 +31517,7 @@ var require_pkg_src = __commonJS({
31517
31517
  validatorWalletAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
31518
31518
  pkp: {
31519
31519
  publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
31520
- ethAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236"
31520
+ ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
31521
31521
  }
31522
31522
  },
31523
31523
  // btc-address-balance (Option B) — address-only signed total balance via
@@ -31538,10 +31538,10 @@ var require_pkg_src = __commonJS({
31538
31538
  deployedAt: 1781116681558,
31539
31539
  size: 21957,
31540
31540
  hash: "b17977304be6b117bcb29feafc3bb654113d72d5147ceeba92e91b4d7f5c0327",
31541
- validatorWalletAddress: "0xf0bf5e3f864b87283a05d1e4a85ee0fa40493fb5",
31541
+ validatorWalletAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
31542
31542
  pkp: {
31543
31543
  publicKey: "0x0498cbb31facfa26e3ec83ccdabfe4fe341ca0282e0c3cb81da7113723b9726e1e49efa92165cc3faa66ced4454cea56dbab12267852d6525a55d7c4f128b912cd",
31544
- ethAddress: "0xF0bF5e3f864B87283a05D1E4A85eE0FA40493fB5"
31544
+ ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
31545
31545
  }
31546
31546
  },
31547
31547
  alwaysSigner: {
@@ -31582,10 +31582,10 @@ var require_pkg_src = __commonJS({
31582
31582
  deployedAt: 1781116700324,
31583
31583
  size: 31148,
31584
31584
  hash: "c93591c7c7f51b519243499d78bd5ac0df1e368caa76c08d6a5d7aea9e3a49cc",
31585
- validatorWalletAddress: "0xa804bbb01d26f250fb3c53007fd32337b985602b",
31585
+ validatorWalletAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
31586
31586
  pkp: {
31587
31587
  publicKey: "0x046da0ad6da7dd4a0063cbeac6f2bdb6a9889c2178b23470833356a8ee5630f7f0eee0db348d9d9aaaadd23eccf0063c8f68ee5e446abe30b882bf1de4c932bc21",
31588
- ethAddress: "0xa804bBb01D26F250FB3c53007fD32337B985602b"
31588
+ ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
31589
31589
  }
31590
31590
  }
31591
31591
  };
@@ -122414,29 +122414,46 @@ Error data: ${errorData || "none"}`
122414
122414
  "Content-Type": "application/json",
122415
122415
  ...await this.getAuthHeader()
122416
122416
  };
122417
- const resp = await fetch(
122418
- `${this.config.serviceEndpoint}/api/lit/pending-withdrawals/execute`,
122419
- {
122420
- method: "POST",
122421
- headers,
122422
- body: JSON.stringify({
122423
- positionId: envelope.positionId,
122424
- txid: envelope.txid,
122425
- vout: envelope.vout,
122426
- satoshis: envelope.satoshis,
122427
- targetAddress: envelope.targetAddress,
122428
- // CRIT-1: send the user-signed targetAmount so the Lit Action can
122429
- // bind it into its hash recomputation AND cross-check against the
122430
- // on-chain authorizer record.
122431
- targetAmount: envelope.targetAmount,
122432
- networkFee: envelope.networkFee,
122433
- userSignature: envelope.userSignature,
122434
- borrowerAddress: envelope.borrowerAddress,
122435
- chainId: envelope.chainId,
122436
- timestamp: envelope.timestamp
122437
- })
122417
+ const PHASE2_CLIENT_TIMEOUT_MS = 6e4;
122418
+ const abort = new AbortController();
122419
+ const abortTimer = setTimeout(() => abort.abort(), PHASE2_CLIENT_TIMEOUT_MS);
122420
+ let resp;
122421
+ try {
122422
+ resp = await fetch(
122423
+ `${this.config.serviceEndpoint}/api/lit/pending-withdrawals/execute`,
122424
+ {
122425
+ method: "POST",
122426
+ headers,
122427
+ signal: abort.signal,
122428
+ body: JSON.stringify({
122429
+ positionId: envelope.positionId,
122430
+ txid: envelope.txid,
122431
+ vout: envelope.vout,
122432
+ satoshis: envelope.satoshis,
122433
+ targetAddress: envelope.targetAddress,
122434
+ // CRIT-1: send the user-signed targetAmount so the Lit Action can
122435
+ // bind it into its hash recomputation AND cross-check against the
122436
+ // on-chain authorizer record.
122437
+ targetAmount: envelope.targetAmount,
122438
+ networkFee: envelope.networkFee,
122439
+ userSignature: envelope.userSignature,
122440
+ borrowerAddress: envelope.borrowerAddress,
122441
+ chainId: envelope.chainId,
122442
+ timestamp: envelope.timestamp
122443
+ })
122444
+ }
122445
+ );
122446
+ } catch (fetchErr) {
122447
+ if (abort.signal.aborted) {
122448
+ return {
122449
+ success: false,
122450
+ error: "Withdrawal signing timed out. Your withdrawal is still authorized on-chain \u2014 retry Execute from Pending Withdrawals to complete it."
122451
+ };
122438
122452
  }
122439
- );
122453
+ throw fetchErr;
122454
+ } finally {
122455
+ clearTimeout(abortTimer);
122456
+ }
122440
122457
  const json = await resp.json();
122441
122458
  if (!json.success || !json.data?.success) {
122442
122459
  const errMsg = json.data?.error ?? json.error ?? "BTC broadcast failed";
@@ -122710,38 +122727,68 @@ Error data: ${errorData || "none"}`
122710
122727
  error: "chainId required for recoverStaleSpend (set DiamondHandsSDKConfig.chainId)"
122711
122728
  };
122712
122729
  }
122713
- const rpcUrl = params.rpcUrl ?? this.config.ethRpcUrl;
122714
- if (!rpcUrl) {
122715
- return {
122716
- success: false,
122717
- failedStep: "config",
122718
- error: "ethRpcUrl required for recoverStaleSpend \u2014 set DiamondHandsSDKConfig.ethRpcUrl or pass rpcUrl"
122730
+ let attRes;
122731
+ if (this.config.mode === "service" && this.config.serviceEndpoint) {
122732
+ const headers = {
122733
+ "Content-Type": "application/json",
122734
+ ...await this.getAuthHeader()
122719
122735
  };
122720
- }
122721
- const sdkBitcoinProviderUrl = this.config.bitcoinProviders?.[0]?.url;
122722
- const attRes = await this.litOps.requestStaleSpendRecoveryAttestation({
122723
- chainId,
122724
- positionId: this.toBytes32(params.positionId),
122725
- utxoTxid: params.utxoTxid,
122726
- utxoVout: params.utxoVout,
122727
- invalidatorTxid: params.invalidatorTxid,
122728
- contractAddresses: {
122729
- PositionManager: contractAddresses.positionManager,
122730
- BTCSpendAuthorizer: btcSpendAuthorizerAddress,
122731
- ...contractAddresses.bitcoinProviderRegistry && {
122732
- BitcoinProviderRegistry: contractAddresses.bitcoinProviderRegistry
122736
+ const resp = await fetch(
122737
+ `${this.config.serviceEndpoint}/api/lit/stale-spend/recover`,
122738
+ {
122739
+ method: "POST",
122740
+ headers,
122741
+ body: JSON.stringify({
122742
+ positionId: this.toBytes32(params.positionId),
122743
+ utxoTxid: params.utxoTxid,
122744
+ utxoVout: params.utxoVout,
122745
+ invalidatorTxid: params.invalidatorTxid,
122746
+ chainId,
122747
+ ...params.minConfirmations !== void 0 && {
122748
+ minConfirmations: params.minConfirmations
122749
+ }
122750
+ })
122733
122751
  }
122734
- },
122735
- rpcUrl,
122736
- ...sdkBitcoinProviderUrl && { bitcoinProviderUrl: sdkBitcoinProviderUrl },
122737
- // Hardhat (chainId 1337/31337) has no on-chain BitcoinProviderRegistry —
122738
- // Lit Actions read `devBitcoinProviderUrl` from globalThis. Always pass;
122739
- // non-hardhat chains ignore it. (Single source of truth: bitcoinProviderUrl.)
122740
- ...sdkBitcoinProviderUrl && { devBitcoinProviderUrl: sdkBitcoinProviderUrl },
122741
- ...params.minConfirmations !== void 0 && {
122742
- minConfirmations: params.minConfirmations
122752
+ );
122753
+ const json = await resp.json();
122754
+ attRes = json.data ?? {
122755
+ success: false,
122756
+ error: json.error ?? "stale-spend recovery request failed"
122757
+ };
122758
+ } else {
122759
+ const rpcUrl = params.rpcUrl ?? this.config.ethRpcUrl;
122760
+ if (!rpcUrl) {
122761
+ return {
122762
+ success: false,
122763
+ failedStep: "config",
122764
+ error: "ethRpcUrl required for recoverStaleSpend \u2014 set DiamondHandsSDKConfig.ethRpcUrl or pass rpcUrl"
122765
+ };
122743
122766
  }
122744
- });
122767
+ const sdkBitcoinProviderUrl = this.config.bitcoinProviders?.[0]?.url;
122768
+ attRes = await this.litOps.requestStaleSpendRecoveryAttestation({
122769
+ chainId,
122770
+ positionId: this.toBytes32(params.positionId),
122771
+ utxoTxid: params.utxoTxid,
122772
+ utxoVout: params.utxoVout,
122773
+ invalidatorTxid: params.invalidatorTxid,
122774
+ contractAddresses: {
122775
+ PositionManager: contractAddresses.positionManager,
122776
+ BTCSpendAuthorizer: btcSpendAuthorizerAddress,
122777
+ ...contractAddresses.bitcoinProviderRegistry && {
122778
+ BitcoinProviderRegistry: contractAddresses.bitcoinProviderRegistry
122779
+ }
122780
+ },
122781
+ rpcUrl,
122782
+ ...sdkBitcoinProviderUrl && { bitcoinProviderUrl: sdkBitcoinProviderUrl },
122783
+ // Hardhat (chainId 1337/31337) has no on-chain BitcoinProviderRegistry —
122784
+ // Lit Actions read `devBitcoinProviderUrl` from globalThis. Always pass;
122785
+ // non-hardhat chains ignore it. (Single source of truth: bitcoinProviderUrl.)
122786
+ ...sdkBitcoinProviderUrl && { devBitcoinProviderUrl: sdkBitcoinProviderUrl },
122787
+ ...params.minConfirmations !== void 0 && {
122788
+ minConfirmations: params.minConfirmations
122789
+ }
122790
+ });
122791
+ }
122745
122792
  if (!attRes.success || !attRes.signature || !attRes.attestation) {
122746
122793
  return {
122747
122794
  success: false,
package/dist/index.mjs CHANGED
@@ -31381,10 +31381,10 @@ var require_pkg_src = __commonJS({
31381
31381
  deployedAt: 1781116572961,
31382
31382
  size: 4110,
31383
31383
  hash: "c3b121afcdc0d7d7ed7ca3be5b185fc502ffad99bf83cdf166769bbfa5194687",
31384
- validatorWalletAddress: "0x9ee56687f7a984d5df7ab79330271a619ef56ddd",
31384
+ validatorWalletAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
31385
31385
  pkp: {
31386
31386
  publicKey: "0x04ec0e3acc40884e3f366ca469d08899eb640ad5259fa196b0238075086208a9f8732a3175704f35f0bcc28e07406cfb24c254efd1e7355640577330f0d2dd755f",
31387
- ethAddress: "0x9eE56687F7a984D5DF7aB79330271a619ef56DdD"
31387
+ ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
31388
31388
  }
31389
31389
  },
31390
31390
  btcTransactionSigner: {
@@ -31415,7 +31415,7 @@ var require_pkg_src = __commonJS({
31415
31415
  validatorWalletAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
31416
31416
  pkp: {
31417
31417
  publicKey: "0x041ab17cd91fc5c0b761eea6092d032807561b621b82c488826776e04a9158d61ba64d809a4729f0501289d980732cb06d8dfd06999dd9c8efd2f495dad78b31bb",
31418
- ethAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236"
31418
+ ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
31419
31419
  }
31420
31420
  },
31421
31421
  processPaymentValidator: {
@@ -31433,7 +31433,7 @@ var require_pkg_src = __commonJS({
31433
31433
  validatorWalletAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
31434
31434
  pkp: {
31435
31435
  publicKey: "0x04cfccb9b6c7addc79469c0e9fafebef4c70801302c62cdb26b610723a9b8527d23f98a40158c7340d83fd0e62d02b5ec74c12f7a86d98e8c6973b4811110f19ad",
31436
- ethAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236"
31436
+ ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
31437
31437
  }
31438
31438
  },
31439
31439
  extendPositionValidator: {
@@ -31451,7 +31451,7 @@ var require_pkg_src = __commonJS({
31451
31451
  validatorWalletAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
31452
31452
  pkp: {
31453
31453
  publicKey: "0x04e52338f6a0c3362800f1a94c4c8f08be5030dde0fa217388c53d1c1a4790f4443c9f2886b2d2d8f4b75a9a156e9b028011b1a1cf7648da0e556aa980ec692836",
31454
- ethAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236"
31454
+ ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
31455
31455
  }
31456
31456
  },
31457
31457
  btcWithdrawal: {
@@ -31469,7 +31469,7 @@ var require_pkg_src = __commonJS({
31469
31469
  validatorWalletAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
31470
31470
  pkp: {
31471
31471
  publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
31472
- ethAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236"
31472
+ ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
31473
31473
  }
31474
31474
  },
31475
31475
  liquidationValidator: {
@@ -31487,7 +31487,7 @@ var require_pkg_src = __commonJS({
31487
31487
  validatorWalletAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
31488
31488
  pkp: {
31489
31489
  publicKey: "0x041a241de58976c13e3d7ca5a18e494f7330151e3818706135d50176e78ffb673e58b11f0b67a87c73fade6c6b27d6e7a7377ea9f4c10bf31880f1d725f18cc6f8",
31490
- ethAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236"
31490
+ ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
31491
31491
  }
31492
31492
  },
31493
31493
  priceOracle: {
@@ -31502,10 +31502,10 @@ var require_pkg_src = __commonJS({
31502
31502
  deployedAt: 1781116663270,
31503
31503
  size: 8695,
31504
31504
  hash: "ba20ade60a7fa5acd80dadfafa179c507388cfe6ce48a22a672d70b317ffcc74",
31505
- validatorWalletAddress: "0x831ddf3048547b983efe3ccbbb35a45a53191651",
31505
+ validatorWalletAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
31506
31506
  pkp: {
31507
31507
  publicKey: "0x043beaa1da47875601a8d6f430b1438ee2d4732eefd06e5c63a474bbdaf9e7df1797b1b951e041b627c2bf839788164825324c9cbd1e2d6f740fdd4bff69b1900b",
31508
- ethAddress: "0x831DdF3048547B983EFE3ccBBB35a45a53191651"
31508
+ ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
31509
31509
  }
31510
31510
  },
31511
31511
  loanVaultBtcBalance: {
@@ -31523,7 +31523,7 @@ var require_pkg_src = __commonJS({
31523
31523
  validatorWalletAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
31524
31524
  pkp: {
31525
31525
  publicKey: "0x043616787c5432415c24378c4ef48de2bcd6bb7b575b837e3cff09171802662da7105d79586c7659677a0ecbaddac4cce06cb2a11f69a16fa0c4d7002ac7d51a4d",
31526
- ethAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236"
31526
+ ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
31527
31527
  }
31528
31528
  },
31529
31529
  // btc-address-balance (Option B) — address-only signed total balance via
@@ -31544,10 +31544,10 @@ var require_pkg_src = __commonJS({
31544
31544
  deployedAt: 1781116681558,
31545
31545
  size: 21957,
31546
31546
  hash: "b17977304be6b117bcb29feafc3bb654113d72d5147ceeba92e91b4d7f5c0327",
31547
- validatorWalletAddress: "0xf0bf5e3f864b87283a05d1e4a85ee0fa40493fb5",
31547
+ validatorWalletAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
31548
31548
  pkp: {
31549
31549
  publicKey: "0x0498cbb31facfa26e3ec83ccdabfe4fe341ca0282e0c3cb81da7113723b9726e1e49efa92165cc3faa66ced4454cea56dbab12267852d6525a55d7c4f128b912cd",
31550
- ethAddress: "0xF0bF5e3f864B87283a05D1E4A85eE0FA40493fB5"
31550
+ ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
31551
31551
  }
31552
31552
  },
31553
31553
  alwaysSigner: {
@@ -31588,10 +31588,10 @@ var require_pkg_src = __commonJS({
31588
31588
  deployedAt: 1781116700324,
31589
31589
  size: 31148,
31590
31590
  hash: "c93591c7c7f51b519243499d78bd5ac0df1e368caa76c08d6a5d7aea9e3a49cc",
31591
- validatorWalletAddress: "0xa804bbb01d26f250fb3c53007fd32337b985602b",
31591
+ validatorWalletAddress: "0x82db9f515957aa380b596c6ea2bd30cef181f236",
31592
31592
  pkp: {
31593
31593
  publicKey: "0x046da0ad6da7dd4a0063cbeac6f2bdb6a9889c2178b23470833356a8ee5630f7f0eee0db348d9d9aaaadd23eccf0063c8f68ee5e446abe30b882bf1de4c932bc21",
31594
- ethAddress: "0xa804bBb01D26F250FB3c53007fD32337B985602b"
31594
+ ethAddress: "0xc7e1588Db94Bbe92Ab209B833235144Fc5b97607"
31595
31595
  }
31596
31596
  }
31597
31597
  };
@@ -122336,29 +122336,46 @@ Error data: ${errorData || "none"}`
122336
122336
  "Content-Type": "application/json",
122337
122337
  ...await this.getAuthHeader()
122338
122338
  };
122339
- const resp = await fetch(
122340
- `${this.config.serviceEndpoint}/api/lit/pending-withdrawals/execute`,
122341
- {
122342
- method: "POST",
122343
- headers,
122344
- body: JSON.stringify({
122345
- positionId: envelope.positionId,
122346
- txid: envelope.txid,
122347
- vout: envelope.vout,
122348
- satoshis: envelope.satoshis,
122349
- targetAddress: envelope.targetAddress,
122350
- // CRIT-1: send the user-signed targetAmount so the Lit Action can
122351
- // bind it into its hash recomputation AND cross-check against the
122352
- // on-chain authorizer record.
122353
- targetAmount: envelope.targetAmount,
122354
- networkFee: envelope.networkFee,
122355
- userSignature: envelope.userSignature,
122356
- borrowerAddress: envelope.borrowerAddress,
122357
- chainId: envelope.chainId,
122358
- timestamp: envelope.timestamp
122359
- })
122339
+ const PHASE2_CLIENT_TIMEOUT_MS = 6e4;
122340
+ const abort = new AbortController();
122341
+ const abortTimer = setTimeout(() => abort.abort(), PHASE2_CLIENT_TIMEOUT_MS);
122342
+ let resp;
122343
+ try {
122344
+ resp = await fetch(
122345
+ `${this.config.serviceEndpoint}/api/lit/pending-withdrawals/execute`,
122346
+ {
122347
+ method: "POST",
122348
+ headers,
122349
+ signal: abort.signal,
122350
+ body: JSON.stringify({
122351
+ positionId: envelope.positionId,
122352
+ txid: envelope.txid,
122353
+ vout: envelope.vout,
122354
+ satoshis: envelope.satoshis,
122355
+ targetAddress: envelope.targetAddress,
122356
+ // CRIT-1: send the user-signed targetAmount so the Lit Action can
122357
+ // bind it into its hash recomputation AND cross-check against the
122358
+ // on-chain authorizer record.
122359
+ targetAmount: envelope.targetAmount,
122360
+ networkFee: envelope.networkFee,
122361
+ userSignature: envelope.userSignature,
122362
+ borrowerAddress: envelope.borrowerAddress,
122363
+ chainId: envelope.chainId,
122364
+ timestamp: envelope.timestamp
122365
+ })
122366
+ }
122367
+ );
122368
+ } catch (fetchErr) {
122369
+ if (abort.signal.aborted) {
122370
+ return {
122371
+ success: false,
122372
+ error: "Withdrawal signing timed out. Your withdrawal is still authorized on-chain \u2014 retry Execute from Pending Withdrawals to complete it."
122373
+ };
122360
122374
  }
122361
- );
122375
+ throw fetchErr;
122376
+ } finally {
122377
+ clearTimeout(abortTimer);
122378
+ }
122362
122379
  const json = await resp.json();
122363
122380
  if (!json.success || !json.data?.success) {
122364
122381
  const errMsg = json.data?.error ?? json.error ?? "BTC broadcast failed";
@@ -122632,38 +122649,68 @@ Error data: ${errorData || "none"}`
122632
122649
  error: "chainId required for recoverStaleSpend (set DiamondHandsSDKConfig.chainId)"
122633
122650
  };
122634
122651
  }
122635
- const rpcUrl = params.rpcUrl ?? this.config.ethRpcUrl;
122636
- if (!rpcUrl) {
122637
- return {
122638
- success: false,
122639
- failedStep: "config",
122640
- error: "ethRpcUrl required for recoverStaleSpend \u2014 set DiamondHandsSDKConfig.ethRpcUrl or pass rpcUrl"
122652
+ let attRes;
122653
+ if (this.config.mode === "service" && this.config.serviceEndpoint) {
122654
+ const headers = {
122655
+ "Content-Type": "application/json",
122656
+ ...await this.getAuthHeader()
122641
122657
  };
122642
- }
122643
- const sdkBitcoinProviderUrl = this.config.bitcoinProviders?.[0]?.url;
122644
- const attRes = await this.litOps.requestStaleSpendRecoveryAttestation({
122645
- chainId,
122646
- positionId: this.toBytes32(params.positionId),
122647
- utxoTxid: params.utxoTxid,
122648
- utxoVout: params.utxoVout,
122649
- invalidatorTxid: params.invalidatorTxid,
122650
- contractAddresses: {
122651
- PositionManager: contractAddresses.positionManager,
122652
- BTCSpendAuthorizer: btcSpendAuthorizerAddress,
122653
- ...contractAddresses.bitcoinProviderRegistry && {
122654
- BitcoinProviderRegistry: contractAddresses.bitcoinProviderRegistry
122658
+ const resp = await fetch(
122659
+ `${this.config.serviceEndpoint}/api/lit/stale-spend/recover`,
122660
+ {
122661
+ method: "POST",
122662
+ headers,
122663
+ body: JSON.stringify({
122664
+ positionId: this.toBytes32(params.positionId),
122665
+ utxoTxid: params.utxoTxid,
122666
+ utxoVout: params.utxoVout,
122667
+ invalidatorTxid: params.invalidatorTxid,
122668
+ chainId,
122669
+ ...params.minConfirmations !== void 0 && {
122670
+ minConfirmations: params.minConfirmations
122671
+ }
122672
+ })
122655
122673
  }
122656
- },
122657
- rpcUrl,
122658
- ...sdkBitcoinProviderUrl && { bitcoinProviderUrl: sdkBitcoinProviderUrl },
122659
- // Hardhat (chainId 1337/31337) has no on-chain BitcoinProviderRegistry —
122660
- // Lit Actions read `devBitcoinProviderUrl` from globalThis. Always pass;
122661
- // non-hardhat chains ignore it. (Single source of truth: bitcoinProviderUrl.)
122662
- ...sdkBitcoinProviderUrl && { devBitcoinProviderUrl: sdkBitcoinProviderUrl },
122663
- ...params.minConfirmations !== void 0 && {
122664
- minConfirmations: params.minConfirmations
122674
+ );
122675
+ const json = await resp.json();
122676
+ attRes = json.data ?? {
122677
+ success: false,
122678
+ error: json.error ?? "stale-spend recovery request failed"
122679
+ };
122680
+ } else {
122681
+ const rpcUrl = params.rpcUrl ?? this.config.ethRpcUrl;
122682
+ if (!rpcUrl) {
122683
+ return {
122684
+ success: false,
122685
+ failedStep: "config",
122686
+ error: "ethRpcUrl required for recoverStaleSpend \u2014 set DiamondHandsSDKConfig.ethRpcUrl or pass rpcUrl"
122687
+ };
122665
122688
  }
122666
- });
122689
+ const sdkBitcoinProviderUrl = this.config.bitcoinProviders?.[0]?.url;
122690
+ attRes = await this.litOps.requestStaleSpendRecoveryAttestation({
122691
+ chainId,
122692
+ positionId: this.toBytes32(params.positionId),
122693
+ utxoTxid: params.utxoTxid,
122694
+ utxoVout: params.utxoVout,
122695
+ invalidatorTxid: params.invalidatorTxid,
122696
+ contractAddresses: {
122697
+ PositionManager: contractAddresses.positionManager,
122698
+ BTCSpendAuthorizer: btcSpendAuthorizerAddress,
122699
+ ...contractAddresses.bitcoinProviderRegistry && {
122700
+ BitcoinProviderRegistry: contractAddresses.bitcoinProviderRegistry
122701
+ }
122702
+ },
122703
+ rpcUrl,
122704
+ ...sdkBitcoinProviderUrl && { bitcoinProviderUrl: sdkBitcoinProviderUrl },
122705
+ // Hardhat (chainId 1337/31337) has no on-chain BitcoinProviderRegistry —
122706
+ // Lit Actions read `devBitcoinProviderUrl` from globalThis. Always pass;
122707
+ // non-hardhat chains ignore it. (Single source of truth: bitcoinProviderUrl.)
122708
+ ...sdkBitcoinProviderUrl && { devBitcoinProviderUrl: sdkBitcoinProviderUrl },
122709
+ ...params.minConfirmations !== void 0 && {
122710
+ minConfirmations: params.minConfirmations
122711
+ }
122712
+ });
122713
+ }
122667
122714
  if (!attRes.success || !attRes.signature || !attRes.attestation) {
122668
122715
  return {
122669
122716
  success: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gvnrdao/dh-sdk",
3
- "version": "0.0.278",
3
+ "version": "0.0.280",
4
4
  "description": "TypeScript SDK for Diamond Hands Protocol - Bitcoin-backed lending with LIT Protocol PKPs",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -81,8 +81,8 @@
81
81
  },
82
82
  "sideEffects": false,
83
83
  "dependencies": {
84
- "@gvnrdao/dh-lit-actions": "^0.0.308",
85
- "@gvnrdao/dh-lit-ops": "^0.0.296",
84
+ "@gvnrdao/dh-lit-actions": "^0.0.309",
85
+ "@gvnrdao/dh-lit-ops": "^0.0.297",
86
86
  "@noble/hashes": "^1.5.0",
87
87
  "axios": "^1.17.0",
88
88
  "bech32": "^2.0.0",