@arkade-os/sdk 0.4.60 → 0.4.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/expo.cjs +5 -5
- package/dist/adapters/expo.d.cts +4 -4
- package/dist/adapters/expo.d.ts +4 -4
- package/dist/adapters/expo.js +3 -3
- package/dist/adapters/indexedDB.cjs +5 -5
- package/dist/adapters/indexedDB.js +4 -4
- package/dist/{asyncStorageTaskQueue-CqijAAPG.d.cts → asyncStorageTaskQueue-BWDxp3Dr.d.cts} +2 -2
- package/dist/{asyncStorageTaskQueue-Vsp6uk8e.d.ts → asyncStorageTaskQueue-Cq9FpKv6.d.ts} +2 -2
- package/dist/{chunk-PRFL62ID.cjs → chunk-2JHN5RCY.cjs} +17 -17
- package/dist/{chunk-PRFL62ID.cjs.map → chunk-2JHN5RCY.cjs.map} +1 -1
- package/dist/{chunk-KNS5MTTI.cjs → chunk-3NUDA3MB.cjs} +1045 -461
- package/dist/chunk-3NUDA3MB.cjs.map +1 -0
- package/dist/{chunk-2DINXHGQ.js → chunk-6O5OLYTZ.js} +66 -35
- package/dist/chunk-6O5OLYTZ.js.map +1 -0
- package/dist/{chunk-Y54MUBT7.js → chunk-AUEXB42T.js} +654 -84
- package/dist/chunk-AUEXB42T.js.map +1 -0
- package/dist/{chunk-4A4GRSTB.cjs → chunk-FNCQJLR2.cjs} +3 -3
- package/dist/{chunk-4A4GRSTB.cjs.map → chunk-FNCQJLR2.cjs.map} +1 -1
- package/dist/{chunk-3Q7BBUWO.js → chunk-GDI2A65Z.js} +4 -4
- package/dist/{chunk-3Q7BBUWO.js.map → chunk-GDI2A65Z.js.map} +1 -1
- package/dist/{chunk-JBULXTCC.js → chunk-PVY6DMN5.js} +3 -3
- package/dist/{chunk-JBULXTCC.js.map → chunk-PVY6DMN5.js.map} +1 -1
- package/dist/{chunk-MZNLCMUP.cjs → chunk-SF5NKAUA.cjs} +113 -79
- package/dist/chunk-SF5NKAUA.cjs.map +1 -0
- package/dist/{chunk-H7JCHFM6.cjs → chunk-XFYFREPH.cjs} +17 -17
- package/dist/{chunk-H7JCHFM6.cjs.map → chunk-XFYFREPH.cjs.map} +1 -1
- package/dist/{chunk-B66RYHTB.js → chunk-XLHN5L2O.js} +4 -4
- package/dist/{chunk-B66RYHTB.js.map → chunk-XLHN5L2O.js.map} +1 -1
- package/dist/{chunk-2XLNQHG4.cjs → chunk-XMRB74HA.cjs} +10 -10
- package/dist/{chunk-2XLNQHG4.cjs.map → chunk-XMRB74HA.cjs.map} +1 -1
- package/dist/{chunk-FSKANUV4.js → chunk-YVQNHELA.js} +3 -3
- package/dist/{chunk-FSKANUV4.js.map → chunk-YVQNHELA.js.map} +1 -1
- package/dist/contracts/handlers/index.cjs +9 -9
- package/dist/contracts/handlers/index.d.cts +5 -5
- package/dist/contracts/handlers/index.d.ts +5 -5
- package/dist/contracts/handlers/index.js +2 -2
- package/dist/{delegate-DNEuM_nK.d.cts → delegate-BySzD37I.d.ts} +1 -1
- package/dist/{delegate-DidNTsKm.d.ts → delegate-C4Rl6h9l.d.cts} +1 -1
- package/dist/{ark-D2_yNhfz.d.cts → index-BcRCHnzN.d.cts} +4846 -4776
- package/dist/{ark-D2_yNhfz.d.ts → index-BcRCHnzN.d.ts} +4846 -4776
- package/dist/{index-DzQbNQUG.d.ts → index-Butfkm-K.d.cts} +102 -102
- package/dist/{index-BP8-zniX.d.cts → index-C29VNcxC.d.ts} +102 -102
- package/dist/index.cjs +320 -248
- package/dist/index.d.cts +256 -54
- package/dist/index.d.ts +256 -54
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +19 -19
- package/dist/repositories/realm/index.d.cts +4 -4
- package/dist/repositories/realm/index.d.ts +4 -4
- package/dist/repositories/realm/index.js +5 -5
- package/dist/repositories/sqlite/index.cjs +18 -18
- package/dist/repositories/sqlite/index.d.cts +4 -4
- package/dist/repositories/sqlite/index.d.ts +4 -4
- package/dist/repositories/sqlite/index.js +5 -5
- package/dist/{taskRunner-9gnlYEpb.d.ts → taskRunner-BTq3rMpI.d.cts} +2 -2
- package/dist/{taskRunner-BEQNFEa4.d.cts → taskRunner-DxMJYJ7Y.d.ts} +2 -2
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.d.cts +5 -5
- package/dist/wallet/expo/background.d.ts +5 -5
- package/dist/wallet/expo/background.js +6 -6
- package/dist/wallet/expo/index.cjs +34 -14
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +12 -5
- package/dist/wallet/expo/index.d.ts +12 -5
- package/dist/wallet/expo/index.js +25 -5
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/{wallet-ipUA1XCp.d.cts → wallet-BVIfg2ic.d.ts} +79 -14
- package/dist/{wallet-C_MYHyOj.d.ts → wallet-DrSsUden.d.cts} +79 -14
- package/dist/worker/expo/index.cjs +9 -9
- package/dist/worker/expo/index.d.cts +6 -6
- package/dist/worker/expo/index.d.ts +6 -6
- package/dist/worker/expo/index.js +5 -5
- package/package.json +1 -1
- package/dist/chunk-2DINXHGQ.js.map +0 -1
- package/dist/chunk-KNS5MTTI.cjs.map +0 -1
- package/dist/chunk-MZNLCMUP.cjs.map +0 -1
- package/dist/chunk-Y54MUBT7.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunk2JHN5RCY_cjs = require('./chunk-2JHN5RCY.cjs');
|
|
4
|
+
var chunkSF5NKAUA_cjs = require('./chunk-SF5NKAUA.cjs');
|
|
5
|
+
var chunkFNCQJLR2_cjs = require('./chunk-FNCQJLR2.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 = chunkFNCQJLR2_cjs.getArkPsbtFields(tx.root, 0, chunkFNCQJLR2_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 = chunkFNCQJLR2_cjs.getArkPsbtFields(g.root, 0, chunkFNCQJLR2_cjs.CosignerPublicKey).map((c) => c.key);
|
|
244
244
|
const { finalKey } = aggregateKeys(cosigners, true, {
|
|
245
245
|
taprootTweak: this.scriptRoot
|
|
246
246
|
});
|
|
@@ -419,7 +419,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
419
419
|
let network;
|
|
420
420
|
if ("descriptor" in opts && typeof opts.descriptor === "string") {
|
|
421
421
|
descriptor = opts.descriptor;
|
|
422
|
-
network =
|
|
422
|
+
network = chunkSF5NKAUA_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
423
423
|
} else {
|
|
424
424
|
network = opts.isMainnet ?? true ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
425
425
|
descriptor = descriptorsScure.scriptExpressions.trBIP32({
|
|
@@ -504,7 +504,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
504
504
|
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
505
505
|
*/
|
|
506
506
|
isOurs(descriptor) {
|
|
507
|
-
return
|
|
507
|
+
return chunkSF5NKAUA_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
|
|
508
508
|
}
|
|
509
509
|
/**
|
|
510
510
|
* Signs each request with the key derived from its descriptor.
|
|
@@ -553,7 +553,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
553
553
|
}
|
|
554
554
|
// ── internal helpers ─────────────────────────────────────────────
|
|
555
555
|
derivePrivateKeyForDescriptor(descriptor) {
|
|
556
|
-
const network =
|
|
556
|
+
const network = chunkSF5NKAUA_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
557
557
|
const expansion = descriptorsScure.expand({ descriptor, network });
|
|
558
558
|
if (expansion.isRanged) {
|
|
559
559
|
throw new Error(
|
|
@@ -639,7 +639,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
639
639
|
*/
|
|
640
640
|
descriptor;
|
|
641
641
|
constructor(descriptor) {
|
|
642
|
-
const network =
|
|
642
|
+
const network = chunkSF5NKAUA_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
643
643
|
let expansion;
|
|
644
644
|
try {
|
|
645
645
|
expansion = descriptorsScure.expand({ descriptor, network, index: 0 });
|
|
@@ -689,7 +689,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
689
689
|
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
690
690
|
*/
|
|
691
691
|
isOurs(descriptor) {
|
|
692
|
-
return
|
|
692
|
+
return chunkSF5NKAUA_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
|
|
693
693
|
}
|
|
694
694
|
};
|
|
695
695
|
function serializeSeedOwnedSigningIdentity(identity) {
|
|
@@ -851,10 +851,10 @@ var DescriptorIdentity = class {
|
|
|
851
851
|
this.base = base;
|
|
852
852
|
}
|
|
853
853
|
async xOnlyPublicKey() {
|
|
854
|
-
return
|
|
854
|
+
return chunkSF5NKAUA_cjs.deriveDescriptorLeafPubKey(this.descriptor);
|
|
855
855
|
}
|
|
856
856
|
async compressedPublicKey() {
|
|
857
|
-
return
|
|
857
|
+
return chunkSF5NKAUA_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
|
|
858
858
|
}
|
|
859
859
|
async sign(tx, inputIndexes) {
|
|
860
860
|
const [signed] = await this.signer.signWithDescriptor([
|
|
@@ -901,8 +901,33 @@ function isHDCapableIdentity(value) {
|
|
|
901
901
|
function isBatchSignable(identity) {
|
|
902
902
|
return "signMultiple" in identity && typeof identity.signMultiple === "function";
|
|
903
903
|
}
|
|
904
|
-
|
|
905
|
-
|
|
904
|
+
function isSigningIdentity(value) {
|
|
905
|
+
if (typeof value !== "object" || value === null) return false;
|
|
906
|
+
const v = value;
|
|
907
|
+
return typeof v.sign === "function" && typeof v.signMessage === "function" && typeof v.signerSession === "function" && typeof v.xOnlyPublicKey === "function";
|
|
908
|
+
}
|
|
909
|
+
var ForeignDescriptorError = class extends Error {
|
|
910
|
+
constructor(descriptor, options) {
|
|
911
|
+
super(`this wallet holds no key for descriptor: ${descriptor}`, options);
|
|
912
|
+
this.descriptor = descriptor;
|
|
913
|
+
}
|
|
914
|
+
descriptor;
|
|
915
|
+
name = "ForeignDescriptorError";
|
|
916
|
+
};
|
|
917
|
+
async function resolveDescriptorSigner(descriptor, identity, provider) {
|
|
918
|
+
const owner = provider?.isOurs(descriptor) ? provider : isHDCapableIdentity(identity) && identity.isOurs(descriptor) ? identity : void 0;
|
|
919
|
+
if (owner && chunkSF5NKAUA_cjs.parseHDDescriptor(descriptor)) {
|
|
920
|
+
return new DescriptorIdentity({ descriptor, signer: owner, base: identity });
|
|
921
|
+
}
|
|
922
|
+
let key;
|
|
923
|
+
try {
|
|
924
|
+
key = chunkSF5NKAUA_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
925
|
+
} catch {
|
|
926
|
+
throw new ForeignDescriptorError(descriptor);
|
|
927
|
+
}
|
|
928
|
+
if (utils_js.equalBytes(await identity.xOnlyPublicKey(), key)) return identity;
|
|
929
|
+
throw new ForeignDescriptorError(descriptor);
|
|
930
|
+
}
|
|
906
931
|
function isHDWalletCapable(value) {
|
|
907
932
|
if (typeof value !== "object" || value === null) return false;
|
|
908
933
|
const v = value;
|
|
@@ -914,6 +939,441 @@ function isHDAllocationCapable(value) {
|
|
|
914
939
|
return typeof v.getNextSigningDescriptor === "function" && typeof v.advanceSigningDescriptorWatermark === "function";
|
|
915
940
|
}
|
|
916
941
|
|
|
942
|
+
// ../../node_modules/@noble/hashes/utils.js
|
|
943
|
+
function isBytes(a) {
|
|
944
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
945
|
+
}
|
|
946
|
+
function abytes(value, length, title = "") {
|
|
947
|
+
const bytes = isBytes(value);
|
|
948
|
+
const len = value?.length;
|
|
949
|
+
const needsLen = length !== void 0;
|
|
950
|
+
if (!bytes || needsLen) {
|
|
951
|
+
const prefix = title && `"${title}" `;
|
|
952
|
+
const ofLen = "";
|
|
953
|
+
const got = bytes ? `length=${len}` : `type=${typeof value}`;
|
|
954
|
+
throw new Error(prefix + "expected Uint8Array" + ofLen + ", got " + got);
|
|
955
|
+
}
|
|
956
|
+
return value;
|
|
957
|
+
}
|
|
958
|
+
function aexists(instance, checkFinished = true) {
|
|
959
|
+
if (instance.destroyed)
|
|
960
|
+
throw new Error("Hash instance has been destroyed");
|
|
961
|
+
if (checkFinished && instance.finished)
|
|
962
|
+
throw new Error("Hash#digest() has already been called");
|
|
963
|
+
}
|
|
964
|
+
function aoutput(out, instance) {
|
|
965
|
+
abytes(out, void 0, "digestInto() output");
|
|
966
|
+
const min = instance.outputLen;
|
|
967
|
+
if (out.length < min) {
|
|
968
|
+
throw new Error('"digestInto() output" expected to be of length >=' + min);
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
function clean(...arrays) {
|
|
972
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
973
|
+
arrays[i].fill(0);
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
function createView(arr) {
|
|
977
|
+
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
978
|
+
}
|
|
979
|
+
function rotr(word, shift) {
|
|
980
|
+
return word << 32 - shift | word >>> shift;
|
|
981
|
+
}
|
|
982
|
+
function createHasher(hashCons, info = {}) {
|
|
983
|
+
const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
|
|
984
|
+
const tmp = hashCons(void 0);
|
|
985
|
+
hashC.outputLen = tmp.outputLen;
|
|
986
|
+
hashC.blockLen = tmp.blockLen;
|
|
987
|
+
hashC.create = (opts) => hashCons(opts);
|
|
988
|
+
Object.assign(hashC, info);
|
|
989
|
+
return Object.freeze(hashC);
|
|
990
|
+
}
|
|
991
|
+
function randomBytes(bytesLength = 32) {
|
|
992
|
+
const cr = typeof globalThis === "object" ? globalThis.crypto : null;
|
|
993
|
+
if (typeof cr?.getRandomValues !== "function")
|
|
994
|
+
throw new Error("crypto.getRandomValues must be defined");
|
|
995
|
+
return cr.getRandomValues(new Uint8Array(bytesLength));
|
|
996
|
+
}
|
|
997
|
+
var oidNist = (suffix) => ({
|
|
998
|
+
oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
|
|
999
|
+
});
|
|
1000
|
+
|
|
1001
|
+
// ../../node_modules/@noble/hashes/_md.js
|
|
1002
|
+
function Chi(a, b, c) {
|
|
1003
|
+
return a & b ^ ~a & c;
|
|
1004
|
+
}
|
|
1005
|
+
function Maj(a, b, c) {
|
|
1006
|
+
return a & b ^ a & c ^ b & c;
|
|
1007
|
+
}
|
|
1008
|
+
var HashMD = class {
|
|
1009
|
+
blockLen;
|
|
1010
|
+
outputLen;
|
|
1011
|
+
padOffset;
|
|
1012
|
+
isLE;
|
|
1013
|
+
// For partial updates less than block size
|
|
1014
|
+
buffer;
|
|
1015
|
+
view;
|
|
1016
|
+
finished = false;
|
|
1017
|
+
length = 0;
|
|
1018
|
+
pos = 0;
|
|
1019
|
+
destroyed = false;
|
|
1020
|
+
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
1021
|
+
this.blockLen = blockLen;
|
|
1022
|
+
this.outputLen = outputLen;
|
|
1023
|
+
this.padOffset = padOffset;
|
|
1024
|
+
this.isLE = isLE;
|
|
1025
|
+
this.buffer = new Uint8Array(blockLen);
|
|
1026
|
+
this.view = createView(this.buffer);
|
|
1027
|
+
}
|
|
1028
|
+
update(data) {
|
|
1029
|
+
aexists(this);
|
|
1030
|
+
abytes(data);
|
|
1031
|
+
const { view, buffer, blockLen } = this;
|
|
1032
|
+
const len = data.length;
|
|
1033
|
+
for (let pos = 0; pos < len; ) {
|
|
1034
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
1035
|
+
if (take === blockLen) {
|
|
1036
|
+
const dataView = createView(data);
|
|
1037
|
+
for (; blockLen <= len - pos; pos += blockLen)
|
|
1038
|
+
this.process(dataView, pos);
|
|
1039
|
+
continue;
|
|
1040
|
+
}
|
|
1041
|
+
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
1042
|
+
this.pos += take;
|
|
1043
|
+
pos += take;
|
|
1044
|
+
if (this.pos === blockLen) {
|
|
1045
|
+
this.process(view, 0);
|
|
1046
|
+
this.pos = 0;
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
this.length += data.length;
|
|
1050
|
+
this.roundClean();
|
|
1051
|
+
return this;
|
|
1052
|
+
}
|
|
1053
|
+
digestInto(out) {
|
|
1054
|
+
aexists(this);
|
|
1055
|
+
aoutput(out, this);
|
|
1056
|
+
this.finished = true;
|
|
1057
|
+
const { buffer, view, blockLen, isLE } = this;
|
|
1058
|
+
let { pos } = this;
|
|
1059
|
+
buffer[pos++] = 128;
|
|
1060
|
+
clean(this.buffer.subarray(pos));
|
|
1061
|
+
if (this.padOffset > blockLen - pos) {
|
|
1062
|
+
this.process(view, 0);
|
|
1063
|
+
pos = 0;
|
|
1064
|
+
}
|
|
1065
|
+
for (let i = pos; i < blockLen; i++)
|
|
1066
|
+
buffer[i] = 0;
|
|
1067
|
+
view.setBigUint64(blockLen - 8, BigInt(this.length * 8), isLE);
|
|
1068
|
+
this.process(view, 0);
|
|
1069
|
+
const oview = createView(out);
|
|
1070
|
+
const len = this.outputLen;
|
|
1071
|
+
if (len % 4)
|
|
1072
|
+
throw new Error("_sha2: outputLen must be aligned to 32bit");
|
|
1073
|
+
const outLen = len / 4;
|
|
1074
|
+
const state = this.get();
|
|
1075
|
+
if (outLen > state.length)
|
|
1076
|
+
throw new Error("_sha2: outputLen bigger than state");
|
|
1077
|
+
for (let i = 0; i < outLen; i++)
|
|
1078
|
+
oview.setUint32(4 * i, state[i], isLE);
|
|
1079
|
+
}
|
|
1080
|
+
digest() {
|
|
1081
|
+
const { buffer, outputLen } = this;
|
|
1082
|
+
this.digestInto(buffer);
|
|
1083
|
+
const res = buffer.slice(0, outputLen);
|
|
1084
|
+
this.destroy();
|
|
1085
|
+
return res;
|
|
1086
|
+
}
|
|
1087
|
+
_cloneInto(to) {
|
|
1088
|
+
to ||= new this.constructor();
|
|
1089
|
+
to.set(...this.get());
|
|
1090
|
+
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
1091
|
+
to.destroyed = destroyed;
|
|
1092
|
+
to.finished = finished;
|
|
1093
|
+
to.length = length;
|
|
1094
|
+
to.pos = pos;
|
|
1095
|
+
if (length % blockLen)
|
|
1096
|
+
to.buffer.set(buffer);
|
|
1097
|
+
return to;
|
|
1098
|
+
}
|
|
1099
|
+
clone() {
|
|
1100
|
+
return this._cloneInto();
|
|
1101
|
+
}
|
|
1102
|
+
};
|
|
1103
|
+
var SHA256_IV = /* @__PURE__ */ Uint32Array.from([
|
|
1104
|
+
1779033703,
|
|
1105
|
+
3144134277,
|
|
1106
|
+
1013904242,
|
|
1107
|
+
2773480762,
|
|
1108
|
+
1359893119,
|
|
1109
|
+
2600822924,
|
|
1110
|
+
528734635,
|
|
1111
|
+
1541459225
|
|
1112
|
+
]);
|
|
1113
|
+
|
|
1114
|
+
// ../../node_modules/@noble/hashes/sha2.js
|
|
1115
|
+
var SHA256_K = /* @__PURE__ */ Uint32Array.from([
|
|
1116
|
+
1116352408,
|
|
1117
|
+
1899447441,
|
|
1118
|
+
3049323471,
|
|
1119
|
+
3921009573,
|
|
1120
|
+
961987163,
|
|
1121
|
+
1508970993,
|
|
1122
|
+
2453635748,
|
|
1123
|
+
2870763221,
|
|
1124
|
+
3624381080,
|
|
1125
|
+
310598401,
|
|
1126
|
+
607225278,
|
|
1127
|
+
1426881987,
|
|
1128
|
+
1925078388,
|
|
1129
|
+
2162078206,
|
|
1130
|
+
2614888103,
|
|
1131
|
+
3248222580,
|
|
1132
|
+
3835390401,
|
|
1133
|
+
4022224774,
|
|
1134
|
+
264347078,
|
|
1135
|
+
604807628,
|
|
1136
|
+
770255983,
|
|
1137
|
+
1249150122,
|
|
1138
|
+
1555081692,
|
|
1139
|
+
1996064986,
|
|
1140
|
+
2554220882,
|
|
1141
|
+
2821834349,
|
|
1142
|
+
2952996808,
|
|
1143
|
+
3210313671,
|
|
1144
|
+
3336571891,
|
|
1145
|
+
3584528711,
|
|
1146
|
+
113926993,
|
|
1147
|
+
338241895,
|
|
1148
|
+
666307205,
|
|
1149
|
+
773529912,
|
|
1150
|
+
1294757372,
|
|
1151
|
+
1396182291,
|
|
1152
|
+
1695183700,
|
|
1153
|
+
1986661051,
|
|
1154
|
+
2177026350,
|
|
1155
|
+
2456956037,
|
|
1156
|
+
2730485921,
|
|
1157
|
+
2820302411,
|
|
1158
|
+
3259730800,
|
|
1159
|
+
3345764771,
|
|
1160
|
+
3516065817,
|
|
1161
|
+
3600352804,
|
|
1162
|
+
4094571909,
|
|
1163
|
+
275423344,
|
|
1164
|
+
430227734,
|
|
1165
|
+
506948616,
|
|
1166
|
+
659060556,
|
|
1167
|
+
883997877,
|
|
1168
|
+
958139571,
|
|
1169
|
+
1322822218,
|
|
1170
|
+
1537002063,
|
|
1171
|
+
1747873779,
|
|
1172
|
+
1955562222,
|
|
1173
|
+
2024104815,
|
|
1174
|
+
2227730452,
|
|
1175
|
+
2361852424,
|
|
1176
|
+
2428436474,
|
|
1177
|
+
2756734187,
|
|
1178
|
+
3204031479,
|
|
1179
|
+
3329325298
|
|
1180
|
+
]);
|
|
1181
|
+
var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
1182
|
+
var SHA2_32B = class extends HashMD {
|
|
1183
|
+
constructor(outputLen) {
|
|
1184
|
+
super(64, outputLen, 8, false);
|
|
1185
|
+
}
|
|
1186
|
+
get() {
|
|
1187
|
+
const { A, B, C, D, E, F, G, H } = this;
|
|
1188
|
+
return [A, B, C, D, E, F, G, H];
|
|
1189
|
+
}
|
|
1190
|
+
// prettier-ignore
|
|
1191
|
+
set(A, B, C, D, E, F, G, H) {
|
|
1192
|
+
this.A = A | 0;
|
|
1193
|
+
this.B = B | 0;
|
|
1194
|
+
this.C = C | 0;
|
|
1195
|
+
this.D = D | 0;
|
|
1196
|
+
this.E = E | 0;
|
|
1197
|
+
this.F = F | 0;
|
|
1198
|
+
this.G = G | 0;
|
|
1199
|
+
this.H = H | 0;
|
|
1200
|
+
}
|
|
1201
|
+
process(view, offset) {
|
|
1202
|
+
for (let i = 0; i < 16; i++, offset += 4)
|
|
1203
|
+
SHA256_W[i] = view.getUint32(offset, false);
|
|
1204
|
+
for (let i = 16; i < 64; i++) {
|
|
1205
|
+
const W15 = SHA256_W[i - 15];
|
|
1206
|
+
const W2 = SHA256_W[i - 2];
|
|
1207
|
+
const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
|
|
1208
|
+
const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10;
|
|
1209
|
+
SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
|
|
1210
|
+
}
|
|
1211
|
+
let { A, B, C, D, E, F, G, H } = this;
|
|
1212
|
+
for (let i = 0; i < 64; i++) {
|
|
1213
|
+
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
|
1214
|
+
const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
|
|
1215
|
+
const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
|
|
1216
|
+
const T2 = sigma0 + Maj(A, B, C) | 0;
|
|
1217
|
+
H = G;
|
|
1218
|
+
G = F;
|
|
1219
|
+
F = E;
|
|
1220
|
+
E = D + T1 | 0;
|
|
1221
|
+
D = C;
|
|
1222
|
+
C = B;
|
|
1223
|
+
B = A;
|
|
1224
|
+
A = T1 + T2 | 0;
|
|
1225
|
+
}
|
|
1226
|
+
A = A + this.A | 0;
|
|
1227
|
+
B = B + this.B | 0;
|
|
1228
|
+
C = C + this.C | 0;
|
|
1229
|
+
D = D + this.D | 0;
|
|
1230
|
+
E = E + this.E | 0;
|
|
1231
|
+
F = F + this.F | 0;
|
|
1232
|
+
G = G + this.G | 0;
|
|
1233
|
+
H = H + this.H | 0;
|
|
1234
|
+
this.set(A, B, C, D, E, F, G, H);
|
|
1235
|
+
}
|
|
1236
|
+
roundClean() {
|
|
1237
|
+
clean(SHA256_W);
|
|
1238
|
+
}
|
|
1239
|
+
destroy() {
|
|
1240
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
1241
|
+
clean(this.buffer);
|
|
1242
|
+
}
|
|
1243
|
+
};
|
|
1244
|
+
var _SHA256 = class extends SHA2_32B {
|
|
1245
|
+
// We cannot use array here since array allows indexing by variable
|
|
1246
|
+
// which means optimizer/compiler cannot use registers.
|
|
1247
|
+
A = SHA256_IV[0] | 0;
|
|
1248
|
+
B = SHA256_IV[1] | 0;
|
|
1249
|
+
C = SHA256_IV[2] | 0;
|
|
1250
|
+
D = SHA256_IV[3] | 0;
|
|
1251
|
+
E = SHA256_IV[4] | 0;
|
|
1252
|
+
F = SHA256_IV[5] | 0;
|
|
1253
|
+
G = SHA256_IV[6] | 0;
|
|
1254
|
+
H = SHA256_IV[7] | 0;
|
|
1255
|
+
constructor() {
|
|
1256
|
+
super(32);
|
|
1257
|
+
}
|
|
1258
|
+
};
|
|
1259
|
+
var sha256 = /* @__PURE__ */ createHasher(
|
|
1260
|
+
() => new _SHA256(),
|
|
1261
|
+
/* @__PURE__ */ oidNist(1)
|
|
1262
|
+
);
|
|
1263
|
+
var ARKADE_SWAP_PREIMAGE_TAG = "Arkade-RFQ-Preimage-v1";
|
|
1264
|
+
function buildPreimageMessage(xonly, index) {
|
|
1265
|
+
if (xonly.length !== 32) {
|
|
1266
|
+
throw new Error(`x-only pubkey must be 32 bytes, got ${xonly.length}`);
|
|
1267
|
+
}
|
|
1268
|
+
if (!Number.isInteger(index) || index < 0 || index > 4294967295) {
|
|
1269
|
+
throw new Error(`index must be a u32, got ${index}`);
|
|
1270
|
+
}
|
|
1271
|
+
const tag = new TextEncoder().encode(ARKADE_SWAP_PREIMAGE_TAG);
|
|
1272
|
+
const message = new Uint8Array(tag.length + 32 + 4);
|
|
1273
|
+
message.set(tag, 0);
|
|
1274
|
+
message.set(xonly, tag.length);
|
|
1275
|
+
new DataView(message.buffer).setUint32(tag.length + 32, index, true);
|
|
1276
|
+
return message;
|
|
1277
|
+
}
|
|
1278
|
+
var PREIMAGE_INDEX = 0;
|
|
1279
|
+
function isPerArtifactDescriptor(descriptor) {
|
|
1280
|
+
return chunkSF5NKAUA_cjs.parseHDDescriptor(descriptor) !== null;
|
|
1281
|
+
}
|
|
1282
|
+
async function provisionDescriptor(wallet) {
|
|
1283
|
+
const allocated = isHDAllocationCapable(wallet) ? await wallet.getNextSigningDescriptor() : void 0;
|
|
1284
|
+
return allocated ?? await chunkSF5NKAUA_cjs.identityDescriptor(wallet.identity);
|
|
1285
|
+
}
|
|
1286
|
+
async function provisionRefundKey(wallet) {
|
|
1287
|
+
const descriptor = await provisionDescriptor(wallet);
|
|
1288
|
+
const signer = await contractSigner(wallet, descriptor);
|
|
1289
|
+
return { descriptor, pubkey: await signer.xOnlyPublicKey() };
|
|
1290
|
+
}
|
|
1291
|
+
async function provisionClaimSecret(wallet, opts = {}) {
|
|
1292
|
+
if (opts.preimage && opts.preimage.length !== 32) {
|
|
1293
|
+
throw new Error(`preimage must be 32 bytes, got ${opts.preimage.length}`);
|
|
1294
|
+
}
|
|
1295
|
+
const { descriptor, pubkey } = await provisionRefundKey(wallet);
|
|
1296
|
+
const derivable = !opts.preimage && isPerArtifactDescriptor(descriptor);
|
|
1297
|
+
const preimage = opts.preimage ?? (derivable ? await derivePreimage(wallet, descriptor) : randomBytes(32));
|
|
1298
|
+
return {
|
|
1299
|
+
descriptor,
|
|
1300
|
+
pubkey,
|
|
1301
|
+
preimage,
|
|
1302
|
+
paymentHash: sha256(preimage),
|
|
1303
|
+
mustPersistPreimage: !derivable
|
|
1304
|
+
};
|
|
1305
|
+
}
|
|
1306
|
+
async function contractSigner(wallet, descriptor) {
|
|
1307
|
+
const signer = isHDWalletCapable(wallet) ? await wallet.signerForDescriptor(descriptor) : wallet.identity;
|
|
1308
|
+
let expected;
|
|
1309
|
+
try {
|
|
1310
|
+
expected = chunkSF5NKAUA_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
1311
|
+
} catch (cause) {
|
|
1312
|
+
throw new ForeignDescriptorError(descriptor, { cause });
|
|
1313
|
+
}
|
|
1314
|
+
const actual = await signer.xOnlyPublicKey();
|
|
1315
|
+
if (!utils_js.equalBytes(actual, expected)) throw new ForeignDescriptorError(descriptor);
|
|
1316
|
+
if (!isSigningIdentity(signer)) throw new WalletCannotSignError(descriptor);
|
|
1317
|
+
return signer;
|
|
1318
|
+
}
|
|
1319
|
+
var WalletCannotSignError = class extends Error {
|
|
1320
|
+
constructor(descriptor) {
|
|
1321
|
+
super(`this wallet holds the key for ${descriptor} but cannot sign with it`);
|
|
1322
|
+
this.descriptor = descriptor;
|
|
1323
|
+
}
|
|
1324
|
+
descriptor;
|
|
1325
|
+
name = "WalletCannotSignError";
|
|
1326
|
+
};
|
|
1327
|
+
async function contractPreimage(wallet, descriptor, stored) {
|
|
1328
|
+
if (stored) {
|
|
1329
|
+
if (stored.length !== 32) {
|
|
1330
|
+
throw new Error(`stored preimage must be 32 bytes, got ${stored.length}`);
|
|
1331
|
+
}
|
|
1332
|
+
return stored;
|
|
1333
|
+
}
|
|
1334
|
+
if (!isPerArtifactDescriptor(descriptor)) {
|
|
1335
|
+
throw new Error(
|
|
1336
|
+
`descriptor ${descriptor} names no single artifact, so its preimage cannot be derived; none was stored`
|
|
1337
|
+
);
|
|
1338
|
+
}
|
|
1339
|
+
return derivePreimage(wallet, descriptor);
|
|
1340
|
+
}
|
|
1341
|
+
function isDeterministicSigner(value) {
|
|
1342
|
+
if (typeof value !== "object" || value === null) return false;
|
|
1343
|
+
const v = value;
|
|
1344
|
+
return typeof v.signSchnorrDeterministic === "function" && typeof v.xOnlyPublicKey === "function";
|
|
1345
|
+
}
|
|
1346
|
+
async function derivePreimage(wallet, descriptor) {
|
|
1347
|
+
const signer = await contractSigner(wallet, descriptor);
|
|
1348
|
+
if (!isDeterministicSigner(signer)) {
|
|
1349
|
+
throw new Error(
|
|
1350
|
+
`wallet cannot sign deterministically for ${descriptor}; its preimage is not derivable`
|
|
1351
|
+
);
|
|
1352
|
+
}
|
|
1353
|
+
const message = buildPreimageMessage(await signer.xOnlyPublicKey(), PREIMAGE_INDEX);
|
|
1354
|
+
try {
|
|
1355
|
+
return sha256(await signer.signSchnorrDeterministic(sha256(message)));
|
|
1356
|
+
} catch (cause) {
|
|
1357
|
+
throw new Error(
|
|
1358
|
+
`wallet cannot sign deterministically for ${descriptor}; its preimage is not derivable`,
|
|
1359
|
+
{ cause }
|
|
1360
|
+
);
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
async function adoptContractDescriptor(wallet, descriptor) {
|
|
1364
|
+
if (!isHDAllocationCapable(wallet)) return;
|
|
1365
|
+
if (!isPerArtifactDescriptor(descriptor)) return;
|
|
1366
|
+
if (isHDWalletCapable(wallet)) {
|
|
1367
|
+
try {
|
|
1368
|
+
await wallet.signerForDescriptor(descriptor);
|
|
1369
|
+
} catch (error) {
|
|
1370
|
+
if (error instanceof ForeignDescriptorError) return;
|
|
1371
|
+
throw error;
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
await wallet.advanceSigningDescriptorWatermark(descriptor);
|
|
1375
|
+
}
|
|
1376
|
+
|
|
917
1377
|
// src/worker/browser/service-worker-manager.ts
|
|
918
1378
|
var registrations = /* @__PURE__ */ new Map();
|
|
919
1379
|
var handshakes = /* @__PURE__ */ new WeakSet();
|
|
@@ -1066,14 +1526,14 @@ var RestDelegateProvider = class {
|
|
|
1066
1526
|
*/
|
|
1067
1527
|
async delegate(intent, forfeitTxs, options) {
|
|
1068
1528
|
const url = `${this.url}/v1/delegate`;
|
|
1069
|
-
const response = await
|
|
1529
|
+
const response = await chunkFNCQJLR2_cjs.baseFetch(url, {
|
|
1070
1530
|
method: "POST",
|
|
1071
1531
|
headers: {
|
|
1072
1532
|
"Content-Type": "application/json"
|
|
1073
1533
|
},
|
|
1074
1534
|
body: JSON.stringify({
|
|
1075
1535
|
intent: {
|
|
1076
|
-
message:
|
|
1536
|
+
message: chunkFNCQJLR2_cjs.Intent.encodeMessage(intent.message),
|
|
1077
1537
|
proof: intent.proof
|
|
1078
1538
|
},
|
|
1079
1539
|
forfeit_txs: forfeitTxs,
|
|
@@ -1093,7 +1553,7 @@ var RestDelegateProvider = class {
|
|
|
1093
1553
|
*/
|
|
1094
1554
|
async getDelegateInfo() {
|
|
1095
1555
|
const url = `${this.url}/v1/delegator/info`;
|
|
1096
|
-
const response = await
|
|
1556
|
+
const response = await chunkFNCQJLR2_cjs.rateGate.runHttp(url, () => chunkFNCQJLR2_cjs.baseFetch(url));
|
|
1097
1557
|
if (!response.ok) {
|
|
1098
1558
|
const errorText2 = await response.text();
|
|
1099
1559
|
throw new Error(`Failed to get delegate info: ${errorText2}`);
|
|
@@ -1120,7 +1580,7 @@ var ESPLORA_URL = {
|
|
|
1120
1580
|
regtest: "http://localhost:3000/api"
|
|
1121
1581
|
};
|
|
1122
1582
|
var EsploraProvider = class {
|
|
1123
|
-
constructor(baseUrl = ESPLORA_URL[
|
|
1583
|
+
constructor(baseUrl = ESPLORA_URL[chunkFNCQJLR2_cjs.DEFAULT_NETWORK_NAME], opts) {
|
|
1124
1584
|
this.baseUrl = baseUrl;
|
|
1125
1585
|
this.pollingInterval = opts?.pollingInterval ?? 15e3;
|
|
1126
1586
|
this.forcePolling = opts?.forcePolling ?? false;
|
|
@@ -1129,14 +1589,14 @@ var EsploraProvider = class {
|
|
|
1129
1589
|
pollingInterval;
|
|
1130
1590
|
forcePolling;
|
|
1131
1591
|
async getCoins(address) {
|
|
1132
|
-
const response = await
|
|
1592
|
+
const response = await chunkFNCQJLR2_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
|
|
1133
1593
|
if (!response.ok) {
|
|
1134
1594
|
throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
|
|
1135
1595
|
}
|
|
1136
1596
|
return response.json();
|
|
1137
1597
|
}
|
|
1138
1598
|
async getFeeRate() {
|
|
1139
|
-
const response = await
|
|
1599
|
+
const response = await chunkFNCQJLR2_cjs.baseFetch(`${this.baseUrl}/fee-estimates`);
|
|
1140
1600
|
if (response.status === 404) {
|
|
1141
1601
|
return void 0;
|
|
1142
1602
|
}
|
|
@@ -1157,7 +1617,7 @@ var EsploraProvider = class {
|
|
|
1157
1617
|
}
|
|
1158
1618
|
}
|
|
1159
1619
|
async getTxOutspends(txid) {
|
|
1160
|
-
const response = await
|
|
1620
|
+
const response = await chunkFNCQJLR2_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
|
|
1161
1621
|
if (!response.ok) {
|
|
1162
1622
|
const error = await response.text();
|
|
1163
1623
|
throw new Error(`Failed to get transaction outspends: ${error}`);
|
|
@@ -1165,7 +1625,7 @@ var EsploraProvider = class {
|
|
|
1165
1625
|
return response.json();
|
|
1166
1626
|
}
|
|
1167
1627
|
async getTransactions(address) {
|
|
1168
|
-
const response = await
|
|
1628
|
+
const response = await chunkFNCQJLR2_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
|
|
1169
1629
|
if (!response.ok) {
|
|
1170
1630
|
const error = await response.text();
|
|
1171
1631
|
throw new Error(`Failed to get transactions: ${error}`);
|
|
@@ -1173,7 +1633,7 @@ var EsploraProvider = class {
|
|
|
1173
1633
|
return response.json();
|
|
1174
1634
|
}
|
|
1175
1635
|
async getTxStatus(txid) {
|
|
1176
|
-
const txresponse = await
|
|
1636
|
+
const txresponse = await chunkFNCQJLR2_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
|
|
1177
1637
|
if (!txresponse.ok) {
|
|
1178
1638
|
throw new Error(txresponse.statusText);
|
|
1179
1639
|
}
|
|
@@ -1181,7 +1641,7 @@ var EsploraProvider = class {
|
|
|
1181
1641
|
if (!tx.status.confirmed) {
|
|
1182
1642
|
return { confirmed: false };
|
|
1183
1643
|
}
|
|
1184
|
-
const response = await
|
|
1644
|
+
const response = await chunkFNCQJLR2_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
|
|
1185
1645
|
if (!response.ok) {
|
|
1186
1646
|
throw new Error(`Failed to get transaction status: ${response.statusText}`);
|
|
1187
1647
|
}
|
|
@@ -1265,7 +1725,7 @@ var EsploraProvider = class {
|
|
|
1265
1725
|
return stopFunc;
|
|
1266
1726
|
}
|
|
1267
1727
|
async getChainTip() {
|
|
1268
|
-
const tipBlocks = await
|
|
1728
|
+
const tipBlocks = await chunkFNCQJLR2_cjs.baseFetch(`${this.baseUrl}/blocks`);
|
|
1269
1729
|
if (!tipBlocks.ok) {
|
|
1270
1730
|
throw new Error(`Failed to get chain tip: ${tipBlocks.statusText}`);
|
|
1271
1731
|
}
|
|
@@ -1284,7 +1744,7 @@ var EsploraProvider = class {
|
|
|
1284
1744
|
};
|
|
1285
1745
|
}
|
|
1286
1746
|
async broadcastPackage(parent, child) {
|
|
1287
|
-
const response = await
|
|
1747
|
+
const response = await chunkFNCQJLR2_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
|
|
1288
1748
|
method: "POST",
|
|
1289
1749
|
headers: {
|
|
1290
1750
|
"Content-Type": "application/json"
|
|
@@ -1298,7 +1758,7 @@ var EsploraProvider = class {
|
|
|
1298
1758
|
return response.json();
|
|
1299
1759
|
}
|
|
1300
1760
|
async broadcastTx(tx) {
|
|
1301
|
-
const response = await
|
|
1761
|
+
const response = await chunkFNCQJLR2_cjs.baseFetch(`${this.baseUrl}/tx`, {
|
|
1302
1762
|
method: "POST",
|
|
1303
1763
|
headers: {
|
|
1304
1764
|
"Content-Type": "text/plain"
|
|
@@ -1460,7 +1920,7 @@ function findP2AOutput(tx) {
|
|
|
1460
1920
|
var CHILD_DUST_AMOUNT = 546;
|
|
1461
1921
|
function buildAnchorChild(params) {
|
|
1462
1922
|
const { parent, feeRate, fundingCoins, changeAddress, tapInternalKey, network } = params;
|
|
1463
|
-
const child = new
|
|
1923
|
+
const child = new chunkFNCQJLR2_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
|
|
1464
1924
|
child.addInput(findP2AOutput(parent));
|
|
1465
1925
|
const estimator = TxWeightEstimator.create().addP2AInput();
|
|
1466
1926
|
for (const _ of fundingCoins) {
|
|
@@ -1508,7 +1968,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
|
|
|
1508
1968
|
);
|
|
1509
1969
|
}
|
|
1510
1970
|
function buildForfeitTxWithOutput(inputs, output, txLocktime) {
|
|
1511
|
-
const tx = new
|
|
1971
|
+
const tx = new chunkFNCQJLR2_cjs.Transaction({
|
|
1512
1972
|
version: 3,
|
|
1513
1973
|
lockTime: txLocktime
|
|
1514
1974
|
});
|
|
@@ -1584,7 +2044,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
|
|
|
1584
2044
|
if (previousScriptKey.length !== 32) {
|
|
1585
2045
|
throw new Error(`parent output ${childIndex} has invalid script`);
|
|
1586
2046
|
}
|
|
1587
|
-
const cosigners =
|
|
2047
|
+
const cosigners = chunkFNCQJLR2_cjs.getArkPsbtFields(child.root, 0, chunkFNCQJLR2_cjs.CosignerPublicKey);
|
|
1588
2048
|
if (cosigners.length === 0) {
|
|
1589
2049
|
throw ErrMissingCosignersPublicKeys;
|
|
1590
2050
|
}
|
|
@@ -1642,7 +2102,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
1642
2102
|
return new _EmulatorPacket(entries);
|
|
1643
2103
|
}
|
|
1644
2104
|
static fromBytes(data) {
|
|
1645
|
-
const reader = new
|
|
2105
|
+
const reader = new chunk2JHN5RCY_cjs.BufferReader(data);
|
|
1646
2106
|
const entryCount = reader.readCompactSize();
|
|
1647
2107
|
const entries = [];
|
|
1648
2108
|
for (let i = 0; i < entryCount; i++) {
|
|
@@ -1660,7 +2120,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
1660
2120
|
return _EmulatorPacket.PACKET_TYPE;
|
|
1661
2121
|
}
|
|
1662
2122
|
serialize() {
|
|
1663
|
-
const writer = new
|
|
2123
|
+
const writer = new chunk2JHN5RCY_cjs.BufferWriter();
|
|
1664
2124
|
writer.writeCompactSize(this.entries.length);
|
|
1665
2125
|
for (const entry of this.entries) {
|
|
1666
2126
|
writer.writeUint16LE(entry.vin);
|
|
@@ -1747,7 +2207,7 @@ var Extension = class _Extension {
|
|
|
1747
2207
|
`expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
|
|
1748
2208
|
);
|
|
1749
2209
|
}
|
|
1750
|
-
const reader = new
|
|
2210
|
+
const reader = new chunk2JHN5RCY_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
|
|
1751
2211
|
const packets = [];
|
|
1752
2212
|
while (reader.remaining() > 0) {
|
|
1753
2213
|
const packetType = reader.readByte();
|
|
@@ -1821,7 +2281,7 @@ var Extension = class _Extension {
|
|
|
1821
2281
|
*/
|
|
1822
2282
|
getAssetPacket() {
|
|
1823
2283
|
for (const p of this.packets) {
|
|
1824
|
-
if (p instanceof
|
|
2284
|
+
if (p instanceof chunk2JHN5RCY_cjs.Packet) {
|
|
1825
2285
|
return p;
|
|
1826
2286
|
}
|
|
1827
2287
|
}
|
|
@@ -1859,8 +2319,8 @@ var Extension = class _Extension {
|
|
|
1859
2319
|
};
|
|
1860
2320
|
function parsePacket(packetType, data) {
|
|
1861
2321
|
switch (packetType) {
|
|
1862
|
-
case
|
|
1863
|
-
return
|
|
2322
|
+
case chunk2JHN5RCY_cjs.Packet.PACKET_TYPE:
|
|
2323
|
+
return chunk2JHN5RCY_cjs.Packet.fromBytes(data);
|
|
1864
2324
|
case EmulatorPacket.PACKET_TYPE:
|
|
1865
2325
|
return EmulatorPacket.fromBytes(data);
|
|
1866
2326
|
default:
|
|
@@ -1907,16 +2367,16 @@ function buildOpReturnScript(data) {
|
|
|
1907
2367
|
}
|
|
1908
2368
|
return script;
|
|
1909
2369
|
}
|
|
1910
|
-
var ErrOffchainOutputNotFound = (address) => new
|
|
1911
|
-
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new
|
|
2370
|
+
var ErrOffchainOutputNotFound = (address) => new chunkFNCQJLR2_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
|
|
2371
|
+
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkFNCQJLR2_cjs.ServerResponseMismatchError(
|
|
1912
2372
|
`invalid asset output amount for ${assetId}: got ${got}, want ${want}`
|
|
1913
2373
|
);
|
|
1914
|
-
var ErrAssetGroupNotFound = (assetId) => new
|
|
1915
|
-
var ErrAssetOutputNotFound = (assetId, outputIndex) => new
|
|
2374
|
+
var ErrAssetGroupNotFound = (assetId) => new chunkFNCQJLR2_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
|
|
2375
|
+
var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkFNCQJLR2_cjs.ServerResponseMismatchError(
|
|
1916
2376
|
`asset output not found in asset group ${assetId} at index ${outputIndex}`
|
|
1917
2377
|
);
|
|
1918
|
-
var ErrOnchainOutputNotFound = (address) => new
|
|
1919
|
-
var ErrUnvalidatedOffchainOutput = (address) => new
|
|
2378
|
+
var ErrOnchainOutputNotFound = (address) => new chunkFNCQJLR2_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
|
|
2379
|
+
var ErrUnvalidatedOffchainOutput = (address) => new chunkFNCQJLR2_cjs.ServerResponseMismatchError(
|
|
1920
2380
|
`offchain output ${address} cannot be validated: virtual output tree signing did not run`
|
|
1921
2381
|
);
|
|
1922
2382
|
var ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
|
|
@@ -1925,7 +2385,7 @@ var ErrInvalidOffchainOutputAmount = (address) => new Error(`invalid offchain ou
|
|
|
1925
2385
|
function assertFinalCommitmentMatchesValidated(finalCommitmentTx, validatedCommitmentTxid, context) {
|
|
1926
2386
|
if (!validatedCommitmentTxid) return;
|
|
1927
2387
|
if (finalCommitmentTx.id === validatedCommitmentTxid) return;
|
|
1928
|
-
throw new
|
|
2388
|
+
throw new chunkFNCQJLR2_cjs.ServerResponseMismatchError(
|
|
1929
2389
|
`${context}: finalization commitment tx ${finalCommitmentTx.id} differs from the validated commitment tx ${validatedCommitmentTxid}`
|
|
1930
2390
|
);
|
|
1931
2391
|
}
|
|
@@ -1935,7 +2395,7 @@ function validateBatchRecipients(commitmentTx, vtxoTreeLeaves, recipients, netwo
|
|
|
1935
2395
|
for (const recipient of recipients) {
|
|
1936
2396
|
let arkAddress;
|
|
1937
2397
|
try {
|
|
1938
|
-
arkAddress =
|
|
2398
|
+
arkAddress = chunkFNCQJLR2_cjs.ArkAddress.decode(recipient.address);
|
|
1939
2399
|
} catch {
|
|
1940
2400
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
1941
2401
|
continue;
|
|
@@ -1947,7 +2407,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
|
|
|
1947
2407
|
const usedOnchainOutputs = /* @__PURE__ */ new Set();
|
|
1948
2408
|
for (const recipient of recipients) {
|
|
1949
2409
|
try {
|
|
1950
|
-
|
|
2410
|
+
chunkFNCQJLR2_cjs.ArkAddress.decode(recipient.address);
|
|
1951
2411
|
} catch {
|
|
1952
2412
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
1953
2413
|
continue;
|
|
@@ -2178,7 +2638,7 @@ function assetMintResolver() {
|
|
|
2178
2638
|
if (!tx.assets?.length || !tx.key.arkTxid) return void 0;
|
|
2179
2639
|
const minted = tx.assets.filter((a) => {
|
|
2180
2640
|
try {
|
|
2181
|
-
return base.hex.encode(
|
|
2641
|
+
return base.hex.encode(chunk2JHN5RCY_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
|
|
2182
2642
|
} catch {
|
|
2183
2643
|
return false;
|
|
2184
2644
|
}
|
|
@@ -2221,7 +2681,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2221
2681
|
const existing = inputsByAssetId.get(asset.assetId);
|
|
2222
2682
|
inputsByAssetId.set(asset.assetId, [
|
|
2223
2683
|
...existing ?? [],
|
|
2224
|
-
|
|
2684
|
+
chunk2JHN5RCY_cjs.AssetInput.create(inputIndex, asset.amount)
|
|
2225
2685
|
]);
|
|
2226
2686
|
}
|
|
2227
2687
|
}
|
|
@@ -2233,7 +2693,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2233
2693
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
2234
2694
|
outputsByAssetId.set(asset.assetId, [
|
|
2235
2695
|
...existing ?? [],
|
|
2236
|
-
|
|
2696
|
+
chunk2JHN5RCY_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
2237
2697
|
]);
|
|
2238
2698
|
}
|
|
2239
2699
|
}
|
|
@@ -2244,7 +2704,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2244
2704
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
2245
2705
|
outputsByAssetId.set(asset.assetId, [
|
|
2246
2706
|
...existing ?? [],
|
|
2247
|
-
|
|
2707
|
+
chunk2JHN5RCY_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
2248
2708
|
]);
|
|
2249
2709
|
}
|
|
2250
2710
|
}
|
|
@@ -2253,11 +2713,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2253
2713
|
for (const assetIdStr of allAssetIds) {
|
|
2254
2714
|
const inputs = inputsByAssetId.get(assetIdStr);
|
|
2255
2715
|
const outputs = outputsByAssetId.get(assetIdStr);
|
|
2256
|
-
const assetId =
|
|
2257
|
-
const group =
|
|
2716
|
+
const assetId = chunk2JHN5RCY_cjs.AssetId.fromString(assetIdStr);
|
|
2717
|
+
const group = chunk2JHN5RCY_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
|
|
2258
2718
|
groups.push(group);
|
|
2259
2719
|
}
|
|
2260
|
-
return
|
|
2720
|
+
return chunk2JHN5RCY_cjs.Packet.create(groups);
|
|
2261
2721
|
}
|
|
2262
2722
|
function selectCoinsWithAsset(coins, assetId, requiredAmount) {
|
|
2263
2723
|
const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
|
|
@@ -2342,13 +2802,13 @@ var toTimelock = (value) => ({
|
|
|
2342
2802
|
var toSeconds = (t) => t.type === "seconds" ? t.value : t.value * NOMINAL_BLOCK_SECONDS;
|
|
2343
2803
|
function assertTimelockInPolicy(timelock, policy, label, overrideOption) {
|
|
2344
2804
|
if (policy.requireSeconds && timelock.type === "blocks") {
|
|
2345
|
-
throw new
|
|
2805
|
+
throw new chunkFNCQJLR2_cjs.ServerResponseMismatchError(
|
|
2346
2806
|
`${label} rejected: block-typed timelocks are not accepted (got ${timelock.value})`
|
|
2347
2807
|
);
|
|
2348
2808
|
}
|
|
2349
2809
|
const seconds = toSeconds(timelock);
|
|
2350
2810
|
if (seconds < policy.minSeconds) {
|
|
2351
|
-
throw new
|
|
2811
|
+
throw new chunkFNCQJLR2_cjs.ServerResponseMismatchError(
|
|
2352
2812
|
`${label} rejected: ${timelock.value} ${timelock.type} is below the ${policy.minSeconds}s floor; pass ${overrideOption}: ${seconds}n to Wallet.create to lower it`
|
|
2353
2813
|
);
|
|
2354
2814
|
}
|
|
@@ -2369,7 +2829,7 @@ function resolveBatchExpiryPolicy(network, overrides) {
|
|
|
2369
2829
|
}
|
|
2370
2830
|
function assertValidBatchExpiry(batchExpiry, policy) {
|
|
2371
2831
|
if (policy.advertisedVtxoTreeExpiry !== void 0 && batchExpiry !== policy.advertisedVtxoTreeExpiry) {
|
|
2372
|
-
throw new
|
|
2832
|
+
throw new chunkFNCQJLR2_cjs.ServerResponseMismatchError(
|
|
2373
2833
|
`batch expiry rejected: ${batchExpiry} does not match the advertised vtxoTreeExpiry ${policy.advertisedVtxoTreeExpiry}`
|
|
2374
2834
|
);
|
|
2375
2835
|
}
|
|
@@ -2399,21 +2859,21 @@ function resolveCheckpointExitDelayPolicy(network, overrides) {
|
|
|
2399
2859
|
function assertValidServerUnrollScript(checkpointTapscript, policy) {
|
|
2400
2860
|
let script;
|
|
2401
2861
|
try {
|
|
2402
|
-
script =
|
|
2862
|
+
script = chunkFNCQJLR2_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
|
|
2403
2863
|
} catch (e) {
|
|
2404
|
-
throw new
|
|
2864
|
+
throw new chunkFNCQJLR2_cjs.ServerResponseMismatchError(
|
|
2405
2865
|
`checkpoint exit delay rejected: invalid checkpointTapscript from server (${e instanceof Error ? e.message : String(e)})`
|
|
2406
2866
|
);
|
|
2407
2867
|
}
|
|
2408
2868
|
if (policy.advertisedForfeitPubkey !== void 0) {
|
|
2409
2869
|
const { pubkeys } = script.params;
|
|
2410
2870
|
if (pubkeys.length !== 1) {
|
|
2411
|
-
throw new
|
|
2871
|
+
throw new chunkFNCQJLR2_cjs.ServerResponseMismatchError(
|
|
2412
2872
|
`checkpoint exit delay rejected: checkpointTapscript must commit to exactly one pubkey, got ${pubkeys.length} [${pubkeys.map(base.hex.encode).join(", ")}]`
|
|
2413
2873
|
);
|
|
2414
2874
|
}
|
|
2415
2875
|
if (!utils_js.equalBytes(pubkeys[0], policy.advertisedForfeitPubkey)) {
|
|
2416
|
-
throw new
|
|
2876
|
+
throw new chunkFNCQJLR2_cjs.ServerResponseMismatchError(
|
|
2417
2877
|
`checkpoint exit delay rejected: checkpointTapscript pubkey ${base.hex.encode(pubkeys[0])} does not match the advertised forfeitPubkey ${base.hex.encode(policy.advertisedForfeitPubkey)}`
|
|
2418
2878
|
);
|
|
2419
2879
|
}
|
|
@@ -2457,8 +2917,8 @@ function buildOffchainTx(inputs, outputs, serverUnrollScript) {
|
|
|
2457
2917
|
function buildVirtualTx(inputs, outputs) {
|
|
2458
2918
|
let lockTime = 0n;
|
|
2459
2919
|
for (const input of inputs) {
|
|
2460
|
-
const tapscript =
|
|
2461
|
-
if (
|
|
2920
|
+
const tapscript = chunkFNCQJLR2_cjs.decodeTapscript(chunkFNCQJLR2_cjs.scriptFromTapLeafScript(input.tapLeafScript));
|
|
2921
|
+
if (chunkFNCQJLR2_cjs.CLTVMultisigTapscript.is(tapscript)) {
|
|
2462
2922
|
if (lockTime !== 0n) {
|
|
2463
2923
|
if (isSeconds(lockTime) !== isSeconds(tapscript.params.absoluteTimelock)) {
|
|
2464
2924
|
throw new Error("cannot mix seconds and blocks locktime");
|
|
@@ -2469,7 +2929,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
2469
2929
|
}
|
|
2470
2930
|
}
|
|
2471
2931
|
}
|
|
2472
|
-
const tx = new
|
|
2932
|
+
const tx = new chunkFNCQJLR2_cjs.Transaction({
|
|
2473
2933
|
version: 3,
|
|
2474
2934
|
lockTime: Number(lockTime)
|
|
2475
2935
|
});
|
|
@@ -2479,12 +2939,12 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
2479
2939
|
index: input.vout,
|
|
2480
2940
|
sequence: lockTime ? btcSigner.DEFAULT_SEQUENCE - 1 : void 0,
|
|
2481
2941
|
witnessUtxo: {
|
|
2482
|
-
script:
|
|
2942
|
+
script: chunkFNCQJLR2_cjs.VtxoScript.decode(input.tapTree).pkScript,
|
|
2483
2943
|
amount: BigInt(input.value)
|
|
2484
2944
|
},
|
|
2485
2945
|
tapLeafScript: [input.tapLeafScript]
|
|
2486
2946
|
});
|
|
2487
|
-
|
|
2947
|
+
chunkFNCQJLR2_cjs.setArkPsbtField(tx, i, chunkFNCQJLR2_cjs.VtxoTaprootTree, input.tapTree);
|
|
2488
2948
|
}
|
|
2489
2949
|
for (const output of outputs) {
|
|
2490
2950
|
tx.addOutput(output);
|
|
@@ -2493,8 +2953,8 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
2493
2953
|
return tx;
|
|
2494
2954
|
}
|
|
2495
2955
|
function buildCheckpointTx(vtxo, serverUnrollScript) {
|
|
2496
|
-
const collaborativeClosure =
|
|
2497
|
-
const checkpointVtxoScript = new
|
|
2956
|
+
const collaborativeClosure = chunkFNCQJLR2_cjs.decodeTapscript(chunkFNCQJLR2_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
|
|
2957
|
+
const checkpointVtxoScript = new chunkFNCQJLR2_cjs.VtxoScript([
|
|
2498
2958
|
serverUnrollScript.script,
|
|
2499
2959
|
collaborativeClosure.script
|
|
2500
2960
|
]);
|
|
@@ -2647,7 +3107,7 @@ function combineTapscriptSigs(signedTx, originalTx) {
|
|
|
2647
3107
|
}
|
|
2648
3108
|
function isValidArkAddress(address) {
|
|
2649
3109
|
try {
|
|
2650
|
-
|
|
3110
|
+
chunkFNCQJLR2_cjs.ArkAddress.decode(address);
|
|
2651
3111
|
return true;
|
|
2652
3112
|
} catch (e) {
|
|
2653
3113
|
return false;
|
|
@@ -2655,16 +3115,16 @@ function isValidArkAddress(address) {
|
|
|
2655
3115
|
}
|
|
2656
3116
|
function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, context) {
|
|
2657
3117
|
if (serverCheckpointTxs.length !== expectedCheckpoints.length) {
|
|
2658
|
-
throw new
|
|
3118
|
+
throw new chunkFNCQJLR2_cjs.ServerResponseMismatchError(
|
|
2659
3119
|
`${context} returned ${serverCheckpointTxs.length} checkpoints, expected ${expectedCheckpoints.length}`
|
|
2660
3120
|
);
|
|
2661
3121
|
}
|
|
2662
3122
|
const byTxid = new Map(expectedCheckpoints.map((c) => [c.id, c]));
|
|
2663
3123
|
return serverCheckpointTxs.map((encoded, index) => {
|
|
2664
|
-
const server =
|
|
3124
|
+
const server = chunkFNCQJLR2_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
|
|
2665
3125
|
const local = byTxid.get(server.id);
|
|
2666
3126
|
if (!local) {
|
|
2667
|
-
throw new
|
|
3127
|
+
throw new chunkFNCQJLR2_cjs.ServerResponseMismatchError(
|
|
2668
3128
|
`${context} checkpoint ${index} txid ${server.id} does not match any submitted checkpoint`
|
|
2669
3129
|
);
|
|
2670
3130
|
}
|
|
@@ -2674,14 +3134,14 @@ function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, contex
|
|
|
2674
3134
|
}
|
|
2675
3135
|
function assertSubmittedArkTxid(response, signedArkTx, context) {
|
|
2676
3136
|
if (response.arkTxid !== signedArkTx.id) {
|
|
2677
|
-
throw new
|
|
3137
|
+
throw new chunkFNCQJLR2_cjs.ServerResponseMismatchError(
|
|
2678
3138
|
`${context} returned ark txid ${response.arkTxid}, expected ${signedArkTx.id}`
|
|
2679
3139
|
);
|
|
2680
3140
|
}
|
|
2681
3141
|
if (response.finalArkTx === void 0) return;
|
|
2682
|
-
const finalTxid =
|
|
3142
|
+
const finalTxid = chunkFNCQJLR2_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
|
|
2683
3143
|
if (finalTxid !== signedArkTx.id) {
|
|
2684
|
-
throw new
|
|
3144
|
+
throw new chunkFNCQJLR2_cjs.ServerResponseMismatchError(
|
|
2685
3145
|
`${context} returned final ark tx ${finalTxid}, expected ${signedArkTx.id}`
|
|
2686
3146
|
);
|
|
2687
3147
|
}
|
|
@@ -2700,10 +3160,10 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeyHex,
|
|
|
2700
3160
|
[serverPubkeyHex],
|
|
2701
3161
|
void 0,
|
|
2702
3162
|
void 0,
|
|
2703
|
-
payment_js.tapLeafHash(
|
|
3163
|
+
payment_js.tapLeafHash(chunkFNCQJLR2_cjs.scriptFromTapLeafScript(leaf))
|
|
2704
3164
|
);
|
|
2705
3165
|
} catch (error) {
|
|
2706
|
-
throw new
|
|
3166
|
+
throw new chunkFNCQJLR2_cjs.ServerResponseMismatchError(
|
|
2707
3167
|
`${context}: input ${inputIndex} is not signed by the server on the leaf being spent (${error instanceof Error ? error.message : String(error)})`
|
|
2708
3168
|
);
|
|
2709
3169
|
}
|
|
@@ -2712,20 +3172,20 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
2712
3172
|
const byOutpoint = new Map(inputs.map((input) => [`${input.txid}:${input.vout}`, input]));
|
|
2713
3173
|
for (const [index, checkpoint] of checkpoints.entries()) {
|
|
2714
3174
|
if (checkpoint.inputsLength !== 1) {
|
|
2715
|
-
throw new
|
|
3175
|
+
throw new chunkFNCQJLR2_cjs.ServerResponseMismatchError(
|
|
2716
3176
|
`${context}: checkpoint ${index} spends ${checkpoint.inputsLength} inputs, expected 1`
|
|
2717
3177
|
);
|
|
2718
3178
|
}
|
|
2719
3179
|
const spent = checkpoint.getInput(0);
|
|
2720
3180
|
if (!spent.txid || spent.index === void 0) {
|
|
2721
|
-
throw new
|
|
3181
|
+
throw new chunkFNCQJLR2_cjs.ServerResponseMismatchError(
|
|
2722
3182
|
`${context}: checkpoint ${index} has no input outpoint`
|
|
2723
3183
|
);
|
|
2724
3184
|
}
|
|
2725
3185
|
const outpoint = `${base.hex.encode(spent.txid)}:${spent.index}`;
|
|
2726
3186
|
const input = byOutpoint.get(outpoint);
|
|
2727
3187
|
if (!input) {
|
|
2728
|
-
throw new
|
|
3188
|
+
throw new chunkFNCQJLR2_cjs.ServerResponseMismatchError(
|
|
2729
3189
|
`${context}: checkpoint ${index} spends ${outpoint}, which is not one of the requested virtual outputs`
|
|
2730
3190
|
);
|
|
2731
3191
|
}
|
|
@@ -2733,7 +3193,7 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
2733
3193
|
(unroll) => buildCheckpointTx(input, unroll).tx.id === checkpoint.id
|
|
2734
3194
|
);
|
|
2735
3195
|
if (!rebuilt) {
|
|
2736
|
-
throw new
|
|
3196
|
+
throw new chunkFNCQJLR2_cjs.ServerResponseMismatchError(
|
|
2737
3197
|
`${context}: checkpoint ${index} txid ${checkpoint.id} differs from the checkpoint built locally for ${outpoint}`
|
|
2738
3198
|
);
|
|
2739
3199
|
}
|
|
@@ -2760,11 +3220,11 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
2760
3220
|
const verify = options?.verifyServerSignatures;
|
|
2761
3221
|
if (verify) {
|
|
2762
3222
|
if (response.finalArkTx === void 0) {
|
|
2763
|
-
throw new
|
|
3223
|
+
throw new chunkFNCQJLR2_cjs.ServerResponseMismatchError(
|
|
2764
3224
|
"submitTx: server returned no final ark tx to verify its signatures against"
|
|
2765
3225
|
);
|
|
2766
3226
|
}
|
|
2767
|
-
const finalArkTx =
|
|
3227
|
+
const finalArkTx = chunkFNCQJLR2_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
|
|
2768
3228
|
const serverPubkeyHex = base.hex.encode(
|
|
2769
3229
|
verify.serverPubkey.length === 33 ? verify.serverPubkey.subarray(1) : verify.serverPubkey
|
|
2770
3230
|
);
|
|
@@ -2823,12 +3283,12 @@ function claimWithPreimageIdentity(identity, preimage) {
|
|
|
2823
3283
|
return {
|
|
2824
3284
|
...identity,
|
|
2825
3285
|
sign: async (tx, inputIndexes) => {
|
|
2826
|
-
const signed =
|
|
3286
|
+
const signed = chunkFNCQJLR2_cjs.Transaction.fromPSBT(
|
|
2827
3287
|
(await identity.sign(tx.clone(), inputIndexes)).toPSBT()
|
|
2828
3288
|
);
|
|
2829
3289
|
const indexes = inputIndexes ?? Array.from({ length: signed.inputsLength }, (_, i) => i);
|
|
2830
3290
|
for (const index of indexes) {
|
|
2831
|
-
|
|
3291
|
+
chunkFNCQJLR2_cjs.setArkPsbtField(signed, index, chunkFNCQJLR2_cjs.ConditionWitness, [preimage]);
|
|
2832
3292
|
}
|
|
2833
3293
|
return signed;
|
|
2834
3294
|
}
|
|
@@ -3020,7 +3480,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
|
|
|
3020
3480
|
};
|
|
3021
3481
|
}
|
|
3022
3482
|
function deriveContractTapscripts(contract) {
|
|
3023
|
-
const handler =
|
|
3483
|
+
const handler = chunkSF5NKAUA_cjs.contractHandlers.get(contract.type);
|
|
3024
3484
|
if (!handler) {
|
|
3025
3485
|
throw new Error(`No handler for contract type '${contract.type}'`);
|
|
3026
3486
|
}
|
|
@@ -3091,7 +3551,7 @@ function getRandomId() {
|
|
|
3091
3551
|
}
|
|
3092
3552
|
function isValidArkAddress2(address) {
|
|
3093
3553
|
try {
|
|
3094
|
-
|
|
3554
|
+
chunkFNCQJLR2_cjs.ArkAddress.decode(address);
|
|
3095
3555
|
return true;
|
|
3096
3556
|
} catch (e) {
|
|
3097
3557
|
return false;
|
|
@@ -3121,7 +3581,7 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
3121
3581
|
for (const recipient of recipients) {
|
|
3122
3582
|
let address;
|
|
3123
3583
|
try {
|
|
3124
|
-
address =
|
|
3584
|
+
address = chunkFNCQJLR2_cjs.ArkAddress.decode(recipient.address);
|
|
3125
3585
|
} catch (e) {
|
|
3126
3586
|
throw new Error(`Invalid Arkade address: ${recipient.address}`);
|
|
3127
3587
|
}
|
|
@@ -3140,6 +3600,44 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
3140
3600
|
return validatedRecipients;
|
|
3141
3601
|
}
|
|
3142
3602
|
|
|
3603
|
+
// src/contracts/spendability.ts
|
|
3604
|
+
function isContractGenericallySpendable(contract) {
|
|
3605
|
+
return chunkSF5NKAUA_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
|
|
3606
|
+
}
|
|
3607
|
+
function gatedContracts(contracts) {
|
|
3608
|
+
const gated = /* @__PURE__ */ new Map();
|
|
3609
|
+
for (const contract of contracts) {
|
|
3610
|
+
if (!isContractGenericallySpendable(contract)) gated.set(contract.script, contract.type);
|
|
3611
|
+
}
|
|
3612
|
+
return gated;
|
|
3613
|
+
}
|
|
3614
|
+
function gateExclusion(gated) {
|
|
3615
|
+
return (vtxo) => {
|
|
3616
|
+
const type = vtxo.script === void 0 ? void 0 : gated.get(vtxo.script);
|
|
3617
|
+
if (type === void 0) return void 0;
|
|
3618
|
+
return `at ${vtxo.script} (contract type '${type}') is not generically spendable`;
|
|
3619
|
+
};
|
|
3620
|
+
}
|
|
3621
|
+
function outpointExclusion(outpoints, reason) {
|
|
3622
|
+
return (vtxo) => outpoints.has(`${vtxo.txid}:${vtxo.vout}`) ? reason : void 0;
|
|
3623
|
+
}
|
|
3624
|
+
function outpointReasons(reasons) {
|
|
3625
|
+
return (vtxo) => reasons.get(`${vtxo.txid}:${vtxo.vout}`);
|
|
3626
|
+
}
|
|
3627
|
+
function logExcludedVtxos(source, vtxos, exclusions) {
|
|
3628
|
+
if (exclusions.length === 0) return;
|
|
3629
|
+
for (const vtxo of vtxos) {
|
|
3630
|
+
for (const exclusion of exclusions) {
|
|
3631
|
+
const reason = exclusion(vtxo);
|
|
3632
|
+
if (reason === void 0) continue;
|
|
3633
|
+
console.debug(`[spendability] ${source}: ${vtxo.txid}:${vtxo.vout} ${reason}`);
|
|
3634
|
+
}
|
|
3635
|
+
}
|
|
3636
|
+
}
|
|
3637
|
+
var UnannotatableInputError = class extends Error {
|
|
3638
|
+
name = "UnannotatableInputError";
|
|
3639
|
+
};
|
|
3640
|
+
|
|
3143
3641
|
// src/wallet/vtxo-manager.ts
|
|
3144
3642
|
function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSeconds = Math.floor(Date.now() / 1e3)) {
|
|
3145
3643
|
const out = /* @__PURE__ */ new Set();
|
|
@@ -3150,7 +3648,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
|
|
|
3150
3648
|
continue;
|
|
3151
3649
|
}
|
|
3152
3650
|
for (const v of vtxos) {
|
|
3153
|
-
if (!
|
|
3651
|
+
if (!chunkFNCQJLR2_cjs.hasTerminalSpend(v) && !v.isSwept) out.add(`${v.txid}:${v.vout}`);
|
|
3154
3652
|
}
|
|
3155
3653
|
}
|
|
3156
3654
|
return out;
|
|
@@ -3183,10 +3681,10 @@ function byValueDescending(vtxos) {
|
|
|
3183
3681
|
return [...vtxos].sort((a, b) => b.value - a.value);
|
|
3184
3682
|
}
|
|
3185
3683
|
async function fetchTimeHeight(wallet) {
|
|
3186
|
-
return
|
|
3684
|
+
return chunkFNCQJLR2_cjs.resolveTimeHeight(wallet.onchainProvider);
|
|
3187
3685
|
}
|
|
3188
3686
|
function canMigrateBySend(vtxo, now) {
|
|
3189
|
-
if (!
|
|
3687
|
+
if (!chunkFNCQJLR2_cjs.canSpendOffchain(vtxo, now)) return false;
|
|
3190
3688
|
return vtxo.expiresAt !== void 0 || vtxo.expiresAtHeight !== void 0;
|
|
3191
3689
|
}
|
|
3192
3690
|
function byExpiryAscending(vtxos, now) {
|
|
@@ -3194,7 +3692,7 @@ function byExpiryAscending(vtxos, now) {
|
|
|
3194
3692
|
if (vtxo.isSwept) return -Infinity;
|
|
3195
3693
|
if (vtxo.expiresAt !== void 0) return vtxo.expiresAt.getTime();
|
|
3196
3694
|
if (vtxo.expiresAtHeight !== void 0) {
|
|
3197
|
-
return
|
|
3695
|
+
return chunkFNCQJLR2_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
|
|
3198
3696
|
}
|
|
3199
3697
|
return Infinity;
|
|
3200
3698
|
};
|
|
@@ -3221,7 +3719,7 @@ function priceSettlementInputs(vtxos, estimator) {
|
|
|
3221
3719
|
const payable = [];
|
|
3222
3720
|
const net = /* @__PURE__ */ new Map();
|
|
3223
3721
|
for (const vtxo of vtxos) {
|
|
3224
|
-
const inputFee = estimator.evalOffchainInput(
|
|
3722
|
+
const inputFee = estimator.evalOffchainInput(chunkFNCQJLR2_cjs.toOffchainInputFeeParams(vtxo));
|
|
3225
3723
|
if (inputFee.satoshis >= vtxo.value) {
|
|
3226
3724
|
continue;
|
|
3227
3725
|
}
|
|
@@ -3247,7 +3745,7 @@ function deductOffchainOutputFee(subtotal, estimator, arkAddress) {
|
|
|
3247
3745
|
}
|
|
3248
3746
|
const outputFee = estimator.evalOffchainOutput({
|
|
3249
3747
|
amount: subtotal,
|
|
3250
|
-
script: base.hex.encode(
|
|
3748
|
+
script: base.hex.encode(chunkFNCQJLR2_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
3251
3749
|
});
|
|
3252
3750
|
return subtotal - BigInt(outputFee.satoshis);
|
|
3253
3751
|
}
|
|
@@ -3265,10 +3763,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
|
|
|
3265
3763
|
};
|
|
3266
3764
|
function getRecoverableVtxos(vtxos, dustAmount, now) {
|
|
3267
3765
|
return vtxos.filter((vtxo) => {
|
|
3268
|
-
if (
|
|
3766
|
+
if (chunkFNCQJLR2_cjs.canRecoverOnchain(vtxo, now)) {
|
|
3269
3767
|
return true;
|
|
3270
3768
|
}
|
|
3271
|
-
if (
|
|
3769
|
+
if (chunkFNCQJLR2_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
|
|
3272
3770
|
return true;
|
|
3273
3771
|
}
|
|
3274
3772
|
return false;
|
|
@@ -3299,7 +3797,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
|
|
|
3299
3797
|
}
|
|
3300
3798
|
function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
3301
3799
|
const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
|
|
3302
|
-
const expiresAt =
|
|
3800
|
+
const expiresAt = chunkFNCQJLR2_cjs.normalizeVtxo(vtxo).expiresAt;
|
|
3303
3801
|
if (expiresAt === void 0) return false;
|
|
3304
3802
|
const now = Date.now();
|
|
3305
3803
|
const batchExpiry = expiresAt.getTime();
|
|
@@ -3308,7 +3806,7 @@ function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
|
3308
3806
|
}
|
|
3309
3807
|
function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
|
|
3310
3808
|
return vtxos.filter(
|
|
3311
|
-
(vtxo) => isVtxoExpiringSoon(vtxo, thresholdMs) ||
|
|
3809
|
+
(vtxo) => isVtxoExpiringSoon(vtxo, thresholdMs) || chunkFNCQJLR2_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount)
|
|
3312
3810
|
);
|
|
3313
3811
|
}
|
|
3314
3812
|
function isMigrationCapable(wallet) {
|
|
@@ -3422,6 +3920,27 @@ var VtxoManager = class _VtxoManager {
|
|
|
3422
3920
|
static MIGRATION_COOLDOWN_MS = 3e4;
|
|
3423
3921
|
static MIGRATION_MAX_BACKOFF_MS = 5 * 60 * 1e3;
|
|
3424
3922
|
// ========== Recovery Methods ==========
|
|
3923
|
+
/**
|
|
3924
|
+
* Outpoints recovery must not name yet, with the reason each was refused.
|
|
3925
|
+
* Empty when the manager offers no opinion — an embedder's may not implement
|
|
3926
|
+
* the predicate, and every contract type but VHTLC never answers.
|
|
3927
|
+
*
|
|
3928
|
+
* Reaches only a lockup whose `sender` is this wallet's own key: role
|
|
3929
|
+
* resolution matches that key against the contract's params, so a
|
|
3930
|
+
* descriptor-derived sender (every RFQ lockup) is not matched and such a row
|
|
3931
|
+
* still fails its batch at submit.
|
|
3932
|
+
*
|
|
3933
|
+
* The key stays a thunk so an ordinary recovery never touches the identity,
|
|
3934
|
+
* and the full coins are passed rather than bare outpoints because only they
|
|
3935
|
+
* carry the confirmation a relative timelock is measured from.
|
|
3936
|
+
*/
|
|
3937
|
+
async unspendableNow(vtxos) {
|
|
3938
|
+
const contractManager = await this.wallet.getContractManager();
|
|
3939
|
+
return await contractManager.unspendableNowReasons?.(
|
|
3940
|
+
vtxos,
|
|
3941
|
+
async () => base.hex.encode(await this.wallet.identity.xOnlyPublicKey())
|
|
3942
|
+
) ?? /* @__PURE__ */ new Map();
|
|
3943
|
+
}
|
|
3425
3944
|
/**
|
|
3426
3945
|
* Recover swept/expired virtual outputs by settling them back to the wallet's Arkade address.
|
|
3427
3946
|
*
|
|
@@ -3434,6 +3953,11 @@ var VtxoManager = class _VtxoManager {
|
|
|
3434
3953
|
* Note: Settled virtual outputs with long expiry are NOT recovered to avoid locking liquidity unnecessarily.
|
|
3435
3954
|
* Only preconfirmed subdust is recovered to consolidate small amounts.
|
|
3436
3955
|
*
|
|
3956
|
+
* Inputs whose contract refuses a spend right now — an immature VHTLC refund
|
|
3957
|
+
* path — are skipped rather than failing the batch that holds them, and
|
|
3958
|
+
* {@link getRecoverableBalance} skips the same set. See
|
|
3959
|
+
* {@link unspendableNow} for which rows that reaches.
|
|
3960
|
+
*
|
|
3437
3961
|
* @param eventCallback - Optional callback to receive settlement events
|
|
3438
3962
|
* @returns Settlement transaction ID
|
|
3439
3963
|
* @throws Error if no recoverable virtual outputs found
|
|
@@ -3462,6 +3986,26 @@ var VtxoManager = class _VtxoManager {
|
|
|
3462
3986
|
if (vtxosToRecover.length === 0) {
|
|
3463
3987
|
throw new Error("No recoverable VTXOs found");
|
|
3464
3988
|
}
|
|
3989
|
+
const refused = await this.unspendableNow(vtxosToRecover);
|
|
3990
|
+
if (refused.size > 0) {
|
|
3991
|
+
logExcludedVtxos("recoverVtxos", vtxosToRecover, [outpointReasons(refused)]);
|
|
3992
|
+
const held = vtxosToRecover.length;
|
|
3993
|
+
vtxosToRecover = vtxosToRecover.filter(
|
|
3994
|
+
(vtxo) => !refused.has(`${vtxo.txid}:${vtxo.vout}`)
|
|
3995
|
+
);
|
|
3996
|
+
if (vtxosToRecover.length === 0) {
|
|
3997
|
+
const why = refused.size === 1 ? [...refused.values()][0] : [...refused].map(([outpoint, reason]) => `${outpoint}: ${reason}`).join("; ");
|
|
3998
|
+
throw new Error(
|
|
3999
|
+
`All ${held} recoverable VTXO(s) are held by a contract that refuses a spend right now: ${why}`
|
|
4000
|
+
);
|
|
4001
|
+
}
|
|
4002
|
+
({ vtxosToRecover } = getRecoverableWithSubdust(vtxosToRecover, dustAmount, now));
|
|
4003
|
+
if (vtxosToRecover.length === 0) {
|
|
4004
|
+
throw new Error(
|
|
4005
|
+
`Excluding ${refused.size} VTXO(s) not yet spendable, the remaining recoverable amount is below the dust threshold ${dustAmount}`
|
|
4006
|
+
);
|
|
4007
|
+
}
|
|
4008
|
+
}
|
|
3465
4009
|
const info = await this.getInfoProvider()?.getInfo();
|
|
3466
4010
|
const vtxoMaxAmount = info?.vtxoMaxAmount ?? -1n;
|
|
3467
4011
|
const estimator = new Estimator(info?.fees.intentFee ?? {});
|
|
@@ -3525,6 +4069,11 @@ var VtxoManager = class _VtxoManager {
|
|
|
3525
4069
|
* The batch size caps are not applied here: they defer the overflow to the
|
|
3526
4070
|
* next cycle rather than reducing what is recoverable.
|
|
3527
4071
|
*
|
|
4072
|
+
* Inputs a contract refuses right now are excluded, so this and
|
|
4073
|
+
* {@link recoverVtxos} answer over the same set. `Balance.recoverable` still
|
|
4074
|
+
* counts them: that field reports what the wallet owns, this one what a
|
|
4075
|
+
* batch would hand back today.
|
|
4076
|
+
*
|
|
3528
4077
|
* @returns Object containing recoverable amounts and subdust information
|
|
3529
4078
|
*
|
|
3530
4079
|
* @example
|
|
@@ -3546,11 +4095,24 @@ var VtxoManager = class _VtxoManager {
|
|
|
3546
4095
|
withUnrolled: false
|
|
3547
4096
|
});
|
|
3548
4097
|
const dustAmount = getDustAmount(this.wallet);
|
|
3549
|
-
const
|
|
4098
|
+
const now = await fetchTimeHeight(this.wallet);
|
|
4099
|
+
let { vtxosToRecover, includesSubdust } = getRecoverableWithSubdust(
|
|
3550
4100
|
allVtxos,
|
|
3551
4101
|
dustAmount,
|
|
3552
|
-
|
|
4102
|
+
now
|
|
3553
4103
|
);
|
|
4104
|
+
const refused = await this.unspendableNow(vtxosToRecover);
|
|
4105
|
+
if (refused.size > 0) {
|
|
4106
|
+
logExcludedVtxos("getRecoverableBalance", vtxosToRecover, [outpointReasons(refused)]);
|
|
4107
|
+
const remaining = vtxosToRecover.filter(
|
|
4108
|
+
(vtxo) => !refused.has(`${vtxo.txid}:${vtxo.vout}`)
|
|
4109
|
+
);
|
|
4110
|
+
({ vtxosToRecover, includesSubdust } = getRecoverableWithSubdust(
|
|
4111
|
+
remaining,
|
|
4112
|
+
dustAmount,
|
|
4113
|
+
now
|
|
4114
|
+
));
|
|
4115
|
+
}
|
|
3554
4116
|
const info = await this.getInfoProvider()?.getInfo();
|
|
3555
4117
|
const estimator = new Estimator(info?.fees.intentFee ?? {});
|
|
3556
4118
|
const { payable, net } = priceSettlementInputs(vtxosToRecover, estimator);
|
|
@@ -3843,11 +4405,11 @@ var VtxoManager = class _VtxoManager {
|
|
|
3843
4405
|
`Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
|
|
3844
4406
|
);
|
|
3845
4407
|
}
|
|
3846
|
-
const tx = new
|
|
4408
|
+
const tx = new chunkFNCQJLR2_cjs.Transaction();
|
|
3847
4409
|
for (const utxo of expiredUtxos) {
|
|
3848
|
-
const utxoScript =
|
|
4410
|
+
const utxoScript = chunkFNCQJLR2_cjs.VtxoScript.decode(utxo.tapTree);
|
|
3849
4411
|
const utxoExitLeaf = utxoScript.leaves.find(
|
|
3850
|
-
(leaf) =>
|
|
4412
|
+
(leaf) => chunkFNCQJLR2_cjs.CSVMultisigTapscript.isScriptValid(chunkFNCQJLR2_cjs.scriptFromTapLeafScript(leaf)) === true
|
|
3851
4413
|
);
|
|
3852
4414
|
if (!utxoExitLeaf) {
|
|
3853
4415
|
throw new Error(
|
|
@@ -3862,7 +4424,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
3862
4424
|
amount: BigInt(utxo.value)
|
|
3863
4425
|
},
|
|
3864
4426
|
tapLeafScript: [utxoExitLeaf],
|
|
3865
|
-
sequence:
|
|
4427
|
+
sequence: chunkFNCQJLR2_cjs.getSequence(utxoExitLeaf)
|
|
3866
4428
|
});
|
|
3867
4429
|
}
|
|
3868
4430
|
tx.addOutputAddress(boardingAddress, outputAmount, this.getNetwork());
|
|
@@ -4096,8 +4658,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
4096
4658
|
if (!serverPubKey) continue;
|
|
4097
4659
|
const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
|
|
4098
4660
|
if (cls.status === "CURRENT") continue;
|
|
4099
|
-
const recoverable = vtxos.filter((v) => v.isSwept && !
|
|
4100
|
-
const spendable = vtxos.filter((v) => !
|
|
4661
|
+
const recoverable = vtxos.filter((v) => v.isSwept && !chunkFNCQJLR2_cjs.hasTerminalSpend(v));
|
|
4662
|
+
const spendable = vtxos.filter((v) => !chunkFNCQJLR2_cjs.hasTerminalSpend(v) && !v.isSwept);
|
|
4101
4663
|
const value = spendable.reduce((sum, v) => sum + v.value, 0);
|
|
4102
4664
|
let recoverableCount = 0;
|
|
4103
4665
|
let recoverableValue = 0;
|
|
@@ -4110,7 +4672,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4110
4672
|
awaitingSweepCount = spendable.length;
|
|
4111
4673
|
awaitingSweepValue = value;
|
|
4112
4674
|
for (const v of spendable) {
|
|
4113
|
-
const exp =
|
|
4675
|
+
const exp = chunkFNCQJLR2_cjs.toBatchExpiry(v);
|
|
4114
4676
|
if (exp !== void 0 && (nextSweepEta === void 0 || exp < nextSweepEta)) {
|
|
4115
4677
|
nextSweepEta = exp;
|
|
4116
4678
|
}
|
|
@@ -4371,7 +4933,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4371
4933
|
/** Decodes the boarding tapscript exit path to extract the CSV timelock. */
|
|
4372
4934
|
getBoardingTimelock() {
|
|
4373
4935
|
const wallet = this.getSweepWallet();
|
|
4374
|
-
const exitScript =
|
|
4936
|
+
const exitScript = chunkFNCQJLR2_cjs.CSVMultisigTapscript.decode(
|
|
4375
4937
|
base.hex.decode(wallet.boardingTapscript.exitScript)
|
|
4376
4938
|
);
|
|
4377
4939
|
return exitScript.params.timelock;
|
|
@@ -4502,8 +5064,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
4502
5064
|
* or doesn't carry the metadata.
|
|
4503
5065
|
*/
|
|
4504
5066
|
extractSpentOutpoint(error) {
|
|
4505
|
-
const ark =
|
|
4506
|
-
if (!
|
|
5067
|
+
const ark = chunkFNCQJLR2_cjs.maybeArkError(error);
|
|
5068
|
+
if (!chunkFNCQJLR2_cjs.isArkError(ark, chunkFNCQJLR2_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
|
|
4507
5069
|
const raw = ark.metadata?.vtxo_outpoint;
|
|
4508
5070
|
if (typeof raw !== "string") return void 0;
|
|
4509
5071
|
const [txid, voutStr] = raw.split(":");
|
|
@@ -4693,7 +5255,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4693
5255
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
4694
5256
|
break;
|
|
4695
5257
|
}
|
|
4696
|
-
const inputFee = estimator.evalOffchainInput(
|
|
5258
|
+
const inputFee = estimator.evalOffchainInput(chunkFNCQJLR2_cjs.toOffchainInputFeeParams(v));
|
|
4697
5259
|
if (inputFee.satoshis >= v.value) {
|
|
4698
5260
|
continue;
|
|
4699
5261
|
}
|
|
@@ -4713,7 +5275,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4713
5275
|
const arkAddress = await this.wallet.getAddress();
|
|
4714
5276
|
const outputFee = estimator.evalOffchainOutput({
|
|
4715
5277
|
amount: totalAmount,
|
|
4716
|
-
script: base.hex.encode(
|
|
5278
|
+
script: base.hex.encode(chunkFNCQJLR2_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
4717
5279
|
});
|
|
4718
5280
|
totalAmount -= BigInt(outputFee.satoshis);
|
|
4719
5281
|
if (totalAmount < dustAmount) return;
|
|
@@ -4793,7 +5355,7 @@ var ArkNote = class _ArkNote {
|
|
|
4793
5355
|
this.value = value;
|
|
4794
5356
|
this.HRP = HRP;
|
|
4795
5357
|
const preimageHash = utils_js.sha256(this.preimage);
|
|
4796
|
-
this.vtxoScript = new
|
|
5358
|
+
this.vtxoScript = new chunkFNCQJLR2_cjs.VtxoScript([noteTapscript(preimageHash)]);
|
|
4797
5359
|
const leaf = this.vtxoScript.leaves[0];
|
|
4798
5360
|
this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
|
|
4799
5361
|
this.tapTree = this.vtxoScript.encode();
|
|
@@ -4960,7 +5522,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
4960
5522
|
const privateKey = data.slice(1, 33);
|
|
4961
5523
|
const serverPubKey = data.slice(33, 65);
|
|
4962
5524
|
const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
|
|
4963
|
-
const csvTimelock =
|
|
5525
|
+
const csvTimelock = chunkFNCQJLR2_cjs.sequenceToTimelock(sequence);
|
|
4964
5526
|
return new _ArkadeCash(privateKey, serverPubKey, csvTimelock, decoded.prefix);
|
|
4965
5527
|
}
|
|
4966
5528
|
toString() {
|
|
@@ -4968,7 +5530,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
4968
5530
|
data[0] = _ArkadeCash.Version;
|
|
4969
5531
|
data.set(this._privateKey, 1);
|
|
4970
5532
|
data.set(this._serverPubKey, 33);
|
|
4971
|
-
const sequence =
|
|
5533
|
+
const sequence = chunkFNCQJLR2_cjs.timelockToSequence(this.csvTimelock);
|
|
4972
5534
|
new DataView(data.buffer, data.byteOffset + 65, 4).setUint32(0, sequence, false);
|
|
4973
5535
|
const words = base.bech32m.toWords(data);
|
|
4974
5536
|
return base.bech32m.encode(this.hrp, words, 1023);
|
|
@@ -4977,7 +5539,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
4977
5539
|
return SingleKey.fromPrivateKey(this._privateKey);
|
|
4978
5540
|
}
|
|
4979
5541
|
get vtxoScript() {
|
|
4980
|
-
return new
|
|
5542
|
+
return new chunkSF5NKAUA_cjs.DefaultVtxo.Script({
|
|
4981
5543
|
pubKey: this._publicKey,
|
|
4982
5544
|
serverPubKey: this._serverPubKey,
|
|
4983
5545
|
csvTimelock: this.csvTimelock
|
|
@@ -5238,7 +5800,7 @@ async function captureExitBranch(params) {
|
|
|
5238
5800
|
const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
|
|
5239
5801
|
if (nonCommitment.length > 0) {
|
|
5240
5802
|
for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
|
|
5241
|
-
psbtByTxid.set(
|
|
5803
|
+
psbtByTxid.set(chunkFNCQJLR2_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
5242
5804
|
}
|
|
5243
5805
|
}
|
|
5244
5806
|
}
|
|
@@ -5281,10 +5843,10 @@ var IndexerExitDataSource = class {
|
|
|
5281
5843
|
while (hasMore) {
|
|
5282
5844
|
const { chain: page, page: meta } = await this.indexer.getVtxoChain(
|
|
5283
5845
|
{ txid: vtxo.txid, vout: vtxo.vout },
|
|
5284
|
-
{ pageIndex, pageSize:
|
|
5846
|
+
{ pageIndex, pageSize: chunkFNCQJLR2_cjs.DEFAULT_PAGE_SIZE }
|
|
5285
5847
|
);
|
|
5286
5848
|
chain.push(...page);
|
|
5287
|
-
hasMore = meta ? page.length ===
|
|
5849
|
+
hasMore = meta ? page.length === chunkFNCQJLR2_cjs.DEFAULT_PAGE_SIZE : false;
|
|
5288
5850
|
pageIndex++;
|
|
5289
5851
|
}
|
|
5290
5852
|
return chain;
|
|
@@ -5296,12 +5858,12 @@ var IndexerExitDataSource = class {
|
|
|
5296
5858
|
while (hasMore) {
|
|
5297
5859
|
const { txs, page } = await this.indexer.getVirtualTxs(txids, {
|
|
5298
5860
|
pageIndex,
|
|
5299
|
-
pageSize:
|
|
5861
|
+
pageSize: chunkFNCQJLR2_cjs.DEFAULT_PAGE_SIZE
|
|
5300
5862
|
});
|
|
5301
5863
|
for (const psbt of txs) {
|
|
5302
|
-
out.set(
|
|
5864
|
+
out.set(chunkFNCQJLR2_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
5303
5865
|
}
|
|
5304
|
-
hasMore = page ? txs.length ===
|
|
5866
|
+
hasMore = page ? txs.length === chunkFNCQJLR2_cjs.DEFAULT_PAGE_SIZE : false;
|
|
5305
5867
|
pageIndex++;
|
|
5306
5868
|
}
|
|
5307
5869
|
return out;
|
|
@@ -5322,7 +5884,7 @@ function chainedTxTypeToChainTxType(t) {
|
|
|
5322
5884
|
}
|
|
5323
5885
|
}
|
|
5324
5886
|
function psbtInputTxids(psbtBase64) {
|
|
5325
|
-
const tx =
|
|
5887
|
+
const tx = chunkFNCQJLR2_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
5326
5888
|
const ids = [];
|
|
5327
5889
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
5328
5890
|
const txid = tx.getInput(i).txid;
|
|
@@ -5675,10 +6237,10 @@ async function resolveArkInfo(arkProvider, walletRepository) {
|
|
|
5675
6237
|
try {
|
|
5676
6238
|
info = await arkProvider.getInfo();
|
|
5677
6239
|
} catch (err) {
|
|
5678
|
-
if (!
|
|
6240
|
+
if (!chunkFNCQJLR2_cjs.isRetryableProviderError(err)) throw err;
|
|
5679
6241
|
const snapshot = await loadArkInfoSnapshot(walletRepository);
|
|
5680
6242
|
if (!snapshot) {
|
|
5681
|
-
throw new
|
|
6243
|
+
throw new chunkFNCQJLR2_cjs.ProviderUnavailableError(
|
|
5682
6244
|
"Arkade server info is unavailable and no cached snapshot exists",
|
|
5683
6245
|
{ cause: err }
|
|
5684
6246
|
);
|
|
@@ -6061,7 +6623,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos) {
|
|
|
6061
6623
|
return [...txids];
|
|
6062
6624
|
}
|
|
6063
6625
|
async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt) {
|
|
6064
|
-
const fromOldestVtxo = vtxos.map(
|
|
6626
|
+
const fromOldestVtxo = vtxos.map(chunkFNCQJLR2_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
6065
6627
|
const txidsNeedingCreatedAt = resolveTxCreatedAt ? collectArkTxidsNeedingCreatedAt(fromOldestVtxo) : [];
|
|
6066
6628
|
const resolvedCreatedAt = resolveTxCreatedAt && txidsNeedingCreatedAt.length > 0 ? await resolveTxCreatedAt(txidsNeedingCreatedAt) : /* @__PURE__ */ new Map();
|
|
6067
6629
|
const unmatchedSettledBoardingTxs = allBoardingTxs.filter(isSettledBoardingReceive).sort((a, b) => a.createdAt - b.createdAt);
|
|
@@ -6225,7 +6787,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6225
6787
|
const virtualCoins = await this.wallet.getSpendableVtxos({
|
|
6226
6788
|
withRecoverable: false
|
|
6227
6789
|
});
|
|
6228
|
-
const controlAssetRef = params.controlAssetId ?
|
|
6790
|
+
const controlAssetRef = params.controlAssetId ? chunk2JHN5RCY_cjs.AssetRef.fromId(chunk2JHN5RCY_cjs.AssetId.fromString(params.controlAssetId)) : null;
|
|
6229
6791
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
6230
6792
|
let totalBtcSelected = 0n;
|
|
6231
6793
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -6238,8 +6800,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6238
6800
|
}
|
|
6239
6801
|
}
|
|
6240
6802
|
const groups = [];
|
|
6241
|
-
const issuedAssetOutput =
|
|
6242
|
-
const issuedAssetGroup =
|
|
6803
|
+
const issuedAssetOutput = chunk2JHN5RCY_cjs.AssetOutput.create(0, params.amount);
|
|
6804
|
+
const issuedAssetGroup = chunk2JHN5RCY_cjs.AssetGroup.create(
|
|
6243
6805
|
null,
|
|
6244
6806
|
controlAssetRef,
|
|
6245
6807
|
[],
|
|
@@ -6254,28 +6816,28 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6254
6816
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6255
6817
|
for (const asset of assets) {
|
|
6256
6818
|
if (asset.assetId !== assetId) continue;
|
|
6257
|
-
changeInputs.push(
|
|
6819
|
+
changeInputs.push(chunk2JHN5RCY_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6258
6820
|
}
|
|
6259
6821
|
}
|
|
6260
6822
|
groups.push(
|
|
6261
|
-
|
|
6262
|
-
|
|
6823
|
+
chunk2JHN5RCY_cjs.AssetGroup.create(
|
|
6824
|
+
chunk2JHN5RCY_cjs.AssetId.fromString(assetId),
|
|
6263
6825
|
null,
|
|
6264
6826
|
changeInputs,
|
|
6265
|
-
[
|
|
6827
|
+
[chunk2JHN5RCY_cjs.AssetOutput.create(0, amount)],
|
|
6266
6828
|
[]
|
|
6267
6829
|
)
|
|
6268
6830
|
);
|
|
6269
6831
|
}
|
|
6270
6832
|
}
|
|
6271
6833
|
const address = await this.wallet.getAddress();
|
|
6272
|
-
const outputAddress =
|
|
6834
|
+
const outputAddress = chunkFNCQJLR2_cjs.ArkAddress.decode(address);
|
|
6273
6835
|
const outputs = [
|
|
6274
6836
|
{
|
|
6275
6837
|
script: outputAddress.pkScript,
|
|
6276
6838
|
amount: BigInt(totalBtcSelected)
|
|
6277
6839
|
},
|
|
6278
|
-
Extension.create([
|
|
6840
|
+
Extension.create([chunk2JHN5RCY_cjs.Packet.create(groups)]).txOut()
|
|
6279
6841
|
];
|
|
6280
6842
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
|
|
6281
6843
|
coinSelection.inputs,
|
|
@@ -6283,7 +6845,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6283
6845
|
);
|
|
6284
6846
|
return {
|
|
6285
6847
|
arkTxId: arkTxid,
|
|
6286
|
-
assetId:
|
|
6848
|
+
assetId: chunk2JHN5RCY_cjs.AssetId.create(arkTxid, 0).toString()
|
|
6287
6849
|
};
|
|
6288
6850
|
}
|
|
6289
6851
|
/**
|
|
@@ -6355,16 +6917,16 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6355
6917
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6356
6918
|
for (const asset of assets) {
|
|
6357
6919
|
if (asset.assetId !== params.assetId) continue;
|
|
6358
|
-
reissueInputs.push(
|
|
6920
|
+
reissueInputs.push(chunk2JHN5RCY_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6359
6921
|
}
|
|
6360
6922
|
}
|
|
6361
6923
|
const totalAssetAmount = assetToReissueAmount + params.amount;
|
|
6362
|
-
const reissueAssetIdObj =
|
|
6363
|
-
const reissueAssetGroup =
|
|
6924
|
+
const reissueAssetIdObj = chunk2JHN5RCY_cjs.AssetId.fromString(params.assetId);
|
|
6925
|
+
const reissueAssetGroup = chunk2JHN5RCY_cjs.AssetGroup.create(
|
|
6364
6926
|
reissueAssetIdObj,
|
|
6365
6927
|
null,
|
|
6366
6928
|
reissueInputs,
|
|
6367
|
-
[
|
|
6929
|
+
[chunk2JHN5RCY_cjs.AssetOutput.create(0, totalAssetAmount)],
|
|
6368
6930
|
[]
|
|
6369
6931
|
);
|
|
6370
6932
|
const groups = [reissueAssetGroup];
|
|
@@ -6373,27 +6935,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6373
6935
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6374
6936
|
for (const asset of assets) {
|
|
6375
6937
|
if (asset.assetId !== assetId) continue;
|
|
6376
|
-
changeInputs.push(
|
|
6938
|
+
changeInputs.push(chunk2JHN5RCY_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6377
6939
|
}
|
|
6378
6940
|
}
|
|
6379
6941
|
groups.push(
|
|
6380
|
-
|
|
6381
|
-
|
|
6942
|
+
chunk2JHN5RCY_cjs.AssetGroup.create(
|
|
6943
|
+
chunk2JHN5RCY_cjs.AssetId.fromString(assetId),
|
|
6382
6944
|
null,
|
|
6383
6945
|
changeInputs,
|
|
6384
|
-
[
|
|
6946
|
+
[chunk2JHN5RCY_cjs.AssetOutput.create(0, amount)],
|
|
6385
6947
|
[]
|
|
6386
6948
|
)
|
|
6387
6949
|
);
|
|
6388
6950
|
}
|
|
6389
6951
|
const address = await this.wallet.getAddress();
|
|
6390
|
-
const outputAddress =
|
|
6952
|
+
const outputAddress = chunkFNCQJLR2_cjs.ArkAddress.decode(address);
|
|
6391
6953
|
const outputs = [
|
|
6392
6954
|
{
|
|
6393
6955
|
script: outputAddress.pkScript,
|
|
6394
6956
|
amount: BigInt(totalBtcSelected)
|
|
6395
6957
|
},
|
|
6396
|
-
Extension.create([
|
|
6958
|
+
Extension.create([chunk2JHN5RCY_cjs.Packet.create(groups)]).txOut()
|
|
6397
6959
|
];
|
|
6398
6960
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
6399
6961
|
return arkTxid;
|
|
@@ -6460,27 +7022,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6460
7022
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6461
7023
|
for (const asset of assets) {
|
|
6462
7024
|
if (asset.assetId !== assetId) continue;
|
|
6463
|
-
changeInputs.push(
|
|
7025
|
+
changeInputs.push(chunk2JHN5RCY_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6464
7026
|
}
|
|
6465
7027
|
}
|
|
6466
7028
|
groups.push(
|
|
6467
|
-
|
|
6468
|
-
|
|
7029
|
+
chunk2JHN5RCY_cjs.AssetGroup.create(
|
|
7030
|
+
chunk2JHN5RCY_cjs.AssetId.fromString(assetId),
|
|
6469
7031
|
null,
|
|
6470
7032
|
changeInputs,
|
|
6471
|
-
amount > 0n ? [
|
|
7033
|
+
amount > 0n ? [chunk2JHN5RCY_cjs.AssetOutput.create(0, amount)] : [],
|
|
6472
7034
|
[]
|
|
6473
7035
|
)
|
|
6474
7036
|
);
|
|
6475
7037
|
}
|
|
6476
7038
|
const address = await this.wallet.getAddress();
|
|
6477
|
-
const outputAddress =
|
|
7039
|
+
const outputAddress = chunkFNCQJLR2_cjs.ArkAddress.decode(address);
|
|
6478
7040
|
const outputs = [
|
|
6479
7041
|
{
|
|
6480
7042
|
script: outputAddress.pkScript,
|
|
6481
7043
|
amount: BigInt(totalBtcSelected)
|
|
6482
7044
|
},
|
|
6483
|
-
Extension.create([
|
|
7045
|
+
Extension.create([chunk2JHN5RCY_cjs.Packet.create(groups)]).txOut()
|
|
6484
7046
|
];
|
|
6485
7047
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
6486
7048
|
return arkTxid;
|
|
@@ -6505,7 +7067,7 @@ function castMetadata(metadata) {
|
|
|
6505
7067
|
} else {
|
|
6506
7068
|
throw new Error("Invalid metadata value type");
|
|
6507
7069
|
}
|
|
6508
|
-
md.push(
|
|
7070
|
+
md.push(chunk2JHN5RCY_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
|
|
6509
7071
|
}
|
|
6510
7072
|
return md;
|
|
6511
7073
|
}
|
|
@@ -6526,10 +7088,10 @@ var DelegateManagerImpl = class {
|
|
|
6526
7088
|
if (vtxos.length === 0) {
|
|
6527
7089
|
return { delegated: [], failed: [] };
|
|
6528
7090
|
}
|
|
6529
|
-
const destinationScript =
|
|
7091
|
+
const destinationScript = chunkFNCQJLR2_cjs.ArkAddress.decode(destination).pkScript;
|
|
6530
7092
|
const arkInfo = await this.arkInfoProvider.getInfo();
|
|
6531
7093
|
const delegateInfo = await this.delegateProvider.getDelegateInfo();
|
|
6532
|
-
const eligible = vtxos.map(
|
|
7094
|
+
const eligible = vtxos.map(chunkFNCQJLR2_cjs.normalizeVtxo).filter(
|
|
6533
7095
|
(v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
|
|
6534
7096
|
);
|
|
6535
7097
|
if (eligible.length === 0) {
|
|
@@ -6558,11 +7120,11 @@ var DelegateManagerImpl = class {
|
|
|
6558
7120
|
const groupByExpiry = /* @__PURE__ */ new Map();
|
|
6559
7121
|
let recoverableVtxos = [];
|
|
6560
7122
|
for (const vtxo of eligible) {
|
|
6561
|
-
if (
|
|
7123
|
+
if (chunkFNCQJLR2_cjs.canRecoverOnchain(vtxo, now)) {
|
|
6562
7124
|
recoverableVtxos.push(vtxo);
|
|
6563
7125
|
continue;
|
|
6564
7126
|
}
|
|
6565
|
-
const expiry =
|
|
7127
|
+
const expiry = chunkFNCQJLR2_cjs.toBatchExpiry(vtxo);
|
|
6566
7128
|
if (!expiry) continue;
|
|
6567
7129
|
const dayKey = getDayTimestamp(expiry);
|
|
6568
7130
|
groupByExpiry.set(dayKey, [...groupByExpiry.get(dayKey) ?? [], vtxo]);
|
|
@@ -6627,7 +7189,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6627
7189
|
}
|
|
6628
7190
|
if (!delegateAt) {
|
|
6629
7191
|
const now = { timestamp: /* @__PURE__ */ new Date() };
|
|
6630
|
-
const expiryTimestamp = vtxos.filter((coin) => !
|
|
7192
|
+
const expiryTimestamp = vtxos.filter((coin) => !chunkFNCQJLR2_cjs.canRecoverOnchain(coin, now) && chunkFNCQJLR2_cjs.toBatchExpiry(coin)).reduce((min, coin) => Math.min(min, chunkFNCQJLR2_cjs.toBatchExpiry(coin)), Number.MAX_SAFE_INTEGER);
|
|
6631
7193
|
if (!expiryTimestamp || expiryTimestamp === Number.MAX_SAFE_INTEGER) {
|
|
6632
7194
|
delegateAt = new Date(Date.now() + 1 * 60 * 1e3);
|
|
6633
7195
|
} else {
|
|
@@ -6656,7 +7218,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6656
7218
|
let amount = 0n;
|
|
6657
7219
|
for (const coin of vtxos) {
|
|
6658
7220
|
const inputFee = estimator.evalOffchainInput({
|
|
6659
|
-
...
|
|
7221
|
+
...chunkFNCQJLR2_cjs.toOffchainInputFeeParams(coin),
|
|
6660
7222
|
type: "vtxo"
|
|
6661
7223
|
});
|
|
6662
7224
|
if (inputFee.value >= coin.value) {
|
|
@@ -6670,7 +7232,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6670
7232
|
const delegateFee = BigInt(Number(fee));
|
|
6671
7233
|
if (delegateFee > 0n) {
|
|
6672
7234
|
outputs.push({
|
|
6673
|
-
script:
|
|
7235
|
+
script: chunkFNCQJLR2_cjs.ArkAddress.decode(delegateAddress).pkScript,
|
|
6674
7236
|
amount: delegateFee
|
|
6675
7237
|
});
|
|
6676
7238
|
}
|
|
@@ -6703,10 +7265,10 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6703
7265
|
destinationScript
|
|
6704
7266
|
);
|
|
6705
7267
|
const forfeitOutputScript = btcSigner.OutScript.encode(
|
|
6706
|
-
btcSigner.Address(
|
|
7268
|
+
btcSigner.Address(chunkFNCQJLR2_cjs.getNetwork(network)).decode(forfeitAddress)
|
|
6707
7269
|
);
|
|
6708
7270
|
const forfeits = await Promise.all(
|
|
6709
|
-
vtxos.filter((v) => !
|
|
7271
|
+
vtxos.filter((v) => !chunkFNCQJLR2_cjs.canRecoverOnchain(v, { timestamp: /* @__PURE__ */ new Date() })).map(async (coin) => {
|
|
6710
7272
|
const forfeit = await makeDelegateForfeitTx(
|
|
6711
7273
|
coin,
|
|
6712
7274
|
dust,
|
|
@@ -6731,7 +7293,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
|
|
|
6731
7293
|
index: input.vout,
|
|
6732
7294
|
witnessUtxo: {
|
|
6733
7295
|
amount: BigInt(input.value),
|
|
6734
|
-
script:
|
|
7296
|
+
script: chunkFNCQJLR2_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
6735
7297
|
},
|
|
6736
7298
|
sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
|
|
6737
7299
|
tapLeafScript: [delegateTapLeaf]
|
|
@@ -6789,7 +7351,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
6789
7351
|
expire_at: 0,
|
|
6790
7352
|
cosigners_public_keys: cosignerPubKeys
|
|
6791
7353
|
};
|
|
6792
|
-
const proof =
|
|
7354
|
+
const proof = chunkFNCQJLR2_cjs.Intent.create(message, coins, outputs);
|
|
6793
7355
|
const signedProof = await identity.sign(proof);
|
|
6794
7356
|
return {
|
|
6795
7357
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -6807,10 +7369,10 @@ function getDayTimestamp(timestamp) {
|
|
|
6807
7369
|
function findDelegateTapLeaf(vtxo, delegatePubkey) {
|
|
6808
7370
|
if (!vtxo.tapTree) return void 0;
|
|
6809
7371
|
const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
|
|
6810
|
-
const vtxoScript =
|
|
7372
|
+
const vtxoScript = chunkFNCQJLR2_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
6811
7373
|
return vtxoScript.leaves.find((tapLeaf) => {
|
|
6812
|
-
const arkTapscript =
|
|
6813
|
-
if (!
|
|
7374
|
+
const arkTapscript = chunkFNCQJLR2_cjs.decodeTapscript(chunkFNCQJLR2_cjs.scriptFromTapLeafScript(tapLeaf));
|
|
7375
|
+
if (!chunkFNCQJLR2_cjs.MultisigTapscript.is(arkTapscript)) return false;
|
|
6814
7376
|
return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
|
|
6815
7377
|
});
|
|
6816
7378
|
}
|
|
@@ -6998,7 +7560,7 @@ async function closeDatabase(dbName) {
|
|
|
6998
7560
|
return true;
|
|
6999
7561
|
}
|
|
7000
7562
|
function scriptFromArkAddress(address) {
|
|
7001
|
-
return base.hex.encode(
|
|
7563
|
+
return base.hex.encode(chunkFNCQJLR2_cjs.ArkAddress.decode(address).pkScript);
|
|
7002
7564
|
}
|
|
7003
7565
|
|
|
7004
7566
|
// src/repositories/indexedDB/schema.ts
|
|
@@ -7495,7 +8057,7 @@ function validateVtxosForScript(vtxos, script, context) {
|
|
|
7495
8057
|
}
|
|
7496
8058
|
async function getVtxosForContract(repo, contract) {
|
|
7497
8059
|
const vtxos = repo.getVtxosForScript ? await repo.getVtxosForScript(contract.script) : filterVtxosForScript(await repo.getVtxos(contract.address), contract.script);
|
|
7498
|
-
return vtxos.map(
|
|
8060
|
+
return vtxos.map(chunkFNCQJLR2_cjs.normalizeVtxo);
|
|
7499
8061
|
}
|
|
7500
8062
|
async function saveVtxosForContract(repo, contract, vtxos) {
|
|
7501
8063
|
if (repo.saveVtxosForScript) {
|
|
@@ -7612,41 +8174,6 @@ function mergeByKey(existing, incoming, toKey) {
|
|
|
7612
8174
|
});
|
|
7613
8175
|
return Array.from(next.values());
|
|
7614
8176
|
}
|
|
7615
|
-
|
|
7616
|
-
// src/contracts/spendability.ts
|
|
7617
|
-
function isContractGenericallySpendable(contract) {
|
|
7618
|
-
return chunkMZNLCMUP_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
|
|
7619
|
-
}
|
|
7620
|
-
function gatedContracts(contracts) {
|
|
7621
|
-
const gated = /* @__PURE__ */ new Map();
|
|
7622
|
-
for (const contract of contracts) {
|
|
7623
|
-
if (!isContractGenericallySpendable(contract)) gated.set(contract.script, contract.type);
|
|
7624
|
-
}
|
|
7625
|
-
return gated;
|
|
7626
|
-
}
|
|
7627
|
-
function gateExclusion(gated) {
|
|
7628
|
-
return (vtxo) => {
|
|
7629
|
-
const type = vtxo.script === void 0 ? void 0 : gated.get(vtxo.script);
|
|
7630
|
-
if (type === void 0) return void 0;
|
|
7631
|
-
return `at ${vtxo.script} (contract type '${type}') is not generically spendable`;
|
|
7632
|
-
};
|
|
7633
|
-
}
|
|
7634
|
-
function outpointExclusion(outpoints, reason) {
|
|
7635
|
-
return (vtxo) => outpoints.has(`${vtxo.txid}:${vtxo.vout}`) ? reason : void 0;
|
|
7636
|
-
}
|
|
7637
|
-
function logExcludedVtxos(source, vtxos, exclusions) {
|
|
7638
|
-
if (exclusions.length === 0) return;
|
|
7639
|
-
for (const vtxo of vtxos) {
|
|
7640
|
-
for (const exclusion of exclusions) {
|
|
7641
|
-
const reason = exclusion(vtxo);
|
|
7642
|
-
if (reason === void 0) continue;
|
|
7643
|
-
console.debug(`[spendability] ${source}: ${vtxo.txid}:${vtxo.vout} ${reason}`);
|
|
7644
|
-
}
|
|
7645
|
-
}
|
|
7646
|
-
}
|
|
7647
|
-
var UnannotatableInputError = class extends Error {
|
|
7648
|
-
name = "UnannotatableInputError";
|
|
7649
|
-
};
|
|
7650
8177
|
var ARKCONTRACT_PREFIX = "arkcontract";
|
|
7651
8178
|
function encodeArkContract(contract) {
|
|
7652
8179
|
const params = new URLSearchParams();
|
|
@@ -7672,7 +8199,7 @@ function decodeArkContract(encoded) {
|
|
|
7672
8199
|
}
|
|
7673
8200
|
function contractFromArkContract(encoded, options = {}) {
|
|
7674
8201
|
const parsed = decodeArkContract(encoded);
|
|
7675
|
-
const handler =
|
|
8202
|
+
const handler = chunkSF5NKAUA_cjs.contractHandlers.get(parsed.type);
|
|
7676
8203
|
if (!handler) {
|
|
7677
8204
|
throw new Error(`No handler registered for contract type '${parsed.type}'`);
|
|
7678
8205
|
}
|
|
@@ -7686,9 +8213,9 @@ function contractFromArkContract(encoded, options = {}) {
|
|
|
7686
8213
|
metadata: options.metadata
|
|
7687
8214
|
};
|
|
7688
8215
|
}
|
|
7689
|
-
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix =
|
|
8216
|
+
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkFNCQJLR2_cjs.DEFAULT_NETWORK.hrp, options = {}) {
|
|
7690
8217
|
const parsed = decodeArkContract(encoded);
|
|
7691
|
-
const handler =
|
|
8218
|
+
const handler = chunkSF5NKAUA_cjs.contractHandlers.getOrThrow(parsed.type);
|
|
7692
8219
|
const params = parsed.data;
|
|
7693
8220
|
const vtxoScript = handler.createScript(params);
|
|
7694
8221
|
return {
|
|
@@ -7942,9 +8469,9 @@ var ContractWatcher = class {
|
|
|
7942
8469
|
this.connectionState = "connected";
|
|
7943
8470
|
this.reconnectAttempts = 0;
|
|
7944
8471
|
this.listenLoop().catch((e) => {
|
|
7945
|
-
if (
|
|
8472
|
+
if (chunkFNCQJLR2_cjs.isEventSourceError(e)) {
|
|
7946
8473
|
console.debug("ContractWatcher subscription disconnected; reconnecting");
|
|
7947
|
-
} else if (!
|
|
8474
|
+
} else if (!chunkFNCQJLR2_cjs.isEventSourceUnavailableError(e)) {
|
|
7948
8475
|
console.error(e);
|
|
7949
8476
|
}
|
|
7950
8477
|
this.connectionState = "disconnected";
|
|
@@ -7956,7 +8483,7 @@ var ContractWatcher = class {
|
|
|
7956
8483
|
this.scheduleReconnect();
|
|
7957
8484
|
});
|
|
7958
8485
|
} catch (error) {
|
|
7959
|
-
if (!
|
|
8486
|
+
if (!chunkFNCQJLR2_cjs.isEventSourceUnavailableError(error)) {
|
|
7960
8487
|
console.error("ContractWatcher connection failed:", error);
|
|
7961
8488
|
}
|
|
7962
8489
|
this.connectionState = "disconnected";
|
|
@@ -7982,7 +8509,7 @@ var ContractWatcher = class {
|
|
|
7982
8509
|
* slower; what it loses is push latency.
|
|
7983
8510
|
*/
|
|
7984
8511
|
reportEventSourceUnavailable(error) {
|
|
7985
|
-
if (!
|
|
8512
|
+
if (!chunkFNCQJLR2_cjs.isEventSourceUnavailableError(error)) return false;
|
|
7986
8513
|
if (!this.eventSourceReported) {
|
|
7987
8514
|
this.eventSourceReported = true;
|
|
7988
8515
|
console.warn(
|
|
@@ -8198,14 +8725,14 @@ var ContractWatcher = class {
|
|
|
8198
8725
|
const timestamp = Date.now();
|
|
8199
8726
|
if (update.newVtxos?.length) {
|
|
8200
8727
|
this.processSubscriptionVtxos(
|
|
8201
|
-
update.newVtxos.map(
|
|
8728
|
+
update.newVtxos.map(chunkFNCQJLR2_cjs.normalizeVtxo),
|
|
8202
8729
|
"vtxo_received",
|
|
8203
8730
|
timestamp
|
|
8204
8731
|
);
|
|
8205
8732
|
}
|
|
8206
8733
|
if (update.spentVtxos?.length) {
|
|
8207
8734
|
this.processSubscriptionVtxos(
|
|
8208
|
-
update.spentVtxos.map(
|
|
8735
|
+
update.spentVtxos.map(chunkFNCQJLR2_cjs.normalizeVtxo),
|
|
8209
8736
|
"vtxo_spent",
|
|
8210
8737
|
timestamp
|
|
8211
8738
|
);
|
|
@@ -8338,7 +8865,7 @@ async function reconcileIntents(deps) {
|
|
|
8338
8865
|
let vtxosByOutpoint = /* @__PURE__ */ new Map();
|
|
8339
8866
|
if (outpoints.length > 0) {
|
|
8340
8867
|
try {
|
|
8341
|
-
const { vtxos } = await
|
|
8868
|
+
const { vtxos } = await chunkFNCQJLR2_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
|
|
8342
8869
|
vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
|
|
8343
8870
|
} catch (e) {
|
|
8344
8871
|
console.error("reconcileIntents: failed to fetch input VTXO state", e);
|
|
@@ -8512,7 +9039,7 @@ var ContractManager = class _ContractManager {
|
|
|
8512
9039
|
await this.reconcileWatched();
|
|
8513
9040
|
this.markSyncOnline();
|
|
8514
9041
|
} catch (err) {
|
|
8515
|
-
if (!
|
|
9042
|
+
if (!chunkFNCQJLR2_cjs.isRetryableProviderError(err)) throw err;
|
|
8516
9043
|
this.markSyncDegraded(err);
|
|
8517
9044
|
}
|
|
8518
9045
|
this.initialized = true;
|
|
@@ -8644,7 +9171,7 @@ var ContractManager = class _ContractManager {
|
|
|
8644
9171
|
const from = Math.max(0, watermark - lookAhead.size);
|
|
8645
9172
|
const to = watermark + lookAhead.size;
|
|
8646
9173
|
const deps = lookAhead.candidateDeps();
|
|
8647
|
-
const handlers =
|
|
9174
|
+
const handlers = chunkSF5NKAUA_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkSF5NKAUA_cjs.contractHandlers.get(t)).filter(hasCandidates);
|
|
8648
9175
|
const band = /* @__PURE__ */ new Map();
|
|
8649
9176
|
for (let index = from; index <= to; index++) {
|
|
8650
9177
|
const descriptor = lookAhead.materialize(index);
|
|
@@ -8655,7 +9182,7 @@ var ContractManager = class _ContractManager {
|
|
|
8655
9182
|
index,
|
|
8656
9183
|
params: {
|
|
8657
9184
|
...candidate,
|
|
8658
|
-
...
|
|
9185
|
+
...chunkSF5NKAUA_cjs.speculativeReceiveMetadata(descriptor)
|
|
8659
9186
|
}
|
|
8660
9187
|
});
|
|
8661
9188
|
}
|
|
@@ -8717,7 +9244,7 @@ var ContractManager = class _ContractManager {
|
|
|
8717
9244
|
});
|
|
8718
9245
|
for (const entry of pending) entry.catchUpPending = false;
|
|
8719
9246
|
} catch (err) {
|
|
8720
|
-
if (!
|
|
9247
|
+
if (!chunkFNCQJLR2_cjs.isRetryableProviderError(err)) throw err;
|
|
8721
9248
|
this.markSyncDegraded(err);
|
|
8722
9249
|
}
|
|
8723
9250
|
}
|
|
@@ -8767,7 +9294,7 @@ var ContractManager = class _ContractManager {
|
|
|
8767
9294
|
await this.fetchContractVxosFromIndexer([contract]);
|
|
8768
9295
|
this.markSyncOnline();
|
|
8769
9296
|
} catch (err) {
|
|
8770
|
-
if (!
|
|
9297
|
+
if (!chunkFNCQJLR2_cjs.isRetryableProviderError(err)) throw err;
|
|
8771
9298
|
this.markSyncDegraded(err);
|
|
8772
9299
|
}
|
|
8773
9300
|
await this.watcher.addContract(contract);
|
|
@@ -8804,7 +9331,7 @@ var ContractManager = class _ContractManager {
|
|
|
8804
9331
|
return result;
|
|
8805
9332
|
}
|
|
8806
9333
|
async upsertContractRow(params) {
|
|
8807
|
-
const handler =
|
|
9334
|
+
const handler = chunkSF5NKAUA_cjs.contractHandlers.get(params.type);
|
|
8808
9335
|
if (!handler) {
|
|
8809
9336
|
throw new Error(`No handler registered for contract type '${params.type}'`);
|
|
8810
9337
|
}
|
|
@@ -8904,7 +9431,7 @@ var ContractManager = class _ContractManager {
|
|
|
8904
9431
|
`scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
|
|
8905
9432
|
);
|
|
8906
9433
|
}
|
|
8907
|
-
const registered =
|
|
9434
|
+
const registered = chunkSF5NKAUA_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkSF5NKAUA_cjs.contractHandlers.get(t)).filter(isDiscoverable);
|
|
8908
9435
|
const discoverables = [
|
|
8909
9436
|
...registered.filter((h) => h.type === "boarding"),
|
|
8910
9437
|
...registered.filter((h) => h.type !== "boarding")
|
|
@@ -9039,7 +9566,7 @@ var ContractManager = class _ContractManager {
|
|
|
9039
9566
|
await this.syncContracts({ contracts, pageSize });
|
|
9040
9567
|
this.markSyncOnline();
|
|
9041
9568
|
} catch (err) {
|
|
9042
|
-
if (!
|
|
9569
|
+
if (!chunkFNCQJLR2_cjs.isRetryableProviderError(err)) throw err;
|
|
9043
9570
|
this.markSyncDegraded(err);
|
|
9044
9571
|
}
|
|
9045
9572
|
const vtxos = await this.getVtxosForContracts(contracts);
|
|
@@ -9060,7 +9587,7 @@ var ContractManager = class _ContractManager {
|
|
|
9060
9587
|
}
|
|
9061
9588
|
const tapscriptCache = tapscripts ?? /* @__PURE__ */ new Map();
|
|
9062
9589
|
return vtxos.map(
|
|
9063
|
-
(vtxo) => extendVirtualCoinForContract(
|
|
9590
|
+
(vtxo) => extendVirtualCoinForContract(chunkFNCQJLR2_cjs.normalizeVtxo(vtxo), byScript, tapscriptCache)
|
|
9064
9591
|
);
|
|
9065
9592
|
}
|
|
9066
9593
|
/** @inheritdoc */
|
|
@@ -9087,21 +9614,31 @@ var ContractManager = class _ContractManager {
|
|
|
9087
9614
|
}
|
|
9088
9615
|
/** @inheritdoc */
|
|
9089
9616
|
async assertSpendableNow(vtxos, walletPubKey) {
|
|
9090
|
-
|
|
9617
|
+
const refused = await this.unspendableNowReasons(vtxos, walletPubKey);
|
|
9618
|
+
if (refused.size === 0) return;
|
|
9619
|
+
if (refused.size === 1) throw new Error([...refused.values()][0]);
|
|
9620
|
+
throw new Error(
|
|
9621
|
+
`refusing to spend ${refused.size} vtxo(s) that cannot be spent yet: ` + [...refused].map(([outpoint, why]) => `${outpoint}: ${why}`).join("; ")
|
|
9622
|
+
);
|
|
9623
|
+
}
|
|
9624
|
+
/** @inheritdoc */
|
|
9625
|
+
async unspendableNowReasons(vtxos, walletPubKey) {
|
|
9626
|
+
const refused = /* @__PURE__ */ new Map();
|
|
9627
|
+
if (vtxos.length === 0) return refused;
|
|
9091
9628
|
const contracts = await this.config.contractRepository.getContracts({
|
|
9092
9629
|
script: Array.from(new Set(vtxos.map((vtxo) => vtxo.script)))
|
|
9093
9630
|
});
|
|
9094
9631
|
const byScript = new Map(contracts.map((contract) => [contract.script, contract]));
|
|
9095
9632
|
const asking = vtxos.filter((vtxo) => {
|
|
9096
9633
|
const contract = byScript.get(vtxo.script);
|
|
9097
|
-
return contract !== void 0 &&
|
|
9634
|
+
return contract !== void 0 && chunkSF5NKAUA_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
|
|
9098
9635
|
});
|
|
9099
|
-
if (asking.length === 0) return;
|
|
9636
|
+
if (asking.length === 0) return refused;
|
|
9100
9637
|
const tip = await this.currentChainTip();
|
|
9101
9638
|
const walletKey = await walletPubKey?.();
|
|
9102
9639
|
for (const vtxo of asking) {
|
|
9103
9640
|
const contract = byScript.get(vtxo.script);
|
|
9104
|
-
const handler =
|
|
9641
|
+
const handler = chunkSF5NKAUA_cjs.contractHandlers.get(contract.type);
|
|
9105
9642
|
if (!handler?.assertSpendableNow) continue;
|
|
9106
9643
|
const context = {
|
|
9107
9644
|
collaborative: true,
|
|
@@ -9116,14 +9653,22 @@ var ContractManager = class _ContractManager {
|
|
|
9116
9653
|
// the next handler to answer a CSV question would meet a
|
|
9117
9654
|
// TypeError instead of a `false`. Carry the coin only when it
|
|
9118
9655
|
// really is one.
|
|
9119
|
-
vtxo:
|
|
9656
|
+
vtxo: chunkFNCQJLR2_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
|
|
9120
9657
|
};
|
|
9121
|
-
|
|
9122
|
-
handler.
|
|
9123
|
-
|
|
9124
|
-
|
|
9125
|
-
|
|
9658
|
+
try {
|
|
9659
|
+
await handler.assertSpendableNow(
|
|
9660
|
+
handler.createScript(contract.params),
|
|
9661
|
+
contract,
|
|
9662
|
+
context
|
|
9663
|
+
);
|
|
9664
|
+
} catch (err) {
|
|
9665
|
+
refused.set(
|
|
9666
|
+
`${vtxo.txid}:${vtxo.vout}`,
|
|
9667
|
+
err instanceof Error ? err.message : String(err)
|
|
9668
|
+
);
|
|
9669
|
+
}
|
|
9126
9670
|
}
|
|
9671
|
+
return refused;
|
|
9127
9672
|
}
|
|
9128
9673
|
// Field-by-field, so every filter a caller can express reaches the
|
|
9129
9674
|
// repository. A field missing here is not a narrower query — it is an
|
|
@@ -9264,7 +9809,7 @@ var ContractManager = class _ContractManager {
|
|
|
9264
9809
|
const { contractScript, collaborative = true, walletPubKey, vtxo } = options;
|
|
9265
9810
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
9266
9811
|
if (!contract) return [];
|
|
9267
|
-
const handler =
|
|
9812
|
+
const handler = chunkSF5NKAUA_cjs.contractHandlers.get(contract.type);
|
|
9268
9813
|
if (!handler) return [];
|
|
9269
9814
|
const script = handler.createScript(contract.params);
|
|
9270
9815
|
const tip = await this.currentChainTip();
|
|
@@ -9292,7 +9837,7 @@ var ContractManager = class _ContractManager {
|
|
|
9292
9837
|
const { contractScript, collaborative = true, walletPubKey } = options;
|
|
9293
9838
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
9294
9839
|
if (!contract) return [];
|
|
9295
|
-
const handler =
|
|
9840
|
+
const handler = chunkSF5NKAUA_cjs.contractHandlers.get(contract.type);
|
|
9296
9841
|
if (!handler) return [];
|
|
9297
9842
|
const script = handler.createScript(contract.params);
|
|
9298
9843
|
const context = {
|
|
@@ -9348,7 +9893,7 @@ var ContractManager = class _ContractManager {
|
|
|
9348
9893
|
}
|
|
9349
9894
|
async refreshOutpoints(outpoints) {
|
|
9350
9895
|
if (outpoints.length === 0) return;
|
|
9351
|
-
const { vtxos } = await
|
|
9896
|
+
const { vtxos } = await chunkFNCQJLR2_cjs.getNormalizedVtxos(this.config.indexerProvider, {
|
|
9352
9897
|
outpoints
|
|
9353
9898
|
});
|
|
9354
9899
|
if (vtxos.length === 0) return;
|
|
@@ -9427,7 +9972,7 @@ var ContractManager = class _ContractManager {
|
|
|
9427
9972
|
break;
|
|
9428
9973
|
}
|
|
9429
9974
|
} catch (err) {
|
|
9430
|
-
if (!
|
|
9975
|
+
if (!chunkFNCQJLR2_cjs.isRetryableProviderError(err)) throw err;
|
|
9431
9976
|
this.markSyncDegraded(err);
|
|
9432
9977
|
}
|
|
9433
9978
|
this.emitEvent(event);
|
|
@@ -9506,7 +10051,7 @@ var ContractManager = class _ContractManager {
|
|
|
9506
10051
|
*/
|
|
9507
10052
|
async reconcilePendingFrontier(contracts) {
|
|
9508
10053
|
const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
|
|
9509
|
-
const vtxos = await
|
|
10054
|
+
const vtxos = await chunkFNCQJLR2_cjs.getAllNormalizedVtxos(
|
|
9510
10055
|
this.config.indexerProvider,
|
|
9511
10056
|
contracts.map((c) => c.script),
|
|
9512
10057
|
{ pendingOnly: true }
|
|
@@ -9589,7 +10134,7 @@ var ContractManager = class _ContractManager {
|
|
|
9589
10134
|
}
|
|
9590
10135
|
return result;
|
|
9591
10136
|
}
|
|
9592
|
-
async fetchContractVtxosBulk(contracts, pageSize =
|
|
10137
|
+
async fetchContractVtxosBulk(contracts, pageSize = chunkFNCQJLR2_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
|
|
9593
10138
|
if (contracts.length === 0) {
|
|
9594
10139
|
return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
|
|
9595
10140
|
}
|
|
@@ -9605,7 +10150,7 @@ var ContractManager = class _ContractManager {
|
|
|
9605
10150
|
before: syncWindow.before
|
|
9606
10151
|
}
|
|
9607
10152
|
} : {};
|
|
9608
|
-
const vtxos = await
|
|
10153
|
+
const vtxos = await chunkFNCQJLR2_cjs.getAllNormalizedVtxos(
|
|
9609
10154
|
this.config.indexerProvider,
|
|
9610
10155
|
contracts.map((c) => c.script),
|
|
9611
10156
|
{ ...windowOpts, pageSize }
|
|
@@ -9750,7 +10295,7 @@ var deserializeTapLeaf = (t) => {
|
|
|
9750
10295
|
const s = base.hex.decode(t.s);
|
|
9751
10296
|
return [cb, s];
|
|
9752
10297
|
};
|
|
9753
|
-
var deserializeVtxo = (o) =>
|
|
10298
|
+
var deserializeVtxo = (o) => chunkFNCQJLR2_cjs.normalizeVtxo({
|
|
9754
10299
|
...o,
|
|
9755
10300
|
createdAt: new Date(o.createdAt),
|
|
9756
10301
|
tapTree: base.hex.decode(o.tapTree),
|
|
@@ -10791,7 +11336,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
10791
11336
|
*/
|
|
10792
11337
|
materializeDescriptorAt(index) {
|
|
10793
11338
|
const descriptor = this.identity.descriptor;
|
|
10794
|
-
const network =
|
|
11339
|
+
const network = chunkSF5NKAUA_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
10795
11340
|
const expansion = descriptorsScure.expand({ descriptor, network, index });
|
|
10796
11341
|
const keyInfo = expansion.expansionMap?.["@0"];
|
|
10797
11342
|
if (!keyInfo?.keyExpression) {
|
|
@@ -10939,7 +11484,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
10939
11484
|
const provider = await resolveDescriptorProvider(config, setup.walletRepository);
|
|
10940
11485
|
if (!provider) return void 0;
|
|
10941
11486
|
const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
|
|
10942
|
-
const expectedContractType = setup.offchainTapscript instanceof
|
|
11487
|
+
const expectedContractType = setup.offchainTapscript instanceof chunkSF5NKAUA_cjs.DelegateVtxo.Script ? "delegate" : "default";
|
|
10943
11488
|
const factoryOpts = {
|
|
10944
11489
|
walletRepository: setup.walletRepository,
|
|
10945
11490
|
contractRepository: setup.contractRepository,
|
|
@@ -11138,7 +11683,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
11138
11683
|
};
|
|
11139
11684
|
function deriveLeafPubkey(descriptor) {
|
|
11140
11685
|
try {
|
|
11141
|
-
return
|
|
11686
|
+
return chunkSF5NKAUA_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
11142
11687
|
} catch (e) {
|
|
11143
11688
|
throw new NonRangeableDescriptorError(
|
|
11144
11689
|
"Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
|
|
@@ -11150,7 +11695,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
11150
11695
|
const pubKey = deriveLeafPubkey(descriptor);
|
|
11151
11696
|
const tapscript = rebuildTapscript(current, pubKey);
|
|
11152
11697
|
const serverPubKey = tapscript.options.serverPubKey;
|
|
11153
|
-
const csvTimelock =
|
|
11698
|
+
const csvTimelock = chunkFNCQJLR2_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
|
|
11154
11699
|
const base$1 = {
|
|
11155
11700
|
script: base.hex.encode(tapscript.pkScript),
|
|
11156
11701
|
address: tapscript.address(hrp, serverPubKey).encode(),
|
|
@@ -11161,11 +11706,11 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
11161
11706
|
// index-0 key. Without it, spends produce unsigned PSBTs that the
|
|
11162
11707
|
// server rejects with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
11163
11708
|
metadata: {
|
|
11164
|
-
...{ source:
|
|
11709
|
+
...{ source: chunkSF5NKAUA_cjs.WALLET_RECEIVE_SOURCE },
|
|
11165
11710
|
signingDescriptor: descriptor
|
|
11166
11711
|
}
|
|
11167
11712
|
};
|
|
11168
|
-
const params = tapscript instanceof
|
|
11713
|
+
const params = tapscript instanceof chunkSF5NKAUA_cjs.DelegateVtxo.Script ? {
|
|
11169
11714
|
...base$1,
|
|
11170
11715
|
type: "delegate",
|
|
11171
11716
|
params: {
|
|
@@ -11186,10 +11731,10 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
11186
11731
|
return { tapscript, params };
|
|
11187
11732
|
}
|
|
11188
11733
|
function rebuildTapscript(current, pubKey) {
|
|
11189
|
-
if (current instanceof
|
|
11190
|
-
return new
|
|
11734
|
+
if (current instanceof chunkSF5NKAUA_cjs.DelegateVtxo.Script) {
|
|
11735
|
+
return new chunkSF5NKAUA_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
|
|
11191
11736
|
}
|
|
11192
|
-
return new
|
|
11737
|
+
return new chunkSF5NKAUA_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
|
|
11193
11738
|
}
|
|
11194
11739
|
async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
|
|
11195
11740
|
const candidates = await contractRepository.getContracts({
|
|
@@ -11198,7 +11743,7 @@ async function pickActiveReceive(contractRepository, serverPubKey, expectedType)
|
|
|
11198
11743
|
});
|
|
11199
11744
|
const serverPubKeyHex = base.hex.encode(serverPubKey);
|
|
11200
11745
|
const matching = candidates.filter(
|
|
11201
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
11746
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkSF5NKAUA_cjs.WALLET_RECEIVE_SOURCE
|
|
11202
11747
|
).sort((a, b) => {
|
|
11203
11748
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
11204
11749
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -11251,17 +11796,17 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
11251
11796
|
}
|
|
11252
11797
|
};
|
|
11253
11798
|
for (const vtxo of vtxos) {
|
|
11254
|
-
if (
|
|
11799
|
+
if (chunkFNCQJLR2_cjs.hasTerminalSpend(vtxo)) continue;
|
|
11255
11800
|
addAssets(owned, vtxo);
|
|
11256
11801
|
if (isPendingRecovery(vtxo)) {
|
|
11257
11802
|
pendingRecovery += vtxo.value;
|
|
11258
11803
|
continue;
|
|
11259
11804
|
}
|
|
11260
|
-
if (
|
|
11805
|
+
if (chunkFNCQJLR2_cjs.canRecoverOnchain(vtxo, now)) {
|
|
11261
11806
|
recoverable += vtxo.value;
|
|
11262
11807
|
continue;
|
|
11263
11808
|
}
|
|
11264
|
-
if (!
|
|
11809
|
+
if (!chunkFNCQJLR2_cjs.canSpendOffchain(vtxo, now)) continue;
|
|
11265
11810
|
if (vtxo.isPreconfirmed) {
|
|
11266
11811
|
preconfirmed += vtxo.value;
|
|
11267
11812
|
} else {
|
|
@@ -11424,12 +11969,12 @@ var InputSignerRouter = class {
|
|
|
11424
11969
|
};
|
|
11425
11970
|
|
|
11426
11971
|
// src/wallet/wallet.ts
|
|
11427
|
-
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl ||
|
|
11972
|
+
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl || chunkFNCQJLR2_cjs.DEFAULT_ARKADE_SERVER_URL;
|
|
11428
11973
|
function intentProofJobs(coins) {
|
|
11429
11974
|
if (coins.length === 0) return [];
|
|
11430
11975
|
const coinJobs = coins.map((coin, i) => ({
|
|
11431
11976
|
index: i + 1,
|
|
11432
|
-
lookupScript:
|
|
11977
|
+
lookupScript: chunkFNCQJLR2_cjs.VtxoScript.decode(coin.tapTree).pkScript
|
|
11433
11978
|
}));
|
|
11434
11979
|
return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
|
|
11435
11980
|
}
|
|
@@ -11455,7 +12000,7 @@ function dedupeTimelocks(timelocks) {
|
|
|
11455
12000
|
const seen = /* @__PURE__ */ new Set();
|
|
11456
12001
|
const deduped = [];
|
|
11457
12002
|
for (const timelock of timelocks) {
|
|
11458
|
-
const sequence =
|
|
12003
|
+
const sequence = chunkFNCQJLR2_cjs.timelockToSequence(timelock).toString();
|
|
11459
12004
|
if (seen.has(sequence)) continue;
|
|
11460
12005
|
seen.add(sequence);
|
|
11461
12006
|
deduped.push(timelock);
|
|
@@ -11472,7 +12017,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
11472
12017
|
state: "active"
|
|
11473
12018
|
});
|
|
11474
12019
|
const newest = candidates.filter(
|
|
11475
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
12020
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkSF5NKAUA_cjs.WALLET_RECEIVE_SOURCE
|
|
11476
12021
|
).sort((a, b) => {
|
|
11477
12022
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
11478
12023
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -11480,7 +12025,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
11480
12025
|
if (!newest?.params.pubKey) return baseline;
|
|
11481
12026
|
try {
|
|
11482
12027
|
const pubKey = base.hex.decode(newest.params.pubKey);
|
|
11483
|
-
return new
|
|
12028
|
+
return new chunkSF5NKAUA_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
|
|
11484
12029
|
} catch (e) {
|
|
11485
12030
|
console.warn("Skipping malformed boarding contract at boot", newest.script, e);
|
|
11486
12031
|
return baseline;
|
|
@@ -11496,8 +12041,8 @@ function filterSnapshotVtxos(snapshot, filter, pendingSpendOutpoints) {
|
|
|
11496
12041
|
if (pendingSpendOutpoints.has(`${vtxo.txid}:${vtxo.vout}`)) {
|
|
11497
12042
|
return false;
|
|
11498
12043
|
}
|
|
11499
|
-
if (!
|
|
11500
|
-
if (!f.withRecoverable &&
|
|
12044
|
+
if (!chunkFNCQJLR2_cjs.hasTerminalSpend(vtxo)) {
|
|
12045
|
+
if (!f.withRecoverable && chunkFNCQJLR2_cjs.canRecoverOnchain(vtxo, now)) {
|
|
11501
12046
|
return false;
|
|
11502
12047
|
}
|
|
11503
12048
|
return true;
|
|
@@ -11838,7 +12383,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11838
12383
|
*/
|
|
11839
12384
|
static async setupWalletConfig(config, pubKey) {
|
|
11840
12385
|
const arkadeServerUrl = getArkadeServerUrl(config);
|
|
11841
|
-
const arkProvider = config.arkProvider || new
|
|
12386
|
+
const arkProvider = config.arkProvider || new chunkFNCQJLR2_cjs.RestArkProvider(arkadeServerUrl);
|
|
11842
12387
|
let indexerProvider = config.indexerProvider;
|
|
11843
12388
|
if (!indexerProvider) {
|
|
11844
12389
|
let indexerUrl = config.indexerUrl;
|
|
@@ -11855,7 +12400,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11855
12400
|
indexerUrl = arkadeServerUrl;
|
|
11856
12401
|
}
|
|
11857
12402
|
}
|
|
11858
|
-
indexerProvider = new
|
|
12403
|
+
indexerProvider = new chunk2JHN5RCY_cjs.RestIndexerProvider(indexerUrl);
|
|
11859
12404
|
}
|
|
11860
12405
|
const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
11861
12406
|
const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
@@ -11864,7 +12409,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11864
12409
|
source: serverInfoSource,
|
|
11865
12410
|
lastOnlineAt: serverInfoLastOnlineAt
|
|
11866
12411
|
} = await resolveArkInfo(arkProvider, walletRepository);
|
|
11867
|
-
const network =
|
|
12412
|
+
const network = chunkFNCQJLR2_cjs.getNetwork(info.network);
|
|
11868
12413
|
if ("descriptor" in config.identity) {
|
|
11869
12414
|
const descriptor = config.identity.descriptor;
|
|
11870
12415
|
const identityIsMainnet = !descriptor.includes("tpub");
|
|
@@ -11911,11 +12456,11 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11911
12456
|
serverPubKey,
|
|
11912
12457
|
csvTimelock: exitTimelock
|
|
11913
12458
|
};
|
|
11914
|
-
const offchainTapscript = !delegatePubKey ? new
|
|
11915
|
-
const boardingTapscript =
|
|
12459
|
+
const offchainTapscript = !delegatePubKey ? new chunkSF5NKAUA_cjs.DefaultVtxo.Script(offchainOptions) : new chunkSF5NKAUA_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
|
|
12460
|
+
const boardingTapscript = chunkSF5NKAUA_cjs.BoardingContractHandler.createScript({
|
|
11916
12461
|
pubKey: base.hex.encode(pubKey),
|
|
11917
12462
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
11918
|
-
csvTimelock:
|
|
12463
|
+
csvTimelock: chunkFNCQJLR2_cjs.timelockToSequence(boardingTimelock).toString()
|
|
11919
12464
|
});
|
|
11920
12465
|
return {
|
|
11921
12466
|
arkProvider,
|
|
@@ -12210,7 +12755,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12210
12755
|
const response = await contractManager.getContractsWithVtxos();
|
|
12211
12756
|
const allVtxos = response.flatMap((_) => _.vtxos);
|
|
12212
12757
|
const { boardingTxs, commitmentsToIgnore } = await this.getBoardingTxs();
|
|
12213
|
-
const resolveTxCreatedAt = (txids) =>
|
|
12758
|
+
const resolveTxCreatedAt = (txids) => chunkFNCQJLR2_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
|
|
12214
12759
|
return buildTransactionHistory(
|
|
12215
12760
|
allVtxos,
|
|
12216
12761
|
boardingTxs,
|
|
@@ -12304,7 +12849,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12304
12849
|
},
|
|
12305
12850
|
isUnrolled: true,
|
|
12306
12851
|
...boardingFacts,
|
|
12307
|
-
virtualStatus:
|
|
12852
|
+
virtualStatus: chunkFNCQJLR2_cjs.toVirtualStatus(boardingFacts),
|
|
12308
12853
|
spentBy: "",
|
|
12309
12854
|
createdAt: tx.status.confirmed ? new Date(tx.status.block_time * 1e3) : /* @__PURE__ */ new Date(0),
|
|
12310
12855
|
script: scriptHex
|
|
@@ -12360,9 +12905,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12360
12905
|
async getBoardingTapscripts(allowedSigners) {
|
|
12361
12906
|
const byScript = /* @__PURE__ */ new Map();
|
|
12362
12907
|
const add = (s) => byScript.set(base.hex.encode(s.pkScript), s);
|
|
12363
|
-
const boardingCsv = this.boardingTapscript.options.csvTimelock ??
|
|
12908
|
+
const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkSF5NKAUA_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
12364
12909
|
add(
|
|
12365
|
-
new
|
|
12910
|
+
new chunkSF5NKAUA_cjs.DefaultVtxo.Script({
|
|
12366
12911
|
pubKey: await this.identity.xOnlyPublicKey(),
|
|
12367
12912
|
serverPubKey: this.boardingTapscript.options.serverPubKey,
|
|
12368
12913
|
csvTimelock: boardingCsv
|
|
@@ -12377,7 +12922,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12377
12922
|
for (const c of boardingContracts) {
|
|
12378
12923
|
if (!allowed.has(toXOnlySignerHex(c.params.serverPubKey))) continue;
|
|
12379
12924
|
try {
|
|
12380
|
-
add(
|
|
12925
|
+
add(chunkSF5NKAUA_cjs.BoardingContractHandler.createScript(c.params));
|
|
12381
12926
|
} catch (e) {
|
|
12382
12927
|
console.warn("Skipping malformed boarding contract", c.script, e);
|
|
12383
12928
|
}
|
|
@@ -12415,7 +12960,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12415
12960
|
// Per-row CSV delay decoded from THIS tapscript's exit leaf —
|
|
12416
12961
|
// not the wallet's current boarding timelock, which a signer
|
|
12417
12962
|
// rotation may have changed.
|
|
12418
|
-
csvTimelock:
|
|
12963
|
+
csvTimelock: chunkFNCQJLR2_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
|
|
12419
12964
|
coins: utxos
|
|
12420
12965
|
});
|
|
12421
12966
|
}
|
|
@@ -12548,7 +13093,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12548
13093
|
/** Fetch Arkade transaction ids that are still pending final settlement. */
|
|
12549
13094
|
async fetchPendingTxs() {
|
|
12550
13095
|
const scripts = await this.getWalletScripts();
|
|
12551
|
-
const vtxos = await
|
|
13096
|
+
const vtxos = await chunkFNCQJLR2_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
|
|
12552
13097
|
return vtxos.filter(
|
|
12553
13098
|
(vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
|
|
12554
13099
|
).map((_) => _.arkTxId);
|
|
@@ -12579,7 +13124,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12579
13124
|
});
|
|
12580
13125
|
for (const contract of contracts) {
|
|
12581
13126
|
if (map.has(contract.script)) continue;
|
|
12582
|
-
const handler =
|
|
13127
|
+
const handler = chunkSF5NKAUA_cjs.contractHandlers.get(contract.type);
|
|
12583
13128
|
if (handler) {
|
|
12584
13129
|
const script = handler.createScript(contract.params);
|
|
12585
13130
|
map.set(contract.script, script);
|
|
@@ -12691,7 +13236,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12691
13236
|
}
|
|
12692
13237
|
});
|
|
12693
13238
|
const baselinePubkey = await this.identity.xOnlyPublicKey();
|
|
12694
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
13239
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkSF5NKAUA_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
12695
13240
|
const baselineSigners = [
|
|
12696
13241
|
this.offchainTapscript.options.serverPubKey,
|
|
12697
13242
|
...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
|
|
@@ -12699,8 +13244,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12699
13244
|
const seenBaselineScripts = /* @__PURE__ */ new Set();
|
|
12700
13245
|
for (const serverPubKey of baselineSigners) {
|
|
12701
13246
|
for (const csvTimelock of this.walletContractTimelocks) {
|
|
12702
|
-
const csvTimelockStr =
|
|
12703
|
-
const defaultScript = new
|
|
13247
|
+
const csvTimelockStr = chunkFNCQJLR2_cjs.timelockToSequence(csvTimelock).toString();
|
|
13248
|
+
const defaultScript = new chunkSF5NKAUA_cjs.DefaultVtxo.Script({
|
|
12704
13249
|
pubKey: baselinePubkey,
|
|
12705
13250
|
serverPubKey,
|
|
12706
13251
|
csvTimelock
|
|
@@ -12721,7 +13266,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12721
13266
|
});
|
|
12722
13267
|
}
|
|
12723
13268
|
if (delegatePubKey) {
|
|
12724
|
-
const delegateScript = new
|
|
13269
|
+
const delegateScript = new chunkSF5NKAUA_cjs.DelegateVtxo.Script({
|
|
12725
13270
|
pubKey: baselinePubkey,
|
|
12726
13271
|
serverPubKey,
|
|
12727
13272
|
delegatePubKey,
|
|
@@ -12745,9 +13290,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12745
13290
|
}
|
|
12746
13291
|
}
|
|
12747
13292
|
}
|
|
12748
|
-
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ??
|
|
13293
|
+
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkSF5NKAUA_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
12749
13294
|
for (const serverPubKey of baselineSigners) {
|
|
12750
|
-
const baselineBoarding = new
|
|
13295
|
+
const baselineBoarding = new chunkSF5NKAUA_cjs.DefaultVtxo.Script({
|
|
12751
13296
|
pubKey: baselinePubkey,
|
|
12752
13297
|
serverPubKey,
|
|
12753
13298
|
csvTimelock: boardingCsvTimelock
|
|
@@ -12760,7 +13305,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12760
13305
|
params: {
|
|
12761
13306
|
pubKey: base.hex.encode(baselineBoarding.options.pubKey),
|
|
12762
13307
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
12763
|
-
csvTimelock:
|
|
13308
|
+
csvTimelock: chunkFNCQJLR2_cjs.timelockToSequence(boardingCsvTimelock).toString()
|
|
12764
13309
|
},
|
|
12765
13310
|
script: boardingScriptHex,
|
|
12766
13311
|
address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
|
|
@@ -12939,7 +13484,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12939
13484
|
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
12940
13485
|
deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
|
|
12941
13486
|
csvTimelocks: this.walletContractTimelocks,
|
|
12942
|
-
delegatePubKey: this.offchainTapscript instanceof
|
|
13487
|
+
delegatePubKey: this.offchainTapscript instanceof chunkSF5NKAUA_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
|
|
12943
13488
|
};
|
|
12944
13489
|
}
|
|
12945
13490
|
_signerRouter;
|
|
@@ -13033,24 +13578,24 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13033
13578
|
const manager = await this.getContractManager();
|
|
13034
13579
|
const descriptor = await manager.getNextSigningDescriptor();
|
|
13035
13580
|
if (!descriptor) return this.getBoardingAddress();
|
|
13036
|
-
const pubKey =
|
|
13037
|
-
const newBoarding = new
|
|
13581
|
+
const pubKey = chunkSF5NKAUA_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
13582
|
+
const newBoarding = new chunkSF5NKAUA_cjs.DefaultVtxo.Script({
|
|
13038
13583
|
...this._boardingTapscript.options,
|
|
13039
13584
|
pubKey
|
|
13040
13585
|
});
|
|
13041
|
-
const csvTimelock = newBoarding.options.csvTimelock ??
|
|
13586
|
+
const csvTimelock = newBoarding.options.csvTimelock ?? chunkSF5NKAUA_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
13042
13587
|
await manager.createContract({
|
|
13043
13588
|
type: "boarding",
|
|
13044
13589
|
params: {
|
|
13045
13590
|
pubKey: base.hex.encode(pubKey),
|
|
13046
13591
|
serverPubKey: base.hex.encode(newBoarding.options.serverPubKey),
|
|
13047
|
-
csvTimelock:
|
|
13592
|
+
csvTimelock: chunkFNCQJLR2_cjs.timelockToSequence(csvTimelock).toString()
|
|
13048
13593
|
},
|
|
13049
13594
|
script: base.hex.encode(newBoarding.pkScript),
|
|
13050
13595
|
address: newBoarding.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
13051
13596
|
state: "active",
|
|
13052
13597
|
metadata: {
|
|
13053
|
-
source:
|
|
13598
|
+
source: chunkSF5NKAUA_cjs.WALLET_RECEIVE_SOURCE,
|
|
13054
13599
|
signingDescriptor: descriptor
|
|
13055
13600
|
}
|
|
13056
13601
|
});
|
|
@@ -13071,15 +13616,24 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13071
13616
|
return provider.getCurrentSigningDescriptor();
|
|
13072
13617
|
}
|
|
13073
13618
|
/**
|
|
13074
|
-
* @see
|
|
13619
|
+
* @see HDAllocationCapable.getNextSigningDescriptor
|
|
13620
|
+
*
|
|
13621
|
+
* Every `Wallet` answers — this is where the wallet's key-provisioning
|
|
13622
|
+
* policy lives, so consumers never have to branch on wallet shape:
|
|
13623
|
+
* - HD: allocate a fresh index through the contract manager (which owns
|
|
13624
|
+
* cross-context serialization and the look-ahead band).
|
|
13625
|
+
* - custom provider: whatever the provider allocates.
|
|
13626
|
+
* - static / `auto`: the identity key as a bare `tr(pubkey)` descriptor —
|
|
13627
|
+
* the same answer every call, because that IS the static policy.
|
|
13075
13628
|
*/
|
|
13076
13629
|
async getNextSigningDescriptor() {
|
|
13077
|
-
|
|
13078
|
-
|
|
13079
|
-
|
|
13630
|
+
if (this._descriptorProvider instanceof HDDescriptorProvider) {
|
|
13631
|
+
return (await this.getContractManager()).getNextSigningDescriptor();
|
|
13632
|
+
}
|
|
13633
|
+
return chunkSF5NKAUA_cjs.identityDescriptor(this.identity);
|
|
13080
13634
|
}
|
|
13081
13635
|
/**
|
|
13082
|
-
* @see
|
|
13636
|
+
* @see HDAllocationCapable.advanceSigningDescriptorWatermark
|
|
13083
13637
|
*/
|
|
13084
13638
|
async advanceSigningDescriptorWatermark(descriptor) {
|
|
13085
13639
|
const provider = this._descriptorProvider;
|
|
@@ -13132,13 +13686,16 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13132
13686
|
}
|
|
13133
13687
|
/**
|
|
13134
13688
|
* @see HDWalletCapable.signerForDescriptor
|
|
13689
|
+
*
|
|
13690
|
+
* Fail-loud contract: the returned identity is always the descriptor's
|
|
13691
|
+
* own key. A descriptor this wallet cannot sign for throws
|
|
13692
|
+
* {@link ForeignDescriptorError} instead of silently substituting the
|
|
13693
|
+
* baseline identity — that identity would sign happily with the wrong
|
|
13694
|
+
* key, and the failure would only surface as a rejected transaction or a
|
|
13695
|
+
* dead script, far from the call that caused it.
|
|
13135
13696
|
*/
|
|
13136
13697
|
async signerForDescriptor(descriptor) {
|
|
13137
|
-
|
|
13138
|
-
if (!(provider instanceof HDDescriptorProvider) || !provider.isOurs(descriptor)) {
|
|
13139
|
-
return this.identity;
|
|
13140
|
-
}
|
|
13141
|
-
return new DescriptorIdentity({ descriptor, signer: provider, base: this.identity });
|
|
13698
|
+
return resolveDescriptorSigner(descriptor, this.identity, this._descriptorProvider);
|
|
13142
13699
|
}
|
|
13143
13700
|
/**
|
|
13144
13701
|
* Mid-session server-signer rotation (plan §4). When arkd rotates its
|
|
@@ -13198,21 +13755,21 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13198
13755
|
const [currentBoardingRow] = await manager.getContracts({
|
|
13199
13756
|
script: currentBoardingScript
|
|
13200
13757
|
});
|
|
13201
|
-
const newOffchain = this.offchainTapscript instanceof
|
|
13758
|
+
const newOffchain = this.offchainTapscript instanceof chunkSF5NKAUA_cjs.DelegateVtxo.Script ? new chunkSF5NKAUA_cjs.DelegateVtxo.Script({
|
|
13202
13759
|
...this.offchainTapscript.options,
|
|
13203
13760
|
serverPubKey: xonly
|
|
13204
|
-
}) : new
|
|
13761
|
+
}) : new chunkSF5NKAUA_cjs.DefaultVtxo.Script({
|
|
13205
13762
|
...this.offchainTapscript.options,
|
|
13206
13763
|
serverPubKey: xonly
|
|
13207
13764
|
});
|
|
13208
|
-
const newBoarding = new
|
|
13765
|
+
const newBoarding = new chunkSF5NKAUA_cjs.DefaultVtxo.Script({
|
|
13209
13766
|
...this._boardingTapscript.options,
|
|
13210
13767
|
serverPubKey: xonly
|
|
13211
13768
|
});
|
|
13212
|
-
const offchainCsv =
|
|
13769
|
+
const offchainCsv = chunkFNCQJLR2_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
|
|
13213
13770
|
const newOffchainScript = base.hex.encode(newOffchain.pkScript);
|
|
13214
13771
|
const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
|
|
13215
|
-
if (newOffchain instanceof
|
|
13772
|
+
if (newOffchain instanceof chunkSF5NKAUA_cjs.DelegateVtxo.Script) {
|
|
13216
13773
|
await manager.createContract({
|
|
13217
13774
|
type: "delegate",
|
|
13218
13775
|
params: {
|
|
@@ -13240,13 +13797,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13240
13797
|
metadata: currentOffchainRow?.metadata
|
|
13241
13798
|
});
|
|
13242
13799
|
}
|
|
13243
|
-
const boardingCsv = newBoarding.options.csvTimelock ??
|
|
13800
|
+
const boardingCsv = newBoarding.options.csvTimelock ?? chunkSF5NKAUA_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
13244
13801
|
await manager.createContract({
|
|
13245
13802
|
type: "boarding",
|
|
13246
13803
|
params: {
|
|
13247
13804
|
pubKey: base.hex.encode(newBoarding.options.pubKey),
|
|
13248
13805
|
serverPubKey: base.hex.encode(xonly),
|
|
13249
|
-
csvTimelock:
|
|
13806
|
+
csvTimelock: chunkFNCQJLR2_cjs.timelockToSequence(boardingCsv).toString()
|
|
13250
13807
|
},
|
|
13251
13808
|
script: base.hex.encode(newBoarding.pkScript),
|
|
13252
13809
|
address: newBoarding.address(this.network.hrp, xonly).encode(),
|
|
@@ -13279,14 +13836,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13279
13836
|
_restoreInFlight;
|
|
13280
13837
|
_addPendingSpends(inputs) {
|
|
13281
13838
|
for (const input of inputs) {
|
|
13282
|
-
if (
|
|
13839
|
+
if (chunkFNCQJLR2_cjs.isVirtualCoin(input)) {
|
|
13283
13840
|
this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
|
|
13284
13841
|
}
|
|
13285
13842
|
}
|
|
13286
13843
|
}
|
|
13287
13844
|
_removePendingSpends(inputs) {
|
|
13288
13845
|
for (const input of inputs) {
|
|
13289
|
-
if (
|
|
13846
|
+
if (chunkFNCQJLR2_cjs.isVirtualCoin(input)) {
|
|
13290
13847
|
this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
|
|
13291
13848
|
}
|
|
13292
13849
|
}
|
|
@@ -13344,9 +13901,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13344
13901
|
const manager = await this.getContractManager();
|
|
13345
13902
|
const provider = this._descriptorProvider;
|
|
13346
13903
|
const hd = provider instanceof HDDescriptorProvider;
|
|
13347
|
-
const staticDescriptor = hd ? void 0 :
|
|
13904
|
+
const staticDescriptor = hd ? void 0 : await chunkSF5NKAUA_cjs.identityDescriptor(this.identity);
|
|
13348
13905
|
const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
|
|
13349
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
13906
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkSF5NKAUA_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
13350
13907
|
const arkInfo = await this.arkProvider.getInfo();
|
|
13351
13908
|
const currentSignerPubKey = toXOnlyPubKey(base.hex.decode(arkInfo.signerPubkey));
|
|
13352
13909
|
const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
|
|
@@ -13365,7 +13922,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13365
13922
|
csvTimelocks: this.walletContractTimelocks,
|
|
13366
13923
|
// Boarding-exit CSV so the boarding handler can build its
|
|
13367
13924
|
// candidate script (distinct from the unilateral-exit matrix).
|
|
13368
|
-
boardingTimelock: this.boardingTapscript.options.csvTimelock ??
|
|
13925
|
+
boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkSF5NKAUA_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
|
|
13369
13926
|
delegatePubKey
|
|
13370
13927
|
};
|
|
13371
13928
|
const result = await manager.scanContracts({
|
|
@@ -13628,7 +14185,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13628
14185
|
inputs: params.selectedVtxos,
|
|
13629
14186
|
changeAmount: BigInt(changeAmount)
|
|
13630
14187
|
};
|
|
13631
|
-
const outputAddress =
|
|
14188
|
+
const outputAddress = chunkFNCQJLR2_cjs.ArkAddress.decode(params.address);
|
|
13632
14189
|
assertRecipientArkAddress(
|
|
13633
14190
|
params.address,
|
|
13634
14191
|
outputAddress,
|
|
@@ -13694,13 +14251,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13694
14251
|
void this.logUngatedInputs("settle({ inputs })", params.inputs);
|
|
13695
14252
|
}
|
|
13696
14253
|
const offchainAddress = await this.getAddress();
|
|
13697
|
-
const offchainPkScript =
|
|
14254
|
+
const offchainPkScript = chunkFNCQJLR2_cjs.ArkAddress.decode(offchainAddress).pkScript;
|
|
13698
14255
|
const offchainOutputScript = base.hex.encode(offchainPkScript);
|
|
13699
14256
|
if (!params) {
|
|
13700
14257
|
const { fees, vtxoMaxAmount } = await this.arkProvider.getInfo();
|
|
13701
14258
|
const estimator = new Estimator(fees.intentFee);
|
|
13702
14259
|
let amount = 0;
|
|
13703
|
-
const exitScript =
|
|
14260
|
+
const exitScript = chunkFNCQJLR2_cjs.CSVMultisigTapscript.decode(
|
|
13704
14261
|
base.hex.decode(this.boardingTapscript.exitScript)
|
|
13705
14262
|
);
|
|
13706
14263
|
const boardingTimelock = exitScript.params.timelock;
|
|
@@ -13729,7 +14286,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13729
14286
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
13730
14287
|
break;
|
|
13731
14288
|
}
|
|
13732
|
-
const inputFee = estimator.evalOffchainInput(
|
|
14289
|
+
const inputFee = estimator.evalOffchainInput(chunkFNCQJLR2_cjs.toOffchainInputFeeParams(vtxo));
|
|
13733
14290
|
if (inputFee.satoshis >= vtxo.value) {
|
|
13734
14291
|
continue;
|
|
13735
14292
|
}
|
|
@@ -13776,7 +14333,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13776
14333
|
let script;
|
|
13777
14334
|
let arkAddress;
|
|
13778
14335
|
try {
|
|
13779
|
-
arkAddress =
|
|
14336
|
+
arkAddress = chunkFNCQJLR2_cjs.ArkAddress.decode(output.address);
|
|
13780
14337
|
} catch {
|
|
13781
14338
|
arkAddress = void 0;
|
|
13782
14339
|
}
|
|
@@ -13866,7 +14423,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13866
14423
|
const abortController = new AbortController();
|
|
13867
14424
|
let stream;
|
|
13868
14425
|
let committedTxid;
|
|
13869
|
-
const settleInputVtxos = params.inputs.filter(
|
|
14426
|
+
const settleInputVtxos = params.inputs.filter(chunkFNCQJLR2_cjs.isVirtualCoin);
|
|
13870
14427
|
const contractManager = await this.getContractManager();
|
|
13871
14428
|
await contractManager.assertAnnotatable(settleInputVtxos);
|
|
13872
14429
|
await contractManager.assertSpendableNow?.(
|
|
@@ -13975,7 +14532,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13975
14532
|
async maybeRotateBoardingAfterBoard(inputs) {
|
|
13976
14533
|
if (!this._descriptorProvider) return;
|
|
13977
14534
|
const consumedBoarding = inputs.some(
|
|
13978
|
-
(input) => typeof input !== "string" && !
|
|
14535
|
+
(input) => typeof input !== "string" && !chunkFNCQJLR2_cjs.isVirtualCoin(input)
|
|
13979
14536
|
);
|
|
13980
14537
|
if (!consumedBoarding) return;
|
|
13981
14538
|
try {
|
|
@@ -13999,7 +14556,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13999
14556
|
let connectorIndex = 0;
|
|
14000
14557
|
const connectorsLeaves = connectorsGraph?.leaves() || [];
|
|
14001
14558
|
for (const input of inputs) {
|
|
14002
|
-
if (!
|
|
14559
|
+
if (!chunkFNCQJLR2_cjs.isVirtualCoin(input)) {
|
|
14003
14560
|
for (let i = 0; i < settlementPsbt.inputsLength; i++) {
|
|
14004
14561
|
const settlementInput = settlementPsbt.getInput(i);
|
|
14005
14562
|
if (!settlementInput.txid || settlementInput.index === void 0) {
|
|
@@ -14030,7 +14587,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14030
14587
|
}
|
|
14031
14588
|
continue;
|
|
14032
14589
|
}
|
|
14033
|
-
if (
|
|
14590
|
+
if (chunkFNCQJLR2_cjs.canRecoverOnchain(input, { timestamp: /* @__PURE__ */ new Date() }) || isSubdust({ value: input.value }, this.dustAmount)) {
|
|
14034
14591
|
continue;
|
|
14035
14592
|
}
|
|
14036
14593
|
if (connectorsLeaves.length === 0) {
|
|
@@ -14058,7 +14615,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14058
14615
|
index: input.vout,
|
|
14059
14616
|
witnessUtxo: {
|
|
14060
14617
|
amount: BigInt(input.value),
|
|
14061
|
-
script:
|
|
14618
|
+
script: chunkFNCQJLR2_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
14062
14619
|
},
|
|
14063
14620
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
14064
14621
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -14077,7 +14634,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14077
14634
|
forfeitTx = await this._signerRouter.sign(forfeitTx, [
|
|
14078
14635
|
{
|
|
14079
14636
|
index: 0,
|
|
14080
|
-
lookupScript:
|
|
14637
|
+
lookupScript: chunkFNCQJLR2_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
14081
14638
|
}
|
|
14082
14639
|
]);
|
|
14083
14640
|
signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
|
|
@@ -14135,7 +14692,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14135
14692
|
resolveBatchExpiryPolicy(this.network, this.batchExpiryPolicy)
|
|
14136
14693
|
);
|
|
14137
14694
|
await this.arkProvider.confirmRegistration(intentId);
|
|
14138
|
-
const sweepTapscript =
|
|
14695
|
+
const sweepTapscript = chunkFNCQJLR2_cjs.CSVMultisigTapscript.encode({
|
|
14139
14696
|
timelock,
|
|
14140
14697
|
pubkeys: [this.forfeitPubkey]
|
|
14141
14698
|
}).script;
|
|
@@ -14241,9 +14798,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14241
14798
|
...existing ?? {},
|
|
14242
14799
|
intentTxId,
|
|
14243
14800
|
registerProof: intent.proof,
|
|
14244
|
-
registerProofMessage:
|
|
14801
|
+
registerProofMessage: chunkFNCQJLR2_cjs.Intent.encodeMessage(intent.message),
|
|
14245
14802
|
deleteProof: deleteIntent.proof,
|
|
14246
|
-
deleteProofMessage:
|
|
14803
|
+
deleteProofMessage: chunkFNCQJLR2_cjs.Intent.encodeMessage(deleteIntent.message),
|
|
14247
14804
|
intentVtxos: inputs.map((i) => ({
|
|
14248
14805
|
txid: i.txid,
|
|
14249
14806
|
vout: i.vout
|
|
@@ -14275,7 +14832,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14275
14832
|
try {
|
|
14276
14833
|
return await this.arkProvider.registerIntent(intent);
|
|
14277
14834
|
} catch (error) {
|
|
14278
|
-
if (error instanceof
|
|
14835
|
+
if (error instanceof chunkFNCQJLR2_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
|
|
14279
14836
|
const deleteIntent = await this.makeDeleteIntentSignature(inputs);
|
|
14280
14837
|
await this.arkProvider.deleteIntent(deleteIntent);
|
|
14281
14838
|
return this.arkProvider.registerIntent(intent);
|
|
@@ -14291,7 +14848,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14291
14848
|
expire_at: 0,
|
|
14292
14849
|
cosigners_public_keys: cosignerPubKeys
|
|
14293
14850
|
};
|
|
14294
|
-
const proof =
|
|
14851
|
+
const proof = chunkFNCQJLR2_cjs.Intent.create(message, coins, outputs);
|
|
14295
14852
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
14296
14853
|
return {
|
|
14297
14854
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -14303,7 +14860,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14303
14860
|
type: "delete",
|
|
14304
14861
|
expire_at: 0
|
|
14305
14862
|
};
|
|
14306
|
-
const proof =
|
|
14863
|
+
const proof = chunkFNCQJLR2_cjs.Intent.create(message, coins, []);
|
|
14307
14864
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
14308
14865
|
return {
|
|
14309
14866
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -14315,7 +14872,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14315
14872
|
type: "get-pending-tx",
|
|
14316
14873
|
expire_at: 0
|
|
14317
14874
|
};
|
|
14318
|
-
const proof =
|
|
14875
|
+
const proof = chunkFNCQJLR2_cjs.Intent.create(message, coins, []);
|
|
14319
14876
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
14320
14877
|
return {
|
|
14321
14878
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -14336,7 +14893,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14336
14893
|
if (!vtxos || vtxos.length === 0) {
|
|
14337
14894
|
const scriptMap = await this.getScriptMap();
|
|
14338
14895
|
const allExtended = [];
|
|
14339
|
-
const fetchedVtxos = await
|
|
14896
|
+
const fetchedVtxos = await chunkFNCQJLR2_cjs.getAllNormalizedVtxos(this.indexerProvider, [
|
|
14340
14897
|
...scriptMap.keys()
|
|
14341
14898
|
]);
|
|
14342
14899
|
for (const vtxo of fetchedVtxos) {
|
|
@@ -14450,11 +15007,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14450
15007
|
* against the current key alone would leave it pending forever.
|
|
14451
15008
|
*/
|
|
14452
15009
|
checkpointUnrollCandidates(info) {
|
|
14453
|
-
const current =
|
|
15010
|
+
const current = chunkFNCQJLR2_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
14454
15011
|
const candidates = [this._serverUnrollScript, current];
|
|
14455
15012
|
for (const deprecated of signerSetFromInfo(info).deprecated.keys()) {
|
|
14456
15013
|
candidates.push(
|
|
14457
|
-
|
|
15014
|
+
chunkFNCQJLR2_cjs.CSVMultisigTapscript.encode({
|
|
14458
15015
|
...current.params,
|
|
14459
15016
|
pubkeys: [base.hex.decode(deprecated)]
|
|
14460
15017
|
})
|
|
@@ -14545,7 +15102,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14545
15102
|
if (vtxos.length === 0) {
|
|
14546
15103
|
throw new Error("No VTXOs found for this arkadeCash");
|
|
14547
15104
|
}
|
|
14548
|
-
const myPkScript =
|
|
15105
|
+
const myPkScript = chunkFNCQJLR2_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
|
|
14549
15106
|
let { spendable, unclaimed } = this.classifyCashVtxos(vtxos);
|
|
14550
15107
|
let swept = 0;
|
|
14551
15108
|
const drainable = vtxos.filter((vtxo) => !isSubdust(vtxo, this.dustAmount));
|
|
@@ -14619,7 +15176,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14619
15176
|
const spendable = [];
|
|
14620
15177
|
const unclaimed = [];
|
|
14621
15178
|
for (const vtxo of vtxos) {
|
|
14622
|
-
if (
|
|
15179
|
+
if (chunkFNCQJLR2_cjs.hasTerminalSpend(vtxo)) {
|
|
14623
15180
|
unclaimed.push(cashReport(vtxo, "already-spent"));
|
|
14624
15181
|
} else if (isSubdust(vtxo, this.dustAmount)) {
|
|
14625
15182
|
unclaimed.push(cashReport(vtxo, "subdust"));
|
|
@@ -14639,7 +15196,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14639
15196
|
const all = [];
|
|
14640
15197
|
const seen = /* @__PURE__ */ new Set();
|
|
14641
15198
|
for (let pageIndex = 0; ; pageIndex++) {
|
|
14642
|
-
const { vtxos, page } = await
|
|
15199
|
+
const { vtxos, page } = await chunkFNCQJLR2_cjs.getNormalizedVtxos(this.indexerProvider, {
|
|
14643
15200
|
scripts,
|
|
14644
15201
|
pageIndex,
|
|
14645
15202
|
pageSize
|
|
@@ -14686,7 +15243,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14686
15243
|
for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
|
|
14687
15244
|
const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
|
|
14688
15245
|
const message = { type: "get-pending-tx", expire_at: 0 };
|
|
14689
|
-
const proof =
|
|
15246
|
+
const proof = chunkFNCQJLR2_cjs.Intent.create(message, batch, []);
|
|
14690
15247
|
const signedProof = await identity.sign(
|
|
14691
15248
|
proof,
|
|
14692
15249
|
Array.from({ length: batch.length + 1 }, (_, j) => j)
|
|
@@ -14994,10 +15551,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14994
15551
|
const serverPubKey = this.arkServerPublicKey;
|
|
14995
15552
|
const serverUnrollScript = this.serverUnrollScript;
|
|
14996
15553
|
const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
|
|
14997
|
-
const normalizedInputs = inputs.map(
|
|
14998
|
-
const at = now ?? await
|
|
15554
|
+
const normalizedInputs = inputs.map(chunkFNCQJLR2_cjs.normalizeVtxo);
|
|
15555
|
+
const at = now ?? await chunkFNCQJLR2_cjs.resolveTimeHeight(this.onchainProvider);
|
|
14999
15556
|
for (const input of normalizedInputs) {
|
|
15000
|
-
if (!
|
|
15557
|
+
if (!chunkFNCQJLR2_cjs.canSpendOffchain(input, at)) {
|
|
15001
15558
|
throw new Error(
|
|
15002
15559
|
`sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
|
|
15003
15560
|
);
|
|
@@ -15067,7 +15624,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15067
15624
|
);
|
|
15068
15625
|
const arkTxJobs = inputs.map((input, index) => ({
|
|
15069
15626
|
index,
|
|
15070
|
-
lookupScript:
|
|
15627
|
+
lookupScript: chunkFNCQJLR2_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
15071
15628
|
}));
|
|
15072
15629
|
const identity = this.identity;
|
|
15073
15630
|
const signer = {
|
|
@@ -15153,14 +15710,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15153
15710
|
const spentBy = checkpointIdByOutpoint.get(`${vtxo.txid}:${vtxo.vout}`);
|
|
15154
15711
|
spentVtxos.push({
|
|
15155
15712
|
...spentFacts,
|
|
15156
|
-
virtualStatus:
|
|
15713
|
+
virtualStatus: chunkFNCQJLR2_cjs.toVirtualStatus(spentFacts),
|
|
15157
15714
|
...spentBy ? { spentBy } : {},
|
|
15158
15715
|
arkTxId: arkTxid
|
|
15159
15716
|
});
|
|
15160
15717
|
for (const id of vtxo.commitmentTxIds) {
|
|
15161
15718
|
commitmentTxIds.add(id);
|
|
15162
15719
|
}
|
|
15163
|
-
const vtxoExpiry =
|
|
15720
|
+
const vtxoExpiry = chunkFNCQJLR2_cjs.toBatchExpiry(vtxo);
|
|
15164
15721
|
if (vtxoExpiry) {
|
|
15165
15722
|
batchExpiry = Math.min(batchExpiry, vtxoExpiry);
|
|
15166
15723
|
}
|
|
@@ -15173,7 +15730,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15173
15730
|
isSwept: false,
|
|
15174
15731
|
isPreconfirmed: true,
|
|
15175
15732
|
commitmentTxIds: Array.from(commitmentTxIds),
|
|
15176
|
-
...
|
|
15733
|
+
...chunkFNCQJLR2_cjs.parseLegacyExpiry(batchExpiry)
|
|
15177
15734
|
};
|
|
15178
15735
|
changeVtxo = {
|
|
15179
15736
|
txid: arkTxid,
|
|
@@ -15185,7 +15742,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15185
15742
|
tapTree: offchainTapscript.encode(),
|
|
15186
15743
|
value: Number(changeAmount),
|
|
15187
15744
|
...changeFacts,
|
|
15188
|
-
virtualStatus:
|
|
15745
|
+
virtualStatus: chunkFNCQJLR2_cjs.toVirtualStatus(changeFacts),
|
|
15189
15746
|
spentBy: "",
|
|
15190
15747
|
status: {
|
|
15191
15748
|
confirmed: false
|
|
@@ -15254,12 +15811,12 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15254
15811
|
const spentVtxos = [];
|
|
15255
15812
|
const inputArkTxIds = /* @__PURE__ */ new Set();
|
|
15256
15813
|
const boardingRemovalsByAddress = /* @__PURE__ */ new Map();
|
|
15257
|
-
const vtxoInputs = inputs.filter(
|
|
15814
|
+
const vtxoInputs = inputs.filter(chunkFNCQJLR2_cjs.isVirtualCoin);
|
|
15258
15815
|
const cm = await this.getContractManager();
|
|
15259
15816
|
const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
|
|
15260
15817
|
const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
|
|
15261
15818
|
for (const input of inputs) {
|
|
15262
|
-
if (
|
|
15819
|
+
if (chunkFNCQJLR2_cjs.isVirtualCoin(input)) {
|
|
15263
15820
|
const outpoint = `${input.txid}:${input.vout}`;
|
|
15264
15821
|
const vtxo = annotatedByKey.get(outpoint);
|
|
15265
15822
|
if (!vtxo) {
|
|
@@ -15271,13 +15828,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15271
15828
|
const settledFacts = { ...vtxo, isSpent: true };
|
|
15272
15829
|
spentVtxos.push({
|
|
15273
15830
|
...settledFacts,
|
|
15274
|
-
virtualStatus:
|
|
15831
|
+
virtualStatus: chunkFNCQJLR2_cjs.toVirtualStatus(settledFacts),
|
|
15275
15832
|
settledBy: commitmentTxid
|
|
15276
15833
|
});
|
|
15277
15834
|
} else {
|
|
15278
15835
|
let sourceAddress;
|
|
15279
15836
|
try {
|
|
15280
|
-
sourceAddress =
|
|
15837
|
+
sourceAddress = chunkFNCQJLR2_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
|
|
15281
15838
|
this.network
|
|
15282
15839
|
);
|
|
15283
15840
|
} catch {
|
|
@@ -15335,9 +15892,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15335
15892
|
}
|
|
15336
15893
|
};
|
|
15337
15894
|
function selectVirtualCoins(coins, targetAmount) {
|
|
15338
|
-
const sortedCoins = coins.map(
|
|
15339
|
-
const expiryA =
|
|
15340
|
-
const expiryB =
|
|
15895
|
+
const sortedCoins = coins.map(chunkFNCQJLR2_cjs.normalizeVtxo).sort((a, b) => {
|
|
15896
|
+
const expiryA = chunkFNCQJLR2_cjs.toBatchExpiry(a) || Number.MAX_SAFE_INTEGER;
|
|
15897
|
+
const expiryB = chunkFNCQJLR2_cjs.toBatchExpiry(b) || Number.MAX_SAFE_INTEGER;
|
|
15341
15898
|
if (expiryA !== expiryB) {
|
|
15342
15899
|
return expiryA - expiryB;
|
|
15343
15900
|
}
|
|
@@ -15597,7 +16154,7 @@ var MessageBus = class {
|
|
|
15597
16154
|
this.initialized = true;
|
|
15598
16155
|
}
|
|
15599
16156
|
async buildServices(config) {
|
|
15600
|
-
const arkProvider = new
|
|
16157
|
+
const arkProvider = new chunkFNCQJLR2_cjs.RestArkProvider(config.arkServer.url);
|
|
15601
16158
|
const storage = {
|
|
15602
16159
|
walletRepository: this.walletRepository,
|
|
15603
16160
|
contractRepository: this.contractRepository,
|
|
@@ -15939,7 +16496,7 @@ var offboardNetworkNames = [
|
|
|
15939
16496
|
function offboardDestinationScript(destinationAddress) {
|
|
15940
16497
|
for (const networkName of offboardNetworkNames) {
|
|
15941
16498
|
try {
|
|
15942
|
-
const network =
|
|
16499
|
+
const network = chunkFNCQJLR2_cjs.networks[networkName];
|
|
15943
16500
|
const addr = btcSigner.Address(network).decode(destinationAddress);
|
|
15944
16501
|
return btcSigner.OutScript.encode(addr);
|
|
15945
16502
|
} catch {
|
|
@@ -16003,7 +16560,7 @@ var Ramps = class {
|
|
|
16003
16560
|
}
|
|
16004
16561
|
amount = amount ?? totalAmount;
|
|
16005
16562
|
const offchainAddress = await this.wallet.getAddress();
|
|
16006
|
-
const offchainAddr =
|
|
16563
|
+
const offchainAddr = chunkFNCQJLR2_cjs.ArkAddress.decode(offchainAddress);
|
|
16007
16564
|
const offchainScript = base.hex.encode(offchainAddr.pkScript);
|
|
16008
16565
|
const outputFee = estimator.evalOffchainOutput({
|
|
16009
16566
|
amount,
|
|
@@ -16063,7 +16620,7 @@ var Ramps = class {
|
|
|
16063
16620
|
const filteredVtxos = [];
|
|
16064
16621
|
let totalAmount = 0n;
|
|
16065
16622
|
for (const vtxo of vtxos) {
|
|
16066
|
-
const inputFee = estimator.evalOffchainInput(
|
|
16623
|
+
const inputFee = estimator.evalOffchainInput(chunkFNCQJLR2_cjs.toOffchainInputFeeParams(vtxo));
|
|
16067
16624
|
if (inputFee.satoshis >= vtxo.value) {
|
|
16068
16625
|
continue;
|
|
16069
16626
|
}
|
|
@@ -16830,7 +17387,7 @@ var WalletMessageHandler = class {
|
|
|
16830
17387
|
// Wallet methods
|
|
16831
17388
|
async handleInitWallet({ payload }) {
|
|
16832
17389
|
const { arkServerUrl } = payload;
|
|
16833
|
-
this.indexerProvider = new
|
|
17390
|
+
this.indexerProvider = new chunk2JHN5RCY_cjs.RestIndexerProvider(arkServerUrl);
|
|
16834
17391
|
await this.onWalletInitialized();
|
|
16835
17392
|
}
|
|
16836
17393
|
/**
|
|
@@ -17095,17 +17652,17 @@ var WalletMessageHandler = class {
|
|
|
17095
17652
|
throw new WalletNotInitializedError();
|
|
17096
17653
|
}
|
|
17097
17654
|
const allVtxos = await this.getVtxosFromRepo();
|
|
17098
|
-
const vtxos = allVtxos.filter((v) => !
|
|
17655
|
+
const vtxos = allVtxos.filter((v) => !chunkFNCQJLR2_cjs.hasTerminalSpend(v));
|
|
17099
17656
|
const dustAmount = this.readonlyWallet.dustAmount;
|
|
17100
17657
|
const includeRecoverable = message.payload.filter?.withRecoverable ?? false;
|
|
17101
17658
|
const filteredVtxos = includeRecoverable ? vtxos : vtxos.filter((v) => {
|
|
17102
17659
|
if (dustAmount != null && isSubdust(v, dustAmount)) {
|
|
17103
17660
|
return false;
|
|
17104
17661
|
}
|
|
17105
|
-
if (
|
|
17662
|
+
if (chunkFNCQJLR2_cjs.isRecoverable(v)) {
|
|
17106
17663
|
return false;
|
|
17107
17664
|
}
|
|
17108
|
-
if (
|
|
17665
|
+
if (chunkFNCQJLR2_cjs.isExpired(v)) {
|
|
17109
17666
|
return false;
|
|
17110
17667
|
}
|
|
17111
17668
|
return true;
|
|
@@ -17113,7 +17670,7 @@ var WalletMessageHandler = class {
|
|
|
17113
17670
|
if (!message.payload.filter?.withUnrolled) {
|
|
17114
17671
|
return filteredVtxos;
|
|
17115
17672
|
}
|
|
17116
|
-
return filteredVtxos.concat(allVtxos.filter((v) =>
|
|
17673
|
+
return filteredVtxos.concat(allVtxos.filter((v) => chunkFNCQJLR2_cjs.hasTerminalSpend(v) && v.isUnrolled));
|
|
17117
17674
|
}
|
|
17118
17675
|
/** Tear down handler subscriptions, then delegate the full wipe to the wallet. */
|
|
17119
17676
|
async clear() {
|
|
@@ -17203,7 +17760,7 @@ var WalletMessageHandler = class {
|
|
|
17203
17760
|
if (!this.readonlyWallet) return null;
|
|
17204
17761
|
const { boardingTxs, commitmentsToIgnore } = await this.readonlyWallet.getBoardingTxs();
|
|
17205
17762
|
const indexerProvider = this.indexerProvider;
|
|
17206
|
-
const resolveTxCreatedAt = indexerProvider ? (txids) =>
|
|
17763
|
+
const resolveTxCreatedAt = indexerProvider ? (txids) => chunkFNCQJLR2_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
|
|
17207
17764
|
return buildTransactionHistory(vtxos, boardingTxs, commitmentsToIgnore, resolveTxCreatedAt);
|
|
17208
17765
|
}
|
|
17209
17766
|
async ensureContractEventBroadcasting() {
|
|
@@ -17320,10 +17877,6 @@ function getRequestDedupKey(request) {
|
|
|
17320
17877
|
const { id, tag, ...rest } = request;
|
|
17321
17878
|
return JSON.stringify(rest);
|
|
17322
17879
|
}
|
|
17323
|
-
function isSigningCapable(identity) {
|
|
17324
|
-
const candidate = identity;
|
|
17325
|
-
return typeof candidate.signMessage === "function" && typeof candidate.sign === "function" && typeof candidate.signerSession === "function";
|
|
17326
|
-
}
|
|
17327
17880
|
var ServiceWorkerReadonlyAssetManager = class {
|
|
17328
17881
|
constructor(sendMessage, messageTag) {
|
|
17329
17882
|
this.sendMessage = sendMessage;
|
|
@@ -17896,7 +18449,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
17896
18449
|
};
|
|
17897
18450
|
try {
|
|
17898
18451
|
const response = await this.sendMessage(message);
|
|
17899
|
-
return response.payload.vtxos.map(
|
|
18452
|
+
return response.payload.vtxos.map(chunkFNCQJLR2_cjs.normalizeVtxo);
|
|
17900
18453
|
} catch (error) {
|
|
17901
18454
|
throw new Error(`Failed to get vtxos: ${error}`);
|
|
17902
18455
|
}
|
|
@@ -17921,7 +18474,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
17921
18474
|
};
|
|
17922
18475
|
try {
|
|
17923
18476
|
const response = await this.sendMessage(message);
|
|
17924
|
-
return response.payload.vtxos.map(
|
|
18477
|
+
return response.payload.vtxos.map(chunkFNCQJLR2_cjs.normalizeVtxo);
|
|
17925
18478
|
} catch (error) {
|
|
17926
18479
|
throw new Error(`Failed to get spendable vtxos: ${error}`);
|
|
17927
18480
|
}
|
|
@@ -18031,7 +18584,15 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
18031
18584
|
*/
|
|
18032
18585
|
async assertAnnotatable() {
|
|
18033
18586
|
},
|
|
18034
|
-
/**
|
|
18587
|
+
/**
|
|
18588
|
+
* Same reasoning as {@link assertAnnotatable}: the worker checks it.
|
|
18589
|
+
*
|
|
18590
|
+
* `unspendableNowReasons` is deliberately absent rather than stubbed
|
|
18591
|
+
* alongside it. A stub returning an empty map reads as "nothing
|
|
18592
|
+
* refused", and a filter acting on that silently drops its decision;
|
|
18593
|
+
* absent, the optional call is skipped. Recovery — the only caller —
|
|
18594
|
+
* runs inside the worker against the real manager anyway.
|
|
18595
|
+
*/
|
|
18035
18596
|
async assertSpendableNow() {
|
|
18036
18597
|
},
|
|
18037
18598
|
async annotateVtxos(vtxos) {
|
|
@@ -18044,7 +18605,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
18044
18605
|
};
|
|
18045
18606
|
try {
|
|
18046
18607
|
const response = await sendContractMessage(message);
|
|
18047
|
-
return response.payload.vtxos.map(
|
|
18608
|
+
return response.payload.vtxos.map(chunkFNCQJLR2_cjs.normalizeVtxo);
|
|
18048
18609
|
} catch (e) {
|
|
18049
18610
|
throw new Error("Failed to annotate vtxos");
|
|
18050
18611
|
}
|
|
@@ -18257,7 +18818,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
18257
18818
|
}
|
|
18258
18819
|
const walletRepository = options.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
18259
18820
|
const contractRepository = options.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
18260
|
-
if (!
|
|
18821
|
+
if (!isSigningIdentity(options.identity)) {
|
|
18261
18822
|
throw new Error(
|
|
18262
18823
|
"ServiceWorkerWallet.create() requires a signing Identity; got a ReadonlyIdentity"
|
|
18263
18824
|
);
|
|
@@ -18417,17 +18978,21 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
18417
18978
|
/**
|
|
18418
18979
|
* @see HDWalletCapable.signerForDescriptor
|
|
18419
18980
|
*
|
|
18420
|
-
* Runs page-side: an Identity cannot cross the message bus, and it does
|
|
18421
|
-
* not need to — the page owns the signing identity, and
|
|
18422
|
-
* no allocation state.
|
|
18423
|
-
*
|
|
18981
|
+
* Runs page-side: an `Identity` cannot cross the message bus, and it does
|
|
18982
|
+
* not need to — the page owns the signing identity, and resolving a
|
|
18983
|
+
* descriptor reads no allocation state. Shares
|
|
18984
|
+
* {@link resolveDescriptorSigner} with {@link Wallet.signerForDescriptor}
|
|
18985
|
+
* so the two sides of the bus cannot answer differently for one
|
|
18424
18986
|
* descriptor.
|
|
18987
|
+
*
|
|
18988
|
+
* No provider is passed, and none is needed: `HDDescriptorProvider`'s
|
|
18989
|
+
* `isOurs` and signing members all delegate to the identity, which the
|
|
18990
|
+
* page holds. Building one here would only add a page-side read of the
|
|
18991
|
+
* wallet state the worker allocates from — shared mutable state on a path
|
|
18992
|
+
* that has no business touching it.
|
|
18425
18993
|
*/
|
|
18426
18994
|
async signerForDescriptor(descriptor) {
|
|
18427
|
-
|
|
18428
|
-
const provider = await HDDescriptorProvider.create(this.identity, this.walletRepository);
|
|
18429
|
-
if (!provider.isOurs(descriptor)) return this.identity;
|
|
18430
|
-
return new DescriptorIdentity({ descriptor, signer: provider, base: this.identity });
|
|
18995
|
+
return resolveDescriptorSigner(descriptor, this.identity);
|
|
18431
18996
|
}
|
|
18432
18997
|
async sendBitcoin(params) {
|
|
18433
18998
|
const message = {
|
|
@@ -18608,7 +19173,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
18608
19173
|
};
|
|
18609
19174
|
try {
|
|
18610
19175
|
const response = await wallet.sendMessage(message);
|
|
18611
|
-
return response.payload.vtxos.map(
|
|
19176
|
+
return response.payload.vtxos.map(chunkFNCQJLR2_cjs.normalizeVtxo);
|
|
18612
19177
|
} catch (e) {
|
|
18613
19178
|
throw new Error(`Failed to get expiring vtxos: ${e}`);
|
|
18614
19179
|
}
|
|
@@ -18720,12 +19285,12 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
18720
19285
|
* @returns Configured onchain wallet
|
|
18721
19286
|
* @throws Error if the configured identity cannot produce a valid x-only public key
|
|
18722
19287
|
*/
|
|
18723
|
-
static async create(identity, networkName =
|
|
19288
|
+
static async create(identity, networkName = chunkFNCQJLR2_cjs.DEFAULT_NETWORK_NAME, provider) {
|
|
18724
19289
|
const pubkey = await identity.xOnlyPublicKey();
|
|
18725
19290
|
if (!pubkey) {
|
|
18726
19291
|
throw new Error("Invalid configured public key");
|
|
18727
19292
|
}
|
|
18728
|
-
const network =
|
|
19293
|
+
const network = chunkFNCQJLR2_cjs.getNetwork(networkName);
|
|
18729
19294
|
const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
|
|
18730
19295
|
const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
|
|
18731
19296
|
return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
|
|
@@ -18831,7 +19396,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
18831
19396
|
if (!inputs) {
|
|
18832
19397
|
throw new Error("Fee estimation failed");
|
|
18833
19398
|
}
|
|
18834
|
-
let tx = new
|
|
19399
|
+
let tx = new chunkFNCQJLR2_cjs.Transaction();
|
|
18835
19400
|
for (const input of inputs) {
|
|
18836
19401
|
tx.addInput({
|
|
18837
19402
|
txid: input.txid,
|
|
@@ -18889,7 +19454,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
18889
19454
|
* @throws If the parent has no anchor, or funding cannot be selected/signed
|
|
18890
19455
|
*/
|
|
18891
19456
|
async bumpAnchor(parentHex, feeRate) {
|
|
18892
|
-
const parent =
|
|
19457
|
+
const parent = chunkFNCQJLR2_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
|
|
18893
19458
|
const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
|
|
18894
19459
|
const child = await this.buildBumpPackage(parent, feeRate, coins);
|
|
18895
19460
|
return [parent.hex, child.hex];
|
|
@@ -19654,7 +20219,7 @@ exports.BIP322 = void 0;
|
|
|
19654
20219
|
async function sign2(message, identity, network) {
|
|
19655
20220
|
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
19656
20221
|
const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
|
|
19657
|
-
const toSpend =
|
|
20222
|
+
const toSpend = chunkFNCQJLR2_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
19658
20223
|
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
19659
20224
|
const signed = await identity.sign(toSign, [0]);
|
|
19660
20225
|
signed.finalizeIdx(0);
|
|
@@ -19712,7 +20277,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
|
19712
20277
|
if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
|
|
19713
20278
|
return false;
|
|
19714
20279
|
}
|
|
19715
|
-
const toSpend =
|
|
20280
|
+
const toSpend = chunkFNCQJLR2_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
19716
20281
|
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
|
|
19717
20282
|
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
19718
20283
|
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
@@ -19733,7 +20298,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
|
19733
20298
|
}
|
|
19734
20299
|
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
19735
20300
|
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
19736
|
-
const toSpend =
|
|
20301
|
+
const toSpend = chunkFNCQJLR2_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
19737
20302
|
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
19738
20303
|
const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
|
|
19739
20304
|
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
@@ -19786,7 +20351,7 @@ function encodeCompactSize(n) {
|
|
|
19786
20351
|
return buf;
|
|
19787
20352
|
}
|
|
19788
20353
|
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
19789
|
-
const tx = new
|
|
20354
|
+
const tx = new chunkFNCQJLR2_cjs.Transaction({ version: 0 });
|
|
19790
20355
|
tx.addInput({
|
|
19791
20356
|
txid: toSpend.id,
|
|
19792
20357
|
index: 0,
|
|
@@ -19800,12 +20365,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
|
19800
20365
|
});
|
|
19801
20366
|
tx.addOutput({
|
|
19802
20367
|
amount: 0n,
|
|
19803
|
-
script:
|
|
20368
|
+
script: chunkFNCQJLR2_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
19804
20369
|
});
|
|
19805
20370
|
return tx;
|
|
19806
20371
|
}
|
|
19807
20372
|
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
19808
|
-
const tx = new
|
|
20373
|
+
const tx = new chunkFNCQJLR2_cjs.Transaction({ version: 0 });
|
|
19809
20374
|
tx.addInput({
|
|
19810
20375
|
txid: toSpend.id,
|
|
19811
20376
|
index: 0,
|
|
@@ -19817,7 +20382,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
|
19817
20382
|
});
|
|
19818
20383
|
tx.addOutput({
|
|
19819
20384
|
amount: 0n,
|
|
19820
|
-
script:
|
|
20385
|
+
script: chunkFNCQJLR2_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
19821
20386
|
});
|
|
19822
20387
|
return tx;
|
|
19823
20388
|
}
|
|
@@ -19948,7 +20513,7 @@ var RestEmulatorProvider = class {
|
|
|
19948
20513
|
}
|
|
19949
20514
|
};
|
|
19950
20515
|
function finalizeVirtualTx(type, psbtBase64) {
|
|
19951
|
-
const tx =
|
|
20516
|
+
const tx = chunkFNCQJLR2_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
19952
20517
|
if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
|
|
19953
20518
|
const input = tx.getInput(0);
|
|
19954
20519
|
if (!input) {
|
|
@@ -19975,14 +20540,14 @@ var ExitPathError = class extends Error {
|
|
|
19975
20540
|
reason;
|
|
19976
20541
|
};
|
|
19977
20542
|
function delayWeight(sequence) {
|
|
19978
|
-
const t =
|
|
20543
|
+
const t = chunkFNCQJLR2_cjs.sequenceToTimelock(sequence);
|
|
19979
20544
|
return t.type === "blocks" ? Number(t.value) : Number(t.value) / 600;
|
|
19980
20545
|
}
|
|
19981
20546
|
async function resolveUnilateralPath(params) {
|
|
19982
20547
|
const { vtxo, scriptHex, contractRepository } = params;
|
|
19983
20548
|
const contract = contractRepository ? (await contractRepository.getContracts({ script: scriptHex }))[0] : void 0;
|
|
19984
20549
|
if (contract) {
|
|
19985
|
-
const handler =
|
|
20550
|
+
const handler = chunkSF5NKAUA_cjs.contractHandlers.get(contract.type);
|
|
19986
20551
|
if (!handler) {
|
|
19987
20552
|
throw new ExitPathError(
|
|
19988
20553
|
"no-handler",
|
|
@@ -20005,12 +20570,12 @@ async function resolveUnilateralPath(params) {
|
|
|
20005
20570
|
paths.sort((a, b) => delayWeight(a.sequence) - delayWeight(b.sequence));
|
|
20006
20571
|
return { selection: paths[0], label: `${contract.type}:unilateral` };
|
|
20007
20572
|
}
|
|
20008
|
-
const decoded =
|
|
20573
|
+
const decoded = chunkFNCQJLR2_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
20009
20574
|
let best;
|
|
20010
20575
|
for (const exit of decoded.exitPaths()) {
|
|
20011
20576
|
const leaf = decoded.findLeaf(base.hex.encode(exit.script));
|
|
20012
20577
|
if (!leaf) continue;
|
|
20013
|
-
const sequence =
|
|
20578
|
+
const sequence = chunkFNCQJLR2_cjs.timelockToSequence(exit.params.timelock);
|
|
20014
20579
|
const weight = delayWeight(sequence);
|
|
20015
20580
|
if (!best || weight < best.weight) {
|
|
20016
20581
|
best = { selection: { leaf, sequence }, weight };
|
|
@@ -20196,14 +20761,14 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
20196
20761
|
}
|
|
20197
20762
|
const resolved = await resolveUnilateralPath({
|
|
20198
20763
|
vtxo,
|
|
20199
|
-
scriptHex: base.hex.encode(
|
|
20764
|
+
scriptHex: base.hex.encode(chunkFNCQJLR2_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
20200
20765
|
contractRepository: wallet.contractRepository,
|
|
20201
20766
|
walletPubKeyHex: base.hex.encode(await wallet.identity.xOnlyPublicKey()),
|
|
20202
20767
|
currentTime: Date.now()
|
|
20203
20768
|
});
|
|
20204
20769
|
const spendingLeaf = resolved.selection.leaf;
|
|
20205
20770
|
const sequence = resolved.selection.sequence;
|
|
20206
|
-
const timelock =
|
|
20771
|
+
const timelock = chunkFNCQJLR2_cjs.sequenceToTimelock(sequence);
|
|
20207
20772
|
const elapsed = timelock.type === "blocks" ? chainTip.height >= txStatus.blockHeight + Number(timelock.value) : chainTip.time >= txStatus.blockTime + Number(timelock.value);
|
|
20208
20773
|
if (!elapsed) {
|
|
20209
20774
|
throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
|
|
@@ -20216,7 +20781,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
20216
20781
|
sequence,
|
|
20217
20782
|
witnessUtxo: {
|
|
20218
20783
|
amount: BigInt(vtxo.value),
|
|
20219
|
-
script:
|
|
20784
|
+
script: chunkFNCQJLR2_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
|
|
20220
20785
|
},
|
|
20221
20786
|
sighashType: btcSigner.SigHash.DEFAULT
|
|
20222
20787
|
});
|
|
@@ -20226,7 +20791,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
20226
20791
|
btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
|
|
20227
20792
|
);
|
|
20228
20793
|
}
|
|
20229
|
-
const tx = new
|
|
20794
|
+
const tx = new chunkFNCQJLR2_cjs.Transaction({ version: 2 });
|
|
20230
20795
|
for (const input of inputs) {
|
|
20231
20796
|
tx.addInput(input);
|
|
20232
20797
|
}
|
|
@@ -20293,7 +20858,7 @@ async function buildSignedSweep(params) {
|
|
|
20293
20858
|
`uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
|
|
20294
20859
|
);
|
|
20295
20860
|
}
|
|
20296
|
-
const tx = new
|
|
20861
|
+
const tx = new chunkFNCQJLR2_cjs.Transaction({ version: 2 });
|
|
20297
20862
|
tx.addInput({
|
|
20298
20863
|
txid: vtxo.txid,
|
|
20299
20864
|
index: vtxo.vout,
|
|
@@ -20318,7 +20883,7 @@ async function buildSignedSweep(params) {
|
|
|
20318
20883
|
finalScriptWitness: [
|
|
20319
20884
|
tapScriptSig[0][1],
|
|
20320
20885
|
...path.extraWitness,
|
|
20321
|
-
|
|
20886
|
+
chunkFNCQJLR2_cjs.scriptFromTapLeafScript(path.leaf),
|
|
20322
20887
|
btcSigner.TaprootControlBlock.encode(controlBlock)
|
|
20323
20888
|
]
|
|
20324
20889
|
});
|
|
@@ -20348,7 +20913,7 @@ async function resolveFeeRate(opts) {
|
|
|
20348
20913
|
}
|
|
20349
20914
|
async function selectExitVtxos(opts) {
|
|
20350
20915
|
if (!opts.vtxos) return opts.wallet.getVtxos();
|
|
20351
|
-
const res = await
|
|
20916
|
+
const res = await chunkFNCQJLR2_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
|
|
20352
20917
|
const tapTrees = /* @__PURE__ */ new Map();
|
|
20353
20918
|
const out = [];
|
|
20354
20919
|
for (const vtxo of res.vtxos) {
|
|
@@ -20363,7 +20928,7 @@ async function selectExitVtxos(opts) {
|
|
|
20363
20928
|
`no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
|
|
20364
20929
|
);
|
|
20365
20930
|
}
|
|
20366
|
-
const handler =
|
|
20931
|
+
const handler = chunkSF5NKAUA_cjs.contractHandlers.get(contract.type);
|
|
20367
20932
|
if (!handler) {
|
|
20368
20933
|
throw new Error(`no contract handler registered for type '${contract.type}'`);
|
|
20369
20934
|
}
|
|
@@ -20393,7 +20958,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
20393
20958
|
if (pendingNodes.length > 0) {
|
|
20394
20959
|
const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
|
|
20395
20960
|
for (const psbt of txs) {
|
|
20396
|
-
psbts.set(
|
|
20961
|
+
psbts.set(chunkFNCQJLR2_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
20397
20962
|
}
|
|
20398
20963
|
}
|
|
20399
20964
|
const childVsize = Number(
|
|
@@ -20429,7 +20994,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
20429
20994
|
try {
|
|
20430
20995
|
const resolved = await resolveUnilateralPath({
|
|
20431
20996
|
vtxo,
|
|
20432
|
-
scriptHex: base.hex.encode(
|
|
20997
|
+
scriptHex: base.hex.encode(chunkFNCQJLR2_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
20433
20998
|
contractRepository: wallet.contractRepository,
|
|
20434
20999
|
walletPubKeyHex,
|
|
20435
21000
|
currentTime: Date.now()
|
|
@@ -20448,7 +21013,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
20448
21013
|
});
|
|
20449
21014
|
continue;
|
|
20450
21015
|
}
|
|
20451
|
-
const t =
|
|
21016
|
+
const t = chunkFNCQJLR2_cjs.sequenceToTimelock(resolved.selection.sequence);
|
|
20452
21017
|
const delay = { type: t.type, value: Number(t.value) };
|
|
20453
21018
|
infos.push({ outpoint, value: vtxo.value, sweepFee, path: resolved.label, delay });
|
|
20454
21019
|
sweeps.push({ vtxo, resolved, sweepFee, delay });
|
|
@@ -20787,7 +21352,7 @@ async function prepare(opts) {
|
|
|
20787
21352
|
txid: sweep.vtxo.txid,
|
|
20788
21353
|
vout: sweep.vtxo.vout,
|
|
20789
21354
|
value: sweep.vtxo.value,
|
|
20790
|
-
pkScript:
|
|
21355
|
+
pkScript: chunkFNCQJLR2_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
|
|
20791
21356
|
},
|
|
20792
21357
|
path: sweep.resolved.selection,
|
|
20793
21358
|
outputAddress: opts.sweepAddress,
|
|
@@ -20872,7 +21437,7 @@ async function prepare(opts) {
|
|
|
20872
21437
|
if (newFee <= splitterFee) break;
|
|
20873
21438
|
splitterFee = newFee;
|
|
20874
21439
|
}
|
|
20875
|
-
const splitter = new
|
|
21440
|
+
const splitter = new chunkFNCQJLR2_cjs.Transaction({ version: 2 });
|
|
20876
21441
|
for (const coin of selected.inputs) {
|
|
20877
21442
|
splitter.addInput({
|
|
20878
21443
|
txid: coin.txid,
|
|
@@ -21015,41 +21580,41 @@ var UnilateralExit = {
|
|
|
21015
21580
|
// src/arkade/index.ts
|
|
21016
21581
|
var arkade_exports = {};
|
|
21017
21582
|
chunk5BLDMQED_cjs.__export(arkade_exports, {
|
|
21018
|
-
ARKADE_OP: () =>
|
|
21019
|
-
ARKADE_OPCODES: () =>
|
|
21020
|
-
ARKADE_OPCODE_NAMES: () =>
|
|
21021
|
-
ARKADE_OPCODE_VALUES: () =>
|
|
21022
|
-
ARKADE_OPS: () =>
|
|
21583
|
+
ARKADE_OP: () => chunkSF5NKAUA_cjs.ARKADE_OP,
|
|
21584
|
+
ARKADE_OPCODES: () => chunkSF5NKAUA_cjs.ARKADE_OPCODES,
|
|
21585
|
+
ARKADE_OPCODE_NAMES: () => chunkSF5NKAUA_cjs.ARKADE_OPCODE_NAMES,
|
|
21586
|
+
ARKADE_OPCODE_VALUES: () => chunkSF5NKAUA_cjs.ARKADE_OPCODE_VALUES,
|
|
21587
|
+
ARKADE_OPS: () => chunkSF5NKAUA_cjs.ARKADE_OPS,
|
|
21023
21588
|
Arkade: () => Arkade,
|
|
21024
21589
|
ArkadeContract: () => ArkadeContract,
|
|
21025
|
-
ArkadeProgramScript: () =>
|
|
21026
|
-
ArkadeScript: () =>
|
|
21590
|
+
ArkadeProgramScript: () => chunkSF5NKAUA_cjs.ArkadeProgramScript,
|
|
21591
|
+
ArkadeScript: () => chunkSF5NKAUA_cjs.ArkadeScript,
|
|
21027
21592
|
ArkadeTransactionBuilder: () => ArkadeTransactionBuilder,
|
|
21028
|
-
BigNum: () =>
|
|
21593
|
+
BigNum: () => chunkSF5NKAUA_cjs.bignum_exports,
|
|
21029
21594
|
OP: () => btcSigner.OP,
|
|
21030
|
-
OPCODE_NAMES: () =>
|
|
21031
|
-
OPCODE_VALUES: () =>
|
|
21032
|
-
SUPPORTED_PROGRAM_VERSION: () =>
|
|
21595
|
+
OPCODE_NAMES: () => chunkSF5NKAUA_cjs.OPCODE_NAMES,
|
|
21596
|
+
OPCODE_VALUES: () => chunkSF5NKAUA_cjs.OPCODE_VALUES,
|
|
21597
|
+
SUPPORTED_PROGRAM_VERSION: () => chunkSF5NKAUA_cjs.SUPPORTED_PROGRAM_VERSION,
|
|
21033
21598
|
Script: () => btcSigner.Script,
|
|
21034
|
-
arkadeScriptHash: () =>
|
|
21035
|
-
arkadeWitnessHash: () =>
|
|
21036
|
-
asmToBytes: () =>
|
|
21037
|
-
bytesToASM: () =>
|
|
21038
|
-
computeArkadeScriptPublicKey: () =>
|
|
21599
|
+
arkadeScriptHash: () => chunkSF5NKAUA_cjs.arkadeScriptHash,
|
|
21600
|
+
arkadeWitnessHash: () => chunkSF5NKAUA_cjs.arkadeWitnessHash,
|
|
21601
|
+
asmToBytes: () => chunkSF5NKAUA_cjs.asmToBytes,
|
|
21602
|
+
bytesToASM: () => chunkSF5NKAUA_cjs.bytesToASM,
|
|
21603
|
+
computeArkadeScriptPublicKey: () => chunkSF5NKAUA_cjs.computeArkadeScriptPublicKey,
|
|
21039
21604
|
createArkadeBatchHandler: () => createArkadeBatchHandler,
|
|
21040
|
-
deserializeArkadeContractParams: () =>
|
|
21041
|
-
fromASM: () =>
|
|
21042
|
-
getOpcodeName: () =>
|
|
21043
|
-
getOpcodeValue: () =>
|
|
21044
|
-
parseArtifact: () =>
|
|
21045
|
-
resolveAsm: () =>
|
|
21046
|
-
serializeArkadeContractParams: () =>
|
|
21047
|
-
stringifyArtifact: () =>
|
|
21048
|
-
toASM: () =>
|
|
21049
|
-
validateProgram: () =>
|
|
21050
|
-
witnessRefToBytes: () =>
|
|
21605
|
+
deserializeArkadeContractParams: () => chunkSF5NKAUA_cjs.deserializeArkadeContractParams,
|
|
21606
|
+
fromASM: () => chunkSF5NKAUA_cjs.fromASM,
|
|
21607
|
+
getOpcodeName: () => chunkSF5NKAUA_cjs.getOpcodeName,
|
|
21608
|
+
getOpcodeValue: () => chunkSF5NKAUA_cjs.getOpcodeValue,
|
|
21609
|
+
parseArtifact: () => chunkSF5NKAUA_cjs.parseArtifact,
|
|
21610
|
+
resolveAsm: () => chunkSF5NKAUA_cjs.resolveAsm,
|
|
21611
|
+
serializeArkadeContractParams: () => chunkSF5NKAUA_cjs.serializeArkadeContractParams,
|
|
21612
|
+
stringifyArtifact: () => chunkSF5NKAUA_cjs.stringifyArtifact,
|
|
21613
|
+
toASM: () => chunkSF5NKAUA_cjs.toASM,
|
|
21614
|
+
validateProgram: () => chunkSF5NKAUA_cjs.validateProgram,
|
|
21615
|
+
witnessRefToBytes: () => chunkSF5NKAUA_cjs.witnessRefToBytes
|
|
21051
21616
|
});
|
|
21052
|
-
var isVtxoCoin = (input) =>
|
|
21617
|
+
var isVtxoCoin = (input) => chunkFNCQJLR2_cjs.isVirtualCoin(input);
|
|
21053
21618
|
function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
|
|
21054
21619
|
let batchId;
|
|
21055
21620
|
let sweepTapTreeRoot;
|
|
@@ -21070,7 +21635,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
21070
21635
|
);
|
|
21071
21636
|
await arkProvider.confirmRegistration(intentId);
|
|
21072
21637
|
batchId = event.id;
|
|
21073
|
-
const sweepTapscript =
|
|
21638
|
+
const sweepTapscript = chunkFNCQJLR2_cjs.CSVMultisigTapscript.encode({
|
|
21074
21639
|
timelock,
|
|
21075
21640
|
pubkeys: [base.hex.decode(info.forfeitPubkey).subarray(1)]
|
|
21076
21641
|
}).script;
|
|
@@ -21084,7 +21649,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
21084
21649
|
if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
|
|
21085
21650
|
return { skip: true };
|
|
21086
21651
|
}
|
|
21087
|
-
const commitmentTx =
|
|
21652
|
+
const commitmentTx = chunkFNCQJLR2_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
|
|
21088
21653
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
21089
21654
|
if (recipients && recipients.length > 0) {
|
|
21090
21655
|
validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
|
|
@@ -21116,7 +21681,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
21116
21681
|
if (connectorTree) {
|
|
21117
21682
|
validateConnectorsTxGraph(event.commitmentTx, connectorTree);
|
|
21118
21683
|
}
|
|
21119
|
-
let commitmentPsbt =
|
|
21684
|
+
let commitmentPsbt = chunkFNCQJLR2_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
21120
21685
|
assertFinalCommitmentMatchesValidated(
|
|
21121
21686
|
commitmentPsbt,
|
|
21122
21687
|
validatedCommitmentTxid,
|
|
@@ -21151,7 +21716,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
21151
21716
|
boardingIndices.push(boardingIdx);
|
|
21152
21717
|
continue;
|
|
21153
21718
|
}
|
|
21154
|
-
if (
|
|
21719
|
+
if (chunkFNCQJLR2_cjs.isRecoverable(input) || isSubdust(input, info.dust)) {
|
|
21155
21720
|
continue;
|
|
21156
21721
|
}
|
|
21157
21722
|
if (connectorIndex >= connectorLeaves.length) {
|
|
@@ -21172,7 +21737,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
21172
21737
|
index: input.vout,
|
|
21173
21738
|
witnessUtxo: {
|
|
21174
21739
|
amount: BigInt(input.value),
|
|
21175
|
-
script:
|
|
21740
|
+
script: chunkFNCQJLR2_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
21176
21741
|
},
|
|
21177
21742
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
21178
21743
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -21264,11 +21829,11 @@ var Arkade = class _Arkade {
|
|
|
21264
21829
|
static async connect(opts) {
|
|
21265
21830
|
const info = await opts.arkade.getInfo();
|
|
21266
21831
|
const serverKey = base.hex.decode(info.signerPubkey).slice(1);
|
|
21267
|
-
const checkpoint =
|
|
21268
|
-
const network = opts.network ??
|
|
21832
|
+
const checkpoint = chunkFNCQJLR2_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
21833
|
+
const network = opts.network ?? chunkFNCQJLR2_cjs.DEFAULT_NETWORK;
|
|
21269
21834
|
let emulatorKey;
|
|
21270
21835
|
if (opts.emulator) {
|
|
21271
|
-
emulatorKey = base.hex.decode(
|
|
21836
|
+
emulatorKey = base.hex.decode(chunkFNCQJLR2_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
|
|
21272
21837
|
}
|
|
21273
21838
|
let userKey;
|
|
21274
21839
|
if (opts.identity) {
|
|
@@ -21299,7 +21864,7 @@ var Arkade = class _Arkade {
|
|
|
21299
21864
|
* key respectively; explicit args always win.
|
|
21300
21865
|
*/
|
|
21301
21866
|
contract(program, args = {}) {
|
|
21302
|
-
const declared = (program.params ?? []).map(
|
|
21867
|
+
const declared = (program.params ?? []).map(chunkSF5NKAUA_cjs.inputName);
|
|
21303
21868
|
if (declared.includes("server") && args.server === void 0) {
|
|
21304
21869
|
args = { ...args, server: this.serverKey };
|
|
21305
21870
|
}
|
|
@@ -21319,7 +21884,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
21319
21884
|
userKey: client.userKey,
|
|
21320
21885
|
emulatorKey: client.emulatorKey
|
|
21321
21886
|
};
|
|
21322
|
-
this.vtxoScript = new
|
|
21887
|
+
this.vtxoScript = new chunkSF5NKAUA_cjs.ArkadeProgramScript(program, args, this.keys);
|
|
21323
21888
|
this.tapTree = this.vtxoScript.encode();
|
|
21324
21889
|
this.compiled = this.vtxoScript.compiled;
|
|
21325
21890
|
}
|
|
@@ -21347,7 +21912,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
21347
21912
|
`ArkadeContract.fromContract: expected contract type 'arkade', got '${contract.type}'`
|
|
21348
21913
|
);
|
|
21349
21914
|
}
|
|
21350
|
-
const typed =
|
|
21915
|
+
const typed = chunkSF5NKAUA_cjs.deserializeArkadeContractParams(contract.params);
|
|
21351
21916
|
return new _ArkadeContract(client, typed.program, typed.args, {
|
|
21352
21917
|
serverKey: typed.serverKey,
|
|
21353
21918
|
userKey: typed.userKey,
|
|
@@ -21388,7 +21953,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
21388
21953
|
toContractParams() {
|
|
21389
21954
|
return {
|
|
21390
21955
|
type: "arkade",
|
|
21391
|
-
params:
|
|
21956
|
+
params: chunkSF5NKAUA_cjs.serializeArkadeContractParams({
|
|
21392
21957
|
program: this.program,
|
|
21393
21958
|
args: this.args,
|
|
21394
21959
|
serverKey: this.keys.serverKey,
|
|
@@ -21433,13 +21998,13 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
21433
21998
|
const [registered] = await manager.getContracts({ script: scriptHex });
|
|
21434
21999
|
if (registered) {
|
|
21435
22000
|
const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
|
|
21436
|
-
return (withVtxos?.vtxos ?? []).filter((v) => !
|
|
22001
|
+
return (withVtxos?.vtxos ?? []).filter((v) => !chunkFNCQJLR2_cjs.hasTerminalSpend(v));
|
|
21437
22002
|
}
|
|
21438
22003
|
}
|
|
21439
22004
|
if (!this.client.indexer) {
|
|
21440
22005
|
throw new Error("ArkadeContract.getUtxos: an indexer is required");
|
|
21441
22006
|
}
|
|
21442
|
-
const { vtxos } = await
|
|
22007
|
+
const { vtxos } = await chunkFNCQJLR2_cjs.getNormalizedVtxos(this.client.indexer, {
|
|
21443
22008
|
scripts: [scriptHex],
|
|
21444
22009
|
spendableOnly: true
|
|
21445
22010
|
});
|
|
@@ -21541,12 +22106,12 @@ var ArkadeTransactionBuilder = class {
|
|
|
21541
22106
|
this.contract.client.checkpoint
|
|
21542
22107
|
);
|
|
21543
22108
|
if (coin.sourceTx) {
|
|
21544
|
-
|
|
22109
|
+
chunkFNCQJLR2_cjs.setArkPsbtField(arkTx, 0, chunkFNCQJLR2_cjs.PrevArkTxField, coin.sourceTx);
|
|
21545
22110
|
}
|
|
21546
22111
|
const condition = (def.tapscript.witness ?? []).map((w) => this.witnessBytes(w));
|
|
21547
22112
|
if (condition.length > 0) {
|
|
21548
|
-
|
|
21549
|
-
|
|
22113
|
+
chunkFNCQJLR2_cjs.setArkPsbtField(arkTx, 0, chunkFNCQJLR2_cjs.ConditionWitness, condition);
|
|
22114
|
+
chunkFNCQJLR2_cjs.setArkPsbtField(checkpoints[0], 0, chunkFNCQJLR2_cjs.ConditionWitness, condition);
|
|
21550
22115
|
}
|
|
21551
22116
|
const packets = [];
|
|
21552
22117
|
if (this.assetSpecs.length > 0) {
|
|
@@ -21585,7 +22150,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
21585
22150
|
base.base64.encode(signedArk2.toPSBT()),
|
|
21586
22151
|
signedCps.map((c) => base.base64.encode(c.toPSBT()))
|
|
21587
22152
|
);
|
|
21588
|
-
const txid =
|
|
22153
|
+
const txid = chunkFNCQJLR2_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
|
|
21589
22154
|
return {
|
|
21590
22155
|
txid,
|
|
21591
22156
|
signedArkTx: res2.signedArkTx,
|
|
@@ -21644,23 +22209,23 @@ var ArkadeTransactionBuilder = class {
|
|
|
21644
22209
|
}
|
|
21645
22210
|
buildAssetPacket() {
|
|
21646
22211
|
const groups = this.assetSpecs.map((s) => {
|
|
21647
|
-
const id = typeof s.assetId === "string" ?
|
|
21648
|
-
return
|
|
22212
|
+
const id = typeof s.assetId === "string" ? chunk2JHN5RCY_cjs.AssetId.fromString(s.assetId) : chunk2JHN5RCY_cjs.AssetId.fromBytes(s.assetId);
|
|
22213
|
+
return chunk2JHN5RCY_cjs.AssetGroup.create(
|
|
21649
22214
|
id,
|
|
21650
22215
|
null,
|
|
21651
|
-
s.inputs.map((i) =>
|
|
21652
|
-
s.outputs.map((o) =>
|
|
21653
|
-
(s.metadata ?? []).map((m) =>
|
|
22216
|
+
s.inputs.map((i) => chunk2JHN5RCY_cjs.AssetInput.create(i.vin, i.amount)),
|
|
22217
|
+
s.outputs.map((o) => chunk2JHN5RCY_cjs.AssetOutput.create(o.vout, o.amount)),
|
|
22218
|
+
(s.metadata ?? []).map((m) => chunk2JHN5RCY_cjs.Metadata.create(m.key, m.value))
|
|
21654
22219
|
);
|
|
21655
22220
|
});
|
|
21656
|
-
return
|
|
22221
|
+
return chunk2JHN5RCY_cjs.Packet.create(groups);
|
|
21657
22222
|
}
|
|
21658
22223
|
witnessBytes(ref) {
|
|
21659
|
-
return
|
|
22224
|
+
return chunkSF5NKAUA_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
|
|
21660
22225
|
}
|
|
21661
22226
|
};
|
|
21662
22227
|
function bindInputs(fn, callArgs) {
|
|
21663
|
-
const names = (fn.def.inputs ?? []).map(
|
|
22228
|
+
const names = (fn.def.inputs ?? []).map(chunkSF5NKAUA_cjs.inputName);
|
|
21664
22229
|
if (callArgs.length !== names.length) {
|
|
21665
22230
|
throw new Error(`${fn.name}: expected ${names.length} argument(s), got ${callArgs.length}`);
|
|
21666
22231
|
}
|
|
@@ -22042,8 +22607,14 @@ function createDefaultPaymentRouter(wallet) {
|
|
|
22042
22607
|
prefs: { priority: ["ark", "lightning", "onchain"] }
|
|
22043
22608
|
}).use(arkRail()).use(onchainRail());
|
|
22044
22609
|
}
|
|
22610
|
+
/*! Bundled license information:
|
|
22611
|
+
|
|
22612
|
+
@noble/hashes/utils.js:
|
|
22613
|
+
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
22614
|
+
*/
|
|
22045
22615
|
|
|
22046
22616
|
exports.ARKADE_MAGIC = ARKADE_MAGIC;
|
|
22617
|
+
exports.ARKADE_SWAP_PREIMAGE_TAG = ARKADE_SWAP_PREIMAGE_TAG;
|
|
22047
22618
|
exports.ActivityRegistry = ActivityRegistry;
|
|
22048
22619
|
exports.AmbiguousRouteError = AmbiguousRouteError;
|
|
22049
22620
|
exports.ArkNote = ArkNote;
|
|
@@ -22076,6 +22647,7 @@ exports.EsploraProvider = EsploraProvider;
|
|
|
22076
22647
|
exports.Estimator = Estimator;
|
|
22077
22648
|
exports.Extension = Extension;
|
|
22078
22649
|
exports.ExtensionNotFoundError = ExtensionNotFoundError;
|
|
22650
|
+
exports.ForeignDescriptorError = ForeignDescriptorError;
|
|
22079
22651
|
exports.HDDescriptorProvider = HDDescriptorProvider;
|
|
22080
22652
|
exports.INTENT_TERMINAL_STATES = INTENT_TERMINAL_STATES;
|
|
22081
22653
|
exports.InMemoryContractRepository = InMemoryContractRepository;
|
|
@@ -22124,10 +22696,12 @@ exports.UnilateralExit = UnilateralExit;
|
|
|
22124
22696
|
exports.UnknownPacket = UnknownPacket;
|
|
22125
22697
|
exports.VtxoManager = VtxoManager;
|
|
22126
22698
|
exports.Wallet = Wallet2;
|
|
22699
|
+
exports.WalletCannotSignError = WalletCannotSignError;
|
|
22127
22700
|
exports.WalletMessageHandler = WalletMessageHandler;
|
|
22128
22701
|
exports.WalletNotInitializedError = WalletNotInitializedError;
|
|
22129
22702
|
exports.WalletRepositoryImpl = WalletRepositoryImpl;
|
|
22130
22703
|
exports.WsElectrumChainSource = WsElectrumChainSource;
|
|
22704
|
+
exports.adoptContractDescriptor = adoptContractDescriptor;
|
|
22131
22705
|
exports.arkRail = arkRail;
|
|
22132
22706
|
exports.arkTarget = arkTarget;
|
|
22133
22707
|
exports.arkade_exports = arkade_exports;
|
|
@@ -22142,6 +22716,7 @@ exports.boardingResolver = boardingResolver;
|
|
|
22142
22716
|
exports.btcTarget = btcTarget;
|
|
22143
22717
|
exports.buildForfeitTx = buildForfeitTx;
|
|
22144
22718
|
exports.buildOffchainTx = buildOffchainTx;
|
|
22719
|
+
exports.buildPreimageMessage = buildPreimageMessage;
|
|
22145
22720
|
exports.claimWithPreimageIdentity = claimWithPreimageIdentity;
|
|
22146
22721
|
exports.classifyAgainstSignerSet = classifyAgainstSignerSet;
|
|
22147
22722
|
exports.classifyContractSigner = classifyContractSigner;
|
|
@@ -22150,6 +22725,8 @@ exports.collabExitResolver = collabExitResolver;
|
|
|
22150
22725
|
exports.combineTapscriptSigs = combineTapscriptSigs;
|
|
22151
22726
|
exports.contractFromArkContract = contractFromArkContract;
|
|
22152
22727
|
exports.contractFromArkContractWithAddress = contractFromArkContractWithAddress;
|
|
22728
|
+
exports.contractPreimage = contractPreimage;
|
|
22729
|
+
exports.contractSigner = contractSigner;
|
|
22153
22730
|
exports.createAssetPacket = createAssetPacket;
|
|
22154
22731
|
exports.createDefaultActivityRegistry = createDefaultActivityRegistry;
|
|
22155
22732
|
exports.createDefaultPaymentRouter = createDefaultPaymentRouter;
|
|
@@ -22177,6 +22754,7 @@ exports.isBatchSignable = isBatchSignable;
|
|
|
22177
22754
|
exports.isBtcAddress = isBtcAddress;
|
|
22178
22755
|
exports.isContractGenericallySpendable = isContractGenericallySpendable;
|
|
22179
22756
|
exports.isCooperativelyMigratable = isCooperativelyMigratable;
|
|
22757
|
+
exports.isDeterministicSigner = isDeterministicSigner;
|
|
22180
22758
|
exports.isDiscoverable = isDiscoverable;
|
|
22181
22759
|
exports.isHDAllocationCapable = isHDAllocationCapable;
|
|
22182
22760
|
exports.isHDDeterministicSignCapable = isHDDeterministicSignCapable;
|
|
@@ -22185,6 +22763,8 @@ exports.isLightningInvoice = isLightningInvoice;
|
|
|
22185
22763
|
exports.isLnurl = isLnurl;
|
|
22186
22764
|
exports.isMessageBusInitializingError = isMessageBusInitializingError;
|
|
22187
22765
|
exports.isMessageBusNotInitializedError = isMessageBusNotInitializedError;
|
|
22766
|
+
exports.isPerArtifactDescriptor = isPerArtifactDescriptor;
|
|
22767
|
+
exports.isSigningIdentity = isSigningIdentity;
|
|
22188
22768
|
exports.isSubdust = isSubdust;
|
|
22189
22769
|
exports.isTerminalIntentState = isTerminalIntentState;
|
|
22190
22770
|
exports.isValidArkAddress = isValidArkAddress;
|
|
@@ -22199,9 +22779,13 @@ exports.migrateWalletRepository = migrateWalletRepository;
|
|
|
22199
22779
|
exports.onchainRail = onchainRail;
|
|
22200
22780
|
exports.openDatabase = openDatabase;
|
|
22201
22781
|
exports.outpointExclusion = outpointExclusion;
|
|
22782
|
+
exports.outpointReasons = outpointReasons;
|
|
22783
|
+
exports.provisionClaimSecret = provisionClaimSecret;
|
|
22784
|
+
exports.provisionRefundKey = provisionRefundKey;
|
|
22202
22785
|
exports.requiresMigration = requiresMigration;
|
|
22203
22786
|
exports.resolveBatchExpiryPolicy = resolveBatchExpiryPolicy;
|
|
22204
22787
|
exports.resolveCheckpointExitDelayPolicy = resolveCheckpointExitDelayPolicy;
|
|
22788
|
+
exports.resolveDescriptorSigner = resolveDescriptorSigner;
|
|
22205
22789
|
exports.resolveSendAmount = resolveSendAmount;
|
|
22206
22790
|
exports.rollbackMigration = rollbackMigration;
|
|
22207
22791
|
exports.saveVtxosForContract = saveVtxosForContract;
|
|
@@ -22225,5 +22809,5 @@ exports.validateVtxoTxGraph = validateVtxoTxGraph;
|
|
|
22225
22809
|
exports.verifyTapscriptSignatures = verifyTapscriptSignatures;
|
|
22226
22810
|
exports.waitForIncomingFunds = waitForIncomingFunds;
|
|
22227
22811
|
exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
|
|
22228
|
-
//# sourceMappingURL=chunk-
|
|
22229
|
-
//# sourceMappingURL=chunk-
|
|
22812
|
+
//# sourceMappingURL=chunk-3NUDA3MB.cjs.map
|
|
22813
|
+
//# sourceMappingURL=chunk-3NUDA3MB.cjs.map
|