@routstr/sdk 0.3.0 → 0.3.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/dist/client/index.js +5 -4
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +5 -4
- 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 +7 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/client/index.mjs
CHANGED
|
@@ -4203,11 +4203,12 @@ var RoutstrClient = class {
|
|
|
4203
4203
|
baseUrl
|
|
4204
4204
|
);
|
|
4205
4205
|
const currentBalance = currentBalanceInfo.unit === "msat" ? currentBalanceInfo.amount / 1e3 : currentBalanceInfo.amount;
|
|
4206
|
-
const
|
|
4206
|
+
const reservedBalance = currentBalanceInfo.unit === "msat" ? (currentBalanceInfo.reserved ?? 0) / 1e3 : currentBalanceInfo.reserved ?? 0;
|
|
4207
|
+
const shortfall = Math.max(0, params.requiredSats - currentBalance + reservedBalance);
|
|
4207
4208
|
topupAmount = shortfall > 0.21 * params.requiredSats ? shortfall : 0.21 * params.requiredSats;
|
|
4208
4209
|
this._log(
|
|
4209
4210
|
"DEBUG",
|
|
4210
|
-
`The shortfall is: ${shortfall}. requiredSats: ${params.requiredSats}. Current Balance: ${currentBalance} `
|
|
4211
|
+
`The shortfall is: ${shortfall}. requiredSats: ${params.requiredSats}. Current Balance: ${currentBalance}. Reserved Balance: ${reservedBalance}. Available Balance: ${currentBalance - reservedBalance}`
|
|
4211
4212
|
);
|
|
4212
4213
|
} catch (e) {
|
|
4213
4214
|
this._log(
|
|
@@ -4352,10 +4353,10 @@ var RoutstrClient = class {
|
|
|
4352
4353
|
tryNextProvider = true;
|
|
4353
4354
|
}
|
|
4354
4355
|
}
|
|
4355
|
-
if ((status === 401 || status === 403 || status === 413 || status === 400 || status === 500 || status === 502 || status === 503 || status === 504 || status === 521) && !tryNextProvider) {
|
|
4356
|
+
if ((status === 401 || status === 403 || status === 413 || status === 400 || status === 429 || status === 500 || status === 502 || status === 503 || status === 504 || status === 521) && !tryNextProvider) {
|
|
4356
4357
|
this._log(
|
|
4357
4358
|
"DEBUG",
|
|
4358
|
-
`[RoutstrClient] _handleErrorResponse: Status ${status} (auth/server error), attempting refund for ${baseUrl}, mode=${this.mode}`
|
|
4359
|
+
`[RoutstrClient] _handleErrorResponse: Status ${status} (${status === 429 ? "rate limited" : "auth/server error"}), attempting refund for ${baseUrl}, mode=${this.mode}`
|
|
4359
4360
|
);
|
|
4360
4361
|
if (this.mode === "apikeys") {
|
|
4361
4362
|
this._log(
|