@arkade-os/sdk 0.4.55 → 0.4.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/adapters/expo.cjs +5 -5
  2. package/dist/adapters/expo.d.cts +2 -2
  3. package/dist/adapters/expo.d.ts +2 -2
  4. package/dist/adapters/expo.js +3 -3
  5. package/dist/adapters/indexedDB.cjs +5 -5
  6. package/dist/adapters/indexedDB.js +4 -4
  7. package/dist/{ark-Do9Lqfsp.d.cts → ark-CJgH_pmn.d.cts} +25 -2
  8. package/dist/{ark-Do9Lqfsp.d.ts → ark-CJgH_pmn.d.ts} +25 -2
  9. package/dist/{asyncStorageTaskQueue-DOnBOEDn.d.ts → asyncStorageTaskQueue-BeeZbf-Q.d.ts} +2 -2
  10. package/dist/{asyncStorageTaskQueue-C3DYxvAT.d.cts → asyncStorageTaskQueue-BlrsUUX_.d.cts} +2 -2
  11. package/dist/{chunk-C6UYPHTQ.cjs → chunk-A7TOVUYG.cjs} +9 -9
  12. package/dist/{chunk-C6UYPHTQ.cjs.map → chunk-A7TOVUYG.cjs.map} +1 -1
  13. package/dist/{chunk-ENWR2F2P.js → chunk-ASUJNZ63.js} +3 -3
  14. package/dist/{chunk-ENWR2F2P.js.map → chunk-ASUJNZ63.js.map} +1 -1
  15. package/dist/{chunk-LAONNMM5.js → chunk-C4SVRVNM.js} +4 -4
  16. package/dist/{chunk-LAONNMM5.js.map → chunk-C4SVRVNM.js.map} +1 -1
  17. package/dist/{chunk-SG4X7SEC.js → chunk-CPS7V4A3.js} +4 -4
  18. package/dist/{chunk-SG4X7SEC.js.map → chunk-CPS7V4A3.js.map} +1 -1
  19. package/dist/{chunk-CSS74VCN.cjs → chunk-EZBKSWEL.cjs} +17 -17
  20. package/dist/{chunk-CSS74VCN.cjs.map → chunk-EZBKSWEL.cjs.map} +1 -1
  21. package/dist/{chunk-ZPL34T2Q.cjs → chunk-KEG4AAKX.cjs} +568 -413
  22. package/dist/chunk-KEG4AAKX.cjs.map +1 -0
  23. package/dist/{chunk-OWCPXRGP.cjs → chunk-KUN5ZRMW.cjs} +4 -3
  24. package/dist/chunk-KUN5ZRMW.cjs.map +1 -0
  25. package/dist/{chunk-QO3IKBYL.js → chunk-NIZPFPUM.js} +192 -49
  26. package/dist/chunk-NIZPFPUM.js.map +1 -0
  27. package/dist/{chunk-V2TOHHPW.cjs → chunk-OWTKOMJZ.cjs} +40 -40
  28. package/dist/{chunk-V2TOHHPW.cjs.map → chunk-OWTKOMJZ.cjs.map} +1 -1
  29. package/dist/{chunk-QMPNPZ2T.js → chunk-P6L2W5IL.js} +3 -3
  30. package/dist/{chunk-QMPNPZ2T.js.map → chunk-P6L2W5IL.js.map} +1 -1
  31. package/dist/{chunk-JCJ5WFS3.js → chunk-PUNBWFIV.js} +4 -3
  32. package/dist/chunk-PUNBWFIV.js.map +1 -0
  33. package/dist/{chunk-G7DOBFQN.cjs → chunk-YK6NP5KX.cjs} +15 -15
  34. package/dist/{chunk-G7DOBFQN.cjs.map → chunk-YK6NP5KX.cjs.map} +1 -1
  35. package/dist/contracts/handlers/index.cjs +8 -8
  36. package/dist/contracts/handlers/index.d.cts +3 -3
  37. package/dist/contracts/handlers/index.d.ts +3 -3
  38. package/dist/contracts/handlers/index.js +2 -2
  39. package/dist/{delegate-DmhFrtdq.d.ts → delegate-DM3YECSY.d.ts} +1 -1
  40. package/dist/{delegate-C0iIBxen.d.cts → delegate-Dk-OJVdf.d.cts} +1 -1
  41. package/dist/{index-BnLM1XxA.d.cts → index-Cig0RkTf.d.cts} +2 -2
  42. package/dist/{index-BNt4wcSh.d.ts → index-CnE7Gnvb.d.ts} +2 -2
  43. package/dist/index.cjs +259 -211
  44. package/dist/index.d.cts +43 -12
  45. package/dist/index.d.ts +43 -12
  46. package/dist/index.js +4 -4
  47. package/dist/repositories/realm/index.cjs +19 -19
  48. package/dist/repositories/realm/index.d.cts +2 -2
  49. package/dist/repositories/realm/index.d.ts +2 -2
  50. package/dist/repositories/realm/index.js +5 -5
  51. package/dist/repositories/sqlite/index.cjs +18 -18
  52. package/dist/repositories/sqlite/index.d.cts +2 -2
  53. package/dist/repositories/sqlite/index.d.ts +2 -2
  54. package/dist/repositories/sqlite/index.js +5 -5
  55. package/dist/{taskRunner-RwUvgQ5M.d.cts → taskRunner-CnGSTaAJ.d.cts} +2 -2
  56. package/dist/{taskRunner-Bgs-0I3x.d.ts → taskRunner-F7tWzsrC.d.ts} +2 -2
  57. package/dist/wallet/expo/background.cjs +14 -14
  58. package/dist/wallet/expo/background.d.cts +3 -3
  59. package/dist/wallet/expo/background.d.ts +3 -3
  60. package/dist/wallet/expo/background.js +6 -6
  61. package/dist/wallet/expo/index.cjs +14 -14
  62. package/dist/wallet/expo/index.d.cts +4 -4
  63. package/dist/wallet/expo/index.d.ts +4 -4
  64. package/dist/wallet/expo/index.js +5 -5
  65. package/dist/{wallet-5Aou-V5n.d.ts → wallet-D6_S0n6B.d.ts} +124 -4
  66. package/dist/{wallet-Ck7BH8zR.d.cts → wallet-DvRIQBBY.d.cts} +124 -4
  67. package/dist/worker/expo/index.cjs +9 -9
  68. package/dist/worker/expo/index.d.cts +4 -4
  69. package/dist/worker/expo/index.d.ts +4 -4
  70. package/dist/worker/expo/index.js +5 -5
  71. package/package.json +1 -1
  72. package/dist/chunk-JCJ5WFS3.js.map +0 -1
  73. package/dist/chunk-OWCPXRGP.cjs.map +0 -1
  74. package/dist/chunk-QO3IKBYL.js.map +0 -1
  75. package/dist/chunk-ZPL34T2Q.cjs.map +0 -1
