@arkade-os/sdk 0.5.0-rc.8 → 0.5.0-rc.9

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 (55) hide show
  1. package/dist/adapters/expo.cjs +5 -5
  2. package/dist/adapters/expo.js +3 -3
  3. package/dist/{asyncStorageTaskQueue-Bn3FoNkc.d.cts → asyncStorageTaskQueue-ChKX-D51.d.cts} +2 -2
  4. package/dist/{asyncStorageTaskQueue-CeYTmuGU.d.ts → asyncStorageTaskQueue-DZYrAWN8.d.ts} +2 -2
  5. package/dist/{chunk-LN4ZJZK4.js → chunk-3TCWQPAC.js} +162 -35
  6. package/dist/chunk-3TCWQPAC.js.map +1 -0
  7. package/dist/{chunk-56RCBKNF.cjs → chunk-7OL2P5TV.cjs} +17 -17
  8. package/dist/{chunk-56RCBKNF.cjs.map → chunk-7OL2P5TV.cjs.map} +1 -1
  9. package/dist/{chunk-INTEA7D3.js → chunk-FQCMEAWN.js} +4 -4
  10. package/dist/{chunk-INTEA7D3.js.map → chunk-FQCMEAWN.js.map} +1 -1
  11. package/dist/{chunk-G6S4XSFI.js → chunk-J2K7WWMJ.js} +3 -3
  12. package/dist/{chunk-G6S4XSFI.js.map → chunk-J2K7WWMJ.js.map} +1 -1
  13. package/dist/{chunk-MTYQXZ2T.js → chunk-JFZBKPSV.js} +3 -3
  14. package/dist/{chunk-MTYQXZ2T.js.map → chunk-JFZBKPSV.js.map} +1 -1
  15. package/dist/{chunk-ZTCDT7KB.cjs → chunk-PKD5VPYX.cjs} +590 -463
  16. package/dist/chunk-PKD5VPYX.cjs.map +1 -0
  17. package/dist/{chunk-BMPGUGYZ.cjs → chunk-PO2ZDZZC.cjs} +10 -10
  18. package/dist/{chunk-BMPGUGYZ.cjs.map → chunk-PO2ZDZZC.cjs.map} +1 -1
  19. package/dist/{chunk-XCNAGBFR.js → chunk-R4KRWX7R.js} +3 -3
  20. package/dist/{chunk-XCNAGBFR.js.map → chunk-R4KRWX7R.js.map} +1 -1
  21. package/dist/{chunk-2AWDPVZI.cjs → chunk-V4JZOFYT.cjs} +18 -18
  22. package/dist/{chunk-2AWDPVZI.cjs.map → chunk-V4JZOFYT.cjs.map} +1 -1
  23. package/dist/{chunk-K5RED5VE.cjs → chunk-VMVHRKXM.cjs} +50 -50
  24. package/dist/{chunk-K5RED5VE.cjs.map → chunk-VMVHRKXM.cjs.map} +1 -1
  25. package/dist/{chunk-NY5FN4VV.cjs → chunk-VTXMC4N7.cjs} +3 -3
  26. package/dist/{chunk-NY5FN4VV.cjs.map → chunk-VTXMC4N7.cjs.map} +1 -1
  27. package/dist/{chunk-BIRUBLP3.js → chunk-Z3QM5XFY.js} +4 -4
  28. package/dist/{chunk-BIRUBLP3.js.map → chunk-Z3QM5XFY.js.map} +1 -1
  29. package/dist/contracts/handlers/index.cjs +9 -9
  30. package/dist/contracts/handlers/index.js +2 -2
  31. package/dist/index.cjs +291 -291
  32. package/dist/index.d.cts +3 -0
  33. package/dist/index.d.ts +3 -0
  34. package/dist/index.js +4 -4
  35. package/dist/repositories/realm/index.cjs +20 -20
  36. package/dist/repositories/realm/index.js +5 -5
  37. package/dist/repositories/sqlite/index.cjs +19 -19
  38. package/dist/repositories/sqlite/index.js +5 -5
  39. package/dist/{taskRunner-CRbuzUXR.d.ts → taskRunner-Cu4uO1to.d.ts} +1 -1
  40. package/dist/{taskRunner-z_BGID85.d.cts → taskRunner-DxpSuKmh.d.cts} +1 -1
  41. package/dist/wallet/expo/background.cjs +14 -14
  42. package/dist/wallet/expo/background.d.cts +2 -2
  43. package/dist/wallet/expo/background.d.ts +2 -2
  44. package/dist/wallet/expo/background.js +6 -6
  45. package/dist/wallet/expo/index.cjs +14 -14
  46. package/dist/wallet/expo/index.d.cts +1 -1
  47. package/dist/wallet/expo/index.d.ts +1 -1
  48. package/dist/wallet/expo/index.js +5 -5
  49. package/dist/worker/expo/index.cjs +9 -9
  50. package/dist/worker/expo/index.d.cts +3 -3
  51. package/dist/worker/expo/index.d.ts +3 -3
  52. package/dist/worker/expo/index.js +5 -5
  53. package/package.json +1 -1
  54. package/dist/chunk-LN4ZJZK4.js.map +0 -1
  55. package/dist/chunk-ZTCDT7KB.cjs.map +0 -1
