@arkade-os/sdk 0.5.6 → 0.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/expo.cjs +6 -6
- package/dist/adapters/expo.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +3 -3
- package/dist/{asyncStorageTaskQueue-Bh2n0msM.d.cts → asyncStorageTaskQueue-B9byr6ij.d.cts} +2 -2
- package/dist/{asyncStorageTaskQueue-CpkstKZ5.d.ts → asyncStorageTaskQueue-XP4CCdRY.d.ts} +2 -2
- package/dist/{chunk-HKEPJBTY.cjs → chunk-3NALVGMJ.cjs} +16 -16
- package/dist/{chunk-HKEPJBTY.cjs.map → chunk-3NALVGMJ.cjs.map} +1 -1
- package/dist/{chunk-VWW2ZBPI.js → chunk-4AJRIM44.js} +4 -4
- package/dist/{chunk-VWW2ZBPI.js.map → chunk-4AJRIM44.js.map} +1 -1
- package/dist/{chunk-NDQ4LB4X.cjs → chunk-MQUATTIM.cjs} +8 -8
- package/dist/{chunk-NDQ4LB4X.cjs.map → chunk-MQUATTIM.cjs.map} +1 -1
- package/dist/{chunk-DJYX73W2.js → chunk-MWEDDWFU.js} +4 -4
- package/dist/{chunk-DJYX73W2.js.map → chunk-MWEDDWFU.js.map} +1 -1
- package/dist/{chunk-C7NY6WSA.js → chunk-MWMO2ZQP.js} +3 -3
- package/dist/{chunk-C7NY6WSA.js.map → chunk-MWMO2ZQP.js.map} +1 -1
- package/dist/{chunk-4X67IB2V.cjs → chunk-MXCB6EVM.cjs} +15 -15
- package/dist/{chunk-4X67IB2V.cjs.map → chunk-MXCB6EVM.cjs.map} +1 -1
- package/dist/{chunk-LZAINCGU.cjs → chunk-OMPDPBT5.cjs} +3 -3
- package/dist/chunk-OMPDPBT5.cjs.map +1 -0
- package/dist/{chunk-YKT4NAQG.js → chunk-RLD7DRSZ.js} +341 -25
- package/dist/chunk-RLD7DRSZ.js.map +1 -0
- package/dist/{chunk-Y3CDDPWI.cjs → chunk-URGVQ5TQ.cjs} +756 -434
- package/dist/chunk-URGVQ5TQ.cjs.map +1 -0
- package/dist/{chunk-47Z4LEIW.js → chunk-V2DDN4MV.js} +3 -3
- package/dist/{chunk-47Z4LEIW.js.map → chunk-V2DDN4MV.js.map} +1 -1
- package/dist/{chunk-YS76JSGP.cjs → chunk-V5WRO3P6.cjs} +10 -10
- package/dist/{chunk-YS76JSGP.cjs.map → chunk-V5WRO3P6.cjs.map} +1 -1
- package/dist/{chunk-QTMK34TP.js → chunk-VMVFRTF4.js} +3 -3
- package/dist/chunk-VMVFRTF4.js.map +1 -0
- package/dist/contracts/handlers/index.cjs +9 -9
- package/dist/contracts/handlers/index.d.cts +2 -2
- package/dist/contracts/handlers/index.d.ts +2 -2
- package/dist/contracts/handlers/index.js +2 -2
- package/dist/{index-C66rjxz2.d.ts → index-18cDMayF.d.ts} +1 -1
- package/dist/{index-2wKMrT0a.d.ts → index-B_kcptF8.d.ts} +1 -1
- package/dist/{index-46g577Ka.d.cts → index-Ccfhdfvj.d.cts} +1 -1
- package/dist/{index-Dqk07NwJ.d.cts → index-DDJFHfba.d.cts} +1 -1
- package/dist/index.cjs +335 -311
- package/dist/index.d.cts +72 -121
- package/dist/index.d.ts +72 -121
- package/dist/index.js +4 -4
- package/dist/{keyringDescriptorProvider-DiBM4GmB.d.ts → keyringDescriptorProvider-DL-jAiRO.d.ts} +150 -2
- package/dist/{keyringDescriptorProvider-DnaLUC7v.d.cts → keyringDescriptorProvider-Dtv0JWrT.d.cts} +150 -2
- package/dist/repositories/realm/index.cjs +37 -37
- package/dist/repositories/realm/index.d.cts +2 -2
- package/dist/repositories/realm/index.d.ts +2 -2
- package/dist/repositories/realm/index.js +5 -5
- package/dist/repositories/sqlite/index.cjs +35 -35
- package/dist/repositories/sqlite/index.d.cts +2 -2
- package/dist/repositories/sqlite/index.d.ts +2 -2
- package/dist/repositories/sqlite/index.js +5 -5
- package/dist/{taskRunner-BM6IAKlS.d.ts → taskRunner-DUafWu0o.d.ts} +2 -2
- package/dist/{taskRunner-BmDIZiSl.d.cts → taskRunner-JYHaLPne.d.cts} +2 -2
- package/dist/wallet/expo/background.cjs +14 -14
- 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 -6
- package/dist/wallet/expo/index.cjs +15 -15
- package/dist/wallet/expo/index.d.cts +3 -3
- package/dist/wallet/expo/index.d.ts +3 -3
- package/dist/wallet/expo/index.js +5 -5
- package/dist/worker/expo/index.cjs +9 -9
- 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 -5
- package/package.json +2 -2
- package/dist/chunk-LZAINCGU.cjs.map +0 -1
- package/dist/chunk-QTMK34TP.js.map +0 -1
- package/dist/chunk-Y3CDDPWI.cjs.map +0 -1
- package/dist/chunk-YKT4NAQG.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkX6ZI53DZ_cjs = require('./chunk-X6ZI53DZ.cjs');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var chunk3NALVGMJ_cjs = require('./chunk-3NALVGMJ.cjs');
|
|
5
|
+
var chunkMQUATTIM_cjs = require('./chunk-MQUATTIM.cjs');
|
|
6
6
|
var chunkJFJNB7ZH_cjs = require('./chunk-JFJNB7ZH.cjs');
|
|
7
|
-
var
|
|
7
|
+
var chunkOMPDPBT5_cjs = require('./chunk-OMPDPBT5.cjs');
|
|
8
8
|
var chunkFLPWNMX3_cjs = require('./chunk-FLPWNMX3.cjs');
|
|
9
9
|
var bip39 = require('@scure/bip39');
|
|
10
10
|
var english_js = require('@scure/bip39/wordlists/english.js');
|
|
@@ -325,7 +325,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
325
325
|
noncesByPubkey.set(base.hex.encode(myPublicKey.subarray(1)), myNonce);
|
|
326
326
|
const tx = this.graph.find(txid);
|
|
327
327
|
if (!tx) throw new Error(`missing tx for txid ${txid}`);
|
|
328
|
-
const cosigners =
|
|
328
|
+
const cosigners = chunkOMPDPBT5_cjs.getArkPsbtFields(tx.root, 0, chunkOMPDPBT5_cjs.CosignerPublicKey).map(
|
|
329
329
|
(c) => base.hex.encode(c.key.subarray(1))
|
|
330
330
|
// xonly pubkey
|
|
331
331
|
);
|
|
@@ -377,7 +377,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
377
377
|
if (!aggNonce) throw new Error("missing aggregate nonce");
|
|
378
378
|
const prevoutAmounts = [];
|
|
379
379
|
const prevoutScripts = [];
|
|
380
|
-
const cosigners =
|
|
380
|
+
const cosigners = chunkOMPDPBT5_cjs.getArkPsbtFields(g.root, 0, chunkOMPDPBT5_cjs.CosignerPublicKey).map((c) => c.key);
|
|
381
381
|
const { finalKey } = aggregateKeys(cosigners, true, {
|
|
382
382
|
taprootTweak: this.scriptRoot
|
|
383
383
|
});
|
|
@@ -460,7 +460,7 @@ var SingleKey = class _SingleKey {
|
|
|
460
460
|
async sign(tx, inputIndexes) {
|
|
461
461
|
const txCpy = tx.clone();
|
|
462
462
|
if (!inputIndexes) {
|
|
463
|
-
|
|
463
|
+
chunkOMPDPBT5_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH);
|
|
464
464
|
try {
|
|
465
465
|
if (!txCpy.sign(this.key, ALLOWED_SIGHASH)) {
|
|
466
466
|
throw new Error("Failed to sign transaction");
|
|
@@ -560,7 +560,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
560
560
|
let network;
|
|
561
561
|
if ("descriptor" in opts && typeof opts.descriptor === "string") {
|
|
562
562
|
descriptor = opts.descriptor;
|
|
563
|
-
network =
|
|
563
|
+
network = chunkMQUATTIM_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
564
564
|
} else {
|
|
565
565
|
network = opts.isMainnet ?? true ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
566
566
|
descriptor = descriptorsScure.scriptExpressions.trBIP32({
|
|
@@ -637,7 +637,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
637
637
|
}
|
|
638
638
|
/** Returns true when `descriptor` is derived from this identity's seed. */
|
|
639
639
|
ownsDescriptor(descriptor) {
|
|
640
|
-
return
|
|
640
|
+
return chunkMQUATTIM_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
|
|
641
641
|
}
|
|
642
642
|
/**
|
|
643
643
|
* Signs each request with the key derived from its descriptor.
|
|
@@ -676,7 +676,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
676
676
|
}
|
|
677
677
|
// ── internal helpers ─────────────────────────────────────────────
|
|
678
678
|
derivePrivateKeyForDescriptor(descriptor) {
|
|
679
|
-
const network =
|
|
679
|
+
const network = chunkMQUATTIM_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
680
680
|
const expansion = descriptorsScure.expand({ descriptor, network });
|
|
681
681
|
if (expansion.isRanged) {
|
|
682
682
|
throw new Error(
|
|
@@ -701,7 +701,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
701
701
|
signTxWithKey(tx, key, inputIndexes) {
|
|
702
702
|
const txCpy = tx.clone();
|
|
703
703
|
if (!inputIndexes) {
|
|
704
|
-
|
|
704
|
+
chunkOMPDPBT5_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH2);
|
|
705
705
|
try {
|
|
706
706
|
if (!txCpy.sign(key, ALLOWED_SIGHASH2)) {
|
|
707
707
|
throw new Error("Failed to sign transaction");
|
|
@@ -802,7 +802,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
802
802
|
/** Wildcard account-descriptor template (e.g. `tr([fp/86'/0'/0']xpub/0/*)`). */
|
|
803
803
|
descriptor;
|
|
804
804
|
constructor(descriptor) {
|
|
805
|
-
const network =
|
|
805
|
+
const network = chunkMQUATTIM_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
806
806
|
let expansion;
|
|
807
807
|
try {
|
|
808
808
|
expansion = descriptorsScure.expand({ descriptor, network, index: 0 });
|
|
@@ -837,7 +837,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
837
837
|
}
|
|
838
838
|
/** Returns true when `descriptor` derives from this identity's xpub. */
|
|
839
839
|
ownsDescriptor(descriptor) {
|
|
840
|
-
return
|
|
840
|
+
return chunkMQUATTIM_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
|
|
841
841
|
}
|
|
842
842
|
};
|
|
843
843
|
function serializeSeedOwnedSigningIdentity(identity) {
|
|
@@ -980,10 +980,10 @@ var DescriptorIdentity = class {
|
|
|
980
980
|
this.base = base;
|
|
981
981
|
}
|
|
982
982
|
async xOnlyPublicKey() {
|
|
983
|
-
return
|
|
983
|
+
return chunkMQUATTIM_cjs.deriveDescriptorLeafPubKey(this.descriptor);
|
|
984
984
|
}
|
|
985
985
|
async compressedPublicKey() {
|
|
986
|
-
return
|
|
986
|
+
return chunkMQUATTIM_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
|
|
987
987
|
}
|
|
988
988
|
async sign(tx, inputIndexes) {
|
|
989
989
|
const [signed] = await this.signer.signWithDescriptor([
|
|
@@ -1043,8 +1043,8 @@ var StaticDescriptorProvider = class _StaticDescriptorProvider {
|
|
|
1043
1043
|
}
|
|
1044
1044
|
isOurs(descriptor) {
|
|
1045
1045
|
try {
|
|
1046
|
-
const normalized =
|
|
1047
|
-
const pubKey =
|
|
1046
|
+
const normalized = chunkMQUATTIM_cjs.normalizeToDescriptor(descriptor);
|
|
1047
|
+
const pubKey = chunkMQUATTIM_cjs.extractPubKey(normalized);
|
|
1048
1048
|
return pubKey.toLowerCase() === this.pubKeyHex.toLowerCase();
|
|
1049
1049
|
} catch {
|
|
1050
1050
|
return false;
|
|
@@ -1386,7 +1386,7 @@ function unwrapKeyring(provider) {
|
|
|
1386
1386
|
}
|
|
1387
1387
|
function keyOf(descriptor) {
|
|
1388
1388
|
try {
|
|
1389
|
-
return
|
|
1389
|
+
return chunkMQUATTIM_cjs.extractPubKey(chunkMQUATTIM_cjs.normalizeToDescriptor(descriptor)).toLowerCase();
|
|
1390
1390
|
} catch {
|
|
1391
1391
|
return void 0;
|
|
1392
1392
|
}
|
|
@@ -1477,12 +1477,12 @@ async function resolveDescriptorSigner(descriptor, identity, provider) {
|
|
|
1477
1477
|
signMessageWithDescriptor: (ownedDescriptor, message, signatureType) => identity.signDescriptorMessage(ownedDescriptor, message, signatureType)
|
|
1478
1478
|
} : void 0;
|
|
1479
1479
|
const owner = providerOwner ?? identityOwner;
|
|
1480
|
-
if (owner &&
|
|
1480
|
+
if (owner && chunkMQUATTIM_cjs.parseHDDescriptor(descriptor)) {
|
|
1481
1481
|
return new DescriptorIdentity({ descriptor, signer: owner, base: identity });
|
|
1482
1482
|
}
|
|
1483
1483
|
let key;
|
|
1484
1484
|
try {
|
|
1485
|
-
key =
|
|
1485
|
+
key = chunkMQUATTIM_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
1486
1486
|
} catch {
|
|
1487
1487
|
throw new ForeignDescriptorError(descriptor);
|
|
1488
1488
|
}
|
|
@@ -1535,14 +1535,14 @@ function buildSaltedPreimageMessage(xonly, salt) {
|
|
|
1535
1535
|
}
|
|
1536
1536
|
var PREIMAGE_INDEX = 0;
|
|
1537
1537
|
function isPerArtifactDescriptor(descriptor) {
|
|
1538
|
-
return
|
|
1538
|
+
return chunkMQUATTIM_cjs.parseHDDescriptor(descriptor) !== null;
|
|
1539
1539
|
}
|
|
1540
1540
|
async function provisionDescriptor(wallet) {
|
|
1541
1541
|
const allocated = isHDAllocationCapable(wallet) ? await wallet.getNextSigningDescriptor() : void 0;
|
|
1542
|
-
return allocated ?? await
|
|
1542
|
+
return allocated ?? await chunkMQUATTIM_cjs.identityDescriptor(wallet.identity);
|
|
1543
1543
|
}
|
|
1544
1544
|
async function provisionRefundKey(wallet) {
|
|
1545
|
-
const descriptorPromise =
|
|
1545
|
+
const descriptorPromise = chunkMQUATTIM_cjs.identityDescriptor(wallet.identity);
|
|
1546
1546
|
const identityPubkeyPromise = wallet.identity.xOnlyPublicKey();
|
|
1547
1547
|
void identityPubkeyPromise.catch(() => void 0);
|
|
1548
1548
|
const descriptor = await descriptorPromise;
|
|
@@ -1605,7 +1605,7 @@ async function contractSigner(wallet, descriptor) {
|
|
|
1605
1605
|
const signer = isHDWalletCapable(wallet) ? await wallet.signerForDescriptor(descriptor) : wallet.identity;
|
|
1606
1606
|
let expected;
|
|
1607
1607
|
try {
|
|
1608
|
-
expected =
|
|
1608
|
+
expected = chunkMQUATTIM_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
1609
1609
|
} catch (cause) {
|
|
1610
1610
|
throw new ForeignDescriptorError(descriptor, { cause });
|
|
1611
1611
|
}
|
|
@@ -1687,7 +1687,7 @@ function debugLog(debug, ...args) {
|
|
|
1687
1687
|
}
|
|
1688
1688
|
function normalizeOptions(pathOrOptions) {
|
|
1689
1689
|
const o = typeof pathOrOptions === "string" ? { path: pathOrOptions } : pathOrOptions;
|
|
1690
|
-
|
|
1690
|
+
chunkOMPDPBT5_cjs.assertTimerMs("activationTimeoutMs", o.activationTimeoutMs);
|
|
1691
1691
|
return {
|
|
1692
1692
|
path: o.path,
|
|
1693
1693
|
updateViaCache: o.updateViaCache ?? "none",
|
|
@@ -1810,14 +1810,14 @@ var RestDelegateProvider = class {
|
|
|
1810
1810
|
*/
|
|
1811
1811
|
async delegate(intent, forfeitTxs, options) {
|
|
1812
1812
|
const url = `${this.url}/v1/delegate`;
|
|
1813
|
-
const response = await
|
|
1813
|
+
const response = await chunkOMPDPBT5_cjs.baseFetch(url, {
|
|
1814
1814
|
method: "POST",
|
|
1815
1815
|
headers: {
|
|
1816
1816
|
"Content-Type": "application/json"
|
|
1817
1817
|
},
|
|
1818
1818
|
body: JSON.stringify({
|
|
1819
1819
|
intent: {
|
|
1820
|
-
message:
|
|
1820
|
+
message: chunkOMPDPBT5_cjs.Proof.encodeMessage(intent.message),
|
|
1821
1821
|
proof: intent.proof
|
|
1822
1822
|
},
|
|
1823
1823
|
forfeit_txs: forfeitTxs,
|
|
@@ -1836,7 +1836,7 @@ var RestDelegateProvider = class {
|
|
|
1836
1836
|
*/
|
|
1837
1837
|
async getDelegateInfo() {
|
|
1838
1838
|
const url = `${this.url}/v1/delegator/info`;
|
|
1839
|
-
const response = await
|
|
1839
|
+
const response = await chunkOMPDPBT5_cjs.rateGate.runHttp(url, () => chunkOMPDPBT5_cjs.baseFetch(url));
|
|
1840
1840
|
if (!response.ok) {
|
|
1841
1841
|
const errorText2 = await response.text();
|
|
1842
1842
|
throw new Error(`Failed to get delegate info: ${errorText2}`);
|
|
@@ -1973,7 +1973,7 @@ var EsploraProvider = class {
|
|
|
1973
1973
|
*/
|
|
1974
1974
|
addressWatches = /* @__PURE__ */ new Map();
|
|
1975
1975
|
async getCoins(address) {
|
|
1976
|
-
const response = await
|
|
1976
|
+
const response = await chunkOMPDPBT5_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
|
|
1977
1977
|
if (!response.ok) {
|
|
1978
1978
|
throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
|
|
1979
1979
|
}
|
|
@@ -1982,12 +1982,12 @@ var EsploraProvider = class {
|
|
|
1982
1982
|
async getFeeRate() {
|
|
1983
1983
|
let url = `${this.baseUrl}/fee-estimates`;
|
|
1984
1984
|
let key = "1";
|
|
1985
|
-
let response = await
|
|
1985
|
+
let response = await chunkOMPDPBT5_cjs.baseFetch(url);
|
|
1986
1986
|
if (response.status === 404) {
|
|
1987
1987
|
await response.body?.cancel();
|
|
1988
1988
|
url = `${this.baseUrl}/v1/fees/recommended`;
|
|
1989
1989
|
key = "fastestFee";
|
|
1990
|
-
response = await
|
|
1990
|
+
response = await chunkOMPDPBT5_cjs.baseFetch(url);
|
|
1991
1991
|
}
|
|
1992
1992
|
if (response.status === 404) {
|
|
1993
1993
|
await response.body?.cancel();
|
|
@@ -2024,7 +2024,7 @@ var EsploraProvider = class {
|
|
|
2024
2024
|
}
|
|
2025
2025
|
}
|
|
2026
2026
|
async getTxOutspends(txid) {
|
|
2027
|
-
const response = await
|
|
2027
|
+
const response = await chunkOMPDPBT5_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
|
|
2028
2028
|
if (!response.ok) {
|
|
2029
2029
|
const error = await response.text();
|
|
2030
2030
|
throw new Error(`Failed to get transaction outspends: ${error}`);
|
|
@@ -2032,7 +2032,7 @@ var EsploraProvider = class {
|
|
|
2032
2032
|
return response.json();
|
|
2033
2033
|
}
|
|
2034
2034
|
async getTransactions(address) {
|
|
2035
|
-
const response = await
|
|
2035
|
+
const response = await chunkOMPDPBT5_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
|
|
2036
2036
|
if (!response.ok) {
|
|
2037
2037
|
const error = await response.text();
|
|
2038
2038
|
throw new Error(`Failed to get transactions: ${error}`);
|
|
@@ -2041,14 +2041,14 @@ var EsploraProvider = class {
|
|
|
2041
2041
|
}
|
|
2042
2042
|
/** Orders of magnitude smaller than `/address/{addr}/txs`: the polling fallback's probe. */
|
|
2043
2043
|
async getAddressStats(address) {
|
|
2044
|
-
const response = await
|
|
2044
|
+
const response = await chunkOMPDPBT5_cjs.baseFetch(`${this.baseUrl}/address/${address}`);
|
|
2045
2045
|
if (!response.ok) {
|
|
2046
2046
|
throw new Error(`Failed to get address stats: ${response.statusText}`);
|
|
2047
2047
|
}
|
|
2048
2048
|
return response.json();
|
|
2049
2049
|
}
|
|
2050
2050
|
async getRawTransaction(txid) {
|
|
2051
|
-
const response = await
|
|
2051
|
+
const response = await chunkOMPDPBT5_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/hex`);
|
|
2052
2052
|
if (!response.ok) {
|
|
2053
2053
|
const error = await response.text();
|
|
2054
2054
|
throw new Error(`Failed to get raw transaction ${txid}: ${error}`);
|
|
@@ -2056,7 +2056,7 @@ var EsploraProvider = class {
|
|
|
2056
2056
|
return base.hex.decode((await response.text()).trim());
|
|
2057
2057
|
}
|
|
2058
2058
|
async getTxStatus(txid) {
|
|
2059
|
-
const txresponse = await
|
|
2059
|
+
const txresponse = await chunkOMPDPBT5_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
|
|
2060
2060
|
if (!txresponse.ok) {
|
|
2061
2061
|
throw new Error(txresponse.statusText);
|
|
2062
2062
|
}
|
|
@@ -2064,7 +2064,7 @@ var EsploraProvider = class {
|
|
|
2064
2064
|
if (!tx.status.confirmed) {
|
|
2065
2065
|
return { confirmed: false };
|
|
2066
2066
|
}
|
|
2067
|
-
const response = await
|
|
2067
|
+
const response = await chunkOMPDPBT5_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
|
|
2068
2068
|
if (!response.ok) {
|
|
2069
2069
|
throw new Error(`Failed to get transaction status: ${response.statusText}`);
|
|
2070
2070
|
}
|
|
@@ -2145,14 +2145,22 @@ var EsploraProvider = class {
|
|
|
2145
2145
|
let anchorHeight;
|
|
2146
2146
|
const baseline = (async () => {
|
|
2147
2147
|
const [history, tip] = await Promise.allSettled([getAllTxs(), this.getChainTip()]);
|
|
2148
|
+
let failure;
|
|
2148
2149
|
if (history.status === "fulfilled") {
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2150
|
+
try {
|
|
2151
|
+
const keys = history.value.map(txKey2);
|
|
2152
|
+
for (const key of keys) seen.add(key);
|
|
2153
|
+
baselined = true;
|
|
2154
|
+
return;
|
|
2155
|
+
} catch (error) {
|
|
2156
|
+
failure = error;
|
|
2157
|
+
}
|
|
2158
|
+
} else {
|
|
2159
|
+
failure = history.reason;
|
|
2152
2160
|
}
|
|
2153
2161
|
console.warn(
|
|
2154
2162
|
"Could not baseline watched addresses; the first poll pass will establish it instead:",
|
|
2155
|
-
|
|
2163
|
+
failure
|
|
2156
2164
|
);
|
|
2157
2165
|
if (tip.status === "fulfilled") anchorHeight = tip.value.height;
|
|
2158
2166
|
})();
|
|
@@ -2338,9 +2346,9 @@ var EsploraProvider = class {
|
|
|
2338
2346
|
return { subscribers, teardown, started };
|
|
2339
2347
|
}
|
|
2340
2348
|
async getChainTip() {
|
|
2341
|
-
let tipBlocks = await
|
|
2349
|
+
let tipBlocks = await chunkOMPDPBT5_cjs.baseFetch(`${this.baseUrl}/blocks`);
|
|
2342
2350
|
if (tipBlocks.status === 404) {
|
|
2343
|
-
tipBlocks = await
|
|
2351
|
+
tipBlocks = await chunkOMPDPBT5_cjs.baseFetch(`${this.baseUrl}/v1/blocks`);
|
|
2344
2352
|
}
|
|
2345
2353
|
if (!tipBlocks.ok) {
|
|
2346
2354
|
throw new Error(`Failed to get chain tip: ${tipBlocks.statusText}`);
|
|
@@ -2364,7 +2372,7 @@ var EsploraProvider = class {
|
|
|
2364
2372
|
if (!Number.isInteger(height) || height < 0) {
|
|
2365
2373
|
throw new Error(`Invalid block height for median-time-past: ${height}`);
|
|
2366
2374
|
}
|
|
2367
|
-
const hashResponse = await
|
|
2375
|
+
const hashResponse = await chunkOMPDPBT5_cjs.baseFetch(`${this.baseUrl}/block-height/${height}`);
|
|
2368
2376
|
if (!hashResponse.ok) {
|
|
2369
2377
|
throw new Error(
|
|
2370
2378
|
`Failed to get block hash at height ${height}: ${hashResponse.statusText}`
|
|
@@ -2372,7 +2380,7 @@ var EsploraProvider = class {
|
|
|
2372
2380
|
}
|
|
2373
2381
|
const hash = (await hashResponse.text()).trim();
|
|
2374
2382
|
if (!hash) throw new Error(`No block hash returned at height ${height}`);
|
|
2375
|
-
const blockResponse = await
|
|
2383
|
+
const blockResponse = await chunkOMPDPBT5_cjs.baseFetch(`${this.baseUrl}/block/${hash}`);
|
|
2376
2384
|
if (!blockResponse.ok) {
|
|
2377
2385
|
throw new Error(`Failed to get block ${hash}: ${blockResponse.statusText}`);
|
|
2378
2386
|
}
|
|
@@ -2383,7 +2391,7 @@ var EsploraProvider = class {
|
|
|
2383
2391
|
return block.mediantime;
|
|
2384
2392
|
}
|
|
2385
2393
|
async broadcastPackage(parent, child) {
|
|
2386
|
-
const response = await
|
|
2394
|
+
const response = await chunkOMPDPBT5_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
|
|
2387
2395
|
method: "POST",
|
|
2388
2396
|
headers: {
|
|
2389
2397
|
"Content-Type": "application/json"
|
|
@@ -2399,7 +2407,7 @@ var EsploraProvider = class {
|
|
|
2399
2407
|
return result;
|
|
2400
2408
|
}
|
|
2401
2409
|
async broadcastTx(tx) {
|
|
2402
|
-
const response = await
|
|
2410
|
+
const response = await chunkOMPDPBT5_cjs.baseFetch(`${this.baseUrl}/tx`, {
|
|
2403
2411
|
method: "POST",
|
|
2404
2412
|
headers: {
|
|
2405
2413
|
"Content-Type": "text/plain"
|
|
@@ -2571,7 +2579,7 @@ function findP2AOutput(tx) {
|
|
|
2571
2579
|
var CHILD_DUST_AMOUNT = 546;
|
|
2572
2580
|
function buildAnchorChild(params) {
|
|
2573
2581
|
const { parent, feeRate, fundingCoins, changeAddress, tapInternalKey, network } = params;
|
|
2574
|
-
const child = new
|
|
2582
|
+
const child = new chunkOMPDPBT5_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
|
|
2575
2583
|
const anchor = findP2AOutput(parent);
|
|
2576
2584
|
child.addInput(anchor);
|
|
2577
2585
|
const estimator = TxWeightEstimator.create().addP2AInput();
|
|
@@ -2620,7 +2628,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
|
|
|
2620
2628
|
);
|
|
2621
2629
|
}
|
|
2622
2630
|
function buildForfeitTxWithOutput(inputs, output, txLocktime) {
|
|
2623
|
-
const tx = new
|
|
2631
|
+
const tx = new chunkOMPDPBT5_cjs.Transaction({
|
|
2624
2632
|
version: 3,
|
|
2625
2633
|
lockTime: txLocktime
|
|
2626
2634
|
});
|
|
@@ -2647,7 +2655,7 @@ function validateConnectorsTxGraph(settlementTxB64, connectorsGraph) {
|
|
|
2647
2655
|
connectorsGraph.validate();
|
|
2648
2656
|
if (connectorsGraph.root.inputsLength !== 1) throw ErrNumberOfInputs;
|
|
2649
2657
|
const rootInput = connectorsGraph.root.getInput(0);
|
|
2650
|
-
const settlementTx =
|
|
2658
|
+
const settlementTx = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(settlementTxB64));
|
|
2651
2659
|
if (settlementTx.outputsLength <= BATCH_OUTPUT_CONNECTORS_INDEX)
|
|
2652
2660
|
throw ErrInvalidSettlementTxOutputs;
|
|
2653
2661
|
const expectedRootTxid = settlementTx.id;
|
|
@@ -2696,7 +2704,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
|
|
|
2696
2704
|
if (previousScriptKey.length !== 32) {
|
|
2697
2705
|
throw new Error(`parent output ${childIndex} has invalid script`);
|
|
2698
2706
|
}
|
|
2699
|
-
const cosigners =
|
|
2707
|
+
const cosigners = chunkOMPDPBT5_cjs.getArkPsbtFields(child.root, 0, chunkOMPDPBT5_cjs.CosignerPublicKey);
|
|
2700
2708
|
if (cosigners.length === 0) {
|
|
2701
2709
|
throw ErrMissingCosignersPublicKeys;
|
|
2702
2710
|
}
|
|
@@ -2754,7 +2762,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
2754
2762
|
return new _EmulatorPacket(entries);
|
|
2755
2763
|
}
|
|
2756
2764
|
static fromBytes(data) {
|
|
2757
|
-
const reader = new
|
|
2765
|
+
const reader = new chunk3NALVGMJ_cjs.BufferReader(data);
|
|
2758
2766
|
const entryCount = reader.readCompactSize();
|
|
2759
2767
|
const entries = [];
|
|
2760
2768
|
for (let i = 0; i < entryCount; i++) {
|
|
@@ -2772,7 +2780,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
2772
2780
|
return _EmulatorPacket.PACKET_TYPE;
|
|
2773
2781
|
}
|
|
2774
2782
|
serialize() {
|
|
2775
|
-
const writer = new
|
|
2783
|
+
const writer = new chunk3NALVGMJ_cjs.BufferWriter();
|
|
2776
2784
|
writer.writeCompactSize(this.entries.length);
|
|
2777
2785
|
for (const entry of this.entries) {
|
|
2778
2786
|
writer.writeUint16LE(entry.vin);
|
|
@@ -2859,7 +2867,7 @@ var Extension = class _Extension {
|
|
|
2859
2867
|
`expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
|
|
2860
2868
|
);
|
|
2861
2869
|
}
|
|
2862
|
-
const reader = new
|
|
2870
|
+
const reader = new chunk3NALVGMJ_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
|
|
2863
2871
|
const packets = [];
|
|
2864
2872
|
while (reader.remaining() > 0) {
|
|
2865
2873
|
const packetType = reader.readByte();
|
|
@@ -2932,7 +2940,7 @@ var Extension = class _Extension {
|
|
|
2932
2940
|
* getAssetPacket returns the embedded Packet, or null if not present.
|
|
2933
2941
|
*/
|
|
2934
2942
|
getAssetPacket() {
|
|
2935
|
-
return this.packets.find((p) => p instanceof
|
|
2943
|
+
return this.packets.find((p) => p instanceof chunk3NALVGMJ_cjs.Packet) ?? null;
|
|
2936
2944
|
}
|
|
2937
2945
|
/**
|
|
2938
2946
|
* getEmulatorPacket returns the embedded EmulatorPacket, or null if not present.
|
|
@@ -2956,8 +2964,8 @@ var Extension = class _Extension {
|
|
|
2956
2964
|
};
|
|
2957
2965
|
function parsePacket(packetType, data) {
|
|
2958
2966
|
switch (packetType) {
|
|
2959
|
-
case
|
|
2960
|
-
return
|
|
2967
|
+
case chunk3NALVGMJ_cjs.Packet.PACKET_TYPE:
|
|
2968
|
+
return chunk3NALVGMJ_cjs.Packet.fromBytes(data);
|
|
2961
2969
|
case EmulatorPacket.PACKET_TYPE:
|
|
2962
2970
|
return EmulatorPacket.fromBytes(data);
|
|
2963
2971
|
default:
|
|
@@ -3004,22 +3012,22 @@ function buildOpReturnScript(data) {
|
|
|
3004
3012
|
}
|
|
3005
3013
|
return script;
|
|
3006
3014
|
}
|
|
3007
|
-
var ErrOffchainOutputNotFound = (address) => new
|
|
3008
|
-
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new
|
|
3015
|
+
var ErrOffchainOutputNotFound = (address) => new chunkOMPDPBT5_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
|
|
3016
|
+
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
|
|
3009
3017
|
`invalid asset output amount for ${assetId}: got ${got}, want ${want}`
|
|
3010
3018
|
);
|
|
3011
|
-
var ErrAssetGroupNotFound = (assetId) => new
|
|
3012
|
-
var ErrAssetOutputNotFound = (assetId, outputIndex) => new
|
|
3019
|
+
var ErrAssetGroupNotFound = (assetId) => new chunkOMPDPBT5_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
|
|
3020
|
+
var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
|
|
3013
3021
|
`asset output not found in asset group ${assetId} at index ${outputIndex}`
|
|
3014
3022
|
);
|
|
3015
|
-
var ErrOnchainOutputNotFound = (address) => new
|
|
3016
|
-
var ErrUnvalidatedOffchainOutput = (address) => new
|
|
3023
|
+
var ErrOnchainOutputNotFound = (address) => new chunkOMPDPBT5_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
|
|
3024
|
+
var ErrUnvalidatedOffchainOutput = (address) => new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
|
|
3017
3025
|
`offchain output ${address} cannot be validated: virtual output tree signing did not run`
|
|
3018
3026
|
);
|
|
3019
|
-
var ErrIntentOutputNotFound = (index, kind) => new
|
|
3027
|
+
var ErrIntentOutputNotFound = (index, kind) => new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
|
|
3020
3028
|
`${kind} output ${index} of the proof is not present in what the server built`
|
|
3021
3029
|
);
|
|
3022
|
-
var ErrUnvalidatedIntentOutput = (index) => new
|
|
3030
|
+
var ErrUnvalidatedIntentOutput = (index) => new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
|
|
3023
3031
|
`offchain output ${index} of the proof cannot be validated: virtual output tree signing did not run`
|
|
3024
3032
|
);
|
|
3025
3033
|
var ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
|
|
@@ -3028,7 +3036,7 @@ var ErrInvalidOffchainOutputAmount = (address) => new Error(`invalid offchain ou
|
|
|
3028
3036
|
function assertFinalCommitmentMatchesValidated(finalCommitmentTx, validatedCommitmentTxid, context) {
|
|
3029
3037
|
if (!validatedCommitmentTxid) return;
|
|
3030
3038
|
if (finalCommitmentTx.id === validatedCommitmentTxid) return;
|
|
3031
|
-
throw new
|
|
3039
|
+
throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
|
|
3032
3040
|
`${context}: finalization commitment tx ${finalCommitmentTx.id} differs from the validated commitment tx ${validatedCommitmentTxid}`
|
|
3033
3041
|
);
|
|
3034
3042
|
}
|
|
@@ -3059,7 +3067,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
|
|
|
3059
3067
|
}
|
|
3060
3068
|
}
|
|
3061
3069
|
function declaredIntentOutputs(signedProof, onchainOutputIndexes) {
|
|
3062
|
-
const proof =
|
|
3070
|
+
const proof = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(signedProof));
|
|
3063
3071
|
const onchain = new Set(onchainOutputIndexes);
|
|
3064
3072
|
const declared = [];
|
|
3065
3073
|
for (let i = 0; i < proof.outputsLength; i++) {
|
|
@@ -3351,7 +3359,7 @@ function assetMintResolver() {
|
|
|
3351
3359
|
if (!tx.assets?.length || !tx.key.arkTxid) return void 0;
|
|
3352
3360
|
const minted = tx.assets.filter((a) => {
|
|
3353
3361
|
try {
|
|
3354
|
-
return base.hex.encode(
|
|
3362
|
+
return base.hex.encode(chunk3NALVGMJ_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
|
|
3355
3363
|
} catch {
|
|
3356
3364
|
return false;
|
|
3357
3365
|
}
|
|
@@ -3428,7 +3436,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3428
3436
|
const existing = inputsByAssetId.get(asset.assetId);
|
|
3429
3437
|
inputsByAssetId.set(asset.assetId, [
|
|
3430
3438
|
...existing ?? [],
|
|
3431
|
-
|
|
3439
|
+
chunk3NALVGMJ_cjs.AssetInput.create(inputIndex, asset.amount)
|
|
3432
3440
|
]);
|
|
3433
3441
|
}
|
|
3434
3442
|
}
|
|
@@ -3440,7 +3448,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3440
3448
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
3441
3449
|
outputsByAssetId.set(asset.assetId, [
|
|
3442
3450
|
...existing ?? [],
|
|
3443
|
-
|
|
3451
|
+
chunk3NALVGMJ_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
3444
3452
|
]);
|
|
3445
3453
|
}
|
|
3446
3454
|
}
|
|
@@ -3451,7 +3459,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3451
3459
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
3452
3460
|
outputsByAssetId.set(asset.assetId, [
|
|
3453
3461
|
...existing ?? [],
|
|
3454
|
-
|
|
3462
|
+
chunk3NALVGMJ_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
3455
3463
|
]);
|
|
3456
3464
|
}
|
|
3457
3465
|
}
|
|
@@ -3460,11 +3468,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3460
3468
|
for (const assetIdStr of allAssetIds) {
|
|
3461
3469
|
const inputs = inputsByAssetId.get(assetIdStr);
|
|
3462
3470
|
const outputs = outputsByAssetId.get(assetIdStr);
|
|
3463
|
-
const assetId =
|
|
3464
|
-
const group =
|
|
3471
|
+
const assetId = chunk3NALVGMJ_cjs.AssetId.fromString(assetIdStr);
|
|
3472
|
+
const group = chunk3NALVGMJ_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
|
|
3465
3473
|
groups.push(group);
|
|
3466
3474
|
}
|
|
3467
|
-
return
|
|
3475
|
+
return chunk3NALVGMJ_cjs.Packet.create(groups);
|
|
3468
3476
|
}
|
|
3469
3477
|
function selectCoinsWithAsset(coins, assetId, requiredAmount) {
|
|
3470
3478
|
const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
|
|
@@ -3595,14 +3603,14 @@ var toTimelock = (value) => ({
|
|
|
3595
3603
|
var toSeconds = (t) => t.type === "seconds" ? t.value : t.value * NOMINAL_BLOCK_SECONDS;
|
|
3596
3604
|
function assertTimelockInPolicy(timelock, policy, label, overrideOption) {
|
|
3597
3605
|
if (policy.requireSeconds && timelock.type === "blocks") {
|
|
3598
|
-
throw new
|
|
3606
|
+
throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
|
|
3599
3607
|
`${label} rejected: block-typed timelocks are not accepted (got ${timelock.value})`
|
|
3600
3608
|
);
|
|
3601
3609
|
}
|
|
3602
3610
|
const seconds = toSeconds(timelock);
|
|
3603
3611
|
if (seconds < policy.minSeconds) {
|
|
3604
3612
|
const remedy = overrideOption ? `; pass ${overrideOption}: ${seconds}n to Wallet.create to lower it` : "";
|
|
3605
|
-
throw new
|
|
3613
|
+
throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
|
|
3606
3614
|
`${label} rejected: ${timelock.value} ${timelock.type} is below the ${policy.minSeconds}s floor${remedy}`
|
|
3607
3615
|
);
|
|
3608
3616
|
}
|
|
@@ -3623,7 +3631,7 @@ function resolveBatchExpiryPolicy(network, overrides) {
|
|
|
3623
3631
|
}
|
|
3624
3632
|
function assertValidBatchExpiry(batchExpiry, policy) {
|
|
3625
3633
|
if (policy.advertisedVtxoTreeExpiry !== void 0 && batchExpiry !== policy.advertisedVtxoTreeExpiry) {
|
|
3626
|
-
throw new
|
|
3634
|
+
throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
|
|
3627
3635
|
`batch expiry rejected: ${batchExpiry} does not match the advertised vtxoTreeExpiry ${policy.advertisedVtxoTreeExpiry}`
|
|
3628
3636
|
);
|
|
3629
3637
|
}
|
|
@@ -3634,19 +3642,19 @@ function assertValidServerUnrollScript(checkpointTapscript, network, advertisedF
|
|
|
3634
3642
|
try {
|
|
3635
3643
|
script = chunkFLPWNMX3_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
|
|
3636
3644
|
} catch (e) {
|
|
3637
|
-
throw new
|
|
3645
|
+
throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
|
|
3638
3646
|
`checkpoint exit delay rejected: invalid checkpointTapscript from server (${e instanceof Error ? e.message : String(e)})`
|
|
3639
3647
|
);
|
|
3640
3648
|
}
|
|
3641
3649
|
if (advertisedForfeitPubkey !== void 0) {
|
|
3642
3650
|
const { pubkeys } = script.params;
|
|
3643
3651
|
if (pubkeys.length !== 1) {
|
|
3644
|
-
throw new
|
|
3652
|
+
throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
|
|
3645
3653
|
`checkpoint exit delay rejected: checkpointTapscript must commit to exactly one pubkey, got ${pubkeys.length} [${pubkeys.map(base.hex.encode).join(", ")}]`
|
|
3646
3654
|
);
|
|
3647
3655
|
}
|
|
3648
3656
|
if (!utils_js.equalBytes(pubkeys[0], advertisedForfeitPubkey)) {
|
|
3649
|
-
throw new
|
|
3657
|
+
throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
|
|
3650
3658
|
`checkpoint exit delay rejected: checkpointTapscript pubkey ${base.hex.encode(pubkeys[0])} does not match the advertised forfeitPubkey ${base.hex.encode(advertisedForfeitPubkey)}`
|
|
3651
3659
|
);
|
|
3652
3660
|
}
|
|
@@ -3701,7 +3709,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3701
3709
|
}
|
|
3702
3710
|
}
|
|
3703
3711
|
}
|
|
3704
|
-
const tx = new
|
|
3712
|
+
const tx = new chunkOMPDPBT5_cjs.Transaction({
|
|
3705
3713
|
version: 3,
|
|
3706
3714
|
lockTime: Number(lockTime)
|
|
3707
3715
|
});
|
|
@@ -3716,7 +3724,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3716
3724
|
},
|
|
3717
3725
|
tapLeafScript: [input.tapLeafScript]
|
|
3718
3726
|
});
|
|
3719
|
-
|
|
3727
|
+
chunkOMPDPBT5_cjs.setArkPsbtField(tx, i, chunkOMPDPBT5_cjs.VtxoTaprootTree, input.tapTree);
|
|
3720
3728
|
}
|
|
3721
3729
|
for (const output of outputs) {
|
|
3722
3730
|
tx.addOutput(output);
|
|
@@ -3862,7 +3870,7 @@ function verifyTapscriptSignatures(tx, inputIndex, requiredSigners, excludePubke
|
|
|
3862
3870
|
const sighashType = signature.length === 65 ? signature[64] : btcSigner.SigHash.DEFAULT;
|
|
3863
3871
|
const sig = signature.subarray(0, 64);
|
|
3864
3872
|
if (!allowedSighashTypes.includes(sighashType)) {
|
|
3865
|
-
const sighashName =
|
|
3873
|
+
const sighashName = chunkOMPDPBT5_cjs.formatSighash(sighashType);
|
|
3866
3874
|
throw new Error(
|
|
3867
3875
|
`Unallowed sighash type ${sighashName} for input ${inputIndex}, pubkey ${pubKeyHex}.`
|
|
3868
3876
|
);
|
|
@@ -3944,16 +3952,16 @@ function isValidArkAddress(address) {
|
|
|
3944
3952
|
}
|
|
3945
3953
|
function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, context) {
|
|
3946
3954
|
if (serverCheckpointTxs.length !== expectedCheckpoints.length) {
|
|
3947
|
-
throw new
|
|
3955
|
+
throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
|
|
3948
3956
|
`${context} returned ${serverCheckpointTxs.length} checkpoints, expected ${expectedCheckpoints.length}`
|
|
3949
3957
|
);
|
|
3950
3958
|
}
|
|
3951
3959
|
const byTxid = new Map(expectedCheckpoints.map((c) => [c.id, c]));
|
|
3952
3960
|
return serverCheckpointTxs.map((encoded, index) => {
|
|
3953
|
-
const server =
|
|
3961
|
+
const server = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
|
|
3954
3962
|
const local = byTxid.get(server.id);
|
|
3955
3963
|
if (!local) {
|
|
3956
|
-
throw new
|
|
3964
|
+
throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
|
|
3957
3965
|
`${context} checkpoint ${index} txid ${server.id} does not match any submitted checkpoint`
|
|
3958
3966
|
);
|
|
3959
3967
|
}
|
|
@@ -3963,14 +3971,14 @@ function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, contex
|
|
|
3963
3971
|
}
|
|
3964
3972
|
function assertSubmittedArkTxid(response, signedArkTx, context) {
|
|
3965
3973
|
if (response.arkTxid !== signedArkTx.id) {
|
|
3966
|
-
throw new
|
|
3974
|
+
throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
|
|
3967
3975
|
`${context} returned ark txid ${response.arkTxid}, expected ${signedArkTx.id}`
|
|
3968
3976
|
);
|
|
3969
3977
|
}
|
|
3970
3978
|
if (response.finalArkTx === void 0) return;
|
|
3971
|
-
const finalTxid =
|
|
3979
|
+
const finalTxid = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
|
|
3972
3980
|
if (finalTxid !== signedArkTx.id) {
|
|
3973
|
-
throw new
|
|
3981
|
+
throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
|
|
3974
3982
|
`${context} returned final ark tx ${finalTxid}, expected ${signedArkTx.id}`
|
|
3975
3983
|
);
|
|
3976
3984
|
}
|
|
@@ -3989,13 +3997,13 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeys, co
|
|
|
3989
3997
|
(key) => base.hex.encode(chunkJFJNB7ZH_cjs.toXOnly(key, "leaf key"))
|
|
3990
3998
|
);
|
|
3991
3999
|
} catch (error) {
|
|
3992
|
-
throw new
|
|
4000
|
+
throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
|
|
3993
4001
|
`${context}: input ${inputIndex} spend leaf cannot be decoded (${error instanceof Error ? error.message : String(error)})`
|
|
3994
4002
|
);
|
|
3995
4003
|
}
|
|
3996
4004
|
const signer = leafPubkeys.find((key) => serverPubkeys.has(key));
|
|
3997
4005
|
if (!signer) {
|
|
3998
|
-
throw new
|
|
4006
|
+
throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
|
|
3999
4007
|
`${context}: input ${inputIndex} spend leaf names no signer key the server advertises`
|
|
4000
4008
|
);
|
|
4001
4009
|
}
|
|
@@ -4009,7 +4017,7 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeys, co
|
|
|
4009
4017
|
payment_js.tapLeafHash(script)
|
|
4010
4018
|
);
|
|
4011
4019
|
} catch (error) {
|
|
4012
|
-
throw new
|
|
4020
|
+
throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
|
|
4013
4021
|
`${context}: input ${inputIndex} is not signed by the server on the leaf being spent (${error instanceof Error ? error.message : String(error)})`
|
|
4014
4022
|
);
|
|
4015
4023
|
}
|
|
@@ -4018,20 +4026,20 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
4018
4026
|
const byOutpoint = new Map(inputs.map((input) => [`${input.txid}:${input.vout}`, input]));
|
|
4019
4027
|
for (const [index, checkpoint] of checkpoints.entries()) {
|
|
4020
4028
|
if (checkpoint.inputsLength !== 1) {
|
|
4021
|
-
throw new
|
|
4029
|
+
throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
|
|
4022
4030
|
`${context}: checkpoint ${index} spends ${checkpoint.inputsLength} inputs, expected 1`
|
|
4023
4031
|
);
|
|
4024
4032
|
}
|
|
4025
4033
|
const spent = checkpoint.getInput(0);
|
|
4026
4034
|
if (!spent.txid || spent.index === void 0) {
|
|
4027
|
-
throw new
|
|
4035
|
+
throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
|
|
4028
4036
|
`${context}: checkpoint ${index} has no input outpoint`
|
|
4029
4037
|
);
|
|
4030
4038
|
}
|
|
4031
4039
|
const outpoint = `${base.hex.encode(spent.txid)}:${spent.index}`;
|
|
4032
4040
|
const input = byOutpoint.get(outpoint);
|
|
4033
4041
|
if (!input) {
|
|
4034
|
-
throw new
|
|
4042
|
+
throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
|
|
4035
4043
|
`${context}: checkpoint ${index} spends ${outpoint}, which is not one of the requested virtual outputs`
|
|
4036
4044
|
);
|
|
4037
4045
|
}
|
|
@@ -4039,7 +4047,7 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
4039
4047
|
(unroll) => buildCheckpointTx(input, unroll).tx.id === checkpoint.id
|
|
4040
4048
|
);
|
|
4041
4049
|
if (!rebuilt) {
|
|
4042
|
-
throw new
|
|
4050
|
+
throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
|
|
4043
4051
|
`${context}: checkpoint ${index} txid ${checkpoint.id} differs from the checkpoint built locally for ${outpoint}`
|
|
4044
4052
|
);
|
|
4045
4053
|
}
|
|
@@ -4068,9 +4076,9 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
4068
4076
|
if (!oneShot) {
|
|
4069
4077
|
matched.forEach(({ server }, index) => {
|
|
4070
4078
|
try {
|
|
4071
|
-
|
|
4079
|
+
chunkOMPDPBT5_cjs.assertAllowedSighashTypes(server);
|
|
4072
4080
|
} catch (error) {
|
|
4073
|
-
throw new
|
|
4081
|
+
throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
|
|
4074
4082
|
`submitTx checkpoint ${index}: ${error instanceof Error ? error.message : String(error)}`
|
|
4075
4083
|
);
|
|
4076
4084
|
}
|
|
@@ -4079,11 +4087,11 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
4079
4087
|
const verify = options?.verifyServerSignatures;
|
|
4080
4088
|
if (verify) {
|
|
4081
4089
|
if (response.finalArkTx === void 0) {
|
|
4082
|
-
throw new
|
|
4090
|
+
throw new chunkOMPDPBT5_cjs.ServerResponseMismatchError(
|
|
4083
4091
|
"submitTx: server returned no final ark tx to verify its signatures against"
|
|
4084
4092
|
);
|
|
4085
4093
|
}
|
|
4086
|
-
const finalArkTx =
|
|
4094
|
+
const finalArkTx = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
|
|
4087
4095
|
const serverPubkeys = new Set(
|
|
4088
4096
|
[verify.serverPubkey, ...verify.deprecatedServerPubkeys ?? []].map(
|
|
4089
4097
|
(key) => base.hex.encode(chunkJFJNB7ZH_cjs.toXOnly(key, "server key"))
|
|
@@ -4134,19 +4142,19 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
4134
4142
|
return result;
|
|
4135
4143
|
}
|
|
4136
4144
|
function carryConditionWitness(ours, server) {
|
|
4137
|
-
if (
|
|
4138
|
-
const [witness] =
|
|
4139
|
-
if (witness)
|
|
4145
|
+
if (chunkOMPDPBT5_cjs.getArkPsbtFields(server, 0, chunkOMPDPBT5_cjs.ConditionWitness).length > 0) return;
|
|
4146
|
+
const [witness] = chunkOMPDPBT5_cjs.getArkPsbtFields(ours, 0, chunkOMPDPBT5_cjs.ConditionWitness);
|
|
4147
|
+
if (witness) chunkOMPDPBT5_cjs.setArkPsbtField(server, 0, chunkOMPDPBT5_cjs.ConditionWitness, witness);
|
|
4140
4148
|
}
|
|
4141
4149
|
function withArkInputWitness(checkpoint, signedArkTx) {
|
|
4142
|
-
if (
|
|
4150
|
+
if (chunkOMPDPBT5_cjs.getArkPsbtFields(checkpoint, 0, chunkOMPDPBT5_cjs.ConditionWitness).length > 0) return checkpoint;
|
|
4143
4151
|
for (let i = 0; i < signedArkTx.inputsLength; i++) {
|
|
4144
4152
|
const { txid } = signedArkTx.getInput(i);
|
|
4145
4153
|
if (!txid || base.hex.encode(txid) !== checkpoint.id) continue;
|
|
4146
|
-
const [witness] =
|
|
4154
|
+
const [witness] = chunkOMPDPBT5_cjs.getArkPsbtFields(signedArkTx, i, chunkOMPDPBT5_cjs.ConditionWitness);
|
|
4147
4155
|
if (!witness) return checkpoint;
|
|
4148
4156
|
const carried = checkpoint.clone();
|
|
4149
|
-
|
|
4157
|
+
chunkOMPDPBT5_cjs.setArkPsbtField(carried, 0, chunkOMPDPBT5_cjs.ConditionWitness, witness);
|
|
4150
4158
|
return carried;
|
|
4151
4159
|
}
|
|
4152
4160
|
return checkpoint;
|
|
@@ -4187,7 +4195,7 @@ async function submitViaEmulator(emulator, offchainTx, signer, opts) {
|
|
|
4187
4195
|
base.base64.encode(arkTx.toPSBT()),
|
|
4188
4196
|
checkpoints.map((c) => base.base64.encode(c.toPSBT()))
|
|
4189
4197
|
);
|
|
4190
|
-
const txid =
|
|
4198
|
+
const txid = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(res.signedArkTx)).id;
|
|
4191
4199
|
assertSubmittedArkTxid({ arkTxid: txid }, arkTx, "emulator submitTx");
|
|
4192
4200
|
return { txid, signedArkTx: res.signedArkTx, signedCheckpointTxs: res.signedCheckpointTxs };
|
|
4193
4201
|
}
|
|
@@ -4195,12 +4203,12 @@ function claimWithPreimageIdentity(identity, preimage) {
|
|
|
4195
4203
|
return {
|
|
4196
4204
|
...identity,
|
|
4197
4205
|
sign: async (tx, inputIndexes) => {
|
|
4198
|
-
const signed =
|
|
4206
|
+
const signed = chunkOMPDPBT5_cjs.Transaction.fromPSBT(
|
|
4199
4207
|
(await identity.sign(tx.clone(), inputIndexes)).toPSBT()
|
|
4200
4208
|
);
|
|
4201
4209
|
const indexes = inputIndexes ?? Array.from({ length: signed.inputsLength }, (_, i) => i);
|
|
4202
4210
|
for (const index of indexes) {
|
|
4203
|
-
|
|
4211
|
+
chunkOMPDPBT5_cjs.setArkPsbtField(signed, index, chunkOMPDPBT5_cjs.ConditionWitness, [preimage]);
|
|
4204
4212
|
}
|
|
4205
4213
|
return signed;
|
|
4206
4214
|
}
|
|
@@ -4209,7 +4217,7 @@ function claimWithPreimageIdentity(identity, preimage) {
|
|
|
4209
4217
|
|
|
4210
4218
|
// src/contracts/scope.ts
|
|
4211
4219
|
function scopeOf(contract) {
|
|
4212
|
-
return contract.scope ??
|
|
4220
|
+
return contract.scope ?? chunkMQUATTIM_cjs.contractHandlers.get(contract.type)?.defaultScope ?? "offchain";
|
|
4213
4221
|
}
|
|
4214
4222
|
function isOnchainScoped(contract) {
|
|
4215
4223
|
return scopeOf(contract) !== "offchain";
|
|
@@ -4286,9 +4294,9 @@ async function collectScriptVtxos(repository, script, options) {
|
|
|
4286
4294
|
return [...byOutpoint.values()].map((row) => row.vtxo);
|
|
4287
4295
|
}
|
|
4288
4296
|
function unspentScriptVtxos(rows, copies) {
|
|
4289
|
-
const spent = copies.filter((copy) =>
|
|
4297
|
+
const spent = copies.filter((copy) => chunkOMPDPBT5_cjs.isVtxoSpent(copy.vtxo));
|
|
4290
4298
|
return rows.filter(
|
|
4291
|
-
(row) => !
|
|
4299
|
+
(row) => !chunkOMPDPBT5_cjs.isVtxoSpent(row.vtxo) && !spent.some(
|
|
4292
4300
|
(copy) => copy.address !== row.address && copy.vtxo.txid === row.vtxo.txid && copy.vtxo.vout === row.vtxo.vout && shouldReplaceScriptVtxo(row, copy)
|
|
4293
4301
|
)
|
|
4294
4302
|
);
|
|
@@ -4345,7 +4353,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
|
|
|
4345
4353
|
};
|
|
4346
4354
|
}
|
|
4347
4355
|
function deriveContractTapscripts(contract) {
|
|
4348
|
-
const handler =
|
|
4356
|
+
const handler = chunkMQUATTIM_cjs.contractHandlers.get(contract.type);
|
|
4349
4357
|
if (!handler) {
|
|
4350
4358
|
throw new Error(`No handler for contract type '${contract.type}'`);
|
|
4351
4359
|
}
|
|
@@ -4548,8 +4556,8 @@ function checkSaveVtxosForScript(backend, key, vtxos) {
|
|
|
4548
4556
|
}
|
|
4549
4557
|
async function getVtxosForContract(repo, contract, options) {
|
|
4550
4558
|
const vtxos = repo.getVtxosForScriptPage ? await collectScriptVtxos(repo, contract.script, options) : filterVtxosForScript(await collectVtxos(repo, contract.address), contract.script);
|
|
4551
|
-
const normalized = vtxos.map(
|
|
4552
|
-
return options?.unspentOnly ? normalized.filter((vtxo) => !
|
|
4559
|
+
const normalized = vtxos.map(chunkOMPDPBT5_cjs.normalizeVtxo);
|
|
4560
|
+
return options?.unspentOnly ? normalized.filter((vtxo) => !chunkOMPDPBT5_cjs.isVtxoSpent(vtxo)) : normalized;
|
|
4553
4561
|
}
|
|
4554
4562
|
async function hasVtxosForContract(repo, contract) {
|
|
4555
4563
|
if (repo.getVtxosForScriptPage) {
|
|
@@ -4631,7 +4639,7 @@ async function saveVtxosForContract(repo, contract, vtxos) {
|
|
|
4631
4639
|
// src/contracts/onchainCoins.ts
|
|
4632
4640
|
var MIGRATED_KEY = "legacyUtxosMigrated";
|
|
4633
4641
|
function createScript(contract) {
|
|
4634
|
-
const handler =
|
|
4642
|
+
const handler = chunkMQUATTIM_cjs.contractHandlers.get(contract.type);
|
|
4635
4643
|
if (!handler) throw new Error(`No handler for contract type '${contract.type}'`);
|
|
4636
4644
|
return handler.createScript(contract.params);
|
|
4637
4645
|
}
|
|
@@ -4690,7 +4698,7 @@ async function migrateLegacyUtxos(deps) {
|
|
|
4690
4698
|
let migrated = 0;
|
|
4691
4699
|
for (const contract of await collectContracts(contractRepository)) {
|
|
4692
4700
|
if (!isOnchainScoped(contract)) continue;
|
|
4693
|
-
if (!
|
|
4701
|
+
if (!chunkMQUATTIM_cjs.contractHandlers.has(contract.type)) {
|
|
4694
4702
|
console.warn("Skipping legacy utxos of a contract with no handler", contract.type);
|
|
4695
4703
|
continue;
|
|
4696
4704
|
}
|
|
@@ -4716,7 +4724,7 @@ var DEFAULT_COSIGN_MARGIN_BLOCKS = 6;
|
|
|
4716
4724
|
var MAX_COSIGN_INPUTS = 64;
|
|
4717
4725
|
var ONCHAIN_RENEW_WINDOW_BLOCKS = 144;
|
|
4718
4726
|
function exitCsvOf(contract) {
|
|
4719
|
-
const sequence =
|
|
4727
|
+
const sequence = chunkMQUATTIM_cjs.exitSequence(contract);
|
|
4720
4728
|
return sequence === void 0 ? void 0 : chunkFLPWNMX3_cjs.sequenceToTimelock(sequence);
|
|
4721
4729
|
}
|
|
4722
4730
|
var ONCHAIN_COSIGN_PREFLIGHT_PREFIX = "Onchain cosign preflight failed: ";
|
|
@@ -4734,7 +4742,7 @@ function prepareOwnedInput(tx, { index, coin, path, tapTree }) {
|
|
|
4734
4742
|
tx.updateInput(index, { tapLeafScript: void 0, tapScriptSig: void 0 }, true);
|
|
4735
4743
|
}
|
|
4736
4744
|
const kept = unknown?.filter(
|
|
4737
|
-
(u) =>
|
|
4745
|
+
(u) => chunkOMPDPBT5_cjs.VtxoTaprootTree.decode(u) === null && chunkOMPDPBT5_cjs.ConditionWitness.decode(u) === null
|
|
4738
4746
|
);
|
|
4739
4747
|
if (kept && kept.length !== unknown.length) {
|
|
4740
4748
|
tx.updateInput(index, { unknown: void 0 }, true);
|
|
@@ -4745,9 +4753,9 @@ function prepareOwnedInput(tx, { index, coin, path, tapTree }) {
|
|
|
4745
4753
|
tapLeafScript: [path.leaf],
|
|
4746
4754
|
sighashType: btcSigner.SigHash.DEFAULT
|
|
4747
4755
|
});
|
|
4748
|
-
|
|
4756
|
+
chunkOMPDPBT5_cjs.setArkPsbtField(tx, index, chunkOMPDPBT5_cjs.VtxoTaprootTree, tapTree);
|
|
4749
4757
|
if (path.extraWitness?.length) {
|
|
4750
|
-
|
|
4758
|
+
chunkOMPDPBT5_cjs.setArkPsbtField(tx, index, chunkOMPDPBT5_cjs.ConditionWitness, path.extraWitness);
|
|
4751
4759
|
}
|
|
4752
4760
|
}
|
|
4753
4761
|
function emulatorInputIndexes(tx) {
|
|
@@ -4794,7 +4802,7 @@ function isBoardingContract(contract, boardingCsv) {
|
|
|
4794
4802
|
if (!isOnchainScoped(contract)) return false;
|
|
4795
4803
|
if (contract.type === "boarding") return true;
|
|
4796
4804
|
if (contract.type !== "default" || scopeOf(contract) !== "both") return false;
|
|
4797
|
-
return
|
|
4805
|
+
return chunkMQUATTIM_cjs.exitSequence(contract) === chunkFLPWNMX3_cjs.timelockToSequence(boardingCsv);
|
|
4798
4806
|
}
|
|
4799
4807
|
function needsOnchainSweep(coin, contract, boardingCsv, tip, marginBlocks = DEFAULT_COSIGN_MARGIN_BLOCKS) {
|
|
4800
4808
|
if (!isBoardingContract(contract, boardingCsv) || !isExplorerCoin(coin)) return false;
|
|
@@ -4806,7 +4814,7 @@ function needsOnchainSweep(coin, contract, boardingCsv, tip, marginBlocks = DEFA
|
|
|
4806
4814
|
return left.remaining > margin && left.remaining <= margin + window2;
|
|
4807
4815
|
}
|
|
4808
4816
|
function finalizeOwnedInput(tx, index) {
|
|
4809
|
-
const condition =
|
|
4817
|
+
const condition = chunkOMPDPBT5_cjs.getArkPsbtFields(tx, index, chunkOMPDPBT5_cjs.ConditionWitness)[0];
|
|
4810
4818
|
if (!condition) {
|
|
4811
4819
|
tx.finalizeIdx(index);
|
|
4812
4820
|
return;
|
|
@@ -4829,27 +4837,27 @@ var DEFINITE_COSIGN_REJECTIONS = /* @__PURE__ */ new Set([
|
|
|
4829
4837
|
"TX_TOO_LARGE"
|
|
4830
4838
|
]);
|
|
4831
4839
|
function isCosignRejectedAfterSigning(e) {
|
|
4832
|
-
return e instanceof
|
|
4840
|
+
return e instanceof chunkOMPDPBT5_cjs.OnchainCosignRejectedError && !isCosignFallback(e);
|
|
4833
4841
|
}
|
|
4834
4842
|
function isCosignFallback(e) {
|
|
4835
|
-
if (e instanceof
|
|
4843
|
+
if (e instanceof chunkOMPDPBT5_cjs.OnchainCosignRejectedError) {
|
|
4836
4844
|
return !!e.arkErrorName && DEFINITE_COSIGN_REJECTIONS.has(e.arkErrorName);
|
|
4837
4845
|
}
|
|
4838
|
-
return e instanceof
|
|
4846
|
+
return e instanceof chunkOMPDPBT5_cjs.OnchainCosignUnsupportedError || e instanceof OnchainCosignPreflightError;
|
|
4839
4847
|
}
|
|
4840
4848
|
function rehydrateCosignError(e) {
|
|
4841
|
-
if (!(e instanceof Error) || e instanceof
|
|
4849
|
+
if (!(e instanceof Error) || e instanceof chunkOMPDPBT5_cjs.OnchainCosignRejectedError || e instanceof chunkOMPDPBT5_cjs.OnchainCosignAmbiguousError || e instanceof chunkOMPDPBT5_cjs.OnchainCosignUnsupportedError || e instanceof OnchainCosignPreflightError) {
|
|
4842
4850
|
return e;
|
|
4843
4851
|
}
|
|
4844
4852
|
const { message } = e;
|
|
4845
|
-
if (message.startsWith(
|
|
4846
|
-
const rest = message.slice(
|
|
4853
|
+
if (message.startsWith(chunkOMPDPBT5_cjs.ONCHAIN_COSIGN_REJECTED_PREFIX)) {
|
|
4854
|
+
const rest = message.slice(chunkOMPDPBT5_cjs.ONCHAIN_COSIGN_REJECTED_PREFIX.length);
|
|
4847
4855
|
const named = rest.match(/^\[([A-Z0-9_]+)\] ([\s\S]*)$/);
|
|
4848
|
-
return named ? new
|
|
4856
|
+
return named ? new chunkOMPDPBT5_cjs.OnchainCosignRejectedError(named[2], named[1]) : new chunkOMPDPBT5_cjs.OnchainCosignRejectedError(rest);
|
|
4849
4857
|
}
|
|
4850
|
-
if (message.startsWith(
|
|
4851
|
-
return new
|
|
4852
|
-
message.slice(
|
|
4858
|
+
if (message.startsWith(chunkOMPDPBT5_cjs.ONCHAIN_COSIGN_AMBIGUOUS_PREFIX)) {
|
|
4859
|
+
return new chunkOMPDPBT5_cjs.OnchainCosignAmbiguousError(
|
|
4860
|
+
message.slice(chunkOMPDPBT5_cjs.ONCHAIN_COSIGN_AMBIGUOUS_PREFIX.length)
|
|
4853
4861
|
);
|
|
4854
4862
|
}
|
|
4855
4863
|
if (message.startsWith(ONCHAIN_COSIGN_PREFLIGHT_PREFIX)) {
|
|
@@ -4857,8 +4865,8 @@ function rehydrateCosignError(e) {
|
|
|
4857
4865
|
message.slice(ONCHAIN_COSIGN_PREFLIGHT_PREFIX.length)
|
|
4858
4866
|
);
|
|
4859
4867
|
}
|
|
4860
|
-
if (message.startsWith(
|
|
4861
|
-
return new
|
|
4868
|
+
if (message.startsWith(chunkOMPDPBT5_cjs.ONCHAIN_COSIGN_UNSUPPORTED_PREFIX))
|
|
4869
|
+
return new chunkOMPDPBT5_cjs.OnchainCosignUnsupportedError();
|
|
4862
4870
|
return e;
|
|
4863
4871
|
}
|
|
4864
4872
|
function estimateOnchainCosignFee(nIn, nOut, feeRate) {
|
|
@@ -4874,13 +4882,13 @@ async function submitOnchainSpend(tx, arkInputs, deps) {
|
|
|
4874
4882
|
throw new Error("emulator inputs present but no emulator provider configured");
|
|
4875
4883
|
}
|
|
4876
4884
|
const { signedTx } = await deps.emulator.submitOnchainTx(base.base64.encode(tx.toPSBT()));
|
|
4877
|
-
tx =
|
|
4885
|
+
tx = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(signedTx));
|
|
4878
4886
|
}
|
|
4879
4887
|
if (arkInputs.size > 0) {
|
|
4880
4888
|
if (!deps.arkProvider) {
|
|
4881
4889
|
throw new Error("arkd-cosigned inputs present but no arkProvider configured");
|
|
4882
4890
|
}
|
|
4883
|
-
if (!deps.arkProvider.cosignOnchainTx) throw new
|
|
4891
|
+
if (!deps.arkProvider.cosignOnchainTx) throw new chunkOMPDPBT5_cjs.OnchainCosignUnsupportedError();
|
|
4884
4892
|
return deps.arkProvider.cosignOnchainTx(base.base64.encode(tx.toPSBT()));
|
|
4885
4893
|
}
|
|
4886
4894
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
@@ -5031,7 +5039,7 @@ function parseProgram(text, env) {
|
|
|
5031
5039
|
|
|
5032
5040
|
// src/contracts/spendability.ts
|
|
5033
5041
|
function isContractGenericallySpendable(contract) {
|
|
5034
|
-
return
|
|
5042
|
+
return chunkMQUATTIM_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
|
|
5035
5043
|
}
|
|
5036
5044
|
function gatedContracts(contracts) {
|
|
5037
5045
|
const gated = /* @__PURE__ */ new Map();
|
|
@@ -5053,7 +5061,7 @@ function gateExclusion(gated) {
|
|
|
5053
5061
|
return (vtxo) => {
|
|
5054
5062
|
const type = gatedTypeOf(vtxo, gated);
|
|
5055
5063
|
if (type === void 0) return void 0;
|
|
5056
|
-
if (!
|
|
5064
|
+
if (!chunkMQUATTIM_cjs.contractHandlers.has(type)) {
|
|
5057
5065
|
return `at ${vtxo.script} (contract type '${type}') has no handler registered in this build`;
|
|
5058
5066
|
}
|
|
5059
5067
|
return `at ${vtxo.script} (contract type '${type}') is not generically spendable`;
|
|
@@ -5089,7 +5097,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
|
|
|
5089
5097
|
continue;
|
|
5090
5098
|
}
|
|
5091
5099
|
for (const v of vtxos) {
|
|
5092
|
-
if (!
|
|
5100
|
+
if (!chunkOMPDPBT5_cjs.isVtxoSpent(v) && !v.isSwept && !v.isUnrolled) {
|
|
5093
5101
|
out.add(`${v.txid}:${v.vout}`);
|
|
5094
5102
|
}
|
|
5095
5103
|
}
|
|
@@ -5131,14 +5139,14 @@ function byValueDescending(vtxos) {
|
|
|
5131
5139
|
return [...vtxos].sort((a, b) => b.value - a.value);
|
|
5132
5140
|
}
|
|
5133
5141
|
async function fetchTimeHeight(wallet) {
|
|
5134
|
-
return
|
|
5142
|
+
return chunkOMPDPBT5_cjs.resolveTimeHeight(wallet.onchainProvider);
|
|
5135
5143
|
}
|
|
5136
5144
|
function heldVtxosOf(wallet) {
|
|
5137
5145
|
const held = wallet.getHeldVtxos;
|
|
5138
5146
|
return typeof held === "function" ? held.call(wallet) : Promise.resolve([]);
|
|
5139
5147
|
}
|
|
5140
5148
|
function canMigrateBySend(vtxo, now) {
|
|
5141
|
-
if (!
|
|
5149
|
+
if (!chunkOMPDPBT5_cjs.canSpendOffchain(vtxo, now)) return false;
|
|
5142
5150
|
return vtxo.expiresAt !== void 0 || vtxo.expiresAtHeight !== void 0;
|
|
5143
5151
|
}
|
|
5144
5152
|
function byExpiryAscending(vtxos, now) {
|
|
@@ -5146,7 +5154,7 @@ function byExpiryAscending(vtxos, now) {
|
|
|
5146
5154
|
if (vtxo.isSwept) return -Infinity;
|
|
5147
5155
|
if (vtxo.expiresAt !== void 0) return vtxo.expiresAt.getTime();
|
|
5148
5156
|
if (vtxo.expiresAtHeight !== void 0) {
|
|
5149
|
-
return
|
|
5157
|
+
return chunkOMPDPBT5_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
|
|
5150
5158
|
}
|
|
5151
5159
|
return Infinity;
|
|
5152
5160
|
};
|
|
@@ -5173,7 +5181,7 @@ function priceSettlementInputs(vtxos, estimator) {
|
|
|
5173
5181
|
const payable = [];
|
|
5174
5182
|
const net = /* @__PURE__ */ new Map();
|
|
5175
5183
|
for (const vtxo of vtxos) {
|
|
5176
|
-
const inputFee = estimator.evalOffchainInput(
|
|
5184
|
+
const inputFee = estimator.evalOffchainInput(chunkOMPDPBT5_cjs.toOffchainInputFeeParams(vtxo));
|
|
5177
5185
|
if (inputFee.satoshis >= vtxo.value) {
|
|
5178
5186
|
continue;
|
|
5179
5187
|
}
|
|
@@ -5253,10 +5261,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
|
|
|
5253
5261
|
};
|
|
5254
5262
|
function getRecoverableVtxos(vtxos, dustAmount, now) {
|
|
5255
5263
|
return vtxos.filter((vtxo) => {
|
|
5256
|
-
if (
|
|
5264
|
+
if (chunkOMPDPBT5_cjs.canRecoverOnchain(vtxo, now)) {
|
|
5257
5265
|
return true;
|
|
5258
5266
|
}
|
|
5259
|
-
if (
|
|
5267
|
+
if (chunkOMPDPBT5_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
|
|
5260
5268
|
return true;
|
|
5261
5269
|
}
|
|
5262
5270
|
return false;
|
|
@@ -5288,7 +5296,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
|
|
|
5288
5296
|
function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
5289
5297
|
if (vtxo.isUnrolled) return false;
|
|
5290
5298
|
const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
|
|
5291
|
-
const expiresAt =
|
|
5299
|
+
const expiresAt = chunkOMPDPBT5_cjs.normalizeVtxo(vtxo).expiresAt;
|
|
5292
5300
|
if (expiresAt === void 0) return false;
|
|
5293
5301
|
const now = Date.now();
|
|
5294
5302
|
const batchExpiry = expiresAt.getTime();
|
|
@@ -5299,7 +5307,7 @@ function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
|
|
|
5299
5307
|
return vtxos.filter(
|
|
5300
5308
|
// The leading exclusion covers the `isSubdust` arm too, which is a value
|
|
5301
5309
|
// property and would otherwise re-admit an exited coin on its own.
|
|
5302
|
-
(vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) ||
|
|
5310
|
+
(vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) || chunkOMPDPBT5_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount))
|
|
5303
5311
|
);
|
|
5304
5312
|
}
|
|
5305
5313
|
function isMigrationCapable(wallet) {
|
|
@@ -5359,7 +5367,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5359
5367
|
constructor(wallet, settlementConfig) {
|
|
5360
5368
|
this.wallet = wallet;
|
|
5361
5369
|
if (settlementConfig !== false) {
|
|
5362
|
-
|
|
5370
|
+
chunkOMPDPBT5_cjs.assertTimerMs("pollIntervalMs", settlementConfig?.pollIntervalMs);
|
|
5363
5371
|
}
|
|
5364
5372
|
this.settlementConfig = settlementConfig !== void 0 ? settlementConfig : { ...DEFAULT_SETTLEMENT_CONFIG };
|
|
5365
5373
|
this.contractEventsSubscriptionReady = this.initializeSubscription();
|
|
@@ -5671,7 +5679,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5671
5679
|
* {@link recoverImportedContracts}).
|
|
5672
5680
|
*/
|
|
5673
5681
|
async recoverOneImportedContract(wallet, contract, vtxos, info, dustAmount) {
|
|
5674
|
-
const recoverable = vtxos.filter((vtxo) => vtxo.isSwept && !
|
|
5682
|
+
const recoverable = vtxos.filter((vtxo) => vtxo.isSwept && !chunkOMPDPBT5_cjs.isVtxoSpent(vtxo));
|
|
5675
5683
|
const estimator = new Estimator(info?.fees.intentFee ?? {});
|
|
5676
5684
|
const { payable, net } = priceSettlementInputs(recoverable, estimator);
|
|
5677
5685
|
const vtxoMaxAmount = info?.vtxoMaxAmount ?? -1n;
|
|
@@ -5685,15 +5693,27 @@ var VtxoManager = class _VtxoManager {
|
|
|
5685
5693
|
const arkAddress = await wallet.getAddress();
|
|
5686
5694
|
const totalAmount = deductOffchainOutputFee(subtotal, estimator, arkAddress);
|
|
5687
5695
|
if (totalAmount < dustAmount) return;
|
|
5688
|
-
await wallet.settle({
|
|
5696
|
+
const settledTxid = await wallet.settle({
|
|
5689
5697
|
inputs: batch,
|
|
5690
5698
|
outputs: [{ address: arkAddress, amount: totalAmount }]
|
|
5691
5699
|
});
|
|
5700
|
+
try {
|
|
5701
|
+
await wallet.correlateArkadeCashRecovery?.(
|
|
5702
|
+
contract.script,
|
|
5703
|
+
settledTxid,
|
|
5704
|
+
Number(totalAmount)
|
|
5705
|
+
);
|
|
5706
|
+
} catch (error) {
|
|
5707
|
+
console.error(
|
|
5708
|
+
`Failed to record arkcash recovery ${settledTxid} for ${contract.script}:`,
|
|
5709
|
+
error
|
|
5710
|
+
);
|
|
5711
|
+
}
|
|
5692
5712
|
}
|
|
5693
5713
|
if (vtxos.length === 0) return;
|
|
5694
5714
|
const spent = new Set(batch.map((vtxo) => `${vtxo.txid}:${vtxo.vout}`));
|
|
5695
5715
|
const stillSpendable = vtxos.some(
|
|
5696
|
-
(vtxo) => !
|
|
5716
|
+
(vtxo) => !chunkOMPDPBT5_cjs.isVtxoSpent(vtxo) && !spent.has(`${vtxo.txid}:${vtxo.vout}`)
|
|
5697
5717
|
);
|
|
5698
5718
|
if (!stillSpendable) {
|
|
5699
5719
|
await wallet.removeRecoveryContract(contract.script);
|
|
@@ -5935,7 +5955,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5935
5955
|
return txid;
|
|
5936
5956
|
} catch (e) {
|
|
5937
5957
|
if (!isCosignFallback(e)) throw e;
|
|
5938
|
-
if (e instanceof
|
|
5958
|
+
if (e instanceof chunkOMPDPBT5_cjs.OnchainCosignRejectedError) {
|
|
5939
5959
|
console.warn("Onchain cosign sweep rejected, falling back to CSV exit:", e.message);
|
|
5940
5960
|
}
|
|
5941
5961
|
return void 0;
|
|
@@ -6012,7 +6032,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
6012
6032
|
`Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
|
|
6013
6033
|
);
|
|
6014
6034
|
}
|
|
6015
|
-
const tx = new
|
|
6035
|
+
const tx = new chunkOMPDPBT5_cjs.Transaction();
|
|
6016
6036
|
for (const { utxo, script, leaf } of inputs) {
|
|
6017
6037
|
tx.addInput({
|
|
6018
6038
|
txid: utxo.txid,
|
|
@@ -6250,8 +6270,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
6250
6270
|
const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
|
|
6251
6271
|
if (cls.status === "CURRENT") continue;
|
|
6252
6272
|
const live = vtxos.filter((v) => !v.isUnrolled);
|
|
6253
|
-
const recoverable = live.filter((v) => v.isSwept && !
|
|
6254
|
-
const spendable = live.filter((v) => !
|
|
6273
|
+
const recoverable = live.filter((v) => v.isSwept && !chunkOMPDPBT5_cjs.isVtxoSpent(v));
|
|
6274
|
+
const spendable = live.filter((v) => !chunkOMPDPBT5_cjs.isVtxoSpent(v) && !v.isSwept);
|
|
6255
6275
|
const value = spendable.reduce((sum, v) => sum + v.value, 0);
|
|
6256
6276
|
let recoverableCount = 0;
|
|
6257
6277
|
let recoverableValue = 0;
|
|
@@ -6607,8 +6627,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
6607
6627
|
}
|
|
6608
6628
|
/** The outpoint a `VTXO_ALREADY_SPENT` error carries in `metadata.vtxo_outpoint`, if any. */
|
|
6609
6629
|
extractSpentOutpoint(error) {
|
|
6610
|
-
const ark =
|
|
6611
|
-
if (!
|
|
6630
|
+
const ark = chunkOMPDPBT5_cjs.maybeArkError(error);
|
|
6631
|
+
if (!chunkOMPDPBT5_cjs.isArkError(ark, chunkOMPDPBT5_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
|
|
6612
6632
|
const raw = ark.metadata?.vtxo_outpoint;
|
|
6613
6633
|
if (typeof raw !== "string") return void 0;
|
|
6614
6634
|
const [txid, voutStr] = raw.split(":");
|
|
@@ -6789,7 +6809,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
6789
6809
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
6790
6810
|
break;
|
|
6791
6811
|
}
|
|
6792
|
-
const inputFee = estimator.evalOffchainInput(
|
|
6812
|
+
const inputFee = estimator.evalOffchainInput(chunkOMPDPBT5_cjs.toOffchainInputFeeParams(v));
|
|
6793
6813
|
if (inputFee.satoshis >= v.value) {
|
|
6794
6814
|
continue;
|
|
6795
6815
|
}
|
|
@@ -7098,7 +7118,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
7098
7118
|
return SingleKey.fromPrivateKey(this._privateKey);
|
|
7099
7119
|
}
|
|
7100
7120
|
get vtxoScript() {
|
|
7101
|
-
return new
|
|
7121
|
+
return new chunkMQUATTIM_cjs.DefaultVtxo.Script({
|
|
7102
7122
|
pubKey: this._publicKey,
|
|
7103
7123
|
serverPubKey: this._serverPubKey,
|
|
7104
7124
|
csvTimelock: this.csvTimelock
|
|
@@ -7108,11 +7128,97 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
7108
7128
|
return this.vtxoScript.address(addressHrp, this._serverPubKey);
|
|
7109
7129
|
}
|
|
7110
7130
|
};
|
|
7131
|
+
var ArkadeCashTracker = class {
|
|
7132
|
+
records = /* @__PURE__ */ new Map();
|
|
7133
|
+
get(id) {
|
|
7134
|
+
return this.records.get(id);
|
|
7135
|
+
}
|
|
7136
|
+
list() {
|
|
7137
|
+
return [...this.records.values()].sort((a, b) => b.createdAt - a.createdAt);
|
|
7138
|
+
}
|
|
7139
|
+
};
|
|
7140
|
+
function createArkadeCashTracker() {
|
|
7141
|
+
return new ArkadeCashTracker();
|
|
7142
|
+
}
|
|
7143
|
+
var unionByTxid = (a, b) => [
|
|
7144
|
+
...new Map([...a, ...b].map((entry) => [entry.txid, entry])).values()
|
|
7145
|
+
];
|
|
7146
|
+
function mergeArkadeCashRecord(prev, next) {
|
|
7147
|
+
if (!prev) return next;
|
|
7148
|
+
const lead = prev.action === "claimed" && next.action === "issued" ? prev : next;
|
|
7149
|
+
return {
|
|
7150
|
+
id: next.id,
|
|
7151
|
+
action: lead.action,
|
|
7152
|
+
outcome: lead.outcome,
|
|
7153
|
+
createdAt: Math.min(prev.createdAt, next.createdAt),
|
|
7154
|
+
issues: unionByTxid(prev.issues, next.issues),
|
|
7155
|
+
claims: unionByTxid(prev.claims, next.claims)
|
|
7156
|
+
};
|
|
7157
|
+
}
|
|
7158
|
+
function isArkadeCashRecord(value) {
|
|
7159
|
+
if (!value || typeof value !== "object") return false;
|
|
7160
|
+
const v = value;
|
|
7161
|
+
return typeof v.id === "string" && (v.action === "issued" || v.action === "claimed") && typeof v.createdAt === "number" && typeof v.outcome === "string" && Array.isArray(v.issues) && Array.isArray(v.claims);
|
|
7162
|
+
}
|
|
7163
|
+
function addArkadeCashRecord(records, record) {
|
|
7164
|
+
records.records.set(record.id, mergeArkadeCashRecord(records.get(record.id), record));
|
|
7165
|
+
}
|
|
7166
|
+
function arkadeCashId(cash) {
|
|
7167
|
+
return base.hex.encode(cash.vtxoScript.pkScript);
|
|
7168
|
+
}
|
|
7169
|
+
function arkadeCashResolver(records) {
|
|
7170
|
+
let index;
|
|
7171
|
+
const build = () => {
|
|
7172
|
+
const next = /* @__PURE__ */ new Map();
|
|
7173
|
+
for (const record of records.list()) {
|
|
7174
|
+
for (const { txid } of [...record.issues, ...record.claims]) {
|
|
7175
|
+
const touching = next.get(txid) ?? [];
|
|
7176
|
+
if (touching[touching.length - 1] !== record) touching.push(record);
|
|
7177
|
+
next.set(txid, touching);
|
|
7178
|
+
}
|
|
7179
|
+
}
|
|
7180
|
+
return next;
|
|
7181
|
+
};
|
|
7182
|
+
return {
|
|
7183
|
+
id: "arkade-cash",
|
|
7184
|
+
async prepare() {
|
|
7185
|
+
index = build();
|
|
7186
|
+
},
|
|
7187
|
+
resolve(tx) {
|
|
7188
|
+
if (tx.key.boardingTxid) return [];
|
|
7189
|
+
index ??= build();
|
|
7190
|
+
const txid = tx.key.arkTxid || tx.key.commitmentTxid;
|
|
7191
|
+
const isBatchRow = !tx.key.arkTxid;
|
|
7192
|
+
const direction = tx.type === "SENT" /* TxSent */ ? "issued" : "claimed";
|
|
7193
|
+
return (index.get(txid) ?? []).flatMap((record) => {
|
|
7194
|
+
const entries = direction === "issued" ? record.issues : record.claims;
|
|
7195
|
+
const match = entries.find(
|
|
7196
|
+
(entry) => entry.txid === txid && (!isBatchRow || entry.amount === tx.amount)
|
|
7197
|
+
);
|
|
7198
|
+
if (!match) return [];
|
|
7199
|
+
return [
|
|
7200
|
+
{
|
|
7201
|
+
groupId: `arkade-cash:${record.id}:${direction}`,
|
|
7202
|
+
label: direction === "issued" ? "Cash issued" : "Cash claimed",
|
|
7203
|
+
kind: "arkade-cash",
|
|
7204
|
+
outcome: record.outcome,
|
|
7205
|
+
metadata: { cashId: record.id, direction },
|
|
7206
|
+
amount: match.amount
|
|
7207
|
+
}
|
|
7208
|
+
];
|
|
7209
|
+
});
|
|
7210
|
+
}
|
|
7211
|
+
};
|
|
7212
|
+
}
|
|
7213
|
+
async function arkadeCashActivity(records, txs) {
|
|
7214
|
+
const activities = await buildActivities(txs, [arkadeCashResolver(records)]);
|
|
7215
|
+
return activities.filter((activity) => activity.intent?.kind === "arkade-cash");
|
|
7216
|
+
}
|
|
7111
7217
|
|
|
7112
7218
|
// src/wallet/intentReconciliation.ts
|
|
7113
7219
|
var NON_TERMINAL_INTENT_STATES = ALL_BATCH_REGISTRATION_STATES.filter((s) => !isTerminalBatchRegistrationState(s));
|
|
7114
7220
|
function isConsumed(vtxo) {
|
|
7115
|
-
return vtxo !== void 0 &&
|
|
7221
|
+
return vtxo !== void 0 && chunkOMPDPBT5_cjs.isVtxoSpent(vtxo);
|
|
7116
7222
|
}
|
|
7117
7223
|
async function classifyIntent(intent, vtxosByOutpoint, now) {
|
|
7118
7224
|
if (isTerminalBatchRegistrationState(intent.state)) return void 0;
|
|
@@ -7150,7 +7256,7 @@ async function reconcileIntents(deps) {
|
|
|
7150
7256
|
let vtxosByOutpoint = /* @__PURE__ */ new Map();
|
|
7151
7257
|
if (outpoints.length > 0) {
|
|
7152
7258
|
try {
|
|
7153
|
-
const { vtxos } = await
|
|
7259
|
+
const { vtxos } = await chunkOMPDPBT5_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
|
|
7154
7260
|
vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
|
|
7155
7261
|
} catch (e) {
|
|
7156
7262
|
console.error("reconcileIntents: failed to fetch input VTXO state", e);
|
|
@@ -7210,7 +7316,7 @@ async function releaseFromServer(intent, deps, now) {
|
|
|
7210
7316
|
});
|
|
7211
7317
|
}
|
|
7212
7318
|
function isNoMatchingIntentsError(e) {
|
|
7213
|
-
return
|
|
7319
|
+
return chunkOMPDPBT5_cjs.isArkError(e, chunkOMPDPBT5_cjs.ArkErrorName.INVALID_INTENT_PROOF) && e.message.includes("no matching intents found");
|
|
7214
7320
|
}
|
|
7215
7321
|
function terminal(intent, state, now, patch) {
|
|
7216
7322
|
return { ...intent, ...patch, state, updatedAt: now };
|
|
@@ -7437,7 +7543,7 @@ async function captureExitBranch(params) {
|
|
|
7437
7543
|
const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
|
|
7438
7544
|
if (nonCommitment.length > 0) {
|
|
7439
7545
|
for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
|
|
7440
|
-
psbtByTxid.set(
|
|
7546
|
+
psbtByTxid.set(chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
7441
7547
|
}
|
|
7442
7548
|
}
|
|
7443
7549
|
}
|
|
@@ -7480,10 +7586,10 @@ var IndexerExitDataSource = class {
|
|
|
7480
7586
|
while (hasMore) {
|
|
7481
7587
|
const { chain: page, page: meta } = await this.indexer.getVtxoChain(
|
|
7482
7588
|
{ txid: vtxo.txid, vout: vtxo.vout },
|
|
7483
|
-
{ pageIndex, pageSize:
|
|
7589
|
+
{ pageIndex, pageSize: chunkOMPDPBT5_cjs.DEFAULT_PAGE_SIZE }
|
|
7484
7590
|
);
|
|
7485
7591
|
chain.push(...page);
|
|
7486
|
-
hasMore = meta ? page.length ===
|
|
7592
|
+
hasMore = meta ? page.length === chunkOMPDPBT5_cjs.DEFAULT_PAGE_SIZE : false;
|
|
7487
7593
|
pageIndex++;
|
|
7488
7594
|
}
|
|
7489
7595
|
return chain;
|
|
@@ -7495,12 +7601,12 @@ var IndexerExitDataSource = class {
|
|
|
7495
7601
|
while (hasMore) {
|
|
7496
7602
|
const { txs, page } = await this.indexer.getVirtualTxs(txids, {
|
|
7497
7603
|
pageIndex,
|
|
7498
|
-
pageSize:
|
|
7604
|
+
pageSize: chunkOMPDPBT5_cjs.DEFAULT_PAGE_SIZE
|
|
7499
7605
|
});
|
|
7500
7606
|
for (const psbt of txs) {
|
|
7501
|
-
out.set(
|
|
7607
|
+
out.set(chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
7502
7608
|
}
|
|
7503
|
-
hasMore = page ? txs.length ===
|
|
7609
|
+
hasMore = page ? txs.length === chunkOMPDPBT5_cjs.DEFAULT_PAGE_SIZE : false;
|
|
7504
7610
|
pageIndex++;
|
|
7505
7611
|
}
|
|
7506
7612
|
return out;
|
|
@@ -7521,7 +7627,7 @@ function chainedTxTypeToChainTxType(t) {
|
|
|
7521
7627
|
}
|
|
7522
7628
|
}
|
|
7523
7629
|
function psbtInputTxids(psbtBase64) {
|
|
7524
|
-
return txInputTxids(
|
|
7630
|
+
return txInputTxids(chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64)));
|
|
7525
7631
|
}
|
|
7526
7632
|
function txInputTxids(tx) {
|
|
7527
7633
|
const ids = [];
|
|
@@ -7828,10 +7934,10 @@ async function resolveArkInfo(arkProvider, walletRepository, opts) {
|
|
|
7828
7934
|
try {
|
|
7829
7935
|
info = await arkProvider.getInfo();
|
|
7830
7936
|
} catch (err) {
|
|
7831
|
-
if (opts?.requireLive || !
|
|
7937
|
+
if (opts?.requireLive || !chunkOMPDPBT5_cjs.isRetryableProviderError(err)) throw err;
|
|
7832
7938
|
const snapshot = await loadArkInfoSnapshot(walletRepository);
|
|
7833
7939
|
if (!snapshot) {
|
|
7834
|
-
throw new
|
|
7940
|
+
throw new chunkOMPDPBT5_cjs.ProviderUnavailableError(
|
|
7835
7941
|
"Operator info is unavailable and no cached snapshot exists",
|
|
7836
7942
|
{ cause: err }
|
|
7837
7943
|
);
|
|
@@ -8023,7 +8129,7 @@ function buildGraph(rootTxid, chunksByTxid) {
|
|
|
8023
8129
|
return new TxTree(rootTx, children);
|
|
8024
8130
|
}
|
|
8025
8131
|
function decodeNode(chunk) {
|
|
8026
|
-
const tx =
|
|
8132
|
+
const tx = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(chunk.tx));
|
|
8027
8133
|
return { tx, children: chunk.children };
|
|
8028
8134
|
}
|
|
8029
8135
|
exports.Batch = void 0;
|
|
@@ -8247,7 +8353,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos, localCreatedAt) {
|
|
|
8247
8353
|
return [...txids];
|
|
8248
8354
|
}
|
|
8249
8355
|
async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt, gatedScripts = /* @__PURE__ */ new Map()) {
|
|
8250
|
-
const normalized = vtxos.map(
|
|
8356
|
+
const normalized = vtxos.map(chunkOMPDPBT5_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
8251
8357
|
const localCreatedAt = localCreatedAtByTxid(normalized);
|
|
8252
8358
|
const gatedVtxos = normalized.filter((vtxo) => isGatedVtxo(vtxo, gatedScripts));
|
|
8253
8359
|
const ownVtxos = normalized.filter((vtxo) => !isGatedVtxo(vtxo, gatedScripts));
|
|
@@ -8434,7 +8540,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
8434
8540
|
withRecoverable: false,
|
|
8435
8541
|
genericallySpendableOnly: true
|
|
8436
8542
|
});
|
|
8437
|
-
const controlAssetRef = params.controlAssetId ?
|
|
8543
|
+
const controlAssetRef = params.controlAssetId ? chunk3NALVGMJ_cjs.AssetRef.fromId(chunk3NALVGMJ_cjs.AssetId.fromString(params.controlAssetId)) : null;
|
|
8438
8544
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
8439
8545
|
let totalBtcSelected = 0n;
|
|
8440
8546
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -8447,8 +8553,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
8447
8553
|
}
|
|
8448
8554
|
}
|
|
8449
8555
|
const groups = [];
|
|
8450
|
-
const issuedAssetOutput =
|
|
8451
|
-
const issuedAssetGroup =
|
|
8556
|
+
const issuedAssetOutput = chunk3NALVGMJ_cjs.AssetOutput.create(0, params.amount);
|
|
8557
|
+
const issuedAssetGroup = chunk3NALVGMJ_cjs.AssetGroup.create(
|
|
8452
8558
|
null,
|
|
8453
8559
|
controlAssetRef,
|
|
8454
8560
|
[],
|
|
@@ -8461,11 +8567,11 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
8461
8567
|
for (const [assetId, amount] of assetChanges) {
|
|
8462
8568
|
const changeInputs = inputsForAsset(assetInputs, assetId);
|
|
8463
8569
|
groups.push(
|
|
8464
|
-
|
|
8465
|
-
|
|
8570
|
+
chunk3NALVGMJ_cjs.AssetGroup.create(
|
|
8571
|
+
chunk3NALVGMJ_cjs.AssetId.fromString(assetId),
|
|
8466
8572
|
null,
|
|
8467
8573
|
changeInputs,
|
|
8468
|
-
[
|
|
8574
|
+
[chunk3NALVGMJ_cjs.AssetOutput.create(0, amount)],
|
|
8469
8575
|
[]
|
|
8470
8576
|
)
|
|
8471
8577
|
);
|
|
@@ -8480,7 +8586,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
8480
8586
|
);
|
|
8481
8587
|
return {
|
|
8482
8588
|
arkTxId: arkTxid,
|
|
8483
|
-
assetId:
|
|
8589
|
+
assetId: chunk3NALVGMJ_cjs.AssetId.create(arkTxid, 0).toString()
|
|
8484
8590
|
};
|
|
8485
8591
|
}
|
|
8486
8592
|
/**
|
|
@@ -8554,23 +8660,23 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
8554
8660
|
const assetInputs = selectedCoinsToAssetInputs(selectedCoins);
|
|
8555
8661
|
const reissueInputs = inputsForAsset(assetInputs, params.assetId);
|
|
8556
8662
|
const totalAssetAmount = assetToReissueAmount + params.amount;
|
|
8557
|
-
const reissueAssetIdObj =
|
|
8558
|
-
const reissueAssetGroup =
|
|
8663
|
+
const reissueAssetIdObj = chunk3NALVGMJ_cjs.AssetId.fromString(params.assetId);
|
|
8664
|
+
const reissueAssetGroup = chunk3NALVGMJ_cjs.AssetGroup.create(
|
|
8559
8665
|
reissueAssetIdObj,
|
|
8560
8666
|
null,
|
|
8561
8667
|
reissueInputs,
|
|
8562
|
-
[
|
|
8668
|
+
[chunk3NALVGMJ_cjs.AssetOutput.create(0, totalAssetAmount)],
|
|
8563
8669
|
[]
|
|
8564
8670
|
);
|
|
8565
8671
|
const groups = [reissueAssetGroup];
|
|
8566
8672
|
for (const [assetId, amount] of assetChanges) {
|
|
8567
8673
|
const changeInputs = inputsForAsset(assetInputs, assetId);
|
|
8568
8674
|
groups.push(
|
|
8569
|
-
|
|
8570
|
-
|
|
8675
|
+
chunk3NALVGMJ_cjs.AssetGroup.create(
|
|
8676
|
+
chunk3NALVGMJ_cjs.AssetId.fromString(assetId),
|
|
8571
8677
|
null,
|
|
8572
8678
|
changeInputs,
|
|
8573
|
-
[
|
|
8679
|
+
[chunk3NALVGMJ_cjs.AssetOutput.create(0, amount)],
|
|
8574
8680
|
[]
|
|
8575
8681
|
)
|
|
8576
8682
|
);
|
|
@@ -8641,11 +8747,11 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
8641
8747
|
for (const [assetId, amount] of assetChanges) {
|
|
8642
8748
|
const changeInputs = inputsForAsset(assetInputs, assetId);
|
|
8643
8749
|
groups.push(
|
|
8644
|
-
|
|
8645
|
-
|
|
8750
|
+
chunk3NALVGMJ_cjs.AssetGroup.create(
|
|
8751
|
+
chunk3NALVGMJ_cjs.AssetId.fromString(assetId),
|
|
8646
8752
|
null,
|
|
8647
8753
|
changeInputs,
|
|
8648
|
-
amount > 0n ? [
|
|
8754
|
+
amount > 0n ? [chunk3NALVGMJ_cjs.AssetOutput.create(0, amount)] : [],
|
|
8649
8755
|
[]
|
|
8650
8756
|
)
|
|
8651
8757
|
);
|
|
@@ -8658,7 +8764,7 @@ function inputsForAsset(assetInputs, assetId) {
|
|
|
8658
8764
|
for (const [inputIndex, assets] of assetInputs) {
|
|
8659
8765
|
for (const asset of assets) {
|
|
8660
8766
|
if (asset.assetId !== assetId) continue;
|
|
8661
|
-
inputs.push(
|
|
8767
|
+
inputs.push(chunk3NALVGMJ_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
8662
8768
|
}
|
|
8663
8769
|
}
|
|
8664
8770
|
return inputs;
|
|
@@ -8667,7 +8773,7 @@ async function submitToSelf(submit, wallet, inputs, amount, groups) {
|
|
|
8667
8773
|
const outputAddress = chunkFLPWNMX3_cjs.ArkAddress.decode(await wallet.getAddress());
|
|
8668
8774
|
const outputs = [
|
|
8669
8775
|
{ script: outputAddress.pkScript, amount: BigInt(amount) },
|
|
8670
|
-
Extension.create([
|
|
8776
|
+
Extension.create([chunk3NALVGMJ_cjs.Packet.create(groups)]).txOut()
|
|
8671
8777
|
];
|
|
8672
8778
|
const { arkTxid } = await submit(inputs, outputs);
|
|
8673
8779
|
return arkTxid;
|
|
@@ -8691,7 +8797,7 @@ function castMetadata(metadata) {
|
|
|
8691
8797
|
} else {
|
|
8692
8798
|
throw new Error("Invalid metadata value type");
|
|
8693
8799
|
}
|
|
8694
|
-
md.push(
|
|
8800
|
+
md.push(chunk3NALVGMJ_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
|
|
8695
8801
|
}
|
|
8696
8802
|
return md;
|
|
8697
8803
|
}
|
|
@@ -8717,7 +8823,7 @@ var DelegateManagerImpl = class {
|
|
|
8717
8823
|
this.arkInfoProvider.getInfo(),
|
|
8718
8824
|
this.delegateProvider.getDelegateInfo()
|
|
8719
8825
|
]);
|
|
8720
|
-
const eligible = vtxos.map(
|
|
8826
|
+
const eligible = vtxos.map(chunkOMPDPBT5_cjs.normalizeVtxo).filter(
|
|
8721
8827
|
(v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
|
|
8722
8828
|
);
|
|
8723
8829
|
if (eligible.length === 0) {
|
|
@@ -8749,7 +8855,7 @@ var DelegateManagerImpl = class {
|
|
|
8749
8855
|
const groupByExpiry = /* @__PURE__ */ new Map();
|
|
8750
8856
|
let recoverableVtxos = [];
|
|
8751
8857
|
for (const vtxo of eligible) {
|
|
8752
|
-
if (
|
|
8858
|
+
if (chunkOMPDPBT5_cjs.canRecoverOnchain(vtxo, now)) {
|
|
8753
8859
|
recoverableVtxos.push(vtxo);
|
|
8754
8860
|
continue;
|
|
8755
8861
|
}
|
|
@@ -8801,7 +8907,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
8801
8907
|
}
|
|
8802
8908
|
if (!delegateAt) {
|
|
8803
8909
|
const now = { timestamp: /* @__PURE__ */ new Date() };
|
|
8804
|
-
const expiryTimestamp = vtxos.filter((coin) => !
|
|
8910
|
+
const expiryTimestamp = vtxos.filter((coin) => !chunkOMPDPBT5_cjs.canRecoverOnchain(coin, now) && coin.expiresAt).reduce(
|
|
8805
8911
|
(min, coin) => Math.min(min, coin.expiresAt.getTime()),
|
|
8806
8912
|
Number.MAX_SAFE_INTEGER
|
|
8807
8913
|
);
|
|
@@ -8821,7 +8927,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
8821
8927
|
let amount = 0n;
|
|
8822
8928
|
for (const coin of vtxos) {
|
|
8823
8929
|
const inputFee = estimator.evalOffchainInput({
|
|
8824
|
-
...
|
|
8930
|
+
...chunkOMPDPBT5_cjs.toOffchainInputFeeParams(coin),
|
|
8825
8931
|
type: "vtxo"
|
|
8826
8932
|
});
|
|
8827
8933
|
if (inputFee.satoshis >= coin.value) {
|
|
@@ -8871,7 +8977,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
8871
8977
|
btcSigner.Address(chunkFLPWNMX3_cjs.getNetwork(network)).decode(forfeitAddress)
|
|
8872
8978
|
);
|
|
8873
8979
|
const forfeits = await Promise.all(
|
|
8874
|
-
vtxos.filter((v) =>
|
|
8980
|
+
vtxos.filter((v) => chunkOMPDPBT5_cjs.requiresForfeit(v)).map(async (coin) => {
|
|
8875
8981
|
const forfeit = await makeDelegateForfeitTx(
|
|
8876
8982
|
coin,
|
|
8877
8983
|
dust,
|
|
@@ -8954,7 +9060,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
8954
9060
|
expire_at: 0,
|
|
8955
9061
|
cosigners_public_keys: cosignerPubKeys
|
|
8956
9062
|
};
|
|
8957
|
-
const proof =
|
|
9063
|
+
const proof = chunkOMPDPBT5_cjs.Proof.create(message, coins, outputs);
|
|
8958
9064
|
const signedProof = await identity.sign(proof);
|
|
8959
9065
|
return {
|
|
8960
9066
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -9696,7 +9802,7 @@ function decodeArkContract(encoded) {
|
|
|
9696
9802
|
}
|
|
9697
9803
|
function contractFromArkContract(encoded, options = {}) {
|
|
9698
9804
|
const parsed = decodeArkContract(encoded);
|
|
9699
|
-
const handler =
|
|
9805
|
+
const handler = chunkMQUATTIM_cjs.contractHandlers.get(parsed.type);
|
|
9700
9806
|
if (!handler) {
|
|
9701
9807
|
throw new Error(`No handler registered for contract type '${parsed.type}'`);
|
|
9702
9808
|
}
|
|
@@ -9712,7 +9818,7 @@ function contractFromArkContract(encoded, options = {}) {
|
|
|
9712
9818
|
}
|
|
9713
9819
|
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkFLPWNMX3_cjs.DEFAULT_NETWORK.hrp, options = {}) {
|
|
9714
9820
|
const parsed = decodeArkContract(encoded);
|
|
9715
|
-
const handler =
|
|
9821
|
+
const handler = chunkMQUATTIM_cjs.contractHandlers.getOrThrow(parsed.type);
|
|
9716
9822
|
const params = parsed.data;
|
|
9717
9823
|
const vtxoScript = handler.createScript(params);
|
|
9718
9824
|
return {
|
|
@@ -9769,10 +9875,10 @@ var ContractWatcher = class {
|
|
|
9769
9875
|
eventSourceReported = false;
|
|
9770
9876
|
/** @see ContractWatcherConfig */
|
|
9771
9877
|
constructor(config) {
|
|
9772
|
-
|
|
9773
|
-
|
|
9774
|
-
|
|
9775
|
-
|
|
9878
|
+
chunkOMPDPBT5_cjs.assertTimerMs("failsafePollIntervalMs", config.failsafePollIntervalMs);
|
|
9879
|
+
chunkOMPDPBT5_cjs.assertTimerMs("reconnectDelayMs", config.reconnectDelayMs);
|
|
9880
|
+
chunkOMPDPBT5_cjs.assertTimerMs("maxReconnectDelayMs", config.maxReconnectDelayMs);
|
|
9881
|
+
chunkOMPDPBT5_cjs.assertTimerMs("subscriptionRequestTimeoutMs", config.subscriptionRequestTimeoutMs);
|
|
9776
9882
|
if (config.subscriptionRequestTimeoutMs === 0) {
|
|
9777
9883
|
throw new Error("subscriptionRequestTimeoutMs must be greater than 0");
|
|
9778
9884
|
}
|
|
@@ -9995,9 +10101,9 @@ var ContractWatcher = class {
|
|
|
9995
10101
|
this.reconnectAttempts = 0;
|
|
9996
10102
|
this.listenLoop().catch((e) => {
|
|
9997
10103
|
if (!this.isWatching || signal?.aborted) return;
|
|
9998
|
-
if (
|
|
10104
|
+
if (chunkOMPDPBT5_cjs.isEventSourceError(e)) {
|
|
9999
10105
|
console.debug("ContractWatcher subscription disconnected; reconnecting");
|
|
10000
|
-
} else if (!
|
|
10106
|
+
} else if (!chunkOMPDPBT5_cjs.isEventSourceUnavailableError(e)) {
|
|
10001
10107
|
console.error(e);
|
|
10002
10108
|
}
|
|
10003
10109
|
this.connectionState = "disconnected";
|
|
@@ -10007,7 +10113,7 @@ var ContractWatcher = class {
|
|
|
10007
10113
|
});
|
|
10008
10114
|
} catch (error) {
|
|
10009
10115
|
if (!this.isWatching || signal?.aborted) return;
|
|
10010
|
-
if (!
|
|
10116
|
+
if (!chunkOMPDPBT5_cjs.isEventSourceUnavailableError(error)) {
|
|
10011
10117
|
console.error("ContractWatcher connection failed:", error);
|
|
10012
10118
|
}
|
|
10013
10119
|
this.connectionState = "disconnected";
|
|
@@ -10023,7 +10129,7 @@ var ContractWatcher = class {
|
|
|
10023
10129
|
* few seconds.
|
|
10024
10130
|
*/
|
|
10025
10131
|
reportEventSourceUnavailable(error) {
|
|
10026
|
-
if (!
|
|
10132
|
+
if (!chunkOMPDPBT5_cjs.isEventSourceUnavailableError(error)) return false;
|
|
10027
10133
|
if (!this.eventSourceReported) {
|
|
10028
10134
|
this.eventSourceReported = true;
|
|
10029
10135
|
console.warn(
|
|
@@ -10088,7 +10194,7 @@ var ContractWatcher = class {
|
|
|
10088
10194
|
const now = Date.now();
|
|
10089
10195
|
let current;
|
|
10090
10196
|
try {
|
|
10091
|
-
current = await
|
|
10197
|
+
current = await chunkOMPDPBT5_cjs.getAllNormalizedVtxos(this.config.indexerProvider, scripts, {
|
|
10092
10198
|
spendableOnly: true
|
|
10093
10199
|
});
|
|
10094
10200
|
} catch (error) {
|
|
@@ -10370,14 +10476,14 @@ var ContractWatcher = class {
|
|
|
10370
10476
|
const timestamp = Date.now();
|
|
10371
10477
|
if (update.newVtxos?.length) {
|
|
10372
10478
|
this.processSubscriptionVtxos(
|
|
10373
|
-
update.newVtxos.map(
|
|
10479
|
+
update.newVtxos.map(chunkOMPDPBT5_cjs.normalizeVtxo),
|
|
10374
10480
|
"vtxo_received",
|
|
10375
10481
|
timestamp
|
|
10376
10482
|
);
|
|
10377
10483
|
}
|
|
10378
10484
|
if (update.spentVtxos?.length) {
|
|
10379
10485
|
this.processSubscriptionVtxos(
|
|
10380
|
-
update.spentVtxos.map(
|
|
10486
|
+
update.spentVtxos.map(chunkOMPDPBT5_cjs.normalizeVtxo),
|
|
10381
10487
|
"vtxo_spent",
|
|
10382
10488
|
timestamp
|
|
10383
10489
|
);
|
|
@@ -10402,8 +10508,8 @@ var ContractWatcher = class {
|
|
|
10402
10508
|
continue;
|
|
10403
10509
|
}
|
|
10404
10510
|
if (target === byWatchedScript && eventType === "vtxo_received") {
|
|
10405
|
-
const n =
|
|
10406
|
-
if (
|
|
10511
|
+
const n = chunkOMPDPBT5_cjs.normalizeVtxo(vtxo);
|
|
10512
|
+
if (chunkOMPDPBT5_cjs.isVtxoSpent(n) || n.isSwept || chunkOMPDPBT5_cjs.isPastExpiry(n, now)) continue;
|
|
10407
10513
|
}
|
|
10408
10514
|
let bucket = target.get(vtxo.script);
|
|
10409
10515
|
if (!bucket) {
|
|
@@ -10591,7 +10697,7 @@ function annotatableIn(scriptToContract, vtxos, memo) {
|
|
|
10591
10697
|
if (!contract) continue;
|
|
10592
10698
|
try {
|
|
10593
10699
|
const key = contractKey(contract);
|
|
10594
|
-
const handler =
|
|
10700
|
+
const handler = chunkMQUATTIM_cjs.contractHandlers.get(contract.type);
|
|
10595
10701
|
const hit = memo?.get(script);
|
|
10596
10702
|
let tapscripts;
|
|
10597
10703
|
if (hit && hit.key === key && hit.handler === handler) {
|
|
@@ -10623,7 +10729,7 @@ function annotatableIn(scriptToContract, vtxos, memo) {
|
|
|
10623
10729
|
}
|
|
10624
10730
|
function annotateAgainst(vtxos, byScript, tapscripts = /* @__PURE__ */ new Map()) {
|
|
10625
10731
|
return vtxos.map(
|
|
10626
|
-
(vtxo) => extendVirtualCoinForContract(
|
|
10732
|
+
(vtxo) => extendVirtualCoinForContract(chunkOMPDPBT5_cjs.normalizeVtxo(vtxo), byScript, tapscripts)
|
|
10627
10733
|
);
|
|
10628
10734
|
}
|
|
10629
10735
|
var SCAN_MAX_INDEX = 1e4;
|
|
@@ -10672,8 +10778,8 @@ var ContractManager = class _ContractManager {
|
|
|
10672
10778
|
/** Serializes onchain read-modify-writes so a pending spender is never overwritten. */
|
|
10673
10779
|
onchainChain = Promise.resolve();
|
|
10674
10780
|
constructor(config) {
|
|
10675
|
-
|
|
10676
|
-
|
|
10781
|
+
chunkOMPDPBT5_cjs.assertNonNegativeMs("vtxoSyncMaxAgeMs", config.vtxoSyncMaxAgeMs);
|
|
10782
|
+
chunkOMPDPBT5_cjs.assertNonNegativeMs("vtxoSyncOverlapMs", config.vtxoSyncOverlapMs);
|
|
10677
10783
|
this.config = { ...config };
|
|
10678
10784
|
if (config.onchainProvider && config.network) {
|
|
10679
10785
|
this.onchainWatcher = new OnchainContractWatcher({
|
|
@@ -10718,12 +10824,12 @@ var ContractManager = class _ContractManager {
|
|
|
10718
10824
|
}
|
|
10719
10825
|
/** @see ContractManagerConfig.vtxoSyncMaxAgeMs — for factory-built managers. */
|
|
10720
10826
|
setVtxoSyncMaxAge(maxAgeMs) {
|
|
10721
|
-
|
|
10827
|
+
chunkOMPDPBT5_cjs.assertNonNegativeMs("vtxoSyncMaxAgeMs", maxAgeMs);
|
|
10722
10828
|
this.config.vtxoSyncMaxAgeMs = maxAgeMs;
|
|
10723
10829
|
}
|
|
10724
10830
|
/** @see ContractManagerConfig.vtxoSyncOverlapMs — for factory-built managers. */
|
|
10725
10831
|
setVtxoSyncOverlap(overlapMs) {
|
|
10726
|
-
|
|
10832
|
+
chunkOMPDPBT5_cjs.assertNonNegativeMs("vtxoSyncOverlapMs", overlapMs);
|
|
10727
10833
|
this.config.vtxoSyncOverlapMs = overlapMs;
|
|
10728
10834
|
}
|
|
10729
10835
|
markSyncOnline() {
|
|
@@ -10787,7 +10893,7 @@ var ContractManager = class _ContractManager {
|
|
|
10787
10893
|
if (this.unsupportedContracts.get(contract.script) === key) return true;
|
|
10788
10894
|
if (this.tapscriptMemo.get(contract.script)?.key === key) return false;
|
|
10789
10895
|
try {
|
|
10790
|
-
|
|
10896
|
+
chunkMQUATTIM_cjs.contractHandlers.get(contract.type)?.createScript(contract.params);
|
|
10791
10897
|
return false;
|
|
10792
10898
|
} catch (err) {
|
|
10793
10899
|
if (!(err instanceof chunkJFJNB7ZH_cjs.UnsupportedProgramVersionError)) return false;
|
|
@@ -10803,7 +10909,7 @@ var ContractManager = class _ContractManager {
|
|
|
10803
10909
|
this.markSyncOnline();
|
|
10804
10910
|
return void 0;
|
|
10805
10911
|
} catch (err) {
|
|
10806
|
-
if (!
|
|
10912
|
+
if (!chunkOMPDPBT5_cjs.isRetryableProviderError(err)) throw err;
|
|
10807
10913
|
this.markSyncDegraded(err);
|
|
10808
10914
|
return err;
|
|
10809
10915
|
}
|
|
@@ -10826,7 +10932,7 @@ var ContractManager = class _ContractManager {
|
|
|
10826
10932
|
try {
|
|
10827
10933
|
await this.scheduleLookAheadDrain();
|
|
10828
10934
|
} catch (err) {
|
|
10829
|
-
if (!
|
|
10935
|
+
if (!chunkOMPDPBT5_cjs.isRetryableProviderError(err)) throw err;
|
|
10830
10936
|
this.lookAheadRefillOwed = true;
|
|
10831
10937
|
this.markSyncDegraded(err);
|
|
10832
10938
|
}
|
|
@@ -10889,7 +10995,7 @@ var ContractManager = class _ContractManager {
|
|
|
10889
10995
|
/** No throw: construction returned long ago, so the state is the channel. */
|
|
10890
10996
|
reportBackgroundFailure(stage, err) {
|
|
10891
10997
|
this.markSyncDegraded(err);
|
|
10892
|
-
if (!
|
|
10998
|
+
if (!chunkOMPDPBT5_cjs.isRetryableProviderError(err)) {
|
|
10893
10999
|
console.error(`[contracts] background ${stage} failed`, err);
|
|
10894
11000
|
}
|
|
10895
11001
|
}
|
|
@@ -10991,7 +11097,7 @@ var ContractManager = class _ContractManager {
|
|
|
10991
11097
|
const from = Math.max(0, watermark - lookAhead.size);
|
|
10992
11098
|
const to = watermark + lookAhead.size;
|
|
10993
11099
|
const deps = lookAhead.candidateDeps();
|
|
10994
|
-
const handlers =
|
|
11100
|
+
const handlers = chunkMQUATTIM_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkMQUATTIM_cjs.contractHandlers.get(t)).filter(hasCandidates);
|
|
10995
11101
|
const band = /* @__PURE__ */ new Map();
|
|
10996
11102
|
for (let index = from; index <= to; index++) {
|
|
10997
11103
|
const descriptor = lookAhead.materialize(index);
|
|
@@ -11002,7 +11108,7 @@ var ContractManager = class _ContractManager {
|
|
|
11002
11108
|
index,
|
|
11003
11109
|
params: {
|
|
11004
11110
|
...candidate,
|
|
11005
|
-
...
|
|
11111
|
+
...chunkMQUATTIM_cjs.speculativeReceiveMetadata(descriptor)
|
|
11006
11112
|
}
|
|
11007
11113
|
});
|
|
11008
11114
|
}
|
|
@@ -11061,7 +11167,7 @@ var ContractManager = class _ContractManager {
|
|
|
11061
11167
|
});
|
|
11062
11168
|
for (const entry of pending) entry.catchUpPending = false;
|
|
11063
11169
|
} catch (err) {
|
|
11064
|
-
if (!
|
|
11170
|
+
if (!chunkOMPDPBT5_cjs.isRetryableProviderError(err)) throw err;
|
|
11065
11171
|
this.markSyncDegraded(err);
|
|
11066
11172
|
}
|
|
11067
11173
|
}
|
|
@@ -11152,7 +11258,7 @@ var ContractManager = class _ContractManager {
|
|
|
11152
11258
|
return result;
|
|
11153
11259
|
}
|
|
11154
11260
|
async upsertContractRow(params) {
|
|
11155
|
-
const handler =
|
|
11261
|
+
const handler = chunkMQUATTIM_cjs.contractHandlers.get(params.type);
|
|
11156
11262
|
if (!handler) {
|
|
11157
11263
|
throw new Error(`No handler registered for contract type '${params.type}'`);
|
|
11158
11264
|
}
|
|
@@ -11254,7 +11360,7 @@ var ContractManager = class _ContractManager {
|
|
|
11254
11360
|
`scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
|
|
11255
11361
|
);
|
|
11256
11362
|
}
|
|
11257
|
-
const registered =
|
|
11363
|
+
const registered = chunkMQUATTIM_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkMQUATTIM_cjs.contractHandlers.get(t)).filter(isDiscoverable);
|
|
11258
11364
|
const discoverables = [
|
|
11259
11365
|
...registered.filter((h) => h.type === "boarding"),
|
|
11260
11366
|
...registered.filter((h) => h.type !== "boarding")
|
|
@@ -11385,7 +11491,7 @@ var ContractManager = class _ContractManager {
|
|
|
11385
11491
|
return contracts.filter((contract) => this.isUnsupported(contract));
|
|
11386
11492
|
}
|
|
11387
11493
|
async getContractsWithVtxos(filter, pageSize, options) {
|
|
11388
|
-
|
|
11494
|
+
chunkOMPDPBT5_cjs.assertNonNegativeMs("maxSyncAgeMs", options?.maxSyncAgeMs);
|
|
11389
11495
|
const contracts = await this.getContracts(filter);
|
|
11390
11496
|
if (this.syncedWithin(
|
|
11391
11497
|
contracts,
|
|
@@ -11493,7 +11599,7 @@ var ContractManager = class _ContractManager {
|
|
|
11493
11599
|
const byScript = new Map(contracts.map((contract) => [contract.script, contract]));
|
|
11494
11600
|
const asking = vtxos.filter((vtxo) => {
|
|
11495
11601
|
const contract = byScript.get(vtxo.script);
|
|
11496
|
-
return contract !== void 0 &&
|
|
11602
|
+
return contract !== void 0 && chunkMQUATTIM_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
|
|
11497
11603
|
});
|
|
11498
11604
|
if (asking.length === 0) return refused;
|
|
11499
11605
|
const [tip, walletDescriptorValue] = await Promise.all([
|
|
@@ -11502,7 +11608,7 @@ var ContractManager = class _ContractManager {
|
|
|
11502
11608
|
]);
|
|
11503
11609
|
for (const vtxo of asking) {
|
|
11504
11610
|
const contract = byScript.get(vtxo.script);
|
|
11505
|
-
const handler =
|
|
11611
|
+
const handler = chunkMQUATTIM_cjs.contractHandlers.get(contract.type);
|
|
11506
11612
|
if (!handler?.assertSpendableNow) continue;
|
|
11507
11613
|
const context = {
|
|
11508
11614
|
collaborative: true,
|
|
@@ -11512,7 +11618,7 @@ var ContractManager = class _ContractManager {
|
|
|
11512
11618
|
walletDescriptor: walletDescriptorValue,
|
|
11513
11619
|
// `isVirtualCoin` only checks `script`, which every input has; `isCsvSpendable`
|
|
11514
11620
|
// reads `vtxo.status.block_time` unguarded, so require `status` too.
|
|
11515
|
-
vtxo:
|
|
11621
|
+
vtxo: chunkOMPDPBT5_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
|
|
11516
11622
|
};
|
|
11517
11623
|
try {
|
|
11518
11624
|
await handler.assertSpendableNow(
|
|
@@ -11626,7 +11732,7 @@ var ContractManager = class _ContractManager {
|
|
|
11626
11732
|
const { contractScript, collaborative = true, walletDescriptor, vtxo } = options;
|
|
11627
11733
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
11628
11734
|
if (!contract) return [];
|
|
11629
|
-
const handler =
|
|
11735
|
+
const handler = chunkMQUATTIM_cjs.contractHandlers.get(contract.type);
|
|
11630
11736
|
if (!handler) return [];
|
|
11631
11737
|
const script = handler.createScript(contract.params);
|
|
11632
11738
|
const tip = await this.currentChainTip();
|
|
@@ -11648,7 +11754,7 @@ var ContractManager = class _ContractManager {
|
|
|
11648
11754
|
const { contractScript, collaborative = true, walletDescriptor } = options;
|
|
11649
11755
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
11650
11756
|
if (!contract) return [];
|
|
11651
|
-
const handler =
|
|
11757
|
+
const handler = chunkMQUATTIM_cjs.contractHandlers.get(contract.type);
|
|
11652
11758
|
if (!handler) return [];
|
|
11653
11759
|
const script = handler.createScript(contract.params);
|
|
11654
11760
|
const context = {
|
|
@@ -11694,7 +11800,7 @@ var ContractManager = class _ContractManager {
|
|
|
11694
11800
|
}
|
|
11695
11801
|
async refreshOutpoints(outpoints) {
|
|
11696
11802
|
if (outpoints.length === 0) return;
|
|
11697
|
-
const { vtxos } = await
|
|
11803
|
+
const { vtxos } = await chunkOMPDPBT5_cjs.getNormalizedVtxos(this.config.indexerProvider, {
|
|
11698
11804
|
outpoints
|
|
11699
11805
|
});
|
|
11700
11806
|
if (vtxos.length === 0) return;
|
|
@@ -11819,7 +11925,7 @@ var ContractManager = class _ContractManager {
|
|
|
11819
11925
|
...Object.values(pending).map((p) => p.script)
|
|
11820
11926
|
]);
|
|
11821
11927
|
const targets = contracts.filter(
|
|
11822
|
-
(c) =>
|
|
11928
|
+
(c) => chunkMQUATTIM_cjs.contractHandlers.has(c.type) && (c.state === "active" && isOnchainScoped(c) || owners.has(c.script))
|
|
11823
11929
|
);
|
|
11824
11930
|
const wanted = scripts && new Set(scripts);
|
|
11825
11931
|
const settled = [];
|
|
@@ -11854,7 +11960,7 @@ var ContractManager = class _ContractManager {
|
|
|
11854
11960
|
).catch((e) => console.warn("[contracts] onchain watch failed", e));
|
|
11855
11961
|
}
|
|
11856
11962
|
async syncOnchainContract(contract, onchainProvider, network, pending, tipHeight, prefetched) {
|
|
11857
|
-
|
|
11963
|
+
chunkMQUATTIM_cjs.contractHandlers.get(contract.type).createScript(contract.params);
|
|
11858
11964
|
const coins = prefetched ?? await onchainProvider.getCoins(onchainAddressOf(contract, network));
|
|
11859
11965
|
const stored = new Map(
|
|
11860
11966
|
(await getVtxosForContract(this.config.walletRepository, contract)).map((v) => [
|
|
@@ -11952,8 +12058,8 @@ var ContractManager = class _ContractManager {
|
|
|
11952
12058
|
const found = /* @__PURE__ */ new Map();
|
|
11953
12059
|
if (!indexerProvider.getUtxos || rows.length === 0) return found;
|
|
11954
12060
|
try {
|
|
11955
|
-
for (let i = 0; i < rows.length; i +=
|
|
11956
|
-
const outpoints = rows.slice(i, i +
|
|
12061
|
+
for (let i = 0; i < rows.length; i += chunkOMPDPBT5_cjs.OUTPOINT_QUERY_CHUNK_SIZE) {
|
|
12062
|
+
const outpoints = rows.slice(i, i + chunkOMPDPBT5_cjs.OUTPOINT_QUERY_CHUNK_SIZE).map(({ txid, vout }) => ({ txid, vout }));
|
|
11957
12063
|
let pageIndex;
|
|
11958
12064
|
let pages = 0;
|
|
11959
12065
|
do {
|
|
@@ -11963,7 +12069,7 @@ var ContractManager = class _ContractManager {
|
|
|
11963
12069
|
const { utxos, page } = await indexerProvider.getUtxos({
|
|
11964
12070
|
outpoints,
|
|
11965
12071
|
pageIndex,
|
|
11966
|
-
pageSize:
|
|
12072
|
+
pageSize: chunkOMPDPBT5_cjs.OUTPOINT_QUERY_CHUNK_SIZE
|
|
11967
12073
|
});
|
|
11968
12074
|
for (const utxo of utxos) found.set(vtxoOutpoint(utxo), utxo);
|
|
11969
12075
|
const more = page && page.current < page.total && page.next > page.current;
|
|
@@ -11971,7 +12077,7 @@ var ContractManager = class _ContractManager {
|
|
|
11971
12077
|
} while (pageIndex !== void 0);
|
|
11972
12078
|
}
|
|
11973
12079
|
} catch (e) {
|
|
11974
|
-
if (e instanceof
|
|
12080
|
+
if (e instanceof chunk3NALVGMJ_cjs.IndexerUtxosUnsupportedError) return found;
|
|
11975
12081
|
console.warn("[contracts] arkd spend lookup failed; using the explorer", e);
|
|
11976
12082
|
return void 0;
|
|
11977
12083
|
}
|
|
@@ -12024,7 +12130,7 @@ var ContractManager = class _ContractManager {
|
|
|
12024
12130
|
break;
|
|
12025
12131
|
}
|
|
12026
12132
|
} catch (err) {
|
|
12027
|
-
if (!
|
|
12133
|
+
if (!chunkOMPDPBT5_cjs.isRetryableProviderError(err)) throw err;
|
|
12028
12134
|
this.markSyncDegraded(err);
|
|
12029
12135
|
synced = false;
|
|
12030
12136
|
}
|
|
@@ -12112,7 +12218,7 @@ var ContractManager = class _ContractManager {
|
|
|
12112
12218
|
*/
|
|
12113
12219
|
async reconcilePendingFrontier(contracts) {
|
|
12114
12220
|
const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
|
|
12115
|
-
const vtxos = await
|
|
12221
|
+
const vtxos = await chunkOMPDPBT5_cjs.getAllNormalizedVtxos(
|
|
12116
12222
|
this.config.indexerProvider,
|
|
12117
12223
|
contracts.map((c) => c.script),
|
|
12118
12224
|
{ pendingOnly: true }
|
|
@@ -12187,7 +12293,7 @@ var ContractManager = class _ContractManager {
|
|
|
12187
12293
|
}
|
|
12188
12294
|
return result;
|
|
12189
12295
|
}
|
|
12190
|
-
async fetchContractVtxosBulk(contracts, pageSize =
|
|
12296
|
+
async fetchContractVtxosBulk(contracts, pageSize = chunkOMPDPBT5_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
|
|
12191
12297
|
if (contracts.length === 0) {
|
|
12192
12298
|
return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
|
|
12193
12299
|
}
|
|
@@ -12203,7 +12309,7 @@ var ContractManager = class _ContractManager {
|
|
|
12203
12309
|
before: syncWindow.before
|
|
12204
12310
|
}
|
|
12205
12311
|
} : {};
|
|
12206
|
-
const vtxos = await
|
|
12312
|
+
const vtxos = await chunkOMPDPBT5_cjs.getAllNormalizedVtxos(
|
|
12207
12313
|
this.config.indexerProvider,
|
|
12208
12314
|
contracts.map((c) => c.script),
|
|
12209
12315
|
{ ...windowOpts, pageSize }
|
|
@@ -12310,7 +12416,7 @@ function parseLegacyExpiry(batchExpiry) {
|
|
|
12310
12416
|
if (typeof batchExpiry !== "number" || !Number.isFinite(batchExpiry) || batchExpiry <= 0) {
|
|
12311
12417
|
return {};
|
|
12312
12418
|
}
|
|
12313
|
-
if (batchExpiry >=
|
|
12419
|
+
if (batchExpiry >= chunkOMPDPBT5_cjs.EXPIRY_MIN_PLAUSIBLE_MS) return { expiresAt: new Date(batchExpiry) };
|
|
12314
12420
|
return { expiresAtHeight: batchExpiry / 1e3 };
|
|
12315
12421
|
}
|
|
12316
12422
|
function legacyVtxoFacts(status) {
|
|
@@ -12548,7 +12654,7 @@ function backfillContractWatchState(store) {
|
|
|
12548
12654
|
};
|
|
12549
12655
|
readPage();
|
|
12550
12656
|
}
|
|
12551
|
-
var unspentFlag = (vtxo) =>
|
|
12657
|
+
var unspentFlag = (vtxo) => chunkOMPDPBT5_cjs.isVtxoSpent(vtxo) ? {} : { unspent: 1 };
|
|
12552
12658
|
function backfillVtxoIndexFields(transaction) {
|
|
12553
12659
|
const store = transaction.objectStore(STORE_VTXOS);
|
|
12554
12660
|
const pageSize = 1e3;
|
|
@@ -12579,7 +12685,7 @@ var DEFAULT_DB_NAME = "arkade-service-worker";
|
|
|
12579
12685
|
var DEFAULT_SERVICE_WORKER_ACTIVATION_TIMEOUT_MS = 1e4;
|
|
12580
12686
|
function normalizeOptions2(pathOrOptions) {
|
|
12581
12687
|
const o = typeof pathOrOptions === "string" ? { path: pathOrOptions } : pathOrOptions;
|
|
12582
|
-
|
|
12688
|
+
chunkOMPDPBT5_cjs.assertTimerMs("activationTimeoutMs", o.activationTimeoutMs);
|
|
12583
12689
|
return {
|
|
12584
12690
|
path: o.path,
|
|
12585
12691
|
activationTimeoutMs: o.activationTimeoutMs ?? DEFAULT_SERVICE_WORKER_ACTIVATION_TIMEOUT_MS
|
|
@@ -12807,7 +12913,7 @@ var deserializeTapLeaf = (t) => {
|
|
|
12807
12913
|
var deserializeVtxo = ({
|
|
12808
12914
|
intentTapLeafScript,
|
|
12809
12915
|
...o
|
|
12810
|
-
}) =>
|
|
12916
|
+
}) => chunkOMPDPBT5_cjs.normalizeVtxo({
|
|
12811
12917
|
...o,
|
|
12812
12918
|
createdAt: new Date(o.createdAt),
|
|
12813
12919
|
tapTree: base.hex.decode(o.tapTree),
|
|
@@ -13207,7 +13313,7 @@ var RestEmulatorProvider = class {
|
|
|
13207
13313
|
serverUrl;
|
|
13208
13314
|
async getInfo() {
|
|
13209
13315
|
const url = `${this.serverUrl}/v1/info`;
|
|
13210
|
-
const response = await
|
|
13316
|
+
const response = await chunkOMPDPBT5_cjs.baseFetch(url);
|
|
13211
13317
|
if (!response.ok) {
|
|
13212
13318
|
const errorText2 = await response.text();
|
|
13213
13319
|
throw new Error(`Failed to get emulator info: ${errorText2}`);
|
|
@@ -13331,7 +13437,7 @@ function arkadeServiceUrl(service) {
|
|
|
13331
13437
|
}
|
|
13332
13438
|
async function resolveArkadeService(service, opts = {}) {
|
|
13333
13439
|
const operatorUrl = arkadeServiceUrl(service);
|
|
13334
|
-
const arkProvider = opts.arkProvider ?? new
|
|
13440
|
+
const arkProvider = opts.arkProvider ?? new chunkOMPDPBT5_cjs.RestOperatorProvider(operatorUrl);
|
|
13335
13441
|
const info = opts.info ?? await arkProvider.getInfo();
|
|
13336
13442
|
if ("network" in service && service.network !== info.network) {
|
|
13337
13443
|
throw new Error(
|
|
@@ -13350,7 +13456,7 @@ async function resolveArkadeService(service, opts = {}) {
|
|
|
13350
13456
|
}
|
|
13351
13457
|
return {
|
|
13352
13458
|
arkProvider,
|
|
13353
|
-
indexerProvider: new
|
|
13459
|
+
indexerProvider: new chunk3NALVGMJ_cjs.RestIndexerProvider(operatorUrl),
|
|
13354
13460
|
onchainProvider: new EsploraProvider(esploraUrl),
|
|
13355
13461
|
emulator,
|
|
13356
13462
|
info
|
|
@@ -13434,7 +13540,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
13434
13540
|
*/
|
|
13435
13541
|
materializeDescriptorAt(index) {
|
|
13436
13542
|
const descriptor = this.identity.descriptor;
|
|
13437
|
-
const network =
|
|
13543
|
+
const network = chunkMQUATTIM_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
13438
13544
|
const expansion = descriptorsScure.expand({ descriptor, network, index });
|
|
13439
13545
|
const keyInfo = expansion.expansionMap?.["@0"];
|
|
13440
13546
|
if (!keyInfo?.keyExpression) {
|
|
@@ -13502,7 +13608,7 @@ function signingDescriptorIndex(descriptor) {
|
|
|
13502
13608
|
}
|
|
13503
13609
|
function newestWalletReceiveContract(contracts, serverPubKeyHex) {
|
|
13504
13610
|
return contracts.filter(
|
|
13505
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
13611
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkMQUATTIM_cjs.WALLET_RECEIVE_SOURCE
|
|
13506
13612
|
).sort((a, b) => {
|
|
13507
13613
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
13508
13614
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -13553,7 +13659,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
13553
13659
|
const provider = await resolveDescriptorProvider(config, setup.walletRepository);
|
|
13554
13660
|
if (!provider) return void 0;
|
|
13555
13661
|
const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
|
|
13556
|
-
const expectedContractType = setup.offchainTapscript instanceof
|
|
13662
|
+
const expectedContractType = setup.offchainTapscript instanceof chunkMQUATTIM_cjs.DelegateVtxo.Script ? "delegate" : "default";
|
|
13557
13663
|
const factoryOpts = {
|
|
13558
13664
|
walletRepository: setup.walletRepository,
|
|
13559
13665
|
contractRepository: setup.contractRepository,
|
|
@@ -13713,7 +13819,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
13713
13819
|
};
|
|
13714
13820
|
function deriveLeafPubkey(descriptor) {
|
|
13715
13821
|
try {
|
|
13716
|
-
return
|
|
13822
|
+
return chunkMQUATTIM_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
13717
13823
|
} catch (e) {
|
|
13718
13824
|
throw new NonRangeableDescriptorError(
|
|
13719
13825
|
"Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
|
|
@@ -13733,11 +13839,11 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
13733
13839
|
// Read at sign time to route rotated-pubkey inputs through `signWithDescriptor`; without
|
|
13734
13840
|
// it spends are rejected with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
13735
13841
|
metadata: {
|
|
13736
|
-
...tagSource && { source:
|
|
13842
|
+
...tagSource && { source: chunkMQUATTIM_cjs.WALLET_RECEIVE_SOURCE },
|
|
13737
13843
|
signingDescriptor: descriptor
|
|
13738
13844
|
}
|
|
13739
13845
|
};
|
|
13740
|
-
const params = tapscript instanceof
|
|
13846
|
+
const params = tapscript instanceof chunkMQUATTIM_cjs.DelegateVtxo.Script ? {
|
|
13741
13847
|
...base$1,
|
|
13742
13848
|
type: "delegate",
|
|
13743
13849
|
params: {
|
|
@@ -13758,10 +13864,10 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
13758
13864
|
return { tapscript, params };
|
|
13759
13865
|
}
|
|
13760
13866
|
function rebuildTapscript(current, pubKey) {
|
|
13761
|
-
if (current instanceof
|
|
13762
|
-
return new
|
|
13867
|
+
if (current instanceof chunkMQUATTIM_cjs.DelegateVtxo.Script) {
|
|
13868
|
+
return new chunkMQUATTIM_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
|
|
13763
13869
|
}
|
|
13764
|
-
return new
|
|
13870
|
+
return new chunkMQUATTIM_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
|
|
13765
13871
|
}
|
|
13766
13872
|
async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
|
|
13767
13873
|
const candidates = await collectContracts(contractRepository, {
|
|
@@ -13814,7 +13920,7 @@ async function resolvePrevTxs(txids, source, onchain) {
|
|
|
13814
13920
|
try {
|
|
13815
13921
|
const { txs } = await source.getVirtualTxs(wanted);
|
|
13816
13922
|
for (const psbt of txs) {
|
|
13817
|
-
const tx =
|
|
13923
|
+
const tx = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(psbt));
|
|
13818
13924
|
resolved.set(tx.id, tx.toBytes());
|
|
13819
13925
|
}
|
|
13820
13926
|
} catch (err) {
|
|
@@ -13847,7 +13953,7 @@ async function resolvePrevTxs(txids, source, onchain) {
|
|
|
13847
13953
|
async function attachPrevArkTxs(tx, txids, source, onchain) {
|
|
13848
13954
|
const pending = [];
|
|
13849
13955
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
13850
|
-
if (
|
|
13956
|
+
if (chunkOMPDPBT5_cjs.getArkPsbtFields(tx, i, chunkOMPDPBT5_cjs.PrevArkTxField).length === 0) pending.push(i);
|
|
13851
13957
|
}
|
|
13852
13958
|
if (pending.length === 0) return;
|
|
13853
13959
|
const resolved = await resolvePrevTxs(
|
|
@@ -13856,13 +13962,13 @@ async function attachPrevArkTxs(tx, txids, source, onchain) {
|
|
|
13856
13962
|
onchain
|
|
13857
13963
|
);
|
|
13858
13964
|
for (const i of pending) {
|
|
13859
|
-
|
|
13965
|
+
chunkOMPDPBT5_cjs.setArkPsbtField(tx, i, chunkOMPDPBT5_cjs.PrevArkTxField, resolved.get(txidAt(txids, i)));
|
|
13860
13966
|
}
|
|
13861
13967
|
}
|
|
13862
13968
|
async function attachPrevoutTxs(tx, source) {
|
|
13863
13969
|
const pending = [];
|
|
13864
13970
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
13865
|
-
if (
|
|
13971
|
+
if (chunkOMPDPBT5_cjs.getArkPsbtFields(tx, i, chunkOMPDPBT5_cjs.PrevoutTxField).length > 0) continue;
|
|
13866
13972
|
const input = tx.getInput(i);
|
|
13867
13973
|
if (!input?.txid) throw new PrevTxUnavailableError(`input ${i} has no outpoint`);
|
|
13868
13974
|
pending.push({ index: i, txid: base.hex.encode(input.txid) });
|
|
@@ -13877,7 +13983,7 @@ async function attachPrevoutTxs(tx, source) {
|
|
|
13877
13983
|
resolved.set(txids[i], result.value);
|
|
13878
13984
|
}
|
|
13879
13985
|
for (const { index, txid } of pending) {
|
|
13880
|
-
|
|
13986
|
+
chunkOMPDPBT5_cjs.setArkPsbtField(tx, index, chunkOMPDPBT5_cjs.PrevoutTxField, resolved.get(txid));
|
|
13881
13987
|
}
|
|
13882
13988
|
}
|
|
13883
13989
|
async function withPrevTxs(coins, source, onchain) {
|
|
@@ -13918,7 +14024,7 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
13918
14024
|
}
|
|
13919
14025
|
};
|
|
13920
14026
|
for (const vtxo of vtxos) {
|
|
13921
|
-
if (
|
|
14027
|
+
if (chunkOMPDPBT5_cjs.isVtxoSpent(vtxo)) continue;
|
|
13922
14028
|
addAssets(owned, vtxo);
|
|
13923
14029
|
if (vtxo.isUnrolled) {
|
|
13924
14030
|
unrolled += vtxo.value;
|
|
@@ -13928,11 +14034,11 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
13928
14034
|
deprecatedSignerLocked += vtxo.value;
|
|
13929
14035
|
continue;
|
|
13930
14036
|
}
|
|
13931
|
-
if (
|
|
14037
|
+
if (chunkOMPDPBT5_cjs.canRecoverOnchain(vtxo, now)) {
|
|
13932
14038
|
recoverable += vtxo.value;
|
|
13933
14039
|
continue;
|
|
13934
14040
|
}
|
|
13935
|
-
if (!
|
|
14041
|
+
if (!chunkOMPDPBT5_cjs.canSpendOffchain(vtxo, now)) continue;
|
|
13936
14042
|
if (vtxo.isPreconfirmed) {
|
|
13937
14043
|
preconfirmed += vtxo.value;
|
|
13938
14044
|
} else {
|
|
@@ -14207,7 +14313,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
14207
14313
|
if (!newest?.params.pubKey) return baseline;
|
|
14208
14314
|
try {
|
|
14209
14315
|
const pubKey = base.hex.decode(newest.params.pubKey);
|
|
14210
|
-
return new
|
|
14316
|
+
return new chunkMQUATTIM_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
|
|
14211
14317
|
} catch (e) {
|
|
14212
14318
|
console.warn("Skipping malformed boarding contract at boot", newest.script, e);
|
|
14213
14319
|
return baseline;
|
|
@@ -14239,21 +14345,21 @@ function filterFlatVtxos(vtxos, filter, pendingSpendOutpoints) {
|
|
|
14239
14345
|
if (vtxo.isUnrolled) {
|
|
14240
14346
|
return !!f.withUnrolled;
|
|
14241
14347
|
}
|
|
14242
|
-
if (
|
|
14348
|
+
if (chunkOMPDPBT5_cjs.isVtxoSpent(vtxo)) {
|
|
14243
14349
|
return false;
|
|
14244
14350
|
}
|
|
14245
|
-
if (!f.withRecoverable &&
|
|
14351
|
+
if (!f.withRecoverable && chunkOMPDPBT5_cjs.canRecoverOnchain(vtxo, now)) {
|
|
14246
14352
|
return false;
|
|
14247
14353
|
}
|
|
14248
14354
|
return true;
|
|
14249
14355
|
});
|
|
14250
14356
|
}
|
|
14251
14357
|
async function refreshSweptStateOfExpiredInputs(wallet, inputs) {
|
|
14252
|
-
const candidates = inputs.filter(
|
|
14358
|
+
const candidates = inputs.filter(chunkOMPDPBT5_cjs.isVirtualCoin).map(chunkOMPDPBT5_cjs.normalizeVtxo).filter((v) => !v.isSwept);
|
|
14253
14359
|
if (candidates.length === 0) return inputs;
|
|
14254
|
-
const now = candidates.some((v) => v.expiresAtHeight !== void 0) ? await
|
|
14360
|
+
const now = candidates.some((v) => v.expiresAtHeight !== void 0) ? await chunkOMPDPBT5_cjs.resolveTimeHeight(wallet.onchainProvider) : { timestamp: /* @__PURE__ */ new Date() };
|
|
14255
14361
|
const suspects = candidates.filter(
|
|
14256
|
-
(v) =>
|
|
14362
|
+
(v) => chunkOMPDPBT5_cjs.isPastExpiry(v, now) || v.expiresAtHeight !== void 0 && now.height === void 0
|
|
14257
14363
|
);
|
|
14258
14364
|
if (suspects.length === 0) return inputs;
|
|
14259
14365
|
let sweptNow;
|
|
@@ -14267,12 +14373,12 @@ async function refreshSweptStateOfExpiredInputs(wallet, inputs) {
|
|
|
14267
14373
|
);
|
|
14268
14374
|
} catch (e) {
|
|
14269
14375
|
const message = "could not confirm the swept state of expired settlement inputs; retry the settlement";
|
|
14270
|
-
throw
|
|
14376
|
+
throw chunkOMPDPBT5_cjs.isRetryableProviderError(e) ? new chunkOMPDPBT5_cjs.ProviderUnavailableError(message, { cause: e }) : new Error(message, { cause: e });
|
|
14271
14377
|
}
|
|
14272
14378
|
if (sweptNow.size === 0) return inputs;
|
|
14273
14379
|
return inputs.map((input) => {
|
|
14274
|
-
if (!
|
|
14275
|
-
return { ...
|
|
14380
|
+
if (!chunkOMPDPBT5_cjs.isVirtualCoin(input) || !sweptNow.has(`${input.txid}:${input.vout}`)) return input;
|
|
14381
|
+
return { ...chunkOMPDPBT5_cjs.normalizeVtxo(input), isSwept: true };
|
|
14276
14382
|
});
|
|
14277
14383
|
}
|
|
14278
14384
|
var PENDING_RECOVERY_REASON = "is past its operator signer's rotation cutoff \u2014 the operator will not co-sign it until it recovers";
|
|
@@ -14571,7 +14677,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14571
14677
|
async getArkadeReader() {
|
|
14572
14678
|
const indexer = this.indexerProvider;
|
|
14573
14679
|
return {
|
|
14574
|
-
getVtxos: (opts) =>
|
|
14680
|
+
getVtxos: (opts) => chunkOMPDPBT5_cjs.getNormalizedVtxos(indexer, opts),
|
|
14575
14681
|
getVirtualTxs: (txids, opts) => indexer.getVirtualTxs(txids, opts)
|
|
14576
14682
|
};
|
|
14577
14683
|
}
|
|
@@ -14621,7 +14727,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14621
14727
|
"Pass either `service` or `operatorProvider`/`indexerProvider`/`onchainProvider`, not both"
|
|
14622
14728
|
);
|
|
14623
14729
|
}
|
|
14624
|
-
const arkProvider = callerProvider || new
|
|
14730
|
+
const arkProvider = callerProvider || new chunkOMPDPBT5_cjs.RestOperatorProvider(config.service ? arkadeServiceUrl(config.service) : void 0);
|
|
14625
14731
|
let indexerProvider = config.indexerProvider;
|
|
14626
14732
|
if (!indexerProvider && !config.service) {
|
|
14627
14733
|
const derived = extractOperatorProviderUrl(arkProvider);
|
|
@@ -14630,7 +14736,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14630
14736
|
"indexerProvider is required when operatorProvider is provided without a discoverable serverUrl"
|
|
14631
14737
|
);
|
|
14632
14738
|
}
|
|
14633
|
-
indexerProvider = new
|
|
14739
|
+
indexerProvider = new chunk3NALVGMJ_cjs.RestIndexerProvider(derived ?? chunkFLPWNMX3_cjs.DEFAULT_ARKADE_SERVER_URL);
|
|
14634
14740
|
}
|
|
14635
14741
|
const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
14636
14742
|
const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
@@ -14688,8 +14794,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14688
14794
|
serverPubKey,
|
|
14689
14795
|
csvTimelock: exitTimelock
|
|
14690
14796
|
};
|
|
14691
|
-
const offchainTapscript = !delegatePubKey ? new
|
|
14692
|
-
const boardingTapscript =
|
|
14797
|
+
const offchainTapscript = !delegatePubKey ? new chunkMQUATTIM_cjs.DefaultVtxo.Script(offchainOptions) : new chunkMQUATTIM_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
|
|
14798
|
+
const boardingTapscript = chunkMQUATTIM_cjs.BoardingContractHandler.createScript({
|
|
14693
14799
|
pubKey: base.hex.encode(pubKey),
|
|
14694
14800
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
14695
14801
|
csvTimelock: chunkFLPWNMX3_cjs.timelockToSequence(boardingTimelock).toString()
|
|
@@ -14858,7 +14964,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14858
14964
|
if (!filter?.withUnrolled) {
|
|
14859
14965
|
logExcludedVtxos(
|
|
14860
14966
|
"getSpendableVtxos",
|
|
14861
|
-
snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !
|
|
14967
|
+
snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !chunkOMPDPBT5_cjs.isVtxoSpent(vtxo)),
|
|
14862
14968
|
[() => UNROLLED_REASON]
|
|
14863
14969
|
);
|
|
14864
14970
|
}
|
|
@@ -14998,12 +15104,13 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14998
15104
|
* Return wallet transaction history derived from Arkade state and boarding transactions.
|
|
14999
15105
|
*/
|
|
15000
15106
|
async getTransactionHistory() {
|
|
15001
|
-
const [
|
|
15107
|
+
const [fullSnapshot, { boardingTxs, commitmentsToIgnore }] = await Promise.all([
|
|
15002
15108
|
this.contractSnapshot(),
|
|
15003
15109
|
this.getBoardingTxs()
|
|
15004
15110
|
]);
|
|
15111
|
+
const snapshot = fullSnapshot.filter(({ contract }) => !isRecoveryOnlyContract(contract));
|
|
15005
15112
|
const allVtxos = snapshot.flatMap((_) => _.vtxos);
|
|
15006
|
-
const resolveTxCreatedAt = (txids) =>
|
|
15113
|
+
const resolveTxCreatedAt = (txids) => chunkOMPDPBT5_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
|
|
15007
15114
|
return buildTransactionHistory(
|
|
15008
15115
|
allVtxos,
|
|
15009
15116
|
boardingTxs,
|
|
@@ -15203,11 +15310,11 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
15203
15310
|
const currentServerPubKey = this.boardingTapscript.options.serverPubKey;
|
|
15204
15311
|
const currentServerSigner = toXOnlySignerHex(base.hex.encode(currentServerPubKey));
|
|
15205
15312
|
const signers = /* @__PURE__ */ new Set([currentServerSigner, ...allowedSigners ?? []]);
|
|
15206
|
-
const boardingCsv = this.boardingTapscript.options.csvTimelock ??
|
|
15313
|
+
const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkMQUATTIM_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
15207
15314
|
const baselinePubkey = await this.identity.xOnlyPublicKey();
|
|
15208
15315
|
for (const signer of signers) {
|
|
15209
15316
|
add(
|
|
15210
|
-
new
|
|
15317
|
+
new chunkMQUATTIM_cjs.DefaultVtxo.Script({
|
|
15211
15318
|
pubKey: baselinePubkey,
|
|
15212
15319
|
serverPubKey: base.hex.decode(signer),
|
|
15213
15320
|
csvTimelock: boardingCsv
|
|
@@ -15228,7 +15335,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
15228
15335
|
continue;
|
|
15229
15336
|
}
|
|
15230
15337
|
add(
|
|
15231
|
-
c.type === "default" ?
|
|
15338
|
+
c.type === "default" ? chunkMQUATTIM_cjs.DefaultContractHandler.createScript(c.params) : chunkMQUATTIM_cjs.BoardingContractHandler.createScript(c.params)
|
|
15232
15339
|
);
|
|
15233
15340
|
} catch (e) {
|
|
15234
15341
|
console.warn("Skipping malformed boarding contract", c.script, e);
|
|
@@ -15277,7 +15384,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
15277
15384
|
tapscripts.map(async (tapscript, i) => {
|
|
15278
15385
|
const contract = contracts.get(scripts[i]);
|
|
15279
15386
|
const spent = new Set(
|
|
15280
|
-
contract ? (await getVtxosForContract(this.walletRepository, contract)).filter(
|
|
15387
|
+
contract ? (await getVtxosForContract(this.walletRepository, contract)).filter(chunkOMPDPBT5_cjs.isVtxoSpent).map(vtxoOutpoint) : []
|
|
15281
15388
|
);
|
|
15282
15389
|
const utxos = fetched[i].filter((c) => !spent.has(vtxoOutpoint(c))).map((utxo) => extendCoinWithTapscript(tapscript, utxo));
|
|
15283
15390
|
return {
|
|
@@ -15306,10 +15413,10 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
15306
15413
|
timer = setTimeout(
|
|
15307
15414
|
() => reject(
|
|
15308
15415
|
new Error(
|
|
15309
|
-
`Boarding address lookup timed out after ${
|
|
15416
|
+
`Boarding address lookup timed out after ${chunkOMPDPBT5_cjs.READ_TIMEOUT_MS}ms`
|
|
15310
15417
|
)
|
|
15311
15418
|
),
|
|
15312
|
-
|
|
15419
|
+
chunkOMPDPBT5_cjs.READ_TIMEOUT_MS
|
|
15313
15420
|
);
|
|
15314
15421
|
})
|
|
15315
15422
|
]);
|
|
@@ -15495,7 +15602,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
15495
15602
|
/** Fetch Arkade transaction ids that are still pending final settlement. */
|
|
15496
15603
|
async fetchPendingTxs() {
|
|
15497
15604
|
const scripts = await this.getWalletScripts();
|
|
15498
|
-
const vtxos = await
|
|
15605
|
+
const vtxos = await chunkOMPDPBT5_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
|
|
15499
15606
|
return vtxos.filter(
|
|
15500
15607
|
(vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
|
|
15501
15608
|
).map((_) => _.arkTxId);
|
|
@@ -15526,7 +15633,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
15526
15633
|
});
|
|
15527
15634
|
for (const contract of contracts) {
|
|
15528
15635
|
if (map.has(contract.script)) continue;
|
|
15529
|
-
const handler =
|
|
15636
|
+
const handler = chunkMQUATTIM_cjs.contractHandlers.get(contract.type);
|
|
15530
15637
|
if (handler) {
|
|
15531
15638
|
const script = handler.createScript(contract.params);
|
|
15532
15639
|
map.set(contract.script, script);
|
|
@@ -15645,7 +15752,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
15645
15752
|
});
|
|
15646
15753
|
try {
|
|
15647
15754
|
const baselinePubkey = await baselinePubkeyPromise;
|
|
15648
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
15755
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkMQUATTIM_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
15649
15756
|
const baselineSigners = [
|
|
15650
15757
|
this.offchainTapscript.options.serverPubKey,
|
|
15651
15758
|
...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
|
|
@@ -15655,7 +15762,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
15655
15762
|
for (const serverPubKey of baselineSigners) {
|
|
15656
15763
|
for (const csvTimelock of this.walletContractTimelocks) {
|
|
15657
15764
|
const csvTimelockStr = chunkFLPWNMX3_cjs.timelockToSequence(csvTimelock).toString();
|
|
15658
|
-
const defaultScript = new
|
|
15765
|
+
const defaultScript = new chunkMQUATTIM_cjs.DefaultVtxo.Script({
|
|
15659
15766
|
pubKey: baselinePubkey,
|
|
15660
15767
|
serverPubKey,
|
|
15661
15768
|
csvTimelock
|
|
@@ -15676,7 +15783,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
15676
15783
|
});
|
|
15677
15784
|
}
|
|
15678
15785
|
if (delegatePubKey) {
|
|
15679
|
-
const delegateScript = new
|
|
15786
|
+
const delegateScript = new chunkMQUATTIM_cjs.DelegateVtxo.Script({
|
|
15680
15787
|
pubKey: baselinePubkey,
|
|
15681
15788
|
serverPubKey,
|
|
15682
15789
|
delegatePubKey,
|
|
@@ -15700,9 +15807,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
15700
15807
|
}
|
|
15701
15808
|
}
|
|
15702
15809
|
}
|
|
15703
|
-
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ??
|
|
15810
|
+
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkMQUATTIM_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
15704
15811
|
for (const serverPubKey of baselineSigners) {
|
|
15705
|
-
const baselineBoarding = new
|
|
15812
|
+
const baselineBoarding = new chunkMQUATTIM_cjs.DefaultVtxo.Script({
|
|
15706
15813
|
pubKey: baselinePubkey,
|
|
15707
15814
|
serverPubKey,
|
|
15708
15815
|
csvTimelock: boardingCsvTimelock
|
|
@@ -15919,7 +16026,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15919
16026
|
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
15920
16027
|
deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
|
|
15921
16028
|
csvTimelocks: this.walletContractTimelocks,
|
|
15922
|
-
delegatePubKey: this.offchainTapscript instanceof
|
|
16029
|
+
delegatePubKey: this.offchainTapscript instanceof chunkMQUATTIM_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
|
|
15923
16030
|
};
|
|
15924
16031
|
}
|
|
15925
16032
|
_signerRouter;
|
|
@@ -16081,7 +16188,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16081
16188
|
const [row] = await manager.getContracts({ script: base.hex.encode(display.pkScript) });
|
|
16082
16189
|
const persisted = row?.metadata?.signingDescriptor;
|
|
16083
16190
|
if (typeof persisted === "string") return persisted;
|
|
16084
|
-
return
|
|
16191
|
+
return chunkMQUATTIM_cjs.identityDescriptor(this.identity);
|
|
16085
16192
|
}
|
|
16086
16193
|
/**
|
|
16087
16194
|
* Build, persist and shape one address of `type` owned by `descriptor`. The descriptor is the
|
|
@@ -16091,7 +16198,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16091
16198
|
async mintAddress(manager, type, descriptor, tagSource, allocated) {
|
|
16092
16199
|
if (type === "boarding") {
|
|
16093
16200
|
const built2 = this.buildBoardingContract(
|
|
16094
|
-
|
|
16201
|
+
chunkMQUATTIM_cjs.deriveDescriptorLeafPubKey(descriptor),
|
|
16095
16202
|
descriptor,
|
|
16096
16203
|
tagSource
|
|
16097
16204
|
);
|
|
@@ -16128,11 +16235,11 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16128
16235
|
* (offchain analogue: {@link buildReceiveContract}).
|
|
16129
16236
|
*/
|
|
16130
16237
|
buildBoardingContract(pubKey, descriptor, tagSource) {
|
|
16131
|
-
const tapscript = new
|
|
16238
|
+
const tapscript = new chunkMQUATTIM_cjs.DefaultVtxo.Script({
|
|
16132
16239
|
...this._boardingTapscript.options,
|
|
16133
16240
|
pubKey
|
|
16134
16241
|
});
|
|
16135
|
-
const csvTimelock = tapscript.options.csvTimelock ??
|
|
16242
|
+
const csvTimelock = tapscript.options.csvTimelock ?? chunkMQUATTIM_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
16136
16243
|
return {
|
|
16137
16244
|
tapscript,
|
|
16138
16245
|
params: {
|
|
@@ -16146,7 +16253,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16146
16253
|
address: tapscript.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
16147
16254
|
state: "active",
|
|
16148
16255
|
metadata: {
|
|
16149
|
-
...tagSource && { source:
|
|
16256
|
+
...tagSource && { source: chunkMQUATTIM_cjs.WALLET_RECEIVE_SOURCE },
|
|
16150
16257
|
signingDescriptor: descriptor
|
|
16151
16258
|
}
|
|
16152
16259
|
}
|
|
@@ -16168,7 +16275,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16168
16275
|
if (this._hdProvider) {
|
|
16169
16276
|
return (await this.getContractManager()).getNextSigningDescriptor();
|
|
16170
16277
|
}
|
|
16171
|
-
return
|
|
16278
|
+
return chunkMQUATTIM_cjs.identityDescriptor(this.identity);
|
|
16172
16279
|
}
|
|
16173
16280
|
/**
|
|
16174
16281
|
* @see HDAllocationCapable.advanceSigningDescriptorWatermark
|
|
@@ -16274,21 +16381,21 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16274
16381
|
]);
|
|
16275
16382
|
const [currentOffchainRow] = offchainRows2;
|
|
16276
16383
|
const [currentBoardingRow] = boardingRows;
|
|
16277
|
-
const newOffchain = this.offchainTapscript instanceof
|
|
16384
|
+
const newOffchain = this.offchainTapscript instanceof chunkMQUATTIM_cjs.DelegateVtxo.Script ? new chunkMQUATTIM_cjs.DelegateVtxo.Script({
|
|
16278
16385
|
...this.offchainTapscript.options,
|
|
16279
16386
|
serverPubKey: xonly
|
|
16280
|
-
}) : new
|
|
16387
|
+
}) : new chunkMQUATTIM_cjs.DefaultVtxo.Script({
|
|
16281
16388
|
...this.offchainTapscript.options,
|
|
16282
16389
|
serverPubKey: xonly
|
|
16283
16390
|
});
|
|
16284
|
-
const newBoarding = new
|
|
16391
|
+
const newBoarding = new chunkMQUATTIM_cjs.DefaultVtxo.Script({
|
|
16285
16392
|
...this._boardingTapscript.options,
|
|
16286
16393
|
serverPubKey: xonly
|
|
16287
16394
|
});
|
|
16288
16395
|
const offchainCsv = chunkFLPWNMX3_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
|
|
16289
16396
|
const newOffchainScript = base.hex.encode(newOffchain.pkScript);
|
|
16290
16397
|
const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
|
|
16291
|
-
if (newOffchain instanceof
|
|
16398
|
+
if (newOffchain instanceof chunkMQUATTIM_cjs.DelegateVtxo.Script) {
|
|
16292
16399
|
await manager.createContract({
|
|
16293
16400
|
type: "delegate",
|
|
16294
16401
|
params: {
|
|
@@ -16316,7 +16423,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16316
16423
|
metadata: currentOffchainRow?.metadata
|
|
16317
16424
|
});
|
|
16318
16425
|
}
|
|
16319
|
-
const boardingCsv = newBoarding.options.csvTimelock ??
|
|
16426
|
+
const boardingCsv = newBoarding.options.csvTimelock ?? chunkMQUATTIM_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
16320
16427
|
await manager.createContract({
|
|
16321
16428
|
type: "boarding",
|
|
16322
16429
|
params: {
|
|
@@ -16350,14 +16457,14 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16350
16457
|
_restoreInFlight;
|
|
16351
16458
|
_addPendingSpends(inputs) {
|
|
16352
16459
|
for (const input of inputs) {
|
|
16353
|
-
if (
|
|
16460
|
+
if (chunkOMPDPBT5_cjs.isVirtualCoin(input)) {
|
|
16354
16461
|
this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
|
|
16355
16462
|
}
|
|
16356
16463
|
}
|
|
16357
16464
|
}
|
|
16358
16465
|
_removePendingSpends(inputs) {
|
|
16359
16466
|
for (const input of inputs) {
|
|
16360
|
-
if (
|
|
16467
|
+
if (chunkOMPDPBT5_cjs.isVirtualCoin(input)) {
|
|
16361
16468
|
this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
|
|
16362
16469
|
}
|
|
16363
16470
|
}
|
|
@@ -16421,7 +16528,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16421
16528
|
if (clashing.length > 0) throw new VtxoReservedError(clashing, "in-flight");
|
|
16422
16529
|
}
|
|
16423
16530
|
_assertNotHeld(inputs) {
|
|
16424
|
-
const held = coinKeys(inputs.filter(
|
|
16531
|
+
const held = coinKeys(inputs.filter(chunkOMPDPBT5_cjs.isVirtualCoin)).filter(
|
|
16425
16532
|
(key) => this._heldOutpoints.has(key)
|
|
16426
16533
|
);
|
|
16427
16534
|
if (held.length > 0) throw new VtxoReservedError(held, "held");
|
|
@@ -16460,11 +16567,11 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16460
16567
|
const hd = provider !== void 0;
|
|
16461
16568
|
const [manager, staticDescriptor, arkInfo] = await Promise.all([
|
|
16462
16569
|
this.getContractManager(),
|
|
16463
|
-
hd ? void 0 :
|
|
16570
|
+
hd ? void 0 : chunkMQUATTIM_cjs.identityDescriptor(this.identity),
|
|
16464
16571
|
this.arkProvider.getInfo()
|
|
16465
16572
|
]);
|
|
16466
16573
|
const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
|
|
16467
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
16574
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkMQUATTIM_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
16468
16575
|
const currentSignerPubKey = chunkJFJNB7ZH_cjs.toXOnly(base.hex.decode(arkInfo.signerPubkey), "ark signer key");
|
|
16469
16576
|
const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
|
|
16470
16577
|
(s) => chunkJFJNB7ZH_cjs.toXOnly(base.hex.decode(s.pubkey), "deprecated signer key")
|
|
@@ -16479,7 +16586,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16479
16586
|
deprecatedSignerPubKeys,
|
|
16480
16587
|
csvTimelocks: this.walletContractTimelocks,
|
|
16481
16588
|
// Boarding-exit CSV, distinct from the unilateral-exit matrix.
|
|
16482
|
-
boardingTimelock: this.boardingTapscript.options.csvTimelock ??
|
|
16589
|
+
boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkMQUATTIM_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
|
|
16483
16590
|
delegatePubKey
|
|
16484
16591
|
};
|
|
16485
16592
|
const result = await manager.scanContracts({
|
|
@@ -16812,7 +16919,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16812
16919
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
16813
16920
|
break;
|
|
16814
16921
|
}
|
|
16815
|
-
const inputFee = estimator.evalOffchainInput(
|
|
16922
|
+
const inputFee = estimator.evalOffchainInput(chunkOMPDPBT5_cjs.toOffchainInputFeeParams(vtxo));
|
|
16816
16923
|
if (inputFee.satoshis >= vtxo.value) {
|
|
16817
16924
|
continue;
|
|
16818
16925
|
}
|
|
@@ -16936,11 +17043,11 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16936
17043
|
]);
|
|
16937
17044
|
let intentTxId;
|
|
16938
17045
|
try {
|
|
16939
|
-
intentTxId =
|
|
17046
|
+
intentTxId = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(intent.proof)).id;
|
|
16940
17047
|
} catch {
|
|
16941
17048
|
intentTxId = params.inputs.map((i) => `${i.txid}:${i.vout}`).sort().join("|");
|
|
16942
17049
|
}
|
|
16943
|
-
const settleInputVtxos = params.inputs.filter(
|
|
17050
|
+
const settleInputVtxos = params.inputs.filter(chunkOMPDPBT5_cjs.isVirtualCoin);
|
|
16944
17051
|
const contractManager = await this.getContractManager();
|
|
16945
17052
|
await contractManager.assertAnnotatable(settleInputVtxos);
|
|
16946
17053
|
await contractManager.assertSpendableNow?.(
|
|
@@ -16949,7 +17056,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16949
17056
|
);
|
|
16950
17057
|
if (picked) this._assertNotHeld(params.inputs);
|
|
16951
17058
|
this._addPendingSpends(params.inputs);
|
|
16952
|
-
const boardingKeys = onReserved ? coinKeys(params.inputs.filter((i) => !
|
|
17059
|
+
const boardingKeys = onReserved ? coinKeys(params.inputs.filter((i) => !chunkOMPDPBT5_cjs.isVirtualCoin(i))) : [];
|
|
16953
17060
|
for (const key of boardingKeys) this._pendingSpendOutpoints.add(key);
|
|
16954
17061
|
const settlingKeys = params.inputs.map((i) => `${i.txid}:${i.vout}`);
|
|
16955
17062
|
for (const key of settlingKeys) this._settlingOutpoints.add(key);
|
|
@@ -17059,7 +17166,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17059
17166
|
async maybeRotateBoardingAfterBoard(inputs) {
|
|
17060
17167
|
if (!this._descriptorProvider) return;
|
|
17061
17168
|
const consumedBoarding = inputs.some(
|
|
17062
|
-
(input) => typeof input !== "string" && !
|
|
17169
|
+
(input) => typeof input !== "string" && !chunkOMPDPBT5_cjs.isVirtualCoin(input)
|
|
17063
17170
|
);
|
|
17064
17171
|
if (!consumedBoarding) return;
|
|
17065
17172
|
try {
|
|
@@ -17070,7 +17177,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17070
17177
|
}
|
|
17071
17178
|
async handleSettlementFinalizationEvent(event, inputs, forfeitOutputScript, expectedRecipients, connectorsGraph, validatedCommitmentTxid) {
|
|
17072
17179
|
const signedForfeits = [];
|
|
17073
|
-
let settlementPsbt =
|
|
17180
|
+
let settlementPsbt = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
17074
17181
|
assertFinalCommitmentMatchesValidated(
|
|
17075
17182
|
settlementPsbt,
|
|
17076
17183
|
validatedCommitmentTxid,
|
|
@@ -17083,7 +17190,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17083
17190
|
let connectorIndex = 0;
|
|
17084
17191
|
const connectorsLeaves = connectorsGraph?.leaves() || [];
|
|
17085
17192
|
for (const input of inputs) {
|
|
17086
|
-
if (!
|
|
17193
|
+
if (!chunkOMPDPBT5_cjs.isVirtualCoin(input)) {
|
|
17087
17194
|
let matched = false;
|
|
17088
17195
|
for (let i = 0; i < settlementPsbt.inputsLength; i++) {
|
|
17089
17196
|
const settlementInput = settlementPsbt.getInput(i);
|
|
@@ -17121,7 +17228,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17121
17228
|
}
|
|
17122
17229
|
continue;
|
|
17123
17230
|
}
|
|
17124
|
-
if (!
|
|
17231
|
+
if (!chunkOMPDPBT5_cjs.requiresForfeit(input) || isSubdust({ value: input.value }, this.dustAmount)) {
|
|
17125
17232
|
continue;
|
|
17126
17233
|
}
|
|
17127
17234
|
if (connectorsLeaves.length === 0) {
|
|
@@ -17248,7 +17355,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17248
17355
|
if (!xOnlyPublicKeys.includes(base.hex.encode(xonlySignerPublicKey))) {
|
|
17249
17356
|
return { skip: true };
|
|
17250
17357
|
}
|
|
17251
|
-
const commitmentTx =
|
|
17358
|
+
const commitmentTx = chunkOMPDPBT5_cjs.Transaction.fromPSBT(
|
|
17252
17359
|
base.base64.decode(event.unsignedCommitmentTx)
|
|
17253
17360
|
);
|
|
17254
17361
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
@@ -17330,9 +17437,9 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17330
17437
|
...existing ?? {},
|
|
17331
17438
|
proofTxId: intentTxId,
|
|
17332
17439
|
registerProof: intent.proof,
|
|
17333
|
-
registerProofMessage:
|
|
17440
|
+
registerProofMessage: chunkOMPDPBT5_cjs.Proof.encodeMessage(intent.message),
|
|
17334
17441
|
deleteProof: deleteIntent.proof,
|
|
17335
|
-
deleteProofMessage:
|
|
17442
|
+
deleteProofMessage: chunkOMPDPBT5_cjs.Proof.encodeMessage(deleteIntent.message),
|
|
17336
17443
|
proofInputs: inputs.map((i) => ({
|
|
17337
17444
|
txid: i.txid,
|
|
17338
17445
|
vout: i.vout
|
|
@@ -17363,7 +17470,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17363
17470
|
}
|
|
17364
17471
|
/** @see IWallet.cosignOnchainTx */
|
|
17365
17472
|
async cosignOnchainTx(psbt) {
|
|
17366
|
-
const tx = typeof psbt === "string" ?
|
|
17473
|
+
const tx = typeof psbt === "string" ? chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(psbt)) : psbt;
|
|
17367
17474
|
return this._withTxLock(async () => {
|
|
17368
17475
|
await (await this.getContractManager()).syncOnchain();
|
|
17369
17476
|
return this._cosignOnchainTxImpl(tx);
|
|
@@ -17428,7 +17535,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17428
17535
|
if (reasons.length > 0) throw new OnchainCosignPreflightError(reasons.join("; "));
|
|
17429
17536
|
}
|
|
17430
17537
|
const feeRate = await this.onchainProvider.getFeeRate() ?? 1;
|
|
17431
|
-
const tx = new
|
|
17538
|
+
const tx = new chunkOMPDPBT5_cjs.Transaction({ version: 2 });
|
|
17432
17539
|
if (sweepTo) {
|
|
17433
17540
|
const swept = candidates.slice(0, MAX_COSIGN_INPUTS);
|
|
17434
17541
|
for (const { coin } of swept) {
|
|
@@ -17489,7 +17596,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17489
17596
|
continue;
|
|
17490
17597
|
}
|
|
17491
17598
|
const { coin, contract, script } = mine;
|
|
17492
|
-
const path =
|
|
17599
|
+
const path = chunkMQUATTIM_cjs.contractHandlers.get(contract.type).selectPath(script, contract, {
|
|
17493
17600
|
collaborative: true,
|
|
17494
17601
|
currentTime: Date.now(),
|
|
17495
17602
|
blockHeight: tip.height,
|
|
@@ -17539,7 +17646,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17539
17646
|
onchainProvider: this.onchainProvider
|
|
17540
17647
|
});
|
|
17541
17648
|
} catch (e) {
|
|
17542
|
-
if (e instanceof
|
|
17649
|
+
if (e instanceof chunkOMPDPBT5_cjs.OnchainCosignAmbiguousError || isCosignRejectedAfterSigning(e)) {
|
|
17543
17650
|
await markPending(signed.id);
|
|
17544
17651
|
}
|
|
17545
17652
|
throw e;
|
|
@@ -17559,7 +17666,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17559
17666
|
this.lockedOutpoints(),
|
|
17560
17667
|
this.onchainCoins(manager)
|
|
17561
17668
|
]);
|
|
17562
|
-
const boardingCsv = this.boardingTapscript.options.csvTimelock ??
|
|
17669
|
+
const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkMQUATTIM_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
17563
17670
|
return coins.filter(
|
|
17564
17671
|
({ coin, contract }) => !locked.has(vtxoOutpoint(coin)) && needsOnchainSweep(coin, contract, boardingCsv, tip, this._cosignMarginBlocks)
|
|
17565
17672
|
).slice(0, MAX_COSIGN_INPUTS).map(({ coin }) => ({ txid: coin.txid, vout: coin.vout }));
|
|
@@ -17571,8 +17678,8 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17571
17678
|
unspentOnly: true
|
|
17572
17679
|
});
|
|
17573
17680
|
return snapshot.flatMap(({ contract, vtxos }) => {
|
|
17574
|
-
const handler =
|
|
17575
|
-
const coins = vtxos.filter((v) => v.isUnrolled && !
|
|
17681
|
+
const handler = chunkMQUATTIM_cjs.contractHandlers.get(contract.type);
|
|
17682
|
+
const coins = vtxos.filter((v) => v.isUnrolled && !chunkOMPDPBT5_cjs.isVtxoSpent(v));
|
|
17576
17683
|
if (!handler || coins.length === 0) return [];
|
|
17577
17684
|
const script = handler.createScript(contract.params);
|
|
17578
17685
|
return coins.map((coin) => ({ coin, contract, script }));
|
|
@@ -17582,7 +17689,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17582
17689
|
try {
|
|
17583
17690
|
return await this.arkProvider.registerIntent(intent);
|
|
17584
17691
|
} catch (error) {
|
|
17585
|
-
if (error instanceof
|
|
17692
|
+
if (error instanceof chunkOMPDPBT5_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
|
|
17586
17693
|
const deleteIntent = await this.makeDeleteIntentSignature(inputs);
|
|
17587
17694
|
await this.arkProvider.deleteIntent(deleteIntent);
|
|
17588
17695
|
return this.arkProvider.registerIntent(intent);
|
|
@@ -17598,7 +17705,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17598
17705
|
expire_at: 0,
|
|
17599
17706
|
cosigners_public_keys: cosignerPubKeys
|
|
17600
17707
|
};
|
|
17601
|
-
const proof =
|
|
17708
|
+
const proof = chunkOMPDPBT5_cjs.Proof.create(message, coins, outputs);
|
|
17602
17709
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
17603
17710
|
return {
|
|
17604
17711
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -17610,7 +17717,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17610
17717
|
type: "delete",
|
|
17611
17718
|
expire_at: 0
|
|
17612
17719
|
};
|
|
17613
|
-
const proof =
|
|
17720
|
+
const proof = chunkOMPDPBT5_cjs.Proof.create(message, coins, []);
|
|
17614
17721
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
17615
17722
|
return {
|
|
17616
17723
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -17622,7 +17729,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17622
17729
|
type: "get-pending-tx",
|
|
17623
17730
|
expire_at: 0
|
|
17624
17731
|
};
|
|
17625
|
-
const proof =
|
|
17732
|
+
const proof = chunkOMPDPBT5_cjs.Proof.create(message, coins, []);
|
|
17626
17733
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
17627
17734
|
return {
|
|
17628
17735
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -17643,7 +17750,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17643
17750
|
if (!vtxos || vtxos.length === 0) {
|
|
17644
17751
|
const scriptMap = await this.getScriptMap();
|
|
17645
17752
|
const allExtended = [];
|
|
17646
|
-
const fetchedVtxos = await
|
|
17753
|
+
const fetchedVtxos = await chunkOMPDPBT5_cjs.getAllNormalizedVtxos(this.indexerProvider, [
|
|
17647
17754
|
...scriptMap.keys()
|
|
17648
17755
|
]);
|
|
17649
17756
|
for (const vtxo of fetchedVtxos) {
|
|
@@ -17686,8 +17793,8 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17686
17793
|
batchPending.push(pendingTx.arkTxid);
|
|
17687
17794
|
try {
|
|
17688
17795
|
const checkpointTxs = pendingTx.signedCheckpointTxs.map((c) => {
|
|
17689
|
-
const tx =
|
|
17690
|
-
|
|
17796
|
+
const tx = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(c));
|
|
17797
|
+
chunkOMPDPBT5_cjs.assertAllowedSighashTypes(tx);
|
|
17691
17798
|
return tx;
|
|
17692
17799
|
});
|
|
17693
17800
|
assertCheckpointsMatchInputs(
|
|
@@ -17858,11 +17965,17 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17858
17965
|
const myPkScript = chunkFLPWNMX3_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
|
|
17859
17966
|
let { spendable, recoverable, unclaimed } = this.classifyCashVtxos(vtxos);
|
|
17860
17967
|
let swept = 0;
|
|
17968
|
+
const claims = [];
|
|
17861
17969
|
const drainable = vtxos.filter(
|
|
17862
17970
|
(vtxo) => !isSubdust(vtxo, this.dustAmount) && !vtxo.isUnrolled
|
|
17863
17971
|
);
|
|
17864
17972
|
if (drainable.length > 0) {
|
|
17865
|
-
let drained = {
|
|
17973
|
+
let drained = {
|
|
17974
|
+
count: 0,
|
|
17975
|
+
swept: 0,
|
|
17976
|
+
claimed: /* @__PURE__ */ new Set(),
|
|
17977
|
+
claims: []
|
|
17978
|
+
};
|
|
17866
17979
|
try {
|
|
17867
17980
|
drained = await this.finalizePendingCashTxs(
|
|
17868
17981
|
cash,
|
|
@@ -17873,6 +17986,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17873
17986
|
} catch (error) {
|
|
17874
17987
|
console.error("Failed to drain pending arkadeCash txs:", error);
|
|
17875
17988
|
}
|
|
17989
|
+
claims.push(...drained.claims);
|
|
17876
17990
|
if (drained.count > 0) {
|
|
17877
17991
|
vtxos = await this.fetchAllVtxos(scripts);
|
|
17878
17992
|
({ spendable, recoverable, unclaimed } = this.classifyCashVtxos(vtxos));
|
|
@@ -17890,7 +18004,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17890
18004
|
);
|
|
17891
18005
|
for (const vtxo of spendable) {
|
|
17892
18006
|
try {
|
|
17893
|
-
await signAndSubmitOffchainTx({
|
|
18007
|
+
const registeredTxid = await signAndSubmitOffchainTx({
|
|
17894
18008
|
identity: cash.identity,
|
|
17895
18009
|
provider: this.arkProvider,
|
|
17896
18010
|
inputs: [
|
|
@@ -17906,6 +18020,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17906
18020
|
serverUnrollScript,
|
|
17907
18021
|
oneShot: this.oneShotSubmit
|
|
17908
18022
|
});
|
|
18023
|
+
claims.push({ txid: registeredTxid, amount: vtxo.value });
|
|
17909
18024
|
swept += vtxo.value;
|
|
17910
18025
|
} catch (error) {
|
|
17911
18026
|
console.error(
|
|
@@ -17936,6 +18051,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17936
18051
|
}
|
|
17937
18052
|
}
|
|
17938
18053
|
return {
|
|
18054
|
+
claims,
|
|
17939
18055
|
swept,
|
|
17940
18056
|
recovering: {
|
|
17941
18057
|
amount: recovering.reduce((total, vtxo) => total + vtxo.value, 0),
|
|
@@ -18053,6 +18169,36 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
18053
18169
|
}
|
|
18054
18170
|
await manager.deleteContract(script);
|
|
18055
18171
|
}
|
|
18172
|
+
/**
|
|
18173
|
+
* Correlate an imported voucher's settlement with the voucher record. This
|
|
18174
|
+
* is deliberately kept on wallet state rather than being inferred from the
|
|
18175
|
+
* generic recovery row, which has no safe public correlation key. The
|
|
18176
|
+
* imported contract carries no cash id, so its script is the join key:
|
|
18177
|
+
* the script is the voucher id.
|
|
18178
|
+
*/
|
|
18179
|
+
async correlateArkadeCashRecovery(cashId, txid, amount, outcome = "recovered") {
|
|
18180
|
+
await updateWalletState(this.walletRepository, (state) => {
|
|
18181
|
+
const raw = state.settings?.arkadeCashRecovery;
|
|
18182
|
+
const entries = Array.isArray(raw) ? raw : [];
|
|
18183
|
+
const index = entries.findIndex(
|
|
18184
|
+
(entry) => isArkadeCashRecord(entry) && entry.id === cashId
|
|
18185
|
+
);
|
|
18186
|
+
const previous = index >= 0 ? entries[index] : void 0;
|
|
18187
|
+
if (previous?.claims.some((claim) => claim.txid === txid)) return state;
|
|
18188
|
+
const next = mergeArkadeCashRecord(previous, {
|
|
18189
|
+
id: cashId,
|
|
18190
|
+
action: "claimed",
|
|
18191
|
+
outcome,
|
|
18192
|
+
createdAt: Math.floor(Date.now() / 1e3),
|
|
18193
|
+
issues: [],
|
|
18194
|
+
claims: [{ txid, amount }]
|
|
18195
|
+
});
|
|
18196
|
+
const updated = [...entries];
|
|
18197
|
+
if (index >= 0) updated[index] = next;
|
|
18198
|
+
else updated.push(next);
|
|
18199
|
+
return { ...state, settings: { ...state.settings, arkadeCashRecovery: updated } };
|
|
18200
|
+
});
|
|
18201
|
+
}
|
|
18056
18202
|
/**
|
|
18057
18203
|
* Split the VTXOs at an arkadeCash address into three buckets: the ones the
|
|
18058
18204
|
* thin sweep can move (`spendable`), the operator-swept ones that must go
|
|
@@ -18064,7 +18210,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
18064
18210
|
const recoverable = [];
|
|
18065
18211
|
const unclaimed = [];
|
|
18066
18212
|
for (const vtxo of vtxos) {
|
|
18067
|
-
if (
|
|
18213
|
+
if (chunkOMPDPBT5_cjs.isVtxoSpent(vtxo)) {
|
|
18068
18214
|
unclaimed.push(cashReport(vtxo, "already-spent"));
|
|
18069
18215
|
} else if (vtxo.isUnrolled) {
|
|
18070
18216
|
unclaimed.push(cashReport(vtxo, "exited"));
|
|
@@ -18086,7 +18232,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
18086
18232
|
const all = [];
|
|
18087
18233
|
const seen = /* @__PURE__ */ new Set();
|
|
18088
18234
|
for (let pageIndex = 0; ; pageIndex++) {
|
|
18089
|
-
const { vtxos, page } = await
|
|
18235
|
+
const { vtxos, page } = await chunkOMPDPBT5_cjs.getNormalizedVtxos(this.indexerProvider, {
|
|
18090
18236
|
scripts,
|
|
18091
18237
|
pageIndex,
|
|
18092
18238
|
pageSize
|
|
@@ -18110,7 +18256,12 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
18110
18256
|
* @returns Txs finalized, sats paid to this wallet, and the outpoints consumed to pay it.
|
|
18111
18257
|
*/
|
|
18112
18258
|
async finalizePendingCashTxs(cash, vtxos, cashScript, myPkScript) {
|
|
18113
|
-
const result = {
|
|
18259
|
+
const result = {
|
|
18260
|
+
count: 0,
|
|
18261
|
+
swept: 0,
|
|
18262
|
+
claimed: /* @__PURE__ */ new Set(),
|
|
18263
|
+
claims: []
|
|
18264
|
+
};
|
|
18114
18265
|
const inputs = vtxos.map((vtxo) => ({
|
|
18115
18266
|
...vtxo,
|
|
18116
18267
|
forfeitTapLeafScript: cashScript.forfeit(),
|
|
@@ -18124,7 +18275,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
18124
18275
|
for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_PROOF) {
|
|
18125
18276
|
const batch = inputs.slice(i, i + MAX_INPUTS_PER_PROOF);
|
|
18126
18277
|
const message = { type: "get-pending-tx", expire_at: 0 };
|
|
18127
|
-
const proof =
|
|
18278
|
+
const proof = chunkOMPDPBT5_cjs.Proof.create(message, batch, []);
|
|
18128
18279
|
const signedProof = await identity.sign(
|
|
18129
18280
|
proof,
|
|
18130
18281
|
Array.from({ length: batch.length + 1 }, (_, j) => j)
|
|
@@ -18145,8 +18296,8 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
18145
18296
|
for (const pendingTx of pendingTxs) {
|
|
18146
18297
|
try {
|
|
18147
18298
|
const checkpointTxs = pendingTx.signedCheckpointTxs.map((checkpoint) => {
|
|
18148
|
-
const tx =
|
|
18149
|
-
|
|
18299
|
+
const tx = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(checkpoint));
|
|
18300
|
+
chunkOMPDPBT5_cjs.assertAllowedSighashTypes(tx);
|
|
18150
18301
|
return tx;
|
|
18151
18302
|
});
|
|
18152
18303
|
assertCheckpointsMatchInputs(
|
|
@@ -18167,6 +18318,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
18167
18318
|
result.count++;
|
|
18168
18319
|
const paidToMe = this.arkTxAmountPaidTo(pendingTx.finalArkTx, myPkScriptHex);
|
|
18169
18320
|
if (paidToMe === 0) continue;
|
|
18321
|
+
result.claims.push({ txid: pendingTx.arkTxid, amount: paidToMe });
|
|
18170
18322
|
result.swept += paidToMe;
|
|
18171
18323
|
for (const checkpoint of checkpointTxs) {
|
|
18172
18324
|
for (let i = 0; i < checkpoint.inputsLength; i++) {
|
|
@@ -18186,7 +18338,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
18186
18338
|
}
|
|
18187
18339
|
/** Sum the outputs of an ark tx PSBT that pay the given scriptPubKey. */
|
|
18188
18340
|
arkTxAmountPaidTo(arkTxPsbt, pkScriptHex) {
|
|
18189
|
-
const arkTx =
|
|
18341
|
+
const arkTx = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(arkTxPsbt));
|
|
18190
18342
|
let total = 0;
|
|
18191
18343
|
for (let i = 0; i < arkTx.outputsLength; i++) {
|
|
18192
18344
|
const output = arkTx.getOutput(i);
|
|
@@ -18245,7 +18397,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
18245
18397
|
throw new Error("send({ maxChangeFee }): expected a non-negative safe integer");
|
|
18246
18398
|
}
|
|
18247
18399
|
if (selectedVtxos) {
|
|
18248
|
-
if (inputExpiryFloor) selectedVtxos = selectedVtxos.map(
|
|
18400
|
+
if (inputExpiryFloor) selectedVtxos = selectedVtxos.map(chunkOMPDPBT5_cjs.normalizeVtxo);
|
|
18249
18401
|
if (inputExpiryFloor && selectedVtxos.some((coin) => !meetsInputExpiryFloor(coin, inputExpiryFloor))) {
|
|
18250
18402
|
throw new Error("send({ selectedVtxos }): input expiry floor not met");
|
|
18251
18403
|
}
|
|
@@ -18572,10 +18724,10 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
18572
18724
|
const serverPubKey = this.arkServerPublicKey;
|
|
18573
18725
|
const serverUnrollScript = this.serverUnrollScript;
|
|
18574
18726
|
const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
|
|
18575
|
-
const normalizedInputs = inputs.map(
|
|
18576
|
-
const at = now ?? await
|
|
18727
|
+
const normalizedInputs = inputs.map(chunkOMPDPBT5_cjs.normalizeVtxo);
|
|
18728
|
+
const at = now ?? await chunkOMPDPBT5_cjs.resolveTimeHeight(this.onchainProvider);
|
|
18577
18729
|
for (const input of normalizedInputs) {
|
|
18578
|
-
if (!
|
|
18730
|
+
if (!chunkOMPDPBT5_cjs.canSpendOffchain(input, at)) {
|
|
18579
18731
|
throw new Error(
|
|
18580
18732
|
`sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
|
|
18581
18733
|
);
|
|
@@ -18769,7 +18921,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
18769
18921
|
}
|
|
18770
18922
|
const checkpointIdByOutpoint = /* @__PURE__ */ new Map();
|
|
18771
18923
|
for (const encoded of signedCheckpointTxs) {
|
|
18772
|
-
const checkpoint =
|
|
18924
|
+
const checkpoint = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
|
|
18773
18925
|
for (let i = 0; i < checkpoint.inputsLength; i++) {
|
|
18774
18926
|
const input = checkpoint.getInput(i);
|
|
18775
18927
|
if (!input.txid) continue;
|
|
@@ -18886,12 +19038,12 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
18886
19038
|
const inputArkTxIds = /* @__PURE__ */ new Set();
|
|
18887
19039
|
const boardingScripts = /* @__PURE__ */ new Set();
|
|
18888
19040
|
const boardingOutpoints = [];
|
|
18889
|
-
const vtxoInputs = inputs.filter(
|
|
19041
|
+
const vtxoInputs = inputs.filter(chunkOMPDPBT5_cjs.isVirtualCoin);
|
|
18890
19042
|
const cm = await this.getContractManager();
|
|
18891
19043
|
const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
|
|
18892
19044
|
const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
|
|
18893
19045
|
for (const input of inputs) {
|
|
18894
|
-
if (
|
|
19046
|
+
if (chunkOMPDPBT5_cjs.isVirtualCoin(input)) {
|
|
18895
19047
|
const outpoint = `${input.txid}:${input.vout}`;
|
|
18896
19048
|
const vtxo = annotatedByKey.get(outpoint);
|
|
18897
19049
|
if (!vtxo) {
|
|
@@ -18974,7 +19126,7 @@ function bySelectionOrder(a, b) {
|
|
|
18974
19126
|
return b.value - a.value;
|
|
18975
19127
|
}
|
|
18976
19128
|
function selectVirtualCoins(coins, targetAmount) {
|
|
18977
|
-
const sortedCoins = coins.map(
|
|
19129
|
+
const sortedCoins = coins.map(chunkOMPDPBT5_cjs.normalizeVtxo).sort(bySelectionOrder);
|
|
18978
19130
|
const selectedCoins = [];
|
|
18979
19131
|
let selectedAmount = 0;
|
|
18980
19132
|
for (const coin of sortedCoins) {
|
|
@@ -19102,7 +19254,7 @@ function assertTimeoutMap(name, timeouts) {
|
|
|
19102
19254
|
if (value === void 0) {
|
|
19103
19255
|
throw new Error(`${name}.${key} must be a non-negative safe integer`);
|
|
19104
19256
|
}
|
|
19105
|
-
|
|
19257
|
+
chunkOMPDPBT5_cjs.assertTimerMs(`${name}.${key}`, value);
|
|
19106
19258
|
}
|
|
19107
19259
|
}
|
|
19108
19260
|
var MessageBus = class {
|
|
@@ -19119,8 +19271,8 @@ var MessageBus = class {
|
|
|
19119
19271
|
}) {
|
|
19120
19272
|
this.walletRepository = walletRepository;
|
|
19121
19273
|
this.contractRepository = contractRepository;
|
|
19122
|
-
|
|
19123
|
-
|
|
19274
|
+
chunkOMPDPBT5_cjs.assertTimerMs("tickIntervalMs", tickIntervalMs);
|
|
19275
|
+
chunkOMPDPBT5_cjs.assertTimerMs("messageTimeoutMs", messageTimeoutMs);
|
|
19124
19276
|
assertTimeoutMap("messageTimeoutOverrides", messageTimeoutOverrides);
|
|
19125
19277
|
this.intentRepository = intentRepository;
|
|
19126
19278
|
this.onchainProvider = onchainProvider;
|
|
@@ -19376,14 +19528,14 @@ var MessageBus = class {
|
|
|
19376
19528
|
this.initialized = true;
|
|
19377
19529
|
}
|
|
19378
19530
|
async buildServices(config) {
|
|
19379
|
-
const arkProvider = new
|
|
19531
|
+
const arkProvider = new chunkOMPDPBT5_cjs.RestOperatorProvider(config.arkServer.url);
|
|
19380
19532
|
const storage = {
|
|
19381
19533
|
walletRepository: this.walletRepository,
|
|
19382
19534
|
contractRepository: this.contractRepository,
|
|
19383
19535
|
...this.intentRepository && { intentRepository: this.intentRepository }
|
|
19384
19536
|
};
|
|
19385
19537
|
const delegateProvider = config.delegateUrl ? new RestDelegateProvider(config.delegateUrl) : void 0;
|
|
19386
|
-
const indexerProvider = new
|
|
19538
|
+
const indexerProvider = new chunk3NALVGMJ_cjs.RestIndexerProvider(config.arkServer.url);
|
|
19387
19539
|
const serialized = normalizeSerializedIdentity(config.wallet);
|
|
19388
19540
|
if (isSigningSerialized(serialized)) {
|
|
19389
19541
|
const identity2 = hydrateIdentity(serialized);
|
|
@@ -19766,7 +19918,7 @@ function filterOffboardInputs(vtxos, feeInfo, named) {
|
|
|
19766
19918
|
const inputs = [];
|
|
19767
19919
|
let subtotal = 0n;
|
|
19768
19920
|
for (const vtxo of vtxos) {
|
|
19769
|
-
const inputFee = estimator.evalOffchainInput(
|
|
19921
|
+
const inputFee = estimator.evalOffchainInput(chunkOMPDPBT5_cjs.toOffchainInputFeeParams(vtxo));
|
|
19770
19922
|
if (inputFee.satoshis >= vtxo.value) {
|
|
19771
19923
|
if (named) {
|
|
19772
19924
|
throw new Error(
|
|
@@ -20031,7 +20183,7 @@ var Ramps = class {
|
|
|
20031
20183
|
const ordered = [...candidates].sort(bySelectionOrder);
|
|
20032
20184
|
let covered = 0n;
|
|
20033
20185
|
for (let i = 0; i < ordered.length && i < MAX_VTXOS_PER_SETTLEMENT; i++) {
|
|
20034
|
-
const fee = estimator.evalOffchainInput(
|
|
20186
|
+
const fee = estimator.evalOffchainInput(chunkOMPDPBT5_cjs.toOffchainInputFeeParams(ordered[i])).satoshis;
|
|
20035
20187
|
covered += BigInt(ordered[i].value) - BigInt(fee);
|
|
20036
20188
|
if (covered < needed) continue;
|
|
20037
20189
|
try {
|
|
@@ -20078,6 +20230,51 @@ var Ramps = class {
|
|
|
20078
20230
|
return { change, changeAddress };
|
|
20079
20231
|
}
|
|
20080
20232
|
};
|
|
20233
|
+
function groupByTxid(coins) {
|
|
20234
|
+
const totals = /* @__PURE__ */ new Map();
|
|
20235
|
+
for (const { txid, value } of coins) totals.set(txid, (totals.get(txid) ?? 0) + value);
|
|
20236
|
+
return [...totals].map(([txid, amount]) => ({ txid, amount }));
|
|
20237
|
+
}
|
|
20238
|
+
async function readArkadeCash(token, indexer, info, onchain) {
|
|
20239
|
+
const cash = ArkadeCash.fromString(token);
|
|
20240
|
+
const signer = classifyAgainstSignerSet(base.hex.encode(cash.serverPubKey), signerSetFromInfo(info));
|
|
20241
|
+
if (signer.status === "UNKNOWN_SIGNER") {
|
|
20242
|
+
throw new Error("ArkadeCash belongs to another operator");
|
|
20243
|
+
}
|
|
20244
|
+
const coins = await chunkOMPDPBT5_cjs.getAllNormalizedVtxos(indexer, [arkadeCashId(cash)]);
|
|
20245
|
+
return classifyArkadeCash(
|
|
20246
|
+
coins,
|
|
20247
|
+
info.dust,
|
|
20248
|
+
await chunkOMPDPBT5_cjs.resolveTimeHeight(onchain),
|
|
20249
|
+
signer.status === "EXPIRED"
|
|
20250
|
+
);
|
|
20251
|
+
}
|
|
20252
|
+
function classifyArkadeCash(coins, dust, now, awaitingSweep = false) {
|
|
20253
|
+
const eligible = coins.filter(
|
|
20254
|
+
(coin) => coin.value >= Number(dust) && !(coin.assets && coin.assets.length > 0)
|
|
20255
|
+
);
|
|
20256
|
+
const hasSpent = eligible.some(chunkOMPDPBT5_cjs.isVtxoSpent);
|
|
20257
|
+
const hasLive = eligible.some((coin) => !chunkOMPDPBT5_cjs.isVtxoSpent(coin) && !coin.isUnrolled);
|
|
20258
|
+
const hasExit = eligible.some((coin) => !chunkOMPDPBT5_cjs.isVtxoSpent(coin) && coin.isUnrolled);
|
|
20259
|
+
const recoverable = eligible.some((coin) => !chunkOMPDPBT5_cjs.isVtxoSpent(coin) && coin.isSwept);
|
|
20260
|
+
const elapsedBatch = eligible.some(
|
|
20261
|
+
(coin) => !chunkOMPDPBT5_cjs.isVtxoSpent(coin) && !coin.isSwept && chunkOMPDPBT5_cjs.isPastExpiry(coin, now)
|
|
20262
|
+
);
|
|
20263
|
+
return {
|
|
20264
|
+
status: eligible.length === 0 ? "unissued" : hasExit && !hasLive ? "exited" : hasSpent && !hasLive ? "claimed" : recoverable ? "recovering" : elapsedBatch || awaitingSweep ? "expired" : "available",
|
|
20265
|
+
amount: eligible.reduce((sum, coin) => sum + (chunkOMPDPBT5_cjs.isVtxoSpent(coin) ? 0 : coin.value), 0),
|
|
20266
|
+
issues: groupByTxid(eligible),
|
|
20267
|
+
claims: groupByTxid(
|
|
20268
|
+
// `||`: the indexer reports an unset id as an empty string, not as absent.
|
|
20269
|
+
eligible.flatMap((coin) => {
|
|
20270
|
+
const txid = coin.arkTxId || coin.settledBy;
|
|
20271
|
+
return txid ? [{ txid, value: coin.value }] : [];
|
|
20272
|
+
})
|
|
20273
|
+
)
|
|
20274
|
+
};
|
|
20275
|
+
}
|
|
20276
|
+
|
|
20277
|
+
// src/wallet/serviceWorker/wallet-message-handler.ts
|
|
20081
20278
|
var WalletNotInitializedError = class extends Error {
|
|
20082
20279
|
constructor() {
|
|
20083
20280
|
super("Wallet handler not initialized");
|
|
@@ -20112,6 +20309,25 @@ function deserializeAggregateError(payload) {
|
|
|
20112
20309
|
});
|
|
20113
20310
|
return new AggregateError(errs, payload.message);
|
|
20114
20311
|
}
|
|
20312
|
+
function isSerializedArkadeCashCreateError(value) {
|
|
20313
|
+
if (!value || typeof value !== "object") return false;
|
|
20314
|
+
const v = value;
|
|
20315
|
+
return v.name === "ArkadeCashCreateError" && typeof v.message === "string" && typeof v.cash === "string" && !!v.cause && typeof v.cause.name === "string" && typeof v.cause.message === "string";
|
|
20316
|
+
}
|
|
20317
|
+
function serializeArkadeCashCreateError(error) {
|
|
20318
|
+
const cause = error.cause;
|
|
20319
|
+
return {
|
|
20320
|
+
name: "ArkadeCashCreateError",
|
|
20321
|
+
message: error.message,
|
|
20322
|
+
cash: error.cash,
|
|
20323
|
+
cause: cause instanceof Error ? { name: cause.name, message: cause.message } : { name: "Error", message: String(cause) }
|
|
20324
|
+
};
|
|
20325
|
+
}
|
|
20326
|
+
function deserializeArkadeCashCreateError(payload) {
|
|
20327
|
+
const cause = new Error(payload.cause.message);
|
|
20328
|
+
cause.name = payload.cause.name;
|
|
20329
|
+
return new ArkadeCashCreateError(payload.cash, cause);
|
|
20330
|
+
}
|
|
20115
20331
|
var ReadonlyWalletError = class extends Error {
|
|
20116
20332
|
constructor() {
|
|
20117
20333
|
super("Read-only wallet: operation requires signing");
|
|
@@ -20125,6 +20341,7 @@ var DelegateNotConfiguredError = class extends Error {
|
|
|
20125
20341
|
}
|
|
20126
20342
|
};
|
|
20127
20343
|
var DEFAULT_MESSAGE_TAG = "WALLET_UPDATER";
|
|
20344
|
+
var isLongRunningCashAction = (request) => request.action === "create" || request.action === "claim";
|
|
20128
20345
|
function unsupportedByManager(method) {
|
|
20129
20346
|
return new Error(`Contract manager does not support ${method}`);
|
|
20130
20347
|
}
|
|
@@ -20360,7 +20577,10 @@ var WalletMessageHandler = class {
|
|
|
20360
20577
|
message.type === "MIGRATE_DEPRECATED_SIGNER_VTXOS" || // HD restore walks the index range with one indexer round-trip per
|
|
20361
20578
|
// step until it hits gapLimit consecutive unused indices. The bus
|
|
20362
20579
|
// deadline must not race the scan; liveness stays covered by PING.
|
|
20363
|
-
message.type === "RESTORE_WALLET" ||
|
|
20580
|
+
message.type === "RESTORE_WALLET" || // `create` and `claim` run sends and sweeps. A bus deadline would
|
|
20581
|
+
// answer with a timeout error and drop the token or txids that the
|
|
20582
|
+
// finished handler could still deliver.
|
|
20583
|
+
message.type === "ARKADE_CASH" && isLongRunningCashAction(message.payload) || message.type === "COSIGN_ONCHAIN_TX" || message.type === "SEND_ONCHAIN";
|
|
20364
20584
|
}
|
|
20365
20585
|
async handleMessage(message) {
|
|
20366
20586
|
const id = message.id;
|
|
@@ -20403,6 +20623,82 @@ var WalletMessageHandler = class {
|
|
|
20403
20623
|
payload: { address }
|
|
20404
20624
|
});
|
|
20405
20625
|
}
|
|
20626
|
+
case "ARKADE_CASH": {
|
|
20627
|
+
const request = message.payload;
|
|
20628
|
+
switch (request.action) {
|
|
20629
|
+
case "get": {
|
|
20630
|
+
const cash = ArkadeCash.fromString(request.token);
|
|
20631
|
+
const report = await readArkadeCash(
|
|
20632
|
+
request.token,
|
|
20633
|
+
this.readonlyWallet.indexerProvider,
|
|
20634
|
+
await this.readonlyWallet.getArkadeInfo(),
|
|
20635
|
+
this.readonlyWallet.onchainProvider
|
|
20636
|
+
);
|
|
20637
|
+
return this.tagged({
|
|
20638
|
+
id,
|
|
20639
|
+
type: "ARKADE_CASH",
|
|
20640
|
+
payload: { action: "get", cashId: arkadeCashId(cash), ...report }
|
|
20641
|
+
});
|
|
20642
|
+
}
|
|
20643
|
+
case "create": {
|
|
20644
|
+
try {
|
|
20645
|
+
const token = await this.requireWallet().createCash(request.amount);
|
|
20646
|
+
return this.tagged({
|
|
20647
|
+
id,
|
|
20648
|
+
type: "ARKADE_CASH",
|
|
20649
|
+
payload: { action: "create", token }
|
|
20650
|
+
});
|
|
20651
|
+
} catch (error) {
|
|
20652
|
+
if (!(error instanceof ArkadeCashCreateError)) throw error;
|
|
20653
|
+
return this.tagged({
|
|
20654
|
+
id,
|
|
20655
|
+
error: serializeArkadeCashCreateError(
|
|
20656
|
+
error
|
|
20657
|
+
)
|
|
20658
|
+
});
|
|
20659
|
+
}
|
|
20660
|
+
}
|
|
20661
|
+
case "activities": {
|
|
20662
|
+
const records = createArkadeCashTracker();
|
|
20663
|
+
request.records.forEach(
|
|
20664
|
+
(record) => addArkadeCashRecord(records, record)
|
|
20665
|
+
);
|
|
20666
|
+
const state = await this.walletRepository?.getWalletState();
|
|
20667
|
+
const recovered = state?.settings?.arkadeCashRecovery;
|
|
20668
|
+
if (Array.isArray(recovered)) {
|
|
20669
|
+
recovered.filter(isArkadeCashRecord).forEach((record) => addArkadeCashRecord(records, record));
|
|
20670
|
+
}
|
|
20671
|
+
return this.tagged({
|
|
20672
|
+
id,
|
|
20673
|
+
type: "ARKADE_CASH",
|
|
20674
|
+
payload: {
|
|
20675
|
+
action: "activities",
|
|
20676
|
+
activities: await arkadeCashActivity(
|
|
20677
|
+
records,
|
|
20678
|
+
await this.buildTransactionHistoryFromCache() ?? []
|
|
20679
|
+
)
|
|
20680
|
+
}
|
|
20681
|
+
});
|
|
20682
|
+
}
|
|
20683
|
+
case "claim": {
|
|
20684
|
+
const result = await this.requireWallet().claimCash(request.token);
|
|
20685
|
+
return this.tagged({
|
|
20686
|
+
id,
|
|
20687
|
+
type: "ARKADE_CASH",
|
|
20688
|
+
payload: { action: "claim", ...result }
|
|
20689
|
+
});
|
|
20690
|
+
}
|
|
20691
|
+
case "reveal": {
|
|
20692
|
+
const record = ArkadeCash.fromString(request.token);
|
|
20693
|
+
return this.tagged({
|
|
20694
|
+
id,
|
|
20695
|
+
type: "ARKADE_CASH",
|
|
20696
|
+
payload: { action: "reveal", cashId: arkadeCashId(record) }
|
|
20697
|
+
});
|
|
20698
|
+
}
|
|
20699
|
+
}
|
|
20700
|
+
return this.tagged({ id, error: new Error("Unknown Arkade Cash action") });
|
|
20701
|
+
}
|
|
20406
20702
|
case "GET_OPERATOR_INFO":
|
|
20407
20703
|
case "GET_ARKADE_INFO": {
|
|
20408
20704
|
const { payload } = message;
|
|
@@ -21027,7 +21323,7 @@ var WalletMessageHandler = class {
|
|
|
21027
21323
|
this.lazyBoardingInit = payload.lazyBoarding ?? false;
|
|
21028
21324
|
this.boardingEpoch++;
|
|
21029
21325
|
this.boardingLoaded = false;
|
|
21030
|
-
this.indexerProvider = new
|
|
21326
|
+
this.indexerProvider = new chunk3NALVGMJ_cjs.RestIndexerProvider(arkServerUrl);
|
|
21031
21327
|
await this.onWalletInitialized();
|
|
21032
21328
|
}
|
|
21033
21329
|
/** @see RequestInitWallet.payload.lazyBoarding */
|
|
@@ -21373,9 +21669,8 @@ var WalletMessageHandler = class {
|
|
|
21373
21669
|
* arkcash) are excluded by default, mirroring {@link ReadonlyWallet.getVtxos}:
|
|
21374
21670
|
* they are settled in their own isolated intent and must stay out of the
|
|
21375
21671
|
* wallet's balance / VTXO / coin-selection / pending-tx views that read this.
|
|
21376
|
-
*
|
|
21377
|
-
*
|
|
21378
|
-
* directly and does include them.
|
|
21672
|
+
* Transaction history excludes them too, as does the non-worker
|
|
21673
|
+
* `getTransactionHistory`.
|
|
21379
21674
|
*/
|
|
21380
21675
|
async getVtxosFromRepo(options) {
|
|
21381
21676
|
return (await this.repoSnapshot(options)).vtxos;
|
|
@@ -21393,8 +21688,7 @@ var WalletMessageHandler = class {
|
|
|
21393
21688
|
* what it knows is closed — so the coins of a just-registered escrowed
|
|
21394
21689
|
* contract would count as available until the next poll.
|
|
21395
21690
|
*
|
|
21396
|
-
* Recovery-only contracts are skipped
|
|
21397
|
-
* {@link getVtxosFromRepo}).
|
|
21691
|
+
* Recovery-only contracts are skipped (see {@link getVtxosFromRepo}).
|
|
21398
21692
|
*/
|
|
21399
21693
|
async repoSnapshot(options = {}) {
|
|
21400
21694
|
const repository = this.walletRepository;
|
|
@@ -21418,9 +21712,7 @@ var WalletMessageHandler = class {
|
|
|
21418
21712
|
void addressPromise.catch(() => void 0);
|
|
21419
21713
|
const manager = await wallet.getContractManager();
|
|
21420
21714
|
const contracts = await manager.getContracts();
|
|
21421
|
-
const eligible = contracts.filter(
|
|
21422
|
-
(contract) => options.includeRecoveryOnly || !isRecoveryOnlyContract(contract)
|
|
21423
|
-
);
|
|
21715
|
+
const eligible = contracts.filter((contract) => !isRecoveryOnlyContract(contract));
|
|
21424
21716
|
const listsPromise = Promise.all(
|
|
21425
21717
|
eligible.map((contract) => getVtxosForContract(repository, contract, options))
|
|
21426
21718
|
);
|
|
@@ -21471,11 +21763,11 @@ var WalletMessageHandler = class {
|
|
|
21471
21763
|
async buildTransactionHistoryFromCache() {
|
|
21472
21764
|
if (!this.readonlyWallet) return null;
|
|
21473
21765
|
const [{ snapshot, vtxos }, { boardingTxs, commitmentsToIgnore }] = await Promise.all([
|
|
21474
|
-
this.repoSnapshot(
|
|
21766
|
+
this.repoSnapshot(),
|
|
21475
21767
|
this.readonlyWallet.getBoardingTxs()
|
|
21476
21768
|
]);
|
|
21477
21769
|
const indexerProvider = this.indexerProvider;
|
|
21478
|
-
const resolveTxCreatedAt = indexerProvider ? (txids) =>
|
|
21770
|
+
const resolveTxCreatedAt = indexerProvider ? (txids) => chunkOMPDPBT5_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
|
|
21479
21771
|
return buildTransactionHistory(
|
|
21480
21772
|
vtxos,
|
|
21481
21773
|
boardingTxs,
|
|
@@ -21544,9 +21836,9 @@ var DEFAULT_MESSAGE_TIMEOUTS = {
|
|
|
21544
21836
|
// budget so the worker's snapshot fallback stays reachable before this
|
|
21545
21837
|
// page deadline fires — lowering it below the budget would time the page
|
|
21546
21838
|
// out while the worker is still seconds from answering from cache.
|
|
21547
|
-
GET_OPERATOR_INFO:
|
|
21839
|
+
GET_OPERATOR_INFO: chunkOMPDPBT5_cjs.INFO_FETCH_TIMEOUT_MS + 8e3,
|
|
21548
21840
|
/** @deprecated Use `GET_OPERATOR_INFO`. */
|
|
21549
|
-
GET_ARKADE_INFO:
|
|
21841
|
+
GET_ARKADE_INFO: chunkOMPDPBT5_cjs.INFO_FETCH_TIMEOUT_MS + 8e3,
|
|
21550
21842
|
INDEXER_GET_VTXOS: 2e4,
|
|
21551
21843
|
INDEXER_GET_VIRTUAL_TXS: 2e4,
|
|
21552
21844
|
GET_VTXOS: 2e4,
|
|
@@ -21586,6 +21878,8 @@ var DEFAULT_MESSAGE_TIMEOUTS = {
|
|
|
21586
21878
|
RECOVER_VTXOS: 5e4,
|
|
21587
21879
|
RENEW_VTXOS: 5e4,
|
|
21588
21880
|
SWEEP_EXPIRED_BOARDING_UTXOS: 5e4,
|
|
21881
|
+
// Only `get`/`activities`/`reveal`: `create` and `claim` stream with no deadline.
|
|
21882
|
+
ARKADE_CASH: 5e4,
|
|
21589
21883
|
COSIGN_ONCHAIN_TX: 5e4,
|
|
21590
21884
|
SEND_ONCHAIN: 5e4,
|
|
21591
21885
|
// Streaming/long-running like RENEW_VTXOS (rotation + settle); the value is
|
|
@@ -21644,10 +21938,10 @@ function getRequestDedupKey(request) {
|
|
|
21644
21938
|
}
|
|
21645
21939
|
function cosignWorkerError(e) {
|
|
21646
21940
|
if (e instanceof Error && e.message === "Unknown message") {
|
|
21647
|
-
return new
|
|
21941
|
+
return new chunkOMPDPBT5_cjs.OnchainCosignUnsupportedError();
|
|
21648
21942
|
}
|
|
21649
21943
|
if (e instanceof ServiceWorkerTimeoutError) {
|
|
21650
|
-
return new
|
|
21944
|
+
return new chunkOMPDPBT5_cjs.OnchainCosignAmbiguousError(e.message, { cause: e });
|
|
21651
21945
|
}
|
|
21652
21946
|
return rehydrateCosignError(e);
|
|
21653
21947
|
}
|
|
@@ -21702,7 +21996,7 @@ var ServiceWorkerAssetManager = class extends ServiceWorkerReadonlyAssetManager
|
|
|
21702
21996
|
}
|
|
21703
21997
|
};
|
|
21704
21998
|
var initializeMessageBus = (serviceWorker, config, timeoutMs = 2e3) => {
|
|
21705
|
-
|
|
21999
|
+
chunkOMPDPBT5_cjs.assertTimerMs("messageBusTimeoutMs", timeoutMs);
|
|
21706
22000
|
const initCmd = {
|
|
21707
22001
|
tag: "INITIALIZE_MESSAGE_BUS",
|
|
21708
22002
|
id: getRandomId(),
|
|
@@ -21745,6 +22039,28 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
21745
22039
|
}
|
|
21746
22040
|
serviceWorker;
|
|
21747
22041
|
messageTag;
|
|
22042
|
+
arkadeCash = (request) => this.cashRequest(request);
|
|
22043
|
+
async cashRequest(request) {
|
|
22044
|
+
const message = {
|
|
22045
|
+
id: getRandomId(),
|
|
22046
|
+
tag: this.messageTag,
|
|
22047
|
+
type: "ARKADE_CASH",
|
|
22048
|
+
payload: request
|
|
22049
|
+
};
|
|
22050
|
+
try {
|
|
22051
|
+
const response = isLongRunningCashAction(request) ? await this.sendMessageWithRetry(message, {
|
|
22052
|
+
onEvent: () => {
|
|
22053
|
+
},
|
|
22054
|
+
isComplete: (resp) => resp.type === "ARKADE_CASH"
|
|
22055
|
+
}) : await this.sendMessage(message);
|
|
22056
|
+
return response.payload;
|
|
22057
|
+
} catch (error) {
|
|
22058
|
+
if (isSerializedArkadeCashCreateError(error)) {
|
|
22059
|
+
throw deserializeArkadeCashCreateError(error);
|
|
22060
|
+
}
|
|
22061
|
+
throw error;
|
|
22062
|
+
}
|
|
22063
|
+
}
|
|
21748
22064
|
walletRepository;
|
|
21749
22065
|
contractRepository;
|
|
21750
22066
|
identity;
|
|
@@ -21800,7 +22116,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
21800
22116
|
Object.entries(options.messageTimeouts ?? {}).filter(([, ms]) => ms !== void 0)
|
|
21801
22117
|
);
|
|
21802
22118
|
for (const [key, value] of Object.entries(overrides)) {
|
|
21803
|
-
|
|
22119
|
+
chunkOMPDPBT5_cjs.assertTimerMs(`messageTimeouts.${key}`, value);
|
|
21804
22120
|
}
|
|
21805
22121
|
const messageTimeouts = {
|
|
21806
22122
|
...DEFAULT_MESSAGE_TIMEOUTS,
|
|
@@ -22145,7 +22461,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
22145
22461
|
try {
|
|
22146
22462
|
const response = await this.sendMessage(message);
|
|
22147
22463
|
const { vtxos, page } = response.payload;
|
|
22148
|
-
return { vtxos: vtxos.map(
|
|
22464
|
+
return { vtxos: vtxos.map(chunkOMPDPBT5_cjs.normalizeVtxo), page: page && { ...page } };
|
|
22149
22465
|
} catch (cause) {
|
|
22150
22466
|
throw new Error(`Failed to get vtxos: ${cause}`, { cause });
|
|
22151
22467
|
}
|
|
@@ -22254,7 +22570,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
22254
22570
|
};
|
|
22255
22571
|
try {
|
|
22256
22572
|
const response = await this.sendMessage(message);
|
|
22257
|
-
return response.payload.vtxos.map(
|
|
22573
|
+
return response.payload.vtxos.map(chunkOMPDPBT5_cjs.normalizeVtxo);
|
|
22258
22574
|
} catch (error) {
|
|
22259
22575
|
throw new Error(`Failed to get vtxos: ${error}`);
|
|
22260
22576
|
}
|
|
@@ -22285,7 +22601,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
22285
22601
|
"Service worker does not support the requested contract scope or freshness check"
|
|
22286
22602
|
);
|
|
22287
22603
|
}
|
|
22288
|
-
return payload.vtxos.map(
|
|
22604
|
+
return payload.vtxos.map(chunkOMPDPBT5_cjs.normalizeVtxo);
|
|
22289
22605
|
} catch (error) {
|
|
22290
22606
|
throw new Error(`Failed to get spendable vtxos: ${error}`);
|
|
22291
22607
|
}
|
|
@@ -22480,7 +22796,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
22480
22796
|
};
|
|
22481
22797
|
try {
|
|
22482
22798
|
const response = await sendContractMessage(message);
|
|
22483
|
-
return response.payload.vtxos.map(
|
|
22799
|
+
return response.payload.vtxos.map(chunkOMPDPBT5_cjs.normalizeVtxo);
|
|
22484
22800
|
} catch (cause) {
|
|
22485
22801
|
throw new Error(`Failed to annotate vtxos: ${cause}`, { cause });
|
|
22486
22802
|
}
|
|
@@ -23152,7 +23468,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
23152
23468
|
};
|
|
23153
23469
|
try {
|
|
23154
23470
|
const response = await wallet.sendMessage(message);
|
|
23155
|
-
return response.payload.vtxos.map(
|
|
23471
|
+
return response.payload.vtxos.map(chunkOMPDPBT5_cjs.normalizeVtxo);
|
|
23156
23472
|
} catch (e) {
|
|
23157
23473
|
throw new Error(`Failed to get expiring vtxos: ${e}`);
|
|
23158
23474
|
}
|
|
@@ -23374,7 +23690,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
23374
23690
|
feeRate,
|
|
23375
23691
|
params.address
|
|
23376
23692
|
);
|
|
23377
|
-
let tx = new
|
|
23693
|
+
let tx = new chunkOMPDPBT5_cjs.Transaction();
|
|
23378
23694
|
for (const input of inputs) {
|
|
23379
23695
|
tx.addInput({
|
|
23380
23696
|
txid: input.txid,
|
|
@@ -23432,7 +23748,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
23432
23748
|
* @throws If the parent has no anchor, or funding cannot be selected/signed
|
|
23433
23749
|
*/
|
|
23434
23750
|
async bumpAnchor(parentHex, feeRate) {
|
|
23435
|
-
const parent =
|
|
23751
|
+
const parent = chunkOMPDPBT5_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
|
|
23436
23752
|
const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
|
|
23437
23753
|
const child = await this.buildBumpPackage(parent, feeRate, coins);
|
|
23438
23754
|
return [parent.hex, child.hex];
|
|
@@ -24284,7 +24600,7 @@ var CachingOperatorProvider = class {
|
|
|
24284
24600
|
constructor(inner, ttlMs = DEFAULT_TTL_MS) {
|
|
24285
24601
|
this.inner = inner;
|
|
24286
24602
|
this.ttlMs = ttlMs;
|
|
24287
|
-
|
|
24603
|
+
chunkOMPDPBT5_cjs.assertNonNegativeMs("ttlMs", ttlMs);
|
|
24288
24604
|
this.unsubscribe = inner.onServerInfoChanged?.((info) => {
|
|
24289
24605
|
this.cached = info;
|
|
24290
24606
|
this.expiresAt = Date.now() + this.ttlMs;
|
|
@@ -24371,7 +24687,7 @@ exports.BIP322 = void 0;
|
|
|
24371
24687
|
async function sign2(message, identity, network) {
|
|
24372
24688
|
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
24373
24689
|
const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
|
|
24374
|
-
const toSpend =
|
|
24690
|
+
const toSpend = chunkOMPDPBT5_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
24375
24691
|
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
24376
24692
|
const signed = await identity.sign(toSign, [0]);
|
|
24377
24693
|
signed.finalizeIdx(0);
|
|
@@ -24429,7 +24745,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
|
24429
24745
|
if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
|
|
24430
24746
|
return false;
|
|
24431
24747
|
}
|
|
24432
|
-
const toSpend =
|
|
24748
|
+
const toSpend = chunkOMPDPBT5_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
24433
24749
|
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript);
|
|
24434
24750
|
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
24435
24751
|
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
@@ -24450,7 +24766,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
|
24450
24766
|
}
|
|
24451
24767
|
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
24452
24768
|
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
24453
|
-
const toSpend =
|
|
24769
|
+
const toSpend = chunkOMPDPBT5_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
24454
24770
|
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
24455
24771
|
const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
|
|
24456
24772
|
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
@@ -24503,7 +24819,7 @@ function encodeCompactSize(n) {
|
|
|
24503
24819
|
return buf;
|
|
24504
24820
|
}
|
|
24505
24821
|
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
24506
|
-
const tx = new
|
|
24822
|
+
const tx = new chunkOMPDPBT5_cjs.Transaction({ version: 0 });
|
|
24507
24823
|
tx.addInput({
|
|
24508
24824
|
txid: toSpend.id,
|
|
24509
24825
|
index: 0,
|
|
@@ -24517,12 +24833,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
|
24517
24833
|
});
|
|
24518
24834
|
tx.addOutput({
|
|
24519
24835
|
amount: 0n,
|
|
24520
|
-
script:
|
|
24836
|
+
script: chunkOMPDPBT5_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
24521
24837
|
});
|
|
24522
24838
|
return tx;
|
|
24523
24839
|
}
|
|
24524
24840
|
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
24525
|
-
const tx = new
|
|
24841
|
+
const tx = new chunkOMPDPBT5_cjs.Transaction({ version: 0 });
|
|
24526
24842
|
tx.addInput({
|
|
24527
24843
|
txid: toSpend.id,
|
|
24528
24844
|
index: 0,
|
|
@@ -24534,12 +24850,12 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
|
24534
24850
|
});
|
|
24535
24851
|
tx.addOutput({
|
|
24536
24852
|
amount: 0n,
|
|
24537
|
-
script:
|
|
24853
|
+
script: chunkOMPDPBT5_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
24538
24854
|
});
|
|
24539
24855
|
return tx;
|
|
24540
24856
|
}
|
|
24541
24857
|
function finalizeVirtualTx(type, psbtBase64) {
|
|
24542
|
-
const tx =
|
|
24858
|
+
const tx = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
24543
24859
|
if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
|
|
24544
24860
|
const input = tx.getInput(0);
|
|
24545
24861
|
if (!input) {
|
|
@@ -24573,7 +24889,7 @@ async function resolveUnilateralPath(params) {
|
|
|
24573
24889
|
const { vtxo, scriptHex, contractRepository } = params;
|
|
24574
24890
|
const contract = contractRepository ? (await collectContracts(contractRepository, { script: scriptHex }))[0] : void 0;
|
|
24575
24891
|
if (contract) {
|
|
24576
|
-
const handler =
|
|
24892
|
+
const handler = chunkMQUATTIM_cjs.contractHandlers.get(contract.type);
|
|
24577
24893
|
if (!handler) {
|
|
24578
24894
|
throw new ExitPathError(
|
|
24579
24895
|
"no-handler",
|
|
@@ -24809,7 +25125,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
24809
25125
|
let totalAmount = 0n;
|
|
24810
25126
|
const txWeightEstimator = TxWeightEstimator.create();
|
|
24811
25127
|
for (const vtxo of vtxos) {
|
|
24812
|
-
if (!
|
|
25128
|
+
if (!chunkOMPDPBT5_cjs.canSweepOnchain(vtxo)) {
|
|
24813
25129
|
throw new Error(
|
|
24814
25130
|
`Vtxo ${vtxo.txid}:${vtxo.vout} cannot be swept onchain: it is not fully unrolled (use unroll first), or its exit output was already spent`
|
|
24815
25131
|
);
|
|
@@ -24861,7 +25177,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
24861
25177
|
btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
|
|
24862
25178
|
);
|
|
24863
25179
|
}
|
|
24864
|
-
const tx = new
|
|
25180
|
+
const tx = new chunkOMPDPBT5_cjs.Transaction({ version: 2 });
|
|
24865
25181
|
for (const input of inputs) {
|
|
24866
25182
|
tx.addInput(input);
|
|
24867
25183
|
}
|
|
@@ -24944,7 +25260,7 @@ async function buildSignedSweep(params) {
|
|
|
24944
25260
|
`uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
|
|
24945
25261
|
);
|
|
24946
25262
|
}
|
|
24947
|
-
const tx = new
|
|
25263
|
+
const tx = new chunkOMPDPBT5_cjs.Transaction({ version: 2 });
|
|
24948
25264
|
tx.addInput({
|
|
24949
25265
|
txid: vtxo.txid,
|
|
24950
25266
|
index: vtxo.vout,
|
|
@@ -24999,7 +25315,7 @@ async function resolveFeeRate(opts) {
|
|
|
24999
25315
|
}
|
|
25000
25316
|
async function selectExitVtxos(opts) {
|
|
25001
25317
|
if (!opts.vtxos) return opts.wallet.getVtxos();
|
|
25002
|
-
const res = await
|
|
25318
|
+
const res = await chunkOMPDPBT5_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
|
|
25003
25319
|
const scripts = [
|
|
25004
25320
|
...new Set(res.vtxos.filter((vtxo) => !vtxo.isSpent).map((vtxo) => vtxo.script))
|
|
25005
25321
|
];
|
|
@@ -25017,7 +25333,7 @@ async function selectExitVtxos(opts) {
|
|
|
25017
25333
|
`no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
|
|
25018
25334
|
);
|
|
25019
25335
|
}
|
|
25020
|
-
const handler =
|
|
25336
|
+
const handler = chunkMQUATTIM_cjs.contractHandlers.get(contract.type);
|
|
25021
25337
|
if (!handler) {
|
|
25022
25338
|
throw new Error(`no contract handler registered for type '${contract.type}'`);
|
|
25023
25339
|
}
|
|
@@ -25051,7 +25367,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
25051
25367
|
if (pendingNodes.length > 0) {
|
|
25052
25368
|
const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
|
|
25053
25369
|
for (const psbt of txs) {
|
|
25054
|
-
psbts.set(
|
|
25370
|
+
psbts.set(chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
25055
25371
|
}
|
|
25056
25372
|
}
|
|
25057
25373
|
const childVsize = Number(
|
|
@@ -25216,7 +25532,7 @@ var Executor = class {
|
|
|
25216
25532
|
constructor(pkg, provider, opts) {
|
|
25217
25533
|
this.pkg = pkg;
|
|
25218
25534
|
this.provider = provider;
|
|
25219
|
-
|
|
25535
|
+
chunkOMPDPBT5_cjs.assertTimerMs("pollIntervalMs", opts?.pollIntervalMs);
|
|
25220
25536
|
this.pollIntervalMs = opts?.pollIntervalMs ?? 5e3;
|
|
25221
25537
|
this.feeWallet = opts?.feeWallet;
|
|
25222
25538
|
this.signal = opts?.signal;
|
|
@@ -25600,7 +25916,7 @@ async function prepare(opts) {
|
|
|
25600
25916
|
if (newFee <= splitterFee) break;
|
|
25601
25917
|
splitterFee = newFee;
|
|
25602
25918
|
}
|
|
25603
|
-
const splitter = new
|
|
25919
|
+
const splitter = new chunkOMPDPBT5_cjs.Transaction({ version: 2 });
|
|
25604
25920
|
for (const coin of selected.inputs) {
|
|
25605
25921
|
splitter.addInput({
|
|
25606
25922
|
txid: coin.txid,
|
|
@@ -25779,7 +26095,7 @@ chunkFLPWNMX3_cjs.__export(arkade_exports, {
|
|
|
25779
26095
|
validateProgram: () => chunkJFJNB7ZH_cjs.validateProgram,
|
|
25780
26096
|
witnessRefToBytes: () => chunkJFJNB7ZH_cjs.witnessRefToBytes
|
|
25781
26097
|
});
|
|
25782
|
-
var isVtxoCoin = (input) =>
|
|
26098
|
+
var isVtxoCoin = (input) => chunkOMPDPBT5_cjs.isVirtualCoin(input);
|
|
25783
26099
|
function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
|
|
25784
26100
|
if (!signer && inputs.some((input) => !isVtxoCoin(input))) {
|
|
25785
26101
|
throw new Error("createArkadeBatchHandler: boarding inputs need a signer");
|
|
@@ -25822,7 +26138,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
25822
26138
|
if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
|
|
25823
26139
|
return { skip: true };
|
|
25824
26140
|
}
|
|
25825
|
-
const commitmentTx =
|
|
26141
|
+
const commitmentTx = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
|
|
25826
26142
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
25827
26143
|
if (recipients && recipients.length > 0) {
|
|
25828
26144
|
validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
|
|
@@ -25860,7 +26176,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
25860
26176
|
if (connectorTree) {
|
|
25861
26177
|
validateConnectorsTxGraph(event.commitmentTx, connectorTree);
|
|
25862
26178
|
}
|
|
25863
|
-
let commitmentPsbt =
|
|
26179
|
+
let commitmentPsbt = chunkOMPDPBT5_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
25864
26180
|
assertFinalCommitmentMatchesValidated(
|
|
25865
26181
|
commitmentPsbt,
|
|
25866
26182
|
validatedCommitmentTxid,
|
|
@@ -25902,7 +26218,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
25902
26218
|
boardingIndices.push(boardingIdx);
|
|
25903
26219
|
continue;
|
|
25904
26220
|
}
|
|
25905
|
-
if (!
|
|
26221
|
+
if (!chunkOMPDPBT5_cjs.requiresForfeit(input) || isSubdust(input, info.dust)) {
|
|
25906
26222
|
continue;
|
|
25907
26223
|
}
|
|
25908
26224
|
if (connectorIndex >= connectorLeaves.length) {
|
|
@@ -25940,7 +26256,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
25940
26256
|
forfeitOutputScript
|
|
25941
26257
|
);
|
|
25942
26258
|
if (input.extraWitness?.length) {
|
|
25943
|
-
|
|
26259
|
+
chunkOMPDPBT5_cjs.setArkPsbtField(forfeitTx, 0, chunkOMPDPBT5_cjs.ConditionWitness, input.extraWitness);
|
|
25944
26260
|
}
|
|
25945
26261
|
if (signer) forfeitTx = await signer.sign(forfeitTx, [0]);
|
|
25946
26262
|
signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
|
|
@@ -26035,7 +26351,7 @@ async function renewProgramContractOutputs(client, targets, opts = {}) {
|
|
|
26035
26351
|
});
|
|
26036
26352
|
const { fees } = await arkProvider.getInfo();
|
|
26037
26353
|
const fee = new Estimator(fees?.intentFee ?? {}).evaluate(
|
|
26038
|
-
legs.map(({ coin }) =>
|
|
26354
|
+
legs.map(({ coin }) => chunkOMPDPBT5_cjs.toOffchainInputFeeParams(chunkOMPDPBT5_cjs.normalizeVtxo(coin))),
|
|
26039
26355
|
[],
|
|
26040
26356
|
legs.map(({ contract, coin }) => ({
|
|
26041
26357
|
amount: BigInt(coin.value),
|
|
@@ -26098,7 +26414,7 @@ async function renewProgramContractOutputs(client, targets, opts = {}) {
|
|
|
26098
26414
|
const [signedProof, deleteProof] = await Promise.all(
|
|
26099
26415
|
[message, deleteMessage].map(
|
|
26100
26416
|
(m) => emulator.submitIntent({
|
|
26101
|
-
proof: base.base64.encode(
|
|
26417
|
+
proof: base.base64.encode(chunkOMPDPBT5_cjs.Proof.create(m, coins, outputs).toPSBT()),
|
|
26102
26418
|
message: m
|
|
26103
26419
|
})
|
|
26104
26420
|
)
|
|
@@ -26575,17 +26891,17 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
26575
26891
|
const [registered] = await manager.getContracts({ script: scriptHex });
|
|
26576
26892
|
if (registered) {
|
|
26577
26893
|
const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
|
|
26578
|
-
return (withVtxos?.vtxos ?? []).filter((v) => !
|
|
26894
|
+
return (withVtxos?.vtxos ?? []).filter((v) => !chunkOMPDPBT5_cjs.isVtxoSpent(v) && !v.isUnrolled);
|
|
26579
26895
|
}
|
|
26580
26896
|
}
|
|
26581
26897
|
if (!this.client.indexer) {
|
|
26582
26898
|
throw new Error("ArkadeContract.getUtxos: an indexer is required");
|
|
26583
26899
|
}
|
|
26584
|
-
const { vtxos } = await
|
|
26900
|
+
const { vtxos } = await chunkOMPDPBT5_cjs.getNormalizedVtxos(this.client.indexer, {
|
|
26585
26901
|
scripts: [scriptHex],
|
|
26586
26902
|
spendableOnly: true
|
|
26587
26903
|
});
|
|
26588
|
-
return vtxos.filter((v) => !
|
|
26904
|
+
return vtxos.filter((v) => !chunkOMPDPBT5_cjs.isVtxoSpent(v) && !v.isUnrolled);
|
|
26589
26905
|
}
|
|
26590
26906
|
/** Total spendable balance (requires an indexer). */
|
|
26591
26907
|
async getBalance() {
|
|
@@ -26751,7 +27067,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
26751
27067
|
this.client.checkpoint
|
|
26752
27068
|
);
|
|
26753
27069
|
inputs.forEach(({ coin }, i) => {
|
|
26754
|
-
if (coin.sourceTx)
|
|
27070
|
+
if (coin.sourceTx) chunkOMPDPBT5_cjs.setArkPsbtField(arkTx, i, chunkOMPDPBT5_cjs.PrevArkTxField, coin.sourceTx);
|
|
26755
27071
|
});
|
|
26756
27072
|
if (inputs.some(({ unlocker }) => unlocker.fn.arkadeScript)) {
|
|
26757
27073
|
const indexer = this.client.indexer;
|
|
@@ -26771,8 +27087,8 @@ var ArkadeTransactionBuilder = class {
|
|
|
26771
27087
|
(w) => witnessBytes(unlocker, w)
|
|
26772
27088
|
);
|
|
26773
27089
|
if (condition.length === 0) return;
|
|
26774
|
-
|
|
26775
|
-
|
|
27090
|
+
chunkOMPDPBT5_cjs.setArkPsbtField(arkTx, i, chunkOMPDPBT5_cjs.ConditionWitness, condition);
|
|
27091
|
+
chunkOMPDPBT5_cjs.setArkPsbtField(checkpoints[i], 0, chunkOMPDPBT5_cjs.ConditionWitness, condition);
|
|
26776
27092
|
});
|
|
26777
27093
|
const packets = [];
|
|
26778
27094
|
if (this.assetSpecs.length > 0) {
|
|
@@ -26835,7 +27151,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
26835
27151
|
);
|
|
26836
27152
|
}
|
|
26837
27153
|
const { sequence, lockTime } = this.leafTimelocks(fn);
|
|
26838
|
-
const tx = new
|
|
27154
|
+
const tx = new chunkOMPDPBT5_cjs.Transaction({ version: 2, lockTime });
|
|
26839
27155
|
tx.addInput({ txid: base.hex.decode(coin.txid), index: coin.vout, sequence });
|
|
26840
27156
|
for (const o of outputs) tx.addOutput(o);
|
|
26841
27157
|
const condition = (fn.def.tapscript.witness ?? []).map((w) => witnessBytes(unlocker, w));
|
|
@@ -26999,20 +27315,20 @@ var ArkadeTransactionBuilder = class {
|
|
|
26999
27315
|
* A caller's packet counts for every input, unread; arkd checks what it actually routes.
|
|
27000
27316
|
*/
|
|
27001
27317
|
routesAssetsFrom(vin) {
|
|
27002
|
-
return this.extraPackets.some((p) => p.type() ===
|
|
27318
|
+
return this.extraPackets.some((p) => p.type() === chunk3NALVGMJ_cjs.Packet.PACKET_TYPE) || this.assetSpecs.some((spec) => spec.inputs.some((i) => i.vin === vin));
|
|
27003
27319
|
}
|
|
27004
27320
|
buildAssetPacket() {
|
|
27005
27321
|
const groups = this.assetSpecs.map((s) => {
|
|
27006
|
-
const id = typeof s.assetId === "string" ?
|
|
27007
|
-
return
|
|
27322
|
+
const id = typeof s.assetId === "string" ? chunk3NALVGMJ_cjs.AssetId.fromString(s.assetId) : chunk3NALVGMJ_cjs.AssetId.fromBytes(s.assetId);
|
|
27323
|
+
return chunk3NALVGMJ_cjs.AssetGroup.create(
|
|
27008
27324
|
id,
|
|
27009
27325
|
null,
|
|
27010
|
-
s.inputs.map((i) =>
|
|
27011
|
-
s.outputs.map((o) =>
|
|
27012
|
-
(s.metadata ?? []).map((m) =>
|
|
27326
|
+
s.inputs.map((i) => chunk3NALVGMJ_cjs.AssetInput.create(i.vin, i.amount)),
|
|
27327
|
+
s.outputs.map((o) => chunk3NALVGMJ_cjs.AssetOutput.create(o.vout, o.amount)),
|
|
27328
|
+
(s.metadata ?? []).map((m) => chunk3NALVGMJ_cjs.Metadata.create(m.key, m.value))
|
|
27013
27329
|
);
|
|
27014
27330
|
});
|
|
27015
|
-
return
|
|
27331
|
+
return chunk3NALVGMJ_cjs.Packet.create(groups);
|
|
27016
27332
|
}
|
|
27017
27333
|
};
|
|
27018
27334
|
function unspendable(coin, now) {
|
|
@@ -27485,14 +27801,14 @@ var walletFeeSource = (wallet) => async () => (await wallet.arkProvider.getInfo(
|
|
|
27485
27801
|
function offchainInputFees(vtxos, fees) {
|
|
27486
27802
|
const estimator = new Estimator(fees?.intentFee ?? {});
|
|
27487
27803
|
return vtxos.reduce(
|
|
27488
|
-
(total, vtxo) => total + estimator.evalOffchainInput(
|
|
27804
|
+
(total, vtxo) => total + estimator.evalOffchainInput(chunkOMPDPBT5_cjs.toOffchainInputFeeParams(vtxo)).satoshis,
|
|
27489
27805
|
0
|
|
27490
27806
|
);
|
|
27491
27807
|
}
|
|
27492
27808
|
async function changeOutputFee(wallet, inputs, needed, fees) {
|
|
27493
27809
|
const estimator = new Estimator(fees?.intentFee ?? {});
|
|
27494
27810
|
const net = inputs.reduce(
|
|
27495
|
-
(total, vtxo) => total + BigInt(vtxo.value) - BigInt(estimator.evalOffchainInput(
|
|
27811
|
+
(total, vtxo) => total + BigInt(vtxo.value) - BigInt(estimator.evalOffchainInput(chunkOMPDPBT5_cjs.toOffchainInputFeeParams(vtxo)).satoshis),
|
|
27496
27812
|
0n
|
|
27497
27813
|
);
|
|
27498
27814
|
const script = base.hex.encode(chunkFLPWNMX3_cjs.ArkAddress.decode(await wallet.getAddress()).pkScript);
|
|
@@ -27665,11 +27981,14 @@ exports.WalletCannotSignError = WalletCannotSignError;
|
|
|
27665
27981
|
exports.WalletMessageHandler = WalletMessageHandler;
|
|
27666
27982
|
exports.WalletNotInitializedError = WalletNotInitializedError;
|
|
27667
27983
|
exports.WsElectrumChainSource = WsElectrumChainSource;
|
|
27984
|
+
exports.addArkadeCashRecord = addArkadeCashRecord;
|
|
27668
27985
|
exports.adoptContractDescriptor = adoptContractDescriptor;
|
|
27669
27986
|
exports.applyWalletStateUpdate = applyWalletStateUpdate;
|
|
27670
27987
|
exports.arkAssetRail = arkAssetRail;
|
|
27671
27988
|
exports.arkRail = arkRail;
|
|
27672
27989
|
exports.arkTarget = arkTarget;
|
|
27990
|
+
exports.arkadeCashId = arkadeCashId;
|
|
27991
|
+
exports.arkadeCashResolver = arkadeCashResolver;
|
|
27673
27992
|
exports.arkade_exports = arkade_exports;
|
|
27674
27993
|
exports.assertFinalCommitmentMatchesValidated = assertFinalCommitmentMatchesValidated;
|
|
27675
27994
|
exports.assertHistoryPageFilter = assertHistoryPageFilter;
|
|
@@ -27716,6 +28035,7 @@ exports.contractFromArkContract = contractFromArkContract;
|
|
|
27716
28035
|
exports.contractFromArkContractWithAddress = contractFromArkContractWithAddress;
|
|
27717
28036
|
exports.contractPreimage = contractPreimage;
|
|
27718
28037
|
exports.contractSigner = contractSigner;
|
|
28038
|
+
exports.createArkadeCashTracker = createArkadeCashTracker;
|
|
27719
28039
|
exports.createAssetPacket = createAssetPacket;
|
|
27720
28040
|
exports.createDefaultActivityRegistry = createDefaultActivityRegistry;
|
|
27721
28041
|
exports.createDefaultPaymentRouter = createDefaultPaymentRouter;
|
|
@@ -27772,6 +28092,7 @@ exports.legacyVtxoFacts = legacyVtxoFacts;
|
|
|
27772
28092
|
exports.logExcludedVtxos = logExcludedVtxos;
|
|
27773
28093
|
exports.makeHandle = makeHandle;
|
|
27774
28094
|
exports.matchServerCheckpoints = matchServerCheckpoints;
|
|
28095
|
+
exports.mergeArkadeCashRecord = mergeArkadeCashRecord;
|
|
27775
28096
|
exports.mergeChainedTxType = mergeChainedTxType;
|
|
27776
28097
|
exports.mnemonicFromPrf = mnemonicFromPrf;
|
|
27777
28098
|
exports.notifyExitObserved = notifyExitObserved;
|
|
@@ -27784,6 +28105,7 @@ exports.prfSupport = prfSupport;
|
|
|
27784
28105
|
exports.promisifyRequest = promisifyRequest;
|
|
27785
28106
|
exports.provisionClaimSecret = provisionClaimSecret;
|
|
27786
28107
|
exports.provisionRefundKey = provisionRefundKey;
|
|
28108
|
+
exports.readArkadeCash = readArkadeCash;
|
|
27787
28109
|
exports.registerWalletRestoreHook = registerWalletRestoreHook;
|
|
27788
28110
|
exports.resolveAssetAmount = resolveAssetAmount;
|
|
27789
28111
|
exports.resolveBatchExpiryPolicy = resolveBatchExpiryPolicy;
|
|
@@ -27817,5 +28139,5 @@ exports.waitForIncomingFunds = waitForIncomingFunds;
|
|
|
27817
28139
|
exports.walletFeeSource = walletFeeSource;
|
|
27818
28140
|
exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
|
|
27819
28141
|
exports.withPrevTxs = withPrevTxs;
|
|
27820
|
-
//# sourceMappingURL=chunk-
|
|
27821
|
-
//# sourceMappingURL=chunk-
|
|
28142
|
+
//# sourceMappingURL=chunk-URGVQ5TQ.cjs.map
|
|
28143
|
+
//# sourceMappingURL=chunk-URGVQ5TQ.cjs.map
|