@arkade-os/sdk 0.4.60 → 0.4.61

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 (77) hide show
  1. package/dist/adapters/expo.cjs +5 -5
  2. package/dist/adapters/expo.d.cts +4 -4
  3. package/dist/adapters/expo.d.ts +4 -4
  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/{asyncStorageTaskQueue-CqijAAPG.d.cts → asyncStorageTaskQueue-BWDxp3Dr.d.cts} +2 -2
  8. package/dist/{asyncStorageTaskQueue-Vsp6uk8e.d.ts → asyncStorageTaskQueue-Cq9FpKv6.d.ts} +2 -2
  9. package/dist/{chunk-PRFL62ID.cjs → chunk-2JHN5RCY.cjs} +17 -17
  10. package/dist/{chunk-PRFL62ID.cjs.map → chunk-2JHN5RCY.cjs.map} +1 -1
  11. package/dist/{chunk-KNS5MTTI.cjs → chunk-3NUDA3MB.cjs} +1045 -461
  12. package/dist/chunk-3NUDA3MB.cjs.map +1 -0
  13. package/dist/{chunk-2DINXHGQ.js → chunk-6O5OLYTZ.js} +66 -35
  14. package/dist/chunk-6O5OLYTZ.js.map +1 -0
  15. package/dist/{chunk-Y54MUBT7.js → chunk-AUEXB42T.js} +654 -84
  16. package/dist/chunk-AUEXB42T.js.map +1 -0
  17. package/dist/{chunk-4A4GRSTB.cjs → chunk-FNCQJLR2.cjs} +3 -3
  18. package/dist/{chunk-4A4GRSTB.cjs.map → chunk-FNCQJLR2.cjs.map} +1 -1
  19. package/dist/{chunk-3Q7BBUWO.js → chunk-GDI2A65Z.js} +4 -4
  20. package/dist/{chunk-3Q7BBUWO.js.map → chunk-GDI2A65Z.js.map} +1 -1
  21. package/dist/{chunk-JBULXTCC.js → chunk-PVY6DMN5.js} +3 -3
  22. package/dist/{chunk-JBULXTCC.js.map → chunk-PVY6DMN5.js.map} +1 -1
  23. package/dist/{chunk-MZNLCMUP.cjs → chunk-SF5NKAUA.cjs} +113 -79
  24. package/dist/chunk-SF5NKAUA.cjs.map +1 -0
  25. package/dist/{chunk-H7JCHFM6.cjs → chunk-XFYFREPH.cjs} +17 -17
  26. package/dist/{chunk-H7JCHFM6.cjs.map → chunk-XFYFREPH.cjs.map} +1 -1
  27. package/dist/{chunk-B66RYHTB.js → chunk-XLHN5L2O.js} +4 -4
  28. package/dist/{chunk-B66RYHTB.js.map → chunk-XLHN5L2O.js.map} +1 -1
  29. package/dist/{chunk-2XLNQHG4.cjs → chunk-XMRB74HA.cjs} +10 -10
  30. package/dist/{chunk-2XLNQHG4.cjs.map → chunk-XMRB74HA.cjs.map} +1 -1
  31. package/dist/{chunk-FSKANUV4.js → chunk-YVQNHELA.js} +3 -3
  32. package/dist/{chunk-FSKANUV4.js.map → chunk-YVQNHELA.js.map} +1 -1
  33. package/dist/contracts/handlers/index.cjs +9 -9
  34. package/dist/contracts/handlers/index.d.cts +5 -5
  35. package/dist/contracts/handlers/index.d.ts +5 -5
  36. package/dist/contracts/handlers/index.js +2 -2
  37. package/dist/{delegate-DNEuM_nK.d.cts → delegate-BySzD37I.d.ts} +1 -1
  38. package/dist/{delegate-DidNTsKm.d.ts → delegate-C4Rl6h9l.d.cts} +1 -1
  39. package/dist/{ark-D2_yNhfz.d.cts → index-BcRCHnzN.d.cts} +4846 -4776
  40. package/dist/{ark-D2_yNhfz.d.ts → index-BcRCHnzN.d.ts} +4846 -4776
  41. package/dist/{index-DzQbNQUG.d.ts → index-Butfkm-K.d.cts} +102 -102
  42. package/dist/{index-BP8-zniX.d.cts → index-C29VNcxC.d.ts} +102 -102
  43. package/dist/index.cjs +320 -248
  44. package/dist/index.d.cts +256 -54
  45. package/dist/index.d.ts +256 -54
  46. package/dist/index.js +4 -4
  47. package/dist/repositories/realm/index.cjs +19 -19
  48. package/dist/repositories/realm/index.d.cts +4 -4
  49. package/dist/repositories/realm/index.d.ts +4 -4
  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 +4 -4
  53. package/dist/repositories/sqlite/index.d.ts +4 -4
  54. package/dist/repositories/sqlite/index.js +5 -5
  55. package/dist/{taskRunner-9gnlYEpb.d.ts → taskRunner-BTq3rMpI.d.cts} +2 -2
  56. package/dist/{taskRunner-BEQNFEa4.d.cts → taskRunner-DxMJYJ7Y.d.ts} +2 -2
  57. package/dist/wallet/expo/background.cjs +14 -14
  58. package/dist/wallet/expo/background.d.cts +5 -5
  59. package/dist/wallet/expo/background.d.ts +5 -5
  60. package/dist/wallet/expo/background.js +6 -6
  61. package/dist/wallet/expo/index.cjs +34 -14
  62. package/dist/wallet/expo/index.cjs.map +1 -1
  63. package/dist/wallet/expo/index.d.cts +12 -5
  64. package/dist/wallet/expo/index.d.ts +12 -5
  65. package/dist/wallet/expo/index.js +25 -5
  66. package/dist/wallet/expo/index.js.map +1 -1
  67. package/dist/{wallet-ipUA1XCp.d.cts → wallet-BVIfg2ic.d.ts} +79 -14
  68. package/dist/{wallet-C_MYHyOj.d.ts → wallet-DrSsUden.d.cts} +79 -14
  69. package/dist/worker/expo/index.cjs +9 -9
  70. package/dist/worker/expo/index.d.cts +6 -6
  71. package/dist/worker/expo/index.d.ts +6 -6
  72. package/dist/worker/expo/index.js +5 -5
  73. package/package.json +1 -1
  74. package/dist/chunk-2DINXHGQ.js.map +0 -1
  75. package/dist/chunk-KNS5MTTI.cjs.map +0 -1
  76. package/dist/chunk-MZNLCMUP.cjs.map +0 -1
  77. package/dist/chunk-Y54MUBT7.js.map +0 -1