@@ -1,18 +1,18 @@
1
1
  'use strict';
2
2
 
3
- var chunk56RCBKNF_cjs = require('../chunk-56RCBKNF.cjs');
4
- require('../chunk-2AWDPVZI.cjs');
5
- require('../chunk-NY5FN4VV.cjs');
3
+ var chunk7OL2P5TV_cjs = require('../chunk-7OL2P5TV.cjs');
4
+ require('../chunk-V4JZOFYT.cjs');
5
+ require('../chunk-VTXMC4N7.cjs');
6
6
 
7
7
 
8
8
 
9
9
  Object.defineProperty(exports, "ExpoArkProvider", {
10
10
  enumerable: true,
11
- get: function () { return chunk56RCBKNF_cjs.ExpoArkProvider; }
11
+ get: function () { return chunk7OL2P5TV_cjs.ExpoArkProvider; }
12
12
  });
13
13
  Object.defineProperty(exports, "ExpoIndexerProvider", {
14
14
  enumerable: true,
15
- get: function () { return chunk56RCBKNF_cjs.ExpoIndexerProvider; }
15
+ get: function () { return chunk7OL2P5TV_cjs.ExpoIndexerProvider; }
16
16
  });
17
17
  //# sourceMappingURL=expo.cjs.map
18
18
  //# sourceMappingURL=expo.cjs.map
@@ -1,5 +1,5 @@
1
- export { ExpoArkProvider, ExpoIndexerProvider } from '../chunk-INTEA7D3.js';
2
- import '../chunk-G6S4XSFI.js';
3
- import '../chunk-MTYQXZ2T.js';
1
+ export { ExpoArkProvider, ExpoIndexerProvider } from '../chunk-FQCMEAWN.js';
2
+ import '../chunk-J2K7WWMJ.js';
3
+ import '../chunk-JFZBKPSV.js';
4
4
  //# sourceMappingURL=expo.js.map
5
5
  //# sourceMappingURL=expo.js.map
@@ -1,4 +1,4 @@
1
- import { c as TaskQueue, b as TaskItem, d as TaskResult } from './taskRunner-z_BGID85.cjs';
1
+ import { a as TaskQueue, c as TaskItem, d as TaskResult } from './taskRunner-DxpSuKmh.cjs';
2
2
 