@@ -1,6 +1,6 @@
1
- import { AssetId, AssetGroup, AssetInput, AssetOutput, Metadata, Packet, BufferReader, BufferWriter, AssetRef, RestIndexerProvider } from './chunk-ENWR2F2P.js';
2
- import { witnessRefToBytes, validateProgram, toASM, stringifyArtifact, serializeArkadeContractParams, resolveAsm, parseArtifact, getOpcodeValue, getOpcodeName, fromASM, deserializeArkadeContractParams, computeArkadeScriptPublicKey, bytesToASM, asmToBytes, arkadeWitnessHash, arkadeScriptHash, SUPPORTED_PROGRAM_VERSION, OPCODE_VALUES, OPCODE_NAMES, bignum_exports, ArkadeScript, ArkadeProgramScript, ARKADE_OPS, ARKADE_OPCODE_VALUES, ARKADE_OPCODE_NAMES, ARKADE_OPCODES, ARKADE_OP, inputName, contractHandlers, isMainnetDescriptor, descriptorIsOurs, deriveDescriptorLeafPubKey, deriveDescriptorLeafCompressedPubKey, DefaultVtxo, speculativeReceiveMetadata, DelegateVtxo, WALLET_RECEIVE_SOURCE, BoardingContractHandler } from './chunk-QMPNPZ2T.js';
3
- import { VtxoScript, Transaction, isRecoverable, CSVMultisigTapscript, DEFAULT_NETWORK, hasTerminalSpend, getNormalizedVtxos, setArkPsbtField, PrevArkTxField, ConditionWitness, craftToSpendTx, ArkAddress, isVirtualCoin, getArkPsbtFields, CosignerPublicKey, ServerResponseMismatchError, OP_RETURN_EMPTY_PKSCRIPT, sequenceToTimelock, decodeTapscript, scriptFromTapLeafScript, CLTVMultisigTapscript, VtxoTaprootTree, timelockToSequence, baseFetch, Intent, rateGate, DEFAULT_NETWORK_NAME, normalizeVtxo, getSequence, toBatchExpiry, maybeArkError, isArkError, ArkErrorName, toOffchainInputFeeParams, canRecoverOnchain, getNetwork, MultisigTapscript, isEventSourceError, isRetryableProviderError, getAllNormalizedVtxos, DEFAULT_PAGE_SIZE, RestArkProvider, canSpendOffchain, toVirtualStatus, ArkError, resolveTimeHeight, parseLegacyExpiry, isExpired, DEFAULT_ARKADE_SERVER_URL, ProviderUnavailableError, networks as networks$1, isPastExpiry, fetchVtxoCreatedAtByTxid } from './chunk-JCJ5WFS3.js';
1
+ import { AssetId, AssetGroup, AssetInput, AssetOutput, Metadata, Packet, BufferReader, BufferWriter, AssetRef, RestIndexerProvider } from './chunk-ASUJNZ63.js';
2
+ import { witnessRefToBytes, validateProgram, toASM, stringifyArtifact, serializeArkadeContractParams, resolveAsm, parseArtifact, getOpcodeValue, getOpcodeName, fromASM, deserializeArkadeContractParams, computeArkadeScriptPublicKey, bytesToASM, asmToBytes, arkadeWitnessHash, arkadeScriptHash, SUPPORTED_PROGRAM_VERSION, OPCODE_VALUES, OPCODE_NAMES, bignum_exports, ArkadeScript, ArkadeProgramScript, ARKADE_OPS, ARKADE_OPCODE_VALUES, ARKADE_OPCODE_NAMES, ARKADE_OPCODES, ARKADE_OP, inputName, contractHandlers, isMainnetDescriptor, descriptorIsOurs, deriveDescriptorLeafPubKey, deriveDescriptorLeafCompressedPubKey, DefaultVtxo, speculativeReceiveMetadata, DelegateVtxo, WALLET_RECEIVE_SOURCE, BoardingContractHandler } from './chunk-P6L2W5IL.js';
3
+ import { VtxoScript, Transaction, isRecoverable, CSVMultisigTapscript, DEFAULT_NETWORK, hasTerminalSpend, getNormalizedVtxos, setArkPsbtField, PrevArkTxField, ConditionWitness, craftToSpendTx, ArkAddress, isVirtualCoin, getArkPsbtFields, CosignerPublicKey, ServerResponseMismatchError, OP_RETURN_EMPTY_PKSCRIPT, sequenceToTimelock, decodeTapscript, scriptFromTapLeafScript, CLTVMultisigTapscript, VtxoTaprootTree, timelockToSequence, baseFetch, Intent, rateGate, DEFAULT_NETWORK_NAME, normalizeVtxo, getSequence, toBatchExpiry, maybeArkError, isArkError, ArkErrorName, toOffchainInputFeeParams, canRecoverOnchain, getNetwork, MultisigTapscript, isEventSourceError, isRetryableProviderError, getAllNormalizedVtxos, DEFAULT_PAGE_SIZE, RestArkProvider, canSpendOffchain, toVirtualStatus, ArkError, resolveTimeHeight, parseLegacyExpiry, isExpired, DEFAULT_ARKADE_SERVER_URL, ProviderUnavailableError, networks as networks$1, isPastExpiry, fetchVtxoCreatedAtByTxid } from './chunk-PUNBWFIV.js';
4
4
  import { __export } from './chunk-NSBPE2FW.js';
