@arkade-os/swap 0.0.4 → 0.0.6

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.
@@ -276,9 +276,10 @@ interface RfqStatus {
276
276
  * `senderPubkey` is the trader's own key for the VHTLC's sender-side leaves
277
277
  * (see {@link lightningSendVtxoScript}) — required, never sent anywhere else,
278
278
  * never trusted by the solver as anything but a pubkey to bind into the
279
- * script. On the wire it's `client_refund_pubkey` (docs/rfq-protocol.md
280
- * the solver's schema is `.strict()`, so both the wrong name AND the missing
281
- * required field would refuse every request). */
279
+ * script. On the wire it's `client_refund_pubkey` (the payload schemas are
280
+ * public at https://docs.arkadeos.com/intents/reference/rfq — the solver's schema
281
+ * is `.strict()`, so both the wrong name AND the missing required field would
282
+ * refuse every request). */
282
283
  declare const lightningSendRequest: (input: {
283
284
  rfqId: string;
284
285
  invoice: string;
@@ -355,20 +356,38 @@ declare const relayTransport: (relayUrl: string, options: {
355
356
  WebSocketCtor?: new (url: string) => RelaySocket;
356
357
  timeoutMs?: number;
357
358
  }) => RfqTransport;
359
+ /**
360
+ * How long the sender's SOLO refund opens after the receiver's claim, seconds.
361
+ *
362
+ * This is the window in which a claimant holding the preimage must be able to
363
+ * finish taking their money before the funder could take it back. On a live
364
+ * Arkade server that is one collaborative spend; with the server gone it is a
365
+ * full unilateral exit — an unroll broadcast per chain step, each waiting on a
366
+ * confirmation, then the CSV spend.
367
+ *
368
+ * 4096s (eight 512s units, ~68 minutes) is sized for that worst case. It is
369
+ * REASONED, not measured, and it mirrors `SOLO_REFUND_HEADROOM_SECONDS` in the
370
+ * reference solver's `src/core/timelocks.ts` — the two must move together or a
371
+ * trader derives an address the solver never quoted.
372
+ *
373
+ * A multiple of the granularity on purpose: BIP68 would round anything else,
374
+ * making the encoded timelock differ from the number written here.
375
+ */
376
+ declare const SOLO_REFUND_HEADROOM_SECONDS: number;
358
377
  /** The solver's unilateral-claim delay, derived from the Ark server's reported
359
378
  * exit delay exactly as the reference solver derives it — both sides read the
360
379
  * SAME server, so the derivation (not a quote field) is what keeps the two
361
380
  * scripts identical. */
362
381
  declare const unilateralClaimDelay: (serverExitDelaySeconds: number) => number;
363
- /** VHTLC's `unilateralRefund` tier: sender + solver, no server, one 512s step
364
- * past `claimDelay` the middle rung between the fully-collaborative paths
365
- * and the sender's last-resort `unilateralRefundWithoutReceiver`. Same
366
- * already-rounded `claimDelay` input as {@link unilateralClaimDelay}
367
- * produces — one rounding, shared across all three tiers. */
382
+ /** VHTLC's `unilateralRefund` tier: sender + receiver, no server LEVEL with
383
+ * `claimDelay`, not above it. Neither party can spend a two-signature leaf
384
+ * alone, so separating it buys no safety, and every second spent separating it
385
+ * is a second taken off the headroom that does matter. */
368
386
  declare const unilateralRefundDelay: (claimDelay: number) => number;
369
- /** VHTLC's `unilateralRefundWithoutReceiver` tier: sender alone, needs
370
- * nobody two 512s steps past `claimDelay`, past {@link
371
- * unilateralRefundDelay}. */
387
+ /** VHTLC's `unilateralRefundWithoutReceiver` tier: sender alone, needing
388
+ * nobody. The only leaf whose timing can steal — a funder able to refund
389
+ * before the claimant can claim takes money from someone holding the preimage
390
+ * — so it opens last, by {@link SOLO_REFUND_HEADROOM_SECONDS}. */
372
391
  declare const unilateralRefundWithoutReceiverDelay: (claimDelay: number) => number;
373
392
  /** Compile the lightning-send VHTLC from the quote's binding fields plus the
374
393
  * trader's own data. `paymentHash` is the BOLT11 payment hash (`sha256(P)`,
@@ -631,8 +650,9 @@ declare function requestOnchainSend(wallet: IWallet, arkServerUrl: string, trans
631
650
  htlc: OnchainHtlc;
632
651
  /** The VHTLC `sender` x-only key, bound into the covenant. Public. */
633
652
  senderPubkey: Uint8Array;
634
- /** How the preimage and the `sender` key are recovered later. Persist it
635
- * with the record BEFORE funding. */
653
+ /** How the preimage and the `sender` key are recovered later map it
654
+ * through `swapSecretsToRecord` and persist BEFORE funding. Public unless
655
+ * `mustPersistPreimage` says the wallet could not derive P. */
636
656
  secrets: ProvisionedClaimSecret;
637
657
  }>;
638
658
  /** Default floor for the window between the last moment the hold invoice can
@@ -820,8 +840,9 @@ declare function requestLightningReceive(wallet: IWallet, arkServerUrl: string,
820
840
  payoutAddress: string;
821
841
  /** The trader's covenant `receiver` key, bound into the tree. Public. */
822
842
  payoutPubkey: Uint8Array;
823
- /** How the preimage and the payout key are recovered later. Persist it
824
- * with the record BEFORE paying the invoice. */
843
+ /** How the preimage and the payout key are recovered later map it
844
+ * through `swapSecretsToRecord` and persist BEFORE paying the invoice.
845
+ * Public unless `mustPersistPreimage` says the wallet could not derive P. */
825
846
  secrets: ProvisionedClaimSecret;
826
847
  }>;