3
3
  /**
4
4
  * Minimal async key-value storage interface.
@@ -46,4 +46,4 @@ declare class AsyncStorageTaskQueue implements TaskQueue {
46
46
  private writeList;
47
47
  }
48
48
 
49
- export { type AsyncStorageLike as A, AsyncStorageTaskQueue as a };
49
+ export { AsyncStorageTaskQueue as A, type AsyncStorageLike as a };
@@ -1,4 +1,4 @@
1
- import { c as TaskQueue, b as TaskItem, d as TaskResult } from './taskRunner-CRbuzUXR.js';
1
+ import { a as TaskQueue, c as TaskItem, d as TaskResult } from './taskRunner-Cu4uO1to.js';
2
2
 
3
3
  /**
4
4
  * Minimal async key-value storage interface.
@@ -46,4 +46,4 @@ declare class AsyncStorageTaskQueue implements TaskQueue {
46
46
  private writeList;
47
47
  }
48
48
 
49
- export { type AsyncStorageLike as A, AsyncStorageTaskQueue as a };
49
+ export { AsyncStorageTaskQueue as A, type AsyncStorageLike as a };
@@ -1,6 +1,6 @@
1
- import { AssetId, AssetGroup, AssetInput, AssetOutput, Metadata, Packet, BufferReader, BufferWriter, AssetRef, RestIndexerProvider } from './chunk-G6S4XSFI.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, toXOnly, inputName, contractHandlers, isMainnetDescriptor, descriptorIsOurs, deriveDescriptorLeafPubKey, deriveDescriptorLeafCompressedPubKey, parseHDDescriptor, identityDescriptor, DefaultVtxo, speculativeReceiveMetadata, DelegateVtxo, WALLET_RECEIVE_SOURCE, BoardingContractHandler } from './chunk-XCNAGBFR.js';
3
- import { VtxoScript, __export, Transaction, canRecoverOnchain, CSVMultisigTapscript, DEFAULT_NETWORK, resolveEmulatorPubkey, hasTerminalSpend, getNormalizedVtxos, setArkPsbtField, PrevArkTxField, ConditionWitness, craftToSpendTx, ArkAddress, isVirtualCoin, getArkPsbtFields, CosignerPublicKey, ServerResponseMismatchError, OP_RETURN_EMPTY_PKSCRIPT, canSweepOnchain, sequenceToTimelock, decodeTapscript, scriptFromTapLeafScript, CLTVMultisigTapscript, VtxoTaprootTree, timelockToSequence, assertAllowedSighashTypes, baseFetch, Intent, rateGate, DEFAULT_NETWORK_NAME, formatSighash, normalizeVtxo, getSequence, maybeArkError, isArkError, ArkErrorName, toOffchainInputFeeParams, getNetwork, MultisigTapscript, isEventSourceError, isEventSourceUnavailableError, getAllNormalizedVtxos, isPastExpiry, isRetryableProviderError, DEFAULT_PAGE_SIZE, RestArkProvider, DEFAULT_ARKADE_SERVER_URL, networkFromArkadeInfo, ArkError, TapTreeCoder, resolveTimeHeight, canSpendOffchain, INFO_FETCH_TIMEOUT_MS, PrevoutTxField, fetchVtxoCreatedAtByTxid, EXPIRY_MIN_PLAUSIBLE_MS, ProviderUnavailableError, networks as networks$1 } from './chunk-MTYQXZ2T.js';
1
+ import { AssetId, AssetGroup, AssetInput, AssetOutput, Metadata, Packet, BufferReader, BufferWriter, AssetRef, RestIndexerProvider } from './chunk-J2K7WWMJ.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, toXOnly, inputName, contractHandlers, isMainnetDescriptor, descriptorIsOurs, deriveDescriptorLeafPubKey, deriveDescriptorLeafCompressedPubKey, parseHDDescriptor, identityDescriptor, DefaultVtxo, speculativeReceiveMetadata, DelegateVtxo, WALLET_RECEIVE_SOURCE, BoardingContractHandler } from './chunk-R4KRWX7R.js';
3
+ import { VtxoScript, __export, Transaction, canRecoverOnchain, CSVMultisigTapscript, DEFAULT_NETWORK, resolveEmulatorPubkey, hasTerminalSpend, getNormalizedVtxos, setArkPsbtField, PrevArkTxField, ConditionWitness, craftToSpendTx, ArkAddress, isVirtualCoin, getArkPsbtFields, CosignerPublicKey, ServerResponseMismatchError, OP_RETURN_EMPTY_PKSCRIPT, canSweepOnchain, sequenceToTimelock, decodeTapscript, scriptFromTapLeafScript, CLTVMultisigTapscript, VtxoTaprootTree, timelockToSequence, assertAllowedSighashTypes, baseFetch, Intent, rateGate, DEFAULT_NETWORK_NAME, formatSighash, normalizeVtxo, getSequence, maybeArkError, isArkError, ArkErrorName, toOffchainInputFeeParams, getNetwork, MultisigTapscript, isEventSourceError, isEventSourceUnavailableError, getAllNormalizedVtxos, isPastExpiry, isRetryableProviderError, DEFAULT_PAGE_SIZE, RestArkProvider, DEFAULT_ARKADE_SERVER_URL, networkFromArkadeInfo, ArkError, TapTreeCoder, resolveTimeHeight, canSpendOffchain, INFO_FETCH_TIMEOUT_MS, PrevoutTxField, fetchVtxoCreatedAtByTxid, EXPIRY_MIN_PLAUSIBLE_MS, ProviderUnavailableError, networks as networks$1 } from './chunk-JFZBKPSV.js';
4
4
  import { sha256 as sha256$1, equalBytes, hash160, sha256x2, concatBytes, randomPrivateKeyBytes, pubECDSA, pubSchnorr } from '@scure/btc-signer/utils.js';
5
5
  import { SigHash, Script, OP, OutScript, Address, RawWitness, p2tr, p2wpkh, TaprootControlBlock, DEFAULT_SEQUENCE, Transaction as Transaction$2 } from '@scure/btc-signer';
6
6
  import { hex, base58, base64, bech32m } from '@scure/base';
@@ -2657,6 +2657,12 @@ var ErrOnchainOutputNotFound = (address) => new ServerResponseMismatchError(`onc
2657
2657
  var ErrUnvalidatedOffchainOutput = (address) => new ServerResponseMismatchError(
2658
2658
  `offchain output ${address} cannot be validated: virtual output tree signing did not run`
2659
2659
  );
2660
+ var ErrIntentOutputNotFound = (index, kind) => new ServerResponseMismatchError(
2661
+ `${kind} output ${index} of the intent proof is not present in what the server built`
2662
+ );
2663
+ var ErrUnvalidatedIntentOutput = (index) => new ServerResponseMismatchError(
2664
+ `offchain output ${index} of the intent proof cannot be validated: virtual output tree signing did not run`
2665
+ );
2660
2666
  var ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
2661
2667
  var ErrInvalidOnchainOutputAssets = (address) => new Error(`onchain output ${address} cannot have assets`);
2662
2668
  var ErrInvalidOffchainOutputAmount = (address) => new Error(`invalid offchain output ${address}, missing amount`);
@@ -2693,6 +2699,74 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
2693
2699
  throw ErrUnvalidatedOffchainOutput(recipient.address);
2694
2700
  }
2695
2701
  }
2702
+ function declaredIntentOutputs(signedProof, onchainOutputIndexes) {
2703
+ const proof = Transaction.fromPSBT(base64.decode(signedProof));
2704
+ const onchain = new Set(onchainOutputIndexes);
2705
+ const declared = [];
2706
+ for (let i = 0; i < proof.outputsLength; i++) {
2707
+ const output = proof.getOutput(i);
2708
+ if (!output?.script || output.script.length === 0 || !output.amount) continue;
2709
+ declared.push({
2710
+ index: i,
2711
+ script: output.script,
2712
+ amount: output.amount,
2713
+ onchain: onchain.has(i)
2714
+ });
2715
+ }
2716
+ return declared;
2717
+ }
2718
+ function validateBatchAgainstIntent(commitmentTx, vtxoTreeLeaves, declared) {
2719
+ const usedOnchain = /* @__PURE__ */ new Set();
2720
+ const usedLeaf = /* @__PURE__ */ new Set();
2721
+ for (const output of declared) {
2722
+ if (output.onchain) {
2723
+ if (!takeOnchainOutput(commitmentTx, output, usedOnchain)) {
2724
+ throw ErrIntentOutputNotFound(output.index, "onchain");
2725
+ }
2726
+ continue;
2727
+ }
2728
+ if (!takeLeafOutput(vtxoTreeLeaves, output, usedLeaf)) {
2729
+ throw ErrIntentOutputNotFound(output.index, "offchain");
2730
+ }
2731
+ }
2732
+ }
2733
+ function validateBatchAgainstIntentWithoutTree(commitmentTx, declared) {
2734
+ const usedOnchain = /* @__PURE__ */ new Set();
2735
+ for (const output of declared) {
2736
+ if (!output.onchain) {
2737
+ throw ErrUnvalidatedIntentOutput(output.index);
2738
+ }
2739
+ if (!takeOnchainOutput(commitmentTx, output, usedOnchain)) {
2740
+ throw ErrIntentOutputNotFound(output.index, "onchain");
2741
+ }
2742
+ }
2743
+ }
2744
+ function takeOnchainOutput(commitmentTx, declared, used) {
2745
+ for (let i = 0; i < commitmentTx.outputsLength; i++) {
2746
+ if (used.has(i)) continue;
2747
+ const output = commitmentTx.getOutput(i);
2748
+ if (!output?.script || output.amount !== declared.amount) continue;
2749
+ if (!equalBytes(output.script, declared.script)) continue;
2750
+ used.add(i);
2751
+ return true;
2752
+ }
2753
+ return false;
2754
+ }
2755
+ function takeLeafOutput(leaves, declared, used) {
2756
+ for (let leafIdx = 0; leafIdx < leaves.length; leafIdx++) {
2757
+ const leaf = leaves[leafIdx];
2758
+ for (let i = 0; i < leaf.outputsLength; i++) {
2759
+ const key = `${leafIdx}:${i}`;
2760
+ if (used.has(key)) continue;
2761
+ const output = leaf.getOutput(i);
2762
+ if (!output?.script || output.amount !== declared.amount) continue;
2763
+ if (!equalBytes(output.script, declared.script)) continue;
2764
+ used.add(key);
2765
+ return true;
2766
+ }
2767
+ }
2768
+ return false;
2769
+ }
2696
2770
  function validateOnchainRecipient(commitmentTx, recipient, network, usedOutputs) {
2697
2771
  const addr = Address(network).decode(recipient.address);
2698
2772
  const expectedPkScript = OutScript.encode(addr);
@@ -3455,21 +3529,38 @@ function assertSubmittedArkTxid(response, signedArkTx, context) {
3455
3529
  );
3456
3530
  }
