@arkade-os/sdk 0.4.77 → 0.4.79

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 (76) hide show
  1. package/README.md +1 -1
  2. package/dist/adapters/expo.cjs +5 -5
  3. package/dist/adapters/expo.d.cts +3 -3
  4. package/dist/adapters/expo.d.ts +3 -3
  5. package/dist/adapters/expo.js +3 -3
  6. package/dist/{asyncStorageTaskQueue-DTl0WM7E.d.ts → asyncStorageTaskQueue-C5yQLJhm.d.ts} +2 -2
  7. package/dist/{asyncStorageTaskQueue-MmJyAnu-.d.cts → asyncStorageTaskQueue-Shsih-1l.d.cts} +2 -2
  8. package/dist/{chunk-ACPANSOX.js → chunk-4MXW2NDN.js} +10 -515
  9. package/dist/chunk-4MXW2NDN.js.map +1 -0
  10. package/dist/{chunk-Y4YK44IM.cjs → chunk-54FXLZ3T.cjs} +10 -10
  11. package/dist/{chunk-Y4YK44IM.cjs.map → chunk-54FXLZ3T.cjs.map} +1 -1
  12. package/dist/{chunk-CJN4CUEU.cjs → chunk-DAYCCIRO.cjs} +377 -198
  13. package/dist/chunk-DAYCCIRO.cjs.map +1 -0
  14. package/dist/{chunk-LUWSY2QO.cjs → chunk-FUW3OM5X.cjs} +76 -561
  15. package/dist/chunk-FUW3OM5X.cjs.map +1 -0
  16. package/dist/{chunk-YJEWWLOQ.cjs → chunk-HAM3SHBV.cjs} +650 -548
  17. package/dist/chunk-HAM3SHBV.cjs.map +1 -0
  18. package/dist/{chunk-52OA3UIC.js → chunk-JCPVP7TJ.js} +377 -201
  19. package/dist/chunk-JCPVP7TJ.js.map +1 -0
  20. package/dist/{chunk-4LP6XOMW.cjs → chunk-LASRYLMQ.cjs} +17 -17
  21. package/dist/{chunk-4LP6XOMW.cjs.map → chunk-LASRYLMQ.cjs.map} +1 -1
  22. package/dist/{chunk-HKOFYHZP.js → chunk-QDXOTONI.js} +3 -3
  23. package/dist/{chunk-HKOFYHZP.js.map → chunk-QDXOTONI.js.map} +1 -1
  24. package/dist/{chunk-H62OOAS4.cjs → chunk-SJPPBR2V.cjs} +17 -17
  25. package/dist/{chunk-H62OOAS4.cjs.map → chunk-SJPPBR2V.cjs.map} +1 -1
  26. package/dist/{chunk-T6MGH4V4.js → chunk-SK4OZRMB.js} +4 -4
  27. package/dist/{chunk-T6MGH4V4.js.map → chunk-SK4OZRMB.js.map} +1 -1
  28. package/dist/{chunk-YKNTUOUG.js → chunk-VAFNWP3I.js} +4 -4
  29. package/dist/{chunk-YKNTUOUG.js.map → chunk-VAFNWP3I.js.map} +1 -1
  30. package/dist/{chunk-MLOZHTBN.js → chunk-YPQ37P3H.js} +210 -108
  31. package/dist/chunk-YPQ37P3H.js.map +1 -0
  32. package/dist/contracts/handlers/index.cjs +9 -9
  33. package/dist/contracts/handlers/index.d.cts +4 -4
  34. package/dist/contracts/handlers/index.d.ts +4 -4
  35. package/dist/contracts/handlers/index.js +2 -2
  36. package/dist/{delegate-QPCGaD_z.d.cts → delegate-B4bKASut.d.cts} +1 -1
  37. package/dist/{delegate-CjcysR7s.d.ts → delegate-C9lpdrb0.d.ts} +1 -1
  38. package/dist/{hdWalletCapable--pMncWbC.d.ts → hdWalletCapable-CUJDKRKO.d.cts} +2 -3
  39. package/dist/{hdWalletCapable-Bp_p0WLj.d.cts → hdWalletCapable-DJClhYMC.d.ts} +2 -3
  40. package/dist/{index-Ie_ak2zY.d.ts → index-Ctul0N3Y.d.cts} +28 -6
  41. package/dist/{index-Ie_ak2zY.d.cts → index-Ctul0N3Y.d.ts} +28 -6
  42. package/dist/{index-m-EM-e8D.d.ts → index-D0qe2qVY.d.ts} +2 -2
  43. package/dist/{index-BMY272ns.d.cts → index-YBFmScVS.d.cts} +2 -2
  44. package/dist/index.cjs +304 -304
  45. package/dist/index.d.cts +123 -123
  46. package/dist/index.d.ts +123 -123
  47. package/dist/index.js +4 -4
  48. package/dist/repositories/realm/index.cjs +20 -20
  49. package/dist/repositories/realm/index.d.cts +3 -3
  50. package/dist/repositories/realm/index.d.ts +3 -3
  51. package/dist/repositories/realm/index.js +5 -5
  52. package/dist/repositories/sqlite/index.cjs +19 -19
  53. package/dist/repositories/sqlite/index.d.cts +3 -3
  54. package/dist/repositories/sqlite/index.d.ts +3 -3
  55. package/dist/repositories/sqlite/index.js +5 -5
  56. package/dist/{taskRunner-CqrlrJEt.d.ts → taskRunner-C08egG5a.d.ts} +2 -2
  57. package/dist/{taskRunner-BgRowCqB.d.cts → taskRunner-DB17db5n.d.cts} +2 -2
  58. package/dist/wallet/expo/background.cjs +14 -14
  59. package/dist/wallet/expo/background.d.cts +4 -4
  60. package/dist/wallet/expo/background.d.ts +4 -4
  61. package/dist/wallet/expo/background.js +6 -6
  62. package/dist/wallet/expo/index.cjs +14 -14
  63. package/dist/wallet/expo/index.d.cts +5 -5
  64. package/dist/wallet/expo/index.d.ts +5 -5
  65. package/dist/wallet/expo/index.js +5 -5
  66. package/dist/worker/expo/index.cjs +9 -9
  67. package/dist/worker/expo/index.d.cts +5 -5
  68. package/dist/worker/expo/index.d.ts +5 -5
  69. package/dist/worker/expo/index.js +5 -5
  70. package/package.json +6 -5
  71. package/dist/chunk-52OA3UIC.js.map +0 -1
  72. package/dist/chunk-ACPANSOX.js.map +0 -1
  73. package/dist/chunk-CJN4CUEU.cjs.map +0 -1
  74. package/dist/chunk-LUWSY2QO.cjs.map +0 -1
  75. package/dist/chunk-MLOZHTBN.js.map +0 -1
  76. package/dist/chunk-YJEWWLOQ.cjs.map +0 -1
