@routstr/sdk 0.3.0 → 0.3.2
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/client/index.d.mts +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +7 -6
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +7 -6
- package/dist/client/index.mjs.map +1 -1
- package/dist/discovery/index.js +2 -0
- package/dist/discovery/index.js.map +1 -1
- package/dist/discovery/index.mjs +2 -0
- package/dist/discovery/index.mjs.map +1 -1
- package/dist/index.js +9 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/client/index.d.mts
CHANGED
|
@@ -32,7 +32,7 @@ declare class ProviderManager {
|
|
|
32
32
|
private lastFailed;
|
|
33
33
|
/** Providers on cooldown: [provider_url, cooldown_started_timestamp][] */
|
|
34
34
|
private providersOnCoolDown;
|
|
35
|
-
/** Cooldown duration in milliseconds (
|
|
35
|
+
/** Cooldown duration in milliseconds (42 seconds) */
|
|
36
36
|
private static readonly COOLDOWN_DURATION_MS;
|
|
37
37
|
/** Optional persistent store for failure tracking */
|
|
38
38
|
private store;
|
package/dist/client/index.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ declare class ProviderManager {
|
|
|
32
32
|
private lastFailed;
|
|
33
33
|
/** Providers on cooldown: [provider_url, cooldown_started_timestamp][] */
|
|
34
34
|
private providersOnCoolDown;
|
|
35
|
-
/** Cooldown duration in milliseconds (
|
|
35
|
+
/** Cooldown duration in milliseconds (42 seconds) */
|
|
36
36
|
private static readonly COOLDOWN_DURATION_MS;
|
|
37
37
|
/** Optional persistent store for failure tracking */
|
|
38
38
|
private store;
|
package/dist/client/index.js
CHANGED
|
@@ -1766,8 +1766,8 @@ var ProviderManager = class _ProviderManager {
|
|
|
1766
1766
|
lastFailed = /* @__PURE__ */ new Map();
|
|
1767
1767
|
/** Providers on cooldown: [provider_url, cooldown_started_timestamp][] */
|
|
1768
1768
|
providersOnCoolDown = [];
|
|
1769
|
-
/** Cooldown duration in milliseconds (
|
|
1770
|
-
static COOLDOWN_DURATION_MS =
|
|
1769
|
+
/** Cooldown duration in milliseconds (42 seconds) */
|
|
1770
|
+
static COOLDOWN_DURATION_MS = 42 * 1e3;
|
|
1771
1771
|
/** Optional persistent store for failure tracking */
|
|
1772
1772
|
store = null;
|
|
1773
1773
|
/** Instance ID for debugging */
|
|
@@ -4205,11 +4205,12 @@ var RoutstrClient = class {
|
|
|
4205
4205
|
baseUrl
|
|
4206
4206
|
);
|
|
4207
4207
|
const currentBalance = currentBalanceInfo.unit === "msat" ? currentBalanceInfo.amount / 1e3 : currentBalanceInfo.amount;
|
|
4208
|
-
const
|
|
4208
|
+
const reservedBalance = currentBalanceInfo.unit === "msat" ? (currentBalanceInfo.reserved ?? 0) / 1e3 : currentBalanceInfo.reserved ?? 0;
|
|
4209
|
+
const shortfall = Math.max(0, params.requiredSats - currentBalance + reservedBalance);
|
|
4209
4210
|
topupAmount = shortfall > 0.21 * params.requiredSats ? shortfall : 0.21 * params.requiredSats;
|
|
4210
4211
|
this._log(
|
|
4211
4212
|
"DEBUG",
|
|
4212
|
-
`The shortfall is: ${shortfall}. requiredSats: ${params.requiredSats}. Current Balance: ${currentBalance} `
|
|
4213
|
+
`The shortfall is: ${shortfall}. requiredSats: ${params.requiredSats}. Current Balance: ${currentBalance}. Reserved Balance: ${reservedBalance}. Available Balance: ${currentBalance - reservedBalance}`
|
|
4213
4214
|
);
|
|
4214
4215
|
} catch (e) {
|
|
4215
4216
|
this._log(
|
|
@@ -4354,10 +4355,10 @@ var RoutstrClient = class {
|
|
|
4354
4355
|
tryNextProvider = true;
|
|
4355
4356
|
}
|
|
4356
4357
|
}
|
|
4357
|
-
if ((status === 401 || status === 403 || status === 413 || status === 400 || status === 500 || status === 502 || status === 503 || status === 504 || status === 521) && !tryNextProvider) {
|
|
4358
|
+
if ((status === 401 || status === 403 || status === 413 || status === 400 || status === 429 || status === 500 || status === 502 || status === 503 || status === 504 || status === 521) && !tryNextProvider) {
|
|
4358
4359
|
this._log(
|
|
4359
4360
|
"DEBUG",
|
|
4360
|
-
`[RoutstrClient] _handleErrorResponse: Status ${status} (auth/server error), attempting refund for ${baseUrl}, mode=${this.mode}`
|
|
4361
|
+
`[RoutstrClient] _handleErrorResponse: Status ${status} (${status === 429 ? "rate limited" : "auth/server error"}), attempting refund for ${baseUrl}, mode=${this.mode}`
|
|
4361
4362
|
);
|
|
4362
4363
|
if (this.mode === "apikeys") {
|
|
4363
4364
|
this._log(
|