3457
3531
  }
3458
- function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeyHex, context) {
3532
+ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeys, context) {
3459
3533
  const leaf = localTx.getInput(inputIndex).tapLeafScript?.[0];
3460
3534
  if (!leaf) {
3461
3535
  throw new Error(
3462
3536
  `${context}: input ${inputIndex} carries no spend leaf to verify the server signature against`
3463
3537
  );
3464
3538
  }
3539
+ const script = scriptFromTapLeafScript(leaf);
3540
+ let leafPubkeys;
3541
+ try {
3542
+ leafPubkeys = decodeTapscript(script).params.pubkeys.map(
3543
+ (key) => hex.encode(toXOnly(key, "leaf key"))
3544
+ );
3545
+ } catch (error) {
3546
+ throw new ServerResponseMismatchError(
3547
+ `${context}: input ${inputIndex} spend leaf cannot be decoded (${error instanceof Error ? error.message : String(error)})`
3548
+ );
3549
+ }
3550
+ const signer = leafPubkeys.find((key) => serverPubkeys.has(key));
3551
+ if (!signer) {
3552
+ throw new ServerResponseMismatchError(
3553
+ `${context}: input ${inputIndex} spend leaf names no signer key the server advertises`
3554
+ );
3555
+ }
3465
3556
  try {
3466
3557
  verifyTapscriptSignatures(
3467
3558
  serverTx,
3468
3559
  inputIndex,
3469
- [serverPubkeyHex],
3560
+ [signer],
3470
3561
  void 0,
3471
3562
  void 0,
3472
- tapLeafHash(scriptFromTapLeafScript(leaf))
3563
+ tapLeafHash(script)
3473
3564
  );
3474
3565
  } catch (error) {
3475
3566
  throw new ServerResponseMismatchError(
@@ -3543,24 +3634,22 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
3543
3634
  );
3544
3635
  }
3545
3636
  const finalArkTx = Transaction.fromPSBT(base64.decode(response.finalArkTx));
3546
- const serverPubkeyHex = hex.encode(toXOnly(verify.serverPubkey, "server key"));
3637
+ const serverPubkeys = new Set(
3638
+ [verify.serverPubkey, ...verify.deprecatedServerPubkeys ?? []].map(
3639
+ (key) => hex.encode(toXOnly(key, "server key"))
3640
+ )
3641
+ );
3547
3642
  for (let i = 0; i < offchainTx.arkTx.inputsLength; i++) {
3548
3643
  assertServerSignedLeaf(
3549
3644
  finalArkTx,
3550
3645
  offchainTx.arkTx,
3551
3646
  i,
3552
- serverPubkeyHex,
3647
+ serverPubkeys,
3553
3648
  "submitTx ark tx"
3554
3649
  );
3555
3650
  }
3556
3651
  matched.forEach(
3557
- ({ server, local }, index) => assertServerSignedLeaf(
3558
- server,
3559
- local,
3560
- 0,
3561
- serverPubkeyHex,
3562
- `submitTx checkpoint ${index}`
3563
- )
3652
+ ({ server, local }, index) => assertServerSignedLeaf(server, local, 0, serverPubkeys, `submitTx checkpoint ${index}`)
3564
3653
  );
3565
3654
  }