@@ -1,8 +1,8 @@
1
- import { AssetId, AssetGroup, AssetInput, AssetOutput, Metadata, Packet, BufferReader, BufferWriter, AssetRef, RestIndexerProvider } from './chunk-FSKANUV4.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-2DINXHGQ.js';
3
- import { VtxoScript, Transaction, isRecoverable, CSVMultisigTapscript, DEFAULT_NETWORK, resolveEmulatorPubkey, 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, isEventSourceUnavailableError, isRetryableProviderError, getAllNormalizedVtxos, DEFAULT_PAGE_SIZE, RestArkProvider, toVirtualStatus, ArkError, resolveTimeHeight, canSpendOffchain, parseLegacyExpiry, isExpired, DEFAULT_ARKADE_SERVER_URL, ProviderUnavailableError, networks as networks$1, isPastExpiry, fetchVtxoCreatedAtByTxid } from './chunk-JBULXTCC.js';
1
+ import { AssetId, AssetGroup, AssetInput, AssetOutput, Metadata, Packet, BufferReader, BufferWriter, AssetRef, RestIndexerProvider } from './chunk-YVQNHELA.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, parseHDDescriptor, DefaultVtxo, speculativeReceiveMetadata, DelegateVtxo, WALLET_RECEIVE_SOURCE, BoardingContractHandler, identityDescriptor } from './chunk-6O5OLYTZ.js';
3
+ import { VtxoScript, Transaction, isRecoverable, CSVMultisigTapscript, DEFAULT_NETWORK, resolveEmulatorPubkey, 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, isEventSourceUnavailableError, isRetryableProviderError, getAllNormalizedVtxos, DEFAULT_PAGE_SIZE, RestArkProvider, toVirtualStatus, ArkError, resolveTimeHeight, canSpendOffchain, parseLegacyExpiry, isExpired, DEFAULT_ARKADE_SERVER_URL, ProviderUnavailableError, networks as networks$1, isPastExpiry, fetchVtxoCreatedAtByTxid } from './chunk-PVY6DMN5.js';
4
4
  import { __export } from './chunk-NSBPE2FW.js';
