@satora/swap 1.2.0 → 1.3.0

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.cjs CHANGED
@@ -367,6 +367,16 @@ function deriveSwapActions(input) {
367
367
  return { recommended: "wait", actions: [wait] };
368
368
  }
369
369
  case "clientfunded": {
370
+ if (!clientFunds) {
371
+ const wait2 = {
372
+ id: "wait",
373
+ waitingOn: "server_funding",
374
+ recommended: true,
375
+ automation: "auto",
376
+ reason: "Waiting for the server to fund the swap."
377
+ };
378
+ return { recommended: "wait", actions: [wait2] };
379
+ }
370
380
  const refundUnlocked = clientChainNow >= clientRefundLocktime;
371
381
  if (refundUnlocked) {
372
382
  const refund2 = {
@@ -504,6 +514,16 @@ function deriveSwapActions(input) {
504
514
  case "serverwontfund":
505
515
  case "clientfundedtoolate":
506
516
  case "clientinvalidfunded": {
517
+ if (!clientFunds) {
518
+ const done = {
519
+ id: "none",
520
+ outcome: "refunded",
521
+ recommended: true,
522
+ automation: "auto",
523
+ reason: "The swap did not complete \u2014 your Lightning payment will be refunded automatically."
524
+ };
525
+ return { recommended: "none", actions: [done] };
526
+ }
507
527
  const refundUnlocked = clientChainNow >= clientRefundLocktime;
508
528
  if (refundUnlocked) {
509
529
  const refund2 = {
@@ -2187,6 +2207,27 @@ function swapToTracked(stored) {
2187
2207
  // Pay-on-Lightning: the client pays a Lightning invoice (off-chain, nothing to
2188
2208
  // watch) and claims an on-chain HTLC. No client-funded leg — the client's
2189
2209
  // claim completes the swap; a hold invoice that never settles auto-unwinds.
2210
+ // Client pays the invoice, then claims the server's EVM HTLC.
2211
+ case "lightning_to_evm":
2212
+ return {
2213
+ swapId: r.id,
2214
+ serverHtlc: evmLeg({
2215
+ chainId: r.evm_chain_id,
2216
+ htlc: r.evm_htlc_address,
2217
+ hashLock: r.hash_lock,
2218
+ claimAddress: r.client_evm_address,
2219
+ // the client claims the server's EVM HTLC
2220
+ expectedSats: r.evm_expected_sats,
2221
+ token: r.wbtc_address,
2222
+ sender: r.server_evm_address,
2223
+ // the server funded it
2224
+ timelockSec: r.evm_refund_locktime,
2225
+ createdAt: r.created_at
2226
+ }),
2227
+ clientRefundLocktime: 0,
2228
+ // no on-chain client leg
2229
+ serverRefundLocktime: ms(r.evm_refund_locktime)
2230
+ };
2190
2231
  // Client pays the invoice, then claims the Arkade VHTLC (target_amount).
2191
2232
  case "lightning_to_arkade":
2192
2233
  return {
@@ -2643,6 +2684,14 @@ var Client = class {
2643
2684
  return this.#legacy.getQuote(...args);
2644
2685
  }
2645
2686
  /** Delegated to the legacy client (migration checkpoint). */
2687
+ createLightningToEvmSwap(...args) {
2688
+ return this.#legacy.createLightningToEvmSwap(...args);
2689
+ }
2690
+ /** Delegated to the legacy client (migration checkpoint). */
2691
+ getLightningSendQuote(...args) {
2692
+ return this.#legacy.getLightningSendQuote(...args);
2693
+ }
2694
+ /** Delegated to the legacy client (migration checkpoint). */
2646
2695
  getSwap(...args) {
2647
2696
  return this.#legacy.getSwap(...args);
2648
2697
  }