@@ -1,16 +1,16 @@
1
- import { AssetId, AssetGroup, AssetInput, AssetOutput, Metadata, Packet, BufferReader, BufferWriter, AssetRef, RestIndexerProvider } from './chunk-HKOFYHZP.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-ACPANSOX.js';
3
- import { VtxoScript, Transaction, isRecoverable, CSVMultisigTapscript, networks, getNetwork, DEFAULT_NETWORK, resolveEmulatorPubkey, isVtxoSpent, 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, toBatchExpiry, maybeArkError, isArkError, ArkErrorName, toOffchainInputFeeParams, canRecoverOnchain, MultisigTapscript, isEventSourceError, isEventSourceUnavailableError, getAllNormalizedVtxos, isPastExpiry, isRetryableProviderError, DEFAULT_PAGE_SIZE, RestArkProvider, toVirtualStatus, ArkError, TapTreeCoder, resolveTimeHeight, canSpendOffchain, parseLegacyExpiry, isExpired, PrevoutTxField, fetchVtxoCreatedAtByTxid, DEFAULT_ARKADE_SERVER_URL, ProviderUnavailableError } from './chunk-52OA3UIC.js';
1
+ import { AssetId, AssetGroup, AssetInput, AssetOutput, Metadata, Packet, BufferReader, BufferWriter, AssetRef, RestIndexerProvider } from './chunk-QDXOTONI.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-4MXW2NDN.js';
3
+ import { VtxoScript, Transaction, requiresForfeit, CSVMultisigTapscript, networks, getNetwork, DEFAULT_NETWORK, resolveEmulatorPubkey, isVtxoSpent, getNormalizedVtxos, setArkPsbtField, PrevArkTxField, ConditionWitness, craftToSpendTx, ArkAddress, isVirtualCoin, getArkPsbtFields, CosignerPublicKey, ServerResponseMismatchError, OP_RETURN_EMPTY_PKSCRIPT, canSweepOnchain, sequenceToTimelock, timelockToSequence, decodeTapscript, scriptFromTapLeafScript, CLTVMultisigTapscript, VtxoTaprootTree, assertAllowedSighashTypes, baseFetch, Intent, rateGate, DEFAULT_NETWORK_NAME, formatSighash, normalizeVtxo, getSequence, toBatchExpiry, maybeArkError, isArkError, ArkErrorName, toOffchainInputFeeParams, canRecoverOnchain, MultisigTapscript, isEventSourceError, isEventSourceUnavailableError, getAllNormalizedVtxos, isPastExpiry, isRetryableProviderError, DEFAULT_PAGE_SIZE, RestArkProvider, toVirtualStatus, ArkError, toBIP371TapTree, resolveTimeHeight, canSpendOffchain, parseLegacyExpiry, isRecoverable, isExpired, PrevoutTxField, fetchVtxoCreatedAtByTxid, DEFAULT_ARKADE_SERVER_URL, ProviderUnavailableError } from './chunk-JCPVP7TJ.js';
4
4
  import { __export } from './chunk-NSBPE2FW.js';
5
5
  import { sha256 as sha256$1, equalBytes, hash160, sha256x2, concatBytes, randomPrivateKeyBytes, pubECDSA, pubSchnorr } from '@scure/btc-signer/utils.js';
6
- import { SigHash, Script, OP, OutScript, Address, RawWitness, p2tr, p2wpkh, TaprootControlBlock, DEFAULT_SEQUENCE, Transaction as Transaction$2 } from '@scure/btc-signer';
6
+ import { SigHash, Script, OP, OutScript, Address, RawWitness, p2tr, p2wpkh, TaprootControlBlock, DEFAULT_SEQUENCE, Transaction as Transaction$1 } from '@scure/btc-signer';
7
7
  import { hex, base58, base64, bech32m } from '@scure/base';
8
8
  import * as musig2 from '@scure/btc-signer/musig2.js';
9
9
  import { equalBytes as equalBytes$1, bytesToNumberBE } from '@noble/curves/utils.js';
10
10
  import { signAsync, schnorr as schnorr$1, Point } from '@noble/secp256k1';
11
11
  import { secp256k1, schnorr } from '@noble/curves/secp256k1.js';
12
12
  import { Script as Script$1 } from '@scure/btc-signer/script.js';
13
- import { Transaction as Transaction$1, SigHash as SigHash$1 } from '@scure/btc-signer/transaction.js';
13
+ import { SigHash as SigHash$1 } from '@scure/btc-signer/transaction.js';
14
14
  import { mnemonicToSeedSync, validateMnemonic } from '@scure/bip39';
15
15
  import { wordlist } from '@scure/bip39/wordlists/english.js';
16
16
  import { networks as networks$1, scriptExpressions, HDKey, expand } from '@bitcoinerlab/descriptors-scure';
@@ -954,33 +954,62 @@ function isAddressAllocationCapable(value) {
954
954
  return typeof value.getNewAddresses === "function";
955
955
  }
956
956
 
957
+ // ../../node_modules/@noble/hashes/_u64.js
958
+ var fromNumH = (n) => n / 2 ** 32 | 0;
959
+ var fromNumL = (n) => n >>> 0;
960
+ function setU64FromNum(view, byteOffset, n, isLE) {
961
+ const h = fromNumH(n);
962
+ const l = fromNumL(n);
963
+ view.setUint32(byteOffset, isLE ? l : h, isLE);
964
+ view.setUint32(byteOffset + 4, isLE ? h : l, isLE);
965
+ }
966
+
957
967
  // ../../node_modules/@noble/hashes/utils.js
958
968
  function isBytes(a) {
959
- return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
969
+ return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
970
+ }
971
+ var atitle = (title) => title ? `"${title}" ` : "";
972
+ function anumber(n, title = "") {
973
+ if (typeof n !== "number")
974
+ throw new TypeError(atitle(title) + "expected number, got " + typeof n);
975
+ if (!Number.isSafeInteger(n) || n < 0)
976
+ throw new RangeError(atitle(title) + "expected integer >= 0, got " + n);
977
+ return n;
960
978
  }
961
979
  function abytes(value, length, title = "") {
980
+ if (isBytes(value) && (length === void 0))
981
+ return value;
962
982
  const bytes = isBytes(value);
963
- const len = value?.length;
964
- const needsLen = length !== void 0;
965
- if (!bytes || needsLen) {
966
- const prefix = title && `"${title}" `;
967
- const ofLen = "";
968
- const got = bytes ? `length=${len}` : `type=${typeof value}`;
969
- throw new Error(prefix + "expected Uint8Array" + ofLen + ", got " + got);
970
- }
971
- return value;
972
- }
983
+ const ofLen = "";
984
+ const got = bytes ? `length=${value.length}` : `type=${typeof value}`;
985
+ const message = atitle(title) + "expected Uint8Array" + ofLen + ", got " + got;
986
+ if (!bytes)
987
+ throw new TypeError(message);
988
+ throw new RangeError(message);
989
+ }
990
+ var aobject = (value, label) => {
991
+ if (value === null || typeof value !== "object" || Array.isArray(value))
992
+ throw new TypeError((label === "object" ? "" : `"${label}" `) + "expected object, got type=" + typeof value);
993
+ };
994
+ var aopts = (value, label) => {
995
+ aobject(value, label);
996
+ const proto = Object.getPrototypeOf(value);
997
+ if (proto !== Object.prototype && proto !== null)
998
+ throw new TypeError(`"${label}" expected plain object`);
999
+ if (Object.hasOwn(value, "__proto__"))
1000
+ throw new TypeError(`"${label}.__proto__" is not allowed`);
1001
+ };
973
1002
  function aexists(instance, checkFinished = true) {
974
1003
  if (instance.destroyed)
975
- throw new Error("Hash instance has been destroyed");
1004
+ throw new Error("hash was destroyed");
976
1005
  if (checkFinished && instance.finished)
977
- throw new Error("Hash#digest() has already been called");
1006
+ throw new Error("digest() was already called");
978
1007
  }