3566
3655
  let finalCheckpoints;
@@ -7583,12 +7672,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
7583
7672
  if (!expiryTimestamp || expiryTimestamp === Number.MAX_SAFE_INTEGER) {
7584
7673
  delegateAt = new Date(Date.now() + 1 * 60 * 1e3);
7585
7674
  } else {
7586
- const remainingTimeMs = expiryTimestamp - Date.now();
7587
- if (remainingTimeMs <= 0) {
7588
- delegateAt = new Date(Date.now() + 1 * 60 * 1e3);
7589
- } else {
7590
- delegateAt = new Date(expiryTimestamp - remainingTimeMs * 0.1);
7591
- }
7675
+ delegateAt = defaultDelegateAt(expiryTimestamp, arkInfo.sessionDuration);
7592
7676
  }
7593
7677
  }
7594
7678
  const { fees, dust, forfeitAddress, network } = arkInfo;
@@ -7748,6 +7832,14 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
7748
7832
  message
7749
7833
  };
7750
7834
  }
7835
+ function defaultDelegateAt(expiryTimestamp, sessionDurationSeconds, now = Date.now()) {
7836
+ const remainingTimeMs = expiryTimestamp - now;
7837
+ if (remainingTimeMs <= 0) return new Date(now + 6e4);
7838
+ const sessionLeadMs = Number(sessionDurationSeconds * 1000n);
7839
+ const leadTimeMs = Math.max(remainingTimeMs * 0.1, sessionLeadMs);
7840
+ const delegateAt = expiryTimestamp - leadTimeMs;
7841
+ return new Date(delegateAt > now ? delegateAt : now + 2e3);
7842
+ }
7751
7843
  function findDestinationOutputIndex(outputs, destinationScript) {
7752
7844
  return outputs.findIndex((o) => o.script && equalBytes(o.script, destinationScript));
7753
7845
  }
