@arkade-os/sdk 0.4.65 → 0.4.67

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.
Files changed (82) hide show
  1. package/README.md +66 -15
  2. package/dist/adapters/expo.cjs +5 -5
  3. package/dist/adapters/expo.d.cts +3 -6
  4. package/dist/adapters/expo.d.ts +3 -6
  5. package/dist/adapters/expo.js +3 -3
  6. package/dist/adapters/indexedDB.cjs +5 -5
  7. package/dist/adapters/indexedDB.js +4 -4
  8. package/dist/{asyncStorageTaskQueue-Chwe60Ce.d.cts → asyncStorageTaskQueue-LTpeXYaD.d.cts} +2 -2
  9. package/dist/{asyncStorageTaskQueue-Dq_UcvDx.d.ts → asyncStorageTaskQueue-Za-e_zMk.d.ts} +2 -2
  10. package/dist/{chunk-G552MISJ.cjs → chunk-2JV4VQ7C.cjs} +56 -28
  11. package/dist/chunk-2JV4VQ7C.cjs.map +1 -0
  12. package/dist/{chunk-TFSVXMTM.js → chunk-3WIWNE4P.js} +56 -29
  13. package/dist/chunk-3WIWNE4P.js.map +1 -0
  14. package/dist/{chunk-XMOIRDLF.js → chunk-6TAQF6EV.js} +118 -16
  15. package/dist/chunk-6TAQF6EV.js.map +1 -0
  16. package/dist/{chunk-5YTSQSLE.js → chunk-AEWJU6NZ.js} +1033 -193
  17. package/dist/chunk-AEWJU6NZ.js.map +1 -0
  18. package/dist/{chunk-XN55B6EP.cjs → chunk-CO3KKSWM.cjs} +46 -19
  19. package/dist/chunk-CO3KKSWM.cjs.map +1 -0
  20. package/dist/{chunk-RESN6QHP.js → chunk-EALWOVHK.js} +4 -4
  21. package/dist/{chunk-RESN6QHP.js.map → chunk-EALWOVHK.js.map} +1 -1
  22. package/dist/{chunk-GFZNEMGL.cjs → chunk-MJUTO3PY.cjs} +1425 -574
  23. package/dist/chunk-MJUTO3PY.cjs.map +1 -0
  24. package/dist/{chunk-TYTPVPKD.js → chunk-MZFUZUTQ.js} +4 -4
  25. package/dist/{chunk-TYTPVPKD.js.map → chunk-MZFUZUTQ.js.map} +1 -1
  26. package/dist/{chunk-BABJ77NG.cjs → chunk-OIZ2V2VD.cjs} +163 -60
  27. package/dist/chunk-OIZ2V2VD.cjs.map +1 -0
  28. package/dist/{chunk-SJQM5AVB.cjs → chunk-R2YAMONM.cjs} +17 -17
  29. package/dist/{chunk-SJQM5AVB.cjs.map → chunk-R2YAMONM.cjs.map} +1 -1
  30. package/dist/{chunk-3G5V564P.js → chunk-X3VEMUVV.js} +32 -6
  31. package/dist/chunk-X3VEMUVV.js.map +1 -0
  32. package/dist/{chunk-7X744EFF.cjs → chunk-YDRZDZPP.cjs} +10 -10
  33. package/dist/{chunk-7X744EFF.cjs.map → chunk-YDRZDZPP.cjs.map} +1 -1
  34. package/dist/contracts/handlers/index.cjs +9 -9
  35. package/dist/contracts/handlers/index.d.cts +3 -3
  36. package/dist/contracts/handlers/index.d.ts +3 -3
  37. package/dist/contracts/handlers/index.js +2 -2
  38. package/dist/{delegate-BBQW61ym.d.cts → delegate-Bz2e2zXY.d.cts} +1 -1
  39. package/dist/{delegate-Dv_9OVHv.d.ts → delegate-cdmzb2f9.d.ts} +1 -1
  40. package/dist/{wallet-DJUnN939.d.ts → hdWalletCapable-BSjuUYOO.d.cts} +319 -128
  41. package/dist/{wallet-C2NvHjWB.d.cts → hdWalletCapable-Hi12xjCJ.d.ts} +319 -128
  42. package/dist/{index-fDDiA1-L.d.ts → index-BiACuWaf.d.ts} +109 -13
  43. package/dist/{index-BtTtQFUX.d.cts → index-D2GjZxBr.d.cts} +109 -13
  44. package/dist/{index-CFOMyVMt.d.cts → index-DU5o_hz7.d.cts} +275 -51
  45. package/dist/{index-CFOMyVMt.d.ts → index-DU5o_hz7.d.ts} +275 -51
  46. package/dist/index.cjs +328 -276
  47. package/dist/index.d.cts +312 -41
  48. package/dist/index.d.ts +312 -41
  49. package/dist/index.js +4 -4
  50. package/dist/repositories/realm/index.cjs +19 -19
  51. package/dist/repositories/realm/index.d.cts +2 -2
  52. package/dist/repositories/realm/index.d.ts +2 -2
  53. package/dist/repositories/realm/index.js +5 -5
  54. package/dist/repositories/sqlite/index.cjs +18 -18
  55. package/dist/repositories/sqlite/index.d.cts +2 -2
  56. package/dist/repositories/sqlite/index.d.ts +2 -2
  57. package/dist/repositories/sqlite/index.js +5 -5
  58. package/dist/{taskRunner-CIKOS2OO.d.cts → taskRunner-BZJMLQ6g.d.cts} +2 -2
  59. package/dist/{taskRunner-BDzWbpct.d.ts → taskRunner-DATaRQus.d.ts} +2 -2
  60. package/dist/wallet/expo/background.cjs +14 -14
  61. package/dist/wallet/expo/background.d.cts +3 -3
  62. package/dist/wallet/expo/background.d.ts +3 -3
  63. package/dist/wallet/expo/background.js +6 -6
  64. package/dist/wallet/expo/index.cjs +18 -14
  65. package/dist/wallet/expo/index.cjs.map +1 -1
  66. package/dist/wallet/expo/index.d.cts +7 -5
  67. package/dist/wallet/expo/index.d.ts +7 -5
  68. package/dist/wallet/expo/index.js +10 -6
  69. package/dist/wallet/expo/index.js.map +1 -1
  70. package/dist/worker/expo/index.cjs +9 -9
  71. package/dist/worker/expo/index.d.cts +4 -4
  72. package/dist/worker/expo/index.d.ts +4 -4
  73. package/dist/worker/expo/index.js +5 -5
  74. package/package.json +3 -3
  75. package/dist/chunk-3G5V564P.js.map +0 -1
  76. package/dist/chunk-5YTSQSLE.js.map +0 -1
  77. package/dist/chunk-BABJ77NG.cjs.map +0 -1
  78. package/dist/chunk-G552MISJ.cjs.map +0 -1
  79. package/dist/chunk-GFZNEMGL.cjs.map +0 -1
  80. package/dist/chunk-TFSVXMTM.js.map +0 -1
  81. package/dist/chunk-XMOIRDLF.js.map +0 -1
  82. package/dist/chunk-XN55B6EP.cjs.map +0 -1
@@ -1,5 +1,5 @@
1
- import { RestIndexerProvider } from './chunk-3G5V564P.js';
2
- import { RestArkProvider, DEFAULT_ARKADE_SERVER_URL, isFetchTimeoutError, convertVtxo, buildVersion, sdkVersion, fetch } from './chunk-TFSVXMTM.js';
1
+ import { RestIndexerProvider } from './chunk-X3VEMUVV.js';
2
+ import { RestArkProvider, DEFAULT_ARKADE_SERVER_URL, isFetchTimeoutError, convertVtxo, buildVersion, sdkVersion, fetch } from './chunk-3WIWNE4P.js';
3
3
 
4
4
  // src/providers/expoUtils.ts
