@arkade-os/sdk 0.4.78 → 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.
- package/README.md +1 -1
- package/dist/adapters/expo.cjs +5 -5
- package/dist/adapters/expo.d.cts +3 -3
- package/dist/adapters/expo.d.ts +3 -3
- package/dist/adapters/expo.js +3 -3
- package/dist/{asyncStorageTaskQueue-YW2t31_o.d.ts → asyncStorageTaskQueue-C5yQLJhm.d.ts} +1 -1
- package/dist/{asyncStorageTaskQueue-DiXxP-nQ.d.cts → asyncStorageTaskQueue-Shsih-1l.d.cts} +1 -1
- package/dist/{chunk-ZOCJ7E6M.js → chunk-4MXW2NDN.js} +10 -515
- package/dist/chunk-4MXW2NDN.js.map +1 -0
- package/dist/{chunk-KEEZSFLI.cjs → chunk-54FXLZ3T.cjs} +10 -10
- package/dist/{chunk-KEEZSFLI.cjs.map → chunk-54FXLZ3T.cjs.map} +1 -1
- package/dist/{chunk-PWIESIO6.cjs → chunk-DAYCCIRO.cjs} +372 -198
- package/dist/chunk-DAYCCIRO.cjs.map +1 -0
- package/dist/{chunk-Y7BVR6SQ.cjs → chunk-FUW3OM5X.cjs} +76 -561
- package/dist/chunk-FUW3OM5X.cjs.map +1 -0
- package/dist/{chunk-VJ7M6WKB.cjs → chunk-HAM3SHBV.cjs} +587 -532
- package/dist/chunk-HAM3SHBV.cjs.map +1 -0
- package/dist/{chunk-7KIGEOYT.js → chunk-JCPVP7TJ.js} +373 -201
- package/dist/chunk-JCPVP7TJ.js.map +1 -0
- package/dist/{chunk-DFWLP3MD.cjs → chunk-LASRYLMQ.cjs} +17 -17
- package/dist/{chunk-DFWLP3MD.cjs.map → chunk-LASRYLMQ.cjs.map} +1 -1
- package/dist/{chunk-CTFYT24G.js → chunk-QDXOTONI.js} +3 -3
- package/dist/{chunk-CTFYT24G.js.map → chunk-QDXOTONI.js.map} +1 -1
- package/dist/{chunk-IAM5IEVT.cjs → chunk-SJPPBR2V.cjs} +17 -17
- package/dist/{chunk-IAM5IEVT.cjs.map → chunk-SJPPBR2V.cjs.map} +1 -1
- package/dist/{chunk-P766MOPU.js → chunk-SK4OZRMB.js} +4 -4
- package/dist/{chunk-P766MOPU.js.map → chunk-SK4OZRMB.js.map} +1 -1
- package/dist/{chunk-OUHUC26M.js → chunk-VAFNWP3I.js} +4 -4
- package/dist/{chunk-OUHUC26M.js.map → chunk-VAFNWP3I.js.map} +1 -1
- package/dist/{chunk-LKAASQTL.js → chunk-YPQ37P3H.js} +128 -73
- package/dist/chunk-YPQ37P3H.js.map +1 -0
- package/dist/contracts/handlers/index.cjs +9 -9
- package/dist/contracts/handlers/index.d.cts +4 -4
- package/dist/contracts/handlers/index.d.ts +4 -4
- package/dist/contracts/handlers/index.js +2 -2
- package/dist/{delegate-DaNNUI_B.d.cts → delegate-B4bKASut.d.cts} +1 -1
- package/dist/{delegate-b2Wiymoj.d.ts → delegate-C9lpdrb0.d.ts} +1 -1
- package/dist/{hdWalletCapable-B2XVTOvu.d.ts → hdWalletCapable-CUJDKRKO.d.cts} +2 -3
- package/dist/{hdWalletCapable-D6PqWpuW.d.cts → hdWalletCapable-DJClhYMC.d.ts} +2 -3
- package/dist/{index-CAS4GyN-.d.ts → index-Ctul0N3Y.d.cts} +27 -6
- package/dist/{index-CAS4GyN-.d.cts → index-Ctul0N3Y.d.ts} +27 -6
- package/dist/{index-CYsKAXog.d.ts → index-D0qe2qVY.d.ts} +2 -2
- package/dist/{index-BlB97fYl.d.cts → index-YBFmScVS.d.cts} +2 -2
- package/dist/index.cjs +304 -304
- package/dist/index.d.cts +123 -123
- package/dist/index.d.ts +123 -123
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +20 -20
- package/dist/repositories/realm/index.d.cts +3 -3
- package/dist/repositories/realm/index.d.ts +3 -3
- package/dist/repositories/realm/index.js +5 -5
- package/dist/repositories/sqlite/index.cjs +19 -19
- package/dist/repositories/sqlite/index.d.cts +3 -3
- package/dist/repositories/sqlite/index.d.ts +3 -3
- package/dist/repositories/sqlite/index.js +5 -5
- package/dist/{taskRunner-BJj7xe35.d.ts → taskRunner-C08egG5a.d.ts} +1 -1
- package/dist/{taskRunner-HS2d2oda.d.cts → taskRunner-DB17db5n.d.cts} +1 -1
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.d.cts +4 -4
- package/dist/wallet/expo/background.d.ts +4 -4
- package/dist/wallet/expo/background.js +6 -6
- package/dist/wallet/expo/index.cjs +14 -14
- package/dist/wallet/expo/index.d.cts +5 -5
- package/dist/wallet/expo/index.d.ts +5 -5
- package/dist/wallet/expo/index.js +5 -5
- package/dist/worker/expo/index.cjs +9 -9
- package/dist/worker/expo/index.d.cts +5 -5
- package/dist/worker/expo/index.d.ts +5 -5
- package/dist/worker/expo/index.js +5 -5
- package/package.json +6 -5
- package/dist/chunk-7KIGEOYT.js.map +0 -1
- package/dist/chunk-LKAASQTL.js.map +0 -1
- package/dist/chunk-PWIESIO6.cjs.map +0 -1
- package/dist/chunk-VJ7M6WKB.cjs.map +0 -1
- package/dist/chunk-Y7BVR6SQ.cjs.map +0 -1
- package/dist/chunk-ZOCJ7E6M.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkSJPPBR2V_cjs = require('./chunk-SJPPBR2V.cjs');
|
|
4
|
+
var chunkFUW3OM5X_cjs = require('./chunk-FUW3OM5X.cjs');
|
|
5
|
+
var chunkDAYCCIRO_cjs = require('./chunk-DAYCCIRO.cjs');
|
|
6
6
|
var chunk5BLDMQED_cjs = require('./chunk-5BLDMQED.cjs');
|
|
7
7
|
var utils_js = require('@scure/btc-signer/utils.js');
|
|
8
8
|
var btcSigner = require('@scure/btc-signer');
|
|
@@ -188,7 +188,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
188
188
|
noncesByPubkey.set(base.hex.encode(myPublicKey.subarray(1)), myNonce);
|
|
189
189
|
const tx = this.graph.find(txid);
|
|
190
190
|
if (!tx) throw new Error(`missing tx for txid ${txid}`);
|
|
191
|
-
const cosigners =
|
|
191
|
+
const cosigners = chunkDAYCCIRO_cjs.getArkPsbtFields(tx.root, 0, chunkDAYCCIRO_cjs.CosignerPublicKey).map(
|
|
192
192
|
(c) => base.hex.encode(c.key.subarray(1))
|
|
193
193
|
// xonly pubkey
|
|
194
194
|
);
|
|
@@ -240,7 +240,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
240
240
|
if (!aggNonce) throw new Error("missing aggregate nonce");
|
|
241
241
|
const prevoutAmounts = [];
|
|
242
242
|
const prevoutScripts = [];
|
|
243
|
-
const cosigners =
|
|
243
|
+
const cosigners = chunkDAYCCIRO_cjs.getArkPsbtFields(g.root, 0, chunkDAYCCIRO_cjs.CosignerPublicKey).map((c) => c.key);
|
|
244
244
|
const { finalKey } = aggregateKeys(cosigners, true, {
|
|
245
245
|
taprootTweak: this.scriptRoot
|
|
246
246
|
});
|
|
@@ -323,7 +323,7 @@ var SingleKey = class _SingleKey {
|
|
|
323
323
|
async sign(tx, inputIndexes) {
|
|
324
324
|
const txCpy = tx.clone();
|
|
325
325
|
if (!inputIndexes) {
|
|
326
|
-
|
|
326
|
+
chunkDAYCCIRO_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH);
|
|
327
327
|
try {
|
|
328
328
|
if (!txCpy.sign(this.key, ALLOWED_SIGHASH)) {
|
|
329
329
|
throw new Error("Failed to sign transaction");
|
|
@@ -432,7 +432,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
432
432
|
let network;
|
|
433
433
|
if ("descriptor" in opts && typeof opts.descriptor === "string") {
|
|
434
434
|
descriptor = opts.descriptor;
|
|
435
|
-
network =
|
|
435
|
+
network = chunkFUW3OM5X_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
436
436
|
} else {
|
|
437
437
|
network = opts.isMainnet ?? true ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
438
438
|
descriptor = descriptorsScure.scriptExpressions.trBIP32({
|
|
@@ -530,7 +530,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
530
530
|
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
531
531
|
*/
|
|
532
532
|
isOurs(descriptor) {
|
|
533
|
-
return
|
|
533
|
+
return chunkFUW3OM5X_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
|
|
534
534
|
}
|
|
535
535
|
/**
|
|
536
536
|
* Signs each request with the key derived from its descriptor.
|
|
@@ -579,7 +579,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
579
579
|
}
|
|
580
580
|
// ── internal helpers ─────────────────────────────────────────────
|
|
581
581
|
derivePrivateKeyForDescriptor(descriptor) {
|
|
582
|
-
const network =
|
|
582
|
+
const network = chunkFUW3OM5X_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
583
583
|
const expansion = descriptorsScure.expand({ descriptor, network });
|
|
584
584
|
if (expansion.isRanged) {
|
|
585
585
|
throw new Error(
|
|
@@ -604,7 +604,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
604
604
|
signTxWithKey(tx, key, inputIndexes) {
|
|
605
605
|
const txCpy = tx.clone();
|
|
606
606
|
if (!inputIndexes) {
|
|
607
|
-
|
|
607
|
+
chunkDAYCCIRO_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH2);
|
|
608
608
|
try {
|
|
609
609
|
if (!txCpy.sign(key, ALLOWED_SIGHASH2)) {
|
|
610
610
|
throw new Error("Failed to sign transaction");
|
|
@@ -666,7 +666,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
666
666
|
*/
|
|
667
667
|
descriptor;
|
|
668
668
|
constructor(descriptor) {
|
|
669
|
-
const network =
|
|
669
|
+
const network = chunkFUW3OM5X_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
670
670
|
let expansion;
|
|
671
671
|
try {
|
|
672
672
|
expansion = descriptorsScure.expand({ descriptor, network, index: 0 });
|
|
@@ -716,7 +716,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
716
716
|
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
717
717
|
*/
|
|
718
718
|
isOurs(descriptor) {
|
|
719
|
-
return
|
|
719
|
+
return chunkFUW3OM5X_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
|
|
720
720
|
}
|
|
721
721
|
};
|
|
722
722
|
function serializeSeedOwnedSigningIdentity(identity) {
|
|
@@ -878,10 +878,10 @@ var DescriptorIdentity = class {
|
|
|
878
878
|
this.base = base;
|
|
879
879
|
}
|
|
880
880
|
async xOnlyPublicKey() {
|
|
881
|
-
return
|
|
881
|
+
return chunkFUW3OM5X_cjs.deriveDescriptorLeafPubKey(this.descriptor);
|
|
882
882
|
}
|
|
883
883
|
async compressedPublicKey() {
|
|
884
|
-
return
|
|
884
|
+
return chunkFUW3OM5X_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
|
|
885
885
|
}
|
|
886
886
|
async sign(tx, inputIndexes) {
|
|
887
887
|
const [signed] = await this.signer.signWithDescriptor([
|
|
@@ -949,12 +949,12 @@ var WalletCannotAllocateAddressError = class extends Error {
|
|
|
949
949
|
};
|
|
950
950
|
async function resolveDescriptorSigner(descriptor, identity, provider) {
|
|
951
951
|
const owner = provider?.isOurs(descriptor) ? provider : isHDCapableIdentity(identity) && identity.isOurs(descriptor) ? identity : void 0;
|
|
952
|
-
if (owner &&
|
|
952
|
+
if (owner && chunkFUW3OM5X_cjs.parseHDDescriptor(descriptor)) {
|
|
953
953
|
return new DescriptorIdentity({ descriptor, signer: owner, base: identity });
|
|
954
954
|
}
|
|
955
955
|
let key;
|
|
956
956
|
try {
|
|
957
|
-
key =
|
|
957
|
+
key = chunkFUW3OM5X_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
958
958
|
} catch {
|
|
959
959
|
throw new ForeignDescriptorError(descriptor);
|
|
960
960
|
}
|
|
@@ -976,33 +976,62 @@ function isAddressAllocationCapable(value) {
|
|
|
976
976
|
return typeof value.getNewAddresses === "function";
|
|
977
977
|
}
|
|
978
978
|
|
|
979
|
+
// ../../node_modules/@noble/hashes/_u64.js
|
|
980
|
+
var fromNumH = (n) => n / 2 ** 32 | 0;
|
|
981
|
+
var fromNumL = (n) => n >>> 0;
|
|
982
|
+
function setU64FromNum(view, byteOffset, n, isLE) {
|
|
983
|
+
const h = fromNumH(n);
|
|
984
|
+
const l = fromNumL(n);
|
|
985
|
+
view.setUint32(byteOffset, isLE ? l : h, isLE);
|
|
986
|
+
view.setUint32(byteOffset + 4, isLE ? h : l, isLE);
|
|
987
|
+
}
|
|
988
|
+
|
|
979
989
|
// ../../node_modules/@noble/hashes/utils.js
|
|
980
990
|
function isBytes(a) {
|
|
981
|
-
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
991
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
|
992
|
+
}
|
|
993
|
+
var atitle = (title) => title ? `"${title}" ` : "";
|
|
994
|
+
function anumber(n, title = "") {
|
|
995
|
+
if (typeof n !== "number")
|
|
996
|
+
throw new TypeError(atitle(title) + "expected number, got " + typeof n);
|
|
997
|
+
if (!Number.isSafeInteger(n) || n < 0)
|
|
998
|
+
throw new RangeError(atitle(title) + "expected integer >= 0, got " + n);
|
|
999
|
+
return n;
|
|
982
1000
|
}
|
|
983
1001
|
function abytes(value, length, title = "") {
|
|
1002
|
+
if (isBytes(value) && (length === void 0))
|
|
1003
|
+
return value;
|
|
984
1004
|
const bytes = isBytes(value);
|
|
985
|
-
const
|
|
986
|
-
const
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
}
|
|
1005
|
+
const ofLen = "";
|
|
1006
|
+
const got = bytes ? `length=${value.length}` : `type=${typeof value}`;
|
|
1007
|
+
const message = atitle(title) + "expected Uint8Array" + ofLen + ", got " + got;
|
|
1008
|
+
if (!bytes)
|
|
1009
|
+
throw new TypeError(message);
|
|
1010
|
+
throw new RangeError(message);
|
|
1011
|
+
}
|
|
1012
|
+
var aobject = (value, label) => {
|
|
1013
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
1014
|
+
throw new TypeError((label === "object" ? "" : `"${label}" `) + "expected object, got type=" + typeof value);
|
|
1015
|
+
};
|
|
1016
|
+
var aopts = (value, label) => {
|
|
1017
|
+
aobject(value, label);
|
|
1018
|
+
const proto = Object.getPrototypeOf(value);
|
|
1019
|
+
if (proto !== Object.prototype && proto !== null)
|
|
1020
|
+
throw new TypeError(`"${label}" expected plain object`);
|
|
1021
|
+
if (Object.hasOwn(value, "__proto__"))
|
|
1022
|
+
throw new TypeError(`"${label}.__proto__" is not allowed`);
|
|
1023
|
+
};
|
|
995
1024
|
function aexists(instance, checkFinished = true) {
|
|
996
1025
|
if (instance.destroyed)
|
|
997
|
-
throw new Error("
|
|
1026
|
+
throw new Error("hash was destroyed");
|
|
998
1027
|
if (checkFinished && instance.finished)
|
|
999
|
-
throw new Error("
|
|
1028
|
+
throw new Error("digest() was already called");
|
|
1000
1029
|
}
|
|
1001
1030
|
function aoutput(out, instance) {
|
|
1002
|
-
abytes(out, void 0, "
|
|
1031
|
+
abytes(out, void 0, "output");
|
|
1003
1032
|
const min = instance.outputLen;
|
|
1004
|
-
if (out.length
|
|
1005
|
-
throw new
|
|
1033
|
+
if (!(out.length >= min)) {
|
|
1034
|
+
throw new RangeError('"output" expected length >= ' + min);
|
|
1006
1035
|
}
|
|
1007
1036
|
}
|
|
1008
1037
|
function clean(...arrays) {
|
|
@@ -1016,22 +1045,38 @@ function createView(arr) {
|
|
|
1016
1045
|
function rotr(word, shift) {
|
|
1017
1046
|
return word << 32 - shift | word >>> shift;
|
|
1018
1047
|
}
|
|
1048
|
+
function checkOpts(defaults, opts, title = "opts") {
|
|
1049
|
+
aopts(defaults, "defaults");
|
|
1050
|
+
if (opts !== void 0)
|
|
1051
|
+
aopts(opts, title);
|
|
1052
|
+
const merged = Object.assign(/* @__PURE__ */ Object.create(null), defaults, opts);
|
|
1053
|
+
return merged;
|
|
1054
|
+
}
|
|
1019
1055
|
function createHasher(hashCons, info = {}) {
|
|
1056
|
+
if (typeof hashCons !== "function")
|
|
1057
|
+
throw new TypeError('"hashCons" expected function, got type=' + typeof hashCons);
|
|
1058
|
+
info = checkOpts({}, info, "info");
|
|
1020
1059
|
const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
|
|
1021
1060
|
const tmp = hashCons(void 0);
|
|
1022
1061
|
hashC.outputLen = tmp.outputLen;
|
|
1023
1062
|
hashC.blockLen = tmp.blockLen;
|
|
1063
|
+
hashC.canXOF = tmp.canXOF;
|
|
1024
1064
|
hashC.create = (opts) => hashCons(opts);
|
|
1025
1065
|
Object.assign(hashC, info);
|
|
1026
1066
|
return Object.freeze(hashC);
|
|
1027
1067
|
}
|
|
1028
1068
|
function randomBytes(bytesLength = 32) {
|
|
1069
|
+
anumber(bytesLength, "bytesLength");
|
|
1029
1070
|
const cr = typeof globalThis === "object" ? globalThis.crypto : null;
|
|
1030
1071
|
if (typeof cr?.getRandomValues !== "function")
|
|
1031
1072
|
throw new Error("crypto.getRandomValues must be defined");
|
|
1073
|
+
if (bytesLength > 65536)
|
|
1074
|
+
throw new RangeError(`"bytesLength" expected <= 65536, got ${bytesLength}`);
|
|
1032
1075
|
return cr.getRandomValues(new Uint8Array(bytesLength));
|
|
1033
1076
|
}
|
|
1034
1077
|
var oidNist = (suffix) => ({
|
|
1078
|
+
// Current NIST hashAlgs suffixes used here fit in one DER subidentifier octet.
|
|
1079
|
+
// Larger suffix values would need base-128 OID encoding and a different length byte.
|
|
1035
1080
|
oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
|
|
1036
1081
|
});
|
|
1037
1082
|
|
|
@@ -1045,6 +1090,7 @@ function Maj(a, b, c) {
|
|
|
1045
1090
|
var HashMD = class {
|
|
1046
1091
|
blockLen;
|
|
1047
1092
|
outputLen;
|
|
1093
|
+
canXOF = false;
|
|
1048
1094
|
padOffset;
|
|
1049
1095
|
isLE;
|
|
1050
1096
|
// For partial updates less than block size
|
|
@@ -1067,24 +1113,28 @@ var HashMD = class {
|
|
|
1067
1113
|
abytes(data);
|
|
1068
1114
|
const { view, buffer, blockLen } = this;
|
|
1069
1115
|
const len = data.length;
|
|
1116
|
+
let processed = false;
|
|
1070
1117
|
for (let pos = 0; pos < len; ) {
|
|
1071
1118
|
const take = Math.min(blockLen - this.pos, len - pos);
|
|
1072
1119
|
if (take === blockLen) {
|
|
1073
1120
|
const dataView = createView(data);
|
|
1074
1121
|
for (; blockLen <= len - pos; pos += blockLen)
|
|
1075
1122
|
this.process(dataView, pos);
|
|
1123
|
+
processed = true;
|
|
1076
1124
|
continue;
|
|
1077
1125
|
}
|
|
1078
|
-
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
1126
|
+
buffer.set(pos === 0 && take === len ? data : data.subarray(pos, pos + take), this.pos);
|
|
1079
1127
|
this.pos += take;
|
|
1080
1128
|
pos += take;
|
|
1081
1129
|
if (this.pos === blockLen) {
|
|
1082
1130
|
this.process(view, 0);
|
|
1083
1131
|
this.pos = 0;
|
|
1132
|
+
processed = true;
|
|
1084
1133
|
}
|
|
1085
1134
|
}
|
|
1086
1135
|
this.length += data.length;
|
|
1087
|
-
|
|
1136
|
+
if (processed)
|
|
1137
|
+
this.roundClean();
|
|
1088
1138
|
return this;
|
|
1089
1139
|
}
|
|
1090
1140
|
digestInto(out) {
|
|
@@ -1094,23 +1144,20 @@ var HashMD = class {
|
|
|
1094
1144
|
const { buffer, view, blockLen, isLE } = this;
|
|
1095
1145
|
let { pos } = this;
|
|
1096
1146
|
buffer[pos++] = 128;
|
|
1097
|
-
|
|
1147
|
+
buffer.fill(0, pos);
|
|
1098
1148
|
if (this.padOffset > blockLen - pos) {
|
|
1099
1149
|
this.process(view, 0);
|
|
1100
|
-
|
|
1150
|
+
buffer.fill(0);
|
|
1101
1151
|
}
|
|
1102
|
-
|
|
1103
|
-
buffer[i] = 0;
|
|
1104
|
-
view.setBigUint64(blockLen - 8, BigInt(this.length * 8), isLE);
|
|
1152
|
+
setU64FromNum(view, blockLen - 8, this.length * 8, isLE);
|
|
1105
1153
|
this.process(view, 0);
|
|
1106
|
-
|
|
1154
|
+
this.roundClean();
|
|
1155
|
+
const oview = out === buffer ? view : createView(out);
|
|
1107
1156
|
const len = this.outputLen;
|
|
1108
|
-
if (len % 4)
|
|
1109
|
-
throw new Error("_sha2: outputLen must be aligned to 32bit");
|
|
1110
1157
|
const outLen = len / 4;
|
|
1111
1158
|
const state = this.get();
|
|
1112
|
-
if (outLen > state.length)
|
|
1113
|
-
throw new Error("
|
|
1159
|
+
if (len % 4 || outLen > state.length)
|
|
1160
|
+
throw new Error("invalid outputLen");
|
|
1114
1161
|
for (let i = 0; i < outLen; i++)
|
|
1115
1162
|
oview.setUint32(4 * i, state[i], isLE);
|
|
1116
1163
|
}
|
|
@@ -1121,15 +1168,13 @@ var HashMD = class {
|
|
|
1121
1168
|
this.destroy();
|
|
1122
1169
|
return res;
|
|
1123
1170
|
}
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
to.set(...this.get());
|
|
1127
|
-
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
1171
|
+
_cloneIntoMeta(to) {
|
|
1172
|
+
const { buffer, length, finished, destroyed, pos } = this;
|
|
1128
1173
|
to.destroyed = destroyed;
|
|
1129
1174
|
to.finished = finished;
|
|
1130
1175
|
to.length = length;
|
|
1131
1176
|
to.pos = pos;
|
|
1132
|
-
if (
|
|
1177
|
+
if (pos)
|
|
1133
1178
|
to.buffer.set(buffer);
|
|
1134
1179
|
return to;
|
|
1135
1180
|
}
|
|
@@ -1217,8 +1262,28 @@ var SHA256_K = /* @__PURE__ */ Uint32Array.from([
|
|
|
1217
1262
|
]);
|
|
1218
1263
|
var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
1219
1264
|
var SHA2_32B = class extends HashMD {
|
|
1220
|
-
|
|
1265
|
+
// We cannot use array here since array allows indexing by variable
|
|
1266
|
+
// which means optimizer/compiler cannot use registers.
|
|
1267
|
+
// Numeric initializers matter: starting the fields as `undefined` changes
|
|
1268
|
+
// V8's field representation and makes sha256 3x slower (measured).
|
|
1269
|
+
A = 0;
|
|
1270
|
+
B = 0;
|
|
1271
|
+
C = 0;
|
|
1272
|
+
D = 0;
|
|
1273
|
+
E = 0;
|
|
1274
|
+
F = 0;
|
|
1275
|
+
G = 0;
|
|
1276
|
+
H = 0;
|
|
1277
|
+
constructor(outputLen, IV) {
|
|
1221
1278
|
super(64, outputLen, 8, false);
|
|
1279
|
+
this.A = IV[0] | 0;
|
|
1280
|
+
this.B = IV[1] | 0;
|
|
1281
|
+
this.C = IV[2] | 0;
|
|
1282
|
+
this.D = IV[3] | 0;
|
|
1283
|
+
this.E = IV[4] | 0;
|
|
1284
|
+
this.F = IV[5] | 0;
|
|
1285
|
+
this.G = IV[6] | 0;
|
|
1286
|
+
this.H = IV[7] | 0;
|
|
1222
1287
|
}
|
|
1223
1288
|
get() {
|
|
1224
1289
|
const { A, B, C, D, E, F, G, H } = this;
|
|
@@ -1235,6 +1300,10 @@ var SHA2_32B = class extends HashMD {
|
|
|
1235
1300
|
this.G = G | 0;
|
|
1236
1301
|
this.H = H | 0;
|
|
1237
1302
|
}
|
|
1303
|
+
_cloneInto(to) {
|
|
1304
|
+
(to ||= new this.constructor()).set(...this.get());
|
|
1305
|
+
return this._cloneIntoMeta(to);
|
|
1306
|
+
}
|
|
1238
1307
|
process(view, offset) {
|
|
1239
1308
|
for (let i = 0; i < 16; i++, offset += 4)
|
|
1240
1309
|
SHA256_W[i] = view.getUint32(offset, false);
|
|
@@ -1274,23 +1343,14 @@ var SHA2_32B = class extends HashMD {
|
|
|
1274
1343
|
clean(SHA256_W);
|
|
1275
1344
|
}
|
|
1276
1345
|
destroy() {
|
|
1346
|
+
this.destroyed = true;
|
|
1277
1347
|
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
1278
1348
|
clean(this.buffer);
|
|
1279
1349
|
}
|
|
1280
1350
|
};
|
|
1281
1351
|
var _SHA256 = class extends SHA2_32B {
|
|
1282
|
-
// We cannot use array here since array allows indexing by variable
|
|
1283
|
-
// which means optimizer/compiler cannot use registers.
|
|
1284
|
-
A = SHA256_IV[0] | 0;
|
|
1285
|
-
B = SHA256_IV[1] | 0;
|
|
1286
|
-
C = SHA256_IV[2] | 0;
|
|
1287
|
-
D = SHA256_IV[3] | 0;
|
|
1288
|
-
E = SHA256_IV[4] | 0;
|
|
1289
|
-
F = SHA256_IV[5] | 0;
|
|
1290
|
-
G = SHA256_IV[6] | 0;
|
|
1291
|
-
H = SHA256_IV[7] | 0;
|
|
1292
1352
|
constructor() {
|
|
1293
|
-
super(32);
|
|
1353
|
+
super(32, SHA256_IV);
|
|
1294
1354
|
}
|
|
1295
1355
|
};
|
|
1296
1356
|
var sha256 = /* @__PURE__ */ createHasher(
|
|
@@ -1329,14 +1389,14 @@ function buildSaltedPreimageMessage(xonly, salt) {
|
|
|
1329
1389
|
}
|
|
1330
1390
|
var PREIMAGE_INDEX = 0;
|
|
1331
1391
|
function isPerArtifactDescriptor(descriptor) {
|
|
1332
|
-
return
|
|
1392
|
+
return chunkFUW3OM5X_cjs.parseHDDescriptor(descriptor) !== null;
|
|
1333
1393
|
}
|
|
1334
1394
|
async function provisionDescriptor(wallet) {
|
|
1335
1395
|
const allocated = isHDAllocationCapable(wallet) ? await wallet.getNextSigningDescriptor() : void 0;
|
|
1336
|
-
return allocated ?? await
|
|
1396
|
+
return allocated ?? await chunkFUW3OM5X_cjs.identityDescriptor(wallet.identity);
|
|
1337
1397
|
}
|
|
1338
1398
|
async function provisionRefundKey(wallet) {
|
|
1339
|
-
const descriptor = await
|
|
1399
|
+
const descriptor = await chunkFUW3OM5X_cjs.identityDescriptor(wallet.identity);
|
|
1340
1400
|
const signer = await contractSigner(wallet, descriptor);
|
|
1341
1401
|
const pubkey = await signer.xOnlyPublicKey();
|
|
1342
1402
|
const identityPubkey = await wallet.identity.xOnlyPublicKey();
|
|
@@ -1346,7 +1406,7 @@ async function provisionRefundKey(wallet) {
|
|
|
1346
1406
|
);
|
|
1347
1407
|
}
|
|
1348
1408
|
const address = await wallet.getAddress();
|
|
1349
|
-
const { pkScript } =
|
|
1409
|
+
const { pkScript } = chunkDAYCCIRO_cjs.ArkAddress.decode(address);
|
|
1350
1410
|
return { descriptor, pubkey, pkScript, address };
|
|
1351
1411
|
}
|
|
1352
1412
|
async function provisionClaimSecret(wallet, opts = {}) {
|
|
@@ -1392,7 +1452,7 @@ async function contractSigner(wallet, descriptor) {
|
|
|
1392
1452
|
const signer = isHDWalletCapable(wallet) ? await wallet.signerForDescriptor(descriptor) : wallet.identity;
|
|
1393
1453
|
let expected;
|
|
1394
1454
|
try {
|
|
1395
|
-
expected =
|
|
1455
|
+
expected = chunkFUW3OM5X_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
1396
1456
|
} catch (cause) {
|
|
1397
1457
|
throw new ForeignDescriptorError(descriptor, { cause });
|
|
1398
1458
|
}
|
|
@@ -1611,14 +1671,14 @@ var RestDelegateProvider = class {
|
|
|
1611
1671
|
*/
|
|
1612
1672
|
async delegate(intent, forfeitTxs, options) {
|
|
1613
1673
|
const url = `${this.url}/v1/delegate`;
|
|
1614
|
-
const response = await
|
|
1674
|
+
const response = await chunkDAYCCIRO_cjs.baseFetch(url, {
|
|
1615
1675
|
method: "POST",
|
|
1616
1676
|
headers: {
|
|
1617
1677
|
"Content-Type": "application/json"
|
|
1618
1678
|
},
|
|
1619
1679
|
body: JSON.stringify({
|
|
1620
1680
|
intent: {
|
|
1621
|
-
message:
|
|
1681
|
+
message: chunkDAYCCIRO_cjs.Intent.encodeMessage(intent.message),
|
|
1622
1682
|
proof: intent.proof
|
|
1623
1683
|
},
|
|
1624
1684
|
forfeit_txs: forfeitTxs,
|
|
@@ -1638,7 +1698,7 @@ var RestDelegateProvider = class {
|
|
|
1638
1698
|
*/
|
|
1639
1699
|
async getDelegateInfo() {
|
|
1640
1700
|
const url = `${this.url}/v1/delegator/info`;
|
|
1641
|
-
const response = await
|
|
1701
|
+
const response = await chunkDAYCCIRO_cjs.rateGate.runHttp(url, () => chunkDAYCCIRO_cjs.baseFetch(url));
|
|
1642
1702
|
if (!response.ok) {
|
|
1643
1703
|
const errorText2 = await response.text();
|
|
1644
1704
|
throw new Error(`Failed to get delegate info: ${errorText2}`);
|
|
@@ -1663,7 +1723,7 @@ var ESPLORA_URL = {
|
|
|
1663
1723
|
regtest: "http://localhost:3000/api"
|
|
1664
1724
|
};
|
|
1665
1725
|
var EsploraProvider = class {
|
|
1666
|
-
constructor(baseUrl = ESPLORA_URL[
|
|
1726
|
+
constructor(baseUrl = ESPLORA_URL[chunkDAYCCIRO_cjs.DEFAULT_NETWORK_NAME], opts) {
|
|
1667
1727
|
this.baseUrl = baseUrl;
|
|
1668
1728
|
this.pollingInterval = opts?.pollingInterval ?? 15e3;
|
|
1669
1729
|
this.forcePolling = opts?.forcePolling ?? false;
|
|
@@ -1682,14 +1742,14 @@ var EsploraProvider = class {
|
|
|
1682
1742
|
*/
|
|
1683
1743
|
addressWatches = /* @__PURE__ */ new Map();
|
|
1684
1744
|
async getCoins(address) {
|
|
1685
|
-
const response = await
|
|
1745
|
+
const response = await chunkDAYCCIRO_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
|
|
1686
1746
|
if (!response.ok) {
|
|
1687
1747
|
throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
|
|
1688
1748
|
}
|
|
1689
1749
|
return response.json();
|
|
1690
1750
|
}
|
|
1691
1751
|
async getFeeRate() {
|
|
1692
|
-
const response = await
|
|
1752
|
+
const response = await chunkDAYCCIRO_cjs.baseFetch(`${this.baseUrl}/fee-estimates`);
|
|
1693
1753
|
if (response.status === 404) {
|
|
1694
1754
|
return void 0;
|
|
1695
1755
|
}
|
|
@@ -1710,7 +1770,7 @@ var EsploraProvider = class {
|
|
|
1710
1770
|
}
|
|
1711
1771
|
}
|
|
1712
1772
|
async getTxOutspends(txid) {
|
|
1713
|
-
const response = await
|
|
1773
|
+
const response = await chunkDAYCCIRO_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
|
|
1714
1774
|
if (!response.ok) {
|
|
1715
1775
|
const error = await response.text();
|
|
1716
1776
|
throw new Error(`Failed to get transaction outspends: ${error}`);
|
|
@@ -1718,7 +1778,7 @@ var EsploraProvider = class {
|
|
|
1718
1778
|
return response.json();
|
|
1719
1779
|
}
|
|
1720
1780
|
async getTransactions(address) {
|
|
1721
|
-
const response = await
|
|
1781
|
+
const response = await chunkDAYCCIRO_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
|
|
1722
1782
|
if (!response.ok) {
|
|
1723
1783
|
const error = await response.text();
|
|
1724
1784
|
throw new Error(`Failed to get transactions: ${error}`);
|
|
@@ -1731,14 +1791,14 @@ var EsploraProvider = class {
|
|
|
1731
1791
|
* usable as a change probe for the polling fallback.
|
|
1732
1792
|
*/
|
|
1733
1793
|
async getAddressStats(address) {
|
|
1734
|
-
const response = await
|
|
1794
|
+
const response = await chunkDAYCCIRO_cjs.baseFetch(`${this.baseUrl}/address/${address}`);
|
|
1735
1795
|
if (!response.ok) {
|
|
1736
1796
|
throw new Error(`Failed to get address stats: ${response.statusText}`);
|
|
1737
1797
|
}
|
|
1738
1798
|
return response.json();
|
|
1739
1799
|
}
|
|
1740
1800
|
async getRawTransaction(txid) {
|
|
1741
|
-
const response = await
|
|
1801
|
+
const response = await chunkDAYCCIRO_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/hex`);
|
|
1742
1802
|
if (!response.ok) {
|
|
1743
1803
|
const error = await response.text();
|
|
1744
1804
|
throw new Error(`Failed to get raw transaction ${txid}: ${error}`);
|
|
@@ -1746,7 +1806,7 @@ var EsploraProvider = class {
|
|
|
1746
1806
|
return base.hex.decode((await response.text()).trim());
|
|
1747
1807
|
}
|
|
1748
1808
|
async getTxStatus(txid) {
|
|
1749
|
-
const txresponse = await
|
|
1809
|
+
const txresponse = await chunkDAYCCIRO_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
|
|
1750
1810
|
if (!txresponse.ok) {
|
|
1751
1811
|
throw new Error(txresponse.statusText);
|
|
1752
1812
|
}
|
|
@@ -1754,7 +1814,7 @@ var EsploraProvider = class {
|
|
|
1754
1814
|
if (!tx.status.confirmed) {
|
|
1755
1815
|
return { confirmed: false };
|
|
1756
1816
|
}
|
|
1757
|
-
const response = await
|
|
1817
|
+
const response = await chunkDAYCCIRO_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
|
|
1758
1818
|
if (!response.ok) {
|
|
1759
1819
|
throw new Error(`Failed to get transaction status: ${response.statusText}`);
|
|
1760
1820
|
}
|
|
@@ -2038,9 +2098,9 @@ var EsploraProvider = class {
|
|
|
2038
2098
|
return { subscribers, teardown, started };
|
|
2039
2099
|
}
|
|
2040
2100
|
async getChainTip() {
|
|
2041
|
-
let tipBlocks = await
|
|
2101
|
+
let tipBlocks = await chunkDAYCCIRO_cjs.baseFetch(`${this.baseUrl}/blocks`);
|
|
2042
2102
|
if (tipBlocks.status === 404) {
|
|
2043
|
-
tipBlocks = await
|
|
2103
|
+
tipBlocks = await chunkDAYCCIRO_cjs.baseFetch(`${this.baseUrl}/v1/blocks`);
|
|
2044
2104
|
}
|
|
2045
2105
|
if (!tipBlocks.ok) {
|
|
2046
2106
|
throw new Error(`Failed to get chain tip: ${tipBlocks.statusText}`);
|
|
@@ -2062,7 +2122,7 @@ var EsploraProvider = class {
|
|
|
2062
2122
|
};
|
|
2063
2123
|
}
|
|
2064
2124
|
async broadcastPackage(parent, child) {
|
|
2065
|
-
const response = await
|
|
2125
|
+
const response = await chunkDAYCCIRO_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
|
|
2066
2126
|
method: "POST",
|
|
2067
2127
|
headers: {
|
|
2068
2128
|
"Content-Type": "application/json"
|
|
@@ -2078,7 +2138,7 @@ var EsploraProvider = class {
|
|
|
2078
2138
|
return result;
|
|
2079
2139
|
}
|
|
2080
2140
|
async broadcastTx(tx) {
|
|
2081
|
-
const response = await
|
|
2141
|
+
const response = await chunkDAYCCIRO_cjs.baseFetch(`${this.baseUrl}/tx`, {
|
|
2082
2142
|
method: "POST",
|
|
2083
2143
|
headers: {
|
|
2084
2144
|
"Content-Type": "text/plain"
|
|
@@ -2261,7 +2321,7 @@ function findP2AOutput(tx) {
|
|
|
2261
2321
|
var CHILD_DUST_AMOUNT = 546;
|
|
2262
2322
|
function buildAnchorChild(params) {
|
|
2263
2323
|
const { parent, feeRate, fundingCoins, changeAddress, tapInternalKey, network } = params;
|
|
2264
|
-
const child = new
|
|
2324
|
+
const child = new chunkDAYCCIRO_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
|
|
2265
2325
|
child.addInput(findP2AOutput(parent));
|
|
2266
2326
|
const estimator = TxWeightEstimator.create().addP2AInput();
|
|
2267
2327
|
for (const _ of fundingCoins) {
|
|
@@ -2309,7 +2369,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
|
|
|
2309
2369
|
);
|
|
2310
2370
|
}
|
|
2311
2371
|
function buildForfeitTxWithOutput(inputs, output, txLocktime) {
|
|
2312
|
-
const tx = new
|
|
2372
|
+
const tx = new chunkDAYCCIRO_cjs.Transaction({
|
|
2313
2373
|
version: 3,
|
|
2314
2374
|
lockTime: txLocktime
|
|
2315
2375
|
});
|
|
@@ -2336,7 +2396,7 @@ function validateConnectorsTxGraph(settlementTxB64, connectorsGraph) {
|
|
|
2336
2396
|
connectorsGraph.validate();
|
|
2337
2397
|
if (connectorsGraph.root.inputsLength !== 1) throw ErrNumberOfInputs;
|
|
2338
2398
|
const rootInput = connectorsGraph.root.getInput(0);
|
|
2339
|
-
const settlementTx =
|
|
2399
|
+
const settlementTx = chunkDAYCCIRO_cjs.Transaction.fromPSBT(base.base64.decode(settlementTxB64));
|
|
2340
2400
|
if (settlementTx.outputsLength <= BATCH_OUTPUT_CONNECTORS_INDEX)
|
|
2341
2401
|
throw ErrInvalidSettlementTxOutputs;
|
|
2342
2402
|
const expectedRootTxid = settlementTx.id;
|
|
@@ -2385,7 +2445,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
|
|
|
2385
2445
|
if (previousScriptKey.length !== 32) {
|
|
2386
2446
|
throw new Error(`parent output ${childIndex} has invalid script`);
|
|
2387
2447
|
}
|
|
2388
|
-
const cosigners =
|
|
2448
|
+
const cosigners = chunkDAYCCIRO_cjs.getArkPsbtFields(child.root, 0, chunkDAYCCIRO_cjs.CosignerPublicKey);
|
|
2389
2449
|
if (cosigners.length === 0) {
|
|
2390
2450
|
throw ErrMissingCosignersPublicKeys;
|
|
2391
2451
|
}
|
|
@@ -2443,7 +2503,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
2443
2503
|
return new _EmulatorPacket(entries);
|
|
2444
2504
|
}
|
|
2445
2505
|
static fromBytes(data) {
|
|
2446
|
-
const reader = new
|
|
2506
|
+
const reader = new chunkSJPPBR2V_cjs.BufferReader(data);
|
|
2447
2507
|
const entryCount = reader.readCompactSize();
|
|
2448
2508
|
const entries = [];
|
|
2449
2509
|
for (let i = 0; i < entryCount; i++) {
|
|
@@ -2461,7 +2521,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
2461
2521
|
return _EmulatorPacket.PACKET_TYPE;
|
|
2462
2522
|
}
|
|
2463
2523
|
serialize() {
|
|
2464
|
-
const writer = new
|
|
2524
|
+
const writer = new chunkSJPPBR2V_cjs.BufferWriter();
|
|
2465
2525
|
writer.writeCompactSize(this.entries.length);
|
|
2466
2526
|
for (const entry of this.entries) {
|
|
2467
2527
|
writer.writeUint16LE(entry.vin);
|
|
@@ -2548,7 +2608,7 @@ var Extension = class _Extension {
|
|
|
2548
2608
|
`expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
|
|
2549
2609
|
);
|
|
2550
2610
|
}
|
|
2551
|
-
const reader = new
|
|
2611
|
+
const reader = new chunkSJPPBR2V_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
|
|
2552
2612
|
const packets = [];
|
|
2553
2613
|
while (reader.remaining() > 0) {
|
|
2554
2614
|
const packetType = reader.readByte();
|
|
@@ -2622,7 +2682,7 @@ var Extension = class _Extension {
|
|
|
2622
2682
|
*/
|
|
2623
2683
|
getAssetPacket() {
|
|
2624
2684
|
for (const p of this.packets) {
|
|
2625
|
-
if (p instanceof
|
|
2685
|
+
if (p instanceof chunkSJPPBR2V_cjs.Packet) {
|
|
2626
2686
|
return p;
|
|
2627
2687
|
}
|
|
2628
2688
|
}
|
|
@@ -2660,8 +2720,8 @@ var Extension = class _Extension {
|
|
|
2660
2720
|
};
|
|
2661
2721
|
function parsePacket(packetType, data) {
|
|
2662
2722
|
switch (packetType) {
|
|
2663
|
-
case
|
|
2664
|
-
return
|
|
2723
|
+
case chunkSJPPBR2V_cjs.Packet.PACKET_TYPE:
|
|
2724
|
+
return chunkSJPPBR2V_cjs.Packet.fromBytes(data);
|
|
2665
2725
|
case EmulatorPacket.PACKET_TYPE:
|
|
2666
2726
|
return EmulatorPacket.fromBytes(data);
|
|
2667
2727
|
default:
|
|
@@ -2708,22 +2768,22 @@ function buildOpReturnScript(data) {
|
|
|
2708
2768
|
}
|
|
2709
2769
|
return script;
|
|
2710
2770
|
}
|
|
2711
|
-
var ErrOffchainOutputNotFound = (address) => new
|
|
2712
|
-
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new
|
|
2771
|
+
var ErrOffchainOutputNotFound = (address) => new chunkDAYCCIRO_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
|
|
2772
|
+
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkDAYCCIRO_cjs.ServerResponseMismatchError(
|
|
2713
2773
|
`invalid asset output amount for ${assetId}: got ${got}, want ${want}`
|
|
2714
2774
|
);
|
|
2715
|
-
var ErrAssetGroupNotFound = (assetId) => new
|
|
2716
|
-
var ErrAssetOutputNotFound = (assetId, outputIndex) => new
|
|
2775
|
+
var ErrAssetGroupNotFound = (assetId) => new chunkDAYCCIRO_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
|
|
2776
|
+
var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkDAYCCIRO_cjs.ServerResponseMismatchError(
|
|
2717
2777
|
`asset output not found in asset group ${assetId} at index ${outputIndex}`
|
|
2718
2778
|
);
|
|
2719
|
-
var ErrOnchainOutputNotFound = (address) => new
|
|
2720
|
-
var ErrUnvalidatedOffchainOutput = (address) => new
|
|
2779
|
+
var ErrOnchainOutputNotFound = (address) => new chunkDAYCCIRO_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
|
|
2780
|
+
var ErrUnvalidatedOffchainOutput = (address) => new chunkDAYCCIRO_cjs.ServerResponseMismatchError(
|
|
2721
2781
|
`offchain output ${address} cannot be validated: virtual output tree signing did not run`
|
|
2722
2782
|
);
|
|
2723
|
-
var ErrIntentOutputNotFound = (index, kind) => new
|
|
2783
|
+
var ErrIntentOutputNotFound = (index, kind) => new chunkDAYCCIRO_cjs.ServerResponseMismatchError(
|
|
2724
2784
|
`${kind} output ${index} of the intent proof is not present in what the server built`
|
|
2725
2785
|
);
|
|
2726
|
-
var ErrUnvalidatedIntentOutput = (index) => new
|
|
2786
|
+
var ErrUnvalidatedIntentOutput = (index) => new chunkDAYCCIRO_cjs.ServerResponseMismatchError(
|
|
2727
2787
|
`offchain output ${index} of the intent proof cannot be validated: virtual output tree signing did not run`
|
|
2728
2788
|
);
|
|
2729
2789
|
var ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
|
|
@@ -2732,7 +2792,7 @@ var ErrInvalidOffchainOutputAmount = (address) => new Error(`invalid offchain ou
|
|
|
2732
2792
|
function assertFinalCommitmentMatchesValidated(finalCommitmentTx, validatedCommitmentTxid, context) {
|
|
2733
2793
|
if (!validatedCommitmentTxid) return;
|
|
2734
2794
|
if (finalCommitmentTx.id === validatedCommitmentTxid) return;
|
|
2735
|
-
throw new
|
|
2795
|
+
throw new chunkDAYCCIRO_cjs.ServerResponseMismatchError(
|
|
2736
2796
|
`${context}: finalization commitment tx ${finalCommitmentTx.id} differs from the validated commitment tx ${validatedCommitmentTxid}`
|
|
2737
2797
|
);
|
|
2738
2798
|
}
|
|
@@ -2742,7 +2802,7 @@ function validateBatchRecipients(commitmentTx, vtxoTreeLeaves, recipients, netwo
|
|
|
2742
2802
|
for (const recipient of recipients) {
|
|
2743
2803
|
let arkAddress;
|
|
2744
2804
|
try {
|
|
2745
|
-
arkAddress =
|
|
2805
|
+
arkAddress = chunkDAYCCIRO_cjs.ArkAddress.decode(recipient.address);
|
|
2746
2806
|
} catch {
|
|
2747
2807
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
2748
2808
|
continue;
|
|
@@ -2754,7 +2814,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
|
|
|
2754
2814
|
const usedOnchainOutputs = /* @__PURE__ */ new Set();
|
|
2755
2815
|
for (const recipient of recipients) {
|
|
2756
2816
|
try {
|
|
2757
|
-
|
|
2817
|
+
chunkDAYCCIRO_cjs.ArkAddress.decode(recipient.address);
|
|
2758
2818
|
} catch {
|
|
2759
2819
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
2760
2820
|
continue;
|
|
@@ -2763,7 +2823,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
|
|
|
2763
2823
|
}
|
|
2764
2824
|
}
|
|
2765
2825
|
function declaredIntentOutputs(signedProof, onchainOutputIndexes) {
|
|
2766
|
-
const proof =
|
|
2826
|
+
const proof = chunkDAYCCIRO_cjs.Transaction.fromPSBT(base.base64.decode(signedProof));
|
|
2767
2827
|
const onchain = new Set(onchainOutputIndexes);
|
|
2768
2828
|
const declared = [];
|
|
2769
2829
|
for (let i = 0; i < proof.outputsLength; i++) {
|
|
@@ -3055,7 +3115,7 @@ function assetMintResolver() {
|
|
|
3055
3115
|
if (!tx.assets?.length || !tx.key.arkTxid) return void 0;
|
|
3056
3116
|
const minted = tx.assets.filter((a) => {
|
|
3057
3117
|
try {
|
|
3058
|
-
return base.hex.encode(
|
|
3118
|
+
return base.hex.encode(chunkSJPPBR2V_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
|
|
3059
3119
|
} catch {
|
|
3060
3120
|
return false;
|
|
3061
3121
|
}
|
|
@@ -3131,7 +3191,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3131
3191
|
const existing = inputsByAssetId.get(asset.assetId);
|
|
3132
3192
|
inputsByAssetId.set(asset.assetId, [
|
|
3133
3193
|
...existing ?? [],
|
|
3134
|
-
|
|
3194
|
+
chunkSJPPBR2V_cjs.AssetInput.create(inputIndex, asset.amount)
|
|
3135
3195
|
]);
|
|
3136
3196
|
}
|
|
3137
3197
|
}
|
|
@@ -3143,7 +3203,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3143
3203
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
3144
3204
|
outputsByAssetId.set(asset.assetId, [
|
|
3145
3205
|
...existing ?? [],
|
|
3146
|
-
|
|
3206
|
+
chunkSJPPBR2V_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
3147
3207
|
]);
|
|
3148
3208
|
}
|
|
3149
3209
|
}
|
|
@@ -3154,7 +3214,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3154
3214
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
3155
3215
|
outputsByAssetId.set(asset.assetId, [
|
|
3156
3216
|
...existing ?? [],
|
|
3157
|
-
|
|
3217
|
+
chunkSJPPBR2V_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
3158
3218
|
]);
|
|
3159
3219
|
}
|
|
3160
3220
|
}
|
|
@@ -3163,11 +3223,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3163
3223
|
for (const assetIdStr of allAssetIds) {
|
|
3164
3224
|
const inputs = inputsByAssetId.get(assetIdStr);
|
|
3165
3225
|
const outputs = outputsByAssetId.get(assetIdStr);
|
|
3166
|
-
const assetId =
|
|
3167
|
-
const group =
|
|
3226
|
+
const assetId = chunkSJPPBR2V_cjs.AssetId.fromString(assetIdStr);
|
|
3227
|
+
const group = chunkSJPPBR2V_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
|
|
3168
3228
|
groups.push(group);
|
|
3169
3229
|
}
|
|
3170
|
-
return
|
|
3230
|
+
return chunkSJPPBR2V_cjs.Packet.create(groups);
|
|
3171
3231
|
}
|
|
3172
3232
|
function selectCoinsWithAsset(coins, assetId, requiredAmount) {
|
|
3173
3233
|
const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
|
|
@@ -3204,7 +3264,7 @@ function selectedCoinsToAssetInputs(selectedCoins) {
|
|
|
3204
3264
|
}
|
|
3205
3265
|
function toXOnlySignerHex(pubkeyHex) {
|
|
3206
3266
|
const bytes = base.hex.decode(pubkeyHex);
|
|
3207
|
-
if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(
|
|
3267
|
+
if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(chunkFUW3OM5X_cjs.toXOnly(bytes, "signer key"));
|
|
3208
3268
|
throw new Error(`invalid signer pubkey length: expected 32 or 33 bytes, got ${bytes.length}`);
|
|
3209
3269
|
}
|
|
3210
3270
|
function signerSetFromInfo(info) {
|
|
@@ -3251,13 +3311,13 @@ var toTimelock = (value) => ({
|
|
|
3251
3311
|
var toSeconds = (t) => t.type === "seconds" ? t.value : t.value * NOMINAL_BLOCK_SECONDS;
|
|
3252
3312
|
function assertTimelockInPolicy(timelock, policy, label, overrideOption) {
|
|
3253
3313
|
if (policy.requireSeconds && timelock.type === "blocks") {
|
|
3254
|
-
throw new
|
|
3314
|
+
throw new chunkDAYCCIRO_cjs.ServerResponseMismatchError(
|
|
3255
3315
|
`${label} rejected: block-typed timelocks are not accepted (got ${timelock.value})`
|
|
3256
3316
|
);
|
|
3257
3317
|
}
|
|
3258
3318
|
const seconds = toSeconds(timelock);
|
|
3259
3319
|
if (seconds < policy.minSeconds) {
|
|
3260
|
-
throw new
|
|
3320
|
+
throw new chunkDAYCCIRO_cjs.ServerResponseMismatchError(
|
|
3261
3321
|
`${label} rejected: ${timelock.value} ${timelock.type} is below the ${policy.minSeconds}s floor; pass ${overrideOption}: ${seconds}n to Wallet.create to lower it`
|
|
3262
3322
|
);
|
|
3263
3323
|
}
|
|
@@ -3278,7 +3338,7 @@ function resolveBatchExpiryPolicy(network, overrides) {
|
|
|
3278
3338
|
}
|
|
3279
3339
|
function assertValidBatchExpiry(batchExpiry, policy) {
|
|
3280
3340
|
if (policy.advertisedVtxoTreeExpiry !== void 0 && batchExpiry !== policy.advertisedVtxoTreeExpiry) {
|
|
3281
|
-
throw new
|
|
3341
|
+
throw new chunkDAYCCIRO_cjs.ServerResponseMismatchError(
|
|
3282
3342
|
`batch expiry rejected: ${batchExpiry} does not match the advertised vtxoTreeExpiry ${policy.advertisedVtxoTreeExpiry}`
|
|
3283
3343
|
);
|
|
3284
3344
|
}
|
|
@@ -3308,21 +3368,21 @@ function resolveCheckpointExitDelayPolicy(network, overrides) {
|
|
|
3308
3368
|
function assertValidServerUnrollScript(checkpointTapscript, policy) {
|
|
3309
3369
|
let script;
|
|
3310
3370
|
try {
|
|
3311
|
-
script =
|
|
3371
|
+
script = chunkDAYCCIRO_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
|
|
3312
3372
|
} catch (e) {
|
|
3313
|
-
throw new
|
|
3373
|
+
throw new chunkDAYCCIRO_cjs.ServerResponseMismatchError(
|
|
3314
3374
|
`checkpoint exit delay rejected: invalid checkpointTapscript from server (${e instanceof Error ? e.message : String(e)})`
|
|
3315
3375
|
);
|
|
3316
3376
|
}
|
|
3317
3377
|
if (policy.advertisedForfeitPubkey !== void 0) {
|
|
3318
3378
|
const { pubkeys } = script.params;
|
|
3319
3379
|
if (pubkeys.length !== 1) {
|
|
3320
|
-
throw new
|
|
3380
|
+
throw new chunkDAYCCIRO_cjs.ServerResponseMismatchError(
|
|
3321
3381
|
`checkpoint exit delay rejected: checkpointTapscript must commit to exactly one pubkey, got ${pubkeys.length} [${pubkeys.map(base.hex.encode).join(", ")}]`
|
|
3322
3382
|
);
|
|
3323
3383
|
}
|
|
3324
3384
|
if (!utils_js.equalBytes(pubkeys[0], policy.advertisedForfeitPubkey)) {
|
|
3325
|
-
throw new
|
|
3385
|
+
throw new chunkDAYCCIRO_cjs.ServerResponseMismatchError(
|
|
3326
3386
|
`checkpoint exit delay rejected: checkpointTapscript pubkey ${base.hex.encode(pubkeys[0])} does not match the advertised forfeitPubkey ${base.hex.encode(policy.advertisedForfeitPubkey)}`
|
|
3327
3387
|
);
|
|
3328
3388
|
}
|
|
@@ -3366,8 +3426,8 @@ function buildOffchainTx(inputs, outputs, serverUnrollScript) {
|
|
|
3366
3426
|
function buildVirtualTx(inputs, outputs) {
|
|
3367
3427
|
let lockTime = 0n;
|
|
3368
3428
|
for (const input of inputs) {
|
|
3369
|
-
const tapscript =
|
|
3370
|
-
if (
|
|
3429
|
+
const tapscript = chunkDAYCCIRO_cjs.decodeTapscript(chunkDAYCCIRO_cjs.scriptFromTapLeafScript(input.tapLeafScript));
|
|
3430
|
+
if (chunkDAYCCIRO_cjs.CLTVMultisigTapscript.is(tapscript)) {
|
|
3371
3431
|
if (lockTime !== 0n) {
|
|
3372
3432
|
if (isSeconds(lockTime) !== isSeconds(tapscript.params.absoluteTimelock)) {
|
|
3373
3433
|
throw new Error("cannot mix seconds and blocks locktime");
|
|
@@ -3378,7 +3438,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3378
3438
|
}
|
|
3379
3439
|
}
|
|
3380
3440
|
}
|
|
3381
|
-
const tx = new
|
|
3441
|
+
const tx = new chunkDAYCCIRO_cjs.Transaction({
|
|
3382
3442
|
version: 3,
|
|
3383
3443
|
lockTime: Number(lockTime)
|
|
3384
3444
|
});
|
|
@@ -3388,12 +3448,12 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3388
3448
|
index: input.vout,
|
|
3389
3449
|
sequence: lockTime ? btcSigner.DEFAULT_SEQUENCE - 1 : void 0,
|
|
3390
3450
|
witnessUtxo: {
|
|
3391
|
-
script:
|
|
3451
|
+
script: chunkDAYCCIRO_cjs.VtxoScript.decode(input.tapTree).pkScript,
|
|
3392
3452
|
amount: BigInt(input.value)
|
|
3393
3453
|
},
|
|
3394
3454
|
tapLeafScript: [input.tapLeafScript]
|
|
3395
3455
|
});
|
|
3396
|
-
|
|
3456
|
+
chunkDAYCCIRO_cjs.setArkPsbtField(tx, i, chunkDAYCCIRO_cjs.VtxoTaprootTree, input.tapTree);
|
|
3397
3457
|
}
|
|
3398
3458
|
for (const output of outputs) {
|
|
3399
3459
|
tx.addOutput(output);
|
|
@@ -3402,8 +3462,8 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3402
3462
|
return tx;
|
|
3403
3463
|
}
|
|
3404
3464
|
function buildCheckpointTx(vtxo, serverUnrollScript) {
|
|
3405
|
-
const collaborativeClosure =
|
|
3406
|
-
const checkpointVtxoScript = new
|
|
3465
|
+
const collaborativeClosure = chunkDAYCCIRO_cjs.decodeTapscript(chunkDAYCCIRO_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
|
|
3466
|
+
const checkpointVtxoScript = new chunkDAYCCIRO_cjs.VtxoScript([
|
|
3407
3467
|
serverUnrollScript.script,
|
|
3408
3468
|
collaborativeClosure.script
|
|
3409
3469
|
]);
|
|
@@ -3479,7 +3539,7 @@ function verifyTapscriptSignatures(tx, inputIndex, requiredSigners, excludePubke
|
|
|
3479
3539
|
const sighashType = signature.length === 65 ? signature[64] : btcSigner.SigHash.DEFAULT;
|
|
3480
3540
|
const sig = signature.subarray(0, 64);
|
|
3481
3541
|
if (!allowedSighashTypes.includes(sighashType)) {
|
|
3482
|
-
const sighashName =
|
|
3542
|
+
const sighashName = chunkDAYCCIRO_cjs.formatSighash(sighashType);
|
|
3483
3543
|
throw new Error(
|
|
3484
3544
|
`Unallowed sighash type ${sighashName} for input ${inputIndex}, pubkey ${pubKeyHex}.`
|
|
3485
3545
|
);
|
|
@@ -3553,7 +3613,7 @@ function combineTapscriptSigs(signedTx, originalTx) {
|
|
|
3553
3613
|
}
|
|
3554
3614
|
function isValidArkAddress(address) {
|
|
3555
3615
|
try {
|
|
3556
|
-
|
|
3616
|
+
chunkDAYCCIRO_cjs.ArkAddress.decode(address);
|
|
3557
3617
|
return true;
|
|
3558
3618
|
} catch (e) {
|
|
3559
3619
|
return false;
|
|
@@ -3561,16 +3621,16 @@ function isValidArkAddress(address) {
|
|
|
3561
3621
|
}
|
|
3562
3622
|
function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, context) {
|
|
3563
3623
|
if (serverCheckpointTxs.length !== expectedCheckpoints.length) {
|
|
3564
|
-
throw new
|
|
3624
|
+
throw new chunkDAYCCIRO_cjs.ServerResponseMismatchError(
|
|
3565
3625
|
`${context} returned ${serverCheckpointTxs.length} checkpoints, expected ${expectedCheckpoints.length}`
|
|
3566
3626
|
);
|
|
3567
3627
|
}
|
|
3568
3628
|
const byTxid = new Map(expectedCheckpoints.map((c) => [c.id, c]));
|
|
3569
3629
|
return serverCheckpointTxs.map((encoded, index) => {
|
|
3570
|
-
const server =
|
|
3630
|
+
const server = chunkDAYCCIRO_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
|
|
3571
3631
|
const local = byTxid.get(server.id);
|
|
3572
3632
|
if (!local) {
|
|
3573
|
-
throw new
|
|
3633
|
+
throw new chunkDAYCCIRO_cjs.ServerResponseMismatchError(
|
|
3574
3634
|
`${context} checkpoint ${index} txid ${server.id} does not match any submitted checkpoint`
|
|
3575
3635
|
);
|
|
3576
3636
|
}
|
|
@@ -3580,14 +3640,14 @@ function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, contex
|
|
|
3580
3640
|
}
|
|
3581
3641
|
function assertSubmittedArkTxid(response, signedArkTx, context) {
|
|
3582
3642
|
if (response.arkTxid !== signedArkTx.id) {
|
|
3583
|
-
throw new
|
|
3643
|
+
throw new chunkDAYCCIRO_cjs.ServerResponseMismatchError(
|
|
3584
3644
|
`${context} returned ark txid ${response.arkTxid}, expected ${signedArkTx.id}`
|
|
3585
3645
|
);
|
|
3586
3646
|
}
|
|
3587
3647
|
if (response.finalArkTx === void 0) return;
|
|
3588
|
-
const finalTxid =
|
|
3648
|
+
const finalTxid = chunkDAYCCIRO_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
|
|
3589
3649
|
if (finalTxid !== signedArkTx.id) {
|
|
3590
|
-
throw new
|
|
3650
|
+
throw new chunkDAYCCIRO_cjs.ServerResponseMismatchError(
|
|
3591
3651
|
`${context} returned final ark tx ${finalTxid}, expected ${signedArkTx.id}`
|
|
3592
3652
|
);
|
|
3593
3653
|
}
|
|
@@ -3599,20 +3659,20 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeys, co
|
|
|
3599
3659
|
`${context}: input ${inputIndex} carries no spend leaf to verify the server signature against`
|
|
3600
3660
|
);
|
|
3601
3661
|
}
|
|
3602
|
-
const script =
|
|
3662
|
+
const script = chunkDAYCCIRO_cjs.scriptFromTapLeafScript(leaf);
|
|
3603
3663
|
let leafPubkeys;
|
|
3604
3664
|
try {
|
|
3605
|
-
leafPubkeys =
|
|
3606
|
-
(key) => base.hex.encode(
|
|
3665
|
+
leafPubkeys = chunkDAYCCIRO_cjs.decodeTapscript(script).params.pubkeys.map(
|
|
3666
|
+
(key) => base.hex.encode(chunkFUW3OM5X_cjs.toXOnly(key, "leaf key"))
|
|
3607
3667
|
);
|
|
3608
3668
|
} catch (error) {
|
|
3609
|
-
throw new
|
|
3669
|
+
throw new chunkDAYCCIRO_cjs.ServerResponseMismatchError(
|
|
3610
3670
|
`${context}: input ${inputIndex} spend leaf cannot be decoded (${error instanceof Error ? error.message : String(error)})`
|
|
3611
3671
|
);
|
|
3612
3672
|
}
|
|
3613
3673
|
const signer = leafPubkeys.find((key) => serverPubkeys.has(key));
|
|
3614
3674
|
if (!signer) {
|
|
3615
|
-
throw new
|
|
3675
|
+
throw new chunkDAYCCIRO_cjs.ServerResponseMismatchError(
|
|
3616
3676
|
`${context}: input ${inputIndex} spend leaf names no signer key the server advertises`
|
|
3617
3677
|
);
|
|
3618
3678
|
}
|
|
@@ -3626,7 +3686,7 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeys, co
|
|
|
3626
3686
|
payment_js.tapLeafHash(script)
|
|
3627
3687
|
);
|
|
3628
3688
|
} catch (error) {
|
|
3629
|
-
throw new
|
|
3689
|
+
throw new chunkDAYCCIRO_cjs.ServerResponseMismatchError(
|
|
3630
3690
|
`${context}: input ${inputIndex} is not signed by the server on the leaf being spent (${error instanceof Error ? error.message : String(error)})`
|
|
3631
3691
|
);
|
|
3632
3692
|
}
|
|
@@ -3635,20 +3695,20 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
3635
3695
|
const byOutpoint = new Map(inputs.map((input) => [`${input.txid}:${input.vout}`, input]));
|
|
3636
3696
|
for (const [index, checkpoint] of checkpoints.entries()) {
|
|
3637
3697
|
if (checkpoint.inputsLength !== 1) {
|
|
3638
|
-
throw new
|
|
3698
|
+
throw new chunkDAYCCIRO_cjs.ServerResponseMismatchError(
|
|
3639
3699
|
`${context}: checkpoint ${index} spends ${checkpoint.inputsLength} inputs, expected 1`
|
|
3640
3700
|
);
|
|
3641
3701
|
}
|
|
3642
3702
|
const spent = checkpoint.getInput(0);
|
|
3643
3703
|
if (!spent.txid || spent.index === void 0) {
|
|
3644
|
-
throw new
|
|
3704
|
+
throw new chunkDAYCCIRO_cjs.ServerResponseMismatchError(
|
|
3645
3705
|
`${context}: checkpoint ${index} has no input outpoint`
|
|
3646
3706
|
);
|
|
3647
3707
|
}
|
|
3648
3708
|
const outpoint = `${base.hex.encode(spent.txid)}:${spent.index}`;
|
|
3649
3709
|
const input = byOutpoint.get(outpoint);
|
|
3650
3710
|
if (!input) {
|
|
3651
|
-
throw new
|
|
3711
|
+
throw new chunkDAYCCIRO_cjs.ServerResponseMismatchError(
|
|
3652
3712
|
`${context}: checkpoint ${index} spends ${outpoint}, which is not one of the requested virtual outputs`
|
|
3653
3713
|
);
|
|
3654
3714
|
}
|
|
@@ -3656,7 +3716,7 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
3656
3716
|
(unroll) => buildCheckpointTx(input, unroll).tx.id === checkpoint.id
|
|
3657
3717
|
);
|
|
3658
3718
|
if (!rebuilt) {
|
|
3659
|
-
throw new
|
|
3719
|
+
throw new chunkDAYCCIRO_cjs.ServerResponseMismatchError(
|
|
3660
3720
|
`${context}: checkpoint ${index} txid ${checkpoint.id} differs from the checkpoint built locally for ${outpoint}`
|
|
3661
3721
|
);
|
|
3662
3722
|
}
|
|
@@ -3682,9 +3742,9 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
3682
3742
|
const matched = matchServerCheckpoints(signedCheckpointTxs, offchainTx.checkpoints, "submitTx");
|
|
3683
3743
|
matched.forEach(({ server }, index) => {
|
|
3684
3744
|
try {
|
|
3685
|
-
|
|
3745
|
+
chunkDAYCCIRO_cjs.assertAllowedSighashTypes(server);
|
|
3686
3746
|
} catch (error) {
|
|
3687
|
-
throw new
|
|
3747
|
+
throw new chunkDAYCCIRO_cjs.ServerResponseMismatchError(
|
|
3688
3748
|
`submitTx checkpoint ${index}: ${error instanceof Error ? error.message : String(error)}`
|
|
3689
3749
|
);
|
|
3690
3750
|
}
|
|
@@ -3692,14 +3752,14 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
3692
3752
|
const verify = options?.verifyServerSignatures;
|
|
3693
3753
|
if (verify) {
|
|
3694
3754
|
if (response.finalArkTx === void 0) {
|
|
3695
|
-
throw new
|
|
3755
|
+
throw new chunkDAYCCIRO_cjs.ServerResponseMismatchError(
|
|
3696
3756
|
"submitTx: server returned no final ark tx to verify its signatures against"
|
|
3697
3757
|
);
|
|
3698
3758
|
}
|
|
3699
|
-
const finalArkTx =
|
|
3759
|
+
const finalArkTx = chunkDAYCCIRO_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
|
|
3700
3760
|
const serverPubkeys = new Set(
|
|
3701
3761
|
[verify.serverPubkey, ...verify.deprecatedServerPubkeys ?? []].map(
|
|
3702
|
-
(key) => base.hex.encode(
|
|
3762
|
+
(key) => base.hex.encode(chunkFUW3OM5X_cjs.toXOnly(key, "server key"))
|
|
3703
3763
|
)
|
|
3704
3764
|
);
|
|
3705
3765
|
for (let i = 0; i < offchainTx.arkTx.inputsLength; i++) {
|
|
@@ -3751,12 +3811,12 @@ function claimWithPreimageIdentity(identity, preimage) {
|
|
|
3751
3811
|
return {
|
|
3752
3812
|
...identity,
|
|
3753
3813
|
sign: async (tx, inputIndexes) => {
|
|
3754
|
-
const signed =
|
|
3814
|
+
const signed = chunkDAYCCIRO_cjs.Transaction.fromPSBT(
|
|
3755
3815
|
(await identity.sign(tx.clone(), inputIndexes)).toPSBT()
|
|
3756
3816
|
);
|
|
3757
3817
|
const indexes = inputIndexes ?? Array.from({ length: signed.inputsLength }, (_, i) => i);
|
|
3758
3818
|
for (const index of indexes) {
|
|
3759
|
-
|
|
3819
|
+
chunkDAYCCIRO_cjs.setArkPsbtField(signed, index, chunkDAYCCIRO_cjs.ConditionWitness, [preimage]);
|
|
3760
3820
|
}
|
|
3761
3821
|
return signed;
|
|
3762
3822
|
}
|
|
@@ -3951,7 +4011,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
|
|
|
3951
4011
|
};
|
|
3952
4012
|
}
|
|
3953
4013
|
function deriveContractTapscripts(contract) {
|
|
3954
|
-
const handler =
|
|
4014
|
+
const handler = chunkFUW3OM5X_cjs.contractHandlers.get(contract.type);
|
|
3955
4015
|
if (!handler) {
|
|
3956
4016
|
throw new Error(`No handler for contract type '${contract.type}'`);
|
|
3957
4017
|
}
|
|
@@ -4022,7 +4082,7 @@ function getRandomId() {
|
|
|
4022
4082
|
}
|
|
4023
4083
|
function isValidArkAddress2(address) {
|
|
4024
4084
|
try {
|
|
4025
|
-
|
|
4085
|
+
chunkDAYCCIRO_cjs.ArkAddress.decode(address);
|
|
4026
4086
|
return true;
|
|
4027
4087
|
} catch (e) {
|
|
4028
4088
|
return false;
|
|
@@ -4050,7 +4110,7 @@ function assertRecipientArkAddress(encoded, address, context) {
|
|
|
4050
4110
|
function assertTapTreeDerivesAddress(encoded, tapTree, address) {
|
|
4051
4111
|
let derived;
|
|
4052
4112
|
try {
|
|
4053
|
-
derived =
|
|
4113
|
+
derived = chunkDAYCCIRO_cjs.VtxoScript.decode(tapTree).pkScript;
|
|
4054
4114
|
} catch (e) {
|
|
4055
4115
|
throw new Error(
|
|
4056
4116
|
`Invalid tapTree for ${encoded}: ${e instanceof Error ? e.message : String(e)}`
|
|
@@ -4067,7 +4127,7 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
4067
4127
|
for (const recipient of recipients) {
|
|
4068
4128
|
let address;
|
|
4069
4129
|
try {
|
|
4070
|
-
address =
|
|
4130
|
+
address = chunkDAYCCIRO_cjs.ArkAddress.decode(recipient.address);
|
|
4071
4131
|
} catch (e) {
|
|
4072
4132
|
throw new Error(`Invalid Arkade address: ${recipient.address}`);
|
|
4073
4133
|
}
|
|
@@ -4092,7 +4152,7 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
4092
4152
|
|
|
4093
4153
|
// src/contracts/spendability.ts
|
|
4094
4154
|
function isContractGenericallySpendable(contract) {
|
|
4095
|
-
return
|
|
4155
|
+
return chunkFUW3OM5X_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
|
|
4096
4156
|
}
|
|
4097
4157
|
function gatedContracts(contracts) {
|
|
4098
4158
|
const gated = /* @__PURE__ */ new Map();
|
|
@@ -4114,7 +4174,7 @@ function gateExclusion(gated) {
|
|
|
4114
4174
|
return (vtxo) => {
|
|
4115
4175
|
const type = gatedTypeOf(vtxo, gated);
|
|
4116
4176
|
if (type === void 0) return void 0;
|
|
4117
|
-
if (!
|
|
4177
|
+
if (!chunkFUW3OM5X_cjs.contractHandlers.has(type)) {
|
|
4118
4178
|
return `at ${vtxo.script} (contract type '${type}') has no handler registered in this build`;
|
|
4119
4179
|
}
|
|
4120
4180
|
return `at ${vtxo.script} (contract type '${type}') is not generically spendable`;
|
|
@@ -4150,7 +4210,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
|
|
|
4150
4210
|
continue;
|
|
4151
4211
|
}
|
|
4152
4212
|
for (const v of vtxos) {
|
|
4153
|
-
if (!
|
|
4213
|
+
if (!chunkDAYCCIRO_cjs.isVtxoSpent(v) && !v.isSwept && !v.isUnrolled) {
|
|
4154
4214
|
out.add(`${v.txid}:${v.vout}`);
|
|
4155
4215
|
}
|
|
4156
4216
|
}
|
|
@@ -4185,10 +4245,10 @@ function byValueDescending(vtxos) {
|
|
|
4185
4245
|
return [...vtxos].sort((a, b) => b.value - a.value);
|
|
4186
4246
|
}
|
|
4187
4247
|
async function fetchTimeHeight(wallet) {
|
|
4188
|
-
return
|
|
4248
|
+
return chunkDAYCCIRO_cjs.resolveTimeHeight(wallet.onchainProvider);
|
|
4189
4249
|
}
|
|
4190
4250
|
function canMigrateBySend(vtxo, now) {
|
|
4191
|
-
if (!
|
|
4251
|
+
if (!chunkDAYCCIRO_cjs.canSpendOffchain(vtxo, now)) return false;
|
|
4192
4252
|
return vtxo.expiresAt !== void 0 || vtxo.expiresAtHeight !== void 0;
|
|
4193
4253
|
}
|
|
4194
4254
|
function byExpiryAscending(vtxos, now) {
|
|
@@ -4196,7 +4256,7 @@ function byExpiryAscending(vtxos, now) {
|
|
|
4196
4256
|
if (vtxo.isSwept) return -Infinity;
|
|
4197
4257
|
if (vtxo.expiresAt !== void 0) return vtxo.expiresAt.getTime();
|
|
4198
4258
|
if (vtxo.expiresAtHeight !== void 0) {
|
|
4199
|
-
return
|
|
4259
|
+
return chunkDAYCCIRO_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
|
|
4200
4260
|
}
|
|
4201
4261
|
return Infinity;
|
|
4202
4262
|
};
|
|
@@ -4223,7 +4283,7 @@ function priceSettlementInputs(vtxos, estimator) {
|
|
|
4223
4283
|
const payable = [];
|
|
4224
4284
|
const net = /* @__PURE__ */ new Map();
|
|
4225
4285
|
for (const vtxo of vtxos) {
|
|
4226
|
-
const inputFee = estimator.evalOffchainInput(
|
|
4286
|
+
const inputFee = estimator.evalOffchainInput(chunkDAYCCIRO_cjs.toOffchainInputFeeParams(vtxo));
|
|
4227
4287
|
if (inputFee.satoshis >= vtxo.value) {
|
|
4228
4288
|
continue;
|
|
4229
4289
|
}
|
|
@@ -4249,7 +4309,7 @@ function deductOffchainOutputFee(subtotal, estimator, arkAddress) {
|
|
|
4249
4309
|
}
|
|
4250
4310
|
const outputFee = estimator.evalOffchainOutput({
|
|
4251
4311
|
amount: subtotal,
|
|
4252
|
-
script: base.hex.encode(
|
|
4312
|
+
script: base.hex.encode(chunkDAYCCIRO_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
4253
4313
|
});
|
|
4254
4314
|
return subtotal - BigInt(outputFee.satoshis);
|
|
4255
4315
|
}
|
|
@@ -4267,10 +4327,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
|
|
|
4267
4327
|
};
|
|
4268
4328
|
function getRecoverableVtxos(vtxos, dustAmount, now) {
|
|
4269
4329
|
return vtxos.filter((vtxo) => {
|
|
4270
|
-
if (
|
|
4330
|
+
if (chunkDAYCCIRO_cjs.canRecoverOnchain(vtxo, now)) {
|
|
4271
4331
|
return true;
|
|
4272
4332
|
}
|
|
4273
|
-
if (
|
|
4333
|
+
if (chunkDAYCCIRO_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
|
|
4274
4334
|
return true;
|
|
4275
4335
|
}
|
|
4276
4336
|
return false;
|
|
@@ -4302,7 +4362,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
|
|
|
4302
4362
|
function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
4303
4363
|
if (vtxo.isUnrolled) return false;
|
|
4304
4364
|
const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
|
|
4305
|
-
const expiresAt =
|
|
4365
|
+
const expiresAt = chunkDAYCCIRO_cjs.normalizeVtxo(vtxo).expiresAt;
|
|
4306
4366
|
if (expiresAt === void 0) return false;
|
|
4307
4367
|
const now = Date.now();
|
|
4308
4368
|
const batchExpiry = expiresAt.getTime();
|
|
@@ -4313,7 +4373,7 @@ function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
|
|
|
4313
4373
|
return vtxos.filter(
|
|
4314
4374
|
// The leading exclusion covers the `isSubdust` arm too, which is a value
|
|
4315
4375
|
// property and would otherwise re-admit an exited coin on its own.
|
|
4316
|
-
(vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) ||
|
|
4376
|
+
(vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) || chunkDAYCCIRO_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount))
|
|
4317
4377
|
);
|
|
4318
4378
|
}
|
|
4319
4379
|
function isMigrationCapable(wallet) {
|
|
@@ -4915,11 +4975,11 @@ var VtxoManager = class _VtxoManager {
|
|
|
4915
4975
|
`Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
|
|
4916
4976
|
);
|
|
4917
4977
|
}
|
|
4918
|
-
const tx = new
|
|
4978
|
+
const tx = new chunkDAYCCIRO_cjs.Transaction();
|
|
4919
4979
|
for (const utxo of expiredUtxos) {
|
|
4920
|
-
const utxoScript =
|
|
4980
|
+
const utxoScript = chunkDAYCCIRO_cjs.VtxoScript.decode(utxo.tapTree);
|
|
4921
4981
|
const utxoExitLeaf = utxoScript.leaves.find(
|
|
4922
|
-
(leaf) =>
|
|
4982
|
+
(leaf) => chunkDAYCCIRO_cjs.CSVMultisigTapscript.isScriptValid(chunkDAYCCIRO_cjs.scriptFromTapLeafScript(leaf)) === true
|
|
4923
4983
|
);
|
|
4924
4984
|
if (!utxoExitLeaf) {
|
|
4925
4985
|
throw new Error(
|
|
@@ -4934,7 +4994,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4934
4994
|
amount: BigInt(utxo.value)
|
|
4935
4995
|
},
|
|
4936
4996
|
tapLeafScript: [utxoExitLeaf],
|
|
4937
|
-
sequence:
|
|
4997
|
+
sequence: chunkDAYCCIRO_cjs.getSequence(utxoExitLeaf)
|
|
4938
4998
|
});
|
|
4939
4999
|
}
|
|
4940
5000
|
tx.addOutputAddress(boardingAddress, outputAmount, this.getNetwork());
|
|
@@ -5177,8 +5237,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
5177
5237
|
const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
|
|
5178
5238
|
if (cls.status === "CURRENT") continue;
|
|
5179
5239
|
const live = vtxos.filter((v) => !v.isUnrolled);
|
|
5180
|
-
const recoverable = live.filter((v) => v.isSwept && !
|
|
5181
|
-
const spendable = live.filter((v) => !
|
|
5240
|
+
const recoverable = live.filter((v) => v.isSwept && !chunkDAYCCIRO_cjs.isVtxoSpent(v));
|
|
5241
|
+
const spendable = live.filter((v) => !chunkDAYCCIRO_cjs.isVtxoSpent(v) && !v.isSwept);
|
|
5182
5242
|
const value = spendable.reduce((sum, v) => sum + v.value, 0);
|
|
5183
5243
|
let recoverableCount = 0;
|
|
5184
5244
|
let recoverableValue = 0;
|
|
@@ -5191,7 +5251,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5191
5251
|
awaitingSweepCount = spendable.length;
|
|
5192
5252
|
awaitingSweepValue = value;
|
|
5193
5253
|
for (const v of spendable) {
|
|
5194
|
-
const exp =
|
|
5254
|
+
const exp = chunkDAYCCIRO_cjs.toBatchExpiry(v);
|
|
5195
5255
|
if (exp !== void 0 && (nextSweepEta === void 0 || exp < nextSweepEta)) {
|
|
5196
5256
|
nextSweepEta = exp;
|
|
5197
5257
|
}
|
|
@@ -5452,7 +5512,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5452
5512
|
/** Decodes the boarding tapscript exit path to extract the CSV timelock. */
|
|
5453
5513
|
getBoardingTimelock() {
|
|
5454
5514
|
const wallet = this.getSweepWallet();
|
|
5455
|
-
const exitScript =
|
|
5515
|
+
const exitScript = chunkDAYCCIRO_cjs.CSVMultisigTapscript.decode(
|
|
5456
5516
|
base.hex.decode(wallet.boardingTapscript.exitScript)
|
|
5457
5517
|
);
|
|
5458
5518
|
return exitScript.params.timelock;
|
|
@@ -5583,8 +5643,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
5583
5643
|
* or doesn't carry the metadata.
|
|
5584
5644
|
*/
|
|
5585
5645
|
extractSpentOutpoint(error) {
|
|
5586
|
-
const ark =
|
|
5587
|
-
if (!
|
|
5646
|
+
const ark = chunkDAYCCIRO_cjs.maybeArkError(error);
|
|
5647
|
+
if (!chunkDAYCCIRO_cjs.isArkError(ark, chunkDAYCCIRO_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
|
|
5588
5648
|
const raw = ark.metadata?.vtxo_outpoint;
|
|
5589
5649
|
if (typeof raw !== "string") return void 0;
|
|
5590
5650
|
const [txid, voutStr] = raw.split(":");
|
|
@@ -5774,7 +5834,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5774
5834
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
5775
5835
|
break;
|
|
5776
5836
|
}
|
|
5777
|
-
const inputFee = estimator.evalOffchainInput(
|
|
5837
|
+
const inputFee = estimator.evalOffchainInput(chunkDAYCCIRO_cjs.toOffchainInputFeeParams(v));
|
|
5778
5838
|
if (inputFee.satoshis >= v.value) {
|
|
5779
5839
|
continue;
|
|
5780
5840
|
}
|
|
@@ -5794,7 +5854,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5794
5854
|
const arkAddress = await this.wallet.getAddress();
|
|
5795
5855
|
const outputFee = estimator.evalOffchainOutput({
|
|
5796
5856
|
amount: totalAmount,
|
|
5797
|
-
script: base.hex.encode(
|
|
5857
|
+
script: base.hex.encode(chunkDAYCCIRO_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
5798
5858
|
});
|
|
5799
5859
|
totalAmount -= BigInt(outputFee.satoshis);
|
|
5800
5860
|
if (totalAmount < dustAmount) return;
|
|
@@ -5874,7 +5934,7 @@ var ArkNote = class _ArkNote {
|
|
|
5874
5934
|
this.value = value;
|
|
5875
5935
|
this.HRP = HRP;
|
|
5876
5936
|
const preimageHash = utils_js.sha256(this.preimage);
|
|
5877
|
-
this.vtxoScript = new
|
|
5937
|
+
this.vtxoScript = new chunkDAYCCIRO_cjs.VtxoScript([noteTapscript(preimageHash)]);
|
|
5878
5938
|
const leaf = this.vtxoScript.leaves[0];
|
|
5879
5939
|
this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
|
|
5880
5940
|
this.tapTree = this.vtxoScript.encode();
|
|
@@ -6041,7 +6101,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
6041
6101
|
const privateKey = data.slice(1, 33);
|
|
6042
6102
|
const serverPubKey = data.slice(33, 65);
|
|
6043
6103
|
const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
|
|
6044
|
-
const csvTimelock2 =
|
|
6104
|
+
const csvTimelock2 = chunkDAYCCIRO_cjs.sequenceToTimelock(sequence);
|
|
6045
6105
|
return new _ArkadeCash(privateKey, serverPubKey, csvTimelock2, decoded.prefix);
|
|
6046
6106
|
}
|
|
6047
6107
|
toString() {
|
|
@@ -6049,7 +6109,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
6049
6109
|
data[0] = _ArkadeCash.Version;
|
|
6050
6110
|
data.set(this._privateKey, 1);
|
|
6051
6111
|
data.set(this._serverPubKey, 33);
|
|
6052
|
-
const sequence =
|
|
6112
|
+
const sequence = chunkDAYCCIRO_cjs.timelockToSequence(this.csvTimelock);
|
|
6053
6113
|
new DataView(data.buffer, data.byteOffset + 65, 4).setUint32(0, sequence, false);
|
|
6054
6114
|
const words = base.bech32m.toWords(data);
|
|
6055
6115
|
return base.bech32m.encode(this.hrp, words, 1023);
|
|
@@ -6058,7 +6118,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
6058
6118
|
return SingleKey.fromPrivateKey(this._privateKey);
|
|
6059
6119
|
}
|
|
6060
6120
|
get vtxoScript() {
|
|
6061
|
-
return new
|
|
6121
|
+
return new chunkFUW3OM5X_cjs.DefaultVtxo.Script({
|
|
6062
6122
|
pubKey: this._publicKey,
|
|
6063
6123
|
serverPubKey: this._serverPubKey,
|
|
6064
6124
|
csvTimelock: this.csvTimelock
|
|
@@ -6319,7 +6379,7 @@ async function captureExitBranch(params) {
|
|
|
6319
6379
|
const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
|
|
6320
6380
|
if (nonCommitment.length > 0) {
|
|
6321
6381
|
for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
|
|
6322
|
-
psbtByTxid.set(
|
|
6382
|
+
psbtByTxid.set(chunkDAYCCIRO_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
6323
6383
|
}
|
|
6324
6384
|
}
|
|
6325
6385
|
}
|
|
@@ -6362,10 +6422,10 @@ var IndexerExitDataSource = class {
|
|
|
6362
6422
|
while (hasMore) {
|
|
6363
6423
|
const { chain: page, page: meta } = await this.indexer.getVtxoChain(
|
|
6364
6424
|
{ txid: vtxo.txid, vout: vtxo.vout },
|
|
6365
|
-
{ pageIndex, pageSize:
|
|
6425
|
+
{ pageIndex, pageSize: chunkDAYCCIRO_cjs.DEFAULT_PAGE_SIZE }
|
|
6366
6426
|
);
|
|
6367
6427
|
chain.push(...page);
|
|
6368
|
-
hasMore = meta ? page.length ===
|
|
6428
|
+
hasMore = meta ? page.length === chunkDAYCCIRO_cjs.DEFAULT_PAGE_SIZE : false;
|
|
6369
6429
|
pageIndex++;
|
|
6370
6430
|
}
|
|
6371
6431
|
return chain;
|
|
@@ -6377,12 +6437,12 @@ var IndexerExitDataSource = class {
|
|
|
6377
6437
|
while (hasMore) {
|
|
6378
6438
|
const { txs, page } = await this.indexer.getVirtualTxs(txids, {
|
|
6379
6439
|
pageIndex,
|
|
6380
|
-
pageSize:
|
|
6440
|
+
pageSize: chunkDAYCCIRO_cjs.DEFAULT_PAGE_SIZE
|
|
6381
6441
|
});
|
|
6382
6442
|
for (const psbt of txs) {
|
|
6383
|
-
out.set(
|
|
6443
|
+
out.set(chunkDAYCCIRO_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
6384
6444
|
}
|
|
6385
|
-
hasMore = page ? txs.length ===
|
|
6445
|
+
hasMore = page ? txs.length === chunkDAYCCIRO_cjs.DEFAULT_PAGE_SIZE : false;
|
|
6386
6446
|
pageIndex++;
|
|
6387
6447
|
}
|
|
6388
6448
|
return out;
|
|
@@ -6403,7 +6463,7 @@ function chainedTxTypeToChainTxType(t) {
|
|
|
6403
6463
|
}
|
|
6404
6464
|
}
|
|
6405
6465
|
function psbtInputTxids(psbtBase64) {
|
|
6406
|
-
const tx =
|
|
6466
|
+
const tx = chunkDAYCCIRO_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
6407
6467
|
const ids = [];
|
|
6408
6468
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
6409
6469
|
const txid = tx.getInput(i).txid;
|
|
@@ -6762,10 +6822,10 @@ async function resolveArkInfo(arkProvider, walletRepository) {
|
|
|
6762
6822
|
try {
|
|
6763
6823
|
info = await arkProvider.getInfo();
|
|
6764
6824
|
} catch (err) {
|
|
6765
|
-
if (!
|
|
6825
|
+
if (!chunkDAYCCIRO_cjs.isRetryableProviderError(err)) throw err;
|
|
6766
6826
|
const snapshot = await loadArkInfoSnapshot(walletRepository);
|
|
6767
6827
|
if (!snapshot) {
|
|
6768
|
-
throw new
|
|
6828
|
+
throw new chunkDAYCCIRO_cjs.ProviderUnavailableError(
|
|
6769
6829
|
"Arkade server info is unavailable and no cached snapshot exists",
|
|
6770
6830
|
{ cause: err }
|
|
6771
6831
|
);
|
|
@@ -6957,7 +7017,7 @@ function buildGraph(rootTxid, chunksByTxid) {
|
|
|
6957
7017
|
return new TxTree(rootTx, children);
|
|
6958
7018
|
}
|
|
6959
7019
|
function decodeNode(chunk) {
|
|
6960
|
-
const tx =
|
|
7020
|
+
const tx = chunkDAYCCIRO_cjs.Transaction.fromPSBT(base.base64.decode(chunk.tx));
|
|
6961
7021
|
return { tx, children: chunk.children };
|
|
6962
7022
|
}
|
|
6963
7023
|
exports.Batch = void 0;
|
|
@@ -7172,7 +7232,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos, localCreatedAt) {
|
|
|
7172
7232
|
return [...txids];
|
|
7173
7233
|
}
|
|
7174
7234
|
async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt, gatedScripts = /* @__PURE__ */ new Map()) {
|
|
7175
|
-
const normalized = vtxos.map(
|
|
7235
|
+
const normalized = vtxos.map(chunkDAYCCIRO_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
7176
7236
|
const localCreatedAt = localCreatedAtByTxid(normalized);
|
|
7177
7237
|
const gatedVtxos = normalized.filter((vtxo) => isGatedVtxo(vtxo, gatedScripts));
|
|
7178
7238
|
const ownVtxos = normalized.filter((vtxo) => !isGatedVtxo(vtxo, gatedScripts));
|
|
@@ -7347,7 +7407,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7347
7407
|
withRecoverable: false,
|
|
7348
7408
|
genericallySpendableOnly: true
|
|
7349
7409
|
});
|
|
7350
|
-
const controlAssetRef = params.controlAssetId ?
|
|
7410
|
+
const controlAssetRef = params.controlAssetId ? chunkSJPPBR2V_cjs.AssetRef.fromId(chunkSJPPBR2V_cjs.AssetId.fromString(params.controlAssetId)) : null;
|
|
7351
7411
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
7352
7412
|
let totalBtcSelected = 0n;
|
|
7353
7413
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -7360,8 +7420,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7360
7420
|
}
|
|
7361
7421
|
}
|
|
7362
7422
|
const groups = [];
|
|
7363
|
-
const issuedAssetOutput =
|
|
7364
|
-
const issuedAssetGroup =
|
|
7423
|
+
const issuedAssetOutput = chunkSJPPBR2V_cjs.AssetOutput.create(0, params.amount);
|
|
7424
|
+
const issuedAssetGroup = chunkSJPPBR2V_cjs.AssetGroup.create(
|
|
7365
7425
|
null,
|
|
7366
7426
|
controlAssetRef,
|
|
7367
7427
|
[],
|
|
@@ -7376,28 +7436,28 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7376
7436
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7377
7437
|
for (const asset of assets) {
|
|
7378
7438
|
if (asset.assetId !== assetId) continue;
|
|
7379
|
-
changeInputs.push(
|
|
7439
|
+
changeInputs.push(chunkSJPPBR2V_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7380
7440
|
}
|
|
7381
7441
|
}
|
|
7382
7442
|
groups.push(
|
|
7383
|
-
|
|
7384
|
-
|
|
7443
|
+
chunkSJPPBR2V_cjs.AssetGroup.create(
|
|
7444
|
+
chunkSJPPBR2V_cjs.AssetId.fromString(assetId),
|
|
7385
7445
|
null,
|
|
7386
7446
|
changeInputs,
|
|
7387
|
-
[
|
|
7447
|
+
[chunkSJPPBR2V_cjs.AssetOutput.create(0, amount)],
|
|
7388
7448
|
[]
|
|
7389
7449
|
)
|
|
7390
7450
|
);
|
|
7391
7451
|
}
|
|
7392
7452
|
}
|
|
7393
7453
|
const address = await this.wallet.getAddress();
|
|
7394
|
-
const outputAddress =
|
|
7454
|
+
const outputAddress = chunkDAYCCIRO_cjs.ArkAddress.decode(address);
|
|
7395
7455
|
const outputs = [
|
|
7396
7456
|
{
|
|
7397
7457
|
script: outputAddress.pkScript,
|
|
7398
7458
|
amount: BigInt(totalBtcSelected)
|
|
7399
7459
|
},
|
|
7400
|
-
Extension.create([
|
|
7460
|
+
Extension.create([chunkSJPPBR2V_cjs.Packet.create(groups)]).txOut()
|
|
7401
7461
|
];
|
|
7402
7462
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
|
|
7403
7463
|
coinSelection.inputs,
|
|
@@ -7405,7 +7465,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7405
7465
|
);
|
|
7406
7466
|
return {
|
|
7407
7467
|
arkTxId: arkTxid,
|
|
7408
|
-
assetId:
|
|
7468
|
+
assetId: chunkSJPPBR2V_cjs.AssetId.create(arkTxid, 0).toString()
|
|
7409
7469
|
};
|
|
7410
7470
|
}
|
|
7411
7471
|
/**
|
|
@@ -7478,16 +7538,16 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7478
7538
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7479
7539
|
for (const asset of assets) {
|
|
7480
7540
|
if (asset.assetId !== params.assetId) continue;
|
|
7481
|
-
reissueInputs.push(
|
|
7541
|
+
reissueInputs.push(chunkSJPPBR2V_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7482
7542
|
}
|
|
7483
7543
|
}
|
|
7484
7544
|
const totalAssetAmount = assetToReissueAmount + params.amount;
|
|
7485
|
-
const reissueAssetIdObj =
|
|
7486
|
-
const reissueAssetGroup =
|
|
7545
|
+
const reissueAssetIdObj = chunkSJPPBR2V_cjs.AssetId.fromString(params.assetId);
|
|
7546
|
+
const reissueAssetGroup = chunkSJPPBR2V_cjs.AssetGroup.create(
|
|
7487
7547
|
reissueAssetIdObj,
|
|
7488
7548
|
null,
|
|
7489
7549
|
reissueInputs,
|
|
7490
|
-
[
|
|
7550
|
+
[chunkSJPPBR2V_cjs.AssetOutput.create(0, totalAssetAmount)],
|
|
7491
7551
|
[]
|
|
7492
7552
|
);
|
|
7493
7553
|
const groups = [reissueAssetGroup];
|
|
@@ -7496,27 +7556,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7496
7556
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7497
7557
|
for (const asset of assets) {
|
|
7498
7558
|
if (asset.assetId !== assetId) continue;
|
|
7499
|
-
changeInputs.push(
|
|
7559
|
+
changeInputs.push(chunkSJPPBR2V_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7500
7560
|
}
|
|
7501
7561
|
}
|
|
7502
7562
|
groups.push(
|
|
7503
|
-
|
|
7504
|
-
|
|
7563
|
+
chunkSJPPBR2V_cjs.AssetGroup.create(
|
|
7564
|
+
chunkSJPPBR2V_cjs.AssetId.fromString(assetId),
|
|
7505
7565
|
null,
|
|
7506
7566
|
changeInputs,
|
|
7507
|
-
[
|
|
7567
|
+
[chunkSJPPBR2V_cjs.AssetOutput.create(0, amount)],
|
|
7508
7568
|
[]
|
|
7509
7569
|
)
|
|
7510
7570
|
);
|
|
7511
7571
|
}
|
|
7512
7572
|
const address = await this.wallet.getAddress();
|
|
7513
|
-
const outputAddress =
|
|
7573
|
+
const outputAddress = chunkDAYCCIRO_cjs.ArkAddress.decode(address);
|
|
7514
7574
|
const outputs = [
|
|
7515
7575
|
{
|
|
7516
7576
|
script: outputAddress.pkScript,
|
|
7517
7577
|
amount: BigInt(totalBtcSelected)
|
|
7518
7578
|
},
|
|
7519
|
-
Extension.create([
|
|
7579
|
+
Extension.create([chunkSJPPBR2V_cjs.Packet.create(groups)]).txOut()
|
|
7520
7580
|
];
|
|
7521
7581
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
7522
7582
|
return arkTxid;
|
|
@@ -7584,27 +7644,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7584
7644
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7585
7645
|
for (const asset of assets) {
|
|
7586
7646
|
if (asset.assetId !== assetId) continue;
|
|
7587
|
-
changeInputs.push(
|
|
7647
|
+
changeInputs.push(chunkSJPPBR2V_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7588
7648
|
}
|
|
7589
7649
|
}
|
|
7590
7650
|
groups.push(
|
|
7591
|
-
|
|
7592
|
-
|
|
7651
|
+
chunkSJPPBR2V_cjs.AssetGroup.create(
|
|
7652
|
+
chunkSJPPBR2V_cjs.AssetId.fromString(assetId),
|
|
7593
7653
|
null,
|
|
7594
7654
|
changeInputs,
|
|
7595
|
-
amount > 0n ? [
|
|
7655
|
+
amount > 0n ? [chunkSJPPBR2V_cjs.AssetOutput.create(0, amount)] : [],
|
|
7596
7656
|
[]
|
|
7597
7657
|
)
|
|
7598
7658
|
);
|
|
7599
7659
|
}
|
|
7600
7660
|
const address = await this.wallet.getAddress();
|
|
7601
|
-
const outputAddress =
|
|
7661
|
+
const outputAddress = chunkDAYCCIRO_cjs.ArkAddress.decode(address);
|
|
7602
7662
|
const outputs = [
|
|
7603
7663
|
{
|
|
7604
7664
|
script: outputAddress.pkScript,
|
|
7605
7665
|
amount: BigInt(totalBtcSelected)
|
|
7606
7666
|
},
|
|
7607
|
-
Extension.create([
|
|
7667
|
+
Extension.create([chunkSJPPBR2V_cjs.Packet.create(groups)]).txOut()
|
|
7608
7668
|
];
|
|
7609
7669
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
7610
7670
|
return arkTxid;
|
|
@@ -7629,7 +7689,7 @@ function castMetadata(metadata) {
|
|
|
7629
7689
|
} else {
|
|
7630
7690
|
throw new Error("Invalid metadata value type");
|
|
7631
7691
|
}
|
|
7632
|
-
md.push(
|
|
7692
|
+
md.push(chunkSJPPBR2V_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
|
|
7633
7693
|
}
|
|
7634
7694
|
return md;
|
|
7635
7695
|
}
|
|
@@ -7650,10 +7710,10 @@ var DelegateManagerImpl = class {
|
|
|
7650
7710
|
if (vtxos.length === 0) {
|
|
7651
7711
|
return { delegated: [], failed: [] };
|
|
7652
7712
|
}
|
|
7653
|
-
const destinationScript =
|
|
7713
|
+
const destinationScript = chunkDAYCCIRO_cjs.ArkAddress.decode(destination).pkScript;
|
|
7654
7714
|
const arkInfo = await this.arkInfoProvider.getInfo();
|
|
7655
7715
|
const delegateInfo = await this.delegateProvider.getDelegateInfo();
|
|
7656
|
-
const eligible = vtxos.map(
|
|
7716
|
+
const eligible = vtxos.map(chunkDAYCCIRO_cjs.normalizeVtxo).filter(
|
|
7657
7717
|
(v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
|
|
7658
7718
|
);
|
|
7659
7719
|
if (eligible.length === 0) {
|
|
@@ -7682,11 +7742,11 @@ var DelegateManagerImpl = class {
|
|
|
7682
7742
|
const groupByExpiry = /* @__PURE__ */ new Map();
|
|
7683
7743
|
let recoverableVtxos = [];
|
|
7684
7744
|
for (const vtxo of eligible) {
|
|
7685
|
-
if (
|
|
7745
|
+
if (chunkDAYCCIRO_cjs.canRecoverOnchain(vtxo, now)) {
|
|
7686
7746
|
recoverableVtxos.push(vtxo);
|
|
7687
7747
|
continue;
|
|
7688
7748
|
}
|
|
7689
|
-
const expiry =
|
|
7749
|
+
const expiry = chunkDAYCCIRO_cjs.toBatchExpiry(vtxo);
|
|
7690
7750
|
if (!expiry) continue;
|
|
7691
7751
|
const dayKey = getDayTimestamp(expiry);
|
|
7692
7752
|
groupByExpiry.set(dayKey, [...groupByExpiry.get(dayKey) ?? [], vtxo]);
|
|
@@ -7751,7 +7811,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7751
7811
|
}
|
|
7752
7812
|
if (!delegateAt) {
|
|
7753
7813
|
const now = { timestamp: /* @__PURE__ */ new Date() };
|
|
7754
|
-
const expiryTimestamp = vtxos.filter((coin) => !
|
|
7814
|
+
const expiryTimestamp = vtxos.filter((coin) => !chunkDAYCCIRO_cjs.canRecoverOnchain(coin, now) && chunkDAYCCIRO_cjs.toBatchExpiry(coin)).reduce((min, coin) => Math.min(min, chunkDAYCCIRO_cjs.toBatchExpiry(coin)), Number.MAX_SAFE_INTEGER);
|
|
7755
7815
|
if (!expiryTimestamp || expiryTimestamp === Number.MAX_SAFE_INTEGER) {
|
|
7756
7816
|
delegateAt = new Date(Date.now() + 1 * 60 * 1e3);
|
|
7757
7817
|
} else {
|
|
@@ -7775,7 +7835,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7775
7835
|
let amount = 0n;
|
|
7776
7836
|
for (const coin of vtxos) {
|
|
7777
7837
|
const inputFee = estimator.evalOffchainInput({
|
|
7778
|
-
...
|
|
7838
|
+
...chunkDAYCCIRO_cjs.toOffchainInputFeeParams(coin),
|
|
7779
7839
|
type: "vtxo"
|
|
7780
7840
|
});
|
|
7781
7841
|
if (inputFee.value >= coin.value) {
|
|
@@ -7789,7 +7849,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7789
7849
|
const delegateFee = BigInt(Number(fee));
|
|
7790
7850
|
if (delegateFee > 0n) {
|
|
7791
7851
|
outputs.push({
|
|
7792
|
-
script:
|
|
7852
|
+
script: chunkDAYCCIRO_cjs.ArkAddress.decode(delegateAddress).pkScript,
|
|
7793
7853
|
amount: delegateFee
|
|
7794
7854
|
});
|
|
7795
7855
|
}
|
|
@@ -7822,10 +7882,10 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7822
7882
|
destinationScript
|
|
7823
7883
|
);
|
|
7824
7884
|
const forfeitOutputScript = btcSigner.OutScript.encode(
|
|
7825
|
-
btcSigner.Address(
|
|
7885
|
+
btcSigner.Address(chunkDAYCCIRO_cjs.getNetwork(network)).decode(forfeitAddress)
|
|
7826
7886
|
);
|
|
7827
7887
|
const forfeits = await Promise.all(
|
|
7828
|
-
vtxos.filter((v) =>
|
|
7888
|
+
vtxos.filter((v) => chunkDAYCCIRO_cjs.requiresForfeit(v)).map(async (coin) => {
|
|
7829
7889
|
const forfeit = await makeDelegateForfeitTx(
|
|
7830
7890
|
coin,
|
|
7831
7891
|
dust,
|
|
@@ -7850,7 +7910,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
|
|
|
7850
7910
|
index: input.vout,
|
|
7851
7911
|
witnessUtxo: {
|
|
7852
7912
|
amount: BigInt(input.value),
|
|
7853
|
-
script:
|
|
7913
|
+
script: chunkDAYCCIRO_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
7854
7914
|
},
|
|
7855
7915
|
sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
|
|
7856
7916
|
tapLeafScript: [delegateTapLeaf]
|
|
@@ -7908,7 +7968,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
7908
7968
|
expire_at: 0,
|
|
7909
7969
|
cosigners_public_keys: cosignerPubKeys
|
|
7910
7970
|
};
|
|
7911
|
-
const proof =
|
|
7971
|
+
const proof = chunkDAYCCIRO_cjs.Intent.create(message, coins, outputs);
|
|
7912
7972
|
const signedProof = await identity.sign(proof);
|
|
7913
7973
|
return {
|
|
7914
7974
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -7934,10 +7994,10 @@ function getDayTimestamp(timestamp) {
|
|
|
7934
7994
|
function findDelegateTapLeaf(vtxo, delegatePubkey) {
|
|
7935
7995
|
if (!vtxo.tapTree) return void 0;
|
|
7936
7996
|
const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
|
|
7937
|
-
const vtxoScript =
|
|
7997
|
+
const vtxoScript = chunkDAYCCIRO_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
7938
7998
|
return vtxoScript.leaves.find((tapLeaf) => {
|
|
7939
|
-
const arkTapscript =
|
|
7940
|
-
if (!
|
|
7999
|
+
const arkTapscript = chunkDAYCCIRO_cjs.decodeTapscript(chunkDAYCCIRO_cjs.scriptFromTapLeafScript(tapLeaf));
|
|
8000
|
+
if (!chunkDAYCCIRO_cjs.MultisigTapscript.is(arkTapscript)) return false;
|
|
7941
8001
|
return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
|
|
7942
8002
|
});
|
|
7943
8003
|
}
|
|
@@ -8218,7 +8278,7 @@ function createManagedConnection(dbName, version, initDatabase2) {
|
|
|
8218
8278
|
};
|
|
8219
8279
|
}
|
|
8220
8280
|
function scriptFromArkAddress(address) {
|
|
8221
|
-
return base.hex.encode(
|
|
8281
|
+
return base.hex.encode(chunkDAYCCIRO_cjs.ArkAddress.decode(address).pkScript);
|
|
8222
8282
|
}
|
|
8223
8283
|
|
|
8224
8284
|
// src/repositories/indexedDB/schema.ts
|
|
@@ -8388,7 +8448,7 @@ function initDatabase(db, oldVersion, transaction) {
|
|
|
8388
8448
|
backfillVtxoIndexFields(transaction);
|
|
8389
8449
|
}
|
|
8390
8450
|
}
|
|
8391
|
-
var unspentFlag = (vtxo) =>
|
|
8451
|
+
var unspentFlag = (vtxo) => chunkDAYCCIRO_cjs.isVtxoSpent(vtxo) ? {} : { unspent: 1 };
|
|
8392
8452
|
function initDatabaseWithIntents(db, oldVersion, transaction) {
|
|
8393
8453
|
initDatabase(db, oldVersion, transaction);
|
|
8394
8454
|
if (!db.objectStoreNames.contains(STORE_INTENTS)) {
|
|
@@ -8727,8 +8787,8 @@ function validateVtxosForScript(vtxos, script, context) {
|
|
|
8727
8787
|
}
|
|
8728
8788
|
async function getVtxosForContract(repo, contract, options) {
|
|
8729
8789
|
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);
|
|
8730
|
-
const normalized = vtxos.map(
|
|
8731
|
-
return options?.unspentOnly ? normalized.filter((vtxo) => !
|
|
8790
|
+
const normalized = vtxos.map(chunkDAYCCIRO_cjs.normalizeVtxo);
|
|
8791
|
+
return options?.unspentOnly ? normalized.filter((vtxo) => !chunkDAYCCIRO_cjs.isVtxoSpent(vtxo)) : normalized;
|
|
8732
8792
|
}
|
|
8733
8793
|
function hasRecordedSpend(vtxo) {
|
|
8734
8794
|
return vtxo.isSpent === true && (!!vtxo.spentBy || !!vtxo.arkTxId || !!vtxo.settledBy);
|
|
@@ -8833,7 +8893,7 @@ var InMemoryWalletRepository = class {
|
|
|
8833
8893
|
}
|
|
8834
8894
|
}
|
|
8835
8895
|
const rows = [...byOutpoint.values()];
|
|
8836
|
-
return options?.unspentOnly ? rows.filter((vtxo) => !
|
|
8896
|
+
return options?.unspentOnly ? rows.filter((vtxo) => !chunkDAYCCIRO_cjs.isVtxoSpent(vtxo)) : rows;
|
|
8837
8897
|
}
|
|
8838
8898
|
async saveVtxosForScript(key, vtxos) {
|
|
8839
8899
|
if (!key.address) {
|
|
@@ -8935,7 +8995,7 @@ function decodeArkContract(encoded) {
|
|
|
8935
8995
|
}
|
|
8936
8996
|
function contractFromArkContract(encoded, options = {}) {
|
|
8937
8997
|
const parsed = decodeArkContract(encoded);
|
|
8938
|
-
const handler =
|
|
8998
|
+
const handler = chunkFUW3OM5X_cjs.contractHandlers.get(parsed.type);
|
|
8939
8999
|
if (!handler) {
|
|
8940
9000
|
throw new Error(`No handler registered for contract type '${parsed.type}'`);
|
|
8941
9001
|
}
|
|
@@ -8949,9 +9009,9 @@ function contractFromArkContract(encoded, options = {}) {
|
|
|
8949
9009
|
metadata: options.metadata
|
|
8950
9010
|
};
|
|
8951
9011
|
}
|
|
8952
|
-
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix =
|
|
9012
|
+
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkDAYCCIRO_cjs.DEFAULT_NETWORK.hrp, options = {}) {
|
|
8953
9013
|
const parsed = decodeArkContract(encoded);
|
|
8954
|
-
const handler =
|
|
9014
|
+
const handler = chunkFUW3OM5X_cjs.contractHandlers.getOrThrow(parsed.type);
|
|
8955
9015
|
const params = parsed.data;
|
|
8956
9016
|
const vtxoScript = handler.createScript(params);
|
|
8957
9017
|
return {
|
|
@@ -9257,9 +9317,9 @@ var ContractWatcher = class {
|
|
|
9257
9317
|
this.connectionState = "connected";
|
|
9258
9318
|
this.reconnectAttempts = 0;
|
|
9259
9319
|
this.listenLoop().catch((e) => {
|
|
9260
|
-
if (
|
|
9320
|
+
if (chunkDAYCCIRO_cjs.isEventSourceError(e)) {
|
|
9261
9321
|
console.debug("ContractWatcher subscription disconnected; reconnecting");
|
|
9262
|
-
} else if (!
|
|
9322
|
+
} else if (!chunkDAYCCIRO_cjs.isEventSourceUnavailableError(e)) {
|
|
9263
9323
|
console.error(e);
|
|
9264
9324
|
}
|
|
9265
9325
|
this.connectionState = "disconnected";
|
|
@@ -9271,7 +9331,7 @@ var ContractWatcher = class {
|
|
|
9271
9331
|
this.scheduleReconnect();
|
|
9272
9332
|
});
|
|
9273
9333
|
} catch (error) {
|
|
9274
|
-
if (!
|
|
9334
|
+
if (!chunkDAYCCIRO_cjs.isEventSourceUnavailableError(error)) {
|
|
9275
9335
|
console.error("ContractWatcher connection failed:", error);
|
|
9276
9336
|
}
|
|
9277
9337
|
this.connectionState = "disconnected";
|
|
@@ -9297,7 +9357,7 @@ var ContractWatcher = class {
|
|
|
9297
9357
|
* slower; what it loses is push latency.
|
|
9298
9358
|
*/
|
|
9299
9359
|
reportEventSourceUnavailable(error) {
|
|
9300
|
-
if (!
|
|
9360
|
+
if (!chunkDAYCCIRO_cjs.isEventSourceUnavailableError(error)) return false;
|
|
9301
9361
|
if (!this.eventSourceReported) {
|
|
9302
9362
|
this.eventSourceReported = true;
|
|
9303
9363
|
console.warn(
|
|
@@ -9369,7 +9429,7 @@ var ContractWatcher = class {
|
|
|
9369
9429
|
const now = Date.now();
|
|
9370
9430
|
let current;
|
|
9371
9431
|
try {
|
|
9372
|
-
current = await
|
|
9432
|
+
current = await chunkDAYCCIRO_cjs.getAllNormalizedVtxos(this.config.indexerProvider, scripts, {
|
|
9373
9433
|
spendableOnly: true
|
|
9374
9434
|
});
|
|
9375
9435
|
} catch (error) {
|
|
@@ -9578,14 +9638,14 @@ var ContractWatcher = class {
|
|
|
9578
9638
|
const timestamp = Date.now();
|
|
9579
9639
|
if (update.newVtxos?.length) {
|
|
9580
9640
|
this.processSubscriptionVtxos(
|
|
9581
|
-
update.newVtxos.map(
|
|
9641
|
+
update.newVtxos.map(chunkDAYCCIRO_cjs.normalizeVtxo),
|
|
9582
9642
|
"vtxo_received",
|
|
9583
9643
|
timestamp
|
|
9584
9644
|
);
|
|
9585
9645
|
}
|
|
9586
9646
|
if (update.spentVtxos?.length) {
|
|
9587
9647
|
this.processSubscriptionVtxos(
|
|
9588
|
-
update.spentVtxos.map(
|
|
9648
|
+
update.spentVtxos.map(chunkDAYCCIRO_cjs.normalizeVtxo),
|
|
9589
9649
|
"vtxo_spent",
|
|
9590
9650
|
timestamp
|
|
9591
9651
|
);
|
|
@@ -9613,8 +9673,8 @@ var ContractWatcher = class {
|
|
|
9613
9673
|
continue;
|
|
9614
9674
|
}
|
|
9615
9675
|
if (target === byWatchedScript && eventType === "vtxo_received") {
|
|
9616
|
-
const n =
|
|
9617
|
-
if (
|
|
9676
|
+
const n = chunkDAYCCIRO_cjs.normalizeVtxo(vtxo);
|
|
9677
|
+
if (chunkDAYCCIRO_cjs.isVtxoSpent(n) || n.isSwept || chunkDAYCCIRO_cjs.isPastExpiry(n, now)) continue;
|
|
9618
9678
|
}
|
|
9619
9679
|
let bucket = target.get(vtxo.script);
|
|
9620
9680
|
if (!bucket) {
|
|
@@ -9713,7 +9773,7 @@ var NON_TERMINAL_INTENT_STATES = ALL_INTENT_STATES.filter(
|
|
|
9713
9773
|
(s) => !isTerminalIntentState(s)
|
|
9714
9774
|
);
|
|
9715
9775
|
function isConsumed(vtxo) {
|
|
9716
|
-
return vtxo !== void 0 &&
|
|
9776
|
+
return vtxo !== void 0 && chunkDAYCCIRO_cjs.isVtxoSpent(vtxo);
|
|
9717
9777
|
}
|
|
9718
9778
|
async function classifyIntent(intent, vtxosByOutpoint, now) {
|
|
9719
9779
|
if (isTerminalIntentState(intent.state)) return void 0;
|
|
@@ -9756,7 +9816,7 @@ async function reconcileIntents(deps) {
|
|
|
9756
9816
|
let vtxosByOutpoint = /* @__PURE__ */ new Map();
|
|
9757
9817
|
if (outpoints.length > 0) {
|
|
9758
9818
|
try {
|
|
9759
|
-
const { vtxos } = await
|
|
9819
|
+
const { vtxos } = await chunkDAYCCIRO_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
|
|
9760
9820
|
vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
|
|
9761
9821
|
} catch (e) {
|
|
9762
9822
|
console.error("reconcileIntents: failed to fetch input VTXO state", e);
|
|
@@ -9813,7 +9873,7 @@ function annotatableIn(scriptToContract, vtxos, memo) {
|
|
|
9813
9873
|
if (!contract) continue;
|
|
9814
9874
|
try {
|
|
9815
9875
|
const key = `${contract.type}\0${script}\0${JSON.stringify(contract.params)}`;
|
|
9816
|
-
const handler =
|
|
9876
|
+
const handler = chunkFUW3OM5X_cjs.contractHandlers.get(contract.type);
|
|
9817
9877
|
const hit = memo?.get(script);
|
|
9818
9878
|
let tapscripts;
|
|
9819
9879
|
if (hit && hit.key === key && hit.handler === handler) {
|
|
@@ -9968,7 +10028,7 @@ var ContractManager = class _ContractManager {
|
|
|
9968
10028
|
try {
|
|
9969
10029
|
await this.scheduleLookAheadDrain();
|
|
9970
10030
|
} catch (err) {
|
|
9971
|
-
if (!
|
|
10031
|
+
if (!chunkDAYCCIRO_cjs.isRetryableProviderError(err)) throw err;
|
|
9972
10032
|
this.lookAheadRefillOwed = true;
|
|
9973
10033
|
this.markSyncDegraded(err);
|
|
9974
10034
|
}
|
|
@@ -9976,7 +10036,7 @@ var ContractManager = class _ContractManager {
|
|
|
9976
10036
|
await this.reconcileWatched();
|
|
9977
10037
|
this.markSyncOnline();
|
|
9978
10038
|
} catch (err) {
|
|
9979
|
-
if (!
|
|
10039
|
+
if (!chunkDAYCCIRO_cjs.isRetryableProviderError(err)) throw err;
|
|
9980
10040
|
this.markSyncDegraded(err);
|
|
9981
10041
|
}
|
|
9982
10042
|
this.initialized = true;
|
|
@@ -10108,7 +10168,7 @@ var ContractManager = class _ContractManager {
|
|
|
10108
10168
|
const from = Math.max(0, watermark - lookAhead.size);
|
|
10109
10169
|
const to = watermark + lookAhead.size;
|
|
10110
10170
|
const deps = lookAhead.candidateDeps();
|
|
10111
|
-
const handlers =
|
|
10171
|
+
const handlers = chunkFUW3OM5X_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkFUW3OM5X_cjs.contractHandlers.get(t)).filter(hasCandidates);
|
|
10112
10172
|
const band = /* @__PURE__ */ new Map();
|
|
10113
10173
|
for (let index = from; index <= to; index++) {
|
|
10114
10174
|
const descriptor = lookAhead.materialize(index);
|
|
@@ -10119,7 +10179,7 @@ var ContractManager = class _ContractManager {
|
|
|
10119
10179
|
index,
|
|
10120
10180
|
params: {
|
|
10121
10181
|
...candidate,
|
|
10122
|
-
...
|
|
10182
|
+
...chunkFUW3OM5X_cjs.speculativeReceiveMetadata(descriptor)
|
|
10123
10183
|
}
|
|
10124
10184
|
});
|
|
10125
10185
|
}
|
|
@@ -10181,7 +10241,7 @@ var ContractManager = class _ContractManager {
|
|
|
10181
10241
|
});
|
|
10182
10242
|
for (const entry of pending) entry.catchUpPending = false;
|
|
10183
10243
|
} catch (err) {
|
|
10184
|
-
if (!
|
|
10244
|
+
if (!chunkDAYCCIRO_cjs.isRetryableProviderError(err)) throw err;
|
|
10185
10245
|
this.markSyncDegraded(err);
|
|
10186
10246
|
}
|
|
10187
10247
|
}
|
|
@@ -10231,7 +10291,7 @@ var ContractManager = class _ContractManager {
|
|
|
10231
10291
|
await this.fetchContractVxosFromIndexer([contract]);
|
|
10232
10292
|
this.markSyncOnline();
|
|
10233
10293
|
} catch (err) {
|
|
10234
|
-
if (!
|
|
10294
|
+
if (!chunkDAYCCIRO_cjs.isRetryableProviderError(err)) throw err;
|
|
10235
10295
|
this.markSyncDegraded(err);
|
|
10236
10296
|
}
|
|
10237
10297
|
await this.watcher.addContract(contract);
|
|
@@ -10265,7 +10325,7 @@ var ContractManager = class _ContractManager {
|
|
|
10265
10325
|
await this.fetchContractVxosFromIndexer(fresh);
|
|
10266
10326
|
this.markSyncOnline();
|
|
10267
10327
|
} catch (err) {
|
|
10268
|
-
if (!
|
|
10328
|
+
if (!chunkDAYCCIRO_cjs.isRetryableProviderError(err)) throw err;
|
|
10269
10329
|
this.markSyncDegraded(err);
|
|
10270
10330
|
}
|
|
10271
10331
|
for (const contract of fresh) await this.watcher.addContract(contract);
|
|
@@ -10303,7 +10363,7 @@ var ContractManager = class _ContractManager {
|
|
|
10303
10363
|
return result;
|
|
10304
10364
|
}
|
|
10305
10365
|
async upsertContractRow(params) {
|
|
10306
|
-
const handler =
|
|
10366
|
+
const handler = chunkFUW3OM5X_cjs.contractHandlers.get(params.type);
|
|
10307
10367
|
if (!handler) {
|
|
10308
10368
|
throw new Error(`No handler registered for contract type '${params.type}'`);
|
|
10309
10369
|
}
|
|
@@ -10403,7 +10463,7 @@ var ContractManager = class _ContractManager {
|
|
|
10403
10463
|
`scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
|
|
10404
10464
|
);
|
|
10405
10465
|
}
|
|
10406
|
-
const registered =
|
|
10466
|
+
const registered = chunkFUW3OM5X_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkFUW3OM5X_cjs.contractHandlers.get(t)).filter(isDiscoverable);
|
|
10407
10467
|
const discoverables = [
|
|
10408
10468
|
...registered.filter((h) => h.type === "boarding"),
|
|
10409
10469
|
...registered.filter((h) => h.type !== "boarding")
|
|
@@ -10547,7 +10607,7 @@ var ContractManager = class _ContractManager {
|
|
|
10547
10607
|
await this.syncContracts({ contracts, pageSize });
|
|
10548
10608
|
this.markSyncOnline();
|
|
10549
10609
|
} catch (err) {
|
|
10550
|
-
if (!
|
|
10610
|
+
if (!chunkDAYCCIRO_cjs.isRetryableProviderError(err)) throw err;
|
|
10551
10611
|
this.markSyncDegraded(err);
|
|
10552
10612
|
if (options?.requireSynced) {
|
|
10553
10613
|
throw new Error("Spendable VTXO read requires an online contract sync", {
|
|
@@ -10580,7 +10640,7 @@ var ContractManager = class _ContractManager {
|
|
|
10580
10640
|
}
|
|
10581
10641
|
const tapscriptCache = tapscripts ?? /* @__PURE__ */ new Map();
|
|
10582
10642
|
return vtxos.map(
|
|
10583
|
-
(vtxo) => extendVirtualCoinForContract(
|
|
10643
|
+
(vtxo) => extendVirtualCoinForContract(chunkDAYCCIRO_cjs.normalizeVtxo(vtxo), byScript, tapscriptCache)
|
|
10584
10644
|
);
|
|
10585
10645
|
}
|
|
10586
10646
|
/** @inheritdoc */
|
|
@@ -10625,14 +10685,14 @@ var ContractManager = class _ContractManager {
|
|
|
10625
10685
|
const byScript = new Map(contracts.map((contract) => [contract.script, contract]));
|
|
10626
10686
|
const asking = vtxos.filter((vtxo) => {
|
|
10627
10687
|
const contract = byScript.get(vtxo.script);
|
|
10628
|
-
return contract !== void 0 &&
|
|
10688
|
+
return contract !== void 0 && chunkFUW3OM5X_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
|
|
10629
10689
|
});
|
|
10630
10690
|
if (asking.length === 0) return refused;
|
|
10631
10691
|
const tip = await this.currentChainTip();
|
|
10632
10692
|
const walletKey = await walletPubKey?.();
|
|
10633
10693
|
for (const vtxo of asking) {
|
|
10634
10694
|
const contract = byScript.get(vtxo.script);
|
|
10635
|
-
const handler =
|
|
10695
|
+
const handler = chunkFUW3OM5X_cjs.contractHandlers.get(contract.type);
|
|
10636
10696
|
if (!handler?.assertSpendableNow) continue;
|
|
10637
10697
|
const context = {
|
|
10638
10698
|
collaborative: true,
|
|
@@ -10647,7 +10707,7 @@ var ContractManager = class _ContractManager {
|
|
|
10647
10707
|
// the next handler to answer a CSV question would meet a
|
|
10648
10708
|
// TypeError instead of a `false`. Carry the coin only when it
|
|
10649
10709
|
// really is one.
|
|
10650
|
-
vtxo:
|
|
10710
|
+
vtxo: chunkDAYCCIRO_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
|
|
10651
10711
|
};
|
|
10652
10712
|
try {
|
|
10653
10713
|
await handler.assertSpendableNow(
|
|
@@ -10804,7 +10864,7 @@ var ContractManager = class _ContractManager {
|
|
|
10804
10864
|
const { contractScript, collaborative = true, walletPubKey, vtxo } = options;
|
|
10805
10865
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
10806
10866
|
if (!contract) return [];
|
|
10807
|
-
const handler =
|
|
10867
|
+
const handler = chunkFUW3OM5X_cjs.contractHandlers.get(contract.type);
|
|
10808
10868
|
if (!handler) return [];
|
|
10809
10869
|
const script = handler.createScript(contract.params);
|
|
10810
10870
|
const tip = await this.currentChainTip();
|
|
@@ -10832,7 +10892,7 @@ var ContractManager = class _ContractManager {
|
|
|
10832
10892
|
const { contractScript, collaborative = true, walletPubKey } = options;
|
|
10833
10893
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
10834
10894
|
if (!contract) return [];
|
|
10835
|
-
const handler =
|
|
10895
|
+
const handler = chunkFUW3OM5X_cjs.contractHandlers.get(contract.type);
|
|
10836
10896
|
if (!handler) return [];
|
|
10837
10897
|
const script = handler.createScript(contract.params);
|
|
10838
10898
|
const context = {
|
|
@@ -10888,7 +10948,7 @@ var ContractManager = class _ContractManager {
|
|
|
10888
10948
|
}
|
|
10889
10949
|
async refreshOutpoints(outpoints) {
|
|
10890
10950
|
if (outpoints.length === 0) return;
|
|
10891
|
-
const { vtxos } = await
|
|
10951
|
+
const { vtxos } = await chunkDAYCCIRO_cjs.getNormalizedVtxos(this.config.indexerProvider, {
|
|
10892
10952
|
outpoints
|
|
10893
10953
|
});
|
|
10894
10954
|
if (vtxos.length === 0) return;
|
|
@@ -10990,7 +11050,7 @@ var ContractManager = class _ContractManager {
|
|
|
10990
11050
|
break;
|
|
10991
11051
|
}
|
|
10992
11052
|
} catch (err) {
|
|
10993
|
-
if (!
|
|
11053
|
+
if (!chunkDAYCCIRO_cjs.isRetryableProviderError(err)) throw err;
|
|
10994
11054
|
this.markSyncDegraded(err);
|
|
10995
11055
|
}
|
|
10996
11056
|
this.emitEvent(event);
|
|
@@ -11000,7 +11060,7 @@ var ContractManager = class _ContractManager {
|
|
|
11000
11060
|
let rows;
|
|
11001
11061
|
if (this.config.walletRepository.getVtxosForScripts) {
|
|
11002
11062
|
const byScript = new Set(contracts.map((contract) => contract.script));
|
|
11003
|
-
rows = (await this.config.walletRepository.getVtxosForScripts([...byScript], options)).filter((vtxo) => vtxo.script !== void 0 && byScript.has(vtxo.script)).map((vtxo) => ({ ...
|
|
11063
|
+
rows = (await this.config.walletRepository.getVtxosForScripts([...byScript], options)).filter((vtxo) => vtxo.script !== void 0 && byScript.has(vtxo.script)).map((vtxo) => ({ ...chunkDAYCCIRO_cjs.normalizeVtxo(vtxo), contractScript: vtxo.script }));
|
|
11004
11064
|
} else {
|
|
11005
11065
|
const res = await Promise.all(
|
|
11006
11066
|
contracts.map(
|
|
@@ -11016,7 +11076,7 @@ var ContractManager = class _ContractManager {
|
|
|
11016
11076
|
);
|
|
11017
11077
|
rows = res.flat();
|
|
11018
11078
|
}
|
|
11019
|
-
return options?.unspentOnly ? rows.filter((vtxo) => !
|
|
11079
|
+
return options?.unspentOnly ? rows.filter((vtxo) => !chunkDAYCCIRO_cjs.isVtxoSpent(vtxo)) : rows;
|
|
11020
11080
|
}
|
|
11021
11081
|
/**
|
|
11022
11082
|
* Sync virtual outputs for the given contracts against the indexer.
|
|
@@ -11089,7 +11149,7 @@ var ContractManager = class _ContractManager {
|
|
|
11089
11149
|
*/
|
|
11090
11150
|
async reconcilePendingFrontier(contracts) {
|
|
11091
11151
|
const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
|
|
11092
|
-
const vtxos = await
|
|
11152
|
+
const vtxos = await chunkDAYCCIRO_cjs.getAllNormalizedVtxos(
|
|
11093
11153
|
this.config.indexerProvider,
|
|
11094
11154
|
contracts.map((c) => c.script),
|
|
11095
11155
|
{ pendingOnly: true }
|
|
@@ -11176,7 +11236,7 @@ var ContractManager = class _ContractManager {
|
|
|
11176
11236
|
}
|
|
11177
11237
|
return result;
|
|
11178
11238
|
}
|
|
11179
|
-
async fetchContractVtxosBulk(contracts, pageSize =
|
|
11239
|
+
async fetchContractVtxosBulk(contracts, pageSize = chunkDAYCCIRO_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
|
|
11180
11240
|
if (contracts.length === 0) {
|
|
11181
11241
|
return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
|
|
11182
11242
|
}
|
|
@@ -11192,7 +11252,7 @@ var ContractManager = class _ContractManager {
|
|
|
11192
11252
|
before: syncWindow.before
|
|
11193
11253
|
}
|
|
11194
11254
|
} : {};
|
|
11195
|
-
const vtxos = await
|
|
11255
|
+
const vtxos = await chunkDAYCCIRO_cjs.getAllNormalizedVtxos(
|
|
11196
11256
|
this.config.indexerProvider,
|
|
11197
11257
|
contracts.map((c) => c.script),
|
|
11198
11258
|
{ ...windowOpts, pageSize }
|
|
@@ -11341,7 +11401,7 @@ var deserializeTapLeaf = (t) => {
|
|
|
11341
11401
|
const s = base.hex.decode(t.s);
|
|
11342
11402
|
return [cb, s];
|
|
11343
11403
|
};
|
|
11344
|
-
var deserializeVtxo = (o) =>
|
|
11404
|
+
var deserializeVtxo = (o) => chunkDAYCCIRO_cjs.normalizeVtxo({
|
|
11345
11405
|
...o,
|
|
11346
11406
|
createdAt: new Date(o.createdAt),
|
|
11347
11407
|
tapTree: base.hex.decode(o.tapTree),
|
|
@@ -11572,7 +11632,7 @@ var IndexedDBWalletRepository = class {
|
|
|
11572
11632
|
continue;
|
|
11573
11633
|
}
|
|
11574
11634
|
const vtxo = deserializeVtxoWithBackfill(row);
|
|
11575
|
-
if (!options?.unspentOnly || !
|
|
11635
|
+
if (!options?.unspentOnly || !chunkDAYCCIRO_cjs.isVtxoSpent(vtxo)) result.push(vtxo);
|
|
11576
11636
|
}
|
|
11577
11637
|
return result;
|
|
11578
11638
|
} catch (error) {
|
|
@@ -12185,7 +12245,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
12185
12245
|
*/
|
|
12186
12246
|
materializeDescriptorAt(index) {
|
|
12187
12247
|
const descriptor = this.identity.descriptor;
|
|
12188
|
-
const network =
|
|
12248
|
+
const network = chunkFUW3OM5X_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
12189
12249
|
const expansion = descriptorsScure.expand({ descriptor, network, index });
|
|
12190
12250
|
const keyInfo = expansion.expansionMap?.["@0"];
|
|
12191
12251
|
if (!keyInfo?.keyExpression) {
|
|
@@ -12333,7 +12393,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
12333
12393
|
const provider = await resolveDescriptorProvider(config, setup.walletRepository);
|
|
12334
12394
|
if (!provider) return void 0;
|
|
12335
12395
|
const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
|
|
12336
|
-
const expectedContractType = setup.offchainTapscript instanceof
|
|
12396
|
+
const expectedContractType = setup.offchainTapscript instanceof chunkFUW3OM5X_cjs.DelegateVtxo.Script ? "delegate" : "default";
|
|
12337
12397
|
const factoryOpts = {
|
|
12338
12398
|
walletRepository: setup.walletRepository,
|
|
12339
12399
|
contractRepository: setup.contractRepository,
|
|
@@ -12534,7 +12594,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
12534
12594
|
};
|
|
12535
12595
|
function deriveLeafPubkey(descriptor) {
|
|
12536
12596
|
try {
|
|
12537
|
-
return
|
|
12597
|
+
return chunkFUW3OM5X_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
12538
12598
|
} catch (e) {
|
|
12539
12599
|
throw new NonRangeableDescriptorError(
|
|
12540
12600
|
"Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
|
|
@@ -12546,7 +12606,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
12546
12606
|
const pubKey = deriveLeafPubkey(descriptor);
|
|
12547
12607
|
const tapscript = rebuildTapscript(current, pubKey);
|
|
12548
12608
|
const serverPubKey = tapscript.options.serverPubKey;
|
|
12549
|
-
const csvTimelock2 =
|
|
12609
|
+
const csvTimelock2 = chunkDAYCCIRO_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
|
|
12550
12610
|
const base$1 = {
|
|
12551
12611
|
script: base.hex.encode(tapscript.pkScript),
|
|
12552
12612
|
address: tapscript.address(hrp, serverPubKey).encode(),
|
|
@@ -12557,11 +12617,11 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
12557
12617
|
// index-0 key. Without it, spends produce unsigned PSBTs that the
|
|
12558
12618
|
// server rejects with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
12559
12619
|
metadata: {
|
|
12560
|
-
...tagSource && { source:
|
|
12620
|
+
...tagSource && { source: chunkFUW3OM5X_cjs.WALLET_RECEIVE_SOURCE },
|
|
12561
12621
|
signingDescriptor: descriptor
|
|
12562
12622
|
}
|
|
12563
12623
|
};
|
|
12564
|
-
const params = tapscript instanceof
|
|
12624
|
+
const params = tapscript instanceof chunkFUW3OM5X_cjs.DelegateVtxo.Script ? {
|
|
12565
12625
|
...base$1,
|
|
12566
12626
|
type: "delegate",
|
|
12567
12627
|
params: {
|
|
@@ -12582,10 +12642,10 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
12582
12642
|
return { tapscript, params };
|
|
12583
12643
|
}
|
|
12584
12644
|
function rebuildTapscript(current, pubKey) {
|
|
12585
|
-
if (current instanceof
|
|
12586
|
-
return new
|
|
12645
|
+
if (current instanceof chunkFUW3OM5X_cjs.DelegateVtxo.Script) {
|
|
12646
|
+
return new chunkFUW3OM5X_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
|
|
12587
12647
|
}
|
|
12588
|
-
return new
|
|
12648
|
+
return new chunkFUW3OM5X_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
|
|
12589
12649
|
}
|
|
12590
12650
|
async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
|
|
12591
12651
|
const candidates = await contractRepository.getContracts({
|
|
@@ -12594,7 +12654,7 @@ async function pickActiveReceive(contractRepository, serverPubKey, expectedType)
|
|
|
12594
12654
|
});
|
|
12595
12655
|
const serverPubKeyHex = base.hex.encode(serverPubKey);
|
|
12596
12656
|
const matching = candidates.filter(
|
|
12597
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
12657
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkFUW3OM5X_cjs.WALLET_RECEIVE_SOURCE
|
|
12598
12658
|
).sort((a, b) => {
|
|
12599
12659
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
12600
12660
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -12650,7 +12710,7 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
12650
12710
|
}
|
|
12651
12711
|
};
|
|
12652
12712
|
for (const vtxo of vtxos) {
|
|
12653
|
-
if (
|
|
12713
|
+
if (chunkDAYCCIRO_cjs.isVtxoSpent(vtxo)) continue;
|
|
12654
12714
|
addAssets(owned, vtxo);
|
|
12655
12715
|
if (vtxo.isUnrolled) {
|
|
12656
12716
|
unrolled += vtxo.value;
|
|
@@ -12660,11 +12720,11 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
12660
12720
|
pendingRecovery += vtxo.value;
|
|
12661
12721
|
continue;
|
|
12662
12722
|
}
|
|
12663
|
-
if (
|
|
12723
|
+
if (chunkDAYCCIRO_cjs.canRecoverOnchain(vtxo, now)) {
|
|
12664
12724
|
recoverable += vtxo.value;
|
|
12665
12725
|
continue;
|
|
12666
12726
|
}
|
|
12667
|
-
if (!
|
|
12727
|
+
if (!chunkDAYCCIRO_cjs.canSpendOffchain(vtxo, now)) continue;
|
|
12668
12728
|
if (vtxo.isPreconfirmed) {
|
|
12669
12729
|
preconfirmed += vtxo.value;
|
|
12670
12730
|
} else {
|
|
@@ -12841,12 +12901,12 @@ var InputSignerRouter = class {
|
|
|
12841
12901
|
};
|
|
12842
12902
|
|
|
12843
12903
|
// src/wallet/wallet.ts
|
|
12844
|
-
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl ||
|
|
12904
|
+
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl || chunkDAYCCIRO_cjs.DEFAULT_ARKADE_SERVER_URL;
|
|
12845
12905
|
function intentProofJobs(coins) {
|
|
12846
12906
|
if (coins.length === 0) return [];
|
|
12847
12907
|
const coinJobs = coins.map((coin, i) => ({
|
|
12848
12908
|
index: i + 1,
|
|
12849
|
-
lookupScript:
|
|
12909
|
+
lookupScript: chunkDAYCCIRO_cjs.VtxoScript.decode(coin.tapTree).pkScript
|
|
12850
12910
|
}));
|
|
12851
12911
|
return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
|
|
12852
12912
|
}
|
|
@@ -12878,7 +12938,7 @@ function dedupeTimelocks(timelocks) {
|
|
|
12878
12938
|
const seen = /* @__PURE__ */ new Set();
|
|
12879
12939
|
const deduped = [];
|
|
12880
12940
|
for (const timelock of timelocks) {
|
|
12881
|
-
const sequence =
|
|
12941
|
+
const sequence = chunkDAYCCIRO_cjs.timelockToSequence(timelock).toString();
|
|
12882
12942
|
if (seen.has(sequence)) continue;
|
|
12883
12943
|
seen.add(sequence);
|
|
12884
12944
|
deduped.push(timelock);
|
|
@@ -12895,7 +12955,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
12895
12955
|
state: "active"
|
|
12896
12956
|
});
|
|
12897
12957
|
const newest = candidates.filter(
|
|
12898
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
12958
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkFUW3OM5X_cjs.WALLET_RECEIVE_SOURCE
|
|
12899
12959
|
).sort((a, b) => {
|
|
12900
12960
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
12901
12961
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -12903,7 +12963,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
12903
12963
|
if (!newest?.params.pubKey) return baseline;
|
|
12904
12964
|
try {
|
|
12905
12965
|
const pubKey = base.hex.decode(newest.params.pubKey);
|
|
12906
|
-
return new
|
|
12966
|
+
return new chunkFUW3OM5X_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
|
|
12907
12967
|
} catch (e) {
|
|
12908
12968
|
console.warn("Skipping malformed boarding contract at boot", newest.script, e);
|
|
12909
12969
|
return baseline;
|
|
@@ -12922,21 +12982,21 @@ function filterSnapshotVtxos(snapshot, filter, pendingSpendOutpoints) {
|
|
|
12922
12982
|
if (vtxo.isUnrolled) {
|
|
12923
12983
|
return !!f.withUnrolled;
|
|
12924
12984
|
}
|
|
12925
|
-
if (
|
|
12985
|
+
if (chunkDAYCCIRO_cjs.isVtxoSpent(vtxo)) {
|
|
12926
12986
|
return false;
|
|
12927
12987
|
}
|
|
12928
|
-
if (!f.withRecoverable &&
|
|
12988
|
+
if (!f.withRecoverable && chunkDAYCCIRO_cjs.canRecoverOnchain(vtxo, now)) {
|
|
12929
12989
|
return false;
|
|
12930
12990
|
}
|
|
12931
12991
|
return true;
|
|
12932
12992
|
});
|
|
12933
12993
|
}
|
|
12934
12994
|
async function refreshSweptStateOfExpiredInputs(wallet, inputs) {
|
|
12935
|
-
const candidates = inputs.filter(
|
|
12995
|
+
const candidates = inputs.filter(chunkDAYCCIRO_cjs.isVirtualCoin).map(chunkDAYCCIRO_cjs.normalizeVtxo).filter((v) => !v.isSwept);
|
|
12936
12996
|
if (candidates.length === 0) return inputs;
|
|
12937
|
-
const now = candidates.some((v) => v.expiresAtHeight !== void 0) ? await
|
|
12997
|
+
const now = candidates.some((v) => v.expiresAtHeight !== void 0) ? await chunkDAYCCIRO_cjs.resolveTimeHeight(wallet.onchainProvider) : { timestamp: /* @__PURE__ */ new Date() };
|
|
12938
12998
|
const suspects = candidates.filter(
|
|
12939
|
-
(v) =>
|
|
12999
|
+
(v) => chunkDAYCCIRO_cjs.isPastExpiry(v, now) || v.expiresAtHeight !== void 0 && now.height === void 0
|
|
12940
13000
|
);
|
|
12941
13001
|
if (suspects.length === 0) return inputs;
|
|
12942
13002
|
let sweptNow;
|
|
@@ -12950,13 +13010,13 @@ async function refreshSweptStateOfExpiredInputs(wallet, inputs) {
|
|
|
12950
13010
|
);
|
|
12951
13011
|
} catch (e) {
|
|
12952
13012
|
const message = "could not confirm the swept state of expired settlement inputs; retry the settlement";
|
|
12953
|
-
throw
|
|
13013
|
+
throw chunkDAYCCIRO_cjs.isRetryableProviderError(e) ? new chunkDAYCCIRO_cjs.ProviderUnavailableError(message, { cause: e }) : new Error(message, { cause: e });
|
|
12954
13014
|
}
|
|
12955
13015
|
if (sweptNow.size === 0) return inputs;
|
|
12956
13016
|
return inputs.map((input) => {
|
|
12957
|
-
if (!
|
|
12958
|
-
const swept = { ...
|
|
12959
|
-
return { ...swept, virtualStatus:
|
|
13017
|
+
if (!chunkDAYCCIRO_cjs.isVirtualCoin(input) || !sweptNow.has(`${input.txid}:${input.vout}`)) return input;
|
|
13018
|
+
const swept = { ...chunkDAYCCIRO_cjs.normalizeVtxo(input), isSwept: true };
|
|
13019
|
+
return { ...swept, virtualStatus: chunkDAYCCIRO_cjs.toVirtualStatus(swept) };
|
|
12960
13020
|
});
|
|
12961
13021
|
}
|
|
12962
13022
|
var PENDING_RECOVERY_REASON = "is past its operator signer's rotation cutoff \u2014 the operator will not co-sign it until it recovers";
|
|
@@ -13293,7 +13353,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13293
13353
|
*/
|
|
13294
13354
|
static async setupWalletConfig(config, pubKey) {
|
|
13295
13355
|
const arkadeServerUrl = getArkadeServerUrl(config);
|
|
13296
|
-
const arkProvider = config.arkProvider || new
|
|
13356
|
+
const arkProvider = config.arkProvider || new chunkDAYCCIRO_cjs.RestArkProvider(arkadeServerUrl);
|
|
13297
13357
|
let indexerProvider = config.indexerProvider;
|
|
13298
13358
|
if (!indexerProvider) {
|
|
13299
13359
|
let indexerUrl = config.indexerUrl;
|
|
@@ -13310,7 +13370,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13310
13370
|
indexerUrl = arkadeServerUrl;
|
|
13311
13371
|
}
|
|
13312
13372
|
}
|
|
13313
|
-
indexerProvider = new
|
|
13373
|
+
indexerProvider = new chunkSJPPBR2V_cjs.RestIndexerProvider(indexerUrl);
|
|
13314
13374
|
}
|
|
13315
13375
|
const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
13316
13376
|
const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
@@ -13319,7 +13379,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13319
13379
|
source: serverInfoSource,
|
|
13320
13380
|
lastOnlineAt: serverInfoLastOnlineAt
|
|
13321
13381
|
} = await resolveArkInfo(arkProvider, walletRepository);
|
|
13322
|
-
const network =
|
|
13382
|
+
const network = chunkDAYCCIRO_cjs.getNetwork(info.network);
|
|
13323
13383
|
if ("descriptor" in config.identity) {
|
|
13324
13384
|
const descriptor = config.identity.descriptor;
|
|
13325
13385
|
const identityIsMainnet = !descriptor.includes("tpub");
|
|
@@ -13359,18 +13419,18 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13359
13419
|
value: info.boardingExitDelay,
|
|
13360
13420
|
type: info.boardingExitDelay < 512n ? "blocks" : "seconds"
|
|
13361
13421
|
};
|
|
13362
|
-
const serverPubKey =
|
|
13363
|
-
const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) =>
|
|
13422
|
+
const serverPubKey = chunkFUW3OM5X_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
|
|
13423
|
+
const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) => chunkFUW3OM5X_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : config.delegatorProvider ? await config.delegatorProvider.getDelegateInfo().then((info2) => chunkFUW3OM5X_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : void 0;
|
|
13364
13424
|
const offchainOptions = {
|
|
13365
13425
|
pubKey,
|
|
13366
13426
|
serverPubKey,
|
|
13367
13427
|
csvTimelock: exitTimelock
|
|
13368
13428
|
};
|
|
13369
|
-
const offchainTapscript = !delegatePubKey ? new
|
|
13370
|
-
const boardingTapscript =
|
|
13429
|
+
const offchainTapscript = !delegatePubKey ? new chunkFUW3OM5X_cjs.DefaultVtxo.Script(offchainOptions) : new chunkFUW3OM5X_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
|
|
13430
|
+
const boardingTapscript = chunkFUW3OM5X_cjs.BoardingContractHandler.createScript({
|
|
13371
13431
|
pubKey: base.hex.encode(pubKey),
|
|
13372
13432
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
13373
|
-
csvTimelock:
|
|
13433
|
+
csvTimelock: chunkDAYCCIRO_cjs.timelockToSequence(boardingTimelock).toString()
|
|
13374
13434
|
});
|
|
13375
13435
|
return {
|
|
13376
13436
|
arkProvider,
|
|
@@ -13540,7 +13600,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13540
13600
|
if (!filter?.withUnrolled) {
|
|
13541
13601
|
logExcludedVtxos(
|
|
13542
13602
|
"getSpendableVtxos",
|
|
13543
|
-
snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !
|
|
13603
|
+
snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !chunkDAYCCIRO_cjs.isVtxoSpent(vtxo)),
|
|
13544
13604
|
[() => UNROLLED_REASON]
|
|
13545
13605
|
);
|
|
13546
13606
|
}
|
|
@@ -13701,7 +13761,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13701
13761
|
this.getBoardingTxs()
|
|
13702
13762
|
]);
|
|
13703
13763
|
const allVtxos = snapshot.flatMap((_) => _.vtxos);
|
|
13704
|
-
const resolveTxCreatedAt = (txids) =>
|
|
13764
|
+
const resolveTxCreatedAt = (txids) => chunkDAYCCIRO_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
|
|
13705
13765
|
return buildTransactionHistory(
|
|
13706
13766
|
allVtxos,
|
|
13707
13767
|
boardingTxs,
|
|
@@ -13796,7 +13856,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13796
13856
|
},
|
|
13797
13857
|
isUnrolled: true,
|
|
13798
13858
|
...boardingFacts,
|
|
13799
|
-
virtualStatus:
|
|
13859
|
+
virtualStatus: chunkDAYCCIRO_cjs.toVirtualStatus(boardingFacts),
|
|
13800
13860
|
spentBy: "",
|
|
13801
13861
|
createdAt: tx.status.confirmed ? new Date(tx.status.block_time * 1e3) : /* @__PURE__ */ new Date(0),
|
|
13802
13862
|
script: scriptHex
|
|
@@ -13852,9 +13912,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13852
13912
|
async getBoardingTapscripts(allowedSigners) {
|
|
13853
13913
|
const byScript = /* @__PURE__ */ new Map();
|
|
13854
13914
|
const add = (s) => byScript.set(base.hex.encode(s.pkScript), s);
|
|
13855
|
-
const boardingCsv = this.boardingTapscript.options.csvTimelock ??
|
|
13915
|
+
const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkFUW3OM5X_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
13856
13916
|
add(
|
|
13857
|
-
new
|
|
13917
|
+
new chunkFUW3OM5X_cjs.DefaultVtxo.Script({
|
|
13858
13918
|
pubKey: await this.identity.xOnlyPublicKey(),
|
|
13859
13919
|
serverPubKey: this.boardingTapscript.options.serverPubKey,
|
|
13860
13920
|
csvTimelock: boardingCsv
|
|
@@ -13869,7 +13929,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13869
13929
|
for (const c of boardingContracts) {
|
|
13870
13930
|
if (!allowed.has(toXOnlySignerHex(c.params.serverPubKey))) continue;
|
|
13871
13931
|
try {
|
|
13872
|
-
add(
|
|
13932
|
+
add(chunkFUW3OM5X_cjs.BoardingContractHandler.createScript(c.params));
|
|
13873
13933
|
} catch (e) {
|
|
13874
13934
|
console.warn("Skipping malformed boarding contract", c.script, e);
|
|
13875
13935
|
}
|
|
@@ -13906,7 +13966,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13906
13966
|
// Per-row CSV delay decoded from THIS tapscript's exit leaf —
|
|
13907
13967
|
// not the wallet's current boarding timelock, which a signer
|
|
13908
13968
|
// rotation may have changed.
|
|
13909
|
-
csvTimelock:
|
|
13969
|
+
csvTimelock: chunkDAYCCIRO_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
|
|
13910
13970
|
coins: utxos
|
|
13911
13971
|
};
|
|
13912
13972
|
})
|
|
@@ -14043,7 +14103,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14043
14103
|
/** Fetch Arkade transaction ids that are still pending final settlement. */
|
|
14044
14104
|
async fetchPendingTxs() {
|
|
14045
14105
|
const scripts = await this.getWalletScripts();
|
|
14046
|
-
const vtxos = await
|
|
14106
|
+
const vtxos = await chunkDAYCCIRO_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
|
|
14047
14107
|
return vtxos.filter(
|
|
14048
14108
|
(vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
|
|
14049
14109
|
).map((_) => _.arkTxId);
|
|
@@ -14074,7 +14134,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14074
14134
|
});
|
|
14075
14135
|
for (const contract of contracts) {
|
|
14076
14136
|
if (map.has(contract.script)) continue;
|
|
14077
|
-
const handler =
|
|
14137
|
+
const handler = chunkFUW3OM5X_cjs.contractHandlers.get(contract.type);
|
|
14078
14138
|
if (handler) {
|
|
14079
14139
|
const script = handler.createScript(contract.params);
|
|
14080
14140
|
map.set(contract.script, script);
|
|
@@ -14186,7 +14246,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14186
14246
|
}
|
|
14187
14247
|
});
|
|
14188
14248
|
const baselinePubkey = await this.identity.xOnlyPublicKey();
|
|
14189
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
14249
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkFUW3OM5X_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
14190
14250
|
const baselineSigners = [
|
|
14191
14251
|
this.offchainTapscript.options.serverPubKey,
|
|
14192
14252
|
...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
|
|
@@ -14194,8 +14254,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14194
14254
|
const seenBaselineScripts = /* @__PURE__ */ new Set();
|
|
14195
14255
|
for (const serverPubKey of baselineSigners) {
|
|
14196
14256
|
for (const csvTimelock2 of this.walletContractTimelocks) {
|
|
14197
|
-
const csvTimelockStr =
|
|
14198
|
-
const defaultScript = new
|
|
14257
|
+
const csvTimelockStr = chunkDAYCCIRO_cjs.timelockToSequence(csvTimelock2).toString();
|
|
14258
|
+
const defaultScript = new chunkFUW3OM5X_cjs.DefaultVtxo.Script({
|
|
14199
14259
|
pubKey: baselinePubkey,
|
|
14200
14260
|
serverPubKey,
|
|
14201
14261
|
csvTimelock: csvTimelock2
|
|
@@ -14216,7 +14276,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14216
14276
|
});
|
|
14217
14277
|
}
|
|
14218
14278
|
if (delegatePubKey) {
|
|
14219
|
-
const delegateScript = new
|
|
14279
|
+
const delegateScript = new chunkFUW3OM5X_cjs.DelegateVtxo.Script({
|
|
14220
14280
|
pubKey: baselinePubkey,
|
|
14221
14281
|
serverPubKey,
|
|
14222
14282
|
delegatePubKey,
|
|
@@ -14240,9 +14300,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14240
14300
|
}
|
|
14241
14301
|
}
|
|
14242
14302
|
}
|
|
14243
|
-
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ??
|
|
14303
|
+
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkFUW3OM5X_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
14244
14304
|
for (const serverPubKey of baselineSigners) {
|
|
14245
|
-
const baselineBoarding = new
|
|
14305
|
+
const baselineBoarding = new chunkFUW3OM5X_cjs.DefaultVtxo.Script({
|
|
14246
14306
|
pubKey: baselinePubkey,
|
|
14247
14307
|
serverPubKey,
|
|
14248
14308
|
csvTimelock: boardingCsvTimelock
|
|
@@ -14255,7 +14315,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14255
14315
|
params: {
|
|
14256
14316
|
pubKey: base.hex.encode(baselineBoarding.options.pubKey),
|
|
14257
14317
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
14258
|
-
csvTimelock:
|
|
14318
|
+
csvTimelock: chunkDAYCCIRO_cjs.timelockToSequence(boardingCsvTimelock).toString()
|
|
14259
14319
|
},
|
|
14260
14320
|
script: boardingScriptHex,
|
|
14261
14321
|
address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
|
|
@@ -14455,7 +14515,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14455
14515
|
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
14456
14516
|
deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
|
|
14457
14517
|
csvTimelocks: this.walletContractTimelocks,
|
|
14458
|
-
delegatePubKey: this.offchainTapscript instanceof
|
|
14518
|
+
delegatePubKey: this.offchainTapscript instanceof chunkFUW3OM5X_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
|
|
14459
14519
|
};
|
|
14460
14520
|
}
|
|
14461
14521
|
_signerRouter;
|
|
@@ -14700,7 +14760,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14700
14760
|
const [row] = await manager.getContracts({ script: base.hex.encode(display.pkScript) });
|
|
14701
14761
|
const persisted = row?.metadata?.signingDescriptor;
|
|
14702
14762
|
if (typeof persisted === "string") return persisted;
|
|
14703
|
-
return
|
|
14763
|
+
return chunkFUW3OM5X_cjs.identityDescriptor(this.identity);
|
|
14704
14764
|
}
|
|
14705
14765
|
/**
|
|
14706
14766
|
* Build, persist and shape one address of `type` owned by `descriptor` —
|
|
@@ -14716,7 +14776,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14716
14776
|
async mintAddress(manager, type, descriptor, tagSource, allocated) {
|
|
14717
14777
|
if (type === "boarding") {
|
|
14718
14778
|
const built2 = this.buildBoardingContract(
|
|
14719
|
-
|
|
14779
|
+
chunkFUW3OM5X_cjs.deriveDescriptorLeafPubKey(descriptor),
|
|
14720
14780
|
descriptor,
|
|
14721
14781
|
tagSource
|
|
14722
14782
|
);
|
|
@@ -14761,11 +14821,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14761
14821
|
* {@link buildReceiveContract}.
|
|
14762
14822
|
*/
|
|
14763
14823
|
buildBoardingContract(pubKey, descriptor, tagSource) {
|
|
14764
|
-
const tapscript = new
|
|
14824
|
+
const tapscript = new chunkFUW3OM5X_cjs.DefaultVtxo.Script({
|
|
14765
14825
|
...this._boardingTapscript.options,
|
|
14766
14826
|
pubKey
|
|
14767
14827
|
});
|
|
14768
|
-
const csvTimelock2 = tapscript.options.csvTimelock ??
|
|
14828
|
+
const csvTimelock2 = tapscript.options.csvTimelock ?? chunkFUW3OM5X_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
14769
14829
|
return {
|
|
14770
14830
|
tapscript,
|
|
14771
14831
|
params: {
|
|
@@ -14773,13 +14833,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14773
14833
|
params: {
|
|
14774
14834
|
pubKey: base.hex.encode(pubKey),
|
|
14775
14835
|
serverPubKey: base.hex.encode(tapscript.options.serverPubKey),
|
|
14776
|
-
csvTimelock:
|
|
14836
|
+
csvTimelock: chunkDAYCCIRO_cjs.timelockToSequence(csvTimelock2).toString()
|
|
14777
14837
|
},
|
|
14778
14838
|
script: base.hex.encode(tapscript.pkScript),
|
|
14779
14839
|
address: tapscript.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
14780
14840
|
state: "active",
|
|
14781
14841
|
metadata: {
|
|
14782
|
-
...tagSource && { source:
|
|
14842
|
+
...tagSource && { source: chunkFUW3OM5X_cjs.WALLET_RECEIVE_SOURCE },
|
|
14783
14843
|
signingDescriptor: descriptor
|
|
14784
14844
|
}
|
|
14785
14845
|
}
|
|
@@ -14808,7 +14868,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14808
14868
|
if (this._descriptorProvider instanceof HDDescriptorProvider) {
|
|
14809
14869
|
return (await this.getContractManager()).getNextSigningDescriptor();
|
|
14810
14870
|
}
|
|
14811
|
-
return
|
|
14871
|
+
return chunkFUW3OM5X_cjs.identityDescriptor(this.identity);
|
|
14812
14872
|
}
|
|
14813
14873
|
/**
|
|
14814
14874
|
* @see HDAllocationCapable.advanceSigningDescriptorWatermark
|
|
@@ -14904,7 +14964,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14904
14964
|
* the stable public API.
|
|
14905
14965
|
*/
|
|
14906
14966
|
async rotateServerSigner(newServerPubKey, checkpointTapscript) {
|
|
14907
|
-
const xonly =
|
|
14967
|
+
const xonly = chunkFUW3OM5X_cjs.toXOnly(newServerPubKey, "ark signer key");
|
|
14908
14968
|
const newServerUnrollScript = assertValidServerUnrollScript(
|
|
14909
14969
|
checkpointTapscript,
|
|
14910
14970
|
resolveCheckpointExitDelayPolicy(this.network, this.checkpointExitDelayPolicy)
|
|
@@ -14933,21 +14993,21 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14933
14993
|
const [currentBoardingRow] = await manager.getContracts({
|
|
14934
14994
|
script: currentBoardingScript
|
|
14935
14995
|
});
|
|
14936
|
-
const newOffchain = this.offchainTapscript instanceof
|
|
14996
|
+
const newOffchain = this.offchainTapscript instanceof chunkFUW3OM5X_cjs.DelegateVtxo.Script ? new chunkFUW3OM5X_cjs.DelegateVtxo.Script({
|
|
14937
14997
|
...this.offchainTapscript.options,
|
|
14938
14998
|
serverPubKey: xonly
|
|
14939
|
-
}) : new
|
|
14999
|
+
}) : new chunkFUW3OM5X_cjs.DefaultVtxo.Script({
|
|
14940
15000
|
...this.offchainTapscript.options,
|
|
14941
15001
|
serverPubKey: xonly
|
|
14942
15002
|
});
|
|
14943
|
-
const newBoarding = new
|
|
15003
|
+
const newBoarding = new chunkFUW3OM5X_cjs.DefaultVtxo.Script({
|
|
14944
15004
|
...this._boardingTapscript.options,
|
|
14945
15005
|
serverPubKey: xonly
|
|
14946
15006
|
});
|
|
14947
|
-
const offchainCsv =
|
|
15007
|
+
const offchainCsv = chunkDAYCCIRO_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
|
|
14948
15008
|
const newOffchainScript = base.hex.encode(newOffchain.pkScript);
|
|
14949
15009
|
const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
|
|
14950
|
-
if (newOffchain instanceof
|
|
15010
|
+
if (newOffchain instanceof chunkFUW3OM5X_cjs.DelegateVtxo.Script) {
|
|
14951
15011
|
await manager.createContract({
|
|
14952
15012
|
type: "delegate",
|
|
14953
15013
|
params: {
|
|
@@ -14975,13 +15035,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14975
15035
|
metadata: currentOffchainRow?.metadata
|
|
14976
15036
|
});
|
|
14977
15037
|
}
|
|
14978
|
-
const boardingCsv = newBoarding.options.csvTimelock ??
|
|
15038
|
+
const boardingCsv = newBoarding.options.csvTimelock ?? chunkFUW3OM5X_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
14979
15039
|
await manager.createContract({
|
|
14980
15040
|
type: "boarding",
|
|
14981
15041
|
params: {
|
|
14982
15042
|
pubKey: base.hex.encode(newBoarding.options.pubKey),
|
|
14983
15043
|
serverPubKey: base.hex.encode(xonly),
|
|
14984
|
-
csvTimelock:
|
|
15044
|
+
csvTimelock: chunkDAYCCIRO_cjs.timelockToSequence(boardingCsv).toString()
|
|
14985
15045
|
},
|
|
14986
15046
|
script: base.hex.encode(newBoarding.pkScript),
|
|
14987
15047
|
address: newBoarding.address(this.network.hrp, xonly).encode(),
|
|
@@ -15014,14 +15074,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15014
15074
|
_restoreInFlight;
|
|
15015
15075
|
_addPendingSpends(inputs) {
|
|
15016
15076
|
for (const input of inputs) {
|
|
15017
|
-
if (
|
|
15077
|
+
if (chunkDAYCCIRO_cjs.isVirtualCoin(input)) {
|
|
15018
15078
|
this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
|
|
15019
15079
|
}
|
|
15020
15080
|
}
|
|
15021
15081
|
}
|
|
15022
15082
|
_removePendingSpends(inputs) {
|
|
15023
15083
|
for (const input of inputs) {
|
|
15024
|
-
if (
|
|
15084
|
+
if (chunkDAYCCIRO_cjs.isVirtualCoin(input)) {
|
|
15025
15085
|
this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
|
|
15026
15086
|
}
|
|
15027
15087
|
}
|
|
@@ -15082,13 +15142,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15082
15142
|
const manager = await this.getContractManager();
|
|
15083
15143
|
const provider = this._descriptorProvider;
|
|
15084
15144
|
const hd = provider instanceof HDDescriptorProvider;
|
|
15085
|
-
const staticDescriptor = hd ? void 0 : await
|
|
15145
|
+
const staticDescriptor = hd ? void 0 : await chunkFUW3OM5X_cjs.identityDescriptor(this.identity);
|
|
15086
15146
|
const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
|
|
15087
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
15147
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkFUW3OM5X_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
15088
15148
|
const arkInfo = await this.arkProvider.getInfo();
|
|
15089
|
-
const currentSignerPubKey =
|
|
15149
|
+
const currentSignerPubKey = chunkFUW3OM5X_cjs.toXOnly(base.hex.decode(arkInfo.signerPubkey), "ark signer key");
|
|
15090
15150
|
const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
|
|
15091
|
-
(s) =>
|
|
15151
|
+
(s) => chunkFUW3OM5X_cjs.toXOnly(base.hex.decode(s.pubkey), "deprecated signer key")
|
|
15092
15152
|
);
|
|
15093
15153
|
const deps = {
|
|
15094
15154
|
indexerProvider: this.indexerProvider,
|
|
@@ -15103,7 +15163,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15103
15163
|
csvTimelocks: this.walletContractTimelocks,
|
|
15104
15164
|
// Boarding-exit CSV so the boarding handler can build its
|
|
15105
15165
|
// candidate script (distinct from the unilateral-exit matrix).
|
|
15106
|
-
boardingTimelock: this.boardingTapscript.options.csvTimelock ??
|
|
15166
|
+
boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkFUW3OM5X_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
|
|
15107
15167
|
delegatePubKey
|
|
15108
15168
|
};
|
|
15109
15169
|
const result = await manager.scanContracts({
|
|
@@ -15217,7 +15277,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15217
15277
|
throw new Error("Invalid configured public key");
|
|
15218
15278
|
}
|
|
15219
15279
|
const setup = await ReadonlyWallet.setupWalletConfig(config, pubkey);
|
|
15220
|
-
const forfeitPubkey =
|
|
15280
|
+
const forfeitPubkey = chunkFUW3OM5X_cjs.toXOnly(base.hex.decode(setup.info.forfeitPubkey), "forfeit key");
|
|
15221
15281
|
const forfeitAddress = btcSigner.Address(setup.network).decode(setup.info.forfeitAddress);
|
|
15222
15282
|
const forfeitOutputScript = btcSigner.OutScript.encode(forfeitAddress);
|
|
15223
15283
|
const checkpointExitDelayOverrides = {
|
|
@@ -15366,7 +15426,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15366
15426
|
inputs: params.selectedVtxos,
|
|
15367
15427
|
changeAmount: BigInt(changeAmount)
|
|
15368
15428
|
};
|
|
15369
|
-
const outputAddress =
|
|
15429
|
+
const outputAddress = chunkDAYCCIRO_cjs.ArkAddress.decode(params.address);
|
|
15370
15430
|
assertRecipientArkAddress(
|
|
15371
15431
|
params.address,
|
|
15372
15432
|
outputAddress,
|
|
@@ -15432,13 +15492,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15432
15492
|
void this.logUngatedInputs("settle({ inputs })", params.inputs);
|
|
15433
15493
|
}
|
|
15434
15494
|
const offchainAddress = await this.getAddress();
|
|
15435
|
-
const offchainPkScript =
|
|
15495
|
+
const offchainPkScript = chunkDAYCCIRO_cjs.ArkAddress.decode(offchainAddress).pkScript;
|
|
15436
15496
|
const offchainOutputScript = base.hex.encode(offchainPkScript);
|
|
15437
15497
|
if (!params) {
|
|
15438
15498
|
const { fees, vtxoMaxAmount } = await this.arkProvider.getInfo();
|
|
15439
15499
|
const estimator = new Estimator(fees.intentFee);
|
|
15440
15500
|
let amount = 0;
|
|
15441
|
-
const exitScript =
|
|
15501
|
+
const exitScript = chunkDAYCCIRO_cjs.CSVMultisigTapscript.decode(
|
|
15442
15502
|
base.hex.decode(this.boardingTapscript.exitScript)
|
|
15443
15503
|
);
|
|
15444
15504
|
const boardingTimelock = exitScript.params.timelock;
|
|
@@ -15470,7 +15530,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15470
15530
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
15471
15531
|
break;
|
|
15472
15532
|
}
|
|
15473
|
-
const inputFee = estimator.evalOffchainInput(
|
|
15533
|
+
const inputFee = estimator.evalOffchainInput(chunkDAYCCIRO_cjs.toOffchainInputFeeParams(vtxo));
|
|
15474
15534
|
if (inputFee.satoshis >= vtxo.value) {
|
|
15475
15535
|
continue;
|
|
15476
15536
|
}
|
|
@@ -15521,7 +15581,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15521
15581
|
let script;
|
|
15522
15582
|
let arkAddress;
|
|
15523
15583
|
try {
|
|
15524
|
-
arkAddress =
|
|
15584
|
+
arkAddress = chunkDAYCCIRO_cjs.ArkAddress.decode(output.address);
|
|
15525
15585
|
} catch {
|
|
15526
15586
|
arkAddress = void 0;
|
|
15527
15587
|
}
|
|
@@ -15593,7 +15653,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15593
15653
|
]);
|
|
15594
15654
|
let intentTxId;
|
|
15595
15655
|
try {
|
|
15596
|
-
intentTxId =
|
|
15656
|
+
intentTxId = chunkDAYCCIRO_cjs.Transaction.fromPSBT(base.base64.decode(intent.proof)).id;
|
|
15597
15657
|
} catch {
|
|
15598
15658
|
intentTxId = params.inputs.map((i) => `${i.txid}:${i.vout}`).sort().join("|");
|
|
15599
15659
|
}
|
|
@@ -15611,7 +15671,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15611
15671
|
const abortController = new AbortController();
|
|
15612
15672
|
let stream;
|
|
15613
15673
|
let committedTxid;
|
|
15614
|
-
const settleInputVtxos = params.inputs.filter(
|
|
15674
|
+
const settleInputVtxos = params.inputs.filter(chunkDAYCCIRO_cjs.isVirtualCoin);
|
|
15615
15675
|
const contractManager = await this.getContractManager();
|
|
15616
15676
|
await contractManager.assertAnnotatable(settleInputVtxos);
|
|
15617
15677
|
await contractManager.assertSpendableNow?.(
|
|
@@ -15723,7 +15783,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15723
15783
|
async maybeRotateBoardingAfterBoard(inputs) {
|
|
15724
15784
|
if (!this._descriptorProvider) return;
|
|
15725
15785
|
const consumedBoarding = inputs.some(
|
|
15726
|
-
(input) => typeof input !== "string" && !
|
|
15786
|
+
(input) => typeof input !== "string" && !chunkDAYCCIRO_cjs.isVirtualCoin(input)
|
|
15727
15787
|
);
|
|
15728
15788
|
if (!consumedBoarding) return;
|
|
15729
15789
|
try {
|
|
@@ -15734,7 +15794,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15734
15794
|
}
|
|
15735
15795
|
async handleSettlementFinalizationEvent(event, inputs, forfeitOutputScript, expectedRecipients, connectorsGraph, validatedCommitmentTxid) {
|
|
15736
15796
|
const signedForfeits = [];
|
|
15737
|
-
let settlementPsbt =
|
|
15797
|
+
let settlementPsbt = chunkDAYCCIRO_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
15738
15798
|
assertFinalCommitmentMatchesValidated(
|
|
15739
15799
|
settlementPsbt,
|
|
15740
15800
|
validatedCommitmentTxid,
|
|
@@ -15747,7 +15807,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15747
15807
|
let connectorIndex = 0;
|
|
15748
15808
|
const connectorsLeaves = connectorsGraph?.leaves() || [];
|
|
15749
15809
|
for (const input of inputs) {
|
|
15750
|
-
if (!
|
|
15810
|
+
if (!chunkDAYCCIRO_cjs.isVirtualCoin(input)) {
|
|
15751
15811
|
let matched = false;
|
|
15752
15812
|
for (let i = 0; i < settlementPsbt.inputsLength; i++) {
|
|
15753
15813
|
const settlementInput = settlementPsbt.getInput(i);
|
|
@@ -15785,7 +15845,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15785
15845
|
}
|
|
15786
15846
|
continue;
|
|
15787
15847
|
}
|
|
15788
|
-
if (!
|
|
15848
|
+
if (!chunkDAYCCIRO_cjs.requiresForfeit(input) || isSubdust({ value: input.value }, this.dustAmount)) {
|
|
15789
15849
|
continue;
|
|
15790
15850
|
}
|
|
15791
15851
|
if (connectorsLeaves.length === 0) {
|
|
@@ -15813,7 +15873,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15813
15873
|
index: input.vout,
|
|
15814
15874
|
witnessUtxo: {
|
|
15815
15875
|
amount: BigInt(input.value),
|
|
15816
|
-
script:
|
|
15876
|
+
script: chunkDAYCCIRO_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
15817
15877
|
},
|
|
15818
15878
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
15819
15879
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -15832,7 +15892,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15832
15892
|
forfeitTx = await this._signerRouter.sign(forfeitTx, [
|
|
15833
15893
|
{
|
|
15834
15894
|
index: 0,
|
|
15835
|
-
lookupScript:
|
|
15895
|
+
lookupScript: chunkDAYCCIRO_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
15836
15896
|
}
|
|
15837
15897
|
]);
|
|
15838
15898
|
signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
|
|
@@ -15890,7 +15950,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15890
15950
|
resolveBatchExpiryPolicy(this.network, this.batchExpiryPolicy)
|
|
15891
15951
|
);
|
|
15892
15952
|
await this.arkProvider.confirmRegistration(intentId);
|
|
15893
|
-
const sweepTapscript =
|
|
15953
|
+
const sweepTapscript = chunkDAYCCIRO_cjs.CSVMultisigTapscript.encode({
|
|
15894
15954
|
timelock,
|
|
15895
15955
|
pubkeys: [this.forfeitPubkey]
|
|
15896
15956
|
}).script;
|
|
@@ -15905,14 +15965,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15905
15965
|
throw new Error("Sweep tap tree root not set");
|
|
15906
15966
|
}
|
|
15907
15967
|
const xOnlyPublicKeys = event.cosignersPublicKeys.map(
|
|
15908
|
-
(k) => base.hex.encode(
|
|
15968
|
+
(k) => base.hex.encode(chunkFUW3OM5X_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
|
|
15909
15969
|
);
|
|
15910
15970
|
const signerPublicKey = await session.getPublicKey();
|
|
15911
|
-
const xonlySignerPublicKey =
|
|
15971
|
+
const xonlySignerPublicKey = chunkFUW3OM5X_cjs.toXOnly(signerPublicKey, "signer key");
|
|
15912
15972
|
if (!xOnlyPublicKeys.includes(base.hex.encode(xonlySignerPublicKey))) {
|
|
15913
15973
|
return { skip: true };
|
|
15914
15974
|
}
|
|
15915
|
-
const commitmentTx =
|
|
15975
|
+
const commitmentTx = chunkDAYCCIRO_cjs.Transaction.fromPSBT(
|
|
15916
15976
|
base.base64.decode(event.unsignedCommitmentTx)
|
|
15917
15977
|
);
|
|
15918
15978
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
@@ -15998,9 +16058,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15998
16058
|
...existing ?? {},
|
|
15999
16059
|
intentTxId,
|
|
16000
16060
|
registerProof: intent.proof,
|
|
16001
|
-
registerProofMessage:
|
|
16061
|
+
registerProofMessage: chunkDAYCCIRO_cjs.Intent.encodeMessage(intent.message),
|
|
16002
16062
|
deleteProof: deleteIntent.proof,
|
|
16003
|
-
deleteProofMessage:
|
|
16063
|
+
deleteProofMessage: chunkDAYCCIRO_cjs.Intent.encodeMessage(deleteIntent.message),
|
|
16004
16064
|
intentVtxos: inputs.map((i) => ({
|
|
16005
16065
|
txid: i.txid,
|
|
16006
16066
|
vout: i.vout
|
|
@@ -16033,7 +16093,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16033
16093
|
try {
|
|
16034
16094
|
return await this.arkProvider.registerIntent(intent);
|
|
16035
16095
|
} catch (error) {
|
|
16036
|
-
if (error instanceof
|
|
16096
|
+
if (error instanceof chunkDAYCCIRO_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
|
|
16037
16097
|
const deleteIntent = await this.makeDeleteIntentSignature(inputs);
|
|
16038
16098
|
await this.arkProvider.deleteIntent(deleteIntent);
|
|
16039
16099
|
return this.arkProvider.registerIntent(intent);
|
|
@@ -16049,7 +16109,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16049
16109
|
expire_at: 0,
|
|
16050
16110
|
cosigners_public_keys: cosignerPubKeys
|
|
16051
16111
|
};
|
|
16052
|
-
const proof =
|
|
16112
|
+
const proof = chunkDAYCCIRO_cjs.Intent.create(message, coins, outputs);
|
|
16053
16113
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
16054
16114
|
return {
|
|
16055
16115
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -16061,7 +16121,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16061
16121
|
type: "delete",
|
|
16062
16122
|
expire_at: 0
|
|
16063
16123
|
};
|
|
16064
|
-
const proof =
|
|
16124
|
+
const proof = chunkDAYCCIRO_cjs.Intent.create(message, coins, []);
|
|
16065
16125
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
16066
16126
|
return {
|
|
16067
16127
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -16073,7 +16133,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16073
16133
|
type: "get-pending-tx",
|
|
16074
16134
|
expire_at: 0
|
|
16075
16135
|
};
|
|
16076
|
-
const proof =
|
|
16136
|
+
const proof = chunkDAYCCIRO_cjs.Intent.create(message, coins, []);
|
|
16077
16137
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
16078
16138
|
return {
|
|
16079
16139
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -16094,7 +16154,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16094
16154
|
if (!vtxos || vtxos.length === 0) {
|
|
16095
16155
|
const scriptMap = await this.getScriptMap();
|
|
16096
16156
|
const allExtended = [];
|
|
16097
|
-
const fetchedVtxos = await
|
|
16157
|
+
const fetchedVtxos = await chunkDAYCCIRO_cjs.getAllNormalizedVtxos(this.indexerProvider, [
|
|
16098
16158
|
...scriptMap.keys()
|
|
16099
16159
|
]);
|
|
16100
16160
|
for (const vtxo of fetchedVtxos) {
|
|
@@ -16137,8 +16197,8 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16137
16197
|
batchPending.push(pendingTx.arkTxid);
|
|
16138
16198
|
try {
|
|
16139
16199
|
const checkpointTxs = pendingTx.signedCheckpointTxs.map((c) => {
|
|
16140
|
-
const tx =
|
|
16141
|
-
|
|
16200
|
+
const tx = chunkDAYCCIRO_cjs.Transaction.fromPSBT(base.base64.decode(c));
|
|
16201
|
+
chunkDAYCCIRO_cjs.assertAllowedSighashTypes(tx);
|
|
16142
16202
|
return tx;
|
|
16143
16203
|
});
|
|
16144
16204
|
assertCheckpointsMatchInputs(
|
|
@@ -16210,11 +16270,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16210
16270
|
* against the current key alone would leave it pending forever.
|
|
16211
16271
|
*/
|
|
16212
16272
|
checkpointUnrollCandidates(info) {
|
|
16213
|
-
const current =
|
|
16273
|
+
const current = chunkDAYCCIRO_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
16214
16274
|
const candidates = [this._serverUnrollScript, current];
|
|
16215
16275
|
for (const deprecated of signerSetFromInfo(info).deprecated.keys()) {
|
|
16216
16276
|
candidates.push(
|
|
16217
|
-
|
|
16277
|
+
chunkDAYCCIRO_cjs.CSVMultisigTapscript.encode({
|
|
16218
16278
|
...current.params,
|
|
16219
16279
|
pubkeys: [base.hex.decode(deprecated)]
|
|
16220
16280
|
})
|
|
@@ -16305,7 +16365,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16305
16365
|
if (vtxos.length === 0) {
|
|
16306
16366
|
throw new Error("No VTXOs found for this arkadeCash");
|
|
16307
16367
|
}
|
|
16308
|
-
const myPkScript =
|
|
16368
|
+
const myPkScript = chunkDAYCCIRO_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
|
|
16309
16369
|
let { spendable, unclaimed } = this.classifyCashVtxos(vtxos);
|
|
16310
16370
|
let swept = 0;
|
|
16311
16371
|
const drainable = vtxos.filter(
|
|
@@ -16381,7 +16441,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16381
16441
|
const spendable = [];
|
|
16382
16442
|
const unclaimed = [];
|
|
16383
16443
|
for (const vtxo of vtxos) {
|
|
16384
|
-
if (
|
|
16444
|
+
if (chunkDAYCCIRO_cjs.isVtxoSpent(vtxo)) {
|
|
16385
16445
|
unclaimed.push(cashReport(vtxo, "already-spent"));
|
|
16386
16446
|
} else if (vtxo.isUnrolled) {
|
|
16387
16447
|
unclaimed.push(cashReport(vtxo, "exited"));
|
|
@@ -16403,7 +16463,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16403
16463
|
const all = [];
|
|
16404
16464
|
const seen = /* @__PURE__ */ new Set();
|
|
16405
16465
|
for (let pageIndex = 0; ; pageIndex++) {
|
|
16406
|
-
const { vtxos, page } = await
|
|
16466
|
+
const { vtxos, page } = await chunkDAYCCIRO_cjs.getNormalizedVtxos(this.indexerProvider, {
|
|
16407
16467
|
scripts,
|
|
16408
16468
|
pageIndex,
|
|
16409
16469
|
pageSize
|
|
@@ -16450,7 +16510,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16450
16510
|
for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
|
|
16451
16511
|
const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
|
|
16452
16512
|
const message = { type: "get-pending-tx", expire_at: 0 };
|
|
16453
|
-
const proof =
|
|
16513
|
+
const proof = chunkDAYCCIRO_cjs.Intent.create(message, batch, []);
|
|
16454
16514
|
const signedProof = await identity.sign(
|
|
16455
16515
|
proof,
|
|
16456
16516
|
Array.from({ length: batch.length + 1 }, (_, j) => j)
|
|
@@ -16471,8 +16531,8 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16471
16531
|
for (const pendingTx of pendingTxs) {
|
|
16472
16532
|
try {
|
|
16473
16533
|
const checkpointTxs = pendingTx.signedCheckpointTxs.map((checkpoint) => {
|
|
16474
|
-
const tx =
|
|
16475
|
-
|
|
16534
|
+
const tx = chunkDAYCCIRO_cjs.Transaction.fromPSBT(base.base64.decode(checkpoint));
|
|
16535
|
+
chunkDAYCCIRO_cjs.assertAllowedSighashTypes(tx);
|
|
16476
16536
|
return tx;
|
|
16477
16537
|
});
|
|
16478
16538
|
assertCheckpointsMatchInputs(
|
|
@@ -16512,7 +16572,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16512
16572
|
}
|
|
16513
16573
|
/** Sum the outputs of an ark tx PSBT that pay the given scriptPubKey. */
|
|
16514
16574
|
arkTxAmountPaidTo(arkTxPsbt, pkScriptHex) {
|
|
16515
|
-
const arkTx =
|
|
16575
|
+
const arkTx = chunkDAYCCIRO_cjs.Transaction.fromPSBT(base.base64.decode(arkTxPsbt));
|
|
16516
16576
|
let total = 0;
|
|
16517
16577
|
for (let i = 0; i < arkTx.outputsLength; i++) {
|
|
16518
16578
|
const output = arkTx.getOutput(i);
|
|
@@ -16683,7 +16743,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16683
16743
|
script: recipient.script,
|
|
16684
16744
|
amount: BigInt(recipient.amount),
|
|
16685
16745
|
// Already checked against the recipient address in `validateRecipients`.
|
|
16686
|
-
...recipient.tapTree ? { tapTree:
|
|
16746
|
+
...recipient.tapTree ? { tapTree: chunkDAYCCIRO_cjs.toBIP371TapTree(recipient.tapTree) } : {}
|
|
16687
16747
|
}));
|
|
16688
16748
|
const totalBtcOutput = outputs.reduce((sum, o) => sum + Number(o.amount), 0);
|
|
16689
16749
|
let changeAmount = totalBtcSelected - totalBtcOutput;
|
|
@@ -16867,10 +16927,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16867
16927
|
const serverPubKey = this.arkServerPublicKey;
|
|
16868
16928
|
const serverUnrollScript = this.serverUnrollScript;
|
|
16869
16929
|
const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
|
|
16870
|
-
const normalizedInputs = inputs.map(
|
|
16871
|
-
const at = now ?? await
|
|
16930
|
+
const normalizedInputs = inputs.map(chunkDAYCCIRO_cjs.normalizeVtxo);
|
|
16931
|
+
const at = now ?? await chunkDAYCCIRO_cjs.resolveTimeHeight(this.onchainProvider);
|
|
16872
16932
|
for (const input of normalizedInputs) {
|
|
16873
|
-
if (!
|
|
16933
|
+
if (!chunkDAYCCIRO_cjs.canSpendOffchain(input, at)) {
|
|
16874
16934
|
throw new Error(
|
|
16875
16935
|
`sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
|
|
16876
16936
|
);
|
|
@@ -16940,7 +17000,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16940
17000
|
);
|
|
16941
17001
|
const arkTxJobs = inputs.map((input, index) => ({
|
|
16942
17002
|
index,
|
|
16943
|
-
lookupScript:
|
|
17003
|
+
lookupScript: chunkDAYCCIRO_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
16944
17004
|
}));
|
|
16945
17005
|
const identity = this.identity;
|
|
16946
17006
|
const signer = {
|
|
@@ -17024,7 +17084,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
17024
17084
|
}
|
|
17025
17085
|
const checkpointIdByOutpoint = /* @__PURE__ */ new Map();
|
|
17026
17086
|
for (const encoded of signedCheckpointTxs) {
|
|
17027
|
-
const checkpoint =
|
|
17087
|
+
const checkpoint = chunkDAYCCIRO_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
|
|
17028
17088
|
for (let i = 0; i < checkpoint.inputsLength; i++) {
|
|
17029
17089
|
const input = checkpoint.getInput(i);
|
|
17030
17090
|
if (!input.txid) continue;
|
|
@@ -17041,14 +17101,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
17041
17101
|
const spentBy = checkpointIdByOutpoint.get(`${vtxo.txid}:${vtxo.vout}`);
|
|
17042
17102
|
spentVtxos.push({
|
|
17043
17103
|
...spentFacts,
|
|
17044
|
-
virtualStatus:
|
|
17104
|
+
virtualStatus: chunkDAYCCIRO_cjs.toVirtualStatus(spentFacts),
|
|
17045
17105
|
...spentBy ? { spentBy } : {},
|
|
17046
17106
|
arkTxId: arkTxid
|
|
17047
17107
|
});
|
|
17048
17108
|
for (const id of vtxo.commitmentTxIds) {
|
|
17049
17109
|
commitmentTxIds.add(id);
|
|
17050
17110
|
}
|
|
17051
|
-
const vtxoExpiry =
|
|
17111
|
+
const vtxoExpiry = chunkDAYCCIRO_cjs.toBatchExpiry(vtxo);
|
|
17052
17112
|
if (vtxoExpiry) {
|
|
17053
17113
|
batchExpiry = Math.min(batchExpiry, vtxoExpiry);
|
|
17054
17114
|
}
|
|
@@ -17061,7 +17121,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
17061
17121
|
isSwept: false,
|
|
17062
17122
|
isPreconfirmed: true,
|
|
17063
17123
|
commitmentTxIds: Array.from(commitmentTxIds),
|
|
17064
|
-
...
|
|
17124
|
+
...chunkDAYCCIRO_cjs.parseLegacyExpiry(batchExpiry)
|
|
17065
17125
|
};
|
|
17066
17126
|
changeVtxo = {
|
|
17067
17127
|
txid: arkTxid,
|
|
@@ -17073,7 +17133,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
17073
17133
|
tapTree: offchainTapscript.encode(),
|
|
17074
17134
|
value: Number(changeAmount),
|
|
17075
17135
|
...changeFacts,
|
|
17076
|
-
virtualStatus:
|
|
17136
|
+
virtualStatus: chunkDAYCCIRO_cjs.toVirtualStatus(changeFacts),
|
|
17077
17137
|
spentBy: "",
|
|
17078
17138
|
status: {
|
|
17079
17139
|
confirmed: false
|
|
@@ -17142,12 +17202,12 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
17142
17202
|
const spentVtxos = [];
|
|
17143
17203
|
const inputArkTxIds = /* @__PURE__ */ new Set();
|
|
17144
17204
|
const boardingRemovalsByAddress = /* @__PURE__ */ new Map();
|
|
17145
|
-
const vtxoInputs = inputs.filter(
|
|
17205
|
+
const vtxoInputs = inputs.filter(chunkDAYCCIRO_cjs.isVirtualCoin);
|
|
17146
17206
|
const cm = await this.getContractManager();
|
|
17147
17207
|
const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
|
|
17148
17208
|
const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
|
|
17149
17209
|
for (const input of inputs) {
|
|
17150
|
-
if (
|
|
17210
|
+
if (chunkDAYCCIRO_cjs.isVirtualCoin(input)) {
|
|
17151
17211
|
const outpoint = `${input.txid}:${input.vout}`;
|
|
17152
17212
|
const vtxo = annotatedByKey.get(outpoint);
|
|
17153
17213
|
if (!vtxo) {
|
|
@@ -17159,13 +17219,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
17159
17219
|
const settledFacts = { ...vtxo, isSpent: true };
|
|
17160
17220
|
spentVtxos.push({
|
|
17161
17221
|
...settledFacts,
|
|
17162
|
-
virtualStatus:
|
|
17222
|
+
virtualStatus: chunkDAYCCIRO_cjs.toVirtualStatus(settledFacts),
|
|
17163
17223
|
settledBy: commitmentTxid
|
|
17164
17224
|
});
|
|
17165
17225
|
} else {
|
|
17166
17226
|
let sourceAddress;
|
|
17167
17227
|
try {
|
|
17168
|
-
sourceAddress =
|
|
17228
|
+
sourceAddress = chunkDAYCCIRO_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
|
|
17169
17229
|
this.network
|
|
17170
17230
|
);
|
|
17171
17231
|
} catch {
|
|
@@ -17223,9 +17283,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
17223
17283
|
}
|
|
17224
17284
|
};
|
|
17225
17285
|
function selectVirtualCoins(coins, targetAmount) {
|
|
17226
|
-
const sortedCoins = coins.map(
|
|
17227
|
-
const expiryA =
|
|
17228
|
-
const expiryB =
|
|
17286
|
+
const sortedCoins = coins.map(chunkDAYCCIRO_cjs.normalizeVtxo).sort((a, b) => {
|
|
17287
|
+
const expiryA = chunkDAYCCIRO_cjs.toBatchExpiry(a) || Number.MAX_SAFE_INTEGER;
|
|
17288
|
+
const expiryB = chunkDAYCCIRO_cjs.toBatchExpiry(b) || Number.MAX_SAFE_INTEGER;
|
|
17229
17289
|
if (expiryA !== expiryB) {
|
|
17230
17290
|
return expiryA - expiryB;
|
|
17231
17291
|
}
|
|
@@ -17594,7 +17654,7 @@ var MessageBus = class {
|
|
|
17594
17654
|
this.initialized = true;
|
|
17595
17655
|
}
|
|
17596
17656
|
async buildServices(config) {
|
|
17597
|
-
const arkProvider = new
|
|
17657
|
+
const arkProvider = new chunkDAYCCIRO_cjs.RestArkProvider(config.arkServer.url);
|
|
17598
17658
|
const storage = {
|
|
17599
17659
|
walletRepository: this.walletRepository,
|
|
17600
17660
|
contractRepository: this.contractRepository,
|
|
@@ -17948,7 +18008,7 @@ var offboardNetworkNames = [
|
|
|
17948
18008
|
function offboardDestinationScript(destinationAddress) {
|
|
17949
18009
|
for (const networkName of offboardNetworkNames) {
|
|
17950
18010
|
try {
|
|
17951
|
-
const network =
|
|
18011
|
+
const network = chunkDAYCCIRO_cjs.networks[networkName];
|
|
17952
18012
|
const addr = btcSigner.Address(network).decode(destinationAddress);
|
|
17953
18013
|
return btcSigner.OutScript.encode(addr);
|
|
17954
18014
|
} catch {
|
|
@@ -17984,7 +18044,7 @@ function filterOffboardInputs(vtxos, feeInfo, named) {
|
|
|
17984
18044
|
const inputs = [];
|
|
17985
18045
|
let subtotal = 0n;
|
|
17986
18046
|
for (const vtxo of vtxos) {
|
|
17987
|
-
const inputFee = estimator.evalOffchainInput(
|
|
18047
|
+
const inputFee = estimator.evalOffchainInput(chunkDAYCCIRO_cjs.toOffchainInputFeeParams(vtxo));
|
|
17988
18048
|
if (inputFee.satoshis >= vtxo.value) {
|
|
17989
18049
|
if (named) {
|
|
17990
18050
|
throw new Error(
|
|
@@ -18081,7 +18141,7 @@ var Ramps = class {
|
|
|
18081
18141
|
}
|
|
18082
18142
|
amount = amount ?? totalAmount;
|
|
18083
18143
|
const offchainAddress = await this.wallet.getAddress();
|
|
18084
|
-
const offchainAddr =
|
|
18144
|
+
const offchainAddr = chunkDAYCCIRO_cjs.ArkAddress.decode(offchainAddress);
|
|
18085
18145
|
const offchainScript = base.hex.encode(offchainAddr.pkScript);
|
|
18086
18146
|
const outputFee = estimator.evalOffchainOutput({
|
|
18087
18147
|
amount,
|
|
@@ -18210,7 +18270,7 @@ var Ramps = class {
|
|
|
18210
18270
|
async fundChange(left, estimator) {
|
|
18211
18271
|
if (left <= 0n) return { change: 0n };
|
|
18212
18272
|
const changeAddress = await this.wallet.getAddress();
|
|
18213
|
-
const changeScript = base.hex.encode(
|
|
18273
|
+
const changeScript = base.hex.encode(chunkDAYCCIRO_cjs.ArkAddress.decode(changeAddress).pkScript);
|
|
18214
18274
|
const { change } = changeAfterOutputFee(
|
|
18215
18275
|
left,
|
|
18216
18276
|
(amount) => BigInt(estimator.evalOffchainOutput({ amount, script: changeScript }).satoshis)
|
|
@@ -19043,7 +19103,7 @@ var WalletMessageHandler = class {
|
|
|
19043
19103
|
// Wallet methods
|
|
19044
19104
|
async handleInitWallet({ payload }) {
|
|
19045
19105
|
const { arkServerUrl } = payload;
|
|
19046
|
-
this.indexerProvider = new
|
|
19106
|
+
this.indexerProvider = new chunkSJPPBR2V_cjs.RestIndexerProvider(arkServerUrl);
|
|
19047
19107
|
await this.onWalletInitialized();
|
|
19048
19108
|
}
|
|
19049
19109
|
/**
|
|
@@ -19333,7 +19393,7 @@ var WalletMessageHandler = class {
|
|
|
19333
19393
|
if (v.isUnrolled) {
|
|
19334
19394
|
return withUnrolled;
|
|
19335
19395
|
}
|
|
19336
|
-
if (
|
|
19396
|
+
if (chunkDAYCCIRO_cjs.isVtxoSpent(v)) {
|
|
19337
19397
|
return false;
|
|
19338
19398
|
}
|
|
19339
19399
|
if (includeRecoverable) {
|
|
@@ -19342,10 +19402,10 @@ var WalletMessageHandler = class {
|
|
|
19342
19402
|
if (dustAmount != null && isSubdust(v, dustAmount)) {
|
|
19343
19403
|
return false;
|
|
19344
19404
|
}
|
|
19345
|
-
if (
|
|
19405
|
+
if (chunkDAYCCIRO_cjs.isRecoverable(v)) {
|
|
19346
19406
|
return false;
|
|
19347
19407
|
}
|
|
19348
|
-
if (
|
|
19408
|
+
if (chunkDAYCCIRO_cjs.isExpired(v)) {
|
|
19349
19409
|
return false;
|
|
19350
19410
|
}
|
|
19351
19411
|
return true;
|
|
@@ -19456,7 +19516,7 @@ var WalletMessageHandler = class {
|
|
|
19456
19516
|
this.readonlyWallet.getBoardingTxs()
|
|
19457
19517
|
]);
|
|
19458
19518
|
const indexerProvider = this.indexerProvider;
|
|
19459
|
-
const resolveTxCreatedAt = indexerProvider ? (txids) =>
|
|
19519
|
+
const resolveTxCreatedAt = indexerProvider ? (txids) => chunkDAYCCIRO_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
|
|
19460
19520
|
return buildTransactionHistory(
|
|
19461
19521
|
vtxos,
|
|
19462
19522
|
boardingTxs,
|
|
@@ -20164,7 +20224,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
20164
20224
|
};
|
|
20165
20225
|
try {
|
|
20166
20226
|
const response = await this.sendMessage(message);
|
|
20167
|
-
return response.payload.vtxos.map(
|
|
20227
|
+
return response.payload.vtxos.map(chunkDAYCCIRO_cjs.normalizeVtxo);
|
|
20168
20228
|
} catch (error) {
|
|
20169
20229
|
throw new Error(`Failed to get vtxos: ${error}`);
|
|
20170
20230
|
}
|
|
@@ -20195,7 +20255,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
20195
20255
|
"Service worker does not support the requested contract scope or freshness check"
|
|
20196
20256
|
);
|
|
20197
20257
|
}
|
|
20198
|
-
return payload.vtxos.map(
|
|
20258
|
+
return payload.vtxos.map(chunkDAYCCIRO_cjs.normalizeVtxo);
|
|
20199
20259
|
} catch (error) {
|
|
20200
20260
|
throw new Error(`Failed to get spendable vtxos: ${error}`);
|
|
20201
20261
|
}
|
|
@@ -20371,7 +20431,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
20371
20431
|
};
|
|
20372
20432
|
try {
|
|
20373
20433
|
const response = await sendContractMessage(message);
|
|
20374
|
-
return response.payload.vtxos.map(
|
|
20434
|
+
return response.payload.vtxos.map(chunkDAYCCIRO_cjs.normalizeVtxo);
|
|
20375
20435
|
} catch (e) {
|
|
20376
20436
|
throw new Error("Failed to annotate vtxos");
|
|
20377
20437
|
}
|
|
@@ -20983,7 +21043,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
20983
21043
|
};
|
|
20984
21044
|
try {
|
|
20985
21045
|
const response = await wallet.sendMessage(message);
|
|
20986
|
-
return response.payload.vtxos.map(
|
|
21046
|
+
return response.payload.vtxos.map(chunkDAYCCIRO_cjs.normalizeVtxo);
|
|
20987
21047
|
} catch (e) {
|
|
20988
21048
|
throw new Error(`Failed to get expiring vtxos: ${e}`);
|
|
20989
21049
|
}
|
|
@@ -21095,12 +21155,12 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
21095
21155
|
* @returns Configured onchain wallet
|
|
21096
21156
|
* @throws Error if the configured identity cannot produce a valid x-only public key
|
|
21097
21157
|
*/
|
|
21098
|
-
static async create(identity, networkName =
|
|
21158
|
+
static async create(identity, networkName = chunkDAYCCIRO_cjs.DEFAULT_NETWORK_NAME, provider) {
|
|
21099
21159
|
const pubkey = await identity.xOnlyPublicKey();
|
|
21100
21160
|
if (!pubkey) {
|
|
21101
21161
|
throw new Error("Invalid configured public key");
|
|
21102
21162
|
}
|
|
21103
|
-
const network =
|
|
21163
|
+
const network = chunkDAYCCIRO_cjs.getNetwork(networkName);
|
|
21104
21164
|
const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
|
|
21105
21165
|
const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
|
|
21106
21166
|
return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
|
|
@@ -21206,7 +21266,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
21206
21266
|
if (!inputs) {
|
|
21207
21267
|
throw new Error("Fee estimation failed");
|
|
21208
21268
|
}
|
|
21209
|
-
let tx = new
|
|
21269
|
+
let tx = new chunkDAYCCIRO_cjs.Transaction();
|
|
21210
21270
|
for (const input of inputs) {
|
|
21211
21271
|
tx.addInput({
|
|
21212
21272
|
txid: input.txid,
|
|
@@ -21264,7 +21324,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
21264
21324
|
* @throws If the parent has no anchor, or funding cannot be selected/signed
|
|
21265
21325
|
*/
|
|
21266
21326
|
async bumpAnchor(parentHex, feeRate) {
|
|
21267
|
-
const parent =
|
|
21327
|
+
const parent = chunkDAYCCIRO_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
|
|
21268
21328
|
const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
|
|
21269
21329
|
const child = await this.buildBumpPackage(parent, feeRate, coins);
|
|
21270
21330
|
return [parent.hex, child.hex];
|
|
@@ -22171,7 +22231,7 @@ async function resolvePrevTxs(txids, source, onchain) {
|
|
|
22171
22231
|
try {
|
|
22172
22232
|
const { txs } = await source.getVirtualTxs(wanted);
|
|
22173
22233
|
for (const psbt of txs) {
|
|
22174
|
-
const tx =
|
|
22234
|
+
const tx = chunkDAYCCIRO_cjs.Transaction.fromPSBT(base.base64.decode(psbt));
|
|
22175
22235
|
resolved.set(tx.id, tx.toBytes());
|
|
22176
22236
|
}
|
|
22177
22237
|
} catch (err) {
|
|
@@ -22204,7 +22264,7 @@ async function resolvePrevTxs(txids, source, onchain) {
|
|
|
22204
22264
|
async function attachPrevArkTxs(tx, txids, source, onchain) {
|
|
22205
22265
|
const pending = [];
|
|
22206
22266
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
22207
|
-
if (
|
|
22267
|
+
if (chunkDAYCCIRO_cjs.getArkPsbtFields(tx, i, chunkDAYCCIRO_cjs.PrevArkTxField).length === 0) pending.push(i);
|
|
22208
22268
|
}
|
|
22209
22269
|
if (pending.length === 0) return;
|
|
22210
22270
|
const resolved = await resolvePrevTxs(
|
|
@@ -22213,13 +22273,13 @@ async function attachPrevArkTxs(tx, txids, source, onchain) {
|
|
|
22213
22273
|
onchain
|
|
22214
22274
|
);
|
|
22215
22275
|
for (const i of pending) {
|
|
22216
|
-
|
|
22276
|
+
chunkDAYCCIRO_cjs.setArkPsbtField(tx, i, chunkDAYCCIRO_cjs.PrevArkTxField, resolved.get(txidAt(txids, i)));
|
|
22217
22277
|
}
|
|
22218
22278
|
}
|
|
22219
22279
|
async function attachPrevoutTxs(tx, source) {
|
|
22220
22280
|
const pending = [];
|
|
22221
22281
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
22222
|
-
if (
|
|
22282
|
+
if (chunkDAYCCIRO_cjs.getArkPsbtFields(tx, i, chunkDAYCCIRO_cjs.PrevoutTxField).length > 0) continue;
|
|
22223
22283
|
const input = tx.getInput(i);
|
|
22224
22284
|
if (!input?.txid) throw new PrevTxUnavailableError(`input ${i} has no outpoint`);
|
|
22225
22285
|
pending.push({ index: i, txid: base.hex.encode(input.txid) });
|
|
@@ -22230,7 +22290,7 @@ async function attachPrevoutTxs(tx, source) {
|
|
|
22230
22290
|
resolved.set(txid, await source.getRawTransaction(txid));
|
|
22231
22291
|
}
|
|
22232
22292
|
for (const { index, txid } of pending) {
|
|
22233
|
-
|
|
22293
|
+
chunkDAYCCIRO_cjs.setArkPsbtField(tx, index, chunkDAYCCIRO_cjs.PrevoutTxField, resolved.get(txid));
|
|
22234
22294
|
}
|
|
22235
22295
|
}
|
|
22236
22296
|
async function withPrevTxs(coins, source, onchain) {
|
|
@@ -22256,7 +22316,7 @@ exports.BIP322 = void 0;
|
|
|
22256
22316
|
async function sign2(message, identity, network) {
|
|
22257
22317
|
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
22258
22318
|
const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
|
|
22259
|
-
const toSpend =
|
|
22319
|
+
const toSpend = chunkDAYCCIRO_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
22260
22320
|
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
22261
22321
|
const signed = await identity.sign(toSign, [0]);
|
|
22262
22322
|
signed.finalizeIdx(0);
|
|
@@ -22314,8 +22374,8 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
|
22314
22374
|
if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
|
|
22315
22375
|
return false;
|
|
22316
22376
|
}
|
|
22317
|
-
const toSpend =
|
|
22318
|
-
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript
|
|
22377
|
+
const toSpend = chunkDAYCCIRO_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
22378
|
+
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript);
|
|
22319
22379
|
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
22320
22380
|
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
22321
22381
|
return secp256k1_js.schnorr.verify(rawSig, sighash, pubkey);
|
|
@@ -22335,7 +22395,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
|
22335
22395
|
}
|
|
22336
22396
|
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
22337
22397
|
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
22338
|
-
const toSpend =
|
|
22398
|
+
const toSpend = chunkDAYCCIRO_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
22339
22399
|
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
22340
22400
|
const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
|
|
22341
22401
|
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
@@ -22388,7 +22448,7 @@ function encodeCompactSize(n) {
|
|
|
22388
22448
|
return buf;
|
|
22389
22449
|
}
|
|
22390
22450
|
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
22391
|
-
const tx = new
|
|
22451
|
+
const tx = new chunkDAYCCIRO_cjs.Transaction({ version: 0 });
|
|
22392
22452
|
tx.addInput({
|
|
22393
22453
|
txid: toSpend.id,
|
|
22394
22454
|
index: 0,
|
|
@@ -22402,12 +22462,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
|
22402
22462
|
});
|
|
22403
22463
|
tx.addOutput({
|
|
22404
22464
|
amount: 0n,
|
|
22405
|
-
script:
|
|
22465
|
+
script: chunkDAYCCIRO_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
22406
22466
|
});
|
|
22407
22467
|
return tx;
|
|
22408
22468
|
}
|
|
22409
22469
|
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
22410
|
-
const tx = new
|
|
22470
|
+
const tx = new chunkDAYCCIRO_cjs.Transaction({ version: 0 });
|
|
22411
22471
|
tx.addInput({
|
|
22412
22472
|
txid: toSpend.id,
|
|
22413
22473
|
index: 0,
|
|
@@ -22419,7 +22479,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
|
22419
22479
|
});
|
|
22420
22480
|
tx.addOutput({
|
|
22421
22481
|
amount: 0n,
|
|
22422
|
-
script:
|
|
22482
|
+
script: chunkDAYCCIRO_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
22423
22483
|
});
|
|
22424
22484
|
return tx;
|
|
22425
22485
|
}
|
|
@@ -22432,7 +22492,7 @@ var RestEmulatorProvider = class {
|
|
|
22432
22492
|
serverUrl;
|
|
22433
22493
|
async getInfo() {
|
|
22434
22494
|
const url = `${this.serverUrl}/v1/info`;
|
|
22435
|
-
const response = await
|
|
22495
|
+
const response = await chunkDAYCCIRO_cjs.baseFetch(url);
|
|
22436
22496
|
if (!response.ok) {
|
|
22437
22497
|
const errorText2 = await response.text();
|
|
22438
22498
|
throw new Error(`Failed to get emulator info: ${errorText2}`);
|
|
@@ -22550,7 +22610,7 @@ var RestEmulatorProvider = class {
|
|
|
22550
22610
|
}
|
|
22551
22611
|
};
|
|
22552
22612
|
function finalizeVirtualTx(type, psbtBase64) {
|
|
22553
|
-
const tx =
|
|
22613
|
+
const tx = chunkDAYCCIRO_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
22554
22614
|
if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
|
|
22555
22615
|
const input = tx.getInput(0);
|
|
22556
22616
|
if (!input) {
|
|
@@ -22577,14 +22637,14 @@ var ExitPathError = class extends Error {
|
|
|
22577
22637
|
reason;
|
|
22578
22638
|
};
|
|
22579
22639
|
function delayWeight(sequence) {
|
|
22580
|
-
const t =
|
|
22640
|
+
const t = chunkDAYCCIRO_cjs.sequenceToTimelock(sequence);
|
|
22581
22641
|
return t.type === "blocks" ? Number(t.value) : Number(t.value) / 600;
|
|
22582
22642
|
}
|
|
22583
22643
|
async function resolveUnilateralPath(params) {
|
|
22584
22644
|
const { vtxo, scriptHex, contractRepository } = params;
|
|
22585
22645
|
const contract = contractRepository ? (await contractRepository.getContracts({ script: scriptHex }))[0] : void 0;
|
|
22586
22646
|
if (contract) {
|
|
22587
|
-
const handler =
|
|
22647
|
+
const handler = chunkFUW3OM5X_cjs.contractHandlers.get(contract.type);
|
|
22588
22648
|
if (!handler) {
|
|
22589
22649
|
throw new ExitPathError(
|
|
22590
22650
|
"no-handler",
|
|
@@ -22607,12 +22667,12 @@ async function resolveUnilateralPath(params) {
|
|
|
22607
22667
|
paths.sort((a, b) => delayWeight(a.sequence) - delayWeight(b.sequence));
|
|
22608
22668
|
return { selection: paths[0], label: `${contract.type}:unilateral` };
|
|
22609
22669
|
}
|
|
22610
|
-
const decoded =
|
|
22670
|
+
const decoded = chunkDAYCCIRO_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
22611
22671
|
let best;
|
|
22612
22672
|
for (const exit of decoded.exitPaths()) {
|
|
22613
22673
|
const leaf = decoded.findLeaf(base.hex.encode(exit.script));
|
|
22614
22674
|
if (!leaf) continue;
|
|
22615
|
-
const sequence =
|
|
22675
|
+
const sequence = chunkDAYCCIRO_cjs.timelockToSequence(exit.params.timelock);
|
|
22616
22676
|
const weight = delayWeight(sequence);
|
|
22617
22677
|
if (!best || weight < best.weight) {
|
|
22618
22678
|
best = { selection: { leaf, sequence }, weight };
|
|
@@ -22832,7 +22892,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
22832
22892
|
let totalAmount = 0n;
|
|
22833
22893
|
const txWeightEstimator = TxWeightEstimator.create();
|
|
22834
22894
|
for (const vtxo of vtxos) {
|
|
22835
|
-
if (!
|
|
22895
|
+
if (!chunkDAYCCIRO_cjs.canSweepOnchain(vtxo)) {
|
|
22836
22896
|
throw new Error(
|
|
22837
22897
|
`Vtxo ${vtxo.txid}:${vtxo.vout} cannot be swept onchain: it is not fully unrolled (use unroll first), or its exit output was already spent`
|
|
22838
22898
|
);
|
|
@@ -22843,14 +22903,14 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
22843
22903
|
}
|
|
22844
22904
|
const resolved = await resolveUnilateralPath({
|
|
22845
22905
|
vtxo,
|
|
22846
|
-
scriptHex: base.hex.encode(
|
|
22906
|
+
scriptHex: base.hex.encode(chunkDAYCCIRO_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
22847
22907
|
contractRepository: wallet.contractRepository,
|
|
22848
22908
|
walletPubKeyHex: base.hex.encode(await wallet.identity.xOnlyPublicKey()),
|
|
22849
22909
|
currentTime: Date.now()
|
|
22850
22910
|
});
|
|
22851
22911
|
const spendingLeaf = resolved.selection.leaf;
|
|
22852
22912
|
const sequence = resolved.selection.sequence;
|
|
22853
|
-
const timelock =
|
|
22913
|
+
const timelock = chunkDAYCCIRO_cjs.sequenceToTimelock(sequence);
|
|
22854
22914
|
const elapsed = timelock.type === "blocks" ? chainTip.height >= txStatus.blockHeight + Number(timelock.value) : chainTip.time >= txStatus.blockTime + Number(timelock.value);
|
|
22855
22915
|
if (!elapsed) {
|
|
22856
22916
|
throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
|
|
@@ -22863,7 +22923,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
22863
22923
|
sequence,
|
|
22864
22924
|
witnessUtxo: {
|
|
22865
22925
|
amount: BigInt(vtxo.value),
|
|
22866
|
-
script:
|
|
22926
|
+
script: chunkDAYCCIRO_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
|
|
22867
22927
|
},
|
|
22868
22928
|
sighashType: btcSigner.SigHash.DEFAULT
|
|
22869
22929
|
});
|
|
@@ -22873,7 +22933,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
22873
22933
|
btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
|
|
22874
22934
|
);
|
|
22875
22935
|
}
|
|
22876
|
-
const tx = new
|
|
22936
|
+
const tx = new chunkDAYCCIRO_cjs.Transaction({ version: 2 });
|
|
22877
22937
|
for (const input of inputs) {
|
|
22878
22938
|
tx.addInput(input);
|
|
22879
22939
|
}
|
|
@@ -22956,7 +23016,7 @@ async function buildSignedSweep(params) {
|
|
|
22956
23016
|
`uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
|
|
22957
23017
|
);
|
|
22958
23018
|
}
|
|
22959
|
-
const tx = new
|
|
23019
|
+
const tx = new chunkDAYCCIRO_cjs.Transaction({ version: 2 });
|
|
22960
23020
|
tx.addInput({
|
|
22961
23021
|
txid: vtxo.txid,
|
|
22962
23022
|
index: vtxo.vout,
|
|
@@ -22981,7 +23041,7 @@ async function buildSignedSweep(params) {
|
|
|
22981
23041
|
finalScriptWitness: [
|
|
22982
23042
|
tapScriptSig[0][1],
|
|
22983
23043
|
...path.extraWitness,
|
|
22984
|
-
|
|
23044
|
+
chunkDAYCCIRO_cjs.scriptFromTapLeafScript(path.leaf),
|
|
22985
23045
|
btcSigner.TaprootControlBlock.encode(controlBlock)
|
|
22986
23046
|
]
|
|
22987
23047
|
});
|
|
@@ -23011,7 +23071,7 @@ async function resolveFeeRate(opts) {
|
|
|
23011
23071
|
}
|
|
23012
23072
|
async function selectExitVtxos(opts) {
|
|
23013
23073
|
if (!opts.vtxos) return opts.wallet.getVtxos();
|
|
23014
|
-
const res = await
|
|
23074
|
+
const res = await chunkDAYCCIRO_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
|
|
23015
23075
|
const tapTrees = /* @__PURE__ */ new Map();
|
|
23016
23076
|
const out = [];
|
|
23017
23077
|
for (const vtxo of res.vtxos) {
|
|
@@ -23026,7 +23086,7 @@ async function selectExitVtxos(opts) {
|
|
|
23026
23086
|
`no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
|
|
23027
23087
|
);
|
|
23028
23088
|
}
|
|
23029
|
-
const handler =
|
|
23089
|
+
const handler = chunkFUW3OM5X_cjs.contractHandlers.get(contract.type);
|
|
23030
23090
|
if (!handler) {
|
|
23031
23091
|
throw new Error(`no contract handler registered for type '${contract.type}'`);
|
|
23032
23092
|
}
|
|
@@ -23056,7 +23116,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
23056
23116
|
if (pendingNodes.length > 0) {
|
|
23057
23117
|
const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
|
|
23058
23118
|
for (const psbt of txs) {
|
|
23059
|
-
psbts.set(
|
|
23119
|
+
psbts.set(chunkDAYCCIRO_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
23060
23120
|
}
|
|
23061
23121
|
}
|
|
23062
23122
|
const childVsize = Number(
|
|
@@ -23092,7 +23152,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
23092
23152
|
try {
|
|
23093
23153
|
const resolved = await resolveUnilateralPath({
|
|
23094
23154
|
vtxo,
|
|
23095
|
-
scriptHex: base.hex.encode(
|
|
23155
|
+
scriptHex: base.hex.encode(chunkDAYCCIRO_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
23096
23156
|
contractRepository: wallet.contractRepository,
|
|
23097
23157
|
walletPubKeyHex,
|
|
23098
23158
|
currentTime: Date.now()
|
|
@@ -23111,7 +23171,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
23111
23171
|
});
|
|
23112
23172
|
continue;
|
|
23113
23173
|
}
|
|
23114
|
-
const t =
|
|
23174
|
+
const t = chunkDAYCCIRO_cjs.sequenceToTimelock(resolved.selection.sequence);
|
|
23115
23175
|
const delay = { type: t.type, value: Number(t.value) };
|
|
23116
23176
|
infos.push({ outpoint, value: vtxo.value, sweepFee, path: resolved.label, delay });
|
|
23117
23177
|
sweeps.push({ vtxo, resolved, sweepFee, delay });
|
|
@@ -23512,7 +23572,7 @@ async function prepare(opts) {
|
|
|
23512
23572
|
txid: sweep.vtxo.txid,
|
|
23513
23573
|
vout: sweep.vtxo.vout,
|
|
23514
23574
|
value: sweep.vtxo.value,
|
|
23515
|
-
pkScript:
|
|
23575
|
+
pkScript: chunkDAYCCIRO_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
|
|
23516
23576
|
},
|
|
23517
23577
|
path: sweep.resolved.selection,
|
|
23518
23578
|
outputAddress: opts.sweepAddress,
|
|
@@ -23601,7 +23661,7 @@ async function prepare(opts) {
|
|
|
23601
23661
|
if (newFee <= splitterFee) break;
|
|
23602
23662
|
splitterFee = newFee;
|
|
23603
23663
|
}
|
|
23604
|
-
const splitter = new
|
|
23664
|
+
const splitter = new chunkDAYCCIRO_cjs.Transaction({ version: 2 });
|
|
23605
23665
|
for (const coin of selected.inputs) {
|
|
23606
23666
|
splitter.addInput({
|
|
23607
23667
|
txid: coin.txid,
|
|
@@ -23745,43 +23805,43 @@ var UnilateralExit = {
|
|
|
23745
23805
|
// src/arkade/index.ts
|
|
23746
23806
|
var arkade_exports = {};
|
|
23747
23807
|
chunk5BLDMQED_cjs.__export(arkade_exports, {
|
|
23748
|
-
ARKADE_OP: () =>
|
|
23749
|
-
ARKADE_OPCODES: () =>
|
|
23750
|
-
ARKADE_OPCODE_NAMES: () =>
|
|
23751
|
-
ARKADE_OPCODE_VALUES: () =>
|
|
23752
|
-
ARKADE_OPS: () =>
|
|
23808
|
+
ARKADE_OP: () => chunkFUW3OM5X_cjs.ARKADE_OP,
|
|
23809
|
+
ARKADE_OPCODES: () => chunkFUW3OM5X_cjs.ARKADE_OPCODES,
|
|
23810
|
+
ARKADE_OPCODE_NAMES: () => chunkFUW3OM5X_cjs.ARKADE_OPCODE_NAMES,
|
|
23811
|
+
ARKADE_OPCODE_VALUES: () => chunkFUW3OM5X_cjs.ARKADE_OPCODE_VALUES,
|
|
23812
|
+
ARKADE_OPS: () => chunkFUW3OM5X_cjs.ARKADE_OPS,
|
|
23753
23813
|
Arkade: () => Arkade,
|
|
23754
23814
|
ArkadeContract: () => ArkadeContract,
|
|
23755
|
-
ArkadeProgramScript: () =>
|
|
23756
|
-
ArkadeScript: () =>
|
|
23815
|
+
ArkadeProgramScript: () => chunkFUW3OM5X_cjs.ArkadeProgramScript,
|
|
23816
|
+
ArkadeScript: () => chunkFUW3OM5X_cjs.ArkadeScript,
|
|
23757
23817
|
ArkadeTransactionBuilder: () => ArkadeTransactionBuilder,
|
|
23758
|
-
BigNum: () =>
|
|
23818
|
+
BigNum: () => chunkFUW3OM5X_cjs.bignum_exports,
|
|
23759
23819
|
OP: () => btcSigner.OP,
|
|
23760
|
-
OPCODE_NAMES: () =>
|
|
23761
|
-
OPCODE_VALUES: () =>
|
|
23762
|
-
SUPPORTED_PROGRAM_VERSION: () =>
|
|
23820
|
+
OPCODE_NAMES: () => chunkFUW3OM5X_cjs.OPCODE_NAMES,
|
|
23821
|
+
OPCODE_VALUES: () => chunkFUW3OM5X_cjs.OPCODE_VALUES,
|
|
23822
|
+
SUPPORTED_PROGRAM_VERSION: () => chunkFUW3OM5X_cjs.SUPPORTED_PROGRAM_VERSION,
|
|
23763
23823
|
Script: () => btcSigner.Script,
|
|
23764
|
-
arkadeScriptHash: () =>
|
|
23765
|
-
arkadeWitnessHash: () =>
|
|
23766
|
-
asmToBytes: () =>
|
|
23767
|
-
bytesToASM: () =>
|
|
23768
|
-
computeArkadeScriptPublicKey: () =>
|
|
23824
|
+
arkadeScriptHash: () => chunkFUW3OM5X_cjs.arkadeScriptHash,
|
|
23825
|
+
arkadeWitnessHash: () => chunkFUW3OM5X_cjs.arkadeWitnessHash,
|
|
23826
|
+
asmToBytes: () => chunkFUW3OM5X_cjs.asmToBytes,
|
|
23827
|
+
bytesToASM: () => chunkFUW3OM5X_cjs.bytesToASM,
|
|
23828
|
+
computeArkadeScriptPublicKey: () => chunkFUW3OM5X_cjs.computeArkadeScriptPublicKey,
|
|
23769
23829
|
createArkadeBatchHandler: () => createArkadeBatchHandler,
|
|
23770
|
-
deserializeArkadeContractParams: () =>
|
|
23771
|
-
fromASM: () =>
|
|
23772
|
-
getOpcodeName: () =>
|
|
23773
|
-
getOpcodeValue: () =>
|
|
23830
|
+
deserializeArkadeContractParams: () => chunkFUW3OM5X_cjs.deserializeArkadeContractParams,
|
|
23831
|
+
fromASM: () => chunkFUW3OM5X_cjs.fromASM,
|
|
23832
|
+
getOpcodeName: () => chunkFUW3OM5X_cjs.getOpcodeName,
|
|
23833
|
+
getOpcodeValue: () => chunkFUW3OM5X_cjs.getOpcodeValue,
|
|
23774
23834
|
isContractArtifact: () => isContractArtifact,
|
|
23775
|
-
parseArtifact: () =>
|
|
23835
|
+
parseArtifact: () => chunkFUW3OM5X_cjs.parseArtifact,
|
|
23776
23836
|
programFromArtifact: () => programFromArtifact,
|
|
23777
|
-
resolveAsm: () =>
|
|
23778
|
-
serializeArkadeContractParams: () =>
|
|
23779
|
-
stringifyArtifact: () =>
|
|
23780
|
-
toASM: () =>
|
|
23781
|
-
validateProgram: () =>
|
|
23782
|
-
witnessRefToBytes: () =>
|
|
23837
|
+
resolveAsm: () => chunkFUW3OM5X_cjs.resolveAsm,
|
|
23838
|
+
serializeArkadeContractParams: () => chunkFUW3OM5X_cjs.serializeArkadeContractParams,
|
|
23839
|
+
stringifyArtifact: () => chunkFUW3OM5X_cjs.stringifyArtifact,
|
|
23840
|
+
toASM: () => chunkFUW3OM5X_cjs.toASM,
|
|
23841
|
+
validateProgram: () => chunkFUW3OM5X_cjs.validateProgram,
|
|
23842
|
+
witnessRefToBytes: () => chunkFUW3OM5X_cjs.witnessRefToBytes
|
|
23783
23843
|
});
|
|
23784
|
-
var isVtxoCoin = (input) =>
|
|
23844
|
+
var isVtxoCoin = (input) => chunkDAYCCIRO_cjs.isVirtualCoin(input);
|
|
23785
23845
|
function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
|
|
23786
23846
|
let batchId;
|
|
23787
23847
|
let sweepTapTreeRoot;
|
|
@@ -23802,23 +23862,23 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
23802
23862
|
);
|
|
23803
23863
|
await arkProvider.confirmRegistration(intentId);
|
|
23804
23864
|
batchId = event.id;
|
|
23805
|
-
const sweepTapscript =
|
|
23865
|
+
const sweepTapscript = chunkDAYCCIRO_cjs.CSVMultisigTapscript.encode({
|
|
23806
23866
|
timelock,
|
|
23807
|
-
pubkeys: [
|
|
23867
|
+
pubkeys: [chunkFUW3OM5X_cjs.toXOnly(base.hex.decode(info.forfeitPubkey), "forfeit key")]
|
|
23808
23868
|
}).script;
|
|
23809
23869
|
sweepTapTreeRoot = payment_js.tapLeafHash(sweepTapscript);
|
|
23810
23870
|
return { skip: false };
|
|
23811
23871
|
},
|
|
23812
23872
|
onTreeSigningStarted: async (event, vtxoTree) => {
|
|
23813
23873
|
const signerPubKey = await session.getPublicKey();
|
|
23814
|
-
const xonlySignerPubKey =
|
|
23874
|
+
const xonlySignerPubKey = chunkFUW3OM5X_cjs.toXOnly(signerPubKey, "signer key");
|
|
23815
23875
|
const xOnlyPubkeys = event.cosignersPublicKeys.map(
|
|
23816
|
-
(k) => base.hex.encode(
|
|
23876
|
+
(k) => base.hex.encode(chunkFUW3OM5X_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
|
|
23817
23877
|
);
|
|
23818
23878
|
if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
|
|
23819
23879
|
return { skip: true };
|
|
23820
23880
|
}
|
|
23821
|
-
const commitmentTx =
|
|
23881
|
+
const commitmentTx = chunkDAYCCIRO_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
|
|
23822
23882
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
23823
23883
|
if (recipients && recipients.length > 0) {
|
|
23824
23884
|
validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
|
|
@@ -23856,7 +23916,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
23856
23916
|
if (connectorTree) {
|
|
23857
23917
|
validateConnectorsTxGraph(event.commitmentTx, connectorTree);
|
|
23858
23918
|
}
|
|
23859
|
-
let commitmentPsbt =
|
|
23919
|
+
let commitmentPsbt = chunkDAYCCIRO_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
23860
23920
|
assertFinalCommitmentMatchesValidated(
|
|
23861
23921
|
commitmentPsbt,
|
|
23862
23922
|
validatedCommitmentTxid,
|
|
@@ -23898,7 +23958,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
23898
23958
|
boardingIndices.push(boardingIdx);
|
|
23899
23959
|
continue;
|
|
23900
23960
|
}
|
|
23901
|
-
if (!
|
|
23961
|
+
if (!chunkDAYCCIRO_cjs.requiresForfeit(input) || isSubdust(input, info.dust)) {
|
|
23902
23962
|
continue;
|
|
23903
23963
|
}
|
|
23904
23964
|
if (connectorIndex >= connectorLeaves.length) {
|
|
@@ -23919,7 +23979,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
23919
23979
|
index: input.vout,
|
|
23920
23980
|
witnessUtxo: {
|
|
23921
23981
|
amount: BigInt(input.value),
|
|
23922
|
-
script:
|
|
23982
|
+
script: chunkDAYCCIRO_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
23923
23983
|
},
|
|
23924
23984
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
23925
23985
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -24064,7 +24124,7 @@ function flatten(param, structs, stack = []) {
|
|
|
24064
24124
|
function opcodeToken(token) {
|
|
24065
24125
|
const base = token.slice(3);
|
|
24066
24126
|
const name = base === "0" || /^([1-9]|1[0-6])$/.test(base) ? token : base;
|
|
24067
|
-
if (!Object.hasOwn(
|
|
24127
|
+
if (!Object.hasOwn(chunkFUW3OM5X_cjs.ARKADE_OPS, name)) {
|
|
24068
24128
|
fail(`opcode '${token}' is not in this SDK's table`);
|
|
24069
24129
|
}
|
|
24070
24130
|
return name;
|
|
@@ -24111,8 +24171,8 @@ function providedWitness(witness) {
|
|
|
24111
24171
|
}
|
|
24112
24172
|
function csvTimelock(leafName, operand) {
|
|
24113
24173
|
if (typeof operand === "string") return { type: "blocks", value: operand };
|
|
24114
|
-
const timelock = operand >= 0n && operand < 0x80000000n ?
|
|
24115
|
-
if (!timelock || BigInt(
|
|
24174
|
+
const timelock = operand >= 0n && operand < 0x80000000n ? chunkDAYCCIRO_cjs.sequenceToTimelock(Number(operand)) : void 0;
|
|
24175
|
+
if (!timelock || BigInt(chunkDAYCCIRO_cjs.timelockToSequence(timelock)) !== operand) {
|
|
24116
24176
|
fail(`leaf '${leafName}': CSV literal ${operand} is not a canonical BIP68 sequence`);
|
|
24117
24177
|
}
|
|
24118
24178
|
return timelock;
|
|
@@ -24230,7 +24290,7 @@ function programFromArtifact(artifact) {
|
|
|
24230
24290
|
const paramNames = /* @__PURE__ */ new Set();
|
|
24231
24291
|
for (const param of params) claim(paramNames, param.name, "program parameter");
|
|
24232
24292
|
return {
|
|
24233
|
-
version:
|
|
24293
|
+
version: chunkFUW3OM5X_cjs.SUPPORTED_PROGRAM_VERSION,
|
|
24234
24294
|
name: artifact.contractName,
|
|
24235
24295
|
params,
|
|
24236
24296
|
functions
|
|
@@ -24275,16 +24335,16 @@ var Arkade = class _Arkade {
|
|
|
24275
24335
|
/** Connect and resolve the server key, checkpoint closure and (if present) the co-signer key. */
|
|
24276
24336
|
static async connect(opts) {
|
|
24277
24337
|
const info = await opts.arkade.getInfo();
|
|
24278
|
-
const serverKey =
|
|
24279
|
-
const checkpoint =
|
|
24280
|
-
const network = opts.network ?? (Object.hasOwn(
|
|
24338
|
+
const serverKey = chunkFUW3OM5X_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
|
|
24339
|
+
const checkpoint = chunkDAYCCIRO_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
24340
|
+
const network = opts.network ?? (Object.hasOwn(chunkDAYCCIRO_cjs.networks, info.network) ? chunkDAYCCIRO_cjs.getNetwork(info.network) : chunkDAYCCIRO_cjs.DEFAULT_NETWORK);
|
|
24281
24341
|
let emulatorKey;
|
|
24282
24342
|
if (opts.emulator) {
|
|
24283
|
-
emulatorKey = base.hex.decode(
|
|
24343
|
+
emulatorKey = base.hex.decode(chunkDAYCCIRO_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
|
|
24284
24344
|
}
|
|
24285
24345
|
let userKey;
|
|
24286
24346
|
if (opts.identity) {
|
|
24287
|
-
userKey =
|
|
24347
|
+
userKey = chunkFUW3OM5X_cjs.toXOnly(await opts.identity.xOnlyPublicKey(), "identity key");
|
|
24288
24348
|
}
|
|
24289
24349
|
return new _Arkade({
|
|
24290
24350
|
arkProvider: opts.arkade,
|
|
@@ -24310,7 +24370,7 @@ var Arkade = class _Arkade {
|
|
|
24310
24370
|
* key respectively; explicit args always win.
|
|
24311
24371
|
*/
|
|
24312
24372
|
contract(program, args = {}) {
|
|
24313
|
-
const declared = (program.params ?? []).map(
|
|
24373
|
+
const declared = (program.params ?? []).map(chunkFUW3OM5X_cjs.inputName);
|
|
24314
24374
|
if (declared.includes("server") && args.server === void 0) {
|
|
24315
24375
|
args = { ...args, server: this.serverKey };
|
|
24316
24376
|
}
|
|
@@ -24330,7 +24390,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
24330
24390
|
userKey: client.userKey,
|
|
24331
24391
|
emulatorKey: client.emulatorKey
|
|
24332
24392
|
};
|
|
24333
|
-
this.vtxoScript = new
|
|
24393
|
+
this.vtxoScript = new chunkFUW3OM5X_cjs.ArkadeProgramScript(program, args, this.keys);
|
|
24334
24394
|
this.tapTree = this.vtxoScript.encode();
|
|
24335
24395
|
this.compiled = this.vtxoScript.compiled;
|
|
24336
24396
|
}
|
|
@@ -24358,7 +24418,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
24358
24418
|
`ArkadeContract.fromContract: expected contract type 'arkade', got '${contract.type}'`
|
|
24359
24419
|
);
|
|
24360
24420
|
}
|
|
24361
|
-
const typed =
|
|
24421
|
+
const typed = chunkFUW3OM5X_cjs.deserializeArkadeContractParams(contract.params);
|
|
24362
24422
|
return new _ArkadeContract(client, typed.program, typed.args, {
|
|
24363
24423
|
serverKey: typed.serverKey,
|
|
24364
24424
|
userKey: typed.userKey,
|
|
@@ -24399,7 +24459,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
24399
24459
|
toContractParams() {
|
|
24400
24460
|
return {
|
|
24401
24461
|
type: "arkade",
|
|
24402
|
-
params:
|
|
24462
|
+
params: chunkFUW3OM5X_cjs.serializeArkadeContractParams({
|
|
24403
24463
|
program: this.program,
|
|
24404
24464
|
args: this.args,
|
|
24405
24465
|
serverKey: this.keys.serverKey,
|
|
@@ -24448,17 +24508,17 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
24448
24508
|
const [registered] = await manager.getContracts({ script: scriptHex });
|
|
24449
24509
|
if (registered) {
|
|
24450
24510
|
const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
|
|
24451
|
-
return (withVtxos?.vtxos ?? []).filter((v) => !
|
|
24511
|
+
return (withVtxos?.vtxos ?? []).filter((v) => !chunkDAYCCIRO_cjs.isVtxoSpent(v) && !v.isUnrolled);
|
|
24452
24512
|
}
|
|
24453
24513
|
}
|
|
24454
24514
|
if (!this.client.indexer) {
|
|
24455
24515
|
throw new Error("ArkadeContract.getUtxos: an indexer is required");
|
|
24456
24516
|
}
|
|
24457
|
-
const { vtxos } = await
|
|
24517
|
+
const { vtxos } = await chunkDAYCCIRO_cjs.getNormalizedVtxos(this.client.indexer, {
|
|
24458
24518
|
scripts: [scriptHex],
|
|
24459
24519
|
spendableOnly: true
|
|
24460
24520
|
});
|
|
24461
|
-
return vtxos.filter((v) => !
|
|
24521
|
+
return vtxos.filter((v) => !chunkDAYCCIRO_cjs.isVtxoSpent(v) && !v.isUnrolled);
|
|
24462
24522
|
}
|
|
24463
24523
|
/** Total spendable balance (requires an indexer). */
|
|
24464
24524
|
async getBalance() {
|
|
@@ -24556,7 +24616,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
24556
24616
|
this.contract.client.checkpoint
|
|
24557
24617
|
);
|
|
24558
24618
|
if (coin.sourceTx) {
|
|
24559
|
-
|
|
24619
|
+
chunkDAYCCIRO_cjs.setArkPsbtField(arkTx, 0, chunkDAYCCIRO_cjs.PrevArkTxField, coin.sourceTx);
|
|
24560
24620
|
}
|
|
24561
24621
|
if (this.fn.arkadeScript) {
|
|
24562
24622
|
const indexer = this.contract.client.indexer;
|
|
@@ -24573,8 +24633,8 @@ var ArkadeTransactionBuilder = class {
|
|
|
24573
24633
|
}
|
|
24574
24634
|
const condition = (def.tapscript.witness ?? []).map((w) => this.witnessBytes(w));
|
|
24575
24635
|
if (condition.length > 0) {
|
|
24576
|
-
|
|
24577
|
-
|
|
24636
|
+
chunkDAYCCIRO_cjs.setArkPsbtField(arkTx, 0, chunkDAYCCIRO_cjs.ConditionWitness, condition);
|
|
24637
|
+
chunkDAYCCIRO_cjs.setArkPsbtField(checkpoints[0], 0, chunkDAYCCIRO_cjs.ConditionWitness, condition);
|
|
24578
24638
|
}
|
|
24579
24639
|
const packets = [];
|
|
24580
24640
|
if (this.assetSpecs.length > 0) {
|
|
@@ -24613,7 +24673,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
24613
24673
|
base.base64.encode(signedArk2.toPSBT()),
|
|
24614
24674
|
signedCps.map((c) => base.base64.encode(c.toPSBT()))
|
|
24615
24675
|
);
|
|
24616
|
-
const txid =
|
|
24676
|
+
const txid = chunkDAYCCIRO_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
|
|
24617
24677
|
return {
|
|
24618
24678
|
txid,
|
|
24619
24679
|
signedArkTx: res2.signedArkTx,
|
|
@@ -24672,23 +24732,23 @@ var ArkadeTransactionBuilder = class {
|
|
|
24672
24732
|
}
|
|
24673
24733
|
buildAssetPacket() {
|
|
24674
24734
|
const groups = this.assetSpecs.map((s) => {
|
|
24675
|
-
const id = typeof s.assetId === "string" ?
|
|
24676
|
-
return
|
|
24735
|
+
const id = typeof s.assetId === "string" ? chunkSJPPBR2V_cjs.AssetId.fromString(s.assetId) : chunkSJPPBR2V_cjs.AssetId.fromBytes(s.assetId);
|
|
24736
|
+
return chunkSJPPBR2V_cjs.AssetGroup.create(
|
|
24677
24737
|
id,
|
|
24678
24738
|
null,
|
|
24679
|
-
s.inputs.map((i) =>
|
|
24680
|
-
s.outputs.map((o) =>
|
|
24681
|
-
(s.metadata ?? []).map((m) =>
|
|
24739
|
+
s.inputs.map((i) => chunkSJPPBR2V_cjs.AssetInput.create(i.vin, i.amount)),
|
|
24740
|
+
s.outputs.map((o) => chunkSJPPBR2V_cjs.AssetOutput.create(o.vout, o.amount)),
|
|
24741
|
+
(s.metadata ?? []).map((m) => chunkSJPPBR2V_cjs.Metadata.create(m.key, m.value))
|
|
24682
24742
|
);
|
|
24683
24743
|
});
|
|
24684
|
-
return
|
|
24744
|
+
return chunkSJPPBR2V_cjs.Packet.create(groups);
|
|
24685
24745
|
}
|
|
24686
24746
|
witnessBytes(ref) {
|
|
24687
|
-
return
|
|
24747
|
+
return chunkFUW3OM5X_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
|
|
24688
24748
|
}
|
|
24689
24749
|
};
|
|
24690
24750
|
function bindInputs(fn, callArgs) {
|
|
24691
|
-
const names = (fn.def.inputs ?? []).map(
|
|
24751
|
+
const names = (fn.def.inputs ?? []).map(chunkFUW3OM5X_cjs.inputName);
|
|
24692
24752
|
if (callArgs.length !== names.length) {
|
|
24693
24753
|
throw new Error(`${fn.name}: expected ${names.length} argument(s), got ${callArgs.length}`);
|
|
24694
24754
|
}
|
|
@@ -25101,17 +25161,17 @@ var walletFeeSource = (wallet) => async () => (await wallet.arkProvider.getInfo(
|
|
|
25101
25161
|
function offchainInputFees(vtxos, fees) {
|
|
25102
25162
|
const estimator = new Estimator(fees?.intentFee ?? {});
|
|
25103
25163
|
return vtxos.reduce(
|
|
25104
|
-
(total, vtxo) => total + estimator.evalOffchainInput(
|
|
25164
|
+
(total, vtxo) => total + estimator.evalOffchainInput(chunkDAYCCIRO_cjs.toOffchainInputFeeParams(vtxo)).satoshis,
|
|
25105
25165
|
0
|
|
25106
25166
|
);
|
|
25107
25167
|
}
|
|
25108
25168
|
async function changeOutputFee(wallet, inputs, needed, fees) {
|
|
25109
25169
|
const estimator = new Estimator(fees?.intentFee ?? {});
|
|
25110
25170
|
const net = inputs.reduce(
|
|
25111
|
-
(total, vtxo) => total + BigInt(vtxo.value) - BigInt(estimator.evalOffchainInput(
|
|
25171
|
+
(total, vtxo) => total + BigInt(vtxo.value) - BigInt(estimator.evalOffchainInput(chunkDAYCCIRO_cjs.toOffchainInputFeeParams(vtxo)).satoshis),
|
|
25112
25172
|
0n
|
|
25113
25173
|
);
|
|
25114
|
-
const script = base.hex.encode(
|
|
25174
|
+
const script = base.hex.encode(chunkDAYCCIRO_cjs.ArkAddress.decode(await wallet.getAddress()).pkScript);
|
|
25115
25175
|
return changeAfterOutputFee(
|
|
25116
25176
|
net - needed,
|
|
25117
25177
|
(amount) => BigInt(estimator.evalOffchainOutput({ amount, script }).satoshis)
|
|
@@ -25176,11 +25236,6 @@ function createDefaultPaymentRouter(wallet) {
|
|
|
25176
25236
|
prefs: { priority: ["ark", "ark-asset", "lightning", "onchain"] }
|
|
25177
25237
|
}).use(arkRail()).use(arkAssetRail()).use(onchainRail({ feeInfo: walletFeeSource(wallet) }));
|
|
25178
25238
|
}
|
|
25179
|
-
/*! Bundled license information:
|
|
25180
|
-
|
|
25181
|
-
@noble/hashes/utils.js:
|
|
25182
|
-
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
25183
|
-
*/
|
|
25184
25239
|
|
|
25185
25240
|
exports.ARKADE_MAGIC = ARKADE_MAGIC;
|
|
25186
25241
|
exports.ARKADE_SALTED_PREIMAGE_TAG = ARKADE_SALTED_PREIMAGE_TAG;
|
|
@@ -25410,5 +25465,5 @@ exports.waitForIncomingFunds = waitForIncomingFunds;
|
|
|
25410
25465
|
exports.walletFeeSource = walletFeeSource;
|
|
25411
25466
|
exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
|
|
25412
25467
|
exports.withPrevTxs = withPrevTxs;
|
|
25413
|
-
//# sourceMappingURL=chunk-
|
|
25414
|
-
//# sourceMappingURL=chunk-
|
|
25468
|
+
//# sourceMappingURL=chunk-HAM3SHBV.cjs.map
|
|
25469
|
+
//# sourceMappingURL=chunk-HAM3SHBV.cjs.map
|