@arkade-os/sdk 0.5.0-rc.2 → 0.5.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -67
- package/dist/adapters/expo.cjs +5 -6
- package/dist/adapters/expo.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +3 -4
- package/dist/{asyncStorageTaskQueue-C5rBYlru.d.ts → asyncStorageTaskQueue-BCiOgs5x.d.ts} +2 -2
- package/dist/{asyncStorageTaskQueue-BuDvgWh6.d.cts → asyncStorageTaskQueue-CTIwKrt5.d.cts} +2 -2
- package/dist/{chunk-3R476TDV.js → chunk-4EZOMPAO.js} +14 -38
- package/dist/chunk-4EZOMPAO.js.map +1 -0
- package/dist/{chunk-D25O4EGY.cjs → chunk-5NLJUXXQ.cjs} +10 -10
- package/dist/{chunk-D25O4EGY.cjs.map → chunk-5NLJUXXQ.cjs.map} +1 -1
- package/dist/{chunk-JZWLXNHV.cjs → chunk-C5Y2R63Z.cjs} +25 -71
- package/dist/chunk-C5Y2R63Z.cjs.map +1 -0
- package/dist/{chunk-6DNR46C7.js → chunk-CIBGIZUW.js} +4 -4
- package/dist/{chunk-6DNR46C7.js.map → chunk-CIBGIZUW.js.map} +1 -1
- package/dist/{chunk-43FKNLX4.cjs → chunk-F7HJO5GT.cjs} +61 -85
- package/dist/chunk-F7HJO5GT.cjs.map +1 -0
- package/dist/{chunk-ISO4TI5J.js → chunk-GLZNJFAT.js} +25 -67
- package/dist/chunk-GLZNJFAT.js.map +1 -0
- package/dist/{chunk-HLCGYOIH.cjs → chunk-GPJSGLWM.cjs} +17 -17
- package/dist/{chunk-HLCGYOIH.cjs.map → chunk-GPJSGLWM.cjs.map} +1 -1
- package/dist/{chunk-ZOTXDOS5.js → chunk-MOWSLXGO.js} +4 -4
- package/dist/{chunk-ZOTXDOS5.js.map → chunk-MOWSLXGO.js.map} +1 -1
- package/dist/{chunk-ZRNQV6HV.js → chunk-PYTAH2NY.js} +167 -703
- package/dist/chunk-PYTAH2NY.js.map +1 -0
- package/dist/{chunk-NVZJSKZS.cjs → chunk-SYRQJS5N.cjs} +18 -19
- package/dist/chunk-SYRQJS5N.cjs.map +1 -0
- package/dist/{chunk-4PKLULWT.js → chunk-XHASFSDU.js} +3 -4
- package/dist/chunk-XHASFSDU.js.map +1 -0
- package/dist/{chunk-GMZZQXV5.cjs → chunk-ZHLYFRYY.cjs} +583 -1128
- package/dist/chunk-ZHLYFRYY.cjs.map +1 -0
- package/dist/contracts/handlers/index.cjs +9 -10
- package/dist/contracts/handlers/index.d.cts +3 -3
- package/dist/contracts/handlers/index.d.ts +3 -3
- package/dist/contracts/handlers/index.js +2 -3
- package/dist/{delegate-1yp1HyP7.d.cts → delegate-CpQIgTs7.d.cts} +1 -1
- package/dist/{delegate-BAX5QftB.d.ts → delegate-Dv-us16c.d.ts} +1 -1
- package/dist/{hdWalletCapable-CmEU0NP1.d.ts → hdWalletCapable-BC4Fmmht.d.ts} +7 -25
- package/dist/{hdWalletCapable-eJgaT-ec.d.cts → hdWalletCapable-DotEa5rZ.d.cts} +7 -25
- package/dist/{index-DUxufw76.d.ts → index-Czz9HSqE.d.cts} +21 -220
- package/dist/{index-DUxufw76.d.cts → index-Czz9HSqE.d.ts} +21 -220
- package/dist/{index-Bem5vKzX.d.ts → index-DUkvXxpt.d.ts} +3 -3
- package/dist/{index-W_oMcOmG.d.cts → index-DdJt5fRc.d.cts} +3 -3
- package/dist/index.cjs +291 -340
- package/dist/index.d.cts +58 -223
- package/dist/index.d.ts +58 -223
- package/dist/index.js +4 -5
- package/dist/repositories/realm/index.cjs +57 -24
- package/dist/repositories/realm/index.cjs.map +1 -1
- package/dist/repositories/realm/index.d.cts +12 -4
- package/dist/repositories/realm/index.d.ts +12 -4
- package/dist/repositories/realm/index.js +43 -10
- package/dist/repositories/realm/index.js.map +1 -1
- package/dist/repositories/sqlite/index.cjs +103 -33
- package/dist/repositories/sqlite/index.cjs.map +1 -1
- package/dist/repositories/sqlite/index.d.cts +12 -2
- package/dist/repositories/sqlite/index.d.ts +12 -2
- package/dist/repositories/sqlite/index.js +90 -20
- package/dist/repositories/sqlite/index.js.map +1 -1
- package/dist/{taskRunner-Dr3NStc0.d.cts → taskRunner-7E_Rx8bD.d.cts} +2 -2
- package/dist/{taskRunner-D_iPiZIi.d.ts → taskRunner-DUId1UJ8.d.ts} +2 -2
- package/dist/wallet/expo/background.cjs +14 -15
- package/dist/wallet/expo/background.cjs.map +1 -1
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +6 -7
- package/dist/wallet/expo/background.js.map +1 -1
- package/dist/wallet/expo/index.cjs +15 -23
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +4 -7
- package/dist/wallet/expo/index.d.ts +4 -7
- package/dist/wallet/expo/index.js +7 -15
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/worker/expo/index.cjs +9 -10
- package/dist/worker/expo/index.cjs.map +1 -1
- package/dist/worker/expo/index.d.cts +4 -4
- package/dist/worker/expo/index.d.ts +4 -4
- package/dist/worker/expo/index.js +5 -6
- package/dist/worker/expo/index.js.map +1 -1
- package/package.json +4 -42
- package/dist/adapters/asyncStorage.cjs +0 -48
- package/dist/adapters/asyncStorage.cjs.map +0 -1
- package/dist/adapters/asyncStorage.d.cts +0 -16
- package/dist/adapters/asyncStorage.d.ts +0 -16
- package/dist/adapters/asyncStorage.js +0 -46
- package/dist/adapters/asyncStorage.js.map +0 -1
- package/dist/adapters/fileSystem.cjs +0 -116
- package/dist/adapters/fileSystem.cjs.map +0 -1
- package/dist/adapters/fileSystem.d.cts +0 -17
- package/dist/adapters/fileSystem.d.ts +0 -17
- package/dist/adapters/fileSystem.js +0 -93
- package/dist/adapters/fileSystem.js.map +0 -1
- package/dist/adapters/indexedDB.cjs +0 -103
- package/dist/adapters/indexedDB.cjs.map +0 -1
- package/dist/adapters/indexedDB.d.cts +0 -18
- package/dist/adapters/indexedDB.d.ts +0 -18
- package/dist/adapters/indexedDB.js +0 -101
- package/dist/adapters/indexedDB.js.map +0 -1
- package/dist/adapters/localStorage.cjs +0 -50
- package/dist/adapters/localStorage.cjs.map +0 -1
- package/dist/adapters/localStorage.d.cts +0 -14
- package/dist/adapters/localStorage.d.ts +0 -14
- package/dist/adapters/localStorage.js +0 -48
- package/dist/adapters/localStorage.js.map +0 -1
- package/dist/chunk-3R476TDV.js.map +0 -1
- package/dist/chunk-43FKNLX4.cjs.map +0 -1
- package/dist/chunk-4PKLULWT.js.map +0 -1
- package/dist/chunk-5BLDMQED.cjs +0 -18
- package/dist/chunk-5BLDMQED.cjs.map +0 -1
- package/dist/chunk-GMZZQXV5.cjs.map +0 -1
- package/dist/chunk-ISO4TI5J.js.map +0 -1
- package/dist/chunk-JZWLXNHV.cjs.map +0 -1
- package/dist/chunk-NSBPE2FW.js +0 -15
- package/dist/chunk-NSBPE2FW.js.map +0 -1
- package/dist/chunk-NVZJSKZS.cjs.map +0 -1
- package/dist/chunk-ZRNQV6HV.js.map +0 -1
- package/dist/index-C0IanN1m.d.cts +0 -11
- package/dist/index-C0IanN1m.d.ts +0 -11
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var chunk5BLDMQED_cjs = require('./chunk-5BLDMQED.cjs');
|
|
3
|
+
var chunkSYRQJS5N_cjs = require('./chunk-SYRQJS5N.cjs');
|
|
4
|
+
var chunkF7HJO5GT_cjs = require('./chunk-F7HJO5GT.cjs');
|
|
5
|
+
var chunkC5Y2R63Z_cjs = require('./chunk-C5Y2R63Z.cjs');
|
|
7
6
|
var utils_js = require('@scure/btc-signer/utils.js');
|
|
8
7
|
var btcSigner = require('@scure/btc-signer');
|
|
9
8
|
var base = require('@scure/base');
|
|
@@ -188,7 +187,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
188
187
|
noncesByPubkey.set(base.hex.encode(myPublicKey.subarray(1)), myNonce);
|
|
189
188
|
const tx = this.graph.find(txid);
|
|
190
189
|
if (!tx) throw new Error(`missing tx for txid ${txid}`);
|
|
191
|
-
const cosigners =
|
|
190
|
+
const cosigners = chunkC5Y2R63Z_cjs.getArkPsbtFields(tx.root, 0, chunkC5Y2R63Z_cjs.CosignerPublicKey).map(
|
|
192
191
|
(c) => base.hex.encode(c.key.subarray(1))
|
|
193
192
|
// xonly pubkey
|
|
194
193
|
);
|
|
@@ -240,7 +239,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
240
239
|
if (!aggNonce) throw new Error("missing aggregate nonce");
|
|
241
240
|
const prevoutAmounts = [];
|
|
242
241
|
const prevoutScripts = [];
|
|
243
|
-
const cosigners =
|
|
242
|
+
const cosigners = chunkC5Y2R63Z_cjs.getArkPsbtFields(g.root, 0, chunkC5Y2R63Z_cjs.CosignerPublicKey).map((c) => c.key);
|
|
244
243
|
const { finalKey } = aggregateKeys(cosigners, true, {
|
|
245
244
|
taprootTweak: this.scriptRoot
|
|
246
245
|
});
|
|
@@ -323,7 +322,7 @@ var SingleKey = class _SingleKey {
|
|
|
323
322
|
async sign(tx, inputIndexes) {
|
|
324
323
|
const txCpy = tx.clone();
|
|
325
324
|
if (!inputIndexes) {
|
|
326
|
-
|
|
325
|
+
chunkC5Y2R63Z_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH);
|
|
327
326
|
try {
|
|
328
327
|
if (!txCpy.sign(this.key, ALLOWED_SIGHASH)) {
|
|
329
328
|
throw new Error("Failed to sign transaction");
|
|
@@ -432,7 +431,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
432
431
|
let network;
|
|
433
432
|
if ("descriptor" in opts && typeof opts.descriptor === "string") {
|
|
434
433
|
descriptor = opts.descriptor;
|
|
435
|
-
network =
|
|
434
|
+
network = chunkF7HJO5GT_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
436
435
|
} else {
|
|
437
436
|
network = opts.isMainnet ?? true ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
438
437
|
descriptor = descriptorsScure.scriptExpressions.trBIP32({
|
|
@@ -520,29 +519,17 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
520
519
|
async toReadonly() {
|
|
521
520
|
return ReadonlyDescriptorIdentity.fromDescriptor(this.descriptor);
|
|
522
521
|
}
|
|
523
|
-
/**
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
* match by raw pubkey. See {@link descriptorIsOurs}.
|
|
527
|
-
*
|
|
528
|
-
* @deprecated Prefer `DescriptorProvider.isOurs()` via
|
|
529
|
-
* `HDDescriptorProvider` for rotating HD wallets or
|
|
530
|
-
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
531
|
-
*/
|
|
532
|
-
isOurs(descriptor) {
|
|
533
|
-
return chunk43FKNLX4_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
|
|
522
|
+
/** Returns true when `descriptor` is derived from this identity's seed. */
|
|
523
|
+
ownsDescriptor(descriptor) {
|
|
524
|
+
return chunkF7HJO5GT_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
|
|
534
525
|
}
|
|
535
526
|
/**
|
|
536
527
|
* Signs each request with the key derived from its descriptor.
|
|
537
|
-
* Each descriptor must share this identity's seed ({@link
|
|
538
|
-
*
|
|
539
|
-
* @deprecated Prefer `DescriptorProvider.signWithDescriptor()` via
|
|
540
|
-
* `HDDescriptorProvider` or `StaticDescriptorProvider`. Identities keep
|
|
541
|
-
* this method only as backing implementation for descriptor providers.
|
|
528
|
+
* Each descriptor must share this identity's seed ({@link ownsDescriptor}).
|
|
542
529
|
*/
|
|
543
|
-
async
|
|
530
|
+
async signDescriptorTransactions(requests) {
|
|
544
531
|
return requests.map((request) => {
|
|
545
|
-
if (!this.
|
|
532
|
+
if (!this.ownsDescriptor(request.descriptor)) {
|
|
546
533
|
throw new Error(
|
|
547
534
|
`Descriptor ${request.descriptor} does not belong to this identity`
|
|
548
535
|
);
|
|
@@ -551,15 +538,9 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
551
538
|
return this.signTxWithKey(request.tx, key, request.inputIndexes);
|
|
552
539
|
});
|
|
553
540
|
}
|
|
554
|
-
/**
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
* @deprecated Prefer `DescriptorProvider.signMessageWithDescriptor()` via
|
|
558
|
-
* `HDDescriptorProvider` or `StaticDescriptorProvider`. Identities keep
|
|
559
|
-
* this method only as backing implementation for descriptor providers.
|
|
560
|
-
*/
|
|
561
|
-
async signMessageWithDescriptor(descriptor, message, signatureType = "schnorr") {
|
|
562
|
-
if (!this.isOurs(descriptor)) {
|
|
541
|
+
/** Signs a message with the key derived from `descriptor`. */
|
|
542
|
+
async signDescriptorMessage(descriptor, message, signatureType = "schnorr") {
|
|
543
|
+
if (!this.ownsDescriptor(descriptor)) {
|
|
563
544
|
throw new Error(`Descriptor ${descriptor} does not belong to this identity`);
|
|
564
545
|
}
|
|
565
546
|
const key = this.derivePrivateKeyForDescriptor(descriptor);
|
|
@@ -571,7 +552,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
571
552
|
* which swap preimage derivation reads through.
|
|
572
553
|
*/
|
|
573
554
|
async signSchnorrDeterministicWithDescriptor(descriptor, messageHash) {
|
|
574
|
-
if (!this.
|
|
555
|
+
if (!this.ownsDescriptor(descriptor)) {
|
|
575
556
|
throw new Error(`Descriptor ${descriptor} does not belong to this identity`);
|
|
576
557
|
}
|
|
577
558
|
const key = this.derivePrivateKeyForDescriptor(descriptor);
|
|
@@ -579,7 +560,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
579
560
|
}
|
|
580
561
|
// ── internal helpers ─────────────────────────────────────────────
|
|
581
562
|
derivePrivateKeyForDescriptor(descriptor) {
|
|
582
|
-
const network =
|
|
563
|
+
const network = chunkF7HJO5GT_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
583
564
|
const expansion = descriptorsScure.expand({ descriptor, network });
|
|
584
565
|
if (expansion.isRanged) {
|
|
585
566
|
throw new Error(
|
|
@@ -604,7 +585,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
604
585
|
signTxWithKey(tx, key, inputIndexes) {
|
|
605
586
|
const txCpy = tx.clone();
|
|
606
587
|
if (!inputIndexes) {
|
|
607
|
-
|
|
588
|
+
chunkC5Y2R63Z_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH2);
|
|
608
589
|
try {
|
|
609
590
|
if (!txCpy.sign(key, ALLOWED_SIGHASH2)) {
|
|
610
591
|
throw new Error("Failed to sign transaction");
|
|
@@ -666,7 +647,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
666
647
|
*/
|
|
667
648
|
descriptor;
|
|
668
649
|
constructor(descriptor) {
|
|
669
|
-
const network =
|
|
650
|
+
const network = chunkF7HJO5GT_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
670
651
|
let expansion;
|
|
671
652
|
try {
|
|
672
653
|
expansion = descriptorsScure.expand({ descriptor, network, index: 0 });
|
|
@@ -705,18 +686,9 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
705
686
|
}
|
|
706
687
|
return bip32.publicKey;
|
|
707
688
|
}
|
|
708
|
-
/**
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
* fall back to comparing against the index-0 x-only pubkey. See
|
|
712
|
-
* {@link descriptorIsOurs}.
|
|
713
|
-
*
|
|
714
|
-
* @deprecated Prefer `DescriptorProvider.isOurs()` via
|
|
715
|
-
* `HDDescriptorProvider` for rotating HD wallets or
|
|
716
|
-
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
717
|
-
*/
|
|
718
|
-
isOurs(descriptor) {
|
|
719
|
-
return chunk43FKNLX4_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
|
|
689
|
+
/** Returns true when `descriptor` derives from this identity's xpub. */
|
|
690
|
+
ownsDescriptor(descriptor) {
|
|
691
|
+
return chunkF7HJO5GT_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
|
|
720
692
|
}
|
|
721
693
|
};
|
|
722
694
|
function serializeSeedOwnedSigningIdentity(identity) {
|
|
@@ -805,25 +777,9 @@ function hydrateIdentity(s) {
|
|
|
805
777
|
);
|
|
806
778
|
}
|
|
807
779
|
}
|
|
808
|
-
var warnedLegacyShape = false;
|
|
809
780
|
function normalizeSerializedIdentity(shape) {
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
return shape;
|
|
813
|
-
}
|
|
814
|
-
if (!warnedLegacyShape) {
|
|
815
|
-
warnedLegacyShape = true;
|
|
816
|
-
console.warn(
|
|
817
|
-
"[ts-sdk] Received legacy serialized identity shape (privateKey/publicKey). Upgrade the page build to the latest @arkade-os/sdk \u2014 this compatibility path will be removed in the next major."
|
|
818
|
-
);
|
|
819
|
-
}
|
|
820
|
-
if ("privateKey" in shape && typeof shape.privateKey === "string") {
|
|
821
|
-
return { type: "single-key", privateKey: shape.privateKey };
|
|
822
|
-
}
|
|
823
|
-
if ("publicKey" in shape && typeof shape.publicKey === "string") {
|
|
824
|
-
return { type: "readonly-single-key", publicKey: shape.publicKey };
|
|
825
|
-
}
|
|
826
|
-
throw new Error("Unrecognized serialized identity shape");
|
|
781
|
+
assertValidSerializedIdentity(shape);
|
|
782
|
+
return shape;
|
|
827
783
|
}
|
|
828
784
|
function assertValidSerializedIdentity(s) {
|
|
829
785
|
const kind = s.type;
|
|
@@ -878,10 +834,10 @@ var DescriptorIdentity = class {
|
|
|
878
834
|
this.base = base;
|
|
879
835
|
}
|
|
880
836
|
async xOnlyPublicKey() {
|
|
881
|
-
return
|
|
837
|
+
return chunkF7HJO5GT_cjs.deriveDescriptorLeafPubKey(this.descriptor);
|
|
882
838
|
}
|
|
883
839
|
async compressedPublicKey() {
|
|
884
|
-
return
|
|
840
|
+
return chunkF7HJO5GT_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
|
|
885
841
|
}
|
|
886
842
|
async sign(tx, inputIndexes) {
|
|
887
843
|
const [signed] = await this.signer.signWithDescriptor([
|
|
@@ -921,7 +877,7 @@ var DescriptorIdentity = class {
|
|
|
921
877
|
function isHDCapableIdentity(value) {
|
|
922
878
|
if (typeof value !== "object" || value === null) return false;
|
|
923
879
|
const v = value;
|
|
924
|
-
return typeof v.descriptor === "string" && typeof v.
|
|
880
|
+
return typeof v.descriptor === "string" && typeof v.ownsDescriptor === "function" && typeof v.signDescriptorTransactions === "function" && typeof v.signDescriptorMessage === "function";
|
|
925
881
|
}
|
|
926
882
|
|
|
927
883
|
// src/identity/index.ts
|
|
@@ -948,13 +904,18 @@ var WalletCannotAllocateAddressError = class extends Error {
|
|
|
948
904
|
}
|
|
949
905
|
};
|
|
950
906
|
async function resolveDescriptorSigner(descriptor, identity, provider) {
|
|
951
|
-
const
|
|
952
|
-
|
|
907
|
+
const providerOwner = provider?.isOurs(descriptor) ? provider : void 0;
|
|
908
|
+
const identityOwner = !providerOwner && isHDCapableIdentity(identity) && identity.ownsDescriptor(descriptor) ? {
|
|
909
|
+
signWithDescriptor: (requests) => identity.signDescriptorTransactions(requests),
|
|
910
|
+
signMessageWithDescriptor: (ownedDescriptor, message, signatureType) => identity.signDescriptorMessage(ownedDescriptor, message, signatureType)
|
|
911
|
+
} : void 0;
|
|
912
|
+
const owner = providerOwner ?? identityOwner;
|
|
913
|
+
if (owner && chunkF7HJO5GT_cjs.parseHDDescriptor(descriptor)) {
|
|
953
914
|
return new DescriptorIdentity({ descriptor, signer: owner, base: identity });
|
|
954
915
|
}
|
|
955
916
|
let key;
|
|
956
917
|
try {
|
|
957
|
-
key =
|
|
918
|
+
key = chunkF7HJO5GT_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
958
919
|
} catch {
|
|
959
920
|
throw new ForeignDescriptorError(descriptor);
|
|
960
921
|
}
|
|
@@ -1329,14 +1290,14 @@ function buildSaltedPreimageMessage(xonly, salt) {
|
|
|
1329
1290
|
}
|
|
1330
1291
|
var PREIMAGE_INDEX = 0;
|
|
1331
1292
|
function isPerArtifactDescriptor(descriptor) {
|
|
1332
|
-
return
|
|
1293
|
+
return chunkF7HJO5GT_cjs.parseHDDescriptor(descriptor) !== null;
|
|
1333
1294
|
}
|
|
1334
1295
|
async function provisionDescriptor(wallet) {
|
|
1335
1296
|
const allocated = isHDAllocationCapable(wallet) ? await wallet.getNextSigningDescriptor() : void 0;
|
|
1336
|
-
return allocated ?? await
|
|
1297
|
+
return allocated ?? await chunkF7HJO5GT_cjs.identityDescriptor(wallet.identity);
|
|
1337
1298
|
}
|
|
1338
1299
|
async function provisionRefundKey(wallet) {
|
|
1339
|
-
const descriptor = await
|
|
1300
|
+
const descriptor = await chunkF7HJO5GT_cjs.identityDescriptor(wallet.identity);
|
|
1340
1301
|
const signer = await contractSigner(wallet, descriptor);
|
|
1341
1302
|
const pubkey = await signer.xOnlyPublicKey();
|
|
1342
1303
|
const identityPubkey = await wallet.identity.xOnlyPublicKey();
|
|
@@ -1346,7 +1307,7 @@ async function provisionRefundKey(wallet) {
|
|
|
1346
1307
|
);
|
|
1347
1308
|
}
|
|
1348
1309
|
const address = await wallet.getAddress();
|
|
1349
|
-
const { pkScript } =
|
|
1310
|
+
const { pkScript } = chunkC5Y2R63Z_cjs.ArkAddress.decode(address);
|
|
1350
1311
|
return { descriptor, pubkey, pkScript, address };
|
|
1351
1312
|
}
|
|
1352
1313
|
async function provisionClaimSecret(wallet, opts = {}) {
|
|
@@ -1392,7 +1353,7 @@ async function contractSigner(wallet, descriptor) {
|
|
|
1392
1353
|
const signer = isHDWalletCapable(wallet) ? await wallet.signerForDescriptor(descriptor) : wallet.identity;
|
|
1393
1354
|
let expected;
|
|
1394
1355
|
try {
|
|
1395
|
-
expected =
|
|
1356
|
+
expected = chunkF7HJO5GT_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
1396
1357
|
} catch (cause) {
|
|
1397
1358
|
throw new ForeignDescriptorError(descriptor, { cause });
|
|
1398
1359
|
}
|
|
@@ -1611,14 +1572,14 @@ var RestDelegateProvider = class {
|
|
|
1611
1572
|
*/
|
|
1612
1573
|
async delegate(intent, forfeitTxs, options) {
|
|
1613
1574
|
const url = `${this.url}/v1/delegate`;
|
|
1614
|
-
const response = await
|
|
1575
|
+
const response = await chunkC5Y2R63Z_cjs.baseFetch(url, {
|
|
1615
1576
|
method: "POST",
|
|
1616
1577
|
headers: {
|
|
1617
1578
|
"Content-Type": "application/json"
|
|
1618
1579
|
},
|
|
1619
1580
|
body: JSON.stringify({
|
|
1620
1581
|
intent: {
|
|
1621
|
-
message:
|
|
1582
|
+
message: chunkC5Y2R63Z_cjs.Intent.encodeMessage(intent.message),
|
|
1622
1583
|
proof: intent.proof
|
|
1623
1584
|
},
|
|
1624
1585
|
forfeit_txs: forfeitTxs,
|
|
@@ -1638,7 +1599,7 @@ var RestDelegateProvider = class {
|
|
|
1638
1599
|
*/
|
|
1639
1600
|
async getDelegateInfo() {
|
|
1640
1601
|
const url = `${this.url}/v1/delegator/info`;
|
|
1641
|
-
const response = await
|
|
1602
|
+
const response = await chunkC5Y2R63Z_cjs.rateGate.runHttp(url, () => chunkC5Y2R63Z_cjs.baseFetch(url));
|
|
1642
1603
|
if (!response.ok) {
|
|
1643
1604
|
const errorText2 = await response.text();
|
|
1644
1605
|
throw new Error(`Failed to get delegate info: ${errorText2}`);
|
|
@@ -1647,13 +1608,11 @@ var RestDelegateProvider = class {
|
|
|
1647
1608
|
if (!isDelegateInfo(data)) {
|
|
1648
1609
|
throw new Error("Invalid delegate info");
|
|
1649
1610
|
}
|
|
1650
|
-
|
|
1651
|
-
return { ...data, delegateAddress };
|
|
1611
|
+
return data;
|
|
1652
1612
|
}
|
|
1653
1613
|
};
|
|
1654
|
-
var RestDelegatorProvider = RestDelegateProvider;
|
|
1655
1614
|
function isDelegateInfo(data) {
|
|
1656
|
-
return !!data && typeof data === "object" && "pubkey" in data && "fee" in data && typeof data.pubkey === "string" && typeof data.fee === "string" && data.pubkey !== "" && data.fee !== "" &&
|
|
1615
|
+
return !!data && typeof data === "object" && "pubkey" in data && "fee" in data && typeof data.pubkey === "string" && typeof data.fee === "string" && data.pubkey !== "" && data.fee !== "" && typeof data.delegateAddress === "string" && data.delegateAddress !== "";
|
|
1657
1616
|
}
|
|
1658
1617
|
var ESPLORA_URL = {
|
|
1659
1618
|
bitcoin: "https://mempool.arkade.sh/api",
|
|
@@ -1663,7 +1622,7 @@ var ESPLORA_URL = {
|
|
|
1663
1622
|
regtest: "http://localhost:3000/api"
|
|
1664
1623
|
};
|
|
1665
1624
|
var EsploraProvider = class {
|
|
1666
|
-
constructor(baseUrl = ESPLORA_URL[
|
|
1625
|
+
constructor(baseUrl = ESPLORA_URL[chunkC5Y2R63Z_cjs.DEFAULT_NETWORK_NAME], opts) {
|
|
1667
1626
|
this.baseUrl = baseUrl;
|
|
1668
1627
|
this.pollingInterval = opts?.pollingInterval ?? 15e3;
|
|
1669
1628
|
this.forcePolling = opts?.forcePolling ?? false;
|
|
@@ -1682,14 +1641,14 @@ var EsploraProvider = class {
|
|
|
1682
1641
|
*/
|
|
1683
1642
|
addressWatches = /* @__PURE__ */ new Map();
|
|
1684
1643
|
async getCoins(address) {
|
|
1685
|
-
const response = await
|
|
1644
|
+
const response = await chunkC5Y2R63Z_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
|
|
1686
1645
|
if (!response.ok) {
|
|
1687
1646
|
throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
|
|
1688
1647
|
}
|
|
1689
1648
|
return response.json();
|
|
1690
1649
|
}
|
|
1691
1650
|
async getFeeRate() {
|
|
1692
|
-
const response = await
|
|
1651
|
+
const response = await chunkC5Y2R63Z_cjs.baseFetch(`${this.baseUrl}/fee-estimates`);
|
|
1693
1652
|
if (response.status === 404) {
|
|
1694
1653
|
return void 0;
|
|
1695
1654
|
}
|
|
@@ -1710,7 +1669,7 @@ var EsploraProvider = class {
|
|
|
1710
1669
|
}
|
|
1711
1670
|
}
|
|
1712
1671
|
async getTxOutspends(txid) {
|
|
1713
|
-
const response = await
|
|
1672
|
+
const response = await chunkC5Y2R63Z_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
|
|
1714
1673
|
if (!response.ok) {
|
|
1715
1674
|
const error = await response.text();
|
|
1716
1675
|
throw new Error(`Failed to get transaction outspends: ${error}`);
|
|
@@ -1718,7 +1677,7 @@ var EsploraProvider = class {
|
|
|
1718
1677
|
return response.json();
|
|
1719
1678
|
}
|
|
1720
1679
|
async getTransactions(address) {
|
|
1721
|
-
const response = await
|
|
1680
|
+
const response = await chunkC5Y2R63Z_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
|
|
1722
1681
|
if (!response.ok) {
|
|
1723
1682
|
const error = await response.text();
|
|
1724
1683
|
throw new Error(`Failed to get transactions: ${error}`);
|
|
@@ -1731,14 +1690,14 @@ var EsploraProvider = class {
|
|
|
1731
1690
|
* usable as a change probe for the polling fallback.
|
|
1732
1691
|
*/
|
|
1733
1692
|
async getAddressStats(address) {
|
|
1734
|
-
const response = await
|
|
1693
|
+
const response = await chunkC5Y2R63Z_cjs.baseFetch(`${this.baseUrl}/address/${address}`);
|
|
1735
1694
|
if (!response.ok) {
|
|
1736
1695
|
throw new Error(`Failed to get address stats: ${response.statusText}`);
|
|
1737
1696
|
}
|
|
1738
1697
|
return response.json();
|
|
1739
1698
|
}
|
|
1740
1699
|
async getRawTransaction(txid) {
|
|
1741
|
-
const response = await
|
|
1700
|
+
const response = await chunkC5Y2R63Z_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/hex`);
|
|
1742
1701
|
if (!response.ok) {
|
|
1743
1702
|
const error = await response.text();
|
|
1744
1703
|
throw new Error(`Failed to get raw transaction ${txid}: ${error}`);
|
|
@@ -1746,7 +1705,7 @@ var EsploraProvider = class {
|
|
|
1746
1705
|
return base.hex.decode((await response.text()).trim());
|
|
1747
1706
|
}
|
|
1748
1707
|
async getTxStatus(txid) {
|
|
1749
|
-
const txresponse = await
|
|
1708
|
+
const txresponse = await chunkC5Y2R63Z_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
|
|
1750
1709
|
if (!txresponse.ok) {
|
|
1751
1710
|
throw new Error(txresponse.statusText);
|
|
1752
1711
|
}
|
|
@@ -1754,7 +1713,7 @@ var EsploraProvider = class {
|
|
|
1754
1713
|
if (!tx.status.confirmed) {
|
|
1755
1714
|
return { confirmed: false };
|
|
1756
1715
|
}
|
|
1757
|
-
const response = await
|
|
1716
|
+
const response = await chunkC5Y2R63Z_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
|
|
1758
1717
|
if (!response.ok) {
|
|
1759
1718
|
throw new Error(`Failed to get transaction status: ${response.statusText}`);
|
|
1760
1719
|
}
|
|
@@ -2038,7 +1997,10 @@ var EsploraProvider = class {
|
|
|
2038
1997
|
return { subscribers, teardown, started };
|
|
2039
1998
|
}
|
|
2040
1999
|
async getChainTip() {
|
|
2041
|
-
|
|
2000
|
+
let tipBlocks = await chunkC5Y2R63Z_cjs.baseFetch(`${this.baseUrl}/blocks`);
|
|
2001
|
+
if (tipBlocks.status === 404) {
|
|
2002
|
+
tipBlocks = await chunkC5Y2R63Z_cjs.baseFetch(`${this.baseUrl}/v1/blocks`);
|
|
2003
|
+
}
|
|
2042
2004
|
if (!tipBlocks.ok) {
|
|
2043
2005
|
throw new Error(`Failed to get chain tip: ${tipBlocks.statusText}`);
|
|
2044
2006
|
}
|
|
@@ -2059,7 +2021,7 @@ var EsploraProvider = class {
|
|
|
2059
2021
|
};
|
|
2060
2022
|
}
|
|
2061
2023
|
async broadcastPackage(parent, child) {
|
|
2062
|
-
const response = await
|
|
2024
|
+
const response = await chunkC5Y2R63Z_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
|
|
2063
2025
|
method: "POST",
|
|
2064
2026
|
headers: {
|
|
2065
2027
|
"Content-Type": "application/json"
|
|
@@ -2075,7 +2037,7 @@ var EsploraProvider = class {
|
|
|
2075
2037
|
return result;
|
|
2076
2038
|
}
|
|
2077
2039
|
async broadcastTx(tx) {
|
|
2078
|
-
const response = await
|
|
2040
|
+
const response = await chunkC5Y2R63Z_cjs.baseFetch(`${this.baseUrl}/tx`, {
|
|
2079
2041
|
method: "POST",
|
|
2080
2042
|
headers: {
|
|
2081
2043
|
"Content-Type": "text/plain"
|
|
@@ -2258,7 +2220,7 @@ function findP2AOutput(tx) {
|
|
|
2258
2220
|
var CHILD_DUST_AMOUNT = 546;
|
|
2259
2221
|
function buildAnchorChild(params) {
|
|
2260
2222
|
const { parent, feeRate, fundingCoins, changeAddress, tapInternalKey, network } = params;
|
|
2261
|
-
const child = new
|
|
2223
|
+
const child = new chunkC5Y2R63Z_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
|
|
2262
2224
|
child.addInput(findP2AOutput(parent));
|
|
2263
2225
|
const estimator = TxWeightEstimator.create().addP2AInput();
|
|
2264
2226
|
for (const _ of fundingCoins) {
|
|
@@ -2306,7 +2268,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
|
|
|
2306
2268
|
);
|
|
2307
2269
|
}
|
|
2308
2270
|
function buildForfeitTxWithOutput(inputs, output, txLocktime) {
|
|
2309
|
-
const tx = new
|
|
2271
|
+
const tx = new chunkC5Y2R63Z_cjs.Transaction({
|
|
2310
2272
|
version: 3,
|
|
2311
2273
|
lockTime: txLocktime
|
|
2312
2274
|
});
|
|
@@ -2382,7 +2344,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
|
|
|
2382
2344
|
if (previousScriptKey.length !== 32) {
|
|
2383
2345
|
throw new Error(`parent output ${childIndex} has invalid script`);
|
|
2384
2346
|
}
|
|
2385
|
-
const cosigners =
|
|
2347
|
+
const cosigners = chunkC5Y2R63Z_cjs.getArkPsbtFields(child.root, 0, chunkC5Y2R63Z_cjs.CosignerPublicKey);
|
|
2386
2348
|
if (cosigners.length === 0) {
|
|
2387
2349
|
throw ErrMissingCosignersPublicKeys;
|
|
2388
2350
|
}
|
|
@@ -2440,7 +2402,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
2440
2402
|
return new _EmulatorPacket(entries);
|
|
2441
2403
|
}
|
|
2442
2404
|
static fromBytes(data) {
|
|
2443
|
-
const reader = new
|
|
2405
|
+
const reader = new chunkSYRQJS5N_cjs.BufferReader(data);
|
|
2444
2406
|
const entryCount = reader.readCompactSize();
|
|
2445
2407
|
const entries = [];
|
|
2446
2408
|
for (let i = 0; i < entryCount; i++) {
|
|
@@ -2458,7 +2420,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
2458
2420
|
return _EmulatorPacket.PACKET_TYPE;
|
|
2459
2421
|
}
|
|
2460
2422
|
serialize() {
|
|
2461
|
-
const writer = new
|
|
2423
|
+
const writer = new chunkSYRQJS5N_cjs.BufferWriter();
|
|
2462
2424
|
writer.writeCompactSize(this.entries.length);
|
|
2463
2425
|
for (const entry of this.entries) {
|
|
2464
2426
|
writer.writeUint16LE(entry.vin);
|
|
@@ -2545,7 +2507,7 @@ var Extension = class _Extension {
|
|
|
2545
2507
|
`expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
|
|
2546
2508
|
);
|
|
2547
2509
|
}
|
|
2548
|
-
const reader = new
|
|
2510
|
+
const reader = new chunkSYRQJS5N_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
|
|
2549
2511
|
const packets = [];
|
|
2550
2512
|
while (reader.remaining() > 0) {
|
|
2551
2513
|
const packetType = reader.readByte();
|
|
@@ -2619,7 +2581,7 @@ var Extension = class _Extension {
|
|
|
2619
2581
|
*/
|
|
2620
2582
|
getAssetPacket() {
|
|
2621
2583
|
for (const p of this.packets) {
|
|
2622
|
-
if (p instanceof
|
|
2584
|
+
if (p instanceof chunkSYRQJS5N_cjs.Packet) {
|
|
2623
2585
|
return p;
|
|
2624
2586
|
}
|
|
2625
2587
|
}
|
|
@@ -2657,8 +2619,8 @@ var Extension = class _Extension {
|
|
|
2657
2619
|
};
|
|
2658
2620
|
function parsePacket(packetType, data) {
|
|
2659
2621
|
switch (packetType) {
|
|
2660
|
-
case
|
|
2661
|
-
return
|
|
2622
|
+
case chunkSYRQJS5N_cjs.Packet.PACKET_TYPE:
|
|
2623
|
+
return chunkSYRQJS5N_cjs.Packet.fromBytes(data);
|
|
2662
2624
|
case EmulatorPacket.PACKET_TYPE:
|
|
2663
2625
|
return EmulatorPacket.fromBytes(data);
|
|
2664
2626
|
default:
|
|
@@ -2705,16 +2667,16 @@ function buildOpReturnScript(data) {
|
|
|
2705
2667
|
}
|
|
2706
2668
|
return script;
|
|
2707
2669
|
}
|
|
2708
|
-
var ErrOffchainOutputNotFound = (address) => new
|
|
2709
|
-
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new
|
|
2670
|
+
var ErrOffchainOutputNotFound = (address) => new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
|
|
2671
|
+
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
|
|
2710
2672
|
`invalid asset output amount for ${assetId}: got ${got}, want ${want}`
|
|
2711
2673
|
);
|
|
2712
|
-
var ErrAssetGroupNotFound = (assetId) => new
|
|
2713
|
-
var ErrAssetOutputNotFound = (assetId, outputIndex) => new
|
|
2674
|
+
var ErrAssetGroupNotFound = (assetId) => new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
|
|
2675
|
+
var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
|
|
2714
2676
|
`asset output not found in asset group ${assetId} at index ${outputIndex}`
|
|
2715
2677
|
);
|
|
2716
|
-
var ErrOnchainOutputNotFound = (address) => new
|
|
2717
|
-
var ErrUnvalidatedOffchainOutput = (address) => new
|
|
2678
|
+
var ErrOnchainOutputNotFound = (address) => new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
|
|
2679
|
+
var ErrUnvalidatedOffchainOutput = (address) => new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
|
|
2718
2680
|
`offchain output ${address} cannot be validated: virtual output tree signing did not run`
|
|
2719
2681
|
);
|
|
2720
2682
|
var ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
|
|
@@ -2723,7 +2685,7 @@ var ErrInvalidOffchainOutputAmount = (address) => new Error(`invalid offchain ou
|
|
|
2723
2685
|
function assertFinalCommitmentMatchesValidated(finalCommitmentTx, validatedCommitmentTxid, context) {
|
|
2724
2686
|
if (!validatedCommitmentTxid) return;
|
|
2725
2687
|
if (finalCommitmentTx.id === validatedCommitmentTxid) return;
|
|
2726
|
-
throw new
|
|
2688
|
+
throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
|
|
2727
2689
|
`${context}: finalization commitment tx ${finalCommitmentTx.id} differs from the validated commitment tx ${validatedCommitmentTxid}`
|
|
2728
2690
|
);
|
|
2729
2691
|
}
|
|
@@ -2733,7 +2695,7 @@ function validateBatchRecipients(commitmentTx, vtxoTreeLeaves, recipients, netwo
|
|
|
2733
2695
|
for (const recipient of recipients) {
|
|
2734
2696
|
let arkAddress;
|
|
2735
2697
|
try {
|
|
2736
|
-
arkAddress =
|
|
2698
|
+
arkAddress = chunkC5Y2R63Z_cjs.ArkAddress.decode(recipient.address);
|
|
2737
2699
|
} catch {
|
|
2738
2700
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
2739
2701
|
continue;
|
|
@@ -2745,7 +2707,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
|
|
|
2745
2707
|
const usedOnchainOutputs = /* @__PURE__ */ new Set();
|
|
2746
2708
|
for (const recipient of recipients) {
|
|
2747
2709
|
try {
|
|
2748
|
-
|
|
2710
|
+
chunkC5Y2R63Z_cjs.ArkAddress.decode(recipient.address);
|
|
2749
2711
|
} catch {
|
|
2750
2712
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
2751
2713
|
continue;
|
|
@@ -2978,7 +2940,7 @@ function assetMintResolver() {
|
|
|
2978
2940
|
if (!tx.assets?.length || !tx.key.arkTxid) return void 0;
|
|
2979
2941
|
const minted = tx.assets.filter((a) => {
|
|
2980
2942
|
try {
|
|
2981
|
-
return base.hex.encode(
|
|
2943
|
+
return base.hex.encode(chunkSYRQJS5N_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
|
|
2982
2944
|
} catch {
|
|
2983
2945
|
return false;
|
|
2984
2946
|
}
|
|
@@ -3021,7 +2983,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3021
2983
|
const existing = inputsByAssetId.get(asset.assetId);
|
|
3022
2984
|
inputsByAssetId.set(asset.assetId, [
|
|
3023
2985
|
...existing ?? [],
|
|
3024
|
-
|
|
2986
|
+
chunkSYRQJS5N_cjs.AssetInput.create(inputIndex, asset.amount)
|
|
3025
2987
|
]);
|
|
3026
2988
|
}
|
|
3027
2989
|
}
|
|
@@ -3033,7 +2995,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3033
2995
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
3034
2996
|
outputsByAssetId.set(asset.assetId, [
|
|
3035
2997
|
...existing ?? [],
|
|
3036
|
-
|
|
2998
|
+
chunkSYRQJS5N_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
3037
2999
|
]);
|
|
3038
3000
|
}
|
|
3039
3001
|
}
|
|
@@ -3044,7 +3006,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3044
3006
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
3045
3007
|
outputsByAssetId.set(asset.assetId, [
|
|
3046
3008
|
...existing ?? [],
|
|
3047
|
-
|
|
3009
|
+
chunkSYRQJS5N_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
3048
3010
|
]);
|
|
3049
3011
|
}
|
|
3050
3012
|
}
|
|
@@ -3053,11 +3015,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3053
3015
|
for (const assetIdStr of allAssetIds) {
|
|
3054
3016
|
const inputs = inputsByAssetId.get(assetIdStr);
|
|
3055
3017
|
const outputs = outputsByAssetId.get(assetIdStr);
|
|
3056
|
-
const assetId =
|
|
3057
|
-
const group =
|
|
3018
|
+
const assetId = chunkSYRQJS5N_cjs.AssetId.fromString(assetIdStr);
|
|
3019
|
+
const group = chunkSYRQJS5N_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
|
|
3058
3020
|
groups.push(group);
|
|
3059
3021
|
}
|
|
3060
|
-
return
|
|
3022
|
+
return chunkSYRQJS5N_cjs.Packet.create(groups);
|
|
3061
3023
|
}
|
|
3062
3024
|
function selectCoinsWithAsset(coins, assetId, requiredAmount) {
|
|
3063
3025
|
const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
|
|
@@ -3094,7 +3056,7 @@ function selectedCoinsToAssetInputs(selectedCoins) {
|
|
|
3094
3056
|
}
|
|
3095
3057
|
function toXOnlySignerHex(pubkeyHex) {
|
|
3096
3058
|
const bytes = base.hex.decode(pubkeyHex);
|
|
3097
|
-
if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(
|
|
3059
|
+
if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(chunkF7HJO5GT_cjs.toXOnly(bytes, "signer key"));
|
|
3098
3060
|
throw new Error(`invalid signer pubkey length: expected 32 or 33 bytes, got ${bytes.length}`);
|
|
3099
3061
|
}
|
|
3100
3062
|
function signerSetFromInfo(info) {
|
|
@@ -3141,13 +3103,13 @@ var toTimelock = (value) => ({
|
|
|
3141
3103
|
var toSeconds = (t) => t.type === "seconds" ? t.value : t.value * NOMINAL_BLOCK_SECONDS;
|
|
3142
3104
|
function assertTimelockInPolicy(timelock, policy, label, overrideOption) {
|
|
3143
3105
|
if (policy.requireSeconds && timelock.type === "blocks") {
|
|
3144
|
-
throw new
|
|
3106
|
+
throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
|
|
3145
3107
|
`${label} rejected: block-typed timelocks are not accepted (got ${timelock.value})`
|
|
3146
3108
|
);
|
|
3147
3109
|
}
|
|
3148
3110
|
const seconds = toSeconds(timelock);
|
|
3149
3111
|
if (seconds < policy.minSeconds) {
|
|
3150
|
-
throw new
|
|
3112
|
+
throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
|
|
3151
3113
|
`${label} rejected: ${timelock.value} ${timelock.type} is below the ${policy.minSeconds}s floor; pass ${overrideOption}: ${seconds}n to Wallet.create to lower it`
|
|
3152
3114
|
);
|
|
3153
3115
|
}
|
|
@@ -3168,7 +3130,7 @@ function resolveBatchExpiryPolicy(network, overrides) {
|
|
|
3168
3130
|
}
|
|
3169
3131
|
function assertValidBatchExpiry(batchExpiry, policy) {
|
|
3170
3132
|
if (policy.advertisedVtxoTreeExpiry !== void 0 && batchExpiry !== policy.advertisedVtxoTreeExpiry) {
|
|
3171
|
-
throw new
|
|
3133
|
+
throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
|
|
3172
3134
|
`batch expiry rejected: ${batchExpiry} does not match the advertised vtxoTreeExpiry ${policy.advertisedVtxoTreeExpiry}`
|
|
3173
3135
|
);
|
|
3174
3136
|
}
|
|
@@ -3198,21 +3160,21 @@ function resolveCheckpointExitDelayPolicy(network, overrides) {
|
|
|
3198
3160
|
function assertValidServerUnrollScript(checkpointTapscript, policy) {
|
|
3199
3161
|
let script;
|
|
3200
3162
|
try {
|
|
3201
|
-
script =
|
|
3163
|
+
script = chunkC5Y2R63Z_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
|
|
3202
3164
|
} catch (e) {
|
|
3203
|
-
throw new
|
|
3165
|
+
throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
|
|
3204
3166
|
`checkpoint exit delay rejected: invalid checkpointTapscript from server (${e instanceof Error ? e.message : String(e)})`
|
|
3205
3167
|
);
|
|
3206
3168
|
}
|
|
3207
3169
|
if (policy.advertisedForfeitPubkey !== void 0) {
|
|
3208
3170
|
const { pubkeys } = script.params;
|
|
3209
3171
|
if (pubkeys.length !== 1) {
|
|
3210
|
-
throw new
|
|
3172
|
+
throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
|
|
3211
3173
|
`checkpoint exit delay rejected: checkpointTapscript must commit to exactly one pubkey, got ${pubkeys.length} [${pubkeys.map(base.hex.encode).join(", ")}]`
|
|
3212
3174
|
);
|
|
3213
3175
|
}
|
|
3214
3176
|
if (!utils_js.equalBytes(pubkeys[0], policy.advertisedForfeitPubkey)) {
|
|
3215
|
-
throw new
|
|
3177
|
+
throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
|
|
3216
3178
|
`checkpoint exit delay rejected: checkpointTapscript pubkey ${base.hex.encode(pubkeys[0])} does not match the advertised forfeitPubkey ${base.hex.encode(policy.advertisedForfeitPubkey)}`
|
|
3217
3179
|
);
|
|
3218
3180
|
}
|
|
@@ -3256,8 +3218,8 @@ function buildOffchainTx(inputs, outputs, serverUnrollScript) {
|
|
|
3256
3218
|
function buildVirtualTx(inputs, outputs) {
|
|
3257
3219
|
let lockTime = 0n;
|
|
3258
3220
|
for (const input of inputs) {
|
|
3259
|
-
const tapscript =
|
|
3260
|
-
if (
|
|
3221
|
+
const tapscript = chunkC5Y2R63Z_cjs.decodeTapscript(chunkC5Y2R63Z_cjs.scriptFromTapLeafScript(input.tapLeafScript));
|
|
3222
|
+
if (chunkC5Y2R63Z_cjs.CLTVMultisigTapscript.is(tapscript)) {
|
|
3261
3223
|
if (lockTime !== 0n) {
|
|
3262
3224
|
if (isSeconds(lockTime) !== isSeconds(tapscript.params.absoluteTimelock)) {
|
|
3263
3225
|
throw new Error("cannot mix seconds and blocks locktime");
|
|
@@ -3268,7 +3230,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3268
3230
|
}
|
|
3269
3231
|
}
|
|
3270
3232
|
}
|
|
3271
|
-
const tx = new
|
|
3233
|
+
const tx = new chunkC5Y2R63Z_cjs.Transaction({
|
|
3272
3234
|
version: 3,
|
|
3273
3235
|
lockTime: Number(lockTime)
|
|
3274
3236
|
});
|
|
@@ -3278,12 +3240,12 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3278
3240
|
index: input.vout,
|
|
3279
3241
|
sequence: lockTime ? btcSigner.DEFAULT_SEQUENCE - 1 : void 0,
|
|
3280
3242
|
witnessUtxo: {
|
|
3281
|
-
script:
|
|
3243
|
+
script: chunkC5Y2R63Z_cjs.VtxoScript.decode(input.tapTree).pkScript,
|
|
3282
3244
|
amount: BigInt(input.value)
|
|
3283
3245
|
},
|
|
3284
3246
|
tapLeafScript: [input.tapLeafScript]
|
|
3285
3247
|
});
|
|
3286
|
-
|
|
3248
|
+
chunkC5Y2R63Z_cjs.setArkPsbtField(tx, i, chunkC5Y2R63Z_cjs.VtxoTaprootTree, input.tapTree);
|
|
3287
3249
|
}
|
|
3288
3250
|
for (const output of outputs) {
|
|
3289
3251
|
tx.addOutput(output);
|
|
@@ -3292,8 +3254,8 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3292
3254
|
return tx;
|
|
3293
3255
|
}
|
|
3294
3256
|
function buildCheckpointTx(vtxo, serverUnrollScript) {
|
|
3295
|
-
const collaborativeClosure =
|
|
3296
|
-
const checkpointVtxoScript = new
|
|
3257
|
+
const collaborativeClosure = chunkC5Y2R63Z_cjs.decodeTapscript(chunkC5Y2R63Z_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
|
|
3258
|
+
const checkpointVtxoScript = new chunkC5Y2R63Z_cjs.VtxoScript([
|
|
3297
3259
|
serverUnrollScript.script,
|
|
3298
3260
|
collaborativeClosure.script
|
|
3299
3261
|
]);
|
|
@@ -3369,7 +3331,7 @@ function verifyTapscriptSignatures(tx, inputIndex, requiredSigners, excludePubke
|
|
|
3369
3331
|
const sighashType = signature.length === 65 ? signature[64] : btcSigner.SigHash.DEFAULT;
|
|
3370
3332
|
const sig = signature.subarray(0, 64);
|
|
3371
3333
|
if (!allowedSighashTypes.includes(sighashType)) {
|
|
3372
|
-
const sighashName =
|
|
3334
|
+
const sighashName = chunkC5Y2R63Z_cjs.formatSighash(sighashType);
|
|
3373
3335
|
throw new Error(
|
|
3374
3336
|
`Unallowed sighash type ${sighashName} for input ${inputIndex}, pubkey ${pubKeyHex}.`
|
|
3375
3337
|
);
|
|
@@ -3443,7 +3405,7 @@ function combineTapscriptSigs(signedTx, originalTx) {
|
|
|
3443
3405
|
}
|
|
3444
3406
|
function isValidArkAddress(address) {
|
|
3445
3407
|
try {
|
|
3446
|
-
|
|
3408
|
+
chunkC5Y2R63Z_cjs.ArkAddress.decode(address);
|
|
3447
3409
|
return true;
|
|
3448
3410
|
} catch (e) {
|
|
3449
3411
|
return false;
|
|
@@ -3451,16 +3413,16 @@ function isValidArkAddress(address) {
|
|
|
3451
3413
|
}
|
|
3452
3414
|
function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, context) {
|
|
3453
3415
|
if (serverCheckpointTxs.length !== expectedCheckpoints.length) {
|
|
3454
|
-
throw new
|
|
3416
|
+
throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
|
|
3455
3417
|
`${context} returned ${serverCheckpointTxs.length} checkpoints, expected ${expectedCheckpoints.length}`
|
|
3456
3418
|
);
|
|
3457
3419
|
}
|
|
3458
3420
|
const byTxid = new Map(expectedCheckpoints.map((c) => [c.id, c]));
|
|
3459
3421
|
return serverCheckpointTxs.map((encoded, index) => {
|
|
3460
|
-
const server =
|
|
3422
|
+
const server = chunkC5Y2R63Z_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
|
|
3461
3423
|
const local = byTxid.get(server.id);
|
|
3462
3424
|
if (!local) {
|
|
3463
|
-
throw new
|
|
3425
|
+
throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
|
|
3464
3426
|
`${context} checkpoint ${index} txid ${server.id} does not match any submitted checkpoint`
|
|
3465
3427
|
);
|
|
3466
3428
|
}
|
|
@@ -3470,14 +3432,14 @@ function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, contex
|
|
|
3470
3432
|
}
|
|
3471
3433
|
function assertSubmittedArkTxid(response, signedArkTx, context) {
|
|
3472
3434
|
if (response.arkTxid !== signedArkTx.id) {
|
|
3473
|
-
throw new
|
|
3435
|
+
throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
|
|
3474
3436
|
`${context} returned ark txid ${response.arkTxid}, expected ${signedArkTx.id}`
|
|
3475
3437
|
);
|
|
3476
3438
|
}
|
|
3477
3439
|
if (response.finalArkTx === void 0) return;
|
|
3478
|
-
const finalTxid =
|
|
3440
|
+
const finalTxid = chunkC5Y2R63Z_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
|
|
3479
3441
|
if (finalTxid !== signedArkTx.id) {
|
|
3480
|
-
throw new
|
|
3442
|
+
throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
|
|
3481
3443
|
`${context} returned final ark tx ${finalTxid}, expected ${signedArkTx.id}`
|
|
3482
3444
|
);
|
|
3483
3445
|
}
|
|
@@ -3496,10 +3458,10 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeyHex,
|
|
|
3496
3458
|
[serverPubkeyHex],
|
|
3497
3459
|
void 0,
|
|
3498
3460
|
void 0,
|
|
3499
|
-
payment_js.tapLeafHash(
|
|
3461
|
+
payment_js.tapLeafHash(chunkC5Y2R63Z_cjs.scriptFromTapLeafScript(leaf))
|
|
3500
3462
|
);
|
|
3501
3463
|
} catch (error) {
|
|
3502
|
-
throw new
|
|
3464
|
+
throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
|
|
3503
3465
|
`${context}: input ${inputIndex} is not signed by the server on the leaf being spent (${error instanceof Error ? error.message : String(error)})`
|
|
3504
3466
|
);
|
|
3505
3467
|
}
|
|
@@ -3508,20 +3470,20 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
3508
3470
|
const byOutpoint = new Map(inputs.map((input) => [`${input.txid}:${input.vout}`, input]));
|
|
3509
3471
|
for (const [index, checkpoint] of checkpoints.entries()) {
|
|
3510
3472
|
if (checkpoint.inputsLength !== 1) {
|
|
3511
|
-
throw new
|
|
3473
|
+
throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
|
|
3512
3474
|
`${context}: checkpoint ${index} spends ${checkpoint.inputsLength} inputs, expected 1`
|
|
3513
3475
|
);
|
|
3514
3476
|
}
|
|
3515
3477
|
const spent = checkpoint.getInput(0);
|
|
3516
3478
|
if (!spent.txid || spent.index === void 0) {
|
|
3517
|
-
throw new
|
|
3479
|
+
throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
|
|
3518
3480
|
`${context}: checkpoint ${index} has no input outpoint`
|
|
3519
3481
|
);
|
|
3520
3482
|
}
|
|
3521
3483
|
const outpoint = `${base.hex.encode(spent.txid)}:${spent.index}`;
|
|
3522
3484
|
const input = byOutpoint.get(outpoint);
|
|
3523
3485
|
if (!input) {
|
|
3524
|
-
throw new
|
|
3486
|
+
throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
|
|
3525
3487
|
`${context}: checkpoint ${index} spends ${outpoint}, which is not one of the requested virtual outputs`
|
|
3526
3488
|
);
|
|
3527
3489
|
}
|
|
@@ -3529,7 +3491,7 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
3529
3491
|
(unroll) => buildCheckpointTx(input, unroll).tx.id === checkpoint.id
|
|
3530
3492
|
);
|
|
3531
3493
|
if (!rebuilt) {
|
|
3532
|
-
throw new
|
|
3494
|
+
throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
|
|
3533
3495
|
`${context}: checkpoint ${index} txid ${checkpoint.id} differs from the checkpoint built locally for ${outpoint}`
|
|
3534
3496
|
);
|
|
3535
3497
|
}
|
|
@@ -3555,9 +3517,9 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
3555
3517
|
const matched = matchServerCheckpoints(signedCheckpointTxs, offchainTx.checkpoints, "submitTx");
|
|
3556
3518
|
matched.forEach(({ server }, index) => {
|
|
3557
3519
|
try {
|
|
3558
|
-
|
|
3520
|
+
chunkC5Y2R63Z_cjs.assertAllowedSighashTypes(server);
|
|
3559
3521
|
} catch (error) {
|
|
3560
|
-
throw new
|
|
3522
|
+
throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
|
|
3561
3523
|
`submitTx checkpoint ${index}: ${error instanceof Error ? error.message : String(error)}`
|
|
3562
3524
|
);
|
|
3563
3525
|
}
|
|
@@ -3565,12 +3527,12 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
3565
3527
|
const verify = options?.verifyServerSignatures;
|
|
3566
3528
|
if (verify) {
|
|
3567
3529
|
if (response.finalArkTx === void 0) {
|
|
3568
|
-
throw new
|
|
3530
|
+
throw new chunkC5Y2R63Z_cjs.ServerResponseMismatchError(
|
|
3569
3531
|
"submitTx: server returned no final ark tx to verify its signatures against"
|
|
3570
3532
|
);
|
|
3571
3533
|
}
|
|
3572
|
-
const finalArkTx =
|
|
3573
|
-
const serverPubkeyHex = base.hex.encode(
|
|
3534
|
+
const finalArkTx = chunkC5Y2R63Z_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
|
|
3535
|
+
const serverPubkeyHex = base.hex.encode(chunkF7HJO5GT_cjs.toXOnly(verify.serverPubkey, "server key"));
|
|
3574
3536
|
for (let i = 0; i < offchainTx.arkTx.inputsLength; i++) {
|
|
3575
3537
|
assertServerSignedLeaf(
|
|
3576
3538
|
finalArkTx,
|
|
@@ -3626,12 +3588,12 @@ function claimWithPreimageIdentity(identity, preimage) {
|
|
|
3626
3588
|
return {
|
|
3627
3589
|
...identity,
|
|
3628
3590
|
sign: async (tx, inputIndexes) => {
|
|
3629
|
-
const signed =
|
|
3591
|
+
const signed = chunkC5Y2R63Z_cjs.Transaction.fromPSBT(
|
|
3630
3592
|
(await identity.sign(tx.clone(), inputIndexes)).toPSBT()
|
|
3631
3593
|
);
|
|
3632
3594
|
const indexes = inputIndexes ?? Array.from({ length: signed.inputsLength }, (_, i) => i);
|
|
3633
3595
|
for (const index of indexes) {
|
|
3634
|
-
|
|
3596
|
+
chunkC5Y2R63Z_cjs.setArkPsbtField(signed, index, chunkC5Y2R63Z_cjs.ConditionWitness, [preimage]);
|
|
3635
3597
|
}
|
|
3636
3598
|
return signed;
|
|
3637
3599
|
}
|
|
@@ -3823,7 +3785,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
|
|
|
3823
3785
|
};
|
|
3824
3786
|
}
|
|
3825
3787
|
function deriveContractTapscripts(contract) {
|
|
3826
|
-
const handler =
|
|
3788
|
+
const handler = chunkF7HJO5GT_cjs.contractHandlers.get(contract.type);
|
|
3827
3789
|
if (!handler) {
|
|
3828
3790
|
throw new Error(`No handler for contract type '${contract.type}'`);
|
|
3829
3791
|
}
|
|
@@ -3894,7 +3856,7 @@ function getRandomId() {
|
|
|
3894
3856
|
}
|
|
3895
3857
|
function isValidArkAddress2(address) {
|
|
3896
3858
|
try {
|
|
3897
|
-
|
|
3859
|
+
chunkC5Y2R63Z_cjs.ArkAddress.decode(address);
|
|
3898
3860
|
return true;
|
|
3899
3861
|
} catch (e) {
|
|
3900
3862
|
return false;
|
|
@@ -3922,7 +3884,7 @@ function assertRecipientArkadeAddress(encoded, address, context) {
|
|
|
3922
3884
|
function assertTapTreeDerivesAddress(encoded, tapTree, address) {
|
|
3923
3885
|
let derived;
|
|
3924
3886
|
try {
|
|
3925
|
-
derived =
|
|
3887
|
+
derived = chunkC5Y2R63Z_cjs.VtxoScript.decode(tapTree).pkScript;
|
|
3926
3888
|
} catch (e) {
|
|
3927
3889
|
throw new Error(
|
|
3928
3890
|
`Invalid tapTree for ${encoded}: ${e instanceof Error ? e.message : String(e)}`
|
|
@@ -3939,7 +3901,7 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
3939
3901
|
for (const recipient of recipients) {
|
|
3940
3902
|
let address;
|
|
3941
3903
|
try {
|
|
3942
|
-
address =
|
|
3904
|
+
address = chunkC5Y2R63Z_cjs.ArkAddress.decode(recipient.address);
|
|
3943
3905
|
} catch (e) {
|
|
3944
3906
|
throw new Error(`Invalid Arkade address: ${recipient.address}`);
|
|
3945
3907
|
}
|
|
@@ -3964,7 +3926,7 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
3964
3926
|
|
|
3965
3927
|
// src/contracts/spendability.ts
|
|
3966
3928
|
function isContractGenericallySpendable(contract) {
|
|
3967
|
-
return
|
|
3929
|
+
return chunkF7HJO5GT_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
|
|
3968
3930
|
}
|
|
3969
3931
|
function gatedContracts(contracts) {
|
|
3970
3932
|
const gated = /* @__PURE__ */ new Map();
|
|
@@ -3977,7 +3939,7 @@ function gateExclusion(gated) {
|
|
|
3977
3939
|
return (vtxo) => {
|
|
3978
3940
|
const type = vtxo.script === void 0 ? void 0 : gated.get(vtxo.script);
|
|
3979
3941
|
if (type === void 0) return void 0;
|
|
3980
|
-
if (!
|
|
3942
|
+
if (!chunkF7HJO5GT_cjs.contractHandlers.has(type)) {
|
|
3981
3943
|
return `at ${vtxo.script} (contract type '${type}') has no handler registered in this build`;
|
|
3982
3944
|
}
|
|
3983
3945
|
return `at ${vtxo.script} (contract type '${type}') is not generically spendable`;
|
|
@@ -4013,7 +3975,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
|
|
|
4013
3975
|
continue;
|
|
4014
3976
|
}
|
|
4015
3977
|
for (const v of vtxos) {
|
|
4016
|
-
if (!
|
|
3978
|
+
if (!chunkC5Y2R63Z_cjs.hasTerminalSpend(v) && !v.isSwept && !v.isUnrolled) {
|
|
4017
3979
|
out.add(`${v.txid}:${v.vout}`);
|
|
4018
3980
|
}
|
|
4019
3981
|
}
|
|
@@ -4048,10 +4010,10 @@ function byValueDescending(vtxos) {
|
|
|
4048
4010
|
return [...vtxos].sort((a, b) => b.value - a.value);
|
|
4049
4011
|
}
|
|
4050
4012
|
async function fetchTimeHeight(wallet) {
|
|
4051
|
-
return
|
|
4013
|
+
return chunkC5Y2R63Z_cjs.resolveTimeHeight(wallet.onchainProvider);
|
|
4052
4014
|
}
|
|
4053
4015
|
function canMigrateBySend(vtxo, now) {
|
|
4054
|
-
if (!
|
|
4016
|
+
if (!chunkC5Y2R63Z_cjs.canSpendOffchain(vtxo, now)) return false;
|
|
4055
4017
|
return vtxo.expiresAt !== void 0 || vtxo.expiresAtHeight !== void 0;
|
|
4056
4018
|
}
|
|
4057
4019
|
function byExpiryAscending(vtxos, now) {
|
|
@@ -4059,7 +4021,7 @@ function byExpiryAscending(vtxos, now) {
|
|
|
4059
4021
|
if (vtxo.isSwept) return -Infinity;
|
|
4060
4022
|
if (vtxo.expiresAt !== void 0) return vtxo.expiresAt.getTime();
|
|
4061
4023
|
if (vtxo.expiresAtHeight !== void 0) {
|
|
4062
|
-
return
|
|
4024
|
+
return chunkC5Y2R63Z_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
|
|
4063
4025
|
}
|
|
4064
4026
|
return Infinity;
|
|
4065
4027
|
};
|
|
@@ -4086,7 +4048,7 @@ function priceSettlementInputs(vtxos, estimator) {
|
|
|
4086
4048
|
const payable = [];
|
|
4087
4049
|
const net = /* @__PURE__ */ new Map();
|
|
4088
4050
|
for (const vtxo of vtxos) {
|
|
4089
|
-
const inputFee = estimator.evalOffchainInput(
|
|
4051
|
+
const inputFee = estimator.evalOffchainInput(chunkC5Y2R63Z_cjs.toOffchainInputFeeParams(vtxo));
|
|
4090
4052
|
if (inputFee.satoshis >= vtxo.value) {
|
|
4091
4053
|
continue;
|
|
4092
4054
|
}
|
|
@@ -4112,16 +4074,12 @@ function deductOffchainOutputFee(subtotal, estimator, arkAddress) {
|
|
|
4112
4074
|
}
|
|
4113
4075
|
const outputFee = estimator.evalOffchainOutput({
|
|
4114
4076
|
amount: subtotal,
|
|
4115
|
-
script: base.hex.encode(
|
|
4077
|
+
script: base.hex.encode(chunkC5Y2R63Z_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
4116
4078
|
});
|
|
4117
4079
|
return subtotal - BigInt(outputFee.satoshis);
|
|
4118
4080
|
}
|
|
4119
4081
|
var DEFAULT_THRESHOLD_SECONDS = 259200;
|
|
4120
4082
|
var DEFAULT_THRESHOLD_MS = DEFAULT_THRESHOLD_SECONDS * 1e3;
|
|
4121
|
-
var DEFAULT_RENEWAL_CONFIG = {
|
|
4122
|
-
thresholdMs: DEFAULT_THRESHOLD_MS
|
|
4123
|
-
// 3 days
|
|
4124
|
-
};
|
|
4125
4083
|
var DEFAULT_SETTLEMENT_CONFIG = {
|
|
4126
4084
|
vtxoThreshold: DEFAULT_THRESHOLD_SECONDS,
|
|
4127
4085
|
boardingUtxoSweep: true,
|
|
@@ -4130,10 +4088,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
|
|
|
4130
4088
|
};
|
|
4131
4089
|
function getRecoverableVtxos(vtxos, dustAmount, now) {
|
|
4132
4090
|
return vtxos.filter((vtxo) => {
|
|
4133
|
-
if (
|
|
4091
|
+
if (chunkC5Y2R63Z_cjs.canRecoverOnchain(vtxo, now)) {
|
|
4134
4092
|
return true;
|
|
4135
4093
|
}
|
|
4136
|
-
if (
|
|
4094
|
+
if (chunkC5Y2R63Z_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
|
|
4137
4095
|
return true;
|
|
4138
4096
|
}
|
|
4139
4097
|
return false;
|
|
@@ -4165,7 +4123,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
|
|
|
4165
4123
|
function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
4166
4124
|
if (vtxo.isUnrolled) return false;
|
|
4167
4125
|
const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
|
|
4168
|
-
const expiresAt =
|
|
4126
|
+
const expiresAt = chunkC5Y2R63Z_cjs.normalizeVtxo(vtxo).expiresAt;
|
|
4169
4127
|
if (expiresAt === void 0) return false;
|
|
4170
4128
|
const now = Date.now();
|
|
4171
4129
|
const batchExpiry = expiresAt.getTime();
|
|
@@ -4176,7 +4134,7 @@ function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
|
|
|
4176
4134
|
return vtxos.filter(
|
|
4177
4135
|
// The leading exclusion covers the `isSubdust` arm too, which is a value
|
|
4178
4136
|
// property and would otherwise re-admit an exited coin on its own.
|
|
4179
|
-
(vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) ||
|
|
4137
|
+
(vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) || chunkC5Y2R63Z_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount))
|
|
4180
4138
|
);
|
|
4181
4139
|
}
|
|
4182
4140
|
function isMigrationCapable(wallet) {
|
|
@@ -4225,24 +4183,12 @@ function mergeSignerReports(...reportLists) {
|
|
|
4225
4183
|
return Array.from(bySigner.values());
|
|
4226
4184
|
}
|
|
4227
4185
|
var VtxoManager = class _VtxoManager {
|
|
4228
|
-
constructor(wallet,
|
|
4186
|
+
constructor(wallet, settlementConfig) {
|
|
4229
4187
|
this.wallet = wallet;
|
|
4230
|
-
this.
|
|
4231
|
-
if (settlementConfig !== void 0) {
|
|
4232
|
-
this.settlementConfig = settlementConfig;
|
|
4233
|
-
} else if (renewalConfig && renewalConfig.enabled) {
|
|
4234
|
-
this.settlementConfig = {
|
|
4235
|
-
vtxoThreshold: renewalConfig.thresholdMs ? renewalConfig.thresholdMs / 1e3 : void 0
|
|
4236
|
-
};
|
|
4237
|
-
} else if (renewalConfig) {
|
|
4238
|
-
this.settlementConfig = false;
|
|
4239
|
-
} else {
|
|
4240
|
-
this.settlementConfig = { ...DEFAULT_SETTLEMENT_CONFIG };
|
|
4241
|
-
}
|
|
4188
|
+
this.settlementConfig = settlementConfig !== void 0 ? settlementConfig : { ...DEFAULT_SETTLEMENT_CONFIG };
|
|
4242
4189
|
this.contractEventsSubscriptionReady = this.initializeSubscription();
|
|
4243
4190
|
}
|
|
4244
4191
|
wallet;
|
|
4245
|
-
renewalConfig;
|
|
4246
4192
|
settlementConfig;
|
|
4247
4193
|
contractEventsSubscriptionReady;
|
|
4248
4194
|
disposePromise;
|
|
@@ -4547,7 +4493,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4547
4493
|
} else if (this.settlementConfig !== false && this.settlementConfig && this.settlementConfig.vtxoThreshold !== void 0) {
|
|
4548
4494
|
threshold = this.settlementConfig.vtxoThreshold * 1e3;
|
|
4549
4495
|
} else {
|
|
4550
|
-
threshold =
|
|
4496
|
+
threshold = DEFAULT_THRESHOLD_MS;
|
|
4551
4497
|
}
|
|
4552
4498
|
return getExpiringAndRecoverableVtxos(
|
|
4553
4499
|
vtxos,
|
|
@@ -4605,7 +4551,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4605
4551
|
} else if (this.settlementConfig !== false && this.settlementConfig?.vtxoThreshold !== void 0) {
|
|
4606
4552
|
threshold = this.settlementConfig.vtxoThreshold * 1e3;
|
|
4607
4553
|
} else {
|
|
4608
|
-
threshold =
|
|
4554
|
+
threshold = DEFAULT_THRESHOLD_MS;
|
|
4609
4555
|
}
|
|
4610
4556
|
const now = await fetchTimeHeight(this.wallet);
|
|
4611
4557
|
let vtxos = await this.selectExpiringVtxos(threshold, now);
|
|
@@ -4775,11 +4721,11 @@ var VtxoManager = class _VtxoManager {
|
|
|
4775
4721
|
`Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
|
|
4776
4722
|
);
|
|
4777
4723
|
}
|
|
4778
|
-
const tx = new
|
|
4724
|
+
const tx = new chunkC5Y2R63Z_cjs.Transaction();
|
|
4779
4725
|
for (const utxo of expiredUtxos) {
|
|
4780
|
-
const utxoScript =
|
|
4726
|
+
const utxoScript = chunkC5Y2R63Z_cjs.VtxoScript.decode(utxo.tapTree);
|
|
4781
4727
|
const utxoExitLeaf = utxoScript.leaves.find(
|
|
4782
|
-
(leaf) =>
|
|
4728
|
+
(leaf) => chunkC5Y2R63Z_cjs.CSVMultisigTapscript.isScriptValid(chunkC5Y2R63Z_cjs.scriptFromTapLeafScript(leaf)) === true
|
|
4783
4729
|
);
|
|
4784
4730
|
if (!utxoExitLeaf) {
|
|
4785
4731
|
throw new Error(
|
|
@@ -4794,7 +4740,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4794
4740
|
amount: BigInt(utxo.value)
|
|
4795
4741
|
},
|
|
4796
4742
|
tapLeafScript: [utxoExitLeaf],
|
|
4797
|
-
sequence:
|
|
4743
|
+
sequence: chunkC5Y2R63Z_cjs.getSequence(utxoExitLeaf)
|
|
4798
4744
|
});
|
|
4799
4745
|
}
|
|
4800
4746
|
tx.addOutputAddress(boardingAddress, outputAmount, this.getNetwork());
|
|
@@ -5037,8 +4983,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
5037
4983
|
const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
|
|
5038
4984
|
if (cls.status === "CURRENT") continue;
|
|
5039
4985
|
const live = vtxos.filter((v) => !v.isUnrolled);
|
|
5040
|
-
const recoverable = live.filter((v) => v.isSwept && !
|
|
5041
|
-
const spendable = live.filter((v) => !
|
|
4986
|
+
const recoverable = live.filter((v) => v.isSwept && !chunkC5Y2R63Z_cjs.hasTerminalSpend(v));
|
|
4987
|
+
const spendable = live.filter((v) => !chunkC5Y2R63Z_cjs.hasTerminalSpend(v) && !v.isSwept);
|
|
5042
4988
|
const value = spendable.reduce((sum, v) => sum + v.value, 0);
|
|
5043
4989
|
let recoverableCount = 0;
|
|
5044
4990
|
let recoverableValue = 0;
|
|
@@ -5051,7 +4997,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5051
4997
|
awaitingSweepCount = spendable.length;
|
|
5052
4998
|
awaitingSweepValue = value;
|
|
5053
4999
|
for (const v of spendable) {
|
|
5054
|
-
const exp =
|
|
5000
|
+
const exp = v.expiresAt?.getTime();
|
|
5055
5001
|
if (exp !== void 0 && (nextSweepEta === void 0 || exp < nextSweepEta)) {
|
|
5056
5002
|
nextSweepEta = exp;
|
|
5057
5003
|
}
|
|
@@ -5312,7 +5258,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5312
5258
|
/** Decodes the boarding tapscript exit path to extract the CSV timelock. */
|
|
5313
5259
|
getBoardingTimelock() {
|
|
5314
5260
|
const wallet = this.getSweepWallet();
|
|
5315
|
-
const exitScript =
|
|
5261
|
+
const exitScript = chunkC5Y2R63Z_cjs.CSVMultisigTapscript.decode(
|
|
5316
5262
|
base.hex.decode(wallet.boardingTapscript.exitScript)
|
|
5317
5263
|
);
|
|
5318
5264
|
return exitScript.params.timelock;
|
|
@@ -5443,8 +5389,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
5443
5389
|
* or doesn't carry the metadata.
|
|
5444
5390
|
*/
|
|
5445
5391
|
extractSpentOutpoint(error) {
|
|
5446
|
-
const ark =
|
|
5447
|
-
if (!
|
|
5392
|
+
const ark = chunkC5Y2R63Z_cjs.maybeArkError(error);
|
|
5393
|
+
if (!chunkC5Y2R63Z_cjs.isArkError(ark, chunkC5Y2R63Z_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
|
|
5448
5394
|
const raw = ark.metadata?.vtxo_outpoint;
|
|
5449
5395
|
if (typeof raw !== "string") return void 0;
|
|
5450
5396
|
const [txid, voutStr] = raw.split(":");
|
|
@@ -5634,7 +5580,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5634
5580
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
5635
5581
|
break;
|
|
5636
5582
|
}
|
|
5637
|
-
const inputFee = estimator.evalOffchainInput(
|
|
5583
|
+
const inputFee = estimator.evalOffchainInput(chunkC5Y2R63Z_cjs.toOffchainInputFeeParams(v));
|
|
5638
5584
|
if (inputFee.satoshis >= v.value) {
|
|
5639
5585
|
continue;
|
|
5640
5586
|
}
|
|
@@ -5654,7 +5600,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5654
5600
|
const arkAddress = await this.wallet.getAddress();
|
|
5655
5601
|
const outputFee = estimator.evalOffchainOutput({
|
|
5656
5602
|
amount: totalAmount,
|
|
5657
|
-
script: base.hex.encode(
|
|
5603
|
+
script: base.hex.encode(chunkC5Y2R63Z_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
5658
5604
|
});
|
|
5659
5605
|
totalAmount -= BigInt(outputFee.satoshis);
|
|
5660
5606
|
if (totalAmount < dustAmount) return;
|
|
@@ -5734,7 +5680,7 @@ var ArkNote = class _ArkNote {
|
|
|
5734
5680
|
this.value = value;
|
|
5735
5681
|
this.HRP = HRP;
|
|
5736
5682
|
const preimageHash = utils_js.sha256(this.preimage);
|
|
5737
|
-
this.vtxoScript = new
|
|
5683
|
+
this.vtxoScript = new chunkC5Y2R63Z_cjs.VtxoScript([noteTapscript(preimageHash)]);
|
|
5738
5684
|
const leaf = this.vtxoScript.leaves[0];
|
|
5739
5685
|
this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
|
|
5740
5686
|
this.tapTree = this.vtxoScript.encode();
|
|
@@ -5901,7 +5847,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
5901
5847
|
const privateKey = data.slice(1, 33);
|
|
5902
5848
|
const serverPubKey = data.slice(33, 65);
|
|
5903
5849
|
const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
|
|
5904
|
-
const csvTimelock =
|
|
5850
|
+
const csvTimelock = chunkC5Y2R63Z_cjs.sequenceToTimelock(sequence);
|
|
5905
5851
|
return new _ArkadeCash(privateKey, serverPubKey, csvTimelock, decoded.prefix);
|
|
5906
5852
|
}
|
|
5907
5853
|
toString() {
|
|
@@ -5909,7 +5855,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
5909
5855
|
data[0] = _ArkadeCash.Version;
|
|
5910
5856
|
data.set(this._privateKey, 1);
|
|
5911
5857
|
data.set(this._serverPubKey, 33);
|
|
5912
|
-
const sequence =
|
|
5858
|
+
const sequence = chunkC5Y2R63Z_cjs.timelockToSequence(this.csvTimelock);
|
|
5913
5859
|
new DataView(data.buffer, data.byteOffset + 65, 4).setUint32(0, sequence, false);
|
|
5914
5860
|
const words = base.bech32m.toWords(data);
|
|
5915
5861
|
return base.bech32m.encode(this.hrp, words, 1023);
|
|
@@ -5918,7 +5864,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
5918
5864
|
return SingleKey.fromPrivateKey(this._privateKey);
|
|
5919
5865
|
}
|
|
5920
5866
|
get vtxoScript() {
|
|
5921
|
-
return new
|
|
5867
|
+
return new chunkF7HJO5GT_cjs.DefaultVtxo.Script({
|
|
5922
5868
|
pubKey: this._publicKey,
|
|
5923
5869
|
serverPubKey: this._serverPubKey,
|
|
5924
5870
|
csvTimelock: this.csvTimelock
|
|
@@ -6179,7 +6125,7 @@ async function captureExitBranch(params) {
|
|
|
6179
6125
|
const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
|
|
6180
6126
|
if (nonCommitment.length > 0) {
|
|
6181
6127
|
for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
|
|
6182
|
-
psbtByTxid.set(
|
|
6128
|
+
psbtByTxid.set(chunkC5Y2R63Z_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
6183
6129
|
}
|
|
6184
6130
|
}
|
|
6185
6131
|
}
|
|
@@ -6222,10 +6168,10 @@ var IndexerExitDataSource = class {
|
|
|
6222
6168
|
while (hasMore) {
|
|
6223
6169
|
const { chain: page, page: meta } = await this.indexer.getVtxoChain(
|
|
6224
6170
|
{ txid: vtxo.txid, vout: vtxo.vout },
|
|
6225
|
-
{ pageIndex, pageSize:
|
|
6171
|
+
{ pageIndex, pageSize: chunkC5Y2R63Z_cjs.DEFAULT_PAGE_SIZE }
|
|
6226
6172
|
);
|
|
6227
6173
|
chain.push(...page);
|
|
6228
|
-
hasMore = meta ? page.length ===
|
|
6174
|
+
hasMore = meta ? page.length === chunkC5Y2R63Z_cjs.DEFAULT_PAGE_SIZE : false;
|
|
6229
6175
|
pageIndex++;
|
|
6230
6176
|
}
|
|
6231
6177
|
return chain;
|
|
@@ -6237,12 +6183,12 @@ var IndexerExitDataSource = class {
|
|
|
6237
6183
|
while (hasMore) {
|
|
6238
6184
|
const { txs, page } = await this.indexer.getVirtualTxs(txids, {
|
|
6239
6185
|
pageIndex,
|
|
6240
|
-
pageSize:
|
|
6186
|
+
pageSize: chunkC5Y2R63Z_cjs.DEFAULT_PAGE_SIZE
|
|
6241
6187
|
});
|
|
6242
6188
|
for (const psbt of txs) {
|
|
6243
|
-
out.set(
|
|
6189
|
+
out.set(chunkC5Y2R63Z_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
6244
6190
|
}
|
|
6245
|
-
hasMore = page ? txs.length ===
|
|
6191
|
+
hasMore = page ? txs.length === chunkC5Y2R63Z_cjs.DEFAULT_PAGE_SIZE : false;
|
|
6246
6192
|
pageIndex++;
|
|
6247
6193
|
}
|
|
6248
6194
|
return out;
|
|
@@ -6263,7 +6209,7 @@ function chainedTxTypeToChainTxType(t) {
|
|
|
6263
6209
|
}
|
|
6264
6210
|
}
|
|
6265
6211
|
function psbtInputTxids(psbtBase64) {
|
|
6266
|
-
const tx =
|
|
6212
|
+
const tx = chunkC5Y2R63Z_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
6267
6213
|
const ids = [];
|
|
6268
6214
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
6269
6215
|
const txid = tx.getInput(i).txid;
|
|
@@ -6622,10 +6568,10 @@ async function resolveArkInfo(arkProvider, walletRepository, opts) {
|
|
|
6622
6568
|
try {
|
|
6623
6569
|
info = await arkProvider.getInfo();
|
|
6624
6570
|
} catch (err) {
|
|
6625
|
-
if (opts?.requireLive || !
|
|
6571
|
+
if (opts?.requireLive || !chunkC5Y2R63Z_cjs.isRetryableProviderError(err)) throw err;
|
|
6626
6572
|
const snapshot = await loadArkInfoSnapshot(walletRepository);
|
|
6627
6573
|
if (!snapshot) {
|
|
6628
|
-
throw new
|
|
6574
|
+
throw new chunkC5Y2R63Z_cjs.ProviderUnavailableError(
|
|
6629
6575
|
"Arkade server info is unavailable and no cached snapshot exists",
|
|
6630
6576
|
{ cause: err }
|
|
6631
6577
|
);
|
|
@@ -7015,7 +6961,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos) {
|
|
|
7015
6961
|
return [...txids];
|
|
7016
6962
|
}
|
|
7017
6963
|
async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt) {
|
|
7018
|
-
const fromOldestVtxo = vtxos.map(
|
|
6964
|
+
const fromOldestVtxo = vtxos.map(chunkC5Y2R63Z_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
7019
6965
|
const txidsNeedingCreatedAt = resolveTxCreatedAt ? collectArkTxidsNeedingCreatedAt(fromOldestVtxo) : [];
|
|
7020
6966
|
const resolvedCreatedAt = resolveTxCreatedAt && txidsNeedingCreatedAt.length > 0 ? await resolveTxCreatedAt(txidsNeedingCreatedAt) : /* @__PURE__ */ new Map();
|
|
7021
6967
|
const unmatchedSettledBoardingTxs = allBoardingTxs.filter(isSettledBoardingReceive).sort((a, b) => a.createdAt - b.createdAt);
|
|
@@ -7179,7 +7125,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7179
7125
|
const virtualCoins = await this.wallet.getSpendableVtxos({
|
|
7180
7126
|
withRecoverable: false
|
|
7181
7127
|
});
|
|
7182
|
-
const controlAssetRef = params.controlAssetId ?
|
|
7128
|
+
const controlAssetRef = params.controlAssetId ? chunkSYRQJS5N_cjs.AssetRef.fromId(chunkSYRQJS5N_cjs.AssetId.fromString(params.controlAssetId)) : null;
|
|
7183
7129
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
7184
7130
|
let totalBtcSelected = 0n;
|
|
7185
7131
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -7192,8 +7138,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7192
7138
|
}
|
|
7193
7139
|
}
|
|
7194
7140
|
const groups = [];
|
|
7195
|
-
const issuedAssetOutput =
|
|
7196
|
-
const issuedAssetGroup =
|
|
7141
|
+
const issuedAssetOutput = chunkSYRQJS5N_cjs.AssetOutput.create(0, params.amount);
|
|
7142
|
+
const issuedAssetGroup = chunkSYRQJS5N_cjs.AssetGroup.create(
|
|
7197
7143
|
null,
|
|
7198
7144
|
controlAssetRef,
|
|
7199
7145
|
[],
|
|
@@ -7208,28 +7154,28 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7208
7154
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7209
7155
|
for (const asset of assets) {
|
|
7210
7156
|
if (asset.assetId !== assetId) continue;
|
|
7211
|
-
changeInputs.push(
|
|
7157
|
+
changeInputs.push(chunkSYRQJS5N_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7212
7158
|
}
|
|
7213
7159
|
}
|
|
7214
7160
|
groups.push(
|
|
7215
|
-
|
|
7216
|
-
|
|
7161
|
+
chunkSYRQJS5N_cjs.AssetGroup.create(
|
|
7162
|
+
chunkSYRQJS5N_cjs.AssetId.fromString(assetId),
|
|
7217
7163
|
null,
|
|
7218
7164
|
changeInputs,
|
|
7219
|
-
[
|
|
7165
|
+
[chunkSYRQJS5N_cjs.AssetOutput.create(0, amount)],
|
|
7220
7166
|
[]
|
|
7221
7167
|
)
|
|
7222
7168
|
);
|
|
7223
7169
|
}
|
|
7224
7170
|
}
|
|
7225
7171
|
const address = await this.wallet.getAddress();
|
|
7226
|
-
const outputAddress =
|
|
7172
|
+
const outputAddress = chunkC5Y2R63Z_cjs.ArkAddress.decode(address);
|
|
7227
7173
|
const outputs = [
|
|
7228
7174
|
{
|
|
7229
7175
|
script: outputAddress.pkScript,
|
|
7230
7176
|
amount: BigInt(totalBtcSelected)
|
|
7231
7177
|
},
|
|
7232
|
-
Extension.create([
|
|
7178
|
+
Extension.create([chunkSYRQJS5N_cjs.Packet.create(groups)]).txOut()
|
|
7233
7179
|
];
|
|
7234
7180
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
|
|
7235
7181
|
coinSelection.inputs,
|
|
@@ -7237,7 +7183,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7237
7183
|
);
|
|
7238
7184
|
return {
|
|
7239
7185
|
arkTxId: arkTxid,
|
|
7240
|
-
assetId:
|
|
7186
|
+
assetId: chunkSYRQJS5N_cjs.AssetId.create(arkTxid, 0).toString()
|
|
7241
7187
|
};
|
|
7242
7188
|
}
|
|
7243
7189
|
/**
|
|
@@ -7309,16 +7255,16 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7309
7255
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7310
7256
|
for (const asset of assets) {
|
|
7311
7257
|
if (asset.assetId !== params.assetId) continue;
|
|
7312
|
-
reissueInputs.push(
|
|
7258
|
+
reissueInputs.push(chunkSYRQJS5N_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7313
7259
|
}
|
|
7314
7260
|
}
|
|
7315
7261
|
const totalAssetAmount = assetToReissueAmount + params.amount;
|
|
7316
|
-
const reissueAssetIdObj =
|
|
7317
|
-
const reissueAssetGroup =
|
|
7262
|
+
const reissueAssetIdObj = chunkSYRQJS5N_cjs.AssetId.fromString(params.assetId);
|
|
7263
|
+
const reissueAssetGroup = chunkSYRQJS5N_cjs.AssetGroup.create(
|
|
7318
7264
|
reissueAssetIdObj,
|
|
7319
7265
|
null,
|
|
7320
7266
|
reissueInputs,
|
|
7321
|
-
[
|
|
7267
|
+
[chunkSYRQJS5N_cjs.AssetOutput.create(0, totalAssetAmount)],
|
|
7322
7268
|
[]
|
|
7323
7269
|
);
|
|
7324
7270
|
const groups = [reissueAssetGroup];
|
|
@@ -7327,27 +7273,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7327
7273
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7328
7274
|
for (const asset of assets) {
|
|
7329
7275
|
if (asset.assetId !== assetId) continue;
|
|
7330
|
-
changeInputs.push(
|
|
7276
|
+
changeInputs.push(chunkSYRQJS5N_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7331
7277
|
}
|
|
7332
7278
|
}
|
|
7333
7279
|
groups.push(
|
|
7334
|
-
|
|
7335
|
-
|
|
7280
|
+
chunkSYRQJS5N_cjs.AssetGroup.create(
|
|
7281
|
+
chunkSYRQJS5N_cjs.AssetId.fromString(assetId),
|
|
7336
7282
|
null,
|
|
7337
7283
|
changeInputs,
|
|
7338
|
-
[
|
|
7284
|
+
[chunkSYRQJS5N_cjs.AssetOutput.create(0, amount)],
|
|
7339
7285
|
[]
|
|
7340
7286
|
)
|
|
7341
7287
|
);
|
|
7342
7288
|
}
|
|
7343
7289
|
const address = await this.wallet.getAddress();
|
|
7344
|
-
const outputAddress =
|
|
7290
|
+
const outputAddress = chunkC5Y2R63Z_cjs.ArkAddress.decode(address);
|
|
7345
7291
|
const outputs = [
|
|
7346
7292
|
{
|
|
7347
7293
|
script: outputAddress.pkScript,
|
|
7348
7294
|
amount: BigInt(totalBtcSelected)
|
|
7349
7295
|
},
|
|
7350
|
-
Extension.create([
|
|
7296
|
+
Extension.create([chunkSYRQJS5N_cjs.Packet.create(groups)]).txOut()
|
|
7351
7297
|
];
|
|
7352
7298
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
7353
7299
|
return arkTxid;
|
|
@@ -7414,27 +7360,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7414
7360
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7415
7361
|
for (const asset of assets) {
|
|
7416
7362
|
if (asset.assetId !== assetId) continue;
|
|
7417
|
-
changeInputs.push(
|
|
7363
|
+
changeInputs.push(chunkSYRQJS5N_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7418
7364
|
}
|
|
7419
7365
|
}
|
|
7420
7366
|
groups.push(
|
|
7421
|
-
|
|
7422
|
-
|
|
7367
|
+
chunkSYRQJS5N_cjs.AssetGroup.create(
|
|
7368
|
+
chunkSYRQJS5N_cjs.AssetId.fromString(assetId),
|
|
7423
7369
|
null,
|
|
7424
7370
|
changeInputs,
|
|
7425
|
-
amount > 0n ? [
|
|
7371
|
+
amount > 0n ? [chunkSYRQJS5N_cjs.AssetOutput.create(0, amount)] : [],
|
|
7426
7372
|
[]
|
|
7427
7373
|
)
|
|
7428
7374
|
);
|
|
7429
7375
|
}
|
|
7430
7376
|
const address = await this.wallet.getAddress();
|
|
7431
|
-
const outputAddress =
|
|
7377
|
+
const outputAddress = chunkC5Y2R63Z_cjs.ArkAddress.decode(address);
|
|
7432
7378
|
const outputs = [
|
|
7433
7379
|
{
|
|
7434
7380
|
script: outputAddress.pkScript,
|
|
7435
7381
|
amount: BigInt(totalBtcSelected)
|
|
7436
7382
|
},
|
|
7437
|
-
Extension.create([
|
|
7383
|
+
Extension.create([chunkSYRQJS5N_cjs.Packet.create(groups)]).txOut()
|
|
7438
7384
|
];
|
|
7439
7385
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
7440
7386
|
return arkTxid;
|
|
@@ -7459,7 +7405,7 @@ function castMetadata(metadata) {
|
|
|
7459
7405
|
} else {
|
|
7460
7406
|
throw new Error("Invalid metadata value type");
|
|
7461
7407
|
}
|
|
7462
|
-
md.push(
|
|
7408
|
+
md.push(chunkSYRQJS5N_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
|
|
7463
7409
|
}
|
|
7464
7410
|
return md;
|
|
7465
7411
|
}
|
|
@@ -7480,10 +7426,10 @@ var DelegateManagerImpl = class {
|
|
|
7480
7426
|
if (vtxos.length === 0) {
|
|
7481
7427
|
return { delegated: [], failed: [] };
|
|
7482
7428
|
}
|
|
7483
|
-
const destinationScript =
|
|
7429
|
+
const destinationScript = chunkC5Y2R63Z_cjs.ArkAddress.decode(destination).pkScript;
|
|
7484
7430
|
const arkInfo = await this.arkInfoProvider.getInfo();
|
|
7485
7431
|
const delegateInfo = await this.delegateProvider.getDelegateInfo();
|
|
7486
|
-
const eligible = vtxos.map(
|
|
7432
|
+
const eligible = vtxos.map(chunkC5Y2R63Z_cjs.normalizeVtxo).filter(
|
|
7487
7433
|
(v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
|
|
7488
7434
|
);
|
|
7489
7435
|
if (eligible.length === 0) {
|
|
@@ -7512,11 +7458,11 @@ var DelegateManagerImpl = class {
|
|
|
7512
7458
|
const groupByExpiry = /* @__PURE__ */ new Map();
|
|
7513
7459
|
let recoverableVtxos = [];
|
|
7514
7460
|
for (const vtxo of eligible) {
|
|
7515
|
-
if (
|
|
7461
|
+
if (chunkC5Y2R63Z_cjs.canRecoverOnchain(vtxo, now)) {
|
|
7516
7462
|
recoverableVtxos.push(vtxo);
|
|
7517
7463
|
continue;
|
|
7518
7464
|
}
|
|
7519
|
-
const expiry =
|
|
7465
|
+
const expiry = vtxo.expiresAt?.getTime();
|
|
7520
7466
|
if (!expiry) continue;
|
|
7521
7467
|
const dayKey = getDayTimestamp(expiry);
|
|
7522
7468
|
groupByExpiry.set(dayKey, [...groupByExpiry.get(dayKey) ?? [], vtxo]);
|
|
@@ -7571,7 +7517,6 @@ var DelegateManagerImpl = class {
|
|
|
7571
7517
|
return { delegated, failed };
|
|
7572
7518
|
}
|
|
7573
7519
|
};
|
|
7574
|
-
var DelegatorManagerImpl = DelegateManagerImpl;
|
|
7575
7520
|
async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos, destinationScript, delegateAt) {
|
|
7576
7521
|
if (vtxos.length === 0) {
|
|
7577
7522
|
throw new Error("unable to delegate: no vtxos provided");
|
|
@@ -7581,7 +7526,10 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7581
7526
|
}
|
|
7582
7527
|
if (!delegateAt) {
|
|
7583
7528
|
const now = { timestamp: /* @__PURE__ */ new Date() };
|
|
7584
|
-
const expiryTimestamp = vtxos.filter((coin) => !
|
|
7529
|
+
const expiryTimestamp = vtxos.filter((coin) => !chunkC5Y2R63Z_cjs.canRecoverOnchain(coin, now) && coin.expiresAt).reduce(
|
|
7530
|
+
(min, coin) => Math.min(min, coin.expiresAt.getTime()),
|
|
7531
|
+
Number.MAX_SAFE_INTEGER
|
|
7532
|
+
);
|
|
7585
7533
|
if (!expiryTimestamp || expiryTimestamp === Number.MAX_SAFE_INTEGER) {
|
|
7586
7534
|
delegateAt = new Date(Date.now() + 1 * 60 * 1e3);
|
|
7587
7535
|
} else {
|
|
@@ -7610,7 +7558,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7610
7558
|
let amount = 0n;
|
|
7611
7559
|
for (const coin of vtxos) {
|
|
7612
7560
|
const inputFee = estimator.evalOffchainInput({
|
|
7613
|
-
...
|
|
7561
|
+
...chunkC5Y2R63Z_cjs.toOffchainInputFeeParams(coin),
|
|
7614
7562
|
type: "vtxo"
|
|
7615
7563
|
});
|
|
7616
7564
|
if (inputFee.value >= coin.value) {
|
|
@@ -7624,7 +7572,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7624
7572
|
const delegateFee = BigInt(Number(fee));
|
|
7625
7573
|
if (delegateFee > 0n) {
|
|
7626
7574
|
outputs.push({
|
|
7627
|
-
script:
|
|
7575
|
+
script: chunkC5Y2R63Z_cjs.ArkAddress.decode(delegateAddress).pkScript,
|
|
7628
7576
|
amount: delegateFee
|
|
7629
7577
|
});
|
|
7630
7578
|
}
|
|
@@ -7657,10 +7605,10 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7657
7605
|
destinationScript
|
|
7658
7606
|
);
|
|
7659
7607
|
const forfeitOutputScript = btcSigner.OutScript.encode(
|
|
7660
|
-
btcSigner.Address(
|
|
7608
|
+
btcSigner.Address(chunkC5Y2R63Z_cjs.getNetwork(network)).decode(forfeitAddress)
|
|
7661
7609
|
);
|
|
7662
7610
|
const forfeits = await Promise.all(
|
|
7663
|
-
vtxos.filter((v) => !
|
|
7611
|
+
vtxos.filter((v) => !chunkC5Y2R63Z_cjs.canRecoverOnchain(v, { timestamp: /* @__PURE__ */ new Date() })).map(async (coin) => {
|
|
7664
7612
|
const forfeit = await makeDelegateForfeitTx(
|
|
7665
7613
|
coin,
|
|
7666
7614
|
dust,
|
|
@@ -7685,7 +7633,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
|
|
|
7685
7633
|
index: input.vout,
|
|
7686
7634
|
witnessUtxo: {
|
|
7687
7635
|
amount: BigInt(input.value),
|
|
7688
|
-
script:
|
|
7636
|
+
script: chunkC5Y2R63Z_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
7689
7637
|
},
|
|
7690
7638
|
sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
|
|
7691
7639
|
tapLeafScript: [delegateTapLeaf]
|
|
@@ -7743,7 +7691,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
7743
7691
|
expire_at: 0,
|
|
7744
7692
|
cosigners_public_keys: cosignerPubKeys
|
|
7745
7693
|
};
|
|
7746
|
-
const proof =
|
|
7694
|
+
const proof = chunkC5Y2R63Z_cjs.Intent.create(message, coins, outputs);
|
|
7747
7695
|
const signedProof = await identity.sign(proof);
|
|
7748
7696
|
return {
|
|
7749
7697
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -7761,10 +7709,10 @@ function getDayTimestamp(timestamp) {
|
|
|
7761
7709
|
function findDelegateTapLeaf(vtxo, delegatePubkey) {
|
|
7762
7710
|
if (!vtxo.tapTree) return void 0;
|
|
7763
7711
|
const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
|
|
7764
|
-
const vtxoScript =
|
|
7712
|
+
const vtxoScript = chunkC5Y2R63Z_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
7765
7713
|
return vtxoScript.leaves.find((tapLeaf) => {
|
|
7766
|
-
const arkTapscript =
|
|
7767
|
-
if (!
|
|
7714
|
+
const arkTapscript = chunkC5Y2R63Z_cjs.decodeTapscript(chunkC5Y2R63Z_cjs.scriptFromTapLeafScript(tapLeaf));
|
|
7715
|
+
if (!chunkC5Y2R63Z_cjs.MultisigTapscript.is(arkTapscript)) return false;
|
|
7768
7716
|
return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
|
|
7769
7717
|
});
|
|
7770
7718
|
}
|
|
@@ -8045,7 +7993,7 @@ function createManagedConnection(dbName, version, initDatabase2) {
|
|
|
8045
7993
|
};
|
|
8046
7994
|
}
|
|
8047
7995
|
function scriptFromArkAddress(address) {
|
|
8048
|
-
return base.hex.encode(
|
|
7996
|
+
return base.hex.encode(chunkC5Y2R63Z_cjs.ArkAddress.decode(address).pkScript);
|
|
8049
7997
|
}
|
|
8050
7998
|
|
|
8051
7999
|
// src/repositories/indexedDB/schema.ts
|
|
@@ -8057,7 +8005,6 @@ var STORE_CONTRACTS = "contracts";
|
|
|
8057
8005
|
var STORE_INTENTS = "intents";
|
|
8058
8006
|
var STORE_VIRTUAL_TXS = "virtualTxs";
|
|
8059
8007
|
var STORE_VTXO_BRANCHES = "vtxoBranches";
|
|
8060
|
-
var LEGACY_STORE_CONTRACT_COLLECTIONS = "contractsCollections";
|
|
8061
8008
|
var DB_VERSION = 3;
|
|
8062
8009
|
var INTENT_DB_VERSION = 5;
|
|
8063
8010
|
function initDatabase(db, oldVersion, transaction) {
|
|
@@ -8081,11 +8028,6 @@ function initDatabase(db, oldVersion, transaction) {
|
|
|
8081
8028
|
unique: false
|
|
8082
8029
|
});
|
|
8083
8030
|
}
|
|
8084
|
-
if (!vtxosStore.indexNames.contains("virtualStatus")) {
|
|
8085
|
-
vtxosStore.createIndex("virtualStatus", "virtualStatus", {
|
|
8086
|
-
unique: false
|
|
8087
|
-
});
|
|
8088
|
-
}
|
|
8089
8031
|
if (!vtxosStore.indexNames.contains("createdAt")) {
|
|
8090
8032
|
vtxosStore.createIndex("createdAt", "createdAt", {
|
|
8091
8033
|
unique: false
|
|
@@ -8198,11 +8140,6 @@ function initDatabase(db, oldVersion, transaction) {
|
|
|
8198
8140
|
});
|
|
8199
8141
|
}
|
|
8200
8142
|
}
|
|
8201
|
-
if (!db.objectStoreNames.contains(LEGACY_STORE_CONTRACT_COLLECTIONS)) {
|
|
8202
|
-
db.createObjectStore(LEGACY_STORE_CONTRACT_COLLECTIONS, {
|
|
8203
|
-
keyPath: "key"
|
|
8204
|
-
});
|
|
8205
|
-
}
|
|
8206
8143
|
if (oldVersion >= 1 && oldVersion < 3 && transaction) {
|
|
8207
8144
|
const vtxosStore = transaction.objectStore(STORE_VTXOS);
|
|
8208
8145
|
if (!vtxosStore.indexNames.contains("script")) {
|
|
@@ -8540,7 +8477,7 @@ function validateVtxosForScript(vtxos, script, context) {
|
|
|
8540
8477
|
}
|
|
8541
8478
|
async function getVtxosForContract(repo, contract) {
|
|
8542
8479
|
const vtxos = repo.getVtxosForScript ? await repo.getVtxosForScript(contract.script) : filterVtxosForScript(await repo.getVtxos(contract.address), contract.script);
|
|
8543
|
-
return vtxos.map(
|
|
8480
|
+
return vtxos.map(chunkC5Y2R63Z_cjs.normalizeVtxo);
|
|
8544
8481
|
}
|
|
8545
8482
|
async function saveVtxosForContract(repo, contract, vtxos) {
|
|
8546
8483
|
if (repo.saveVtxosForScript) {
|
|
@@ -8682,7 +8619,7 @@ function decodeArkContract(encoded) {
|
|
|
8682
8619
|
}
|
|
8683
8620
|
function contractFromArkContract(encoded, options = {}) {
|
|
8684
8621
|
const parsed = decodeArkContract(encoded);
|
|
8685
|
-
const handler =
|
|
8622
|
+
const handler = chunkF7HJO5GT_cjs.contractHandlers.get(parsed.type);
|
|
8686
8623
|
if (!handler) {
|
|
8687
8624
|
throw new Error(`No handler registered for contract type '${parsed.type}'`);
|
|
8688
8625
|
}
|
|
@@ -8696,9 +8633,9 @@ function contractFromArkContract(encoded, options = {}) {
|
|
|
8696
8633
|
metadata: options.metadata
|
|
8697
8634
|
};
|
|
8698
8635
|
}
|
|
8699
|
-
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix =
|
|
8636
|
+
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkC5Y2R63Z_cjs.DEFAULT_NETWORK.hrp, options = {}) {
|
|
8700
8637
|
const parsed = decodeArkContract(encoded);
|
|
8701
|
-
const handler =
|
|
8638
|
+
const handler = chunkF7HJO5GT_cjs.contractHandlers.getOrThrow(parsed.type);
|
|
8702
8639
|
const params = parsed.data;
|
|
8703
8640
|
const vtxoScript = handler.createScript(params);
|
|
8704
8641
|
return {
|
|
@@ -8952,9 +8889,9 @@ var ContractWatcher = class {
|
|
|
8952
8889
|
this.connectionState = "connected";
|
|
8953
8890
|
this.reconnectAttempts = 0;
|
|
8954
8891
|
this.listenLoop().catch((e) => {
|
|
8955
|
-
if (
|
|
8892
|
+
if (chunkC5Y2R63Z_cjs.isEventSourceError(e)) {
|
|
8956
8893
|
console.debug("ContractWatcher subscription disconnected; reconnecting");
|
|
8957
|
-
} else if (!
|
|
8894
|
+
} else if (!chunkC5Y2R63Z_cjs.isEventSourceUnavailableError(e)) {
|
|
8958
8895
|
console.error(e);
|
|
8959
8896
|
}
|
|
8960
8897
|
this.connectionState = "disconnected";
|
|
@@ -8966,7 +8903,7 @@ var ContractWatcher = class {
|
|
|
8966
8903
|
this.scheduleReconnect();
|
|
8967
8904
|
});
|
|
8968
8905
|
} catch (error) {
|
|
8969
|
-
if (!
|
|
8906
|
+
if (!chunkC5Y2R63Z_cjs.isEventSourceUnavailableError(error)) {
|
|
8970
8907
|
console.error("ContractWatcher connection failed:", error);
|
|
8971
8908
|
}
|
|
8972
8909
|
this.connectionState = "disconnected";
|
|
@@ -8992,7 +8929,7 @@ var ContractWatcher = class {
|
|
|
8992
8929
|
* slower; what it loses is push latency.
|
|
8993
8930
|
*/
|
|
8994
8931
|
reportEventSourceUnavailable(error) {
|
|
8995
|
-
if (!
|
|
8932
|
+
if (!chunkC5Y2R63Z_cjs.isEventSourceUnavailableError(error)) return false;
|
|
8996
8933
|
if (!this.eventSourceReported) {
|
|
8997
8934
|
this.eventSourceReported = true;
|
|
8998
8935
|
console.warn(
|
|
@@ -9208,14 +9145,14 @@ var ContractWatcher = class {
|
|
|
9208
9145
|
const timestamp = Date.now();
|
|
9209
9146
|
if (update.newVtxos?.length) {
|
|
9210
9147
|
this.processSubscriptionVtxos(
|
|
9211
|
-
update.newVtxos.map(
|
|
9148
|
+
update.newVtxos.map(chunkC5Y2R63Z_cjs.normalizeVtxo),
|
|
9212
9149
|
"vtxo_received",
|
|
9213
9150
|
timestamp
|
|
9214
9151
|
);
|
|
9215
9152
|
}
|
|
9216
9153
|
if (update.spentVtxos?.length) {
|
|
9217
9154
|
this.processSubscriptionVtxos(
|
|
9218
|
-
update.spentVtxos.map(
|
|
9155
|
+
update.spentVtxos.map(chunkC5Y2R63Z_cjs.normalizeVtxo),
|
|
9219
9156
|
"vtxo_spent",
|
|
9220
9157
|
timestamp
|
|
9221
9158
|
);
|
|
@@ -9310,7 +9247,7 @@ var NON_TERMINAL_INTENT_STATES = ALL_INTENT_STATES.filter(
|
|
|
9310
9247
|
(s) => !isTerminalIntentState(s)
|
|
9311
9248
|
);
|
|
9312
9249
|
function isConsumed(vtxo) {
|
|
9313
|
-
return vtxo !== void 0 &&
|
|
9250
|
+
return vtxo !== void 0 && chunkC5Y2R63Z_cjs.hasTerminalSpend(vtxo);
|
|
9314
9251
|
}
|
|
9315
9252
|
async function classifyIntent(intent, vtxosByOutpoint, now) {
|
|
9316
9253
|
if (isTerminalIntentState(intent.state)) return void 0;
|
|
@@ -9353,7 +9290,7 @@ async function reconcileIntents(deps) {
|
|
|
9353
9290
|
let vtxosByOutpoint = /* @__PURE__ */ new Map();
|
|
9354
9291
|
if (outpoints.length > 0) {
|
|
9355
9292
|
try {
|
|
9356
|
-
const { vtxos } = await
|
|
9293
|
+
const { vtxos } = await chunkC5Y2R63Z_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
|
|
9357
9294
|
vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
|
|
9358
9295
|
} catch (e) {
|
|
9359
9296
|
console.error("reconcileIntents: failed to fetch input VTXO state", e);
|
|
@@ -9527,7 +9464,7 @@ var ContractManager = class _ContractManager {
|
|
|
9527
9464
|
await this.reconcileWatched();
|
|
9528
9465
|
this.markSyncOnline();
|
|
9529
9466
|
} catch (err) {
|
|
9530
|
-
if (!
|
|
9467
|
+
if (!chunkC5Y2R63Z_cjs.isRetryableProviderError(err)) throw err;
|
|
9531
9468
|
this.markSyncDegraded(err);
|
|
9532
9469
|
}
|
|
9533
9470
|
this.initialized = true;
|
|
@@ -9659,7 +9596,7 @@ var ContractManager = class _ContractManager {
|
|
|
9659
9596
|
const from = Math.max(0, watermark - lookAhead.size);
|
|
9660
9597
|
const to = watermark + lookAhead.size;
|
|
9661
9598
|
const deps = lookAhead.candidateDeps();
|
|
9662
|
-
const handlers =
|
|
9599
|
+
const handlers = chunkF7HJO5GT_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkF7HJO5GT_cjs.contractHandlers.get(t)).filter(hasCandidates);
|
|
9663
9600
|
const band = /* @__PURE__ */ new Map();
|
|
9664
9601
|
for (let index = from; index <= to; index++) {
|
|
9665
9602
|
const descriptor = lookAhead.materialize(index);
|
|
@@ -9670,7 +9607,7 @@ var ContractManager = class _ContractManager {
|
|
|
9670
9607
|
index,
|
|
9671
9608
|
params: {
|
|
9672
9609
|
...candidate,
|
|
9673
|
-
...
|
|
9610
|
+
...chunkF7HJO5GT_cjs.speculativeReceiveMetadata(descriptor)
|
|
9674
9611
|
}
|
|
9675
9612
|
});
|
|
9676
9613
|
}
|
|
@@ -9732,15 +9669,14 @@ var ContractManager = class _ContractManager {
|
|
|
9732
9669
|
});
|
|
9733
9670
|
for (const entry of pending) entry.catchUpPending = false;
|
|
9734
9671
|
} catch (err) {
|
|
9735
|
-
if (!
|
|
9672
|
+
if (!chunkC5Y2R63Z_cjs.isRetryableProviderError(err)) throw err;
|
|
9736
9673
|
this.markSyncDegraded(err);
|
|
9737
9674
|
}
|
|
9738
9675
|
}
|
|
9739
9676
|
async advanceLookAheadWatermark(index) {
|
|
9740
9677
|
const lookAhead = this.config.lookAhead;
|
|
9741
9678
|
if (!lookAhead) return;
|
|
9742
|
-
|
|
9743
|
-
await advance?.(index);
|
|
9679
|
+
await lookAhead.advanceWatermark?.(index);
|
|
9744
9680
|
}
|
|
9745
9681
|
/**
|
|
9746
9682
|
* Promote every look-ahead entry funded by `vtxos` into a real repository
|
|
@@ -9782,7 +9718,7 @@ var ContractManager = class _ContractManager {
|
|
|
9782
9718
|
await this.fetchContractVxosFromIndexer([contract]);
|
|
9783
9719
|
this.markSyncOnline();
|
|
9784
9720
|
} catch (err) {
|
|
9785
|
-
if (!
|
|
9721
|
+
if (!chunkC5Y2R63Z_cjs.isRetryableProviderError(err)) throw err;
|
|
9786
9722
|
this.markSyncDegraded(err);
|
|
9787
9723
|
}
|
|
9788
9724
|
await this.watcher.addContract(contract);
|
|
@@ -9819,7 +9755,7 @@ var ContractManager = class _ContractManager {
|
|
|
9819
9755
|
return result;
|
|
9820
9756
|
}
|
|
9821
9757
|
async upsertContractRow(params) {
|
|
9822
|
-
const handler =
|
|
9758
|
+
const handler = chunkF7HJO5GT_cjs.contractHandlers.get(params.type);
|
|
9823
9759
|
if (!handler) {
|
|
9824
9760
|
throw new Error(`No handler registered for contract type '${params.type}'`);
|
|
9825
9761
|
}
|
|
@@ -9919,7 +9855,7 @@ var ContractManager = class _ContractManager {
|
|
|
9919
9855
|
`scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
|
|
9920
9856
|
);
|
|
9921
9857
|
}
|
|
9922
|
-
const registered =
|
|
9858
|
+
const registered = chunkF7HJO5GT_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkF7HJO5GT_cjs.contractHandlers.get(t)).filter(isDiscoverable);
|
|
9923
9859
|
const discoverables = [
|
|
9924
9860
|
...registered.filter((h) => h.type === "boarding"),
|
|
9925
9861
|
...registered.filter((h) => h.type !== "boarding")
|
|
@@ -9949,7 +9885,7 @@ var ContractManager = class _ContractManager {
|
|
|
9949
9885
|
);
|
|
9950
9886
|
} catch (error) {
|
|
9951
9887
|
probe.indeterminate.add(index);
|
|
9952
|
-
probe.errors.set(index, { handler: h.type, index, error });
|
|
9888
|
+
probe.errors.set(index, { handler: h.type, fromIndex: index, error });
|
|
9953
9889
|
}
|
|
9954
9890
|
})
|
|
9955
9891
|
);
|
|
@@ -9961,7 +9897,7 @@ var ContractManager = class _ContractManager {
|
|
|
9961
9897
|
for (const e of entries) probe.indeterminate.add(e.index);
|
|
9962
9898
|
probe.errors.set(from, {
|
|
9963
9899
|
handler: h.type,
|
|
9964
|
-
|
|
9900
|
+
fromIndex: from,
|
|
9965
9901
|
...to > from && { toIndex: to },
|
|
9966
9902
|
error
|
|
9967
9903
|
});
|
|
@@ -10023,7 +9959,6 @@ var ContractManager = class _ContractManager {
|
|
|
10023
9959
|
);
|
|
10024
9960
|
}
|
|
10025
9961
|
return {
|
|
10026
|
-
lastIndexUsed: highestConfirmedUsedIndex,
|
|
10027
9962
|
highestConfirmedUsedIndex,
|
|
10028
9963
|
...truncatedAt !== void 0 && { truncatedAt },
|
|
10029
9964
|
handlerErrors
|
|
@@ -10054,7 +9989,7 @@ var ContractManager = class _ContractManager {
|
|
|
10054
9989
|
await this.syncContracts({ contracts, pageSize });
|
|
10055
9990
|
this.markSyncOnline();
|
|
10056
9991
|
} catch (err) {
|
|
10057
|
-
if (!
|
|
9992
|
+
if (!chunkC5Y2R63Z_cjs.isRetryableProviderError(err)) throw err;
|
|
10058
9993
|
this.markSyncDegraded(err);
|
|
10059
9994
|
}
|
|
10060
9995
|
const vtxos = await this.getVtxosForContracts(contracts);
|
|
@@ -10075,7 +10010,7 @@ var ContractManager = class _ContractManager {
|
|
|
10075
10010
|
}
|
|
10076
10011
|
const tapscriptCache = tapscripts ?? /* @__PURE__ */ new Map();
|
|
10077
10012
|
return vtxos.map(
|
|
10078
|
-
(vtxo) => extendVirtualCoinForContract(
|
|
10013
|
+
(vtxo) => extendVirtualCoinForContract(chunkC5Y2R63Z_cjs.normalizeVtxo(vtxo), byScript, tapscriptCache)
|
|
10079
10014
|
);
|
|
10080
10015
|
}
|
|
10081
10016
|
/** @inheritdoc */
|
|
@@ -10101,8 +10036,8 @@ var ContractManager = class _ContractManager {
|
|
|
10101
10036
|
);
|
|
10102
10037
|
}
|
|
10103
10038
|
/** @inheritdoc */
|
|
10104
|
-
async assertSpendableNow(vtxos,
|
|
10105
|
-
const refused = await this.unspendableNowReasons(vtxos,
|
|
10039
|
+
async assertSpendableNow(vtxos, walletDescriptor) {
|
|
10040
|
+
const refused = await this.unspendableNowReasons(vtxos, walletDescriptor);
|
|
10106
10041
|
if (refused.size === 0) return;
|
|
10107
10042
|
if (refused.size === 1) throw new Error([...refused.values()][0]);
|
|
10108
10043
|
throw new Error(
|
|
@@ -10110,7 +10045,7 @@ var ContractManager = class _ContractManager {
|
|
|
10110
10045
|
);
|
|
10111
10046
|
}
|
|
10112
10047
|
/** @inheritdoc */
|
|
10113
|
-
async unspendableNowReasons(vtxos,
|
|
10048
|
+
async unspendableNowReasons(vtxos, walletDescriptor) {
|
|
10114
10049
|
const refused = /* @__PURE__ */ new Map();
|
|
10115
10050
|
if (vtxos.length === 0) return refused;
|
|
10116
10051
|
const contracts = await this.config.contractRepository.getContracts({
|
|
@@ -10119,21 +10054,21 @@ var ContractManager = class _ContractManager {
|
|
|
10119
10054
|
const byScript = new Map(contracts.map((contract) => [contract.script, contract]));
|
|
10120
10055
|
const asking = vtxos.filter((vtxo) => {
|
|
10121
10056
|
const contract = byScript.get(vtxo.script);
|
|
10122
|
-
return contract !== void 0 &&
|
|
10057
|
+
return contract !== void 0 && chunkF7HJO5GT_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
|
|
10123
10058
|
});
|
|
10124
10059
|
if (asking.length === 0) return refused;
|
|
10125
10060
|
const tip = await this.currentChainTip();
|
|
10126
|
-
const
|
|
10061
|
+
const walletDescriptorValue = await walletDescriptor?.();
|
|
10127
10062
|
for (const vtxo of asking) {
|
|
10128
10063
|
const contract = byScript.get(vtxo.script);
|
|
10129
|
-
const handler =
|
|
10064
|
+
const handler = chunkF7HJO5GT_cjs.contractHandlers.get(contract.type);
|
|
10130
10065
|
if (!handler?.assertSpendableNow) continue;
|
|
10131
10066
|
const context = {
|
|
10132
10067
|
collaborative: true,
|
|
10133
10068
|
currentTime: Date.now(),
|
|
10134
10069
|
blockHeight: tip?.height,
|
|
10135
10070
|
chainTime: tip?.time,
|
|
10136
|
-
|
|
10071
|
+
walletDescriptor: walletDescriptorValue,
|
|
10137
10072
|
// `isVirtualCoin` alone is too weak here: it only asks for a
|
|
10138
10073
|
// string `script`, which every AssertSpendableInput has, so a
|
|
10139
10074
|
// bare outpoint would be published as a coin with no `status`.
|
|
@@ -10141,7 +10076,7 @@ var ContractManager = class _ContractManager {
|
|
|
10141
10076
|
// the next handler to answer a CSV question would meet a
|
|
10142
10077
|
// TypeError instead of a `false`. Carry the coin only when it
|
|
10143
10078
|
// really is one.
|
|
10144
|
-
vtxo:
|
|
10079
|
+
vtxo: chunkC5Y2R63Z_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
|
|
10145
10080
|
};
|
|
10146
10081
|
try {
|
|
10147
10082
|
await handler.assertSpendableNow(
|
|
@@ -10294,10 +10229,10 @@ var ContractManager = class _ContractManager {
|
|
|
10294
10229
|
* @param options - Options for getting spendable paths
|
|
10295
10230
|
*/
|
|
10296
10231
|
async getSpendablePaths(options) {
|
|
10297
|
-
const { contractScript, collaborative = true,
|
|
10232
|
+
const { contractScript, collaborative = true, walletDescriptor, vtxo } = options;
|
|
10298
10233
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
10299
10234
|
if (!contract) return [];
|
|
10300
|
-
const handler =
|
|
10235
|
+
const handler = chunkF7HJO5GT_cjs.contractHandlers.get(contract.type);
|
|
10301
10236
|
if (!handler) return [];
|
|
10302
10237
|
const script = handler.createScript(contract.params);
|
|
10303
10238
|
const tip = await this.currentChainTip();
|
|
@@ -10306,7 +10241,7 @@ var ContractManager = class _ContractManager {
|
|
|
10306
10241
|
currentTime: Date.now(),
|
|
10307
10242
|
blockHeight: tip?.height,
|
|
10308
10243
|
chainTime: tip?.time,
|
|
10309
|
-
|
|
10244
|
+
walletDescriptor,
|
|
10310
10245
|
vtxo
|
|
10311
10246
|
};
|
|
10312
10247
|
return handler.getSpendablePaths(script, contract, context);
|
|
@@ -10322,16 +10257,16 @@ var ContractManager = class _ContractManager {
|
|
|
10322
10257
|
* @param options - Options for getting spending paths
|
|
10323
10258
|
*/
|
|
10324
10259
|
async getAllSpendingPaths(options) {
|
|
10325
|
-
const { contractScript, collaborative = true,
|
|
10260
|
+
const { contractScript, collaborative = true, walletDescriptor } = options;
|
|
10326
10261
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
10327
10262
|
if (!contract) return [];
|
|
10328
|
-
const handler =
|
|
10263
|
+
const handler = chunkF7HJO5GT_cjs.contractHandlers.get(contract.type);
|
|
10329
10264
|
if (!handler) return [];
|
|
10330
10265
|
const script = handler.createScript(contract.params);
|
|
10331
10266
|
const context = {
|
|
10332
10267
|
collaborative,
|
|
10333
10268
|
currentTime: Date.now(),
|
|
10334
|
-
|
|
10269
|
+
walletDescriptor
|
|
10335
10270
|
};
|
|
10336
10271
|
return handler.getAllSpendingPaths(script, contract, context);
|
|
10337
10272
|
}
|
|
@@ -10381,7 +10316,7 @@ var ContractManager = class _ContractManager {
|
|
|
10381
10316
|
}
|
|
10382
10317
|
async refreshOutpoints(outpoints) {
|
|
10383
10318
|
if (outpoints.length === 0) return;
|
|
10384
|
-
const { vtxos } = await
|
|
10319
|
+
const { vtxos } = await chunkC5Y2R63Z_cjs.getNormalizedVtxos(this.config.indexerProvider, {
|
|
10385
10320
|
outpoints
|
|
10386
10321
|
});
|
|
10387
10322
|
if (vtxos.length === 0) return;
|
|
@@ -10460,7 +10395,7 @@ var ContractManager = class _ContractManager {
|
|
|
10460
10395
|
break;
|
|
10461
10396
|
}
|
|
10462
10397
|
} catch (err) {
|
|
10463
|
-
if (!
|
|
10398
|
+
if (!chunkC5Y2R63Z_cjs.isRetryableProviderError(err)) throw err;
|
|
10464
10399
|
this.markSyncDegraded(err);
|
|
10465
10400
|
}
|
|
10466
10401
|
this.emitEvent(event);
|
|
@@ -10539,7 +10474,7 @@ var ContractManager = class _ContractManager {
|
|
|
10539
10474
|
*/
|
|
10540
10475
|
async reconcilePendingFrontier(contracts) {
|
|
10541
10476
|
const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
|
|
10542
|
-
const vtxos = await
|
|
10477
|
+
const vtxos = await chunkC5Y2R63Z_cjs.getAllNormalizedVtxos(
|
|
10543
10478
|
this.config.indexerProvider,
|
|
10544
10479
|
contracts.map((c) => c.script),
|
|
10545
10480
|
{ pendingOnly: true }
|
|
@@ -10622,7 +10557,7 @@ var ContractManager = class _ContractManager {
|
|
|
10622
10557
|
}
|
|
10623
10558
|
return result;
|
|
10624
10559
|
}
|
|
10625
|
-
async fetchContractVtxosBulk(contracts, pageSize =
|
|
10560
|
+
async fetchContractVtxosBulk(contracts, pageSize = chunkC5Y2R63Z_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
|
|
10626
10561
|
if (contracts.length === 0) {
|
|
10627
10562
|
return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
|
|
10628
10563
|
}
|
|
@@ -10638,7 +10573,7 @@ var ContractManager = class _ContractManager {
|
|
|
10638
10573
|
before: syncWindow.before
|
|
10639
10574
|
}
|
|
10640
10575
|
} : {};
|
|
10641
|
-
const vtxos = await
|
|
10576
|
+
const vtxos = await chunkC5Y2R63Z_cjs.getAllNormalizedVtxos(
|
|
10642
10577
|
this.config.indexerProvider,
|
|
10643
10578
|
contracts.map((c) => c.script),
|
|
10644
10579
|
{ ...windowOpts, pageSize }
|
|
@@ -10774,16 +10709,12 @@ var serializeUtxo = (u) => ({
|
|
|
10774
10709
|
intentTapLeafScript: serializeTapLeaf(u.intentTapLeafScript),
|
|
10775
10710
|
extraWitness: u.extraWitness?.map(base.hex.encode)
|
|
10776
10711
|
});
|
|
10777
|
-
var serializeTransaction = (t) => ({
|
|
10778
|
-
...t,
|
|
10779
|
-
assets: serializeAssets(t.assets)
|
|
10780
|
-
});
|
|
10781
10712
|
var deserializeTapLeaf = (t) => {
|
|
10782
10713
|
const cb = btcSigner.TaprootControlBlock.decode(base.hex.decode(t.cb));
|
|
10783
10714
|
const s = base.hex.decode(t.s);
|
|
10784
10715
|
return [cb, s];
|
|
10785
10716
|
};
|
|
10786
|
-
var deserializeVtxo = (o) =>
|
|
10717
|
+
var deserializeVtxo = (o) => chunkC5Y2R63Z_cjs.normalizeVtxo({
|
|
10787
10718
|
...o,
|
|
10788
10719
|
createdAt: new Date(o.createdAt),
|
|
10789
10720
|
tapTree: base.hex.decode(o.tapTree),
|
|
@@ -10799,10 +10730,6 @@ var deserializeUtxo = (o) => ({
|
|
|
10799
10730
|
intentTapLeafScript: deserializeTapLeaf(o.intentTapLeafScript),
|
|
10800
10731
|
extraWitness: o.extraWitness?.map(base.hex.decode)
|
|
10801
10732
|
});
|
|
10802
|
-
var deserializeTransaction = (o) => ({
|
|
10803
|
-
...o,
|
|
10804
|
-
assets: deserializeAssets(o.assets)
|
|
10805
|
-
});
|
|
10806
10733
|
|
|
10807
10734
|
// src/repositories/indexedDB/contractRepository.ts
|
|
10808
10735
|
var IndexedDBContractRepository = class {
|
|
@@ -10917,6 +10844,37 @@ function normalizeFilter(filter) {
|
|
|
10917
10844
|
return res;
|
|
10918
10845
|
}
|
|
10919
10846
|
|
|
10847
|
+
// src/repositories/legacyVtxoFacts.ts
|
|
10848
|
+
function parseLegacyExpiry(batchExpiry) {
|
|
10849
|
+
if (typeof batchExpiry !== "number" || !Number.isFinite(batchExpiry) || batchExpiry <= 0) {
|
|
10850
|
+
return {};
|
|
10851
|
+
}
|
|
10852
|
+
if (batchExpiry >= chunkC5Y2R63Z_cjs.EXPIRY_MIN_PLAUSIBLE_MS) return { expiresAt: new Date(batchExpiry) };
|
|
10853
|
+
return { expiresAtHeight: batchExpiry / 1e3 };
|
|
10854
|
+
}
|
|
10855
|
+
function legacyVtxoFacts(status) {
|
|
10856
|
+
let blob = status;
|
|
10857
|
+
if (typeof blob === "string") {
|
|
10858
|
+
try {
|
|
10859
|
+
blob = JSON.parse(blob);
|
|
10860
|
+
} catch {
|
|
10861
|
+
return void 0;
|
|
10862
|
+
}
|
|
10863
|
+
}
|
|
10864
|
+
if (typeof blob !== "object" || blob === null) return void 0;
|
|
10865
|
+
const { state, commitmentTxIds, batchExpiry } = blob;
|
|
10866
|
+
if (state === void 0 && commitmentTxIds === void 0 && batchExpiry === void 0) {
|
|
10867
|
+
return void 0;
|
|
10868
|
+
}
|
|
10869
|
+
return {
|
|
10870
|
+
isSpent: state === "spent",
|
|
10871
|
+
isSwept: state === "swept",
|
|
10872
|
+
isPreconfirmed: state === "preconfirmed",
|
|
10873
|
+
commitmentTxIds: Array.isArray(commitmentTxIds) ? commitmentTxIds : void 0,
|
|
10874
|
+
...parseLegacyExpiry(batchExpiry)
|
|
10875
|
+
};
|
|
10876
|
+
}
|
|
10877
|
+
|
|
10920
10878
|
// src/repositories/indexedDB/walletRepository.ts
|
|
10921
10879
|
var IndexedDBWalletRepository = class {
|
|
10922
10880
|
version = 1;
|
|
@@ -11138,6 +11096,20 @@ function deserializeVtxoWithBackfill(o) {
|
|
|
11138
11096
|
if (!o.script) {
|
|
11139
11097
|
o = { ...o, script: scriptFromArkAddress(o.address) };
|
|
11140
11098
|
}
|
|
11099
|
+
if (o.isSwept === void 0 && o.isPreconfirmed === void 0) {
|
|
11100
|
+
const facts = legacyVtxoFacts(o.virtualStatus);
|
|
11101
|
+
if (facts) {
|
|
11102
|
+
o = {
|
|
11103
|
+
...o,
|
|
11104
|
+
isSpent: o.isSpent ?? facts.isSpent,
|
|
11105
|
+
isSwept: facts.isSwept,
|
|
11106
|
+
isPreconfirmed: facts.isPreconfirmed,
|
|
11107
|
+
commitmentTxIds: o.commitmentTxIds ?? facts.commitmentTxIds,
|
|
11108
|
+
expiresAt: o.expiresAt ?? facts.expiresAt,
|
|
11109
|
+
expiresAtHeight: o.expiresAtHeight ?? facts.expiresAtHeight
|
|
11110
|
+
};
|
|
11111
|
+
}
|
|
11112
|
+
}
|
|
11141
11113
|
return deserializeVtxo(o);
|
|
11142
11114
|
}
|
|
11143
11115
|
function isCanonicalRow(row) {
|
|
@@ -11166,323 +11138,6 @@ function getLifecycleWeight(v) {
|
|
|
11166
11138
|
if (v.arkTxId) weight += 2;
|
|
11167
11139
|
return weight;
|
|
11168
11140
|
}
|
|
11169
|
-
|
|
11170
|
-
// src/repositories/migrations/walletRepositoryImpl.ts
|
|
11171
|
-
var getVtxosStorageKey = (address) => `vtxos:${address}`;
|
|
11172
|
-
var getUtxosStorageKey = (address) => `utxos:${address}`;
|
|
11173
|
-
var getTransactionsStorageKey = (address) => `tx:${address}`;
|
|
11174
|
-
var walletStateStorageKey = "wallet:state";
|
|
11175
|
-
var WalletRepositoryImpl = class {
|
|
11176
|
-
version = 1;
|
|
11177
|
-
storage;
|
|
11178
|
-
constructor(storage) {
|
|
11179
|
-
this.storage = storage;
|
|
11180
|
-
}
|
|
11181
|
-
async getVtxos(address) {
|
|
11182
|
-
const stored = await this.storage.getItem(getVtxosStorageKey(address));
|
|
11183
|
-
if (!stored) return [];
|
|
11184
|
-
try {
|
|
11185
|
-
const parsed = JSON.parse(stored);
|
|
11186
|
-
return parsed.map(deserializeVtxo);
|
|
11187
|
-
} catch (error) {
|
|
11188
|
-
console.error(`Failed to parse VTXOs for address ${address}:`, error);
|
|
11189
|
-
return [];
|
|
11190
|
-
}
|
|
11191
|
-
}
|
|
11192
|
-
async saveVtxos(address, vtxos) {
|
|
11193
|
-
const storedVtxos = await this.getVtxos(address);
|
|
11194
|
-
for (const vtxo of vtxos) {
|
|
11195
|
-
const existing = storedVtxos.findIndex(
|
|
11196
|
-
(v) => v.txid === vtxo.txid && v.vout === vtxo.vout
|
|
11197
|
-
);
|
|
11198
|
-
if (existing !== -1) {
|
|
11199
|
-
storedVtxos[existing] = vtxo;
|
|
11200
|
-
} else {
|
|
11201
|
-
storedVtxos.push(vtxo);
|
|
11202
|
-
}
|
|
11203
|
-
}
|
|
11204
|
-
await this.storage.setItem(
|
|
11205
|
-
getVtxosStorageKey(address),
|
|
11206
|
-
JSON.stringify(storedVtxos.map(serializeVtxo))
|
|
11207
|
-
);
|
|
11208
|
-
}
|
|
11209
|
-
async clearVtxos(address) {
|
|
11210
|
-
return this.deleteVtxos(address);
|
|
11211
|
-
}
|
|
11212
|
-
async deleteVtxos(address) {
|
|
11213
|
-
await this.storage.removeItem(getVtxosStorageKey(address));
|
|
11214
|
-
}
|
|
11215
|
-
async getUtxos(address) {
|
|
11216
|
-
const stored = await this.storage.getItem(getUtxosStorageKey(address));
|
|
11217
|
-
if (!stored) return [];
|
|
11218
|
-
try {
|
|
11219
|
-
const parsed = JSON.parse(stored);
|
|
11220
|
-
return parsed.map(deserializeUtxo);
|
|
11221
|
-
} catch (error) {
|
|
11222
|
-
console.error(`Failed to parse UTXOs for address ${address}:`, error);
|
|
11223
|
-
return [];
|
|
11224
|
-
}
|
|
11225
|
-
}
|
|
11226
|
-
async saveUtxos(address, utxos) {
|
|
11227
|
-
const storedUtxos = await this.getUtxos(address);
|
|
11228
|
-
utxos.forEach((utxo) => {
|
|
11229
|
-
const existing = storedUtxos.findIndex(
|
|
11230
|
-
(u) => u.txid === utxo.txid && u.vout === utxo.vout
|
|
11231
|
-
);
|
|
11232
|
-
if (existing !== -1) {
|
|
11233
|
-
storedUtxos[existing] = utxo;
|
|
11234
|
-
} else {
|
|
11235
|
-
storedUtxos.push(utxo);
|
|
11236
|
-
}
|
|
11237
|
-
});
|
|
11238
|
-
await this.storage.setItem(
|
|
11239
|
-
getUtxosStorageKey(address),
|
|
11240
|
-
JSON.stringify(storedUtxos.map(serializeUtxo))
|
|
11241
|
-
);
|
|
11242
|
-
}
|
|
11243
|
-
async clearUtxos(address) {
|
|
11244
|
-
return this.deleteVtxos(address);
|
|
11245
|
-
}
|
|
11246
|
-
async deleteUtxos(address) {
|
|
11247
|
-
await this.storage.removeItem(getUtxosStorageKey(address));
|
|
11248
|
-
}
|
|
11249
|
-
async getTransactionHistory(address) {
|
|
11250
|
-
const storageKey = getTransactionsStorageKey(address);
|
|
11251
|
-
const stored = await this.storage.getItem(storageKey);
|
|
11252
|
-
if (!stored) return [];
|
|
11253
|
-
try {
|
|
11254
|
-
const parsed = JSON.parse(stored);
|
|
11255
|
-
return parsed.map(deserializeTransaction);
|
|
11256
|
-
} catch (error) {
|
|
11257
|
-
console.error(`Failed to parse transactions for address ${address}:`, error);
|
|
11258
|
-
return [];
|
|
11259
|
-
}
|
|
11260
|
-
}
|
|
11261
|
-
async saveTransactions(address, txs) {
|
|
11262
|
-
const storedTransactions = await this.getTransactionHistory(address);
|
|
11263
|
-
for (const tx of txs) {
|
|
11264
|
-
const existing = storedTransactions.findIndex(
|
|
11265
|
-
(t) => t.key.boardingTxid === tx.key.boardingTxid && t.key.commitmentTxid === tx.key.commitmentTxid && t.key.arkTxid === tx.key.arkTxid
|
|
11266
|
-
);
|
|
11267
|
-
if (existing !== -1) {
|
|
11268
|
-
storedTransactions[existing] = tx;
|
|
11269
|
-
} else {
|
|
11270
|
-
storedTransactions.push(tx);
|
|
11271
|
-
}
|
|
11272
|
-
}
|
|
11273
|
-
await this.storage.setItem(
|
|
11274
|
-
getTransactionsStorageKey(address),
|
|
11275
|
-
JSON.stringify(storedTransactions.map(serializeTransaction))
|
|
11276
|
-
);
|
|
11277
|
-
}
|
|
11278
|
-
async clearTransactions(address) {
|
|
11279
|
-
return this.deleteTransactions(address);
|
|
11280
|
-
}
|
|
11281
|
-
async deleteTransactions(address) {
|
|
11282
|
-
await this.storage.removeItem(getTransactionsStorageKey(address));
|
|
11283
|
-
}
|
|
11284
|
-
async getWalletState() {
|
|
11285
|
-
const stored = await this.storage.getItem(walletStateStorageKey);
|
|
11286
|
-
if (!stored) return null;
|
|
11287
|
-
try {
|
|
11288
|
-
const state = JSON.parse(stored);
|
|
11289
|
-
return state;
|
|
11290
|
-
} catch (error) {
|
|
11291
|
-
console.error("Failed to parse wallet state:", error);
|
|
11292
|
-
return null;
|
|
11293
|
-
}
|
|
11294
|
-
}
|
|
11295
|
-
async saveWalletState(state) {
|
|
11296
|
-
await this.storage.setItem(walletStateStorageKey, JSON.stringify(state));
|
|
11297
|
-
}
|
|
11298
|
-
// New method added in V2, not implemented for legacy
|
|
11299
|
-
async clear() {
|
|
11300
|
-
throw new Error("Method not implemented.");
|
|
11301
|
-
}
|
|
11302
|
-
async [Symbol.asyncDispose]() {
|
|
11303
|
-
return;
|
|
11304
|
-
}
|
|
11305
|
-
};
|
|
11306
|
-
|
|
11307
|
-
// src/repositories/migrations/fromStorageAdapter.ts
|
|
11308
|
-
var MIGRATION_KEY = (repoType) => `migration-from-storage-adapter-${repoType}`;
|
|
11309
|
-
async function getMigrationStatus(repoType, storageAdapter) {
|
|
11310
|
-
try {
|
|
11311
|
-
const migration = await storageAdapter.getItem(MIGRATION_KEY(repoType));
|
|
11312
|
-
if (migration === "done") return "done";
|
|
11313
|
-
if (migration === "in-progress") return "in-progress";
|
|
11314
|
-
return "pending";
|
|
11315
|
-
} catch (e) {
|
|
11316
|
-
if (e instanceof DOMException && e.name === "NotFoundError") return "not-needed";
|
|
11317
|
-
throw e;
|
|
11318
|
-
}
|
|
11319
|
-
}
|
|
11320
|
-
async function requiresMigration(repoType, storageAdapter) {
|
|
11321
|
-
const status = await getMigrationStatus(repoType, storageAdapter);
|
|
11322
|
-
return status === "pending" || status === "in-progress";
|
|
11323
|
-
}
|
|
11324
|
-
async function rollbackMigration(repoType, storageAdapter) {
|
|
11325
|
-
await storageAdapter.removeItem(MIGRATION_KEY(repoType));
|
|
11326
|
-
}
|
|
11327
|
-
async function migrateWalletRepository(storageAdapter, fresh, addresses) {
|
|
11328
|
-
const migrate = await requiresMigration("wallet", storageAdapter);
|
|
11329
|
-
if (!migrate) return;
|
|
11330
|
-
await storageAdapter.setItem(MIGRATION_KEY("wallet"), "in-progress");
|
|
11331
|
-
const old = new WalletRepositoryImpl(storageAdapter);
|
|
11332
|
-
const walletData = await old.getWalletState();
|
|
11333
|
-
const onchainAddrData = await Promise.all(
|
|
11334
|
-
addresses.onchain.map(async (address) => {
|
|
11335
|
-
const utxos = await old.getUtxos(address);
|
|
11336
|
-
return { address, utxos };
|
|
11337
|
-
})
|
|
11338
|
-
);
|
|
11339
|
-
const offchainAddrData = await Promise.all(
|
|
11340
|
-
addresses.offchain.map(async (address) => {
|
|
11341
|
-
const vtxos = await old.getVtxos(address);
|
|
11342
|
-
const txs = await old.getTransactionHistory(address);
|
|
11343
|
-
return { address, vtxos, txs };
|
|
11344
|
-
})
|
|
11345
|
-
);
|
|
11346
|
-
await Promise.all([
|
|
11347
|
-
walletData && fresh.saveWalletState(walletData),
|
|
11348
|
-
...offchainAddrData.map(
|
|
11349
|
-
(addressData) => Promise.all([
|
|
11350
|
-
fresh.saveVtxos(addressData.address, addressData.vtxos),
|
|
11351
|
-
fresh.saveTransactions(addressData.address, addressData.txs)
|
|
11352
|
-
])
|
|
11353
|
-
),
|
|
11354
|
-
...onchainAddrData.map(
|
|
11355
|
-
(addressData) => fresh.saveUtxos(addressData.address, addressData.utxos)
|
|
11356
|
-
)
|
|
11357
|
-
]);
|
|
11358
|
-
await storageAdapter.setItem(MIGRATION_KEY("wallet"), "done");
|
|
11359
|
-
}
|
|
11360
|
-
|
|
11361
|
-
// src/repositories/migrations/contractRepositoryImpl.ts
|
|
11362
|
-
var getContractStorageKey = (id, key) => `contract:${id}:${key}`;
|
|
11363
|
-
var getCollectionStorageKey = (type) => `collection:${type}`;
|
|
11364
|
-
var ContractRepositoryImpl = class {
|
|
11365
|
-
storage;
|
|
11366
|
-
constructor(storage) {
|
|
11367
|
-
this.storage = storage;
|
|
11368
|
-
}
|
|
11369
|
-
get version() {
|
|
11370
|
-
throw new TypeError(
|
|
11371
|
-
"ContractRepositoryImpl is a migration shim and does not implement contract rows."
|
|
11372
|
-
);
|
|
11373
|
-
}
|
|
11374
|
-
async getContractData(contractId, key) {
|
|
11375
|
-
const stored = await this.storage.getItem(getContractStorageKey(contractId, key));
|
|
11376
|
-
if (!stored) return null;
|
|
11377
|
-
try {
|
|
11378
|
-
const data = JSON.parse(stored);
|
|
11379
|
-
return data;
|
|
11380
|
-
} catch (error) {
|
|
11381
|
-
console.error(`Failed to parse contract data for ${contractId}:${key}:`, error);
|
|
11382
|
-
return null;
|
|
11383
|
-
}
|
|
11384
|
-
}
|
|
11385
|
-
async setContractData(contractId, key, data) {
|
|
11386
|
-
try {
|
|
11387
|
-
await this.storage.setItem(
|
|
11388
|
-
getContractStorageKey(contractId, key),
|
|
11389
|
-
JSON.stringify(data)
|
|
11390
|
-
);
|
|
11391
|
-
} catch (error) {
|
|
11392
|
-
console.error(`Failed to persist contract data for ${contractId}:${key}:`, error);
|
|
11393
|
-
throw error;
|
|
11394
|
-
}
|
|
11395
|
-
}
|
|
11396
|
-
async deleteContractData(contractId, key) {
|
|
11397
|
-
try {
|
|
11398
|
-
await this.storage.removeItem(getContractStorageKey(contractId, key));
|
|
11399
|
-
} catch (error) {
|
|
11400
|
-
console.error(`Failed to remove contract data for ${contractId}:${key}:`, error);
|
|
11401
|
-
throw error;
|
|
11402
|
-
}
|
|
11403
|
-
}
|
|
11404
|
-
async getContractCollection(contractType) {
|
|
11405
|
-
const stored = await this.storage.getItem(getCollectionStorageKey(contractType));
|
|
11406
|
-
if (!stored) return [];
|
|
11407
|
-
try {
|
|
11408
|
-
const collection = JSON.parse(stored);
|
|
11409
|
-
return collection;
|
|
11410
|
-
} catch (error) {
|
|
11411
|
-
console.error(`Failed to parse contract collection ${contractType}:`, error);
|
|
11412
|
-
return [];
|
|
11413
|
-
}
|
|
11414
|
-
}
|
|
11415
|
-
async saveToContractCollection(contractType, item, idField) {
|
|
11416
|
-
const collection = await this.getContractCollection(contractType);
|
|
11417
|
-
const itemId = item[idField];
|
|
11418
|
-
if (itemId === void 0 || itemId === null) {
|
|
11419
|
-
throw new Error(`Item is missing required field '${String(idField)}'`);
|
|
11420
|
-
}
|
|
11421
|
-
const existingIndex = collection.findIndex((i) => i[idField] === itemId);
|
|
11422
|
-
let newCollection;
|
|
11423
|
-
if (existingIndex !== -1) {
|
|
11424
|
-
newCollection = [
|
|
11425
|
-
...collection.slice(0, existingIndex),
|
|
11426
|
-
item,
|
|
11427
|
-
...collection.slice(existingIndex + 1)
|
|
11428
|
-
];
|
|
11429
|
-
} else {
|
|
11430
|
-
newCollection = [...collection, item];
|
|
11431
|
-
}
|
|
11432
|
-
try {
|
|
11433
|
-
await this.storage.setItem(
|
|
11434
|
-
getCollectionStorageKey(contractType),
|
|
11435
|
-
JSON.stringify(newCollection)
|
|
11436
|
-
);
|
|
11437
|
-
} catch (error) {
|
|
11438
|
-
console.error(`Failed to persist contract collection ${contractType}:`, error);
|
|
11439
|
-
throw error;
|
|
11440
|
-
}
|
|
11441
|
-
}
|
|
11442
|
-
async removeFromContractCollection(contractType, id, idField) {
|
|
11443
|
-
if (id === void 0 || id === null) {
|
|
11444
|
-
throw new Error(`Invalid id provided for removal: ${String(id)}`);
|
|
11445
|
-
}
|
|
11446
|
-
const collection = await this.getContractCollection(contractType);
|
|
11447
|
-
const filtered = collection.filter((item) => item[idField] !== id);
|
|
11448
|
-
try {
|
|
11449
|
-
await this.storage.setItem(
|
|
11450
|
-
getCollectionStorageKey(contractType),
|
|
11451
|
-
JSON.stringify(filtered)
|
|
11452
|
-
);
|
|
11453
|
-
} catch (error) {
|
|
11454
|
-
console.error(
|
|
11455
|
-
`Failed to persist contract collection removal for ${contractType}:`,
|
|
11456
|
-
error
|
|
11457
|
-
);
|
|
11458
|
-
throw error;
|
|
11459
|
-
}
|
|
11460
|
-
}
|
|
11461
|
-
// The following methods are implemented for compatibility with the new ContractRepository interface
|
|
11462
|
-
// but aren't used.
|
|
11463
|
-
async getContracts(_) {
|
|
11464
|
-
throw new TypeError(
|
|
11465
|
-
"Method not implemented, this is a legacy class and should only be used for migrating data."
|
|
11466
|
-
);
|
|
11467
|
-
}
|
|
11468
|
-
async saveContract(_) {
|
|
11469
|
-
throw new TypeError(
|
|
11470
|
-
"Method not implemented, this is a legacy class and should only be used for migrating data."
|
|
11471
|
-
);
|
|
11472
|
-
}
|
|
11473
|
-
async deleteContract(_) {
|
|
11474
|
-
throw new TypeError(
|
|
11475
|
-
"Method not implemented, this is a legacy class and should only be used for migrating data."
|
|
11476
|
-
);
|
|
11477
|
-
}
|
|
11478
|
-
// used only for tests
|
|
11479
|
-
async clear() {
|
|
11480
|
-
await this.storage.clear();
|
|
11481
|
-
}
|
|
11482
|
-
async [Symbol.asyncDispose]() {
|
|
11483
|
-
return;
|
|
11484
|
-
}
|
|
11485
|
-
};
|
|
11486
11141
|
var HD_SETTINGS_KEY = "hd";
|
|
11487
11142
|
var HARDENED_INDEX_OFFSET = 2147483648;
|
|
11488
11143
|
var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
@@ -11569,7 +11224,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
11569
11224
|
* simple `tr(pubkey)` descriptors.
|
|
11570
11225
|
*/
|
|
11571
11226
|
isOurs(descriptor) {
|
|
11572
|
-
return this.identity.
|
|
11227
|
+
return this.identity.ownsDescriptor(descriptor);
|
|
11573
11228
|
}
|
|
11574
11229
|
/**
|
|
11575
11230
|
* Signs each request with the key derived from its descriptor. Delegates
|
|
@@ -11577,11 +11232,11 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
11577
11232
|
* holds the seed.
|
|
11578
11233
|
*/
|
|
11579
11234
|
async signWithDescriptor(requests) {
|
|
11580
|
-
return this.identity.
|
|
11235
|
+
return this.identity.signDescriptorTransactions(requests);
|
|
11581
11236
|
}
|
|
11582
11237
|
/** Signs a message using the key derived from `descriptor`. */
|
|
11583
11238
|
async signMessageWithDescriptor(descriptor, message, signatureType = "schnorr") {
|
|
11584
|
-
return this.identity.
|
|
11239
|
+
return this.identity.signDescriptorMessage(descriptor, message, signatureType);
|
|
11585
11240
|
}
|
|
11586
11241
|
/**
|
|
11587
11242
|
* HD providers participate in receive rotation. The default
|
|
@@ -11606,7 +11261,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
11606
11261
|
*/
|
|
11607
11262
|
materializeDescriptorAt(index) {
|
|
11608
11263
|
const descriptor = this.identity.descriptor;
|
|
11609
|
-
const network =
|
|
11264
|
+
const network = chunkF7HJO5GT_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
11610
11265
|
const expansion = descriptorsScure.expand({ descriptor, network, index });
|
|
11611
11266
|
const keyInfo = expansion.expansionMap?.["@0"];
|
|
11612
11267
|
if (!keyInfo?.keyExpression) {
|
|
@@ -11754,7 +11409,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
11754
11409
|
const provider = await resolveDescriptorProvider(config, setup.walletRepository);
|
|
11755
11410
|
if (!provider) return void 0;
|
|
11756
11411
|
const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
|
|
11757
|
-
const expectedContractType = setup.offchainTapscript instanceof
|
|
11412
|
+
const expectedContractType = setup.offchainTapscript instanceof chunkF7HJO5GT_cjs.DelegateVtxo.Script ? "delegate" : "default";
|
|
11758
11413
|
const factoryOpts = {
|
|
11759
11414
|
walletRepository: setup.walletRepository,
|
|
11760
11415
|
contractRepository: setup.contractRepository,
|
|
@@ -11955,7 +11610,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
11955
11610
|
};
|
|
11956
11611
|
function deriveLeafPubkey(descriptor) {
|
|
11957
11612
|
try {
|
|
11958
|
-
return
|
|
11613
|
+
return chunkF7HJO5GT_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
11959
11614
|
} catch (e) {
|
|
11960
11615
|
throw new NonRangeableDescriptorError(
|
|
11961
11616
|
"Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
|
|
@@ -11967,7 +11622,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
11967
11622
|
const pubKey = deriveLeafPubkey(descriptor);
|
|
11968
11623
|
const tapscript = rebuildTapscript(current, pubKey);
|
|
11969
11624
|
const serverPubKey = tapscript.options.serverPubKey;
|
|
11970
|
-
const csvTimelock =
|
|
11625
|
+
const csvTimelock = chunkC5Y2R63Z_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
|
|
11971
11626
|
const base$1 = {
|
|
11972
11627
|
script: base.hex.encode(tapscript.pkScript),
|
|
11973
11628
|
address: tapscript.address(hrp, serverPubKey).encode(),
|
|
@@ -11978,11 +11633,11 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
11978
11633
|
// index-0 key. Without it, spends produce unsigned PSBTs that the
|
|
11979
11634
|
// server rejects with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
11980
11635
|
metadata: {
|
|
11981
|
-
...tagSource && { source:
|
|
11636
|
+
...tagSource && { source: chunkF7HJO5GT_cjs.WALLET_RECEIVE_SOURCE },
|
|
11982
11637
|
signingDescriptor: descriptor
|
|
11983
11638
|
}
|
|
11984
11639
|
};
|
|
11985
|
-
const params = tapscript instanceof
|
|
11640
|
+
const params = tapscript instanceof chunkF7HJO5GT_cjs.DelegateVtxo.Script ? {
|
|
11986
11641
|
...base$1,
|
|
11987
11642
|
type: "delegate",
|
|
11988
11643
|
params: {
|
|
@@ -12003,10 +11658,10 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
12003
11658
|
return { tapscript, params };
|
|
12004
11659
|
}
|
|
12005
11660
|
function rebuildTapscript(current, pubKey) {
|
|
12006
|
-
if (current instanceof
|
|
12007
|
-
return new
|
|
11661
|
+
if (current instanceof chunkF7HJO5GT_cjs.DelegateVtxo.Script) {
|
|
11662
|
+
return new chunkF7HJO5GT_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
|
|
12008
11663
|
}
|
|
12009
|
-
return new
|
|
11664
|
+
return new chunkF7HJO5GT_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
|
|
12010
11665
|
}
|
|
12011
11666
|
async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
|
|
12012
11667
|
const candidates = await contractRepository.getContracts({
|
|
@@ -12015,7 +11670,7 @@ async function pickActiveReceive(contractRepository, serverPubKey, expectedType)
|
|
|
12015
11670
|
});
|
|
12016
11671
|
const serverPubKeyHex = base.hex.encode(serverPubKey);
|
|
12017
11672
|
const matching = candidates.filter(
|
|
12018
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
11673
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkF7HJO5GT_cjs.WALLET_RECEIVE_SOURCE
|
|
12019
11674
|
).sort((a, b) => {
|
|
12020
11675
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
12021
11676
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -12071,7 +11726,7 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
12071
11726
|
}
|
|
12072
11727
|
};
|
|
12073
11728
|
for (const vtxo of vtxos) {
|
|
12074
|
-
if (
|
|
11729
|
+
if (chunkC5Y2R63Z_cjs.hasTerminalSpend(vtxo)) continue;
|
|
12075
11730
|
addAssets(owned, vtxo);
|
|
12076
11731
|
if (vtxo.isUnrolled) {
|
|
12077
11732
|
unrolled += vtxo.value;
|
|
@@ -12081,11 +11736,11 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
12081
11736
|
pendingRecovery += vtxo.value;
|
|
12082
11737
|
continue;
|
|
12083
11738
|
}
|
|
12084
|
-
if (
|
|
11739
|
+
if (chunkC5Y2R63Z_cjs.canRecoverOnchain(vtxo, now)) {
|
|
12085
11740
|
recoverable += vtxo.value;
|
|
12086
11741
|
continue;
|
|
12087
11742
|
}
|
|
12088
|
-
if (!
|
|
11743
|
+
if (!chunkC5Y2R63Z_cjs.canSpendOffchain(vtxo, now)) continue;
|
|
12089
11744
|
if (vtxo.isPreconfirmed) {
|
|
12090
11745
|
preconfirmed += vtxo.value;
|
|
12091
11746
|
} else {
|
|
@@ -12255,12 +11910,11 @@ var InputSignerRouter = class {
|
|
|
12255
11910
|
};
|
|
12256
11911
|
|
|
12257
11912
|
// src/wallet/wallet.ts
|
|
12258
|
-
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl || chunkJZWLXNHV_cjs.DEFAULT_ARKADE_SERVER_URL;
|
|
12259
11913
|
function intentProofJobs(coins) {
|
|
12260
11914
|
if (coins.length === 0) return [];
|
|
12261
11915
|
const coinJobs = coins.map((coin, i) => ({
|
|
12262
11916
|
index: i + 1,
|
|
12263
|
-
lookupScript:
|
|
11917
|
+
lookupScript: chunkC5Y2R63Z_cjs.VtxoScript.decode(coin.tapTree).pkScript
|
|
12264
11918
|
}));
|
|
12265
11919
|
return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
|
|
12266
11920
|
}
|
|
@@ -12292,7 +11946,7 @@ function dedupeTimelocks(timelocks) {
|
|
|
12292
11946
|
const seen = /* @__PURE__ */ new Set();
|
|
12293
11947
|
const deduped = [];
|
|
12294
11948
|
for (const timelock of timelocks) {
|
|
12295
|
-
const sequence =
|
|
11949
|
+
const sequence = chunkC5Y2R63Z_cjs.timelockToSequence(timelock).toString();
|
|
12296
11950
|
if (seen.has(sequence)) continue;
|
|
12297
11951
|
seen.add(sequence);
|
|
12298
11952
|
deduped.push(timelock);
|
|
@@ -12309,7 +11963,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
12309
11963
|
state: "active"
|
|
12310
11964
|
});
|
|
12311
11965
|
const newest = candidates.filter(
|
|
12312
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
11966
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkF7HJO5GT_cjs.WALLET_RECEIVE_SOURCE
|
|
12313
11967
|
).sort((a, b) => {
|
|
12314
11968
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
12315
11969
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -12317,7 +11971,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
12317
11971
|
if (!newest?.params.pubKey) return baseline;
|
|
12318
11972
|
try {
|
|
12319
11973
|
const pubKey = base.hex.decode(newest.params.pubKey);
|
|
12320
|
-
return new
|
|
11974
|
+
return new chunkF7HJO5GT_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
|
|
12321
11975
|
} catch (e) {
|
|
12322
11976
|
console.warn("Skipping malformed boarding contract at boot", newest.script, e);
|
|
12323
11977
|
return baseline;
|
|
@@ -12336,10 +11990,10 @@ function filterSnapshotVtxos(snapshot, filter, pendingSpendOutpoints) {
|
|
|
12336
11990
|
if (vtxo.isUnrolled) {
|
|
12337
11991
|
return !!f.withUnrolled;
|
|
12338
11992
|
}
|
|
12339
|
-
if (
|
|
11993
|
+
if (chunkC5Y2R63Z_cjs.hasTerminalSpend(vtxo)) {
|
|
12340
11994
|
return false;
|
|
12341
11995
|
}
|
|
12342
|
-
if (!f.withRecoverable &&
|
|
11996
|
+
if (!f.withRecoverable && chunkC5Y2R63Z_cjs.canRecoverOnchain(vtxo, now)) {
|
|
12343
11997
|
return false;
|
|
12344
11998
|
}
|
|
12345
11999
|
return true;
|
|
@@ -12690,7 +12344,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12690
12344
|
async getArkadeReader() {
|
|
12691
12345
|
const indexer = this.indexerProvider;
|
|
12692
12346
|
return {
|
|
12693
|
-
getVtxos: (opts) =>
|
|
12347
|
+
getVtxos: (opts) => chunkC5Y2R63Z_cjs.getNormalizedVtxos(indexer, opts),
|
|
12694
12348
|
getVirtualTxs: (txids, opts) => indexer.getVirtualTxs(txids, opts)
|
|
12695
12349
|
};
|
|
12696
12350
|
}
|
|
@@ -12745,25 +12399,16 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12745
12399
|
* Extracts common logic used by both ReadonlyWallet.create() and Wallet.create().
|
|
12746
12400
|
*/
|
|
12747
12401
|
static async setupWalletConfig(config, pubKey) {
|
|
12748
|
-
const
|
|
12749
|
-
const arkProvider = config.arkProvider || new chunkJZWLXNHV_cjs.RestArkProvider(arkadeServerUrl);
|
|
12402
|
+
const arkProvider = config.arkProvider || new chunkC5Y2R63Z_cjs.RestArkProvider();
|
|
12750
12403
|
let indexerProvider = config.indexerProvider;
|
|
12751
12404
|
if (!indexerProvider) {
|
|
12752
|
-
|
|
12753
|
-
if (!
|
|
12754
|
-
|
|
12755
|
-
|
|
12756
|
-
|
|
12757
|
-
throw new Error(
|
|
12758
|
-
"indexerUrl is required when arkProvider is provided without a discoverable serverUrl"
|
|
12759
|
-
);
|
|
12760
|
-
}
|
|
12761
|
-
indexerUrl = derived;
|
|
12762
|
-
} else {
|
|
12763
|
-
indexerUrl = arkadeServerUrl;
|
|
12764
|
-
}
|
|
12405
|
+
const derived = extractArkProviderUrl(arkProvider);
|
|
12406
|
+
if (!derived && config.arkProvider) {
|
|
12407
|
+
throw new Error(
|
|
12408
|
+
"indexerProvider is required when arkProvider is provided without a discoverable serverUrl"
|
|
12409
|
+
);
|
|
12765
12410
|
}
|
|
12766
|
-
indexerProvider = new
|
|
12411
|
+
indexerProvider = new chunkSYRQJS5N_cjs.RestIndexerProvider(derived ?? chunkC5Y2R63Z_cjs.DEFAULT_ARKADE_SERVER_URL);
|
|
12767
12412
|
}
|
|
12768
12413
|
const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
12769
12414
|
const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
@@ -12772,7 +12417,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12772
12417
|
source: serverInfoSource,
|
|
12773
12418
|
lastOnlineAt: serverInfoLastOnlineAt
|
|
12774
12419
|
} = await resolveArkInfo(arkProvider, walletRepository);
|
|
12775
|
-
const network =
|
|
12420
|
+
const network = chunkC5Y2R63Z_cjs.networkFromArkadeInfo(info);
|
|
12776
12421
|
if ("descriptor" in config.identity) {
|
|
12777
12422
|
const descriptor = config.identity.descriptor;
|
|
12778
12423
|
const identityIsMainnet = !descriptor.includes("tpub");
|
|
@@ -12788,8 +12433,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12788
12433
|
);
|
|
12789
12434
|
}
|
|
12790
12435
|
}
|
|
12791
|
-
const
|
|
12792
|
-
const onchainProvider = config.onchainProvider || new EsploraProvider(esploraUrl);
|
|
12436
|
+
const onchainProvider = config.onchainProvider || new EsploraProvider(ESPLORA_URL[info.network]);
|
|
12793
12437
|
if (config.exitTimelock) {
|
|
12794
12438
|
const { value, type } = config.exitTimelock;
|
|
12795
12439
|
if (value < 512n && type !== "blocks" || value >= 512n && type !== "seconds") {
|
|
@@ -12812,18 +12456,18 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12812
12456
|
value: info.boardingExitDelay,
|
|
12813
12457
|
type: info.boardingExitDelay < 512n ? "blocks" : "seconds"
|
|
12814
12458
|
};
|
|
12815
|
-
const serverPubKey =
|
|
12816
|
-
const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) =>
|
|
12459
|
+
const serverPubKey = chunkF7HJO5GT_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
|
|
12460
|
+
const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) => chunkF7HJO5GT_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : void 0;
|
|
12817
12461
|
const offchainOptions = {
|
|
12818
12462
|
pubKey,
|
|
12819
12463
|
serverPubKey,
|
|
12820
12464
|
csvTimelock: exitTimelock
|
|
12821
12465
|
};
|
|
12822
|
-
const offchainTapscript = !delegatePubKey ? new
|
|
12823
|
-
const boardingTapscript =
|
|
12466
|
+
const offchainTapscript = !delegatePubKey ? new chunkF7HJO5GT_cjs.DefaultVtxo.Script(offchainOptions) : new chunkF7HJO5GT_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
|
|
12467
|
+
const boardingTapscript = chunkF7HJO5GT_cjs.BoardingContractHandler.createScript({
|
|
12824
12468
|
pubKey: base.hex.encode(pubKey),
|
|
12825
12469
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
12826
|
-
csvTimelock:
|
|
12470
|
+
csvTimelock: chunkC5Y2R63Z_cjs.timelockToSequence(boardingTimelock).toString()
|
|
12827
12471
|
});
|
|
12828
12472
|
return {
|
|
12829
12473
|
arkProvider,
|
|
@@ -12840,9 +12484,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12840
12484
|
info,
|
|
12841
12485
|
serverInfoSource,
|
|
12842
12486
|
serverInfoLastOnlineAt,
|
|
12843
|
-
delegateProvider: config.delegateProvider
|
|
12844
|
-
/** @deprecated alias for `delegateProvider` */
|
|
12845
|
-
delegatorProvider: config.delegateProvider || config.delegatorProvider,
|
|
12487
|
+
delegateProvider: config.delegateProvider,
|
|
12846
12488
|
walletContractTimelocks
|
|
12847
12489
|
};
|
|
12848
12490
|
}
|
|
@@ -12870,7 +12512,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12870
12512
|
setup.dustAmount,
|
|
12871
12513
|
setup.walletRepository,
|
|
12872
12514
|
setup.contractRepository,
|
|
12873
|
-
setup.delegateProvider
|
|
12515
|
+
setup.delegateProvider,
|
|
12874
12516
|
config.watcherConfig,
|
|
12875
12517
|
setup.walletContractTimelocks
|
|
12876
12518
|
);
|
|
@@ -12958,7 +12600,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12958
12600
|
* The raw reporting/recovery read: escrowed, locked and awaiting-recovery
|
|
12959
12601
|
* funds are all present. Coin selection must use
|
|
12960
12602
|
* {@link getSpendableVtxos} instead — feeding this straight into
|
|
12961
|
-
* `settle({ inputs })` or `
|
|
12603
|
+
* `settle({ inputs })` or `send({ selectedVtxos })` bypasses the
|
|
12962
12604
|
* generic-spending gate.
|
|
12963
12605
|
*
|
|
12964
12606
|
* @param filter - Optional flags controlling whether recoverable or unrolled VTXOs are included
|
|
@@ -12990,7 +12632,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12990
12632
|
if (!filter?.withUnrolled) {
|
|
12991
12633
|
logExcludedVtxos(
|
|
12992
12634
|
"getSpendableVtxos",
|
|
12993
|
-
snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !
|
|
12635
|
+
snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !chunkC5Y2R63Z_cjs.hasTerminalSpend(vtxo)),
|
|
12994
12636
|
[() => UNROLLED_REASON]
|
|
12995
12637
|
);
|
|
12996
12638
|
}
|
|
@@ -13133,7 +12775,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13133
12775
|
const response = await contractManager.getContractsWithVtxos();
|
|
13134
12776
|
const allVtxos = response.flatMap((_) => _.vtxos);
|
|
13135
12777
|
const { boardingTxs, commitmentsToIgnore } = await this.getBoardingTxs();
|
|
13136
|
-
const resolveTxCreatedAt = (txids) =>
|
|
12778
|
+
const resolveTxCreatedAt = (txids) => chunkC5Y2R63Z_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
|
|
13137
12779
|
return buildTransactionHistory(
|
|
13138
12780
|
allVtxos,
|
|
13139
12781
|
boardingTxs,
|
|
@@ -13227,7 +12869,6 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13227
12869
|
},
|
|
13228
12870
|
isUnrolled: true,
|
|
13229
12871
|
...boardingFacts,
|
|
13230
|
-
virtualStatus: chunkJZWLXNHV_cjs.toVirtualStatus(boardingFacts),
|
|
13231
12872
|
spentBy: "",
|
|
13232
12873
|
createdAt: tx.status.confirmed ? new Date(tx.status.block_time * 1e3) : /* @__PURE__ */ new Date(0),
|
|
13233
12874
|
script: scriptHex
|
|
@@ -13283,9 +12924,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13283
12924
|
async getBoardingTapscripts(allowedSigners) {
|
|
13284
12925
|
const byScript = /* @__PURE__ */ new Map();
|
|
13285
12926
|
const add = (s) => byScript.set(base.hex.encode(s.pkScript), s);
|
|
13286
|
-
const boardingCsv = this.boardingTapscript.options.csvTimelock ??
|
|
12927
|
+
const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkF7HJO5GT_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
13287
12928
|
add(
|
|
13288
|
-
new
|
|
12929
|
+
new chunkF7HJO5GT_cjs.DefaultVtxo.Script({
|
|
13289
12930
|
pubKey: await this.identity.xOnlyPublicKey(),
|
|
13290
12931
|
serverPubKey: this.boardingTapscript.options.serverPubKey,
|
|
13291
12932
|
csvTimelock: boardingCsv
|
|
@@ -13300,7 +12941,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13300
12941
|
for (const c of boardingContracts) {
|
|
13301
12942
|
if (!allowed.has(toXOnlySignerHex(c.params.serverPubKey))) continue;
|
|
13302
12943
|
try {
|
|
13303
|
-
add(
|
|
12944
|
+
add(chunkF7HJO5GT_cjs.BoardingContractHandler.createScript(c.params));
|
|
13304
12945
|
} catch (e) {
|
|
13305
12946
|
console.warn("Skipping malformed boarding contract", c.script, e);
|
|
13306
12947
|
}
|
|
@@ -13338,7 +12979,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13338
12979
|
// Per-row CSV delay decoded from THIS tapscript's exit leaf —
|
|
13339
12980
|
// not the wallet's current boarding timelock, which a signer
|
|
13340
12981
|
// rotation may have changed.
|
|
13341
|
-
csvTimelock:
|
|
12982
|
+
csvTimelock: chunkC5Y2R63Z_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
|
|
13342
12983
|
coins: utxos
|
|
13343
12984
|
});
|
|
13344
12985
|
}
|
|
@@ -13471,7 +13112,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13471
13112
|
/** Fetch Arkade transaction ids that are still pending final settlement. */
|
|
13472
13113
|
async fetchPendingTxs() {
|
|
13473
13114
|
const scripts = await this.getWalletScripts();
|
|
13474
|
-
const vtxos = await
|
|
13115
|
+
const vtxos = await chunkC5Y2R63Z_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
|
|
13475
13116
|
return vtxos.filter(
|
|
13476
13117
|
(vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
|
|
13477
13118
|
).map((_) => _.arkTxId);
|
|
@@ -13502,7 +13143,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13502
13143
|
});
|
|
13503
13144
|
for (const contract of contracts) {
|
|
13504
13145
|
if (map.has(contract.script)) continue;
|
|
13505
|
-
const handler =
|
|
13146
|
+
const handler = chunkF7HJO5GT_cjs.contractHandlers.get(contract.type);
|
|
13506
13147
|
if (handler) {
|
|
13507
13148
|
const script = handler.createScript(contract.params);
|
|
13508
13149
|
map.set(contract.script, script);
|
|
@@ -13614,7 +13255,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13614
13255
|
}
|
|
13615
13256
|
});
|
|
13616
13257
|
const baselinePubkey = await this.identity.xOnlyPublicKey();
|
|
13617
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
13258
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkF7HJO5GT_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
13618
13259
|
const baselineSigners = [
|
|
13619
13260
|
this.offchainTapscript.options.serverPubKey,
|
|
13620
13261
|
...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
|
|
@@ -13622,8 +13263,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13622
13263
|
const seenBaselineScripts = /* @__PURE__ */ new Set();
|
|
13623
13264
|
for (const serverPubKey of baselineSigners) {
|
|
13624
13265
|
for (const csvTimelock of this.walletContractTimelocks) {
|
|
13625
|
-
const csvTimelockStr =
|
|
13626
|
-
const defaultScript = new
|
|
13266
|
+
const csvTimelockStr = chunkC5Y2R63Z_cjs.timelockToSequence(csvTimelock).toString();
|
|
13267
|
+
const defaultScript = new chunkF7HJO5GT_cjs.DefaultVtxo.Script({
|
|
13627
13268
|
pubKey: baselinePubkey,
|
|
13628
13269
|
serverPubKey,
|
|
13629
13270
|
csvTimelock
|
|
@@ -13644,7 +13285,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13644
13285
|
});
|
|
13645
13286
|
}
|
|
13646
13287
|
if (delegatePubKey) {
|
|
13647
|
-
const delegateScript = new
|
|
13288
|
+
const delegateScript = new chunkF7HJO5GT_cjs.DelegateVtxo.Script({
|
|
13648
13289
|
pubKey: baselinePubkey,
|
|
13649
13290
|
serverPubKey,
|
|
13650
13291
|
delegatePubKey,
|
|
@@ -13668,9 +13309,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13668
13309
|
}
|
|
13669
13310
|
}
|
|
13670
13311
|
}
|
|
13671
|
-
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ??
|
|
13312
|
+
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkF7HJO5GT_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
13672
13313
|
for (const serverPubKey of baselineSigners) {
|
|
13673
|
-
const baselineBoarding = new
|
|
13314
|
+
const baselineBoarding = new chunkF7HJO5GT_cjs.DefaultVtxo.Script({
|
|
13674
13315
|
pubKey: baselinePubkey,
|
|
13675
13316
|
serverPubKey,
|
|
13676
13317
|
csvTimelock: boardingCsvTimelock
|
|
@@ -13683,7 +13324,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13683
13324
|
params: {
|
|
13684
13325
|
pubKey: base.hex.encode(baselineBoarding.options.pubKey),
|
|
13685
13326
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
13686
|
-
csvTimelock:
|
|
13327
|
+
csvTimelock: chunkC5Y2R63Z_cjs.timelockToSequence(boardingCsvTimelock).toString()
|
|
13687
13328
|
},
|
|
13688
13329
|
script: boardingScriptHex,
|
|
13689
13330
|
address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
|
|
@@ -13705,7 +13346,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13705
13346
|
}
|
|
13706
13347
|
};
|
|
13707
13348
|
var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
13708
|
-
constructor(identity, network, onchainProvider, arkProvider, indexerProvider, arkServerPublicKey, offchainTapscript, boardingTapscript, serverUnrollScript, forfeitOutputScript, forfeitPubkey, dustAmount, walletRepository, contractRepository,
|
|
13349
|
+
constructor(identity, network, onchainProvider, arkProvider, indexerProvider, arkServerPublicKey, offchainTapscript, boardingTapscript, serverUnrollScript, forfeitOutputScript, forfeitPubkey, dustAmount, walletRepository, contractRepository, delegateProvider, watcherConfig, settlementConfig, walletContractTimelocks, receiveRotator, descriptorProvider, lookAheadWindow, batchExpiryPolicy, checkpointExitDelayPolicy) {
|
|
13709
13350
|
super(
|
|
13710
13351
|
identity,
|
|
13711
13352
|
network,
|
|
@@ -13727,22 +13368,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13727
13368
|
this.batchExpiryPolicy = batchExpiryPolicy;
|
|
13728
13369
|
this.checkpointExitDelayPolicy = checkpointExitDelayPolicy;
|
|
13729
13370
|
this.identity = identity;
|
|
13730
|
-
this.
|
|
13731
|
-
enabled: renewalConfig?.enabled ?? false,
|
|
13732
|
-
...DEFAULT_RENEWAL_CONFIG,
|
|
13733
|
-
...renewalConfig
|
|
13734
|
-
};
|
|
13735
|
-
if (settlementConfig !== void 0) {
|
|
13736
|
-
this.settlementConfig = settlementConfig;
|
|
13737
|
-
} else if (renewalConfig && this.renewalConfig.enabled) {
|
|
13738
|
-
this.settlementConfig = {
|
|
13739
|
-
vtxoThreshold: renewalConfig.thresholdMs ? renewalConfig.thresholdMs / 1e3 : void 0
|
|
13740
|
-
};
|
|
13741
|
-
} else if (renewalConfig) {
|
|
13742
|
-
this.settlementConfig = false;
|
|
13743
|
-
} else {
|
|
13744
|
-
this.settlementConfig = { ...DEFAULT_SETTLEMENT_CONFIG };
|
|
13745
|
-
}
|
|
13371
|
+
this.settlementConfig = settlementConfig !== void 0 ? settlementConfig : { ...DEFAULT_SETTLEMENT_CONFIG };
|
|
13746
13372
|
this._delegateManager = delegateProvider ? new DelegateManagerImpl(delegateProvider, arkProvider, identity) : void 0;
|
|
13747
13373
|
this._serverUnrollScript = serverUnrollScript;
|
|
13748
13374
|
this._receiveRotator = receiveRotator;
|
|
@@ -13882,7 +13508,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13882
13508
|
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
13883
13509
|
deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
|
|
13884
13510
|
csvTimelocks: this.walletContractTimelocks,
|
|
13885
|
-
delegatePubKey: this.offchainTapscript instanceof
|
|
13511
|
+
delegatePubKey: this.offchainTapscript instanceof chunkF7HJO5GT_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
|
|
13886
13512
|
};
|
|
13887
13513
|
}
|
|
13888
13514
|
_signerRouter;
|
|
@@ -14127,7 +13753,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14127
13753
|
const [row] = await manager.getContracts({ script: base.hex.encode(display.pkScript) });
|
|
14128
13754
|
const persisted = row?.metadata?.signingDescriptor;
|
|
14129
13755
|
if (typeof persisted === "string") return persisted;
|
|
14130
|
-
return
|
|
13756
|
+
return chunkF7HJO5GT_cjs.identityDescriptor(this.identity);
|
|
14131
13757
|
}
|
|
14132
13758
|
/**
|
|
14133
13759
|
* Build, persist and shape one address of `type` owned by `descriptor` —
|
|
@@ -14143,7 +13769,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14143
13769
|
async mintAddress(manager, type, descriptor, tagSource, allocated) {
|
|
14144
13770
|
if (type === "boarding") {
|
|
14145
13771
|
const built2 = this.buildBoardingContract(
|
|
14146
|
-
|
|
13772
|
+
chunkF7HJO5GT_cjs.deriveDescriptorLeafPubKey(descriptor),
|
|
14147
13773
|
descriptor,
|
|
14148
13774
|
tagSource
|
|
14149
13775
|
);
|
|
@@ -14188,11 +13814,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14188
13814
|
* {@link buildReceiveContract}.
|
|
14189
13815
|
*/
|
|
14190
13816
|
buildBoardingContract(pubKey, descriptor, tagSource) {
|
|
14191
|
-
const tapscript = new
|
|
13817
|
+
const tapscript = new chunkF7HJO5GT_cjs.DefaultVtxo.Script({
|
|
14192
13818
|
...this._boardingTapscript.options,
|
|
14193
13819
|
pubKey
|
|
14194
13820
|
});
|
|
14195
|
-
const csvTimelock = tapscript.options.csvTimelock ??
|
|
13821
|
+
const csvTimelock = tapscript.options.csvTimelock ?? chunkF7HJO5GT_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
14196
13822
|
return {
|
|
14197
13823
|
tapscript,
|
|
14198
13824
|
params: {
|
|
@@ -14200,13 +13826,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14200
13826
|
params: {
|
|
14201
13827
|
pubKey: base.hex.encode(pubKey),
|
|
14202
13828
|
serverPubKey: base.hex.encode(tapscript.options.serverPubKey),
|
|
14203
|
-
csvTimelock:
|
|
13829
|
+
csvTimelock: chunkC5Y2R63Z_cjs.timelockToSequence(csvTimelock).toString()
|
|
14204
13830
|
},
|
|
14205
13831
|
script: base.hex.encode(tapscript.pkScript),
|
|
14206
13832
|
address: tapscript.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
14207
13833
|
state: "active",
|
|
14208
13834
|
metadata: {
|
|
14209
|
-
...tagSource && { source:
|
|
13835
|
+
...tagSource && { source: chunkF7HJO5GT_cjs.WALLET_RECEIVE_SOURCE },
|
|
14210
13836
|
signingDescriptor: descriptor
|
|
14211
13837
|
}
|
|
14212
13838
|
}
|
|
@@ -14235,7 +13861,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14235
13861
|
if (this._descriptorProvider instanceof HDDescriptorProvider) {
|
|
14236
13862
|
return (await this.getContractManager()).getNextSigningDescriptor();
|
|
14237
13863
|
}
|
|
14238
|
-
return
|
|
13864
|
+
return chunkF7HJO5GT_cjs.identityDescriptor(this.identity);
|
|
14239
13865
|
}
|
|
14240
13866
|
/**
|
|
14241
13867
|
* @see HDAllocationCapable.advanceSigningDescriptorWatermark
|
|
@@ -14331,7 +13957,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14331
13957
|
* the stable public API.
|
|
14332
13958
|
*/
|
|
14333
13959
|
async rotateServerSigner(newServerPubKey, checkpointTapscript) {
|
|
14334
|
-
const xonly =
|
|
13960
|
+
const xonly = chunkF7HJO5GT_cjs.toXOnly(newServerPubKey, "ark signer key");
|
|
14335
13961
|
const newServerUnrollScript = assertValidServerUnrollScript(
|
|
14336
13962
|
checkpointTapscript,
|
|
14337
13963
|
resolveCheckpointExitDelayPolicy(this.network, this.checkpointExitDelayPolicy)
|
|
@@ -14360,21 +13986,21 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14360
13986
|
const [currentBoardingRow] = await manager.getContracts({
|
|
14361
13987
|
script: currentBoardingScript
|
|
14362
13988
|
});
|
|
14363
|
-
const newOffchain = this.offchainTapscript instanceof
|
|
13989
|
+
const newOffchain = this.offchainTapscript instanceof chunkF7HJO5GT_cjs.DelegateVtxo.Script ? new chunkF7HJO5GT_cjs.DelegateVtxo.Script({
|
|
14364
13990
|
...this.offchainTapscript.options,
|
|
14365
13991
|
serverPubKey: xonly
|
|
14366
|
-
}) : new
|
|
13992
|
+
}) : new chunkF7HJO5GT_cjs.DefaultVtxo.Script({
|
|
14367
13993
|
...this.offchainTapscript.options,
|
|
14368
13994
|
serverPubKey: xonly
|
|
14369
13995
|
});
|
|
14370
|
-
const newBoarding = new
|
|
13996
|
+
const newBoarding = new chunkF7HJO5GT_cjs.DefaultVtxo.Script({
|
|
14371
13997
|
...this._boardingTapscript.options,
|
|
14372
13998
|
serverPubKey: xonly
|
|
14373
13999
|
});
|
|
14374
|
-
const offchainCsv =
|
|
14000
|
+
const offchainCsv = chunkC5Y2R63Z_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
|
|
14375
14001
|
const newOffchainScript = base.hex.encode(newOffchain.pkScript);
|
|
14376
14002
|
const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
|
|
14377
|
-
if (newOffchain instanceof
|
|
14003
|
+
if (newOffchain instanceof chunkF7HJO5GT_cjs.DelegateVtxo.Script) {
|
|
14378
14004
|
await manager.createContract({
|
|
14379
14005
|
type: "delegate",
|
|
14380
14006
|
params: {
|
|
@@ -14402,13 +14028,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14402
14028
|
metadata: currentOffchainRow?.metadata
|
|
14403
14029
|
});
|
|
14404
14030
|
}
|
|
14405
|
-
const boardingCsv = newBoarding.options.csvTimelock ??
|
|
14031
|
+
const boardingCsv = newBoarding.options.csvTimelock ?? chunkF7HJO5GT_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
14406
14032
|
await manager.createContract({
|
|
14407
14033
|
type: "boarding",
|
|
14408
14034
|
params: {
|
|
14409
14035
|
pubKey: base.hex.encode(newBoarding.options.pubKey),
|
|
14410
14036
|
serverPubKey: base.hex.encode(xonly),
|
|
14411
|
-
csvTimelock:
|
|
14037
|
+
csvTimelock: chunkC5Y2R63Z_cjs.timelockToSequence(boardingCsv).toString()
|
|
14412
14038
|
},
|
|
14413
14039
|
script: base.hex.encode(newBoarding.pkScript),
|
|
14414
14040
|
address: newBoarding.address(this.network.hrp, xonly).encode(),
|
|
@@ -14427,7 +14053,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14427
14053
|
}
|
|
14428
14054
|
/**
|
|
14429
14055
|
* Async mutex that serializes all operations submitting VTXOs to the Arkade
|
|
14430
|
-
* server (`settle`, `send
|
|
14056
|
+
* server (`settle`, `send`). This prevents VtxoManager's
|
|
14431
14057
|
* background renewal from racing with user-initiated transactions for the
|
|
14432
14058
|
* same VTXO inputs.
|
|
14433
14059
|
*/
|
|
@@ -14441,14 +14067,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14441
14067
|
_restoreInFlight;
|
|
14442
14068
|
_addPendingSpends(inputs) {
|
|
14443
14069
|
for (const input of inputs) {
|
|
14444
|
-
if (
|
|
14070
|
+
if (chunkC5Y2R63Z_cjs.isVirtualCoin(input)) {
|
|
14445
14071
|
this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
|
|
14446
14072
|
}
|
|
14447
14073
|
}
|
|
14448
14074
|
}
|
|
14449
14075
|
_removePendingSpends(inputs) {
|
|
14450
14076
|
for (const input of inputs) {
|
|
14451
|
-
if (
|
|
14077
|
+
if (chunkC5Y2R63Z_cjs.isVirtualCoin(input)) {
|
|
14452
14078
|
this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
|
|
14453
14079
|
}
|
|
14454
14080
|
}
|
|
@@ -14506,13 +14132,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14506
14132
|
const manager = await this.getContractManager();
|
|
14507
14133
|
const provider = this._descriptorProvider;
|
|
14508
14134
|
const hd = provider instanceof HDDescriptorProvider;
|
|
14509
|
-
const staticDescriptor = hd ? void 0 : await
|
|
14135
|
+
const staticDescriptor = hd ? void 0 : await chunkF7HJO5GT_cjs.identityDescriptor(this.identity);
|
|
14510
14136
|
const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
|
|
14511
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
14137
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkF7HJO5GT_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
14512
14138
|
const arkInfo = await this.arkProvider.getInfo();
|
|
14513
|
-
const currentSignerPubKey =
|
|
14139
|
+
const currentSignerPubKey = chunkF7HJO5GT_cjs.toXOnly(base.hex.decode(arkInfo.signerPubkey), "ark signer key");
|
|
14514
14140
|
const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
|
|
14515
|
-
(s) =>
|
|
14141
|
+
(s) => chunkF7HJO5GT_cjs.toXOnly(base.hex.decode(s.pubkey), "deprecated signer key")
|
|
14516
14142
|
);
|
|
14517
14143
|
const deps = {
|
|
14518
14144
|
indexerProvider: this.indexerProvider,
|
|
@@ -14527,7 +14153,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14527
14153
|
csvTimelocks: this.walletContractTimelocks,
|
|
14528
14154
|
// Boarding-exit CSV so the boarding handler can build its
|
|
14529
14155
|
// candidate script (distinct from the unilateral-exit matrix).
|
|
14530
|
-
boardingTimelock: this.boardingTapscript.options.csvTimelock ??
|
|
14156
|
+
boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkF7HJO5GT_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
|
|
14531
14157
|
delegatePubKey
|
|
14532
14158
|
};
|
|
14533
14159
|
const result = await manager.scanContracts({
|
|
@@ -14557,8 +14183,6 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14557
14183
|
);
|
|
14558
14184
|
}
|
|
14559
14185
|
}
|
|
14560
|
-
/** @deprecated Use settlementConfig instead */
|
|
14561
|
-
renewalConfig;
|
|
14562
14186
|
settlementConfig;
|
|
14563
14187
|
/**
|
|
14564
14188
|
* Broadcast access bound to this wallet's server, so a plugin needs only
|
|
@@ -14587,7 +14211,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14587
14211
|
return this._vtxoManagerInitializing;
|
|
14588
14212
|
}
|
|
14589
14213
|
this._vtxoManagerInitializing = Promise.resolve(
|
|
14590
|
-
new VtxoManager(this, this.
|
|
14214
|
+
new VtxoManager(this, this.settlementConfig)
|
|
14591
14215
|
);
|
|
14592
14216
|
try {
|
|
14593
14217
|
const manager = await this._vtxoManagerInitializing;
|
|
@@ -14656,7 +14280,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14656
14280
|
throw new Error("Invalid configured public key");
|
|
14657
14281
|
}
|
|
14658
14282
|
const setup = await ReadonlyWallet.setupWalletConfig(config, pubkey);
|
|
14659
|
-
const forfeitPubkey =
|
|
14283
|
+
const forfeitPubkey = chunkF7HJO5GT_cjs.toXOnly(base.hex.decode(setup.info.forfeitPubkey), "forfeit key");
|
|
14660
14284
|
const forfeitAddress = btcSigner.Address(setup.network).decode(setup.info.forfeitAddress);
|
|
14661
14285
|
const forfeitOutputScript = btcSigner.OutScript.encode(forfeitAddress);
|
|
14662
14286
|
const checkpointExitDelayOverrides = {
|
|
@@ -14683,8 +14307,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14683
14307
|
setup.dustAmount,
|
|
14684
14308
|
setup.walletRepository,
|
|
14685
14309
|
setup.contractRepository,
|
|
14686
|
-
config.
|
|
14687
|
-
config.delegateProvider || config.delegatorProvider,
|
|
14310
|
+
config.delegateProvider,
|
|
14688
14311
|
config.watcherConfig,
|
|
14689
14312
|
config.settlementConfig,
|
|
14690
14313
|
setup.walletContractTimelocks,
|
|
@@ -14773,74 +14396,6 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14773
14396
|
async getDelegateManager() {
|
|
14774
14397
|
return this._delegateManager;
|
|
14775
14398
|
}
|
|
14776
|
-
/** @deprecated alias for @see Wallet.getDelegateManager */
|
|
14777
|
-
async getDelegatorManager() {
|
|
14778
|
-
return this.getDelegateManager();
|
|
14779
|
-
}
|
|
14780
|
-
/**
|
|
14781
|
-
* Send bitcoin to an Arkade address.
|
|
14782
|
-
*
|
|
14783
|
-
* @deprecated Use `send`.
|
|
14784
|
-
* @param params - Send parameters
|
|
14785
|
-
*/
|
|
14786
|
-
async sendBitcoin(params) {
|
|
14787
|
-
if (params.amount <= 0) {
|
|
14788
|
-
throw new Error("Amount must be positive");
|
|
14789
|
-
}
|
|
14790
|
-
if (!isValidArkAddress(params.address)) {
|
|
14791
|
-
throw new Error("Invalid Arkade address " + params.address);
|
|
14792
|
-
}
|
|
14793
|
-
if (params.selectedVtxos && params.selectedVtxos.length > 0) {
|
|
14794
|
-
void this.logUngatedInputs("sendBitcoin({ selectedVtxos })", params.selectedVtxos);
|
|
14795
|
-
return this._withTxLock(async () => {
|
|
14796
|
-
const offchainTapscript = this.offchainTapscript;
|
|
14797
|
-
const serverPubKey = this.arkServerPublicKey;
|
|
14798
|
-
const serverUnrollScript = this.serverUnrollScript;
|
|
14799
|
-
const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
|
|
14800
|
-
const selectedVtxoSum = params.selectedVtxos.map((v) => v.value).reduce((a, b) => a + b, 0);
|
|
14801
|
-
if (selectedVtxoSum < params.amount) {
|
|
14802
|
-
throw new Error("Selected VTXOs do not cover specified amount");
|
|
14803
|
-
}
|
|
14804
|
-
const changeAmount = selectedVtxoSum - params.amount;
|
|
14805
|
-
const selected = {
|
|
14806
|
-
inputs: params.selectedVtxos,
|
|
14807
|
-
changeAmount: BigInt(changeAmount)
|
|
14808
|
-
};
|
|
14809
|
-
const outputAddress = chunkJZWLXNHV_cjs.ArkAddress.decode(params.address);
|
|
14810
|
-
assertRecipientArkadeAddress(
|
|
14811
|
-
params.address,
|
|
14812
|
-
outputAddress,
|
|
14813
|
-
this.recipientAddressContext(serverPubKey)
|
|
14814
|
-
);
|
|
14815
|
-
const outputScript = BigInt(params.amount) < this.dustAmount ? outputAddress.subdustPkScript : outputAddress.pkScript;
|
|
14816
|
-
const outputs = [
|
|
14817
|
-
{
|
|
14818
|
-
script: outputScript,
|
|
14819
|
-
amount: BigInt(params.amount)
|
|
14820
|
-
}
|
|
14821
|
-
];
|
|
14822
|
-
if (selected.changeAmount > 0n) {
|
|
14823
|
-
const changeOutputScript = selected.changeAmount < this.dustAmount ? arkAddress.subdustPkScript : arkAddress.pkScript;
|
|
14824
|
-
outputs.push({
|
|
14825
|
-
script: changeOutputScript,
|
|
14826
|
-
amount: BigInt(selected.changeAmount)
|
|
14827
|
-
});
|
|
14828
|
-
}
|
|
14829
|
-
return this._submitOffchainSpend(selected.inputs, outputs, {
|
|
14830
|
-
sentAmount: params.amount,
|
|
14831
|
-
changeAmount: selected.changeAmount,
|
|
14832
|
-
changeVout: selected.changeAmount > 0n ? outputs.length - 1 : 0,
|
|
14833
|
-
offchainTapscript,
|
|
14834
|
-
serverPubKey,
|
|
14835
|
-
serverUnrollScript
|
|
14836
|
-
});
|
|
14837
|
-
});
|
|
14838
|
-
}
|
|
14839
|
-
return this.send({
|
|
14840
|
-
address: params.address,
|
|
14841
|
-
amount: params.amount
|
|
14842
|
-
});
|
|
14843
|
-
}
|
|
14844
14399
|
/**
|
|
14845
14400
|
* Settle boarding inputs and/or virtual outputs into a finalized mainnet transaction.
|
|
14846
14401
|
*
|
|
@@ -14872,13 +14427,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14872
14427
|
void this.logUngatedInputs("settle({ inputs })", params.inputs);
|
|
14873
14428
|
}
|
|
14874
14429
|
const offchainAddress = await this.getAddress();
|
|
14875
|
-
const offchainPkScript =
|
|
14430
|
+
const offchainPkScript = chunkC5Y2R63Z_cjs.ArkAddress.decode(offchainAddress).pkScript;
|
|
14876
14431
|
const offchainOutputScript = base.hex.encode(offchainPkScript);
|
|
14877
14432
|
if (!params) {
|
|
14878
14433
|
const { fees, vtxoMaxAmount } = await this.arkProvider.getInfo();
|
|
14879
14434
|
const estimator = new Estimator(fees.intentFee);
|
|
14880
14435
|
let amount = 0;
|
|
14881
|
-
const exitScript =
|
|
14436
|
+
const exitScript = chunkC5Y2R63Z_cjs.CSVMultisigTapscript.decode(
|
|
14882
14437
|
base.hex.decode(this.boardingTapscript.exitScript)
|
|
14883
14438
|
);
|
|
14884
14439
|
const boardingTimelock = exitScript.params.timelock;
|
|
@@ -14907,7 +14462,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14907
14462
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
14908
14463
|
break;
|
|
14909
14464
|
}
|
|
14910
|
-
const inputFee = estimator.evalOffchainInput(
|
|
14465
|
+
const inputFee = estimator.evalOffchainInput(chunkC5Y2R63Z_cjs.toOffchainInputFeeParams(vtxo));
|
|
14911
14466
|
if (inputFee.satoshis >= vtxo.value) {
|
|
14912
14467
|
continue;
|
|
14913
14468
|
}
|
|
@@ -14954,7 +14509,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14954
14509
|
let script;
|
|
14955
14510
|
let arkAddress;
|
|
14956
14511
|
try {
|
|
14957
|
-
arkAddress =
|
|
14512
|
+
arkAddress = chunkC5Y2R63Z_cjs.ArkAddress.decode(output.address);
|
|
14958
14513
|
} catch {
|
|
14959
14514
|
arkAddress = void 0;
|
|
14960
14515
|
}
|
|
@@ -15044,7 +14599,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15044
14599
|
const abortController = new AbortController();
|
|
15045
14600
|
let stream;
|
|
15046
14601
|
let committedTxid;
|
|
15047
|
-
const settleInputVtxos = params.inputs.filter(
|
|
14602
|
+
const settleInputVtxos = params.inputs.filter(chunkC5Y2R63Z_cjs.isVirtualCoin);
|
|
15048
14603
|
const contractManager = await this.getContractManager();
|
|
15049
14604
|
await contractManager.assertAnnotatable(settleInputVtxos);
|
|
15050
14605
|
await contractManager.assertSpendableNow?.(
|
|
@@ -15156,7 +14711,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15156
14711
|
async maybeRotateBoardingAfterBoard(inputs) {
|
|
15157
14712
|
if (!this._descriptorProvider) return;
|
|
15158
14713
|
const consumedBoarding = inputs.some(
|
|
15159
|
-
(input) => typeof input !== "string" && !
|
|
14714
|
+
(input) => typeof input !== "string" && !chunkC5Y2R63Z_cjs.isVirtualCoin(input)
|
|
15160
14715
|
);
|
|
15161
14716
|
if (!consumedBoarding) return;
|
|
15162
14717
|
try {
|
|
@@ -15180,7 +14735,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15180
14735
|
let connectorIndex = 0;
|
|
15181
14736
|
const connectorsLeaves = connectorsGraph?.leaves() || [];
|
|
15182
14737
|
for (const input of inputs) {
|
|
15183
|
-
if (!
|
|
14738
|
+
if (!chunkC5Y2R63Z_cjs.isVirtualCoin(input)) {
|
|
15184
14739
|
for (let i = 0; i < settlementPsbt.inputsLength; i++) {
|
|
15185
14740
|
const settlementInput = settlementPsbt.getInput(i);
|
|
15186
14741
|
if (!settlementInput.txid || settlementInput.index === void 0) {
|
|
@@ -15211,7 +14766,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15211
14766
|
}
|
|
15212
14767
|
continue;
|
|
15213
14768
|
}
|
|
15214
|
-
if (
|
|
14769
|
+
if (chunkC5Y2R63Z_cjs.canRecoverOnchain(input, { timestamp: /* @__PURE__ */ new Date() }) || isSubdust({ value: input.value }, this.dustAmount)) {
|
|
15215
14770
|
continue;
|
|
15216
14771
|
}
|
|
15217
14772
|
if (connectorsLeaves.length === 0) {
|
|
@@ -15239,7 +14794,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15239
14794
|
index: input.vout,
|
|
15240
14795
|
witnessUtxo: {
|
|
15241
14796
|
amount: BigInt(input.value),
|
|
15242
|
-
script:
|
|
14797
|
+
script: chunkC5Y2R63Z_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
15243
14798
|
},
|
|
15244
14799
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
15245
14800
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -15258,7 +14813,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15258
14813
|
forfeitTx = await this._signerRouter.sign(forfeitTx, [
|
|
15259
14814
|
{
|
|
15260
14815
|
index: 0,
|
|
15261
|
-
lookupScript:
|
|
14816
|
+
lookupScript: chunkC5Y2R63Z_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
15262
14817
|
}
|
|
15263
14818
|
]);
|
|
15264
14819
|
signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
|
|
@@ -15316,7 +14871,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15316
14871
|
resolveBatchExpiryPolicy(this.network, this.batchExpiryPolicy)
|
|
15317
14872
|
);
|
|
15318
14873
|
await this.arkProvider.confirmRegistration(intentId);
|
|
15319
|
-
const sweepTapscript =
|
|
14874
|
+
const sweepTapscript = chunkC5Y2R63Z_cjs.CSVMultisigTapscript.encode({
|
|
15320
14875
|
timelock,
|
|
15321
14876
|
pubkeys: [this.forfeitPubkey]
|
|
15322
14877
|
}).script;
|
|
@@ -15331,10 +14886,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15331
14886
|
throw new Error("Sweep tap tree root not set");
|
|
15332
14887
|
}
|
|
15333
14888
|
const xOnlyPublicKeys = event.cosignersPublicKeys.map(
|
|
15334
|
-
(k) => base.hex.encode(
|
|
14889
|
+
(k) => base.hex.encode(chunkF7HJO5GT_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
|
|
15335
14890
|
);
|
|
15336
14891
|
const signerPublicKey = await session.getPublicKey();
|
|
15337
|
-
const xonlySignerPublicKey =
|
|
14892
|
+
const xonlySignerPublicKey = chunkF7HJO5GT_cjs.toXOnly(signerPublicKey, "signer key");
|
|
15338
14893
|
if (!xOnlyPublicKeys.includes(base.hex.encode(xonlySignerPublicKey))) {
|
|
15339
14894
|
return { skip: true };
|
|
15340
14895
|
}
|
|
@@ -15424,9 +14979,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15424
14979
|
...existing ?? {},
|
|
15425
14980
|
intentTxId,
|
|
15426
14981
|
registerProof: intent.proof,
|
|
15427
|
-
registerProofMessage:
|
|
14982
|
+
registerProofMessage: chunkC5Y2R63Z_cjs.Intent.encodeMessage(intent.message),
|
|
15428
14983
|
deleteProof: deleteIntent.proof,
|
|
15429
|
-
deleteProofMessage:
|
|
14984
|
+
deleteProofMessage: chunkC5Y2R63Z_cjs.Intent.encodeMessage(deleteIntent.message),
|
|
15430
14985
|
intentVtxos: inputs.map((i) => ({
|
|
15431
14986
|
txid: i.txid,
|
|
15432
14987
|
vout: i.vout
|
|
@@ -15458,7 +15013,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15458
15013
|
try {
|
|
15459
15014
|
return await this.arkProvider.registerIntent(intent);
|
|
15460
15015
|
} catch (error) {
|
|
15461
|
-
if (error instanceof
|
|
15016
|
+
if (error instanceof chunkC5Y2R63Z_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
|
|
15462
15017
|
const deleteIntent = await this.makeDeleteIntentSignature(inputs);
|
|
15463
15018
|
await this.arkProvider.deleteIntent(deleteIntent);
|
|
15464
15019
|
return this.arkProvider.registerIntent(intent);
|
|
@@ -15474,7 +15029,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15474
15029
|
expire_at: 0,
|
|
15475
15030
|
cosigners_public_keys: cosignerPubKeys
|
|
15476
15031
|
};
|
|
15477
|
-
const proof =
|
|
15032
|
+
const proof = chunkC5Y2R63Z_cjs.Intent.create(message, coins, outputs);
|
|
15478
15033
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
15479
15034
|
return {
|
|
15480
15035
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -15486,7 +15041,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15486
15041
|
type: "delete",
|
|
15487
15042
|
expire_at: 0
|
|
15488
15043
|
};
|
|
15489
|
-
const proof =
|
|
15044
|
+
const proof = chunkC5Y2R63Z_cjs.Intent.create(message, coins, []);
|
|
15490
15045
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
15491
15046
|
return {
|
|
15492
15047
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -15498,7 +15053,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15498
15053
|
type: "get-pending-tx",
|
|
15499
15054
|
expire_at: 0
|
|
15500
15055
|
};
|
|
15501
|
-
const proof =
|
|
15056
|
+
const proof = chunkC5Y2R63Z_cjs.Intent.create(message, coins, []);
|
|
15502
15057
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
15503
15058
|
return {
|
|
15504
15059
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -15519,7 +15074,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15519
15074
|
if (!vtxos || vtxos.length === 0) {
|
|
15520
15075
|
const scriptMap = await this.getScriptMap();
|
|
15521
15076
|
const allExtended = [];
|
|
15522
|
-
const fetchedVtxos = await
|
|
15077
|
+
const fetchedVtxos = await chunkC5Y2R63Z_cjs.getAllNormalizedVtxos(this.indexerProvider, [
|
|
15523
15078
|
...scriptMap.keys()
|
|
15524
15079
|
]);
|
|
15525
15080
|
for (const vtxo of fetchedVtxos) {
|
|
@@ -15563,7 +15118,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15563
15118
|
try {
|
|
15564
15119
|
const checkpointTxs = pendingTx.signedCheckpointTxs.map((c) => {
|
|
15565
15120
|
const tx = btcSigner.Transaction.fromPSBT(base.base64.decode(c));
|
|
15566
|
-
|
|
15121
|
+
chunkC5Y2R63Z_cjs.assertAllowedSighashTypes(tx);
|
|
15567
15122
|
return tx;
|
|
15568
15123
|
});
|
|
15569
15124
|
assertCheckpointsMatchInputs(
|
|
@@ -15635,11 +15190,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15635
15190
|
* against the current key alone would leave it pending forever.
|
|
15636
15191
|
*/
|
|
15637
15192
|
checkpointUnrollCandidates(info) {
|
|
15638
|
-
const current =
|
|
15193
|
+
const current = chunkC5Y2R63Z_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
15639
15194
|
const candidates = [this._serverUnrollScript, current];
|
|
15640
15195
|
for (const deprecated of signerSetFromInfo(info).deprecated.keys()) {
|
|
15641
15196
|
candidates.push(
|
|
15642
|
-
|
|
15197
|
+
chunkC5Y2R63Z_cjs.CSVMultisigTapscript.encode({
|
|
15643
15198
|
...current.params,
|
|
15644
15199
|
pubkeys: [base.hex.decode(deprecated)]
|
|
15645
15200
|
})
|
|
@@ -15730,7 +15285,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15730
15285
|
if (vtxos.length === 0) {
|
|
15731
15286
|
throw new Error("No VTXOs found for this arkadeCash");
|
|
15732
15287
|
}
|
|
15733
|
-
const myPkScript =
|
|
15288
|
+
const myPkScript = chunkC5Y2R63Z_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
|
|
15734
15289
|
let { spendable, unclaimed } = this.classifyCashVtxos(vtxos);
|
|
15735
15290
|
let swept = 0;
|
|
15736
15291
|
const drainable = vtxos.filter(
|
|
@@ -15806,7 +15361,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15806
15361
|
const spendable = [];
|
|
15807
15362
|
const unclaimed = [];
|
|
15808
15363
|
for (const vtxo of vtxos) {
|
|
15809
|
-
if (
|
|
15364
|
+
if (chunkC5Y2R63Z_cjs.hasTerminalSpend(vtxo)) {
|
|
15810
15365
|
unclaimed.push(cashReport(vtxo, "already-spent"));
|
|
15811
15366
|
} else if (vtxo.isUnrolled) {
|
|
15812
15367
|
unclaimed.push(cashReport(vtxo, "exited"));
|
|
@@ -15828,7 +15383,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15828
15383
|
const all = [];
|
|
15829
15384
|
const seen = /* @__PURE__ */ new Set();
|
|
15830
15385
|
for (let pageIndex = 0; ; pageIndex++) {
|
|
15831
|
-
const { vtxos, page } = await
|
|
15386
|
+
const { vtxos, page } = await chunkC5Y2R63Z_cjs.getNormalizedVtxos(this.indexerProvider, {
|
|
15832
15387
|
scripts,
|
|
15833
15388
|
pageIndex,
|
|
15834
15389
|
pageSize
|
|
@@ -15875,7 +15430,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15875
15430
|
for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
|
|
15876
15431
|
const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
|
|
15877
15432
|
const message = { type: "get-pending-tx", expire_at: 0 };
|
|
15878
|
-
const proof =
|
|
15433
|
+
const proof = chunkC5Y2R63Z_cjs.Intent.create(message, batch, []);
|
|
15879
15434
|
const signedProof = await identity.sign(
|
|
15880
15435
|
proof,
|
|
15881
15436
|
Array.from({ length: batch.length + 1 }, (_, j) => j)
|
|
@@ -15897,7 +15452,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15897
15452
|
try {
|
|
15898
15453
|
const checkpointTxs = pendingTx.signedCheckpointTxs.map((checkpoint) => {
|
|
15899
15454
|
const tx = btcSigner.Transaction.fromPSBT(base.base64.decode(checkpoint));
|
|
15900
|
-
|
|
15455
|
+
chunkC5Y2R63Z_cjs.assertAllowedSighashTypes(tx);
|
|
15901
15456
|
return tx;
|
|
15902
15457
|
});
|
|
15903
15458
|
assertCheckpointsMatchInputs(
|
|
@@ -16096,7 +15651,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16096
15651
|
script: recipient.script,
|
|
16097
15652
|
amount: BigInt(recipient.amount),
|
|
16098
15653
|
// Already checked against the recipient address in `validateRecipients`.
|
|
16099
|
-
...recipient.tapTree ? { tapTree:
|
|
15654
|
+
...recipient.tapTree ? { tapTree: chunkC5Y2R63Z_cjs.TapTreeCoder.decode(recipient.tapTree) } : {}
|
|
16100
15655
|
}));
|
|
16101
15656
|
const totalBtcOutput = outputs.reduce((sum, o) => sum + Number(o.amount), 0);
|
|
16102
15657
|
let changeAmount = totalBtcSelected - totalBtcOutput;
|
|
@@ -16184,7 +15739,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16184
15739
|
}
|
|
16185
15740
|
/**
|
|
16186
15741
|
* Shared tail of every Ark-transaction spend path (`send`, selected-VTXO
|
|
16187
|
-
* `
|
|
15742
|
+
* `send`, and {@link sendSelectedVtxosToSelf}): hide the inputs from
|
|
16188
15743
|
* concurrent `getVtxos()`, build+submit the offchain tx, persist the spent
|
|
16189
15744
|
* inputs and any wallet-owned (change / self) output, then release the
|
|
16190
15745
|
* pending-spend hold. Callers own coin selection, output construction, and
|
|
@@ -16240,10 +15795,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16240
15795
|
const serverPubKey = this.arkServerPublicKey;
|
|
16241
15796
|
const serverUnrollScript = this.serverUnrollScript;
|
|
16242
15797
|
const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
|
|
16243
|
-
const normalizedInputs = inputs.map(
|
|
16244
|
-
const at = now ?? await
|
|
15798
|
+
const normalizedInputs = inputs.map(chunkC5Y2R63Z_cjs.normalizeVtxo);
|
|
15799
|
+
const at = now ?? await chunkC5Y2R63Z_cjs.resolveTimeHeight(this.onchainProvider);
|
|
16245
15800
|
for (const input of normalizedInputs) {
|
|
16246
|
-
if (!
|
|
15801
|
+
if (!chunkC5Y2R63Z_cjs.canSpendOffchain(input, at)) {
|
|
16247
15802
|
throw new Error(
|
|
16248
15803
|
`sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
|
|
16249
15804
|
);
|
|
@@ -16313,7 +15868,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16313
15868
|
);
|
|
16314
15869
|
const arkTxJobs = inputs.map((input, index) => ({
|
|
16315
15870
|
index,
|
|
16316
|
-
lookupScript:
|
|
15871
|
+
lookupScript: chunkC5Y2R63Z_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
16317
15872
|
}));
|
|
16318
15873
|
const identity = this.identity;
|
|
16319
15874
|
const signer = {
|
|
@@ -16399,14 +15954,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16399
15954
|
const spentBy = checkpointIdByOutpoint.get(`${vtxo.txid}:${vtxo.vout}`);
|
|
16400
15955
|
spentVtxos.push({
|
|
16401
15956
|
...spentFacts,
|
|
16402
|
-
virtualStatus: chunkJZWLXNHV_cjs.toVirtualStatus(spentFacts),
|
|
16403
15957
|
...spentBy ? { spentBy } : {},
|
|
16404
15958
|
arkTxId: arkTxid
|
|
16405
15959
|
});
|
|
16406
15960
|
for (const id of vtxo.commitmentTxIds) {
|
|
16407
15961
|
commitmentTxIds.add(id);
|
|
16408
15962
|
}
|
|
16409
|
-
const vtxoExpiry =
|
|
15963
|
+
const vtxoExpiry = vtxo.expiresAt?.getTime();
|
|
16410
15964
|
if (vtxoExpiry) {
|
|
16411
15965
|
batchExpiry = Math.min(batchExpiry, vtxoExpiry);
|
|
16412
15966
|
}
|
|
@@ -16419,7 +15973,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16419
15973
|
isSwept: false,
|
|
16420
15974
|
isPreconfirmed: true,
|
|
16421
15975
|
commitmentTxIds: Array.from(commitmentTxIds),
|
|
16422
|
-
|
|
15976
|
+
expiresAt: new Date(batchExpiry)
|
|
16423
15977
|
};
|
|
16424
15978
|
changeVtxo = {
|
|
16425
15979
|
txid: arkTxid,
|
|
@@ -16431,7 +15985,6 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16431
15985
|
tapTree: offchainTapscript.encode(),
|
|
16432
15986
|
value: Number(changeAmount),
|
|
16433
15987
|
...changeFacts,
|
|
16434
|
-
virtualStatus: chunkJZWLXNHV_cjs.toVirtualStatus(changeFacts),
|
|
16435
15988
|
spentBy: "",
|
|
16436
15989
|
status: {
|
|
16437
15990
|
confirmed: false
|
|
@@ -16500,12 +16053,12 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16500
16053
|
const spentVtxos = [];
|
|
16501
16054
|
const inputArkTxIds = /* @__PURE__ */ new Set();
|
|
16502
16055
|
const boardingRemovalsByAddress = /* @__PURE__ */ new Map();
|
|
16503
|
-
const vtxoInputs = inputs.filter(
|
|
16056
|
+
const vtxoInputs = inputs.filter(chunkC5Y2R63Z_cjs.isVirtualCoin);
|
|
16504
16057
|
const cm = await this.getContractManager();
|
|
16505
16058
|
const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
|
|
16506
16059
|
const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
|
|
16507
16060
|
for (const input of inputs) {
|
|
16508
|
-
if (
|
|
16061
|
+
if (chunkC5Y2R63Z_cjs.isVirtualCoin(input)) {
|
|
16509
16062
|
const outpoint = `${input.txid}:${input.vout}`;
|
|
16510
16063
|
const vtxo = annotatedByKey.get(outpoint);
|
|
16511
16064
|
if (!vtxo) {
|
|
@@ -16517,13 +16070,12 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16517
16070
|
const settledFacts = { ...vtxo, isSpent: true };
|
|
16518
16071
|
spentVtxos.push({
|
|
16519
16072
|
...settledFacts,
|
|
16520
|
-
virtualStatus: chunkJZWLXNHV_cjs.toVirtualStatus(settledFacts),
|
|
16521
16073
|
settledBy: commitmentTxid
|
|
16522
16074
|
});
|
|
16523
16075
|
} else {
|
|
16524
16076
|
let sourceAddress;
|
|
16525
16077
|
try {
|
|
16526
|
-
sourceAddress =
|
|
16078
|
+
sourceAddress = chunkC5Y2R63Z_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
|
|
16527
16079
|
this.network
|
|
16528
16080
|
);
|
|
16529
16081
|
} catch {
|
|
@@ -16581,9 +16133,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16581
16133
|
}
|
|
16582
16134
|
};
|
|
16583
16135
|
function selectVirtualCoins(coins, targetAmount) {
|
|
16584
|
-
const sortedCoins = coins.map(
|
|
16585
|
-
const expiryA =
|
|
16586
|
-
const expiryB =
|
|
16136
|
+
const sortedCoins = coins.map(chunkC5Y2R63Z_cjs.normalizeVtxo).sort((a, b) => {
|
|
16137
|
+
const expiryA = a.expiresAt?.getTime() || Number.MAX_SAFE_INTEGER;
|
|
16138
|
+
const expiryB = b.expiresAt?.getTime() || Number.MAX_SAFE_INTEGER;
|
|
16587
16139
|
if (expiryA !== expiryB) {
|
|
16588
16140
|
return expiryA - expiryB;
|
|
16589
16141
|
}
|
|
@@ -16952,22 +16504,22 @@ var MessageBus = class {
|
|
|
16952
16504
|
this.initialized = true;
|
|
16953
16505
|
}
|
|
16954
16506
|
async buildServices(config) {
|
|
16955
|
-
const arkProvider = new
|
|
16507
|
+
const arkProvider = new chunkC5Y2R63Z_cjs.RestArkProvider(config.arkServer.url);
|
|
16956
16508
|
const storage = {
|
|
16957
16509
|
walletRepository: this.walletRepository,
|
|
16958
16510
|
contractRepository: this.contractRepository,
|
|
16959
16511
|
...this.intentRepository && { intentRepository: this.intentRepository }
|
|
16960
16512
|
};
|
|
16961
|
-
const delegateProvider = config.delegateUrl ? new RestDelegateProvider(config.delegateUrl) :
|
|
16513
|
+
const delegateProvider = config.delegateUrl ? new RestDelegateProvider(config.delegateUrl) : void 0;
|
|
16514
|
+
const indexerProvider = new chunkSYRQJS5N_cjs.RestIndexerProvider(config.arkServer.url);
|
|
16962
16515
|
const serialized = normalizeSerializedIdentity(config.wallet);
|
|
16963
16516
|
if (isSigningSerialized(serialized)) {
|
|
16964
16517
|
const identity2 = hydrateIdentity(serialized);
|
|
16965
16518
|
const wallet = await Wallet2.create({
|
|
16966
16519
|
identity: identity2,
|
|
16967
|
-
|
|
16520
|
+
arkProvider,
|
|
16968
16521
|
arkServerPublicKey: config.arkServer.publicKey,
|
|
16969
|
-
|
|
16970
|
-
esploraUrl: config.esploraUrl,
|
|
16522
|
+
indexerProvider,
|
|
16971
16523
|
storage,
|
|
16972
16524
|
delegateProvider,
|
|
16973
16525
|
settlementConfig: config.settlementConfig,
|
|
@@ -16982,10 +16534,9 @@ var MessageBus = class {
|
|
|
16982
16534
|
const identity = hydrateIdentity(serialized);
|
|
16983
16535
|
const readonlyWallet = await ReadonlyWallet.create({
|
|
16984
16536
|
identity,
|
|
16985
|
-
|
|
16537
|
+
arkProvider,
|
|
16986
16538
|
arkServerPublicKey: config.arkServer.publicKey,
|
|
16987
|
-
|
|
16988
|
-
esploraUrl: config.esploraUrl,
|
|
16539
|
+
indexerProvider,
|
|
16989
16540
|
storage,
|
|
16990
16541
|
delegateProvider,
|
|
16991
16542
|
watcherConfig: config.watcherConfig
|
|
@@ -17297,7 +16848,7 @@ var offboardNetworkNames = [
|
|
|
17297
16848
|
function offboardDestinationScript(destinationAddress) {
|
|
17298
16849
|
for (const networkName of offboardNetworkNames) {
|
|
17299
16850
|
try {
|
|
17300
|
-
const network =
|
|
16851
|
+
const network = chunkC5Y2R63Z_cjs.networks[networkName];
|
|
17301
16852
|
const addr = btcSigner.Address(network).decode(destinationAddress);
|
|
17302
16853
|
return btcSigner.OutScript.encode(addr);
|
|
17303
16854
|
} catch {
|
|
@@ -17361,7 +16912,7 @@ var Ramps = class {
|
|
|
17361
16912
|
}
|
|
17362
16913
|
amount = amount ?? totalAmount;
|
|
17363
16914
|
const offchainAddress = await this.wallet.getAddress();
|
|
17364
|
-
const offchainAddr =
|
|
16915
|
+
const offchainAddr = chunkC5Y2R63Z_cjs.ArkAddress.decode(offchainAddress);
|
|
17365
16916
|
const offchainScript = base.hex.encode(offchainAddr.pkScript);
|
|
17366
16917
|
const outputFee = estimator.evalOffchainOutput({
|
|
17367
16918
|
amount,
|
|
@@ -17421,7 +16972,7 @@ var Ramps = class {
|
|
|
17421
16972
|
const filteredVtxos = [];
|
|
17422
16973
|
let totalAmount = 0n;
|
|
17423
16974
|
for (const vtxo of vtxos) {
|
|
17424
|
-
const inputFee = estimator.evalOffchainInput(
|
|
16975
|
+
const inputFee = estimator.evalOffchainInput(chunkC5Y2R63Z_cjs.toOffchainInputFeeParams(vtxo));
|
|
17425
16976
|
if (inputFee.satoshis >= vtxo.value) {
|
|
17426
16977
|
continue;
|
|
17427
16978
|
}
|
|
@@ -17524,7 +17075,6 @@ var DelegateNotConfiguredError = class extends Error {
|
|
|
17524
17075
|
this.name = "DelegateNotConfiguredError";
|
|
17525
17076
|
}
|
|
17526
17077
|
};
|
|
17527
|
-
var DelegatorNotConfiguredError = DelegateNotConfiguredError;
|
|
17528
17078
|
var DEFAULT_MESSAGE_TAG = "WALLET_UPDATER";
|
|
17529
17079
|
var serializeMigrationVtxoRef = (ref) => ({
|
|
17530
17080
|
txid: ref.txid,
|
|
@@ -17771,13 +17321,6 @@ var WalletMessageHandler = class {
|
|
|
17771
17321
|
...response
|
|
17772
17322
|
});
|
|
17773
17323
|
}
|
|
17774
|
-
case "SEND_BITCOIN": {
|
|
17775
|
-
const response = await this.handleSendBitcoin(message);
|
|
17776
|
-
return this.tagged({
|
|
17777
|
-
id,
|
|
17778
|
-
...response
|
|
17779
|
-
});
|
|
17780
|
-
}
|
|
17781
17324
|
case "GET_ADDRESS": {
|
|
17782
17325
|
const address = await this.readonlyWallet.getAddress();
|
|
17783
17326
|
return this.tagged({
|
|
@@ -18097,8 +17640,9 @@ var WalletMessageHandler = class {
|
|
|
18097
17640
|
});
|
|
18098
17641
|
}
|
|
18099
17642
|
case "SEND": {
|
|
17643
|
+
const wallet = this.requireWallet();
|
|
18100
17644
|
const { recipients, selectedVtxos } = message.payload;
|
|
18101
|
-
const txid = await (selectedVtxos ?
|
|
17645
|
+
const txid = await (selectedVtxos ? wallet.send({ recipients, selectedVtxos }) : wallet.send(...recipients));
|
|
18102
17646
|
return this.tagged({
|
|
18103
17647
|
id,
|
|
18104
17648
|
type: "SEND_SUCCESS",
|
|
@@ -18116,7 +17660,7 @@ var WalletMessageHandler = class {
|
|
|
18116
17660
|
}
|
|
18117
17661
|
case "ISSUE": {
|
|
18118
17662
|
const { params } = message.payload;
|
|
18119
|
-
const result = await this.
|
|
17663
|
+
const result = await this.requireWallet().assetManager.issue(params);
|
|
18120
17664
|
return this.tagged({
|
|
18121
17665
|
id,
|
|
18122
17666
|
type: "ISSUE_SUCCESS",
|
|
@@ -18125,7 +17669,7 @@ var WalletMessageHandler = class {
|
|
|
18125
17669
|
}
|
|
18126
17670
|
case "REISSUE": {
|
|
18127
17671
|
const { params } = message.payload;
|
|
18128
|
-
const txid = await this.
|
|
17672
|
+
const txid = await this.requireWallet().assetManager.reissue(params);
|
|
18129
17673
|
return this.tagged({
|
|
18130
17674
|
id,
|
|
18131
17675
|
type: "REISSUE_SUCCESS",
|
|
@@ -18134,7 +17678,7 @@ var WalletMessageHandler = class {
|
|
|
18134
17678
|
}
|
|
18135
17679
|
case "BURN": {
|
|
18136
17680
|
const { params } = message.payload;
|
|
18137
|
-
const txid = await this.
|
|
17681
|
+
const txid = await this.requireWallet().assetManager.burn(params);
|
|
18138
17682
|
return this.tagged({
|
|
18139
17683
|
id,
|
|
18140
17684
|
type: "BURN_SUCCESS",
|
|
@@ -18300,7 +17844,7 @@ var WalletMessageHandler = class {
|
|
|
18300
17844
|
// Wallet methods
|
|
18301
17845
|
async handleInitWallet({ payload }) {
|
|
18302
17846
|
const { arkServerUrl } = payload;
|
|
18303
|
-
this.indexerProvider = new
|
|
17847
|
+
this.indexerProvider = new chunkSYRQJS5N_cjs.RestIndexerProvider(arkServerUrl);
|
|
18304
17848
|
await this.onWalletInitialized();
|
|
18305
17849
|
}
|
|
18306
17850
|
/**
|
|
@@ -18517,17 +18061,6 @@ var WalletMessageHandler = class {
|
|
|
18517
18061
|
}
|
|
18518
18062
|
return { type: "SETTLE_SUCCESS", payload: { txid } };
|
|
18519
18063
|
}
|
|
18520
|
-
async handleSendBitcoin(message) {
|
|
18521
|
-
const wallet = this.requireWallet();
|
|
18522
|
-
const txid = await wallet.sendBitcoin(message.payload);
|
|
18523
|
-
if (!txid) {
|
|
18524
|
-
throw new Error("Send bitcoin failed");
|
|
18525
|
-
}
|
|
18526
|
-
return {
|
|
18527
|
-
type: "SEND_BITCOIN_SUCCESS",
|
|
18528
|
-
payload: { txid }
|
|
18529
|
-
};
|
|
18530
|
-
}
|
|
18531
18064
|
async handleSignTransaction(message) {
|
|
18532
18065
|
const wallet = this.requireWallet();
|
|
18533
18066
|
const { tx, inputIndexes } = message.payload;
|
|
@@ -18589,7 +18122,7 @@ var WalletMessageHandler = class {
|
|
|
18589
18122
|
if (v.isUnrolled) {
|
|
18590
18123
|
return withUnrolled;
|
|
18591
18124
|
}
|
|
18592
|
-
if (
|
|
18125
|
+
if (chunkC5Y2R63Z_cjs.hasTerminalSpend(v)) {
|
|
18593
18126
|
return false;
|
|
18594
18127
|
}
|
|
18595
18128
|
if (includeRecoverable) {
|
|
@@ -18598,13 +18131,7 @@ var WalletMessageHandler = class {
|
|
|
18598
18131
|
if (dustAmount != null && isSubdust(v, dustAmount)) {
|
|
18599
18132
|
return false;
|
|
18600
18133
|
}
|
|
18601
|
-
|
|
18602
|
-
return false;
|
|
18603
|
-
}
|
|
18604
|
-
if (chunkJZWLXNHV_cjs.isExpired(v)) {
|
|
18605
|
-
return false;
|
|
18606
|
-
}
|
|
18607
|
-
return true;
|
|
18134
|
+
return chunkC5Y2R63Z_cjs.canSpendOffchain(v, { timestamp: /* @__PURE__ */ new Date() });
|
|
18608
18135
|
});
|
|
18609
18136
|
}
|
|
18610
18137
|
/** Tear down handler subscriptions, then delegate the full wipe to the wallet. */
|
|
@@ -18699,7 +18226,7 @@ var WalletMessageHandler = class {
|
|
|
18699
18226
|
if (!this.readonlyWallet) return null;
|
|
18700
18227
|
const { boardingTxs, commitmentsToIgnore } = await this.readonlyWallet.getBoardingTxs();
|
|
18701
18228
|
const indexerProvider = this.indexerProvider;
|
|
18702
|
-
const resolveTxCreatedAt = indexerProvider ? (txids) =>
|
|
18229
|
+
const resolveTxCreatedAt = indexerProvider ? (txids) => chunkC5Y2R63Z_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
|
|
18703
18230
|
return buildTransactionHistory(vtxos, boardingTxs, commitmentsToIgnore, resolveTxCreatedAt);
|
|
18704
18231
|
}
|
|
18705
18232
|
async ensureContractEventBroadcasting() {
|
|
@@ -18762,7 +18289,7 @@ var DEFAULT_MESSAGE_TIMEOUTS = {
|
|
|
18762
18289
|
// budget so the worker's snapshot fallback stays reachable before this
|
|
18763
18290
|
// page deadline fires — lowering it below the budget would time the page
|
|
18764
18291
|
// out while the worker is still seconds from answering from cache.
|
|
18765
|
-
GET_ARKADE_INFO:
|
|
18292
|
+
GET_ARKADE_INFO: chunkC5Y2R63Z_cjs.INFO_FETCH_TIMEOUT_MS + 8e3,
|
|
18766
18293
|
INDEXER_GET_VTXOS: 2e4,
|
|
18767
18294
|
INDEXER_GET_VIRTUAL_TXS: 2e4,
|
|
18768
18295
|
GET_VTXOS: 2e4,
|
|
@@ -18784,7 +18311,6 @@ var DEFAULT_MESSAGE_TIMEOUTS = {
|
|
|
18784
18311
|
// SETTLE / RECOVER_VTXOS / RENEW_VTXOS go through the streaming path and
|
|
18785
18312
|
// are treated as long-running on both sides of the bus: the values below
|
|
18786
18313
|
// are retained only for type completeness and are never enforced.
|
|
18787
|
-
SEND_BITCOIN: 5e4,
|
|
18788
18314
|
SEND: 5e4,
|
|
18789
18315
|
SETTLE: 5e4,
|
|
18790
18316
|
// Broadcast: the server round-trip a spend ends in, so it belongs
|
|
@@ -18950,13 +18476,8 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
18950
18476
|
// Denormalized from options so buildInitConfig() can rebuild the init
|
|
18951
18477
|
// envelope on demand for SDK-factory-created wallets. `create()` sets
|
|
18952
18478
|
// these immediately after construction.
|
|
18953
|
-
|
|
18954
|
-
arkServerPublicKey;
|
|
18479
|
+
arkServer;
|
|
18955
18480
|
delegateUrl;
|
|
18956
|
-
/** @deprecated alias for @see ServiceWorkerReadonlyWallet.delegateUrl */
|
|
18957
|
-
delegatorUrl;
|
|
18958
|
-
indexerUrl;
|
|
18959
|
-
esploraUrl;
|
|
18960
18481
|
watcherConfig;
|
|
18961
18482
|
settlementConfig;
|
|
18962
18483
|
reinitPromise = null;
|
|
@@ -18987,16 +18508,10 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
18987
18508
|
messageTag
|
|
18988
18509
|
);
|
|
18989
18510
|
const serializedWallet = await serializeReadonlyIdentity(options.identity);
|
|
18990
|
-
const
|
|
18511
|
+
const arkServer = options.arkServer ?? { url: "https://arkade.computer" };
|
|
18991
18512
|
const initWalletPayload = {
|
|
18992
|
-
|
|
18993
|
-
|
|
18994
|
-
arkServerPublicKey: options.arkServerPublicKey,
|
|
18995
|
-
delegateUrl: options.delegateUrl || options.delegatorUrl,
|
|
18996
|
-
// Keep the deprecated field populated so pre-#519 service workers
|
|
18997
|
-
// (which only read delegatorUrl) keep delegating until they activate
|
|
18998
|
-
// a newer version.
|
|
18999
|
-
delegatorUrl: options.delegateUrl || options.delegatorUrl
|
|
18513
|
+
arkServerUrl: arkServer.url,
|
|
18514
|
+
arkServerPublicKey: arkServer.publicKey
|
|
19000
18515
|
};
|
|
19001
18516
|
const messageTimeouts = options.messageTimeouts ? {
|
|
19002
18517
|
...DEFAULT_MESSAGE_TIMEOUTS,
|
|
@@ -19004,17 +18519,8 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
19004
18519
|
} : DEFAULT_MESSAGE_TIMEOUTS;
|
|
19005
18520
|
const busInitConfig = {
|
|
19006
18521
|
wallet: serializedWallet,
|
|
19007
|
-
arkServer
|
|
19008
|
-
|
|
19009
|
-
publicKey: options.arkServerPublicKey
|
|
19010
|
-
},
|
|
19011
|
-
delegateUrl: options.delegateUrl || options.delegatorUrl,
|
|
19012
|
-
// Keep the deprecated field populated so pre-#519 service workers
|
|
19013
|
-
// (which only read delegatorUrl) keep delegating until they activate
|
|
19014
|
-
// a newer version.
|
|
19015
|
-
delegatorUrl: options.delegateUrl || options.delegatorUrl,
|
|
19016
|
-
indexerUrl: options.indexerUrl,
|
|
19017
|
-
esploraUrl: options.esploraUrl,
|
|
18522
|
+
arkServer,
|
|
18523
|
+
delegateUrl: options.delegateUrl,
|
|
19018
18524
|
watcherConfig: options.watcherConfig,
|
|
19019
18525
|
messageTimeouts
|
|
19020
18526
|
};
|
|
@@ -19047,7 +18553,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
19047
18553
|
* ```typescript
|
|
19048
18554
|
* const wallet = await ServiceWorkerReadonlyWallet.setup({
|
|
19049
18555
|
* serviceWorkerPath: '/service-worker.js',
|
|
19050
|
-
*
|
|
18556
|
+
* arkServer: { url: 'https://arkade.computer' },
|
|
19051
18557
|
* identity: ReadonlySingleKey.fromPublicKey('your_public_key_hex')
|
|
19052
18558
|
* });
|
|
19053
18559
|
* ```
|
|
@@ -19216,23 +18722,14 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
19216
18722
|
*/
|
|
19217
18723
|
async buildInitConfig() {
|
|
19218
18724
|
if (this.initConfig) return this.initConfig;
|
|
19219
|
-
if (!this.
|
|
18725
|
+
if (!this.arkServer) {
|
|
19220
18726
|
throw new Error("Cannot re-initialize: wallet was not initialized via the SDK factory");
|
|
19221
18727
|
}
|
|
19222
18728
|
const wallet = await this.serializeIdentity();
|
|
19223
18729
|
this.initConfig = {
|
|
19224
18730
|
wallet,
|
|
19225
|
-
arkServer:
|
|
19226
|
-
|
|
19227
|
-
publicKey: this.arkServerPublicKey
|
|
19228
|
-
},
|
|
19229
|
-
delegateUrl: this.delegateUrl || this.delegatorUrl,
|
|
19230
|
-
// Keep the deprecated field populated so pre-#519 service workers
|
|
19231
|
-
// (which only read delegatorUrl) keep delegating until they activate
|
|
19232
|
-
// a newer version.
|
|
19233
|
-
delegatorUrl: this.delegateUrl || this.delegatorUrl,
|
|
19234
|
-
indexerUrl: this.indexerUrl,
|
|
19235
|
-
esploraUrl: this.esploraUrl,
|
|
18731
|
+
arkServer: this.arkServer,
|
|
18732
|
+
delegateUrl: this.delegateUrl,
|
|
19236
18733
|
watcherConfig: this.watcherConfig,
|
|
19237
18734
|
settlementConfig: this.settlementConfig
|
|
19238
18735
|
};
|
|
@@ -19241,14 +18738,12 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
19241
18738
|
/** Minimal INIT_WALLET payload used on reinitialize when the cache is gone. */
|
|
19242
18739
|
buildInitWalletPayload() {
|
|
19243
18740
|
if (this.initWalletPayload) return this.initWalletPayload;
|
|
19244
|
-
if (!this.
|
|
18741
|
+
if (!this.arkServer) {
|
|
19245
18742
|
throw new Error("Cannot re-initialize: wallet was not initialized via the SDK factory");
|
|
19246
18743
|
}
|
|
19247
18744
|
this.initWalletPayload = {
|
|
19248
|
-
|
|
19249
|
-
|
|
19250
|
-
arkServerUrl: this.arkServerUrl,
|
|
19251
|
-
arkServerPublicKey: this.arkServerPublicKey
|
|
18745
|
+
arkServerUrl: this.arkServer.url,
|
|
18746
|
+
arkServerPublicKey: this.arkServer.publicKey
|
|
19252
18747
|
};
|
|
19253
18748
|
return this.initWalletPayload;
|
|
19254
18749
|
}
|
|
@@ -19375,7 +18870,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
19375
18870
|
try {
|
|
19376
18871
|
const response = await this.sendMessage(message);
|
|
19377
18872
|
const { vtxos, page } = response.payload;
|
|
19378
|
-
return { vtxos: vtxos.map(
|
|
18873
|
+
return { vtxos: vtxos.map(chunkC5Y2R63Z_cjs.normalizeVtxo), page: page && { ...page } };
|
|
19379
18874
|
} catch (error) {
|
|
19380
18875
|
throw new Error(`Failed to get vtxos: ${error}`, { cause: error });
|
|
19381
18876
|
}
|
|
@@ -19479,7 +18974,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
19479
18974
|
};
|
|
19480
18975
|
try {
|
|
19481
18976
|
const response = await this.sendMessage(message);
|
|
19482
|
-
return response.payload.vtxos.map(
|
|
18977
|
+
return response.payload.vtxos.map(chunkC5Y2R63Z_cjs.normalizeVtxo);
|
|
19483
18978
|
} catch (error) {
|
|
19484
18979
|
throw new Error(`Failed to get vtxos: ${error}`);
|
|
19485
18980
|
}
|
|
@@ -19504,7 +18999,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
19504
18999
|
};
|
|
19505
19000
|
try {
|
|
19506
19001
|
const response = await this.sendMessage(message);
|
|
19507
|
-
return response.payload.vtxos.map(
|
|
19002
|
+
return response.payload.vtxos.map(chunkC5Y2R63Z_cjs.normalizeVtxo);
|
|
19508
19003
|
} catch (error) {
|
|
19509
19004
|
throw new Error(`Failed to get spendable vtxos: ${error}`);
|
|
19510
19005
|
}
|
|
@@ -19635,7 +19130,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
19635
19130
|
};
|
|
19636
19131
|
try {
|
|
19637
19132
|
const response = await sendContractMessage(message);
|
|
19638
|
-
return response.payload.vtxos.map(
|
|
19133
|
+
return response.payload.vtxos.map(chunkC5Y2R63Z_cjs.normalizeVtxo);
|
|
19639
19134
|
} catch (e) {
|
|
19640
19135
|
throw new Error("Failed to annotate vtxos");
|
|
19641
19136
|
}
|
|
@@ -19862,18 +19357,12 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
19862
19357
|
walletRepository,
|
|
19863
19358
|
contractRepository,
|
|
19864
19359
|
messageTag,
|
|
19865
|
-
!!
|
|
19360
|
+
!!options.delegateUrl
|
|
19866
19361
|
);
|
|
19867
|
-
const
|
|
19362
|
+
const arkServer = options.arkServer ?? { url: "https://arkade.computer" };
|
|
19868
19363
|
const initWalletPayload = {
|
|
19869
|
-
|
|
19870
|
-
|
|
19871
|
-
arkServerPublicKey: options.arkServerPublicKey,
|
|
19872
|
-
delegateUrl: options.delegateUrl || options.delegatorUrl,
|
|
19873
|
-
// Keep the deprecated field populated so pre-#519 service workers
|
|
19874
|
-
// (which only read delegatorUrl) keep delegating until they activate
|
|
19875
|
-
// a newer version.
|
|
19876
|
-
delegatorUrl: options.delegateUrl || options.delegatorUrl
|
|
19364
|
+
arkServerUrl: arkServer.url,
|
|
19365
|
+
arkServerPublicKey: arkServer.publicKey
|
|
19877
19366
|
};
|
|
19878
19367
|
const messageTimeouts = options.messageTimeouts ? {
|
|
19879
19368
|
...DEFAULT_MESSAGE_TIMEOUTS,
|
|
@@ -19881,17 +19370,8 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
19881
19370
|
} : DEFAULT_MESSAGE_TIMEOUTS;
|
|
19882
19371
|
const busInitConfig = {
|
|
19883
19372
|
wallet: serializedWallet,
|
|
19884
|
-
arkServer
|
|
19885
|
-
|
|
19886
|
-
publicKey: options.arkServerPublicKey
|
|
19887
|
-
},
|
|
19888
|
-
delegateUrl: options.delegateUrl || options.delegatorUrl,
|
|
19889
|
-
// Keep the deprecated field populated so pre-#519 service workers
|
|
19890
|
-
// (which only read delegatorUrl) keep delegating until they activate
|
|
19891
|
-
// a newer version.
|
|
19892
|
-
delegatorUrl: options.delegateUrl || options.delegatorUrl,
|
|
19893
|
-
indexerUrl: options.indexerUrl,
|
|
19894
|
-
esploraUrl: options.esploraUrl,
|
|
19373
|
+
arkServer,
|
|
19374
|
+
delegateUrl: options.delegateUrl,
|
|
19895
19375
|
settlementConfig: options.settlementConfig,
|
|
19896
19376
|
walletMode: options.walletMode,
|
|
19897
19377
|
watcherConfig: options.watcherConfig,
|
|
@@ -19927,7 +19407,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
19927
19407
|
* ```typescript
|
|
19928
19408
|
* const wallet = await ServiceWorkerWallet.setup({
|
|
19929
19409
|
* serviceWorkerPath: '/service-worker.js',
|
|
19930
|
-
*
|
|
19410
|
+
* arkServer: { url: 'https://arkade.computer' },
|
|
19931
19411
|
* identity: MnemonicIdentity.fromMnemonic('abandon abandon...')
|
|
19932
19412
|
* });
|
|
19933
19413
|
* ```
|
|
@@ -20090,20 +19570,6 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
20090
19570
|
}
|
|
20091
19571
|
};
|
|
20092
19572
|
}
|
|
20093
|
-
async sendBitcoin(params) {
|
|
20094
|
-
const message = {
|
|
20095
|
-
id: getRandomId(),
|
|
20096
|
-
tag: this.messageTag,
|
|
20097
|
-
type: "SEND_BITCOIN",
|
|
20098
|
-
payload: params
|
|
20099
|
-
};
|
|
20100
|
-
try {
|
|
20101
|
-
const response = await this.sendMessage(message);
|
|
20102
|
-
return response.payload.txid;
|
|
20103
|
-
} catch (error) {
|
|
20104
|
-
throw new Error(`Failed to send bitcoin: ${error}`);
|
|
20105
|
-
}
|
|
20106
|
-
}
|
|
20107
19573
|
async settle(params, callback) {
|
|
20108
19574
|
const message = {
|
|
20109
19575
|
id: getRandomId(),
|
|
@@ -20221,10 +19687,6 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
20221
19687
|
};
|
|
20222
19688
|
return manager;
|
|
20223
19689
|
}
|
|
20224
|
-
/** @deprecated alias for @see ServiceWorkerWallet.getDelegateManager */
|
|
20225
|
-
async getDelegatorManager() {
|
|
20226
|
-
return await this.getDelegateManager();
|
|
20227
|
-
}
|
|
20228
19690
|
async getVtxoManager() {
|
|
20229
19691
|
const wallet = this;
|
|
20230
19692
|
const messageTag = this.messageTag;
|
|
@@ -20273,7 +19735,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
20273
19735
|
};
|
|
20274
19736
|
try {
|
|
20275
19737
|
const response = await wallet.sendMessage(message);
|
|
20276
|
-
return response.payload.vtxos.map(
|
|
19738
|
+
return response.payload.vtxos.map(chunkC5Y2R63Z_cjs.normalizeVtxo);
|
|
20277
19739
|
} catch (e) {
|
|
20278
19740
|
throw new Error(`Failed to get expiring vtxos: ${e}`);
|
|
20279
19741
|
}
|
|
@@ -20385,12 +19847,12 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
20385
19847
|
* @returns Configured onchain wallet
|
|
20386
19848
|
* @throws Error if the configured identity cannot produce a valid x-only public key
|
|
20387
19849
|
*/
|
|
20388
|
-
static async create(identity, networkName =
|
|
19850
|
+
static async create(identity, networkName = chunkC5Y2R63Z_cjs.DEFAULT_NETWORK_NAME, provider) {
|
|
20389
19851
|
const pubkey = await identity.xOnlyPublicKey();
|
|
20390
19852
|
if (!pubkey) {
|
|
20391
19853
|
throw new Error("Invalid configured public key");
|
|
20392
19854
|
}
|
|
20393
|
-
const network =
|
|
19855
|
+
const network = chunkC5Y2R63Z_cjs.getNetwork(networkName);
|
|
20394
19856
|
const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
|
|
20395
19857
|
const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
|
|
20396
19858
|
return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
|
|
@@ -20496,7 +19958,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
20496
19958
|
if (!inputs) {
|
|
20497
19959
|
throw new Error("Fee estimation failed");
|
|
20498
19960
|
}
|
|
20499
|
-
let tx = new
|
|
19961
|
+
let tx = new chunkC5Y2R63Z_cjs.Transaction();
|
|
20500
19962
|
for (const input of inputs) {
|
|
20501
19963
|
tx.addInput({
|
|
20502
19964
|
txid: input.txid,
|
|
@@ -20554,7 +20016,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
20554
20016
|
* @throws If the parent has no anchor, or funding cannot be selected/signed
|
|
20555
20017
|
*/
|
|
20556
20018
|
async bumpAnchor(parentHex, feeRate) {
|
|
20557
|
-
const parent =
|
|
20019
|
+
const parent = chunkC5Y2R63Z_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
|
|
20558
20020
|
const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
|
|
20559
20021
|
const child = await this.buildBumpPackage(parent, feeRate, coins);
|
|
20560
20022
|
return [parent.hex, child.hex];
|
|
@@ -21461,7 +20923,7 @@ async function resolvePrevTxs(txids, source, onchain) {
|
|
|
21461
20923
|
try {
|
|
21462
20924
|
const { txs } = await source.getVirtualTxs(wanted);
|
|
21463
20925
|
for (const psbt of txs) {
|
|
21464
|
-
const tx =
|
|
20926
|
+
const tx = chunkC5Y2R63Z_cjs.Transaction.fromPSBT(base.base64.decode(psbt));
|
|
21465
20927
|
resolved.set(tx.id, tx.toBytes());
|
|
21466
20928
|
}
|
|
21467
20929
|
} catch (err) {
|
|
@@ -21494,7 +20956,7 @@ async function resolvePrevTxs(txids, source, onchain) {
|
|
|
21494
20956
|
async function attachPrevArkTxs(tx, txids, source, onchain) {
|
|
21495
20957
|
const pending = [];
|
|
21496
20958
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
21497
|
-
if (
|
|
20959
|
+
if (chunkC5Y2R63Z_cjs.getArkPsbtFields(tx, i, chunkC5Y2R63Z_cjs.PrevArkTxField).length === 0) pending.push(i);
|
|
21498
20960
|
}
|
|
21499
20961
|
if (pending.length === 0) return;
|
|
21500
20962
|
const resolved = await resolvePrevTxs(
|
|
@@ -21503,13 +20965,13 @@ async function attachPrevArkTxs(tx, txids, source, onchain) {
|
|
|
21503
20965
|
onchain
|
|
21504
20966
|
);
|
|
21505
20967
|
for (const i of pending) {
|
|
21506
|
-
|
|
20968
|
+
chunkC5Y2R63Z_cjs.setArkPsbtField(tx, i, chunkC5Y2R63Z_cjs.PrevArkTxField, resolved.get(txidAt(txids, i)));
|
|
21507
20969
|
}
|
|
21508
20970
|
}
|
|
21509
20971
|
async function attachPrevoutTxs(tx, source) {
|
|
21510
20972
|
const pending = [];
|
|
21511
20973
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
21512
|
-
if (
|
|
20974
|
+
if (chunkC5Y2R63Z_cjs.getArkPsbtFields(tx, i, chunkC5Y2R63Z_cjs.PrevoutTxField).length > 0) continue;
|
|
21513
20975
|
const input = tx.getInput(i);
|
|
21514
20976
|
if (!input?.txid) throw new PrevTxUnavailableError(`input ${i} has no outpoint`);
|
|
21515
20977
|
pending.push({ index: i, txid: base.hex.encode(input.txid) });
|
|
@@ -21520,7 +20982,7 @@ async function attachPrevoutTxs(tx, source) {
|
|
|
21520
20982
|
resolved.set(txid, await source.getRawTransaction(txid));
|
|
21521
20983
|
}
|
|
21522
20984
|
for (const { index, txid } of pending) {
|
|
21523
|
-
|
|
20985
|
+
chunkC5Y2R63Z_cjs.setArkPsbtField(tx, index, chunkC5Y2R63Z_cjs.PrevoutTxField, resolved.get(txid));
|
|
21524
20986
|
}
|
|
21525
20987
|
}
|
|
21526
20988
|
async function withPrevTxs(coins, source, onchain) {
|
|
@@ -21546,7 +21008,7 @@ exports.BIP322 = void 0;
|
|
|
21546
21008
|
async function sign2(message, identity, network) {
|
|
21547
21009
|
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
21548
21010
|
const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
|
|
21549
|
-
const toSpend =
|
|
21011
|
+
const toSpend = chunkC5Y2R63Z_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
21550
21012
|
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
21551
21013
|
const signed = await identity.sign(toSign, [0]);
|
|
21552
21014
|
signed.finalizeIdx(0);
|
|
@@ -21604,7 +21066,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
|
21604
21066
|
if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
|
|
21605
21067
|
return false;
|
|
21606
21068
|
}
|
|
21607
|
-
const toSpend =
|
|
21069
|
+
const toSpend = chunkC5Y2R63Z_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
21608
21070
|
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
|
|
21609
21071
|
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
21610
21072
|
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
@@ -21625,7 +21087,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
|
21625
21087
|
}
|
|
21626
21088
|
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
21627
21089
|
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
21628
|
-
const toSpend =
|
|
21090
|
+
const toSpend = chunkC5Y2R63Z_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
21629
21091
|
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
21630
21092
|
const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
|
|
21631
21093
|
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
@@ -21678,7 +21140,7 @@ function encodeCompactSize(n) {
|
|
|
21678
21140
|
return buf;
|
|
21679
21141
|
}
|
|
21680
21142
|
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
21681
|
-
const tx = new
|
|
21143
|
+
const tx = new chunkC5Y2R63Z_cjs.Transaction({ version: 0 });
|
|
21682
21144
|
tx.addInput({
|
|
21683
21145
|
txid: toSpend.id,
|
|
21684
21146
|
index: 0,
|
|
@@ -21692,12 +21154,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
|
21692
21154
|
});
|
|
21693
21155
|
tx.addOutput({
|
|
21694
21156
|
amount: 0n,
|
|
21695
|
-
script:
|
|
21157
|
+
script: chunkC5Y2R63Z_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
21696
21158
|
});
|
|
21697
21159
|
return tx;
|
|
21698
21160
|
}
|
|
21699
21161
|
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
21700
|
-
const tx = new
|
|
21162
|
+
const tx = new chunkC5Y2R63Z_cjs.Transaction({ version: 0 });
|
|
21701
21163
|
tx.addInput({
|
|
21702
21164
|
txid: toSpend.id,
|
|
21703
21165
|
index: 0,
|
|
@@ -21709,7 +21171,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
|
21709
21171
|
});
|
|
21710
21172
|
tx.addOutput({
|
|
21711
21173
|
amount: 0n,
|
|
21712
|
-
script:
|
|
21174
|
+
script: chunkC5Y2R63Z_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
21713
21175
|
});
|
|
21714
21176
|
return tx;
|
|
21715
21177
|
}
|
|
@@ -21840,7 +21302,7 @@ var RestEmulatorProvider = class {
|
|
|
21840
21302
|
}
|
|
21841
21303
|
};
|
|
21842
21304
|
function finalizeVirtualTx(type, psbtBase64) {
|
|
21843
|
-
const tx =
|
|
21305
|
+
const tx = chunkC5Y2R63Z_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
21844
21306
|
if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
|
|
21845
21307
|
const input = tx.getInput(0);
|
|
21846
21308
|
if (!input) {
|
|
@@ -21867,14 +21329,14 @@ var ExitPathError = class extends Error {
|
|
|
21867
21329
|
reason;
|
|
21868
21330
|
};
|
|
21869
21331
|
function delayWeight(sequence) {
|
|
21870
|
-
const t =
|
|
21332
|
+
const t = chunkC5Y2R63Z_cjs.sequenceToTimelock(sequence);
|
|
21871
21333
|
return t.type === "blocks" ? Number(t.value) : Number(t.value) / 600;
|
|
21872
21334
|
}
|
|
21873
21335
|
async function resolveUnilateralPath(params) {
|
|
21874
21336
|
const { vtxo, scriptHex, contractRepository } = params;
|
|
21875
21337
|
const contract = contractRepository ? (await contractRepository.getContracts({ script: scriptHex }))[0] : void 0;
|
|
21876
21338
|
if (contract) {
|
|
21877
|
-
const handler =
|
|
21339
|
+
const handler = chunkF7HJO5GT_cjs.contractHandlers.get(contract.type);
|
|
21878
21340
|
if (!handler) {
|
|
21879
21341
|
throw new ExitPathError(
|
|
21880
21342
|
"no-handler",
|
|
@@ -21885,8 +21347,7 @@ async function resolveUnilateralPath(params) {
|
|
|
21885
21347
|
const paths = handler.getAllSpendingPaths(script, contract, {
|
|
21886
21348
|
collaborative: false,
|
|
21887
21349
|
currentTime: params.currentTime,
|
|
21888
|
-
walletDescriptor: params.walletDescriptor
|
|
21889
|
-
walletPubKey: params.walletPubKeyHex
|
|
21350
|
+
walletDescriptor: params.walletDescriptor
|
|
21890
21351
|
}).filter((p) => p.sequence !== void 0);
|
|
21891
21352
|
if (paths.length === 0) {
|
|
21892
21353
|
throw new ExitPathError(
|
|
@@ -21897,12 +21358,12 @@ async function resolveUnilateralPath(params) {
|
|
|
21897
21358
|
paths.sort((a, b) => delayWeight(a.sequence) - delayWeight(b.sequence));
|
|
21898
21359
|
return { selection: paths[0], label: `${contract.type}:unilateral` };
|
|
21899
21360
|
}
|
|
21900
|
-
const decoded =
|
|
21361
|
+
const decoded = chunkC5Y2R63Z_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
21901
21362
|
let best;
|
|
21902
21363
|
for (const exit of decoded.exitPaths()) {
|
|
21903
21364
|
const leaf = decoded.findLeaf(base.hex.encode(exit.script));
|
|
21904
21365
|
if (!leaf) continue;
|
|
21905
|
-
const sequence =
|
|
21366
|
+
const sequence = chunkC5Y2R63Z_cjs.timelockToSequence(exit.params.timelock);
|
|
21906
21367
|
const weight = delayWeight(sequence);
|
|
21907
21368
|
if (!best || weight < best.weight) {
|
|
21908
21369
|
best = { selection: { leaf, sequence }, weight };
|
|
@@ -22122,7 +21583,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
22122
21583
|
let totalAmount = 0n;
|
|
22123
21584
|
const txWeightEstimator = TxWeightEstimator.create();
|
|
22124
21585
|
for (const vtxo of vtxos) {
|
|
22125
|
-
if (!
|
|
21586
|
+
if (!chunkC5Y2R63Z_cjs.canSweepOnchain(vtxo)) {
|
|
22126
21587
|
throw new Error(
|
|
22127
21588
|
`Vtxo ${vtxo.txid}:${vtxo.vout} cannot be swept onchain: it is not fully unrolled (use unroll first), or its exit output was already spent`
|
|
22128
21589
|
);
|
|
@@ -22133,14 +21594,13 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
22133
21594
|
}
|
|
22134
21595
|
const resolved = await resolveUnilateralPath({
|
|
22135
21596
|
vtxo,
|
|
22136
|
-
scriptHex: base.hex.encode(
|
|
21597
|
+
scriptHex: base.hex.encode(chunkC5Y2R63Z_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
22137
21598
|
contractRepository: wallet.contractRepository,
|
|
22138
|
-
walletPubKeyHex: base.hex.encode(await wallet.identity.xOnlyPublicKey()),
|
|
22139
21599
|
currentTime: Date.now()
|
|
22140
21600
|
});
|
|
22141
21601
|
const spendingLeaf = resolved.selection.leaf;
|
|
22142
21602
|
const sequence = resolved.selection.sequence;
|
|
22143
|
-
const timelock =
|
|
21603
|
+
const timelock = chunkC5Y2R63Z_cjs.sequenceToTimelock(sequence);
|
|
22144
21604
|
const elapsed = timelock.type === "blocks" ? chainTip.height >= txStatus.blockHeight + Number(timelock.value) : chainTip.time >= txStatus.blockTime + Number(timelock.value);
|
|
22145
21605
|
if (!elapsed) {
|
|
22146
21606
|
throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
|
|
@@ -22153,7 +21613,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
22153
21613
|
sequence,
|
|
22154
21614
|
witnessUtxo: {
|
|
22155
21615
|
amount: BigInt(vtxo.value),
|
|
22156
|
-
script:
|
|
21616
|
+
script: chunkC5Y2R63Z_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
|
|
22157
21617
|
},
|
|
22158
21618
|
sighashType: btcSigner.SigHash.DEFAULT
|
|
22159
21619
|
});
|
|
@@ -22163,7 +21623,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
22163
21623
|
btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
|
|
22164
21624
|
);
|
|
22165
21625
|
}
|
|
22166
|
-
const tx = new
|
|
21626
|
+
const tx = new chunkC5Y2R63Z_cjs.Transaction({ version: 2 });
|
|
22167
21627
|
for (const input of inputs) {
|
|
22168
21628
|
tx.addInput(input);
|
|
22169
21629
|
}
|
|
@@ -22246,7 +21706,7 @@ async function buildSignedSweep(params) {
|
|
|
22246
21706
|
`uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
|
|
22247
21707
|
);
|
|
22248
21708
|
}
|
|
22249
|
-
const tx = new
|
|
21709
|
+
const tx = new chunkC5Y2R63Z_cjs.Transaction({ version: 2 });
|
|
22250
21710
|
tx.addInput({
|
|
22251
21711
|
txid: vtxo.txid,
|
|
22252
21712
|
index: vtxo.vout,
|
|
@@ -22271,7 +21731,7 @@ async function buildSignedSweep(params) {
|
|
|
22271
21731
|
finalScriptWitness: [
|
|
22272
21732
|
tapScriptSig[0][1],
|
|
22273
21733
|
...path.extraWitness,
|
|
22274
|
-
|
|
21734
|
+
chunkC5Y2R63Z_cjs.scriptFromTapLeafScript(path.leaf),
|
|
22275
21735
|
btcSigner.TaprootControlBlock.encode(controlBlock)
|
|
22276
21736
|
]
|
|
22277
21737
|
});
|
|
@@ -22301,7 +21761,7 @@ async function resolveFeeRate(opts) {
|
|
|
22301
21761
|
}
|
|
22302
21762
|
async function selectExitVtxos(opts) {
|
|
22303
21763
|
if (!opts.vtxos) return opts.wallet.getVtxos();
|
|
22304
|
-
const res = await
|
|
21764
|
+
const res = await chunkC5Y2R63Z_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
|
|
22305
21765
|
const tapTrees = /* @__PURE__ */ new Map();
|
|
22306
21766
|
const out = [];
|
|
22307
21767
|
for (const vtxo of res.vtxos) {
|
|
@@ -22316,7 +21776,7 @@ async function selectExitVtxos(opts) {
|
|
|
22316
21776
|
`no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
|
|
22317
21777
|
);
|
|
22318
21778
|
}
|
|
22319
|
-
const handler =
|
|
21779
|
+
const handler = chunkF7HJO5GT_cjs.contractHandlers.get(contract.type);
|
|
22320
21780
|
if (!handler) {
|
|
22321
21781
|
throw new Error(`no contract handler registered for type '${contract.type}'`);
|
|
22322
21782
|
}
|
|
@@ -22346,7 +21806,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
22346
21806
|
if (pendingNodes.length > 0) {
|
|
22347
21807
|
const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
|
|
22348
21808
|
for (const psbt of txs) {
|
|
22349
|
-
psbts.set(
|
|
21809
|
+
psbts.set(chunkC5Y2R63Z_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
22350
21810
|
}
|
|
22351
21811
|
}
|
|
22352
21812
|
const childVsize = Number(
|
|
@@ -22374,7 +21834,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
22374
21834
|
(s) => s.parent.id,
|
|
22375
21835
|
(s) => parentInputTxids(s.parent)
|
|
22376
21836
|
);
|
|
22377
|
-
const
|
|
21837
|
+
const walletDescriptor = base.hex.encode(await wallet.identity.xOnlyPublicKey());
|
|
22378
21838
|
const infos = [];
|
|
22379
21839
|
const sweeps = [];
|
|
22380
21840
|
for (const vtxo of vtxos) {
|
|
@@ -22382,9 +21842,9 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
22382
21842
|
try {
|
|
22383
21843
|
const resolved = await resolveUnilateralPath({
|
|
22384
21844
|
vtxo,
|
|
22385
|
-
scriptHex: base.hex.encode(
|
|
21845
|
+
scriptHex: base.hex.encode(chunkC5Y2R63Z_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
22386
21846
|
contractRepository: wallet.contractRepository,
|
|
22387
|
-
|
|
21847
|
+
walletDescriptor,
|
|
22388
21848
|
currentTime: Date.now()
|
|
22389
21849
|
});
|
|
22390
21850
|
const sweepFee = sweepFeeFor(
|
|
@@ -22401,7 +21861,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
22401
21861
|
});
|
|
22402
21862
|
continue;
|
|
22403
21863
|
}
|
|
22404
|
-
const t =
|
|
21864
|
+
const t = chunkC5Y2R63Z_cjs.sequenceToTimelock(resolved.selection.sequence);
|
|
22405
21865
|
const delay = { type: t.type, value: Number(t.value) };
|
|
22406
21866
|
infos.push({ outpoint, value: vtxo.value, sweepFee, path: resolved.label, delay });
|
|
22407
21867
|
sweeps.push({ vtxo, resolved, sweepFee, delay });
|
|
@@ -22802,7 +22262,7 @@ async function prepare(opts) {
|
|
|
22802
22262
|
txid: sweep.vtxo.txid,
|
|
22803
22263
|
vout: sweep.vtxo.vout,
|
|
22804
22264
|
value: sweep.vtxo.value,
|
|
22805
|
-
pkScript:
|
|
22265
|
+
pkScript: chunkC5Y2R63Z_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
|
|
22806
22266
|
},
|
|
22807
22267
|
path: sweep.resolved.selection,
|
|
22808
22268
|
outputAddress: opts.sweepAddress,
|
|
@@ -22890,7 +22350,7 @@ async function prepare(opts) {
|
|
|
22890
22350
|
if (newFee <= splitterFee) break;
|
|
22891
22351
|
splitterFee = newFee;
|
|
22892
22352
|
}
|
|
22893
|
-
const splitter = new
|
|
22353
|
+
const splitter = new chunkC5Y2R63Z_cjs.Transaction({ version: 2 });
|
|
22894
22354
|
for (const coin of selected.inputs) {
|
|
22895
22355
|
splitter.addInput({
|
|
22896
22356
|
txid: coin.txid,
|
|
@@ -23033,42 +22493,42 @@ var UnilateralExit = {
|
|
|
23033
22493
|
|
|
23034
22494
|
// src/arkade/index.ts
|
|
23035
22495
|
var arkade_exports = {};
|
|
23036
|
-
|
|
23037
|
-
ARKADE_OP: () =>
|
|
23038
|
-
ARKADE_OPCODES: () =>
|
|
23039
|
-
ARKADE_OPCODE_NAMES: () =>
|
|
23040
|
-
ARKADE_OPCODE_VALUES: () =>
|
|
23041
|
-
ARKADE_OPS: () =>
|
|
22496
|
+
chunkC5Y2R63Z_cjs.__export(arkade_exports, {
|
|
22497
|
+
ARKADE_OP: () => chunkF7HJO5GT_cjs.ARKADE_OP,
|
|
22498
|
+
ARKADE_OPCODES: () => chunkF7HJO5GT_cjs.ARKADE_OPCODES,
|
|
22499
|
+
ARKADE_OPCODE_NAMES: () => chunkF7HJO5GT_cjs.ARKADE_OPCODE_NAMES,
|
|
22500
|
+
ARKADE_OPCODE_VALUES: () => chunkF7HJO5GT_cjs.ARKADE_OPCODE_VALUES,
|
|
22501
|
+
ARKADE_OPS: () => chunkF7HJO5GT_cjs.ARKADE_OPS,
|
|
23042
22502
|
Arkade: () => Arkade,
|
|
23043
22503
|
ArkadeContract: () => ArkadeContract,
|
|
23044
|
-
ArkadeProgramScript: () =>
|
|
23045
|
-
ArkadeScript: () =>
|
|
22504
|
+
ArkadeProgramScript: () => chunkF7HJO5GT_cjs.ArkadeProgramScript,
|
|
22505
|
+
ArkadeScript: () => chunkF7HJO5GT_cjs.ArkadeScript,
|
|
23046
22506
|
ArkadeTransactionBuilder: () => ArkadeTransactionBuilder,
|
|
23047
|
-
BigNum: () =>
|
|
22507
|
+
BigNum: () => chunkF7HJO5GT_cjs.bignum_exports,
|
|
23048
22508
|
OP: () => btcSigner.OP,
|
|
23049
|
-
OPCODE_NAMES: () =>
|
|
23050
|
-
OPCODE_VALUES: () =>
|
|
23051
|
-
SUPPORTED_PROGRAM_VERSION: () =>
|
|
22509
|
+
OPCODE_NAMES: () => chunkF7HJO5GT_cjs.OPCODE_NAMES,
|
|
22510
|
+
OPCODE_VALUES: () => chunkF7HJO5GT_cjs.OPCODE_VALUES,
|
|
22511
|
+
SUPPORTED_PROGRAM_VERSION: () => chunkF7HJO5GT_cjs.SUPPORTED_PROGRAM_VERSION,
|
|
23052
22512
|
Script: () => btcSigner.Script,
|
|
23053
|
-
arkadeScriptHash: () =>
|
|
23054
|
-
arkadeWitnessHash: () =>
|
|
23055
|
-
asmToBytes: () =>
|
|
23056
|
-
bytesToASM: () =>
|
|
23057
|
-
computeArkadeScriptPublicKey: () =>
|
|
22513
|
+
arkadeScriptHash: () => chunkF7HJO5GT_cjs.arkadeScriptHash,
|
|
22514
|
+
arkadeWitnessHash: () => chunkF7HJO5GT_cjs.arkadeWitnessHash,
|
|
22515
|
+
asmToBytes: () => chunkF7HJO5GT_cjs.asmToBytes,
|
|
22516
|
+
bytesToASM: () => chunkF7HJO5GT_cjs.bytesToASM,
|
|
22517
|
+
computeArkadeScriptPublicKey: () => chunkF7HJO5GT_cjs.computeArkadeScriptPublicKey,
|
|
23058
22518
|
createArkadeBatchHandler: () => createArkadeBatchHandler,
|
|
23059
|
-
deserializeArkadeContractParams: () =>
|
|
23060
|
-
fromASM: () =>
|
|
23061
|
-
getOpcodeName: () =>
|
|
23062
|
-
getOpcodeValue: () =>
|
|
23063
|
-
parseArtifact: () =>
|
|
23064
|
-
resolveAsm: () =>
|
|
23065
|
-
serializeArkadeContractParams: () =>
|
|
23066
|
-
stringifyArtifact: () =>
|
|
23067
|
-
toASM: () =>
|
|
23068
|
-
validateProgram: () =>
|
|
23069
|
-
witnessRefToBytes: () =>
|
|
22519
|
+
deserializeArkadeContractParams: () => chunkF7HJO5GT_cjs.deserializeArkadeContractParams,
|
|
22520
|
+
fromASM: () => chunkF7HJO5GT_cjs.fromASM,
|
|
22521
|
+
getOpcodeName: () => chunkF7HJO5GT_cjs.getOpcodeName,
|
|
22522
|
+
getOpcodeValue: () => chunkF7HJO5GT_cjs.getOpcodeValue,
|
|
22523
|
+
parseArtifact: () => chunkF7HJO5GT_cjs.parseArtifact,
|
|
22524
|
+
resolveAsm: () => chunkF7HJO5GT_cjs.resolveAsm,
|
|
22525
|
+
serializeArkadeContractParams: () => chunkF7HJO5GT_cjs.serializeArkadeContractParams,
|
|
22526
|
+
stringifyArtifact: () => chunkF7HJO5GT_cjs.stringifyArtifact,
|
|
22527
|
+
toASM: () => chunkF7HJO5GT_cjs.toASM,
|
|
22528
|
+
validateProgram: () => chunkF7HJO5GT_cjs.validateProgram,
|
|
22529
|
+
witnessRefToBytes: () => chunkF7HJO5GT_cjs.witnessRefToBytes
|
|
23070
22530
|
});
|
|
23071
|
-
var isVtxoCoin = (input) =>
|
|
22531
|
+
var isVtxoCoin = (input) => chunkC5Y2R63Z_cjs.isVirtualCoin(input);
|
|
23072
22532
|
function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
|
|
23073
22533
|
let batchId;
|
|
23074
22534
|
let sweepTapTreeRoot;
|
|
@@ -23089,23 +22549,23 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
23089
22549
|
);
|
|
23090
22550
|
await arkProvider.confirmRegistration(intentId);
|
|
23091
22551
|
batchId = event.id;
|
|
23092
|
-
const sweepTapscript =
|
|
22552
|
+
const sweepTapscript = chunkC5Y2R63Z_cjs.CSVMultisigTapscript.encode({
|
|
23093
22553
|
timelock,
|
|
23094
|
-
pubkeys: [
|
|
22554
|
+
pubkeys: [chunkF7HJO5GT_cjs.toXOnly(base.hex.decode(info.forfeitPubkey), "forfeit key")]
|
|
23095
22555
|
}).script;
|
|
23096
22556
|
sweepTapTreeRoot = payment_js.tapLeafHash(sweepTapscript);
|
|
23097
22557
|
return { skip: false };
|
|
23098
22558
|
},
|
|
23099
22559
|
onTreeSigningStarted: async (event, vtxoTree) => {
|
|
23100
22560
|
const signerPubKey = await session.getPublicKey();
|
|
23101
|
-
const xonlySignerPubKey =
|
|
22561
|
+
const xonlySignerPubKey = chunkF7HJO5GT_cjs.toXOnly(signerPubKey, "signer key");
|
|
23102
22562
|
const xOnlyPubkeys = event.cosignersPublicKeys.map(
|
|
23103
|
-
(k) => base.hex.encode(
|
|
22563
|
+
(k) => base.hex.encode(chunkF7HJO5GT_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
|
|
23104
22564
|
);
|
|
23105
22565
|
if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
|
|
23106
22566
|
return { skip: true };
|
|
23107
22567
|
}
|
|
23108
|
-
const commitmentTx =
|
|
22568
|
+
const commitmentTx = chunkC5Y2R63Z_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
|
|
23109
22569
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
23110
22570
|
if (recipients && recipients.length > 0) {
|
|
23111
22571
|
validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
|
|
@@ -23137,7 +22597,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
23137
22597
|
if (connectorTree) {
|
|
23138
22598
|
validateConnectorsTxGraph(event.commitmentTx, connectorTree);
|
|
23139
22599
|
}
|
|
23140
|
-
let commitmentPsbt =
|
|
22600
|
+
let commitmentPsbt = chunkC5Y2R63Z_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
23141
22601
|
assertFinalCommitmentMatchesValidated(
|
|
23142
22602
|
commitmentPsbt,
|
|
23143
22603
|
validatedCommitmentTxid,
|
|
@@ -23172,7 +22632,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
23172
22632
|
boardingIndices.push(boardingIdx);
|
|
23173
22633
|
continue;
|
|
23174
22634
|
}
|
|
23175
|
-
if (
|
|
22635
|
+
if (chunkC5Y2R63Z_cjs.canRecoverOnchain(input, { timestamp: /* @__PURE__ */ new Date() }) || isSubdust(input, info.dust)) {
|
|
23176
22636
|
continue;
|
|
23177
22637
|
}
|
|
23178
22638
|
if (connectorIndex >= connectorLeaves.length) {
|
|
@@ -23193,7 +22653,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
23193
22653
|
index: input.vout,
|
|
23194
22654
|
witnessUtxo: {
|
|
23195
22655
|
amount: BigInt(input.value),
|
|
23196
|
-
script:
|
|
22656
|
+
script: chunkC5Y2R63Z_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
23197
22657
|
},
|
|
23198
22658
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
23199
22659
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -23284,16 +22744,16 @@ var Arkade = class _Arkade {
|
|
|
23284
22744
|
/** Connect and resolve the server key, checkpoint closure and (if present) the co-signer key. */
|
|
23285
22745
|
static async connect(opts) {
|
|
23286
22746
|
const info = await opts.arkade.getInfo();
|
|
23287
|
-
const serverKey =
|
|
23288
|
-
const checkpoint =
|
|
23289
|
-
const network = opts.network ??
|
|
22747
|
+
const serverKey = chunkF7HJO5GT_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
|
|
22748
|
+
const checkpoint = chunkC5Y2R63Z_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
22749
|
+
const network = opts.network ?? chunkC5Y2R63Z_cjs.DEFAULT_NETWORK;
|
|
23290
22750
|
let emulatorKey;
|
|
23291
22751
|
if (opts.emulator) {
|
|
23292
|
-
emulatorKey = base.hex.decode(
|
|
22752
|
+
emulatorKey = base.hex.decode(chunkC5Y2R63Z_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
|
|
23293
22753
|
}
|
|
23294
22754
|
let userKey;
|
|
23295
22755
|
if (opts.identity) {
|
|
23296
|
-
userKey =
|
|
22756
|
+
userKey = chunkF7HJO5GT_cjs.toXOnly(await opts.identity.xOnlyPublicKey(), "identity key");
|
|
23297
22757
|
}
|
|
23298
22758
|
return new _Arkade({
|
|
23299
22759
|
arkProvider: opts.arkade,
|
|
@@ -23319,7 +22779,7 @@ var Arkade = class _Arkade {
|
|
|
23319
22779
|
* key respectively; explicit args always win.
|
|
23320
22780
|
*/
|
|
23321
22781
|
contract(program, args = {}) {
|
|
23322
|
-
const declared = (program.params ?? []).map(
|
|
22782
|
+
const declared = (program.params ?? []).map(chunkF7HJO5GT_cjs.inputName);
|
|
23323
22783
|
if (declared.includes("server") && args.server === void 0) {
|
|
23324
22784
|
args = { ...args, server: this.serverKey };
|
|
23325
22785
|
}
|
|
@@ -23339,7 +22799,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
23339
22799
|
userKey: client.userKey,
|
|
23340
22800
|
emulatorKey: client.emulatorKey
|
|
23341
22801
|
};
|
|
23342
|
-
this.vtxoScript = new
|
|
22802
|
+
this.vtxoScript = new chunkF7HJO5GT_cjs.ArkadeProgramScript(program, args, this.keys);
|
|
23343
22803
|
this.tapTree = this.vtxoScript.encode();
|
|
23344
22804
|
this.compiled = this.vtxoScript.compiled;
|
|
23345
22805
|
}
|
|
@@ -23367,7 +22827,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
23367
22827
|
`ArkadeContract.fromContract: expected contract type 'arkade', got '${contract.type}'`
|
|
23368
22828
|
);
|
|
23369
22829
|
}
|
|
23370
|
-
const typed =
|
|
22830
|
+
const typed = chunkF7HJO5GT_cjs.deserializeArkadeContractParams(contract.params);
|
|
23371
22831
|
return new _ArkadeContract(client, typed.program, typed.args, {
|
|
23372
22832
|
serverKey: typed.serverKey,
|
|
23373
22833
|
userKey: typed.userKey,
|
|
@@ -23408,7 +22868,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
23408
22868
|
toContractParams() {
|
|
23409
22869
|
return {
|
|
23410
22870
|
type: "arkade",
|
|
23411
|
-
params:
|
|
22871
|
+
params: chunkF7HJO5GT_cjs.serializeArkadeContractParams({
|
|
23412
22872
|
program: this.program,
|
|
23413
22873
|
args: this.args,
|
|
23414
22874
|
serverKey: this.keys.serverKey,
|
|
@@ -23458,18 +22918,18 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
23458
22918
|
if (registered) {
|
|
23459
22919
|
const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
|
|
23460
22920
|
return (withVtxos?.vtxos ?? []).filter(
|
|
23461
|
-
(v) => !
|
|
22921
|
+
(v) => !chunkC5Y2R63Z_cjs.hasTerminalSpend(v) && !v.isUnrolled
|
|
23462
22922
|
);
|
|
23463
22923
|
}
|
|
23464
22924
|
}
|
|
23465
22925
|
if (!this.client.indexer) {
|
|
23466
22926
|
throw new Error("ArkadeContract.getUtxos: an indexer is required");
|
|
23467
22927
|
}
|
|
23468
|
-
const { vtxos } = await
|
|
22928
|
+
const { vtxos } = await chunkC5Y2R63Z_cjs.getNormalizedVtxos(this.client.indexer, {
|
|
23469
22929
|
scripts: [scriptHex],
|
|
23470
22930
|
spendableOnly: true
|
|
23471
22931
|
});
|
|
23472
|
-
return vtxos.filter((v) => !
|
|
22932
|
+
return vtxos.filter((v) => !chunkC5Y2R63Z_cjs.hasTerminalSpend(v) && !v.isUnrolled);
|
|
23473
22933
|
}
|
|
23474
22934
|
/** Total spendable balance (requires an indexer). */
|
|
23475
22935
|
async getBalance() {
|
|
@@ -23567,7 +23027,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
23567
23027
|
this.contract.client.checkpoint
|
|
23568
23028
|
);
|
|
23569
23029
|
if (coin.sourceTx) {
|
|
23570
|
-
|
|
23030
|
+
chunkC5Y2R63Z_cjs.setArkPsbtField(arkTx, 0, chunkC5Y2R63Z_cjs.PrevArkTxField, coin.sourceTx);
|
|
23571
23031
|
}
|
|
23572
23032
|
if (this.fn.arkadeScript) {
|
|
23573
23033
|
const indexer = this.contract.client.indexer;
|
|
@@ -23584,8 +23044,8 @@ var ArkadeTransactionBuilder = class {
|
|
|
23584
23044
|
}
|
|
23585
23045
|
const condition = (def.tapscript.witness ?? []).map((w) => this.witnessBytes(w));
|
|
23586
23046
|
if (condition.length > 0) {
|
|
23587
|
-
|
|
23588
|
-
|
|
23047
|
+
chunkC5Y2R63Z_cjs.setArkPsbtField(arkTx, 0, chunkC5Y2R63Z_cjs.ConditionWitness, condition);
|
|
23048
|
+
chunkC5Y2R63Z_cjs.setArkPsbtField(checkpoints[0], 0, chunkC5Y2R63Z_cjs.ConditionWitness, condition);
|
|
23589
23049
|
}
|
|
23590
23050
|
const packets = [];
|
|
23591
23051
|
if (this.assetSpecs.length > 0) {
|
|
@@ -23624,7 +23084,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
23624
23084
|
base.base64.encode(signedArk2.toPSBT()),
|
|
23625
23085
|
signedCps.map((c) => base.base64.encode(c.toPSBT()))
|
|
23626
23086
|
);
|
|
23627
|
-
const txid =
|
|
23087
|
+
const txid = chunkC5Y2R63Z_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
|
|
23628
23088
|
return {
|
|
23629
23089
|
txid,
|
|
23630
23090
|
signedArkTx: res2.signedArkTx,
|
|
@@ -23689,23 +23149,23 @@ var ArkadeTransactionBuilder = class {
|
|
|
23689
23149
|
}
|
|
23690
23150
|
buildAssetPacket() {
|
|
23691
23151
|
const groups = this.assetSpecs.map((s) => {
|
|
23692
|
-
const id = typeof s.assetId === "string" ?
|
|
23693
|
-
return
|
|
23152
|
+
const id = typeof s.assetId === "string" ? chunkSYRQJS5N_cjs.AssetId.fromString(s.assetId) : chunkSYRQJS5N_cjs.AssetId.fromBytes(s.assetId);
|
|
23153
|
+
return chunkSYRQJS5N_cjs.AssetGroup.create(
|
|
23694
23154
|
id,
|
|
23695
23155
|
null,
|
|
23696
|
-
s.inputs.map((i) =>
|
|
23697
|
-
s.outputs.map((o) =>
|
|
23698
|
-
(s.metadata ?? []).map((m) =>
|
|
23156
|
+
s.inputs.map((i) => chunkSYRQJS5N_cjs.AssetInput.create(i.vin, i.amount)),
|
|
23157
|
+
s.outputs.map((o) => chunkSYRQJS5N_cjs.AssetOutput.create(o.vout, o.amount)),
|
|
23158
|
+
(s.metadata ?? []).map((m) => chunkSYRQJS5N_cjs.Metadata.create(m.key, m.value))
|
|
23699
23159
|
);
|
|
23700
23160
|
});
|
|
23701
|
-
return
|
|
23161
|
+
return chunkSYRQJS5N_cjs.Packet.create(groups);
|
|
23702
23162
|
}
|
|
23703
23163
|
witnessBytes(ref) {
|
|
23704
|
-
return
|
|
23164
|
+
return chunkF7HJO5GT_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
|
|
23705
23165
|
}
|
|
23706
23166
|
};
|
|
23707
23167
|
function bindInputs(fn, callArgs) {
|
|
23708
|
-
const names = (fn.def.inputs ?? []).map(
|
|
23168
|
+
const names = (fn.def.inputs ?? []).map(chunkF7HJO5GT_cjs.inputName);
|
|
23709
23169
|
if (callArgs.length !== names.length) {
|
|
23710
23170
|
throw new Error(`${fn.name}: expected ${names.length} argument(s), got ${callArgs.length}`);
|
|
23711
23171
|
}
|
|
@@ -24102,6 +23562,7 @@ function arkAssetRail() {
|
|
|
24102
23562
|
}
|
|
24103
23563
|
};
|
|
24104
23564
|
}
|
|
23565
|
+
var walletFeeSource = (wallet) => async () => (await wallet.arkProvider.getInfo()).fees;
|
|
24105
23566
|
var GROSS_UP_MAX_ROUNDS = 8;
|
|
24106
23567
|
function grossUpOffboard(net, feeInfo, script) {
|
|
24107
23568
|
const estimator = new Estimator(feeInfo?.intentFee ?? {});
|
|
@@ -24114,7 +23575,10 @@ function grossUpOffboard(net, feeInfo, script) {
|
|
|
24114
23575
|
}
|
|
24115
23576
|
return { gross, fee: gross - net };
|
|
24116
23577
|
}
|
|
24117
|
-
function onchainRail() {
|
|
23578
|
+
function onchainRail(deps) {
|
|
23579
|
+
if (typeof deps?.feeInfo !== "function") {
|
|
23580
|
+
throw new Error("onchain rail: a feeInfo source is required");
|
|
23581
|
+
}
|
|
24118
23582
|
return {
|
|
24119
23583
|
id: "onchain",
|
|
24120
23584
|
match: (req) => btcTarget(req.raw) !== void 0,
|
|
@@ -24124,7 +23588,7 @@ function onchainRail() {
|
|
|
24124
23588
|
assertNoAssets("onchain", req);
|
|
24125
23589
|
const address = btcTarget(req.raw);
|
|
24126
23590
|
const amt = resolveSendAmount("onchain", req.raw, req.amount);
|
|
24127
|
-
const
|
|
23591
|
+
const fees = await deps.feeInfo();
|
|
24128
23592
|
const script = base.hex.encode(offboardDestinationScript(address));
|
|
24129
23593
|
const { gross, fee } = grossUpOffboard(amt, fees, script);
|
|
24130
23594
|
return {
|
|
@@ -24152,7 +23616,7 @@ function createDefaultPaymentRouter(wallet) {
|
|
|
24152
23616
|
return new PaymentRouter({
|
|
24153
23617
|
wallet,
|
|
24154
23618
|
prefs: { priority: ["ark", "ark-asset", "onchain"] }
|
|
24155
|
-
}).use(arkRail()).use(arkAssetRail()).use(onchainRail());
|
|
23619
|
+
}).use(arkRail()).use(arkAssetRail()).use(onchainRail({ feeInfo: walletFeeSource(wallet) }));
|
|
24156
23620
|
}
|
|
24157
23621
|
/*! Bundled license information:
|
|
24158
23622
|
|
|
@@ -24178,17 +23642,13 @@ exports.CachingArkProvider = CachingArkProvider;
|
|
|
24178
23642
|
exports.ChainedTxType = ChainedTxType;
|
|
24179
23643
|
exports.ConnectionDisposedError = ConnectionDisposedError;
|
|
24180
23644
|
exports.ContractManager = ContractManager;
|
|
24181
|
-
exports.ContractRepositoryImpl = ContractRepositoryImpl;
|
|
24182
23645
|
exports.ContractWatcher = ContractWatcher;
|
|
24183
|
-
exports.DB_VERSION = DB_VERSION;
|
|
24184
23646
|
exports.DEFAULT_MESSAGE_TIMEOUTS = DEFAULT_MESSAGE_TIMEOUTS;
|
|
24185
23647
|
exports.DEFAULT_MIN_BATCH_EXPIRY_SECONDS = DEFAULT_MIN_BATCH_EXPIRY_SECONDS;
|
|
24186
23648
|
exports.DEFAULT_MIN_CHECKPOINT_EXIT_DELAY_SECONDS = DEFAULT_MIN_CHECKPOINT_EXIT_DELAY_SECONDS;
|
|
24187
23649
|
exports.DatabaseUpgradeBlockedError = DatabaseUpgradeBlockedError;
|
|
24188
23650
|
exports.DelegateManagerImpl = DelegateManagerImpl;
|
|
24189
23651
|
exports.DelegateNotConfiguredError = DelegateNotConfiguredError;
|
|
24190
|
-
exports.DelegatorManagerImpl = DelegatorManagerImpl;
|
|
24191
|
-
exports.DelegatorNotConfiguredError = DelegatorNotConfiguredError;
|
|
24192
23652
|
exports.DescriptorIdentity = DescriptorIdentity;
|
|
24193
23653
|
exports.DescriptorSigningProviderMissingError = DescriptorSigningProviderMissingError;
|
|
24194
23654
|
exports.DustChangeError = DustChangeError;
|
|
@@ -24215,7 +23675,6 @@ exports.IndexedDBWalletRepository = IndexedDBWalletRepository;
|
|
|
24215
23675
|
exports.MAX_USED_SIGNING_DESCRIPTORS_LOOK_AHEAD = MAX_USED_SIGNING_DESCRIPTORS_LOOK_AHEAD;
|
|
24216
23676
|
exports.MESSAGE_BUS_INITIALIZING = MESSAGE_BUS_INITIALIZING;
|
|
24217
23677
|
exports.MESSAGE_BUS_NOT_INITIALIZED = MESSAGE_BUS_NOT_INITIALIZED;
|
|
24218
|
-
exports.MIGRATION_KEY = MIGRATION_KEY;
|
|
24219
23678
|
exports.MUTINYNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS = MUTINYNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS;
|
|
24220
23679
|
exports.MessageBus = MessageBus;
|
|
24221
23680
|
exports.MessageBusInitializingError = MessageBusInitializingError;
|
|
@@ -24235,7 +23694,6 @@ exports.ReadonlySingleKey = ReadonlySingleKey;
|
|
|
24235
23694
|
exports.ReadonlyWallet = ReadonlyWallet;
|
|
24236
23695
|
exports.ReadonlyWalletError = ReadonlyWalletError;
|
|
24237
23696
|
exports.RestDelegateProvider = RestDelegateProvider;
|
|
24238
|
-
exports.RestDelegatorProvider = RestDelegatorProvider;
|
|
24239
23697
|
exports.RestEmulatorProvider = RestEmulatorProvider;
|
|
24240
23698
|
exports.SIGNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS = SIGNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS;
|
|
24241
23699
|
exports.SeedIdentity = SeedIdentity;
|
|
@@ -24255,7 +23713,6 @@ exports.WalletCannotAllocateAddressError = WalletCannotAllocateAddressError;
|
|
|
24255
23713
|
exports.WalletCannotSignError = WalletCannotSignError;
|
|
24256
23714
|
exports.WalletMessageHandler = WalletMessageHandler;
|
|
24257
23715
|
exports.WalletNotInitializedError = WalletNotInitializedError;
|
|
24258
|
-
exports.WalletRepositoryImpl = WalletRepositoryImpl;
|
|
24259
23716
|
exports.WsElectrumChainSource = WsElectrumChainSource;
|
|
24260
23717
|
exports.adoptContractDescriptor = adoptContractDescriptor;
|
|
24261
23718
|
exports.arkAssetRail = arkAssetRail;
|
|
@@ -24311,7 +23768,6 @@ exports.extractArkProviderUrl = extractArkProviderUrl;
|
|
|
24311
23768
|
exports.gateExclusion = gateExclusion;
|
|
24312
23769
|
exports.gatedContracts = gatedContracts;
|
|
24313
23770
|
exports.getAllByIndexValues = getAllByIndexValues;
|
|
24314
|
-
exports.getMigrationStatus = getMigrationStatus;
|
|
24315
23771
|
exports.getRandomId = getRandomId;
|
|
24316
23772
|
exports.hasBoardingTxExpired = hasBoardingTxExpired;
|
|
24317
23773
|
exports.hasCandidates = hasCandidates;
|
|
@@ -24341,11 +23797,11 @@ exports.isValidArkAddress = isValidArkAddress;
|
|
|
24341
23797
|
exports.isVtxoExpiringSoon = isVtxoExpiringSoon;
|
|
24342
23798
|
exports.isVtxoForScript = isVtxoForScript;
|
|
24343
23799
|
exports.isWatchedContract = isWatchedContract;
|
|
23800
|
+
exports.legacyVtxoFacts = legacyVtxoFacts;
|
|
24344
23801
|
exports.logExcludedVtxos = logExcludedVtxos;
|
|
24345
23802
|
exports.makeHandle = makeHandle;
|
|
24346
23803
|
exports.matchServerCheckpoints = matchServerCheckpoints;
|
|
24347
23804
|
exports.mergeChainedTxType = mergeChainedTxType;
|
|
24348
|
-
exports.migrateWalletRepository = migrateWalletRepository;
|
|
24349
23805
|
exports.notifyExitObserved = notifyExitObserved;
|
|
24350
23806
|
exports.onchainRail = onchainRail;
|
|
24351
23807
|
exports.openDatabase = openDatabase;
|
|
@@ -24354,14 +23810,12 @@ exports.outpointReasons = outpointReasons;
|
|
|
24354
23810
|
exports.promisifyRequest = promisifyRequest;
|
|
24355
23811
|
exports.provisionClaimSecret = provisionClaimSecret;
|
|
24356
23812
|
exports.provisionRefundKey = provisionRefundKey;
|
|
24357
|
-
exports.requiresMigration = requiresMigration;
|
|
24358
23813
|
exports.resolveAssetAmount = resolveAssetAmount;
|
|
24359
23814
|
exports.resolveBatchExpiryPolicy = resolveBatchExpiryPolicy;
|
|
24360
23815
|
exports.resolveCheckpointExitDelayPolicy = resolveCheckpointExitDelayPolicy;
|
|
24361
23816
|
exports.resolveDescriptorSigner = resolveDescriptorSigner;
|
|
24362
23817
|
exports.resolvePrevTxs = resolvePrevTxs;
|
|
24363
23818
|
exports.resolveSendAmount = resolveSendAmount;
|
|
24364
|
-
exports.rollbackMigration = rollbackMigration;
|
|
24365
23819
|
exports.saveVtxosForContract = saveVtxosForContract;
|
|
24366
23820
|
exports.scriptFromArkAddress = scriptFromArkAddress;
|
|
24367
23821
|
exports.selectCoinsWithAsset = selectCoinsWithAsset;
|
|
@@ -24382,7 +23836,8 @@ exports.validateConnectorsTxGraph = validateConnectorsTxGraph;
|
|
|
24382
23836
|
exports.validateVtxoTxGraph = validateVtxoTxGraph;
|
|
24383
23837
|
exports.verifyTapscriptSignatures = verifyTapscriptSignatures;
|
|
24384
23838
|
exports.waitForIncomingFunds = waitForIncomingFunds;
|
|
23839
|
+
exports.walletFeeSource = walletFeeSource;
|
|
24385
23840
|
exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
|
|
24386
23841
|
exports.withPrevTxs = withPrevTxs;
|
|
24387
|
-
//# sourceMappingURL=chunk-
|
|
24388
|
-
//# sourceMappingURL=chunk-
|
|
23842
|
+
//# sourceMappingURL=chunk-ZHLYFRYY.cjs.map
|
|
23843
|
+
//# sourceMappingURL=chunk-ZHLYFRYY.cjs.map
|