5
5
  async function getExpoFetch(options) {
@@ -185,5 +185,5 @@ var ExpoIndexerProvider = class extends RestIndexerProvider {
185
185
  };
186
186
 
187
187
  export { ExpoArkProvider, ExpoIndexerProvider };
188
- //# sourceMappingURL=chunk-TYTPVPKD.js.map
189
- //# sourceMappingURL=chunk-TYTPVPKD.js.map
188
+ //# sourceMappingURL=chunk-MZFUZUTQ.js.map
189
+ //# sourceMappingURL=chunk-MZFUZUTQ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/providers/expoUtils.ts","../src/providers/expoArk.ts","../src/providers/expoIndexer.ts"],"names":[],"mappings":";;;;AAMA,eAAsB,aAAa,OAAA,EAA4D;AAG3F,EAAA,IAAI;AACA,IAAA,MAAM,eAAA,GAAkB,MAAM,OAAO,YAAY,CAAA;AACjD,IAAA,OAAA,CAAQ,MAAM,gCAAgC,CAAA;AAC9C,IAAA,MAAM,mBAAA,GAAsB,CAAC,KAAA,EAAoB,IAAA,KAAuB;AACpE,MAAA,MAAM,OAAA,GAAU,IAAI,OAAA,CAAQ,IAAA,EAAM,OAAO,CAAA;AACzC,MAAA,OAAA,CAAQ,GAAA,CAAI,mBAAmB,YAAY,CAAA;AAC3C,MAAA,OAAA,CAAQ,GAAA,CAAI,iBAAiB,UAAU,CAAA;AACvC,MAAA,OAAO,gBAAgB,KAAA,CAAM,KAAA,EAAO,EAAE,GAAG,IAAA,EAAM,SAAS,CAAA;AAAA,IAC5D,CAAA;AACA,IAAA,OAAO,mBAAA;AAAA,EACX,SAAS,KAAA,EAAO;AAQZ,IAAA,OAAA,CAAQ,IAAA;AAAA,MACJ,wGAAA;AAAA,MAEA;AAAA,KACJ;AACA,IAAA,OAAO,KAAA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* Dynamically imports expo/fetch with fallback to standard fetch.\n * @returns A fetch function suitable for SSE streaming\n */\nexport async function getExpoFetch(options?: { requireExpo?: boolean }): Promise<typeof fetch> {\n const requireExpo = options?.requireExpo ?? false;\n\n try {\n const expoFetchModule = await import(\"expo/fetch\");\n console.debug(\"Using expo/fetch for streaming\");\n const expoFetchWithHeader = (input: RequestInfo, init?: RequestInit) => {\n const headers = new Headers(init?.headers);\n headers.set(\"X-Build-Version\", buildVersion);\n headers.set(\"X-SDK-VERSION\", sdkVersion);\n return expoFetchModule.fetch(input, { ...init, headers });\n };\n return expoFetchWithHeader as unknown as typeof fetch;\n } catch (error) {\n if (requireExpo) {\n throw new Error(\n \"expo/fetch is unavailable in this environment. \" +\n \"Please ensure expo/fetch is installed and properly configured.\",\n );\n }\n\n console.warn(\n \"Using standard fetch instead of expo/fetch. \" +\n \"Streaming may not be fully supported in some environments.\",\n error,\n );\n return fetch;\n }\n}\n\n/**\n * Generic SSE stream processor using fetch API with ReadableStream.\n * Handles SSE format parsing, buffer management, and abort signals.\n *\n * @param url - The SSE endpoint URL\n * @param abortSignal - Signal to abort the stream\n * @param fetchFn - Fetch function to use (defaults to standard fetch)\n * @param headers - Additional headers to send\n * @param parseData - Function to parse and yield data from SSE events\n */\nexport async function* sseStreamIterator<T>(\n url: string,\n abortSignal: AbortSignal,\n fetchFn: typeof fetch,\n headers: Record<string, string>,\n parseData: (data: any) => T | null,\n): AsyncGenerator<T, void, unknown> {\n const fetchController = new AbortController();\n const cleanup = () => fetchController.abort();\n abortSignal?.addEventListener(\"abort\", cleanup, { once: true });\n\n try {\n const response = await fetchFn(url, {\n headers: {\n Accept: \"text/event-stream\",\n ...headers,\n },\n signal: fetchController.signal,\n });\n\n if (!response.ok) {\n throw new Error(`Unexpected status ${response.status} when fetching SSE stream`);\n }\n\n if (!response.body) {\n throw new Error(\"Response body is null\");\n }\n\n const reader = response.body.getReader();\n const decoder = new TextDecoder();\n let buffer = \"\";\n\n while (!abortSignal?.aborted) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split(\"\\n\");\n\n for (let i = 0; i < lines.length - 1; i++) {\n const line = lines[i].trim();\n if (!line) continue;\n\n if (line.startsWith(\"data:\")) {\n const jsonStr = line.substring(5).trim();\n if (!jsonStr) continue;\n\n try {\n const data = JSON.parse(jsonStr);\n const parsed = parseData(data);\n if (parsed !== null) {\n yield parsed;\n }\n } catch (parseError) {\n console.error(\"Failed to parse SSE data:\", parseError);\n throw parseError;\n }\n }\n }\n\n buffer = lines[lines.length - 1];\n }\n } finally {\n abortSignal?.removeEventListener(\"abort\", cleanup);\n }\n}\n","import { DEFAULT_ARKADE_SERVER_URL } from \"../networks\";\nimport { RestArkProvider, SettlementEvent, TxNotification, isFetchTimeoutError } from \"./ark\";\nimport { getExpoFetch, sseStreamIterator } from \"./expoUtils\";\n\n/**\n * Expo-compatible Arkade provider implementation using expo/fetch for SSE support.\n * This provider works specifically in React Native/Expo environments where\n * standard EventSource is not available but expo/fetch provides SSE capabilities.\n *\n * @example\n * ```typescript\n * import { ExpoArkProvider } from '@arkade-os/sdk/providers/expo';\n *\n * const provider = new ExpoArkProvider('https://arkade.computer');\n * const info = await provider.getInfo();\n * ```\n */\nexport class ExpoArkProvider extends RestArkProvider {\n constructor(serverUrl: string = DEFAULT_ARKADE_SERVER_URL) {\n super(serverUrl);\n }\n\n override async *getEventStream(\n signal: AbortSignal,\n topics: string[],\n ): AsyncIterableIterator<SettlementEvent> {\n const expoFetch = await getExpoFetch();\n const url = `${this.serverUrl}/v1/batch/events`;\n const queryParams =\n topics.length > 0\n ? `?${topics.map((topic) => `topics=${encodeURIComponent(topic)}`).join(\"&\")}`\n : \"\";\n\n while (!signal?.aborted) {\n try {\n yield* sseStreamIterator(url + queryParams, signal, expoFetch, {}, (data) => {\n // Handle different response structures\n // v8 mesh API might wrap in {result: ...} or send directly\n const eventData = data.result || data;\n\n // Skip heartbeat messages\n if (eventData.heartbeat !== undefined) {\n return null;\n }\n\n return this.parseSettlementEvent(eventData);\n });\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n break;\n }\n\n // ignore timeout errors, they're expected when the server is not sending anything for 5 min\n // these timeouts are set by expo/fetch function\n if (isFetchTimeoutError(error)) {\n console.debug(\"Timeout error ignored\");\n continue;\n }\n\n console.error(\"Event stream error:\", error);\n throw error;\n }\n }\n }\n\n override async *getTransactionsStream(signal: AbortSignal): AsyncIterableIterator<{\n commitmentTx?: TxNotification;\n arkTx?: TxNotification;\n }> {\n const expoFetch = await getExpoFetch();\n const url = `${this.serverUrl}/v1/txs`;\n\n while (!signal?.aborted) {\n try {\n yield* sseStreamIterator(url, signal, expoFetch, {}, (data) => {\n return this.parseTransactionNotification(data.result);\n });\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n break;\n }\n\n // ignore timeout errors, they're expected when the server is not sending anything for 5 min\n // these timeouts are set by expo/fetch function\n if (isFetchTimeoutError(error)) {\n console.debug(\"Timeout error ignored\");\n continue;\n }\n\n console.error(\"Transaction stream error:\", error);\n throw error;\n }\n }\n }\n}\n","import { RestIndexerProvider, SubscriptionResponse } from \"./indexer\";\nimport { isFetchTimeoutError } from \"./ark\";\nimport { convertVtxo } from \"../wallet/vtxo\";\nimport { getExpoFetch, sseStreamIterator } from \"./expoUtils\";\nimport { DEFAULT_ARKADE_SERVER_URL } from \"../networks\";\n\n/**\n * Expo-compatible Indexer provider implementation using expo/fetch for streaming support.\n * This provider works specifically in React Native/Expo environments where\n * standard fetch streaming may not work properly but expo/fetch provides streaming capabilities.\n *\n * @example\n * ```typescript\n * import { ExpoIndexerProvider } from '@arkade-os/sdk/adapters/expo';\n *\n * const provider = new ExpoIndexerProvider('https://indexer.example.com');\n * const vtxos = await provider.getVtxos({ scripts: ['script1'] });\n * ```\n */\nexport class ExpoIndexerProvider extends RestIndexerProvider {\n constructor(serverUrl: string = DEFAULT_ARKADE_SERVER_URL) {\n super(serverUrl);\n }\n\n override async *getSubscription(\n subscriptionId: string,\n abortSignal: AbortSignal,\n ): AsyncIterableIterator<SubscriptionResponse> {\n // Detect if we're running in React Native/Expo environment\n const isReactNative =\n typeof navigator !== \"undefined\" && navigator.product === \"ReactNative\";\n\n const expoFetch = await getExpoFetch().catch((error) => {\n // In React Native/Expo, expo/fetch is required for proper streaming support\n if (isReactNative) {\n throw new Error(\n \"expo/fetch is unavailable in React Native environment. \" +\n \"Please ensure expo/fetch is installed and properly configured. \" +\n \"Streaming support may not work with standard fetch in React Native.\",\n );\n }\n throw error;\n });\n\n const url = `${this.serverUrl}/v1/indexer/script/subscription/${subscriptionId}`;\n\n while (!abortSignal.aborted) {\n try {\n yield* sseStreamIterator(\n url,\n abortSignal,\n expoFetch,\n { \"Content-Type\": \"application/json\" },\n (data): SubscriptionResponse | null => {\n // Handle new v8 proto format with heartbeat or event\n if (data.heartbeat !== undefined) {\n // Skip heartbeat messages\n return null;\n }\n // Process event messages\n if (data.event) {\n return {\n txid: data.event.txid,\n scripts: data.event.scripts || [],\n newVtxos: (data.event.newVtxos || []).map(convertVtxo),\n spentVtxos: (data.event.spentVtxos || []).map(convertVtxo),\n sweptVtxos: (data.event.sweptVtxos || []).map(convertVtxo),\n tx: data.event.tx,\n checkpointTxs: data.event.checkpointTxs,\n };\n }\n return null;\n },\n );\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n break;\n }\n\n // ignore timeout errors, they're expected when the server is not sending anything for 5 min\n // these timeouts are set by expo/fetch function\n if (isFetchTimeoutError(error)) {\n console.debug(\"Timeout error ignored\");\n continue;\n }\n\n console.error(\"Subscription error:\", error);\n throw error;\n }\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/providers/expoUtils.ts","../src/providers/expoArk.ts","../src/providers/expoIndexer.ts"],"names":[],"mappings":";;;;AAMA,eAAsB,aAAa,OAAA,EAA4D;AAG3F,EAAA,IAAI;AACA,IAAA,MAAM,eAAA,GAAkB,MAAM,OAAO,YAA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AA,gBACf,aAAA,EAAe,KAAK,KAAA,CAAM;AAAA,eAC9B;AAAA,YACJ;AACA,YAAA,OAAO,IAAA;AAAA,UACX;AAAA,SACJ;AAAA,MACJ,SAAS,KAAA,EAAO;AACZ,QAAA,IAAI,KAAA,YAAiB,KAAA,IAAS,KAAA,CAAM,IAAA,KAAS,YAAA,EAAc;AACvD,UAAA;AAAA,QACJ;AAIA,QAAA,IAAI,mBAAA,CAAoB,KAAK,CAAA,EAAG;AAC5B,UAAA,OAAA,CAAQ,MAAM,uBAAuB,CAAA;AACrC,UAAA;AAAA,QACJ;AAEA,QAAA,OAAA,CAAQ,KAAA,CAAM,uBAAuB,KAAK,CAAA;AAC1C,QAAA,MAAM,KAAA;AAAA,MACV;AAAA,IACJ;AAAA,EACJ;AACJ","file":"chunk-MZFUZUTQ.js","sourcesContent":["import { fetch, buildVersion, sdkVersion } from \"../utils/fetch\";\n\n/**\n * Dynamically imports expo/fetch with fallback to standard fetch.\n * @returns A fetch function suitable for SSE streaming\n */\nexport async function getExpoFetch(options?: { requireExpo?: boolean }): Promise<typeof fetch> {\n const requireExpo = options?.requireExpo ?? false;\n\n try {\n const expoFetchModule = await import(\"expo/fetch\");\n console.debug(\"Using expo/fetch for streaming\");\n const expoFetchWithHeader = (input: RequestInfo, init?: RequestInit) => {\n const headers = new Headers(init?.headers);\n headers.set(\"X-Build-Version\", buildVersion);\n headers.set(\"X-SDK-VERSION\", sdkVersion);\n return expoFetchModule.fetch(input, { ...init, headers });\n };\n return expoFetchWithHeader as unknown as typeof fetch;\n } catch (error) {\n if (requireExpo) {\n throw new Error(\n \"expo/fetch is unavailable in this environment. \" +\n \"Please ensure expo/fetch is installed and properly configured.\",\n );\n }\n\n console.warn(\n \"Using standard fetch instead of expo/fetch. \" +\n \"Streaming may not be fully supported in some environments.\",\n error,\n );\n return fetch;\n }\n}\n\n/**\n * Generic SSE stream processor using fetch API with ReadableStream.\n * Handles SSE format parsing, buffer management, and abort signals.\n *\n * @param url - The SSE endpoint URL\n * @param abortSignal - Signal to abort the stream\n * @param fetchFn - Fetch function to use (defaults to standard fetch)\n * @param headers - Additional headers to send\n * @param parseData - Function to parse and yield data from SSE events\n */\nexport async function* sseStreamIterator<T>(\n url: string,\n abortSignal: AbortSignal,\n fetchFn: typeof fetch,\n headers: Record<string, string>,\n parseData: (data: any) => T | null,\n): AsyncGenerator<T, void, unknown> {\n const fetchController = new AbortController();\n const cleanup = () => fetchController.abort();\n abortSignal?.addEventListener(\"abort\", cleanup, { once: true });\n\n try {\n const response = await fetchFn(url, {\n headers: {\n Accept: \"text/event-stream\",\n ...headers,\n },\n signal: fetchController.signal,\n });\n\n if (!response.ok) {\n throw new Error(`Unexpected status ${response.status} when fetching SSE stream`);\n }\n\n if (!response.body) {\n throw new Error(\"Response body is null\");\n }\n\n const reader = response.body.getReader();\n const decoder = new TextDecoder();\n let buffer = \"\";\n\n while (!abortSignal?.aborted) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split(\"\\n\");\n\n for (let i = 0; i < lines.length - 1; i++) {\n const line = lines[i].trim();\n if (!line) continue;\n\n if (line.startsWith(\"data:\")) {\n const jsonStr = line.substring(5).trim();\n if (!jsonStr) continue;\n\n try {\n const data = JSON.parse(jsonStr);\n const parsed = parseData(data);\n if (parsed !== null) {\n yield parsed;\n }\n } catch (parseError) {\n console.error(\"Failed to parse SSE data:\", parseError);\n throw parseError;\n }\n }\n }\n\n buffer = lines[lines.length - 1];\n }\n } finally {\n abortSignal?.removeEventListener(\"abort\", cleanup);\n }\n}\n","import { DEFAULT_ARKADE_SERVER_URL } from \"../networks\";\nimport { RestArkProvider, SettlementEvent, TxNotificationEvent, isFetchTimeoutError } from \"./ark\";\nimport { getExpoFetch, sseStreamIterator } from \"./expoUtils\";\n\n/**\n * Expo-compatible Arkade provider implementation using expo/fetch for SSE support.\n * This provider works specifically in React Native/Expo environments where\n * standard EventSource is not available but expo/fetch provides SSE capabilities.\n *\n * @example\n * ```typescript\n * import { ExpoArkProvider } from '@arkade-os/sdk/providers/expo';\n *\n * const provider = new ExpoArkProvider('https://arkade.computer');\n * const info = await provider.getInfo();\n * ```\n */\nexport class ExpoArkProvider extends RestArkProvider {\n constructor(serverUrl: string = DEFAULT_ARKADE_SERVER_URL) {\n super(serverUrl);\n }\n\n override async *getEventStream(\n signal: AbortSignal,\n topics: string[],\n ): AsyncIterableIterator<SettlementEvent> {\n const expoFetch = await getExpoFetch();\n const url = `${this.serverUrl}/v1/batch/events`;\n const queryParams =\n topics.length > 0\n ? `?${topics.map((topic) => `topics=${encodeURIComponent(topic)}`).join(\"&\")}`\n : \"\";\n\n while (!signal?.aborted) {\n try {\n yield* sseStreamIterator(url + queryParams, signal, expoFetch, {}, (data) => {\n // Handle different response structures\n // v8 mesh API might wrap in {result: ...} or send directly\n const eventData = data.result || data;\n\n // Skip heartbeat messages\n if (eventData.heartbeat !== undefined) {\n return null;\n }\n\n return this.parseSettlementEvent(eventData);\n });\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n break;\n }\n\n // ignore timeout errors, they're expected when the server is not sending anything for 5 min\n // these timeouts are set by expo/fetch function\n if (isFetchTimeoutError(error)) {\n console.debug(\"Timeout error ignored\");\n continue;\n }\n\n console.error(\"Event stream error:\", error);\n throw error;\n }\n }\n }\n\n override async *getTransactionsStream(\n signal: AbortSignal,\n ): AsyncIterableIterator<TxNotificationEvent> {\n const expoFetch = await getExpoFetch();\n const url = `${this.serverUrl}/v1/txs`;\n\n while (!signal?.aborted) {\n try {\n yield* sseStreamIterator(url, signal, expoFetch, {}, (data) => {\n return this.parseTransactionNotification(data.result);\n });\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n break;\n }\n\n // ignore timeout errors, they're expected when the server is not sending anything for 5 min\n // these timeouts are set by expo/fetch function\n if (isFetchTimeoutError(error)) {\n console.debug(\"Timeout error ignored\");\n continue;\n }\n\n console.error(\"Transaction stream error:\", error);\n throw error;\n }\n }\n }\n}\n","import { RestIndexerProvider, SubscriptionResponse } from \"./indexer\";\nimport { isFetchTimeoutError } from \"./ark\";\nimport { convertVtxo } from \"../wallet/vtxo\";\nimport { getExpoFetch, sseStreamIterator } from \"./expoUtils\";\nimport { DEFAULT_ARKADE_SERVER_URL } from \"../networks\";\n\n/**\n * Expo-compatible Indexer provider implementation using expo/fetch for streaming support.\n * This provider works specifically in React Native/Expo environments where\n * standard fetch streaming may not work properly but expo/fetch provides streaming capabilities.\n *\n * @example\n * ```typescript\n * import { ExpoIndexerProvider } from '@arkade-os/sdk/adapters/expo';\n *\n * const provider = new ExpoIndexerProvider('https://indexer.example.com');\n * const vtxos = await provider.getVtxos({ scripts: ['script1'] });\n * ```\n */\nexport class ExpoIndexerProvider extends RestIndexerProvider {\n constructor(serverUrl: string = DEFAULT_ARKADE_SERVER_URL) {\n super(serverUrl);\n }\n\n override async *getSubscription(\n subscriptionId: string,\n abortSignal: AbortSignal,\n ): AsyncIterableIterator<SubscriptionResponse> {\n // Detect if we're running in React Native/Expo environment\n const isReactNative =\n typeof navigator !== \"undefined\" && navigator.product === \"ReactNative\";\n\n const expoFetch = await getExpoFetch().catch((error) => {\n // In React Native/Expo, expo/fetch is required for proper streaming support\n if (isReactNative) {\n throw new Error(\n \"expo/fetch is unavailable in React Native environment. \" +\n \"Please ensure expo/fetch is installed and properly configured. \" +\n \"Streaming support may not work with standard fetch in React Native.\",\n );\n }\n throw error;\n });\n\n const url = `${this.serverUrl}/v1/indexer/script/subscription/${subscriptionId}`;\n\n while (!abortSignal.aborted) {\n try {\n yield* sseStreamIterator(\n url,\n abortSignal,\n expoFetch,\n { \"Content-Type\": \"application/json\" },\n (data): SubscriptionResponse | null => {\n // Handle new v8 proto format with heartbeat or event\n if (data.heartbeat !== undefined) {\n // Skip heartbeat messages\n return null;\n }\n // Process event messages\n if (data.event) {\n return {\n txid: data.event.txid,\n scripts: data.event.scripts || [],\n newVtxos: (data.event.newVtxos || []).map(convertVtxo),\n spentVtxos: (data.event.spentVtxos || []).map(convertVtxo),\n sweptVtxos: (data.event.sweptVtxos || []).map(convertVtxo),\n tx: data.event.tx,\n checkpointTxs: data.event.checkpointTxs,\n };\n }\n return null;\n },\n );\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n break;\n }\n\n // ignore timeout errors, they're expected when the server is not sending anything for 5 min\n // these timeouts are set by expo/fetch function\n if (isFetchTimeoutError(error)) {\n console.debug(\"Timeout error ignored\");\n continue;\n }\n\n console.error(\"Subscription error:\", error);\n throw error;\n }\n }\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkG552MISJ_cjs = require('./chunk-G552MISJ.cjs');
3
+ var chunk2JV4VQ7C_cjs = require('./chunk-2JV4VQ7C.cjs');
4
4
  var chunk5BLDMQED_cjs = require('./chunk-5BLDMQED.cjs');
5
5
  var base = require('@scure/base');
6
6
  var descriptorsScure = require('@bitcoinerlab/descriptors-scure');
@@ -76,14 +76,14 @@ var ContractHandlerRegistry = class {
76
76
  var contractHandlers = new ContractHandlerRegistry();
77
77
  exports.DefaultVtxo = void 0;
78
78
  ((DefaultVtxo2) => {
79
- class Script3 extends chunkG552MISJ_cjs.VtxoScript {
79
+ class Script3 extends chunk2JV4VQ7C_cjs.VtxoScript {
80
80
  /** Create the default virtual output script with one forfeit path and one exit path. */
81
81
  constructor(options) {
82
82
  const { pubKey, serverPubKey, csvTimelock } = options;
83
- const forfeitScript = chunkG552MISJ_cjs.MultisigTapscript.encode({
83
+ const forfeitScript = chunk2JV4VQ7C_cjs.MultisigTapscript.encode({
84
84
  pubkeys: [pubKey, serverPubKey]
85
85
  }).script;
86
- const exitScript = chunkG552MISJ_cjs.CSVMultisigTapscript.encode({
86
+ const exitScript = chunk2JV4VQ7C_cjs.CSVMultisigTapscript.encode({
87
87
  timelock: csvTimelock,
88
88
  pubkeys: [pubKey]
89
89
  }).script;
@@ -288,7 +288,7 @@ function extractPubKeyBytes(value) {
288
288
  return base.hex.decode(extractPubKey(normalizeToDescriptor(value)));
289
289
  }
290
290
  function deserializeCsvTimelock(value) {
291
- return value !== void 0 && value !== "" ? chunkG552MISJ_cjs.sequenceToTimelock(Number(value)) : exports.DefaultVtxo.Script.DEFAULT_TIMELOCK;
291
+ return value !== void 0 && value !== "" ? chunk2JV4VQ7C_cjs.sequenceToTimelock(Number(value)) : exports.DefaultVtxo.Script.DEFAULT_TIMELOCK;
292
292
  }
293
293
  var CLTV_HEIGHT_THRESHOLD = 500000000n;
294
294
  function isCltvSatisfied(context, locktime) {
@@ -330,7 +330,7 @@ function assertVhtlcSpendableNow(contract, context) {
330
330
  function isCsvSpendable(context, sequence) {
331
331
  if (sequence === void 0) return true;
332
332
  if (!context.vtxo) return false;
333
- const timelock = chunkG552MISJ_cjs.sequenceToTimelock(sequence);
333
+ const timelock = chunk2JV4VQ7C_cjs.sequenceToTimelock(sequence);
334
334
  if (timelock.type === "blocks") {
335
335
  if (context.blockHeight === void 0 || context.vtxo.status.block_height === void 0) {
336
336
  return false;
@@ -388,21 +388,21 @@ function forfeitExitSpendablePaths(script, contract, context) {
388
388
  async function detectUsedScripts(indexerProvider, scriptHexes) {
389
389
  const used = /* @__PURE__ */ new Set();
390
390
  const unique = [...new Set(scriptHexes)];
391
- for (let offset = 0; offset < unique.length; offset += chunkG552MISJ_cjs.SCRIPT_QUERY_CHUNK_SIZE) {
392
- const scripts = unique.slice(offset, offset + chunkG552MISJ_cjs.SCRIPT_QUERY_CHUNK_SIZE);
391
+ for (let offset = 0; offset < unique.length; offset += chunk2JV4VQ7C_cjs.SCRIPT_QUERY_CHUNK_SIZE) {
392
+ const scripts = unique.slice(offset, offset + chunk2JV4VQ7C_cjs.SCRIPT_QUERY_CHUNK_SIZE);
393
393
  const remaining = new Set(scripts);
394
394
  let pageIndex = 0;
395
395
  let hasMore = true;
396
396
  while (hasMore && remaining.size > 0) {
397
- const { vtxos, page } = await chunkG552MISJ_cjs.getNormalizedVtxos(indexerProvider, {
397
+ const { vtxos, page } = await chunk2JV4VQ7C_cjs.getNormalizedVtxos(indexerProvider, {
398
398
  scripts,
399
399
  pageIndex,
400
- pageSize: chunkG552MISJ_cjs.DEFAULT_PAGE_SIZE
400
+ pageSize: chunk2JV4VQ7C_cjs.DEFAULT_PAGE_SIZE
401
401
  });
402
402
  for (const vtxo of vtxos) {
403
403
  if (remaining.delete(vtxo.script)) used.add(vtxo.script);
404
404
  }
405
- hasMore = page ? vtxos.length === chunkG552MISJ_cjs.DEFAULT_PAGE_SIZE : false;
405
+ hasMore = page ? vtxos.length === chunk2JV4VQ7C_cjs.DEFAULT_PAGE_SIZE : false;
406
406
  pageIndex++;
407
407
  }
408
408
  }
@@ -463,7 +463,7 @@ var DefaultContractHandler = {
463
463
  return {
464
464
  pubKey: base.hex.encode(params.pubKey),
465
465
  serverPubKey: base.hex.encode(params.serverPubKey),
466
- csvTimelock: chunkG552MISJ_cjs.timelockToSequence(params.csvTimelock).toString()
466
+ csvTimelock: chunk2JV4VQ7C_cjs.timelockToSequence(params.csvTimelock).toString()
467
467
  };
468
468
  },
469
469
  deserializeParams(params) {
@@ -498,7 +498,7 @@ function defaultCandidatesAt(_index, descriptor, deps) {
498
498
  params: {
499
499
  pubKey: base.hex.encode(c.pubKey),
500
500
  serverPubKey: base.hex.encode(c.serverPubKey),
501
- csvTimelock: chunkG552MISJ_cjs.timelockToSequence(c.csvTimelock).toString()
501
+ csvTimelock: chunk2JV4VQ7C_cjs.timelockToSequence(c.csvTimelock).toString()
502
502
  },
503
503
  script: c.scriptHex,
504
504
  address: c.script.address(deps.network.hrp, c.serverPubKey).encode()
@@ -514,12 +514,12 @@ function discoverDefaultRange(entries, deps) {
514
514
  }
515
515
  exports.DelegateVtxo = void 0;
516
516
  ((DelegateVtxo2) => {
517
- class Script3 extends chunkG552MISJ_cjs.VtxoScript {
517
+ class Script3 extends chunk2JV4VQ7C_cjs.VtxoScript {
518
518
  /** Create a delegated virtual output script with forfeit, exit, and delegate paths. */
519
519
  constructor(options) {
520
520
  const defaultVtxo = new exports.DefaultVtxo.Script(options);
521
521
  const { delegatePubKey, pubKey, serverPubKey } = options;
522
- const delegateScript = chunkG552MISJ_cjs.MultisigTapscript.encode({
522
+ const delegateScript = chunk2JV4VQ7C_cjs.MultisigTapscript.encode({
523
523
  pubkeys: [pubKey, delegatePubKey, serverPubKey]
524
524
  }).script;
525
525
  super([...defaultVtxo.scripts, delegateScript]);
@@ -558,7 +558,7 @@ var DelegateContractHandler = {
558
558
  pubKey: base.hex.encode(params.pubKey),
559
559
  serverPubKey: base.hex.encode(params.serverPubKey),
560
560
  delegatePubKey: base.hex.encode(params.delegatePubKey),
561
- csvTimelock: chunkG552MISJ_cjs.timelockToSequence(params.csvTimelock).toString()
561
+ csvTimelock: chunk2JV4VQ7C_cjs.timelockToSequence(params.csvTimelock).toString()
562
562
  };
563
563
  },
564
564
  deserializeParams(params) {
@@ -602,7 +602,7 @@ function delegateCandidatesAt(_index, descriptor, deps) {
602
602
  pubKey: base.hex.encode(c.pubKey),
603
603
  serverPubKey: base.hex.encode(c.serverPubKey),
604
604
  delegatePubKey: base.hex.encode(delegatePubKey),
605
- csvTimelock: chunkG552MISJ_cjs.timelockToSequence(c.csvTimelock).toString()
605
+ csvTimelock: chunk2JV4VQ7C_cjs.timelockToSequence(c.csvTimelock).toString()
606
606
  },
607
607
  script: c.scriptHex,
608
608
  address: c.script.address(deps.network.hrp, c.serverPubKey).encode()
@@ -1414,6 +1414,15 @@ function asmToBytes(asm) {
1414
1414
  function bytesToASM(script) {
1415
1415
  return toASM(ArkadeScript.decode(script));
1416
1416
  }
1417
+
1418
+ // src/utils/keys.ts
1419
+ function toXOnly(key, label = "public key") {
1420
+ if (key.length === 32) return key;
1421
+ if (key.length === 33 && (key[0] === 2 || key[0] === 3)) return key.subarray(1);
1422
+ throw new Error(`${label} is not a compressed or x-only public key`);
1423
+ }
1424
+
1425
+ // src/arkade/tweak.ts
1417
1426
  var TAG_SCRIPT = "ArkScriptHash";
1418
1427
  var TAG_WITNESS = "ArkWitnessHash";
1419
1428
  function arkadeScriptHash(script) {
@@ -1427,8 +1436,7 @@ function arkadeWitnessHash(witness) {
1427
1436
  }
1428
1437
  function computeArkadeScriptPublicKey(pubKey, script) {
1429
1438
  const hash = arkadeScriptHash(script);
1430
- const xOnly = pubKey.length === 33 ? pubKey.subarray(1) : pubKey;
1431
- const point = secp256k1_js.schnorr.utils.lift_x(utils_js.bytesToNumberBE(xOnly));
1439
+ const point = secp256k1_js.schnorr.utils.lift_x(utils_js.bytesToNumberBE(toXOnly(pubKey, "emulator key")));
1432
1440
  const scalar = utils_js.bytesToNumberBE(hash) % secp256k1_js.secp256k1.Point.CURVE().n;
1433
1441
  const tweak = secp256k1_js.secp256k1.Point.BASE.multiply(scalar);
1434
1442
  return secp256k1_js.schnorr.utils.pointToBytes(point.add(tweak));
@@ -1437,7 +1445,7 @@ function computeArkadeScriptPublicKey(pubKey, script) {
1437
1445
  // src/script/vhtlc.ts
1438
1446
  exports.VHTLC = void 0;
1439
1447
  ((VHTLC2) => {
1440
- class BaseScript extends chunkG552MISJ_cjs.VtxoScript {
1448
+ class BaseScript extends chunk2JV4VQ7C_cjs.VtxoScript {
1441
1449
  options;
1442
1450
  claimScript;
1443
1451
  refundScript;
@@ -1449,6 +1457,8 @@ exports.VHTLC = void 0;
1449
1457
  nonInteractiveClaimArkadeScript;
1450
1458
  nonInteractiveRefundScript;
1451
1459
  nonInteractiveRefundArkadeScript;
1460
+ nonInteractiveRefundWithoutReceiverScript;
1461
+ nonInteractiveRefundWithoutReceiverArkadeScript;
1452
1462
  constructor(options, preimageCondition) {
1453
1463
  validateOptions(options);
1454
1464
  const {
@@ -1462,27 +1472,27 @@ exports.VHTLC = void 0;
1462
1472
  unilateralRefundWithoutReceiverDelay
1463
1473
  } = options;
1464
1474
  const conditionScript = preimageCondition(preimageHash);
1465
- const claimScript = chunkG552MISJ_cjs.ConditionMultisigTapscript.encode({
1475
+ const claimScript = chunk2JV4VQ7C_cjs.ConditionMultisigTapscript.encode({
1466
1476
  conditionScript,
1467
1477
  pubkeys: [receiver, server]
1468
1478
  }).script;
1469
- const refundScript = chunkG552MISJ_cjs.MultisigTapscript.encode({
1479
+ const refundScript = chunk2JV4VQ7C_cjs.MultisigTapscript.encode({
1470
1480
  pubkeys: [sender, receiver, server]
1471
1481
  }).script;
1472
- const refundWithoutReceiverScript = chunkG552MISJ_cjs.CLTVMultisigTapscript.encode({
1482
+ const refundWithoutReceiverScript = chunk2JV4VQ7C_cjs.CLTVMultisigTapscript.encode({
1473
1483
  absoluteTimelock: refundLocktime,
1474
1484
  pubkeys: [sender, server]
1475
1485
  }).script;
1476
- const unilateralClaimScript = chunkG552MISJ_cjs.ConditionCSVMultisigTapscript.encode({
1486
+ const unilateralClaimScript = chunk2JV4VQ7C_cjs.ConditionCSVMultisigTapscript.encode({
1477
1487
  conditionScript,
1478
1488
  timelock: unilateralClaimDelay,
1479
1489
  pubkeys: [receiver]
1480
1490
  }).script;
1481
- const unilateralRefundScript = chunkG552MISJ_cjs.CSVMultisigTapscript.encode({
1491
+ const unilateralRefundScript = chunk2JV4VQ7C_cjs.CSVMultisigTapscript.encode({
1482
1492
  timelock: unilateralRefundDelay,
1483
1493
  pubkeys: [sender, receiver]
1484
1494
  }).script;
1485
- const unilateralRefundWithoutReceiverScript = chunkG552MISJ_cjs.CSVMultisigTapscript.encode({
1495
+ const unilateralRefundWithoutReceiverScript = chunk2JV4VQ7C_cjs.CSVMultisigTapscript.encode({
1486
1496
  timelock: unilateralRefundWithoutReceiverDelay,
1487
1497
  pubkeys: [sender]
1488
1498
  }).script;
@@ -1502,7 +1512,7 @@ exports.VHTLC = void 0;
1502
1512
  options.asset,
1503
1513
  options.nonInteractiveClaim.strict
1504
1514
  );
1505
- nonInteractiveClaimScript = chunkG552MISJ_cjs.ConditionMultisigTapscript.encode({
1515
+ nonInteractiveClaimScript = chunk2JV4VQ7C_cjs.ConditionMultisigTapscript.encode({
1506
1516
  conditionScript,
1507
1517
  pubkeys: [
1508
1518
  server,
@@ -1516,22 +1526,27 @@ exports.VHTLC = void 0;
1516
1526
  }
1517
1527
  let arkadeScriptNir;
1518
1528
  let nonInteractiveRefundScript;
1529
+ let nonInteractiveRefundWithoutReceiverScript;
1519
1530
  if (options.nonInteractiveRefund) {
1520
1531
  arkadeScriptNir = enforcePayToMaybeAsset(
1521
1532
  options.nonInteractiveRefund.senderPkScript,
1522
1533
  options.asset
1523
1534
  );
1524
- nonInteractiveRefundScript = chunkG552MISJ_cjs.MultisigTapscript.encode({
1525
- pubkeys: [
1526
- server,
1527
- receiver,
1528
- computeArkadeScriptPublicKey(
1529
- options.nonInteractiveRefund.emulatorPubkey,
1530
- arkadeScriptNir
1531
- )
1532
- ]
1535
+ const nirCosigner = computeArkadeScriptPublicKey(
1536
+ options.nonInteractiveRefund.emulatorPubkey,
1537
+ arkadeScriptNir
1538
+ );
1539
+ nonInteractiveRefundScript = chunk2JV4VQ7C_cjs.MultisigTapscript.encode({
1540
+ pubkeys: [server, receiver, nirCosigner]
1533
1541
  }).script;
1534
1542
  scripts.push(nonInteractiveRefundScript);
1543
+ if (options.nonInteractiveRefund.withoutReceiver) {
1544
+ nonInteractiveRefundWithoutReceiverScript = chunk2JV4VQ7C_cjs.CLTVMultisigTapscript.encode({
1545
+ absoluteTimelock: refundLocktime,
1546
+ pubkeys: [server, nirCosigner]
1547
+ }).script;
1548
+ scripts.push(nonInteractiveRefundWithoutReceiverScript);
1549
+ }
1535
1550
  }
1536
1551
  super(scripts);
1537
1552
  this.options = options;
@@ -1551,6 +1566,12 @@ exports.VHTLC = void 0;
1551
1566
  this.nonInteractiveRefundScript = base.hex.encode(nonInteractiveRefundScript);
1552
1567
  this.nonInteractiveRefundArkadeScript = arkadeScriptNir;
1553
1568
  }
1569
+ if (nonInteractiveRefundWithoutReceiverScript) {
1570
+ this.nonInteractiveRefundWithoutReceiverScript = base.hex.encode(
1571
+ nonInteractiveRefundWithoutReceiverScript
1572
+ );
1573
+ this.nonInteractiveRefundWithoutReceiverArkadeScript = arkadeScriptNir;
1574
+ }
1554
1575
  }
1555
1576
  /** Return the collaborative claim tapleaf script. */
1556
1577
  claim() {
@@ -1596,6 +1617,67 @@ exports.VHTLC = void 0;
1596
1617
  this.nonInteractiveRefundArkadeScript
1597
1618
  ];
1598
1619
  }
1620
+ /**
1621
+ * Return the timelocked non-interactive refund tapleaf and its ArkadeScript.
1622
+ *
1623
+ * SPENDING THIS LEAF, CONCRETELY — confirmed from this SDK's own
1624
+ * emulator client and covenant-spend builder ({@link
1625
+ * EmulatorProvider} in `src/providers/emulator.ts`, and {@link
1626
+ * ArkadeTransactionBuilder} in `src/arkade/contract.ts`), which is
1627
+ * the general machinery every covenant leaf in this file goes
1628
+ * through:
1629
+ *
1630
+ * 1. Build the ark tx spending this leaf (this method's {@link
1631
+ * TapLeafScript} as `tapLeafScript`, this script's {@link
1632
+ * VtxoScript.encode} as `tapTree`), plus its checkpoint tx.
1633
+ * 2. Attach the ArkadeScript this method returns to the spent
1634
+ * input via an `EmulatorPacket` (type 1) — `{ vin, script:
1635
+ * <this ArkadeScript>, witness: <empty> }`, empty because the
1636
+ * script pushes its own input/output index with
1637
+ * `PUSHCURRENTINPUTINDEX` rather than reading one from the
1638
+ * witness — wrapped in an `Extension` OP_RETURN output on the
1639
+ * ark tx.
1640
+ * 3. Attach the spent input's OWN creating ark tx as `PrevArkTx` on
1641
+ * input 0 — required so the emulator can resolve that input's
1642
+ * prevout pkScript/value; it does not otherwise have them.
1643
+ * 4. POST the (base64-PSBT) ark tx and checkpoint(s) as `{ arkTx,
1644
+ * checkpointTxs }` to the emulator's `POST /v1/tx`.
1645
+ *
1646
+ * THE COVENANT CHECK the emulator runs against that ArkadeScript —
1647
+ * `enforcePayTo(senderPkScript)`, see that function above — is: the
1648
+ * output at this SAME input's index is a v1 P2TR output paying
1649
+ * `senderPkScript`, with a value at least the input's. Only on that
1650
+ * check passing does the emulator sign for `nirCosigner` (the
1651
+ * `emulatorPubkey` tweaked by this ArkadeScript's hash); the
1652
+ * response carries the fully co-signed `signedArkTx` and
1653
+ * `signedCheckpointTxs` — `ArkadeTransactionBuilder.send()`'s own
1654
+ * comment on this path: "the emulator executes the arkade script
1655
+ * and finalizes with arkd" — no separate call to arkd is made by
1656
+ * this SDK for a covenant spend.
1657
+ * Neither `server` nor `receiver` play any part in that check: this
1658
+ * leaf's tapscript still requires `server`'s own signature
1659
+ * alongside `nirCosigner`'s (see the class doc above), but that is
1660
+ * consensus-level multisig, not something the covenant enforces.
1661
+ *
1662
+ * NOT SPENDABLE UNTIL `refundLocktime` MATURES — the tapscript's
1663
+ * `OP_CHECKLOCKTIMEVERIFY` is arkd's concern, not the emulator's;
1664
+ * the emulator will happily co-sign an immature spend and arkd will
1665
+ * then refuse it. A block-height-typed `refundLocktime` (below the
1666
+ * standard height/timestamp boundary this SDK names
1667
+ * `CLTV_HEIGHT_THRESHOLD`, 500,000,000, in
1668
+ * `src/contracts/handlers/helpers.ts`) is refused by arkd for a
1669
+ * forfeit-eligible leaf independent of maturity — use a
1670
+ * seconds-typed (absolute Unix timestamp) value.
1671
+ */
1672
+ nonInteractiveRefundWithoutReceiver() {
1673
+ if (!this.nonInteractiveRefundWithoutReceiverScript || !this.nonInteractiveRefundWithoutReceiverArkadeScript) {
1674
+ throw new Error("VHTLC has no non-interactive refund-without-receiver leaf");
1675
+ }
1676
+ return [
1677
+ this.findLeaf(this.nonInteractiveRefundWithoutReceiverScript),
1678
+ this.nonInteractiveRefundWithoutReceiverArkadeScript
1679
+ ];
1680
+ }
1599
1681
  }
1600
1682
  class Script3 extends BaseScript {
1601
1683
  constructor(options) {
@@ -1802,9 +1884,9 @@ var VHTLCContractHandler = {
1802
1884
  server: base.hex.encode(params.server),
1803
1885
  hash: base.hex.encode(params.preimageHash),
1804
1886
  refundLocktime: params.refundLocktime.toString(),
1805
- claimDelay: chunkG552MISJ_cjs.timelockToSequence(params.unilateralClaimDelay).toString(),
1806
- refundDelay: chunkG552MISJ_cjs.timelockToSequence(params.unilateralRefundDelay).toString(),
1807
- refundNoReceiverDelay: chunkG552MISJ_cjs.timelockToSequence(
1887
+ claimDelay: chunk2JV4VQ7C_cjs.timelockToSequence(params.unilateralClaimDelay).toString(),
1888
+ refundDelay: chunk2JV4VQ7C_cjs.timelockToSequence(params.unilateralRefundDelay).toString(),
1889
+ refundNoReceiverDelay: chunk2JV4VQ7C_cjs.timelockToSequence(
1808
1890
  params.unilateralRefundWithoutReceiverDelay
1809
1891
  ).toString()
1810
1892
  };
@@ -1816,9 +1898,9 @@ var VHTLCContractHandler = {
1816
1898
  server: base.hex.decode(params.server),
1817
1899
  preimageHash: base.hex.decode(params.hash),
1818
1900
  refundLocktime: BigInt(params.refundLocktime),
1819
- unilateralClaimDelay: chunkG552MISJ_cjs.sequenceToTimelock(Number(params.claimDelay)),
1820
- unilateralRefundDelay: chunkG552MISJ_cjs.sequenceToTimelock(Number(params.refundDelay)),
1821
- unilateralRefundWithoutReceiverDelay: chunkG552MISJ_cjs.sequenceToTimelock(
1901
+ unilateralClaimDelay: chunk2JV4VQ7C_cjs.sequenceToTimelock(Number(params.claimDelay)),
1902
+ unilateralRefundDelay: chunk2JV4VQ7C_cjs.sequenceToTimelock(Number(params.refundDelay)),
1903
+ unilateralRefundWithoutReceiverDelay: chunk2JV4VQ7C_cjs.sequenceToTimelock(
1822
1904
  Number(params.refundNoReceiverDelay)
1823
1905
  )
1824
1906
  };
@@ -2063,9 +2145,9 @@ var VHTLCV2ContractHandler = {
2063
2145
  server: base.hex.encode(params.server),
2064
2146
  hash: base.hex.encode(params.preimageHash),
2065
2147
  refundLocktime: params.refundLocktime.toString(),
2066
- claimDelay: chunkG552MISJ_cjs.timelockToSequence(params.unilateralClaimDelay).toString(),
2067
- refundDelay: chunkG552MISJ_cjs.timelockToSequence(params.unilateralRefundDelay).toString(),
2068
- refundNoReceiverDelay: chunkG552MISJ_cjs.timelockToSequence(
2148
+ claimDelay: chunk2JV4VQ7C_cjs.timelockToSequence(params.unilateralClaimDelay).toString(),
2149
+ refundDelay: chunk2JV4VQ7C_cjs.timelockToSequence(params.unilateralRefundDelay).toString(),
2150
+ refundNoReceiverDelay: chunk2JV4VQ7C_cjs.timelockToSequence(
2069
2151
  params.unilateralRefundWithoutReceiverDelay
2070
2152
  ).toString(),
2071
2153
  // Spread rather than written as `undefined`: a `Record<string,
@@ -2095,7 +2177,14 @@ var VHTLCV2ContractHandler = {
2095
2177
  ),
2096
2178
  nonInteractiveRefundEmulatorPubkey: base.hex.encode(
2097
2179
  params.nonInteractiveRefund.emulatorPubkey
2098
- )
2180
+ ),
2181
+ // Spread rather than a "false"/"undefined" string: a dropped
2182
+ // flag re-derives the EIGHT-leaf script, a different pkScript,
2183
+ // and registration dies at `upsertContractRow` with an opaque
2184
+ // `Script mismatch`. Same silent-drop class as the asset keys.
2185
+ ...params.nonInteractiveRefund.withoutReceiver && {
2186
+ nonInteractiveRefundWithoutReceiver: "1"
2187
+ }
2099
2188
  },
2100
2189
  // The asset must round-trip, and its absence here used to be silent
2101
2190
  // in the worst way. `ContractManager` re-derives a contract from
@@ -2135,6 +2224,16 @@ var VHTLCV2ContractHandler = {
2135
2224
  "strictClaimAssetAmount without strictClaimAmount: reading this as 'not strict' would re-derive the default claim covenant, which is weaker than the row asked for"
2136
2225
  );
2137
2226
  }
2227
+ if (params.nonInteractiveRefundWithoutReceiver !== void 0 && !refund) {
2228
+ throw new Error(
2229
+ "nonInteractiveRefundWithoutReceiver without the nonInteractiveRefund keys it extends: reading this as 'not set' would re-derive a script without the leaf"
2230
+ );
2231
+ }
2232
+ if (params.nonInteractiveRefundWithoutReceiver !== void 0 && params.nonInteractiveRefundWithoutReceiver !== "1") {
2233
+ throw new Error(
2234
+ `nonInteractiveRefundWithoutReceiver must be "1" when present, got ` + JSON.stringify(params.nonInteractiveRefundWithoutReceiver)
2235
+ );
2236
+ }
2138
2237
  const asset = params.assetTxid !== void 0 && params.assetGroupIndex !== void 0 ? {
2139
2238
  txid: base.hex.decode(params.assetTxid),
2140
2239
  groupIndex: parseGroupIndex(params.assetGroupIndex)
@@ -2146,9 +2245,9 @@ var VHTLCV2ContractHandler = {
2146
2245
  preimageHash: base.hex.decode(params.hash),
2147
2246
  refundLocktime: BigInt(params.refundLocktime),
2148
2247
  ...asset && { asset },
2149
- unilateralClaimDelay: chunkG552MISJ_cjs.sequenceToTimelock(Number(params.claimDelay)),
2150
- unilateralRefundDelay: chunkG552MISJ_cjs.sequenceToTimelock(Number(params.refundDelay)),
2151
- unilateralRefundWithoutReceiverDelay: chunkG552MISJ_cjs.sequenceToTimelock(
2248
+ unilateralClaimDelay: chunk2JV4VQ7C_cjs.sequenceToTimelock(Number(params.claimDelay)),
2249
+ unilateralRefundDelay: chunk2JV4VQ7C_cjs.sequenceToTimelock(Number(params.refundDelay)),
2250
+ unilateralRefundWithoutReceiverDelay: chunk2JV4VQ7C_cjs.sequenceToTimelock(
2152
2251
  Number(params.refundNoReceiverDelay)
2153
2252
  ),
2154
2253
  ...claim && {
@@ -2168,7 +2267,10 @@ var VHTLCV2ContractHandler = {
2168
2267
  ...refund && {
2169
2268
  nonInteractiveRefund: {
2170
2269
  senderPkScript: refund.destination,
2171
- emulatorPubkey: refund.emulatorPubkey
2270
+ emulatorPubkey: refund.emulatorPubkey,
2271
+ ...params.nonInteractiveRefundWithoutReceiver === "1" && {
2272
+ withoutReceiver: true
2273
+ }
2172
2274
  }
2173
2275
  }
2174
2276
  };
@@ -2429,7 +2531,7 @@ var BoardingContractHandler = {
2429
2531
  const coins = await deps.onchainProvider.getCoins(onchainAddress);
2430
2532
  if (coins.length === 0) return [];
2431
2533
  const scriptHex = base.hex.encode(script.pkScript);
2432
- const boardingSeq = chunkG552MISJ_cjs.timelockToSequence(deps.boardingTimelock);
2534
+ const boardingSeq = chunk2JV4VQ7C_cjs.timelockToSequence(deps.boardingTimelock);
2433
2535
  return [
2434
2536
  {
2435
2537
  type: "boarding",
@@ -2590,27 +2692,27 @@ function encodeTapscriptSegment(seg, pubkeys, args) {
2590
2692
  if (seg.csv) {
2591
2693
  const timelock = { type: seg.csv.type, value: resolveTimelockValue(seg.csv.value, args) };
2592
2694
  if (seg.asm) {
2593
- return chunkG552MISJ_cjs.ConditionCSVMultisigTapscript.encode({
2695
+ return chunk2JV4VQ7C_cjs.ConditionCSVMultisigTapscript.encode({
2594
2696
  conditionScript: resolveAsm(seg.asm, args),
2595
2697
  timelock,
2596
2698
  pubkeys
2597
2699
  });
2598
2700
  }
2599
- return chunkG552MISJ_cjs.CSVMultisigTapscript.encode({ timelock, pubkeys });
2701
+ return chunk2JV4VQ7C_cjs.CSVMultisigTapscript.encode({ timelock, pubkeys });
2600
2702
  }
2601
2703
  if (seg.cltv !== void 0) {
2602
- return chunkG552MISJ_cjs.CLTVMultisigTapscript.encode({
2704
+ return chunk2JV4VQ7C_cjs.CLTVMultisigTapscript.encode({
2603
2705
  absoluteTimelock: resolveTimelockValue(seg.cltv, args),
2604
2706
  pubkeys
2605
2707
  });
2606
2708
  }
2607
2709
  if (seg.asm) {
2608
- return chunkG552MISJ_cjs.ConditionMultisigTapscript.encode({
2710
+ return chunk2JV4VQ7C_cjs.ConditionMultisigTapscript.encode({
2609
2711
  conditionScript: resolveAsm(seg.asm, args),
2610
2712
  pubkeys
2611
2713
  });
2612
2714
  }
2613
- return chunkG552MISJ_cjs.MultisigTapscript.encode({ pubkeys });
2715
+ return chunk2JV4VQ7C_cjs.MultisigTapscript.encode({ pubkeys });
2614
2716
  }
2615
2717
  function compileFunctions(program, args, keys) {
2616
2718
  if (program.version !== SUPPORTED_PROGRAM_VERSION) {
@@ -2640,7 +2742,7 @@ function compileFunctions(program, args, keys) {
2640
2742
  return { name: names[i], def, leafScript, arkadeScript, signerKeys: pubkeys };
2641
2743
  });
2642
2744
  }
2643
- var ArkadeProgramScript = class extends chunkG552MISJ_cjs.VtxoScript {
2745
+ var ArkadeProgramScript = class extends chunk2JV4VQ7C_cjs.VtxoScript {
2644
2746
  constructor(program, args, keys) {
2645
2747
  const partial = compileFunctions(program, args, keys);
2646
2748
  super(partial.map((p) => p.leafScript));
@@ -2853,7 +2955,7 @@ function pathsFor(script, context, opts) {
2853
2955
  continue;
2854
2956
  }
2855
2957
  if (requiresServer) continue;
2856
- const sequence = csv ? Number(chunkG552MISJ_cjs.timelockToSequence(csv)) : void 0;
2958
+ const sequence = csv ? Number(chunk2JV4VQ7C_cjs.timelockToSequence(csv)) : void 0;
2857
2959
  if (opts.checkTimelocks && csv && !isCsvSpendable(context, sequence)) continue;
2858
2960
  if (opts.checkTimelocks && cltv !== void 0 && !isCltvSatisfied(context, cltv)) {
2859
2961
  continue;
@@ -2979,7 +3081,8 @@ exports.serializeArkadeContractParams = serializeArkadeContractParams;
2979
3081
  exports.speculativeReceiveMetadata = speculativeReceiveMetadata;
2980
3082
  exports.stringifyArtifact = stringifyArtifact;
2981
3083
  exports.toASM = toASM;
3084
+ exports.toXOnly = toXOnly;
2982
3085
  exports.validateProgram = validateProgram;
2983
3086
  exports.witnessRefToBytes = witnessRefToBytes;
2984
- //# sourceMappingURL=chunk-BABJ77NG.cjs.map
2985
- //# sourceMappingURL=chunk-BABJ77NG.cjs.map
3087
+ //# sourceMappingURL=chunk-OIZ2V2VD.cjs.map
3088
+ //# sourceMappingURL=chunk-OIZ2V2VD.cjs.map