827
848
  /**
@@ -893,7 +914,10 @@ declare function requestOnchainReceive(wallet: IWallet, arkServerUrl: string, tr
893
914
  htlc: OnchainHtlc;
894
915
  payoutAddress: string;
895
916
  payoutPubkey: Uint8Array;
917
+ /** How the preimage and the payout key are recovered later — map it
918
+ * through `swapSecretsToRecord` and persist BEFORE funding. Public unless
919
+ * `mustPersistPreimage` says the wallet could not derive P. */
896
920
  secrets: ProvisionedClaimSecret;
897
921
  }>;
898
922
 
899
- export { paymentHashOf as $, ARKADE_ASSET as A, buildHtlcClaim as B, type ChainSource as C, buildHtlcRefund as D, claimOnchainFill as E, classifyOnchainHtlc as F, deriveLightningReceive as G, type HtlcUtxo as H, type InvoiceFacts as I, deriveOnchainReceive as J, deriveOnchainSend as K, LIGHTNING_BTC as L, MAX_MIN_CONFIRMATIONS as M, extractPreimage as N, type OnchainHtlc as O, httpTransport as P, lightningReceiveRequest as Q, type RfqStatus as R, SwapRefusal as S, lightningSendRequest as T, lightningSendVtxoScript as U, newPreimage as V, newRfqId as W, offerTermsFromQuote as X, onchainHtlcScript as Y, onchainReceiveRequest as Z, onchainSendRequest as _, type RfqTransport as a, receiveVtxoScript as a0, relayTransport as a1, requestLightningReceive as a2, requestLightningSend as a3, requestOnchainReceive as a4, requestOnchainSend as a5, rfqPair as a6, unilateralClaimDelay as a7, unilateralRefundDelay as a8, unilateralRefundWithoutReceiverDelay as a9, verifyLockupAddress as aa, verifyReceiveInvoice as ab, type ChainUtxo as b, type OnchainHtlcPhase as c, ARKADE_BTC as d, AddressMismatch as e, LIGHTNING_RECEIVE_PAIR as f, LIGHTNING_SEND_PAIR as g, MIN_CLAIM_WINDOW_SECONDS as h, MIN_HEADROOM_SECONDS as i, ONCHAIN_BTC as j, ONCHAIN_CLAIM_MARGIN_SECONDS as k, ONCHAIN_DUST_SATS as l, ONCHAIN_ORDER_MARGIN_SECONDS as m, ONCHAIN_RECEIVE_PAIR as n, ONCHAIN_SECONDS_PER_BLOCK as o, ONCHAIN_SEND_PAIR as p, type OnchainHtlcParams as q, type OnchainNetwork as r, RFQ_TERMINAL_STATES as s, type RelaySocket as t, type RfqQuote as u, type RfqRefusalReason as v, arkadeSwapRequest as w, assertFundable as x, assertReceivable as y, awaitOnchainFill as z };
923
+ export { onchainSendRequest as $, ARKADE_ASSET as A, awaitOnchainFill as B, type ChainSource as C, buildHtlcClaim as D, buildHtlcRefund as E, claimOnchainFill as F, classifyOnchainHtlc as G, type HtlcUtxo as H, type InvoiceFacts as I, deriveLightningReceive as J, deriveOnchainReceive as K, LIGHTNING_BTC as L, MAX_MIN_CONFIRMATIONS as M, deriveOnchainSend as N, type OnchainHtlc as O, extractPreimage as P, httpTransport as Q, type RfqStatus as R, SOLO_REFUND_HEADROOM_SECONDS as S, lightningReceiveRequest as T, lightningSendRequest as U, lightningSendVtxoScript as V, newPreimage as W, newRfqId as X, offerTermsFromQuote as Y, onchainHtlcScript as Z, onchainReceiveRequest as _, type RfqTransport as a, paymentHashOf as a0, receiveVtxoScript as a1, relayTransport as a2, requestLightningReceive as a3, requestLightningSend as a4, requestOnchainReceive as a5, requestOnchainSend as a6, rfqPair as a7, unilateralClaimDelay as a8, unilateralRefundDelay as a9, unilateralRefundWithoutReceiverDelay as aa, verifyLockupAddress as ab, verifyReceiveInvoice as ac, type ChainUtxo as b, type OnchainHtlcPhase as c, ARKADE_BTC as d, AddressMismatch as e, LIGHTNING_RECEIVE_PAIR as f, LIGHTNING_SEND_PAIR as g, MIN_CLAIM_WINDOW_SECONDS as h, MIN_HEADROOM_SECONDS as i, ONCHAIN_BTC as j, ONCHAIN_CLAIM_MARGIN_SECONDS as k, ONCHAIN_DUST_SATS as l, ONCHAIN_ORDER_MARGIN_SECONDS as m, ONCHAIN_RECEIVE_PAIR as n, ONCHAIN_SECONDS_PER_BLOCK as o, ONCHAIN_SEND_PAIR as p, type OnchainHtlcParams as q, type OnchainNetwork as r, RFQ_TERMINAL_STATES as s, type RelaySocket as t, type RfqQuote as u, type RfqRefusalReason as v, SwapRefusal as w, arkadeSwapRequest as x, assertFundable as y, assertReceivable as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkade-os/swap",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "type": "module",
5
5
  "description": "Client-side Arkade Intents asset swaps: discover markets, quote, create/track/cancel offers, restore from chain.",
6
6
  "repository": {
@@ -30,6 +30,26 @@
30
30
  "types": "./dist/nostr.d.ts",
31
31
  "default": "./dist/nostr.cjs"
32
32
  }
33
+ },
34
+ "./repositories/sqlite": {
35
+ "import": {
36
+ "types": "./dist/repositories/sqlite/index.d.ts",
37
+ "default": "./dist/repositories/sqlite/index.js"
38
+ },
39
+ "require": {
40
+ "types": "./dist/repositories/sqlite/index.d.ts",
41
+ "default": "./dist/repositories/sqlite/index.cjs"
42
+ }
43
+ },
44
+ "./repositories/realm": {
45
+ "import": {
46
+ "types": "./dist/repositories/realm/index.d.ts",
47
+ "default": "./dist/repositories/realm/index.js"
48
+ },
49
+ "require": {
50
+ "types": "./dist/repositories/realm/index.d.ts",
51
+ "default": "./dist/repositories/realm/index.cjs"
52
+ }
33
53
  }
