@arkade-os/sdk 0.4.28 → 0.4.30
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/README.md +14 -16
- package/dist/adapters/expo.cjs +5 -5
- package/dist/adapters/expo.d.cts +4 -4
- package/dist/adapters/expo.d.ts +4 -4
- package/dist/adapters/expo.js +3 -3
- package/dist/adapters/indexedDB.cjs +5 -5
- package/dist/adapters/indexedDB.js +4 -4
- package/dist/{ark-TZ1gXAXU.d.cts → ark-C0TMXvwO.d.cts} +92 -63
- package/dist/{ark-TZ1gXAXU.d.ts → ark-C0TMXvwO.d.ts} +92 -63
- package/dist/{asyncStorageTaskQueue-EFqSmYTg.d.cts → asyncStorageTaskQueue-DHOoNvRy.d.cts} +2 -2
- package/dist/{asyncStorageTaskQueue-Cb1F_Z9s.d.ts → asyncStorageTaskQueue-Iip3xMF_.d.ts} +2 -2
- package/dist/{chunk-ADV27S4N.cjs → chunk-6FLL2Q36.cjs} +8 -8
- package/dist/chunk-6FLL2Q36.cjs.map +1 -0
- package/dist/{chunk-ZBUDLTBO.js → chunk-6NWNOLL3.js} +5 -5
- package/dist/chunk-6NWNOLL3.js.map +1 -0
- package/dist/{chunk-BQLHADL7.js → chunk-6NY27WL6.js} +341 -183
- package/dist/chunk-6NY27WL6.js.map +1 -0
- package/dist/{chunk-CFZMTDWI.js → chunk-ABWRLTX5.js} +6 -5
- package/dist/chunk-ABWRLTX5.js.map +1 -0
- package/dist/{chunk-FG5ACJJW.cjs → chunk-GIGILVVP.cjs} +11 -10
- package/dist/chunk-GIGILVVP.cjs.map +1 -0
- package/dist/{chunk-A3EMF7RN.js → chunk-GRJKJNBO.js} +3 -3
- package/dist/{chunk-A3EMF7RN.js.map → chunk-GRJKJNBO.js.map} +1 -1
- package/dist/{chunk-I3DGUUCT.cjs → chunk-IEO3XDKI.cjs} +28 -28
- package/dist/{chunk-I3DGUUCT.cjs.map → chunk-IEO3XDKI.cjs.map} +1 -1
- package/dist/{chunk-IPX2R7FR.cjs → chunk-PCEE6DRL.cjs} +7 -7
- package/dist/{chunk-IPX2R7FR.cjs.map → chunk-PCEE6DRL.cjs.map} +1 -1
- package/dist/{chunk-HW3JJ323.js → chunk-TU3LVAPX.js} +32 -31
- package/dist/chunk-TU3LVAPX.js.map +1 -0
- package/dist/{chunk-5PG7DV7A.cjs → chunk-WMIPYZSB.cjs} +34 -36
- package/dist/chunk-WMIPYZSB.cjs.map +1 -0
- package/dist/{chunk-ZLO6NETT.cjs → chunk-XWJFOP5G.cjs} +505 -337
- package/dist/chunk-XWJFOP5G.cjs.map +1 -0
- package/dist/{chunk-T64LAI7L.js → chunk-YA4G7RFB.js} +3 -3
- package/dist/{chunk-T64LAI7L.js.map → chunk-YA4G7RFB.js.map} +1 -1
- package/dist/contracts/handlers/index.cjs +6 -6
- package/dist/contracts/handlers/index.d.cts +3 -3
- package/dist/contracts/handlers/index.d.ts +3 -3
- package/dist/contracts/handlers/index.js +2 -2
- package/dist/{delegate-aaVGfWsV.d.ts → delegate-CEk9RHVj.d.cts} +2 -2
- package/dist/{delegate-BFZs69hp.d.cts → delegate-Ds4Hi7Xy.d.ts} +2 -2
- package/dist/{index-NDla_UoJ.d.ts → index-DA9r_7Vg.d.ts} +2 -2
- package/dist/{index-B22cA64m.d.cts → index-WIAY0DDn.d.cts} +2 -2
- package/dist/index.cjs +161 -137
- package/dist/index.d.cts +144 -17
- package/dist/index.d.ts +144 -17
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +13 -13
- package/dist/repositories/realm/index.d.cts +2 -2
- package/dist/repositories/realm/index.d.ts +2 -2
- package/dist/repositories/realm/index.js +4 -4
- package/dist/repositories/sqlite/index.cjs +13 -13
- package/dist/repositories/sqlite/index.d.cts +1 -1
- package/dist/repositories/sqlite/index.d.ts +1 -1
- package/dist/repositories/sqlite/index.js +4 -4
- package/dist/{taskRunner-C6Ff4OaU.d.cts → taskRunner-CdEVYgoP.d.cts} +2 -2
- package/dist/{taskRunner-yvPN8Z0K.d.ts → taskRunner-JNjIWWJi.d.ts} +2 -2
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +6 -6
- package/dist/wallet/expo/index.cjs +19 -15
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +9 -7
- package/dist/wallet/expo/index.d.ts +9 -7
- package/dist/wallet/expo/index.js +11 -7
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/{wallet-D9NBRqvC.d.ts → wallet-BGL6SzKQ.d.ts} +19 -15
- package/dist/{wallet-AF-p-OWj.d.cts → wallet-CMgzKP0o.d.cts} +19 -15
- package/dist/worker/expo/index.cjs +9 -9
- package/dist/worker/expo/index.d.cts +4 -4
- package/dist/worker/expo/index.d.ts +4 -4
- package/dist/worker/expo/index.js +5 -5
- package/package.json +1 -1
- package/dist/chunk-5PG7DV7A.cjs.map +0 -1
- package/dist/chunk-ADV27S4N.cjs.map +0 -1
- package/dist/chunk-BQLHADL7.js.map +0 -1
- package/dist/chunk-CFZMTDWI.js.map +0 -1
- package/dist/chunk-FG5ACJJW.cjs.map +0 -1
- package/dist/chunk-HW3JJ323.js.map +0 -1
- package/dist/chunk-ZBUDLTBO.js.map +0 -1
- package/dist/chunk-ZLO6NETT.cjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VtxoScript, MultisigTapscript, CSVMultisigTapscript, ConditionMultisigTapscript, CLTVMultisigTapscript, ConditionCSVMultisigTapscript, timelockToSequence, sequenceToTimelock } from './chunk-
|
|
1
|
+
import { VtxoScript, MultisigTapscript, CSVMultisigTapscript, ConditionMultisigTapscript, CLTVMultisigTapscript, ConditionCSVMultisigTapscript, timelockToSequence, sequenceToTimelock } from './chunk-TU3LVAPX.js';
|
|
2
2
|
import { hex } from '@scure/base';
|
|
3
3
|
import { networks, expand } from '@bitcoinerlab/descriptors-scure';
|
|
4
4
|
import { Script } from '@scure/btc-signer';
|
|
@@ -825,5 +825,5 @@ contractHandlers.register(DelegateContractHandler);
|
|
|
825
825
|
contractHandlers.register(VHTLCContractHandler);
|
|
826
826
|
|
|
827
827
|
export { DefaultContractHandler, DefaultVtxo, DelegateContractHandler, DelegateVtxo, VHTLC, VHTLCContractHandler, WALLET_RECEIVE_SOURCE, contractHandlers, deriveDescriptorLeafPubKey, descriptorIsOurs, isMainnetDescriptor };
|
|
828
|
-
//# sourceMappingURL=chunk-
|
|
829
|
-
//# sourceMappingURL=chunk-
|
|
828
|
+
//# sourceMappingURL=chunk-YA4G7RFB.js.map
|
|
829
|
+
//# sourceMappingURL=chunk-YA4G7RFB.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/contracts/handlers/registry.ts","../src/script/default.ts","../src/identity/descriptor.ts","../src/contracts/handlers/helpers.ts","../src/contracts/metadata.ts","../src/contracts/handlers/default.ts","../src/script/delegate.ts","../src/contracts/handlers/delegate.ts","../src/script/vhtlc.ts","../src/contracts/handlers/vhtlc.ts","../src/contracts/handlers/index.ts"],"names":["DefaultVtxo","Script","hex","DelegateVtxo","VHTLC"],"mappings":";;;;;;AAkBA,IAAM,0BAAN,MAA8B;AAAA,EAClB,QAAA,uBAAe,GAAA,EAAsC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7D,SAAS,OAAA,EAAyC;AAC9C,IAAA,IAAI,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,OAAA,CAAQ,IAAI,CAAA,EAAG;AACjC,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,2BAAA,EAA8B,OAAA,CAAQ,IAAI,CAAA,uBAAA,CAAyB,CAAA;AAAA,IACvF;AACA,IAAA,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,OAAA,CAAQ,IAAA,EAAM,OAAO,CAAA;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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IAAI,IAAA,KAAS,cAAc,QAAA,EAAU;AACjC,MAAA,MAAM,QAAA,GAAW,MAAA,CAAO,QAAA,CAAS,MAAA,CAAO,UAAU,CAAA;AAClD,MAAA,IAAI,cAAA,CAAe,OAAA,EAAS,QAAQ,CAAA,EAAG;AACnC,QAAA,KAAA,CAAM,IAAA,CAAK;AAAA,UACP,IAAA,EAAM,OAAO,eAAA,EAAgB;AAAA,UAC7B,YAAA,EAAc,CAACA,GAAAA,CAAI,MAAA,CAAO,QAAQ,CAAC,CAAA;AAAA,UACnC;AAAA,SACH,CAAA;AAAA,MACL;AAAA,IACJ;AACA,IAAA,IAAI,SAAS,QAAA,EAAU;AACnB,MAAA,MAAM,QAAA,GAAW,MAAA,CAAO,QAAA,CAAS,MAAA,CAAO,qBAAqB,CAAA;AAC7D,MAAA,IAAI,cAAA,CAAe,OAAA,EAAS,QAAQ,CAAA,EAAG;AACnC,QAAA,KAAA,CAAM,IAAA,CAAK;AAAA,UACP,IAAA,EAAM,OAAO,+BAAA,EAAgC;AAAA,UAC7C;AAAA,SACH,CAAA;AAAA,MACL;AAAA,IACJ;AAEA,IAAA,OAAO,KAAA;AAAA,EACX;AACJ;;;ACpOA,gBAAA,CAAiB,SAAS,sBAAsB,CAAA;AAChD,gBAAA,CAAiB,SAAS,uBAAuB,CAAA;AACjD,gBAAA,CAAiB,SAAS,oBAAoB,CAAA","file":"chunk-T64LAI7L.js","sourcesContent":["import { ContractHandler } from \"../types\";\n\n/**\n * Registry for contract handlers.\n *\n * Each contract type (\"default\", \"vhtlc\", etc.) has a handler that knows\n * how to create VtxoScripts, serialize params, and select spending paths.\n *\n * @example\n * ```typescript\n * // Register a custom handler\n * contractHandlers.register(myCustomHandler);\n *\n * // Get handler for a type\n * const handler = contractHandlers.get(\"vhtlc\");\n * const script = handler.createScript(contract.params);\n * ```\n */\nclass ContractHandlerRegistry {\n private handlers = new Map<string, ContractHandler<unknown>>();\n\n /**\n * Register a contract handler.\n *\n * @param handler - The handler to register\n * @throws If a handler for this type is already registered\n */\n register(handler: ContractHandler<unknown>): void {\n if (this.handlers.has(handler.type)) {\n throw new Error(`Contract handler for type '${handler.type}' is already registered`);\n }\n this.handlers.set(handler.type, handler);\n }\n\n /**\n * Get a handler by type.\n *\n * @param type - The contract type\n * @returns The handler, or undefined if not found\n */\n get(type: string): ContractHandler<unknown> | undefined {\n return this.handlers.get(type);\n }\n\n /**\n * Get a handler by type, throwing if not found.\n *\n * @param type - The contract type\n * @returns The handler\n * @throws If no handler is registered for this type\n */\n getOrThrow(type: string): ContractHandler<unknown> {\n const handler = this.get(type);\n if (!handler) {\n throw new Error(`No contract handler registered for type '${type}'`);\n }\n return handler;\n }\n\n /**\n * Check if a handler is registered.\n *\n * @param type - The contract type\n */\n has(type: string): boolean {\n return this.handlers.has(type);\n }\n\n /**\n * Get all registered types.\n */\n getRegisteredTypes(): string[] {\n return Array.from(this.handlers.keys());\n }\n\n /**\n * Unregister a handler (mainly for testing).\n */\n unregister(type: string): boolean {\n return this.handlers.delete(type);\n }\n\n /**\n * Clear all handlers (mainly for testing).\n */\n clear(): void {\n this.handlers.clear();\n }\n}\n\n/**\n * Global registry of contract handlers.\n */\nexport const contractHandlers = new ContractHandlerRegistry();\n","import { Bytes } from \"@scure/btc-signer/utils.js\";\nimport { TapLeafScript, VtxoScript } from \"./base\";\nimport { CSVMultisigTapscript, MultisigTapscript, RelativeTimelock } from \"./tapscript\";\nimport { hex } from \"@scure/base\";\n\n/**\n * DefaultVtxo is the default implementation of a VtxoScript.\n * It contains 1 forfeit path and 1 exit path.\n * - forfeit = (Alice + Server)\n * - exit = (Alice) after csvTimelock\n */\nexport namespace DefaultVtxo {\n /**\n * Options is the options for the DefaultVtxo.Script class.\n * csvTimelock is the exit path timelock, default is 144 blocks (1 day).\n */\n export interface Options {\n pubKey: Bytes;\n serverPubKey: Bytes;\n csvTimelock?: RelativeTimelock;\n }\n\n /**\n * DefaultVtxo.Script is the class letting to create the vtxo script.\n * @example\n * ```typescript\n * const vtxoScript = new DefaultVtxo.Script({\n * pubKey: new Uint8Array(32),\n * serverPubKey: new Uint8Array(32),\n * });\n *\n * console.log(\"script pub key:\", vtxoScript.pkScript)\n * ```\n */\n export class Script extends VtxoScript {\n static readonly DEFAULT_TIMELOCK: RelativeTimelock = {\n value: 144n,\n type: \"blocks\",\n }; // 1 day in blocks\n\n readonly forfeitScript: string;\n readonly exitScript: string;\n\n /** Create the default virtual output script with one forfeit path and one exit path. */\n constructor(readonly options: Options) {\n const { pubKey, serverPubKey, csvTimelock = Script.DEFAULT_TIMELOCK } = options;\n\n const forfeitScript = MultisigTapscript.encode({\n pubkeys: [pubKey, serverPubKey],\n }).script;\n\n const exitScript = CSVMultisigTapscript.encode({\n timelock: csvTimelock,\n pubkeys: [pubKey],\n }).script;\n\n super([forfeitScript, exitScript]);\n\n this.forfeitScript = hex.encode(forfeitScript);\n this.exitScript = hex.encode(exitScript);\n }\n\n /** Return the forfeit tapleaf script. */\n forfeit(): TapLeafScript {\n return this.findLeaf(this.forfeitScript);\n }\n\n /** Return the unilateral exit tapleaf script. */\n exit(): TapLeafScript {\n return this.findLeaf(this.exitScript);\n }\n }\n}\n","import { expand, networks } from \"@bitcoinerlab/descriptors-scure\";\nimport { hex } from \"@scure/base\";\n\n/**\n * True iff `descriptor` is a Bitcoin mainnet descriptor (xpub-prefixed\n * BIP32 key).\n *\n * Note: testnet, signet, regtest, mutinynet, and other non-mainnet\n * networks all share the same `tpub` BIP32 version bytes — they cannot\n * be distinguished from one another at the descriptor level. Callers\n * that need a `Network` constants object for `expand()` pick\n * `networks.bitcoin` vs `networks.testnet` themselves; callers that\n * need the *actual* network the wallet is on must track that\n * out-of-band.\n */\nexport function isMainnetDescriptor(descriptor: string): boolean {\n return !descriptor.includes(\"tpub\");\n}\n\n/**\n * Shared \"does `candidate` belong to the identity backed by\n * `ourDescriptor`?\" predicate.\n *\n * - HD descriptors (expanding to a `bip32` key) match by account xpub\n * on both sides — index-agnostic, so a wildcard template and any\n * concrete index under it all collapse to the same xpub.\n * - Bare `tr(pubkey)` candidates fall back to comparing the candidate\n * pubkey against `ourXOnlyPubkey` (the cached pubkey on the identity\n * side, since pulling it from `ourDescriptor` would require an index\n * substitution the caller already performed).\n */\nexport function descriptorIsOurs(\n candidate: string,\n ourDescriptor: string,\n ourXOnlyPubkey: Uint8Array,\n): boolean {\n if (!isDescriptor(candidate)) return false;\n try {\n const candidateInfo = expand({\n descriptor: candidate,\n network: isMainnetDescriptor(candidate) ? networks.bitcoin : networks.testnet,\n }).expansionMap?.[\"@0\"];\n if (!candidateInfo) return false;\n\n if (candidateInfo.bip32) {\n const ourBip32 = expand({\n descriptor: ourDescriptor,\n network: isMainnetDescriptor(ourDescriptor) ? networks.bitcoin : networks.testnet,\n }).expansionMap?.[\"@0\"]?.bip32;\n if (!ourBip32) return false;\n return ourBip32.toBase58() === candidateInfo.bip32.toBase58();\n }\n if (candidateInfo.pubkey) {\n // For tr() the library hands back a 32-byte x-only key, but\n // strip a leading parity byte defensively so a 33-byte\n // compressed key (mismatched length) doesn't silently\n // false-negative against our 32-byte x-only side.\n const candidatePub =\n candidateInfo.pubkey.length === 33\n ? candidateInfo.pubkey.subarray(1)\n : candidateInfo.pubkey;\n if (candidatePub.length !== ourXOnlyPubkey.length) return false;\n return hex.encode(candidatePub) === hex.encode(ourXOnlyPubkey);\n }\n return false;\n } catch {\n return false;\n }\n}\n\n/**\n * Check if a string is a descriptor of the shape `tr(...)`.\n *\n * This is a shape check only — it does not validate the inner key material.\n * Use {@link expand} (via {@link extractPubKey} / {@link parseHDDescriptor})\n * for full parsing. The guard rejects empty bodies and missing/trailing\n * parentheses so callers can safely branch on descriptor vs. raw pubkey.\n */\nexport function isDescriptor(value: string): boolean {\n if (typeof value !== \"string\") return false;\n if (!value.startsWith(\"tr(\") || !value.endsWith(\")\")) return false;\n // body length > 0 after stripping \"tr(\" and \")\"\n return value.length > \"tr()\".length;\n}\n\n/**\n * Normalize a value to descriptor format.\n * If already a descriptor, return as-is. If hex pubkey, wrap as tr(pubkey).\n * Throws when the value is empty or not a string so we never produce\n * malformed descriptors like `tr()` that downstream parsers would reject.\n */\nexport function normalizeToDescriptor(value: string): string {\n if (typeof value !== \"string\" || value.length === 0) {\n throw new Error(\"normalizeToDescriptor: expected a non-empty string value\");\n }\n if (isDescriptor(value)) {\n return value;\n }\n return `tr(${value})`;\n}\n\n/**\n * Extract the public key from a simple descriptor.\n * For simple descriptors (tr(pubkey)), extracts the pubkey using the library.\n * For HD descriptors, throws — use DescriptorProvider to derive the key.\n */\nexport function extractPubKey(descriptor: string): string {\n if (!isDescriptor(descriptor)) {\n return descriptor;\n }\n\n const network = isMainnetDescriptor(descriptor) ? networks.bitcoin : networks.testnet;\n const expansion = expand({ descriptor, network });\n\n if (!expansion.expansionMap) {\n throw new Error(\"Cannot extract pubkey from descriptor: expansion failed.\");\n }\n\n const key = expansion.expansionMap[\"@0\"];\n\n // HD descriptors (have a bip32 key) require DescriptorProvider for derivation\n if (key?.bip32) {\n throw new Error(\n \"Cannot extract pubkey from HD descriptor without derivation. \" +\n \"Use DescriptorProvider to derive the key from the xpub.\",\n );\n }\n\n if (!key?.pubkey) {\n throw new Error(\"Cannot extract pubkey from descriptor: no key found.\");\n }\n\n return hex.encode(key.pubkey);\n}\n\n/**\n * Extract the x-only (32-byte) pubkey from a materialized descriptor.\n * Handles both static `tr(pubkey)` and materialized HD\n * `tr([fp/..]xpub/0/<i>)` shapes via the descriptors-scure expansion map.\n * Throws a plain Error when the descriptor is non-rangeable / unparseable;\n * callers that need a typed error wrap this.\n */\nexport function deriveDescriptorLeafPubKey(descriptor: string): Uint8Array {\n const network = isMainnetDescriptor(descriptor) ? networks.bitcoin : networks.testnet;\n let expansion;\n try {\n expansion = expand({ descriptor, network });\n } catch (e) {\n throw new Error(\n `Cannot derive leaf pubkey from descriptor (length=${descriptor.length}): ` +\n `ensure it is materialized (no wildcard) and parsable.`,\n { cause: e },\n );\n }\n const key = expansion.expansionMap?.[\"@0\"];\n if (!key?.pubkey) {\n throw new Error(\n `Cannot derive leaf pubkey from descriptor (length=${descriptor.length}): ` +\n `parsed but no '@0' pubkey in the expansion map.`,\n );\n }\n return key.pubkey;\n}\n\n/** Parsed HD descriptor components. */\nexport interface ParsedHDDescriptor {\n fingerprint: string;\n basePath: string;\n xpub: string;\n derivationPath: string;\n}\n\n/**\n * Parse an HD descriptor into its components.\n * HD descriptors have the format: tr([fingerprint/path']xpub/derivation)\n * Returns null if the descriptor is not in HD format.\n */\nexport function parseHDDescriptor(descriptor: string): ParsedHDDescriptor | null {\n if (!isDescriptor(descriptor)) {\n return null;\n }\n\n let expansion;\n try {\n const network = isMainnetDescriptor(descriptor) ? networks.bitcoin : networks.testnet;\n expansion = expand({ descriptor, network });\n } catch {\n return null;\n }\n\n const key = expansion.expansionMap?.[\"@0\"];\n if (!key?.masterFingerprint || !key.originPath || !key.keyPath || !key.bip32) {\n return null;\n }\n\n return {\n fingerprint: hex.encode(key.masterFingerprint),\n basePath: key.originPath.replace(/^\\//, \"\"),\n xpub: key.bip32.toBase58(),\n derivationPath: key.keyPath.replace(/^\\//, \"\"),\n };\n}\n","import { sequenceToTimelock } from \"../../utils/timelock\";\nimport { Contract, PathContext } from \"../types\";\nimport { isDescriptor, extractPubKey } from \"../../identity/descriptor\";\n\n/**\n * Extract raw hex pubkey from a value that may be a descriptor or raw hex.\n * Returns undefined for HD descriptors or unparseable values so role\n * resolution stays best-effort and never throws.\n */\nfunction extractRawPubKey(value: string): string | undefined {\n if (!isDescriptor(value)) {\n return value.toLowerCase();\n }\n try {\n return extractPubKey(value).toLowerCase();\n } catch {\n return undefined;\n }\n}\n\n/**\n * Resolve wallet's role from explicit role or by matching descriptor/pubkey.\n */\nexport function resolveRole(\n contract: Contract,\n context: PathContext,\n): \"sender\" | \"receiver\" | undefined {\n // Explicit role takes precedence\n if (context.role === \"sender\" || context.role === \"receiver\") {\n return context.role;\n }\n\n const senderKey = contract.params.sender ? extractRawPubKey(contract.params.sender) : undefined;\n const receiverKey = contract.params.receiver\n ? extractRawPubKey(contract.params.receiver)\n : undefined;\n\n const matchRole = (rawWalletKey: string | undefined): \"sender\" | \"receiver\" | undefined => {\n if (!rawWalletKey) return undefined;\n if (senderKey && rawWalletKey === senderKey) {\n return \"sender\";\n }\n if (receiverKey && rawWalletKey === receiverKey) {\n return \"receiver\";\n }\n return undefined;\n };\n\n // Try the preferred descriptor first. If it cannot be resolved\n // (for example an HD descriptor without derivation support), fall back\n // to walletPubKey for backward compatibility.\n if (context.walletDescriptor) {\n const walletDescriptorKey = extractRawPubKey(context.walletDescriptor);\n const matchedRole = matchRole(walletDescriptorKey);\n if (matchedRole) {\n return matchedRole;\n }\n\n if (!walletDescriptorKey && context.walletPubKey) {\n return matchRole(extractRawPubKey(context.walletPubKey));\n }\n return undefined;\n }\n\n if (context.walletPubKey) {\n return matchRole(extractRawPubKey(context.walletPubKey));\n }\n\n return undefined;\n}\n\n/**\n * BIP65 threshold: locktime values below this are interpreted as block heights,\n * values at or above are interpreted as Unix timestamps (seconds).\n */\nconst CLTV_HEIGHT_THRESHOLD = 500_000_000n;\n\n/**\n * Check if an absolute (CLTV) locktime is currently satisfied.\n *\n * Following the BIP65 convention:\n * - locktime < 500_000_000 → interpreted as a block height; compared against `context.blockHeight`\n * - locktime >= 500_000_000 → interpreted as a Unix timestamp (seconds); compared against `context.currentTime`\n *\n * Returns false if the relevant context field is missing.\n */\nexport function isCltvSatisfied(context: PathContext, locktime: bigint): boolean {\n if (locktime < CLTV_HEIGHT_THRESHOLD) {\n if (context.blockHeight === undefined) return false;\n return BigInt(context.blockHeight) >= locktime;\n }\n const currentTimeSec = BigInt(Math.floor(context.currentTime / 1000));\n return currentTimeSec >= locktime;\n}\n\n/**\n * Check if a CSV timelock is currently satisfied for the given context/virtual output.\n */\nexport function isCsvSpendable(context: PathContext, sequence?: number): boolean {\n if (sequence === undefined) return true;\n if (!context.vtxo) return false;\n const timelock = sequenceToTimelock(sequence);\n\n if (timelock.type === \"blocks\") {\n if (context.blockHeight === undefined || context.vtxo.status.block_height === undefined) {\n return false;\n }\n return context.blockHeight - context.vtxo.status.block_height >= Number(timelock.value);\n }\n\n if (timelock.type === \"seconds\") {\n const blockTime = context.vtxo.status.block_time;\n if (blockTime === undefined) return false;\n return context.currentTime / 1000 - blockTime >= Number(timelock.value);\n }\n\n return false;\n}\n","/**\n * Sentinel stored in `contract.metadata.source` to mark a contract the\n * wallet generated for its own rotating receive address. Lives here (the\n * contracts layer) so contract handlers can tag/discover without importing\n * the wallet module. Re-exported from `wallet/walletReceiveRotator` for\n * backward compatibility of existing import paths.\n *\n * Tagging makes the boot lookup unambiguous — the rotator filters on\n * `metadata.source === WALLET_RECEIVE_SOURCE` rather than on \"any active\n * default contract\", so a contract repo that also holds default contracts\n * created for other reasons (legacy timelock variants, external\n * integrations) doesn't confuse the wallet's display state.\n */\nexport const WALLET_RECEIVE_SOURCE = \"wallet-receive\";\n","import { hex } from \"@scure/base\";\nimport { DefaultVtxo } from \"../../script/default\";\nimport { RelativeTimelock } from \"../../script/tapscript\";\nimport { Contract, ContractHandler, Discoverable, PathContext, PathSelection } from \"../types\";\nimport type { DiscoveredContract, DiscoveryDeps } from \"../types\";\nimport { isCsvSpendable } from \"./helpers\";\nimport { sequenceToTimelock, timelockToSequence } from \"../../utils/timelock\";\nimport {\n normalizeToDescriptor,\n extractPubKey,\n deriveDescriptorLeafPubKey,\n} from \"../../identity/descriptor\";\nimport { WALLET_RECEIVE_SOURCE } from \"../metadata\";\n\n/**\n * Typed parameters for DefaultVtxo contracts.\n */\nexport interface DefaultContractParams {\n pubKey: Uint8Array;\n serverPubKey: Uint8Array;\n csvTimelock: RelativeTimelock;\n}\n\n/**\n * Extract pubkey bytes from a descriptor or hex string.\n */\nfunction extractPubKeyBytes(value: string): Uint8Array {\n return hex.decode(extractPubKey(normalizeToDescriptor(value)));\n}\n\n/**\n * Handler for default wallet VTXOs.\n *\n * Default contracts use the standard forfeit + exit tapscript:\n * - forfeit: (Alice + Server) multisig for collaborative spending\n * - exit: (Alice) + CSV timelock for unilateral exit\n */\nexport const DefaultContractHandler: ContractHandler<DefaultContractParams, DefaultVtxo.Script> &\n Discoverable = {\n type: \"default\",\n\n createScript(params: Record<string, string>): DefaultVtxo.Script {\n const typed = this.deserializeParams(params);\n return new DefaultVtxo.Script(typed);\n },\n\n serializeParams(params: DefaultContractParams): Record<string, string> {\n return {\n pubKey: hex.encode(params.pubKey),\n serverPubKey: hex.encode(params.serverPubKey),\n csvTimelock: timelockToSequence(params.csvTimelock).toString(),\n };\n },\n\n deserializeParams(params: Record<string, string>): DefaultContractParams {\n const csvTimelock = params.csvTimelock\n ? sequenceToTimelock(Number(params.csvTimelock))\n : DefaultVtxo.Script.DEFAULT_TIMELOCK;\n return {\n pubKey: extractPubKeyBytes(params.pubKey),\n serverPubKey: extractPubKeyBytes(params.serverPubKey),\n csvTimelock,\n };\n },\n\n selectPath(\n script: DefaultVtxo.Script,\n contract: Contract,\n context: PathContext,\n ): PathSelection | null {\n if (context.collaborative) {\n // Use forfeit path for collaborative spending\n return { leaf: script.forfeit() };\n }\n\n // Use exit path for unilateral exit (only if CSV is satisfied)\n const sequence = contract.params.csvTimelock\n ? Number(contract.params.csvTimelock)\n : undefined;\n if (!isCsvSpendable(context, sequence)) {\n return null;\n }\n return {\n leaf: script.exit(),\n sequence,\n };\n },\n\n getAllSpendingPaths(\n script: DefaultVtxo.Script,\n contract: Contract,\n context: PathContext,\n ): PathSelection[] {\n const paths: PathSelection[] = [];\n\n // Forfeit path available with server cooperation\n if (context.collaborative) {\n paths.push({ leaf: script.forfeit() });\n }\n\n // Exit path always possible (CSV checked at tx time)\n const exitPath: PathSelection = { leaf: script.exit() };\n if (contract.params.csvTimelock) {\n exitPath.sequence = Number(contract.params.csvTimelock);\n }\n paths.push(exitPath);\n\n return paths;\n },\n\n getSpendablePaths(\n script: DefaultVtxo.Script,\n contract: Contract,\n context: PathContext,\n ): PathSelection[] {\n const paths: PathSelection[] = [];\n\n if (context.collaborative) {\n paths.push({ leaf: script.forfeit() });\n }\n\n const exitSequence = contract.params.csvTimelock\n ? Number(contract.params.csvTimelock)\n : undefined;\n\n if (isCsvSpendable(context, exitSequence)) {\n const exitPath: PathSelection = { leaf: script.exit() };\n if (exitSequence !== undefined) {\n exitPath.sequence = exitSequence;\n }\n paths.push(exitPath);\n }\n\n return paths;\n },\n\n async discoverAt(\n index: number,\n descriptor: string,\n deps: DiscoveryDeps,\n ): Promise<DiscoveredContract[]> {\n const pubKey = deriveDescriptorLeafPubKey(descriptor);\n const out: DiscoveredContract[] = [];\n for (const csvTimelock of deps.csvTimelocks) {\n const script = new DefaultVtxo.Script({\n pubKey,\n serverPubKey: deps.serverPubKey,\n csvTimelock,\n });\n const scriptHex = hex.encode(script.pkScript);\n const { vtxos } = await deps.indexerProvider.getVtxos({\n scripts: [scriptHex],\n });\n if (vtxos.length === 0) continue;\n out.push({\n type: \"default\",\n params: {\n pubKey: hex.encode(pubKey),\n serverPubKey: hex.encode(deps.serverPubKey),\n csvTimelock: timelockToSequence(csvTimelock).toString(),\n },\n script: scriptHex,\n address: script.address(deps.network.hrp, deps.serverPubKey).encode(),\n ...(index > 0\n ? {\n metadata: {\n source: WALLET_RECEIVE_SOURCE,\n signingDescriptor: descriptor,\n },\n }\n : {}),\n });\n }\n return out;\n },\n};\n","import { Bytes } from \"@scure/btc-signer/utils.js\";\nimport { DefaultVtxo } from \"./default\";\nimport { MultisigTapscript } from \"./tapscript\";\nimport { TapLeafScript, VtxoScript } from \"./base\";\nimport { hex } from \"@scure/base\";\n\n/**\n * DelegateVtxo extends DefaultVtxo with an extra delegator path\n */\nexport namespace DelegateVtxo {\n /**\n * Options extends DefaultVtxo.Options and adds a delegatePubKey\n */\n export interface Options extends DefaultVtxo.Options {\n delegatePubKey: Bytes;\n }\n\n /**\n * DelegateVtxo.Script extends DefaultVtxo.Script and adds a delegate path.\n * @example\n * ```typescript\n * const vtxoScript = new DelegateVtxo.Script({\n * pubKey: new Uint8Array(32),\n * serverPubKey: new Uint8Array(32),\n * delegatePubKey: new Uint8Array(32),\n * });\n *\n * console.log(\"script pub key:\", vtxoScript.pkScript)\n * ```\n */\n export class Script extends VtxoScript {\n readonly defaultVtxo: DefaultVtxo.Script;\n readonly delegateScript: string;\n\n /** Create a delegated virtual output script with forfeit, exit, and delegate paths. */\n constructor(readonly options: Options) {\n const defaultVtxo = new DefaultVtxo.Script(options);\n const { delegatePubKey, pubKey, serverPubKey } = options;\n const delegateScript = MultisigTapscript.encode({\n pubkeys: [pubKey, delegatePubKey, serverPubKey],\n }).script;\n\n super([...defaultVtxo.scripts, delegateScript]);\n\n this.defaultVtxo = defaultVtxo;\n this.delegateScript = hex.encode(delegateScript);\n }\n\n /** Return the forfeit tapleaf script. */\n forfeit(): TapLeafScript {\n return this.findLeaf(this.defaultVtxo.forfeitScript);\n }\n\n /** Return the unilateral exit tapleaf script. */\n exit(): TapLeafScript {\n return this.findLeaf(this.defaultVtxo.exitScript);\n }\n\n /** Return the delegate tapleaf script. */\n delegate(): TapLeafScript {\n return this.findLeaf(this.delegateScript);\n }\n }\n}\n","import { hex } from \"@scure/base\";\nimport { DelegateVtxo } from \"../../script/delegate\";\nimport { DefaultVtxo } from \"../../script/default\";\nimport { RelativeTimelock } from \"../../script/tapscript\";\nimport { Contract, ContractHandler, Discoverable, PathContext, PathSelection } from \"../types\";\nimport type { DiscoveredContract, DiscoveryDeps } from \"../types\";\nimport { isCsvSpendable } from \"./helpers\";\nimport { sequenceToTimelock, timelockToSequence } from \"../../utils/timelock\";\nimport { deriveDescriptorLeafPubKey } from \"../../identity/descriptor\";\nimport { WALLET_RECEIVE_SOURCE } from \"../metadata\";\n\n/**\n * Typed parameters for DelegateVtxo contracts.\n */\nexport interface DelegateContractParams {\n pubKey: Uint8Array;\n serverPubKey: Uint8Array;\n delegatePubKey: Uint8Array;\n csvTimelock: RelativeTimelock;\n}\n\n/**\n * Handler for delegate wallet virtual outputs.\n *\n * Delegate contracts extend the default tapscript with an additional delegate path:\n * - forfeit: (Alice + Server) multisig for collaborative spending\n * - exit: (Alice) + CSV timelock for unilateral exit\n * - delegate: (Alice + Delegate + Server) multisig for delegated renewal\n */\nexport const DelegateContractHandler: ContractHandler<DelegateContractParams, DelegateVtxo.Script> &\n Discoverable = {\n type: \"delegate\",\n\n createScript(params: Record<string, string>): DelegateVtxo.Script {\n const typed = this.deserializeParams(params);\n return new DelegateVtxo.Script(typed);\n },\n\n serializeParams(params: DelegateContractParams): Record<string, string> {\n return {\n pubKey: hex.encode(params.pubKey),\n serverPubKey: hex.encode(params.serverPubKey),\n delegatePubKey: hex.encode(params.delegatePubKey),\n csvTimelock: timelockToSequence(params.csvTimelock).toString(),\n };\n },\n\n deserializeParams(params: Record<string, string>): DelegateContractParams {\n const csvTimelock = params.csvTimelock\n ? sequenceToTimelock(Number(params.csvTimelock))\n : DefaultVtxo.Script.DEFAULT_TIMELOCK;\n return {\n pubKey: hex.decode(params.pubKey),\n serverPubKey: hex.decode(params.serverPubKey),\n delegatePubKey: hex.decode(params.delegatePubKey),\n csvTimelock,\n };\n },\n\n selectPath(\n script: DelegateVtxo.Script,\n contract: Contract,\n context: PathContext,\n ): PathSelection | null {\n if (context.collaborative) {\n return { leaf: script.forfeit() };\n }\n\n const sequence = contract.params.csvTimelock\n ? Number(contract.params.csvTimelock)\n : undefined;\n if (!isCsvSpendable(context, sequence)) {\n return null;\n }\n return {\n leaf: script.exit(),\n sequence,\n };\n },\n\n getAllSpendingPaths(\n script: DelegateVtxo.Script,\n contract: Contract,\n context: PathContext,\n ): PathSelection[] {\n const paths: PathSelection[] = [];\n\n if (context.collaborative) {\n paths.push({ leaf: script.forfeit() });\n }\n\n const exitPath: PathSelection = { leaf: script.exit() };\n if (contract.params.csvTimelock) {\n exitPath.sequence = Number(contract.params.csvTimelock);\n }\n paths.push(exitPath);\n\n // Delegate path (Alice + Delegate + Server) — collaborative only\n if (context.collaborative) {\n paths.push({ leaf: script.delegate() });\n }\n\n return paths;\n },\n\n getSpendablePaths(\n script: DelegateVtxo.Script,\n contract: Contract,\n context: PathContext,\n ): PathSelection[] {\n const paths: PathSelection[] = [];\n\n if (context.collaborative) {\n paths.push({ leaf: script.forfeit() });\n }\n\n const exitSequence = contract.params.csvTimelock\n ? Number(contract.params.csvTimelock)\n : undefined;\n\n if (isCsvSpendable(context, exitSequence)) {\n const exitPath: PathSelection = { leaf: script.exit() };\n if (exitSequence !== undefined) {\n exitPath.sequence = exitSequence;\n }\n paths.push(exitPath);\n }\n\n return paths;\n },\n\n async discoverAt(\n index: number,\n descriptor: string,\n deps: DiscoveryDeps,\n ): Promise<DiscoveredContract[]> {\n if (!deps.delegatePubKey) return [];\n const pubKey = deriveDescriptorLeafPubKey(descriptor);\n const out: DiscoveredContract[] = [];\n for (const csvTimelock of deps.csvTimelocks) {\n const script = new DelegateVtxo.Script({\n pubKey,\n serverPubKey: deps.serverPubKey,\n delegatePubKey: deps.delegatePubKey,\n csvTimelock,\n });\n const scriptHex = hex.encode(script.pkScript);\n const { vtxos } = await deps.indexerProvider.getVtxos({\n scripts: [scriptHex],\n });\n if (vtxos.length === 0) continue;\n out.push({\n type: \"delegate\",\n params: {\n pubKey: hex.encode(pubKey),\n serverPubKey: hex.encode(deps.serverPubKey),\n delegatePubKey: hex.encode(deps.delegatePubKey),\n csvTimelock: timelockToSequence(csvTimelock).toString(),\n },\n script: scriptHex,\n address: script.address(deps.network.hrp, deps.serverPubKey).encode(),\n ...(index > 0\n ? {\n metadata: {\n source: WALLET_RECEIVE_SOURCE,\n signingDescriptor: descriptor,\n },\n }\n : {}),\n });\n }\n return out;\n },\n};\n","import { Script } from \"@scure/btc-signer\";\nimport { Bytes } from \"@scure/btc-signer/utils.js\";\nimport {\n CLTVMultisigTapscript,\n ConditionCSVMultisigTapscript,\n ConditionMultisigTapscript,\n CSVMultisigTapscript,\n MultisigTapscript,\n RelativeTimelock,\n} from \"./tapscript\";\nimport { hex } from \"@scure/base\";\nimport { TapLeafScript, VtxoScript } from \"./base\";\n\n/** Virtual Hash Time Lock Contract (VHTLC) namespace. */\nexport namespace VHTLC {\n export interface Options {\n sender: Bytes;\n receiver: Bytes;\n server: Bytes;\n preimageHash: Bytes;\n refundLocktime: bigint;\n unilateralClaimDelay: RelativeTimelock;\n unilateralRefundDelay: RelativeTimelock;\n unilateralRefundWithoutReceiverDelay: RelativeTimelock;\n }\n\n /**\n * Virtual Hash Time Lock Contract (VHTLC) script implementation.\n *\n * VHTLC enables atomic swaps and conditional payments in the Arkade protocol.\n * It provides multiple spending paths:\n *\n * - **claim**: Receiver can claim funds by revealing the preimage\n * - **refund**: Sender and receiver can collaboratively refund\n * - **refundWithoutReceiver**: Sender can refund after locktime expires\n * - **unilateralClaim**: Receiver can claim unilaterally after delay\n * - **unilateralRefund**: Sender and receiver can refund unilaterally after delay\n * - **unilateralRefundWithoutReceiver**: Sender can refund unilaterally after delay\n *\n * @example\n * ```typescript\n * const vhtlc = new VHTLC.Script({\n * sender: alicePubKey,\n * receiver: bobPubKey,\n * server: serverPubKey,\n * preimageHash: hash160(secret),\n * refundLocktime: BigInt(chainTip + 10),\n * unilateralClaimDelay: { type: 'blocks', value: 100n },\n * unilateralRefundDelay: { type: 'blocks', value: 102n },\n * unilateralRefundWithoutReceiverDelay: { type: 'blocks', value: 103n }\n * });\n * ```\n */\n export class Script extends VtxoScript {\n readonly claimScript: string;\n readonly refundScript: string;\n readonly refundWithoutReceiverScript: string;\n readonly unilateralClaimScript: string;\n readonly unilateralRefundScript: string;\n readonly unilateralRefundWithoutReceiverScript: string;\n\n /** Create a VHTLC script from the supplied participant keys, hash, and timelocks. */\n constructor(readonly options: Options) {\n validateOptions(options);\n\n const {\n sender,\n receiver,\n server,\n preimageHash,\n refundLocktime,\n unilateralClaimDelay,\n unilateralRefundDelay,\n unilateralRefundWithoutReceiverDelay,\n } = options;\n\n const conditionScript = preimageConditionScript(preimageHash);\n\n const claimScript = ConditionMultisigTapscript.encode({\n conditionScript,\n pubkeys: [receiver, server],\n }).script;\n\n const refundScript = MultisigTapscript.encode({\n pubkeys: [sender, receiver, server],\n }).script;\n\n const refundWithoutReceiverScript = CLTVMultisigTapscript.encode({\n absoluteTimelock: refundLocktime,\n pubkeys: [sender, server],\n }).script;\n\n const unilateralClaimScript = ConditionCSVMultisigTapscript.encode({\n conditionScript,\n timelock: unilateralClaimDelay,\n pubkeys: [receiver],\n }).script;\n\n const unilateralRefundScript = CSVMultisigTapscript.encode({\n timelock: unilateralRefundDelay,\n pubkeys: [sender, receiver],\n }).script;\n\n const unilateralRefundWithoutReceiverScript = CSVMultisigTapscript.encode({\n timelock: unilateralRefundWithoutReceiverDelay,\n pubkeys: [sender],\n }).script;\n\n super([\n claimScript,\n refundScript,\n refundWithoutReceiverScript,\n unilateralClaimScript,\n unilateralRefundScript,\n unilateralRefundWithoutReceiverScript,\n ]);\n\n this.claimScript = hex.encode(claimScript);\n this.refundScript = hex.encode(refundScript);\n this.refundWithoutReceiverScript = hex.encode(refundWithoutReceiverScript);\n this.unilateralClaimScript = hex.encode(unilateralClaimScript);\n this.unilateralRefundScript = hex.encode(unilateralRefundScript);\n this.unilateralRefundWithoutReceiverScript = hex.encode(\n unilateralRefundWithoutReceiverScript,\n );\n }\n\n /** Return the collaborative claim tapleaf script. */\n claim(): TapLeafScript {\n return this.findLeaf(this.claimScript);\n }\n\n /** Return the collaborative refund tapleaf script. */\n refund(): TapLeafScript {\n return this.findLeaf(this.refundScript);\n }\n\n /** Return the refund-without-receiver tapleaf script. */\n refundWithoutReceiver(): TapLeafScript {\n return this.findLeaf(this.refundWithoutReceiverScript);\n }\n\n /** Return the unilateral claim tapleaf script. */\n unilateralClaim(): TapLeafScript {\n return this.findLeaf(this.unilateralClaimScript);\n }\n\n /** Return the unilateral refund tapleaf script. */\n unilateralRefund(): TapLeafScript {\n return this.findLeaf(this.unilateralRefundScript);\n }\n\n /** Return the unilateral refund-without-receiver tapleaf script. */\n unilateralRefundWithoutReceiver(): TapLeafScript {\n return this.findLeaf(this.unilateralRefundWithoutReceiverScript);\n }\n }\n\n function validateOptions(options: Options): void {\n const {\n sender,\n receiver,\n server,\n preimageHash,\n refundLocktime,\n unilateralClaimDelay,\n unilateralRefundDelay,\n unilateralRefundWithoutReceiverDelay,\n } = options;\n\n if (!preimageHash || preimageHash.length !== 20) {\n throw new Error(\"preimage hash must be 20 bytes\");\n }\n if (!receiver || receiver.length !== 32) {\n throw new Error(\"Invalid public key length (receiver)\");\n }\n if (!sender || sender.length !== 32) {\n throw new Error(\"Invalid public key length (sender)\");\n }\n if (!server || server.length !== 32) {\n throw new Error(\"Invalid public key length (server)\");\n }\n if (typeof refundLocktime !== \"bigint\" || refundLocktime <= 0n) {\n throw new Error(\"refund locktime must be greater than 0\");\n }\n if (\n !unilateralClaimDelay ||\n typeof unilateralClaimDelay.value !== \"bigint\" ||\n unilateralClaimDelay.value <= 0n\n ) {\n throw new Error(\"unilateral claim delay must greater than 0\");\n }\n if (unilateralClaimDelay.type === \"seconds\" && unilateralClaimDelay.value % 512n !== 0n) {\n throw new Error(\"seconds timelock must be multiple of 512\");\n }\n if (unilateralClaimDelay.type === \"seconds\" && unilateralClaimDelay.value < 512n) {\n throw new Error(\"seconds timelock must be greater or equal to 512\");\n }\n if (\n !unilateralRefundDelay ||\n typeof unilateralRefundDelay.value !== \"bigint\" ||\n unilateralRefundDelay.value <= 0n\n ) {\n throw new Error(\"unilateral refund delay must greater than 0\");\n }\n if (unilateralRefundDelay.type === \"seconds\" && unilateralRefundDelay.value % 512n !== 0n) {\n throw new Error(\"seconds timelock must be multiple of 512\");\n }\n if (unilateralRefundDelay.type === \"seconds\" && unilateralRefundDelay.value < 512n) {\n throw new Error(\"seconds timelock must be greater or equal to 512\");\n }\n if (\n !unilateralRefundWithoutReceiverDelay ||\n typeof unilateralRefundWithoutReceiverDelay.value !== \"bigint\" ||\n unilateralRefundWithoutReceiverDelay.value <= 0n\n ) {\n throw new Error(\"unilateral refund without receiver delay must greater than 0\");\n }\n if (\n unilateralRefundWithoutReceiverDelay.type === \"seconds\" &&\n unilateralRefundWithoutReceiverDelay.value % 512n !== 0n\n ) {\n throw new Error(\"seconds timelock must be multiple of 512\");\n }\n if (\n unilateralRefundWithoutReceiverDelay.type === \"seconds\" &&\n unilateralRefundWithoutReceiverDelay.value < 512n\n ) {\n throw new Error(\"seconds timelock must be greater or equal to 512\");\n }\n }\n}\n\nfunction preimageConditionScript(preimageHash: Bytes): Bytes {\n return Script.encode([\"HASH160\", preimageHash, \"EQUAL\"]);\n}\n","import { hex } from \"@scure/base\";\nimport { VHTLC } from \"../../script/vhtlc\";\nimport { RelativeTimelock } from \"../../script/tapscript\";\nimport { Contract, ContractHandler, PathContext, PathSelection } from \"../types\";\nimport { isCltvSatisfied, isCsvSpendable, resolveRole } from \"./helpers\";\nimport { sequenceToTimelock, timelockToSequence } from \"../../utils/timelock\";\n\n/**\n * Typed parameters for VHTLC contracts.\n */\nexport interface VHTLCContractParams {\n sender: Uint8Array;\n receiver: Uint8Array;\n server: Uint8Array;\n preimageHash: Uint8Array;\n refundLocktime: bigint;\n unilateralClaimDelay: RelativeTimelock;\n unilateralRefundDelay: RelativeTimelock;\n unilateralRefundWithoutReceiverDelay: RelativeTimelock;\n}\n\n/**\n * Handler for Virtual Hash Time Lock Contract (VHTLC).\n *\n * VHTLC supports multiple spending paths:\n *\n * Collaborative paths (with server):\n * - claim: Receiver + Server with preimage\n * - refund: Sender + Receiver + Server\n * - refundWithoutReceiver: Sender + Server after CLTV locktime\n *\n * Unilateral paths (without server):\n * - unilateralClaim: Receiver with preimage after CSV delay\n * - unilateralRefund: Sender + Receiver after CSV delay\n * - unilateralRefundWithoutReceiver: Sender after CSV delay\n */\nexport const VHTLCContractHandler: ContractHandler<VHTLCContractParams, VHTLC.Script> = {\n type: \"vhtlc\",\n\n createScript(params: Record<string, string>): VHTLC.Script {\n const typed = this.deserializeParams(params);\n return new VHTLC.Script(typed);\n },\n\n serializeParams(params: VHTLCContractParams): Record<string, string> {\n return {\n sender: hex.encode(params.sender),\n receiver: hex.encode(params.receiver),\n server: hex.encode(params.server),\n hash: hex.encode(params.preimageHash),\n refundLocktime: params.refundLocktime.toString(),\n claimDelay: timelockToSequence(params.unilateralClaimDelay).toString(),\n refundDelay: timelockToSequence(params.unilateralRefundDelay).toString(),\n refundNoReceiverDelay: timelockToSequence(\n params.unilateralRefundWithoutReceiverDelay,\n ).toString(),\n };\n },\n\n deserializeParams(params: Record<string, string>): VHTLCContractParams {\n return {\n sender: hex.decode(params.sender),\n receiver: hex.decode(params.receiver),\n server: hex.decode(params.server),\n preimageHash: hex.decode(params.hash),\n refundLocktime: BigInt(params.refundLocktime),\n unilateralClaimDelay: sequenceToTimelock(Number(params.claimDelay)),\n unilateralRefundDelay: sequenceToTimelock(Number(params.refundDelay)),\n unilateralRefundWithoutReceiverDelay: sequenceToTimelock(\n Number(params.refundNoReceiverDelay),\n ),\n };\n },\n\n /**\n * Select spending path based on context.\n *\n * Role is determined from `context.role` or by matching\n * `context.walletDescriptor` (preferred) / `context.walletPubKey`\n * against sender/receiver in contract params.\n */\n selectPath(\n script: VHTLC.Script,\n contract: Contract,\n context: PathContext,\n ): PathSelection | null {\n const role = resolveRole(contract, context);\n const preimage = contract.params?.preimage;\n const refundLocktime = BigInt(contract.params.refundLocktime);\n\n if (!role) {\n return null;\n }\n\n if (context.collaborative) {\n if (role === \"receiver\" && preimage) {\n return {\n leaf: script.claim(),\n extraWitness: [hex.decode(preimage)],\n };\n }\n\n if (role === \"sender\" && isCltvSatisfied(context, refundLocktime)) {\n return {\n leaf: script.refundWithoutReceiver(),\n };\n }\n\n return null;\n }\n\n // Unilateral paths\n if (role === \"receiver\" && preimage) {\n const sequence = Number(contract.params.claimDelay);\n if (!isCsvSpendable(context, sequence)) return null;\n return {\n leaf: script.unilateralClaim(),\n extraWitness: [hex.decode(preimage)],\n sequence,\n };\n }\n\n if (role === \"sender\") {\n const sequence = Number(contract.params.refundNoReceiverDelay);\n if (!isCsvSpendable(context, sequence)) return null;\n return {\n leaf: script.unilateralRefundWithoutReceiver(),\n sequence,\n };\n }\n\n return null;\n },\n\n /**\n * Get all possible spending paths (no timelock checks).\n *\n * Role is determined from `context.role` or by matching\n * `context.walletDescriptor` (preferred) / `context.walletPubKey`\n * against sender/receiver in contract params.\n */\n getAllSpendingPaths(\n script: VHTLC.Script,\n contract: Contract,\n context: PathContext,\n ): PathSelection[] {\n const role = resolveRole(contract, context);\n const paths: PathSelection[] = [];\n\n if (!role) {\n return paths;\n }\n\n const preimage = contract.params?.preimage;\n\n if (context.collaborative) {\n // Collaborative paths (no timelock checks)\n if (role === \"receiver\" && preimage) {\n paths.push({\n leaf: script.claim(),\n extraWitness: [hex.decode(preimage)],\n });\n }\n if (role === \"sender\") {\n paths.push({\n leaf: script.refundWithoutReceiver(),\n });\n }\n } else {\n // Unilateral paths (no timelock checks)\n if (role === \"receiver\" && preimage) {\n const sequence = Number(contract.params.claimDelay);\n paths.push({\n leaf: script.unilateralClaim(),\n extraWitness: [hex.decode(preimage)],\n sequence,\n });\n }\n if (role === \"sender\") {\n const sequence = Number(contract.params.refundNoReceiverDelay);\n paths.push({\n leaf: script.unilateralRefundWithoutReceiver(),\n sequence,\n });\n }\n }\n\n return paths;\n },\n\n getSpendablePaths(\n script: VHTLC.Script,\n contract: Contract,\n context: PathContext,\n ): PathSelection[] {\n const role = resolveRole(contract, context);\n const paths: PathSelection[] = [];\n\n if (!role) {\n return paths;\n }\n\n const preimage = contract.params?.preimage;\n const refundLocktime = BigInt(contract.params.refundLocktime);\n\n if (context.collaborative) {\n if (role === \"receiver\" && preimage) {\n paths.push({\n leaf: script.claim(),\n extraWitness: [hex.decode(preimage)],\n });\n }\n if (role === \"sender\" && isCltvSatisfied(context, refundLocktime)) {\n paths.push({\n leaf: script.refundWithoutReceiver(),\n });\n }\n return paths;\n }\n\n if (role === \"receiver\" && preimage) {\n const sequence = Number(contract.params.claimDelay);\n if (isCsvSpendable(context, sequence)) {\n paths.push({\n leaf: script.unilateralClaim(),\n extraWitness: [hex.decode(preimage)],\n sequence,\n });\n }\n }\n if (role === \"sender\") {\n const sequence = Number(contract.params.refundNoReceiverDelay);\n if (isCsvSpendable(context, sequence)) {\n paths.push({\n leaf: script.unilateralRefundWithoutReceiver(),\n sequence,\n });\n }\n }\n\n return paths;\n },\n};\n","export { contractHandlers } from \"./registry\";\nexport { DefaultContractHandler } from \"./default\";\nexport type { DefaultContractParams } from \"./default\";\nexport { DelegateContractHandler } from \"./delegate\";\nexport type { DelegateContractParams } from \"./delegate\";\nexport { VHTLCContractHandler } from \"./vhtlc\";\nexport type { VHTLCContractParams } from \"./vhtlc\";\n\n// Register built-in handlers\nimport { contractHandlers } from \"./registry\";\nimport { DefaultContractHandler } from \"./default\";\nimport { DelegateContractHandler } from \"./delegate\";\nimport { VHTLCContractHandler } from \"./vhtlc\";\n\ncontractHandlers.register(DefaultContractHandler);\ncontractHandlers.register(DelegateContractHandler);\ncontractHandlers.register(VHTLCContractHandler);\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/contracts/handlers/registry.ts","../src/script/default.ts","../src/identity/descriptor.ts","../src/contracts/handlers/helpers.ts","../src/contracts/metadata.ts","../src/contracts/handlers/default.ts","../src/script/delegate.ts","../src/contracts/handlers/delegate.ts","../src/script/vhtlc.ts","../src/contracts/handlers/vhtlc.ts","../src/contracts/handlers/index.ts"],"names":["DefaultVtxo","Script","hex","DelegateVtxo","VHTLC"],"mappings":";;;;;;AAkBA,IAAM,0BAAN,MAA8B;AAAA,EAClB,QAAA,uBAAe,GAAA,EAAsC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7D,SAAS,OAAA,EAAyC;AAC9C,IAAA,IAAI,IAAA,CAAK,QAAA,CAAS,GAAA,CAAI,OAAA,CAAQ,IAAI,CAAA,EAAG;AACjC,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,2BAAA,EAA8B,OAAA,CAAQ,IAAI,CAAA,uBAAA,CAAyB,CAAA;AAAA,IAC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KAAA,CAAM,IAAA,CAAK;AAAA,UACP,IAAA,EAAM,OAAO,qBAAA;AAAsB,SACtC,CAAA;AAAA,MACL;AACA,MAAA,OAAO,KAAA;AAAA,IACX;AAEA,IAAA,IAAI,IAAA,KAAS,cAAc,QAAA,EAAU;AACjC,MAAA,MAAM,QAAA,GAAW,MAAA,CAAO,QAAA,CAAS,MAAA,CAAO,UAAU,CAAA;AAClD,MAAA,IAAI,cAAA,CAAe,OAAA,EAAS,QAAQ,CAAA,EAAG;AACnC,QAAA,KAAA,CAAM,IAAA,CAAK;AAAA,UACP,IAAA,EAAM,OAAO,eAAA,EAAgB;AAAA,UAC7B,YAAA,EAAc,CAACA,GAAAA,CAAI,MAAA,CAAO,QAAQ,CAAC,CAAA;AAAA,UACnC;AAAA,SACH,CAAA;AAAA,MACL;AAAA,IACJ;AACA,IAAA,IAAI,SAAS,QAAA,EAAU;AACnB,MAAA,MAAM,QAAA,GAAW,MAAA,CAAO,QAAA,CAAS,MAAA,CAAO,qBAAqB,CAAA;AAC7D,MAAA,IAAI,cAAA,CAAe,OAAA,EAAS,QAAQ,CAAA,EAAG;AACnC,QAAA,KAAA,CAAM,IAAA,CAAK;AAAA,UACP,IAAA,EAAM,OAAO,+BAAA,EAAgC;AAAA,UAC7C;AAAA,SACH,CAAA;AAAA,MACL;AAAA,IACJ;AAEA,IAAA,OAAO,KAAA;AAAA,EACX;AACJ;;;ACpOA,gBAAA,CAAiB,SAAS,sBAAsB,CAAA;AAChD,gBAAA,CAAiB,SAAS,uBAAuB,CAAA;AACjD,gBAAA,CAAiB,SAAS,oBAAoB,CAAA","file":"chunk-YA4G7RFB.js","sourcesContent":["import { ContractHandler } from \"../types\";\n\n/**\n * Registry for contract handlers.\n *\n * Each contract type (\"default\", \"vhtlc\", etc.) has a handler that knows\n * how to create VtxoScripts, serialize params, and select spending paths.\n *\n * @example\n * ```typescript\n * // Register a custom handler\n * contractHandlers.register(myCustomHandler);\n *\n * // Get handler for a type\n * const handler = contractHandlers.get(\"vhtlc\");\n * const script = handler.createScript(contract.params);\n * ```\n */\nclass ContractHandlerRegistry {\n private handlers = new Map<string, ContractHandler<unknown>>();\n\n /**\n * Register a contract handler.\n *\n * @param handler - The handler to register\n * @throws If a handler for this type is already registered\n */\n register(handler: ContractHandler<unknown>): void {\n if (this.handlers.has(handler.type)) {\n throw new Error(`Contract handler for type '${handler.type}' is already registered`);\n }\n this.handlers.set(handler.type, handler);\n }\n\n /**\n * Get a handler by type.\n *\n * @param type - The contract type\n * @returns The handler, or undefined if not found\n */\n get(type: string): ContractHandler<unknown> | undefined {\n return this.handlers.get(type);\n }\n\n /**\n * Get a handler by type, throwing if not found.\n *\n * @param type - The contract type\n * @returns The handler\n * @throws If no handler is registered for this type\n */\n getOrThrow(type: string): ContractHandler<unknown> {\n const handler = this.get(type);\n if (!handler) {\n throw new Error(`No contract handler registered for type '${type}'`);\n }\n return handler;\n }\n\n /**\n * Check if a handler is registered.\n *\n * @param type - The contract type\n */\n has(type: string): boolean {\n return this.handlers.has(type);\n }\n\n /**\n * Get all registered types.\n */\n getRegisteredTypes(): string[] {\n return Array.from(this.handlers.keys());\n }\n\n /**\n * Unregister a handler (mainly for testing).\n */\n unregister(type: string): boolean {\n return this.handlers.delete(type);\n }\n\n /**\n * Clear all handlers (mainly for testing).\n */\n clear(): void {\n this.handlers.clear();\n }\n}\n\n/**\n * Global registry of contract handlers.\n */\nexport const contractHandlers = new ContractHandlerRegistry();\n","import { Bytes } from \"@scure/btc-signer/utils.js\";\nimport { TapLeafScript, VtxoScript } from \"./base\";\nimport { CSVMultisigTapscript, MultisigTapscript, RelativeTimelock } from \"./tapscript\";\nimport { hex } from \"@scure/base\";\n\n/**\n * DefaultVtxo is the default implementation of a VtxoScript.\n * It contains 1 forfeit path and 1 exit path.\n * - forfeit = (Alice + Server)\n * - exit = (Alice) after csvTimelock\n */\nexport namespace DefaultVtxo {\n /**\n * Options is the options for the DefaultVtxo.Script class.\n * csvTimelock is the exit path timelock, default is 144 blocks (1 day).\n */\n export interface Options {\n pubKey: Bytes;\n serverPubKey: Bytes;\n csvTimelock?: RelativeTimelock;\n }\n\n /**\n * DefaultVtxo.Script is the class letting to create the vtxo script.\n * @example\n * ```typescript\n * const vtxoScript = new DefaultVtxo.Script({\n * pubKey: new Uint8Array(32),\n * serverPubKey: new Uint8Array(32),\n * });\n *\n * console.log(\"script pub key:\", vtxoScript.pkScript)\n * ```\n */\n export class Script extends VtxoScript {\n static readonly DEFAULT_TIMELOCK: RelativeTimelock = {\n value: 144n,\n type: \"blocks\",\n }; // 1 day in blocks\n\n readonly forfeitScript: string;\n readonly exitScript: string;\n\n /** Create the default virtual output script with one forfeit path and one exit path. */\n constructor(readonly options: Options) {\n const { pubKey, serverPubKey, csvTimelock = Script.DEFAULT_TIMELOCK } = options;\n\n const forfeitScript = MultisigTapscript.encode({\n pubkeys: [pubKey, serverPubKey],\n }).script;\n\n const exitScript = CSVMultisigTapscript.encode({\n timelock: csvTimelock,\n pubkeys: [pubKey],\n }).script;\n\n super([forfeitScript, exitScript]);\n\n this.forfeitScript = hex.encode(forfeitScript);\n this.exitScript = hex.encode(exitScript);\n }\n\n /** Return the forfeit tapleaf script. */\n forfeit(): TapLeafScript {\n return this.findLeaf(this.forfeitScript);\n }\n\n /** Return the unilateral exit tapleaf script. */\n exit(): TapLeafScript {\n return this.findLeaf(this.exitScript);\n }\n }\n}\n","import { expand, networks } from \"@bitcoinerlab/descriptors-scure\";\nimport { hex } from \"@scure/base\";\n\n/**\n * True iff `descriptor` is a Bitcoin mainnet descriptor (xpub-prefixed\n * BIP32 key).\n *\n * Note: testnet, signet, regtest, mutinynet, and other non-mainnet\n * networks all share the same `tpub` BIP32 version bytes — they cannot\n * be distinguished from one another at the descriptor level. Callers\n * that need a `Network` constants object for `expand()` pick\n * `networks.bitcoin` vs `networks.testnet` themselves; callers that\n * need the *actual* network the wallet is on must track that\n * out-of-band.\n */\nexport function isMainnetDescriptor(descriptor: string): boolean {\n return !descriptor.includes(\"tpub\");\n}\n\n/**\n * Shared \"does `candidate` belong to the identity backed by\n * `ourDescriptor`?\" predicate.\n *\n * - HD descriptors (expanding to a `bip32` key) match by account xpub\n * on both sides — index-agnostic, so a wildcard template and any\n * concrete index under it all collapse to the same xpub.\n * - Bare `tr(pubkey)` candidates fall back to comparing the candidate\n * pubkey against `ourXOnlyPubkey` (the cached pubkey on the identity\n * side, since pulling it from `ourDescriptor` would require an index\n * substitution the caller already performed).\n */\nexport function descriptorIsOurs(\n candidate: string,\n ourDescriptor: string,\n ourXOnlyPubkey: Uint8Array,\n): boolean {\n if (!isDescriptor(candidate)) return false;\n try {\n const candidateInfo = expand({\n descriptor: candidate,\n network: isMainnetDescriptor(candidate) ? networks.bitcoin : networks.testnet,\n }).expansionMap?.[\"@0\"];\n if (!candidateInfo) return false;\n\n if (candidateInfo.bip32) {\n const ourBip32 = expand({\n descriptor: ourDescriptor,\n network: isMainnetDescriptor(ourDescriptor) ? networks.bitcoin : networks.testnet,\n }).expansionMap?.[\"@0\"]?.bip32;\n if (!ourBip32) return false;\n return ourBip32.toBase58() === candidateInfo.bip32.toBase58();\n }\n if (candidateInfo.pubkey) {\n // For tr() the library hands back a 32-byte x-only key, but\n // strip a leading parity byte defensively so a 33-byte\n // compressed key (mismatched length) doesn't silently\n // false-negative against our 32-byte x-only side.\n const candidatePub =\n candidateInfo.pubkey.length === 33\n ? candidateInfo.pubkey.subarray(1)\n : candidateInfo.pubkey;\n if (candidatePub.length !== ourXOnlyPubkey.length) return false;\n return hex.encode(candidatePub) === hex.encode(ourXOnlyPubkey);\n }\n return false;\n } catch {\n return false;\n }\n}\n\n/**\n * Check if a string is a descriptor of the shape `tr(...)`.\n *\n * This is a shape check only — it does not validate the inner key material.\n * Use {@link expand} (via {@link extractPubKey} / {@link parseHDDescriptor})\n * for full parsing. The guard rejects empty bodies and missing/trailing\n * parentheses so callers can safely branch on descriptor vs. raw pubkey.\n */\nexport function isDescriptor(value: string): boolean {\n if (typeof value !== \"string\") return false;\n if (!value.startsWith(\"tr(\") || !value.endsWith(\")\")) return false;\n // body length > 0 after stripping \"tr(\" and \")\"\n return value.length > \"tr()\".length;\n}\n\n/**\n * Normalize a value to descriptor format.\n * If already a descriptor, return as-is. If hex pubkey, wrap as tr(pubkey).\n * Throws when the value is empty or not a string so we never produce\n * malformed descriptors like `tr()` that downstream parsers would reject.\n */\nexport function normalizeToDescriptor(value: string): string {\n if (typeof value !== \"string\" || value.length === 0) {\n throw new Error(\"normalizeToDescriptor: expected a non-empty string value\");\n }\n if (isDescriptor(value)) {\n return value;\n }\n return `tr(${value})`;\n}\n\n/**\n * Extract the public key from a simple descriptor.\n * For simple descriptors (tr(pubkey)), extracts the pubkey using the library.\n * For HD descriptors, throws — use DescriptorProvider to derive the key.\n */\nexport function extractPubKey(descriptor: string): string {\n if (!isDescriptor(descriptor)) {\n return descriptor;\n }\n\n const network = isMainnetDescriptor(descriptor) ? networks.bitcoin : networks.testnet;\n const expansion = expand({ descriptor, network });\n\n if (!expansion.expansionMap) {\n throw new Error(\"Cannot extract pubkey from descriptor: expansion failed.\");\n }\n\n const key = expansion.expansionMap[\"@0\"];\n\n // HD descriptors (have a bip32 key) require DescriptorProvider for derivation\n if (key?.bip32) {\n throw new Error(\n \"Cannot extract pubkey from HD descriptor without derivation. \" +\n \"Use DescriptorProvider to derive the key from the xpub.\",\n );\n }\n\n if (!key?.pubkey) {\n throw new Error(\"Cannot extract pubkey from descriptor: no key found.\");\n }\n\n return hex.encode(key.pubkey);\n}\n\n/**\n * Extract the x-only (32-byte) pubkey from a materialized descriptor.\n * Handles both static `tr(pubkey)` and materialized HD\n * `tr([fp/..]xpub/0/<i>)` shapes via the descriptors-scure expansion map.\n * Throws a plain Error when the descriptor is non-rangeable / unparseable;\n * callers that need a typed error wrap this.\n */\nexport function deriveDescriptorLeafPubKey(descriptor: string): Uint8Array {\n const network = isMainnetDescriptor(descriptor) ? networks.bitcoin : networks.testnet;\n let expansion;\n try {\n expansion = expand({ descriptor, network });\n } catch (e) {\n throw new Error(\n `Cannot derive leaf pubkey from descriptor (length=${descriptor.length}): ` +\n `ensure it is materialized (no wildcard) and parsable.`,\n { cause: e },\n );\n }\n const key = expansion.expansionMap?.[\"@0\"];\n if (!key?.pubkey) {\n throw new Error(\n `Cannot derive leaf pubkey from descriptor (length=${descriptor.length}): ` +\n `parsed but no '@0' pubkey in the expansion map.`,\n );\n }\n return key.pubkey;\n}\n\n/** Parsed HD descriptor components. */\nexport interface ParsedHDDescriptor {\n fingerprint: string;\n basePath: string;\n xpub: string;\n derivationPath: string;\n}\n\n/**\n * Parse an HD descriptor into its components.\n * HD descriptors have the format: tr([fingerprint/path']xpub/derivation)\n * Returns null if the descriptor is not in HD format.\n */\nexport function parseHDDescriptor(descriptor: string): ParsedHDDescriptor | null {\n if (!isDescriptor(descriptor)) {\n return null;\n }\n\n let expansion;\n try {\n const network = isMainnetDescriptor(descriptor) ? networks.bitcoin : networks.testnet;\n expansion = expand({ descriptor, network });\n } catch {\n return null;\n }\n\n const key = expansion.expansionMap?.[\"@0\"];\n if (!key?.masterFingerprint || !key.originPath || !key.keyPath || !key.bip32) {\n return null;\n }\n\n return {\n fingerprint: hex.encode(key.masterFingerprint),\n basePath: key.originPath.replace(/^\\//, \"\"),\n xpub: key.bip32.toBase58(),\n derivationPath: key.keyPath.replace(/^\\//, \"\"),\n };\n}\n","import { sequenceToTimelock } from \"../../utils/timelock\";\nimport { Contract, PathContext } from \"../types\";\nimport { isDescriptor, extractPubKey } from \"../../identity/descriptor\";\n\n/**\n * Extract raw hex pubkey from a value that may be a descriptor or raw hex.\n * Returns undefined for HD descriptors or unparseable values so role\n * resolution stays best-effort and never throws.\n */\nfunction extractRawPubKey(value: string): string | undefined {\n if (!isDescriptor(value)) {\n return value.toLowerCase();\n }\n try {\n return extractPubKey(value).toLowerCase();\n } catch {\n return undefined;\n }\n}\n\n/**\n * Resolve wallet's role from explicit role or by matching descriptor/pubkey.\n */\nexport function resolveRole(\n contract: Contract,\n context: PathContext,\n): \"sender\" | \"receiver\" | undefined {\n // Explicit role takes precedence\n if (context.role === \"sender\" || context.role === \"receiver\") {\n return context.role;\n }\n\n const senderKey = contract.params.sender ? extractRawPubKey(contract.params.sender) : undefined;\n const receiverKey = contract.params.receiver\n ? extractRawPubKey(contract.params.receiver)\n : undefined;\n\n const matchRole = (rawWalletKey: string | undefined): \"sender\" | \"receiver\" | undefined => {\n if (!rawWalletKey) return undefined;\n if (senderKey && rawWalletKey === senderKey) {\n return \"sender\";\n }\n if (receiverKey && rawWalletKey === receiverKey) {\n return \"receiver\";\n }\n return undefined;\n };\n\n // Try the preferred descriptor first. If it cannot be resolved\n // (for example an HD descriptor without derivation support), fall back\n // to walletPubKey for backward compatibility.\n if (context.walletDescriptor) {\n const walletDescriptorKey = extractRawPubKey(context.walletDescriptor);\n const matchedRole = matchRole(walletDescriptorKey);\n if (matchedRole) {\n return matchedRole;\n }\n\n if (!walletDescriptorKey && context.walletPubKey) {\n return matchRole(extractRawPubKey(context.walletPubKey));\n }\n return undefined;\n }\n\n if (context.walletPubKey) {\n return matchRole(extractRawPubKey(context.walletPubKey));\n }\n\n return undefined;\n}\n\n/**\n * BIP65 threshold: locktime values below this are interpreted as block heights,\n * values at or above are interpreted as Unix timestamps (seconds).\n */\nconst CLTV_HEIGHT_THRESHOLD = 500_000_000n;\n\n/**\n * Check if an absolute (CLTV) locktime is currently satisfied.\n *\n * Following the BIP65 convention:\n * - locktime < 500_000_000 → interpreted as a block height; compared against `context.blockHeight`\n * - locktime >= 500_000_000 → interpreted as a Unix timestamp (seconds); compared against `context.currentTime`\n *\n * Returns false if the relevant context field is missing.\n */\nexport function isCltvSatisfied(context: PathContext, locktime: bigint): boolean {\n if (locktime < CLTV_HEIGHT_THRESHOLD) {\n if (context.blockHeight === undefined) return false;\n return BigInt(context.blockHeight) >= locktime;\n }\n const currentTimeSec = BigInt(Math.floor(context.currentTime / 1000));\n return currentTimeSec >= locktime;\n}\n\n/**\n * Check if a CSV timelock is currently satisfied for the given context/virtual output.\n */\nexport function isCsvSpendable(context: PathContext, sequence?: number): boolean {\n if (sequence === undefined) return true;\n if (!context.vtxo) return false;\n const timelock = sequenceToTimelock(sequence);\n\n if (timelock.type === \"blocks\") {\n if (context.blockHeight === undefined || context.vtxo.status.block_height === undefined) {\n return false;\n }\n return context.blockHeight - context.vtxo.status.block_height >= Number(timelock.value);\n }\n\n if (timelock.type === \"seconds\") {\n const blockTime = context.vtxo.status.block_time;\n if (blockTime === undefined) return false;\n return context.currentTime / 1000 - blockTime >= Number(timelock.value);\n }\n\n return false;\n}\n","/**\n * Sentinel stored in `contract.metadata.source` to mark a contract the\n * wallet generated for its own rotating receive address. Lives here (the\n * contracts layer) so contract handlers can tag/discover without importing\n * the wallet module. Re-exported from `wallet/walletReceiveRotator` for\n * backward compatibility of existing import paths.\n *\n * Tagging makes the boot lookup unambiguous — the rotator filters on\n * `metadata.source === WALLET_RECEIVE_SOURCE` rather than on \"any active\n * default contract\", so a contract repo that also holds default contracts\n * created for other reasons (legacy timelock variants, external\n * integrations) doesn't confuse the wallet's display state.\n */\nexport const WALLET_RECEIVE_SOURCE = \"wallet-receive\";\n","import { hex } from \"@scure/base\";\nimport { DefaultVtxo } from \"../../script/default\";\nimport { RelativeTimelock } from \"../../script/tapscript\";\nimport { Contract, ContractHandler, Discoverable, PathContext, PathSelection } from \"../types\";\nimport type { DiscoveredContract, DiscoveryDeps } from \"../types\";\nimport { isCsvSpendable } from \"./helpers\";\nimport { sequenceToTimelock, timelockToSequence } from \"../../utils/timelock\";\nimport {\n normalizeToDescriptor,\n extractPubKey,\n deriveDescriptorLeafPubKey,\n} from \"../../identity/descriptor\";\nimport { WALLET_RECEIVE_SOURCE } from \"../metadata\";\n\n/**\n * Typed parameters for DefaultVtxo contracts.\n */\nexport interface DefaultContractParams {\n pubKey: Uint8Array;\n serverPubKey: Uint8Array;\n csvTimelock: RelativeTimelock;\n}\n\n/**\n * Extract pubkey bytes from a descriptor or hex string.\n */\nfunction extractPubKeyBytes(value: string): Uint8Array {\n return hex.decode(extractPubKey(normalizeToDescriptor(value)));\n}\n\n/**\n * Handler for default wallet VTXOs.\n *\n * Default contracts use the standard forfeit + exit tapscript:\n * - forfeit: (Alice + Server) multisig for collaborative spending\n * - exit: (Alice) + CSV timelock for unilateral exit\n */\nexport const DefaultContractHandler: ContractHandler<DefaultContractParams, DefaultVtxo.Script> &\n Discoverable = {\n type: \"default\",\n\n createScript(params: Record<string, string>): DefaultVtxo.Script {\n const typed = this.deserializeParams(params);\n return new DefaultVtxo.Script(typed);\n },\n\n serializeParams(params: DefaultContractParams): Record<string, string> {\n return {\n pubKey: hex.encode(params.pubKey),\n serverPubKey: hex.encode(params.serverPubKey),\n csvTimelock: timelockToSequence(params.csvTimelock).toString(),\n };\n },\n\n deserializeParams(params: Record<string, string>): DefaultContractParams {\n const csvTimelock = params.csvTimelock\n ? sequenceToTimelock(Number(params.csvTimelock))\n : DefaultVtxo.Script.DEFAULT_TIMELOCK;\n return {\n pubKey: extractPubKeyBytes(params.pubKey),\n serverPubKey: extractPubKeyBytes(params.serverPubKey),\n csvTimelock,\n };\n },\n\n selectPath(\n script: DefaultVtxo.Script,\n contract: Contract,\n context: PathContext,\n ): PathSelection | null {\n if (context.collaborative) {\n // Use forfeit path for collaborative spending\n return { leaf: script.forfeit() };\n }\n\n // Use exit path for unilateral exit (only if CSV is satisfied)\n const sequence = contract.params.csvTimelock\n ? Number(contract.params.csvTimelock)\n : undefined;\n if (!isCsvSpendable(context, sequence)) {\n return null;\n }\n return {\n leaf: script.exit(),\n sequence,\n };\n },\n\n getAllSpendingPaths(\n script: DefaultVtxo.Script,\n contract: Contract,\n context: PathContext,\n ): PathSelection[] {\n const paths: PathSelection[] = [];\n\n // Forfeit path available with server cooperation\n if (context.collaborative) {\n paths.push({ leaf: script.forfeit() });\n }\n\n // Exit path always possible (CSV checked at tx time)\n const exitPath: PathSelection = { leaf: script.exit() };\n if (contract.params.csvTimelock) {\n exitPath.sequence = Number(contract.params.csvTimelock);\n }\n paths.push(exitPath);\n\n return paths;\n },\n\n getSpendablePaths(\n script: DefaultVtxo.Script,\n contract: Contract,\n context: PathContext,\n ): PathSelection[] {\n const paths: PathSelection[] = [];\n\n if (context.collaborative) {\n paths.push({ leaf: script.forfeit() });\n }\n\n const exitSequence = contract.params.csvTimelock\n ? Number(contract.params.csvTimelock)\n : undefined;\n\n if (isCsvSpendable(context, exitSequence)) {\n const exitPath: PathSelection = { leaf: script.exit() };\n if (exitSequence !== undefined) {\n exitPath.sequence = exitSequence;\n }\n paths.push(exitPath);\n }\n\n return paths;\n },\n\n async discoverAt(\n index: number,\n descriptor: string,\n deps: DiscoveryDeps,\n ): Promise<DiscoveredContract[]> {\n const pubKey = deriveDescriptorLeafPubKey(descriptor);\n const out: DiscoveredContract[] = [];\n for (const csvTimelock of deps.csvTimelocks) {\n const script = new DefaultVtxo.Script({\n pubKey,\n serverPubKey: deps.serverPubKey,\n csvTimelock,\n });\n const scriptHex = hex.encode(script.pkScript);\n const { vtxos } = await deps.indexerProvider.getVtxos({\n scripts: [scriptHex],\n });\n if (vtxos.length === 0) continue;\n out.push({\n type: \"default\",\n params: {\n pubKey: hex.encode(pubKey),\n serverPubKey: hex.encode(deps.serverPubKey),\n csvTimelock: timelockToSequence(csvTimelock).toString(),\n },\n script: scriptHex,\n address: script.address(deps.network.hrp, deps.serverPubKey).encode(),\n ...(index > 0\n ? {\n metadata: {\n source: WALLET_RECEIVE_SOURCE,\n signingDescriptor: descriptor,\n },\n }\n : {}),\n });\n }\n return out;\n },\n};\n","import { Bytes } from \"@scure/btc-signer/utils.js\";\nimport { DefaultVtxo } from \"./default\";\nimport { MultisigTapscript } from \"./tapscript\";\nimport { TapLeafScript, VtxoScript } from \"./base\";\nimport { hex } from \"@scure/base\";\n\n/**\n * DelegateVtxo extends DefaultVtxo with an extra delegate path\n */\nexport namespace DelegateVtxo {\n /**\n * Options extends DefaultVtxo.Options and adds a delegatePubKey\n */\n export interface Options extends DefaultVtxo.Options {\n delegatePubKey: Bytes;\n }\n\n /**\n * DelegateVtxo.Script extends DefaultVtxo.Script and adds a delegate path.\n * @example\n * ```typescript\n * const vtxoScript = new DelegateVtxo.Script({\n * pubKey: new Uint8Array(32),\n * serverPubKey: new Uint8Array(32),\n * delegatePubKey: new Uint8Array(32),\n * });\n *\n * console.log(\"script pub key:\", vtxoScript.pkScript)\n * ```\n */\n export class Script extends VtxoScript {\n readonly defaultVtxo: DefaultVtxo.Script;\n readonly delegateScript: string;\n\n /** Create a delegated virtual output script with forfeit, exit, and delegate paths. */\n constructor(readonly options: Options) {\n const defaultVtxo = new DefaultVtxo.Script(options);\n const { delegatePubKey, pubKey, serverPubKey } = options;\n const delegateScript = MultisigTapscript.encode({\n pubkeys: [pubKey, delegatePubKey, serverPubKey],\n }).script;\n\n super([...defaultVtxo.scripts, delegateScript]);\n\n this.defaultVtxo = defaultVtxo;\n this.delegateScript = hex.encode(delegateScript);\n }\n\n /** Return the forfeit tapleaf script. */\n forfeit(): TapLeafScript {\n return this.findLeaf(this.defaultVtxo.forfeitScript);\n }\n\n /** Return the unilateral exit tapleaf script. */\n exit(): TapLeafScript {\n return this.findLeaf(this.defaultVtxo.exitScript);\n }\n\n /** Return the delegate tapleaf script. */\n delegate(): TapLeafScript {\n return this.findLeaf(this.delegateScript);\n }\n }\n}\n","import { hex } from \"@scure/base\";\nimport { DelegateVtxo } from \"../../script/delegate\";\nimport { DefaultVtxo } from \"../../script/default\";\nimport { RelativeTimelock } from \"../../script/tapscript\";\nimport { Contract, ContractHandler, Discoverable, PathContext, PathSelection } from \"../types\";\nimport type { DiscoveredContract, DiscoveryDeps } from \"../types\";\nimport { isCsvSpendable } from \"./helpers\";\nimport { sequenceToTimelock, timelockToSequence } from \"../../utils/timelock\";\nimport { deriveDescriptorLeafPubKey } from \"../../identity/descriptor\";\nimport { WALLET_RECEIVE_SOURCE } from \"../metadata\";\n\n/**\n * Typed parameters for DelegateVtxo contracts.\n */\nexport interface DelegateContractParams {\n pubKey: Uint8Array;\n serverPubKey: Uint8Array;\n delegatePubKey: Uint8Array;\n csvTimelock: RelativeTimelock;\n}\n\n/**\n * Handler for delegate wallet virtual outputs.\n *\n * Delegate contracts extend the default tapscript with an additional delegate path:\n * - forfeit: (Alice + Server) multisig for collaborative spending\n * - exit: (Alice) + CSV timelock for unilateral exit\n * - delegate: (Alice + Delegate + Server) multisig for delegated renewal\n */\nexport const DelegateContractHandler: ContractHandler<DelegateContractParams, DelegateVtxo.Script> &\n Discoverable = {\n type: \"delegate\",\n\n createScript(params: Record<string, string>): DelegateVtxo.Script {\n const typed = this.deserializeParams(params);\n return new DelegateVtxo.Script(typed);\n },\n\n serializeParams(params: DelegateContractParams): Record<string, string> {\n return {\n pubKey: hex.encode(params.pubKey),\n serverPubKey: hex.encode(params.serverPubKey),\n delegatePubKey: hex.encode(params.delegatePubKey),\n csvTimelock: timelockToSequence(params.csvTimelock).toString(),\n };\n },\n\n deserializeParams(params: Record<string, string>): DelegateContractParams {\n const csvTimelock = params.csvTimelock\n ? sequenceToTimelock(Number(params.csvTimelock))\n : DefaultVtxo.Script.DEFAULT_TIMELOCK;\n return {\n pubKey: hex.decode(params.pubKey),\n serverPubKey: hex.decode(params.serverPubKey),\n delegatePubKey: hex.decode(params.delegatePubKey),\n csvTimelock,\n };\n },\n\n selectPath(\n script: DelegateVtxo.Script,\n contract: Contract,\n context: PathContext,\n ): PathSelection | null {\n if (context.collaborative) {\n return { leaf: script.forfeit() };\n }\n\n const sequence = contract.params.csvTimelock\n ? Number(contract.params.csvTimelock)\n : undefined;\n if (!isCsvSpendable(context, sequence)) {\n return null;\n }\n return {\n leaf: script.exit(),\n sequence,\n };\n },\n\n getAllSpendingPaths(\n script: DelegateVtxo.Script,\n contract: Contract,\n context: PathContext,\n ): PathSelection[] {\n const paths: PathSelection[] = [];\n\n if (context.collaborative) {\n paths.push({ leaf: script.forfeit() });\n }\n\n const exitPath: PathSelection = { leaf: script.exit() };\n if (contract.params.csvTimelock) {\n exitPath.sequence = Number(contract.params.csvTimelock);\n }\n paths.push(exitPath);\n\n // Delegate path (Alice + Delegate + Server) — collaborative only\n if (context.collaborative) {\n paths.push({ leaf: script.delegate() });\n }\n\n return paths;\n },\n\n getSpendablePaths(\n script: DelegateVtxo.Script,\n contract: Contract,\n context: PathContext,\n ): PathSelection[] {\n const paths: PathSelection[] = [];\n\n if (context.collaborative) {\n paths.push({ leaf: script.forfeit() });\n }\n\n const exitSequence = contract.params.csvTimelock\n ? Number(contract.params.csvTimelock)\n : undefined;\n\n if (isCsvSpendable(context, exitSequence)) {\n const exitPath: PathSelection = { leaf: script.exit() };\n if (exitSequence !== undefined) {\n exitPath.sequence = exitSequence;\n }\n paths.push(exitPath);\n }\n\n return paths;\n },\n\n async discoverAt(\n index: number,\n descriptor: string,\n deps: DiscoveryDeps,\n ): Promise<DiscoveredContract[]> {\n if (!deps.delegatePubKey) return [];\n const pubKey = deriveDescriptorLeafPubKey(descriptor);\n const out: DiscoveredContract[] = [];\n for (const csvTimelock of deps.csvTimelocks) {\n const script = new DelegateVtxo.Script({\n pubKey,\n serverPubKey: deps.serverPubKey,\n delegatePubKey: deps.delegatePubKey,\n csvTimelock,\n });\n const scriptHex = hex.encode(script.pkScript);\n const { vtxos } = await deps.indexerProvider.getVtxos({\n scripts: [scriptHex],\n });\n if (vtxos.length === 0) continue;\n out.push({\n type: \"delegate\",\n params: {\n pubKey: hex.encode(pubKey),\n serverPubKey: hex.encode(deps.serverPubKey),\n delegatePubKey: hex.encode(deps.delegatePubKey),\n csvTimelock: timelockToSequence(csvTimelock).toString(),\n },\n script: scriptHex,\n address: script.address(deps.network.hrp, deps.serverPubKey).encode(),\n ...(index > 0\n ? {\n metadata: {\n source: WALLET_RECEIVE_SOURCE,\n signingDescriptor: descriptor,\n },\n }\n : {}),\n });\n }\n return out;\n },\n};\n","import { Script } from \"@scure/btc-signer\";\nimport { Bytes } from \"@scure/btc-signer/utils.js\";\nimport {\n CLTVMultisigTapscript,\n ConditionCSVMultisigTapscript,\n ConditionMultisigTapscript,\n CSVMultisigTapscript,\n MultisigTapscript,\n RelativeTimelock,\n} from \"./tapscript\";\nimport { hex } from \"@scure/base\";\nimport { TapLeafScript, VtxoScript } from \"./base\";\n\n/** Virtual Hash Time Lock Contract (VHTLC) namespace. */\nexport namespace VHTLC {\n export interface Options {\n sender: Bytes;\n receiver: Bytes;\n server: Bytes;\n preimageHash: Bytes;\n refundLocktime: bigint;\n unilateralClaimDelay: RelativeTimelock;\n unilateralRefundDelay: RelativeTimelock;\n unilateralRefundWithoutReceiverDelay: RelativeTimelock;\n }\n\n /**\n * Virtual Hash Time Lock Contract (VHTLC) script implementation.\n *\n * VHTLC enables atomic swaps and conditional payments in the Arkade protocol.\n * It provides multiple spending paths:\n *\n * - **claim**: Receiver can claim funds by revealing the preimage\n * - **refund**: Sender and receiver can collaboratively refund\n * - **refundWithoutReceiver**: Sender can refund after locktime expires\n * - **unilateralClaim**: Receiver can claim unilaterally after delay\n * - **unilateralRefund**: Sender and receiver can refund unilaterally after delay\n * - **unilateralRefundWithoutReceiver**: Sender can refund unilaterally after delay\n *\n * @example\n * ```typescript\n * const vhtlc = new VHTLC.Script({\n * sender: alicePubKey,\n * receiver: bobPubKey,\n * server: serverPubKey,\n * preimageHash: hash160(secret),\n * refundLocktime: BigInt(chainTip + 10),\n * unilateralClaimDelay: { type: 'blocks', value: 100n },\n * unilateralRefundDelay: { type: 'blocks', value: 102n },\n * unilateralRefundWithoutReceiverDelay: { type: 'blocks', value: 103n }\n * });\n * ```\n */\n export class Script extends VtxoScript {\n readonly claimScript: string;\n readonly refundScript: string;\n readonly refundWithoutReceiverScript: string;\n readonly unilateralClaimScript: string;\n readonly unilateralRefundScript: string;\n readonly unilateralRefundWithoutReceiverScript: string;\n\n /** Create a VHTLC script from the supplied participant keys, hash, and timelocks. */\n constructor(readonly options: Options) {\n validateOptions(options);\n\n const {\n sender,\n receiver,\n server,\n preimageHash,\n refundLocktime,\n unilateralClaimDelay,\n unilateralRefundDelay,\n unilateralRefundWithoutReceiverDelay,\n } = options;\n\n const conditionScript = preimageConditionScript(preimageHash);\n\n const claimScript = ConditionMultisigTapscript.encode({\n conditionScript,\n pubkeys: [receiver, server],\n }).script;\n\n const refundScript = MultisigTapscript.encode({\n pubkeys: [sender, receiver, server],\n }).script;\n\n const refundWithoutReceiverScript = CLTVMultisigTapscript.encode({\n absoluteTimelock: refundLocktime,\n pubkeys: [sender, server],\n }).script;\n\n const unilateralClaimScript = ConditionCSVMultisigTapscript.encode({\n conditionScript,\n timelock: unilateralClaimDelay,\n pubkeys: [receiver],\n }).script;\n\n const unilateralRefundScript = CSVMultisigTapscript.encode({\n timelock: unilateralRefundDelay,\n pubkeys: [sender, receiver],\n }).script;\n\n const unilateralRefundWithoutReceiverScript = CSVMultisigTapscript.encode({\n timelock: unilateralRefundWithoutReceiverDelay,\n pubkeys: [sender],\n }).script;\n\n super([\n claimScript,\n refundScript,\n refundWithoutReceiverScript,\n unilateralClaimScript,\n unilateralRefundScript,\n unilateralRefundWithoutReceiverScript,\n ]);\n\n this.claimScript = hex.encode(claimScript);\n this.refundScript = hex.encode(refundScript);\n this.refundWithoutReceiverScript = hex.encode(refundWithoutReceiverScript);\n this.unilateralClaimScript = hex.encode(unilateralClaimScript);\n this.unilateralRefundScript = hex.encode(unilateralRefundScript);\n this.unilateralRefundWithoutReceiverScript = hex.encode(\n unilateralRefundWithoutReceiverScript,\n );\n }\n\n /** Return the collaborative claim tapleaf script. */\n claim(): TapLeafScript {\n return this.findLeaf(this.claimScript);\n }\n\n /** Return the collaborative refund tapleaf script. */\n refund(): TapLeafScript {\n return this.findLeaf(this.refundScript);\n }\n\n /** Return the refund-without-receiver tapleaf script. */\n refundWithoutReceiver(): TapLeafScript {\n return this.findLeaf(this.refundWithoutReceiverScript);\n }\n\n /** Return the unilateral claim tapleaf script. */\n unilateralClaim(): TapLeafScript {\n return this.findLeaf(this.unilateralClaimScript);\n }\n\n /** Return the unilateral refund tapleaf script. */\n unilateralRefund(): TapLeafScript {\n return this.findLeaf(this.unilateralRefundScript);\n }\n\n /** Return the unilateral refund-without-receiver tapleaf script. */\n unilateralRefundWithoutReceiver(): TapLeafScript {\n return this.findLeaf(this.unilateralRefundWithoutReceiverScript);\n }\n }\n\n function validateOptions(options: Options): void {\n const {\n sender,\n receiver,\n server,\n preimageHash,\n refundLocktime,\n unilateralClaimDelay,\n unilateralRefundDelay,\n unilateralRefundWithoutReceiverDelay,\n } = options;\n\n if (!preimageHash || preimageHash.length !== 20) {\n throw new Error(\"preimage hash must be 20 bytes\");\n }\n if (!receiver || receiver.length !== 32) {\n throw new Error(\"Invalid public key length (receiver)\");\n }\n if (!sender || sender.length !== 32) {\n throw new Error(\"Invalid public key length (sender)\");\n }\n if (!server || server.length !== 32) {\n throw new Error(\"Invalid public key length (server)\");\n }\n if (typeof refundLocktime !== \"bigint\" || refundLocktime <= 0n) {\n throw new Error(\"refund locktime must be greater than 0\");\n }\n if (\n !unilateralClaimDelay ||\n typeof unilateralClaimDelay.value !== \"bigint\" ||\n unilateralClaimDelay.value <= 0n\n ) {\n throw new Error(\"unilateral claim delay must greater than 0\");\n }\n if (unilateralClaimDelay.type === \"seconds\" && unilateralClaimDelay.value % 512n !== 0n) {\n throw new Error(\"seconds timelock must be multiple of 512\");\n }\n if (unilateralClaimDelay.type === \"seconds\" && unilateralClaimDelay.value < 512n) {\n throw new Error(\"seconds timelock must be greater or equal to 512\");\n }\n if (\n !unilateralRefundDelay ||\n typeof unilateralRefundDelay.value !== \"bigint\" ||\n unilateralRefundDelay.value <= 0n\n ) {\n throw new Error(\"unilateral refund delay must greater than 0\");\n }\n if (unilateralRefundDelay.type === \"seconds\" && unilateralRefundDelay.value % 512n !== 0n) {\n throw new Error(\"seconds timelock must be multiple of 512\");\n }\n if (unilateralRefundDelay.type === \"seconds\" && unilateralRefundDelay.value < 512n) {\n throw new Error(\"seconds timelock must be greater or equal to 512\");\n }\n if (\n !unilateralRefundWithoutReceiverDelay ||\n typeof unilateralRefundWithoutReceiverDelay.value !== \"bigint\" ||\n unilateralRefundWithoutReceiverDelay.value <= 0n\n ) {\n throw new Error(\"unilateral refund without receiver delay must greater than 0\");\n }\n if (\n unilateralRefundWithoutReceiverDelay.type === \"seconds\" &&\n unilateralRefundWithoutReceiverDelay.value % 512n !== 0n\n ) {\n throw new Error(\"seconds timelock must be multiple of 512\");\n }\n if (\n unilateralRefundWithoutReceiverDelay.type === \"seconds\" &&\n unilateralRefundWithoutReceiverDelay.value < 512n\n ) {\n throw new Error(\"seconds timelock must be greater or equal to 512\");\n }\n }\n}\n\nfunction preimageConditionScript(preimageHash: Bytes): Bytes {\n return Script.encode([\"HASH160\", preimageHash, \"EQUAL\"]);\n}\n","import { hex } from \"@scure/base\";\nimport { VHTLC } from \"../../script/vhtlc\";\nimport { RelativeTimelock } from \"../../script/tapscript\";\nimport { Contract, ContractHandler, PathContext, PathSelection } from \"../types\";\nimport { isCltvSatisfied, isCsvSpendable, resolveRole } from \"./helpers\";\nimport { sequenceToTimelock, timelockToSequence } from \"../../utils/timelock\";\n\n/**\n * Typed parameters for VHTLC contracts.\n */\nexport interface VHTLCContractParams {\n sender: Uint8Array;\n receiver: Uint8Array;\n server: Uint8Array;\n preimageHash: Uint8Array;\n refundLocktime: bigint;\n unilateralClaimDelay: RelativeTimelock;\n unilateralRefundDelay: RelativeTimelock;\n unilateralRefundWithoutReceiverDelay: RelativeTimelock;\n}\n\n/**\n * Handler for Virtual Hash Time Lock Contract (VHTLC).\n *\n * VHTLC supports multiple spending paths:\n *\n * Collaborative paths (with server):\n * - claim: Receiver + Server with preimage\n * - refund: Sender + Receiver + Server\n * - refundWithoutReceiver: Sender + Server after CLTV locktime\n *\n * Unilateral paths (without server):\n * - unilateralClaim: Receiver with preimage after CSV delay\n * - unilateralRefund: Sender + Receiver after CSV delay\n * - unilateralRefundWithoutReceiver: Sender after CSV delay\n */\nexport const VHTLCContractHandler: ContractHandler<VHTLCContractParams, VHTLC.Script> = {\n type: \"vhtlc\",\n\n createScript(params: Record<string, string>): VHTLC.Script {\n const typed = this.deserializeParams(params);\n return new VHTLC.Script(typed);\n },\n\n serializeParams(params: VHTLCContractParams): Record<string, string> {\n return {\n sender: hex.encode(params.sender),\n receiver: hex.encode(params.receiver),\n server: hex.encode(params.server),\n hash: hex.encode(params.preimageHash),\n refundLocktime: params.refundLocktime.toString(),\n claimDelay: timelockToSequence(params.unilateralClaimDelay).toString(),\n refundDelay: timelockToSequence(params.unilateralRefundDelay).toString(),\n refundNoReceiverDelay: timelockToSequence(\n params.unilateralRefundWithoutReceiverDelay,\n ).toString(),\n };\n },\n\n deserializeParams(params: Record<string, string>): VHTLCContractParams {\n return {\n sender: hex.decode(params.sender),\n receiver: hex.decode(params.receiver),\n server: hex.decode(params.server),\n preimageHash: hex.decode(params.hash),\n refundLocktime: BigInt(params.refundLocktime),\n unilateralClaimDelay: sequenceToTimelock(Number(params.claimDelay)),\n unilateralRefundDelay: sequenceToTimelock(Number(params.refundDelay)),\n unilateralRefundWithoutReceiverDelay: sequenceToTimelock(\n Number(params.refundNoReceiverDelay),\n ),\n };\n },\n\n /**\n * Select spending path based on context.\n *\n * Role is determined from `context.role` or by matching\n * `context.walletDescriptor` (preferred) / `context.walletPubKey`\n * against sender/receiver in contract params.\n */\n selectPath(\n script: VHTLC.Script,\n contract: Contract,\n context: PathContext,\n ): PathSelection | null {\n const role = resolveRole(contract, context);\n const preimage = contract.params?.preimage;\n const refundLocktime = BigInt(contract.params.refundLocktime);\n\n if (!role) {\n return null;\n }\n\n if (context.collaborative) {\n if (role === \"receiver\" && preimage) {\n return {\n leaf: script.claim(),\n extraWitness: [hex.decode(preimage)],\n };\n }\n\n if (role === \"sender\" && isCltvSatisfied(context, refundLocktime)) {\n return {\n leaf: script.refundWithoutReceiver(),\n };\n }\n\n return null;\n }\n\n // Unilateral paths\n if (role === \"receiver\" && preimage) {\n const sequence = Number(contract.params.claimDelay);\n if (!isCsvSpendable(context, sequence)) return null;\n return {\n leaf: script.unilateralClaim(),\n extraWitness: [hex.decode(preimage)],\n sequence,\n };\n }\n\n if (role === \"sender\") {\n const sequence = Number(contract.params.refundNoReceiverDelay);\n if (!isCsvSpendable(context, sequence)) return null;\n return {\n leaf: script.unilateralRefundWithoutReceiver(),\n sequence,\n };\n }\n\n return null;\n },\n\n /**\n * Get all possible spending paths (no timelock checks).\n *\n * Role is determined from `context.role` or by matching\n * `context.walletDescriptor` (preferred) / `context.walletPubKey`\n * against sender/receiver in contract params.\n */\n getAllSpendingPaths(\n script: VHTLC.Script,\n contract: Contract,\n context: PathContext,\n ): PathSelection[] {\n const role = resolveRole(contract, context);\n const paths: PathSelection[] = [];\n\n if (!role) {\n return paths;\n }\n\n const preimage = contract.params?.preimage;\n\n if (context.collaborative) {\n // Collaborative paths (no timelock checks)\n if (role === \"receiver\" && preimage) {\n paths.push({\n leaf: script.claim(),\n extraWitness: [hex.decode(preimage)],\n });\n }\n if (role === \"sender\") {\n paths.push({\n leaf: script.refundWithoutReceiver(),\n });\n }\n } else {\n // Unilateral paths (no timelock checks)\n if (role === \"receiver\" && preimage) {\n const sequence = Number(contract.params.claimDelay);\n paths.push({\n leaf: script.unilateralClaim(),\n extraWitness: [hex.decode(preimage)],\n sequence,\n });\n }\n if (role === \"sender\") {\n const sequence = Number(contract.params.refundNoReceiverDelay);\n paths.push({\n leaf: script.unilateralRefundWithoutReceiver(),\n sequence,\n });\n }\n }\n\n return paths;\n },\n\n getSpendablePaths(\n script: VHTLC.Script,\n contract: Contract,\n context: PathContext,\n ): PathSelection[] {\n const role = resolveRole(contract, context);\n const paths: PathSelection[] = [];\n\n if (!role) {\n return paths;\n }\n\n const preimage = contract.params?.preimage;\n const refundLocktime = BigInt(contract.params.refundLocktime);\n\n if (context.collaborative) {\n if (role === \"receiver\" && preimage) {\n paths.push({\n leaf: script.claim(),\n extraWitness: [hex.decode(preimage)],\n });\n }\n if (role === \"sender\" && isCltvSatisfied(context, refundLocktime)) {\n paths.push({\n leaf: script.refundWithoutReceiver(),\n });\n }\n return paths;\n }\n\n if (role === \"receiver\" && preimage) {\n const sequence = Number(contract.params.claimDelay);\n if (isCsvSpendable(context, sequence)) {\n paths.push({\n leaf: script.unilateralClaim(),\n extraWitness: [hex.decode(preimage)],\n sequence,\n });\n }\n }\n if (role === \"sender\") {\n const sequence = Number(contract.params.refundNoReceiverDelay);\n if (isCsvSpendable(context, sequence)) {\n paths.push({\n leaf: script.unilateralRefundWithoutReceiver(),\n sequence,\n });\n }\n }\n\n return paths;\n },\n};\n","export { contractHandlers } from \"./registry\";\nexport { DefaultContractHandler } from \"./default\";\nexport type { DefaultContractParams } from \"./default\";\nexport { DelegateContractHandler } from \"./delegate\";\nexport type { DelegateContractParams } from \"./delegate\";\nexport { VHTLCContractHandler } from \"./vhtlc\";\nexport type { VHTLCContractParams } from \"./vhtlc\";\n\n// Register built-in handlers\nimport { contractHandlers } from \"./registry\";\nimport { DefaultContractHandler } from \"./default\";\nimport { DelegateContractHandler } from \"./delegate\";\nimport { VHTLCContractHandler } from \"./vhtlc\";\n\ncontractHandlers.register(DefaultContractHandler);\ncontractHandlers.register(DelegateContractHandler);\ncontractHandlers.register(VHTLCContractHandler);\n"]}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../../chunk-
|
|
3
|
+
var chunkIEO3XDKI_cjs = require('../../chunk-IEO3XDKI.cjs');
|
|
4
|
+
require('../../chunk-WMIPYZSB.cjs');
|
|
5
5
|
require('../../chunk-5BLDMQED.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
Object.defineProperty(exports, "DefaultContractHandler", {
|
|
10
10
|
enumerable: true,
|
|
11
|
-
get: function () { return
|
|
11
|
+
get: function () { return chunkIEO3XDKI_cjs.DefaultContractHandler; }
|
|
12
12
|
});
|
|
13
13
|
Object.defineProperty(exports, "DelegateContractHandler", {
|
|
14
14
|
enumerable: true,
|
|
15
|
-
get: function () { return
|
|
15
|
+
get: function () { return chunkIEO3XDKI_cjs.DelegateContractHandler; }
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "VHTLCContractHandler", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: function () { return
|
|
19
|
+
get: function () { return chunkIEO3XDKI_cjs.VHTLCContractHandler; }
|
|
20
20
|
});
|
|
21
21
|
Object.defineProperty(exports, "contractHandlers", {
|
|
22
22
|
enumerable: true,
|
|
23
|
-
get: function () { return
|
|
23
|
+
get: function () { return chunkIEO3XDKI_cjs.contractHandlers; }
|
|
24
24
|
});
|
|
25
25
|
//# sourceMappingURL=index.cjs.map
|
|
26
26
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { D as DefaultContractHandler, a as DefaultContractParams, b as DelegateContractHandler, c as DelegateContractParams, d as VHTLCContractHandler, e as VHTLCContractParams, f as contractHandlers } from '../../index-
|
|
2
|
-
import '../../ark-
|
|
1
|
+
export { D as DefaultContractHandler, a as DefaultContractParams, b as DelegateContractHandler, c as DelegateContractParams, d as VHTLCContractHandler, e as VHTLCContractParams, f as contractHandlers } from '../../index-WIAY0DDn.cjs';
|
|
2
|
+
import '../../ark-C0TMXvwO.cjs';
|
|
3
3
|
import '@scure/btc-signer/transaction.js';
|
|
4
4
|
import '@scure/btc-signer/utils.js';
|
|
5
5
|
import '@scure/btc-signer/psbt.js';
|
|
6
6
|
import '@scure/btc-signer';
|
|
7
|
-
import '../../delegate-
|
|
7
|
+
import '../../delegate-CEk9RHVj.cjs';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { D as DefaultContractHandler, a as DefaultContractParams, b as DelegateContractHandler, c as DelegateContractParams, d as VHTLCContractHandler, e as VHTLCContractParams, f as contractHandlers } from '../../index-
|
|
2
|
-
import '../../ark-
|
|
1
|
+
export { D as DefaultContractHandler, a as DefaultContractParams, b as DelegateContractHandler, c as DelegateContractParams, d as VHTLCContractHandler, e as VHTLCContractParams, f as contractHandlers } from '../../index-DA9r_7Vg.js';
|
|
2
|
+
import '../../ark-C0TMXvwO.js';
|
|
3
3
|
import '@scure/btc-signer/transaction.js';
|
|
4
4
|
import '@scure/btc-signer/utils.js';
|
|
5
5
|
import '@scure/btc-signer/psbt.js';
|
|
6
6
|
import '@scure/btc-signer';
|
|
7
|
-
import '../../delegate-
|
|
7
|
+
import '../../delegate-Ds4Hi7Xy.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { DefaultContractHandler, DelegateContractHandler, VHTLCContractHandler, contractHandlers } from '../../chunk-
|
|
2
|
-
import '../../chunk-
|
|
1
|
+
export { DefaultContractHandler, DelegateContractHandler, VHTLCContractHandler, contractHandlers } from '../../chunk-YA4G7RFB.js';
|
|
2
|
+
import '../../chunk-TU3LVAPX.js';
|
|
3
3
|
import '../../chunk-NSBPE2FW.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Bytes } from '@scure/btc-signer/utils.js';
|
|
2
|
-
import { o as RelativeTimelock, V as VtxoScript, p as TapLeafScript } from './ark-
|
|
2
|
+
import { o as RelativeTimelock, V as VtxoScript, p as TapLeafScript } from './ark-C0TMXvwO.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* DefaultVtxo is the default implementation of a VtxoScript.
|
|
@@ -44,7 +44,7 @@ declare namespace DefaultVtxo {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
|
-
* DelegateVtxo extends DefaultVtxo with an extra
|
|
47
|
+
* DelegateVtxo extends DefaultVtxo with an extra delegate path
|
|
48
48
|
*/
|
|
49
49
|
declare namespace DelegateVtxo {
|
|
50
50
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Bytes } from '@scure/btc-signer/utils.js';
|
|
2
|
-
import { o as RelativeTimelock, V as VtxoScript, p as TapLeafScript } from './ark-
|
|
2
|
+
import { o as RelativeTimelock, V as VtxoScript, p as TapLeafScript } from './ark-C0TMXvwO.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* DefaultVtxo is the default implementation of a VtxoScript.
|
|
@@ -44,7 +44,7 @@ declare namespace DefaultVtxo {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
|
-
* DelegateVtxo extends DefaultVtxo with an extra
|
|
47
|
+
* DelegateVtxo extends DefaultVtxo with an extra delegate path
|
|
48
48
|
*/
|
|
49
49
|
declare namespace DelegateVtxo {
|
|
50
50
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as RelativeTimelock, V as VtxoScript, p as TapLeafScript,
|
|
2
|
-
import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-
|
|
1
|
+
import { o as RelativeTimelock, V as VtxoScript, p as TapLeafScript, aM as ContractHandler, aV as Discoverable } from './ark-C0TMXvwO.js';
|
|
2
|
+
import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-Ds4Hi7Xy.js';
|
|
3
3
|
import { Bytes } from '@scure/btc-signer/utils.js';
|
|
4
4
|
|
|
5
5
|
/** Virtual Hash Time Lock Contract (VHTLC) namespace. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as RelativeTimelock, V as VtxoScript, p as TapLeafScript,
|
|
2
|
-
import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-
|
|
1
|
+
import { o as RelativeTimelock, V as VtxoScript, p as TapLeafScript, aM as ContractHandler, aV as Discoverable } from './ark-C0TMXvwO.cjs';
|
|
2
|
+
import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-CEk9RHVj.cjs';
|
|
3
3
|
import { Bytes } from '@scure/btc-signer/utils.js';
|
|
4
4
|
|
|
5
5
|
/** Virtual Hash Time Lock Contract (VHTLC) namespace. */
|