@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.
@@ -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 shortfall = Math.max(0, params.requiredSats - currentBalance);
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(