34
54
  },
35
55
  "files": [
@@ -44,12 +64,12 @@
44
64
  "author": "Arkade-OS",
45
65
  "license": "MIT",
46
66
  "dependencies": {
47
- "@arkade-os/solver-discovery": "0.2.1",
67
+ "@arkade-os/solver-discovery": "0.2.3",
48
68
  "@noble/curves": "2.0.1",
49
69
  "@noble/hashes": "2.0.1",
50
70
  "@scure/base": "2.0.0",
51
71
  "@scure/btc-signer": "2.0.1",
52
- "@arkade-os/sdk": "0.4.61"
72
+ "@arkade-os/sdk": "0.4.63"
53
73
  },
54
74
  "peerDependencies": {
55
75
  "nostr-tools": "^2.12.0"
@@ -68,7 +88,7 @@
68
88
  "nostr-tools": "^2.12.0"
69
89
  },
70
90
  "scripts": {
71
- "build": "tsup src/index.ts src/nostr.ts --format esm,cjs --dts --clean",
91
+ "build": "tsup src/index.ts src/nostr.ts src/repositories/sqlite/index.ts src/repositories/realm/index.ts --format esm,cjs --dts --clean",
72
92
  "typecheck": "tsc --noEmit",
73
93
  "format": "prettier --write src test",
74
94
  "lint": "prettier --check src test",