@@ -15005,6 +15097,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15005
15097
  const connectorsLeaves = connectorsGraph?.leaves() || [];
15006
15098
  for (const input of inputs) {
15007
15099
  if (!isVirtualCoin(input)) {
15100
+ let matched = false;
15008
15101
  for (let i = 0; i < settlementPsbt.inputsLength; i++) {
15009
15102
  const settlementInput = settlementPsbt.getInput(i);
15010
15103
  if (!settlementInput.txid || settlementInput.index === void 0) {
@@ -15031,8 +15124,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15031
15124
  throw new Error(await this.unsignableBoardingInputError(input, script));
15032
15125
  }
15033
15126
  hasBoardingUtxos = true;
15127
+ matched = true;
15034
15128
  break;
15035
15129
  }
15130
+ if (!matched && !(input instanceof ArkNote)) {
15131
+ throw new Error(
15132
+ `boarding input ${input.txid}:${input.vout} is not an input of the commitment tx`
15133
+ );
15134
+ }
15036
15135
  continue;
15037
15136
  }
15038
15137
  if (canRecoverOnchain(input, { timestamp: /* @__PURE__ */ new Date() }) || isSubdust({ value: input.value }, this.dustAmount)) {
@@ -16173,18 +16272,33 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16173
16272
  this.inputSigningJobsFromWitnessUtxos(checkpoint)
16174
16273
  )
16175
16274
  };