979
1008
  function aoutput(out, instance) {
980
- abytes(out, void 0, "digestInto() output");
1009
+ abytes(out, void 0, "output");
981
1010
  const min = instance.outputLen;
982
- if (out.length < min) {
983
- throw new Error('"digestInto() output" expected to be of length >=' + min);
1011
+ if (!(out.length >= min)) {
1012
+ throw new RangeError('"output" expected length >= ' + min);
984
1013
  }
985
1014
  }
986
1015
  function clean(...arrays) {
@@ -994,22 +1023,38 @@ function createView(arr) {
994
1023
  function rotr(word, shift) {
995
1024
  return word << 32 - shift | word >>> shift;
996
1025
  }
1026
+ function checkOpts(defaults, opts, title = "opts") {
1027
+ aopts(defaults, "defaults");
1028
+ if (opts !== void 0)
1029
+ aopts(opts, title);
1030
+ const merged = Object.assign(/* @__PURE__ */ Object.create(null), defaults, opts);
1031
+ return merged;
1032
+ }
997
1033
  function createHasher(hashCons, info = {}) {
1034
+ if (typeof hashCons !== "function")
1035
+ throw new TypeError('"hashCons" expected function, got type=' + typeof hashCons);
1036
+ info = checkOpts({}, info, "info");
998
1037
  const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
999
1038
  const tmp = hashCons(void 0);
1000
1039
  hashC.outputLen = tmp.outputLen;
1001
1040
  hashC.blockLen = tmp.blockLen;
1041
+ hashC.canXOF = tmp.canXOF;
1002
1042
  hashC.create = (opts) => hashCons(opts);
1003
1043
  Object.assign(hashC, info);
1004
1044
  return Object.freeze(hashC);
1005
1045
  }
1006
1046
  function randomBytes(bytesLength = 32) {
1047
+ anumber(bytesLength, "bytesLength");
1007
1048
  const cr = typeof globalThis === "object" ? globalThis.crypto : null;
1008
1049
  if (typeof cr?.getRandomValues !== "function")
1009
1050
  throw new Error("crypto.getRandomValues must be defined");
1051
+ if (bytesLength > 65536)
1052
+ throw new RangeError(`"bytesLength" expected <= 65536, got ${bytesLength}`);
1010
1053
  return cr.getRandomValues(new Uint8Array(bytesLength));
1011
1054
  }
1012
1055
  var oidNist = (suffix) => ({
1056
+ // Current NIST hashAlgs suffixes used here fit in one DER subidentifier octet.
1057
+ // Larger suffix values would need base-128 OID encoding and a different length byte.
1013
1058
  oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
1014
1059
  });
1015
1060
 
@@ -1023,6 +1068,7 @@ function Maj(a, b, c) {
1023
1068
  var HashMD = class {
1024
1069
  blockLen;
1025
1070
  outputLen;
1071
+ canXOF = false;
1026
1072
  padOffset;
1027
1073
  isLE;
1028
1074
  // For partial updates less than block size
@@ -1045,24 +1091,28 @@ var HashMD = class {
1045
1091
  abytes(data);
1046
1092
  const { view, buffer, blockLen } = this;
1047
1093
  const len = data.length;
1094
+ let processed = false;
1048
1095
  for (let pos = 0; pos < len; ) {
1049
1096
  const take = Math.min(blockLen - this.pos, len - pos);
1050
1097
  if (take === blockLen) {
1051
1098
  const dataView = createView(data);
1052
1099
  for (; blockLen <= len - pos; pos += blockLen)
1053
1100
  this.process(dataView, pos);
1101
+ processed = true;
1054
1102
  continue;
1055
1103
  }
1056
- buffer.set(data.subarray(pos, pos + take), this.pos);
1104
+ buffer.set(pos === 0 && take === len ? data : data.subarray(pos, pos + take), this.pos);
1057
1105
  this.pos += take;
1058
1106
  pos += take;
1059
1107
  if (this.pos === blockLen) {
1060
1108
  this.process(view, 0);
1061
1109
  this.pos = 0;
1110
+ processed = true;
1062
1111
  }
1063
1112
  }
1064
1113
  this.length += data.length;
1065
- this.roundClean();
1114
+ if (processed)
1115
+ this.roundClean();
1066
1116
  return this;
1067
1117
  }
1068
1118
  digestInto(out) {
@@ -1072,23 +1122,20 @@ var HashMD = class {
1072
1122
  const { buffer, view, blockLen, isLE } = this;
1073
1123
  let { pos } = this;
1074
1124
  buffer[pos++] = 128;
1075
- clean(this.buffer.subarray(pos));
1125
+ buffer.fill(0, pos);
1076
1126
  if (this.padOffset > blockLen - pos) {
1077
1127
  this.process(view, 0);
1078
- pos = 0;
1128
+ buffer.fill(0);
1079
1129
  }
1080
- for (let i = pos; i < blockLen; i++)
1081
- buffer[i] = 0;
1082
- view.setBigUint64(blockLen - 8, BigInt(this.length * 8), isLE);
1130
+ setU64FromNum(view, blockLen - 8, this.length * 8, isLE);
1083
1131
  this.process(view, 0);
1084
- const oview = createView(out);
1132
+ this.roundClean();
1133
+ const oview = out === buffer ? view : createView(out);
1085
1134
  const len = this.outputLen;
1086
- if (len % 4)
1087
- throw new Error("_sha2: outputLen must be aligned to 32bit");
1088
1135
  const outLen = len / 4;
1089
1136
  const state = this.get();
1090
- if (outLen > state.length)
1091
- throw new Error("_sha2: outputLen bigger than state");
1137
+ if (len % 4 || outLen > state.length)
1138
+ throw new Error("invalid outputLen");
1092
1139
  for (let i = 0; i < outLen; i++)
1093
1140
  oview.setUint32(4 * i, state[i], isLE);
1094
1141
  }
@@ -1099,15 +1146,13 @@ var HashMD = class {
1099
1146
  this.destroy();
1100
1147
  return res;
1101
1148
  }
1102
- _cloneInto(to) {
1103
- to ||= new this.constructor();
1104
- to.set(...this.get());
1105
- const { blockLen, buffer, length, finished, destroyed, pos } = this;
1149
+ _cloneIntoMeta(to) {
1150
+ const { buffer, length, finished, destroyed, pos } = this;
1106
1151
  to.destroyed = destroyed;
1107
1152
  to.finished = finished;
1108
1153
  to.length = length;
1109
1154
  to.pos = pos;
1110
- if (length % blockLen)
1155
+ if (pos)
1111
1156
  to.buffer.set(buffer);
1112
1157
  return to;
1113
1158
  }
@@ -1195,8 +1240,28 @@ var SHA256_K = /* @__PURE__ */ Uint32Array.from([
1195
1240
  ]);
1196
1241
  var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
1197
1242
  var SHA2_32B = class extends HashMD {
1198
- constructor(outputLen) {
1243
+ // We cannot use array here since array allows indexing by variable
1244
+ // which means optimizer/compiler cannot use registers.
1245
+ // Numeric initializers matter: starting the fields as `undefined` changes
1246
+ // V8's field representation and makes sha256 3x slower (measured).
1247
+ A = 0;
1248
+ B = 0;
1249
+ C = 0;
1250
+ D = 0;
1251
+ E = 0;
1252
+ F = 0;
1253
+ G = 0;
1254
+ H = 0;
1255
+ constructor(outputLen, IV) {
1199
1256
  super(64, outputLen, 8, false);
1257
+ this.A = IV[0] | 0;
1258
+ this.B = IV[1] | 0;
1259
+ this.C = IV[2] | 0;
1260
+ this.D = IV[3] | 0;
1261
+ this.E = IV[4] | 0;
1262
+ this.F = IV[5] | 0;
1263
+ this.G = IV[6] | 0;
1264
+ this.H = IV[7] | 0;
1200
1265
  }
1201
1266
  get() {
1202
1267
  const { A, B, C, D, E, F, G, H } = this;
@@ -1213,6 +1278,10 @@ var SHA2_32B = class extends HashMD {
1213
1278
  this.G = G | 0;
1214
1279
  this.H = H | 0;
1215
1280
  }
1281
+ _cloneInto(to) {
1282
+ (to ||= new this.constructor()).set(...this.get());
1283
+ return this._cloneIntoMeta(to);
1284
+ }
1216
1285
  process(view, offset) {
1217
1286
  for (let i = 0; i < 16; i++, offset += 4)
1218
1287
  SHA256_W[i] = view.getUint32(offset, false);
@@ -1252,23 +1321,14 @@ var SHA2_32B = class extends HashMD {
1252
1321
  clean(SHA256_W);
1253
1322
  }
1254
1323
  destroy() {
1324
+ this.destroyed = true;
1255
1325
  this.set(0, 0, 0, 0, 0, 0, 0, 0);
1256
1326
  clean(this.buffer);
1257
1327
  }
1258
1328
  };
1259
1329
  var _SHA256 = class extends SHA2_32B {
1260
- // We cannot use array here since array allows indexing by variable
1261
- // which means optimizer/compiler cannot use registers.
1262
- A = SHA256_IV[0] | 0;
1263
- B = SHA256_IV[1] | 0;
1264
- C = SHA256_IV[2] | 0;
1265
- D = SHA256_IV[3] | 0;
1266
- E = SHA256_IV[4] | 0;
1267
- F = SHA256_IV[5] | 0;
1268
- G = SHA256_IV[6] | 0;
1269
- H = SHA256_IV[7] | 0;
1270
1330
  constructor() {
1271
- super(32);
1331
+ super(32, SHA256_IV);
1272
1332
  }
1273
1333
  };
1274
1334
  var sha256 = /* @__PURE__ */ createHasher(
@@ -2314,7 +2374,7 @@ function validateConnectorsTxGraph(settlementTxB64, connectorsGraph) {
2314
2374
  connectorsGraph.validate();
2315
2375
  if (connectorsGraph.root.inputsLength !== 1) throw ErrNumberOfInputs;
2316
2376
  const rootInput = connectorsGraph.root.getInput(0);
2317
- const settlementTx = Transaction$1.fromPSBT(base64.decode(settlementTxB64));
2377
+ const settlementTx = Transaction.fromPSBT(base64.decode(settlementTxB64));
2318
2378
  if (settlementTx.outputsLength <= BATCH_OUTPUT_CONNECTORS_INDEX)
2319
2379
  throw ErrInvalidSettlementTxOutputs;
2320
2380
  const expectedRootTxid = settlementTx.id;
@@ -5957,8 +6017,8 @@ function noteTapscript(preimageHash) {
5957
6017
  return Script.encode(["SHA256", preimageHash, "EQUAL"]);
5958
6018
  }
5959
6019
  var ArkadeCash = class _ArkadeCash {
5960
- constructor(privateKey, serverPubKey, csvTimelock, hrp = _ArkadeCash.DefaultHRP) {
5961
- this.csvTimelock = csvTimelock;
6020
+ constructor(privateKey, serverPubKey, csvTimelock2, hrp = _ArkadeCash.DefaultHRP) {
6021
+ this.csvTimelock = csvTimelock2;
5962
6022
  this.hrp = hrp;
5963
6023
  if (privateKey.length !== 32) {
5964
6024
  throw new Error(
@@ -5998,8 +6058,8 @@ var ArkadeCash = class _ArkadeCash {
5998
6058
  get publicKey() {
5999
6059
  return this._publicKey.slice();
6000
6060
  }
6001
- static generate(serverPubKey, csvTimelock, hrp) {
6002
- return new _ArkadeCash(randomPrivateKeyBytes(), serverPubKey, csvTimelock, hrp);
6061
+ static generate(serverPubKey, csvTimelock2, hrp) {
6062
+ return new _ArkadeCash(randomPrivateKeyBytes(), serverPubKey, csvTimelock2, hrp);
6003
6063
  }
6004
6064
  static fromString(encoded) {
6005
6065
  const decoded = bech32m.decodeUnsafe(encoded.trim().toLowerCase(), 1023);
@@ -6019,8 +6079,8 @@ var ArkadeCash = class _ArkadeCash {
6019
6079
  const privateKey = data.slice(1, 33);
6020
6080
  const serverPubKey = data.slice(33, 65);
6021
6081
  const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
6022
- const csvTimelock = sequenceToTimelock(sequence);
6023
- return new _ArkadeCash(privateKey, serverPubKey, csvTimelock, decoded.prefix);
6082
+ const csvTimelock2 = sequenceToTimelock(sequence);
6083
+ return new _ArkadeCash(privateKey, serverPubKey, csvTimelock2, decoded.prefix);
6024
6084
  }
6025
6085
  toString() {
6026
6086
  const data = new Uint8Array(_ArkadeCash.PayloadLength);
@@ -6935,7 +6995,7 @@ function buildGraph(rootTxid, chunksByTxid) {
6935
6995
  return new TxTree(rootTx, children);
6936
6996
  }
6937
6997
  function decodeNode(chunk) {
6938
- const tx = Transaction$1.fromPSBT(base64.decode(chunk.tx));
6998
+ const tx = Transaction.fromPSBT(base64.decode(chunk.tx));
6939
6999
  return { tx, children: chunk.children };
6940
7000
  }
6941
7001
  var Batch;
@@ -7803,7 +7863,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
7803
7863
  Address(getNetwork(network)).decode(forfeitAddress)
7804
7864
  );
7805
7865
  const forfeits = await Promise.all(
7806
- vtxos.filter((v) => !canRecoverOnchain(v, { timestamp: /* @__PURE__ */ new Date() })).map(async (coin) => {
7866
+ vtxos.filter((v) => requiresForfeit(v)).map(async (coin) => {
7807
7867
  const forfeit = await makeDelegateForfeitTx(
7808
7868
  coin,
7809
7869
  dust,
@@ -8703,9 +8763,10 @@ function validateVtxosForScript(vtxos, script, context) {
8703
8763
  `${context}: refusing to persist ${mismatches.length} VTXO(s) whose script does not match ${script}: ${detail}`
8704
8764
  );
8705
8765
  }
8706
- async function getVtxosForContract(repo, contract) {
8707
- const vtxos = repo.getVtxosForScript ? await repo.getVtxosForScript(contract.script) : filterVtxosForScript(await repo.getVtxos(contract.address), contract.script);
8708
- return vtxos.map(normalizeVtxo);
8766
+ async function getVtxosForContract(repo, contract, options) {
8767
+ const vtxos = options?.unspentOnly && repo.getVtxosForScripts ? await repo.getVtxosForScripts([contract.script], options) : repo.getVtxosForScript ? await repo.getVtxosForScript(contract.script) : filterVtxosForScript(await repo.getVtxos(contract.address), contract.script);
8768
+ const normalized = vtxos.map(normalizeVtxo);
8769
+ return options?.unspentOnly ? normalized.filter((vtxo) => !isVtxoSpent(vtxo)) : normalized;
8709
8770
  }
8710
8771
  function hasRecordedSpend(vtxo) {
8711
8772
  return vtxo.isSpent === true && (!!vtxo.spentBy || !!vtxo.arkTxId || !!vtxo.settledBy);
@@ -12523,7 +12584,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
12523
12584
  const pubKey = deriveLeafPubkey(descriptor);
12524
12585
  const tapscript = rebuildTapscript(current, pubKey);
12525
12586
  const serverPubKey = tapscript.options.serverPubKey;
12526
- const csvTimelock = timelockToSequence(tapscript.options.csvTimelock).toString();
12587
+ const csvTimelock2 = timelockToSequence(tapscript.options.csvTimelock).toString();
12527
12588
  const base = {
12528
12589
  script: hex.encode(tapscript.pkScript),
12529
12590
  address: tapscript.address(hrp, serverPubKey).encode(),
@@ -12545,7 +12606,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
12545
12606
  pubKey: hex.encode(pubKey),
12546
12607
  serverPubKey: hex.encode(serverPubKey),
12547
12608
  delegatePubKey: hex.encode(tapscript.options.delegatePubKey),
12548
- csvTimelock
12609
+ csvTimelock: csvTimelock2
12549
12610
  }
12550
12611
  } : {
12551
12612
  ...base,
@@ -12553,7 +12614,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
12553
12614
  params: {
12554
12615
  pubKey: hex.encode(pubKey),
12555
12616
  serverPubKey: hex.encode(serverPubKey),
12556
- csvTimelock
12617
+ csvTimelock: csvTimelock2
12557
12618
  }
12558
12619
  };
12559
12620
  return { tapscript, params };
@@ -12908,6 +12969,34 @@ function filterSnapshotVtxos(snapshot, filter, pendingSpendOutpoints) {
12908
12969
  return true;
12909
12970
  });
12910
12971
  }
12972
+ async function refreshSweptStateOfExpiredInputs(wallet, inputs) {
12973
+ const candidates = inputs.filter(isVirtualCoin).map(normalizeVtxo).filter((v) => !v.isSwept);
12974
+ if (candidates.length === 0) return inputs;
12975
+ const now = candidates.some((v) => v.expiresAtHeight !== void 0) ? await resolveTimeHeight(wallet.onchainProvider) : { timestamp: /* @__PURE__ */ new Date() };
12976
+ const suspects = candidates.filter(
12977
+ (v) => isPastExpiry(v, now) || v.expiresAtHeight !== void 0 && now.height === void 0
12978
+ );
12979
+ if (suspects.length === 0) return inputs;
12980
+ let sweptNow;
12981
+ try {
12982
+ const manager = await wallet.getContractManager();
12983
+ await manager.refreshOutpoints(suspects.map(({ txid, vout }) => ({ txid, vout })));
12984
+ const suspectKeys = new Set(suspects.map((v) => `${v.txid}:${v.vout}`));
12985
+ const fresh = await wallet.getVtxos({ withRecoverable: true });
12986
+ sweptNow = new Set(
12987
+ fresh.filter((v) => v.isSwept && suspectKeys.has(`${v.txid}:${v.vout}`)).map((v) => `${v.txid}:${v.vout}`)
12988
+ );
12989
+ } catch (e) {
12990
+ const message = "could not confirm the swept state of expired settlement inputs; retry the settlement";
12991
+ throw isRetryableProviderError(e) ? new ProviderUnavailableError(message, { cause: e }) : new Error(message, { cause: e });
12992
+ }
12993
+ if (sweptNow.size === 0) return inputs;
12994
+ return inputs.map((input) => {
12995
+ if (!isVirtualCoin(input) || !sweptNow.has(`${input.txid}:${input.vout}`)) return input;
12996
+ const swept = { ...normalizeVtxo(input), isSwept: true };
12997
+ return { ...swept, virtualStatus: toVirtualStatus(swept) };
12998
+ });
12999
+ }
12911
13000
  var PENDING_RECOVERY_REASON = "is past its operator signer's rotation cutoff \u2014 the operator will not co-sign it until it recovers";
12912
13001
  var UNROLLED_REASON = "was unilaterally exited and lives onchain \u2014 `Unroll.completeUnroll` is the only spend that reaches it";
12913
13002
  function omittedOutpoints(before, after) {
@@ -13407,7 +13496,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
13407
13496
  async getBalance() {
13408
13497
  const [boardingUtxos, snapshot] = await Promise.all([
13409
13498
  this.getBoardingUtxos(),
13410
- this.contractSnapshot()
13499
+ // The bucketer drops every spent coin and the gate reads contracts only.
13500
+ this.contractSnapshot(void 0, { unspentOnly: true })
13411
13501
  ]);
13412
13502
  const vtxos = filterSnapshotVtxos(
13413
13503
  snapshot,
@@ -13460,7 +13550,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
13460
13550
  */
13461
13551
  async getVtxos(filter) {
13462
13552
  return filterSnapshotVtxos(
13463
- await this.contractSnapshot(),
13553
+ // Only an unrolled coin is returned spent, so no other read needs spent rows.
13554
+ await this.contractSnapshot(void 0, { unspentOnly: !filter?.withUnrolled }),
13464
13555
  filter,
13465
13556
  this._pendingSpendOutpoints
13466
13557
  );
@@ -14140,12 +14231,12 @@ var ReadonlyWallet = class _ReadonlyWallet {
14140
14231
  ];
14141
14232
  const seenBaselineScripts = /* @__PURE__ */ new Set();
14142
14233
  for (const serverPubKey of baselineSigners) {
14143
- for (const csvTimelock of this.walletContractTimelocks) {
14144
- const csvTimelockStr = timelockToSequence(csvTimelock).toString();
14234
+ for (const csvTimelock2 of this.walletContractTimelocks) {
14235
+ const csvTimelockStr = timelockToSequence(csvTimelock2).toString();
14145
14236
  const defaultScript = new DefaultVtxo.Script({
14146
14237
  pubKey: baselinePubkey,
14147
14238
  serverPubKey,
14148
- csvTimelock
14239
+ csvTimelock: csvTimelock2
14149
14240
  });
14150
14241
  const defaultScriptHex = hex.encode(defaultScript.pkScript);
14151
14242
  if (!seenBaselineScripts.has(defaultScriptHex)) {
@@ -14167,7 +14258,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
14167
14258
  pubKey: baselinePubkey,
14168
14259
  serverPubKey,
14169
14260
  delegatePubKey,
14170
- csvTimelock
14261
+ csvTimelock: csvTimelock2
14171
14262
  });
14172
14263
  const delegateScriptHex = hex.encode(delegateScript.pkScript);
14173
14264
  if (seenBaselineScripts.has(delegateScriptHex)) continue;
@@ -14712,7 +14803,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14712
14803
  ...this._boardingTapscript.options,
14713
14804
  pubKey
14714
14805
  });
14715
- const csvTimelock = tapscript.options.csvTimelock ?? DefaultVtxo.Script.DEFAULT_TIMELOCK;
14806
+ const csvTimelock2 = tapscript.options.csvTimelock ?? DefaultVtxo.Script.DEFAULT_TIMELOCK;
14716
14807
  return {
14717
14808
  tapscript,
14718
14809
  params: {
@@ -14720,7 +14811,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14720
14811
  params: {
14721
14812
  pubKey: hex.encode(pubKey),
14722
14813
  serverPubKey: hex.encode(tapscript.options.serverPubKey),
14723
- csvTimelock: timelockToSequence(csvTimelock).toString()
14814
+ csvTimelock: timelockToSequence(csvTimelock2).toString()
14724
14815
  },
14725
14816
  script: hex.encode(tapscript.pkScript),
14726
14817
  address: tapscript.address(this.network.hrp, this.arkServerPublicKey).encode(),
@@ -15456,6 +15547,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15456
15547
  outputs: [output]
15457
15548
  };
15458
15549
  }
15550
+ params = {
15551
+ ...params,
15552
+ inputs: await refreshSweptStateOfExpiredInputs(this, params.inputs)
15553
+ };
15459
15554
  const onchainOutputIndexes = [];
15460
15555
  const outputs = [];
15461
15556
  let hasOffchainOutputs = false;
@@ -15536,7 +15631,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15536
15631
  ]);
15537
15632
  let intentTxId;
15538
15633
  try {
15539
- intentTxId = Transaction$2.fromPSBT(base64.decode(intent.proof)).id;
15634
+ intentTxId = Transaction.fromPSBT(base64.decode(intent.proof)).id;
15540
15635
  } catch {
15541
15636
  intentTxId = params.inputs.map((i) => `${i.txid}:${i.vout}`).sort().join("|");
15542
15637
  }
@@ -15677,7 +15772,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15677
15772
  }
15678
15773
  async handleSettlementFinalizationEvent(event, inputs, forfeitOutputScript, expectedRecipients, connectorsGraph, validatedCommitmentTxid) {
15679
15774
  const signedForfeits = [];
15680
- let settlementPsbt = Transaction$2.fromPSBT(base64.decode(event.commitmentTx));
15775
+ let settlementPsbt = Transaction.fromPSBT(base64.decode(event.commitmentTx));
15681
15776
  assertFinalCommitmentMatchesValidated(
15682
15777
  settlementPsbt,
15683
15778
  validatedCommitmentTxid,
@@ -15728,7 +15823,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15728
15823
  }
15729
15824
  continue;
15730
15825
  }
15731
- if (canRecoverOnchain(input, { timestamp: /* @__PURE__ */ new Date() }) || isSubdust({ value: input.value }, this.dustAmount)) {
15826
+ if (!requiresForfeit(input) || isSubdust({ value: input.value }, this.dustAmount)) {
15732
15827
  continue;
15733
15828
  }
15734
15829
  if (connectorsLeaves.length === 0) {
@@ -15855,7 +15950,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15855
15950
  if (!xOnlyPublicKeys.includes(hex.encode(xonlySignerPublicKey))) {
15856
15951
  return { skip: true };
15857
15952
  }
15858
- const commitmentTx = Transaction$2.fromPSBT(
15953
+ const commitmentTx = Transaction.fromPSBT(
15859
15954
  base64.decode(event.unsignedCommitmentTx)
15860
15955
  );
15861
15956
  validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
@@ -16080,7 +16175,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16080
16175
  batchPending.push(pendingTx.arkTxid);
16081
16176
  try {
16082
16177
  const checkpointTxs = pendingTx.signedCheckpointTxs.map((c) => {
16083
- const tx = Transaction$2.fromPSBT(base64.decode(c));
16178
+ const tx = Transaction.fromPSBT(base64.decode(c));
16084
16179
  assertAllowedSighashTypes(tx);
16085
16180
  return tx;
16086
16181
  });
@@ -16414,7 +16509,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16414
16509
  for (const pendingTx of pendingTxs) {
16415
16510
  try {
16416
16511
  const checkpointTxs = pendingTx.signedCheckpointTxs.map((checkpoint) => {
16417
- const tx = Transaction$2.fromPSBT(base64.decode(checkpoint));
16512
+ const tx = Transaction.fromPSBT(base64.decode(checkpoint));
16418
16513
  assertAllowedSighashTypes(tx);
16419
16514
  return tx;
16420
16515
  });
@@ -16455,7 +16550,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16455
16550
  }
16456
16551
  /** Sum the outputs of an ark tx PSBT that pay the given scriptPubKey. */
16457
16552
  arkTxAmountPaidTo(arkTxPsbt, pkScriptHex) {
16458
- const arkTx = Transaction$2.fromPSBT(base64.decode(arkTxPsbt));
16553
+ const arkTx = Transaction.fromPSBT(base64.decode(arkTxPsbt));
16459
16554
  let total = 0;
16460
16555
  for (let i = 0; i < arkTx.outputsLength; i++) {
16461
16556
  const output = arkTx.getOutput(i);
@@ -16626,7 +16721,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16626
16721
  script: recipient.script,
16627
16722
  amount: BigInt(recipient.amount),
16628
16723
  // Already checked against the recipient address in `validateRecipients`.
16629
- ...recipient.tapTree ? { tapTree: TapTreeCoder.decode(recipient.tapTree) } : {}
16724
+ ...recipient.tapTree ? { tapTree: toBIP371TapTree(recipient.tapTree) } : {}
16630
16725
  }));
16631
16726
  const totalBtcOutput = outputs.reduce((sum, o) => sum + Number(o.amount), 0);
16632
16727
  let changeAmount = totalBtcSelected - totalBtcOutput;
@@ -16967,7 +17062,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16967
17062
  }
16968
17063
  const checkpointIdByOutpoint = /* @__PURE__ */ new Map();
16969
17064
  for (const encoded of signedCheckpointTxs) {
16970
- const checkpoint = Transaction$2.fromPSBT(base64.decode(encoded));
17065
+ const checkpoint = Transaction.fromPSBT(base64.decode(encoded));
16971
17066
  for (let i = 0; i < checkpoint.inputsLength; i++) {
16972
17067
  const input = checkpoint.getInput(i);
16973
17068
  if (!input.txid) continue;
@@ -19000,7 +19095,8 @@ var WalletMessageHandler = class {
19000
19095
  async handleGetBalance() {
19001
19096
  const [boardingUtxos, { snapshot, vtxos: allVtxos }] = await Promise.all([
19002
19097
  this.getAllBoardingUtxos(),
19003
- this.repoSnapshot()
19098
+ // The bucketer drops every spent coin and the gate reads contracts only.
19099
+ this.repoSnapshot({ unspentOnly: true })
19004
19100
  ]);
19005
19101
  const pendingOutpoints = this.readonlyWallet?.pendingRecoveryOutpointsIn(snapshot) ?? /* @__PURE__ */ new Set();
19006
19102
  let confirmed = 0;
@@ -19267,9 +19363,9 @@ var WalletMessageHandler = class {
19267
19363
  if (!this.readonlyWallet) {
19268
19364
  throw new WalletNotInitializedError();
19269
19365
  }
19270
- const allVtxos = await this.getVtxosFromRepo();
19271
- const dustAmount = this.readonlyWallet.dustAmount;
19272
19366
  const withUnrolled = message.payload.filter?.withUnrolled ?? false;
19367
+ const allVtxos = await this.getVtxosFromRepo({ unspentOnly: !withUnrolled });
19368
+ const dustAmount = this.readonlyWallet.dustAmount;
19273
19369
  const includeRecoverable = message.payload.filter?.withRecoverable ?? false;
19274
19370
  return allVtxos.filter((v) => {
19275
19371
  if (v.isUnrolled) {
@@ -19319,8 +19415,8 @@ var WalletMessageHandler = class {
19319
19415
  * Read all virtual outputs from the repository, aggregated across all contract
19320
19416
  * addresses and the wallet's primary address, with deduplication.
19321
19417
  */
19322
- async getVtxosFromRepo() {
19323
- return (await this.repoSnapshot()).vtxos;
19418
+ async getVtxosFromRepo(options) {
19419
+ return (await this.repoSnapshot(options)).vtxos;
19324
19420
  }
19325
19421
  /**
19326
19422
  * The worker's equivalent of `ReadonlyWallet.contractSnapshot`: contracts
@@ -19335,7 +19431,7 @@ var WalletMessageHandler = class {
19335
19431
  * what it knows is closed — so the coins of a just-registered escrowed
19336
19432
  * contract would count as available until the next poll.
19337
19433
  */
19338
- async repoSnapshot() {
19434
+ async repoSnapshot(options) {
19339
19435
  if (!this.walletRepository || !this.readonlyWallet) return { snapshot: [], vtxos: [] };
19340
19436
  const seen = /* @__PURE__ */ new Set();
19341
19437
  const allVtxos = [];
@@ -19357,7 +19453,9 @@ var WalletMessageHandler = class {
19357
19453
  for (const contract of contracts) {
19358
19454
  snapshot.push({
19359
19455
  contract,
19360
- vtxos: addVtxos(await getVtxosForContract(this.walletRepository, contract))
19456
+ vtxos: addVtxos(
19457
+ await getVtxosForContract(this.walletRepository, contract, options)
19458
+ )
19361
19459
  });
19362
19460
  }
19363
19461
  const walletAddress = await this.readonlyWallet.getAddress();
@@ -19370,10 +19468,11 @@ var WalletMessageHandler = class {
19370
19468
  );
19371
19469
  }
19372
19470
  addVtxos(
19373
- await getVtxosForContract(this.walletRepository, {
19374
- script: walletScript,
19375
- address: walletAddress
19376
- })
19471
+ await getVtxosForContract(
19472
+ this.walletRepository,
19473
+ { script: walletScript, address: walletAddress },
19474
+ options
19475
+ )
19377
19476
  );
19378
19477
  return { snapshot, vtxos: allVtxos };
19379
19478
  }
@@ -21571,7 +21670,7 @@ var WsElectrumChainSource = class {
21571
21670
  );
21572
21671
  const txs = await this.fetchTransactions(unspentsFromElectrum.map((u) => u.tx_hash));
21573
21672
  return unspentsFromElectrum.map((u, index) => {
21574
- const tx = Transaction$2.fromRaw(hex.decode(txs[index].hex), {
21673
+ const tx = Transaction$1.fromRaw(hex.decode(txs[index].hex), {
21575
21674
  allowUnknownOutputs: true
21576
21675
  });
21577
21676
  const output = tx.getOutput(u.tx_pos);
@@ -21666,7 +21765,7 @@ var ElectrumOnchainProvider = class {
21666
21765
  }
21667
21766
  async getTxOutspends(txid) {
21668
21767
  const [txResult] = await this.chain.fetchTransactions([txid]);
21669
- const tx = Transaction$2.fromRaw(hex.decode(txResult.hex), {
21768
+ const tx = Transaction$1.fromRaw(hex.decode(txResult.hex), {
21670
21769
  allowUnknownOutputs: true
21671
21770
  });
21672
21771
  const outputCount = tx.outputsLength;
@@ -21734,7 +21833,7 @@ var ElectrumOnchainProvider = class {
21734
21833
  for (const candidateTxid of ambiguousCandidates[j]) {
21735
21834
  const rawHex = txMap.get(candidateTxid);
21736
21835
  if (!rawHex) continue;
21737
- const candidateTx = Transaction$2.fromRaw(hex.decode(rawHex), {
21836
+ const candidateTx = Transaction$1.fromRaw(hex.decode(rawHex), {
21738
21837
  allowUnknownOutputs: true,
21739
21838
  allowUnknownInputs: true
21740
21839
  });
@@ -21810,7 +21909,7 @@ var ElectrumOnchainProvider = class {
21810
21909
  if (rawHex) {
21811
21910
  let tx;
21812
21911
  try {
21813
- tx = Transaction$2.fromRaw(hex.decode(rawHex), {
21912
+ tx = Transaction$1.fromRaw(hex.decode(rawHex), {
21814
21913
  allowUnknownOutputs: true,
21815
21914
  allowUnknownInputs: true
21816
21915
  });
@@ -22006,7 +22105,7 @@ function isTxNotInBlockError(err) {
22006
22105
  return normalized.includes("notyetinablock") || normalized.includes("notinablock") || normalized.includes("notinblock") || normalized.includes("noconfirmedtransaction");
22007
22106
  }
22008
22107
  function childTxidFromHex(txHex) {
22009
- const tx = Transaction$2.fromRaw(hex.decode(txHex), {
22108
+ const tx = Transaction$1.fromRaw(hex.decode(txHex), {
22010
22109
  allowUnknownOutputs: true,
22011
22110
  allowUnknownInputs: true
22012
22111
  });
@@ -22254,7 +22353,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
22254
22353
  return false;
22255
22354
  }
22256
22355
  const toSpend = craftToSpendTx(message, pkScript, TAG_BIP322);
22257
- const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
22356
+ const toSign = craftBIP322ToSignP2TR(toSpend, pkScript);
22258
22357
  const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
22259
22358
  const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
22260
22359
  return schnorr.verify(rawSig, sighash, pubkey);
@@ -23837,7 +23936,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
23837
23936
  boardingIndices.push(boardingIdx);
23838
23937
  continue;
23839
23938
  }
23840
- if (isRecoverable(input) || isSubdust(input, info.dust)) {
23939
+ if (!requiresForfeit(input) || isSubdust(input, info.dust)) {
23841
23940
  continue;
23842
23941
  }
23843
23942
  if (connectorIndex >= connectorLeaves.length) {
@@ -24048,6 +24147,14 @@ function providedWitness(witness) {
24048
24147
  return !item.injected && item.type !== "signature";
24049
24148
  });
24050
24149
  }
24150
+ function csvTimelock(leafName, operand) {
24151
+ if (typeof operand === "string") return { type: "blocks", value: operand };
24152
+ const timelock = operand >= 0n && operand < 0x80000000n ? sequenceToTimelock(Number(operand)) : void 0;
24153
+ if (!timelock || BigInt(timelockToSequence(timelock)) !== operand) {
24154
+ fail(`leaf '${leafName}': CSV literal ${operand} is not a canonical BIP68 sequence`);
24155
+ }
24156
+ return timelock;
24157
+ }
24051
24158
  function parseLeaf(leaf, hasCovenant, instantiations, extras) {
24052
24159
  const asm = leaf.asm;
24053
24160
  let index = 0;
@@ -24062,7 +24169,7 @@ function parseLeaf(leaf, hasCovenant, instantiations, extras) {
24062
24169
  let cltv;
24063
24170
  if (asm.length >= index + 3 && asm[index + 2] === "OP_DROP") {
24064
24171
  const operand = asm[index].startsWith("<") && asm[index].endsWith(">") ? `$${asm[index].slice(1, -1)}` : BigInt(asm[index]);
24065
- if (asm[index + 1] === "OP_CHECKSEQUENCEVERIFY") csv = { type: "blocks", value: operand };
24172
+ if (asm[index + 1] === "OP_CHECKSEQUENCEVERIFY") csv = csvTimelock(leaf.name, operand);
24066
24173
  else if (asm[index + 1] === "OP_CHECKLOCKTIMEVERIFY") cltv = operand;
24067
24174
  else fail(`leaf '${leaf.name}': unexpected timelock opcode ${asm[index + 1]}`);
24068
24175
  index += 3;
@@ -25107,12 +25214,7 @@ function createDefaultPaymentRouter(wallet) {
25107
25214
  prefs: { priority: ["ark", "ark-asset", "lightning", "onchain"] }
25108
25215
  }).use(arkRail()).use(arkAssetRail()).use(onchainRail({ feeInfo: walletFeeSource(wallet) }));
25109
25216
  }
25110
- /*! Bundled license information:
25111
-
25112
- @noble/hashes/utils.js:
25113
- (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
25114
- */
25115
25217
 
25116
25218
  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, ContractRepositoryImpl, ContractWatcher, DEFAULT_MESSAGE_TIMEOUTS, DEFAULT_MIN_BATCH_EXPIRY_SECONDS, DEFAULT_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, DatabaseUpgradeBlockedError, DelegateManagerImpl, DelegateNotConfiguredError, DelegatorManagerImpl, DelegatorNotConfiguredError, 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, MIGRATION_KEY, MUTINYNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, MessageBus, MessageBusInitializingError, MessageBusNotInitializedError, MissingSigningDescriptorError, MnemonicIdentity, OnchainWallet, OversizedChangeError, P2A, PaymentRouter, PrevTxUnavailableError, REGTEST_MIN_BATCH_EXPIRY_SECONDS, REGTEST_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, Ramps, ReadonlyAssetManager, ReadonlyDescriptorIdentity, ReadonlySingleKey, ReadonlyWallet, ReadonlyWalletError, RestDelegateProvider, RestDelegatorProvider, 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, WalletRepositoryImpl, WsElectrumChainSource, adoptContractDescriptor, arkAssetRail, arkRail, arkTarget, arkade_exports, assertFinalCommitmentMatchesValidated, assertIntentIdUnique, assertNoAssets, assertNoSelection, 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, getMigrationStatus, 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, logExcludedVtxos, makeHandle, matchServerCheckpoints, mergeChainedTxType, migrateWalletRepository, notifyExitObserved, onchainRail, openDatabase, outpointExclusion, outpointReasons, promisifyRequest, provisionClaimSecret, provisionRefundKey, registerWalletRestoreHook, requiresMigration, resolveAssetAmount, resolveBatchExpiryPolicy, resolveCheckpointExitDelayPolicy, resolveDescriptorSigner, resolvePrevTxs, resolveSendAmount, rollbackMigration, saveVtxosForContract, scriptFromArkAddress, selectCoinsWithAsset, selectVirtualCoins, selectionOf, serializeAssets, serializeExitPackage, serializeUtxo, serializeVtxo, setupServiceWorker, signAndSubmitOffchainTx, signerSetFromInfo, signingDescriptorIndex, strictSigningDescriptorIndex, toXOnlySignerHex, tryResolveSendAmount, validateBatchRecipients, validateConnectorsTxGraph, validateVtxoTxGraph, verifyTapscriptSignatures, waitForIncomingFunds, walletFeeSource, warnAndFilterVtxosForScript, withPrevTxs };
25117
- //# sourceMappingURL=chunk-MLOZHTBN.js.map
25118
- //# sourceMappingURL=chunk-MLOZHTBN.js.map
25219
+ //# sourceMappingURL=chunk-YPQ37P3H.js.map
25220
+ //# sourceMappingURL=chunk-YPQ37P3H.js.map