5
- import { sha256, equalBytes, hash160, sha256x2, concatBytes, randomPrivateKeyBytes, pubECDSA, pubSchnorr } from '@scure/btc-signer/utils.js';
5
+ import { sha256 as sha256$1, 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';
7
7
  import { hex, base58, base64, bech32m } from '@scure/base';
8
8
  import * as musig2 from '@scure/btc-signer/musig2.js';
@@ -879,8 +879,33 @@ function isHDCapableIdentity(value) {
879
879
  function isBatchSignable(identity) {
880
880
  return "signMultiple" in identity && typeof identity.signMultiple === "function";
881
881
  }
882
-
883
- // src/wallet/hdWalletCapable.ts
882
+ function isSigningIdentity(value) {
883
+ if (typeof value !== "object" || value === null) return false;
884
+ const v = value;
885
+ return typeof v.sign === "function" && typeof v.signMessage === "function" && typeof v.signerSession === "function" && typeof v.xOnlyPublicKey === "function";
886
+ }
887
+ var ForeignDescriptorError = class extends Error {
888
+ constructor(descriptor, options) {
889
+ super(`this wallet holds no key for descriptor: ${descriptor}`, options);
890
+ this.descriptor = descriptor;
891
+ }
892
+ descriptor;
893
+ name = "ForeignDescriptorError";
894
+ };
895
+ async function resolveDescriptorSigner(descriptor, identity, provider) {
896
+ const owner = provider?.isOurs(descriptor) ? provider : isHDCapableIdentity(identity) && identity.isOurs(descriptor) ? identity : void 0;
897
+ if (owner && parseHDDescriptor(descriptor)) {
898
+ return new DescriptorIdentity({ descriptor, signer: owner, base: identity });
899
+ }
900
+ let key;
901
+ try {
902
+ key = deriveDescriptorLeafPubKey(descriptor);
903
+ } catch {
904
+ throw new ForeignDescriptorError(descriptor);
905
+ }
906
+ if (equalBytes(await identity.xOnlyPublicKey(), key)) return identity;
907
+ throw new ForeignDescriptorError(descriptor);
908
+ }
884
909
  function isHDWalletCapable(value) {
885
910
  if (typeof value !== "object" || value === null) return false;
886
911
  const v = value;
@@ -892,6 +917,441 @@ function isHDAllocationCapable(value) {
892
917
  return typeof v.getNextSigningDescriptor === "function" && typeof v.advanceSigningDescriptorWatermark === "function";
893
918
  }
894
919
 
920
+ // ../../node_modules/@noble/hashes/utils.js
921
+ function isBytes(a) {
922
+ return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
923
+ }
924
+ function abytes(value, length, title = "") {
925
+ const bytes = isBytes(value);
926
+ const len = value?.length;
927
+ const needsLen = length !== void 0;
928
+ if (!bytes || needsLen) {
929
+ const prefix = title && `"${title}" `;
930
+ const ofLen = "";
931
+ const got = bytes ? `length=${len}` : `type=${typeof value}`;
932
+ throw new Error(prefix + "expected Uint8Array" + ofLen + ", got " + got);
933
+ }
934
+ return value;
935
+ }
936
+ function aexists(instance, checkFinished = true) {
937
+ if (instance.destroyed)
938
+ throw new Error("Hash instance has been destroyed");
939
+ if (checkFinished && instance.finished)
940
+ throw new Error("Hash#digest() has already been called");
941
+ }
942
+ function aoutput(out, instance) {
943
+ abytes(out, void 0, "digestInto() output");
944
+ const min = instance.outputLen;
945
+ if (out.length < min) {
946
+ throw new Error('"digestInto() output" expected to be of length >=' + min);
947
+ }
948
+ }
949
+ function clean(...arrays) {
950
+ for (let i = 0; i < arrays.length; i++) {
951
+ arrays[i].fill(0);
952
+ }
953
+ }
954
+ function createView(arr) {
955
+ return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
956
+ }
957
+ function rotr(word, shift) {
958
+ return word << 32 - shift | word >>> shift;
959
+ }
960
+ function createHasher(hashCons, info = {}) {
961
+ const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
962
+ const tmp = hashCons(void 0);
963
+ hashC.outputLen = tmp.outputLen;
964
+ hashC.blockLen = tmp.blockLen;
965
+ hashC.create = (opts) => hashCons(opts);
966
+ Object.assign(hashC, info);
967
+ return Object.freeze(hashC);
968
+ }
969
+ function randomBytes(bytesLength = 32) {
970
+ const cr = typeof globalThis === "object" ? globalThis.crypto : null;
971
+ if (typeof cr?.getRandomValues !== "function")
972
+ throw new Error("crypto.getRandomValues must be defined");
973
+ return cr.getRandomValues(new Uint8Array(bytesLength));
974
+ }
975
+ var oidNist = (suffix) => ({
976
+ oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
977
+ });
978
+
979
+ // ../../node_modules/@noble/hashes/_md.js
980
+ function Chi(a, b, c) {
981
+ return a & b ^ ~a & c;
982
+ }
983
+ function Maj(a, b, c) {
984
+ return a & b ^ a & c ^ b & c;
985
+ }
986
+ var HashMD = class {
987
+ blockLen;
988
+ outputLen;
989
+ padOffset;
990
+ isLE;
991
+ // For partial updates less than block size
992
+ buffer;
993
+ view;
994
+ finished = false;
995
+ length = 0;
996
+ pos = 0;
997
+ destroyed = false;
998
+ constructor(blockLen, outputLen, padOffset, isLE) {
999
+ this.blockLen = blockLen;
1000
+ this.outputLen = outputLen;
1001
+ this.padOffset = padOffset;
1002
+ this.isLE = isLE;
1003
+ this.buffer = new Uint8Array(blockLen);
1004
+ this.view = createView(this.buffer);
1005
+ }
1006
+ update(data) {
1007
+ aexists(this);
1008
+ abytes(data);
1009
+ const { view, buffer, blockLen } = this;
1010
+ const len = data.length;
1011
+ for (let pos = 0; pos < len; ) {
1012
+ const take = Math.min(blockLen - this.pos, len - pos);
1013
+ if (take === blockLen) {
1014
+ const dataView = createView(data);
1015
+ for (; blockLen <= len - pos; pos += blockLen)
1016
+ this.process(dataView, pos);
1017
+ continue;
1018
+ }
1019
+ buffer.set(data.subarray(pos, pos + take), this.pos);
1020
+ this.pos += take;
1021
+ pos += take;
1022
+ if (this.pos === blockLen) {
1023
+ this.process(view, 0);
1024
+ this.pos = 0;
1025
+ }
1026
+ }
1027
+ this.length += data.length;
1028
+ this.roundClean();
1029
+ return this;
1030
+ }
1031
+ digestInto(out) {
1032
+ aexists(this);
1033
+ aoutput(out, this);
1034
+ this.finished = true;
1035
+ const { buffer, view, blockLen, isLE } = this;
1036
+ let { pos } = this;
1037
+ buffer[pos++] = 128;
1038
+ clean(this.buffer.subarray(pos));
1039
+ if (this.padOffset > blockLen - pos) {
1040
+ this.process(view, 0);
1041
+ pos = 0;
1042
+ }
1043
+ for (let i = pos; i < blockLen; i++)
1044
+ buffer[i] = 0;
1045
+ view.setBigUint64(blockLen - 8, BigInt(this.length * 8), isLE);
1046
+ this.process(view, 0);
1047
+ const oview = createView(out);
1048
+ const len = this.outputLen;
1049
+ if (len % 4)
1050
+ throw new Error("_sha2: outputLen must be aligned to 32bit");
1051
+ const outLen = len / 4;
1052
+ const state = this.get();
1053
+ if (outLen > state.length)
1054
+ throw new Error("_sha2: outputLen bigger than state");
1055
+ for (let i = 0; i < outLen; i++)
1056
+ oview.setUint32(4 * i, state[i], isLE);
1057
+ }
1058
+ digest() {
1059
+ const { buffer, outputLen } = this;
1060
+ this.digestInto(buffer);
1061
+ const res = buffer.slice(0, outputLen);
1062
+ this.destroy();
1063
+ return res;
1064
+ }
1065
+ _cloneInto(to) {
1066
+ to ||= new this.constructor();
1067
+ to.set(...this.get());
1068
+ const { blockLen, buffer, length, finished, destroyed, pos } = this;
1069
+ to.destroyed = destroyed;
1070
+ to.finished = finished;
1071
+ to.length = length;
1072
+ to.pos = pos;
1073
+ if (length % blockLen)
1074
+ to.buffer.set(buffer);
1075
+ return to;
1076
+ }
1077
+ clone() {
1078
+ return this._cloneInto();
1079
+ }
1080
+ };
1081
+ var SHA256_IV = /* @__PURE__ */ Uint32Array.from([
1082
+ 1779033703,
1083
+ 3144134277,
1084
+ 1013904242,
1085
+ 2773480762,
1086
+ 1359893119,
1087
+ 2600822924,
1088
+ 528734635,
1089
+ 1541459225
1090
+ ]);
1091
+
1092
+ // ../../node_modules/@noble/hashes/sha2.js
1093
+ var SHA256_K = /* @__PURE__ */ Uint32Array.from([
1094
+ 1116352408,
1095
+ 1899447441,
1096
+ 3049323471,
1097
+ 3921009573,
1098
+ 961987163,
1099
+ 1508970993,
1100
+ 2453635748,
1101
+ 2870763221,
1102
+ 3624381080,
1103
+ 310598401,
1104
+ 607225278,
1105
+ 1426881987,
1106
+ 1925078388,
1107
+ 2162078206,
1108
+ 2614888103,
1109
+ 3248222580,
1110
+ 3835390401,
1111
+ 4022224774,
1112
+ 264347078,
1113
+ 604807628,
1114
+ 770255983,
1115
+ 1249150122,
1116
+ 1555081692,
1117
+ 1996064986,
1118
+ 2554220882,
1119
+ 2821834349,
1120
+ 2952996808,
1121
+ 3210313671,
1122
+ 3336571891,
1123
+ 3584528711,
1124
+ 113926993,
1125
+ 338241895,
1126
+ 666307205,
1127
+ 773529912,
1128
+ 1294757372,
1129
+ 1396182291,
1130
+ 1695183700,
1131
+ 1986661051,
1132
+ 2177026350,
1133
+ 2456956037,
1134
+ 2730485921,
1135
+ 2820302411,
1136
+ 3259730800,
1137
+ 3345764771,
1138
+ 3516065817,
1139
+ 3600352804,
1140
+ 4094571909,
1141
+ 275423344,
1142
+ 430227734,
1143
+ 506948616,
1144
+ 659060556,
1145
+ 883997877,
1146
+ 958139571,
1147
+ 1322822218,
1148
+ 1537002063,
1149
+ 1747873779,
1150
+ 1955562222,
1151
+ 2024104815,
1152
+ 2227730452,
1153
+ 2361852424,
1154
+ 2428436474,
1155
+ 2756734187,
1156
+ 3204031479,
1157
+ 3329325298
1158
+ ]);
1159
+ var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
1160
+ var SHA2_32B = class extends HashMD {
1161
+ constructor(outputLen) {
1162
+ super(64, outputLen, 8, false);
1163
+ }
1164
+ get() {
1165
+ const { A, B, C, D, E, F, G, H } = this;
1166
+ return [A, B, C, D, E, F, G, H];
1167
+ }
1168
+ // prettier-ignore
1169
+ set(A, B, C, D, E, F, G, H) {
1170
+ this.A = A | 0;
1171
+ this.B = B | 0;
1172
+ this.C = C | 0;
1173
+ this.D = D | 0;
1174
+ this.E = E | 0;
1175
+ this.F = F | 0;
1176
+ this.G = G | 0;
1177
+ this.H = H | 0;
1178
+ }
1179
+ process(view, offset) {
1180
+ for (let i = 0; i < 16; i++, offset += 4)
1181
+ SHA256_W[i] = view.getUint32(offset, false);
1182
+ for (let i = 16; i < 64; i++) {
1183
+ const W15 = SHA256_W[i - 15];
1184
+ const W2 = SHA256_W[i - 2];
1185
+ const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
1186
+ const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10;
1187
+ SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
1188
+ }
1189
+ let { A, B, C, D, E, F, G, H } = this;
1190
+ for (let i = 0; i < 64; i++) {
1191
+ const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
1192
+ const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
1193
+ const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
1194
+ const T2 = sigma0 + Maj(A, B, C) | 0;
1195
+ H = G;
1196
+ G = F;
1197
+ F = E;
1198
+ E = D + T1 | 0;
1199
+ D = C;
1200
+ C = B;
1201
+ B = A;
1202
+ A = T1 + T2 | 0;
1203
+ }
1204
+ A = A + this.A | 0;
1205
+ B = B + this.B | 0;
1206
+ C = C + this.C | 0;
1207
+ D = D + this.D | 0;
1208
+ E = E + this.E | 0;
1209
+ F = F + this.F | 0;
1210
+ G = G + this.G | 0;
1211
+ H = H + this.H | 0;
1212
+ this.set(A, B, C, D, E, F, G, H);
1213
+ }
1214
+ roundClean() {
1215
+ clean(SHA256_W);
1216
+ }
1217
+ destroy() {
1218
+ this.set(0, 0, 0, 0, 0, 0, 0, 0);
1219
+ clean(this.buffer);
1220
+ }
1221
+ };
1222
+ var _SHA256 = class extends SHA2_32B {
1223
+ // We cannot use array here since array allows indexing by variable
1224
+ // which means optimizer/compiler cannot use registers.
1225
+ A = SHA256_IV[0] | 0;
1226
+ B = SHA256_IV[1] | 0;
1227
+ C = SHA256_IV[2] | 0;
1228
+ D = SHA256_IV[3] | 0;
1229
+ E = SHA256_IV[4] | 0;
1230
+ F = SHA256_IV[5] | 0;
1231
+ G = SHA256_IV[6] | 0;
1232
+ H = SHA256_IV[7] | 0;
1233
+ constructor() {
1234
+ super(32);
1235
+ }
1236
+ };
1237
+ var sha256 = /* @__PURE__ */ createHasher(
1238
+ () => new _SHA256(),
1239
+ /* @__PURE__ */ oidNist(1)
1240
+ );
1241
+ var ARKADE_SWAP_PREIMAGE_TAG = "Arkade-RFQ-Preimage-v1";
1242
+ function buildPreimageMessage(xonly, index) {
1243
+ if (xonly.length !== 32) {
1244
+ throw new Error(`x-only pubkey must be 32 bytes, got ${xonly.length}`);
1245
+ }
1246
+ if (!Number.isInteger(index) || index < 0 || index > 4294967295) {
1247
+ throw new Error(`index must be a u32, got ${index}`);
1248
+ }
1249
+ const tag = new TextEncoder().encode(ARKADE_SWAP_PREIMAGE_TAG);
1250
+ const message = new Uint8Array(tag.length + 32 + 4);
1251
+ message.set(tag, 0);
1252
+ message.set(xonly, tag.length);
1253
+ new DataView(message.buffer).setUint32(tag.length + 32, index, true);
1254
+ return message;
1255
+ }
1256
+ var PREIMAGE_INDEX = 0;
1257
+ function isPerArtifactDescriptor(descriptor) {
1258
+ return parseHDDescriptor(descriptor) !== null;
1259
+ }
1260
+ async function provisionDescriptor(wallet) {
1261
+ const allocated = isHDAllocationCapable(wallet) ? await wallet.getNextSigningDescriptor() : void 0;
1262
+ return allocated ?? await identityDescriptor(wallet.identity);
1263
+ }
1264
+ async function provisionRefundKey(wallet) {
1265
+ const descriptor = await provisionDescriptor(wallet);
1266
+ const signer = await contractSigner(wallet, descriptor);
1267
+ return { descriptor, pubkey: await signer.xOnlyPublicKey() };
1268
+ }
1269
+ async function provisionClaimSecret(wallet, opts = {}) {
1270
+ if (opts.preimage && opts.preimage.length !== 32) {
1271
+ throw new Error(`preimage must be 32 bytes, got ${opts.preimage.length}`);
1272
+ }
1273
+ const { descriptor, pubkey } = await provisionRefundKey(wallet);
1274
+ const derivable = !opts.preimage && isPerArtifactDescriptor(descriptor);
1275
+ const preimage = opts.preimage ?? (derivable ? await derivePreimage(wallet, descriptor) : randomBytes(32));
1276
+ return {
1277
+ descriptor,
1278
+ pubkey,
1279
+ preimage,
1280
+ paymentHash: sha256(preimage),
1281
+ mustPersistPreimage: !derivable
1282
+ };
1283
+ }
1284
+ async function contractSigner(wallet, descriptor) {
1285
+ const signer = isHDWalletCapable(wallet) ? await wallet.signerForDescriptor(descriptor) : wallet.identity;
1286
+ let expected;
1287
+ try {
1288
+ expected = deriveDescriptorLeafPubKey(descriptor);
1289
+ } catch (cause) {
1290
+ throw new ForeignDescriptorError(descriptor, { cause });
1291
+ }
1292
+ const actual = await signer.xOnlyPublicKey();
1293
+ if (!equalBytes(actual, expected)) throw new ForeignDescriptorError(descriptor);
1294
+ if (!isSigningIdentity(signer)) throw new WalletCannotSignError(descriptor);
1295
+ return signer;
1296
+ }
1297
+ var WalletCannotSignError = class extends Error {
1298
+ constructor(descriptor) {
1299
+ super(`this wallet holds the key for ${descriptor} but cannot sign with it`);
1300
+ this.descriptor = descriptor;
1301
+ }
1302
+ descriptor;
1303
+ name = "WalletCannotSignError";
1304
+ };
1305
+ async function contractPreimage(wallet, descriptor, stored) {
1306
+ if (stored) {
1307
+ if (stored.length !== 32) {
1308
+ throw new Error(`stored preimage must be 32 bytes, got ${stored.length}`);
1309
+ }
1310
+ return stored;
1311
+ }
1312
+ if (!isPerArtifactDescriptor(descriptor)) {
1313
+ throw new Error(
1314
+ `descriptor ${descriptor} names no single artifact, so its preimage cannot be derived; none was stored`
1315
+ );
1316
+ }
1317
+ return derivePreimage(wallet, descriptor);
1318
+ }
1319
+ function isDeterministicSigner(value) {
1320
+ if (typeof value !== "object" || value === null) return false;
1321
+ const v = value;
1322
+ return typeof v.signSchnorrDeterministic === "function" && typeof v.xOnlyPublicKey === "function";
1323
+ }
1324
+ async function derivePreimage(wallet, descriptor) {
1325
+ const signer = await contractSigner(wallet, descriptor);
1326
+ if (!isDeterministicSigner(signer)) {
1327
+ throw new Error(
1328
+ `wallet cannot sign deterministically for ${descriptor}; its preimage is not derivable`
1329
+ );
1330
+ }
1331
+ const message = buildPreimageMessage(await signer.xOnlyPublicKey(), PREIMAGE_INDEX);
1332
+ try {
1333
+ return sha256(await signer.signSchnorrDeterministic(sha256(message)));
1334
+ } catch (cause) {
1335
+ throw new Error(
1336
+ `wallet cannot sign deterministically for ${descriptor}; its preimage is not derivable`,
1337
+ { cause }
1338
+ );
1339
+ }
1340
+ }
1341
+ async function adoptContractDescriptor(wallet, descriptor) {
1342
+ if (!isHDAllocationCapable(wallet)) return;
1343
+ if (!isPerArtifactDescriptor(descriptor)) return;
1344
+ if (isHDWalletCapable(wallet)) {
1345
+ try {
1346
+ await wallet.signerForDescriptor(descriptor);
1347
+ } catch (error) {
1348
+ if (error instanceof ForeignDescriptorError) return;
1349
+ throw error;
1350
+ }
1351
+ }
1352
+ await wallet.advanceSigningDescriptorWatermark(descriptor);
1353
+ }
1354
+
895
1355
  // src/worker/browser/service-worker-manager.ts
896
1356
  var registrations = /* @__PURE__ */ new Map();
897
1357
  var handshakes = /* @__PURE__ */ new WeakSet();
@@ -3118,6 +3578,44 @@ function validateRecipients(recipients, dustAmount, context) {
3118
3578
  return validatedRecipients;
3119
3579
  }
3120
3580
 
3581
+ // src/contracts/spendability.ts
3582
+ function isContractGenericallySpendable(contract) {
3583
+ return contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
3584
+ }
3585
+ function gatedContracts(contracts) {
3586
+ const gated = /* @__PURE__ */ new Map();
3587
+ for (const contract of contracts) {
3588
+ if (!isContractGenericallySpendable(contract)) gated.set(contract.script, contract.type);
3589
+ }
3590
+ return gated;
3591
+ }
3592
+ function gateExclusion(gated) {
3593
+ return (vtxo) => {
3594
+ const type = vtxo.script === void 0 ? void 0 : gated.get(vtxo.script);
3595
+ if (type === void 0) return void 0;
3596
+ return `at ${vtxo.script} (contract type '${type}') is not generically spendable`;
3597
+ };
3598
+ }
3599
+ function outpointExclusion(outpoints, reason) {
3600
+ return (vtxo) => outpoints.has(`${vtxo.txid}:${vtxo.vout}`) ? reason : void 0;
3601
+ }
3602
+ function outpointReasons(reasons) {
3603
+ return (vtxo) => reasons.get(`${vtxo.txid}:${vtxo.vout}`);
3604
+ }
3605
+ function logExcludedVtxos(source, vtxos, exclusions) {
3606
+ if (exclusions.length === 0) return;
3607
+ for (const vtxo of vtxos) {
3608
+ for (const exclusion of exclusions) {
3609
+ const reason = exclusion(vtxo);
3610
+ if (reason === void 0) continue;
3611
+ console.debug(`[spendability] ${source}: ${vtxo.txid}:${vtxo.vout} ${reason}`);
3612
+ }
3613
+ }
3614
+ }
3615
+ var UnannotatableInputError = class extends Error {
3616
+ name = "UnannotatableInputError";
3617
+ };
3618
+
3121
3619
  // src/wallet/vtxo-manager.ts
3122
3620
  function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSeconds = Math.floor(Date.now() / 1e3)) {
3123
3621
  const out = /* @__PURE__ */ new Set();
@@ -3400,6 +3898,27 @@ var VtxoManager = class _VtxoManager {
3400
3898
  static MIGRATION_COOLDOWN_MS = 3e4;
3401
3899
  static MIGRATION_MAX_BACKOFF_MS = 5 * 60 * 1e3;
3402
3900
  // ========== Recovery Methods ==========
3901
+ /**
3902
+ * Outpoints recovery must not name yet, with the reason each was refused.
3903
+ * Empty when the manager offers no opinion — an embedder's may not implement
3904
+ * the predicate, and every contract type but VHTLC never answers.
3905
+ *
3906
+ * Reaches only a lockup whose `sender` is this wallet's own key: role
3907
+ * resolution matches that key against the contract's params, so a
3908
+ * descriptor-derived sender (every RFQ lockup) is not matched and such a row
3909
+ * still fails its batch at submit.
3910
+ *
3911
+ * The key stays a thunk so an ordinary recovery never touches the identity,
3912
+ * and the full coins are passed rather than bare outpoints because only they
3913
+ * carry the confirmation a relative timelock is measured from.
3914
+ */
3915
+ async unspendableNow(vtxos) {
3916
+ const contractManager = await this.wallet.getContractManager();
3917
+ return await contractManager.unspendableNowReasons?.(
3918
+ vtxos,
3919
+ async () => hex.encode(await this.wallet.identity.xOnlyPublicKey())
3920
+ ) ?? /* @__PURE__ */ new Map();
3921
+ }
3403
3922
  /**
3404
3923
  * Recover swept/expired virtual outputs by settling them back to the wallet's Arkade address.
3405
3924
  *
@@ -3412,6 +3931,11 @@ var VtxoManager = class _VtxoManager {
3412
3931
  * Note: Settled virtual outputs with long expiry are NOT recovered to avoid locking liquidity unnecessarily.
3413
3932
  * Only preconfirmed subdust is recovered to consolidate small amounts.
3414
3933
  *
3934
+ * Inputs whose contract refuses a spend right now — an immature VHTLC refund
3935
+ * path — are skipped rather than failing the batch that holds them, and
3936
+ * {@link getRecoverableBalance} skips the same set. See
3937
+ * {@link unspendableNow} for which rows that reaches.
3938
+ *
3415
3939
  * @param eventCallback - Optional callback to receive settlement events
3416
3940
  * @returns Settlement transaction ID
3417
3941
  * @throws Error if no recoverable virtual outputs found
@@ -3440,6 +3964,26 @@ var VtxoManager = class _VtxoManager {
3440
3964
  if (vtxosToRecover.length === 0) {
3441
3965
  throw new Error("No recoverable VTXOs found");
3442
3966
  }
3967
+ const refused = await this.unspendableNow(vtxosToRecover);
3968
+ if (refused.size > 0) {
3969
+ logExcludedVtxos("recoverVtxos", vtxosToRecover, [outpointReasons(refused)]);
3970
+ const held = vtxosToRecover.length;
3971
+ vtxosToRecover = vtxosToRecover.filter(
3972
+ (vtxo) => !refused.has(`${vtxo.txid}:${vtxo.vout}`)
3973
+ );
3974
+ if (vtxosToRecover.length === 0) {
3975
+ const why = refused.size === 1 ? [...refused.values()][0] : [...refused].map(([outpoint, reason]) => `${outpoint}: ${reason}`).join("; ");
3976
+ throw new Error(
3977
+ `All ${held} recoverable VTXO(s) are held by a contract that refuses a spend right now: ${why}`
3978
+ );
3979
+ }
3980
+ ({ vtxosToRecover } = getRecoverableWithSubdust(vtxosToRecover, dustAmount, now));
3981
+ if (vtxosToRecover.length === 0) {
3982
+ throw new Error(
3983
+ `Excluding ${refused.size} VTXO(s) not yet spendable, the remaining recoverable amount is below the dust threshold ${dustAmount}`
3984
+ );
3985
+ }
3986
+ }
3443
3987
  const info = await this.getInfoProvider()?.getInfo();
3444
3988
  const vtxoMaxAmount = info?.vtxoMaxAmount ?? -1n;
3445
3989
  const estimator = new Estimator(info?.fees.intentFee ?? {});
@@ -3503,6 +4047,11 @@ var VtxoManager = class _VtxoManager {
3503
4047
  * The batch size caps are not applied here: they defer the overflow to the
3504
4048
  * next cycle rather than reducing what is recoverable.
3505
4049
  *
4050
+ * Inputs a contract refuses right now are excluded, so this and
4051
+ * {@link recoverVtxos} answer over the same set. `Balance.recoverable` still
4052
+ * counts them: that field reports what the wallet owns, this one what a
4053
+ * batch would hand back today.
4054
+ *
3506
4055
  * @returns Object containing recoverable amounts and subdust information
3507
4056
  *
3508
4057
  * @example
@@ -3524,11 +4073,24 @@ var VtxoManager = class _VtxoManager {
3524
4073
  withUnrolled: false
3525
4074
  });
3526
4075
  const dustAmount = getDustAmount(this.wallet);
3527
- const { vtxosToRecover, includesSubdust } = getRecoverableWithSubdust(
4076
+ const now = await fetchTimeHeight(this.wallet);
4077
+ let { vtxosToRecover, includesSubdust } = getRecoverableWithSubdust(
3528
4078
  allVtxos,
3529
4079
  dustAmount,
3530
- await fetchTimeHeight(this.wallet)
4080
+ now
3531
4081
  );
4082
+ const refused = await this.unspendableNow(vtxosToRecover);
4083
+ if (refused.size > 0) {
4084
+ logExcludedVtxos("getRecoverableBalance", vtxosToRecover, [outpointReasons(refused)]);
4085
+ const remaining = vtxosToRecover.filter(
4086
+ (vtxo) => !refused.has(`${vtxo.txid}:${vtxo.vout}`)
4087
+ );
4088
+ ({ vtxosToRecover, includesSubdust } = getRecoverableWithSubdust(
4089
+ remaining,
4090
+ dustAmount,
4091
+ now
4092
+ ));
4093
+ }
3532
4094
  const info = await this.getInfoProvider()?.getInfo();
3533
4095
  const estimator = new Estimator(info?.fees.intentFee ?? {});
3534
4096
  const { payable, net } = priceSettlementInputs(vtxosToRecover, estimator);
@@ -4770,7 +5332,7 @@ var ArkNote = class _ArkNote {
4770
5332
  this.preimage = preimage;
4771
5333
  this.value = value;
4772
5334
  this.HRP = HRP;
4773
- const preimageHash = sha256(this.preimage);
5335
+ const preimageHash = sha256$1(this.preimage);
4774
5336
  this.vtxoScript = new VtxoScript([noteTapscript(preimageHash)]);
4775
5337
  const leaf = this.vtxoScript.leaves[0];
4776
5338
  this.txid = hex.encode(new Uint8Array(preimageHash).reverse());
@@ -7590,41 +8152,6 @@ function mergeByKey(existing, incoming, toKey) {
7590
8152
  });
7591
8153
  return Array.from(next.values());
7592
8154
  }
7593
-
7594
- // src/contracts/spendability.ts
7595
- function isContractGenericallySpendable(contract) {
7596
- return contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
7597
- }
7598
- function gatedContracts(contracts) {
7599
- const gated = /* @__PURE__ */ new Map();
7600
- for (const contract of contracts) {
7601
- if (!isContractGenericallySpendable(contract)) gated.set(contract.script, contract.type);
7602
- }
7603
- return gated;
7604
- }
7605
- function gateExclusion(gated) {
7606
- return (vtxo) => {
7607
- const type = vtxo.script === void 0 ? void 0 : gated.get(vtxo.script);
7608
- if (type === void 0) return void 0;
7609
- return `at ${vtxo.script} (contract type '${type}') is not generically spendable`;
7610
- };
7611
- }
7612
- function outpointExclusion(outpoints, reason) {
7613
- return (vtxo) => outpoints.has(`${vtxo.txid}:${vtxo.vout}`) ? reason : void 0;
7614
- }
7615
- function logExcludedVtxos(source, vtxos, exclusions) {
7616
- if (exclusions.length === 0) return;
7617
- for (const vtxo of vtxos) {
7618
- for (const exclusion of exclusions) {
7619
- const reason = exclusion(vtxo);
7620
- if (reason === void 0) continue;
7621
- console.debug(`[spendability] ${source}: ${vtxo.txid}:${vtxo.vout} ${reason}`);
7622
- }
7623
- }
7624
- }
7625
- var UnannotatableInputError = class extends Error {
7626
- name = "UnannotatableInputError";
7627
- };
7628
8155
  var ARKCONTRACT_PREFIX = "arkcontract";
7629
8156
  function encodeArkContract(contract) {
7630
8157
  const params = new URLSearchParams();
@@ -9065,7 +9592,17 @@ var ContractManager = class _ContractManager {
9065
9592
  }
9066
9593
  /** @inheritdoc */
9067
9594
  async assertSpendableNow(vtxos, walletPubKey) {
9068
- if (vtxos.length === 0) return;
9595
+ const refused = await this.unspendableNowReasons(vtxos, walletPubKey);
9596
+ if (refused.size === 0) return;
9597
+ if (refused.size === 1) throw new Error([...refused.values()][0]);
9598
+ throw new Error(
9599
+ `refusing to spend ${refused.size} vtxo(s) that cannot be spent yet: ` + [...refused].map(([outpoint, why]) => `${outpoint}: ${why}`).join("; ")
9600
+ );
9601
+ }
9602
+ /** @inheritdoc */
9603
+ async unspendableNowReasons(vtxos, walletPubKey) {
9604
+ const refused = /* @__PURE__ */ new Map();
9605
+ if (vtxos.length === 0) return refused;
9069
9606
  const contracts = await this.config.contractRepository.getContracts({
9070
9607
  script: Array.from(new Set(vtxos.map((vtxo) => vtxo.script)))
9071
9608
  });
@@ -9074,7 +9611,7 @@ var ContractManager = class _ContractManager {
9074
9611
  const contract = byScript.get(vtxo.script);
9075
9612
  return contract !== void 0 && contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
9076
9613
  });
9077
- if (asking.length === 0) return;
9614
+ if (asking.length === 0) return refused;
9078
9615
  const tip = await this.currentChainTip();
9079
9616
  const walletKey = await walletPubKey?.();
9080
9617
  for (const vtxo of asking) {
@@ -9096,12 +9633,20 @@ var ContractManager = class _ContractManager {
9096
9633
  // really is one.
9097
9634
  vtxo: isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
9098
9635
  };
9099
- await handler.assertSpendableNow(
9100
- handler.createScript(contract.params),
9101
- contract,
9102
- context
9103
- );
9636
+ try {
9637
+ await handler.assertSpendableNow(
9638
+ handler.createScript(contract.params),
9639
+ contract,
9640
+ context
9641
+ );
9642
+ } catch (err) {
9643
+ refused.set(
9644
+ `${vtxo.txid}:${vtxo.vout}`,
9645
+ err instanceof Error ? err.message : String(err)
9646
+ );
9647
+ }
9104
9648
  }
9649
+ return refused;
9105
9650
  }
9106
9651
  // Field-by-field, so every filter a caller can express reaches the
9107
9652
  // repository. A field missing here is not a narrower query — it is an
@@ -13049,15 +13594,24 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
13049
13594
  return provider.getCurrentSigningDescriptor();
13050
13595
  }
13051
13596
  /**
13052
- * @see HDWalletCapable.getNextSigningDescriptor
13597
+ * @see HDAllocationCapable.getNextSigningDescriptor
13598
+ *
13599
+ * Every `Wallet` answers — this is where the wallet's key-provisioning
13600
+ * policy lives, so consumers never have to branch on wallet shape:
13601
+ * - HD: allocate a fresh index through the contract manager (which owns
13602
+ * cross-context serialization and the look-ahead band).
13603
+ * - custom provider: whatever the provider allocates.
13604
+ * - static / `auto`: the identity key as a bare `tr(pubkey)` descriptor —
13605
+ * the same answer every call, because that IS the static policy.
13053
13606
  */
13054
13607
  async getNextSigningDescriptor() {
13055
- const provider = this._descriptorProvider;
13056
- if (!(provider instanceof HDDescriptorProvider)) return void 0;
13057
- return (await this.getContractManager()).getNextSigningDescriptor();
13608
+ if (this._descriptorProvider instanceof HDDescriptorProvider) {
13609
+ return (await this.getContractManager()).getNextSigningDescriptor();
13610
+ }
13611
+ return identityDescriptor(this.identity);
13058
13612
  }
13059
13613
  /**
13060
- * @see HDWalletCapable.advanceSigningDescriptorWatermark
13614
+ * @see HDAllocationCapable.advanceSigningDescriptorWatermark
13061
13615
  */
13062
13616
  async advanceSigningDescriptorWatermark(descriptor) {
13063
13617
  const provider = this._descriptorProvider;
@@ -13110,13 +13664,16 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
13110
13664
  }
13111
13665
  /**
13112
13666
  * @see HDWalletCapable.signerForDescriptor
13667
+ *
13668
+ * Fail-loud contract: the returned identity is always the descriptor's
13669
+ * own key. A descriptor this wallet cannot sign for throws
13670
+ * {@link ForeignDescriptorError} instead of silently substituting the
13671
+ * baseline identity — that identity would sign happily with the wrong
13672
+ * key, and the failure would only surface as a rejected transaction or a
13673
+ * dead script, far from the call that caused it.
13113
13674
  */
13114
13675
  async signerForDescriptor(descriptor) {
13115
- const provider = this._descriptorProvider;
13116
- if (!(provider instanceof HDDescriptorProvider) || !provider.isOurs(descriptor)) {
13117
- return this.identity;
13118
- }
13119
- return new DescriptorIdentity({ descriptor, signer: provider, base: this.identity });
13676
+ return resolveDescriptorSigner(descriptor, this.identity, this._descriptorProvider);
13120
13677
  }
13121
13678
  /**
13122
13679
  * Mid-session server-signer rotation (plan §4). When arkd rotates its
@@ -13322,7 +13879,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
13322
13879
  const manager = await this.getContractManager();
13323
13880
  const provider = this._descriptorProvider;
13324
13881
  const hd = provider instanceof HDDescriptorProvider;
13325
- const staticDescriptor = hd ? void 0 : `tr(${hex.encode(await this.identity.xOnlyPublicKey())})`;
13882
+ const staticDescriptor = hd ? void 0 : await identityDescriptor(this.identity);
13326
13883
  const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
13327
13884
  const delegatePubKey = this.offchainTapscript instanceof DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
13328
13885
  const arkInfo = await this.arkProvider.getInfo();
@@ -14099,7 +14656,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14099
14656
  return {
14100
14657
  onBatchStarted: async (event) => {
14101
14658
  const utf8IntentId = new TextEncoder().encode(intentId);
14102
- const intentIdHash = sha256(utf8IntentId);
14659
+ const intentIdHash = sha256$1(utf8IntentId);
14103
14660
  const intentIdHashStr = hex.encode(intentIdHash);
14104
14661
  const skip = !event.intentIdHashes.includes(intentIdHashStr);
14105
14662
  if (skip) {
@@ -17298,10 +17855,6 @@ function getRequestDedupKey(request) {
17298
17855
  const { id, tag, ...rest } = request;
17299
17856
  return JSON.stringify(rest);
17300
17857
  }
17301
- function isSigningCapable(identity) {
17302
- const candidate = identity;
17303
- return typeof candidate.signMessage === "function" && typeof candidate.sign === "function" && typeof candidate.signerSession === "function";
17304
- }
17305
17858
  var ServiceWorkerReadonlyAssetManager = class {
17306
17859
  constructor(sendMessage, messageTag) {
17307
17860
  this.sendMessage = sendMessage;
@@ -18009,7 +18562,15 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
18009
18562
  */
18010
18563
  async assertAnnotatable() {
18011
18564
  },
18012
- /** Same reasoning as {@link assertAnnotatable}: the worker checks it. */
18565
+ /**
18566
+ * Same reasoning as {@link assertAnnotatable}: the worker checks it.
18567
+ *
18568
+ * `unspendableNowReasons` is deliberately absent rather than stubbed
18569
+ * alongside it. A stub returning an empty map reads as "nothing
18570
+ * refused", and a filter acting on that silently drops its decision;
18571
+ * absent, the optional call is skipped. Recovery — the only caller —
18572
+ * runs inside the worker against the real manager anyway.
18573
+ */
18013
18574
  async assertSpendableNow() {
18014
18575
  },
18015
18576
  async annotateVtxos(vtxos) {
@@ -18235,7 +18796,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
18235
18796
  }
18236
18797
  const walletRepository = options.storage?.walletRepository ?? new IndexedDBWalletRepository();
18237
18798
  const contractRepository = options.storage?.contractRepository ?? new IndexedDBContractRepository();
18238
- if (!isSigningCapable(options.identity)) {
18799
+ if (!isSigningIdentity(options.identity)) {
18239
18800
  throw new Error(
18240
18801
  "ServiceWorkerWallet.create() requires a signing Identity; got a ReadonlyIdentity"
18241
18802
  );
@@ -18395,17 +18956,21 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
18395
18956
  /**
18396
18957
  * @see HDWalletCapable.signerForDescriptor
18397
18958
  *
18398
- * Runs page-side: an Identity cannot cross the message bus, and it does
18399
- * not need to — the page owns the signing identity, and derivation reads
18400
- * no allocation state. Mirrors {@link Wallet.signerForDescriptor}'s
18401
- * fallback: the wallet identity itself for a non-HD identity or a foreign
18959
+ * Runs page-side: an `Identity` cannot cross the message bus, and it does
18960
+ * not need to — the page owns the signing identity, and resolving a
18961
+ * descriptor reads no allocation state. Shares
18962
+ * {@link resolveDescriptorSigner} with {@link Wallet.signerForDescriptor}
18963
+ * so the two sides of the bus cannot answer differently for one
18402
18964
  * descriptor.
18965
+ *
18966
+ * No provider is passed, and none is needed: `HDDescriptorProvider`'s
18967
+ * `isOurs` and signing members all delegate to the identity, which the
18968
+ * page holds. Building one here would only add a page-side read of the
18969
+ * wallet state the worker allocates from — shared mutable state on a path
18970
+ * that has no business touching it.
18403
18971
  */
18404
18972
  async signerForDescriptor(descriptor) {
18405
- if (!isHDCapableIdentity(this.identity)) return this.identity;
18406
- const provider = await HDDescriptorProvider.create(this.identity, this.walletRepository);
18407
- if (!provider.isOurs(descriptor)) return this.identity;
18408
- return new DescriptorIdentity({ descriptor, signer: provider, base: this.identity });
18973
+ return resolveDescriptorSigner(descriptor, this.identity);
18409
18974
  }
18410
18975
  async sendBitcoin(params) {
18411
18976
  const message = {
@@ -18975,8 +19540,8 @@ function parseBlockHeader(headerHex) {
18975
19540
  }
18976
19541
  const view = new DataView(headerBytes.buffer, headerBytes.byteOffset);
18977
19542
  const timestamp = view.getUint32(68, true);
18978
- const hash1 = sha256(headerBytes);
18979
- const hash2 = sha256(hash1);
19543
+ const hash1 = sha256$1(headerBytes);
19544
+ const hash2 = sha256$1(hash1);
18980
19545
  const hashStr = hex.encode(new Uint8Array(hash2).reverse());
18981
19546
  return { hash: hashStr, timestamp };
18982
19547
  }
@@ -19594,7 +20159,7 @@ var ElectrumOnchainProvider = class {
19594
20159
  }
19595
20160
  };
19596
20161
  function toScriptHash(script) {
19597
- return hex.encode(sha256(script).reverse());
20162
+ return hex.encode(sha256$1(script).reverse());
19598
20163
  }
19599
20164
  function isHeaderSubscribeResult(v) {
19600
20165
  if (typeof v !== "object" || v === null) return false;
@@ -21035,7 +21600,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
21035
21600
  return {
21036
21601
  onBatchStarted: async (event) => {
21037
21602
  const utf8IntentId = new TextEncoder().encode(intentId);
21038
- const intentIdHash = sha256(utf8IntentId);
21603
+ const intentIdHash = sha256$1(utf8IntentId);
21039
21604
  const intentIdHashStr = hex.encode(intentIdHash);
21040
21605
  if (!event.intentIdHashes.includes(intentIdHashStr)) return { skip: true };
21041
21606
  const info = await arkProvider.getInfo();
@@ -22020,7 +22585,12 @@ function createDefaultPaymentRouter(wallet) {
22020
22585
  prefs: { priority: ["ark", "lightning", "onchain"] }
22021
22586
  }).use(arkRail()).use(onchainRail());
22022
22587
  }
22588
+ /*! Bundled license information:
22589
+
22590
+ @noble/hashes/utils.js:
22591
+ (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
22592
+ */
22023
22593
 
22024
- 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, 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, P2A, PaymentRouter, 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, WalletMessageHandler, WalletNotInitializedError, WalletRepositoryImpl, WsElectrumChainSource, arkRail, arkTarget, arkade_exports, assertFinalCommitmentMatchesValidated, assertIntentIdUnique, assertSendableAmount, assertSubmittedArkTxid, assertValidBatchExpiry, assertValidServerUnrollScript, assetMintResolver, boardingResolver, btcTarget, buildForfeitTx, buildOffchainTx, claimWithPreimageIdentity, classifyAgainstSignerSet, classifyContractSigner, closeDatabase, collabExitResolver, combineTapscriptSigs, contractFromArkContract, contractFromArkContractWithAddress, createAssetPacket, createDefaultActivityRegistry, createDefaultPaymentRouter, createExitChainResolver, decodeArkContract, defaultBatchExpiryPolicy, defaultCheckpointExitDelayPolicy, deserializeAssets, deserializeExitPackage, deserializeUtxo, deserializeVtxo, encodeArkContract, extendVirtualCoinForContract, gateExclusion, gatedContracts, getMigrationStatus, getRandomId, hasBoardingTxExpired, hasCandidates, intentMatchesFilter, intentPageBounds, invoiceTarget, isArkContract, isBatchSignable, isBtcAddress, isContractGenericallySpendable, isCooperativelyMigratable, isDiscoverable, isHDAllocationCapable, isHDDeterministicSignCapable, isHDWalletCapable, isLightningInvoice, isLnurl, isMessageBusInitializingError, isMessageBusNotInitializedError, isSubdust, isTerminalIntentState, isValidArkAddress, isVtxoExpiringSoon, isVtxoForScript, isWatchedContract, logExcludedVtxos, makeHandle, matchServerCheckpoints, mergeChainedTxType, migrateWalletRepository, onchainRail, openDatabase, outpointExclusion, requiresMigration, resolveBatchExpiryPolicy, resolveCheckpointExitDelayPolicy, resolveSendAmount, rollbackMigration, saveVtxosForContract, scriptFromArkAddress, selectCoinsWithAsset, selectVirtualCoins, serializeAssets, serializeExitPackage, serializeUtxo, serializeVtxo, setupServiceWorker, signAndSubmitOffchainTx, signerSetFromInfo, signingDescriptorIndex, strictSigningDescriptorIndex, toXOnlySignerHex, tryResolveSendAmount, validateBatchRecipients, validateConnectorsTxGraph, validateVtxoTxGraph, verifyTapscriptSignatures, waitForIncomingFunds, warnAndFilterVtxosForScript };
22025
- //# sourceMappingURL=chunk-Y54MUBT7.js.map
22026
- //# sourceMappingURL=chunk-Y54MUBT7.js.map
22594
+ export { ARKADE_MAGIC, ARKADE_SWAP_PREIMAGE_TAG, 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, 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, P2A, PaymentRouter, 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, WalletCannotSignError, WalletMessageHandler, WalletNotInitializedError, WalletRepositoryImpl, WsElectrumChainSource, adoptContractDescriptor, arkRail, arkTarget, arkade_exports, assertFinalCommitmentMatchesValidated, assertIntentIdUnique, assertSendableAmount, assertSubmittedArkTxid, assertValidBatchExpiry, assertValidServerUnrollScript, assetMintResolver, boardingResolver, btcTarget, buildForfeitTx, buildOffchainTx, buildPreimageMessage, claimWithPreimageIdentity, classifyAgainstSignerSet, classifyContractSigner, closeDatabase, collabExitResolver, combineTapscriptSigs, contractFromArkContract, contractFromArkContractWithAddress, contractPreimage, contractSigner, createAssetPacket, createDefaultActivityRegistry, createDefaultPaymentRouter, createExitChainResolver, decodeArkContract, defaultBatchExpiryPolicy, defaultCheckpointExitDelayPolicy, deserializeAssets, deserializeExitPackage, deserializeUtxo, deserializeVtxo, encodeArkContract, extendVirtualCoinForContract, gateExclusion, gatedContracts, getMigrationStatus, getRandomId, hasBoardingTxExpired, hasCandidates, intentMatchesFilter, intentPageBounds, invoiceTarget, isArkContract, isBatchSignable, isBtcAddress, isContractGenericallySpendable, isCooperativelyMigratable, isDeterministicSigner, isDiscoverable, isHDAllocationCapable, isHDDeterministicSignCapable, isHDWalletCapable, isLightningInvoice, isLnurl, isMessageBusInitializingError, isMessageBusNotInitializedError, isPerArtifactDescriptor, isSigningIdentity, isSubdust, isTerminalIntentState, isValidArkAddress, isVtxoExpiringSoon, isVtxoForScript, isWatchedContract, logExcludedVtxos, makeHandle, matchServerCheckpoints, mergeChainedTxType, migrateWalletRepository, onchainRail, openDatabase, outpointExclusion, outpointReasons, provisionClaimSecret, provisionRefundKey, requiresMigration, resolveBatchExpiryPolicy, resolveCheckpointExitDelayPolicy, resolveDescriptorSigner, resolveSendAmount, rollbackMigration, saveVtxosForContract, scriptFromArkAddress, selectCoinsWithAsset, selectVirtualCoins, serializeAssets, serializeExitPackage, serializeUtxo, serializeVtxo, setupServiceWorker, signAndSubmitOffchainTx, signerSetFromInfo, signingDescriptorIndex, strictSigningDescriptorIndex, toXOnlySignerHex, tryResolveSendAmount, validateBatchRecipients, validateConnectorsTxGraph, validateVtxoTxGraph, verifyTapscriptSignatures, waitForIncomingFunds, warnAndFilterVtxosForScript };
22595
+ //# sourceMappingURL=chunk-AUEXB42T.js.map
22596
+ //# sourceMappingURL=chunk-AUEXB42T.js.map