16176
- return submitOffchainTx(this.arkProvider, offchainTx, signer, {
16177
- // Mark pending before submitting — if we crash between submit and
16178
- // finalize, the next init recovers via finalizePendingTxs.
16179
- beforeSubmit: () => this.setPendingTxFlag(true),
16180
- afterFinalize: async () => {
16181
- try {
16182
- await this.setPendingTxFlag(false);
16183
- } catch (error) {
16184
- console.error("Failed to clear pending tx flag:", error);
16275
+ return submitOffchainTx(
16276
+ this.arkProvider,
16277
+ offchainTx,
16278
+ signer,
16279
+ {
16280
+ // Mark pending before submitting — if we crash between submit and
16281
+ // finalize, the next init recovers via finalizePendingTxs.
16282
+ beforeSubmit: () => this.setPendingTxFlag(true),
16283
+ afterFinalize: async () => {
16284
+ try {
16285
+ await this.setPendingTxFlag(false);
16286
+ } catch (error) {
16287
+ console.error("Failed to clear pending tx flag:", error);
16288
+ }
16289
+ }
16290
+ },
16291
+ {
16292
+ // Deprecated keys too: a vtxo built before a rotation is still
16293
+ // spent under the signer its leaf names.
16294
+ verifyServerSignatures: {
16295
+ serverPubkey: this._arkServerPublicKey,
16296
+ deprecatedServerPubkeys: [...this._deprecatedSigners.keys()].map(
16297
+ (h) => hex.decode(h)
16298
+ )
16185
16299
  }
16186
16300
  }
16187
- });
16301
+ );
16188
16302
  }
16189
16303
  // mark virtual outputs as spent, save change outputs if any.
16190
16304
  // `offchainTapscript` and `serverPubKey` are the epoch snapshot the
@@ -22947,6 +23061,12 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
22947
23061
  validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
22948
23062
  if (recipients && recipients.length > 0) {
22949
23063
  validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
23064
+ } else {
23065
+ validateBatchAgainstIntent(
23066
+ commitmentTx,
23067
+ vtxoTree.leaves(),
23068
+ declaredIntentOutputs(signedProof, message.onchain_output_indexes)
23069
+ );
22950
23070
  }
22951
23071
  const sharedOutput = commitmentTx.getOutput(0);
22952
23072
  if (!sharedOutput?.amount) {
@@ -22981,8 +23101,15 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
22981
23101
  validatedCommitmentTxid,
22982
23102
  "arkade batch finalization"
22983
23103
  );
22984
- if (!validatedCommitmentTxid && recipients && recipients.length > 0) {
22985
- validateBatchRecipientsWithoutTree(commitmentPsbt, recipients, network);
23104
+ if (!validatedCommitmentTxid) {
23105
+ if (recipients && recipients.length > 0) {
23106
+ validateBatchRecipientsWithoutTree(commitmentPsbt, recipients, network);
23107
+ } else {
23108
+ validateBatchAgainstIntentWithoutTree(
23109
+ commitmentPsbt,
23110
+ declaredIntentOutputs(signedProof, message.onchain_output_indexes)
23111
+ );
23112
+ }
22986
23113
  }
22987
23114
  const signedForfeits = [];
22988
23115
  let connectorIndex = 0;
@@ -24003,5 +24130,5 @@ function createDefaultPaymentRouter(wallet) {
24003
24130
  */
24004
24131
 
24005
24132
  export { ARKADE_MAGIC, ARKADE_SALTED_PREIMAGE_TAG, ARKADE_SWAP_PREIMAGE_TAG, ASSET_CARRIER_SATS, AbortError, ActivityRegistry, AmbiguousRouteError, ArkNote, ArkadeCash, ArkadeCashCreateError, AssetManager, BIP21, BIP21Error, BIP322, BLOCKED_UPGRADE_TIMEOUT_MS, Batch, CachingArkProvider, ChainedTxType, ConnectionDisposedError, ContractManager, ContractWatcher, DEFAULT_MESSAGE_TIMEOUTS, DEFAULT_MIN_BATCH_EXPIRY_SECONDS, DEFAULT_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, DatabaseUpgradeBlockedError, DelegateManagerImpl, DelegateNotConfiguredError, DescriptorIdentity, DescriptorSigningProviderMissingError, DustChangeError, ELECTRUM_TCP_HOST, ELECTRUM_WS_URL, ESPLORA_URL, ElectrumOnchainProvider, EmulatorPacket, EsploraProvider, Estimator, Extension, ExtensionNotFoundError, ForeignDescriptorError, HDDescriptorProvider, INTENT_TERMINAL_STATES, InMemoryContractRepository, InMemoryIntentRepository, InMemoryVirtualTxRepository, InMemoryWalletRepository, IndexedDBContractRepository, IndexedDBIntentRepository, IndexedDBVirtualTxRepository, IndexedDBWalletRepository, MAX_USED_SIGNING_DESCRIPTORS_LOOK_AHEAD, MESSAGE_BUS_INITIALIZING, MESSAGE_BUS_NOT_INITIALIZED, MUTINYNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, MessageBus, MessageBusInitializingError, MessageBusNotInitializedError, MissingSigningDescriptorError, MnemonicIdentity, OnchainWallet, P2A, PaymentRouter, PrevTxUnavailableError, REGTEST_MIN_BATCH_EXPIRY_SECONDS, REGTEST_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, Ramps, ReadonlyAssetManager, ReadonlyDescriptorIdentity, ReadonlySingleKey, ReadonlyWallet, ReadonlyWalletError, RestDelegateProvider, RestEmulatorProvider, SIGNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, SeedIdentity, ServiceWorkerReadonlyWallet, ServiceWorkerTimeoutError, ServiceWorkerWallet, SingleKey, TxTree, TxType, TxWeightEstimator, UnannotatableInputError, UnilateralExit, UnknownPacket, Unroll, VtxoManager, Wallet2 as Wallet, WalletCannotAllocateAddressError, WalletCannotSignError, WalletMessageHandler, WalletNotInitializedError, WsElectrumChainSource, adoptContractDescriptor, arkAssetRail, arkRail, arkTarget, arkade_exports, assertFinalCommitmentMatchesValidated, assertIntentIdUnique, assertNoAssets, assertRecipientArkadeAddress, assertSendableAmount, assertSubmittedArkTxid, assertValidBatchExpiry, assertValidServerUnrollScript, assetMintResolver, assetsOf, attachPrevArkTxs, attachPrevoutTxs, awaitTransaction, boardingResolver, btcTarget, buildForfeitTx, buildOffchainTx, buildPreimageMessage, buildSaltedPreimageMessage, claimWithPreimageIdentity, classifyAgainstSignerSet, classifyContractSigner, closeDatabase, collabExitResolver, combineTapscriptSigs, contractFromArkContract, contractFromArkContractWithAddress, contractPreimage, contractSigner, createAssetPacket, createDefaultActivityRegistry, createDefaultPaymentRouter, createExitChainResolver, createManagedConnection, decodeArkContract, defaultBatchExpiryPolicy, defaultCheckpointExitDelayPolicy, deleteByIndex, deserializeAssets, deserializeExitPackage, deserializeUtxo, deserializeVtxo, encodeArkContract, exitObserverFor, extendVirtualCoinForContract, extractArkProviderUrl, gateExclusion, gatedContracts, getAllByIndexValues, getRandomId, hasBoardingTxExpired, hasCandidates, intentMatchesFilter, intentPageBounds, invoiceTarget, isAddressAllocationCapable, isArkContract, isBatchSignable, isBtcAddress, isContractGenericallySpendable, isContractVtxoEvent, isCooperativelyMigratable, isDeterministicSigner, isDiscoverable, isHDAllocationCapable, isHDDeterministicSignCapable, isHDWalletCapable, isLightningInvoice, isLnurl, isMessageBusInitializingError, isMessageBusNotInitializedError, isPerArtifactDescriptor, isSigningIdentity, isSubdust, isTerminalIntentState, isValidArkAddress, isVtxoExpiringSoon, isVtxoForScript, isWatchedContract, legacyVtxoFacts, logExcludedVtxos, makeHandle, matchServerCheckpoints, mergeChainedTxType, notifyExitObserved, onchainRail, openDatabase, outpointExclusion, outpointReasons, promisifyRequest, provisionClaimSecret, provisionRefundKey, registerWalletRestoreHook, resolveAssetAmount, resolveBatchExpiryPolicy, resolveCheckpointExitDelayPolicy, resolveDescriptorSigner, resolvePrevTxs, resolveSendAmount, saveVtxosForContract, scriptFromArkAddress, selectCoinsWithAsset, selectVirtualCoins, serializeAssets, serializeExitPackage, serializeUtxo, serializeVtxo, setupServiceWorker, signAndSubmitOffchainTx, signerSetFromInfo, signingDescriptorIndex, strictSigningDescriptorIndex, toXOnlySignerHex, tryResolveSendAmount, validateBatchRecipients, validateConnectorsTxGraph, validateVtxoTxGraph, verifyTapscriptSignatures, waitForIncomingFunds, walletFeeSource, warnAndFilterVtxosForScript, withPrevTxs };
24006
- //# sourceMappingURL=chunk-LN4ZJZK4.js.map
24007
- //# sourceMappingURL=chunk-LN4ZJZK4.js.map
24133
+ //# sourceMappingURL=chunk-3TCWQPAC.js.map
24134
+ //# sourceMappingURL=chunk-3TCWQPAC.js.map