5
5
  import { sha256, equalBytes, hash160, sha256x2, concatBytes, randomPrivateKeyBytes, pubECDSA, pubSchnorr } from '@scure/btc-signer/utils.js';
6
6
  import { SigHash, Script, OP, OutScript, Address, RawWitness, p2tr, p2wpkh, TaprootControlBlock, DEFAULT_SEQUENCE, Transaction as Transaction$2 } from '@scure/btc-signer';
@@ -2304,6 +2304,83 @@ function classifyContractSigner(contractServerPubKeyHex, info, nowSeconds = Math
2304
2304
  function isCooperativelyMigratable(status) {
2305
2305
  return status === "MIGRATABLE" || status === "DUE_NOW";
2306
2306
  }
2307
+
2308
+ // src/wallet/timelockPolicy.ts
2309
+ var isRegtest = (network) => network.bech32 === "bcrt";
2310
+ var NOMINAL_BLOCK_SECONDS = 600n;
2311
+ var toTimelock = (value) => ({
2312
+ value,
2313
+ type: value >= 512n ? "seconds" : "blocks"
2314
+ });
2315
+ var toSeconds = (t) => t.type === "seconds" ? t.value : t.value * NOMINAL_BLOCK_SECONDS;
2316
+ function assertTimelockInPolicy(timelock, policy, label) {
2317
+ if (policy.requireSeconds && timelock.type === "blocks") {
2318
+ throw new ServerResponseMismatchError(
2319
+ `${label} rejected: block-typed timelocks are not accepted (got ${timelock.value})`
2320
+ );
2321
+ }
2322
+ const seconds = toSeconds(timelock);
2323
+ if (seconds < policy.minSeconds) {
2324
+ throw new ServerResponseMismatchError(
2325
+ `${label} rejected: ${timelock.value} ${timelock.type} is below the ${policy.minSeconds}s floor`
2326
+ );
2327
+ }
2328
+ return timelock;
2329
+ }
2330
+ function assertTimelockWithinFloor(value, policy, label) {
2331
+ return assertTimelockInPolicy(toTimelock(value), policy, label);
2332
+ }
2333
+
2334
+ // src/wallet/batchExpiry.ts
2335
+ var DEFAULT_MIN_BATCH_EXPIRY_SECONDS = 86400n;
2336
+ var REGTEST_MIN_BATCH_EXPIRY_SECONDS = 6000n;
2337
+ function defaultBatchExpiryPolicy(network) {
2338
+ return isRegtest(network) ? { minSeconds: REGTEST_MIN_BATCH_EXPIRY_SECONDS, requireSeconds: false } : { minSeconds: DEFAULT_MIN_BATCH_EXPIRY_SECONDS, requireSeconds: true };
2339
+ }
2340
+ function resolveBatchExpiryPolicy(network, overrides) {
2341
+ return { ...defaultBatchExpiryPolicy(network), ...overrides };
2342
+ }
2343
+ function assertValidBatchExpiry(batchExpiry, policy) {
2344
+ if (policy.advertisedVtxoTreeExpiry !== void 0 && batchExpiry !== policy.advertisedVtxoTreeExpiry) {
2345
+ throw new ServerResponseMismatchError(
2346
+ `batch expiry rejected: ${batchExpiry} does not match the advertised vtxoTreeExpiry ${policy.advertisedVtxoTreeExpiry}`
2347
+ );
2348
+ }
2349
+ return assertTimelockWithinFloor(batchExpiry, policy, "batch expiry");
2350
+ }
2351
+ var DEFAULT_MIN_CHECKPOINT_EXIT_DELAY_SECONDS = 86400n;
2352
+ var REGTEST_MIN_CHECKPOINT_EXIT_DELAY_SECONDS = 1200n;
2353
+ function defaultCheckpointExitDelayPolicy(network) {
2354
+ return isRegtest(network) ? { minSeconds: REGTEST_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, requireSeconds: false } : { minSeconds: DEFAULT_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, requireSeconds: true };
2355
+ }
2356
+ function resolveCheckpointExitDelayPolicy(network, overrides) {
2357
+ return { ...defaultCheckpointExitDelayPolicy(network), ...overrides };
2358
+ }
2359
+ function assertValidServerUnrollScript(checkpointTapscript, policy) {
2360
+ let script;
2361
+ try {
2362
+ script = CSVMultisigTapscript.decode(hex.decode(checkpointTapscript));
2363
+ } catch (e) {
2364
+ throw new ServerResponseMismatchError(
2365
+ `checkpoint exit delay rejected: invalid checkpointTapscript from server (${e instanceof Error ? e.message : String(e)})`
2366
+ );
2367
+ }
2368
+ if (policy.advertisedForfeitPubkey !== void 0) {
2369
+ const { pubkeys } = script.params;
2370
+ if (pubkeys.length !== 1) {
2371
+ throw new ServerResponseMismatchError(
2372
+ `checkpoint exit delay rejected: checkpointTapscript must commit to exactly one pubkey, got ${pubkeys.length} [${pubkeys.map(hex.encode).join(", ")}]`
2373
+ );
2374
+ }
2375
+ if (!equalBytes(pubkeys[0], policy.advertisedForfeitPubkey)) {
2376
+ throw new ServerResponseMismatchError(
2377
+ `checkpoint exit delay rejected: checkpointTapscript pubkey ${hex.encode(pubkeys[0])} does not match the advertised forfeitPubkey ${hex.encode(policy.advertisedForfeitPubkey)}`
2378
+ );
2379
+ }
2380
+ }
2381
+ assertTimelockInPolicy(script.params.timelock, policy, "checkpoint exit delay");
2382
+ return script;
2383
+ }
2307
2384
  function buildOffchainTx(inputs, outputs, serverUnrollScript) {
2308
2385
  const MAX_OP_RETURN = 2;
2309
2386
  let countOpReturn = 0;
@@ -2900,7 +2977,26 @@ function isValidArkAddress2(address) {
2900
2977
  return false;
2901
2978
  }
2902
2979
  }
2903
- function validateRecipients(recipients, dustAmount) {
2980
+ function assertRecipientArkAddress(encoded, address, context) {
2981
+ if (address.hrp !== context.hrp) {
2982
+ throw new Error(
2983
+ `Invalid Arkade address ${encoded}: expected prefix "${context.hrp}", got "${address.hrp}"`
2984
+ );
2985
+ }
2986
+ const { status } = classifyAgainstSignerSet(
2987
+ hex.encode(address.serverPubKey),
2988
+ context.signerSet
2989
+ );
2990
+ if (status === "UNKNOWN_SIGNER") {
2991
+ throw new Error(`Invalid Arkade address ${encoded}: unknown operator signer key`);
2992
+ }
2993
+ if (status === "EXPIRED") {
2994
+ throw new Error(
2995
+ `Invalid Arkade address ${encoded}: operator signer key is past its rotation cutoff`
2996
+ );
2997
+ }
2998
+ }
2999
+ function validateRecipients(recipients, dustAmount, context) {
2904
3000
  const validatedRecipients = [];
2905
3001
  for (const recipient of recipients) {
2906
3002
  let address;
@@ -2909,6 +3005,7 @@ function validateRecipients(recipients, dustAmount) {
2909
3005
  } catch (e) {
2910
3006
  throw new Error(`Invalid Arkade address: ${recipient.address}`);
2911
3007
  }
3008
+ assertRecipientArkAddress(recipient.address, address, context);
2912
3009
  const amount = recipient.amount || dustAmount;
2913
3010
  if (amount <= 0) {
2914
3011
  throw new Error("Amount must be positive");
@@ -5198,6 +5295,7 @@ function serializeArkInfoSnapshot(info, savedAt) {
5198
5295
  forfeitPubkey: info.forfeitPubkey,
5199
5296
  unilateralExitDelay: info.unilateralExitDelay.toString(),
5200
5297
  boardingExitDelay: info.boardingExitDelay.toString(),
5298
+ vtxoTreeExpiry: info.vtxoTreeExpiry?.toString(),
5201
5299
  sessionDuration: info.sessionDuration.toString(),
5202
5300
  dust: info.dust.toString(),
5203
5301
  fees: info.fees,
@@ -5247,6 +5345,7 @@ function hydrateArkInfo(snapshot) {
5247
5345
  sessionDuration: BigInt(a.sessionDuration),
5248
5346
  signerPubkey: a.signerPubkey,
5249
5347
  unilateralExitDelay: BigInt(a.unilateralExitDelay),
5348
+ vtxoTreeExpiry: a.vtxoTreeExpiry !== void 0 ? BigInt(a.vtxoTreeExpiry) : void 0,
5250
5349
  utxoMaxAmount: BigInt(a.utxoMaxAmount),
5251
5350
  utxoMinAmount: BigInt(a.utxoMinAmount),
5252
5351
  version: a.version,
@@ -5319,6 +5418,9 @@ function parseStoredArkInfoSnapshot(raw) {
5319
5418
  ]) {
5320
5419
  assertDecimalString(a[field], `arkInfo.${field}`);
5321
5420
  }
5421
+ if (a.vtxoTreeExpiry !== void 0) {
5422
+ assertDecimalString(a.vtxoTreeExpiry, "arkInfo.vtxoTreeExpiry");
5423
+ }
5322
5424
  assertFeeInfo(a.fees, "arkInfo.fees");
5323
5425
  if (!Array.isArray(a.deprecatedSigners)) {
5324
5426
  throw new MalformedArkInfoSnapshotError("arkInfo.deprecatedSigners must be an array");
@@ -10974,6 +11076,20 @@ var ReadonlyWallet = class _ReadonlyWallet {
10974
11076
  ...this._deprecatedSigners.keys()
10975
11077
  ]);
10976
11078
  }
11079
+ /**
11080
+ * `serverPubKey` defaults to the live key; spend paths that snapshot it
11081
+ * against mid-flight rotation pass their snapshot, so the check reads from
11082
+ * one rotation epoch.
11083
+ */
11084
+ recipientAddressContext(serverPubKey = this._arkServerPublicKey) {
11085
+ return {
11086
+ hrp: this.network.hrp,
11087
+ signerSet: {
11088
+ active: toXOnlySignerHex(hex.encode(serverPubKey)),
11089
+ deprecated: this._deprecatedSigners
11090
+ }
11091
+ };
11092
+ }
10977
11093
  /**
10978
11094
  * Currently-active receive tapscript. Read-only from the outside;
10979
11095
  * mutated only via {@link Wallet.setOffchainTapscriptForRotation}
@@ -11877,7 +11993,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
11877
11993
  }
11878
11994
  };
11879
11995
  var Wallet2 = class _Wallet extends ReadonlyWallet {
11880
- constructor(identity, network, onchainProvider, arkProvider, indexerProvider, arkServerPublicKey, offchainTapscript, boardingTapscript, serverUnrollScript, forfeitOutputScript, forfeitPubkey, dustAmount, walletRepository, contractRepository, renewalConfig, delegateProvider, watcherConfig, settlementConfig, walletContractTimelocks, receiveRotator, descriptorProvider, lookAheadWindow) {
11996
+ constructor(identity, network, onchainProvider, arkProvider, indexerProvider, arkServerPublicKey, offchainTapscript, boardingTapscript, serverUnrollScript, forfeitOutputScript, forfeitPubkey, dustAmount, walletRepository, contractRepository, renewalConfig, delegateProvider, watcherConfig, settlementConfig, walletContractTimelocks, receiveRotator, descriptorProvider, lookAheadWindow, batchExpiryPolicy, checkpointExitDelayPolicy) {
11881
11997
  super(
11882
11998
  identity,
11883
11999
  network,
@@ -11896,6 +12012,8 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
11896
12012
  this.arkProvider = arkProvider;
11897
12013
  this.forfeitOutputScript = forfeitOutputScript;
11898
12014
  this.forfeitPubkey = forfeitPubkey;
12015
+ this.batchExpiryPolicy = batchExpiryPolicy;
12016
+ this.checkpointExitDelayPolicy = checkpointExitDelayPolicy;
11899
12017
  this.identity = identity;
11900
12018
  this.renewalConfig = {
11901
12019
  enabled: renewalConfig?.enabled ?? false,
@@ -11928,6 +12046,8 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
11928
12046
  arkProvider;
11929
12047
  forfeitOutputScript;
11930
12048
  forfeitPubkey;
12049
+ batchExpiryPolicy;
12050
+ checkpointExitDelayPolicy;
11931
12051
  static MIN_FEE_RATE = 1;
11932
12052
  // sats/vbyte
11933
12053
  identity;
@@ -12226,12 +12346,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
12226
12346
  */
12227
12347
  async rotateServerSigner(newServerPubKey, checkpointTapscript) {
12228
12348
  const xonly = toXOnlyPubKey(newServerPubKey);
12229
- let newServerUnrollScript;
12230
- try {
12231
- newServerUnrollScript = CSVMultisigTapscript.decode(hex.decode(checkpointTapscript));
12232
- } catch (e) {
12233
- throw new Error("Invalid checkpointTapscript from server");
12234
- }
12349
+ const newServerUnrollScript = assertValidServerUnrollScript(
12350
+ checkpointTapscript,
12351
+ resolveCheckpointExitDelayPolicy(this.network, this.checkpointExitDelayPolicy)
12352
+ );
12235
12353
  if (equalBytes(xonly, this.arkServerPublicKey)) return;
12236
12354
  if (this._receiveRotator) {
12237
12355
  await this._receiveRotator.runExclusive(
@@ -12537,16 +12655,17 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
12537
12655
  throw new Error("Invalid configured public key");
12538
12656
  }
12539
12657
  const setup = await ReadonlyWallet.setupWalletConfig(config, pubkey);
12540
- let serverUnrollScript;
12541
- try {
12542
- const raw = hex.decode(setup.info.checkpointTapscript);
12543
- serverUnrollScript = CSVMultisigTapscript.decode(raw);
12544
- } catch (e) {
12545
- throw new Error("Invalid checkpointTapscript from server");
12546
- }
12547
12658
  const forfeitPubkey = hex.decode(setup.info.forfeitPubkey).slice(1);
12548
12659
  const forfeitAddress = Address(setup.network).decode(setup.info.forfeitAddress);
12549
12660
  const forfeitOutputScript = OutScript.encode(forfeitAddress);
12661
+ const checkpointExitDelayOverrides = {
12662
+ advertisedForfeitPubkey: forfeitPubkey,
12663
+ ...config.minCheckpointExitDelaySeconds !== void 0 ? { minSeconds: config.minCheckpointExitDelaySeconds } : {}
12664
+ };
12665
+ const serverUnrollScript = assertValidServerUnrollScript(
12666
+ setup.info.checkpointTapscript,
12667
+ resolveCheckpointExitDelayPolicy(setup.network, checkpointExitDelayOverrides)
12668
+ );
12550
12669
  const boot = await WalletReceiveRotator.resolveBoot(config, setup);
12551
12670
  const wallet = new _Wallet(
12552
12671
  config.identity,
@@ -12570,7 +12689,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
12570
12689
  setup.walletContractTimelocks,
12571
12690
  boot?.rotator,
12572
12691
  boot?.provider,
12573
- config.lookAheadWindow
12692
+ config.lookAheadWindow,
12693
+ // Pinned at setup rather than refetched per round.
12694
+ {
12695
+ advertisedVtxoTreeExpiry: setup.info.vtxoTreeExpiry,
12696
+ ...config.minBatchExpirySeconds !== void 0 ? { minSeconds: config.minBatchExpirySeconds } : {}
12697
+ },
12698
+ checkpointExitDelayOverrides
12574
12699
  );
12575
12700
  wallet._serverInfoSource = setup.serverInfoSource;
12576
12701
  if (setup.serverInfoSource === "live") {
@@ -12679,6 +12804,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
12679
12804
  changeAmount: BigInt(changeAmount)
12680
12805
  };
12681
12806
  const outputAddress = ArkAddress.decode(params.address);
12807
+ assertRecipientArkAddress(
12808
+ params.address,
12809
+ outputAddress,
12810
+ this.recipientAddressContext(serverPubKey)
12811
+ );
12682
12812
  const outputScript = BigInt(params.amount) < this.dustAmount ? outputAddress.subdustPkScript : outputAddress.pkScript;
12683
12813
  const outputs = [
12684
12814
  {
@@ -12808,13 +12938,21 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
12808
12938
  const onchainOutputIndexes = [];
12809
12939
  const outputs = [];
12810
12940
  let hasOffchainOutputs = false;
12941
+ let recipientContext;
12811
12942
  for (const [index, output] of params.outputs.entries()) {
12812
12943
  let script;
12944
+ let arkAddress;
12813
12945
  try {
12814
- const addr = ArkAddress.decode(output.address);
12815
- script = addr.pkScript;
12816
- hasOffchainOutputs = true;
12946
+ arkAddress = ArkAddress.decode(output.address);
12817
12947
  } catch {
12948
+ arkAddress = void 0;
12949
+ }
12950
+ if (arkAddress) {
12951
+ recipientContext ??= this.recipientAddressContext();
12952
+ assertRecipientArkAddress(output.address, arkAddress, recipientContext);
12953
+ script = arkAddress.pkScript;
12954
+ hasOffchainOutputs = true;
12955
+ } else {
12818
12956
  const addr = Address(this.network).decode(output.address);
12819
12957
  script = OutScript.encode(addr);
12820
12958
  onchainOutputIndexes.push(index);
@@ -13145,24 +13283,20 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
13145
13283
  const utf8IntentId = new TextEncoder().encode(intentId);
13146
13284
  const intentIdHash = sha256(utf8IntentId);
13147
13285
  const intentIdHashStr = hex.encode(intentIdHash);
13148
- let skip = true;
13149
- for (const idHash of event.intentIdHashes) {
13150
- if (idHash === intentIdHashStr) {
13151
- if (!this.arkProvider) {
13152
- throw new Error("Arkade provider not configured");
13153
- }
13154
- await this.arkProvider.confirmRegistration(intentId);
13155
- skip = false;
13156
- }
13157
- }
13286
+ const skip = !event.intentIdHashes.includes(intentIdHashStr);
13158
13287
  if (skip) {
13159
13288
  return { skip };
13160
13289
  }
13290
+ if (!this.arkProvider) {
13291
+ throw new Error("Arkade provider not configured");
13292
+ }
13293
+ const timelock = assertValidBatchExpiry(
13294
+ event.batchExpiry,
13295
+ resolveBatchExpiryPolicy(this.network, this.batchExpiryPolicy)
13296
+ );
13297
+ await this.arkProvider.confirmRegistration(intentId);
13161
13298
  const sweepTapscript = CSVMultisigTapscript.encode({
13162
- timelock: {
13163
- value: event.batchExpiry,
13164
- type: event.batchExpiry >= 512n ? "seconds" : "blocks"
13165
- },
13299
+ timelock,
13166
13300
  pubkeys: [this.forfeitPubkey]
13167
13301
  }).script;
13168
13302
  sweepTapTreeRoot = tapLeafHash(sweepTapscript);
@@ -13598,8 +13732,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
13598
13732
  }
13599
13733
  if (spendable.length > 0) {
13600
13734
  const info = await this.arkProvider.getInfo();
13601
- const serverUnrollScript = CSVMultisigTapscript.decode(
13602
- hex.decode(info.checkpointTapscript)
13735
+ const serverUnrollScript = assertValidServerUnrollScript(
13736
+ info.checkpointTapscript,
13737
+ resolveCheckpointExitDelayPolicy(this.network, this.checkpointExitDelayPolicy)
13603
13738
  );
13604
13739
  for (const vtxo of spendable) {
13605
13740
  try {
@@ -13807,7 +13942,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
13807
13942
  const serverUnrollScript = this.serverUnrollScript;
13808
13943
  const outputAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
13809
13944
  const address = outputAddress.encode();
13810
- const recipients = validateRecipients(args, Number(this.dustAmount));
13945
+ const recipients = validateRecipients(
13946
+ args,
13947
+ Number(this.dustAmount),
13948
+ this.recipientAddressContext(serverPubKey)
13949
+ );
13811
13950
  const allVirtualCoins = await this.getVtxos({
13812
13951
  withRecoverable: false
13813
13952
  });
@@ -19830,7 +19969,7 @@ __export(arkade_exports, {
19830
19969
  witnessRefToBytes: () => witnessRefToBytes
19831
19970
  });
19832
19971
  var isVtxoCoin = (input) => isVirtualCoin(input);
19833
- function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients) {
19972
+ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
19834
19973
  let batchId;
19835
19974
  let sweepTapTreeRoot;
19836
19975
  let validatedCommitmentTxid;
@@ -19840,15 +19979,19 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
19840
19979
  const intentIdHash = sha256(utf8IntentId);
19841
19980
  const intentIdHashStr = hex.encode(intentIdHash);
19842
19981
  if (!event.intentIdHashes.includes(intentIdHashStr)) return { skip: true };
19982
+ const info = await arkProvider.getInfo();
19983
+ const timelock = assertValidBatchExpiry(
19984
+ event.batchExpiry,
19985
+ resolveBatchExpiryPolicy(network, {
19986
+ advertisedVtxoTreeExpiry: info.vtxoTreeExpiry,
19987
+ ...batchExpiryPolicy
19988
+ })
19989
+ );
19843
19990
  await arkProvider.confirmRegistration(intentId);
19844
19991
  batchId = event.id;
19845
19992
  const sweepTapscript = CSVMultisigTapscript.encode({
19846
- timelock: {
19847
- value: event.batchExpiry,
19848
- // BIP-65: values >= 512 are interpreted as seconds, below as blocks
19849
- type: event.batchExpiry >= 512n ? "seconds" : "blocks"
19850
- },
19851
- pubkeys: [hex.decode((await arkProvider.getInfo()).forfeitPubkey).subarray(1)]
19993
+ timelock,
19994
+ pubkeys: [hex.decode(info.forfeitPubkey).subarray(1)]
19852
19995
  }).script;
19853
19996
  sweepTapTreeRoot = tapLeafHash(sweepTapscript);
19854
19997
  return { skip: false };
@@ -20868,6 +21011,6 @@ function isArkContract(str) {
20868
21011
  return str.startsWith(ARKCONTRACT_PREFIX + "=");
20869
21012
  }
20870
21013
 
20871
- export { ARKADE_MAGIC, ActivityRegistry, AmbiguousRouteError, ArkNote, ArkadeCash, ArkadeCashCreateError, AssetManager, BIP21, BIP21Error, BIP322, Batch, ChainedTxType, ContractManager, ContractRepositoryImpl, ContractWatcher, DB_VERSION, DEFAULT_MESSAGE_TIMEOUTS, DelegateManagerImpl, DelegateNotConfiguredError, DelegatorManagerImpl, DelegatorNotConfiguredError, DescriptorIdentity, DescriptorSigningProviderMissingError, DustChangeError, ELECTRUM_TCP_HOST, ELECTRUM_WS_URL, ESPLORA_URL, ElectrumOnchainProvider, EmulatorPacket, EsploraProvider, Estimator, Extension, ExtensionNotFoundError, HDDescriptorProvider, INTENT_TERMINAL_STATES, InMemoryContractRepository, InMemoryIntentRepository, InMemoryVirtualTxRepository, InMemoryWalletRepository, IndexedDBContractRepository, IndexedDBIntentRepository, IndexedDBVirtualTxRepository, IndexedDBWalletRepository, MESSAGE_BUS_INITIALIZING, MESSAGE_BUS_NOT_INITIALIZED, MIGRATION_KEY, MessageBus, MessageBusInitializingError, MessageBusNotInitializedError, MissingSigningDescriptorError, MnemonicIdentity, OnchainWallet, P2A, PaymentRouter, Ramps, ReadonlyAssetManager, ReadonlyDescriptorIdentity, ReadonlySingleKey, ReadonlyWallet, ReadonlyWalletError, RestDelegateProvider, RestDelegatorProvider, RestEmulatorProvider, SeedIdentity, ServiceWorkerReadonlyWallet, ServiceWorkerTimeoutError, ServiceWorkerWallet, SingleKey, TxTree, TxType, TxWeightEstimator, UnilateralExit, UnknownPacket, Unroll, VtxoManager, Wallet2 as Wallet, WalletMessageHandler, WalletNotInitializedError, WalletRepositoryImpl, WsElectrumChainSource, arkRail, arkTarget, arkade_exports, assertIntentIdUnique, assertSendableAmount, assertSubmittedArkTxid, assetMintResolver, boardingResolver, btcTarget, buildForfeitTx, buildOffchainTx, classifyAgainstSignerSet, classifyContractSigner, closeDatabase, collabExitResolver, combineTapscriptSigs, contractFromArkContract, contractFromArkContractWithAddress, createAssetPacket, createDefaultActivityRegistry, createDefaultPaymentRouter, createExitChainResolver, decodeArkContract, deserializeAssets, deserializeExitPackage, deserializeUtxo, deserializeVtxo, encodeArkContract, extendVirtualCoinForContract, getMigrationStatus, getRandomId, hasBoardingTxExpired, hasCandidates, intentMatchesFilter, intentPageBounds, invoiceTarget, isArkContract, isBatchSignable, isBtcAddress, isCooperativelyMigratable, isDiscoverable, isHDDeterministicSignCapable, isHDWalletCapable, isLightningInvoice, isLnurl, isMessageBusInitializingError, isMessageBusNotInitializedError, isSubdust, isTerminalIntentState, isValidArkAddress, isVtxoExpiringSoon, isVtxoForScript, makeHandle, matchServerCheckpoints, mergeChainedTxType, migrateWalletRepository, onchainRail, openDatabase, requiresMigration, resolveSendAmount, rollbackMigration, saveVtxosForContract, scriptFromArkAddress, selectCoinsWithAsset, selectVirtualCoins, serializeAssets, serializeExitPackage, serializeUtxo, serializeVtxo, setupServiceWorker, signerSetFromInfo, toXOnlySignerHex, tryResolveSendAmount, validateConnectorsTxGraph, validateVtxoTxGraph, verifyTapscriptSignatures, waitForIncomingFunds, warnAndFilterVtxosForScript };
20872
- //# sourceMappingURL=chunk-QO3IKBYL.js.map
20873
- //# sourceMappingURL=chunk-QO3IKBYL.js.map
21014
+ export { ARKADE_MAGIC, ActivityRegistry, AmbiguousRouteError, ArkNote, ArkadeCash, ArkadeCashCreateError, AssetManager, BIP21, BIP21Error, BIP322, Batch, ChainedTxType, ContractManager, ContractRepositoryImpl, ContractWatcher, DB_VERSION, DEFAULT_MESSAGE_TIMEOUTS, DEFAULT_MIN_BATCH_EXPIRY_SECONDS, DEFAULT_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, DelegateManagerImpl, DelegateNotConfiguredError, DelegatorManagerImpl, DelegatorNotConfiguredError, DescriptorIdentity, DescriptorSigningProviderMissingError, DustChangeError, ELECTRUM_TCP_HOST, ELECTRUM_WS_URL, ESPLORA_URL, ElectrumOnchainProvider, EmulatorPacket, EsploraProvider, Estimator, Extension, ExtensionNotFoundError, HDDescriptorProvider, INTENT_TERMINAL_STATES, InMemoryContractRepository, InMemoryIntentRepository, InMemoryVirtualTxRepository, InMemoryWalletRepository, IndexedDBContractRepository, IndexedDBIntentRepository, IndexedDBVirtualTxRepository, IndexedDBWalletRepository, MESSAGE_BUS_INITIALIZING, MESSAGE_BUS_NOT_INITIALIZED, MIGRATION_KEY, MessageBus, MessageBusInitializingError, MessageBusNotInitializedError, MissingSigningDescriptorError, MnemonicIdentity, OnchainWallet, P2A, PaymentRouter, REGTEST_MIN_BATCH_EXPIRY_SECONDS, REGTEST_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, Ramps, ReadonlyAssetManager, ReadonlyDescriptorIdentity, ReadonlySingleKey, ReadonlyWallet, ReadonlyWalletError, RestDelegateProvider, RestDelegatorProvider, RestEmulatorProvider, SeedIdentity, ServiceWorkerReadonlyWallet, ServiceWorkerTimeoutError, ServiceWorkerWallet, SingleKey, TxTree, TxType, TxWeightEstimator, UnilateralExit, UnknownPacket, Unroll, VtxoManager, Wallet2 as Wallet, WalletMessageHandler, WalletNotInitializedError, WalletRepositoryImpl, WsElectrumChainSource, arkRail, arkTarget, arkade_exports, assertFinalCommitmentMatchesValidated, assertIntentIdUnique, assertSendableAmount, assertSubmittedArkTxid, assertValidBatchExpiry, assertValidServerUnrollScript, assetMintResolver, boardingResolver, btcTarget, buildForfeitTx, buildOffchainTx, classifyAgainstSignerSet, classifyContractSigner, closeDatabase, collabExitResolver, combineTapscriptSigs, contractFromArkContract, contractFromArkContractWithAddress, createAssetPacket, createDefaultActivityRegistry, createDefaultPaymentRouter, createExitChainResolver, decodeArkContract, defaultBatchExpiryPolicy, defaultCheckpointExitDelayPolicy, deserializeAssets, deserializeExitPackage, deserializeUtxo, deserializeVtxo, encodeArkContract, extendVirtualCoinForContract, getMigrationStatus, getRandomId, hasBoardingTxExpired, hasCandidates, intentMatchesFilter, intentPageBounds, invoiceTarget, isArkContract, isBatchSignable, isBtcAddress, isCooperativelyMigratable, isDiscoverable, isHDDeterministicSignCapable, isHDWalletCapable, isLightningInvoice, isLnurl, isMessageBusInitializingError, isMessageBusNotInitializedError, isSubdust, isTerminalIntentState, isValidArkAddress, isVtxoExpiringSoon, isVtxoForScript, makeHandle, matchServerCheckpoints, mergeChainedTxType, migrateWalletRepository, onchainRail, openDatabase, requiresMigration, resolveBatchExpiryPolicy, resolveCheckpointExitDelayPolicy, resolveSendAmount, rollbackMigration, saveVtxosForContract, scriptFromArkAddress, selectCoinsWithAsset, selectVirtualCoins, serializeAssets, serializeExitPackage, serializeUtxo, serializeVtxo, setupServiceWorker, signerSetFromInfo, toXOnlySignerHex, tryResolveSendAmount, validateBatchRecipients, validateConnectorsTxGraph, validateVtxoTxGraph, verifyTapscriptSignatures, waitForIncomingFunds, warnAndFilterVtxosForScript };
21015
+ //# sourceMappingURL=chunk-NIZPFPUM.js.map
21016
+ //# sourceMappingURL=chunk-NIZPFPUM.js.map