@arkade-os/sdk 0.4.60 → 0.4.62
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-B53mOTCw.d.cts} +2 -2
- package/dist/{asyncStorageTaskQueue-Vsp6uk8e.d.ts → asyncStorageTaskQueue-Df-CTfTE.d.ts} +2 -2
- package/dist/{chunk-Y54MUBT7.js → chunk-2IZW6AEK.js} +879 -146
- package/dist/chunk-2IZW6AEK.js.map +1 -0
- package/dist/{chunk-MZNLCMUP.cjs → chunk-G53HASDV.cjs} +113 -79
- package/dist/chunk-G53HASDV.cjs.map +1 -0
- package/dist/{chunk-3Q7BBUWO.js → chunk-H2ZAJOQA.js} +4 -4
- package/dist/{chunk-3Q7BBUWO.js.map → chunk-H2ZAJOQA.js.map} +1 -1
- package/dist/{chunk-PRFL62ID.cjs → chunk-I6EDUE75.cjs} +17 -17
- package/dist/{chunk-PRFL62ID.cjs.map → chunk-I6EDUE75.cjs.map} +1 -1
- package/dist/{chunk-B66RYHTB.js → chunk-I7RLG6VX.js} +4 -4
- package/dist/{chunk-B66RYHTB.js.map → chunk-I7RLG6VX.js.map} +1 -1
- package/dist/{chunk-2DINXHGQ.js → chunk-L7S5KC5B.js} +66 -35
- package/dist/chunk-L7S5KC5B.js.map +1 -0
- package/dist/{chunk-4A4GRSTB.cjs → chunk-OH2XLTXE.cjs} +3 -3
- package/dist/{chunk-4A4GRSTB.cjs.map → chunk-OH2XLTXE.cjs.map} +1 -1
- package/dist/{chunk-2XLNQHG4.cjs → chunk-PWWA4DBL.cjs} +10 -10
- package/dist/{chunk-2XLNQHG4.cjs.map → chunk-PWWA4DBL.cjs.map} +1 -1
- package/dist/{chunk-H7JCHFM6.cjs → chunk-QRSR4HV4.cjs} +17 -17
- package/dist/{chunk-H7JCHFM6.cjs.map → chunk-QRSR4HV4.cjs.map} +1 -1
- package/dist/{chunk-FSKANUV4.js → chunk-RMBI6P4N.js} +3 -3
- package/dist/{chunk-FSKANUV4.js.map → chunk-RMBI6P4N.js.map} +1 -1
- package/dist/{chunk-JBULXTCC.js → chunk-URT2RVGB.js} +3 -3
- package/dist/{chunk-JBULXTCC.js.map → chunk-URT2RVGB.js.map} +1 -1
- package/dist/{chunk-KNS5MTTI.cjs → chunk-Z2OZMKFV.cjs} +1272 -523
- package/dist/chunk-Z2OZMKFV.cjs.map +1 -0
- 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-BjYJJsml.d.ts} +1 -1
- package/dist/{delegate-DidNTsKm.d.ts → delegate-CC1gcvuC.d.cts} +1 -1
- package/dist/{index-BP8-zniX.d.cts → index-C888wFEV.d.ts} +102 -102
- package/dist/{ark-D2_yNhfz.d.cts → index-CwBr7qzV.d.cts} +3941 -3812
- package/dist/{ark-D2_yNhfz.d.ts → index-CwBr7qzV.d.ts} +3941 -3812
- package/dist/{index-DzQbNQUG.d.ts → index-Cz5_WaQP.d.cts} +102 -102
- package/dist/index.cjs +328 -248
- package/dist/index.d.cts +340 -52
- package/dist/index.d.ts +340 -52
- 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-BMUndClz.d.cts} +2 -2
- package/dist/{taskRunner-BEQNFEa4.d.cts → taskRunner-DZWUsSzA.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 +36 -16
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +13 -6
- package/dist/wallet/expo/index.d.ts +13 -6
- package/dist/wallet/expo/index.js +27 -7
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/{wallet-ipUA1XCp.d.cts → wallet-Dpjx6CJ7.d.ts} +91 -17
- package/dist/{wallet-C_MYHyOj.d.ts → wallet-H3f14est.d.cts} +91 -17
- 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 chunkI6EDUE75_cjs = require('./chunk-I6EDUE75.cjs');
|
|
4
|
+
var chunkG53HASDV_cjs = require('./chunk-G53HASDV.cjs');
|
|
5
|
+
var chunkOH2XLTXE_cjs = require('./chunk-OH2XLTXE.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 = chunkOH2XLTXE_cjs.getArkPsbtFields(tx.root, 0, chunkOH2XLTXE_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 = chunkOH2XLTXE_cjs.getArkPsbtFields(g.root, 0, chunkOH2XLTXE_cjs.CosignerPublicKey).map((c) => c.key);
|
|
244
244
|
const { finalKey } = aggregateKeys(cosigners, true, {
|
|
245
245
|
taprootTweak: this.scriptRoot
|
|
246
246
|
});
|
|
@@ -354,6 +354,18 @@ var SingleKey = class _SingleKey {
|
|
|
354
354
|
if (signatureType === "ecdsa") return secp256k1.signAsync(message, this.key, { prehash: false });
|
|
355
355
|
return secp256k1.schnorr.signAsync(message, this.key);
|
|
356
356
|
}
|
|
357
|
+
/**
|
|
358
|
+
* BIP-340 sign `messageHash` with aux_rand = 0, so the signature — and
|
|
359
|
+
* anything derived from it — is reproducible from the key alone.
|
|
360
|
+
*
|
|
361
|
+
* What lets a static wallet derive a swap preimage instead of storing one
|
|
362
|
+
* (see `wallet/contractSecrets.ts`). Deliberately NOT `signMessage`, whose
|
|
363
|
+
* schnorr branch draws a random aux_rand: a preimage derived from that is
|
|
364
|
+
* unrecoverable, and the loss would only surface at claim time.
|
|
365
|
+
*/
|
|
366
|
+
async signSchnorrDeterministic(messageHash) {
|
|
367
|
+
return secp256k1.schnorr.signAsync(messageHash, this.key, new Uint8Array(32));
|
|
368
|
+
}
|
|
357
369
|
async toReadonly() {
|
|
358
370
|
return new ReadonlySingleKey(await this.compressedPublicKey());
|
|
359
371
|
}
|
|
@@ -419,7 +431,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
419
431
|
let network;
|
|
420
432
|
if ("descriptor" in opts && typeof opts.descriptor === "string") {
|
|
421
433
|
descriptor = opts.descriptor;
|
|
422
|
-
network =
|
|
434
|
+
network = chunkG53HASDV_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
423
435
|
} else {
|
|
424
436
|
network = opts.isMainnet ?? true ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
425
437
|
descriptor = descriptorsScure.scriptExpressions.trBIP32({
|
|
@@ -483,6 +495,19 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
483
495
|
async signMessage(message, signatureType = "schnorr") {
|
|
484
496
|
return this.signMessageWithKey(this.derivedKey, message, signatureType);
|
|
485
497
|
}
|
|
498
|
+
/**
|
|
499
|
+
* BIP-340 sign `messageHash` with this identity's own key, aux_rand = 0.
|
|
500
|
+
*
|
|
501
|
+
* The descriptor-less sibling of
|
|
502
|
+
* {@link signSchnorrDeterministicWithDescriptor}, for an `auto`-mode wallet
|
|
503
|
+
* whose bare `tr(pubkey)` resolves to the identity itself rather than to a
|
|
504
|
+
* {@link DescriptorIdentity}. Deliberately NOT routed through
|
|
505
|
+
* `signMessage`, whose schnorr branch draws a random aux_rand and would
|
|
506
|
+
* make the "deterministic" signature unreproducible.
|
|
507
|
+
*/
|
|
508
|
+
async signSchnorrDeterministic(messageHash) {
|
|
509
|
+
return secp256k1.schnorr.signAsync(messageHash, this.derivedKey, new Uint8Array(32));
|
|
510
|
+
}
|
|
486
511
|
signerSession() {
|
|
487
512
|
return TreeSignerSession.random();
|
|
488
513
|
}
|
|
@@ -504,7 +529,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
504
529
|
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
505
530
|
*/
|
|
506
531
|
isOurs(descriptor) {
|
|
507
|
-
return
|
|
532
|
+
return chunkG53HASDV_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
|
|
508
533
|
}
|
|
509
534
|
/**
|
|
510
535
|
* Signs each request with the key derived from its descriptor.
|
|
@@ -553,7 +578,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
553
578
|
}
|
|
554
579
|
// ── internal helpers ─────────────────────────────────────────────
|
|
555
580
|
derivePrivateKeyForDescriptor(descriptor) {
|
|
556
|
-
const network =
|
|
581
|
+
const network = chunkG53HASDV_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
557
582
|
const expansion = descriptorsScure.expand({ descriptor, network });
|
|
558
583
|
if (expansion.isRanged) {
|
|
559
584
|
throw new Error(
|
|
@@ -639,7 +664,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
639
664
|
*/
|
|
640
665
|
descriptor;
|
|
641
666
|
constructor(descriptor) {
|
|
642
|
-
const network =
|
|
667
|
+
const network = chunkG53HASDV_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
643
668
|
let expansion;
|
|
644
669
|
try {
|
|
645
670
|
expansion = descriptorsScure.expand({ descriptor, network, index: 0 });
|
|
@@ -689,7 +714,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
689
714
|
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
690
715
|
*/
|
|
691
716
|
isOurs(descriptor) {
|
|
692
|
-
return
|
|
717
|
+
return chunkG53HASDV_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
|
|
693
718
|
}
|
|
694
719
|
};
|
|
695
720
|
function serializeSeedOwnedSigningIdentity(identity) {
|
|
@@ -851,10 +876,10 @@ var DescriptorIdentity = class {
|
|
|
851
876
|
this.base = base;
|
|
852
877
|
}
|
|
853
878
|
async xOnlyPublicKey() {
|
|
854
|
-
return
|
|
879
|
+
return chunkG53HASDV_cjs.deriveDescriptorLeafPubKey(this.descriptor);
|
|
855
880
|
}
|
|
856
881
|
async compressedPublicKey() {
|
|
857
|
-
return
|
|
882
|
+
return chunkG53HASDV_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
|
|
858
883
|
}
|
|
859
884
|
async sign(tx, inputIndexes) {
|
|
860
885
|
const [signed] = await this.signer.signWithDescriptor([
|
|
@@ -901,8 +926,33 @@ function isHDCapableIdentity(value) {
|
|
|
901
926
|
function isBatchSignable(identity) {
|
|
902
927
|
return "signMultiple" in identity && typeof identity.signMultiple === "function";
|
|
903
928
|
}
|
|
904
|
-
|
|
905
|
-
|
|
929
|
+
function isSigningIdentity(value) {
|
|
930
|
+
if (typeof value !== "object" || value === null) return false;
|
|
931
|
+
const v = value;
|
|
932
|
+
return typeof v.sign === "function" && typeof v.signMessage === "function" && typeof v.signerSession === "function" && typeof v.xOnlyPublicKey === "function";
|
|
933
|
+
}
|
|
934
|
+
var ForeignDescriptorError = class extends Error {
|
|
935
|
+
constructor(descriptor, options) {
|
|
936
|
+
super(`this wallet holds no key for descriptor: ${descriptor}`, options);
|
|
937
|
+
this.descriptor = descriptor;
|
|
938
|
+
}
|
|
939
|
+
descriptor;
|
|
940
|
+
name = "ForeignDescriptorError";
|
|
941
|
+
};
|
|
942
|
+
async function resolveDescriptorSigner(descriptor, identity, provider) {
|
|
943
|
+
const owner = provider?.isOurs(descriptor) ? provider : isHDCapableIdentity(identity) && identity.isOurs(descriptor) ? identity : void 0;
|
|
944
|
+
if (owner && chunkG53HASDV_cjs.parseHDDescriptor(descriptor)) {
|
|
945
|
+
return new DescriptorIdentity({ descriptor, signer: owner, base: identity });
|
|
946
|
+
}
|
|
947
|
+
let key;
|
|
948
|
+
try {
|
|
949
|
+
key = chunkG53HASDV_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
950
|
+
} catch {
|
|
951
|
+
throw new ForeignDescriptorError(descriptor);
|
|
952
|
+
}
|
|
953
|
+
if (utils_js.equalBytes(await identity.xOnlyPublicKey(), key)) return identity;
|
|
954
|
+
throw new ForeignDescriptorError(descriptor);
|
|
955
|
+
}
|
|
906
956
|
function isHDWalletCapable(value) {
|
|
907
957
|
if (typeof value !== "object" || value === null) return false;
|
|
908
958
|
const v = value;
|
|
@@ -914,6 +964,478 @@ function isHDAllocationCapable(value) {
|
|
|
914
964
|
return typeof v.getNextSigningDescriptor === "function" && typeof v.advanceSigningDescriptorWatermark === "function";
|
|
915
965
|
}
|
|
916
966
|
|
|
967
|
+
// ../../node_modules/@noble/hashes/utils.js
|
|
968
|
+
function isBytes(a) {
|
|
969
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
970
|
+
}
|
|
971
|
+
function abytes(value, length, title = "") {
|
|
972
|
+
const bytes = isBytes(value);
|
|
973
|
+
const len = value?.length;
|
|
974
|
+
const needsLen = length !== void 0;
|
|
975
|
+
if (!bytes || needsLen) {
|
|
976
|
+
const prefix = title && `"${title}" `;
|
|
977
|
+
const ofLen = "";
|
|
978
|
+
const got = bytes ? `length=${len}` : `type=${typeof value}`;
|
|
979
|
+
throw new Error(prefix + "expected Uint8Array" + ofLen + ", got " + got);
|
|
980
|
+
}
|
|
981
|
+
return value;
|
|
982
|
+
}
|
|
983
|
+
function aexists(instance, checkFinished = true) {
|
|
984
|
+
if (instance.destroyed)
|
|
985
|
+
throw new Error("Hash instance has been destroyed");
|
|
986
|
+
if (checkFinished && instance.finished)
|
|
987
|
+
throw new Error("Hash#digest() has already been called");
|
|
988
|
+
}
|
|
989
|
+
function aoutput(out, instance) {
|
|
990
|
+
abytes(out, void 0, "digestInto() output");
|
|
991
|
+
const min = instance.outputLen;
|
|
992
|
+
if (out.length < min) {
|
|
993
|
+
throw new Error('"digestInto() output" expected to be of length >=' + min);
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
function clean(...arrays) {
|
|
997
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
998
|
+
arrays[i].fill(0);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
function createView(arr) {
|
|
1002
|
+
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
1003
|
+
}
|
|
1004
|
+
function rotr(word, shift) {
|
|
1005
|
+
return word << 32 - shift | word >>> shift;
|
|
1006
|
+
}
|
|
1007
|
+
function createHasher(hashCons, info = {}) {
|
|
1008
|
+
const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
|
|
1009
|
+
const tmp = hashCons(void 0);
|
|
1010
|
+
hashC.outputLen = tmp.outputLen;
|
|
1011
|
+
hashC.blockLen = tmp.blockLen;
|
|
1012
|
+
hashC.create = (opts) => hashCons(opts);
|
|
1013
|
+
Object.assign(hashC, info);
|
|
1014
|
+
return Object.freeze(hashC);
|
|
1015
|
+
}
|
|
1016
|
+
function randomBytes(bytesLength = 32) {
|
|
1017
|
+
const cr = typeof globalThis === "object" ? globalThis.crypto : null;
|
|
1018
|
+
if (typeof cr?.getRandomValues !== "function")
|
|
1019
|
+
throw new Error("crypto.getRandomValues must be defined");
|
|
1020
|
+
return cr.getRandomValues(new Uint8Array(bytesLength));
|
|
1021
|
+
}
|
|
1022
|
+
var oidNist = (suffix) => ({
|
|
1023
|
+
oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
|
|
1024
|
+
});
|
|
1025
|
+
|
|
1026
|
+
// ../../node_modules/@noble/hashes/_md.js
|
|
1027
|
+
function Chi(a, b, c) {
|
|
1028
|
+
return a & b ^ ~a & c;
|
|
1029
|
+
}
|
|
1030
|
+
function Maj(a, b, c) {
|
|
1031
|
+
return a & b ^ a & c ^ b & c;
|
|
1032
|
+
}
|
|
1033
|
+
var HashMD = class {
|
|
1034
|
+
blockLen;
|
|
1035
|
+
outputLen;
|
|
1036
|
+
padOffset;
|
|
1037
|
+
isLE;
|
|
1038
|
+
// For partial updates less than block size
|
|
1039
|
+
buffer;
|
|
1040
|
+
view;
|
|
1041
|
+
finished = false;
|
|
1042
|
+
length = 0;
|
|
1043
|
+
pos = 0;
|
|
1044
|
+
destroyed = false;
|
|
1045
|
+
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
1046
|
+
this.blockLen = blockLen;
|
|
1047
|
+
this.outputLen = outputLen;
|
|
1048
|
+
this.padOffset = padOffset;
|
|
1049
|
+
this.isLE = isLE;
|
|
1050
|
+
this.buffer = new Uint8Array(blockLen);
|
|
1051
|
+
this.view = createView(this.buffer);
|
|
1052
|
+
}
|
|
1053
|
+
update(data) {
|
|
1054
|
+
aexists(this);
|
|
1055
|
+
abytes(data);
|
|
1056
|
+
const { view, buffer, blockLen } = this;
|
|
1057
|
+
const len = data.length;
|
|
1058
|
+
for (let pos = 0; pos < len; ) {
|
|
1059
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
1060
|
+
if (take === blockLen) {
|
|
1061
|
+
const dataView = createView(data);
|
|
1062
|
+
for (; blockLen <= len - pos; pos += blockLen)
|
|
1063
|
+
this.process(dataView, pos);
|
|
1064
|
+
continue;
|
|
1065
|
+
}
|
|
1066
|
+
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
1067
|
+
this.pos += take;
|
|
1068
|
+
pos += take;
|
|
1069
|
+
if (this.pos === blockLen) {
|
|
1070
|
+
this.process(view, 0);
|
|
1071
|
+
this.pos = 0;
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
this.length += data.length;
|
|
1075
|
+
this.roundClean();
|
|
1076
|
+
return this;
|
|
1077
|
+
}
|
|
1078
|
+
digestInto(out) {
|
|
1079
|
+
aexists(this);
|
|
1080
|
+
aoutput(out, this);
|
|
1081
|
+
this.finished = true;
|
|
1082
|
+
const { buffer, view, blockLen, isLE } = this;
|
|
1083
|
+
let { pos } = this;
|
|
1084
|
+
buffer[pos++] = 128;
|
|
1085
|
+
clean(this.buffer.subarray(pos));
|
|
1086
|
+
if (this.padOffset > blockLen - pos) {
|
|
1087
|
+
this.process(view, 0);
|
|
1088
|
+
pos = 0;
|
|
1089
|
+
}
|
|
1090
|
+
for (let i = pos; i < blockLen; i++)
|
|
1091
|
+
buffer[i] = 0;
|
|
1092
|
+
view.setBigUint64(blockLen - 8, BigInt(this.length * 8), isLE);
|
|
1093
|
+
this.process(view, 0);
|
|
1094
|
+
const oview = createView(out);
|
|
1095
|
+
const len = this.outputLen;
|
|
1096
|
+
if (len % 4)
|
|
1097
|
+
throw new Error("_sha2: outputLen must be aligned to 32bit");
|
|
1098
|
+
const outLen = len / 4;
|
|
1099
|
+
const state = this.get();
|
|
1100
|
+
if (outLen > state.length)
|
|
1101
|
+
throw new Error("_sha2: outputLen bigger than state");
|
|
1102
|
+
for (let i = 0; i < outLen; i++)
|
|
1103
|
+
oview.setUint32(4 * i, state[i], isLE);
|
|
1104
|
+
}
|
|
1105
|
+
digest() {
|
|
1106
|
+
const { buffer, outputLen } = this;
|
|
1107
|
+
this.digestInto(buffer);
|
|
1108
|
+
const res = buffer.slice(0, outputLen);
|
|
1109
|
+
this.destroy();
|
|
1110
|
+
return res;
|
|
1111
|
+
}
|
|
1112
|
+
_cloneInto(to) {
|
|
1113
|
+
to ||= new this.constructor();
|
|
1114
|
+
to.set(...this.get());
|
|
1115
|
+
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
1116
|
+
to.destroyed = destroyed;
|
|
1117
|
+
to.finished = finished;
|
|
1118
|
+
to.length = length;
|
|
1119
|
+
to.pos = pos;
|
|
1120
|
+
if (length % blockLen)
|
|
1121
|
+
to.buffer.set(buffer);
|
|
1122
|
+
return to;
|
|
1123
|
+
}
|
|
1124
|
+
clone() {
|
|
1125
|
+
return this._cloneInto();
|
|
1126
|
+
}
|
|
1127
|
+
};
|
|
1128
|
+
var SHA256_IV = /* @__PURE__ */ Uint32Array.from([
|
|
1129
|
+
1779033703,
|
|
1130
|
+
3144134277,
|
|
1131
|
+
1013904242,
|
|
1132
|
+
2773480762,
|
|
1133
|
+
1359893119,
|
|
1134
|
+
2600822924,
|
|
1135
|
+
528734635,
|
|
1136
|
+
1541459225
|
|
1137
|
+
]);
|
|
1138
|
+
|
|
1139
|
+
// ../../node_modules/@noble/hashes/sha2.js
|
|
1140
|
+
var SHA256_K = /* @__PURE__ */ Uint32Array.from([
|
|
1141
|
+
1116352408,
|
|
1142
|
+
1899447441,
|
|
1143
|
+
3049323471,
|
|
1144
|
+
3921009573,
|
|
1145
|
+
961987163,
|
|
1146
|
+
1508970993,
|
|
1147
|
+
2453635748,
|
|
1148
|
+
2870763221,
|
|
1149
|
+
3624381080,
|
|
1150
|
+
310598401,
|
|
1151
|
+
607225278,
|
|
1152
|
+
1426881987,
|
|
1153
|
+
1925078388,
|
|
1154
|
+
2162078206,
|
|
1155
|
+
2614888103,
|
|
1156
|
+
3248222580,
|
|
1157
|
+
3835390401,
|
|
1158
|
+
4022224774,
|
|
1159
|
+
264347078,
|
|
1160
|
+
604807628,
|
|
1161
|
+
770255983,
|
|
1162
|
+
1249150122,
|
|
1163
|
+
1555081692,
|
|
1164
|
+
1996064986,
|
|
1165
|
+
2554220882,
|
|
1166
|
+
2821834349,
|
|
1167
|
+
2952996808,
|
|
1168
|
+
3210313671,
|
|
1169
|
+
3336571891,
|
|
1170
|
+
3584528711,
|
|
1171
|
+
113926993,
|
|
1172
|
+
338241895,
|
|
1173
|
+
666307205,
|
|
1174
|
+
773529912,
|
|
1175
|
+
1294757372,
|
|
1176
|
+
1396182291,
|
|
1177
|
+
1695183700,
|
|
1178
|
+
1986661051,
|
|
1179
|
+
2177026350,
|
|
1180
|
+
2456956037,
|
|
1181
|
+
2730485921,
|
|
1182
|
+
2820302411,
|
|
1183
|
+
3259730800,
|
|
1184
|
+
3345764771,
|
|
1185
|
+
3516065817,
|
|
1186
|
+
3600352804,
|
|
1187
|
+
4094571909,
|
|
1188
|
+
275423344,
|
|
1189
|
+
430227734,
|
|
1190
|
+
506948616,
|
|
1191
|
+
659060556,
|
|
1192
|
+
883997877,
|
|
1193
|
+
958139571,
|
|
1194
|
+
1322822218,
|
|
1195
|
+
1537002063,
|
|
1196
|
+
1747873779,
|
|
1197
|
+
1955562222,
|
|
1198
|
+
2024104815,
|
|
1199
|
+
2227730452,
|
|
1200
|
+
2361852424,
|
|
1201
|
+
2428436474,
|
|
1202
|
+
2756734187,
|
|
1203
|
+
3204031479,
|
|
1204
|
+
3329325298
|
|
1205
|
+
]);
|
|
1206
|
+
var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
1207
|
+
var SHA2_32B = class extends HashMD {
|
|
1208
|
+
constructor(outputLen) {
|
|
1209
|
+
super(64, outputLen, 8, false);
|
|
1210
|
+
}
|
|
1211
|
+
get() {
|
|
1212
|
+
const { A, B, C, D, E, F, G, H } = this;
|
|
1213
|
+
return [A, B, C, D, E, F, G, H];
|
|
1214
|
+
}
|
|
1215
|
+
// prettier-ignore
|
|
1216
|
+
set(A, B, C, D, E, F, G, H) {
|
|
1217
|
+
this.A = A | 0;
|
|
1218
|
+
this.B = B | 0;
|
|
1219
|
+
this.C = C | 0;
|
|
1220
|
+
this.D = D | 0;
|
|
1221
|
+
this.E = E | 0;
|
|
1222
|
+
this.F = F | 0;
|
|
1223
|
+
this.G = G | 0;
|
|
1224
|
+
this.H = H | 0;
|
|
1225
|
+
}
|
|
1226
|
+
process(view, offset) {
|
|
1227
|
+
for (let i = 0; i < 16; i++, offset += 4)
|
|
1228
|
+
SHA256_W[i] = view.getUint32(offset, false);
|
|
1229
|
+
for (let i = 16; i < 64; i++) {
|
|
1230
|
+
const W15 = SHA256_W[i - 15];
|
|
1231
|
+
const W2 = SHA256_W[i - 2];
|
|
1232
|
+
const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
|
|
1233
|
+
const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10;
|
|
1234
|
+
SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
|
|
1235
|
+
}
|
|
1236
|
+
let { A, B, C, D, E, F, G, H } = this;
|
|
1237
|
+
for (let i = 0; i < 64; i++) {
|
|
1238
|
+
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
|
1239
|
+
const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
|
|
1240
|
+
const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
|
|
1241
|
+
const T2 = sigma0 + Maj(A, B, C) | 0;
|
|
1242
|
+
H = G;
|
|
1243
|
+
G = F;
|
|
1244
|
+
F = E;
|
|
1245
|
+
E = D + T1 | 0;
|
|
1246
|
+
D = C;
|
|
1247
|
+
C = B;
|
|
1248
|
+
B = A;
|
|
1249
|
+
A = T1 + T2 | 0;
|
|
1250
|
+
}
|
|
1251
|
+
A = A + this.A | 0;
|
|
1252
|
+
B = B + this.B | 0;
|
|
1253
|
+
C = C + this.C | 0;
|
|
1254
|
+
D = D + this.D | 0;
|
|
1255
|
+
E = E + this.E | 0;
|
|
1256
|
+
F = F + this.F | 0;
|
|
1257
|
+
G = G + this.G | 0;
|
|
1258
|
+
H = H + this.H | 0;
|
|
1259
|
+
this.set(A, B, C, D, E, F, G, H);
|
|
1260
|
+
}
|
|
1261
|
+
roundClean() {
|
|
1262
|
+
clean(SHA256_W);
|
|
1263
|
+
}
|
|
1264
|
+
destroy() {
|
|
1265
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
1266
|
+
clean(this.buffer);
|
|
1267
|
+
}
|
|
1268
|
+
};
|
|
1269
|
+
var _SHA256 = class extends SHA2_32B {
|
|
1270
|
+
// We cannot use array here since array allows indexing by variable
|
|
1271
|
+
// which means optimizer/compiler cannot use registers.
|
|
1272
|
+
A = SHA256_IV[0] | 0;
|
|
1273
|
+
B = SHA256_IV[1] | 0;
|
|
1274
|
+
C = SHA256_IV[2] | 0;
|
|
1275
|
+
D = SHA256_IV[3] | 0;
|
|
1276
|
+
E = SHA256_IV[4] | 0;
|
|
1277
|
+
F = SHA256_IV[5] | 0;
|
|
1278
|
+
G = SHA256_IV[6] | 0;
|
|
1279
|
+
H = SHA256_IV[7] | 0;
|
|
1280
|
+
constructor() {
|
|
1281
|
+
super(32);
|
|
1282
|
+
}
|
|
1283
|
+
};
|
|
1284
|
+
var sha256 = /* @__PURE__ */ createHasher(
|
|
1285
|
+
() => new _SHA256(),
|
|
1286
|
+
/* @__PURE__ */ oidNist(1)
|
|
1287
|
+
);
|
|
1288
|
+
var ARKADE_SWAP_PREIMAGE_TAG = "Arkade-RFQ-Preimage-v1";
|
|
1289
|
+
var ARKADE_SALTED_PREIMAGE_TAG = "Arkade-Contract-Preimage-Salted-v1";
|
|
1290
|
+
function buildPreimageMessage(xonly, index) {
|
|
1291
|
+
if (xonly.length !== 32) {
|
|
1292
|
+
throw new Error(`x-only pubkey must be 32 bytes, got ${xonly.length}`);
|
|
1293
|
+
}
|
|
1294
|
+
if (!Number.isInteger(index) || index < 0 || index > 4294967295) {
|
|
1295
|
+
throw new Error(`index must be a u32, got ${index}`);
|
|
1296
|
+
}
|
|
1297
|
+
const tag = new TextEncoder().encode(ARKADE_SWAP_PREIMAGE_TAG);
|
|
1298
|
+
const message = new Uint8Array(tag.length + 32 + 4);
|
|
1299
|
+
message.set(tag, 0);
|
|
1300
|
+
message.set(xonly, tag.length);
|
|
1301
|
+
new DataView(message.buffer).setUint32(tag.length + 32, index, true);
|
|
1302
|
+
return message;
|
|
1303
|
+
}
|
|
1304
|
+
function buildSaltedPreimageMessage(xonly, salt) {
|
|
1305
|
+
if (xonly.length !== 32) {
|
|
1306
|
+
throw new Error(`x-only pubkey must be 32 bytes, got ${xonly.length}`);
|
|
1307
|
+
}
|
|
1308
|
+
if (salt.length !== 32) {
|
|
1309
|
+
throw new Error(`preimage salt must be 32 bytes, got ${salt.length}`);
|
|
1310
|
+
}
|
|
1311
|
+
const tag = new TextEncoder().encode(ARKADE_SALTED_PREIMAGE_TAG);
|
|
1312
|
+
const message = new Uint8Array(tag.length + 32 + 32);
|
|
1313
|
+
message.set(tag, 0);
|
|
1314
|
+
message.set(xonly, tag.length);
|
|
1315
|
+
message.set(salt, tag.length + 32);
|
|
1316
|
+
return message;
|
|
1317
|
+
}
|
|
1318
|
+
var PREIMAGE_INDEX = 0;
|
|
1319
|
+
function isPerArtifactDescriptor(descriptor) {
|
|
1320
|
+
return chunkG53HASDV_cjs.parseHDDescriptor(descriptor) !== null;
|
|
1321
|
+
}
|
|
1322
|
+
async function provisionDescriptor(wallet) {
|
|
1323
|
+
const allocated = isHDAllocationCapable(wallet) ? await wallet.getNextSigningDescriptor() : void 0;
|
|
1324
|
+
return allocated ?? await chunkG53HASDV_cjs.identityDescriptor(wallet.identity);
|
|
1325
|
+
}
|
|
1326
|
+
async function provisionRefundKey(wallet) {
|
|
1327
|
+
const descriptor = await provisionDescriptor(wallet);
|
|
1328
|
+
const signer = await contractSigner(wallet, descriptor);
|
|
1329
|
+
return { descriptor, pubkey: await signer.xOnlyPublicKey() };
|
|
1330
|
+
}
|
|
1331
|
+
async function provisionClaimSecret(wallet, opts = {}) {
|
|
1332
|
+
if (opts.preimage && opts.preimage.length !== 32) {
|
|
1333
|
+
throw new Error(`preimage must be 32 bytes, got ${opts.preimage.length}`);
|
|
1334
|
+
}
|
|
1335
|
+
const { descriptor, pubkey } = await provisionRefundKey(wallet);
|
|
1336
|
+
const claim = async () => {
|
|
1337
|
+
if (opts.preimage) return { preimage: opts.preimage, mustPersistPreimage: true };
|
|
1338
|
+
if (isPerArtifactDescriptor(descriptor)) {
|
|
1339
|
+
return {
|
|
1340
|
+
preimage: await derivePreimage(wallet, descriptor),
|
|
1341
|
+
mustPersistPreimage: false
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1344
|
+
const preimageSalt2 = randomBytes(32);
|
|
1345
|
+
try {
|
|
1346
|
+
return {
|
|
1347
|
+
preimage: await derivePreimage(wallet, descriptor, preimageSalt2),
|
|
1348
|
+
preimageSalt: preimageSalt2,
|
|
1349
|
+
mustPersistPreimage: false
|
|
1350
|
+
};
|
|
1351
|
+
} catch (cause) {
|
|
1352
|
+
if (cause instanceof ForeignDescriptorError || cause instanceof WalletCannotSignError) {
|
|
1353
|
+
throw cause;
|
|
1354
|
+
}
|
|
1355
|
+
return { preimage: randomBytes(32), mustPersistPreimage: true };
|
|
1356
|
+
}
|
|
1357
|
+
};
|
|
1358
|
+
const { preimage, preimageSalt, mustPersistPreimage } = await claim();
|
|
1359
|
+
return {
|
|
1360
|
+
descriptor,
|
|
1361
|
+
pubkey,
|
|
1362
|
+
preimage,
|
|
1363
|
+
paymentHash: sha256(preimage),
|
|
1364
|
+
...preimageSalt ? { preimageSalt } : {},
|
|
1365
|
+
mustPersistPreimage
|
|
1366
|
+
};
|
|
1367
|
+
}
|
|
1368
|
+
async function contractSigner(wallet, descriptor) {
|
|
1369
|
+
const signer = isHDWalletCapable(wallet) ? await wallet.signerForDescriptor(descriptor) : wallet.identity;
|
|
1370
|
+
let expected;
|
|
1371
|
+
try {
|
|
1372
|
+
expected = chunkG53HASDV_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
1373
|
+
} catch (cause) {
|
|
1374
|
+
throw new ForeignDescriptorError(descriptor, { cause });
|
|
1375
|
+
}
|
|
1376
|
+
const actual = await signer.xOnlyPublicKey();
|
|
1377
|
+
if (!utils_js.equalBytes(actual, expected)) throw new ForeignDescriptorError(descriptor);
|
|
1378
|
+
if (!isSigningIdentity(signer)) throw new WalletCannotSignError(descriptor);
|
|
1379
|
+
return signer;
|
|
1380
|
+
}
|
|
1381
|
+
var WalletCannotSignError = class extends Error {
|
|
1382
|
+
constructor(descriptor) {
|
|
1383
|
+
super(`this wallet holds the key for ${descriptor} but cannot sign with it`);
|
|
1384
|
+
this.descriptor = descriptor;
|
|
1385
|
+
}
|
|
1386
|
+
descriptor;
|
|
1387
|
+
name = "WalletCannotSignError";
|
|
1388
|
+
};
|
|
1389
|
+
async function contractPreimage(wallet, descriptor, opts = {}) {
|
|
1390
|
+
if (opts.stored) {
|
|
1391
|
+
if (opts.stored.length !== 32) {
|
|
1392
|
+
throw new Error(`stored preimage must be 32 bytes, got ${opts.stored.length}`);
|
|
1393
|
+
}
|
|
1394
|
+
return opts.stored;
|
|
1395
|
+
}
|
|
1396
|
+
if (isPerArtifactDescriptor(descriptor)) return derivePreimage(wallet, descriptor);
|
|
1397
|
+
if (opts.salt) return derivePreimage(wallet, descriptor, opts.salt);
|
|
1398
|
+
throw new Error(
|
|
1399
|
+
`descriptor ${descriptor} names no single artifact, so its preimage cannot be derived; no salt and no stored preimage were given`
|
|
1400
|
+
);
|
|
1401
|
+
}
|
|
1402
|
+
function isDeterministicSigner(value) {
|
|
1403
|
+
if (typeof value !== "object" || value === null) return false;
|
|
1404
|
+
const v = value;
|
|
1405
|
+
return typeof v.signSchnorrDeterministic === "function" && typeof v.xOnlyPublicKey === "function";
|
|
1406
|
+
}
|
|
1407
|
+
async function derivePreimage(wallet, descriptor, salt) {
|
|
1408
|
+
const signer = await contractSigner(wallet, descriptor);
|
|
1409
|
+
if (!isDeterministicSigner(signer)) {
|
|
1410
|
+
throw new Error(
|
|
1411
|
+
`wallet cannot sign deterministically for ${descriptor}; its preimage is not derivable`
|
|
1412
|
+
);
|
|
1413
|
+
}
|
|
1414
|
+
const xonly = await signer.xOnlyPublicKey();
|
|
1415
|
+
const message = salt ? buildSaltedPreimageMessage(xonly, salt) : buildPreimageMessage(xonly, PREIMAGE_INDEX);
|
|
1416
|
+
try {
|
|
1417
|
+
return sha256(await signer.signSchnorrDeterministic(sha256(message)));
|
|
1418
|
+
} catch (cause) {
|
|
1419
|
+
throw new Error(
|
|
1420
|
+
`wallet cannot sign deterministically for ${descriptor}; its preimage is not derivable`,
|
|
1421
|
+
{ cause }
|
|
1422
|
+
);
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
async function adoptContractDescriptor(wallet, descriptor) {
|
|
1426
|
+
if (!isHDAllocationCapable(wallet)) return;
|
|
1427
|
+
if (!isPerArtifactDescriptor(descriptor)) return;
|
|
1428
|
+
if (isHDWalletCapable(wallet)) {
|
|
1429
|
+
try {
|
|
1430
|
+
await wallet.signerForDescriptor(descriptor);
|
|
1431
|
+
} catch (error) {
|
|
1432
|
+
if (error instanceof ForeignDescriptorError) return;
|
|
1433
|
+
throw error;
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
await wallet.advanceSigningDescriptorWatermark(descriptor);
|
|
1437
|
+
}
|
|
1438
|
+
|
|
917
1439
|
// src/worker/browser/service-worker-manager.ts
|
|
918
1440
|
var registrations = /* @__PURE__ */ new Map();
|
|
919
1441
|
var handshakes = /* @__PURE__ */ new WeakSet();
|
|
@@ -1066,14 +1588,14 @@ var RestDelegateProvider = class {
|
|
|
1066
1588
|
*/
|
|
1067
1589
|
async delegate(intent, forfeitTxs, options) {
|
|
1068
1590
|
const url = `${this.url}/v1/delegate`;
|
|
1069
|
-
const response = await
|
|
1591
|
+
const response = await chunkOH2XLTXE_cjs.baseFetch(url, {
|
|
1070
1592
|
method: "POST",
|
|
1071
1593
|
headers: {
|
|
1072
1594
|
"Content-Type": "application/json"
|
|
1073
1595
|
},
|
|
1074
1596
|
body: JSON.stringify({
|
|
1075
1597
|
intent: {
|
|
1076
|
-
message:
|
|
1598
|
+
message: chunkOH2XLTXE_cjs.Intent.encodeMessage(intent.message),
|
|
1077
1599
|
proof: intent.proof
|
|
1078
1600
|
},
|
|
1079
1601
|
forfeit_txs: forfeitTxs,
|
|
@@ -1093,7 +1615,7 @@ var RestDelegateProvider = class {
|
|
|
1093
1615
|
*/
|
|
1094
1616
|
async getDelegateInfo() {
|
|
1095
1617
|
const url = `${this.url}/v1/delegator/info`;
|
|
1096
|
-
const response = await
|
|
1618
|
+
const response = await chunkOH2XLTXE_cjs.rateGate.runHttp(url, () => chunkOH2XLTXE_cjs.baseFetch(url));
|
|
1097
1619
|
if (!response.ok) {
|
|
1098
1620
|
const errorText2 = await response.text();
|
|
1099
1621
|
throw new Error(`Failed to get delegate info: ${errorText2}`);
|
|
@@ -1120,7 +1642,7 @@ var ESPLORA_URL = {
|
|
|
1120
1642
|
regtest: "http://localhost:3000/api"
|
|
1121
1643
|
};
|
|
1122
1644
|
var EsploraProvider = class {
|
|
1123
|
-
constructor(baseUrl = ESPLORA_URL[
|
|
1645
|
+
constructor(baseUrl = ESPLORA_URL[chunkOH2XLTXE_cjs.DEFAULT_NETWORK_NAME], opts) {
|
|
1124
1646
|
this.baseUrl = baseUrl;
|
|
1125
1647
|
this.pollingInterval = opts?.pollingInterval ?? 15e3;
|
|
1126
1648
|
this.forcePolling = opts?.forcePolling ?? false;
|
|
@@ -1129,14 +1651,14 @@ var EsploraProvider = class {
|
|
|
1129
1651
|
pollingInterval;
|
|
1130
1652
|
forcePolling;
|
|
1131
1653
|
async getCoins(address) {
|
|
1132
|
-
const response = await
|
|
1654
|
+
const response = await chunkOH2XLTXE_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
|
|
1133
1655
|
if (!response.ok) {
|
|
1134
1656
|
throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
|
|
1135
1657
|
}
|
|
1136
1658
|
return response.json();
|
|
1137
1659
|
}
|
|
1138
1660
|
async getFeeRate() {
|
|
1139
|
-
const response = await
|
|
1661
|
+
const response = await chunkOH2XLTXE_cjs.baseFetch(`${this.baseUrl}/fee-estimates`);
|
|
1140
1662
|
if (response.status === 404) {
|
|
1141
1663
|
return void 0;
|
|
1142
1664
|
}
|
|
@@ -1157,7 +1679,7 @@ var EsploraProvider = class {
|
|
|
1157
1679
|
}
|
|
1158
1680
|
}
|
|
1159
1681
|
async getTxOutspends(txid) {
|
|
1160
|
-
const response = await
|
|
1682
|
+
const response = await chunkOH2XLTXE_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
|
|
1161
1683
|
if (!response.ok) {
|
|
1162
1684
|
const error = await response.text();
|
|
1163
1685
|
throw new Error(`Failed to get transaction outspends: ${error}`);
|
|
@@ -1165,7 +1687,7 @@ var EsploraProvider = class {
|
|
|
1165
1687
|
return response.json();
|
|
1166
1688
|
}
|
|
1167
1689
|
async getTransactions(address) {
|
|
1168
|
-
const response = await
|
|
1690
|
+
const response = await chunkOH2XLTXE_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
|
|
1169
1691
|
if (!response.ok) {
|
|
1170
1692
|
const error = await response.text();
|
|
1171
1693
|
throw new Error(`Failed to get transactions: ${error}`);
|
|
@@ -1173,7 +1695,7 @@ var EsploraProvider = class {
|
|
|
1173
1695
|
return response.json();
|
|
1174
1696
|
}
|
|
1175
1697
|
async getTxStatus(txid) {
|
|
1176
|
-
const txresponse = await
|
|
1698
|
+
const txresponse = await chunkOH2XLTXE_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
|
|
1177
1699
|
if (!txresponse.ok) {
|
|
1178
1700
|
throw new Error(txresponse.statusText);
|
|
1179
1701
|
}
|
|
@@ -1181,7 +1703,7 @@ var EsploraProvider = class {
|
|
|
1181
1703
|
if (!tx.status.confirmed) {
|
|
1182
1704
|
return { confirmed: false };
|
|
1183
1705
|
}
|
|
1184
|
-
const response = await
|
|
1706
|
+
const response = await chunkOH2XLTXE_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
|
|
1185
1707
|
if (!response.ok) {
|
|
1186
1708
|
throw new Error(`Failed to get transaction status: ${response.statusText}`);
|
|
1187
1709
|
}
|
|
@@ -1265,7 +1787,7 @@ var EsploraProvider = class {
|
|
|
1265
1787
|
return stopFunc;
|
|
1266
1788
|
}
|
|
1267
1789
|
async getChainTip() {
|
|
1268
|
-
const tipBlocks = await
|
|
1790
|
+
const tipBlocks = await chunkOH2XLTXE_cjs.baseFetch(`${this.baseUrl}/blocks`);
|
|
1269
1791
|
if (!tipBlocks.ok) {
|
|
1270
1792
|
throw new Error(`Failed to get chain tip: ${tipBlocks.statusText}`);
|
|
1271
1793
|
}
|
|
@@ -1284,7 +1806,7 @@ var EsploraProvider = class {
|
|
|
1284
1806
|
};
|
|
1285
1807
|
}
|
|
1286
1808
|
async broadcastPackage(parent, child) {
|
|
1287
|
-
const response = await
|
|
1809
|
+
const response = await chunkOH2XLTXE_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
|
|
1288
1810
|
method: "POST",
|
|
1289
1811
|
headers: {
|
|
1290
1812
|
"Content-Type": "application/json"
|
|
@@ -1298,7 +1820,7 @@ var EsploraProvider = class {
|
|
|
1298
1820
|
return response.json();
|
|
1299
1821
|
}
|
|
1300
1822
|
async broadcastTx(tx) {
|
|
1301
|
-
const response = await
|
|
1823
|
+
const response = await chunkOH2XLTXE_cjs.baseFetch(`${this.baseUrl}/tx`, {
|
|
1302
1824
|
method: "POST",
|
|
1303
1825
|
headers: {
|
|
1304
1826
|
"Content-Type": "text/plain"
|
|
@@ -1460,7 +1982,7 @@ function findP2AOutput(tx) {
|
|
|
1460
1982
|
var CHILD_DUST_AMOUNT = 546;
|
|
1461
1983
|
function buildAnchorChild(params) {
|
|
1462
1984
|
const { parent, feeRate, fundingCoins, changeAddress, tapInternalKey, network } = params;
|
|
1463
|
-
const child = new
|
|
1985
|
+
const child = new chunkOH2XLTXE_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
|
|
1464
1986
|
child.addInput(findP2AOutput(parent));
|
|
1465
1987
|
const estimator = TxWeightEstimator.create().addP2AInput();
|
|
1466
1988
|
for (const _ of fundingCoins) {
|
|
@@ -1508,7 +2030,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
|
|
|
1508
2030
|
);
|
|
1509
2031
|
}
|
|
1510
2032
|
function buildForfeitTxWithOutput(inputs, output, txLocktime) {
|
|
1511
|
-
const tx = new
|
|
2033
|
+
const tx = new chunkOH2XLTXE_cjs.Transaction({
|
|
1512
2034
|
version: 3,
|
|
1513
2035
|
lockTime: txLocktime
|
|
1514
2036
|
});
|
|
@@ -1584,7 +2106,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
|
|
|
1584
2106
|
if (previousScriptKey.length !== 32) {
|
|
1585
2107
|
throw new Error(`parent output ${childIndex} has invalid script`);
|
|
1586
2108
|
}
|
|
1587
|
-
const cosigners =
|
|
2109
|
+
const cosigners = chunkOH2XLTXE_cjs.getArkPsbtFields(child.root, 0, chunkOH2XLTXE_cjs.CosignerPublicKey);
|
|
1588
2110
|
if (cosigners.length === 0) {
|
|
1589
2111
|
throw ErrMissingCosignersPublicKeys;
|
|
1590
2112
|
}
|
|
@@ -1642,7 +2164,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
1642
2164
|
return new _EmulatorPacket(entries);
|
|
1643
2165
|
}
|
|
1644
2166
|
static fromBytes(data) {
|
|
1645
|
-
const reader = new
|
|
2167
|
+
const reader = new chunkI6EDUE75_cjs.BufferReader(data);
|
|
1646
2168
|
const entryCount = reader.readCompactSize();
|
|
1647
2169
|
const entries = [];
|
|
1648
2170
|
for (let i = 0; i < entryCount; i++) {
|
|
@@ -1660,7 +2182,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
1660
2182
|
return _EmulatorPacket.PACKET_TYPE;
|
|
1661
2183
|
}
|
|
1662
2184
|
serialize() {
|
|
1663
|
-
const writer = new
|
|
2185
|
+
const writer = new chunkI6EDUE75_cjs.BufferWriter();
|
|
1664
2186
|
writer.writeCompactSize(this.entries.length);
|
|
1665
2187
|
for (const entry of this.entries) {
|
|
1666
2188
|
writer.writeUint16LE(entry.vin);
|
|
@@ -1747,7 +2269,7 @@ var Extension = class _Extension {
|
|
|
1747
2269
|
`expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
|
|
1748
2270
|
);
|
|
1749
2271
|
}
|
|
1750
|
-
const reader = new
|
|
2272
|
+
const reader = new chunkI6EDUE75_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
|
|
1751
2273
|
const packets = [];
|
|
1752
2274
|
while (reader.remaining() > 0) {
|
|
1753
2275
|
const packetType = reader.readByte();
|
|
@@ -1821,7 +2343,7 @@ var Extension = class _Extension {
|
|
|
1821
2343
|
*/
|
|
1822
2344
|
getAssetPacket() {
|
|
1823
2345
|
for (const p of this.packets) {
|
|
1824
|
-
if (p instanceof
|
|
2346
|
+
if (p instanceof chunkI6EDUE75_cjs.Packet) {
|
|
1825
2347
|
return p;
|
|
1826
2348
|
}
|
|
1827
2349
|
}
|
|
@@ -1859,8 +2381,8 @@ var Extension = class _Extension {
|
|
|
1859
2381
|
};
|
|
1860
2382
|
function parsePacket(packetType, data) {
|
|
1861
2383
|
switch (packetType) {
|
|
1862
|
-
case
|
|
1863
|
-
return
|
|
2384
|
+
case chunkI6EDUE75_cjs.Packet.PACKET_TYPE:
|
|
2385
|
+
return chunkI6EDUE75_cjs.Packet.fromBytes(data);
|
|
1864
2386
|
case EmulatorPacket.PACKET_TYPE:
|
|
1865
2387
|
return EmulatorPacket.fromBytes(data);
|
|
1866
2388
|
default:
|
|
@@ -1907,16 +2429,16 @@ function buildOpReturnScript(data) {
|
|
|
1907
2429
|
}
|
|
1908
2430
|
return script;
|
|
1909
2431
|
}
|
|
1910
|
-
var ErrOffchainOutputNotFound = (address) => new
|
|
1911
|
-
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new
|
|
2432
|
+
var ErrOffchainOutputNotFound = (address) => new chunkOH2XLTXE_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
|
|
2433
|
+
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkOH2XLTXE_cjs.ServerResponseMismatchError(
|
|
1912
2434
|
`invalid asset output amount for ${assetId}: got ${got}, want ${want}`
|
|
1913
2435
|
);
|
|
1914
|
-
var ErrAssetGroupNotFound = (assetId) => new
|
|
1915
|
-
var ErrAssetOutputNotFound = (assetId, outputIndex) => new
|
|
2436
|
+
var ErrAssetGroupNotFound = (assetId) => new chunkOH2XLTXE_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
|
|
2437
|
+
var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkOH2XLTXE_cjs.ServerResponseMismatchError(
|
|
1916
2438
|
`asset output not found in asset group ${assetId} at index ${outputIndex}`
|
|
1917
2439
|
);
|
|
1918
|
-
var ErrOnchainOutputNotFound = (address) => new
|
|
1919
|
-
var ErrUnvalidatedOffchainOutput = (address) => new
|
|
2440
|
+
var ErrOnchainOutputNotFound = (address) => new chunkOH2XLTXE_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
|
|
2441
|
+
var ErrUnvalidatedOffchainOutput = (address) => new chunkOH2XLTXE_cjs.ServerResponseMismatchError(
|
|
1920
2442
|
`offchain output ${address} cannot be validated: virtual output tree signing did not run`
|
|
1921
2443
|
);
|
|
1922
2444
|
var ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
|
|
@@ -1925,7 +2447,7 @@ var ErrInvalidOffchainOutputAmount = (address) => new Error(`invalid offchain ou
|
|
|
1925
2447
|
function assertFinalCommitmentMatchesValidated(finalCommitmentTx, validatedCommitmentTxid, context) {
|
|
1926
2448
|
if (!validatedCommitmentTxid) return;
|
|
1927
2449
|
if (finalCommitmentTx.id === validatedCommitmentTxid) return;
|
|
1928
|
-
throw new
|
|
2450
|
+
throw new chunkOH2XLTXE_cjs.ServerResponseMismatchError(
|
|
1929
2451
|
`${context}: finalization commitment tx ${finalCommitmentTx.id} differs from the validated commitment tx ${validatedCommitmentTxid}`
|
|
1930
2452
|
);
|
|
1931
2453
|
}
|
|
@@ -1935,7 +2457,7 @@ function validateBatchRecipients(commitmentTx, vtxoTreeLeaves, recipients, netwo
|
|
|
1935
2457
|
for (const recipient of recipients) {
|
|
1936
2458
|
let arkAddress;
|
|
1937
2459
|
try {
|
|
1938
|
-
arkAddress =
|
|
2460
|
+
arkAddress = chunkOH2XLTXE_cjs.ArkAddress.decode(recipient.address);
|
|
1939
2461
|
} catch {
|
|
1940
2462
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
1941
2463
|
continue;
|
|
@@ -1947,7 +2469,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
|
|
|
1947
2469
|
const usedOnchainOutputs = /* @__PURE__ */ new Set();
|
|
1948
2470
|
for (const recipient of recipients) {
|
|
1949
2471
|
try {
|
|
1950
|
-
|
|
2472
|
+
chunkOH2XLTXE_cjs.ArkAddress.decode(recipient.address);
|
|
1951
2473
|
} catch {
|
|
1952
2474
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
1953
2475
|
continue;
|
|
@@ -2178,7 +2700,7 @@ function assetMintResolver() {
|
|
|
2178
2700
|
if (!tx.assets?.length || !tx.key.arkTxid) return void 0;
|
|
2179
2701
|
const minted = tx.assets.filter((a) => {
|
|
2180
2702
|
try {
|
|
2181
|
-
return base.hex.encode(
|
|
2703
|
+
return base.hex.encode(chunkI6EDUE75_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
|
|
2182
2704
|
} catch {
|
|
2183
2705
|
return false;
|
|
2184
2706
|
}
|
|
@@ -2221,7 +2743,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2221
2743
|
const existing = inputsByAssetId.get(asset.assetId);
|
|
2222
2744
|
inputsByAssetId.set(asset.assetId, [
|
|
2223
2745
|
...existing ?? [],
|
|
2224
|
-
|
|
2746
|
+
chunkI6EDUE75_cjs.AssetInput.create(inputIndex, asset.amount)
|
|
2225
2747
|
]);
|
|
2226
2748
|
}
|
|
2227
2749
|
}
|
|
@@ -2233,7 +2755,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2233
2755
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
2234
2756
|
outputsByAssetId.set(asset.assetId, [
|
|
2235
2757
|
...existing ?? [],
|
|
2236
|
-
|
|
2758
|
+
chunkI6EDUE75_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
2237
2759
|
]);
|
|
2238
2760
|
}
|
|
2239
2761
|
}
|
|
@@ -2244,7 +2766,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2244
2766
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
2245
2767
|
outputsByAssetId.set(asset.assetId, [
|
|
2246
2768
|
...existing ?? [],
|
|
2247
|
-
|
|
2769
|
+
chunkI6EDUE75_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
2248
2770
|
]);
|
|
2249
2771
|
}
|
|
2250
2772
|
}
|
|
@@ -2253,11 +2775,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2253
2775
|
for (const assetIdStr of allAssetIds) {
|
|
2254
2776
|
const inputs = inputsByAssetId.get(assetIdStr);
|
|
2255
2777
|
const outputs = outputsByAssetId.get(assetIdStr);
|
|
2256
|
-
const assetId =
|
|
2257
|
-
const group =
|
|
2778
|
+
const assetId = chunkI6EDUE75_cjs.AssetId.fromString(assetIdStr);
|
|
2779
|
+
const group = chunkI6EDUE75_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
|
|
2258
2780
|
groups.push(group);
|
|
2259
2781
|
}
|
|
2260
|
-
return
|
|
2782
|
+
return chunkI6EDUE75_cjs.Packet.create(groups);
|
|
2261
2783
|
}
|
|
2262
2784
|
function selectCoinsWithAsset(coins, assetId, requiredAmount) {
|
|
2263
2785
|
const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
|
|
@@ -2342,13 +2864,13 @@ var toTimelock = (value) => ({
|
|
|
2342
2864
|
var toSeconds = (t) => t.type === "seconds" ? t.value : t.value * NOMINAL_BLOCK_SECONDS;
|
|
2343
2865
|
function assertTimelockInPolicy(timelock, policy, label, overrideOption) {
|
|
2344
2866
|
if (policy.requireSeconds && timelock.type === "blocks") {
|
|
2345
|
-
throw new
|
|
2867
|
+
throw new chunkOH2XLTXE_cjs.ServerResponseMismatchError(
|
|
2346
2868
|
`${label} rejected: block-typed timelocks are not accepted (got ${timelock.value})`
|
|
2347
2869
|
);
|
|
2348
2870
|
}
|
|
2349
2871
|
const seconds = toSeconds(timelock);
|
|
2350
2872
|
if (seconds < policy.minSeconds) {
|
|
2351
|
-
throw new
|
|
2873
|
+
throw new chunkOH2XLTXE_cjs.ServerResponseMismatchError(
|
|
2352
2874
|
`${label} rejected: ${timelock.value} ${timelock.type} is below the ${policy.minSeconds}s floor; pass ${overrideOption}: ${seconds}n to Wallet.create to lower it`
|
|
2353
2875
|
);
|
|
2354
2876
|
}
|
|
@@ -2369,7 +2891,7 @@ function resolveBatchExpiryPolicy(network, overrides) {
|
|
|
2369
2891
|
}
|
|
2370
2892
|
function assertValidBatchExpiry(batchExpiry, policy) {
|
|
2371
2893
|
if (policy.advertisedVtxoTreeExpiry !== void 0 && batchExpiry !== policy.advertisedVtxoTreeExpiry) {
|
|
2372
|
-
throw new
|
|
2894
|
+
throw new chunkOH2XLTXE_cjs.ServerResponseMismatchError(
|
|
2373
2895
|
`batch expiry rejected: ${batchExpiry} does not match the advertised vtxoTreeExpiry ${policy.advertisedVtxoTreeExpiry}`
|
|
2374
2896
|
);
|
|
2375
2897
|
}
|
|
@@ -2399,21 +2921,21 @@ function resolveCheckpointExitDelayPolicy(network, overrides) {
|
|
|
2399
2921
|
function assertValidServerUnrollScript(checkpointTapscript, policy) {
|
|
2400
2922
|
let script;
|
|
2401
2923
|
try {
|
|
2402
|
-
script =
|
|
2924
|
+
script = chunkOH2XLTXE_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
|
|
2403
2925
|
} catch (e) {
|
|
2404
|
-
throw new
|
|
2926
|
+
throw new chunkOH2XLTXE_cjs.ServerResponseMismatchError(
|
|
2405
2927
|
`checkpoint exit delay rejected: invalid checkpointTapscript from server (${e instanceof Error ? e.message : String(e)})`
|
|
2406
2928
|
);
|
|
2407
2929
|
}
|
|
2408
2930
|
if (policy.advertisedForfeitPubkey !== void 0) {
|
|
2409
2931
|
const { pubkeys } = script.params;
|
|
2410
2932
|
if (pubkeys.length !== 1) {
|
|
2411
|
-
throw new
|
|
2933
|
+
throw new chunkOH2XLTXE_cjs.ServerResponseMismatchError(
|
|
2412
2934
|
`checkpoint exit delay rejected: checkpointTapscript must commit to exactly one pubkey, got ${pubkeys.length} [${pubkeys.map(base.hex.encode).join(", ")}]`
|
|
2413
2935
|
);
|
|
2414
2936
|
}
|
|
2415
2937
|
if (!utils_js.equalBytes(pubkeys[0], policy.advertisedForfeitPubkey)) {
|
|
2416
|
-
throw new
|
|
2938
|
+
throw new chunkOH2XLTXE_cjs.ServerResponseMismatchError(
|
|
2417
2939
|
`checkpoint exit delay rejected: checkpointTapscript pubkey ${base.hex.encode(pubkeys[0])} does not match the advertised forfeitPubkey ${base.hex.encode(policy.advertisedForfeitPubkey)}`
|
|
2418
2940
|
);
|
|
2419
2941
|
}
|
|
@@ -2457,8 +2979,8 @@ function buildOffchainTx(inputs, outputs, serverUnrollScript) {
|
|
|
2457
2979
|
function buildVirtualTx(inputs, outputs) {
|
|
2458
2980
|
let lockTime = 0n;
|
|
2459
2981
|
for (const input of inputs) {
|
|
2460
|
-
const tapscript =
|
|
2461
|
-
if (
|
|
2982
|
+
const tapscript = chunkOH2XLTXE_cjs.decodeTapscript(chunkOH2XLTXE_cjs.scriptFromTapLeafScript(input.tapLeafScript));
|
|
2983
|
+
if (chunkOH2XLTXE_cjs.CLTVMultisigTapscript.is(tapscript)) {
|
|
2462
2984
|
if (lockTime !== 0n) {
|
|
2463
2985
|
if (isSeconds(lockTime) !== isSeconds(tapscript.params.absoluteTimelock)) {
|
|
2464
2986
|
throw new Error("cannot mix seconds and blocks locktime");
|
|
@@ -2469,7 +2991,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
2469
2991
|
}
|
|
2470
2992
|
}
|
|
2471
2993
|
}
|
|
2472
|
-
const tx = new
|
|
2994
|
+
const tx = new chunkOH2XLTXE_cjs.Transaction({
|
|
2473
2995
|
version: 3,
|
|
2474
2996
|
lockTime: Number(lockTime)
|
|
2475
2997
|
});
|
|
@@ -2479,12 +3001,12 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
2479
3001
|
index: input.vout,
|
|
2480
3002
|
sequence: lockTime ? btcSigner.DEFAULT_SEQUENCE - 1 : void 0,
|
|
2481
3003
|
witnessUtxo: {
|
|
2482
|
-
script:
|
|
3004
|
+
script: chunkOH2XLTXE_cjs.VtxoScript.decode(input.tapTree).pkScript,
|
|
2483
3005
|
amount: BigInt(input.value)
|
|
2484
3006
|
},
|
|
2485
3007
|
tapLeafScript: [input.tapLeafScript]
|
|
2486
3008
|
});
|
|
2487
|
-
|
|
3009
|
+
chunkOH2XLTXE_cjs.setArkPsbtField(tx, i, chunkOH2XLTXE_cjs.VtxoTaprootTree, input.tapTree);
|
|
2488
3010
|
}
|
|
2489
3011
|
for (const output of outputs) {
|
|
2490
3012
|
tx.addOutput(output);
|
|
@@ -2493,8 +3015,8 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
2493
3015
|
return tx;
|
|
2494
3016
|
}
|
|
2495
3017
|
function buildCheckpointTx(vtxo, serverUnrollScript) {
|
|
2496
|
-
const collaborativeClosure =
|
|
2497
|
-
const checkpointVtxoScript = new
|
|
3018
|
+
const collaborativeClosure = chunkOH2XLTXE_cjs.decodeTapscript(chunkOH2XLTXE_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
|
|
3019
|
+
const checkpointVtxoScript = new chunkOH2XLTXE_cjs.VtxoScript([
|
|
2498
3020
|
serverUnrollScript.script,
|
|
2499
3021
|
collaborativeClosure.script
|
|
2500
3022
|
]);
|
|
@@ -2647,7 +3169,7 @@ function combineTapscriptSigs(signedTx, originalTx) {
|
|
|
2647
3169
|
}
|
|
2648
3170
|
function isValidArkAddress(address) {
|
|
2649
3171
|
try {
|
|
2650
|
-
|
|
3172
|
+
chunkOH2XLTXE_cjs.ArkAddress.decode(address);
|
|
2651
3173
|
return true;
|
|
2652
3174
|
} catch (e) {
|
|
2653
3175
|
return false;
|
|
@@ -2655,16 +3177,16 @@ function isValidArkAddress(address) {
|
|
|
2655
3177
|
}
|
|
2656
3178
|
function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, context) {
|
|
2657
3179
|
if (serverCheckpointTxs.length !== expectedCheckpoints.length) {
|
|
2658
|
-
throw new
|
|
3180
|
+
throw new chunkOH2XLTXE_cjs.ServerResponseMismatchError(
|
|
2659
3181
|
`${context} returned ${serverCheckpointTxs.length} checkpoints, expected ${expectedCheckpoints.length}`
|
|
2660
3182
|
);
|
|
2661
3183
|
}
|
|
2662
3184
|
const byTxid = new Map(expectedCheckpoints.map((c) => [c.id, c]));
|
|
2663
3185
|
return serverCheckpointTxs.map((encoded, index) => {
|
|
2664
|
-
const server =
|
|
3186
|
+
const server = chunkOH2XLTXE_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
|
|
2665
3187
|
const local = byTxid.get(server.id);
|
|
2666
3188
|
if (!local) {
|
|
2667
|
-
throw new
|
|
3189
|
+
throw new chunkOH2XLTXE_cjs.ServerResponseMismatchError(
|
|
2668
3190
|
`${context} checkpoint ${index} txid ${server.id} does not match any submitted checkpoint`
|
|
2669
3191
|
);
|
|
2670
3192
|
}
|
|
@@ -2674,14 +3196,14 @@ function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, contex
|
|
|
2674
3196
|
}
|
|
2675
3197
|
function assertSubmittedArkTxid(response, signedArkTx, context) {
|
|
2676
3198
|
if (response.arkTxid !== signedArkTx.id) {
|
|
2677
|
-
throw new
|
|
3199
|
+
throw new chunkOH2XLTXE_cjs.ServerResponseMismatchError(
|
|
2678
3200
|
`${context} returned ark txid ${response.arkTxid}, expected ${signedArkTx.id}`
|
|
2679
3201
|
);
|
|
2680
3202
|
}
|
|
2681
3203
|
if (response.finalArkTx === void 0) return;
|
|
2682
|
-
const finalTxid =
|
|
3204
|
+
const finalTxid = chunkOH2XLTXE_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
|
|
2683
3205
|
if (finalTxid !== signedArkTx.id) {
|
|
2684
|
-
throw new
|
|
3206
|
+
throw new chunkOH2XLTXE_cjs.ServerResponseMismatchError(
|
|
2685
3207
|
`${context} returned final ark tx ${finalTxid}, expected ${signedArkTx.id}`
|
|
2686
3208
|
);
|
|
2687
3209
|
}
|
|
@@ -2700,10 +3222,10 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeyHex,
|
|
|
2700
3222
|
[serverPubkeyHex],
|
|
2701
3223
|
void 0,
|
|
2702
3224
|
void 0,
|
|
2703
|
-
payment_js.tapLeafHash(
|
|
3225
|
+
payment_js.tapLeafHash(chunkOH2XLTXE_cjs.scriptFromTapLeafScript(leaf))
|
|
2704
3226
|
);
|
|
2705
3227
|
} catch (error) {
|
|
2706
|
-
throw new
|
|
3228
|
+
throw new chunkOH2XLTXE_cjs.ServerResponseMismatchError(
|
|
2707
3229
|
`${context}: input ${inputIndex} is not signed by the server on the leaf being spent (${error instanceof Error ? error.message : String(error)})`
|
|
2708
3230
|
);
|
|
2709
3231
|
}
|
|
@@ -2712,20 +3234,20 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
2712
3234
|
const byOutpoint = new Map(inputs.map((input) => [`${input.txid}:${input.vout}`, input]));
|
|
2713
3235
|
for (const [index, checkpoint] of checkpoints.entries()) {
|
|
2714
3236
|
if (checkpoint.inputsLength !== 1) {
|
|
2715
|
-
throw new
|
|
3237
|
+
throw new chunkOH2XLTXE_cjs.ServerResponseMismatchError(
|
|
2716
3238
|
`${context}: checkpoint ${index} spends ${checkpoint.inputsLength} inputs, expected 1`
|
|
2717
3239
|
);
|
|
2718
3240
|
}
|
|
2719
3241
|
const spent = checkpoint.getInput(0);
|
|
2720
3242
|
if (!spent.txid || spent.index === void 0) {
|
|
2721
|
-
throw new
|
|
3243
|
+
throw new chunkOH2XLTXE_cjs.ServerResponseMismatchError(
|
|
2722
3244
|
`${context}: checkpoint ${index} has no input outpoint`
|
|
2723
3245
|
);
|
|
2724
3246
|
}
|
|
2725
3247
|
const outpoint = `${base.hex.encode(spent.txid)}:${spent.index}`;
|
|
2726
3248
|
const input = byOutpoint.get(outpoint);
|
|
2727
3249
|
if (!input) {
|
|
2728
|
-
throw new
|
|
3250
|
+
throw new chunkOH2XLTXE_cjs.ServerResponseMismatchError(
|
|
2729
3251
|
`${context}: checkpoint ${index} spends ${outpoint}, which is not one of the requested virtual outputs`
|
|
2730
3252
|
);
|
|
2731
3253
|
}
|
|
@@ -2733,7 +3255,7 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
2733
3255
|
(unroll) => buildCheckpointTx(input, unroll).tx.id === checkpoint.id
|
|
2734
3256
|
);
|
|
2735
3257
|
if (!rebuilt) {
|
|
2736
|
-
throw new
|
|
3258
|
+
throw new chunkOH2XLTXE_cjs.ServerResponseMismatchError(
|
|
2737
3259
|
`${context}: checkpoint ${index} txid ${checkpoint.id} differs from the checkpoint built locally for ${outpoint}`
|
|
2738
3260
|
);
|
|
2739
3261
|
}
|
|
@@ -2760,11 +3282,11 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
2760
3282
|
const verify = options?.verifyServerSignatures;
|
|
2761
3283
|
if (verify) {
|
|
2762
3284
|
if (response.finalArkTx === void 0) {
|
|
2763
|
-
throw new
|
|
3285
|
+
throw new chunkOH2XLTXE_cjs.ServerResponseMismatchError(
|
|
2764
3286
|
"submitTx: server returned no final ark tx to verify its signatures against"
|
|
2765
3287
|
);
|
|
2766
3288
|
}
|
|
2767
|
-
const finalArkTx =
|
|
3289
|
+
const finalArkTx = chunkOH2XLTXE_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
|
|
2768
3290
|
const serverPubkeyHex = base.hex.encode(
|
|
2769
3291
|
verify.serverPubkey.length === 33 ? verify.serverPubkey.subarray(1) : verify.serverPubkey
|
|
2770
3292
|
);
|
|
@@ -2823,12 +3345,12 @@ function claimWithPreimageIdentity(identity, preimage) {
|
|
|
2823
3345
|
return {
|
|
2824
3346
|
...identity,
|
|
2825
3347
|
sign: async (tx, inputIndexes) => {
|
|
2826
|
-
const signed =
|
|
3348
|
+
const signed = chunkOH2XLTXE_cjs.Transaction.fromPSBT(
|
|
2827
3349
|
(await identity.sign(tx.clone(), inputIndexes)).toPSBT()
|
|
2828
3350
|
);
|
|
2829
3351
|
const indexes = inputIndexes ?? Array.from({ length: signed.inputsLength }, (_, i) => i);
|
|
2830
3352
|
for (const index of indexes) {
|
|
2831
|
-
|
|
3353
|
+
chunkOH2XLTXE_cjs.setArkPsbtField(signed, index, chunkOH2XLTXE_cjs.ConditionWitness, [preimage]);
|
|
2832
3354
|
}
|
|
2833
3355
|
return signed;
|
|
2834
3356
|
}
|
|
@@ -3020,7 +3542,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
|
|
|
3020
3542
|
};
|
|
3021
3543
|
}
|
|
3022
3544
|
function deriveContractTapscripts(contract) {
|
|
3023
|
-
const handler =
|
|
3545
|
+
const handler = chunkG53HASDV_cjs.contractHandlers.get(contract.type);
|
|
3024
3546
|
if (!handler) {
|
|
3025
3547
|
throw new Error(`No handler for contract type '${contract.type}'`);
|
|
3026
3548
|
}
|
|
@@ -3091,7 +3613,7 @@ function getRandomId() {
|
|
|
3091
3613
|
}
|
|
3092
3614
|
function isValidArkAddress2(address) {
|
|
3093
3615
|
try {
|
|
3094
|
-
|
|
3616
|
+
chunkOH2XLTXE_cjs.ArkAddress.decode(address);
|
|
3095
3617
|
return true;
|
|
3096
3618
|
} catch (e) {
|
|
3097
3619
|
return false;
|
|
@@ -3116,12 +3638,27 @@ function assertRecipientArkAddress(encoded, address, context) {
|
|
|
3116
3638
|
);
|
|
3117
3639
|
}
|
|
3118
3640
|
}
|
|
3641
|
+
function assertTapTreeDerivesAddress(encoded, tapTree, address) {
|
|
3642
|
+
let derived;
|
|
3643
|
+
try {
|
|
3644
|
+
derived = chunkOH2XLTXE_cjs.VtxoScript.decode(tapTree).pkScript;
|
|
3645
|
+
} catch (e) {
|
|
3646
|
+
throw new Error(
|
|
3647
|
+
`Invalid tapTree for ${encoded}: ${e instanceof Error ? e.message : String(e)}`
|
|
3648
|
+
);
|
|
3649
|
+
}
|
|
3650
|
+
if (base.hex.encode(derived) !== base.hex.encode(address.pkScript)) {
|
|
3651
|
+
throw new Error(
|
|
3652
|
+
`Invalid tapTree for ${encoded}: derives ${base.hex.encode(derived)}, address is ${base.hex.encode(address.pkScript)}. Expected VtxoScript.encode() form: leaf depths are ignored and the tree is rebuilt in arkd's canonical shape.`
|
|
3653
|
+
);
|
|
3654
|
+
}
|
|
3655
|
+
}
|
|
3119
3656
|
function validateRecipients(recipients, dustAmount, context) {
|
|
3120
3657
|
const validatedRecipients = [];
|
|
3121
3658
|
for (const recipient of recipients) {
|
|
3122
3659
|
let address;
|
|
3123
3660
|
try {
|
|
3124
|
-
address =
|
|
3661
|
+
address = chunkOH2XLTXE_cjs.ArkAddress.decode(recipient.address);
|
|
3125
3662
|
} catch (e) {
|
|
3126
3663
|
throw new Error(`Invalid Arkade address: ${recipient.address}`);
|
|
3127
3664
|
}
|
|
@@ -3130,16 +3667,58 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
3130
3667
|
if (amount <= 0) {
|
|
3131
3668
|
throw new Error("Amount must be positive");
|
|
3132
3669
|
}
|
|
3670
|
+
if (recipient.tapTree) {
|
|
3671
|
+
assertTapTreeDerivesAddress(recipient.address, recipient.tapTree, address);
|
|
3672
|
+
}
|
|
3133
3673
|
validatedRecipients.push({
|
|
3134
3674
|
address: recipient.address,
|
|
3135
3675
|
assets: recipient.assets ?? [],
|
|
3136
3676
|
amount,
|
|
3137
|
-
script: amount < dustAmount ? address.subdustPkScript : address.pkScript
|
|
3677
|
+
script: amount < dustAmount ? address.subdustPkScript : address.pkScript,
|
|
3678
|
+
tapTree: recipient.tapTree
|
|
3138
3679
|
});
|
|
3139
3680
|
}
|
|
3140
3681
|
return validatedRecipients;
|
|
3141
3682
|
}
|
|
3142
3683
|
|
|
3684
|
+
// src/contracts/spendability.ts
|
|
3685
|
+
function isContractGenericallySpendable(contract) {
|
|
3686
|
+
return chunkG53HASDV_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
|
|
3687
|
+
}
|
|
3688
|
+
function gatedContracts(contracts) {
|
|
3689
|
+
const gated = /* @__PURE__ */ new Map();
|
|
3690
|
+
for (const contract of contracts) {
|
|
3691
|
+
if (!isContractGenericallySpendable(contract)) gated.set(contract.script, contract.type);
|
|
3692
|
+
}
|
|
3693
|
+
return gated;
|
|
3694
|
+
}
|
|
3695
|
+
function gateExclusion(gated) {
|
|
3696
|
+
return (vtxo) => {
|
|
3697
|
+
const type = vtxo.script === void 0 ? void 0 : gated.get(vtxo.script);
|
|
3698
|
+
if (type === void 0) return void 0;
|
|
3699
|
+
return `at ${vtxo.script} (contract type '${type}') is not generically spendable`;
|
|
3700
|
+
};
|
|
3701
|
+
}
|
|
3702
|
+
function outpointExclusion(outpoints, reason) {
|
|
3703
|
+
return (vtxo) => outpoints.has(`${vtxo.txid}:${vtxo.vout}`) ? reason : void 0;
|
|
3704
|
+
}
|
|
3705
|
+
function outpointReasons(reasons) {
|
|
3706
|
+
return (vtxo) => reasons.get(`${vtxo.txid}:${vtxo.vout}`);
|
|
3707
|
+
}
|
|
3708
|
+
function logExcludedVtxos(source, vtxos, exclusions) {
|
|
3709
|
+
if (exclusions.length === 0) return;
|
|
3710
|
+
for (const vtxo of vtxos) {
|
|
3711
|
+
for (const exclusion of exclusions) {
|
|
3712
|
+
const reason = exclusion(vtxo);
|
|
3713
|
+
if (reason === void 0) continue;
|
|
3714
|
+
console.debug(`[spendability] ${source}: ${vtxo.txid}:${vtxo.vout} ${reason}`);
|
|
3715
|
+
}
|
|
3716
|
+
}
|
|
3717
|
+
}
|
|
3718
|
+
var UnannotatableInputError = class extends Error {
|
|
3719
|
+
name = "UnannotatableInputError";
|
|
3720
|
+
};
|
|
3721
|
+
|
|
3143
3722
|
// src/wallet/vtxo-manager.ts
|
|
3144
3723
|
function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSeconds = Math.floor(Date.now() / 1e3)) {
|
|
3145
3724
|
const out = /* @__PURE__ */ new Set();
|
|
@@ -3150,7 +3729,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
|
|
|
3150
3729
|
continue;
|
|
3151
3730
|
}
|
|
3152
3731
|
for (const v of vtxos) {
|
|
3153
|
-
if (!
|
|
3732
|
+
if (!chunkOH2XLTXE_cjs.hasTerminalSpend(v) && !v.isSwept) out.add(`${v.txid}:${v.vout}`);
|
|
3154
3733
|
}
|
|
3155
3734
|
}
|
|
3156
3735
|
return out;
|
|
@@ -3183,10 +3762,10 @@ function byValueDescending(vtxos) {
|
|
|
3183
3762
|
return [...vtxos].sort((a, b) => b.value - a.value);
|
|
3184
3763
|
}
|
|
3185
3764
|
async function fetchTimeHeight(wallet) {
|
|
3186
|
-
return
|
|
3765
|
+
return chunkOH2XLTXE_cjs.resolveTimeHeight(wallet.onchainProvider);
|
|
3187
3766
|
}
|
|
3188
3767
|
function canMigrateBySend(vtxo, now) {
|
|
3189
|
-
if (!
|
|
3768
|
+
if (!chunkOH2XLTXE_cjs.canSpendOffchain(vtxo, now)) return false;
|
|
3190
3769
|
return vtxo.expiresAt !== void 0 || vtxo.expiresAtHeight !== void 0;
|
|
3191
3770
|
}
|
|
3192
3771
|
function byExpiryAscending(vtxos, now) {
|
|
@@ -3194,7 +3773,7 @@ function byExpiryAscending(vtxos, now) {
|
|
|
3194
3773
|
if (vtxo.isSwept) return -Infinity;
|
|
3195
3774
|
if (vtxo.expiresAt !== void 0) return vtxo.expiresAt.getTime();
|
|
3196
3775
|
if (vtxo.expiresAtHeight !== void 0) {
|
|
3197
|
-
return
|
|
3776
|
+
return chunkOH2XLTXE_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
|
|
3198
3777
|
}
|
|
3199
3778
|
return Infinity;
|
|
3200
3779
|
};
|
|
@@ -3221,7 +3800,7 @@ function priceSettlementInputs(vtxos, estimator) {
|
|
|
3221
3800
|
const payable = [];
|
|
3222
3801
|
const net = /* @__PURE__ */ new Map();
|
|
3223
3802
|
for (const vtxo of vtxos) {
|
|
3224
|
-
const inputFee = estimator.evalOffchainInput(
|
|
3803
|
+
const inputFee = estimator.evalOffchainInput(chunkOH2XLTXE_cjs.toOffchainInputFeeParams(vtxo));
|
|
3225
3804
|
if (inputFee.satoshis >= vtxo.value) {
|
|
3226
3805
|
continue;
|
|
3227
3806
|
}
|
|
@@ -3247,7 +3826,7 @@ function deductOffchainOutputFee(subtotal, estimator, arkAddress) {
|
|
|
3247
3826
|
}
|
|
3248
3827
|
const outputFee = estimator.evalOffchainOutput({
|
|
3249
3828
|
amount: subtotal,
|
|
3250
|
-
script: base.hex.encode(
|
|
3829
|
+
script: base.hex.encode(chunkOH2XLTXE_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
3251
3830
|
});
|
|
3252
3831
|
return subtotal - BigInt(outputFee.satoshis);
|
|
3253
3832
|
}
|
|
@@ -3265,10 +3844,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
|
|
|
3265
3844
|
};
|
|
3266
3845
|
function getRecoverableVtxos(vtxos, dustAmount, now) {
|
|
3267
3846
|
return vtxos.filter((vtxo) => {
|
|
3268
|
-
if (
|
|
3847
|
+
if (chunkOH2XLTXE_cjs.canRecoverOnchain(vtxo, now)) {
|
|
3269
3848
|
return true;
|
|
3270
3849
|
}
|
|
3271
|
-
if (
|
|
3850
|
+
if (chunkOH2XLTXE_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
|
|
3272
3851
|
return true;
|
|
3273
3852
|
}
|
|
3274
3853
|
return false;
|
|
@@ -3299,7 +3878,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
|
|
|
3299
3878
|
}
|
|
3300
3879
|
function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
3301
3880
|
const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
|
|
3302
|
-
const expiresAt =
|
|
3881
|
+
const expiresAt = chunkOH2XLTXE_cjs.normalizeVtxo(vtxo).expiresAt;
|
|
3303
3882
|
if (expiresAt === void 0) return false;
|
|
3304
3883
|
const now = Date.now();
|
|
3305
3884
|
const batchExpiry = expiresAt.getTime();
|
|
@@ -3308,7 +3887,7 @@ function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
|
3308
3887
|
}
|
|
3309
3888
|
function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
|
|
3310
3889
|
return vtxos.filter(
|
|
3311
|
-
(vtxo) => isVtxoExpiringSoon(vtxo, thresholdMs) ||
|
|
3890
|
+
(vtxo) => isVtxoExpiringSoon(vtxo, thresholdMs) || chunkOH2XLTXE_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount)
|
|
3312
3891
|
);
|
|
3313
3892
|
}
|
|
3314
3893
|
function isMigrationCapable(wallet) {
|
|
@@ -3422,6 +4001,27 @@ var VtxoManager = class _VtxoManager {
|
|
|
3422
4001
|
static MIGRATION_COOLDOWN_MS = 3e4;
|
|
3423
4002
|
static MIGRATION_MAX_BACKOFF_MS = 5 * 60 * 1e3;
|
|
3424
4003
|
// ========== Recovery Methods ==========
|
|
4004
|
+
/**
|
|
4005
|
+
* Outpoints recovery must not name yet, with the reason each was refused.
|
|
4006
|
+
* Empty when the manager offers no opinion — an embedder's may not implement
|
|
4007
|
+
* the predicate, and every contract type but VHTLC never answers.
|
|
4008
|
+
*
|
|
4009
|
+
* Reaches only a lockup whose `sender` is this wallet's own key: role
|
|
4010
|
+
* resolution matches that key against the contract's params, so a
|
|
4011
|
+
* descriptor-derived sender (every RFQ lockup) is not matched and such a row
|
|
4012
|
+
* still fails its batch at submit.
|
|
4013
|
+
*
|
|
4014
|
+
* The key stays a thunk so an ordinary recovery never touches the identity,
|
|
4015
|
+
* and the full coins are passed rather than bare outpoints because only they
|
|
4016
|
+
* carry the confirmation a relative timelock is measured from.
|
|
4017
|
+
*/
|
|
4018
|
+
async unspendableNow(vtxos) {
|
|
4019
|
+
const contractManager = await this.wallet.getContractManager();
|
|
4020
|
+
return await contractManager.unspendableNowReasons?.(
|
|
4021
|
+
vtxos,
|
|
4022
|
+
async () => base.hex.encode(await this.wallet.identity.xOnlyPublicKey())
|
|
4023
|
+
) ?? /* @__PURE__ */ new Map();
|
|
4024
|
+
}
|
|
3425
4025
|
/**
|
|
3426
4026
|
* Recover swept/expired virtual outputs by settling them back to the wallet's Arkade address.
|
|
3427
4027
|
*
|
|
@@ -3434,6 +4034,11 @@ var VtxoManager = class _VtxoManager {
|
|
|
3434
4034
|
* Note: Settled virtual outputs with long expiry are NOT recovered to avoid locking liquidity unnecessarily.
|
|
3435
4035
|
* Only preconfirmed subdust is recovered to consolidate small amounts.
|
|
3436
4036
|
*
|
|
4037
|
+
* Inputs whose contract refuses a spend right now — an immature VHTLC refund
|
|
4038
|
+
* path — are skipped rather than failing the batch that holds them, and
|
|
4039
|
+
* {@link getRecoverableBalance} skips the same set. See
|
|
4040
|
+
* {@link unspendableNow} for which rows that reaches.
|
|
4041
|
+
*
|
|
3437
4042
|
* @param eventCallback - Optional callback to receive settlement events
|
|
3438
4043
|
* @returns Settlement transaction ID
|
|
3439
4044
|
* @throws Error if no recoverable virtual outputs found
|
|
@@ -3462,6 +4067,26 @@ var VtxoManager = class _VtxoManager {
|
|
|
3462
4067
|
if (vtxosToRecover.length === 0) {
|
|
3463
4068
|
throw new Error("No recoverable VTXOs found");
|
|
3464
4069
|
}
|
|
4070
|
+
const refused = await this.unspendableNow(vtxosToRecover);
|
|
4071
|
+
if (refused.size > 0) {
|
|
4072
|
+
logExcludedVtxos("recoverVtxos", vtxosToRecover, [outpointReasons(refused)]);
|
|
4073
|
+
const held = vtxosToRecover.length;
|
|
4074
|
+
vtxosToRecover = vtxosToRecover.filter(
|
|
4075
|
+
(vtxo) => !refused.has(`${vtxo.txid}:${vtxo.vout}`)
|
|
4076
|
+
);
|
|
4077
|
+
if (vtxosToRecover.length === 0) {
|
|
4078
|
+
const why = refused.size === 1 ? [...refused.values()][0] : [...refused].map(([outpoint, reason]) => `${outpoint}: ${reason}`).join("; ");
|
|
4079
|
+
throw new Error(
|
|
4080
|
+
`All ${held} recoverable VTXO(s) are held by a contract that refuses a spend right now: ${why}`
|
|
4081
|
+
);
|
|
4082
|
+
}
|
|
4083
|
+
({ vtxosToRecover } = getRecoverableWithSubdust(vtxosToRecover, dustAmount, now));
|
|
4084
|
+
if (vtxosToRecover.length === 0) {
|
|
4085
|
+
throw new Error(
|
|
4086
|
+
`Excluding ${refused.size} VTXO(s) not yet spendable, the remaining recoverable amount is below the dust threshold ${dustAmount}`
|
|
4087
|
+
);
|
|
4088
|
+
}
|
|
4089
|
+
}
|
|
3465
4090
|
const info = await this.getInfoProvider()?.getInfo();
|
|
3466
4091
|
const vtxoMaxAmount = info?.vtxoMaxAmount ?? -1n;
|
|
3467
4092
|
const estimator = new Estimator(info?.fees.intentFee ?? {});
|
|
@@ -3525,6 +4150,11 @@ var VtxoManager = class _VtxoManager {
|
|
|
3525
4150
|
* The batch size caps are not applied here: they defer the overflow to the
|
|
3526
4151
|
* next cycle rather than reducing what is recoverable.
|
|
3527
4152
|
*
|
|
4153
|
+
* Inputs a contract refuses right now are excluded, so this and
|
|
4154
|
+
* {@link recoverVtxos} answer over the same set. `Balance.recoverable` still
|
|
4155
|
+
* counts them: that field reports what the wallet owns, this one what a
|
|
4156
|
+
* batch would hand back today.
|
|
4157
|
+
*
|
|
3528
4158
|
* @returns Object containing recoverable amounts and subdust information
|
|
3529
4159
|
*
|
|
3530
4160
|
* @example
|
|
@@ -3546,11 +4176,24 @@ var VtxoManager = class _VtxoManager {
|
|
|
3546
4176
|
withUnrolled: false
|
|
3547
4177
|
});
|
|
3548
4178
|
const dustAmount = getDustAmount(this.wallet);
|
|
3549
|
-
const
|
|
4179
|
+
const now = await fetchTimeHeight(this.wallet);
|
|
4180
|
+
let { vtxosToRecover, includesSubdust } = getRecoverableWithSubdust(
|
|
3550
4181
|
allVtxos,
|
|
3551
4182
|
dustAmount,
|
|
3552
|
-
|
|
4183
|
+
now
|
|
3553
4184
|
);
|
|
4185
|
+
const refused = await this.unspendableNow(vtxosToRecover);
|
|
4186
|
+
if (refused.size > 0) {
|
|
4187
|
+
logExcludedVtxos("getRecoverableBalance", vtxosToRecover, [outpointReasons(refused)]);
|
|
4188
|
+
const remaining = vtxosToRecover.filter(
|
|
4189
|
+
(vtxo) => !refused.has(`${vtxo.txid}:${vtxo.vout}`)
|
|
4190
|
+
);
|
|
4191
|
+
({ vtxosToRecover, includesSubdust } = getRecoverableWithSubdust(
|
|
4192
|
+
remaining,
|
|
4193
|
+
dustAmount,
|
|
4194
|
+
now
|
|
4195
|
+
));
|
|
4196
|
+
}
|
|
3554
4197
|
const info = await this.getInfoProvider()?.getInfo();
|
|
3555
4198
|
const estimator = new Estimator(info?.fees.intentFee ?? {});
|
|
3556
4199
|
const { payable, net } = priceSettlementInputs(vtxosToRecover, estimator);
|
|
@@ -3843,11 +4486,11 @@ var VtxoManager = class _VtxoManager {
|
|
|
3843
4486
|
`Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
|
|
3844
4487
|
);
|
|
3845
4488
|
}
|
|
3846
|
-
const tx = new
|
|
4489
|
+
const tx = new chunkOH2XLTXE_cjs.Transaction();
|
|
3847
4490
|
for (const utxo of expiredUtxos) {
|
|
3848
|
-
const utxoScript =
|
|
4491
|
+
const utxoScript = chunkOH2XLTXE_cjs.VtxoScript.decode(utxo.tapTree);
|
|
3849
4492
|
const utxoExitLeaf = utxoScript.leaves.find(
|
|
3850
|
-
(leaf) =>
|
|
4493
|
+
(leaf) => chunkOH2XLTXE_cjs.CSVMultisigTapscript.isScriptValid(chunkOH2XLTXE_cjs.scriptFromTapLeafScript(leaf)) === true
|
|
3851
4494
|
);
|
|
3852
4495
|
if (!utxoExitLeaf) {
|
|
3853
4496
|
throw new Error(
|
|
@@ -3862,7 +4505,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
3862
4505
|
amount: BigInt(utxo.value)
|
|
3863
4506
|
},
|
|
3864
4507
|
tapLeafScript: [utxoExitLeaf],
|
|
3865
|
-
sequence:
|
|
4508
|
+
sequence: chunkOH2XLTXE_cjs.getSequence(utxoExitLeaf)
|
|
3866
4509
|
});
|
|
3867
4510
|
}
|
|
3868
4511
|
tx.addOutputAddress(boardingAddress, outputAmount, this.getNetwork());
|
|
@@ -4096,8 +4739,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
4096
4739
|
if (!serverPubKey) continue;
|
|
4097
4740
|
const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
|
|
4098
4741
|
if (cls.status === "CURRENT") continue;
|
|
4099
|
-
const recoverable = vtxos.filter((v) => v.isSwept && !
|
|
4100
|
-
const spendable = vtxos.filter((v) => !
|
|
4742
|
+
const recoverable = vtxos.filter((v) => v.isSwept && !chunkOH2XLTXE_cjs.hasTerminalSpend(v));
|
|
4743
|
+
const spendable = vtxos.filter((v) => !chunkOH2XLTXE_cjs.hasTerminalSpend(v) && !v.isSwept);
|
|
4101
4744
|
const value = spendable.reduce((sum, v) => sum + v.value, 0);
|
|
4102
4745
|
let recoverableCount = 0;
|
|
4103
4746
|
let recoverableValue = 0;
|
|
@@ -4110,7 +4753,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4110
4753
|
awaitingSweepCount = spendable.length;
|
|
4111
4754
|
awaitingSweepValue = value;
|
|
4112
4755
|
for (const v of spendable) {
|
|
4113
|
-
const exp =
|
|
4756
|
+
const exp = chunkOH2XLTXE_cjs.toBatchExpiry(v);
|
|
4114
4757
|
if (exp !== void 0 && (nextSweepEta === void 0 || exp < nextSweepEta)) {
|
|
4115
4758
|
nextSweepEta = exp;
|
|
4116
4759
|
}
|
|
@@ -4371,7 +5014,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4371
5014
|
/** Decodes the boarding tapscript exit path to extract the CSV timelock. */
|
|
4372
5015
|
getBoardingTimelock() {
|
|
4373
5016
|
const wallet = this.getSweepWallet();
|
|
4374
|
-
const exitScript =
|
|
5017
|
+
const exitScript = chunkOH2XLTXE_cjs.CSVMultisigTapscript.decode(
|
|
4375
5018
|
base.hex.decode(wallet.boardingTapscript.exitScript)
|
|
4376
5019
|
);
|
|
4377
5020
|
return exitScript.params.timelock;
|
|
@@ -4502,8 +5145,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
4502
5145
|
* or doesn't carry the metadata.
|
|
4503
5146
|
*/
|
|
4504
5147
|
extractSpentOutpoint(error) {
|
|
4505
|
-
const ark =
|
|
4506
|
-
if (!
|
|
5148
|
+
const ark = chunkOH2XLTXE_cjs.maybeArkError(error);
|
|
5149
|
+
if (!chunkOH2XLTXE_cjs.isArkError(ark, chunkOH2XLTXE_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
|
|
4507
5150
|
const raw = ark.metadata?.vtxo_outpoint;
|
|
4508
5151
|
if (typeof raw !== "string") return void 0;
|
|
4509
5152
|
const [txid, voutStr] = raw.split(":");
|
|
@@ -4693,7 +5336,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4693
5336
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
4694
5337
|
break;
|
|
4695
5338
|
}
|
|
4696
|
-
const inputFee = estimator.evalOffchainInput(
|
|
5339
|
+
const inputFee = estimator.evalOffchainInput(chunkOH2XLTXE_cjs.toOffchainInputFeeParams(v));
|
|
4697
5340
|
if (inputFee.satoshis >= v.value) {
|
|
4698
5341
|
continue;
|
|
4699
5342
|
}
|
|
@@ -4713,7 +5356,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4713
5356
|
const arkAddress = await this.wallet.getAddress();
|
|
4714
5357
|
const outputFee = estimator.evalOffchainOutput({
|
|
4715
5358
|
amount: totalAmount,
|
|
4716
|
-
script: base.hex.encode(
|
|
5359
|
+
script: base.hex.encode(chunkOH2XLTXE_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
4717
5360
|
});
|
|
4718
5361
|
totalAmount -= BigInt(outputFee.satoshis);
|
|
4719
5362
|
if (totalAmount < dustAmount) return;
|
|
@@ -4793,7 +5436,7 @@ var ArkNote = class _ArkNote {
|
|
|
4793
5436
|
this.value = value;
|
|
4794
5437
|
this.HRP = HRP;
|
|
4795
5438
|
const preimageHash = utils_js.sha256(this.preimage);
|
|
4796
|
-
this.vtxoScript = new
|
|
5439
|
+
this.vtxoScript = new chunkOH2XLTXE_cjs.VtxoScript([noteTapscript(preimageHash)]);
|
|
4797
5440
|
const leaf = this.vtxoScript.leaves[0];
|
|
4798
5441
|
this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
|
|
4799
5442
|
this.tapTree = this.vtxoScript.encode();
|
|
@@ -4960,7 +5603,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
4960
5603
|
const privateKey = data.slice(1, 33);
|
|
4961
5604
|
const serverPubKey = data.slice(33, 65);
|
|
4962
5605
|
const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
|
|
4963
|
-
const csvTimelock =
|
|
5606
|
+
const csvTimelock = chunkOH2XLTXE_cjs.sequenceToTimelock(sequence);
|
|
4964
5607
|
return new _ArkadeCash(privateKey, serverPubKey, csvTimelock, decoded.prefix);
|
|
4965
5608
|
}
|
|
4966
5609
|
toString() {
|
|
@@ -4968,7 +5611,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
4968
5611
|
data[0] = _ArkadeCash.Version;
|
|
4969
5612
|
data.set(this._privateKey, 1);
|
|
4970
5613
|
data.set(this._serverPubKey, 33);
|
|
4971
|
-
const sequence =
|
|
5614
|
+
const sequence = chunkOH2XLTXE_cjs.timelockToSequence(this.csvTimelock);
|
|
4972
5615
|
new DataView(data.buffer, data.byteOffset + 65, 4).setUint32(0, sequence, false);
|
|
4973
5616
|
const words = base.bech32m.toWords(data);
|
|
4974
5617
|
return base.bech32m.encode(this.hrp, words, 1023);
|
|
@@ -4977,7 +5620,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
4977
5620
|
return SingleKey.fromPrivateKey(this._privateKey);
|
|
4978
5621
|
}
|
|
4979
5622
|
get vtxoScript() {
|
|
4980
|
-
return new
|
|
5623
|
+
return new chunkG53HASDV_cjs.DefaultVtxo.Script({
|
|
4981
5624
|
pubKey: this._publicKey,
|
|
4982
5625
|
serverPubKey: this._serverPubKey,
|
|
4983
5626
|
csvTimelock: this.csvTimelock
|
|
@@ -5238,7 +5881,7 @@ async function captureExitBranch(params) {
|
|
|
5238
5881
|
const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
|
|
5239
5882
|
if (nonCommitment.length > 0) {
|
|
5240
5883
|
for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
|
|
5241
|
-
psbtByTxid.set(
|
|
5884
|
+
psbtByTxid.set(chunkOH2XLTXE_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
5242
5885
|
}
|
|
5243
5886
|
}
|
|
5244
5887
|
}
|
|
@@ -5281,10 +5924,10 @@ var IndexerExitDataSource = class {
|
|
|
5281
5924
|
while (hasMore) {
|
|
5282
5925
|
const { chain: page, page: meta } = await this.indexer.getVtxoChain(
|
|
5283
5926
|
{ txid: vtxo.txid, vout: vtxo.vout },
|
|
5284
|
-
{ pageIndex, pageSize:
|
|
5927
|
+
{ pageIndex, pageSize: chunkOH2XLTXE_cjs.DEFAULT_PAGE_SIZE }
|
|
5285
5928
|
);
|
|
5286
5929
|
chain.push(...page);
|
|
5287
|
-
hasMore = meta ? page.length ===
|
|
5930
|
+
hasMore = meta ? page.length === chunkOH2XLTXE_cjs.DEFAULT_PAGE_SIZE : false;
|
|
5288
5931
|
pageIndex++;
|
|
5289
5932
|
}
|
|
5290
5933
|
return chain;
|
|
@@ -5296,12 +5939,12 @@ var IndexerExitDataSource = class {
|
|
|
5296
5939
|
while (hasMore) {
|
|
5297
5940
|
const { txs, page } = await this.indexer.getVirtualTxs(txids, {
|
|
5298
5941
|
pageIndex,
|
|
5299
|
-
pageSize:
|
|
5942
|
+
pageSize: chunkOH2XLTXE_cjs.DEFAULT_PAGE_SIZE
|
|
5300
5943
|
});
|
|
5301
5944
|
for (const psbt of txs) {
|
|
5302
|
-
out.set(
|
|
5945
|
+
out.set(chunkOH2XLTXE_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
5303
5946
|
}
|
|
5304
|
-
hasMore = page ? txs.length ===
|
|
5947
|
+
hasMore = page ? txs.length === chunkOH2XLTXE_cjs.DEFAULT_PAGE_SIZE : false;
|
|
5305
5948
|
pageIndex++;
|
|
5306
5949
|
}
|
|
5307
5950
|
return out;
|
|
@@ -5322,7 +5965,7 @@ function chainedTxTypeToChainTxType(t) {
|
|
|
5322
5965
|
}
|
|
5323
5966
|
}
|
|
5324
5967
|
function psbtInputTxids(psbtBase64) {
|
|
5325
|
-
const tx =
|
|
5968
|
+
const tx = chunkOH2XLTXE_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
5326
5969
|
const ids = [];
|
|
5327
5970
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
5328
5971
|
const txid = tx.getInput(i).txid;
|
|
@@ -5675,10 +6318,10 @@ async function resolveArkInfo(arkProvider, walletRepository) {
|
|
|
5675
6318
|
try {
|
|
5676
6319
|
info = await arkProvider.getInfo();
|
|
5677
6320
|
} catch (err) {
|
|
5678
|
-
if (!
|
|
6321
|
+
if (!chunkOH2XLTXE_cjs.isRetryableProviderError(err)) throw err;
|
|
5679
6322
|
const snapshot = await loadArkInfoSnapshot(walletRepository);
|
|
5680
6323
|
if (!snapshot) {
|
|
5681
|
-
throw new
|
|
6324
|
+
throw new chunkOH2XLTXE_cjs.ProviderUnavailableError(
|
|
5682
6325
|
"Arkade server info is unavailable and no cached snapshot exists",
|
|
5683
6326
|
{ cause: err }
|
|
5684
6327
|
);
|
|
@@ -6061,7 +6704,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos) {
|
|
|
6061
6704
|
return [...txids];
|
|
6062
6705
|
}
|
|
6063
6706
|
async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt) {
|
|
6064
|
-
const fromOldestVtxo = vtxos.map(
|
|
6707
|
+
const fromOldestVtxo = vtxos.map(chunkOH2XLTXE_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
6065
6708
|
const txidsNeedingCreatedAt = resolveTxCreatedAt ? collectArkTxidsNeedingCreatedAt(fromOldestVtxo) : [];
|
|
6066
6709
|
const resolvedCreatedAt = resolveTxCreatedAt && txidsNeedingCreatedAt.length > 0 ? await resolveTxCreatedAt(txidsNeedingCreatedAt) : /* @__PURE__ */ new Map();
|
|
6067
6710
|
const unmatchedSettledBoardingTxs = allBoardingTxs.filter(isSettledBoardingReceive).sort((a, b) => a.createdAt - b.createdAt);
|
|
@@ -6225,7 +6868,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6225
6868
|
const virtualCoins = await this.wallet.getSpendableVtxos({
|
|
6226
6869
|
withRecoverable: false
|
|
6227
6870
|
});
|
|
6228
|
-
const controlAssetRef = params.controlAssetId ?
|
|
6871
|
+
const controlAssetRef = params.controlAssetId ? chunkI6EDUE75_cjs.AssetRef.fromId(chunkI6EDUE75_cjs.AssetId.fromString(params.controlAssetId)) : null;
|
|
6229
6872
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
6230
6873
|
let totalBtcSelected = 0n;
|
|
6231
6874
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -6238,8 +6881,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6238
6881
|
}
|
|
6239
6882
|
}
|
|
6240
6883
|
const groups = [];
|
|
6241
|
-
const issuedAssetOutput =
|
|
6242
|
-
const issuedAssetGroup =
|
|
6884
|
+
const issuedAssetOutput = chunkI6EDUE75_cjs.AssetOutput.create(0, params.amount);
|
|
6885
|
+
const issuedAssetGroup = chunkI6EDUE75_cjs.AssetGroup.create(
|
|
6243
6886
|
null,
|
|
6244
6887
|
controlAssetRef,
|
|
6245
6888
|
[],
|
|
@@ -6254,28 +6897,28 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6254
6897
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6255
6898
|
for (const asset of assets) {
|
|
6256
6899
|
if (asset.assetId !== assetId) continue;
|
|
6257
|
-
changeInputs.push(
|
|
6900
|
+
changeInputs.push(chunkI6EDUE75_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6258
6901
|
}
|
|
6259
6902
|
}
|
|
6260
6903
|
groups.push(
|
|
6261
|
-
|
|
6262
|
-
|
|
6904
|
+
chunkI6EDUE75_cjs.AssetGroup.create(
|
|
6905
|
+
chunkI6EDUE75_cjs.AssetId.fromString(assetId),
|
|
6263
6906
|
null,
|
|
6264
6907
|
changeInputs,
|
|
6265
|
-
[
|
|
6908
|
+
[chunkI6EDUE75_cjs.AssetOutput.create(0, amount)],
|
|
6266
6909
|
[]
|
|
6267
6910
|
)
|
|
6268
6911
|
);
|
|
6269
6912
|
}
|
|
6270
6913
|
}
|
|
6271
6914
|
const address = await this.wallet.getAddress();
|
|
6272
|
-
const outputAddress =
|
|
6915
|
+
const outputAddress = chunkOH2XLTXE_cjs.ArkAddress.decode(address);
|
|
6273
6916
|
const outputs = [
|
|
6274
6917
|
{
|
|
6275
6918
|
script: outputAddress.pkScript,
|
|
6276
6919
|
amount: BigInt(totalBtcSelected)
|
|
6277
6920
|
},
|
|
6278
|
-
Extension.create([
|
|
6921
|
+
Extension.create([chunkI6EDUE75_cjs.Packet.create(groups)]).txOut()
|
|
6279
6922
|
];
|
|
6280
6923
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
|
|
6281
6924
|
coinSelection.inputs,
|
|
@@ -6283,7 +6926,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6283
6926
|
);
|
|
6284
6927
|
return {
|
|
6285
6928
|
arkTxId: arkTxid,
|
|
6286
|
-
assetId:
|
|
6929
|
+
assetId: chunkI6EDUE75_cjs.AssetId.create(arkTxid, 0).toString()
|
|
6287
6930
|
};
|
|
6288
6931
|
}
|
|
6289
6932
|
/**
|
|
@@ -6355,16 +6998,16 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6355
6998
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6356
6999
|
for (const asset of assets) {
|
|
6357
7000
|
if (asset.assetId !== params.assetId) continue;
|
|
6358
|
-
reissueInputs.push(
|
|
7001
|
+
reissueInputs.push(chunkI6EDUE75_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6359
7002
|
}
|
|
6360
7003
|
}
|
|
6361
7004
|
const totalAssetAmount = assetToReissueAmount + params.amount;
|
|
6362
|
-
const reissueAssetIdObj =
|
|
6363
|
-
const reissueAssetGroup =
|
|
7005
|
+
const reissueAssetIdObj = chunkI6EDUE75_cjs.AssetId.fromString(params.assetId);
|
|
7006
|
+
const reissueAssetGroup = chunkI6EDUE75_cjs.AssetGroup.create(
|
|
6364
7007
|
reissueAssetIdObj,
|
|
6365
7008
|
null,
|
|
6366
7009
|
reissueInputs,
|
|
6367
|
-
[
|
|
7010
|
+
[chunkI6EDUE75_cjs.AssetOutput.create(0, totalAssetAmount)],
|
|
6368
7011
|
[]
|
|
6369
7012
|
);
|
|
6370
7013
|
const groups = [reissueAssetGroup];
|
|
@@ -6373,27 +7016,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6373
7016
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6374
7017
|
for (const asset of assets) {
|
|
6375
7018
|
if (asset.assetId !== assetId) continue;
|
|
6376
|
-
changeInputs.push(
|
|
7019
|
+
changeInputs.push(chunkI6EDUE75_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6377
7020
|
}
|
|
6378
7021
|
}
|
|
6379
7022
|
groups.push(
|
|
6380
|
-
|
|
6381
|
-
|
|
7023
|
+
chunkI6EDUE75_cjs.AssetGroup.create(
|
|
7024
|
+
chunkI6EDUE75_cjs.AssetId.fromString(assetId),
|
|
6382
7025
|
null,
|
|
6383
7026
|
changeInputs,
|
|
6384
|
-
[
|
|
7027
|
+
[chunkI6EDUE75_cjs.AssetOutput.create(0, amount)],
|
|
6385
7028
|
[]
|
|
6386
7029
|
)
|
|
6387
7030
|
);
|
|
6388
7031
|
}
|
|
6389
7032
|
const address = await this.wallet.getAddress();
|
|
6390
|
-
const outputAddress =
|
|
7033
|
+
const outputAddress = chunkOH2XLTXE_cjs.ArkAddress.decode(address);
|
|
6391
7034
|
const outputs = [
|
|
6392
7035
|
{
|
|
6393
7036
|
script: outputAddress.pkScript,
|
|
6394
7037
|
amount: BigInt(totalBtcSelected)
|
|
6395
7038
|
},
|
|
6396
|
-
Extension.create([
|
|
7039
|
+
Extension.create([chunkI6EDUE75_cjs.Packet.create(groups)]).txOut()
|
|
6397
7040
|
];
|
|
6398
7041
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
6399
7042
|
return arkTxid;
|
|
@@ -6460,27 +7103,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6460
7103
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6461
7104
|
for (const asset of assets) {
|
|
6462
7105
|
if (asset.assetId !== assetId) continue;
|
|
6463
|
-
changeInputs.push(
|
|
7106
|
+
changeInputs.push(chunkI6EDUE75_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6464
7107
|
}
|
|
6465
7108
|
}
|
|
6466
7109
|
groups.push(
|
|
6467
|
-
|
|
6468
|
-
|
|
7110
|
+
chunkI6EDUE75_cjs.AssetGroup.create(
|
|
7111
|
+
chunkI6EDUE75_cjs.AssetId.fromString(assetId),
|
|
6469
7112
|
null,
|
|
6470
7113
|
changeInputs,
|
|
6471
|
-
amount > 0n ? [
|
|
7114
|
+
amount > 0n ? [chunkI6EDUE75_cjs.AssetOutput.create(0, amount)] : [],
|
|
6472
7115
|
[]
|
|
6473
7116
|
)
|
|
6474
7117
|
);
|
|
6475
7118
|
}
|
|
6476
7119
|
const address = await this.wallet.getAddress();
|
|
6477
|
-
const outputAddress =
|
|
7120
|
+
const outputAddress = chunkOH2XLTXE_cjs.ArkAddress.decode(address);
|
|
6478
7121
|
const outputs = [
|
|
6479
7122
|
{
|
|
6480
7123
|
script: outputAddress.pkScript,
|
|
6481
7124
|
amount: BigInt(totalBtcSelected)
|
|
6482
7125
|
},
|
|
6483
|
-
Extension.create([
|
|
7126
|
+
Extension.create([chunkI6EDUE75_cjs.Packet.create(groups)]).txOut()
|
|
6484
7127
|
];
|
|
6485
7128
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
6486
7129
|
return arkTxid;
|
|
@@ -6505,7 +7148,7 @@ function castMetadata(metadata) {
|
|
|
6505
7148
|
} else {
|
|
6506
7149
|
throw new Error("Invalid metadata value type");
|
|
6507
7150
|
}
|
|
6508
|
-
md.push(
|
|
7151
|
+
md.push(chunkI6EDUE75_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
|
|
6509
7152
|
}
|
|
6510
7153
|
return md;
|
|
6511
7154
|
}
|
|
@@ -6526,10 +7169,10 @@ var DelegateManagerImpl = class {
|
|
|
6526
7169
|
if (vtxos.length === 0) {
|
|
6527
7170
|
return { delegated: [], failed: [] };
|
|
6528
7171
|
}
|
|
6529
|
-
const destinationScript =
|
|
7172
|
+
const destinationScript = chunkOH2XLTXE_cjs.ArkAddress.decode(destination).pkScript;
|
|
6530
7173
|
const arkInfo = await this.arkInfoProvider.getInfo();
|
|
6531
7174
|
const delegateInfo = await this.delegateProvider.getDelegateInfo();
|
|
6532
|
-
const eligible = vtxos.map(
|
|
7175
|
+
const eligible = vtxos.map(chunkOH2XLTXE_cjs.normalizeVtxo).filter(
|
|
6533
7176
|
(v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
|
|
6534
7177
|
);
|
|
6535
7178
|
if (eligible.length === 0) {
|
|
@@ -6558,11 +7201,11 @@ var DelegateManagerImpl = class {
|
|
|
6558
7201
|
const groupByExpiry = /* @__PURE__ */ new Map();
|
|
6559
7202
|
let recoverableVtxos = [];
|
|
6560
7203
|
for (const vtxo of eligible) {
|
|
6561
|
-
if (
|
|
7204
|
+
if (chunkOH2XLTXE_cjs.canRecoverOnchain(vtxo, now)) {
|
|
6562
7205
|
recoverableVtxos.push(vtxo);
|
|
6563
7206
|
continue;
|
|
6564
7207
|
}
|
|
6565
|
-
const expiry =
|
|
7208
|
+
const expiry = chunkOH2XLTXE_cjs.toBatchExpiry(vtxo);
|
|
6566
7209
|
if (!expiry) continue;
|
|
6567
7210
|
const dayKey = getDayTimestamp(expiry);
|
|
6568
7211
|
groupByExpiry.set(dayKey, [...groupByExpiry.get(dayKey) ?? [], vtxo]);
|
|
@@ -6627,7 +7270,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6627
7270
|
}
|
|
6628
7271
|
if (!delegateAt) {
|
|
6629
7272
|
const now = { timestamp: /* @__PURE__ */ new Date() };
|
|
6630
|
-
const expiryTimestamp = vtxos.filter((coin) => !
|
|
7273
|
+
const expiryTimestamp = vtxos.filter((coin) => !chunkOH2XLTXE_cjs.canRecoverOnchain(coin, now) && chunkOH2XLTXE_cjs.toBatchExpiry(coin)).reduce((min, coin) => Math.min(min, chunkOH2XLTXE_cjs.toBatchExpiry(coin)), Number.MAX_SAFE_INTEGER);
|
|
6631
7274
|
if (!expiryTimestamp || expiryTimestamp === Number.MAX_SAFE_INTEGER) {
|
|
6632
7275
|
delegateAt = new Date(Date.now() + 1 * 60 * 1e3);
|
|
6633
7276
|
} else {
|
|
@@ -6656,7 +7299,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6656
7299
|
let amount = 0n;
|
|
6657
7300
|
for (const coin of vtxos) {
|
|
6658
7301
|
const inputFee = estimator.evalOffchainInput({
|
|
6659
|
-
...
|
|
7302
|
+
...chunkOH2XLTXE_cjs.toOffchainInputFeeParams(coin),
|
|
6660
7303
|
type: "vtxo"
|
|
6661
7304
|
});
|
|
6662
7305
|
if (inputFee.value >= coin.value) {
|
|
@@ -6670,7 +7313,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6670
7313
|
const delegateFee = BigInt(Number(fee));
|
|
6671
7314
|
if (delegateFee > 0n) {
|
|
6672
7315
|
outputs.push({
|
|
6673
|
-
script:
|
|
7316
|
+
script: chunkOH2XLTXE_cjs.ArkAddress.decode(delegateAddress).pkScript,
|
|
6674
7317
|
amount: delegateFee
|
|
6675
7318
|
});
|
|
6676
7319
|
}
|
|
@@ -6703,10 +7346,10 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6703
7346
|
destinationScript
|
|
6704
7347
|
);
|
|
6705
7348
|
const forfeitOutputScript = btcSigner.OutScript.encode(
|
|
6706
|
-
btcSigner.Address(
|
|
7349
|
+
btcSigner.Address(chunkOH2XLTXE_cjs.getNetwork(network)).decode(forfeitAddress)
|
|
6707
7350
|
);
|
|
6708
7351
|
const forfeits = await Promise.all(
|
|
6709
|
-
vtxos.filter((v) => !
|
|
7352
|
+
vtxos.filter((v) => !chunkOH2XLTXE_cjs.canRecoverOnchain(v, { timestamp: /* @__PURE__ */ new Date() })).map(async (coin) => {
|
|
6710
7353
|
const forfeit = await makeDelegateForfeitTx(
|
|
6711
7354
|
coin,
|
|
6712
7355
|
dust,
|
|
@@ -6731,7 +7374,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
|
|
|
6731
7374
|
index: input.vout,
|
|
6732
7375
|
witnessUtxo: {
|
|
6733
7376
|
amount: BigInt(input.value),
|
|
6734
|
-
script:
|
|
7377
|
+
script: chunkOH2XLTXE_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
6735
7378
|
},
|
|
6736
7379
|
sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
|
|
6737
7380
|
tapLeafScript: [delegateTapLeaf]
|
|
@@ -6789,7 +7432,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
6789
7432
|
expire_at: 0,
|
|
6790
7433
|
cosigners_public_keys: cosignerPubKeys
|
|
6791
7434
|
};
|
|
6792
|
-
const proof =
|
|
7435
|
+
const proof = chunkOH2XLTXE_cjs.Intent.create(message, coins, outputs);
|
|
6793
7436
|
const signedProof = await identity.sign(proof);
|
|
6794
7437
|
return {
|
|
6795
7438
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -6807,10 +7450,10 @@ function getDayTimestamp(timestamp) {
|
|
|
6807
7450
|
function findDelegateTapLeaf(vtxo, delegatePubkey) {
|
|
6808
7451
|
if (!vtxo.tapTree) return void 0;
|
|
6809
7452
|
const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
|
|
6810
|
-
const vtxoScript =
|
|
7453
|
+
const vtxoScript = chunkOH2XLTXE_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
6811
7454
|
return vtxoScript.leaves.find((tapLeaf) => {
|
|
6812
|
-
const arkTapscript =
|
|
6813
|
-
if (!
|
|
7455
|
+
const arkTapscript = chunkOH2XLTXE_cjs.decodeTapscript(chunkOH2XLTXE_cjs.scriptFromTapLeafScript(tapLeaf));
|
|
7456
|
+
if (!chunkOH2XLTXE_cjs.MultisigTapscript.is(arkTapscript)) return false;
|
|
6814
7457
|
return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
|
|
6815
7458
|
});
|
|
6816
7459
|
}
|
|
@@ -6998,7 +7641,7 @@ async function closeDatabase(dbName) {
|
|
|
6998
7641
|
return true;
|
|
6999
7642
|
}
|
|
7000
7643
|
function scriptFromArkAddress(address) {
|
|
7001
|
-
return base.hex.encode(
|
|
7644
|
+
return base.hex.encode(chunkOH2XLTXE_cjs.ArkAddress.decode(address).pkScript);
|
|
7002
7645
|
}
|
|
7003
7646
|
|
|
7004
7647
|
// src/repositories/indexedDB/schema.ts
|
|
@@ -7495,7 +8138,7 @@ function validateVtxosForScript(vtxos, script, context) {
|
|
|
7495
8138
|
}
|
|
7496
8139
|
async function getVtxosForContract(repo, contract) {
|
|
7497
8140
|
const vtxos = repo.getVtxosForScript ? await repo.getVtxosForScript(contract.script) : filterVtxosForScript(await repo.getVtxos(contract.address), contract.script);
|
|
7498
|
-
return vtxos.map(
|
|
8141
|
+
return vtxos.map(chunkOH2XLTXE_cjs.normalizeVtxo);
|
|
7499
8142
|
}
|
|
7500
8143
|
async function saveVtxosForContract(repo, contract, vtxos) {
|
|
7501
8144
|
if (repo.saveVtxosForScript) {
|
|
@@ -7612,41 +8255,6 @@ function mergeByKey(existing, incoming, toKey) {
|
|
|
7612
8255
|
});
|
|
7613
8256
|
return Array.from(next.values());
|
|
7614
8257
|
}
|
|
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
8258
|
var ARKCONTRACT_PREFIX = "arkcontract";
|
|
7651
8259
|
function encodeArkContract(contract) {
|
|
7652
8260
|
const params = new URLSearchParams();
|
|
@@ -7672,7 +8280,7 @@ function decodeArkContract(encoded) {
|
|
|
7672
8280
|
}
|
|
7673
8281
|
function contractFromArkContract(encoded, options = {}) {
|
|
7674
8282
|
const parsed = decodeArkContract(encoded);
|
|
7675
|
-
const handler =
|
|
8283
|
+
const handler = chunkG53HASDV_cjs.contractHandlers.get(parsed.type);
|
|
7676
8284
|
if (!handler) {
|
|
7677
8285
|
throw new Error(`No handler registered for contract type '${parsed.type}'`);
|
|
7678
8286
|
}
|
|
@@ -7686,9 +8294,9 @@ function contractFromArkContract(encoded, options = {}) {
|
|
|
7686
8294
|
metadata: options.metadata
|
|
7687
8295
|
};
|
|
7688
8296
|
}
|
|
7689
|
-
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix =
|
|
8297
|
+
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkOH2XLTXE_cjs.DEFAULT_NETWORK.hrp, options = {}) {
|
|
7690
8298
|
const parsed = decodeArkContract(encoded);
|
|
7691
|
-
const handler =
|
|
8299
|
+
const handler = chunkG53HASDV_cjs.contractHandlers.getOrThrow(parsed.type);
|
|
7692
8300
|
const params = parsed.data;
|
|
7693
8301
|
const vtxoScript = handler.createScript(params);
|
|
7694
8302
|
return {
|
|
@@ -7942,9 +8550,9 @@ var ContractWatcher = class {
|
|
|
7942
8550
|
this.connectionState = "connected";
|
|
7943
8551
|
this.reconnectAttempts = 0;
|
|
7944
8552
|
this.listenLoop().catch((e) => {
|
|
7945
|
-
if (
|
|
8553
|
+
if (chunkOH2XLTXE_cjs.isEventSourceError(e)) {
|
|
7946
8554
|
console.debug("ContractWatcher subscription disconnected; reconnecting");
|
|
7947
|
-
} else if (!
|
|
8555
|
+
} else if (!chunkOH2XLTXE_cjs.isEventSourceUnavailableError(e)) {
|
|
7948
8556
|
console.error(e);
|
|
7949
8557
|
}
|
|
7950
8558
|
this.connectionState = "disconnected";
|
|
@@ -7956,7 +8564,7 @@ var ContractWatcher = class {
|
|
|
7956
8564
|
this.scheduleReconnect();
|
|
7957
8565
|
});
|
|
7958
8566
|
} catch (error) {
|
|
7959
|
-
if (!
|
|
8567
|
+
if (!chunkOH2XLTXE_cjs.isEventSourceUnavailableError(error)) {
|
|
7960
8568
|
console.error("ContractWatcher connection failed:", error);
|
|
7961
8569
|
}
|
|
7962
8570
|
this.connectionState = "disconnected";
|
|
@@ -7982,7 +8590,7 @@ var ContractWatcher = class {
|
|
|
7982
8590
|
* slower; what it loses is push latency.
|
|
7983
8591
|
*/
|
|
7984
8592
|
reportEventSourceUnavailable(error) {
|
|
7985
|
-
if (!
|
|
8593
|
+
if (!chunkOH2XLTXE_cjs.isEventSourceUnavailableError(error)) return false;
|
|
7986
8594
|
if (!this.eventSourceReported) {
|
|
7987
8595
|
this.eventSourceReported = true;
|
|
7988
8596
|
console.warn(
|
|
@@ -8198,14 +8806,14 @@ var ContractWatcher = class {
|
|
|
8198
8806
|
const timestamp = Date.now();
|
|
8199
8807
|
if (update.newVtxos?.length) {
|
|
8200
8808
|
this.processSubscriptionVtxos(
|
|
8201
|
-
update.newVtxos.map(
|
|
8809
|
+
update.newVtxos.map(chunkOH2XLTXE_cjs.normalizeVtxo),
|
|
8202
8810
|
"vtxo_received",
|
|
8203
8811
|
timestamp
|
|
8204
8812
|
);
|
|
8205
8813
|
}
|
|
8206
8814
|
if (update.spentVtxos?.length) {
|
|
8207
8815
|
this.processSubscriptionVtxos(
|
|
8208
|
-
update.spentVtxos.map(
|
|
8816
|
+
update.spentVtxos.map(chunkOH2XLTXE_cjs.normalizeVtxo),
|
|
8209
8817
|
"vtxo_spent",
|
|
8210
8818
|
timestamp
|
|
8211
8819
|
);
|
|
@@ -8338,7 +8946,7 @@ async function reconcileIntents(deps) {
|
|
|
8338
8946
|
let vtxosByOutpoint = /* @__PURE__ */ new Map();
|
|
8339
8947
|
if (outpoints.length > 0) {
|
|
8340
8948
|
try {
|
|
8341
|
-
const { vtxos } = await
|
|
8949
|
+
const { vtxos } = await chunkOH2XLTXE_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
|
|
8342
8950
|
vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
|
|
8343
8951
|
} catch (e) {
|
|
8344
8952
|
console.error("reconcileIntents: failed to fetch input VTXO state", e);
|
|
@@ -8512,7 +9120,7 @@ var ContractManager = class _ContractManager {
|
|
|
8512
9120
|
await this.reconcileWatched();
|
|
8513
9121
|
this.markSyncOnline();
|
|
8514
9122
|
} catch (err) {
|
|
8515
|
-
if (!
|
|
9123
|
+
if (!chunkOH2XLTXE_cjs.isRetryableProviderError(err)) throw err;
|
|
8516
9124
|
this.markSyncDegraded(err);
|
|
8517
9125
|
}
|
|
8518
9126
|
this.initialized = true;
|
|
@@ -8644,7 +9252,7 @@ var ContractManager = class _ContractManager {
|
|
|
8644
9252
|
const from = Math.max(0, watermark - lookAhead.size);
|
|
8645
9253
|
const to = watermark + lookAhead.size;
|
|
8646
9254
|
const deps = lookAhead.candidateDeps();
|
|
8647
|
-
const handlers =
|
|
9255
|
+
const handlers = chunkG53HASDV_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkG53HASDV_cjs.contractHandlers.get(t)).filter(hasCandidates);
|
|
8648
9256
|
const band = /* @__PURE__ */ new Map();
|
|
8649
9257
|
for (let index = from; index <= to; index++) {
|
|
8650
9258
|
const descriptor = lookAhead.materialize(index);
|
|
@@ -8655,7 +9263,7 @@ var ContractManager = class _ContractManager {
|
|
|
8655
9263
|
index,
|
|
8656
9264
|
params: {
|
|
8657
9265
|
...candidate,
|
|
8658
|
-
...
|
|
9266
|
+
...chunkG53HASDV_cjs.speculativeReceiveMetadata(descriptor)
|
|
8659
9267
|
}
|
|
8660
9268
|
});
|
|
8661
9269
|
}
|
|
@@ -8717,7 +9325,7 @@ var ContractManager = class _ContractManager {
|
|
|
8717
9325
|
});
|
|
8718
9326
|
for (const entry of pending) entry.catchUpPending = false;
|
|
8719
9327
|
} catch (err) {
|
|
8720
|
-
if (!
|
|
9328
|
+
if (!chunkOH2XLTXE_cjs.isRetryableProviderError(err)) throw err;
|
|
8721
9329
|
this.markSyncDegraded(err);
|
|
8722
9330
|
}
|
|
8723
9331
|
}
|
|
@@ -8767,7 +9375,7 @@ var ContractManager = class _ContractManager {
|
|
|
8767
9375
|
await this.fetchContractVxosFromIndexer([contract]);
|
|
8768
9376
|
this.markSyncOnline();
|
|
8769
9377
|
} catch (err) {
|
|
8770
|
-
if (!
|
|
9378
|
+
if (!chunkOH2XLTXE_cjs.isRetryableProviderError(err)) throw err;
|
|
8771
9379
|
this.markSyncDegraded(err);
|
|
8772
9380
|
}
|
|
8773
9381
|
await this.watcher.addContract(contract);
|
|
@@ -8804,7 +9412,7 @@ var ContractManager = class _ContractManager {
|
|
|
8804
9412
|
return result;
|
|
8805
9413
|
}
|
|
8806
9414
|
async upsertContractRow(params) {
|
|
8807
|
-
const handler =
|
|
9415
|
+
const handler = chunkG53HASDV_cjs.contractHandlers.get(params.type);
|
|
8808
9416
|
if (!handler) {
|
|
8809
9417
|
throw new Error(`No handler registered for contract type '${params.type}'`);
|
|
8810
9418
|
}
|
|
@@ -8904,7 +9512,7 @@ var ContractManager = class _ContractManager {
|
|
|
8904
9512
|
`scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
|
|
8905
9513
|
);
|
|
8906
9514
|
}
|
|
8907
|
-
const registered =
|
|
9515
|
+
const registered = chunkG53HASDV_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkG53HASDV_cjs.contractHandlers.get(t)).filter(isDiscoverable);
|
|
8908
9516
|
const discoverables = [
|
|
8909
9517
|
...registered.filter((h) => h.type === "boarding"),
|
|
8910
9518
|
...registered.filter((h) => h.type !== "boarding")
|
|
@@ -9039,7 +9647,7 @@ var ContractManager = class _ContractManager {
|
|
|
9039
9647
|
await this.syncContracts({ contracts, pageSize });
|
|
9040
9648
|
this.markSyncOnline();
|
|
9041
9649
|
} catch (err) {
|
|
9042
|
-
if (!
|
|
9650
|
+
if (!chunkOH2XLTXE_cjs.isRetryableProviderError(err)) throw err;
|
|
9043
9651
|
this.markSyncDegraded(err);
|
|
9044
9652
|
}
|
|
9045
9653
|
const vtxos = await this.getVtxosForContracts(contracts);
|
|
@@ -9060,7 +9668,7 @@ var ContractManager = class _ContractManager {
|
|
|
9060
9668
|
}
|
|
9061
9669
|
const tapscriptCache = tapscripts ?? /* @__PURE__ */ new Map();
|
|
9062
9670
|
return vtxos.map(
|
|
9063
|
-
(vtxo) => extendVirtualCoinForContract(
|
|
9671
|
+
(vtxo) => extendVirtualCoinForContract(chunkOH2XLTXE_cjs.normalizeVtxo(vtxo), byScript, tapscriptCache)
|
|
9064
9672
|
);
|
|
9065
9673
|
}
|
|
9066
9674
|
/** @inheritdoc */
|
|
@@ -9087,21 +9695,31 @@ var ContractManager = class _ContractManager {
|
|
|
9087
9695
|
}
|
|
9088
9696
|
/** @inheritdoc */
|
|
9089
9697
|
async assertSpendableNow(vtxos, walletPubKey) {
|
|
9090
|
-
|
|
9698
|
+
const refused = await this.unspendableNowReasons(vtxos, walletPubKey);
|
|
9699
|
+
if (refused.size === 0) return;
|
|
9700
|
+
if (refused.size === 1) throw new Error([...refused.values()][0]);
|
|
9701
|
+
throw new Error(
|
|
9702
|
+
`refusing to spend ${refused.size} vtxo(s) that cannot be spent yet: ` + [...refused].map(([outpoint, why]) => `${outpoint}: ${why}`).join("; ")
|
|
9703
|
+
);
|
|
9704
|
+
}
|
|
9705
|
+
/** @inheritdoc */
|
|
9706
|
+
async unspendableNowReasons(vtxos, walletPubKey) {
|
|
9707
|
+
const refused = /* @__PURE__ */ new Map();
|
|
9708
|
+
if (vtxos.length === 0) return refused;
|
|
9091
9709
|
const contracts = await this.config.contractRepository.getContracts({
|
|
9092
9710
|
script: Array.from(new Set(vtxos.map((vtxo) => vtxo.script)))
|
|
9093
9711
|
});
|
|
9094
9712
|
const byScript = new Map(contracts.map((contract) => [contract.script, contract]));
|
|
9095
9713
|
const asking = vtxos.filter((vtxo) => {
|
|
9096
9714
|
const contract = byScript.get(vtxo.script);
|
|
9097
|
-
return contract !== void 0 &&
|
|
9715
|
+
return contract !== void 0 && chunkG53HASDV_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
|
|
9098
9716
|
});
|
|
9099
|
-
if (asking.length === 0) return;
|
|
9717
|
+
if (asking.length === 0) return refused;
|
|
9100
9718
|
const tip = await this.currentChainTip();
|
|
9101
9719
|
const walletKey = await walletPubKey?.();
|
|
9102
9720
|
for (const vtxo of asking) {
|
|
9103
9721
|
const contract = byScript.get(vtxo.script);
|
|
9104
|
-
const handler =
|
|
9722
|
+
const handler = chunkG53HASDV_cjs.contractHandlers.get(contract.type);
|
|
9105
9723
|
if (!handler?.assertSpendableNow) continue;
|
|
9106
9724
|
const context = {
|
|
9107
9725
|
collaborative: true,
|
|
@@ -9116,14 +9734,22 @@ var ContractManager = class _ContractManager {
|
|
|
9116
9734
|
// the next handler to answer a CSV question would meet a
|
|
9117
9735
|
// TypeError instead of a `false`. Carry the coin only when it
|
|
9118
9736
|
// really is one.
|
|
9119
|
-
vtxo:
|
|
9737
|
+
vtxo: chunkOH2XLTXE_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
|
|
9120
9738
|
};
|
|
9121
|
-
|
|
9122
|
-
handler.
|
|
9123
|
-
|
|
9124
|
-
|
|
9125
|
-
|
|
9739
|
+
try {
|
|
9740
|
+
await handler.assertSpendableNow(
|
|
9741
|
+
handler.createScript(contract.params),
|
|
9742
|
+
contract,
|
|
9743
|
+
context
|
|
9744
|
+
);
|
|
9745
|
+
} catch (err) {
|
|
9746
|
+
refused.set(
|
|
9747
|
+
`${vtxo.txid}:${vtxo.vout}`,
|
|
9748
|
+
err instanceof Error ? err.message : String(err)
|
|
9749
|
+
);
|
|
9750
|
+
}
|
|
9126
9751
|
}
|
|
9752
|
+
return refused;
|
|
9127
9753
|
}
|
|
9128
9754
|
// Field-by-field, so every filter a caller can express reaches the
|
|
9129
9755
|
// repository. A field missing here is not a narrower query — it is an
|
|
@@ -9264,7 +9890,7 @@ var ContractManager = class _ContractManager {
|
|
|
9264
9890
|
const { contractScript, collaborative = true, walletPubKey, vtxo } = options;
|
|
9265
9891
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
9266
9892
|
if (!contract) return [];
|
|
9267
|
-
const handler =
|
|
9893
|
+
const handler = chunkG53HASDV_cjs.contractHandlers.get(contract.type);
|
|
9268
9894
|
if (!handler) return [];
|
|
9269
9895
|
const script = handler.createScript(contract.params);
|
|
9270
9896
|
const tip = await this.currentChainTip();
|
|
@@ -9292,7 +9918,7 @@ var ContractManager = class _ContractManager {
|
|
|
9292
9918
|
const { contractScript, collaborative = true, walletPubKey } = options;
|
|
9293
9919
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
9294
9920
|
if (!contract) return [];
|
|
9295
|
-
const handler =
|
|
9921
|
+
const handler = chunkG53HASDV_cjs.contractHandlers.get(contract.type);
|
|
9296
9922
|
if (!handler) return [];
|
|
9297
9923
|
const script = handler.createScript(contract.params);
|
|
9298
9924
|
const context = {
|
|
@@ -9348,7 +9974,7 @@ var ContractManager = class _ContractManager {
|
|
|
9348
9974
|
}
|
|
9349
9975
|
async refreshOutpoints(outpoints) {
|
|
9350
9976
|
if (outpoints.length === 0) return;
|
|
9351
|
-
const { vtxos } = await
|
|
9977
|
+
const { vtxos } = await chunkOH2XLTXE_cjs.getNormalizedVtxos(this.config.indexerProvider, {
|
|
9352
9978
|
outpoints
|
|
9353
9979
|
});
|
|
9354
9980
|
if (vtxos.length === 0) return;
|
|
@@ -9427,7 +10053,7 @@ var ContractManager = class _ContractManager {
|
|
|
9427
10053
|
break;
|
|
9428
10054
|
}
|
|
9429
10055
|
} catch (err) {
|
|
9430
|
-
if (!
|
|
10056
|
+
if (!chunkOH2XLTXE_cjs.isRetryableProviderError(err)) throw err;
|
|
9431
10057
|
this.markSyncDegraded(err);
|
|
9432
10058
|
}
|
|
9433
10059
|
this.emitEvent(event);
|
|
@@ -9506,7 +10132,7 @@ var ContractManager = class _ContractManager {
|
|
|
9506
10132
|
*/
|
|
9507
10133
|
async reconcilePendingFrontier(contracts) {
|
|
9508
10134
|
const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
|
|
9509
|
-
const vtxos = await
|
|
10135
|
+
const vtxos = await chunkOH2XLTXE_cjs.getAllNormalizedVtxos(
|
|
9510
10136
|
this.config.indexerProvider,
|
|
9511
10137
|
contracts.map((c) => c.script),
|
|
9512
10138
|
{ pendingOnly: true }
|
|
@@ -9589,7 +10215,7 @@ var ContractManager = class _ContractManager {
|
|
|
9589
10215
|
}
|
|
9590
10216
|
return result;
|
|
9591
10217
|
}
|
|
9592
|
-
async fetchContractVtxosBulk(contracts, pageSize =
|
|
10218
|
+
async fetchContractVtxosBulk(contracts, pageSize = chunkOH2XLTXE_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
|
|
9593
10219
|
if (contracts.length === 0) {
|
|
9594
10220
|
return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
|
|
9595
10221
|
}
|
|
@@ -9605,7 +10231,7 @@ var ContractManager = class _ContractManager {
|
|
|
9605
10231
|
before: syncWindow.before
|
|
9606
10232
|
}
|
|
9607
10233
|
} : {};
|
|
9608
|
-
const vtxos = await
|
|
10234
|
+
const vtxos = await chunkOH2XLTXE_cjs.getAllNormalizedVtxos(
|
|
9609
10235
|
this.config.indexerProvider,
|
|
9610
10236
|
contracts.map((c) => c.script),
|
|
9611
10237
|
{ ...windowOpts, pageSize }
|
|
@@ -9750,7 +10376,7 @@ var deserializeTapLeaf = (t) => {
|
|
|
9750
10376
|
const s = base.hex.decode(t.s);
|
|
9751
10377
|
return [cb, s];
|
|
9752
10378
|
};
|
|
9753
|
-
var deserializeVtxo = (o) =>
|
|
10379
|
+
var deserializeVtxo = (o) => chunkOH2XLTXE_cjs.normalizeVtxo({
|
|
9754
10380
|
...o,
|
|
9755
10381
|
createdAt: new Date(o.createdAt),
|
|
9756
10382
|
tapTree: base.hex.decode(o.tapTree),
|
|
@@ -10791,7 +11417,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
10791
11417
|
*/
|
|
10792
11418
|
materializeDescriptorAt(index) {
|
|
10793
11419
|
const descriptor = this.identity.descriptor;
|
|
10794
|
-
const network =
|
|
11420
|
+
const network = chunkG53HASDV_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
10795
11421
|
const expansion = descriptorsScure.expand({ descriptor, network, index });
|
|
10796
11422
|
const keyInfo = expansion.expansionMap?.["@0"];
|
|
10797
11423
|
if (!keyInfo?.keyExpression) {
|
|
@@ -10939,7 +11565,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
10939
11565
|
const provider = await resolveDescriptorProvider(config, setup.walletRepository);
|
|
10940
11566
|
if (!provider) return void 0;
|
|
10941
11567
|
const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
|
|
10942
|
-
const expectedContractType = setup.offchainTapscript instanceof
|
|
11568
|
+
const expectedContractType = setup.offchainTapscript instanceof chunkG53HASDV_cjs.DelegateVtxo.Script ? "delegate" : "default";
|
|
10943
11569
|
const factoryOpts = {
|
|
10944
11570
|
walletRepository: setup.walletRepository,
|
|
10945
11571
|
contractRepository: setup.contractRepository,
|
|
@@ -11138,7 +11764,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
11138
11764
|
};
|
|
11139
11765
|
function deriveLeafPubkey(descriptor) {
|
|
11140
11766
|
try {
|
|
11141
|
-
return
|
|
11767
|
+
return chunkG53HASDV_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
11142
11768
|
} catch (e) {
|
|
11143
11769
|
throw new NonRangeableDescriptorError(
|
|
11144
11770
|
"Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
|
|
@@ -11150,7 +11776,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
11150
11776
|
const pubKey = deriveLeafPubkey(descriptor);
|
|
11151
11777
|
const tapscript = rebuildTapscript(current, pubKey);
|
|
11152
11778
|
const serverPubKey = tapscript.options.serverPubKey;
|
|
11153
|
-
const csvTimelock =
|
|
11779
|
+
const csvTimelock = chunkOH2XLTXE_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
|
|
11154
11780
|
const base$1 = {
|
|
11155
11781
|
script: base.hex.encode(tapscript.pkScript),
|
|
11156
11782
|
address: tapscript.address(hrp, serverPubKey).encode(),
|
|
@@ -11161,11 +11787,11 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
11161
11787
|
// index-0 key. Without it, spends produce unsigned PSBTs that the
|
|
11162
11788
|
// server rejects with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
11163
11789
|
metadata: {
|
|
11164
|
-
...{ source:
|
|
11790
|
+
...{ source: chunkG53HASDV_cjs.WALLET_RECEIVE_SOURCE },
|
|
11165
11791
|
signingDescriptor: descriptor
|
|
11166
11792
|
}
|
|
11167
11793
|
};
|
|
11168
|
-
const params = tapscript instanceof
|
|
11794
|
+
const params = tapscript instanceof chunkG53HASDV_cjs.DelegateVtxo.Script ? {
|
|
11169
11795
|
...base$1,
|
|
11170
11796
|
type: "delegate",
|
|
11171
11797
|
params: {
|
|
@@ -11186,10 +11812,10 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
11186
11812
|
return { tapscript, params };
|
|
11187
11813
|
}
|
|
11188
11814
|
function rebuildTapscript(current, pubKey) {
|
|
11189
|
-
if (current instanceof
|
|
11190
|
-
return new
|
|
11815
|
+
if (current instanceof chunkG53HASDV_cjs.DelegateVtxo.Script) {
|
|
11816
|
+
return new chunkG53HASDV_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
|
|
11191
11817
|
}
|
|
11192
|
-
return new
|
|
11818
|
+
return new chunkG53HASDV_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
|
|
11193
11819
|
}
|
|
11194
11820
|
async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
|
|
11195
11821
|
const candidates = await contractRepository.getContracts({
|
|
@@ -11198,7 +11824,7 @@ async function pickActiveReceive(contractRepository, serverPubKey, expectedType)
|
|
|
11198
11824
|
});
|
|
11199
11825
|
const serverPubKeyHex = base.hex.encode(serverPubKey);
|
|
11200
11826
|
const matching = candidates.filter(
|
|
11201
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
11827
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkG53HASDV_cjs.WALLET_RECEIVE_SOURCE
|
|
11202
11828
|
).sort((a, b) => {
|
|
11203
11829
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
11204
11830
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -11241,6 +11867,8 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
11241
11867
|
let settled = 0;
|
|
11242
11868
|
let preconfirmed = 0;
|
|
11243
11869
|
let available = 0;
|
|
11870
|
+
let gated = 0;
|
|
11871
|
+
let intentLocked = 0;
|
|
11244
11872
|
let recoverable = 0;
|
|
11245
11873
|
let pendingRecovery = 0;
|
|
11246
11874
|
const owned = /* @__PURE__ */ new Map();
|
|
@@ -11251,23 +11879,27 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
11251
11879
|
}
|
|
11252
11880
|
};
|
|
11253
11881
|
for (const vtxo of vtxos) {
|
|
11254
|
-
if (
|
|
11882
|
+
if (chunkOH2XLTXE_cjs.hasTerminalSpend(vtxo)) continue;
|
|
11255
11883
|
addAssets(owned, vtxo);
|
|
11256
11884
|
if (isPendingRecovery(vtxo)) {
|
|
11257
11885
|
pendingRecovery += vtxo.value;
|
|
11258
11886
|
continue;
|
|
11259
11887
|
}
|
|
11260
|
-
if (
|
|
11888
|
+
if (chunkOH2XLTXE_cjs.canRecoverOnchain(vtxo, now)) {
|
|
11261
11889
|
recoverable += vtxo.value;
|
|
11262
11890
|
continue;
|
|
11263
11891
|
}
|
|
11264
|
-
if (!
|
|
11892
|
+
if (!chunkOH2XLTXE_cjs.canSpendOffchain(vtxo, now)) continue;
|
|
11265
11893
|
if (vtxo.isPreconfirmed) {
|
|
11266
11894
|
preconfirmed += vtxo.value;
|
|
11267
11895
|
} else {
|
|
11268
11896
|
settled += vtxo.value;
|
|
11269
11897
|
}
|
|
11270
|
-
if (isGenericallySpendable(vtxo)
|
|
11898
|
+
if (!isGenericallySpendable(vtxo)) {
|
|
11899
|
+
gated += vtxo.value;
|
|
11900
|
+
} else if (!isUnlocked(vtxo)) {
|
|
11901
|
+
intentLocked += vtxo.value;
|
|
11902
|
+
} else {
|
|
11271
11903
|
available += vtxo.value;
|
|
11272
11904
|
addAssets(spendable, vtxo);
|
|
11273
11905
|
}
|
|
@@ -11277,6 +11909,8 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
11277
11909
|
settled,
|
|
11278
11910
|
preconfirmed,
|
|
11279
11911
|
available,
|
|
11912
|
+
gated,
|
|
11913
|
+
intentLocked,
|
|
11280
11914
|
recoverable,
|
|
11281
11915
|
pendingRecovery,
|
|
11282
11916
|
total: settled + preconfirmed + recoverable + pendingRecovery,
|
|
@@ -11424,15 +12058,26 @@ var InputSignerRouter = class {
|
|
|
11424
12058
|
};
|
|
11425
12059
|
|
|
11426
12060
|
// src/wallet/wallet.ts
|
|
11427
|
-
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl ||
|
|
12061
|
+
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl || chunkOH2XLTXE_cjs.DEFAULT_ARKADE_SERVER_URL;
|
|
11428
12062
|
function intentProofJobs(coins) {
|
|
11429
12063
|
if (coins.length === 0) return [];
|
|
11430
12064
|
const coinJobs = coins.map((coin, i) => ({
|
|
11431
12065
|
index: i + 1,
|
|
11432
|
-
lookupScript:
|
|
12066
|
+
lookupScript: chunkOH2XLTXE_cjs.VtxoScript.decode(coin.tapTree).pkScript
|
|
11433
12067
|
}));
|
|
11434
12068
|
return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
|
|
11435
12069
|
}
|
|
12070
|
+
function asSendParams(args) {
|
|
12071
|
+
const [first] = args;
|
|
12072
|
+
if (args.length === 1 && first && "recipients" in first) {
|
|
12073
|
+
const params = first;
|
|
12074
|
+
if (params.recipients.length === 0) {
|
|
12075
|
+
throw new Error("At least one receiver is required");
|
|
12076
|
+
}
|
|
12077
|
+
return params;
|
|
12078
|
+
}
|
|
12079
|
+
return { recipients: args };
|
|
12080
|
+
}
|
|
11436
12081
|
function extractArkProviderUrl(provider) {
|
|
11437
12082
|
const serverUrl = provider.serverUrl;
|
|
11438
12083
|
return typeof serverUrl === "string" && serverUrl.length > 0 ? serverUrl : void 0;
|
|
@@ -11455,7 +12100,7 @@ function dedupeTimelocks(timelocks) {
|
|
|
11455
12100
|
const seen = /* @__PURE__ */ new Set();
|
|
11456
12101
|
const deduped = [];
|
|
11457
12102
|
for (const timelock of timelocks) {
|
|
11458
|
-
const sequence =
|
|
12103
|
+
const sequence = chunkOH2XLTXE_cjs.timelockToSequence(timelock).toString();
|
|
11459
12104
|
if (seen.has(sequence)) continue;
|
|
11460
12105
|
seen.add(sequence);
|
|
11461
12106
|
deduped.push(timelock);
|
|
@@ -11472,7 +12117,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
11472
12117
|
state: "active"
|
|
11473
12118
|
});
|
|
11474
12119
|
const newest = candidates.filter(
|
|
11475
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
12120
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkG53HASDV_cjs.WALLET_RECEIVE_SOURCE
|
|
11476
12121
|
).sort((a, b) => {
|
|
11477
12122
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
11478
12123
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -11480,7 +12125,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
11480
12125
|
if (!newest?.params.pubKey) return baseline;
|
|
11481
12126
|
try {
|
|
11482
12127
|
const pubKey = base.hex.decode(newest.params.pubKey);
|
|
11483
|
-
return new
|
|
12128
|
+
return new chunkG53HASDV_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
|
|
11484
12129
|
} catch (e) {
|
|
11485
12130
|
console.warn("Skipping malformed boarding contract at boot", newest.script, e);
|
|
11486
12131
|
return baseline;
|
|
@@ -11496,8 +12141,8 @@ function filterSnapshotVtxos(snapshot, filter, pendingSpendOutpoints) {
|
|
|
11496
12141
|
if (pendingSpendOutpoints.has(`${vtxo.txid}:${vtxo.vout}`)) {
|
|
11497
12142
|
return false;
|
|
11498
12143
|
}
|
|
11499
|
-
if (!
|
|
11500
|
-
if (!f.withRecoverable &&
|
|
12144
|
+
if (!chunkOH2XLTXE_cjs.hasTerminalSpend(vtxo)) {
|
|
12145
|
+
if (!f.withRecoverable && chunkOH2XLTXE_cjs.canRecoverOnchain(vtxo, now)) {
|
|
11501
12146
|
return false;
|
|
11502
12147
|
}
|
|
11503
12148
|
return true;
|
|
@@ -11838,7 +12483,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11838
12483
|
*/
|
|
11839
12484
|
static async setupWalletConfig(config, pubKey) {
|
|
11840
12485
|
const arkadeServerUrl = getArkadeServerUrl(config);
|
|
11841
|
-
const arkProvider = config.arkProvider || new
|
|
12486
|
+
const arkProvider = config.arkProvider || new chunkOH2XLTXE_cjs.RestArkProvider(arkadeServerUrl);
|
|
11842
12487
|
let indexerProvider = config.indexerProvider;
|
|
11843
12488
|
if (!indexerProvider) {
|
|
11844
12489
|
let indexerUrl = config.indexerUrl;
|
|
@@ -11855,7 +12500,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11855
12500
|
indexerUrl = arkadeServerUrl;
|
|
11856
12501
|
}
|
|
11857
12502
|
}
|
|
11858
|
-
indexerProvider = new
|
|
12503
|
+
indexerProvider = new chunkI6EDUE75_cjs.RestIndexerProvider(indexerUrl);
|
|
11859
12504
|
}
|
|
11860
12505
|
const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
11861
12506
|
const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
@@ -11864,7 +12509,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11864
12509
|
source: serverInfoSource,
|
|
11865
12510
|
lastOnlineAt: serverInfoLastOnlineAt
|
|
11866
12511
|
} = await resolveArkInfo(arkProvider, walletRepository);
|
|
11867
|
-
const network =
|
|
12512
|
+
const network = chunkOH2XLTXE_cjs.getNetwork(info.network);
|
|
11868
12513
|
if ("descriptor" in config.identity) {
|
|
11869
12514
|
const descriptor = config.identity.descriptor;
|
|
11870
12515
|
const identityIsMainnet = !descriptor.includes("tpub");
|
|
@@ -11911,11 +12556,11 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11911
12556
|
serverPubKey,
|
|
11912
12557
|
csvTimelock: exitTimelock
|
|
11913
12558
|
};
|
|
11914
|
-
const offchainTapscript = !delegatePubKey ? new
|
|
11915
|
-
const boardingTapscript =
|
|
12559
|
+
const offchainTapscript = !delegatePubKey ? new chunkG53HASDV_cjs.DefaultVtxo.Script(offchainOptions) : new chunkG53HASDV_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
|
|
12560
|
+
const boardingTapscript = chunkG53HASDV_cjs.BoardingContractHandler.createScript({
|
|
11916
12561
|
pubKey: base.hex.encode(pubKey),
|
|
11917
12562
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
11918
|
-
csvTimelock:
|
|
12563
|
+
csvTimelock: chunkOH2XLTXE_cjs.timelockToSequence(boardingTimelock).toString()
|
|
11919
12564
|
});
|
|
11920
12565
|
return {
|
|
11921
12566
|
arkProvider,
|
|
@@ -12029,6 +12674,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12029
12674
|
settled: offchain.settled,
|
|
12030
12675
|
preconfirmed: offchain.preconfirmed,
|
|
12031
12676
|
available: offchain.available,
|
|
12677
|
+
gated: offchain.gated,
|
|
12678
|
+
intentLocked: offchain.intentLocked,
|
|
12032
12679
|
recoverable: offchain.recoverable,
|
|
12033
12680
|
pendingRecovery: offchain.pendingRecovery,
|
|
12034
12681
|
total: totalBoarding + offchain.total,
|
|
@@ -12210,7 +12857,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12210
12857
|
const response = await contractManager.getContractsWithVtxos();
|
|
12211
12858
|
const allVtxos = response.flatMap((_) => _.vtxos);
|
|
12212
12859
|
const { boardingTxs, commitmentsToIgnore } = await this.getBoardingTxs();
|
|
12213
|
-
const resolveTxCreatedAt = (txids) =>
|
|
12860
|
+
const resolveTxCreatedAt = (txids) => chunkOH2XLTXE_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
|
|
12214
12861
|
return buildTransactionHistory(
|
|
12215
12862
|
allVtxos,
|
|
12216
12863
|
boardingTxs,
|
|
@@ -12304,7 +12951,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12304
12951
|
},
|
|
12305
12952
|
isUnrolled: true,
|
|
12306
12953
|
...boardingFacts,
|
|
12307
|
-
virtualStatus:
|
|
12954
|
+
virtualStatus: chunkOH2XLTXE_cjs.toVirtualStatus(boardingFacts),
|
|
12308
12955
|
spentBy: "",
|
|
12309
12956
|
createdAt: tx.status.confirmed ? new Date(tx.status.block_time * 1e3) : /* @__PURE__ */ new Date(0),
|
|
12310
12957
|
script: scriptHex
|
|
@@ -12360,9 +13007,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12360
13007
|
async getBoardingTapscripts(allowedSigners) {
|
|
12361
13008
|
const byScript = /* @__PURE__ */ new Map();
|
|
12362
13009
|
const add = (s) => byScript.set(base.hex.encode(s.pkScript), s);
|
|
12363
|
-
const boardingCsv = this.boardingTapscript.options.csvTimelock ??
|
|
13010
|
+
const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkG53HASDV_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
12364
13011
|
add(
|
|
12365
|
-
new
|
|
13012
|
+
new chunkG53HASDV_cjs.DefaultVtxo.Script({
|
|
12366
13013
|
pubKey: await this.identity.xOnlyPublicKey(),
|
|
12367
13014
|
serverPubKey: this.boardingTapscript.options.serverPubKey,
|
|
12368
13015
|
csvTimelock: boardingCsv
|
|
@@ -12377,7 +13024,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12377
13024
|
for (const c of boardingContracts) {
|
|
12378
13025
|
if (!allowed.has(toXOnlySignerHex(c.params.serverPubKey))) continue;
|
|
12379
13026
|
try {
|
|
12380
|
-
add(
|
|
13027
|
+
add(chunkG53HASDV_cjs.BoardingContractHandler.createScript(c.params));
|
|
12381
13028
|
} catch (e) {
|
|
12382
13029
|
console.warn("Skipping malformed boarding contract", c.script, e);
|
|
12383
13030
|
}
|
|
@@ -12415,7 +13062,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12415
13062
|
// Per-row CSV delay decoded from THIS tapscript's exit leaf —
|
|
12416
13063
|
// not the wallet's current boarding timelock, which a signer
|
|
12417
13064
|
// rotation may have changed.
|
|
12418
|
-
csvTimelock:
|
|
13065
|
+
csvTimelock: chunkOH2XLTXE_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
|
|
12419
13066
|
coins: utxos
|
|
12420
13067
|
});
|
|
12421
13068
|
}
|
|
@@ -12548,7 +13195,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12548
13195
|
/** Fetch Arkade transaction ids that are still pending final settlement. */
|
|
12549
13196
|
async fetchPendingTxs() {
|
|
12550
13197
|
const scripts = await this.getWalletScripts();
|
|
12551
|
-
const vtxos = await
|
|
13198
|
+
const vtxos = await chunkOH2XLTXE_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
|
|
12552
13199
|
return vtxos.filter(
|
|
12553
13200
|
(vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
|
|
12554
13201
|
).map((_) => _.arkTxId);
|
|
@@ -12579,7 +13226,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12579
13226
|
});
|
|
12580
13227
|
for (const contract of contracts) {
|
|
12581
13228
|
if (map.has(contract.script)) continue;
|
|
12582
|
-
const handler =
|
|
13229
|
+
const handler = chunkG53HASDV_cjs.contractHandlers.get(contract.type);
|
|
12583
13230
|
if (handler) {
|
|
12584
13231
|
const script = handler.createScript(contract.params);
|
|
12585
13232
|
map.set(contract.script, script);
|
|
@@ -12691,7 +13338,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12691
13338
|
}
|
|
12692
13339
|
});
|
|
12693
13340
|
const baselinePubkey = await this.identity.xOnlyPublicKey();
|
|
12694
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
13341
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkG53HASDV_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
12695
13342
|
const baselineSigners = [
|
|
12696
13343
|
this.offchainTapscript.options.serverPubKey,
|
|
12697
13344
|
...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
|
|
@@ -12699,8 +13346,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12699
13346
|
const seenBaselineScripts = /* @__PURE__ */ new Set();
|
|
12700
13347
|
for (const serverPubKey of baselineSigners) {
|
|
12701
13348
|
for (const csvTimelock of this.walletContractTimelocks) {
|
|
12702
|
-
const csvTimelockStr =
|
|
12703
|
-
const defaultScript = new
|
|
13349
|
+
const csvTimelockStr = chunkOH2XLTXE_cjs.timelockToSequence(csvTimelock).toString();
|
|
13350
|
+
const defaultScript = new chunkG53HASDV_cjs.DefaultVtxo.Script({
|
|
12704
13351
|
pubKey: baselinePubkey,
|
|
12705
13352
|
serverPubKey,
|
|
12706
13353
|
csvTimelock
|
|
@@ -12721,7 +13368,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12721
13368
|
});
|
|
12722
13369
|
}
|
|
12723
13370
|
if (delegatePubKey) {
|
|
12724
|
-
const delegateScript = new
|
|
13371
|
+
const delegateScript = new chunkG53HASDV_cjs.DelegateVtxo.Script({
|
|
12725
13372
|
pubKey: baselinePubkey,
|
|
12726
13373
|
serverPubKey,
|
|
12727
13374
|
delegatePubKey,
|
|
@@ -12745,9 +13392,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12745
13392
|
}
|
|
12746
13393
|
}
|
|
12747
13394
|
}
|
|
12748
|
-
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ??
|
|
13395
|
+
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkG53HASDV_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
12749
13396
|
for (const serverPubKey of baselineSigners) {
|
|
12750
|
-
const baselineBoarding = new
|
|
13397
|
+
const baselineBoarding = new chunkG53HASDV_cjs.DefaultVtxo.Script({
|
|
12751
13398
|
pubKey: baselinePubkey,
|
|
12752
13399
|
serverPubKey,
|
|
12753
13400
|
csvTimelock: boardingCsvTimelock
|
|
@@ -12760,7 +13407,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12760
13407
|
params: {
|
|
12761
13408
|
pubKey: base.hex.encode(baselineBoarding.options.pubKey),
|
|
12762
13409
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
12763
|
-
csvTimelock:
|
|
13410
|
+
csvTimelock: chunkOH2XLTXE_cjs.timelockToSequence(boardingCsvTimelock).toString()
|
|
12764
13411
|
},
|
|
12765
13412
|
script: boardingScriptHex,
|
|
12766
13413
|
address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
|
|
@@ -12939,7 +13586,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12939
13586
|
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
12940
13587
|
deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
|
|
12941
13588
|
csvTimelocks: this.walletContractTimelocks,
|
|
12942
|
-
delegatePubKey: this.offchainTapscript instanceof
|
|
13589
|
+
delegatePubKey: this.offchainTapscript instanceof chunkG53HASDV_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
|
|
12943
13590
|
};
|
|
12944
13591
|
}
|
|
12945
13592
|
_signerRouter;
|
|
@@ -13033,24 +13680,24 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13033
13680
|
const manager = await this.getContractManager();
|
|
13034
13681
|
const descriptor = await manager.getNextSigningDescriptor();
|
|
13035
13682
|
if (!descriptor) return this.getBoardingAddress();
|
|
13036
|
-
const pubKey =
|
|
13037
|
-
const newBoarding = new
|
|
13683
|
+
const pubKey = chunkG53HASDV_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
13684
|
+
const newBoarding = new chunkG53HASDV_cjs.DefaultVtxo.Script({
|
|
13038
13685
|
...this._boardingTapscript.options,
|
|
13039
13686
|
pubKey
|
|
13040
13687
|
});
|
|
13041
|
-
const csvTimelock = newBoarding.options.csvTimelock ??
|
|
13688
|
+
const csvTimelock = newBoarding.options.csvTimelock ?? chunkG53HASDV_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
13042
13689
|
await manager.createContract({
|
|
13043
13690
|
type: "boarding",
|
|
13044
13691
|
params: {
|
|
13045
13692
|
pubKey: base.hex.encode(pubKey),
|
|
13046
13693
|
serverPubKey: base.hex.encode(newBoarding.options.serverPubKey),
|
|
13047
|
-
csvTimelock:
|
|
13694
|
+
csvTimelock: chunkOH2XLTXE_cjs.timelockToSequence(csvTimelock).toString()
|
|
13048
13695
|
},
|
|
13049
13696
|
script: base.hex.encode(newBoarding.pkScript),
|
|
13050
13697
|
address: newBoarding.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
13051
13698
|
state: "active",
|
|
13052
13699
|
metadata: {
|
|
13053
|
-
source:
|
|
13700
|
+
source: chunkG53HASDV_cjs.WALLET_RECEIVE_SOURCE,
|
|
13054
13701
|
signingDescriptor: descriptor
|
|
13055
13702
|
}
|
|
13056
13703
|
});
|
|
@@ -13071,15 +13718,24 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13071
13718
|
return provider.getCurrentSigningDescriptor();
|
|
13072
13719
|
}
|
|
13073
13720
|
/**
|
|
13074
|
-
* @see
|
|
13721
|
+
* @see HDAllocationCapable.getNextSigningDescriptor
|
|
13722
|
+
*
|
|
13723
|
+
* Every `Wallet` answers — this is where the wallet's key-provisioning
|
|
13724
|
+
* policy lives, so consumers never have to branch on wallet shape:
|
|
13725
|
+
* - HD: allocate a fresh index through the contract manager (which owns
|
|
13726
|
+
* cross-context serialization and the look-ahead band).
|
|
13727
|
+
* - custom provider: whatever the provider allocates.
|
|
13728
|
+
* - static / `auto`: the identity key as a bare `tr(pubkey)` descriptor —
|
|
13729
|
+
* the same answer every call, because that IS the static policy.
|
|
13075
13730
|
*/
|
|
13076
13731
|
async getNextSigningDescriptor() {
|
|
13077
|
-
|
|
13078
|
-
|
|
13079
|
-
|
|
13732
|
+
if (this._descriptorProvider instanceof HDDescriptorProvider) {
|
|
13733
|
+
return (await this.getContractManager()).getNextSigningDescriptor();
|
|
13734
|
+
}
|
|
13735
|
+
return chunkG53HASDV_cjs.identityDescriptor(this.identity);
|
|
13080
13736
|
}
|
|
13081
13737
|
/**
|
|
13082
|
-
* @see
|
|
13738
|
+
* @see HDAllocationCapable.advanceSigningDescriptorWatermark
|
|
13083
13739
|
*/
|
|
13084
13740
|
async advanceSigningDescriptorWatermark(descriptor) {
|
|
13085
13741
|
const provider = this._descriptorProvider;
|
|
@@ -13132,13 +13788,16 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13132
13788
|
}
|
|
13133
13789
|
/**
|
|
13134
13790
|
* @see HDWalletCapable.signerForDescriptor
|
|
13791
|
+
*
|
|
13792
|
+
* Fail-loud contract: the returned identity is always the descriptor's
|
|
13793
|
+
* own key. A descriptor this wallet cannot sign for throws
|
|
13794
|
+
* {@link ForeignDescriptorError} instead of silently substituting the
|
|
13795
|
+
* baseline identity — that identity would sign happily with the wrong
|
|
13796
|
+
* key, and the failure would only surface as a rejected transaction or a
|
|
13797
|
+
* dead script, far from the call that caused it.
|
|
13135
13798
|
*/
|
|
13136
13799
|
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 });
|
|
13800
|
+
return resolveDescriptorSigner(descriptor, this.identity, this._descriptorProvider);
|
|
13142
13801
|
}
|
|
13143
13802
|
/**
|
|
13144
13803
|
* Mid-session server-signer rotation (plan §4). When arkd rotates its
|
|
@@ -13198,21 +13857,21 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13198
13857
|
const [currentBoardingRow] = await manager.getContracts({
|
|
13199
13858
|
script: currentBoardingScript
|
|
13200
13859
|
});
|
|
13201
|
-
const newOffchain = this.offchainTapscript instanceof
|
|
13860
|
+
const newOffchain = this.offchainTapscript instanceof chunkG53HASDV_cjs.DelegateVtxo.Script ? new chunkG53HASDV_cjs.DelegateVtxo.Script({
|
|
13202
13861
|
...this.offchainTapscript.options,
|
|
13203
13862
|
serverPubKey: xonly
|
|
13204
|
-
}) : new
|
|
13863
|
+
}) : new chunkG53HASDV_cjs.DefaultVtxo.Script({
|
|
13205
13864
|
...this.offchainTapscript.options,
|
|
13206
13865
|
serverPubKey: xonly
|
|
13207
13866
|
});
|
|
13208
|
-
const newBoarding = new
|
|
13867
|
+
const newBoarding = new chunkG53HASDV_cjs.DefaultVtxo.Script({
|
|
13209
13868
|
...this._boardingTapscript.options,
|
|
13210
13869
|
serverPubKey: xonly
|
|
13211
13870
|
});
|
|
13212
|
-
const offchainCsv =
|
|
13871
|
+
const offchainCsv = chunkOH2XLTXE_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
|
|
13213
13872
|
const newOffchainScript = base.hex.encode(newOffchain.pkScript);
|
|
13214
13873
|
const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
|
|
13215
|
-
if (newOffchain instanceof
|
|
13874
|
+
if (newOffchain instanceof chunkG53HASDV_cjs.DelegateVtxo.Script) {
|
|
13216
13875
|
await manager.createContract({
|
|
13217
13876
|
type: "delegate",
|
|
13218
13877
|
params: {
|
|
@@ -13240,13 +13899,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13240
13899
|
metadata: currentOffchainRow?.metadata
|
|
13241
13900
|
});
|
|
13242
13901
|
}
|
|
13243
|
-
const boardingCsv = newBoarding.options.csvTimelock ??
|
|
13902
|
+
const boardingCsv = newBoarding.options.csvTimelock ?? chunkG53HASDV_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
13244
13903
|
await manager.createContract({
|
|
13245
13904
|
type: "boarding",
|
|
13246
13905
|
params: {
|
|
13247
13906
|
pubKey: base.hex.encode(newBoarding.options.pubKey),
|
|
13248
13907
|
serverPubKey: base.hex.encode(xonly),
|
|
13249
|
-
csvTimelock:
|
|
13908
|
+
csvTimelock: chunkOH2XLTXE_cjs.timelockToSequence(boardingCsv).toString()
|
|
13250
13909
|
},
|
|
13251
13910
|
script: base.hex.encode(newBoarding.pkScript),
|
|
13252
13911
|
address: newBoarding.address(this.network.hrp, xonly).encode(),
|
|
@@ -13279,14 +13938,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13279
13938
|
_restoreInFlight;
|
|
13280
13939
|
_addPendingSpends(inputs) {
|
|
13281
13940
|
for (const input of inputs) {
|
|
13282
|
-
if (
|
|
13941
|
+
if (chunkOH2XLTXE_cjs.isVirtualCoin(input)) {
|
|
13283
13942
|
this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
|
|
13284
13943
|
}
|
|
13285
13944
|
}
|
|
13286
13945
|
}
|
|
13287
13946
|
_removePendingSpends(inputs) {
|
|
13288
13947
|
for (const input of inputs) {
|
|
13289
|
-
if (
|
|
13948
|
+
if (chunkOH2XLTXE_cjs.isVirtualCoin(input)) {
|
|
13290
13949
|
this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
|
|
13291
13950
|
}
|
|
13292
13951
|
}
|
|
@@ -13344,9 +14003,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13344
14003
|
const manager = await this.getContractManager();
|
|
13345
14004
|
const provider = this._descriptorProvider;
|
|
13346
14005
|
const hd = provider instanceof HDDescriptorProvider;
|
|
13347
|
-
const staticDescriptor = hd ? void 0 :
|
|
14006
|
+
const staticDescriptor = hd ? void 0 : await chunkG53HASDV_cjs.identityDescriptor(this.identity);
|
|
13348
14007
|
const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
|
|
13349
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
14008
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkG53HASDV_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
13350
14009
|
const arkInfo = await this.arkProvider.getInfo();
|
|
13351
14010
|
const currentSignerPubKey = toXOnlyPubKey(base.hex.decode(arkInfo.signerPubkey));
|
|
13352
14011
|
const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
|
|
@@ -13365,7 +14024,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13365
14024
|
csvTimelocks: this.walletContractTimelocks,
|
|
13366
14025
|
// Boarding-exit CSV so the boarding handler can build its
|
|
13367
14026
|
// candidate script (distinct from the unilateral-exit matrix).
|
|
13368
|
-
boardingTimelock: this.boardingTapscript.options.csvTimelock ??
|
|
14027
|
+
boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkG53HASDV_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
|
|
13369
14028
|
delegatePubKey
|
|
13370
14029
|
};
|
|
13371
14030
|
const result = await manager.scanContracts({
|
|
@@ -13628,7 +14287,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13628
14287
|
inputs: params.selectedVtxos,
|
|
13629
14288
|
changeAmount: BigInt(changeAmount)
|
|
13630
14289
|
};
|
|
13631
|
-
const outputAddress =
|
|
14290
|
+
const outputAddress = chunkOH2XLTXE_cjs.ArkAddress.decode(params.address);
|
|
13632
14291
|
assertRecipientArkAddress(
|
|
13633
14292
|
params.address,
|
|
13634
14293
|
outputAddress,
|
|
@@ -13694,13 +14353,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13694
14353
|
void this.logUngatedInputs("settle({ inputs })", params.inputs);
|
|
13695
14354
|
}
|
|
13696
14355
|
const offchainAddress = await this.getAddress();
|
|
13697
|
-
const offchainPkScript =
|
|
14356
|
+
const offchainPkScript = chunkOH2XLTXE_cjs.ArkAddress.decode(offchainAddress).pkScript;
|
|
13698
14357
|
const offchainOutputScript = base.hex.encode(offchainPkScript);
|
|
13699
14358
|
if (!params) {
|
|
13700
14359
|
const { fees, vtxoMaxAmount } = await this.arkProvider.getInfo();
|
|
13701
14360
|
const estimator = new Estimator(fees.intentFee);
|
|
13702
14361
|
let amount = 0;
|
|
13703
|
-
const exitScript =
|
|
14362
|
+
const exitScript = chunkOH2XLTXE_cjs.CSVMultisigTapscript.decode(
|
|
13704
14363
|
base.hex.decode(this.boardingTapscript.exitScript)
|
|
13705
14364
|
);
|
|
13706
14365
|
const boardingTimelock = exitScript.params.timelock;
|
|
@@ -13729,7 +14388,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13729
14388
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
13730
14389
|
break;
|
|
13731
14390
|
}
|
|
13732
|
-
const inputFee = estimator.evalOffchainInput(
|
|
14391
|
+
const inputFee = estimator.evalOffchainInput(chunkOH2XLTXE_cjs.toOffchainInputFeeParams(vtxo));
|
|
13733
14392
|
if (inputFee.satoshis >= vtxo.value) {
|
|
13734
14393
|
continue;
|
|
13735
14394
|
}
|
|
@@ -13776,7 +14435,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13776
14435
|
let script;
|
|
13777
14436
|
let arkAddress;
|
|
13778
14437
|
try {
|
|
13779
|
-
arkAddress =
|
|
14438
|
+
arkAddress = chunkOH2XLTXE_cjs.ArkAddress.decode(output.address);
|
|
13780
14439
|
} catch {
|
|
13781
14440
|
arkAddress = void 0;
|
|
13782
14441
|
}
|
|
@@ -13866,7 +14525,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13866
14525
|
const abortController = new AbortController();
|
|
13867
14526
|
let stream;
|
|
13868
14527
|
let committedTxid;
|
|
13869
|
-
const settleInputVtxos = params.inputs.filter(
|
|
14528
|
+
const settleInputVtxos = params.inputs.filter(chunkOH2XLTXE_cjs.isVirtualCoin);
|
|
13870
14529
|
const contractManager = await this.getContractManager();
|
|
13871
14530
|
await contractManager.assertAnnotatable(settleInputVtxos);
|
|
13872
14531
|
await contractManager.assertSpendableNow?.(
|
|
@@ -13975,7 +14634,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13975
14634
|
async maybeRotateBoardingAfterBoard(inputs) {
|
|
13976
14635
|
if (!this._descriptorProvider) return;
|
|
13977
14636
|
const consumedBoarding = inputs.some(
|
|
13978
|
-
(input) => typeof input !== "string" && !
|
|
14637
|
+
(input) => typeof input !== "string" && !chunkOH2XLTXE_cjs.isVirtualCoin(input)
|
|
13979
14638
|
);
|
|
13980
14639
|
if (!consumedBoarding) return;
|
|
13981
14640
|
try {
|
|
@@ -13999,7 +14658,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13999
14658
|
let connectorIndex = 0;
|
|
14000
14659
|
const connectorsLeaves = connectorsGraph?.leaves() || [];
|
|
14001
14660
|
for (const input of inputs) {
|
|
14002
|
-
if (!
|
|
14661
|
+
if (!chunkOH2XLTXE_cjs.isVirtualCoin(input)) {
|
|
14003
14662
|
for (let i = 0; i < settlementPsbt.inputsLength; i++) {
|
|
14004
14663
|
const settlementInput = settlementPsbt.getInput(i);
|
|
14005
14664
|
if (!settlementInput.txid || settlementInput.index === void 0) {
|
|
@@ -14030,7 +14689,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14030
14689
|
}
|
|
14031
14690
|
continue;
|
|
14032
14691
|
}
|
|
14033
|
-
if (
|
|
14692
|
+
if (chunkOH2XLTXE_cjs.canRecoverOnchain(input, { timestamp: /* @__PURE__ */ new Date() }) || isSubdust({ value: input.value }, this.dustAmount)) {
|
|
14034
14693
|
continue;
|
|
14035
14694
|
}
|
|
14036
14695
|
if (connectorsLeaves.length === 0) {
|
|
@@ -14058,7 +14717,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14058
14717
|
index: input.vout,
|
|
14059
14718
|
witnessUtxo: {
|
|
14060
14719
|
amount: BigInt(input.value),
|
|
14061
|
-
script:
|
|
14720
|
+
script: chunkOH2XLTXE_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
14062
14721
|
},
|
|
14063
14722
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
14064
14723
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -14077,7 +14736,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14077
14736
|
forfeitTx = await this._signerRouter.sign(forfeitTx, [
|
|
14078
14737
|
{
|
|
14079
14738
|
index: 0,
|
|
14080
|
-
lookupScript:
|
|
14739
|
+
lookupScript: chunkOH2XLTXE_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
14081
14740
|
}
|
|
14082
14741
|
]);
|
|
14083
14742
|
signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
|
|
@@ -14135,7 +14794,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14135
14794
|
resolveBatchExpiryPolicy(this.network, this.batchExpiryPolicy)
|
|
14136
14795
|
);
|
|
14137
14796
|
await this.arkProvider.confirmRegistration(intentId);
|
|
14138
|
-
const sweepTapscript =
|
|
14797
|
+
const sweepTapscript = chunkOH2XLTXE_cjs.CSVMultisigTapscript.encode({
|
|
14139
14798
|
timelock,
|
|
14140
14799
|
pubkeys: [this.forfeitPubkey]
|
|
14141
14800
|
}).script;
|
|
@@ -14241,9 +14900,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14241
14900
|
...existing ?? {},
|
|
14242
14901
|
intentTxId,
|
|
14243
14902
|
registerProof: intent.proof,
|
|
14244
|
-
registerProofMessage:
|
|
14903
|
+
registerProofMessage: chunkOH2XLTXE_cjs.Intent.encodeMessage(intent.message),
|
|
14245
14904
|
deleteProof: deleteIntent.proof,
|
|
14246
|
-
deleteProofMessage:
|
|
14905
|
+
deleteProofMessage: chunkOH2XLTXE_cjs.Intent.encodeMessage(deleteIntent.message),
|
|
14247
14906
|
intentVtxos: inputs.map((i) => ({
|
|
14248
14907
|
txid: i.txid,
|
|
14249
14908
|
vout: i.vout
|
|
@@ -14275,7 +14934,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14275
14934
|
try {
|
|
14276
14935
|
return await this.arkProvider.registerIntent(intent);
|
|
14277
14936
|
} catch (error) {
|
|
14278
|
-
if (error instanceof
|
|
14937
|
+
if (error instanceof chunkOH2XLTXE_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
|
|
14279
14938
|
const deleteIntent = await this.makeDeleteIntentSignature(inputs);
|
|
14280
14939
|
await this.arkProvider.deleteIntent(deleteIntent);
|
|
14281
14940
|
return this.arkProvider.registerIntent(intent);
|
|
@@ -14291,7 +14950,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14291
14950
|
expire_at: 0,
|
|
14292
14951
|
cosigners_public_keys: cosignerPubKeys
|
|
14293
14952
|
};
|
|
14294
|
-
const proof =
|
|
14953
|
+
const proof = chunkOH2XLTXE_cjs.Intent.create(message, coins, outputs);
|
|
14295
14954
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
14296
14955
|
return {
|
|
14297
14956
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -14303,7 +14962,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14303
14962
|
type: "delete",
|
|
14304
14963
|
expire_at: 0
|
|
14305
14964
|
};
|
|
14306
|
-
const proof =
|
|
14965
|
+
const proof = chunkOH2XLTXE_cjs.Intent.create(message, coins, []);
|
|
14307
14966
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
14308
14967
|
return {
|
|
14309
14968
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -14315,7 +14974,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14315
14974
|
type: "get-pending-tx",
|
|
14316
14975
|
expire_at: 0
|
|
14317
14976
|
};
|
|
14318
|
-
const proof =
|
|
14977
|
+
const proof = chunkOH2XLTXE_cjs.Intent.create(message, coins, []);
|
|
14319
14978
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
14320
14979
|
return {
|
|
14321
14980
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -14336,7 +14995,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14336
14995
|
if (!vtxos || vtxos.length === 0) {
|
|
14337
14996
|
const scriptMap = await this.getScriptMap();
|
|
14338
14997
|
const allExtended = [];
|
|
14339
|
-
const fetchedVtxos = await
|
|
14998
|
+
const fetchedVtxos = await chunkOH2XLTXE_cjs.getAllNormalizedVtxos(this.indexerProvider, [
|
|
14340
14999
|
...scriptMap.keys()
|
|
14341
15000
|
]);
|
|
14342
15001
|
for (const vtxo of fetchedVtxos) {
|
|
@@ -14450,11 +15109,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14450
15109
|
* against the current key alone would leave it pending forever.
|
|
14451
15110
|
*/
|
|
14452
15111
|
checkpointUnrollCandidates(info) {
|
|
14453
|
-
const current =
|
|
15112
|
+
const current = chunkOH2XLTXE_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
14454
15113
|
const candidates = [this._serverUnrollScript, current];
|
|
14455
15114
|
for (const deprecated of signerSetFromInfo(info).deprecated.keys()) {
|
|
14456
15115
|
candidates.push(
|
|
14457
|
-
|
|
15116
|
+
chunkOH2XLTXE_cjs.CSVMultisigTapscript.encode({
|
|
14458
15117
|
...current.params,
|
|
14459
15118
|
pubkeys: [base.hex.decode(deprecated)]
|
|
14460
15119
|
})
|
|
@@ -14545,7 +15204,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14545
15204
|
if (vtxos.length === 0) {
|
|
14546
15205
|
throw new Error("No VTXOs found for this arkadeCash");
|
|
14547
15206
|
}
|
|
14548
|
-
const myPkScript =
|
|
15207
|
+
const myPkScript = chunkOH2XLTXE_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
|
|
14549
15208
|
let { spendable, unclaimed } = this.classifyCashVtxos(vtxos);
|
|
14550
15209
|
let swept = 0;
|
|
14551
15210
|
const drainable = vtxos.filter((vtxo) => !isSubdust(vtxo, this.dustAmount));
|
|
@@ -14619,7 +15278,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14619
15278
|
const spendable = [];
|
|
14620
15279
|
const unclaimed = [];
|
|
14621
15280
|
for (const vtxo of vtxos) {
|
|
14622
|
-
if (
|
|
15281
|
+
if (chunkOH2XLTXE_cjs.hasTerminalSpend(vtxo)) {
|
|
14623
15282
|
unclaimed.push(cashReport(vtxo, "already-spent"));
|
|
14624
15283
|
} else if (isSubdust(vtxo, this.dustAmount)) {
|
|
14625
15284
|
unclaimed.push(cashReport(vtxo, "subdust"));
|
|
@@ -14639,7 +15298,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14639
15298
|
const all = [];
|
|
14640
15299
|
const seen = /* @__PURE__ */ new Set();
|
|
14641
15300
|
for (let pageIndex = 0; ; pageIndex++) {
|
|
14642
|
-
const { vtxos, page } = await
|
|
15301
|
+
const { vtxos, page } = await chunkOH2XLTXE_cjs.getNormalizedVtxos(this.indexerProvider, {
|
|
14643
15302
|
scripts,
|
|
14644
15303
|
pageIndex,
|
|
14645
15304
|
pageSize
|
|
@@ -14686,7 +15345,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14686
15345
|
for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
|
|
14687
15346
|
const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
|
|
14688
15347
|
const message = { type: "get-pending-tx", expire_at: 0 };
|
|
14689
|
-
const proof =
|
|
15348
|
+
const proof = chunkOH2XLTXE_cjs.Intent.create(message, batch, []);
|
|
14690
15349
|
const signedProof = await identity.sign(
|
|
14691
15350
|
proof,
|
|
14692
15351
|
Array.from({ length: batch.length + 1 }, (_, j) => j)
|
|
@@ -14756,10 +15415,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14756
15415
|
return total;
|
|
14757
15416
|
}
|
|
14758
15417
|
/**
|
|
14759
|
-
* Send BTC and/or assets to one or more recipients
|
|
15418
|
+
* Send BTC and/or assets to one or more recipients, passed either as
|
|
15419
|
+
* variadic `Recipient`s or as a single `SendParams` object — the latter
|
|
15420
|
+
* also carries the virtual outputs to spend.
|
|
14760
15421
|
*
|
|
14761
|
-
* @param args - Recipients
|
|
15422
|
+
* @param args - Recipients, or a `SendParams` object
|
|
14762
15423
|
* @returns Promise resolving to the Arkade transaction ID
|
|
15424
|
+
* @see SendParams
|
|
14763
15425
|
*
|
|
14764
15426
|
* @example
|
|
14765
15427
|
* ```typescript
|
|
@@ -14768,15 +15430,28 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14768
15430
|
* amount: 1000, // (optional, default to dust) btc amount to send to the output
|
|
14769
15431
|
* assets: [{ assetId: 'abc123...', amount: 50n }] // (optional) list of assets to send
|
|
14770
15432
|
* });
|
|
15433
|
+
*
|
|
15434
|
+
* // choosing the inputs as well as the outputs
|
|
15435
|
+
* const txid = await wallet.send({
|
|
15436
|
+
* recipients: [{ address: 'ark1q...', amount: 1000 }],
|
|
15437
|
+
* selectedVtxos: mine, // spent as given, nothing added
|
|
15438
|
+
* });
|
|
14771
15439
|
* ```
|
|
14772
15440
|
*/
|
|
14773
15441
|
async send(...args) {
|
|
14774
|
-
|
|
15442
|
+
const params = asSendParams(args);
|
|
15443
|
+
return this._withTxLock(() => this._sendImpl(params));
|
|
14775
15444
|
}
|
|
14776
|
-
async _sendImpl(
|
|
15445
|
+
async _sendImpl({ recipients: args, selectedVtxos }) {
|
|
14777
15446
|
if (args.length === 0) {
|
|
14778
15447
|
throw new Error("At least one receiver is required");
|
|
14779
15448
|
}
|
|
15449
|
+
if (selectedVtxos && selectedVtxos.length === 0) {
|
|
15450
|
+
throw new Error("send({ selectedVtxos }): no inputs");
|
|
15451
|
+
}
|
|
15452
|
+
if (selectedVtxos) {
|
|
15453
|
+
void this.logUngatedInputs("send({ selectedVtxos })", selectedVtxos);
|
|
15454
|
+
}
|
|
14780
15455
|
const offchainTapscript = this.offchainTapscript;
|
|
14781
15456
|
const serverPubKey = this.arkServerPublicKey;
|
|
14782
15457
|
const serverUnrollScript = this.serverUnrollScript;
|
|
@@ -14787,84 +15462,123 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14787
15462
|
Number(this.dustAmount),
|
|
14788
15463
|
this.recipientAddressContext(serverPubKey)
|
|
14789
15464
|
);
|
|
14790
|
-
|
|
14791
|
-
|
|
14792
|
-
|
|
15465
|
+
let virtualCoins = [];
|
|
15466
|
+
if (!selectedVtxos) {
|
|
15467
|
+
virtualCoins = await this.getSpendableVtxos({
|
|
15468
|
+
withRecoverable: false
|
|
15469
|
+
});
|
|
15470
|
+
}
|
|
14793
15471
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
14794
|
-
let selectedCoins = [];
|
|
15472
|
+
let selectedCoins = selectedVtxos ? [...selectedVtxos] : [];
|
|
14795
15473
|
let btcAmountToSelect = 0;
|
|
14796
15474
|
for (const recipient of recipients) {
|
|
14797
15475
|
btcAmountToSelect += Math.max(recipient.amount, Number(this.dustAmount));
|
|
14798
15476
|
}
|
|
14799
|
-
|
|
14800
|
-
|
|
14801
|
-
|
|
15477
|
+
if (selectedVtxos) {
|
|
15478
|
+
for (const coin of selectedCoins) {
|
|
15479
|
+
for (const asset of coin.assets ?? []) {
|
|
15480
|
+
const existing = assetChanges.get(asset.assetId) ?? 0n;
|
|
15481
|
+
assetChanges.set(asset.assetId, existing + asset.amount);
|
|
15482
|
+
}
|
|
14802
15483
|
}
|
|
14803
|
-
for (const
|
|
14804
|
-
|
|
14805
|
-
|
|
14806
|
-
|
|
14807
|
-
|
|
14808
|
-
|
|
14809
|
-
|
|
15484
|
+
for (const recipient of recipients) {
|
|
15485
|
+
for (const asset of recipient.assets) {
|
|
15486
|
+
const remaining = (assetChanges.get(asset.assetId) ?? 0n) - asset.amount;
|
|
15487
|
+
if (remaining < 0n) {
|
|
15488
|
+
throw new Error(
|
|
15489
|
+
`send({ selectedVtxos }): inputs are short ${-remaining} of asset ${asset.assetId}`
|
|
15490
|
+
);
|
|
15491
|
+
}
|
|
15492
|
+
if (remaining === 0n) {
|
|
15493
|
+
assetChanges.delete(asset.assetId);
|
|
15494
|
+
} else {
|
|
15495
|
+
assetChanges.set(asset.assetId, remaining);
|
|
14810
15496
|
}
|
|
15497
|
+
}
|
|
15498
|
+
}
|
|
15499
|
+
} else {
|
|
15500
|
+
for (const recipient of recipients) {
|
|
15501
|
+
if (!recipient.assets) {
|
|
14811
15502
|
continue;
|
|
14812
15503
|
}
|
|
14813
|
-
|
|
14814
|
-
amountToSelect
|
|
14815
|
-
assetChanges.
|
|
15504
|
+
for (const receiverAsset of recipient.assets) {
|
|
15505
|
+
let amountToSelect = receiverAsset.amount;
|
|
15506
|
+
const existingChange = assetChanges.get(receiverAsset.assetId) ?? 0n;
|
|
15507
|
+
if (existingChange >= amountToSelect) {
|
|
15508
|
+
assetChanges.set(receiverAsset.assetId, existingChange - amountToSelect);
|
|
15509
|
+
if (assetChanges.get(receiverAsset.assetId) === 0n) {
|
|
15510
|
+
assetChanges.delete(receiverAsset.assetId);
|
|
15511
|
+
}
|
|
15512
|
+
continue;
|
|
15513
|
+
}
|
|
15514
|
+
if (existingChange > 0n) {
|
|
15515
|
+
amountToSelect -= existingChange;
|
|
15516
|
+
assetChanges.delete(receiverAsset.assetId);
|
|
15517
|
+
}
|
|
15518
|
+
const availableCoins = virtualCoins.filter(
|
|
15519
|
+
(c) => !selectedCoins.find((sc) => sc.txid === c.txid && sc.vout === c.vout)
|
|
15520
|
+
);
|
|
15521
|
+
const { selected, totalAssetAmount } = selectCoinsWithAsset(
|
|
15522
|
+
availableCoins,
|
|
15523
|
+
receiverAsset.assetId,
|
|
15524
|
+
amountToSelect
|
|
15525
|
+
);
|
|
15526
|
+
for (const coin of selected) {
|
|
15527
|
+
selectedCoins.push(coin);
|
|
15528
|
+
btcAmountToSelect -= coin.value;
|
|
15529
|
+
if (coin.assets) {
|
|
15530
|
+
for (const a of coin.assets) {
|
|
15531
|
+
if (a.assetId === receiverAsset.assetId) {
|
|
15532
|
+
continue;
|
|
15533
|
+
}
|
|
15534
|
+
const existing = assetChanges.get(a.assetId) ?? 0n;
|
|
15535
|
+
assetChanges.set(a.assetId, existing + a.amount);
|
|
15536
|
+
}
|
|
15537
|
+
}
|
|
15538
|
+
}
|
|
15539
|
+
const assetChangeAmount = totalAssetAmount - amountToSelect;
|
|
15540
|
+
if (assetChangeAmount > 0n) {
|
|
15541
|
+
const existing = assetChanges.get(receiverAsset.assetId) ?? 0n;
|
|
15542
|
+
assetChanges.set(receiverAsset.assetId, existing + assetChangeAmount);
|
|
15543
|
+
}
|
|
14816
15544
|
}
|
|
15545
|
+
}
|
|
15546
|
+
if (btcAmountToSelect > 0) {
|
|
14817
15547
|
const availableCoins = virtualCoins.filter(
|
|
14818
15548
|
(c) => !selectedCoins.find((sc) => sc.txid === c.txid && sc.vout === c.vout)
|
|
14819
15549
|
);
|
|
14820
|
-
const {
|
|
14821
|
-
|
|
14822
|
-
receiverAsset.assetId,
|
|
14823
|
-
amountToSelect
|
|
14824
|
-
);
|
|
14825
|
-
for (const coin of selected) {
|
|
14826
|
-
selectedCoins.push(coin);
|
|
14827
|
-
btcAmountToSelect -= coin.value;
|
|
15550
|
+
const { inputs: btcCoins } = selectVirtualCoins(availableCoins, btcAmountToSelect);
|
|
15551
|
+
for (const coin of btcCoins) {
|
|
14828
15552
|
if (coin.assets) {
|
|
14829
|
-
for (const
|
|
14830
|
-
|
|
14831
|
-
|
|
14832
|
-
}
|
|
14833
|
-
const existing = assetChanges.get(a.assetId) ?? 0n;
|
|
14834
|
-
assetChanges.set(a.assetId, existing + a.amount);
|
|
15553
|
+
for (const asset of coin.assets) {
|
|
15554
|
+
const existing = assetChanges.get(asset.assetId) ?? 0n;
|
|
15555
|
+
assetChanges.set(asset.assetId, existing + asset.amount);
|
|
14835
15556
|
}
|
|
14836
15557
|
}
|
|
14837
15558
|
}
|
|
14838
|
-
|
|
14839
|
-
if (assetChangeAmount > 0n) {
|
|
14840
|
-
const existing = assetChanges.get(receiverAsset.assetId) ?? 0n;
|
|
14841
|
-
assetChanges.set(receiverAsset.assetId, existing + assetChangeAmount);
|
|
14842
|
-
}
|
|
14843
|
-
}
|
|
14844
|
-
}
|
|
14845
|
-
if (btcAmountToSelect > 0) {
|
|
14846
|
-
const availableCoins = virtualCoins.filter(
|
|
14847
|
-
(c) => !selectedCoins.find((sc) => sc.txid === c.txid && sc.vout === c.vout)
|
|
14848
|
-
);
|
|
14849
|
-
const { inputs: btcCoins } = selectVirtualCoins(availableCoins, btcAmountToSelect);
|
|
14850
|
-
for (const coin of btcCoins) {
|
|
14851
|
-
if (coin.assets) {
|
|
14852
|
-
for (const asset of coin.assets) {
|
|
14853
|
-
const existing = assetChanges.get(asset.assetId) ?? 0n;
|
|
14854
|
-
assetChanges.set(asset.assetId, existing + asset.amount);
|
|
14855
|
-
}
|
|
14856
|
-
}
|
|
15559
|
+
selectedCoins = [...selectedCoins, ...btcCoins];
|
|
14857
15560
|
}
|
|
14858
|
-
selectedCoins = [...selectedCoins, ...btcCoins];
|
|
14859
15561
|
}
|
|
14860
15562
|
let totalBtcSelected = selectedCoins.reduce((sum, c) => sum + c.value, 0);
|
|
14861
15563
|
const outputs = recipients.map((recipient) => ({
|
|
14862
15564
|
script: recipient.script,
|
|
14863
|
-
amount: BigInt(recipient.amount)
|
|
15565
|
+
amount: BigInt(recipient.amount),
|
|
15566
|
+
// Already checked against the recipient address in `validateRecipients`.
|
|
15567
|
+
...recipient.tapTree ? { tapTree: chunkOH2XLTXE_cjs.TapTreeCoder.decode(recipient.tapTree) } : {}
|
|
14864
15568
|
}));
|
|
14865
15569
|
const totalBtcOutput = outputs.reduce((sum, o) => sum + Number(o.amount), 0);
|
|
14866
15570
|
let changeAmount = totalBtcSelected - totalBtcOutput;
|
|
15571
|
+
if (changeAmount < 0) {
|
|
15572
|
+
throw new Error(
|
|
15573
|
+
`send({ selectedVtxos }): inputs total ${totalBtcSelected} sats, outputs need ${totalBtcOutput}`
|
|
15574
|
+
);
|
|
15575
|
+
}
|
|
14867
15576
|
if (assetChanges.size > 0 && changeAmount < Number(this.dustAmount)) {
|
|
15577
|
+
if (selectedVtxos) {
|
|
15578
|
+
throw new Error(
|
|
15579
|
+
`send({ selectedVtxos }): ${changeAmount} sats of change cannot carry ${assetChanges.size} asset change(s), needs ${this.dustAmount}`
|
|
15580
|
+
);
|
|
15581
|
+
}
|
|
14868
15582
|
const availableCoins = virtualCoins.filter(
|
|
14869
15583
|
(c) => !selectedCoins.find((sc) => sc.txid === c.txid && sc.vout === c.vout)
|
|
14870
15584
|
);
|
|
@@ -14994,10 +15708,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14994
15708
|
const serverPubKey = this.arkServerPublicKey;
|
|
14995
15709
|
const serverUnrollScript = this.serverUnrollScript;
|
|
14996
15710
|
const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
|
|
14997
|
-
const normalizedInputs = inputs.map(
|
|
14998
|
-
const at = now ?? await
|
|
15711
|
+
const normalizedInputs = inputs.map(chunkOH2XLTXE_cjs.normalizeVtxo);
|
|
15712
|
+
const at = now ?? await chunkOH2XLTXE_cjs.resolveTimeHeight(this.onchainProvider);
|
|
14999
15713
|
for (const input of normalizedInputs) {
|
|
15000
|
-
if (!
|
|
15714
|
+
if (!chunkOH2XLTXE_cjs.canSpendOffchain(input, at)) {
|
|
15001
15715
|
throw new Error(
|
|
15002
15716
|
`sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
|
|
15003
15717
|
);
|
|
@@ -15067,7 +15781,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15067
15781
|
);
|
|
15068
15782
|
const arkTxJobs = inputs.map((input, index) => ({
|
|
15069
15783
|
index,
|
|
15070
|
-
lookupScript:
|
|
15784
|
+
lookupScript: chunkOH2XLTXE_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
15071
15785
|
}));
|
|
15072
15786
|
const identity = this.identity;
|
|
15073
15787
|
const signer = {
|
|
@@ -15153,14 +15867,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15153
15867
|
const spentBy = checkpointIdByOutpoint.get(`${vtxo.txid}:${vtxo.vout}`);
|
|
15154
15868
|
spentVtxos.push({
|
|
15155
15869
|
...spentFacts,
|
|
15156
|
-
virtualStatus:
|
|
15870
|
+
virtualStatus: chunkOH2XLTXE_cjs.toVirtualStatus(spentFacts),
|
|
15157
15871
|
...spentBy ? { spentBy } : {},
|
|
15158
15872
|
arkTxId: arkTxid
|
|
15159
15873
|
});
|
|
15160
15874
|
for (const id of vtxo.commitmentTxIds) {
|
|
15161
15875
|
commitmentTxIds.add(id);
|
|
15162
15876
|
}
|
|
15163
|
-
const vtxoExpiry =
|
|
15877
|
+
const vtxoExpiry = chunkOH2XLTXE_cjs.toBatchExpiry(vtxo);
|
|
15164
15878
|
if (vtxoExpiry) {
|
|
15165
15879
|
batchExpiry = Math.min(batchExpiry, vtxoExpiry);
|
|
15166
15880
|
}
|
|
@@ -15173,7 +15887,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15173
15887
|
isSwept: false,
|
|
15174
15888
|
isPreconfirmed: true,
|
|
15175
15889
|
commitmentTxIds: Array.from(commitmentTxIds),
|
|
15176
|
-
...
|
|
15890
|
+
...chunkOH2XLTXE_cjs.parseLegacyExpiry(batchExpiry)
|
|
15177
15891
|
};
|
|
15178
15892
|
changeVtxo = {
|
|
15179
15893
|
txid: arkTxid,
|
|
@@ -15185,7 +15899,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15185
15899
|
tapTree: offchainTapscript.encode(),
|
|
15186
15900
|
value: Number(changeAmount),
|
|
15187
15901
|
...changeFacts,
|
|
15188
|
-
virtualStatus:
|
|
15902
|
+
virtualStatus: chunkOH2XLTXE_cjs.toVirtualStatus(changeFacts),
|
|
15189
15903
|
spentBy: "",
|
|
15190
15904
|
status: {
|
|
15191
15905
|
confirmed: false
|
|
@@ -15254,12 +15968,12 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15254
15968
|
const spentVtxos = [];
|
|
15255
15969
|
const inputArkTxIds = /* @__PURE__ */ new Set();
|
|
15256
15970
|
const boardingRemovalsByAddress = /* @__PURE__ */ new Map();
|
|
15257
|
-
const vtxoInputs = inputs.filter(
|
|
15971
|
+
const vtxoInputs = inputs.filter(chunkOH2XLTXE_cjs.isVirtualCoin);
|
|
15258
15972
|
const cm = await this.getContractManager();
|
|
15259
15973
|
const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
|
|
15260
15974
|
const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
|
|
15261
15975
|
for (const input of inputs) {
|
|
15262
|
-
if (
|
|
15976
|
+
if (chunkOH2XLTXE_cjs.isVirtualCoin(input)) {
|
|
15263
15977
|
const outpoint = `${input.txid}:${input.vout}`;
|
|
15264
15978
|
const vtxo = annotatedByKey.get(outpoint);
|
|
15265
15979
|
if (!vtxo) {
|
|
@@ -15271,13 +15985,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15271
15985
|
const settledFacts = { ...vtxo, isSpent: true };
|
|
15272
15986
|
spentVtxos.push({
|
|
15273
15987
|
...settledFacts,
|
|
15274
|
-
virtualStatus:
|
|
15988
|
+
virtualStatus: chunkOH2XLTXE_cjs.toVirtualStatus(settledFacts),
|
|
15275
15989
|
settledBy: commitmentTxid
|
|
15276
15990
|
});
|
|
15277
15991
|
} else {
|
|
15278
15992
|
let sourceAddress;
|
|
15279
15993
|
try {
|
|
15280
|
-
sourceAddress =
|
|
15994
|
+
sourceAddress = chunkOH2XLTXE_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
|
|
15281
15995
|
this.network
|
|
15282
15996
|
);
|
|
15283
15997
|
} catch {
|
|
@@ -15335,9 +16049,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15335
16049
|
}
|
|
15336
16050
|
};
|
|
15337
16051
|
function selectVirtualCoins(coins, targetAmount) {
|
|
15338
|
-
const sortedCoins = coins.map(
|
|
15339
|
-
const expiryA =
|
|
15340
|
-
const expiryB =
|
|
16052
|
+
const sortedCoins = coins.map(chunkOH2XLTXE_cjs.normalizeVtxo).sort((a, b) => {
|
|
16053
|
+
const expiryA = chunkOH2XLTXE_cjs.toBatchExpiry(a) || Number.MAX_SAFE_INTEGER;
|
|
16054
|
+
const expiryB = chunkOH2XLTXE_cjs.toBatchExpiry(b) || Number.MAX_SAFE_INTEGER;
|
|
15341
16055
|
if (expiryA !== expiryB) {
|
|
15342
16056
|
return expiryA - expiryB;
|
|
15343
16057
|
}
|
|
@@ -15597,7 +16311,7 @@ var MessageBus = class {
|
|
|
15597
16311
|
this.initialized = true;
|
|
15598
16312
|
}
|
|
15599
16313
|
async buildServices(config) {
|
|
15600
|
-
const arkProvider = new
|
|
16314
|
+
const arkProvider = new chunkOH2XLTXE_cjs.RestArkProvider(config.arkServer.url);
|
|
15601
16315
|
const storage = {
|
|
15602
16316
|
walletRepository: this.walletRepository,
|
|
15603
16317
|
contractRepository: this.contractRepository,
|
|
@@ -15939,7 +16653,7 @@ var offboardNetworkNames = [
|
|
|
15939
16653
|
function offboardDestinationScript(destinationAddress) {
|
|
15940
16654
|
for (const networkName of offboardNetworkNames) {
|
|
15941
16655
|
try {
|
|
15942
|
-
const network =
|
|
16656
|
+
const network = chunkOH2XLTXE_cjs.networks[networkName];
|
|
15943
16657
|
const addr = btcSigner.Address(network).decode(destinationAddress);
|
|
15944
16658
|
return btcSigner.OutScript.encode(addr);
|
|
15945
16659
|
} catch {
|
|
@@ -16003,7 +16717,7 @@ var Ramps = class {
|
|
|
16003
16717
|
}
|
|
16004
16718
|
amount = amount ?? totalAmount;
|
|
16005
16719
|
const offchainAddress = await this.wallet.getAddress();
|
|
16006
|
-
const offchainAddr =
|
|
16720
|
+
const offchainAddr = chunkOH2XLTXE_cjs.ArkAddress.decode(offchainAddress);
|
|
16007
16721
|
const offchainScript = base.hex.encode(offchainAddr.pkScript);
|
|
16008
16722
|
const outputFee = estimator.evalOffchainOutput({
|
|
16009
16723
|
amount,
|
|
@@ -16063,7 +16777,7 @@ var Ramps = class {
|
|
|
16063
16777
|
const filteredVtxos = [];
|
|
16064
16778
|
let totalAmount = 0n;
|
|
16065
16779
|
for (const vtxo of vtxos) {
|
|
16066
|
-
const inputFee = estimator.evalOffchainInput(
|
|
16780
|
+
const inputFee = estimator.evalOffchainInput(chunkOH2XLTXE_cjs.toOffchainInputFeeParams(vtxo));
|
|
16067
16781
|
if (inputFee.satoshis >= vtxo.value) {
|
|
16068
16782
|
continue;
|
|
16069
16783
|
}
|
|
@@ -16627,8 +17341,8 @@ var WalletMessageHandler = class {
|
|
|
16627
17341
|
});
|
|
16628
17342
|
}
|
|
16629
17343
|
case "SEND": {
|
|
16630
|
-
const { recipients } = message.payload;
|
|
16631
|
-
const txid = await this.wallet.send(...recipients);
|
|
17344
|
+
const { recipients, selectedVtxos } = message.payload;
|
|
17345
|
+
const txid = await (selectedVtxos ? this.wallet.send({ recipients, selectedVtxos }) : this.wallet.send(...recipients));
|
|
16632
17346
|
return this.tagged({
|
|
16633
17347
|
id,
|
|
16634
17348
|
type: "SEND_SUCCESS",
|
|
@@ -16830,7 +17544,7 @@ var WalletMessageHandler = class {
|
|
|
16830
17544
|
// Wallet methods
|
|
16831
17545
|
async handleInitWallet({ payload }) {
|
|
16832
17546
|
const { arkServerUrl } = payload;
|
|
16833
|
-
this.indexerProvider = new
|
|
17547
|
+
this.indexerProvider = new chunkI6EDUE75_cjs.RestIndexerProvider(arkServerUrl);
|
|
16834
17548
|
await this.onWalletInitialized();
|
|
16835
17549
|
}
|
|
16836
17550
|
/**
|
|
@@ -16876,6 +17590,8 @@ var WalletMessageHandler = class {
|
|
|
16876
17590
|
settled: offchain.settled,
|
|
16877
17591
|
preconfirmed: offchain.preconfirmed,
|
|
16878
17592
|
available: offchain.available,
|
|
17593
|
+
gated: offchain.gated,
|
|
17594
|
+
intentLocked: offchain.intentLocked,
|
|
16879
17595
|
recoverable: offchain.recoverable,
|
|
16880
17596
|
pendingRecovery: offchain.pendingRecovery,
|
|
16881
17597
|
total: totalBoarding + offchain.total,
|
|
@@ -17095,17 +17811,17 @@ var WalletMessageHandler = class {
|
|
|
17095
17811
|
throw new WalletNotInitializedError();
|
|
17096
17812
|
}
|
|
17097
17813
|
const allVtxos = await this.getVtxosFromRepo();
|
|
17098
|
-
const vtxos = allVtxos.filter((v) => !
|
|
17814
|
+
const vtxos = allVtxos.filter((v) => !chunkOH2XLTXE_cjs.hasTerminalSpend(v));
|
|
17099
17815
|
const dustAmount = this.readonlyWallet.dustAmount;
|
|
17100
17816
|
const includeRecoverable = message.payload.filter?.withRecoverable ?? false;
|
|
17101
17817
|
const filteredVtxos = includeRecoverable ? vtxos : vtxos.filter((v) => {
|
|
17102
17818
|
if (dustAmount != null && isSubdust(v, dustAmount)) {
|
|
17103
17819
|
return false;
|
|
17104
17820
|
}
|
|
17105
|
-
if (
|
|
17821
|
+
if (chunkOH2XLTXE_cjs.isRecoverable(v)) {
|
|
17106
17822
|
return false;
|
|
17107
17823
|
}
|
|
17108
|
-
if (
|
|
17824
|
+
if (chunkOH2XLTXE_cjs.isExpired(v)) {
|
|
17109
17825
|
return false;
|
|
17110
17826
|
}
|
|
17111
17827
|
return true;
|
|
@@ -17113,7 +17829,7 @@ var WalletMessageHandler = class {
|
|
|
17113
17829
|
if (!message.payload.filter?.withUnrolled) {
|
|
17114
17830
|
return filteredVtxos;
|
|
17115
17831
|
}
|
|
17116
|
-
return filteredVtxos.concat(allVtxos.filter((v) =>
|
|
17832
|
+
return filteredVtxos.concat(allVtxos.filter((v) => chunkOH2XLTXE_cjs.hasTerminalSpend(v) && v.isUnrolled));
|
|
17117
17833
|
}
|
|
17118
17834
|
/** Tear down handler subscriptions, then delegate the full wipe to the wallet. */
|
|
17119
17835
|
async clear() {
|
|
@@ -17203,7 +17919,7 @@ var WalletMessageHandler = class {
|
|
|
17203
17919
|
if (!this.readonlyWallet) return null;
|
|
17204
17920
|
const { boardingTxs, commitmentsToIgnore } = await this.readonlyWallet.getBoardingTxs();
|
|
17205
17921
|
const indexerProvider = this.indexerProvider;
|
|
17206
|
-
const resolveTxCreatedAt = indexerProvider ? (txids) =>
|
|
17922
|
+
const resolveTxCreatedAt = indexerProvider ? (txids) => chunkOH2XLTXE_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
|
|
17207
17923
|
return buildTransactionHistory(vtxos, boardingTxs, commitmentsToIgnore, resolveTxCreatedAt);
|
|
17208
17924
|
}
|
|
17209
17925
|
async ensureContractEventBroadcasting() {
|
|
@@ -17320,10 +18036,6 @@ function getRequestDedupKey(request) {
|
|
|
17320
18036
|
const { id, tag, ...rest } = request;
|
|
17321
18037
|
return JSON.stringify(rest);
|
|
17322
18038
|
}
|
|
17323
|
-
function isSigningCapable(identity) {
|
|
17324
|
-
const candidate = identity;
|
|
17325
|
-
return typeof candidate.signMessage === "function" && typeof candidate.sign === "function" && typeof candidate.signerSession === "function";
|
|
17326
|
-
}
|
|
17327
18039
|
var ServiceWorkerReadonlyAssetManager = class {
|
|
17328
18040
|
constructor(sendMessage, messageTag) {
|
|
17329
18041
|
this.sendMessage = sendMessage;
|
|
@@ -17896,7 +18608,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
17896
18608
|
};
|
|
17897
18609
|
try {
|
|
17898
18610
|
const response = await this.sendMessage(message);
|
|
17899
|
-
return response.payload.vtxos.map(
|
|
18611
|
+
return response.payload.vtxos.map(chunkOH2XLTXE_cjs.normalizeVtxo);
|
|
17900
18612
|
} catch (error) {
|
|
17901
18613
|
throw new Error(`Failed to get vtxos: ${error}`);
|
|
17902
18614
|
}
|
|
@@ -17921,7 +18633,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
17921
18633
|
};
|
|
17922
18634
|
try {
|
|
17923
18635
|
const response = await this.sendMessage(message);
|
|
17924
|
-
return response.payload.vtxos.map(
|
|
18636
|
+
return response.payload.vtxos.map(chunkOH2XLTXE_cjs.normalizeVtxo);
|
|
17925
18637
|
} catch (error) {
|
|
17926
18638
|
throw new Error(`Failed to get spendable vtxos: ${error}`);
|
|
17927
18639
|
}
|
|
@@ -18031,7 +18743,15 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
18031
18743
|
*/
|
|
18032
18744
|
async assertAnnotatable() {
|
|
18033
18745
|
},
|
|
18034
|
-
/**
|
|
18746
|
+
/**
|
|
18747
|
+
* Same reasoning as {@link assertAnnotatable}: the worker checks it.
|
|
18748
|
+
*
|
|
18749
|
+
* `unspendableNowReasons` is deliberately absent rather than stubbed
|
|
18750
|
+
* alongside it. A stub returning an empty map reads as "nothing
|
|
18751
|
+
* refused", and a filter acting on that silently drops its decision;
|
|
18752
|
+
* absent, the optional call is skipped. Recovery — the only caller —
|
|
18753
|
+
* runs inside the worker against the real manager anyway.
|
|
18754
|
+
*/
|
|
18035
18755
|
async assertSpendableNow() {
|
|
18036
18756
|
},
|
|
18037
18757
|
async annotateVtxos(vtxos) {
|
|
@@ -18044,7 +18764,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
18044
18764
|
};
|
|
18045
18765
|
try {
|
|
18046
18766
|
const response = await sendContractMessage(message);
|
|
18047
|
-
return response.payload.vtxos.map(
|
|
18767
|
+
return response.payload.vtxos.map(chunkOH2XLTXE_cjs.normalizeVtxo);
|
|
18048
18768
|
} catch (e) {
|
|
18049
18769
|
throw new Error("Failed to annotate vtxos");
|
|
18050
18770
|
}
|
|
@@ -18257,7 +18977,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
18257
18977
|
}
|
|
18258
18978
|
const walletRepository = options.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
18259
18979
|
const contractRepository = options.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
18260
|
-
if (!
|
|
18980
|
+
if (!isSigningIdentity(options.identity)) {
|
|
18261
18981
|
throw new Error(
|
|
18262
18982
|
"ServiceWorkerWallet.create() requires a signing Identity; got a ReadonlyIdentity"
|
|
18263
18983
|
);
|
|
@@ -18417,17 +19137,21 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
18417
19137
|
/**
|
|
18418
19138
|
* @see HDWalletCapable.signerForDescriptor
|
|
18419
19139
|
*
|
|
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
|
-
*
|
|
19140
|
+
* Runs page-side: an `Identity` cannot cross the message bus, and it does
|
|
19141
|
+
* not need to — the page owns the signing identity, and resolving a
|
|
19142
|
+
* descriptor reads no allocation state. Shares
|
|
19143
|
+
* {@link resolveDescriptorSigner} with {@link Wallet.signerForDescriptor}
|
|
19144
|
+
* so the two sides of the bus cannot answer differently for one
|
|
18424
19145
|
* descriptor.
|
|
19146
|
+
*
|
|
19147
|
+
* No provider is passed, and none is needed: `HDDescriptorProvider`'s
|
|
19148
|
+
* `isOurs` and signing members all delegate to the identity, which the
|
|
19149
|
+
* page holds. Building one here would only add a page-side read of the
|
|
19150
|
+
* wallet state the worker allocates from — shared mutable state on a path
|
|
19151
|
+
* that has no business touching it.
|
|
18425
19152
|
*/
|
|
18426
19153
|
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 });
|
|
19154
|
+
return resolveDescriptorSigner(descriptor, this.identity);
|
|
18431
19155
|
}
|
|
18432
19156
|
async sendBitcoin(params) {
|
|
18433
19157
|
const message = {
|
|
@@ -18491,12 +19215,16 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
18491
19215
|
throw error;
|
|
18492
19216
|
}
|
|
18493
19217
|
}
|
|
18494
|
-
async send(...
|
|
19218
|
+
async send(...args) {
|
|
19219
|
+
const [first] = args;
|
|
19220
|
+
const { recipients, selectedVtxos } = args.length === 1 && first && "recipients" in first ? first : { recipients: args, selectedVtxos: void 0 };
|
|
18495
19221
|
const message = {
|
|
18496
19222
|
tag: this.messageTag,
|
|
18497
19223
|
type: "SEND",
|
|
18498
19224
|
id: getRandomId(),
|
|
18499
|
-
|
|
19225
|
+
// Omitted rather than sent as `undefined`, so an older worker sees
|
|
19226
|
+
// exactly the payload it saw before.
|
|
19227
|
+
payload: selectedVtxos ? { recipients, selectedVtxos } : { recipients }
|
|
18500
19228
|
};
|
|
18501
19229
|
try {
|
|
18502
19230
|
const response = await this.sendMessage(message);
|
|
@@ -18608,7 +19336,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
18608
19336
|
};
|
|
18609
19337
|
try {
|
|
18610
19338
|
const response = await wallet.sendMessage(message);
|
|
18611
|
-
return response.payload.vtxos.map(
|
|
19339
|
+
return response.payload.vtxos.map(chunkOH2XLTXE_cjs.normalizeVtxo);
|
|
18612
19340
|
} catch (e) {
|
|
18613
19341
|
throw new Error(`Failed to get expiring vtxos: ${e}`);
|
|
18614
19342
|
}
|
|
@@ -18720,12 +19448,12 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
18720
19448
|
* @returns Configured onchain wallet
|
|
18721
19449
|
* @throws Error if the configured identity cannot produce a valid x-only public key
|
|
18722
19450
|
*/
|
|
18723
|
-
static async create(identity, networkName =
|
|
19451
|
+
static async create(identity, networkName = chunkOH2XLTXE_cjs.DEFAULT_NETWORK_NAME, provider) {
|
|
18724
19452
|
const pubkey = await identity.xOnlyPublicKey();
|
|
18725
19453
|
if (!pubkey) {
|
|
18726
19454
|
throw new Error("Invalid configured public key");
|
|
18727
19455
|
}
|
|
18728
|
-
const network =
|
|
19456
|
+
const network = chunkOH2XLTXE_cjs.getNetwork(networkName);
|
|
18729
19457
|
const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
|
|
18730
19458
|
const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
|
|
18731
19459
|
return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
|
|
@@ -18831,7 +19559,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
18831
19559
|
if (!inputs) {
|
|
18832
19560
|
throw new Error("Fee estimation failed");
|
|
18833
19561
|
}
|
|
18834
|
-
let tx = new
|
|
19562
|
+
let tx = new chunkOH2XLTXE_cjs.Transaction();
|
|
18835
19563
|
for (const input of inputs) {
|
|
18836
19564
|
tx.addInput({
|
|
18837
19565
|
txid: input.txid,
|
|
@@ -18889,7 +19617,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
18889
19617
|
* @throws If the parent has no anchor, or funding cannot be selected/signed
|
|
18890
19618
|
*/
|
|
18891
19619
|
async bumpAnchor(parentHex, feeRate) {
|
|
18892
|
-
const parent =
|
|
19620
|
+
const parent = chunkOH2XLTXE_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
|
|
18893
19621
|
const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
|
|
18894
19622
|
const child = await this.buildBumpPackage(parent, feeRate, coins);
|
|
18895
19623
|
return [parent.hex, child.hex];
|
|
@@ -19654,7 +20382,7 @@ exports.BIP322 = void 0;
|
|
|
19654
20382
|
async function sign2(message, identity, network) {
|
|
19655
20383
|
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
19656
20384
|
const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
|
|
19657
|
-
const toSpend =
|
|
20385
|
+
const toSpend = chunkOH2XLTXE_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
19658
20386
|
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
19659
20387
|
const signed = await identity.sign(toSign, [0]);
|
|
19660
20388
|
signed.finalizeIdx(0);
|
|
@@ -19712,7 +20440,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
|
19712
20440
|
if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
|
|
19713
20441
|
return false;
|
|
19714
20442
|
}
|
|
19715
|
-
const toSpend =
|
|
20443
|
+
const toSpend = chunkOH2XLTXE_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
19716
20444
|
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
|
|
19717
20445
|
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
19718
20446
|
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
@@ -19733,7 +20461,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
|
19733
20461
|
}
|
|
19734
20462
|
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
19735
20463
|
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
19736
|
-
const toSpend =
|
|
20464
|
+
const toSpend = chunkOH2XLTXE_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
19737
20465
|
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
19738
20466
|
const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
|
|
19739
20467
|
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
@@ -19786,7 +20514,7 @@ function encodeCompactSize(n) {
|
|
|
19786
20514
|
return buf;
|
|
19787
20515
|
}
|
|
19788
20516
|
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
19789
|
-
const tx = new
|
|
20517
|
+
const tx = new chunkOH2XLTXE_cjs.Transaction({ version: 0 });
|
|
19790
20518
|
tx.addInput({
|
|
19791
20519
|
txid: toSpend.id,
|
|
19792
20520
|
index: 0,
|
|
@@ -19800,12 +20528,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
|
19800
20528
|
});
|
|
19801
20529
|
tx.addOutput({
|
|
19802
20530
|
amount: 0n,
|
|
19803
|
-
script:
|
|
20531
|
+
script: chunkOH2XLTXE_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
19804
20532
|
});
|
|
19805
20533
|
return tx;
|
|
19806
20534
|
}
|
|
19807
20535
|
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
19808
|
-
const tx = new
|
|
20536
|
+
const tx = new chunkOH2XLTXE_cjs.Transaction({ version: 0 });
|
|
19809
20537
|
tx.addInput({
|
|
19810
20538
|
txid: toSpend.id,
|
|
19811
20539
|
index: 0,
|
|
@@ -19817,7 +20545,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
|
19817
20545
|
});
|
|
19818
20546
|
tx.addOutput({
|
|
19819
20547
|
amount: 0n,
|
|
19820
|
-
script:
|
|
20548
|
+
script: chunkOH2XLTXE_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
19821
20549
|
});
|
|
19822
20550
|
return tx;
|
|
19823
20551
|
}
|
|
@@ -19948,7 +20676,7 @@ var RestEmulatorProvider = class {
|
|
|
19948
20676
|
}
|
|
19949
20677
|
};
|
|
19950
20678
|
function finalizeVirtualTx(type, psbtBase64) {
|
|
19951
|
-
const tx =
|
|
20679
|
+
const tx = chunkOH2XLTXE_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
19952
20680
|
if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
|
|
19953
20681
|
const input = tx.getInput(0);
|
|
19954
20682
|
if (!input) {
|
|
@@ -19975,14 +20703,14 @@ var ExitPathError = class extends Error {
|
|
|
19975
20703
|
reason;
|
|
19976
20704
|
};
|
|
19977
20705
|
function delayWeight(sequence) {
|
|
19978
|
-
const t =
|
|
20706
|
+
const t = chunkOH2XLTXE_cjs.sequenceToTimelock(sequence);
|
|
19979
20707
|
return t.type === "blocks" ? Number(t.value) : Number(t.value) / 600;
|
|
19980
20708
|
}
|
|
19981
20709
|
async function resolveUnilateralPath(params) {
|
|
19982
20710
|
const { vtxo, scriptHex, contractRepository } = params;
|
|
19983
20711
|
const contract = contractRepository ? (await contractRepository.getContracts({ script: scriptHex }))[0] : void 0;
|
|
19984
20712
|
if (contract) {
|
|
19985
|
-
const handler =
|
|
20713
|
+
const handler = chunkG53HASDV_cjs.contractHandlers.get(contract.type);
|
|
19986
20714
|
if (!handler) {
|
|
19987
20715
|
throw new ExitPathError(
|
|
19988
20716
|
"no-handler",
|
|
@@ -20005,12 +20733,12 @@ async function resolveUnilateralPath(params) {
|
|
|
20005
20733
|
paths.sort((a, b) => delayWeight(a.sequence) - delayWeight(b.sequence));
|
|
20006
20734
|
return { selection: paths[0], label: `${contract.type}:unilateral` };
|
|
20007
20735
|
}
|
|
20008
|
-
const decoded =
|
|
20736
|
+
const decoded = chunkOH2XLTXE_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
20009
20737
|
let best;
|
|
20010
20738
|
for (const exit of decoded.exitPaths()) {
|
|
20011
20739
|
const leaf = decoded.findLeaf(base.hex.encode(exit.script));
|
|
20012
20740
|
if (!leaf) continue;
|
|
20013
|
-
const sequence =
|
|
20741
|
+
const sequence = chunkOH2XLTXE_cjs.timelockToSequence(exit.params.timelock);
|
|
20014
20742
|
const weight = delayWeight(sequence);
|
|
20015
20743
|
if (!best || weight < best.weight) {
|
|
20016
20744
|
best = { selection: { leaf, sequence }, weight };
|
|
@@ -20196,14 +20924,14 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
20196
20924
|
}
|
|
20197
20925
|
const resolved = await resolveUnilateralPath({
|
|
20198
20926
|
vtxo,
|
|
20199
|
-
scriptHex: base.hex.encode(
|
|
20927
|
+
scriptHex: base.hex.encode(chunkOH2XLTXE_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
20200
20928
|
contractRepository: wallet.contractRepository,
|
|
20201
20929
|
walletPubKeyHex: base.hex.encode(await wallet.identity.xOnlyPublicKey()),
|
|
20202
20930
|
currentTime: Date.now()
|
|
20203
20931
|
});
|
|
20204
20932
|
const spendingLeaf = resolved.selection.leaf;
|
|
20205
20933
|
const sequence = resolved.selection.sequence;
|
|
20206
|
-
const timelock =
|
|
20934
|
+
const timelock = chunkOH2XLTXE_cjs.sequenceToTimelock(sequence);
|
|
20207
20935
|
const elapsed = timelock.type === "blocks" ? chainTip.height >= txStatus.blockHeight + Number(timelock.value) : chainTip.time >= txStatus.blockTime + Number(timelock.value);
|
|
20208
20936
|
if (!elapsed) {
|
|
20209
20937
|
throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
|
|
@@ -20216,7 +20944,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
20216
20944
|
sequence,
|
|
20217
20945
|
witnessUtxo: {
|
|
20218
20946
|
amount: BigInt(vtxo.value),
|
|
20219
|
-
script:
|
|
20947
|
+
script: chunkOH2XLTXE_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
|
|
20220
20948
|
},
|
|
20221
20949
|
sighashType: btcSigner.SigHash.DEFAULT
|
|
20222
20950
|
});
|
|
@@ -20226,7 +20954,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
20226
20954
|
btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
|
|
20227
20955
|
);
|
|
20228
20956
|
}
|
|
20229
|
-
const tx = new
|
|
20957
|
+
const tx = new chunkOH2XLTXE_cjs.Transaction({ version: 2 });
|
|
20230
20958
|
for (const input of inputs) {
|
|
20231
20959
|
tx.addInput(input);
|
|
20232
20960
|
}
|
|
@@ -20293,7 +21021,7 @@ async function buildSignedSweep(params) {
|
|
|
20293
21021
|
`uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
|
|
20294
21022
|
);
|
|
20295
21023
|
}
|
|
20296
|
-
const tx = new
|
|
21024
|
+
const tx = new chunkOH2XLTXE_cjs.Transaction({ version: 2 });
|
|
20297
21025
|
tx.addInput({
|
|
20298
21026
|
txid: vtxo.txid,
|
|
20299
21027
|
index: vtxo.vout,
|
|
@@ -20318,7 +21046,7 @@ async function buildSignedSweep(params) {
|
|
|
20318
21046
|
finalScriptWitness: [
|
|
20319
21047
|
tapScriptSig[0][1],
|
|
20320
21048
|
...path.extraWitness,
|
|
20321
|
-
|
|
21049
|
+
chunkOH2XLTXE_cjs.scriptFromTapLeafScript(path.leaf),
|
|
20322
21050
|
btcSigner.TaprootControlBlock.encode(controlBlock)
|
|
20323
21051
|
]
|
|
20324
21052
|
});
|
|
@@ -20348,7 +21076,7 @@ async function resolveFeeRate(opts) {
|
|
|
20348
21076
|
}
|
|
20349
21077
|
async function selectExitVtxos(opts) {
|
|
20350
21078
|
if (!opts.vtxos) return opts.wallet.getVtxos();
|
|
20351
|
-
const res = await
|
|
21079
|
+
const res = await chunkOH2XLTXE_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
|
|
20352
21080
|
const tapTrees = /* @__PURE__ */ new Map();
|
|
20353
21081
|
const out = [];
|
|
20354
21082
|
for (const vtxo of res.vtxos) {
|
|
@@ -20363,7 +21091,7 @@ async function selectExitVtxos(opts) {
|
|
|
20363
21091
|
`no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
|
|
20364
21092
|
);
|
|
20365
21093
|
}
|
|
20366
|
-
const handler =
|
|
21094
|
+
const handler = chunkG53HASDV_cjs.contractHandlers.get(contract.type);
|
|
20367
21095
|
if (!handler) {
|
|
20368
21096
|
throw new Error(`no contract handler registered for type '${contract.type}'`);
|
|
20369
21097
|
}
|
|
@@ -20393,7 +21121,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
20393
21121
|
if (pendingNodes.length > 0) {
|
|
20394
21122
|
const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
|
|
20395
21123
|
for (const psbt of txs) {
|
|
20396
|
-
psbts.set(
|
|
21124
|
+
psbts.set(chunkOH2XLTXE_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
20397
21125
|
}
|
|
20398
21126
|
}
|
|
20399
21127
|
const childVsize = Number(
|
|
@@ -20429,7 +21157,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
20429
21157
|
try {
|
|
20430
21158
|
const resolved = await resolveUnilateralPath({
|
|
20431
21159
|
vtxo,
|
|
20432
|
-
scriptHex: base.hex.encode(
|
|
21160
|
+
scriptHex: base.hex.encode(chunkOH2XLTXE_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
20433
21161
|
contractRepository: wallet.contractRepository,
|
|
20434
21162
|
walletPubKeyHex,
|
|
20435
21163
|
currentTime: Date.now()
|
|
@@ -20448,7 +21176,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
20448
21176
|
});
|
|
20449
21177
|
continue;
|
|
20450
21178
|
}
|
|
20451
|
-
const t =
|
|
21179
|
+
const t = chunkOH2XLTXE_cjs.sequenceToTimelock(resolved.selection.sequence);
|
|
20452
21180
|
const delay = { type: t.type, value: Number(t.value) };
|
|
20453
21181
|
infos.push({ outpoint, value: vtxo.value, sweepFee, path: resolved.label, delay });
|
|
20454
21182
|
sweeps.push({ vtxo, resolved, sweepFee, delay });
|
|
@@ -20787,7 +21515,7 @@ async function prepare(opts) {
|
|
|
20787
21515
|
txid: sweep.vtxo.txid,
|
|
20788
21516
|
vout: sweep.vtxo.vout,
|
|
20789
21517
|
value: sweep.vtxo.value,
|
|
20790
|
-
pkScript:
|
|
21518
|
+
pkScript: chunkOH2XLTXE_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
|
|
20791
21519
|
},
|
|
20792
21520
|
path: sweep.resolved.selection,
|
|
20793
21521
|
outputAddress: opts.sweepAddress,
|
|
@@ -20872,7 +21600,7 @@ async function prepare(opts) {
|
|
|
20872
21600
|
if (newFee <= splitterFee) break;
|
|
20873
21601
|
splitterFee = newFee;
|
|
20874
21602
|
}
|
|
20875
|
-
const splitter = new
|
|
21603
|
+
const splitter = new chunkOH2XLTXE_cjs.Transaction({ version: 2 });
|
|
20876
21604
|
for (const coin of selected.inputs) {
|
|
20877
21605
|
splitter.addInput({
|
|
20878
21606
|
txid: coin.txid,
|
|
@@ -21015,41 +21743,41 @@ var UnilateralExit = {
|
|
|
21015
21743
|
// src/arkade/index.ts
|
|
21016
21744
|
var arkade_exports = {};
|
|
21017
21745
|
chunk5BLDMQED_cjs.__export(arkade_exports, {
|
|
21018
|
-
ARKADE_OP: () =>
|
|
21019
|
-
ARKADE_OPCODES: () =>
|
|
21020
|
-
ARKADE_OPCODE_NAMES: () =>
|
|
21021
|
-
ARKADE_OPCODE_VALUES: () =>
|
|
21022
|
-
ARKADE_OPS: () =>
|
|
21746
|
+
ARKADE_OP: () => chunkG53HASDV_cjs.ARKADE_OP,
|
|
21747
|
+
ARKADE_OPCODES: () => chunkG53HASDV_cjs.ARKADE_OPCODES,
|
|
21748
|
+
ARKADE_OPCODE_NAMES: () => chunkG53HASDV_cjs.ARKADE_OPCODE_NAMES,
|
|
21749
|
+
ARKADE_OPCODE_VALUES: () => chunkG53HASDV_cjs.ARKADE_OPCODE_VALUES,
|
|
21750
|
+
ARKADE_OPS: () => chunkG53HASDV_cjs.ARKADE_OPS,
|
|
21023
21751
|
Arkade: () => Arkade,
|
|
21024
21752
|
ArkadeContract: () => ArkadeContract,
|
|
21025
|
-
ArkadeProgramScript: () =>
|
|
21026
|
-
ArkadeScript: () =>
|
|
21753
|
+
ArkadeProgramScript: () => chunkG53HASDV_cjs.ArkadeProgramScript,
|
|
21754
|
+
ArkadeScript: () => chunkG53HASDV_cjs.ArkadeScript,
|
|
21027
21755
|
ArkadeTransactionBuilder: () => ArkadeTransactionBuilder,
|
|
21028
|
-
BigNum: () =>
|
|
21756
|
+
BigNum: () => chunkG53HASDV_cjs.bignum_exports,
|
|
21029
21757
|
OP: () => btcSigner.OP,
|
|
21030
|
-
OPCODE_NAMES: () =>
|
|
21031
|
-
OPCODE_VALUES: () =>
|
|
21032
|
-
SUPPORTED_PROGRAM_VERSION: () =>
|
|
21758
|
+
OPCODE_NAMES: () => chunkG53HASDV_cjs.OPCODE_NAMES,
|
|
21759
|
+
OPCODE_VALUES: () => chunkG53HASDV_cjs.OPCODE_VALUES,
|
|
21760
|
+
SUPPORTED_PROGRAM_VERSION: () => chunkG53HASDV_cjs.SUPPORTED_PROGRAM_VERSION,
|
|
21033
21761
|
Script: () => btcSigner.Script,
|
|
21034
|
-
arkadeScriptHash: () =>
|
|
21035
|
-
arkadeWitnessHash: () =>
|
|
21036
|
-
asmToBytes: () =>
|
|
21037
|
-
bytesToASM: () =>
|
|
21038
|
-
computeArkadeScriptPublicKey: () =>
|
|
21762
|
+
arkadeScriptHash: () => chunkG53HASDV_cjs.arkadeScriptHash,
|
|
21763
|
+
arkadeWitnessHash: () => chunkG53HASDV_cjs.arkadeWitnessHash,
|
|
21764
|
+
asmToBytes: () => chunkG53HASDV_cjs.asmToBytes,
|
|
21765
|
+
bytesToASM: () => chunkG53HASDV_cjs.bytesToASM,
|
|
21766
|
+
computeArkadeScriptPublicKey: () => chunkG53HASDV_cjs.computeArkadeScriptPublicKey,
|
|
21039
21767
|
createArkadeBatchHandler: () => createArkadeBatchHandler,
|
|
21040
|
-
deserializeArkadeContractParams: () =>
|
|
21041
|
-
fromASM: () =>
|
|
21042
|
-
getOpcodeName: () =>
|
|
21043
|
-
getOpcodeValue: () =>
|
|
21044
|
-
parseArtifact: () =>
|
|
21045
|
-
resolveAsm: () =>
|
|
21046
|
-
serializeArkadeContractParams: () =>
|
|
21047
|
-
stringifyArtifact: () =>
|
|
21048
|
-
toASM: () =>
|
|
21049
|
-
validateProgram: () =>
|
|
21050
|
-
witnessRefToBytes: () =>
|
|
21768
|
+
deserializeArkadeContractParams: () => chunkG53HASDV_cjs.deserializeArkadeContractParams,
|
|
21769
|
+
fromASM: () => chunkG53HASDV_cjs.fromASM,
|
|
21770
|
+
getOpcodeName: () => chunkG53HASDV_cjs.getOpcodeName,
|
|
21771
|
+
getOpcodeValue: () => chunkG53HASDV_cjs.getOpcodeValue,
|
|
21772
|
+
parseArtifact: () => chunkG53HASDV_cjs.parseArtifact,
|
|
21773
|
+
resolveAsm: () => chunkG53HASDV_cjs.resolveAsm,
|
|
21774
|
+
serializeArkadeContractParams: () => chunkG53HASDV_cjs.serializeArkadeContractParams,
|
|
21775
|
+
stringifyArtifact: () => chunkG53HASDV_cjs.stringifyArtifact,
|
|
21776
|
+
toASM: () => chunkG53HASDV_cjs.toASM,
|
|
21777
|
+
validateProgram: () => chunkG53HASDV_cjs.validateProgram,
|
|
21778
|
+
witnessRefToBytes: () => chunkG53HASDV_cjs.witnessRefToBytes
|
|
21051
21779
|
});
|
|
21052
|
-
var isVtxoCoin = (input) =>
|
|
21780
|
+
var isVtxoCoin = (input) => chunkOH2XLTXE_cjs.isVirtualCoin(input);
|
|
21053
21781
|
function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
|
|
21054
21782
|
let batchId;
|
|
21055
21783
|
let sweepTapTreeRoot;
|
|
@@ -21070,7 +21798,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
21070
21798
|
);
|
|
21071
21799
|
await arkProvider.confirmRegistration(intentId);
|
|
21072
21800
|
batchId = event.id;
|
|
21073
|
-
const sweepTapscript =
|
|
21801
|
+
const sweepTapscript = chunkOH2XLTXE_cjs.CSVMultisigTapscript.encode({
|
|
21074
21802
|
timelock,
|
|
21075
21803
|
pubkeys: [base.hex.decode(info.forfeitPubkey).subarray(1)]
|
|
21076
21804
|
}).script;
|
|
@@ -21084,7 +21812,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
21084
21812
|
if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
|
|
21085
21813
|
return { skip: true };
|
|
21086
21814
|
}
|
|
21087
|
-
const commitmentTx =
|
|
21815
|
+
const commitmentTx = chunkOH2XLTXE_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
|
|
21088
21816
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
21089
21817
|
if (recipients && recipients.length > 0) {
|
|
21090
21818
|
validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
|
|
@@ -21116,7 +21844,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
21116
21844
|
if (connectorTree) {
|
|
21117
21845
|
validateConnectorsTxGraph(event.commitmentTx, connectorTree);
|
|
21118
21846
|
}
|
|
21119
|
-
let commitmentPsbt =
|
|
21847
|
+
let commitmentPsbt = chunkOH2XLTXE_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
21120
21848
|
assertFinalCommitmentMatchesValidated(
|
|
21121
21849
|
commitmentPsbt,
|
|
21122
21850
|
validatedCommitmentTxid,
|
|
@@ -21151,7 +21879,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
21151
21879
|
boardingIndices.push(boardingIdx);
|
|
21152
21880
|
continue;
|
|
21153
21881
|
}
|
|
21154
|
-
if (
|
|
21882
|
+
if (chunkOH2XLTXE_cjs.isRecoverable(input) || isSubdust(input, info.dust)) {
|
|
21155
21883
|
continue;
|
|
21156
21884
|
}
|
|
21157
21885
|
if (connectorIndex >= connectorLeaves.length) {
|
|
@@ -21172,7 +21900,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
21172
21900
|
index: input.vout,
|
|
21173
21901
|
witnessUtxo: {
|
|
21174
21902
|
amount: BigInt(input.value),
|
|
21175
|
-
script:
|
|
21903
|
+
script: chunkOH2XLTXE_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
21176
21904
|
},
|
|
21177
21905
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
21178
21906
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -21264,11 +21992,11 @@ var Arkade = class _Arkade {
|
|
|
21264
21992
|
static async connect(opts) {
|
|
21265
21993
|
const info = await opts.arkade.getInfo();
|
|
21266
21994
|
const serverKey = base.hex.decode(info.signerPubkey).slice(1);
|
|
21267
|
-
const checkpoint =
|
|
21268
|
-
const network = opts.network ??
|
|
21995
|
+
const checkpoint = chunkOH2XLTXE_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
21996
|
+
const network = opts.network ?? chunkOH2XLTXE_cjs.DEFAULT_NETWORK;
|
|
21269
21997
|
let emulatorKey;
|
|
21270
21998
|
if (opts.emulator) {
|
|
21271
|
-
emulatorKey = base.hex.decode(
|
|
21999
|
+
emulatorKey = base.hex.decode(chunkOH2XLTXE_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
|
|
21272
22000
|
}
|
|
21273
22001
|
let userKey;
|
|
21274
22002
|
if (opts.identity) {
|
|
@@ -21299,7 +22027,7 @@ var Arkade = class _Arkade {
|
|
|
21299
22027
|
* key respectively; explicit args always win.
|
|
21300
22028
|
*/
|
|
21301
22029
|
contract(program, args = {}) {
|
|
21302
|
-
const declared = (program.params ?? []).map(
|
|
22030
|
+
const declared = (program.params ?? []).map(chunkG53HASDV_cjs.inputName);
|
|
21303
22031
|
if (declared.includes("server") && args.server === void 0) {
|
|
21304
22032
|
args = { ...args, server: this.serverKey };
|
|
21305
22033
|
}
|
|
@@ -21319,7 +22047,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
21319
22047
|
userKey: client.userKey,
|
|
21320
22048
|
emulatorKey: client.emulatorKey
|
|
21321
22049
|
};
|
|
21322
|
-
this.vtxoScript = new
|
|
22050
|
+
this.vtxoScript = new chunkG53HASDV_cjs.ArkadeProgramScript(program, args, this.keys);
|
|
21323
22051
|
this.tapTree = this.vtxoScript.encode();
|
|
21324
22052
|
this.compiled = this.vtxoScript.compiled;
|
|
21325
22053
|
}
|
|
@@ -21347,7 +22075,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
21347
22075
|
`ArkadeContract.fromContract: expected contract type 'arkade', got '${contract.type}'`
|
|
21348
22076
|
);
|
|
21349
22077
|
}
|
|
21350
|
-
const typed =
|
|
22078
|
+
const typed = chunkG53HASDV_cjs.deserializeArkadeContractParams(contract.params);
|
|
21351
22079
|
return new _ArkadeContract(client, typed.program, typed.args, {
|
|
21352
22080
|
serverKey: typed.serverKey,
|
|
21353
22081
|
userKey: typed.userKey,
|
|
@@ -21388,7 +22116,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
21388
22116
|
toContractParams() {
|
|
21389
22117
|
return {
|
|
21390
22118
|
type: "arkade",
|
|
21391
|
-
params:
|
|
22119
|
+
params: chunkG53HASDV_cjs.serializeArkadeContractParams({
|
|
21392
22120
|
program: this.program,
|
|
21393
22121
|
args: this.args,
|
|
21394
22122
|
serverKey: this.keys.serverKey,
|
|
@@ -21433,13 +22161,13 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
21433
22161
|
const [registered] = await manager.getContracts({ script: scriptHex });
|
|
21434
22162
|
if (registered) {
|
|
21435
22163
|
const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
|
|
21436
|
-
return (withVtxos?.vtxos ?? []).filter((v) => !
|
|
22164
|
+
return (withVtxos?.vtxos ?? []).filter((v) => !chunkOH2XLTXE_cjs.hasTerminalSpend(v));
|
|
21437
22165
|
}
|
|
21438
22166
|
}
|
|
21439
22167
|
if (!this.client.indexer) {
|
|
21440
22168
|
throw new Error("ArkadeContract.getUtxos: an indexer is required");
|
|
21441
22169
|
}
|
|
21442
|
-
const { vtxos } = await
|
|
22170
|
+
const { vtxos } = await chunkOH2XLTXE_cjs.getNormalizedVtxos(this.client.indexer, {
|
|
21443
22171
|
scripts: [scriptHex],
|
|
21444
22172
|
spendableOnly: true
|
|
21445
22173
|
});
|
|
@@ -21541,12 +22269,12 @@ var ArkadeTransactionBuilder = class {
|
|
|
21541
22269
|
this.contract.client.checkpoint
|
|
21542
22270
|
);
|
|
21543
22271
|
if (coin.sourceTx) {
|
|
21544
|
-
|
|
22272
|
+
chunkOH2XLTXE_cjs.setArkPsbtField(arkTx, 0, chunkOH2XLTXE_cjs.PrevArkTxField, coin.sourceTx);
|
|
21545
22273
|
}
|
|
21546
22274
|
const condition = (def.tapscript.witness ?? []).map((w) => this.witnessBytes(w));
|
|
21547
22275
|
if (condition.length > 0) {
|
|
21548
|
-
|
|
21549
|
-
|
|
22276
|
+
chunkOH2XLTXE_cjs.setArkPsbtField(arkTx, 0, chunkOH2XLTXE_cjs.ConditionWitness, condition);
|
|
22277
|
+
chunkOH2XLTXE_cjs.setArkPsbtField(checkpoints[0], 0, chunkOH2XLTXE_cjs.ConditionWitness, condition);
|
|
21550
22278
|
}
|
|
21551
22279
|
const packets = [];
|
|
21552
22280
|
if (this.assetSpecs.length > 0) {
|
|
@@ -21585,7 +22313,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
21585
22313
|
base.base64.encode(signedArk2.toPSBT()),
|
|
21586
22314
|
signedCps.map((c) => base.base64.encode(c.toPSBT()))
|
|
21587
22315
|
);
|
|
21588
|
-
const txid =
|
|
22316
|
+
const txid = chunkOH2XLTXE_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
|
|
21589
22317
|
return {
|
|
21590
22318
|
txid,
|
|
21591
22319
|
signedArkTx: res2.signedArkTx,
|
|
@@ -21644,23 +22372,23 @@ var ArkadeTransactionBuilder = class {
|
|
|
21644
22372
|
}
|
|
21645
22373
|
buildAssetPacket() {
|
|
21646
22374
|
const groups = this.assetSpecs.map((s) => {
|
|
21647
|
-
const id = typeof s.assetId === "string" ?
|
|
21648
|
-
return
|
|
22375
|
+
const id = typeof s.assetId === "string" ? chunkI6EDUE75_cjs.AssetId.fromString(s.assetId) : chunkI6EDUE75_cjs.AssetId.fromBytes(s.assetId);
|
|
22376
|
+
return chunkI6EDUE75_cjs.AssetGroup.create(
|
|
21649
22377
|
id,
|
|
21650
22378
|
null,
|
|
21651
|
-
s.inputs.map((i) =>
|
|
21652
|
-
s.outputs.map((o) =>
|
|
21653
|
-
(s.metadata ?? []).map((m) =>
|
|
22379
|
+
s.inputs.map((i) => chunkI6EDUE75_cjs.AssetInput.create(i.vin, i.amount)),
|
|
22380
|
+
s.outputs.map((o) => chunkI6EDUE75_cjs.AssetOutput.create(o.vout, o.amount)),
|
|
22381
|
+
(s.metadata ?? []).map((m) => chunkI6EDUE75_cjs.Metadata.create(m.key, m.value))
|
|
21654
22382
|
);
|
|
21655
22383
|
});
|
|
21656
|
-
return
|
|
22384
|
+
return chunkI6EDUE75_cjs.Packet.create(groups);
|
|
21657
22385
|
}
|
|
21658
22386
|
witnessBytes(ref) {
|
|
21659
|
-
return
|
|
22387
|
+
return chunkG53HASDV_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
|
|
21660
22388
|
}
|
|
21661
22389
|
};
|
|
21662
22390
|
function bindInputs(fn, callArgs) {
|
|
21663
|
-
const names = (fn.def.inputs ?? []).map(
|
|
22391
|
+
const names = (fn.def.inputs ?? []).map(chunkG53HASDV_cjs.inputName);
|
|
21664
22392
|
if (callArgs.length !== names.length) {
|
|
21665
22393
|
throw new Error(`${fn.name}: expected ${names.length} argument(s), got ${callArgs.length}`);
|
|
21666
22394
|
}
|
|
@@ -22042,8 +22770,15 @@ function createDefaultPaymentRouter(wallet) {
|
|
|
22042
22770
|
prefs: { priority: ["ark", "lightning", "onchain"] }
|
|
22043
22771
|
}).use(arkRail()).use(onchainRail());
|
|
22044
22772
|
}
|
|
22773
|
+
/*! Bundled license information:
|
|
22774
|
+
|
|
22775
|
+
@noble/hashes/utils.js:
|
|
22776
|
+
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
22777
|
+
*/
|
|
22045
22778
|
|
|
22046
22779
|
exports.ARKADE_MAGIC = ARKADE_MAGIC;
|
|
22780
|
+
exports.ARKADE_SALTED_PREIMAGE_TAG = ARKADE_SALTED_PREIMAGE_TAG;
|
|
22781
|
+
exports.ARKADE_SWAP_PREIMAGE_TAG = ARKADE_SWAP_PREIMAGE_TAG;
|
|
22047
22782
|
exports.ActivityRegistry = ActivityRegistry;
|
|
22048
22783
|
exports.AmbiguousRouteError = AmbiguousRouteError;
|
|
22049
22784
|
exports.ArkNote = ArkNote;
|
|
@@ -22076,6 +22811,7 @@ exports.EsploraProvider = EsploraProvider;
|
|
|
22076
22811
|
exports.Estimator = Estimator;
|
|
22077
22812
|
exports.Extension = Extension;
|
|
22078
22813
|
exports.ExtensionNotFoundError = ExtensionNotFoundError;
|
|
22814
|
+
exports.ForeignDescriptorError = ForeignDescriptorError;
|
|
22079
22815
|
exports.HDDescriptorProvider = HDDescriptorProvider;
|
|
22080
22816
|
exports.INTENT_TERMINAL_STATES = INTENT_TERMINAL_STATES;
|
|
22081
22817
|
exports.InMemoryContractRepository = InMemoryContractRepository;
|
|
@@ -22124,10 +22860,12 @@ exports.UnilateralExit = UnilateralExit;
|
|
|
22124
22860
|
exports.UnknownPacket = UnknownPacket;
|
|
22125
22861
|
exports.VtxoManager = VtxoManager;
|
|
22126
22862
|
exports.Wallet = Wallet2;
|
|
22863
|
+
exports.WalletCannotSignError = WalletCannotSignError;
|
|
22127
22864
|
exports.WalletMessageHandler = WalletMessageHandler;
|
|
22128
22865
|
exports.WalletNotInitializedError = WalletNotInitializedError;
|
|
22129
22866
|
exports.WalletRepositoryImpl = WalletRepositoryImpl;
|
|
22130
22867
|
exports.WsElectrumChainSource = WsElectrumChainSource;
|
|
22868
|
+
exports.adoptContractDescriptor = adoptContractDescriptor;
|
|
22131
22869
|
exports.arkRail = arkRail;
|
|
22132
22870
|
exports.arkTarget = arkTarget;
|
|
22133
22871
|
exports.arkade_exports = arkade_exports;
|
|
@@ -22142,6 +22880,8 @@ exports.boardingResolver = boardingResolver;
|
|
|
22142
22880
|
exports.btcTarget = btcTarget;
|
|
22143
22881
|
exports.buildForfeitTx = buildForfeitTx;
|
|
22144
22882
|
exports.buildOffchainTx = buildOffchainTx;
|
|
22883
|
+
exports.buildPreimageMessage = buildPreimageMessage;
|
|
22884
|
+
exports.buildSaltedPreimageMessage = buildSaltedPreimageMessage;
|
|
22145
22885
|
exports.claimWithPreimageIdentity = claimWithPreimageIdentity;
|
|
22146
22886
|
exports.classifyAgainstSignerSet = classifyAgainstSignerSet;
|
|
22147
22887
|
exports.classifyContractSigner = classifyContractSigner;
|
|
@@ -22150,6 +22890,8 @@ exports.collabExitResolver = collabExitResolver;
|
|
|
22150
22890
|
exports.combineTapscriptSigs = combineTapscriptSigs;
|
|
22151
22891
|
exports.contractFromArkContract = contractFromArkContract;
|
|
22152
22892
|
exports.contractFromArkContractWithAddress = contractFromArkContractWithAddress;
|
|
22893
|
+
exports.contractPreimage = contractPreimage;
|
|
22894
|
+
exports.contractSigner = contractSigner;
|
|
22153
22895
|
exports.createAssetPacket = createAssetPacket;
|
|
22154
22896
|
exports.createDefaultActivityRegistry = createDefaultActivityRegistry;
|
|
22155
22897
|
exports.createDefaultPaymentRouter = createDefaultPaymentRouter;
|
|
@@ -22177,6 +22919,7 @@ exports.isBatchSignable = isBatchSignable;
|
|
|
22177
22919
|
exports.isBtcAddress = isBtcAddress;
|
|
22178
22920
|
exports.isContractGenericallySpendable = isContractGenericallySpendable;
|
|
22179
22921
|
exports.isCooperativelyMigratable = isCooperativelyMigratable;
|
|
22922
|
+
exports.isDeterministicSigner = isDeterministicSigner;
|
|
22180
22923
|
exports.isDiscoverable = isDiscoverable;
|
|
22181
22924
|
exports.isHDAllocationCapable = isHDAllocationCapable;
|
|
22182
22925
|
exports.isHDDeterministicSignCapable = isHDDeterministicSignCapable;
|
|
@@ -22185,6 +22928,8 @@ exports.isLightningInvoice = isLightningInvoice;
|
|
|
22185
22928
|
exports.isLnurl = isLnurl;
|
|
22186
22929
|
exports.isMessageBusInitializingError = isMessageBusInitializingError;
|
|
22187
22930
|
exports.isMessageBusNotInitializedError = isMessageBusNotInitializedError;
|
|
22931
|
+
exports.isPerArtifactDescriptor = isPerArtifactDescriptor;
|
|
22932
|
+
exports.isSigningIdentity = isSigningIdentity;
|
|
22188
22933
|
exports.isSubdust = isSubdust;
|
|
22189
22934
|
exports.isTerminalIntentState = isTerminalIntentState;
|
|
22190
22935
|
exports.isValidArkAddress = isValidArkAddress;
|
|
@@ -22199,9 +22944,13 @@ exports.migrateWalletRepository = migrateWalletRepository;
|
|
|
22199
22944
|
exports.onchainRail = onchainRail;
|
|
22200
22945
|
exports.openDatabase = openDatabase;
|
|
22201
22946
|
exports.outpointExclusion = outpointExclusion;
|
|
22947
|
+
exports.outpointReasons = outpointReasons;
|
|
22948
|
+
exports.provisionClaimSecret = provisionClaimSecret;
|
|
22949
|
+
exports.provisionRefundKey = provisionRefundKey;
|
|
22202
22950
|
exports.requiresMigration = requiresMigration;
|
|
22203
22951
|
exports.resolveBatchExpiryPolicy = resolveBatchExpiryPolicy;
|
|
22204
22952
|
exports.resolveCheckpointExitDelayPolicy = resolveCheckpointExitDelayPolicy;
|
|
22953
|
+
exports.resolveDescriptorSigner = resolveDescriptorSigner;
|
|
22205
22954
|
exports.resolveSendAmount = resolveSendAmount;
|
|
22206
22955
|
exports.rollbackMigration = rollbackMigration;
|
|
22207
22956
|
exports.saveVtxosForContract = saveVtxosForContract;
|
|
@@ -22225,5 +22974,5 @@ exports.validateVtxoTxGraph = validateVtxoTxGraph;
|
|
|
22225
22974
|
exports.verifyTapscriptSignatures = verifyTapscriptSignatures;
|
|
22226
22975
|
exports.waitForIncomingFunds = waitForIncomingFunds;
|
|
22227
22976
|
exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
|
|
22228
|
-
//# sourceMappingURL=chunk-
|
|
22229
|
-
//# sourceMappingURL=chunk-
|
|
22977
|
+
//# sourceMappingURL=chunk-Z2OZMKFV.cjs.map
|
|
22978
|
+
//# sourceMappingURL=chunk-Z2OZMKFV.cjs.map
|