@arkade-os/sdk 0.4.75 → 0.4.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/expo.cjs +5 -5
- package/dist/adapters/expo.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +3 -3
- package/dist/adapters/indexedDB.cjs +5 -5
- package/dist/adapters/indexedDB.js +4 -4
- package/dist/{asyncStorageTaskQueue-5k0H_cDM.d.cts → asyncStorageTaskQueue-D7BU-BdP.d.cts} +1 -1
- package/dist/{asyncStorageTaskQueue-DjwCbb07.d.ts → asyncStorageTaskQueue-DrKbfleJ.d.ts} +1 -1
- package/dist/{chunk-YA3L3WL4.cjs → chunk-2KFXM3N5.cjs} +17 -17
- package/dist/{chunk-YA3L3WL4.cjs.map → chunk-2KFXM3N5.cjs.map} +1 -1
- package/dist/{chunk-PS564TAU.js → chunk-54W6QBXL.js} +3 -3
- package/dist/{chunk-PS564TAU.js.map → chunk-54W6QBXL.js.map} +1 -1
- package/dist/{chunk-4GLSOP6L.js → chunk-7UJLIZQU.js} +3 -3
- package/dist/{chunk-4GLSOP6L.js.map → chunk-7UJLIZQU.js.map} +1 -1
- package/dist/{chunk-YYWEBYFJ.cjs → chunk-CQNX4BTA.cjs} +49 -49
- package/dist/{chunk-YYWEBYFJ.cjs.map → chunk-CQNX4BTA.cjs.map} +1 -1
- package/dist/{chunk-UKFA7NVE.js → chunk-F6YOCYWU.js} +3 -3
- package/dist/{chunk-UKFA7NVE.js.map → chunk-F6YOCYWU.js.map} +1 -1
- package/dist/{chunk-EHJYR4E5.cjs → chunk-LHSVPDFJ.cjs} +501 -464
- package/dist/chunk-LHSVPDFJ.cjs.map +1 -0
- package/dist/{chunk-2Q2PYU3Y.cjs → chunk-LQM6RHNT.cjs} +10 -10
- package/dist/{chunk-2Q2PYU3Y.cjs.map → chunk-LQM6RHNT.cjs.map} +1 -1
- package/dist/{chunk-2ULUCL6A.js → chunk-MUBPGYUE.js} +4 -4
- package/dist/{chunk-2ULUCL6A.js.map → chunk-MUBPGYUE.js.map} +1 -1
- package/dist/{chunk-SKAL4MCW.js → chunk-O2BIWLZC.js} +4 -4
- package/dist/{chunk-SKAL4MCW.js.map → chunk-O2BIWLZC.js.map} +1 -1
- package/dist/{chunk-J5EX3OMM.cjs → chunk-P53OHGXY.cjs} +3 -3
- package/dist/{chunk-J5EX3OMM.cjs.map → chunk-P53OHGXY.cjs.map} +1 -1
- package/dist/{chunk-SH23SRZE.cjs → chunk-T327OEMV.cjs} +17 -17
- package/dist/{chunk-SH23SRZE.cjs.map → chunk-T327OEMV.cjs.map} +1 -1
- package/dist/{chunk-FTLPTF3R.js → chunk-WMHELOHH.js} +52 -15
- package/dist/chunk-WMHELOHH.js.map +1 -0
- package/dist/contracts/handlers/index.cjs +9 -9
- package/dist/contracts/handlers/index.d.cts +3 -3
- package/dist/contracts/handlers/index.d.ts +3 -3
- package/dist/contracts/handlers/index.js +2 -2
- package/dist/{delegate-D_sW61rj.d.ts → delegate-BAYpqkEx.d.ts} +1 -1
- package/dist/{delegate-D0v8yT-a.d.cts → delegate-CR7msIXK.d.cts} +1 -1
- package/dist/{hdWalletCapable-DHCNbAgl.d.ts → hdWalletCapable-BSF29IjK.d.ts} +2 -2
- package/dist/{hdWalletCapable-66hG5KQP.d.cts → hdWalletCapable-BbZxCUeZ.d.cts} +2 -2
- package/dist/{index-B2JSxDi1.d.cts → index-4NF3srcg.d.cts} +2 -2
- package/dist/{index-TZBbMNqA.d.ts → index-B_RYn9rg.d.cts} +4 -0
- package/dist/{index-TZBbMNqA.d.cts → index-B_RYn9rg.d.ts} +4 -0
- package/dist/{index-vUeTpifq.d.ts → index-Dj2yOhQ2.d.ts} +2 -2
- package/dist/index.cjs +303 -303
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +19 -19
- 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 +18 -18
- 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-CAAPpdyi.d.cts → taskRunner-DGxde-YU.d.cts} +1 -1
- package/dist/{taskRunner-CairkunF.d.ts → taskRunner-TzGUhxP-.d.ts} +1 -1
- 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 +14 -14
- package/dist/wallet/expo/index.d.cts +4 -4
- package/dist/wallet/expo/index.d.ts +4 -4
- 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 +1 -1
- package/dist/chunk-EHJYR4E5.cjs.map +0 -1
- package/dist/chunk-FTLPTF3R.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkT327OEMV_cjs = require('./chunk-T327OEMV.cjs');
|
|
4
|
+
var chunkCQNX4BTA_cjs = require('./chunk-CQNX4BTA.cjs');
|
|
5
|
+
var chunkP53OHGXY_cjs = require('./chunk-P53OHGXY.cjs');
|
|
6
6
|
var chunk5BLDMQED_cjs = require('./chunk-5BLDMQED.cjs');
|
|
7
7
|
var utils_js = require('@scure/btc-signer/utils.js');
|
|
8
8
|
var btcSigner = require('@scure/btc-signer');
|
|
@@ -188,7 +188,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
188
188
|
noncesByPubkey.set(base.hex.encode(myPublicKey.subarray(1)), myNonce);
|
|
189
189
|
const tx = this.graph.find(txid);
|
|
190
190
|
if (!tx) throw new Error(`missing tx for txid ${txid}`);
|
|
191
|
-
const cosigners =
|
|
191
|
+
const cosigners = chunkP53OHGXY_cjs.getArkPsbtFields(tx.root, 0, chunkP53OHGXY_cjs.CosignerPublicKey).map(
|
|
192
192
|
(c) => base.hex.encode(c.key.subarray(1))
|
|
193
193
|
// xonly pubkey
|
|
194
194
|
);
|
|
@@ -240,7 +240,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
240
240
|
if (!aggNonce) throw new Error("missing aggregate nonce");
|
|
241
241
|
const prevoutAmounts = [];
|
|
242
242
|
const prevoutScripts = [];
|
|
243
|
-
const cosigners =
|
|
243
|
+
const cosigners = chunkP53OHGXY_cjs.getArkPsbtFields(g.root, 0, chunkP53OHGXY_cjs.CosignerPublicKey).map((c) => c.key);
|
|
244
244
|
const { finalKey } = aggregateKeys(cosigners, true, {
|
|
245
245
|
taprootTweak: this.scriptRoot
|
|
246
246
|
});
|
|
@@ -323,7 +323,7 @@ var SingleKey = class _SingleKey {
|
|
|
323
323
|
async sign(tx, inputIndexes) {
|
|
324
324
|
const txCpy = tx.clone();
|
|
325
325
|
if (!inputIndexes) {
|
|
326
|
-
|
|
326
|
+
chunkP53OHGXY_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH);
|
|
327
327
|
try {
|
|
328
328
|
if (!txCpy.sign(this.key, ALLOWED_SIGHASH)) {
|
|
329
329
|
throw new Error("Failed to sign transaction");
|
|
@@ -432,7 +432,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
432
432
|
let network;
|
|
433
433
|
if ("descriptor" in opts && typeof opts.descriptor === "string") {
|
|
434
434
|
descriptor = opts.descriptor;
|
|
435
|
-
network =
|
|
435
|
+
network = chunkCQNX4BTA_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
436
436
|
} else {
|
|
437
437
|
network = opts.isMainnet ?? true ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
438
438
|
descriptor = descriptorsScure.scriptExpressions.trBIP32({
|
|
@@ -530,7 +530,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
530
530
|
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
531
531
|
*/
|
|
532
532
|
isOurs(descriptor) {
|
|
533
|
-
return
|
|
533
|
+
return chunkCQNX4BTA_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
|
|
534
534
|
}
|
|
535
535
|
/**
|
|
536
536
|
* Signs each request with the key derived from its descriptor.
|
|
@@ -579,7 +579,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
579
579
|
}
|
|
580
580
|
// ── internal helpers ─────────────────────────────────────────────
|
|
581
581
|
derivePrivateKeyForDescriptor(descriptor) {
|
|
582
|
-
const network =
|
|
582
|
+
const network = chunkCQNX4BTA_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
583
583
|
const expansion = descriptorsScure.expand({ descriptor, network });
|
|
584
584
|
if (expansion.isRanged) {
|
|
585
585
|
throw new Error(
|
|
@@ -604,7 +604,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
604
604
|
signTxWithKey(tx, key, inputIndexes) {
|
|
605
605
|
const txCpy = tx.clone();
|
|
606
606
|
if (!inputIndexes) {
|
|
607
|
-
|
|
607
|
+
chunkP53OHGXY_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH2);
|
|
608
608
|
try {
|
|
609
609
|
if (!txCpy.sign(key, ALLOWED_SIGHASH2)) {
|
|
610
610
|
throw new Error("Failed to sign transaction");
|
|
@@ -666,7 +666,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
666
666
|
*/
|
|
667
667
|
descriptor;
|
|
668
668
|
constructor(descriptor) {
|
|
669
|
-
const network =
|
|
669
|
+
const network = chunkCQNX4BTA_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
670
670
|
let expansion;
|
|
671
671
|
try {
|
|
672
672
|
expansion = descriptorsScure.expand({ descriptor, network, index: 0 });
|
|
@@ -716,7 +716,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
716
716
|
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
717
717
|
*/
|
|
718
718
|
isOurs(descriptor) {
|
|
719
|
-
return
|
|
719
|
+
return chunkCQNX4BTA_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
|
|
720
720
|
}
|
|
721
721
|
};
|
|
722
722
|
function serializeSeedOwnedSigningIdentity(identity) {
|
|
@@ -878,10 +878,10 @@ var DescriptorIdentity = class {
|
|
|
878
878
|
this.base = base;
|
|
879
879
|
}
|
|
880
880
|
async xOnlyPublicKey() {
|
|
881
|
-
return
|
|
881
|
+
return chunkCQNX4BTA_cjs.deriveDescriptorLeafPubKey(this.descriptor);
|
|
882
882
|
}
|
|
883
883
|
async compressedPublicKey() {
|
|
884
|
-
return
|
|
884
|
+
return chunkCQNX4BTA_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
|
|
885
885
|
}
|
|
886
886
|
async sign(tx, inputIndexes) {
|
|
887
887
|
const [signed] = await this.signer.signWithDescriptor([
|
|
@@ -949,12 +949,12 @@ var WalletCannotAllocateAddressError = class extends Error {
|
|
|
949
949
|
};
|
|
950
950
|
async function resolveDescriptorSigner(descriptor, identity, provider) {
|
|
951
951
|
const owner = provider?.isOurs(descriptor) ? provider : isHDCapableIdentity(identity) && identity.isOurs(descriptor) ? identity : void 0;
|
|
952
|
-
if (owner &&
|
|
952
|
+
if (owner && chunkCQNX4BTA_cjs.parseHDDescriptor(descriptor)) {
|
|
953
953
|
return new DescriptorIdentity({ descriptor, signer: owner, base: identity });
|
|
954
954
|
}
|
|
955
955
|
let key;
|
|
956
956
|
try {
|
|
957
|
-
key =
|
|
957
|
+
key = chunkCQNX4BTA_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
958
958
|
} catch {
|
|
959
959
|
throw new ForeignDescriptorError(descriptor);
|
|
960
960
|
}
|
|
@@ -1329,14 +1329,14 @@ function buildSaltedPreimageMessage(xonly, salt) {
|
|
|
1329
1329
|
}
|
|
1330
1330
|
var PREIMAGE_INDEX = 0;
|
|
1331
1331
|
function isPerArtifactDescriptor(descriptor) {
|
|
1332
|
-
return
|
|
1332
|
+
return chunkCQNX4BTA_cjs.parseHDDescriptor(descriptor) !== null;
|
|
1333
1333
|
}
|
|
1334
1334
|
async function provisionDescriptor(wallet) {
|
|
1335
1335
|
const allocated = isHDAllocationCapable(wallet) ? await wallet.getNextSigningDescriptor() : void 0;
|
|
1336
|
-
return allocated ?? await
|
|
1336
|
+
return allocated ?? await chunkCQNX4BTA_cjs.identityDescriptor(wallet.identity);
|
|
1337
1337
|
}
|
|
1338
1338
|
async function provisionRefundKey(wallet) {
|
|
1339
|
-
const descriptor = await
|
|
1339
|
+
const descriptor = await chunkCQNX4BTA_cjs.identityDescriptor(wallet.identity);
|
|
1340
1340
|
const signer = await contractSigner(wallet, descriptor);
|
|
1341
1341
|
const pubkey = await signer.xOnlyPublicKey();
|
|
1342
1342
|
const identityPubkey = await wallet.identity.xOnlyPublicKey();
|
|
@@ -1346,7 +1346,7 @@ async function provisionRefundKey(wallet) {
|
|
|
1346
1346
|
);
|
|
1347
1347
|
}
|
|
1348
1348
|
const address = await wallet.getAddress();
|
|
1349
|
-
const { pkScript } =
|
|
1349
|
+
const { pkScript } = chunkP53OHGXY_cjs.ArkAddress.decode(address);
|
|
1350
1350
|
return { descriptor, pubkey, pkScript, address };
|
|
1351
1351
|
}
|
|
1352
1352
|
async function provisionClaimSecret(wallet, opts = {}) {
|
|
@@ -1392,7 +1392,7 @@ async function contractSigner(wallet, descriptor) {
|
|
|
1392
1392
|
const signer = isHDWalletCapable(wallet) ? await wallet.signerForDescriptor(descriptor) : wallet.identity;
|
|
1393
1393
|
let expected;
|
|
1394
1394
|
try {
|
|
1395
|
-
expected =
|
|
1395
|
+
expected = chunkCQNX4BTA_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
1396
1396
|
} catch (cause) {
|
|
1397
1397
|
throw new ForeignDescriptorError(descriptor, { cause });
|
|
1398
1398
|
}
|
|
@@ -1611,14 +1611,14 @@ var RestDelegateProvider = class {
|
|
|
1611
1611
|
*/
|
|
1612
1612
|
async delegate(intent, forfeitTxs, options) {
|
|
1613
1613
|
const url = `${this.url}/v1/delegate`;
|
|
1614
|
-
const response = await
|
|
1614
|
+
const response = await chunkP53OHGXY_cjs.baseFetch(url, {
|
|
1615
1615
|
method: "POST",
|
|
1616
1616
|
headers: {
|
|
1617
1617
|
"Content-Type": "application/json"
|
|
1618
1618
|
},
|
|
1619
1619
|
body: JSON.stringify({
|
|
1620
1620
|
intent: {
|
|
1621
|
-
message:
|
|
1621
|
+
message: chunkP53OHGXY_cjs.Intent.encodeMessage(intent.message),
|
|
1622
1622
|
proof: intent.proof
|
|
1623
1623
|
},
|
|
1624
1624
|
forfeit_txs: forfeitTxs,
|
|
@@ -1638,7 +1638,7 @@ var RestDelegateProvider = class {
|
|
|
1638
1638
|
*/
|
|
1639
1639
|
async getDelegateInfo() {
|
|
1640
1640
|
const url = `${this.url}/v1/delegator/info`;
|
|
1641
|
-
const response = await
|
|
1641
|
+
const response = await chunkP53OHGXY_cjs.rateGate.runHttp(url, () => chunkP53OHGXY_cjs.baseFetch(url));
|
|
1642
1642
|
if (!response.ok) {
|
|
1643
1643
|
const errorText2 = await response.text();
|
|
1644
1644
|
throw new Error(`Failed to get delegate info: ${errorText2}`);
|
|
@@ -1663,7 +1663,7 @@ var ESPLORA_URL = {
|
|
|
1663
1663
|
regtest: "http://localhost:3000/api"
|
|
1664
1664
|
};
|
|
1665
1665
|
var EsploraProvider = class {
|
|
1666
|
-
constructor(baseUrl = ESPLORA_URL[
|
|
1666
|
+
constructor(baseUrl = ESPLORA_URL[chunkP53OHGXY_cjs.DEFAULT_NETWORK_NAME], opts) {
|
|
1667
1667
|
this.baseUrl = baseUrl;
|
|
1668
1668
|
this.pollingInterval = opts?.pollingInterval ?? 15e3;
|
|
1669
1669
|
this.forcePolling = opts?.forcePolling ?? false;
|
|
@@ -1682,14 +1682,14 @@ var EsploraProvider = class {
|
|
|
1682
1682
|
*/
|
|
1683
1683
|
addressWatches = /* @__PURE__ */ new Map();
|
|
1684
1684
|
async getCoins(address) {
|
|
1685
|
-
const response = await
|
|
1685
|
+
const response = await chunkP53OHGXY_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
|
|
1686
1686
|
if (!response.ok) {
|
|
1687
1687
|
throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
|
|
1688
1688
|
}
|
|
1689
1689
|
return response.json();
|
|
1690
1690
|
}
|
|
1691
1691
|
async getFeeRate() {
|
|
1692
|
-
const response = await
|
|
1692
|
+
const response = await chunkP53OHGXY_cjs.baseFetch(`${this.baseUrl}/fee-estimates`);
|
|
1693
1693
|
if (response.status === 404) {
|
|
1694
1694
|
return void 0;
|
|
1695
1695
|
}
|
|
@@ -1710,7 +1710,7 @@ var EsploraProvider = class {
|
|
|
1710
1710
|
}
|
|
1711
1711
|
}
|
|
1712
1712
|
async getTxOutspends(txid) {
|
|
1713
|
-
const response = await
|
|
1713
|
+
const response = await chunkP53OHGXY_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
|
|
1714
1714
|
if (!response.ok) {
|
|
1715
1715
|
const error = await response.text();
|
|
1716
1716
|
throw new Error(`Failed to get transaction outspends: ${error}`);
|
|
@@ -1718,7 +1718,7 @@ var EsploraProvider = class {
|
|
|
1718
1718
|
return response.json();
|
|
1719
1719
|
}
|
|
1720
1720
|
async getTransactions(address) {
|
|
1721
|
-
const response = await
|
|
1721
|
+
const response = await chunkP53OHGXY_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
|
|
1722
1722
|
if (!response.ok) {
|
|
1723
1723
|
const error = await response.text();
|
|
1724
1724
|
throw new Error(`Failed to get transactions: ${error}`);
|
|
@@ -1731,14 +1731,14 @@ var EsploraProvider = class {
|
|
|
1731
1731
|
* usable as a change probe for the polling fallback.
|
|
1732
1732
|
*/
|
|
1733
1733
|
async getAddressStats(address) {
|
|
1734
|
-
const response = await
|
|
1734
|
+
const response = await chunkP53OHGXY_cjs.baseFetch(`${this.baseUrl}/address/${address}`);
|
|
1735
1735
|
if (!response.ok) {
|
|
1736
1736
|
throw new Error(`Failed to get address stats: ${response.statusText}`);
|
|
1737
1737
|
}
|
|
1738
1738
|
return response.json();
|
|
1739
1739
|
}
|
|
1740
1740
|
async getRawTransaction(txid) {
|
|
1741
|
-
const response = await
|
|
1741
|
+
const response = await chunkP53OHGXY_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/hex`);
|
|
1742
1742
|
if (!response.ok) {
|
|
1743
1743
|
const error = await response.text();
|
|
1744
1744
|
throw new Error(`Failed to get raw transaction ${txid}: ${error}`);
|
|
@@ -1746,7 +1746,7 @@ var EsploraProvider = class {
|
|
|
1746
1746
|
return base.hex.decode((await response.text()).trim());
|
|
1747
1747
|
}
|
|
1748
1748
|
async getTxStatus(txid) {
|
|
1749
|
-
const txresponse = await
|
|
1749
|
+
const txresponse = await chunkP53OHGXY_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
|
|
1750
1750
|
if (!txresponse.ok) {
|
|
1751
1751
|
throw new Error(txresponse.statusText);
|
|
1752
1752
|
}
|
|
@@ -1754,7 +1754,7 @@ var EsploraProvider = class {
|
|
|
1754
1754
|
if (!tx.status.confirmed) {
|
|
1755
1755
|
return { confirmed: false };
|
|
1756
1756
|
}
|
|
1757
|
-
const response = await
|
|
1757
|
+
const response = await chunkP53OHGXY_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
|
|
1758
1758
|
if (!response.ok) {
|
|
1759
1759
|
throw new Error(`Failed to get transaction status: ${response.statusText}`);
|
|
1760
1760
|
}
|
|
@@ -2038,9 +2038,9 @@ var EsploraProvider = class {
|
|
|
2038
2038
|
return { subscribers, teardown, started };
|
|
2039
2039
|
}
|
|
2040
2040
|
async getChainTip() {
|
|
2041
|
-
let tipBlocks = await
|
|
2041
|
+
let tipBlocks = await chunkP53OHGXY_cjs.baseFetch(`${this.baseUrl}/blocks`);
|
|
2042
2042
|
if (tipBlocks.status === 404) {
|
|
2043
|
-
tipBlocks = await
|
|
2043
|
+
tipBlocks = await chunkP53OHGXY_cjs.baseFetch(`${this.baseUrl}/v1/blocks`);
|
|
2044
2044
|
}
|
|
2045
2045
|
if (!tipBlocks.ok) {
|
|
2046
2046
|
throw new Error(`Failed to get chain tip: ${tipBlocks.statusText}`);
|
|
@@ -2062,7 +2062,7 @@ var EsploraProvider = class {
|
|
|
2062
2062
|
};
|
|
2063
2063
|
}
|
|
2064
2064
|
async broadcastPackage(parent, child) {
|
|
2065
|
-
const response = await
|
|
2065
|
+
const response = await chunkP53OHGXY_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
|
|
2066
2066
|
method: "POST",
|
|
2067
2067
|
headers: {
|
|
2068
2068
|
"Content-Type": "application/json"
|
|
@@ -2078,7 +2078,7 @@ var EsploraProvider = class {
|
|
|
2078
2078
|
return result;
|
|
2079
2079
|
}
|
|
2080
2080
|
async broadcastTx(tx) {
|
|
2081
|
-
const response = await
|
|
2081
|
+
const response = await chunkP53OHGXY_cjs.baseFetch(`${this.baseUrl}/tx`, {
|
|
2082
2082
|
method: "POST",
|
|
2083
2083
|
headers: {
|
|
2084
2084
|
"Content-Type": "text/plain"
|
|
@@ -2261,7 +2261,7 @@ function findP2AOutput(tx) {
|
|
|
2261
2261
|
var CHILD_DUST_AMOUNT = 546;
|
|
2262
2262
|
function buildAnchorChild(params) {
|
|
2263
2263
|
const { parent, feeRate, fundingCoins, changeAddress, tapInternalKey, network } = params;
|
|
2264
|
-
const child = new
|
|
2264
|
+
const child = new chunkP53OHGXY_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
|
|
2265
2265
|
child.addInput(findP2AOutput(parent));
|
|
2266
2266
|
const estimator = TxWeightEstimator.create().addP2AInput();
|
|
2267
2267
|
for (const _ of fundingCoins) {
|
|
@@ -2309,7 +2309,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
|
|
|
2309
2309
|
);
|
|
2310
2310
|
}
|
|
2311
2311
|
function buildForfeitTxWithOutput(inputs, output, txLocktime) {
|
|
2312
|
-
const tx = new
|
|
2312
|
+
const tx = new chunkP53OHGXY_cjs.Transaction({
|
|
2313
2313
|
version: 3,
|
|
2314
2314
|
lockTime: txLocktime
|
|
2315
2315
|
});
|
|
@@ -2385,7 +2385,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
|
|
|
2385
2385
|
if (previousScriptKey.length !== 32) {
|
|
2386
2386
|
throw new Error(`parent output ${childIndex} has invalid script`);
|
|
2387
2387
|
}
|
|
2388
|
-
const cosigners =
|
|
2388
|
+
const cosigners = chunkP53OHGXY_cjs.getArkPsbtFields(child.root, 0, chunkP53OHGXY_cjs.CosignerPublicKey);
|
|
2389
2389
|
if (cosigners.length === 0) {
|
|
2390
2390
|
throw ErrMissingCosignersPublicKeys;
|
|
2391
2391
|
}
|
|
@@ -2443,7 +2443,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
2443
2443
|
return new _EmulatorPacket(entries);
|
|
2444
2444
|
}
|
|
2445
2445
|
static fromBytes(data) {
|
|
2446
|
-
const reader = new
|
|
2446
|
+
const reader = new chunkT327OEMV_cjs.BufferReader(data);
|
|
2447
2447
|
const entryCount = reader.readCompactSize();
|
|
2448
2448
|
const entries = [];
|
|
2449
2449
|
for (let i = 0; i < entryCount; i++) {
|
|
@@ -2461,7 +2461,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
2461
2461
|
return _EmulatorPacket.PACKET_TYPE;
|
|
2462
2462
|
}
|
|
2463
2463
|
serialize() {
|
|
2464
|
-
const writer = new
|
|
2464
|
+
const writer = new chunkT327OEMV_cjs.BufferWriter();
|
|
2465
2465
|
writer.writeCompactSize(this.entries.length);
|
|
2466
2466
|
for (const entry of this.entries) {
|
|
2467
2467
|
writer.writeUint16LE(entry.vin);
|
|
@@ -2548,7 +2548,7 @@ var Extension = class _Extension {
|
|
|
2548
2548
|
`expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
|
|
2549
2549
|
);
|
|
2550
2550
|
}
|
|
2551
|
-
const reader = new
|
|
2551
|
+
const reader = new chunkT327OEMV_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
|
|
2552
2552
|
const packets = [];
|
|
2553
2553
|
while (reader.remaining() > 0) {
|
|
2554
2554
|
const packetType = reader.readByte();
|
|
@@ -2622,7 +2622,7 @@ var Extension = class _Extension {
|
|
|
2622
2622
|
*/
|
|
2623
2623
|
getAssetPacket() {
|
|
2624
2624
|
for (const p of this.packets) {
|
|
2625
|
-
if (p instanceof
|
|
2625
|
+
if (p instanceof chunkT327OEMV_cjs.Packet) {
|
|
2626
2626
|
return p;
|
|
2627
2627
|
}
|
|
2628
2628
|
}
|
|
@@ -2660,8 +2660,8 @@ var Extension = class _Extension {
|
|
|
2660
2660
|
};
|
|
2661
2661
|
function parsePacket(packetType, data) {
|
|
2662
2662
|
switch (packetType) {
|
|
2663
|
-
case
|
|
2664
|
-
return
|
|
2663
|
+
case chunkT327OEMV_cjs.Packet.PACKET_TYPE:
|
|
2664
|
+
return chunkT327OEMV_cjs.Packet.fromBytes(data);
|
|
2665
2665
|
case EmulatorPacket.PACKET_TYPE:
|
|
2666
2666
|
return EmulatorPacket.fromBytes(data);
|
|
2667
2667
|
default:
|
|
@@ -2708,22 +2708,22 @@ function buildOpReturnScript(data) {
|
|
|
2708
2708
|
}
|
|
2709
2709
|
return script;
|
|
2710
2710
|
}
|
|
2711
|
-
var ErrOffchainOutputNotFound = (address) => new
|
|
2712
|
-
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new
|
|
2711
|
+
var ErrOffchainOutputNotFound = (address) => new chunkP53OHGXY_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
|
|
2712
|
+
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkP53OHGXY_cjs.ServerResponseMismatchError(
|
|
2713
2713
|
`invalid asset output amount for ${assetId}: got ${got}, want ${want}`
|
|
2714
2714
|
);
|
|
2715
|
-
var ErrAssetGroupNotFound = (assetId) => new
|
|
2716
|
-
var ErrAssetOutputNotFound = (assetId, outputIndex) => new
|
|
2715
|
+
var ErrAssetGroupNotFound = (assetId) => new chunkP53OHGXY_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
|
|
2716
|
+
var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkP53OHGXY_cjs.ServerResponseMismatchError(
|
|
2717
2717
|
`asset output not found in asset group ${assetId} at index ${outputIndex}`
|
|
2718
2718
|
);
|
|
2719
|
-
var ErrOnchainOutputNotFound = (address) => new
|
|
2720
|
-
var ErrUnvalidatedOffchainOutput = (address) => new
|
|
2719
|
+
var ErrOnchainOutputNotFound = (address) => new chunkP53OHGXY_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
|
|
2720
|
+
var ErrUnvalidatedOffchainOutput = (address) => new chunkP53OHGXY_cjs.ServerResponseMismatchError(
|
|
2721
2721
|
`offchain output ${address} cannot be validated: virtual output tree signing did not run`
|
|
2722
2722
|
);
|
|
2723
|
-
var ErrIntentOutputNotFound = (index, kind) => new
|
|
2723
|
+
var ErrIntentOutputNotFound = (index, kind) => new chunkP53OHGXY_cjs.ServerResponseMismatchError(
|
|
2724
2724
|
`${kind} output ${index} of the intent proof is not present in what the server built`
|
|
2725
2725
|
);
|
|
2726
|
-
var ErrUnvalidatedIntentOutput = (index) => new
|
|
2726
|
+
var ErrUnvalidatedIntentOutput = (index) => new chunkP53OHGXY_cjs.ServerResponseMismatchError(
|
|
2727
2727
|
`offchain output ${index} of the intent proof cannot be validated: virtual output tree signing did not run`
|
|
2728
2728
|
);
|
|
2729
2729
|
var ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
|
|
@@ -2732,7 +2732,7 @@ var ErrInvalidOffchainOutputAmount = (address) => new Error(`invalid offchain ou
|
|
|
2732
2732
|
function assertFinalCommitmentMatchesValidated(finalCommitmentTx, validatedCommitmentTxid, context) {
|
|
2733
2733
|
if (!validatedCommitmentTxid) return;
|
|
2734
2734
|
if (finalCommitmentTx.id === validatedCommitmentTxid) return;
|
|
2735
|
-
throw new
|
|
2735
|
+
throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
|
|
2736
2736
|
`${context}: finalization commitment tx ${finalCommitmentTx.id} differs from the validated commitment tx ${validatedCommitmentTxid}`
|
|
2737
2737
|
);
|
|
2738
2738
|
}
|
|
@@ -2742,7 +2742,7 @@ function validateBatchRecipients(commitmentTx, vtxoTreeLeaves, recipients, netwo
|
|
|
2742
2742
|
for (const recipient of recipients) {
|
|
2743
2743
|
let arkAddress;
|
|
2744
2744
|
try {
|
|
2745
|
-
arkAddress =
|
|
2745
|
+
arkAddress = chunkP53OHGXY_cjs.ArkAddress.decode(recipient.address);
|
|
2746
2746
|
} catch {
|
|
2747
2747
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
2748
2748
|
continue;
|
|
@@ -2754,7 +2754,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
|
|
|
2754
2754
|
const usedOnchainOutputs = /* @__PURE__ */ new Set();
|
|
2755
2755
|
for (const recipient of recipients) {
|
|
2756
2756
|
try {
|
|
2757
|
-
|
|
2757
|
+
chunkP53OHGXY_cjs.ArkAddress.decode(recipient.address);
|
|
2758
2758
|
} catch {
|
|
2759
2759
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
2760
2760
|
continue;
|
|
@@ -2763,7 +2763,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
|
|
|
2763
2763
|
}
|
|
2764
2764
|
}
|
|
2765
2765
|
function declaredIntentOutputs(signedProof, onchainOutputIndexes) {
|
|
2766
|
-
const proof =
|
|
2766
|
+
const proof = chunkP53OHGXY_cjs.Transaction.fromPSBT(base.base64.decode(signedProof));
|
|
2767
2767
|
const onchain = new Set(onchainOutputIndexes);
|
|
2768
2768
|
const declared = [];
|
|
2769
2769
|
for (let i = 0; i < proof.outputsLength; i++) {
|
|
@@ -3055,7 +3055,7 @@ function assetMintResolver() {
|
|
|
3055
3055
|
if (!tx.assets?.length || !tx.key.arkTxid) return void 0;
|
|
3056
3056
|
const minted = tx.assets.filter((a) => {
|
|
3057
3057
|
try {
|
|
3058
|
-
return base.hex.encode(
|
|
3058
|
+
return base.hex.encode(chunkT327OEMV_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
|
|
3059
3059
|
} catch {
|
|
3060
3060
|
return false;
|
|
3061
3061
|
}
|
|
@@ -3131,7 +3131,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3131
3131
|
const existing = inputsByAssetId.get(asset.assetId);
|
|
3132
3132
|
inputsByAssetId.set(asset.assetId, [
|
|
3133
3133
|
...existing ?? [],
|
|
3134
|
-
|
|
3134
|
+
chunkT327OEMV_cjs.AssetInput.create(inputIndex, asset.amount)
|
|
3135
3135
|
]);
|
|
3136
3136
|
}
|
|
3137
3137
|
}
|
|
@@ -3143,7 +3143,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3143
3143
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
3144
3144
|
outputsByAssetId.set(asset.assetId, [
|
|
3145
3145
|
...existing ?? [],
|
|
3146
|
-
|
|
3146
|
+
chunkT327OEMV_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
3147
3147
|
]);
|
|
3148
3148
|
}
|
|
3149
3149
|
}
|
|
@@ -3154,7 +3154,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3154
3154
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
3155
3155
|
outputsByAssetId.set(asset.assetId, [
|
|
3156
3156
|
...existing ?? [],
|
|
3157
|
-
|
|
3157
|
+
chunkT327OEMV_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
3158
3158
|
]);
|
|
3159
3159
|
}
|
|
3160
3160
|
}
|
|
@@ -3163,11 +3163,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3163
3163
|
for (const assetIdStr of allAssetIds) {
|
|
3164
3164
|
const inputs = inputsByAssetId.get(assetIdStr);
|
|
3165
3165
|
const outputs = outputsByAssetId.get(assetIdStr);
|
|
3166
|
-
const assetId =
|
|
3167
|
-
const group =
|
|
3166
|
+
const assetId = chunkT327OEMV_cjs.AssetId.fromString(assetIdStr);
|
|
3167
|
+
const group = chunkT327OEMV_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
|
|
3168
3168
|
groups.push(group);
|
|
3169
3169
|
}
|
|
3170
|
-
return
|
|
3170
|
+
return chunkT327OEMV_cjs.Packet.create(groups);
|
|
3171
3171
|
}
|
|
3172
3172
|
function selectCoinsWithAsset(coins, assetId, requiredAmount) {
|
|
3173
3173
|
const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
|
|
@@ -3204,7 +3204,7 @@ function selectedCoinsToAssetInputs(selectedCoins) {
|
|
|
3204
3204
|
}
|
|
3205
3205
|
function toXOnlySignerHex(pubkeyHex) {
|
|
3206
3206
|
const bytes = base.hex.decode(pubkeyHex);
|
|
3207
|
-
if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(
|
|
3207
|
+
if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(chunkCQNX4BTA_cjs.toXOnly(bytes, "signer key"));
|
|
3208
3208
|
throw new Error(`invalid signer pubkey length: expected 32 or 33 bytes, got ${bytes.length}`);
|
|
3209
3209
|
}
|
|
3210
3210
|
function signerSetFromInfo(info) {
|
|
@@ -3251,13 +3251,13 @@ var toTimelock = (value) => ({
|
|
|
3251
3251
|
var toSeconds = (t) => t.type === "seconds" ? t.value : t.value * NOMINAL_BLOCK_SECONDS;
|
|
3252
3252
|
function assertTimelockInPolicy(timelock, policy, label, overrideOption) {
|
|
3253
3253
|
if (policy.requireSeconds && timelock.type === "blocks") {
|
|
3254
|
-
throw new
|
|
3254
|
+
throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
|
|
3255
3255
|
`${label} rejected: block-typed timelocks are not accepted (got ${timelock.value})`
|
|
3256
3256
|
);
|
|
3257
3257
|
}
|
|
3258
3258
|
const seconds = toSeconds(timelock);
|
|
3259
3259
|
if (seconds < policy.minSeconds) {
|
|
3260
|
-
throw new
|
|
3260
|
+
throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
|
|
3261
3261
|
`${label} rejected: ${timelock.value} ${timelock.type} is below the ${policy.minSeconds}s floor; pass ${overrideOption}: ${seconds}n to Wallet.create to lower it`
|
|
3262
3262
|
);
|
|
3263
3263
|
}
|
|
@@ -3278,7 +3278,7 @@ function resolveBatchExpiryPolicy(network, overrides) {
|
|
|
3278
3278
|
}
|
|
3279
3279
|
function assertValidBatchExpiry(batchExpiry, policy) {
|
|
3280
3280
|
if (policy.advertisedVtxoTreeExpiry !== void 0 && batchExpiry !== policy.advertisedVtxoTreeExpiry) {
|
|
3281
|
-
throw new
|
|
3281
|
+
throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
|
|
3282
3282
|
`batch expiry rejected: ${batchExpiry} does not match the advertised vtxoTreeExpiry ${policy.advertisedVtxoTreeExpiry}`
|
|
3283
3283
|
);
|
|
3284
3284
|
}
|
|
@@ -3308,21 +3308,21 @@ function resolveCheckpointExitDelayPolicy(network, overrides) {
|
|
|
3308
3308
|
function assertValidServerUnrollScript(checkpointTapscript, policy) {
|
|
3309
3309
|
let script;
|
|
3310
3310
|
try {
|
|
3311
|
-
script =
|
|
3311
|
+
script = chunkP53OHGXY_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
|
|
3312
3312
|
} catch (e) {
|
|
3313
|
-
throw new
|
|
3313
|
+
throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
|
|
3314
3314
|
`checkpoint exit delay rejected: invalid checkpointTapscript from server (${e instanceof Error ? e.message : String(e)})`
|
|
3315
3315
|
);
|
|
3316
3316
|
}
|
|
3317
3317
|
if (policy.advertisedForfeitPubkey !== void 0) {
|
|
3318
3318
|
const { pubkeys } = script.params;
|
|
3319
3319
|
if (pubkeys.length !== 1) {
|
|
3320
|
-
throw new
|
|
3320
|
+
throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
|
|
3321
3321
|
`checkpoint exit delay rejected: checkpointTapscript must commit to exactly one pubkey, got ${pubkeys.length} [${pubkeys.map(base.hex.encode).join(", ")}]`
|
|
3322
3322
|
);
|
|
3323
3323
|
}
|
|
3324
3324
|
if (!utils_js.equalBytes(pubkeys[0], policy.advertisedForfeitPubkey)) {
|
|
3325
|
-
throw new
|
|
3325
|
+
throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
|
|
3326
3326
|
`checkpoint exit delay rejected: checkpointTapscript pubkey ${base.hex.encode(pubkeys[0])} does not match the advertised forfeitPubkey ${base.hex.encode(policy.advertisedForfeitPubkey)}`
|
|
3327
3327
|
);
|
|
3328
3328
|
}
|
|
@@ -3366,8 +3366,8 @@ function buildOffchainTx(inputs, outputs, serverUnrollScript) {
|
|
|
3366
3366
|
function buildVirtualTx(inputs, outputs) {
|
|
3367
3367
|
let lockTime = 0n;
|
|
3368
3368
|
for (const input of inputs) {
|
|
3369
|
-
const tapscript =
|
|
3370
|
-
if (
|
|
3369
|
+
const tapscript = chunkP53OHGXY_cjs.decodeTapscript(chunkP53OHGXY_cjs.scriptFromTapLeafScript(input.tapLeafScript));
|
|
3370
|
+
if (chunkP53OHGXY_cjs.CLTVMultisigTapscript.is(tapscript)) {
|
|
3371
3371
|
if (lockTime !== 0n) {
|
|
3372
3372
|
if (isSeconds(lockTime) !== isSeconds(tapscript.params.absoluteTimelock)) {
|
|
3373
3373
|
throw new Error("cannot mix seconds and blocks locktime");
|
|
@@ -3378,7 +3378,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3378
3378
|
}
|
|
3379
3379
|
}
|
|
3380
3380
|
}
|
|
3381
|
-
const tx = new
|
|
3381
|
+
const tx = new chunkP53OHGXY_cjs.Transaction({
|
|
3382
3382
|
version: 3,
|
|
3383
3383
|
lockTime: Number(lockTime)
|
|
3384
3384
|
});
|
|
@@ -3388,12 +3388,12 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3388
3388
|
index: input.vout,
|
|
3389
3389
|
sequence: lockTime ? btcSigner.DEFAULT_SEQUENCE - 1 : void 0,
|
|
3390
3390
|
witnessUtxo: {
|
|
3391
|
-
script:
|
|
3391
|
+
script: chunkP53OHGXY_cjs.VtxoScript.decode(input.tapTree).pkScript,
|
|
3392
3392
|
amount: BigInt(input.value)
|
|
3393
3393
|
},
|
|
3394
3394
|
tapLeafScript: [input.tapLeafScript]
|
|
3395
3395
|
});
|
|
3396
|
-
|
|
3396
|
+
chunkP53OHGXY_cjs.setArkPsbtField(tx, i, chunkP53OHGXY_cjs.VtxoTaprootTree, input.tapTree);
|
|
3397
3397
|
}
|
|
3398
3398
|
for (const output of outputs) {
|
|
3399
3399
|
tx.addOutput(output);
|
|
@@ -3402,8 +3402,8 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3402
3402
|
return tx;
|
|
3403
3403
|
}
|
|
3404
3404
|
function buildCheckpointTx(vtxo, serverUnrollScript) {
|
|
3405
|
-
const collaborativeClosure =
|
|
3406
|
-
const checkpointVtxoScript = new
|
|
3405
|
+
const collaborativeClosure = chunkP53OHGXY_cjs.decodeTapscript(chunkP53OHGXY_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
|
|
3406
|
+
const checkpointVtxoScript = new chunkP53OHGXY_cjs.VtxoScript([
|
|
3407
3407
|
serverUnrollScript.script,
|
|
3408
3408
|
collaborativeClosure.script
|
|
3409
3409
|
]);
|
|
@@ -3479,7 +3479,7 @@ function verifyTapscriptSignatures(tx, inputIndex, requiredSigners, excludePubke
|
|
|
3479
3479
|
const sighashType = signature.length === 65 ? signature[64] : btcSigner.SigHash.DEFAULT;
|
|
3480
3480
|
const sig = signature.subarray(0, 64);
|
|
3481
3481
|
if (!allowedSighashTypes.includes(sighashType)) {
|
|
3482
|
-
const sighashName =
|
|
3482
|
+
const sighashName = chunkP53OHGXY_cjs.formatSighash(sighashType);
|
|
3483
3483
|
throw new Error(
|
|
3484
3484
|
`Unallowed sighash type ${sighashName} for input ${inputIndex}, pubkey ${pubKeyHex}.`
|
|
3485
3485
|
);
|
|
@@ -3553,7 +3553,7 @@ function combineTapscriptSigs(signedTx, originalTx) {
|
|
|
3553
3553
|
}
|
|
3554
3554
|
function isValidArkAddress(address) {
|
|
3555
3555
|
try {
|
|
3556
|
-
|
|
3556
|
+
chunkP53OHGXY_cjs.ArkAddress.decode(address);
|
|
3557
3557
|
return true;
|
|
3558
3558
|
} catch (e) {
|
|
3559
3559
|
return false;
|
|
@@ -3561,16 +3561,16 @@ function isValidArkAddress(address) {
|
|
|
3561
3561
|
}
|
|
3562
3562
|
function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, context) {
|
|
3563
3563
|
if (serverCheckpointTxs.length !== expectedCheckpoints.length) {
|
|
3564
|
-
throw new
|
|
3564
|
+
throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
|
|
3565
3565
|
`${context} returned ${serverCheckpointTxs.length} checkpoints, expected ${expectedCheckpoints.length}`
|
|
3566
3566
|
);
|
|
3567
3567
|
}
|
|
3568
3568
|
const byTxid = new Map(expectedCheckpoints.map((c) => [c.id, c]));
|
|
3569
3569
|
return serverCheckpointTxs.map((encoded, index) => {
|
|
3570
|
-
const server =
|
|
3570
|
+
const server = chunkP53OHGXY_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
|
|
3571
3571
|
const local = byTxid.get(server.id);
|
|
3572
3572
|
if (!local) {
|
|
3573
|
-
throw new
|
|
3573
|
+
throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
|
|
3574
3574
|
`${context} checkpoint ${index} txid ${server.id} does not match any submitted checkpoint`
|
|
3575
3575
|
);
|
|
3576
3576
|
}
|
|
@@ -3580,14 +3580,14 @@ function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, contex
|
|
|
3580
3580
|
}
|
|
3581
3581
|
function assertSubmittedArkTxid(response, signedArkTx, context) {
|
|
3582
3582
|
if (response.arkTxid !== signedArkTx.id) {
|
|
3583
|
-
throw new
|
|
3583
|
+
throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
|
|
3584
3584
|
`${context} returned ark txid ${response.arkTxid}, expected ${signedArkTx.id}`
|
|
3585
3585
|
);
|
|
3586
3586
|
}
|
|
3587
3587
|
if (response.finalArkTx === void 0) return;
|
|
3588
|
-
const finalTxid =
|
|
3588
|
+
const finalTxid = chunkP53OHGXY_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
|
|
3589
3589
|
if (finalTxid !== signedArkTx.id) {
|
|
3590
|
-
throw new
|
|
3590
|
+
throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
|
|
3591
3591
|
`${context} returned final ark tx ${finalTxid}, expected ${signedArkTx.id}`
|
|
3592
3592
|
);
|
|
3593
3593
|
}
|
|
@@ -3599,20 +3599,20 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeys, co
|
|
|
3599
3599
|
`${context}: input ${inputIndex} carries no spend leaf to verify the server signature against`
|
|
3600
3600
|
);
|
|
3601
3601
|
}
|
|
3602
|
-
const script =
|
|
3602
|
+
const script = chunkP53OHGXY_cjs.scriptFromTapLeafScript(leaf);
|
|
3603
3603
|
let leafPubkeys;
|
|
3604
3604
|
try {
|
|
3605
|
-
leafPubkeys =
|
|
3606
|
-
(key) => base.hex.encode(
|
|
3605
|
+
leafPubkeys = chunkP53OHGXY_cjs.decodeTapscript(script).params.pubkeys.map(
|
|
3606
|
+
(key) => base.hex.encode(chunkCQNX4BTA_cjs.toXOnly(key, "leaf key"))
|
|
3607
3607
|
);
|
|
3608
3608
|
} catch (error) {
|
|
3609
|
-
throw new
|
|
3609
|
+
throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
|
|
3610
3610
|
`${context}: input ${inputIndex} spend leaf cannot be decoded (${error instanceof Error ? error.message : String(error)})`
|
|
3611
3611
|
);
|
|
3612
3612
|
}
|
|
3613
3613
|
const signer = leafPubkeys.find((key) => serverPubkeys.has(key));
|
|
3614
3614
|
if (!signer) {
|
|
3615
|
-
throw new
|
|
3615
|
+
throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
|
|
3616
3616
|
`${context}: input ${inputIndex} spend leaf names no signer key the server advertises`
|
|
3617
3617
|
);
|
|
3618
3618
|
}
|
|
@@ -3626,7 +3626,7 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeys, co
|
|
|
3626
3626
|
payment_js.tapLeafHash(script)
|
|
3627
3627
|
);
|
|
3628
3628
|
} catch (error) {
|
|
3629
|
-
throw new
|
|
3629
|
+
throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
|
|
3630
3630
|
`${context}: input ${inputIndex} is not signed by the server on the leaf being spent (${error instanceof Error ? error.message : String(error)})`
|
|
3631
3631
|
);
|
|
3632
3632
|
}
|
|
@@ -3635,20 +3635,20 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
3635
3635
|
const byOutpoint = new Map(inputs.map((input) => [`${input.txid}:${input.vout}`, input]));
|
|
3636
3636
|
for (const [index, checkpoint] of checkpoints.entries()) {
|
|
3637
3637
|
if (checkpoint.inputsLength !== 1) {
|
|
3638
|
-
throw new
|
|
3638
|
+
throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
|
|
3639
3639
|
`${context}: checkpoint ${index} spends ${checkpoint.inputsLength} inputs, expected 1`
|
|
3640
3640
|
);
|
|
3641
3641
|
}
|
|
3642
3642
|
const spent = checkpoint.getInput(0);
|
|
3643
3643
|
if (!spent.txid || spent.index === void 0) {
|
|
3644
|
-
throw new
|
|
3644
|
+
throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
|
|
3645
3645
|
`${context}: checkpoint ${index} has no input outpoint`
|
|
3646
3646
|
);
|
|
3647
3647
|
}
|
|
3648
3648
|
const outpoint = `${base.hex.encode(spent.txid)}:${spent.index}`;
|
|
3649
3649
|
const input = byOutpoint.get(outpoint);
|
|
3650
3650
|
if (!input) {
|
|
3651
|
-
throw new
|
|
3651
|
+
throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
|
|
3652
3652
|
`${context}: checkpoint ${index} spends ${outpoint}, which is not one of the requested virtual outputs`
|
|
3653
3653
|
);
|
|
3654
3654
|
}
|
|
@@ -3656,7 +3656,7 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
3656
3656
|
(unroll) => buildCheckpointTx(input, unroll).tx.id === checkpoint.id
|
|
3657
3657
|
);
|
|
3658
3658
|
if (!rebuilt) {
|
|
3659
|
-
throw new
|
|
3659
|
+
throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
|
|
3660
3660
|
`${context}: checkpoint ${index} txid ${checkpoint.id} differs from the checkpoint built locally for ${outpoint}`
|
|
3661
3661
|
);
|
|
3662
3662
|
}
|
|
@@ -3682,9 +3682,9 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
3682
3682
|
const matched = matchServerCheckpoints(signedCheckpointTxs, offchainTx.checkpoints, "submitTx");
|
|
3683
3683
|
matched.forEach(({ server }, index) => {
|
|
3684
3684
|
try {
|
|
3685
|
-
|
|
3685
|
+
chunkP53OHGXY_cjs.assertAllowedSighashTypes(server);
|
|
3686
3686
|
} catch (error) {
|
|
3687
|
-
throw new
|
|
3687
|
+
throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
|
|
3688
3688
|
`submitTx checkpoint ${index}: ${error instanceof Error ? error.message : String(error)}`
|
|
3689
3689
|
);
|
|
3690
3690
|
}
|
|
@@ -3692,14 +3692,14 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
3692
3692
|
const verify = options?.verifyServerSignatures;
|
|
3693
3693
|
if (verify) {
|
|
3694
3694
|
if (response.finalArkTx === void 0) {
|
|
3695
|
-
throw new
|
|
3695
|
+
throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
|
|
3696
3696
|
"submitTx: server returned no final ark tx to verify its signatures against"
|
|
3697
3697
|
);
|
|
3698
3698
|
}
|
|
3699
|
-
const finalArkTx =
|
|
3699
|
+
const finalArkTx = chunkP53OHGXY_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
|
|
3700
3700
|
const serverPubkeys = new Set(
|
|
3701
3701
|
[verify.serverPubkey, ...verify.deprecatedServerPubkeys ?? []].map(
|
|
3702
|
-
(key) => base.hex.encode(
|
|
3702
|
+
(key) => base.hex.encode(chunkCQNX4BTA_cjs.toXOnly(key, "server key"))
|
|
3703
3703
|
)
|
|
3704
3704
|
);
|
|
3705
3705
|
for (let i = 0; i < offchainTx.arkTx.inputsLength; i++) {
|
|
@@ -3751,12 +3751,12 @@ function claimWithPreimageIdentity(identity, preimage) {
|
|
|
3751
3751
|
return {
|
|
3752
3752
|
...identity,
|
|
3753
3753
|
sign: async (tx, inputIndexes) => {
|
|
3754
|
-
const signed =
|
|
3754
|
+
const signed = chunkP53OHGXY_cjs.Transaction.fromPSBT(
|
|
3755
3755
|
(await identity.sign(tx.clone(), inputIndexes)).toPSBT()
|
|
3756
3756
|
);
|
|
3757
3757
|
const indexes = inputIndexes ?? Array.from({ length: signed.inputsLength }, (_, i) => i);
|
|
3758
3758
|
for (const index of indexes) {
|
|
3759
|
-
|
|
3759
|
+
chunkP53OHGXY_cjs.setArkPsbtField(signed, index, chunkP53OHGXY_cjs.ConditionWitness, [preimage]);
|
|
3760
3760
|
}
|
|
3761
3761
|
return signed;
|
|
3762
3762
|
}
|
|
@@ -3940,7 +3940,7 @@ function parseProgram(text, env) {
|
|
|
3940
3940
|
var DUST_AMOUNT = 546;
|
|
3941
3941
|
var FALLBACK_WALLET_DUST_AMOUNT = 330n;
|
|
3942
3942
|
function getDustAmount(wallet) {
|
|
3943
|
-
return "dustAmount" in wallet ? wallet.dustAmount : FALLBACK_WALLET_DUST_AMOUNT;
|
|
3943
|
+
return wallet && "dustAmount" in wallet ? wallet.dustAmount : FALLBACK_WALLET_DUST_AMOUNT;
|
|
3944
3944
|
}
|
|
3945
3945
|
function extendCoinWithTapscript(boardingTapscript, utxo) {
|
|
3946
3946
|
return {
|
|
@@ -3951,7 +3951,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
|
|
|
3951
3951
|
};
|
|
3952
3952
|
}
|
|
3953
3953
|
function deriveContractTapscripts(contract) {
|
|
3954
|
-
const handler =
|
|
3954
|
+
const handler = chunkCQNX4BTA_cjs.contractHandlers.get(contract.type);
|
|
3955
3955
|
if (!handler) {
|
|
3956
3956
|
throw new Error(`No handler for contract type '${contract.type}'`);
|
|
3957
3957
|
}
|
|
@@ -4022,7 +4022,7 @@ function getRandomId() {
|
|
|
4022
4022
|
}
|
|
4023
4023
|
function isValidArkAddress2(address) {
|
|
4024
4024
|
try {
|
|
4025
|
-
|
|
4025
|
+
chunkP53OHGXY_cjs.ArkAddress.decode(address);
|
|
4026
4026
|
return true;
|
|
4027
4027
|
} catch (e) {
|
|
4028
4028
|
return false;
|
|
@@ -4050,7 +4050,7 @@ function assertRecipientArkAddress(encoded, address, context) {
|
|
|
4050
4050
|
function assertTapTreeDerivesAddress(encoded, tapTree, address) {
|
|
4051
4051
|
let derived;
|
|
4052
4052
|
try {
|
|
4053
|
-
derived =
|
|
4053
|
+
derived = chunkP53OHGXY_cjs.VtxoScript.decode(tapTree).pkScript;
|
|
4054
4054
|
} catch (e) {
|
|
4055
4055
|
throw new Error(
|
|
4056
4056
|
`Invalid tapTree for ${encoded}: ${e instanceof Error ? e.message : String(e)}`
|
|
@@ -4067,7 +4067,7 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
4067
4067
|
for (const recipient of recipients) {
|
|
4068
4068
|
let address;
|
|
4069
4069
|
try {
|
|
4070
|
-
address =
|
|
4070
|
+
address = chunkP53OHGXY_cjs.ArkAddress.decode(recipient.address);
|
|
4071
4071
|
} catch (e) {
|
|
4072
4072
|
throw new Error(`Invalid Arkade address: ${recipient.address}`);
|
|
4073
4073
|
}
|
|
@@ -4092,7 +4092,7 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
4092
4092
|
|
|
4093
4093
|
// src/contracts/spendability.ts
|
|
4094
4094
|
function isContractGenericallySpendable(contract) {
|
|
4095
|
-
return
|
|
4095
|
+
return chunkCQNX4BTA_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
|
|
4096
4096
|
}
|
|
4097
4097
|
function gatedContracts(contracts) {
|
|
4098
4098
|
const gated = /* @__PURE__ */ new Map();
|
|
@@ -4114,7 +4114,7 @@ function gateExclusion(gated) {
|
|
|
4114
4114
|
return (vtxo) => {
|
|
4115
4115
|
const type = gatedTypeOf(vtxo, gated);
|
|
4116
4116
|
if (type === void 0) return void 0;
|
|
4117
|
-
if (!
|
|
4117
|
+
if (!chunkCQNX4BTA_cjs.contractHandlers.has(type)) {
|
|
4118
4118
|
return `at ${vtxo.script} (contract type '${type}') has no handler registered in this build`;
|
|
4119
4119
|
}
|
|
4120
4120
|
return `at ${vtxo.script} (contract type '${type}') is not generically spendable`;
|
|
@@ -4150,7 +4150,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
|
|
|
4150
4150
|
continue;
|
|
4151
4151
|
}
|
|
4152
4152
|
for (const v of vtxos) {
|
|
4153
|
-
if (!
|
|
4153
|
+
if (!chunkP53OHGXY_cjs.hasTerminalSpend(v) && !v.isSwept && !v.isUnrolled) {
|
|
4154
4154
|
out.add(`${v.txid}:${v.vout}`);
|
|
4155
4155
|
}
|
|
4156
4156
|
}
|
|
@@ -4185,10 +4185,10 @@ function byValueDescending(vtxos) {
|
|
|
4185
4185
|
return [...vtxos].sort((a, b) => b.value - a.value);
|
|
4186
4186
|
}
|
|
4187
4187
|
async function fetchTimeHeight(wallet) {
|
|
4188
|
-
return
|
|
4188
|
+
return chunkP53OHGXY_cjs.resolveTimeHeight(wallet.onchainProvider);
|
|
4189
4189
|
}
|
|
4190
4190
|
function canMigrateBySend(vtxo, now) {
|
|
4191
|
-
if (!
|
|
4191
|
+
if (!chunkP53OHGXY_cjs.canSpendOffchain(vtxo, now)) return false;
|
|
4192
4192
|
return vtxo.expiresAt !== void 0 || vtxo.expiresAtHeight !== void 0;
|
|
4193
4193
|
}
|
|
4194
4194
|
function byExpiryAscending(vtxos, now) {
|
|
@@ -4196,7 +4196,7 @@ function byExpiryAscending(vtxos, now) {
|
|
|
4196
4196
|
if (vtxo.isSwept) return -Infinity;
|
|
4197
4197
|
if (vtxo.expiresAt !== void 0) return vtxo.expiresAt.getTime();
|
|
4198
4198
|
if (vtxo.expiresAtHeight !== void 0) {
|
|
4199
|
-
return
|
|
4199
|
+
return chunkP53OHGXY_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
|
|
4200
4200
|
}
|
|
4201
4201
|
return Infinity;
|
|
4202
4202
|
};
|
|
@@ -4223,7 +4223,7 @@ function priceSettlementInputs(vtxos, estimator) {
|
|
|
4223
4223
|
const payable = [];
|
|
4224
4224
|
const net = /* @__PURE__ */ new Map();
|
|
4225
4225
|
for (const vtxo of vtxos) {
|
|
4226
|
-
const inputFee = estimator.evalOffchainInput(
|
|
4226
|
+
const inputFee = estimator.evalOffchainInput(chunkP53OHGXY_cjs.toOffchainInputFeeParams(vtxo));
|
|
4227
4227
|
if (inputFee.satoshis >= vtxo.value) {
|
|
4228
4228
|
continue;
|
|
4229
4229
|
}
|
|
@@ -4249,7 +4249,7 @@ function deductOffchainOutputFee(subtotal, estimator, arkAddress) {
|
|
|
4249
4249
|
}
|
|
4250
4250
|
const outputFee = estimator.evalOffchainOutput({
|
|
4251
4251
|
amount: subtotal,
|
|
4252
|
-
script: base.hex.encode(
|
|
4252
|
+
script: base.hex.encode(chunkP53OHGXY_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
4253
4253
|
});
|
|
4254
4254
|
return subtotal - BigInt(outputFee.satoshis);
|
|
4255
4255
|
}
|
|
@@ -4267,10 +4267,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
|
|
|
4267
4267
|
};
|
|
4268
4268
|
function getRecoverableVtxos(vtxos, dustAmount, now) {
|
|
4269
4269
|
return vtxos.filter((vtxo) => {
|
|
4270
|
-
if (
|
|
4270
|
+
if (chunkP53OHGXY_cjs.canRecoverOnchain(vtxo, now)) {
|
|
4271
4271
|
return true;
|
|
4272
4272
|
}
|
|
4273
|
-
if (
|
|
4273
|
+
if (chunkP53OHGXY_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
|
|
4274
4274
|
return true;
|
|
4275
4275
|
}
|
|
4276
4276
|
return false;
|
|
@@ -4302,7 +4302,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
|
|
|
4302
4302
|
function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
4303
4303
|
if (vtxo.isUnrolled) return false;
|
|
4304
4304
|
const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
|
|
4305
|
-
const expiresAt =
|
|
4305
|
+
const expiresAt = chunkP53OHGXY_cjs.normalizeVtxo(vtxo).expiresAt;
|
|
4306
4306
|
if (expiresAt === void 0) return false;
|
|
4307
4307
|
const now = Date.now();
|
|
4308
4308
|
const batchExpiry = expiresAt.getTime();
|
|
@@ -4313,7 +4313,7 @@ function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
|
|
|
4313
4313
|
return vtxos.filter(
|
|
4314
4314
|
// The leading exclusion covers the `isSubdust` arm too, which is a value
|
|
4315
4315
|
// property and would otherwise re-admit an exited coin on its own.
|
|
4316
|
-
(vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) ||
|
|
4316
|
+
(vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) || chunkP53OHGXY_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount))
|
|
4317
4317
|
);
|
|
4318
4318
|
}
|
|
4319
4319
|
function isMigrationCapable(wallet) {
|
|
@@ -4912,11 +4912,11 @@ var VtxoManager = class _VtxoManager {
|
|
|
4912
4912
|
`Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
|
|
4913
4913
|
);
|
|
4914
4914
|
}
|
|
4915
|
-
const tx = new
|
|
4915
|
+
const tx = new chunkP53OHGXY_cjs.Transaction();
|
|
4916
4916
|
for (const utxo of expiredUtxos) {
|
|
4917
|
-
const utxoScript =
|
|
4917
|
+
const utxoScript = chunkP53OHGXY_cjs.VtxoScript.decode(utxo.tapTree);
|
|
4918
4918
|
const utxoExitLeaf = utxoScript.leaves.find(
|
|
4919
|
-
(leaf) =>
|
|
4919
|
+
(leaf) => chunkP53OHGXY_cjs.CSVMultisigTapscript.isScriptValid(chunkP53OHGXY_cjs.scriptFromTapLeafScript(leaf)) === true
|
|
4920
4920
|
);
|
|
4921
4921
|
if (!utxoExitLeaf) {
|
|
4922
4922
|
throw new Error(
|
|
@@ -4931,7 +4931,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4931
4931
|
amount: BigInt(utxo.value)
|
|
4932
4932
|
},
|
|
4933
4933
|
tapLeafScript: [utxoExitLeaf],
|
|
4934
|
-
sequence:
|
|
4934
|
+
sequence: chunkP53OHGXY_cjs.getSequence(utxoExitLeaf)
|
|
4935
4935
|
});
|
|
4936
4936
|
}
|
|
4937
4937
|
tx.addOutputAddress(boardingAddress, outputAmount, this.getNetwork());
|
|
@@ -5174,8 +5174,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
5174
5174
|
const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
|
|
5175
5175
|
if (cls.status === "CURRENT") continue;
|
|
5176
5176
|
const live = vtxos.filter((v) => !v.isUnrolled);
|
|
5177
|
-
const recoverable = live.filter((v) => v.isSwept && !
|
|
5178
|
-
const spendable = live.filter((v) => !
|
|
5177
|
+
const recoverable = live.filter((v) => v.isSwept && !chunkP53OHGXY_cjs.hasTerminalSpend(v));
|
|
5178
|
+
const spendable = live.filter((v) => !chunkP53OHGXY_cjs.hasTerminalSpend(v) && !v.isSwept);
|
|
5179
5179
|
const value = spendable.reduce((sum, v) => sum + v.value, 0);
|
|
5180
5180
|
let recoverableCount = 0;
|
|
5181
5181
|
let recoverableValue = 0;
|
|
@@ -5188,7 +5188,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5188
5188
|
awaitingSweepCount = spendable.length;
|
|
5189
5189
|
awaitingSweepValue = value;
|
|
5190
5190
|
for (const v of spendable) {
|
|
5191
|
-
const exp =
|
|
5191
|
+
const exp = chunkP53OHGXY_cjs.toBatchExpiry(v);
|
|
5192
5192
|
if (exp !== void 0 && (nextSweepEta === void 0 || exp < nextSweepEta)) {
|
|
5193
5193
|
nextSweepEta = exp;
|
|
5194
5194
|
}
|
|
@@ -5449,7 +5449,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5449
5449
|
/** Decodes the boarding tapscript exit path to extract the CSV timelock. */
|
|
5450
5450
|
getBoardingTimelock() {
|
|
5451
5451
|
const wallet = this.getSweepWallet();
|
|
5452
|
-
const exitScript =
|
|
5452
|
+
const exitScript = chunkP53OHGXY_cjs.CSVMultisigTapscript.decode(
|
|
5453
5453
|
base.hex.decode(wallet.boardingTapscript.exitScript)
|
|
5454
5454
|
);
|
|
5455
5455
|
return exitScript.params.timelock;
|
|
@@ -5580,8 +5580,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
5580
5580
|
* or doesn't carry the metadata.
|
|
5581
5581
|
*/
|
|
5582
5582
|
extractSpentOutpoint(error) {
|
|
5583
|
-
const ark =
|
|
5584
|
-
if (!
|
|
5583
|
+
const ark = chunkP53OHGXY_cjs.maybeArkError(error);
|
|
5584
|
+
if (!chunkP53OHGXY_cjs.isArkError(ark, chunkP53OHGXY_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
|
|
5585
5585
|
const raw = ark.metadata?.vtxo_outpoint;
|
|
5586
5586
|
if (typeof raw !== "string") return void 0;
|
|
5587
5587
|
const [txid, voutStr] = raw.split(":");
|
|
@@ -5771,7 +5771,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5771
5771
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
5772
5772
|
break;
|
|
5773
5773
|
}
|
|
5774
|
-
const inputFee = estimator.evalOffchainInput(
|
|
5774
|
+
const inputFee = estimator.evalOffchainInput(chunkP53OHGXY_cjs.toOffchainInputFeeParams(v));
|
|
5775
5775
|
if (inputFee.satoshis >= v.value) {
|
|
5776
5776
|
continue;
|
|
5777
5777
|
}
|
|
@@ -5791,7 +5791,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5791
5791
|
const arkAddress = await this.wallet.getAddress();
|
|
5792
5792
|
const outputFee = estimator.evalOffchainOutput({
|
|
5793
5793
|
amount: totalAmount,
|
|
5794
|
-
script: base.hex.encode(
|
|
5794
|
+
script: base.hex.encode(chunkP53OHGXY_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
5795
5795
|
});
|
|
5796
5796
|
totalAmount -= BigInt(outputFee.satoshis);
|
|
5797
5797
|
if (totalAmount < dustAmount) return;
|
|
@@ -5871,7 +5871,7 @@ var ArkNote = class _ArkNote {
|
|
|
5871
5871
|
this.value = value;
|
|
5872
5872
|
this.HRP = HRP;
|
|
5873
5873
|
const preimageHash = utils_js.sha256(this.preimage);
|
|
5874
|
-
this.vtxoScript = new
|
|
5874
|
+
this.vtxoScript = new chunkP53OHGXY_cjs.VtxoScript([noteTapscript(preimageHash)]);
|
|
5875
5875
|
const leaf = this.vtxoScript.leaves[0];
|
|
5876
5876
|
this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
|
|
5877
5877
|
this.tapTree = this.vtxoScript.encode();
|
|
@@ -6038,7 +6038,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
6038
6038
|
const privateKey = data.slice(1, 33);
|
|
6039
6039
|
const serverPubKey = data.slice(33, 65);
|
|
6040
6040
|
const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
|
|
6041
|
-
const csvTimelock =
|
|
6041
|
+
const csvTimelock = chunkP53OHGXY_cjs.sequenceToTimelock(sequence);
|
|
6042
6042
|
return new _ArkadeCash(privateKey, serverPubKey, csvTimelock, decoded.prefix);
|
|
6043
6043
|
}
|
|
6044
6044
|
toString() {
|
|
@@ -6046,7 +6046,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
6046
6046
|
data[0] = _ArkadeCash.Version;
|
|
6047
6047
|
data.set(this._privateKey, 1);
|
|
6048
6048
|
data.set(this._serverPubKey, 33);
|
|
6049
|
-
const sequence =
|
|
6049
|
+
const sequence = chunkP53OHGXY_cjs.timelockToSequence(this.csvTimelock);
|
|
6050
6050
|
new DataView(data.buffer, data.byteOffset + 65, 4).setUint32(0, sequence, false);
|
|
6051
6051
|
const words = base.bech32m.toWords(data);
|
|
6052
6052
|
return base.bech32m.encode(this.hrp, words, 1023);
|
|
@@ -6055,7 +6055,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
6055
6055
|
return SingleKey.fromPrivateKey(this._privateKey);
|
|
6056
6056
|
}
|
|
6057
6057
|
get vtxoScript() {
|
|
6058
|
-
return new
|
|
6058
|
+
return new chunkCQNX4BTA_cjs.DefaultVtxo.Script({
|
|
6059
6059
|
pubKey: this._publicKey,
|
|
6060
6060
|
serverPubKey: this._serverPubKey,
|
|
6061
6061
|
csvTimelock: this.csvTimelock
|
|
@@ -6316,7 +6316,7 @@ async function captureExitBranch(params) {
|
|
|
6316
6316
|
const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
|
|
6317
6317
|
if (nonCommitment.length > 0) {
|
|
6318
6318
|
for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
|
|
6319
|
-
psbtByTxid.set(
|
|
6319
|
+
psbtByTxid.set(chunkP53OHGXY_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
6320
6320
|
}
|
|
6321
6321
|
}
|
|
6322
6322
|
}
|
|
@@ -6359,10 +6359,10 @@ var IndexerExitDataSource = class {
|
|
|
6359
6359
|
while (hasMore) {
|
|
6360
6360
|
const { chain: page, page: meta } = await this.indexer.getVtxoChain(
|
|
6361
6361
|
{ txid: vtxo.txid, vout: vtxo.vout },
|
|
6362
|
-
{ pageIndex, pageSize:
|
|
6362
|
+
{ pageIndex, pageSize: chunkP53OHGXY_cjs.DEFAULT_PAGE_SIZE }
|
|
6363
6363
|
);
|
|
6364
6364
|
chain.push(...page);
|
|
6365
|
-
hasMore = meta ? page.length ===
|
|
6365
|
+
hasMore = meta ? page.length === chunkP53OHGXY_cjs.DEFAULT_PAGE_SIZE : false;
|
|
6366
6366
|
pageIndex++;
|
|
6367
6367
|
}
|
|
6368
6368
|
return chain;
|
|
@@ -6374,12 +6374,12 @@ var IndexerExitDataSource = class {
|
|
|
6374
6374
|
while (hasMore) {
|
|
6375
6375
|
const { txs, page } = await this.indexer.getVirtualTxs(txids, {
|
|
6376
6376
|
pageIndex,
|
|
6377
|
-
pageSize:
|
|
6377
|
+
pageSize: chunkP53OHGXY_cjs.DEFAULT_PAGE_SIZE
|
|
6378
6378
|
});
|
|
6379
6379
|
for (const psbt of txs) {
|
|
6380
|
-
out.set(
|
|
6380
|
+
out.set(chunkP53OHGXY_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
6381
6381
|
}
|
|
6382
|
-
hasMore = page ? txs.length ===
|
|
6382
|
+
hasMore = page ? txs.length === chunkP53OHGXY_cjs.DEFAULT_PAGE_SIZE : false;
|
|
6383
6383
|
pageIndex++;
|
|
6384
6384
|
}
|
|
6385
6385
|
return out;
|
|
@@ -6400,7 +6400,7 @@ function chainedTxTypeToChainTxType(t) {
|
|
|
6400
6400
|
}
|
|
6401
6401
|
}
|
|
6402
6402
|
function psbtInputTxids(psbtBase64) {
|
|
6403
|
-
const tx =
|
|
6403
|
+
const tx = chunkP53OHGXY_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
6404
6404
|
const ids = [];
|
|
6405
6405
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
6406
6406
|
const txid = tx.getInput(i).txid;
|
|
@@ -6759,10 +6759,10 @@ async function resolveArkInfo(arkProvider, walletRepository) {
|
|
|
6759
6759
|
try {
|
|
6760
6760
|
info = await arkProvider.getInfo();
|
|
6761
6761
|
} catch (err) {
|
|
6762
|
-
if (!
|
|
6762
|
+
if (!chunkP53OHGXY_cjs.isRetryableProviderError(err)) throw err;
|
|
6763
6763
|
const snapshot = await loadArkInfoSnapshot(walletRepository);
|
|
6764
6764
|
if (!snapshot) {
|
|
6765
|
-
throw new
|
|
6765
|
+
throw new chunkP53OHGXY_cjs.ProviderUnavailableError(
|
|
6766
6766
|
"Arkade server info is unavailable and no cached snapshot exists",
|
|
6767
6767
|
{ cause: err }
|
|
6768
6768
|
);
|
|
@@ -7169,7 +7169,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos, localCreatedAt) {
|
|
|
7169
7169
|
return [...txids];
|
|
7170
7170
|
}
|
|
7171
7171
|
async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt, gatedScripts = /* @__PURE__ */ new Map()) {
|
|
7172
|
-
const normalized = vtxos.map(
|
|
7172
|
+
const normalized = vtxos.map(chunkP53OHGXY_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
7173
7173
|
const localCreatedAt = localCreatedAtByTxid(normalized);
|
|
7174
7174
|
const gatedVtxos = normalized.filter((vtxo) => isGatedVtxo(vtxo, gatedScripts));
|
|
7175
7175
|
const ownVtxos = normalized.filter((vtxo) => !isGatedVtxo(vtxo, gatedScripts));
|
|
@@ -7343,7 +7343,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7343
7343
|
const virtualCoins = await this.wallet.getSpendableVtxos({
|
|
7344
7344
|
withRecoverable: false
|
|
7345
7345
|
});
|
|
7346
|
-
const controlAssetRef = params.controlAssetId ?
|
|
7346
|
+
const controlAssetRef = params.controlAssetId ? chunkT327OEMV_cjs.AssetRef.fromId(chunkT327OEMV_cjs.AssetId.fromString(params.controlAssetId)) : null;
|
|
7347
7347
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
7348
7348
|
let totalBtcSelected = 0n;
|
|
7349
7349
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -7356,8 +7356,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7356
7356
|
}
|
|
7357
7357
|
}
|
|
7358
7358
|
const groups = [];
|
|
7359
|
-
const issuedAssetOutput =
|
|
7360
|
-
const issuedAssetGroup =
|
|
7359
|
+
const issuedAssetOutput = chunkT327OEMV_cjs.AssetOutput.create(0, params.amount);
|
|
7360
|
+
const issuedAssetGroup = chunkT327OEMV_cjs.AssetGroup.create(
|
|
7361
7361
|
null,
|
|
7362
7362
|
controlAssetRef,
|
|
7363
7363
|
[],
|
|
@@ -7372,28 +7372,28 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7372
7372
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7373
7373
|
for (const asset of assets) {
|
|
7374
7374
|
if (asset.assetId !== assetId) continue;
|
|
7375
|
-
changeInputs.push(
|
|
7375
|
+
changeInputs.push(chunkT327OEMV_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7376
7376
|
}
|
|
7377
7377
|
}
|
|
7378
7378
|
groups.push(
|
|
7379
|
-
|
|
7380
|
-
|
|
7379
|
+
chunkT327OEMV_cjs.AssetGroup.create(
|
|
7380
|
+
chunkT327OEMV_cjs.AssetId.fromString(assetId),
|
|
7381
7381
|
null,
|
|
7382
7382
|
changeInputs,
|
|
7383
|
-
[
|
|
7383
|
+
[chunkT327OEMV_cjs.AssetOutput.create(0, amount)],
|
|
7384
7384
|
[]
|
|
7385
7385
|
)
|
|
7386
7386
|
);
|
|
7387
7387
|
}
|
|
7388
7388
|
}
|
|
7389
7389
|
const address = await this.wallet.getAddress();
|
|
7390
|
-
const outputAddress =
|
|
7390
|
+
const outputAddress = chunkP53OHGXY_cjs.ArkAddress.decode(address);
|
|
7391
7391
|
const outputs = [
|
|
7392
7392
|
{
|
|
7393
7393
|
script: outputAddress.pkScript,
|
|
7394
7394
|
amount: BigInt(totalBtcSelected)
|
|
7395
7395
|
},
|
|
7396
|
-
Extension.create([
|
|
7396
|
+
Extension.create([chunkT327OEMV_cjs.Packet.create(groups)]).txOut()
|
|
7397
7397
|
];
|
|
7398
7398
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
|
|
7399
7399
|
coinSelection.inputs,
|
|
@@ -7401,7 +7401,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7401
7401
|
);
|
|
7402
7402
|
return {
|
|
7403
7403
|
arkTxId: arkTxid,
|
|
7404
|
-
assetId:
|
|
7404
|
+
assetId: chunkT327OEMV_cjs.AssetId.create(arkTxid, 0).toString()
|
|
7405
7405
|
};
|
|
7406
7406
|
}
|
|
7407
7407
|
/**
|
|
@@ -7473,16 +7473,16 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7473
7473
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7474
7474
|
for (const asset of assets) {
|
|
7475
7475
|
if (asset.assetId !== params.assetId) continue;
|
|
7476
|
-
reissueInputs.push(
|
|
7476
|
+
reissueInputs.push(chunkT327OEMV_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7477
7477
|
}
|
|
7478
7478
|
}
|
|
7479
7479
|
const totalAssetAmount = assetToReissueAmount + params.amount;
|
|
7480
|
-
const reissueAssetIdObj =
|
|
7481
|
-
const reissueAssetGroup =
|
|
7480
|
+
const reissueAssetIdObj = chunkT327OEMV_cjs.AssetId.fromString(params.assetId);
|
|
7481
|
+
const reissueAssetGroup = chunkT327OEMV_cjs.AssetGroup.create(
|
|
7482
7482
|
reissueAssetIdObj,
|
|
7483
7483
|
null,
|
|
7484
7484
|
reissueInputs,
|
|
7485
|
-
[
|
|
7485
|
+
[chunkT327OEMV_cjs.AssetOutput.create(0, totalAssetAmount)],
|
|
7486
7486
|
[]
|
|
7487
7487
|
);
|
|
7488
7488
|
const groups = [reissueAssetGroup];
|
|
@@ -7491,27 +7491,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7491
7491
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7492
7492
|
for (const asset of assets) {
|
|
7493
7493
|
if (asset.assetId !== assetId) continue;
|
|
7494
|
-
changeInputs.push(
|
|
7494
|
+
changeInputs.push(chunkT327OEMV_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7495
7495
|
}
|
|
7496
7496
|
}
|
|
7497
7497
|
groups.push(
|
|
7498
|
-
|
|
7499
|
-
|
|
7498
|
+
chunkT327OEMV_cjs.AssetGroup.create(
|
|
7499
|
+
chunkT327OEMV_cjs.AssetId.fromString(assetId),
|
|
7500
7500
|
null,
|
|
7501
7501
|
changeInputs,
|
|
7502
|
-
[
|
|
7502
|
+
[chunkT327OEMV_cjs.AssetOutput.create(0, amount)],
|
|
7503
7503
|
[]
|
|
7504
7504
|
)
|
|
7505
7505
|
);
|
|
7506
7506
|
}
|
|
7507
7507
|
const address = await this.wallet.getAddress();
|
|
7508
|
-
const outputAddress =
|
|
7508
|
+
const outputAddress = chunkP53OHGXY_cjs.ArkAddress.decode(address);
|
|
7509
7509
|
const outputs = [
|
|
7510
7510
|
{
|
|
7511
7511
|
script: outputAddress.pkScript,
|
|
7512
7512
|
amount: BigInt(totalBtcSelected)
|
|
7513
7513
|
},
|
|
7514
|
-
Extension.create([
|
|
7514
|
+
Extension.create([chunkT327OEMV_cjs.Packet.create(groups)]).txOut()
|
|
7515
7515
|
];
|
|
7516
7516
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
7517
7517
|
return arkTxid;
|
|
@@ -7578,27 +7578,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7578
7578
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7579
7579
|
for (const asset of assets) {
|
|
7580
7580
|
if (asset.assetId !== assetId) continue;
|
|
7581
|
-
changeInputs.push(
|
|
7581
|
+
changeInputs.push(chunkT327OEMV_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7582
7582
|
}
|
|
7583
7583
|
}
|
|
7584
7584
|
groups.push(
|
|
7585
|
-
|
|
7586
|
-
|
|
7585
|
+
chunkT327OEMV_cjs.AssetGroup.create(
|
|
7586
|
+
chunkT327OEMV_cjs.AssetId.fromString(assetId),
|
|
7587
7587
|
null,
|
|
7588
7588
|
changeInputs,
|
|
7589
|
-
amount > 0n ? [
|
|
7589
|
+
amount > 0n ? [chunkT327OEMV_cjs.AssetOutput.create(0, amount)] : [],
|
|
7590
7590
|
[]
|
|
7591
7591
|
)
|
|
7592
7592
|
);
|
|
7593
7593
|
}
|
|
7594
7594
|
const address = await this.wallet.getAddress();
|
|
7595
|
-
const outputAddress =
|
|
7595
|
+
const outputAddress = chunkP53OHGXY_cjs.ArkAddress.decode(address);
|
|
7596
7596
|
const outputs = [
|
|
7597
7597
|
{
|
|
7598
7598
|
script: outputAddress.pkScript,
|
|
7599
7599
|
amount: BigInt(totalBtcSelected)
|
|
7600
7600
|
},
|
|
7601
|
-
Extension.create([
|
|
7601
|
+
Extension.create([chunkT327OEMV_cjs.Packet.create(groups)]).txOut()
|
|
7602
7602
|
];
|
|
7603
7603
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
7604
7604
|
return arkTxid;
|
|
@@ -7623,7 +7623,7 @@ function castMetadata(metadata) {
|
|
|
7623
7623
|
} else {
|
|
7624
7624
|
throw new Error("Invalid metadata value type");
|
|
7625
7625
|
}
|
|
7626
|
-
md.push(
|
|
7626
|
+
md.push(chunkT327OEMV_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
|
|
7627
7627
|
}
|
|
7628
7628
|
return md;
|
|
7629
7629
|
}
|
|
@@ -7644,10 +7644,10 @@ var DelegateManagerImpl = class {
|
|
|
7644
7644
|
if (vtxos.length === 0) {
|
|
7645
7645
|
return { delegated: [], failed: [] };
|
|
7646
7646
|
}
|
|
7647
|
-
const destinationScript =
|
|
7647
|
+
const destinationScript = chunkP53OHGXY_cjs.ArkAddress.decode(destination).pkScript;
|
|
7648
7648
|
const arkInfo = await this.arkInfoProvider.getInfo();
|
|
7649
7649
|
const delegateInfo = await this.delegateProvider.getDelegateInfo();
|
|
7650
|
-
const eligible = vtxos.map(
|
|
7650
|
+
const eligible = vtxos.map(chunkP53OHGXY_cjs.normalizeVtxo).filter(
|
|
7651
7651
|
(v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
|
|
7652
7652
|
);
|
|
7653
7653
|
if (eligible.length === 0) {
|
|
@@ -7676,11 +7676,11 @@ var DelegateManagerImpl = class {
|
|
|
7676
7676
|
const groupByExpiry = /* @__PURE__ */ new Map();
|
|
7677
7677
|
let recoverableVtxos = [];
|
|
7678
7678
|
for (const vtxo of eligible) {
|
|
7679
|
-
if (
|
|
7679
|
+
if (chunkP53OHGXY_cjs.canRecoverOnchain(vtxo, now)) {
|
|
7680
7680
|
recoverableVtxos.push(vtxo);
|
|
7681
7681
|
continue;
|
|
7682
7682
|
}
|
|
7683
|
-
const expiry =
|
|
7683
|
+
const expiry = chunkP53OHGXY_cjs.toBatchExpiry(vtxo);
|
|
7684
7684
|
if (!expiry) continue;
|
|
7685
7685
|
const dayKey = getDayTimestamp(expiry);
|
|
7686
7686
|
groupByExpiry.set(dayKey, [...groupByExpiry.get(dayKey) ?? [], vtxo]);
|
|
@@ -7745,7 +7745,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7745
7745
|
}
|
|
7746
7746
|
if (!delegateAt) {
|
|
7747
7747
|
const now = { timestamp: /* @__PURE__ */ new Date() };
|
|
7748
|
-
const expiryTimestamp = vtxos.filter((coin) => !
|
|
7748
|
+
const expiryTimestamp = vtxos.filter((coin) => !chunkP53OHGXY_cjs.canRecoverOnchain(coin, now) && chunkP53OHGXY_cjs.toBatchExpiry(coin)).reduce((min, coin) => Math.min(min, chunkP53OHGXY_cjs.toBatchExpiry(coin)), Number.MAX_SAFE_INTEGER);
|
|
7749
7749
|
if (!expiryTimestamp || expiryTimestamp === Number.MAX_SAFE_INTEGER) {
|
|
7750
7750
|
delegateAt = new Date(Date.now() + 1 * 60 * 1e3);
|
|
7751
7751
|
} else {
|
|
@@ -7769,7 +7769,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7769
7769
|
let amount = 0n;
|
|
7770
7770
|
for (const coin of vtxos) {
|
|
7771
7771
|
const inputFee = estimator.evalOffchainInput({
|
|
7772
|
-
...
|
|
7772
|
+
...chunkP53OHGXY_cjs.toOffchainInputFeeParams(coin),
|
|
7773
7773
|
type: "vtxo"
|
|
7774
7774
|
});
|
|
7775
7775
|
if (inputFee.value >= coin.value) {
|
|
@@ -7783,7 +7783,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7783
7783
|
const delegateFee = BigInt(Number(fee));
|
|
7784
7784
|
if (delegateFee > 0n) {
|
|
7785
7785
|
outputs.push({
|
|
7786
|
-
script:
|
|
7786
|
+
script: chunkP53OHGXY_cjs.ArkAddress.decode(delegateAddress).pkScript,
|
|
7787
7787
|
amount: delegateFee
|
|
7788
7788
|
});
|
|
7789
7789
|
}
|
|
@@ -7816,10 +7816,10 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7816
7816
|
destinationScript
|
|
7817
7817
|
);
|
|
7818
7818
|
const forfeitOutputScript = btcSigner.OutScript.encode(
|
|
7819
|
-
btcSigner.Address(
|
|
7819
|
+
btcSigner.Address(chunkP53OHGXY_cjs.getNetwork(network)).decode(forfeitAddress)
|
|
7820
7820
|
);
|
|
7821
7821
|
const forfeits = await Promise.all(
|
|
7822
|
-
vtxos.filter((v) => !
|
|
7822
|
+
vtxos.filter((v) => !chunkP53OHGXY_cjs.canRecoverOnchain(v, { timestamp: /* @__PURE__ */ new Date() })).map(async (coin) => {
|
|
7823
7823
|
const forfeit = await makeDelegateForfeitTx(
|
|
7824
7824
|
coin,
|
|
7825
7825
|
dust,
|
|
@@ -7844,7 +7844,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
|
|
|
7844
7844
|
index: input.vout,
|
|
7845
7845
|
witnessUtxo: {
|
|
7846
7846
|
amount: BigInt(input.value),
|
|
7847
|
-
script:
|
|
7847
|
+
script: chunkP53OHGXY_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
7848
7848
|
},
|
|
7849
7849
|
sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
|
|
7850
7850
|
tapLeafScript: [delegateTapLeaf]
|
|
@@ -7902,7 +7902,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
7902
7902
|
expire_at: 0,
|
|
7903
7903
|
cosigners_public_keys: cosignerPubKeys
|
|
7904
7904
|
};
|
|
7905
|
-
const proof =
|
|
7905
|
+
const proof = chunkP53OHGXY_cjs.Intent.create(message, coins, outputs);
|
|
7906
7906
|
const signedProof = await identity.sign(proof);
|
|
7907
7907
|
return {
|
|
7908
7908
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -7928,10 +7928,10 @@ function getDayTimestamp(timestamp) {
|
|
|
7928
7928
|
function findDelegateTapLeaf(vtxo, delegatePubkey) {
|
|
7929
7929
|
if (!vtxo.tapTree) return void 0;
|
|
7930
7930
|
const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
|
|
7931
|
-
const vtxoScript =
|
|
7931
|
+
const vtxoScript = chunkP53OHGXY_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
7932
7932
|
return vtxoScript.leaves.find((tapLeaf) => {
|
|
7933
|
-
const arkTapscript =
|
|
7934
|
-
if (!
|
|
7933
|
+
const arkTapscript = chunkP53OHGXY_cjs.decodeTapscript(chunkP53OHGXY_cjs.scriptFromTapLeafScript(tapLeaf));
|
|
7934
|
+
if (!chunkP53OHGXY_cjs.MultisigTapscript.is(arkTapscript)) return false;
|
|
7935
7935
|
return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
|
|
7936
7936
|
});
|
|
7937
7937
|
}
|
|
@@ -8212,7 +8212,7 @@ function createManagedConnection(dbName, version, initDatabase2) {
|
|
|
8212
8212
|
};
|
|
8213
8213
|
}
|
|
8214
8214
|
function scriptFromArkAddress(address) {
|
|
8215
|
-
return base.hex.encode(
|
|
8215
|
+
return base.hex.encode(chunkP53OHGXY_cjs.ArkAddress.decode(address).pkScript);
|
|
8216
8216
|
}
|
|
8217
8217
|
|
|
8218
8218
|
// src/repositories/indexedDB/schema.ts
|
|
@@ -8707,7 +8707,7 @@ function validateVtxosForScript(vtxos, script, context) {
|
|
|
8707
8707
|
}
|
|
8708
8708
|
async function getVtxosForContract(repo, contract) {
|
|
8709
8709
|
const vtxos = repo.getVtxosForScript ? await repo.getVtxosForScript(contract.script) : filterVtxosForScript(await repo.getVtxos(contract.address), contract.script);
|
|
8710
|
-
return vtxos.map(
|
|
8710
|
+
return vtxos.map(chunkP53OHGXY_cjs.normalizeVtxo);
|
|
8711
8711
|
}
|
|
8712
8712
|
function hasRecordedSpend(vtxo) {
|
|
8713
8713
|
return vtxo.isSpent === true && (!!vtxo.spentBy || !!vtxo.arkTxId || !!vtxo.settledBy);
|
|
@@ -8908,7 +8908,7 @@ function decodeArkContract(encoded) {
|
|
|
8908
8908
|
}
|
|
8909
8909
|
function contractFromArkContract(encoded, options = {}) {
|
|
8910
8910
|
const parsed = decodeArkContract(encoded);
|
|
8911
|
-
const handler =
|
|
8911
|
+
const handler = chunkCQNX4BTA_cjs.contractHandlers.get(parsed.type);
|
|
8912
8912
|
if (!handler) {
|
|
8913
8913
|
throw new Error(`No handler registered for contract type '${parsed.type}'`);
|
|
8914
8914
|
}
|
|
@@ -8922,9 +8922,9 @@ function contractFromArkContract(encoded, options = {}) {
|
|
|
8922
8922
|
metadata: options.metadata
|
|
8923
8923
|
};
|
|
8924
8924
|
}
|
|
8925
|
-
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix =
|
|
8925
|
+
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkP53OHGXY_cjs.DEFAULT_NETWORK.hrp, options = {}) {
|
|
8926
8926
|
const parsed = decodeArkContract(encoded);
|
|
8927
|
-
const handler =
|
|
8927
|
+
const handler = chunkCQNX4BTA_cjs.contractHandlers.getOrThrow(parsed.type);
|
|
8928
8928
|
const params = parsed.data;
|
|
8929
8929
|
const vtxoScript = handler.createScript(params);
|
|
8930
8930
|
return {
|
|
@@ -9230,9 +9230,9 @@ var ContractWatcher = class {
|
|
|
9230
9230
|
this.connectionState = "connected";
|
|
9231
9231
|
this.reconnectAttempts = 0;
|
|
9232
9232
|
this.listenLoop().catch((e) => {
|
|
9233
|
-
if (
|
|
9233
|
+
if (chunkP53OHGXY_cjs.isEventSourceError(e)) {
|
|
9234
9234
|
console.debug("ContractWatcher subscription disconnected; reconnecting");
|
|
9235
|
-
} else if (!
|
|
9235
|
+
} else if (!chunkP53OHGXY_cjs.isEventSourceUnavailableError(e)) {
|
|
9236
9236
|
console.error(e);
|
|
9237
9237
|
}
|
|
9238
9238
|
this.connectionState = "disconnected";
|
|
@@ -9244,7 +9244,7 @@ var ContractWatcher = class {
|
|
|
9244
9244
|
this.scheduleReconnect();
|
|
9245
9245
|
});
|
|
9246
9246
|
} catch (error) {
|
|
9247
|
-
if (!
|
|
9247
|
+
if (!chunkP53OHGXY_cjs.isEventSourceUnavailableError(error)) {
|
|
9248
9248
|
console.error("ContractWatcher connection failed:", error);
|
|
9249
9249
|
}
|
|
9250
9250
|
this.connectionState = "disconnected";
|
|
@@ -9270,7 +9270,7 @@ var ContractWatcher = class {
|
|
|
9270
9270
|
* slower; what it loses is push latency.
|
|
9271
9271
|
*/
|
|
9272
9272
|
reportEventSourceUnavailable(error) {
|
|
9273
|
-
if (!
|
|
9273
|
+
if (!chunkP53OHGXY_cjs.isEventSourceUnavailableError(error)) return false;
|
|
9274
9274
|
if (!this.eventSourceReported) {
|
|
9275
9275
|
this.eventSourceReported = true;
|
|
9276
9276
|
console.warn(
|
|
@@ -9342,7 +9342,7 @@ var ContractWatcher = class {
|
|
|
9342
9342
|
const now = Date.now();
|
|
9343
9343
|
let current;
|
|
9344
9344
|
try {
|
|
9345
|
-
current = await
|
|
9345
|
+
current = await chunkP53OHGXY_cjs.getAllNormalizedVtxos(this.config.indexerProvider, scripts, {
|
|
9346
9346
|
spendableOnly: true
|
|
9347
9347
|
});
|
|
9348
9348
|
} catch (error) {
|
|
@@ -9551,14 +9551,14 @@ var ContractWatcher = class {
|
|
|
9551
9551
|
const timestamp = Date.now();
|
|
9552
9552
|
if (update.newVtxos?.length) {
|
|
9553
9553
|
this.processSubscriptionVtxos(
|
|
9554
|
-
update.newVtxos.map(
|
|
9554
|
+
update.newVtxos.map(chunkP53OHGXY_cjs.normalizeVtxo),
|
|
9555
9555
|
"vtxo_received",
|
|
9556
9556
|
timestamp
|
|
9557
9557
|
);
|
|
9558
9558
|
}
|
|
9559
9559
|
if (update.spentVtxos?.length) {
|
|
9560
9560
|
this.processSubscriptionVtxos(
|
|
9561
|
-
update.spentVtxos.map(
|
|
9561
|
+
update.spentVtxos.map(chunkP53OHGXY_cjs.normalizeVtxo),
|
|
9562
9562
|
"vtxo_spent",
|
|
9563
9563
|
timestamp
|
|
9564
9564
|
);
|
|
@@ -9586,8 +9586,8 @@ var ContractWatcher = class {
|
|
|
9586
9586
|
continue;
|
|
9587
9587
|
}
|
|
9588
9588
|
if (target === byWatchedScript && eventType === "vtxo_received") {
|
|
9589
|
-
const n =
|
|
9590
|
-
if (
|
|
9589
|
+
const n = chunkP53OHGXY_cjs.normalizeVtxo(vtxo);
|
|
9590
|
+
if (chunkP53OHGXY_cjs.hasTerminalSpend(n) || n.isSwept || chunkP53OHGXY_cjs.isPastExpiry(n, now)) continue;
|
|
9591
9591
|
}
|
|
9592
9592
|
let bucket = target.get(vtxo.script);
|
|
9593
9593
|
if (!bucket) {
|
|
@@ -9686,7 +9686,7 @@ var NON_TERMINAL_INTENT_STATES = ALL_INTENT_STATES.filter(
|
|
|
9686
9686
|
(s) => !isTerminalIntentState(s)
|
|
9687
9687
|
);
|
|
9688
9688
|
function isConsumed(vtxo) {
|
|
9689
|
-
return vtxo !== void 0 &&
|
|
9689
|
+
return vtxo !== void 0 && chunkP53OHGXY_cjs.hasTerminalSpend(vtxo);
|
|
9690
9690
|
}
|
|
9691
9691
|
async function classifyIntent(intent, vtxosByOutpoint, now) {
|
|
9692
9692
|
if (isTerminalIntentState(intent.state)) return void 0;
|
|
@@ -9729,7 +9729,7 @@ async function reconcileIntents(deps) {
|
|
|
9729
9729
|
let vtxosByOutpoint = /* @__PURE__ */ new Map();
|
|
9730
9730
|
if (outpoints.length > 0) {
|
|
9731
9731
|
try {
|
|
9732
|
-
const { vtxos } = await
|
|
9732
|
+
const { vtxos } = await chunkP53OHGXY_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
|
|
9733
9733
|
vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
|
|
9734
9734
|
} catch (e) {
|
|
9735
9735
|
console.error("reconcileIntents: failed to fetch input VTXO state", e);
|
|
@@ -9776,7 +9776,8 @@ function areCoalescibleContractTypes(a, b) {
|
|
|
9776
9776
|
function toWatchOnlyContract(params) {
|
|
9777
9777
|
return { ...params, state: params.state ?? "active", createdAt: Date.now() };
|
|
9778
9778
|
}
|
|
9779
|
-
|
|
9779
|
+
var TAPSCRIPT_MEMO_MAX_ENTRIES = 1024;
|
|
9780
|
+
function annotatableIn(scriptToContract, vtxos, memo) {
|
|
9780
9781
|
const scripts = /* @__PURE__ */ new Set();
|
|
9781
9782
|
const cache = /* @__PURE__ */ new Map();
|
|
9782
9783
|
const failures = /* @__PURE__ */ new Map();
|
|
@@ -9784,7 +9785,25 @@ function annotatableIn(scriptToContract, vtxos) {
|
|
|
9784
9785
|
const contract = scriptToContract.get(script);
|
|
9785
9786
|
if (!contract) continue;
|
|
9786
9787
|
try {
|
|
9787
|
-
|
|
9788
|
+
const key = `${contract.type}\0${script}\0${JSON.stringify(contract.params)}`;
|
|
9789
|
+
const handler = chunkCQNX4BTA_cjs.contractHandlers.get(contract.type);
|
|
9790
|
+
const hit = memo?.get(script);
|
|
9791
|
+
let tapscripts;
|
|
9792
|
+
if (hit && hit.key === key && hit.handler === handler) {
|
|
9793
|
+
tapscripts = hit.tapscripts;
|
|
9794
|
+
memo.delete(script);
|
|
9795
|
+
memo.set(script, hit);
|
|
9796
|
+
} else {
|
|
9797
|
+
memo?.delete(script);
|
|
9798
|
+
tapscripts = deriveContractTapscripts(contract);
|
|
9799
|
+
if (handler && memo) {
|
|
9800
|
+
memo.set(script, { key, handler, tapscripts });
|
|
9801
|
+
if (memo.size > TAPSCRIPT_MEMO_MAX_ENTRIES) {
|
|
9802
|
+
memo.delete(memo.keys().next().value);
|
|
9803
|
+
}
|
|
9804
|
+
}
|
|
9805
|
+
}
|
|
9806
|
+
cache.set(script, tapscripts);
|
|
9788
9807
|
scripts.add(script);
|
|
9789
9808
|
} catch (err) {
|
|
9790
9809
|
failures.set(
|
|
@@ -9802,6 +9821,8 @@ var CHAIN_TIP_TIMEOUT_MS = 5e3;
|
|
|
9802
9821
|
var ContractManager = class _ContractManager {
|
|
9803
9822
|
config;
|
|
9804
9823
|
watcher;
|
|
9824
|
+
/** Per-sync tapscript caches start empty; this outlives them. Consumers only ever see clones. */
|
|
9825
|
+
tapscriptMemo = /* @__PURE__ */ new Map();
|
|
9805
9826
|
initialized = false;
|
|
9806
9827
|
eventCallbacks = /* @__PURE__ */ new Set();
|
|
9807
9828
|
stopWatcherFn;
|
|
@@ -9920,7 +9941,7 @@ var ContractManager = class _ContractManager {
|
|
|
9920
9941
|
try {
|
|
9921
9942
|
await this.scheduleLookAheadDrain();
|
|
9922
9943
|
} catch (err) {
|
|
9923
|
-
if (!
|
|
9944
|
+
if (!chunkP53OHGXY_cjs.isRetryableProviderError(err)) throw err;
|
|
9924
9945
|
this.lookAheadRefillOwed = true;
|
|
9925
9946
|
this.markSyncDegraded(err);
|
|
9926
9947
|
}
|
|
@@ -9928,7 +9949,7 @@ var ContractManager = class _ContractManager {
|
|
|
9928
9949
|
await this.reconcileWatched();
|
|
9929
9950
|
this.markSyncOnline();
|
|
9930
9951
|
} catch (err) {
|
|
9931
|
-
if (!
|
|
9952
|
+
if (!chunkP53OHGXY_cjs.isRetryableProviderError(err)) throw err;
|
|
9932
9953
|
this.markSyncDegraded(err);
|
|
9933
9954
|
}
|
|
9934
9955
|
this.initialized = true;
|
|
@@ -10060,7 +10081,7 @@ var ContractManager = class _ContractManager {
|
|
|
10060
10081
|
const from = Math.max(0, watermark - lookAhead.size);
|
|
10061
10082
|
const to = watermark + lookAhead.size;
|
|
10062
10083
|
const deps = lookAhead.candidateDeps();
|
|
10063
|
-
const handlers =
|
|
10084
|
+
const handlers = chunkCQNX4BTA_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkCQNX4BTA_cjs.contractHandlers.get(t)).filter(hasCandidates);
|
|
10064
10085
|
const band = /* @__PURE__ */ new Map();
|
|
10065
10086
|
for (let index = from; index <= to; index++) {
|
|
10066
10087
|
const descriptor = lookAhead.materialize(index);
|
|
@@ -10071,7 +10092,7 @@ var ContractManager = class _ContractManager {
|
|
|
10071
10092
|
index,
|
|
10072
10093
|
params: {
|
|
10073
10094
|
...candidate,
|
|
10074
|
-
...
|
|
10095
|
+
...chunkCQNX4BTA_cjs.speculativeReceiveMetadata(descriptor)
|
|
10075
10096
|
}
|
|
10076
10097
|
});
|
|
10077
10098
|
}
|
|
@@ -10133,7 +10154,7 @@ var ContractManager = class _ContractManager {
|
|
|
10133
10154
|
});
|
|
10134
10155
|
for (const entry of pending) entry.catchUpPending = false;
|
|
10135
10156
|
} catch (err) {
|
|
10136
|
-
if (!
|
|
10157
|
+
if (!chunkP53OHGXY_cjs.isRetryableProviderError(err)) throw err;
|
|
10137
10158
|
this.markSyncDegraded(err);
|
|
10138
10159
|
}
|
|
10139
10160
|
}
|
|
@@ -10183,7 +10204,7 @@ var ContractManager = class _ContractManager {
|
|
|
10183
10204
|
await this.fetchContractVxosFromIndexer([contract]);
|
|
10184
10205
|
this.markSyncOnline();
|
|
10185
10206
|
} catch (err) {
|
|
10186
|
-
if (!
|
|
10207
|
+
if (!chunkP53OHGXY_cjs.isRetryableProviderError(err)) throw err;
|
|
10187
10208
|
this.markSyncDegraded(err);
|
|
10188
10209
|
}
|
|
10189
10210
|
await this.watcher.addContract(contract);
|
|
@@ -10217,7 +10238,7 @@ var ContractManager = class _ContractManager {
|
|
|
10217
10238
|
await this.fetchContractVxosFromIndexer(fresh);
|
|
10218
10239
|
this.markSyncOnline();
|
|
10219
10240
|
} catch (err) {
|
|
10220
|
-
if (!
|
|
10241
|
+
if (!chunkP53OHGXY_cjs.isRetryableProviderError(err)) throw err;
|
|
10221
10242
|
this.markSyncDegraded(err);
|
|
10222
10243
|
}
|
|
10223
10244
|
for (const contract of fresh) await this.watcher.addContract(contract);
|
|
@@ -10255,7 +10276,7 @@ var ContractManager = class _ContractManager {
|
|
|
10255
10276
|
return result;
|
|
10256
10277
|
}
|
|
10257
10278
|
async upsertContractRow(params) {
|
|
10258
|
-
const handler =
|
|
10279
|
+
const handler = chunkCQNX4BTA_cjs.contractHandlers.get(params.type);
|
|
10259
10280
|
if (!handler) {
|
|
10260
10281
|
throw new Error(`No handler registered for contract type '${params.type}'`);
|
|
10261
10282
|
}
|
|
@@ -10355,7 +10376,7 @@ var ContractManager = class _ContractManager {
|
|
|
10355
10376
|
`scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
|
|
10356
10377
|
);
|
|
10357
10378
|
}
|
|
10358
|
-
const registered =
|
|
10379
|
+
const registered = chunkCQNX4BTA_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkCQNX4BTA_cjs.contractHandlers.get(t)).filter(isDiscoverable);
|
|
10359
10380
|
const discoverables = [
|
|
10360
10381
|
...registered.filter((h) => h.type === "boarding"),
|
|
10361
10382
|
...registered.filter((h) => h.type !== "boarding")
|
|
@@ -10493,7 +10514,7 @@ var ContractManager = class _ContractManager {
|
|
|
10493
10514
|
await this.syncContracts({ contracts, pageSize });
|
|
10494
10515
|
this.markSyncOnline();
|
|
10495
10516
|
} catch (err) {
|
|
10496
|
-
if (!
|
|
10517
|
+
if (!chunkP53OHGXY_cjs.isRetryableProviderError(err)) throw err;
|
|
10497
10518
|
this.markSyncDegraded(err);
|
|
10498
10519
|
}
|
|
10499
10520
|
}
|
|
@@ -10515,7 +10536,7 @@ var ContractManager = class _ContractManager {
|
|
|
10515
10536
|
}
|
|
10516
10537
|
const tapscriptCache = tapscripts ?? /* @__PURE__ */ new Map();
|
|
10517
10538
|
return vtxos.map(
|
|
10518
|
-
(vtxo) => extendVirtualCoinForContract(
|
|
10539
|
+
(vtxo) => extendVirtualCoinForContract(chunkP53OHGXY_cjs.normalizeVtxo(vtxo), byScript, tapscriptCache)
|
|
10519
10540
|
);
|
|
10520
10541
|
}
|
|
10521
10542
|
/** @inheritdoc */
|
|
@@ -10526,7 +10547,8 @@ var ContractManager = class _ContractManager {
|
|
|
10526
10547
|
});
|
|
10527
10548
|
const { scripts, failures } = annotatableIn(
|
|
10528
10549
|
new Map(contracts.map((contract) => [contract.script, contract])),
|
|
10529
|
-
vtxos
|
|
10550
|
+
vtxos,
|
|
10551
|
+
this.tapscriptMemo
|
|
10530
10552
|
);
|
|
10531
10553
|
const orphans = vtxos.filter(
|
|
10532
10554
|
(vtxo) => !scripts.has(vtxo.script) && !failures.has(vtxo.script)
|
|
@@ -10559,14 +10581,14 @@ var ContractManager = class _ContractManager {
|
|
|
10559
10581
|
const byScript = new Map(contracts.map((contract) => [contract.script, contract]));
|
|
10560
10582
|
const asking = vtxos.filter((vtxo) => {
|
|
10561
10583
|
const contract = byScript.get(vtxo.script);
|
|
10562
|
-
return contract !== void 0 &&
|
|
10584
|
+
return contract !== void 0 && chunkCQNX4BTA_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
|
|
10563
10585
|
});
|
|
10564
10586
|
if (asking.length === 0) return refused;
|
|
10565
10587
|
const tip = await this.currentChainTip();
|
|
10566
10588
|
const walletKey = await walletPubKey?.();
|
|
10567
10589
|
for (const vtxo of asking) {
|
|
10568
10590
|
const contract = byScript.get(vtxo.script);
|
|
10569
|
-
const handler =
|
|
10591
|
+
const handler = chunkCQNX4BTA_cjs.contractHandlers.get(contract.type);
|
|
10570
10592
|
if (!handler?.assertSpendableNow) continue;
|
|
10571
10593
|
const context = {
|
|
10572
10594
|
collaborative: true,
|
|
@@ -10581,7 +10603,7 @@ var ContractManager = class _ContractManager {
|
|
|
10581
10603
|
// the next handler to answer a CSV question would meet a
|
|
10582
10604
|
// TypeError instead of a `false`. Carry the coin only when it
|
|
10583
10605
|
// really is one.
|
|
10584
|
-
vtxo:
|
|
10606
|
+
vtxo: chunkP53OHGXY_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
|
|
10585
10607
|
};
|
|
10586
10608
|
try {
|
|
10587
10609
|
await handler.assertSpendableNow(
|
|
@@ -10677,6 +10699,7 @@ var ContractManager = class _ContractManager {
|
|
|
10677
10699
|
*/
|
|
10678
10700
|
async deleteContract(script) {
|
|
10679
10701
|
await this.config.contractRepository.deleteContract(script);
|
|
10702
|
+
this.tapscriptMemo.delete(script);
|
|
10680
10703
|
await this.watcher.removeContract(script);
|
|
10681
10704
|
}
|
|
10682
10705
|
/**
|
|
@@ -10737,7 +10760,7 @@ var ContractManager = class _ContractManager {
|
|
|
10737
10760
|
const { contractScript, collaborative = true, walletPubKey, vtxo } = options;
|
|
10738
10761
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
10739
10762
|
if (!contract) return [];
|
|
10740
|
-
const handler =
|
|
10763
|
+
const handler = chunkCQNX4BTA_cjs.contractHandlers.get(contract.type);
|
|
10741
10764
|
if (!handler) return [];
|
|
10742
10765
|
const script = handler.createScript(contract.params);
|
|
10743
10766
|
const tip = await this.currentChainTip();
|
|
@@ -10765,7 +10788,7 @@ var ContractManager = class _ContractManager {
|
|
|
10765
10788
|
const { contractScript, collaborative = true, walletPubKey } = options;
|
|
10766
10789
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
10767
10790
|
if (!contract) return [];
|
|
10768
|
-
const handler =
|
|
10791
|
+
const handler = chunkCQNX4BTA_cjs.contractHandlers.get(contract.type);
|
|
10769
10792
|
if (!handler) return [];
|
|
10770
10793
|
const script = handler.createScript(contract.params);
|
|
10771
10794
|
const context = {
|
|
@@ -10821,7 +10844,7 @@ var ContractManager = class _ContractManager {
|
|
|
10821
10844
|
}
|
|
10822
10845
|
async refreshOutpoints(outpoints) {
|
|
10823
10846
|
if (outpoints.length === 0) return;
|
|
10824
|
-
const { vtxos } = await
|
|
10847
|
+
const { vtxos } = await chunkP53OHGXY_cjs.getNormalizedVtxos(this.config.indexerProvider, {
|
|
10825
10848
|
outpoints
|
|
10826
10849
|
});
|
|
10827
10850
|
if (vtxos.length === 0) return;
|
|
@@ -10923,7 +10946,7 @@ var ContractManager = class _ContractManager {
|
|
|
10923
10946
|
break;
|
|
10924
10947
|
}
|
|
10925
10948
|
} catch (err) {
|
|
10926
|
-
if (!
|
|
10949
|
+
if (!chunkP53OHGXY_cjs.isRetryableProviderError(err)) throw err;
|
|
10927
10950
|
this.markSyncDegraded(err);
|
|
10928
10951
|
}
|
|
10929
10952
|
this.emitEvent(event);
|
|
@@ -11014,7 +11037,7 @@ var ContractManager = class _ContractManager {
|
|
|
11014
11037
|
*/
|
|
11015
11038
|
async reconcilePendingFrontier(contracts) {
|
|
11016
11039
|
const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
|
|
11017
|
-
const vtxos = await
|
|
11040
|
+
const vtxos = await chunkP53OHGXY_cjs.getAllNormalizedVtxos(
|
|
11018
11041
|
this.config.indexerProvider,
|
|
11019
11042
|
contracts.map((c) => c.script),
|
|
11020
11043
|
{ pendingOnly: true }
|
|
@@ -11022,7 +11045,11 @@ var ContractManager = class _ContractManager {
|
|
|
11022
11045
|
for (const [script, contract] of await this.promoteLookAheadHits(vtxos)) {
|
|
11023
11046
|
scriptToContract.set(script, contract);
|
|
11024
11047
|
}
|
|
11025
|
-
const {
|
|
11048
|
+
const {
|
|
11049
|
+
scripts: annotatable,
|
|
11050
|
+
cache,
|
|
11051
|
+
failures
|
|
11052
|
+
} = annotatableIn(scriptToContract, vtxos, this.tapscriptMemo);
|
|
11026
11053
|
this.recordAnnotationFailures(annotatable, failures);
|
|
11027
11054
|
const owned = vtxos.filter((v) => annotatable.has(v.script));
|
|
11028
11055
|
const annotated = await this.annotateVtxos(owned, cache);
|
|
@@ -11097,7 +11124,7 @@ var ContractManager = class _ContractManager {
|
|
|
11097
11124
|
}
|
|
11098
11125
|
return result;
|
|
11099
11126
|
}
|
|
11100
|
-
async fetchContractVtxosBulk(contracts, pageSize =
|
|
11127
|
+
async fetchContractVtxosBulk(contracts, pageSize = chunkP53OHGXY_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
|
|
11101
11128
|
if (contracts.length === 0) {
|
|
11102
11129
|
return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
|
|
11103
11130
|
}
|
|
@@ -11113,7 +11140,7 @@ var ContractManager = class _ContractManager {
|
|
|
11113
11140
|
before: syncWindow.before
|
|
11114
11141
|
}
|
|
11115
11142
|
} : {};
|
|
11116
|
-
const vtxos = await
|
|
11143
|
+
const vtxos = await chunkP53OHGXY_cjs.getAllNormalizedVtxos(
|
|
11117
11144
|
this.config.indexerProvider,
|
|
11118
11145
|
contracts.map((c) => c.script),
|
|
11119
11146
|
{ ...windowOpts, pageSize }
|
|
@@ -11122,7 +11149,11 @@ var ContractManager = class _ContractManager {
|
|
|
11122
11149
|
for (const [script, contract] of promoted) {
|
|
11123
11150
|
scriptToContract.set(script, contract);
|
|
11124
11151
|
}
|
|
11125
|
-
const {
|
|
11152
|
+
const {
|
|
11153
|
+
scripts: annotatable,
|
|
11154
|
+
cache,
|
|
11155
|
+
failures
|
|
11156
|
+
} = annotatableIn(scriptToContract, vtxos, this.tapscriptMemo);
|
|
11126
11157
|
this.recordAnnotationFailures(annotatable, failures);
|
|
11127
11158
|
const owned = vtxos.filter((v) => annotatable.has(v.script));
|
|
11128
11159
|
const annotated = await this.annotateVtxos(owned, cache);
|
|
@@ -11258,7 +11289,7 @@ var deserializeTapLeaf = (t) => {
|
|
|
11258
11289
|
const s = base.hex.decode(t.s);
|
|
11259
11290
|
return [cb, s];
|
|
11260
11291
|
};
|
|
11261
|
-
var deserializeVtxo = (o) =>
|
|
11292
|
+
var deserializeVtxo = (o) => chunkP53OHGXY_cjs.normalizeVtxo({
|
|
11262
11293
|
...o,
|
|
11263
11294
|
createdAt: new Date(o.createdAt),
|
|
11264
11295
|
tapTree: base.hex.decode(o.tapTree),
|
|
@@ -12081,7 +12112,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
12081
12112
|
*/
|
|
12082
12113
|
materializeDescriptorAt(index) {
|
|
12083
12114
|
const descriptor = this.identity.descriptor;
|
|
12084
|
-
const network =
|
|
12115
|
+
const network = chunkCQNX4BTA_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
12085
12116
|
const expansion = descriptorsScure.expand({ descriptor, network, index });
|
|
12086
12117
|
const keyInfo = expansion.expansionMap?.["@0"];
|
|
12087
12118
|
if (!keyInfo?.keyExpression) {
|
|
@@ -12229,7 +12260,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
12229
12260
|
const provider = await resolveDescriptorProvider(config, setup.walletRepository);
|
|
12230
12261
|
if (!provider) return void 0;
|
|
12231
12262
|
const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
|
|
12232
|
-
const expectedContractType = setup.offchainTapscript instanceof
|
|
12263
|
+
const expectedContractType = setup.offchainTapscript instanceof chunkCQNX4BTA_cjs.DelegateVtxo.Script ? "delegate" : "default";
|
|
12233
12264
|
const factoryOpts = {
|
|
12234
12265
|
walletRepository: setup.walletRepository,
|
|
12235
12266
|
contractRepository: setup.contractRepository,
|
|
@@ -12430,7 +12461,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
12430
12461
|
};
|
|
12431
12462
|
function deriveLeafPubkey(descriptor) {
|
|
12432
12463
|
try {
|
|
12433
|
-
return
|
|
12464
|
+
return chunkCQNX4BTA_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
12434
12465
|
} catch (e) {
|
|
12435
12466
|
throw new NonRangeableDescriptorError(
|
|
12436
12467
|
"Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
|
|
@@ -12442,7 +12473,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
12442
12473
|
const pubKey = deriveLeafPubkey(descriptor);
|
|
12443
12474
|
const tapscript = rebuildTapscript(current, pubKey);
|
|
12444
12475
|
const serverPubKey = tapscript.options.serverPubKey;
|
|
12445
|
-
const csvTimelock =
|
|
12476
|
+
const csvTimelock = chunkP53OHGXY_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
|
|
12446
12477
|
const base$1 = {
|
|
12447
12478
|
script: base.hex.encode(tapscript.pkScript),
|
|
12448
12479
|
address: tapscript.address(hrp, serverPubKey).encode(),
|
|
@@ -12453,11 +12484,11 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
12453
12484
|
// index-0 key. Without it, spends produce unsigned PSBTs that the
|
|
12454
12485
|
// server rejects with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
12455
12486
|
metadata: {
|
|
12456
|
-
...tagSource && { source:
|
|
12487
|
+
...tagSource && { source: chunkCQNX4BTA_cjs.WALLET_RECEIVE_SOURCE },
|
|
12457
12488
|
signingDescriptor: descriptor
|
|
12458
12489
|
}
|
|
12459
12490
|
};
|
|
12460
|
-
const params = tapscript instanceof
|
|
12491
|
+
const params = tapscript instanceof chunkCQNX4BTA_cjs.DelegateVtxo.Script ? {
|
|
12461
12492
|
...base$1,
|
|
12462
12493
|
type: "delegate",
|
|
12463
12494
|
params: {
|
|
@@ -12478,10 +12509,10 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
12478
12509
|
return { tapscript, params };
|
|
12479
12510
|
}
|
|
12480
12511
|
function rebuildTapscript(current, pubKey) {
|
|
12481
|
-
if (current instanceof
|
|
12482
|
-
return new
|
|
12512
|
+
if (current instanceof chunkCQNX4BTA_cjs.DelegateVtxo.Script) {
|
|
12513
|
+
return new chunkCQNX4BTA_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
|
|
12483
12514
|
}
|
|
12484
|
-
return new
|
|
12515
|
+
return new chunkCQNX4BTA_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
|
|
12485
12516
|
}
|
|
12486
12517
|
async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
|
|
12487
12518
|
const candidates = await contractRepository.getContracts({
|
|
@@ -12490,7 +12521,7 @@ async function pickActiveReceive(contractRepository, serverPubKey, expectedType)
|
|
|
12490
12521
|
});
|
|
12491
12522
|
const serverPubKeyHex = base.hex.encode(serverPubKey);
|
|
12492
12523
|
const matching = candidates.filter(
|
|
12493
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
12524
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkCQNX4BTA_cjs.WALLET_RECEIVE_SOURCE
|
|
12494
12525
|
).sort((a, b) => {
|
|
12495
12526
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
12496
12527
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -12529,7 +12560,7 @@ async function resolveDescriptorProvider(config, walletRepository) {
|
|
|
12529
12560
|
|
|
12530
12561
|
// src/wallet/balance.ts
|
|
12531
12562
|
function computeOffchainBalance(vtxos, caps) {
|
|
12532
|
-
const { now, isPendingRecovery, isGenericallySpendable, isUnlocked } = caps;
|
|
12563
|
+
const { now, isPendingRecovery, isGenericallySpendable, isUnlocked, dustCarrier } = caps;
|
|
12533
12564
|
let settled = 0;
|
|
12534
12565
|
let preconfirmed = 0;
|
|
12535
12566
|
let available = 0;
|
|
@@ -12546,7 +12577,7 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
12546
12577
|
}
|
|
12547
12578
|
};
|
|
12548
12579
|
for (const vtxo of vtxos) {
|
|
12549
|
-
if (
|
|
12580
|
+
if (chunkP53OHGXY_cjs.hasTerminalSpend(vtxo)) continue;
|
|
12550
12581
|
addAssets(owned, vtxo);
|
|
12551
12582
|
if (vtxo.isUnrolled) {
|
|
12552
12583
|
unrolled += vtxo.value;
|
|
@@ -12556,11 +12587,11 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
12556
12587
|
pendingRecovery += vtxo.value;
|
|
12557
12588
|
continue;
|
|
12558
12589
|
}
|
|
12559
|
-
if (
|
|
12590
|
+
if (chunkP53OHGXY_cjs.canRecoverOnchain(vtxo, now)) {
|
|
12560
12591
|
recoverable += vtxo.value;
|
|
12561
12592
|
continue;
|
|
12562
12593
|
}
|
|
12563
|
-
if (!
|
|
12594
|
+
if (!chunkP53OHGXY_cjs.canSpendOffchain(vtxo, now)) continue;
|
|
12564
12595
|
if (vtxo.isPreconfirmed) {
|
|
12565
12596
|
preconfirmed += vtxo.value;
|
|
12566
12597
|
} else {
|
|
@@ -12575,6 +12606,9 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
12575
12606
|
addAssets(spendable, vtxo);
|
|
12576
12607
|
}
|
|
12577
12608
|
}
|
|
12609
|
+
if (available > 0 && spendable.size > 0) {
|
|
12610
|
+
available = Math.max(0, available - Number(dustCarrier));
|
|
12611
|
+
}
|
|
12578
12612
|
const toAssets = (from) => Array.from(from.entries()).map(([assetId, amount]) => ({ assetId, amount }));
|
|
12579
12613
|
return {
|
|
12580
12614
|
settled,
|
|
@@ -12734,12 +12768,12 @@ var InputSignerRouter = class {
|
|
|
12734
12768
|
};
|
|
12735
12769
|
|
|
12736
12770
|
// src/wallet/wallet.ts
|
|
12737
|
-
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl ||
|
|
12771
|
+
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl || chunkP53OHGXY_cjs.DEFAULT_ARKADE_SERVER_URL;
|
|
12738
12772
|
function intentProofJobs(coins) {
|
|
12739
12773
|
if (coins.length === 0) return [];
|
|
12740
12774
|
const coinJobs = coins.map((coin, i) => ({
|
|
12741
12775
|
index: i + 1,
|
|
12742
|
-
lookupScript:
|
|
12776
|
+
lookupScript: chunkP53OHGXY_cjs.VtxoScript.decode(coin.tapTree).pkScript
|
|
12743
12777
|
}));
|
|
12744
12778
|
return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
|
|
12745
12779
|
}
|
|
@@ -12771,7 +12805,7 @@ function dedupeTimelocks(timelocks) {
|
|
|
12771
12805
|
const seen = /* @__PURE__ */ new Set();
|
|
12772
12806
|
const deduped = [];
|
|
12773
12807
|
for (const timelock of timelocks) {
|
|
12774
|
-
const sequence =
|
|
12808
|
+
const sequence = chunkP53OHGXY_cjs.timelockToSequence(timelock).toString();
|
|
12775
12809
|
if (seen.has(sequence)) continue;
|
|
12776
12810
|
seen.add(sequence);
|
|
12777
12811
|
deduped.push(timelock);
|
|
@@ -12788,7 +12822,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
12788
12822
|
state: "active"
|
|
12789
12823
|
});
|
|
12790
12824
|
const newest = candidates.filter(
|
|
12791
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
12825
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkCQNX4BTA_cjs.WALLET_RECEIVE_SOURCE
|
|
12792
12826
|
).sort((a, b) => {
|
|
12793
12827
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
12794
12828
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -12796,7 +12830,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
12796
12830
|
if (!newest?.params.pubKey) return baseline;
|
|
12797
12831
|
try {
|
|
12798
12832
|
const pubKey = base.hex.decode(newest.params.pubKey);
|
|
12799
|
-
return new
|
|
12833
|
+
return new chunkCQNX4BTA_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
|
|
12800
12834
|
} catch (e) {
|
|
12801
12835
|
console.warn("Skipping malformed boarding contract at boot", newest.script, e);
|
|
12802
12836
|
return baseline;
|
|
@@ -12815,10 +12849,10 @@ function filterSnapshotVtxos(snapshot, filter, pendingSpendOutpoints) {
|
|
|
12815
12849
|
if (vtxo.isUnrolled) {
|
|
12816
12850
|
return !!f.withUnrolled;
|
|
12817
12851
|
}
|
|
12818
|
-
if (
|
|
12852
|
+
if (chunkP53OHGXY_cjs.hasTerminalSpend(vtxo)) {
|
|
12819
12853
|
return false;
|
|
12820
12854
|
}
|
|
12821
|
-
if (!f.withRecoverable &&
|
|
12855
|
+
if (!f.withRecoverable && chunkP53OHGXY_cjs.canRecoverOnchain(vtxo, now)) {
|
|
12822
12856
|
return false;
|
|
12823
12857
|
}
|
|
12824
12858
|
return true;
|
|
@@ -13158,7 +13192,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13158
13192
|
*/
|
|
13159
13193
|
static async setupWalletConfig(config, pubKey) {
|
|
13160
13194
|
const arkadeServerUrl = getArkadeServerUrl(config);
|
|
13161
|
-
const arkProvider = config.arkProvider || new
|
|
13195
|
+
const arkProvider = config.arkProvider || new chunkP53OHGXY_cjs.RestArkProvider(arkadeServerUrl);
|
|
13162
13196
|
let indexerProvider = config.indexerProvider;
|
|
13163
13197
|
if (!indexerProvider) {
|
|
13164
13198
|
let indexerUrl = config.indexerUrl;
|
|
@@ -13175,7 +13209,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13175
13209
|
indexerUrl = arkadeServerUrl;
|
|
13176
13210
|
}
|
|
13177
13211
|
}
|
|
13178
|
-
indexerProvider = new
|
|
13212
|
+
indexerProvider = new chunkT327OEMV_cjs.RestIndexerProvider(indexerUrl);
|
|
13179
13213
|
}
|
|
13180
13214
|
const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
13181
13215
|
const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
@@ -13184,7 +13218,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13184
13218
|
source: serverInfoSource,
|
|
13185
13219
|
lastOnlineAt: serverInfoLastOnlineAt
|
|
13186
13220
|
} = await resolveArkInfo(arkProvider, walletRepository);
|
|
13187
|
-
const network =
|
|
13221
|
+
const network = chunkP53OHGXY_cjs.getNetwork(info.network);
|
|
13188
13222
|
if ("descriptor" in config.identity) {
|
|
13189
13223
|
const descriptor = config.identity.descriptor;
|
|
13190
13224
|
const identityIsMainnet = !descriptor.includes("tpub");
|
|
@@ -13224,18 +13258,18 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13224
13258
|
value: info.boardingExitDelay,
|
|
13225
13259
|
type: info.boardingExitDelay < 512n ? "blocks" : "seconds"
|
|
13226
13260
|
};
|
|
13227
|
-
const serverPubKey =
|
|
13228
|
-
const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) =>
|
|
13261
|
+
const serverPubKey = chunkCQNX4BTA_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
|
|
13262
|
+
const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) => chunkCQNX4BTA_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : config.delegatorProvider ? await config.delegatorProvider.getDelegateInfo().then((info2) => chunkCQNX4BTA_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : void 0;
|
|
13229
13263
|
const offchainOptions = {
|
|
13230
13264
|
pubKey,
|
|
13231
13265
|
serverPubKey,
|
|
13232
13266
|
csvTimelock: exitTimelock
|
|
13233
13267
|
};
|
|
13234
|
-
const offchainTapscript = !delegatePubKey ? new
|
|
13235
|
-
const boardingTapscript =
|
|
13268
|
+
const offchainTapscript = !delegatePubKey ? new chunkCQNX4BTA_cjs.DefaultVtxo.Script(offchainOptions) : new chunkCQNX4BTA_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
|
|
13269
|
+
const boardingTapscript = chunkCQNX4BTA_cjs.BoardingContractHandler.createScript({
|
|
13236
13270
|
pubKey: base.hex.encode(pubKey),
|
|
13237
13271
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
13238
|
-
csvTimelock:
|
|
13272
|
+
csvTimelock: chunkP53OHGXY_cjs.timelockToSequence(boardingTimelock).toString()
|
|
13239
13273
|
});
|
|
13240
13274
|
return {
|
|
13241
13275
|
arkProvider,
|
|
@@ -13401,7 +13435,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13401
13435
|
if (!filter?.withUnrolled) {
|
|
13402
13436
|
logExcludedVtxos(
|
|
13403
13437
|
"getSpendableVtxos",
|
|
13404
|
-
snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !
|
|
13438
|
+
snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !chunkP53OHGXY_cjs.hasTerminalSpend(vtxo)),
|
|
13405
13439
|
[() => UNROLLED_REASON]
|
|
13406
13440
|
);
|
|
13407
13441
|
}
|
|
@@ -13501,7 +13535,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13501
13535
|
now: { timestamp: /* @__PURE__ */ new Date() },
|
|
13502
13536
|
isPendingRecovery: (vtxo) => pendingRecovery.has(`${vtxo.txid}:${vtxo.vout}`),
|
|
13503
13537
|
isGenericallySpendable: (vtxo) => !isGatedVtxo(vtxo, gated),
|
|
13504
|
-
isUnlocked: (vtxo) => unlocked.has(`${vtxo.txid}:${vtxo.vout}`)
|
|
13538
|
+
isUnlocked: (vtxo) => unlocked.has(`${vtxo.txid}:${vtxo.vout}`),
|
|
13539
|
+
dustCarrier: getDustAmount(this)
|
|
13505
13540
|
};
|
|
13506
13541
|
}
|
|
13507
13542
|
/**
|
|
@@ -13545,7 +13580,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13545
13580
|
this.getBoardingTxs()
|
|
13546
13581
|
]);
|
|
13547
13582
|
const allVtxos = snapshot.flatMap((_) => _.vtxos);
|
|
13548
|
-
const resolveTxCreatedAt = (txids) =>
|
|
13583
|
+
const resolveTxCreatedAt = (txids) => chunkP53OHGXY_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
|
|
13549
13584
|
return buildTransactionHistory(
|
|
13550
13585
|
allVtxos,
|
|
13551
13586
|
boardingTxs,
|
|
@@ -13640,7 +13675,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13640
13675
|
},
|
|
13641
13676
|
isUnrolled: true,
|
|
13642
13677
|
...boardingFacts,
|
|
13643
|
-
virtualStatus:
|
|
13678
|
+
virtualStatus: chunkP53OHGXY_cjs.toVirtualStatus(boardingFacts),
|
|
13644
13679
|
spentBy: "",
|
|
13645
13680
|
createdAt: tx.status.confirmed ? new Date(tx.status.block_time * 1e3) : /* @__PURE__ */ new Date(0),
|
|
13646
13681
|
script: scriptHex
|
|
@@ -13696,9 +13731,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13696
13731
|
async getBoardingTapscripts(allowedSigners) {
|
|
13697
13732
|
const byScript = /* @__PURE__ */ new Map();
|
|
13698
13733
|
const add = (s) => byScript.set(base.hex.encode(s.pkScript), s);
|
|
13699
|
-
const boardingCsv = this.boardingTapscript.options.csvTimelock ??
|
|
13734
|
+
const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkCQNX4BTA_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
13700
13735
|
add(
|
|
13701
|
-
new
|
|
13736
|
+
new chunkCQNX4BTA_cjs.DefaultVtxo.Script({
|
|
13702
13737
|
pubKey: await this.identity.xOnlyPublicKey(),
|
|
13703
13738
|
serverPubKey: this.boardingTapscript.options.serverPubKey,
|
|
13704
13739
|
csvTimelock: boardingCsv
|
|
@@ -13713,7 +13748,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13713
13748
|
for (const c of boardingContracts) {
|
|
13714
13749
|
if (!allowed.has(toXOnlySignerHex(c.params.serverPubKey))) continue;
|
|
13715
13750
|
try {
|
|
13716
|
-
add(
|
|
13751
|
+
add(chunkCQNX4BTA_cjs.BoardingContractHandler.createScript(c.params));
|
|
13717
13752
|
} catch (e) {
|
|
13718
13753
|
console.warn("Skipping malformed boarding contract", c.script, e);
|
|
13719
13754
|
}
|
|
@@ -13750,7 +13785,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13750
13785
|
// Per-row CSV delay decoded from THIS tapscript's exit leaf —
|
|
13751
13786
|
// not the wallet's current boarding timelock, which a signer
|
|
13752
13787
|
// rotation may have changed.
|
|
13753
|
-
csvTimelock:
|
|
13788
|
+
csvTimelock: chunkP53OHGXY_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
|
|
13754
13789
|
coins: utxos
|
|
13755
13790
|
};
|
|
13756
13791
|
})
|
|
@@ -13887,7 +13922,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13887
13922
|
/** Fetch Arkade transaction ids that are still pending final settlement. */
|
|
13888
13923
|
async fetchPendingTxs() {
|
|
13889
13924
|
const scripts = await this.getWalletScripts();
|
|
13890
|
-
const vtxos = await
|
|
13925
|
+
const vtxos = await chunkP53OHGXY_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
|
|
13891
13926
|
return vtxos.filter(
|
|
13892
13927
|
(vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
|
|
13893
13928
|
).map((_) => _.arkTxId);
|
|
@@ -13918,7 +13953,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13918
13953
|
});
|
|
13919
13954
|
for (const contract of contracts) {
|
|
13920
13955
|
if (map.has(contract.script)) continue;
|
|
13921
|
-
const handler =
|
|
13956
|
+
const handler = chunkCQNX4BTA_cjs.contractHandlers.get(contract.type);
|
|
13922
13957
|
if (handler) {
|
|
13923
13958
|
const script = handler.createScript(contract.params);
|
|
13924
13959
|
map.set(contract.script, script);
|
|
@@ -14030,7 +14065,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14030
14065
|
}
|
|
14031
14066
|
});
|
|
14032
14067
|
const baselinePubkey = await this.identity.xOnlyPublicKey();
|
|
14033
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
14068
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkCQNX4BTA_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
14034
14069
|
const baselineSigners = [
|
|
14035
14070
|
this.offchainTapscript.options.serverPubKey,
|
|
14036
14071
|
...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
|
|
@@ -14038,8 +14073,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14038
14073
|
const seenBaselineScripts = /* @__PURE__ */ new Set();
|
|
14039
14074
|
for (const serverPubKey of baselineSigners) {
|
|
14040
14075
|
for (const csvTimelock of this.walletContractTimelocks) {
|
|
14041
|
-
const csvTimelockStr =
|
|
14042
|
-
const defaultScript = new
|
|
14076
|
+
const csvTimelockStr = chunkP53OHGXY_cjs.timelockToSequence(csvTimelock).toString();
|
|
14077
|
+
const defaultScript = new chunkCQNX4BTA_cjs.DefaultVtxo.Script({
|
|
14043
14078
|
pubKey: baselinePubkey,
|
|
14044
14079
|
serverPubKey,
|
|
14045
14080
|
csvTimelock
|
|
@@ -14060,7 +14095,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14060
14095
|
});
|
|
14061
14096
|
}
|
|
14062
14097
|
if (delegatePubKey) {
|
|
14063
|
-
const delegateScript = new
|
|
14098
|
+
const delegateScript = new chunkCQNX4BTA_cjs.DelegateVtxo.Script({
|
|
14064
14099
|
pubKey: baselinePubkey,
|
|
14065
14100
|
serverPubKey,
|
|
14066
14101
|
delegatePubKey,
|
|
@@ -14084,9 +14119,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14084
14119
|
}
|
|
14085
14120
|
}
|
|
14086
14121
|
}
|
|
14087
|
-
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ??
|
|
14122
|
+
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkCQNX4BTA_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
14088
14123
|
for (const serverPubKey of baselineSigners) {
|
|
14089
|
-
const baselineBoarding = new
|
|
14124
|
+
const baselineBoarding = new chunkCQNX4BTA_cjs.DefaultVtxo.Script({
|
|
14090
14125
|
pubKey: baselinePubkey,
|
|
14091
14126
|
serverPubKey,
|
|
14092
14127
|
csvTimelock: boardingCsvTimelock
|
|
@@ -14099,7 +14134,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14099
14134
|
params: {
|
|
14100
14135
|
pubKey: base.hex.encode(baselineBoarding.options.pubKey),
|
|
14101
14136
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
14102
|
-
csvTimelock:
|
|
14137
|
+
csvTimelock: chunkP53OHGXY_cjs.timelockToSequence(boardingCsvTimelock).toString()
|
|
14103
14138
|
},
|
|
14104
14139
|
script: boardingScriptHex,
|
|
14105
14140
|
address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
|
|
@@ -14299,7 +14334,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14299
14334
|
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
14300
14335
|
deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
|
|
14301
14336
|
csvTimelocks: this.walletContractTimelocks,
|
|
14302
|
-
delegatePubKey: this.offchainTapscript instanceof
|
|
14337
|
+
delegatePubKey: this.offchainTapscript instanceof chunkCQNX4BTA_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
|
|
14303
14338
|
};
|
|
14304
14339
|
}
|
|
14305
14340
|
_signerRouter;
|
|
@@ -14544,7 +14579,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14544
14579
|
const [row] = await manager.getContracts({ script: base.hex.encode(display.pkScript) });
|
|
14545
14580
|
const persisted = row?.metadata?.signingDescriptor;
|
|
14546
14581
|
if (typeof persisted === "string") return persisted;
|
|
14547
|
-
return
|
|
14582
|
+
return chunkCQNX4BTA_cjs.identityDescriptor(this.identity);
|
|
14548
14583
|
}
|
|
14549
14584
|
/**
|
|
14550
14585
|
* Build, persist and shape one address of `type` owned by `descriptor` —
|
|
@@ -14560,7 +14595,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14560
14595
|
async mintAddress(manager, type, descriptor, tagSource, allocated) {
|
|
14561
14596
|
if (type === "boarding") {
|
|
14562
14597
|
const built2 = this.buildBoardingContract(
|
|
14563
|
-
|
|
14598
|
+
chunkCQNX4BTA_cjs.deriveDescriptorLeafPubKey(descriptor),
|
|
14564
14599
|
descriptor,
|
|
14565
14600
|
tagSource
|
|
14566
14601
|
);
|
|
@@ -14605,11 +14640,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14605
14640
|
* {@link buildReceiveContract}.
|
|
14606
14641
|
*/
|
|
14607
14642
|
buildBoardingContract(pubKey, descriptor, tagSource) {
|
|
14608
|
-
const tapscript = new
|
|
14643
|
+
const tapscript = new chunkCQNX4BTA_cjs.DefaultVtxo.Script({
|
|
14609
14644
|
...this._boardingTapscript.options,
|
|
14610
14645
|
pubKey
|
|
14611
14646
|
});
|
|
14612
|
-
const csvTimelock = tapscript.options.csvTimelock ??
|
|
14647
|
+
const csvTimelock = tapscript.options.csvTimelock ?? chunkCQNX4BTA_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
14613
14648
|
return {
|
|
14614
14649
|
tapscript,
|
|
14615
14650
|
params: {
|
|
@@ -14617,13 +14652,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14617
14652
|
params: {
|
|
14618
14653
|
pubKey: base.hex.encode(pubKey),
|
|
14619
14654
|
serverPubKey: base.hex.encode(tapscript.options.serverPubKey),
|
|
14620
|
-
csvTimelock:
|
|
14655
|
+
csvTimelock: chunkP53OHGXY_cjs.timelockToSequence(csvTimelock).toString()
|
|
14621
14656
|
},
|
|
14622
14657
|
script: base.hex.encode(tapscript.pkScript),
|
|
14623
14658
|
address: tapscript.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
14624
14659
|
state: "active",
|
|
14625
14660
|
metadata: {
|
|
14626
|
-
...tagSource && { source:
|
|
14661
|
+
...tagSource && { source: chunkCQNX4BTA_cjs.WALLET_RECEIVE_SOURCE },
|
|
14627
14662
|
signingDescriptor: descriptor
|
|
14628
14663
|
}
|
|
14629
14664
|
}
|
|
@@ -14652,7 +14687,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14652
14687
|
if (this._descriptorProvider instanceof HDDescriptorProvider) {
|
|
14653
14688
|
return (await this.getContractManager()).getNextSigningDescriptor();
|
|
14654
14689
|
}
|
|
14655
|
-
return
|
|
14690
|
+
return chunkCQNX4BTA_cjs.identityDescriptor(this.identity);
|
|
14656
14691
|
}
|
|
14657
14692
|
/**
|
|
14658
14693
|
* @see HDAllocationCapable.advanceSigningDescriptorWatermark
|
|
@@ -14748,7 +14783,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14748
14783
|
* the stable public API.
|
|
14749
14784
|
*/
|
|
14750
14785
|
async rotateServerSigner(newServerPubKey, checkpointTapscript) {
|
|
14751
|
-
const xonly =
|
|
14786
|
+
const xonly = chunkCQNX4BTA_cjs.toXOnly(newServerPubKey, "ark signer key");
|
|
14752
14787
|
const newServerUnrollScript = assertValidServerUnrollScript(
|
|
14753
14788
|
checkpointTapscript,
|
|
14754
14789
|
resolveCheckpointExitDelayPolicy(this.network, this.checkpointExitDelayPolicy)
|
|
@@ -14777,21 +14812,21 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14777
14812
|
const [currentBoardingRow] = await manager.getContracts({
|
|
14778
14813
|
script: currentBoardingScript
|
|
14779
14814
|
});
|
|
14780
|
-
const newOffchain = this.offchainTapscript instanceof
|
|
14815
|
+
const newOffchain = this.offchainTapscript instanceof chunkCQNX4BTA_cjs.DelegateVtxo.Script ? new chunkCQNX4BTA_cjs.DelegateVtxo.Script({
|
|
14781
14816
|
...this.offchainTapscript.options,
|
|
14782
14817
|
serverPubKey: xonly
|
|
14783
|
-
}) : new
|
|
14818
|
+
}) : new chunkCQNX4BTA_cjs.DefaultVtxo.Script({
|
|
14784
14819
|
...this.offchainTapscript.options,
|
|
14785
14820
|
serverPubKey: xonly
|
|
14786
14821
|
});
|
|
14787
|
-
const newBoarding = new
|
|
14822
|
+
const newBoarding = new chunkCQNX4BTA_cjs.DefaultVtxo.Script({
|
|
14788
14823
|
...this._boardingTapscript.options,
|
|
14789
14824
|
serverPubKey: xonly
|
|
14790
14825
|
});
|
|
14791
|
-
const offchainCsv =
|
|
14826
|
+
const offchainCsv = chunkP53OHGXY_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
|
|
14792
14827
|
const newOffchainScript = base.hex.encode(newOffchain.pkScript);
|
|
14793
14828
|
const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
|
|
14794
|
-
if (newOffchain instanceof
|
|
14829
|
+
if (newOffchain instanceof chunkCQNX4BTA_cjs.DelegateVtxo.Script) {
|
|
14795
14830
|
await manager.createContract({
|
|
14796
14831
|
type: "delegate",
|
|
14797
14832
|
params: {
|
|
@@ -14819,13 +14854,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14819
14854
|
metadata: currentOffchainRow?.metadata
|
|
14820
14855
|
});
|
|
14821
14856
|
}
|
|
14822
|
-
const boardingCsv = newBoarding.options.csvTimelock ??
|
|
14857
|
+
const boardingCsv = newBoarding.options.csvTimelock ?? chunkCQNX4BTA_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
14823
14858
|
await manager.createContract({
|
|
14824
14859
|
type: "boarding",
|
|
14825
14860
|
params: {
|
|
14826
14861
|
pubKey: base.hex.encode(newBoarding.options.pubKey),
|
|
14827
14862
|
serverPubKey: base.hex.encode(xonly),
|
|
14828
|
-
csvTimelock:
|
|
14863
|
+
csvTimelock: chunkP53OHGXY_cjs.timelockToSequence(boardingCsv).toString()
|
|
14829
14864
|
},
|
|
14830
14865
|
script: base.hex.encode(newBoarding.pkScript),
|
|
14831
14866
|
address: newBoarding.address(this.network.hrp, xonly).encode(),
|
|
@@ -14858,14 +14893,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14858
14893
|
_restoreInFlight;
|
|
14859
14894
|
_addPendingSpends(inputs) {
|
|
14860
14895
|
for (const input of inputs) {
|
|
14861
|
-
if (
|
|
14896
|
+
if (chunkP53OHGXY_cjs.isVirtualCoin(input)) {
|
|
14862
14897
|
this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
|
|
14863
14898
|
}
|
|
14864
14899
|
}
|
|
14865
14900
|
}
|
|
14866
14901
|
_removePendingSpends(inputs) {
|
|
14867
14902
|
for (const input of inputs) {
|
|
14868
|
-
if (
|
|
14903
|
+
if (chunkP53OHGXY_cjs.isVirtualCoin(input)) {
|
|
14869
14904
|
this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
|
|
14870
14905
|
}
|
|
14871
14906
|
}
|
|
@@ -14926,13 +14961,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14926
14961
|
const manager = await this.getContractManager();
|
|
14927
14962
|
const provider = this._descriptorProvider;
|
|
14928
14963
|
const hd = provider instanceof HDDescriptorProvider;
|
|
14929
|
-
const staticDescriptor = hd ? void 0 : await
|
|
14964
|
+
const staticDescriptor = hd ? void 0 : await chunkCQNX4BTA_cjs.identityDescriptor(this.identity);
|
|
14930
14965
|
const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
|
|
14931
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
14966
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkCQNX4BTA_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
14932
14967
|
const arkInfo = await this.arkProvider.getInfo();
|
|
14933
|
-
const currentSignerPubKey =
|
|
14968
|
+
const currentSignerPubKey = chunkCQNX4BTA_cjs.toXOnly(base.hex.decode(arkInfo.signerPubkey), "ark signer key");
|
|
14934
14969
|
const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
|
|
14935
|
-
(s) =>
|
|
14970
|
+
(s) => chunkCQNX4BTA_cjs.toXOnly(base.hex.decode(s.pubkey), "deprecated signer key")
|
|
14936
14971
|
);
|
|
14937
14972
|
const deps = {
|
|
14938
14973
|
indexerProvider: this.indexerProvider,
|
|
@@ -14947,7 +14982,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14947
14982
|
csvTimelocks: this.walletContractTimelocks,
|
|
14948
14983
|
// Boarding-exit CSV so the boarding handler can build its
|
|
14949
14984
|
// candidate script (distinct from the unilateral-exit matrix).
|
|
14950
|
-
boardingTimelock: this.boardingTapscript.options.csvTimelock ??
|
|
14985
|
+
boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkCQNX4BTA_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
|
|
14951
14986
|
delegatePubKey
|
|
14952
14987
|
};
|
|
14953
14988
|
const result = await manager.scanContracts({
|
|
@@ -15061,7 +15096,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15061
15096
|
throw new Error("Invalid configured public key");
|
|
15062
15097
|
}
|
|
15063
15098
|
const setup = await ReadonlyWallet.setupWalletConfig(config, pubkey);
|
|
15064
|
-
const forfeitPubkey =
|
|
15099
|
+
const forfeitPubkey = chunkCQNX4BTA_cjs.toXOnly(base.hex.decode(setup.info.forfeitPubkey), "forfeit key");
|
|
15065
15100
|
const forfeitAddress = btcSigner.Address(setup.network).decode(setup.info.forfeitAddress);
|
|
15066
15101
|
const forfeitOutputScript = btcSigner.OutScript.encode(forfeitAddress);
|
|
15067
15102
|
const checkpointExitDelayOverrides = {
|
|
@@ -15210,7 +15245,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15210
15245
|
inputs: params.selectedVtxos,
|
|
15211
15246
|
changeAmount: BigInt(changeAmount)
|
|
15212
15247
|
};
|
|
15213
|
-
const outputAddress =
|
|
15248
|
+
const outputAddress = chunkP53OHGXY_cjs.ArkAddress.decode(params.address);
|
|
15214
15249
|
assertRecipientArkAddress(
|
|
15215
15250
|
params.address,
|
|
15216
15251
|
outputAddress,
|
|
@@ -15276,13 +15311,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15276
15311
|
void this.logUngatedInputs("settle({ inputs })", params.inputs);
|
|
15277
15312
|
}
|
|
15278
15313
|
const offchainAddress = await this.getAddress();
|
|
15279
|
-
const offchainPkScript =
|
|
15314
|
+
const offchainPkScript = chunkP53OHGXY_cjs.ArkAddress.decode(offchainAddress).pkScript;
|
|
15280
15315
|
const offchainOutputScript = base.hex.encode(offchainPkScript);
|
|
15281
15316
|
if (!params) {
|
|
15282
15317
|
const { fees, vtxoMaxAmount } = await this.arkProvider.getInfo();
|
|
15283
15318
|
const estimator = new Estimator(fees.intentFee);
|
|
15284
15319
|
let amount = 0;
|
|
15285
|
-
const exitScript =
|
|
15320
|
+
const exitScript = chunkP53OHGXY_cjs.CSVMultisigTapscript.decode(
|
|
15286
15321
|
base.hex.decode(this.boardingTapscript.exitScript)
|
|
15287
15322
|
);
|
|
15288
15323
|
const boardingTimelock = exitScript.params.timelock;
|
|
@@ -15311,7 +15346,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15311
15346
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
15312
15347
|
break;
|
|
15313
15348
|
}
|
|
15314
|
-
const inputFee = estimator.evalOffchainInput(
|
|
15349
|
+
const inputFee = estimator.evalOffchainInput(chunkP53OHGXY_cjs.toOffchainInputFeeParams(vtxo));
|
|
15315
15350
|
if (inputFee.satoshis >= vtxo.value) {
|
|
15316
15351
|
continue;
|
|
15317
15352
|
}
|
|
@@ -15358,7 +15393,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15358
15393
|
let script;
|
|
15359
15394
|
let arkAddress;
|
|
15360
15395
|
try {
|
|
15361
|
-
arkAddress =
|
|
15396
|
+
arkAddress = chunkP53OHGXY_cjs.ArkAddress.decode(output.address);
|
|
15362
15397
|
} catch {
|
|
15363
15398
|
arkAddress = void 0;
|
|
15364
15399
|
}
|
|
@@ -15448,7 +15483,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15448
15483
|
const abortController = new AbortController();
|
|
15449
15484
|
let stream;
|
|
15450
15485
|
let committedTxid;
|
|
15451
|
-
const settleInputVtxos = params.inputs.filter(
|
|
15486
|
+
const settleInputVtxos = params.inputs.filter(chunkP53OHGXY_cjs.isVirtualCoin);
|
|
15452
15487
|
const contractManager = await this.getContractManager();
|
|
15453
15488
|
await contractManager.assertAnnotatable(settleInputVtxos);
|
|
15454
15489
|
await contractManager.assertSpendableNow?.(
|
|
@@ -15560,7 +15595,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15560
15595
|
async maybeRotateBoardingAfterBoard(inputs) {
|
|
15561
15596
|
if (!this._descriptorProvider) return;
|
|
15562
15597
|
const consumedBoarding = inputs.some(
|
|
15563
|
-
(input) => typeof input !== "string" && !
|
|
15598
|
+
(input) => typeof input !== "string" && !chunkP53OHGXY_cjs.isVirtualCoin(input)
|
|
15564
15599
|
);
|
|
15565
15600
|
if (!consumedBoarding) return;
|
|
15566
15601
|
try {
|
|
@@ -15584,7 +15619,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15584
15619
|
let connectorIndex = 0;
|
|
15585
15620
|
const connectorsLeaves = connectorsGraph?.leaves() || [];
|
|
15586
15621
|
for (const input of inputs) {
|
|
15587
|
-
if (!
|
|
15622
|
+
if (!chunkP53OHGXY_cjs.isVirtualCoin(input)) {
|
|
15588
15623
|
let matched = false;
|
|
15589
15624
|
for (let i = 0; i < settlementPsbt.inputsLength; i++) {
|
|
15590
15625
|
const settlementInput = settlementPsbt.getInput(i);
|
|
@@ -15622,7 +15657,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15622
15657
|
}
|
|
15623
15658
|
continue;
|
|
15624
15659
|
}
|
|
15625
|
-
if (
|
|
15660
|
+
if (chunkP53OHGXY_cjs.canRecoverOnchain(input, { timestamp: /* @__PURE__ */ new Date() }) || isSubdust({ value: input.value }, this.dustAmount)) {
|
|
15626
15661
|
continue;
|
|
15627
15662
|
}
|
|
15628
15663
|
if (connectorsLeaves.length === 0) {
|
|
@@ -15650,7 +15685,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15650
15685
|
index: input.vout,
|
|
15651
15686
|
witnessUtxo: {
|
|
15652
15687
|
amount: BigInt(input.value),
|
|
15653
|
-
script:
|
|
15688
|
+
script: chunkP53OHGXY_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
15654
15689
|
},
|
|
15655
15690
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
15656
15691
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -15669,7 +15704,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15669
15704
|
forfeitTx = await this._signerRouter.sign(forfeitTx, [
|
|
15670
15705
|
{
|
|
15671
15706
|
index: 0,
|
|
15672
|
-
lookupScript:
|
|
15707
|
+
lookupScript: chunkP53OHGXY_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
15673
15708
|
}
|
|
15674
15709
|
]);
|
|
15675
15710
|
signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
|
|
@@ -15727,7 +15762,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15727
15762
|
resolveBatchExpiryPolicy(this.network, this.batchExpiryPolicy)
|
|
15728
15763
|
);
|
|
15729
15764
|
await this.arkProvider.confirmRegistration(intentId);
|
|
15730
|
-
const sweepTapscript =
|
|
15765
|
+
const sweepTapscript = chunkP53OHGXY_cjs.CSVMultisigTapscript.encode({
|
|
15731
15766
|
timelock,
|
|
15732
15767
|
pubkeys: [this.forfeitPubkey]
|
|
15733
15768
|
}).script;
|
|
@@ -15742,10 +15777,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15742
15777
|
throw new Error("Sweep tap tree root not set");
|
|
15743
15778
|
}
|
|
15744
15779
|
const xOnlyPublicKeys = event.cosignersPublicKeys.map(
|
|
15745
|
-
(k) => base.hex.encode(
|
|
15780
|
+
(k) => base.hex.encode(chunkCQNX4BTA_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
|
|
15746
15781
|
);
|
|
15747
15782
|
const signerPublicKey = await session.getPublicKey();
|
|
15748
|
-
const xonlySignerPublicKey =
|
|
15783
|
+
const xonlySignerPublicKey = chunkCQNX4BTA_cjs.toXOnly(signerPublicKey, "signer key");
|
|
15749
15784
|
if (!xOnlyPublicKeys.includes(base.hex.encode(xonlySignerPublicKey))) {
|
|
15750
15785
|
return { skip: true };
|
|
15751
15786
|
}
|
|
@@ -15835,9 +15870,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15835
15870
|
...existing ?? {},
|
|
15836
15871
|
intentTxId,
|
|
15837
15872
|
registerProof: intent.proof,
|
|
15838
|
-
registerProofMessage:
|
|
15873
|
+
registerProofMessage: chunkP53OHGXY_cjs.Intent.encodeMessage(intent.message),
|
|
15839
15874
|
deleteProof: deleteIntent.proof,
|
|
15840
|
-
deleteProofMessage:
|
|
15875
|
+
deleteProofMessage: chunkP53OHGXY_cjs.Intent.encodeMessage(deleteIntent.message),
|
|
15841
15876
|
intentVtxos: inputs.map((i) => ({
|
|
15842
15877
|
txid: i.txid,
|
|
15843
15878
|
vout: i.vout
|
|
@@ -15870,7 +15905,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15870
15905
|
try {
|
|
15871
15906
|
return await this.arkProvider.registerIntent(intent);
|
|
15872
15907
|
} catch (error) {
|
|
15873
|
-
if (error instanceof
|
|
15908
|
+
if (error instanceof chunkP53OHGXY_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
|
|
15874
15909
|
const deleteIntent = await this.makeDeleteIntentSignature(inputs);
|
|
15875
15910
|
await this.arkProvider.deleteIntent(deleteIntent);
|
|
15876
15911
|
return this.arkProvider.registerIntent(intent);
|
|
@@ -15886,7 +15921,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15886
15921
|
expire_at: 0,
|
|
15887
15922
|
cosigners_public_keys: cosignerPubKeys
|
|
15888
15923
|
};
|
|
15889
|
-
const proof =
|
|
15924
|
+
const proof = chunkP53OHGXY_cjs.Intent.create(message, coins, outputs);
|
|
15890
15925
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
15891
15926
|
return {
|
|
15892
15927
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -15898,7 +15933,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15898
15933
|
type: "delete",
|
|
15899
15934
|
expire_at: 0
|
|
15900
15935
|
};
|
|
15901
|
-
const proof =
|
|
15936
|
+
const proof = chunkP53OHGXY_cjs.Intent.create(message, coins, []);
|
|
15902
15937
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
15903
15938
|
return {
|
|
15904
15939
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -15910,7 +15945,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15910
15945
|
type: "get-pending-tx",
|
|
15911
15946
|
expire_at: 0
|
|
15912
15947
|
};
|
|
15913
|
-
const proof =
|
|
15948
|
+
const proof = chunkP53OHGXY_cjs.Intent.create(message, coins, []);
|
|
15914
15949
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
15915
15950
|
return {
|
|
15916
15951
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -15931,7 +15966,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15931
15966
|
if (!vtxos || vtxos.length === 0) {
|
|
15932
15967
|
const scriptMap = await this.getScriptMap();
|
|
15933
15968
|
const allExtended = [];
|
|
15934
|
-
const fetchedVtxos = await
|
|
15969
|
+
const fetchedVtxos = await chunkP53OHGXY_cjs.getAllNormalizedVtxos(this.indexerProvider, [
|
|
15935
15970
|
...scriptMap.keys()
|
|
15936
15971
|
]);
|
|
15937
15972
|
for (const vtxo of fetchedVtxos) {
|
|
@@ -15975,7 +16010,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15975
16010
|
try {
|
|
15976
16011
|
const checkpointTxs = pendingTx.signedCheckpointTxs.map((c) => {
|
|
15977
16012
|
const tx = btcSigner.Transaction.fromPSBT(base.base64.decode(c));
|
|
15978
|
-
|
|
16013
|
+
chunkP53OHGXY_cjs.assertAllowedSighashTypes(tx);
|
|
15979
16014
|
return tx;
|
|
15980
16015
|
});
|
|
15981
16016
|
assertCheckpointsMatchInputs(
|
|
@@ -16047,11 +16082,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16047
16082
|
* against the current key alone would leave it pending forever.
|
|
16048
16083
|
*/
|
|
16049
16084
|
checkpointUnrollCandidates(info) {
|
|
16050
|
-
const current =
|
|
16085
|
+
const current = chunkP53OHGXY_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
16051
16086
|
const candidates = [this._serverUnrollScript, current];
|
|
16052
16087
|
for (const deprecated of signerSetFromInfo(info).deprecated.keys()) {
|
|
16053
16088
|
candidates.push(
|
|
16054
|
-
|
|
16089
|
+
chunkP53OHGXY_cjs.CSVMultisigTapscript.encode({
|
|
16055
16090
|
...current.params,
|
|
16056
16091
|
pubkeys: [base.hex.decode(deprecated)]
|
|
16057
16092
|
})
|
|
@@ -16142,7 +16177,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16142
16177
|
if (vtxos.length === 0) {
|
|
16143
16178
|
throw new Error("No VTXOs found for this arkadeCash");
|
|
16144
16179
|
}
|
|
16145
|
-
const myPkScript =
|
|
16180
|
+
const myPkScript = chunkP53OHGXY_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
|
|
16146
16181
|
let { spendable, unclaimed } = this.classifyCashVtxos(vtxos);
|
|
16147
16182
|
let swept = 0;
|
|
16148
16183
|
const drainable = vtxos.filter(
|
|
@@ -16218,7 +16253,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16218
16253
|
const spendable = [];
|
|
16219
16254
|
const unclaimed = [];
|
|
16220
16255
|
for (const vtxo of vtxos) {
|
|
16221
|
-
if (
|
|
16256
|
+
if (chunkP53OHGXY_cjs.hasTerminalSpend(vtxo)) {
|
|
16222
16257
|
unclaimed.push(cashReport(vtxo, "already-spent"));
|
|
16223
16258
|
} else if (vtxo.isUnrolled) {
|
|
16224
16259
|
unclaimed.push(cashReport(vtxo, "exited"));
|
|
@@ -16240,7 +16275,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16240
16275
|
const all = [];
|
|
16241
16276
|
const seen = /* @__PURE__ */ new Set();
|
|
16242
16277
|
for (let pageIndex = 0; ; pageIndex++) {
|
|
16243
|
-
const { vtxos, page } = await
|
|
16278
|
+
const { vtxos, page } = await chunkP53OHGXY_cjs.getNormalizedVtxos(this.indexerProvider, {
|
|
16244
16279
|
scripts,
|
|
16245
16280
|
pageIndex,
|
|
16246
16281
|
pageSize
|
|
@@ -16287,7 +16322,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16287
16322
|
for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
|
|
16288
16323
|
const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
|
|
16289
16324
|
const message = { type: "get-pending-tx", expire_at: 0 };
|
|
16290
|
-
const proof =
|
|
16325
|
+
const proof = chunkP53OHGXY_cjs.Intent.create(message, batch, []);
|
|
16291
16326
|
const signedProof = await identity.sign(
|
|
16292
16327
|
proof,
|
|
16293
16328
|
Array.from({ length: batch.length + 1 }, (_, j) => j)
|
|
@@ -16309,7 +16344,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16309
16344
|
try {
|
|
16310
16345
|
const checkpointTxs = pendingTx.signedCheckpointTxs.map((checkpoint) => {
|
|
16311
16346
|
const tx = btcSigner.Transaction.fromPSBT(base.base64.decode(checkpoint));
|
|
16312
|
-
|
|
16347
|
+
chunkP53OHGXY_cjs.assertAllowedSighashTypes(tx);
|
|
16313
16348
|
return tx;
|
|
16314
16349
|
});
|
|
16315
16350
|
assertCheckpointsMatchInputs(
|
|
@@ -16508,7 +16543,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16508
16543
|
script: recipient.script,
|
|
16509
16544
|
amount: BigInt(recipient.amount),
|
|
16510
16545
|
// Already checked against the recipient address in `validateRecipients`.
|
|
16511
|
-
...recipient.tapTree ? { tapTree:
|
|
16546
|
+
...recipient.tapTree ? { tapTree: chunkP53OHGXY_cjs.TapTreeCoder.decode(recipient.tapTree) } : {}
|
|
16512
16547
|
}));
|
|
16513
16548
|
const totalBtcOutput = outputs.reduce((sum, o) => sum + Number(o.amount), 0);
|
|
16514
16549
|
let changeAmount = totalBtcSelected - totalBtcOutput;
|
|
@@ -16652,10 +16687,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16652
16687
|
const serverPubKey = this.arkServerPublicKey;
|
|
16653
16688
|
const serverUnrollScript = this.serverUnrollScript;
|
|
16654
16689
|
const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
|
|
16655
|
-
const normalizedInputs = inputs.map(
|
|
16656
|
-
const at = now ?? await
|
|
16690
|
+
const normalizedInputs = inputs.map(chunkP53OHGXY_cjs.normalizeVtxo);
|
|
16691
|
+
const at = now ?? await chunkP53OHGXY_cjs.resolveTimeHeight(this.onchainProvider);
|
|
16657
16692
|
for (const input of normalizedInputs) {
|
|
16658
|
-
if (!
|
|
16693
|
+
if (!chunkP53OHGXY_cjs.canSpendOffchain(input, at)) {
|
|
16659
16694
|
throw new Error(
|
|
16660
16695
|
`sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
|
|
16661
16696
|
);
|
|
@@ -16725,7 +16760,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16725
16760
|
);
|
|
16726
16761
|
const arkTxJobs = inputs.map((input, index) => ({
|
|
16727
16762
|
index,
|
|
16728
|
-
lookupScript:
|
|
16763
|
+
lookupScript: chunkP53OHGXY_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
16729
16764
|
}));
|
|
16730
16765
|
const identity = this.identity;
|
|
16731
16766
|
const signer = {
|
|
@@ -16826,14 +16861,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16826
16861
|
const spentBy = checkpointIdByOutpoint.get(`${vtxo.txid}:${vtxo.vout}`);
|
|
16827
16862
|
spentVtxos.push({
|
|
16828
16863
|
...spentFacts,
|
|
16829
|
-
virtualStatus:
|
|
16864
|
+
virtualStatus: chunkP53OHGXY_cjs.toVirtualStatus(spentFacts),
|
|
16830
16865
|
...spentBy ? { spentBy } : {},
|
|
16831
16866
|
arkTxId: arkTxid
|
|
16832
16867
|
});
|
|
16833
16868
|
for (const id of vtxo.commitmentTxIds) {
|
|
16834
16869
|
commitmentTxIds.add(id);
|
|
16835
16870
|
}
|
|
16836
|
-
const vtxoExpiry =
|
|
16871
|
+
const vtxoExpiry = chunkP53OHGXY_cjs.toBatchExpiry(vtxo);
|
|
16837
16872
|
if (vtxoExpiry) {
|
|
16838
16873
|
batchExpiry = Math.min(batchExpiry, vtxoExpiry);
|
|
16839
16874
|
}
|
|
@@ -16846,7 +16881,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16846
16881
|
isSwept: false,
|
|
16847
16882
|
isPreconfirmed: true,
|
|
16848
16883
|
commitmentTxIds: Array.from(commitmentTxIds),
|
|
16849
|
-
...
|
|
16884
|
+
...chunkP53OHGXY_cjs.parseLegacyExpiry(batchExpiry)
|
|
16850
16885
|
};
|
|
16851
16886
|
changeVtxo = {
|
|
16852
16887
|
txid: arkTxid,
|
|
@@ -16858,7 +16893,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16858
16893
|
tapTree: offchainTapscript.encode(),
|
|
16859
16894
|
value: Number(changeAmount),
|
|
16860
16895
|
...changeFacts,
|
|
16861
|
-
virtualStatus:
|
|
16896
|
+
virtualStatus: chunkP53OHGXY_cjs.toVirtualStatus(changeFacts),
|
|
16862
16897
|
spentBy: "",
|
|
16863
16898
|
status: {
|
|
16864
16899
|
confirmed: false
|
|
@@ -16927,12 +16962,12 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16927
16962
|
const spentVtxos = [];
|
|
16928
16963
|
const inputArkTxIds = /* @__PURE__ */ new Set();
|
|
16929
16964
|
const boardingRemovalsByAddress = /* @__PURE__ */ new Map();
|
|
16930
|
-
const vtxoInputs = inputs.filter(
|
|
16965
|
+
const vtxoInputs = inputs.filter(chunkP53OHGXY_cjs.isVirtualCoin);
|
|
16931
16966
|
const cm = await this.getContractManager();
|
|
16932
16967
|
const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
|
|
16933
16968
|
const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
|
|
16934
16969
|
for (const input of inputs) {
|
|
16935
|
-
if (
|
|
16970
|
+
if (chunkP53OHGXY_cjs.isVirtualCoin(input)) {
|
|
16936
16971
|
const outpoint = `${input.txid}:${input.vout}`;
|
|
16937
16972
|
const vtxo = annotatedByKey.get(outpoint);
|
|
16938
16973
|
if (!vtxo) {
|
|
@@ -16944,13 +16979,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16944
16979
|
const settledFacts = { ...vtxo, isSpent: true };
|
|
16945
16980
|
spentVtxos.push({
|
|
16946
16981
|
...settledFacts,
|
|
16947
|
-
virtualStatus:
|
|
16982
|
+
virtualStatus: chunkP53OHGXY_cjs.toVirtualStatus(settledFacts),
|
|
16948
16983
|
settledBy: commitmentTxid
|
|
16949
16984
|
});
|
|
16950
16985
|
} else {
|
|
16951
16986
|
let sourceAddress;
|
|
16952
16987
|
try {
|
|
16953
|
-
sourceAddress =
|
|
16988
|
+
sourceAddress = chunkP53OHGXY_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
|
|
16954
16989
|
this.network
|
|
16955
16990
|
);
|
|
16956
16991
|
} catch {
|
|
@@ -17008,9 +17043,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
17008
17043
|
}
|
|
17009
17044
|
};
|
|
17010
17045
|
function selectVirtualCoins(coins, targetAmount) {
|
|
17011
|
-
const sortedCoins = coins.map(
|
|
17012
|
-
const expiryA =
|
|
17013
|
-
const expiryB =
|
|
17046
|
+
const sortedCoins = coins.map(chunkP53OHGXY_cjs.normalizeVtxo).sort((a, b) => {
|
|
17047
|
+
const expiryA = chunkP53OHGXY_cjs.toBatchExpiry(a) || Number.MAX_SAFE_INTEGER;
|
|
17048
|
+
const expiryB = chunkP53OHGXY_cjs.toBatchExpiry(b) || Number.MAX_SAFE_INTEGER;
|
|
17014
17049
|
if (expiryA !== expiryB) {
|
|
17015
17050
|
return expiryA - expiryB;
|
|
17016
17051
|
}
|
|
@@ -17379,7 +17414,7 @@ var MessageBus = class {
|
|
|
17379
17414
|
this.initialized = true;
|
|
17380
17415
|
}
|
|
17381
17416
|
async buildServices(config) {
|
|
17382
|
-
const arkProvider = new
|
|
17417
|
+
const arkProvider = new chunkP53OHGXY_cjs.RestArkProvider(config.arkServer.url);
|
|
17383
17418
|
const storage = {
|
|
17384
17419
|
walletRepository: this.walletRepository,
|
|
17385
17420
|
contractRepository: this.contractRepository,
|
|
@@ -17733,7 +17768,7 @@ var offboardNetworkNames = [
|
|
|
17733
17768
|
function offboardDestinationScript(destinationAddress) {
|
|
17734
17769
|
for (const networkName of offboardNetworkNames) {
|
|
17735
17770
|
try {
|
|
17736
|
-
const network =
|
|
17771
|
+
const network = chunkP53OHGXY_cjs.networks[networkName];
|
|
17737
17772
|
const addr = btcSigner.Address(network).decode(destinationAddress);
|
|
17738
17773
|
return btcSigner.OutScript.encode(addr);
|
|
17739
17774
|
} catch {
|
|
@@ -17769,7 +17804,7 @@ function filterOffboardInputs(vtxos, feeInfo, named) {
|
|
|
17769
17804
|
const inputs = [];
|
|
17770
17805
|
let subtotal = 0n;
|
|
17771
17806
|
for (const vtxo of vtxos) {
|
|
17772
|
-
const inputFee = estimator.evalOffchainInput(
|
|
17807
|
+
const inputFee = estimator.evalOffchainInput(chunkP53OHGXY_cjs.toOffchainInputFeeParams(vtxo));
|
|
17773
17808
|
if (inputFee.satoshis >= vtxo.value) {
|
|
17774
17809
|
if (named) {
|
|
17775
17810
|
throw new Error(
|
|
@@ -17866,7 +17901,7 @@ var Ramps = class {
|
|
|
17866
17901
|
}
|
|
17867
17902
|
amount = amount ?? totalAmount;
|
|
17868
17903
|
const offchainAddress = await this.wallet.getAddress();
|
|
17869
|
-
const offchainAddr =
|
|
17904
|
+
const offchainAddr = chunkP53OHGXY_cjs.ArkAddress.decode(offchainAddress);
|
|
17870
17905
|
const offchainScript = base.hex.encode(offchainAddr.pkScript);
|
|
17871
17906
|
const outputFee = estimator.evalOffchainOutput({
|
|
17872
17907
|
amount,
|
|
@@ -17993,7 +18028,7 @@ var Ramps = class {
|
|
|
17993
18028
|
async fundChange(left, estimator) {
|
|
17994
18029
|
if (left <= 0n) return { change: 0n };
|
|
17995
18030
|
const changeAddress = await this.wallet.getAddress();
|
|
17996
|
-
const changeScript = base.hex.encode(
|
|
18031
|
+
const changeScript = base.hex.encode(chunkP53OHGXY_cjs.ArkAddress.decode(changeAddress).pkScript);
|
|
17997
18032
|
const { change } = changeAfterOutputFee(
|
|
17998
18033
|
left,
|
|
17999
18034
|
(amount) => BigInt(estimator.evalOffchainOutput({ amount, script: changeScript }).satoshis)
|
|
@@ -18822,7 +18857,7 @@ var WalletMessageHandler = class {
|
|
|
18822
18857
|
// Wallet methods
|
|
18823
18858
|
async handleInitWallet({ payload }) {
|
|
18824
18859
|
const { arkServerUrl } = payload;
|
|
18825
|
-
this.indexerProvider = new
|
|
18860
|
+
this.indexerProvider = new chunkT327OEMV_cjs.RestIndexerProvider(arkServerUrl);
|
|
18826
18861
|
await this.onWalletInitialized();
|
|
18827
18862
|
}
|
|
18828
18863
|
/**
|
|
@@ -18857,7 +18892,8 @@ var WalletMessageHandler = class {
|
|
|
18857
18892
|
now: { timestamp: /* @__PURE__ */ new Date() },
|
|
18858
18893
|
isPendingRecovery: (vtxo) => pendingOutpoints.has(`${vtxo.txid}:${vtxo.vout}`),
|
|
18859
18894
|
isGenericallySpendable: (vtxo) => !isGatedVtxo(vtxo, gated),
|
|
18860
|
-
isUnlocked: (vtxo) => unlocked.has(`${vtxo.txid}:${vtxo.vout}`)
|
|
18895
|
+
isUnlocked: (vtxo) => unlocked.has(`${vtxo.txid}:${vtxo.vout}`),
|
|
18896
|
+
dustCarrier: getDustAmount(this.readonlyWallet)
|
|
18861
18897
|
});
|
|
18862
18898
|
return {
|
|
18863
18899
|
boarding: {
|
|
@@ -19110,7 +19146,7 @@ var WalletMessageHandler = class {
|
|
|
19110
19146
|
if (v.isUnrolled) {
|
|
19111
19147
|
return withUnrolled;
|
|
19112
19148
|
}
|
|
19113
|
-
if (
|
|
19149
|
+
if (chunkP53OHGXY_cjs.hasTerminalSpend(v)) {
|
|
19114
19150
|
return false;
|
|
19115
19151
|
}
|
|
19116
19152
|
if (includeRecoverable) {
|
|
@@ -19119,10 +19155,10 @@ var WalletMessageHandler = class {
|
|
|
19119
19155
|
if (dustAmount != null && isSubdust(v, dustAmount)) {
|
|
19120
19156
|
return false;
|
|
19121
19157
|
}
|
|
19122
|
-
if (
|
|
19158
|
+
if (chunkP53OHGXY_cjs.isRecoverable(v)) {
|
|
19123
19159
|
return false;
|
|
19124
19160
|
}
|
|
19125
|
-
if (
|
|
19161
|
+
if (chunkP53OHGXY_cjs.isExpired(v)) {
|
|
19126
19162
|
return false;
|
|
19127
19163
|
}
|
|
19128
19164
|
return true;
|
|
@@ -19230,7 +19266,7 @@ var WalletMessageHandler = class {
|
|
|
19230
19266
|
this.readonlyWallet.getBoardingTxs()
|
|
19231
19267
|
]);
|
|
19232
19268
|
const indexerProvider = this.indexerProvider;
|
|
19233
|
-
const resolveTxCreatedAt = indexerProvider ? (txids) =>
|
|
19269
|
+
const resolveTxCreatedAt = indexerProvider ? (txids) => chunkP53OHGXY_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
|
|
19234
19270
|
return buildTransactionHistory(
|
|
19235
19271
|
vtxos,
|
|
19236
19272
|
boardingTxs,
|
|
@@ -19938,7 +19974,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
19938
19974
|
};
|
|
19939
19975
|
try {
|
|
19940
19976
|
const response = await this.sendMessage(message);
|
|
19941
|
-
return response.payload.vtxos.map(
|
|
19977
|
+
return response.payload.vtxos.map(chunkP53OHGXY_cjs.normalizeVtxo);
|
|
19942
19978
|
} catch (error) {
|
|
19943
19979
|
throw new Error(`Failed to get vtxos: ${error}`);
|
|
19944
19980
|
}
|
|
@@ -19963,7 +19999,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
19963
19999
|
};
|
|
19964
20000
|
try {
|
|
19965
20001
|
const response = await this.sendMessage(message);
|
|
19966
|
-
return response.payload.vtxos.map(
|
|
20002
|
+
return response.payload.vtxos.map(chunkP53OHGXY_cjs.normalizeVtxo);
|
|
19967
20003
|
} catch (error) {
|
|
19968
20004
|
throw new Error(`Failed to get spendable vtxos: ${error}`);
|
|
19969
20005
|
}
|
|
@@ -20134,7 +20170,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
20134
20170
|
};
|
|
20135
20171
|
try {
|
|
20136
20172
|
const response = await sendContractMessage(message);
|
|
20137
|
-
return response.payload.vtxos.map(
|
|
20173
|
+
return response.payload.vtxos.map(chunkP53OHGXY_cjs.normalizeVtxo);
|
|
20138
20174
|
} catch (e) {
|
|
20139
20175
|
throw new Error("Failed to annotate vtxos");
|
|
20140
20176
|
}
|
|
@@ -20746,7 +20782,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
20746
20782
|
};
|
|
20747
20783
|
try {
|
|
20748
20784
|
const response = await wallet.sendMessage(message);
|
|
20749
|
-
return response.payload.vtxos.map(
|
|
20785
|
+
return response.payload.vtxos.map(chunkP53OHGXY_cjs.normalizeVtxo);
|
|
20750
20786
|
} catch (e) {
|
|
20751
20787
|
throw new Error(`Failed to get expiring vtxos: ${e}`);
|
|
20752
20788
|
}
|
|
@@ -20858,12 +20894,12 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
20858
20894
|
* @returns Configured onchain wallet
|
|
20859
20895
|
* @throws Error if the configured identity cannot produce a valid x-only public key
|
|
20860
20896
|
*/
|
|
20861
|
-
static async create(identity, networkName =
|
|
20897
|
+
static async create(identity, networkName = chunkP53OHGXY_cjs.DEFAULT_NETWORK_NAME, provider) {
|
|
20862
20898
|
const pubkey = await identity.xOnlyPublicKey();
|
|
20863
20899
|
if (!pubkey) {
|
|
20864
20900
|
throw new Error("Invalid configured public key");
|
|
20865
20901
|
}
|
|
20866
|
-
const network =
|
|
20902
|
+
const network = chunkP53OHGXY_cjs.getNetwork(networkName);
|
|
20867
20903
|
const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
|
|
20868
20904
|
const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
|
|
20869
20905
|
return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
|
|
@@ -20969,7 +21005,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
20969
21005
|
if (!inputs) {
|
|
20970
21006
|
throw new Error("Fee estimation failed");
|
|
20971
21007
|
}
|
|
20972
|
-
let tx = new
|
|
21008
|
+
let tx = new chunkP53OHGXY_cjs.Transaction();
|
|
20973
21009
|
for (const input of inputs) {
|
|
20974
21010
|
tx.addInput({
|
|
20975
21011
|
txid: input.txid,
|
|
@@ -21027,7 +21063,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
21027
21063
|
* @throws If the parent has no anchor, or funding cannot be selected/signed
|
|
21028
21064
|
*/
|
|
21029
21065
|
async bumpAnchor(parentHex, feeRate) {
|
|
21030
|
-
const parent =
|
|
21066
|
+
const parent = chunkP53OHGXY_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
|
|
21031
21067
|
const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
|
|
21032
21068
|
const child = await this.buildBumpPackage(parent, feeRate, coins);
|
|
21033
21069
|
return [parent.hex, child.hex];
|
|
@@ -21934,7 +21970,7 @@ async function resolvePrevTxs(txids, source, onchain) {
|
|
|
21934
21970
|
try {
|
|
21935
21971
|
const { txs } = await source.getVirtualTxs(wanted);
|
|
21936
21972
|
for (const psbt of txs) {
|
|
21937
|
-
const tx =
|
|
21973
|
+
const tx = chunkP53OHGXY_cjs.Transaction.fromPSBT(base.base64.decode(psbt));
|
|
21938
21974
|
resolved.set(tx.id, tx.toBytes());
|
|
21939
21975
|
}
|
|
21940
21976
|
} catch (err) {
|
|
@@ -21967,7 +22003,7 @@ async function resolvePrevTxs(txids, source, onchain) {
|
|
|
21967
22003
|
async function attachPrevArkTxs(tx, txids, source, onchain) {
|
|
21968
22004
|
const pending = [];
|
|
21969
22005
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
21970
|
-
if (
|
|
22006
|
+
if (chunkP53OHGXY_cjs.getArkPsbtFields(tx, i, chunkP53OHGXY_cjs.PrevArkTxField).length === 0) pending.push(i);
|
|
21971
22007
|
}
|
|
21972
22008
|
if (pending.length === 0) return;
|
|
21973
22009
|
const resolved = await resolvePrevTxs(
|
|
@@ -21976,13 +22012,13 @@ async function attachPrevArkTxs(tx, txids, source, onchain) {
|
|
|
21976
22012
|
onchain
|
|
21977
22013
|
);
|
|
21978
22014
|
for (const i of pending) {
|
|
21979
|
-
|
|
22015
|
+
chunkP53OHGXY_cjs.setArkPsbtField(tx, i, chunkP53OHGXY_cjs.PrevArkTxField, resolved.get(txidAt(txids, i)));
|
|
21980
22016
|
}
|
|
21981
22017
|
}
|
|
21982
22018
|
async function attachPrevoutTxs(tx, source) {
|
|
21983
22019
|
const pending = [];
|
|
21984
22020
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
21985
|
-
if (
|
|
22021
|
+
if (chunkP53OHGXY_cjs.getArkPsbtFields(tx, i, chunkP53OHGXY_cjs.PrevoutTxField).length > 0) continue;
|
|
21986
22022
|
const input = tx.getInput(i);
|
|
21987
22023
|
if (!input?.txid) throw new PrevTxUnavailableError(`input ${i} has no outpoint`);
|
|
21988
22024
|
pending.push({ index: i, txid: base.hex.encode(input.txid) });
|
|
@@ -21993,7 +22029,7 @@ async function attachPrevoutTxs(tx, source) {
|
|
|
21993
22029
|
resolved.set(txid, await source.getRawTransaction(txid));
|
|
21994
22030
|
}
|
|
21995
22031
|
for (const { index, txid } of pending) {
|
|
21996
|
-
|
|
22032
|
+
chunkP53OHGXY_cjs.setArkPsbtField(tx, index, chunkP53OHGXY_cjs.PrevoutTxField, resolved.get(txid));
|
|
21997
22033
|
}
|
|
21998
22034
|
}
|
|
21999
22035
|
async function withPrevTxs(coins, source, onchain) {
|
|
@@ -22019,7 +22055,7 @@ exports.BIP322 = void 0;
|
|
|
22019
22055
|
async function sign2(message, identity, network) {
|
|
22020
22056
|
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
22021
22057
|
const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
|
|
22022
|
-
const toSpend =
|
|
22058
|
+
const toSpend = chunkP53OHGXY_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
22023
22059
|
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
22024
22060
|
const signed = await identity.sign(toSign, [0]);
|
|
22025
22061
|
signed.finalizeIdx(0);
|
|
@@ -22077,7 +22113,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
|
22077
22113
|
if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
|
|
22078
22114
|
return false;
|
|
22079
22115
|
}
|
|
22080
|
-
const toSpend =
|
|
22116
|
+
const toSpend = chunkP53OHGXY_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
22081
22117
|
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
|
|
22082
22118
|
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
22083
22119
|
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
@@ -22098,7 +22134,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
|
22098
22134
|
}
|
|
22099
22135
|
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
22100
22136
|
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
22101
|
-
const toSpend =
|
|
22137
|
+
const toSpend = chunkP53OHGXY_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
22102
22138
|
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
22103
22139
|
const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
|
|
22104
22140
|
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
@@ -22151,7 +22187,7 @@ function encodeCompactSize(n) {
|
|
|
22151
22187
|
return buf;
|
|
22152
22188
|
}
|
|
22153
22189
|
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
22154
|
-
const tx = new
|
|
22190
|
+
const tx = new chunkP53OHGXY_cjs.Transaction({ version: 0 });
|
|
22155
22191
|
tx.addInput({
|
|
22156
22192
|
txid: toSpend.id,
|
|
22157
22193
|
index: 0,
|
|
@@ -22165,12 +22201,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
|
22165
22201
|
});
|
|
22166
22202
|
tx.addOutput({
|
|
22167
22203
|
amount: 0n,
|
|
22168
|
-
script:
|
|
22204
|
+
script: chunkP53OHGXY_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
22169
22205
|
});
|
|
22170
22206
|
return tx;
|
|
22171
22207
|
}
|
|
22172
22208
|
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
22173
|
-
const tx = new
|
|
22209
|
+
const tx = new chunkP53OHGXY_cjs.Transaction({ version: 0 });
|
|
22174
22210
|
tx.addInput({
|
|
22175
22211
|
txid: toSpend.id,
|
|
22176
22212
|
index: 0,
|
|
@@ -22182,7 +22218,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
|
22182
22218
|
});
|
|
22183
22219
|
tx.addOutput({
|
|
22184
22220
|
amount: 0n,
|
|
22185
|
-
script:
|
|
22221
|
+
script: chunkP53OHGXY_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
22186
22222
|
});
|
|
22187
22223
|
return tx;
|
|
22188
22224
|
}
|
|
@@ -22195,7 +22231,7 @@ var RestEmulatorProvider = class {
|
|
|
22195
22231
|
serverUrl;
|
|
22196
22232
|
async getInfo() {
|
|
22197
22233
|
const url = `${this.serverUrl}/v1/info`;
|
|
22198
|
-
const response = await
|
|
22234
|
+
const response = await chunkP53OHGXY_cjs.baseFetch(url);
|
|
22199
22235
|
if (!response.ok) {
|
|
22200
22236
|
const errorText2 = await response.text();
|
|
22201
22237
|
throw new Error(`Failed to get emulator info: ${errorText2}`);
|
|
@@ -22313,7 +22349,7 @@ var RestEmulatorProvider = class {
|
|
|
22313
22349
|
}
|
|
22314
22350
|
};
|
|
22315
22351
|
function finalizeVirtualTx(type, psbtBase64) {
|
|
22316
|
-
const tx =
|
|
22352
|
+
const tx = chunkP53OHGXY_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
22317
22353
|
if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
|
|
22318
22354
|
const input = tx.getInput(0);
|
|
22319
22355
|
if (!input) {
|
|
@@ -22340,14 +22376,14 @@ var ExitPathError = class extends Error {
|
|
|
22340
22376
|
reason;
|
|
22341
22377
|
};
|
|
22342
22378
|
function delayWeight(sequence) {
|
|
22343
|
-
const t =
|
|
22379
|
+
const t = chunkP53OHGXY_cjs.sequenceToTimelock(sequence);
|
|
22344
22380
|
return t.type === "blocks" ? Number(t.value) : Number(t.value) / 600;
|
|
22345
22381
|
}
|
|
22346
22382
|
async function resolveUnilateralPath(params) {
|
|
22347
22383
|
const { vtxo, scriptHex, contractRepository } = params;
|
|
22348
22384
|
const contract = contractRepository ? (await contractRepository.getContracts({ script: scriptHex }))[0] : void 0;
|
|
22349
22385
|
if (contract) {
|
|
22350
|
-
const handler =
|
|
22386
|
+
const handler = chunkCQNX4BTA_cjs.contractHandlers.get(contract.type);
|
|
22351
22387
|
if (!handler) {
|
|
22352
22388
|
throw new ExitPathError(
|
|
22353
22389
|
"no-handler",
|
|
@@ -22370,12 +22406,12 @@ async function resolveUnilateralPath(params) {
|
|
|
22370
22406
|
paths.sort((a, b) => delayWeight(a.sequence) - delayWeight(b.sequence));
|
|
22371
22407
|
return { selection: paths[0], label: `${contract.type}:unilateral` };
|
|
22372
22408
|
}
|
|
22373
|
-
const decoded =
|
|
22409
|
+
const decoded = chunkP53OHGXY_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
22374
22410
|
let best;
|
|
22375
22411
|
for (const exit of decoded.exitPaths()) {
|
|
22376
22412
|
const leaf = decoded.findLeaf(base.hex.encode(exit.script));
|
|
22377
22413
|
if (!leaf) continue;
|
|
22378
|
-
const sequence =
|
|
22414
|
+
const sequence = chunkP53OHGXY_cjs.timelockToSequence(exit.params.timelock);
|
|
22379
22415
|
const weight = delayWeight(sequence);
|
|
22380
22416
|
if (!best || weight < best.weight) {
|
|
22381
22417
|
best = { selection: { leaf, sequence }, weight };
|
|
@@ -22595,7 +22631,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
22595
22631
|
let totalAmount = 0n;
|
|
22596
22632
|
const txWeightEstimator = TxWeightEstimator.create();
|
|
22597
22633
|
for (const vtxo of vtxos) {
|
|
22598
|
-
if (!
|
|
22634
|
+
if (!chunkP53OHGXY_cjs.canSweepOnchain(vtxo)) {
|
|
22599
22635
|
throw new Error(
|
|
22600
22636
|
`Vtxo ${vtxo.txid}:${vtxo.vout} cannot be swept onchain: it is not fully unrolled (use unroll first), or its exit output was already spent`
|
|
22601
22637
|
);
|
|
@@ -22606,14 +22642,14 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
22606
22642
|
}
|
|
22607
22643
|
const resolved = await resolveUnilateralPath({
|
|
22608
22644
|
vtxo,
|
|
22609
|
-
scriptHex: base.hex.encode(
|
|
22645
|
+
scriptHex: base.hex.encode(chunkP53OHGXY_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
22610
22646
|
contractRepository: wallet.contractRepository,
|
|
22611
22647
|
walletPubKeyHex: base.hex.encode(await wallet.identity.xOnlyPublicKey()),
|
|
22612
22648
|
currentTime: Date.now()
|
|
22613
22649
|
});
|
|
22614
22650
|
const spendingLeaf = resolved.selection.leaf;
|
|
22615
22651
|
const sequence = resolved.selection.sequence;
|
|
22616
|
-
const timelock =
|
|
22652
|
+
const timelock = chunkP53OHGXY_cjs.sequenceToTimelock(sequence);
|
|
22617
22653
|
const elapsed = timelock.type === "blocks" ? chainTip.height >= txStatus.blockHeight + Number(timelock.value) : chainTip.time >= txStatus.blockTime + Number(timelock.value);
|
|
22618
22654
|
if (!elapsed) {
|
|
22619
22655
|
throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
|
|
@@ -22626,7 +22662,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
22626
22662
|
sequence,
|
|
22627
22663
|
witnessUtxo: {
|
|
22628
22664
|
amount: BigInt(vtxo.value),
|
|
22629
|
-
script:
|
|
22665
|
+
script: chunkP53OHGXY_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
|
|
22630
22666
|
},
|
|
22631
22667
|
sighashType: btcSigner.SigHash.DEFAULT
|
|
22632
22668
|
});
|
|
@@ -22636,7 +22672,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
22636
22672
|
btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
|
|
22637
22673
|
);
|
|
22638
22674
|
}
|
|
22639
|
-
const tx = new
|
|
22675
|
+
const tx = new chunkP53OHGXY_cjs.Transaction({ version: 2 });
|
|
22640
22676
|
for (const input of inputs) {
|
|
22641
22677
|
tx.addInput(input);
|
|
22642
22678
|
}
|
|
@@ -22719,7 +22755,7 @@ async function buildSignedSweep(params) {
|
|
|
22719
22755
|
`uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
|
|
22720
22756
|
);
|
|
22721
22757
|
}
|
|
22722
|
-
const tx = new
|
|
22758
|
+
const tx = new chunkP53OHGXY_cjs.Transaction({ version: 2 });
|
|
22723
22759
|
tx.addInput({
|
|
22724
22760
|
txid: vtxo.txid,
|
|
22725
22761
|
index: vtxo.vout,
|
|
@@ -22744,7 +22780,7 @@ async function buildSignedSweep(params) {
|
|
|
22744
22780
|
finalScriptWitness: [
|
|
22745
22781
|
tapScriptSig[0][1],
|
|
22746
22782
|
...path.extraWitness,
|
|
22747
|
-
|
|
22783
|
+
chunkP53OHGXY_cjs.scriptFromTapLeafScript(path.leaf),
|
|
22748
22784
|
btcSigner.TaprootControlBlock.encode(controlBlock)
|
|
22749
22785
|
]
|
|
22750
22786
|
});
|
|
@@ -22774,7 +22810,7 @@ async function resolveFeeRate(opts) {
|
|
|
22774
22810
|
}
|
|
22775
22811
|
async function selectExitVtxos(opts) {
|
|
22776
22812
|
if (!opts.vtxos) return opts.wallet.getVtxos();
|
|
22777
|
-
const res = await
|
|
22813
|
+
const res = await chunkP53OHGXY_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
|
|
22778
22814
|
const tapTrees = /* @__PURE__ */ new Map();
|
|
22779
22815
|
const out = [];
|
|
22780
22816
|
for (const vtxo of res.vtxos) {
|
|
@@ -22789,7 +22825,7 @@ async function selectExitVtxos(opts) {
|
|
|
22789
22825
|
`no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
|
|
22790
22826
|
);
|
|
22791
22827
|
}
|
|
22792
|
-
const handler =
|
|
22828
|
+
const handler = chunkCQNX4BTA_cjs.contractHandlers.get(contract.type);
|
|
22793
22829
|
if (!handler) {
|
|
22794
22830
|
throw new Error(`no contract handler registered for type '${contract.type}'`);
|
|
22795
22831
|
}
|
|
@@ -22819,7 +22855,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
22819
22855
|
if (pendingNodes.length > 0) {
|
|
22820
22856
|
const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
|
|
22821
22857
|
for (const psbt of txs) {
|
|
22822
|
-
psbts.set(
|
|
22858
|
+
psbts.set(chunkP53OHGXY_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
22823
22859
|
}
|
|
22824
22860
|
}
|
|
22825
22861
|
const childVsize = Number(
|
|
@@ -22855,7 +22891,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
22855
22891
|
try {
|
|
22856
22892
|
const resolved = await resolveUnilateralPath({
|
|
22857
22893
|
vtxo,
|
|
22858
|
-
scriptHex: base.hex.encode(
|
|
22894
|
+
scriptHex: base.hex.encode(chunkP53OHGXY_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
22859
22895
|
contractRepository: wallet.contractRepository,
|
|
22860
22896
|
walletPubKeyHex,
|
|
22861
22897
|
currentTime: Date.now()
|
|
@@ -22874,7 +22910,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
22874
22910
|
});
|
|
22875
22911
|
continue;
|
|
22876
22912
|
}
|
|
22877
|
-
const t =
|
|
22913
|
+
const t = chunkP53OHGXY_cjs.sequenceToTimelock(resolved.selection.sequence);
|
|
22878
22914
|
const delay = { type: t.type, value: Number(t.value) };
|
|
22879
22915
|
infos.push({ outpoint, value: vtxo.value, sweepFee, path: resolved.label, delay });
|
|
22880
22916
|
sweeps.push({ vtxo, resolved, sweepFee, delay });
|
|
@@ -23275,7 +23311,7 @@ async function prepare(opts) {
|
|
|
23275
23311
|
txid: sweep.vtxo.txid,
|
|
23276
23312
|
vout: sweep.vtxo.vout,
|
|
23277
23313
|
value: sweep.vtxo.value,
|
|
23278
|
-
pkScript:
|
|
23314
|
+
pkScript: chunkP53OHGXY_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
|
|
23279
23315
|
},
|
|
23280
23316
|
path: sweep.resolved.selection,
|
|
23281
23317
|
outputAddress: opts.sweepAddress,
|
|
@@ -23364,7 +23400,7 @@ async function prepare(opts) {
|
|
|
23364
23400
|
if (newFee <= splitterFee) break;
|
|
23365
23401
|
splitterFee = newFee;
|
|
23366
23402
|
}
|
|
23367
|
-
const splitter = new
|
|
23403
|
+
const splitter = new chunkP53OHGXY_cjs.Transaction({ version: 2 });
|
|
23368
23404
|
for (const coin of selected.inputs) {
|
|
23369
23405
|
splitter.addInput({
|
|
23370
23406
|
txid: coin.txid,
|
|
@@ -23508,41 +23544,41 @@ var UnilateralExit = {
|
|
|
23508
23544
|
// src/arkade/index.ts
|
|
23509
23545
|
var arkade_exports = {};
|
|
23510
23546
|
chunk5BLDMQED_cjs.__export(arkade_exports, {
|
|
23511
|
-
ARKADE_OP: () =>
|
|
23512
|
-
ARKADE_OPCODES: () =>
|
|
23513
|
-
ARKADE_OPCODE_NAMES: () =>
|
|
23514
|
-
ARKADE_OPCODE_VALUES: () =>
|
|
23515
|
-
ARKADE_OPS: () =>
|
|
23547
|
+
ARKADE_OP: () => chunkCQNX4BTA_cjs.ARKADE_OP,
|
|
23548
|
+
ARKADE_OPCODES: () => chunkCQNX4BTA_cjs.ARKADE_OPCODES,
|
|
23549
|
+
ARKADE_OPCODE_NAMES: () => chunkCQNX4BTA_cjs.ARKADE_OPCODE_NAMES,
|
|
23550
|
+
ARKADE_OPCODE_VALUES: () => chunkCQNX4BTA_cjs.ARKADE_OPCODE_VALUES,
|
|
23551
|
+
ARKADE_OPS: () => chunkCQNX4BTA_cjs.ARKADE_OPS,
|
|
23516
23552
|
Arkade: () => Arkade,
|
|
23517
23553
|
ArkadeContract: () => ArkadeContract,
|
|
23518
|
-
ArkadeProgramScript: () =>
|
|
23519
|
-
ArkadeScript: () =>
|
|
23554
|
+
ArkadeProgramScript: () => chunkCQNX4BTA_cjs.ArkadeProgramScript,
|
|
23555
|
+
ArkadeScript: () => chunkCQNX4BTA_cjs.ArkadeScript,
|
|
23520
23556
|
ArkadeTransactionBuilder: () => ArkadeTransactionBuilder,
|
|
23521
|
-
BigNum: () =>
|
|
23557
|
+
BigNum: () => chunkCQNX4BTA_cjs.bignum_exports,
|
|
23522
23558
|
OP: () => btcSigner.OP,
|
|
23523
|
-
OPCODE_NAMES: () =>
|
|
23524
|
-
OPCODE_VALUES: () =>
|
|
23525
|
-
SUPPORTED_PROGRAM_VERSION: () =>
|
|
23559
|
+
OPCODE_NAMES: () => chunkCQNX4BTA_cjs.OPCODE_NAMES,
|
|
23560
|
+
OPCODE_VALUES: () => chunkCQNX4BTA_cjs.OPCODE_VALUES,
|
|
23561
|
+
SUPPORTED_PROGRAM_VERSION: () => chunkCQNX4BTA_cjs.SUPPORTED_PROGRAM_VERSION,
|
|
23526
23562
|
Script: () => btcSigner.Script,
|
|
23527
|
-
arkadeScriptHash: () =>
|
|
23528
|
-
arkadeWitnessHash: () =>
|
|
23529
|
-
asmToBytes: () =>
|
|
23530
|
-
bytesToASM: () =>
|
|
23531
|
-
computeArkadeScriptPublicKey: () =>
|
|
23563
|
+
arkadeScriptHash: () => chunkCQNX4BTA_cjs.arkadeScriptHash,
|
|
23564
|
+
arkadeWitnessHash: () => chunkCQNX4BTA_cjs.arkadeWitnessHash,
|
|
23565
|
+
asmToBytes: () => chunkCQNX4BTA_cjs.asmToBytes,
|
|
23566
|
+
bytesToASM: () => chunkCQNX4BTA_cjs.bytesToASM,
|
|
23567
|
+
computeArkadeScriptPublicKey: () => chunkCQNX4BTA_cjs.computeArkadeScriptPublicKey,
|
|
23532
23568
|
createArkadeBatchHandler: () => createArkadeBatchHandler,
|
|
23533
|
-
deserializeArkadeContractParams: () =>
|
|
23534
|
-
fromASM: () =>
|
|
23535
|
-
getOpcodeName: () =>
|
|
23536
|
-
getOpcodeValue: () =>
|
|
23537
|
-
parseArtifact: () =>
|
|
23538
|
-
resolveAsm: () =>
|
|
23539
|
-
serializeArkadeContractParams: () =>
|
|
23540
|
-
stringifyArtifact: () =>
|
|
23541
|
-
toASM: () =>
|
|
23542
|
-
validateProgram: () =>
|
|
23543
|
-
witnessRefToBytes: () =>
|
|
23569
|
+
deserializeArkadeContractParams: () => chunkCQNX4BTA_cjs.deserializeArkadeContractParams,
|
|
23570
|
+
fromASM: () => chunkCQNX4BTA_cjs.fromASM,
|
|
23571
|
+
getOpcodeName: () => chunkCQNX4BTA_cjs.getOpcodeName,
|
|
23572
|
+
getOpcodeValue: () => chunkCQNX4BTA_cjs.getOpcodeValue,
|
|
23573
|
+
parseArtifact: () => chunkCQNX4BTA_cjs.parseArtifact,
|
|
23574
|
+
resolveAsm: () => chunkCQNX4BTA_cjs.resolveAsm,
|
|
23575
|
+
serializeArkadeContractParams: () => chunkCQNX4BTA_cjs.serializeArkadeContractParams,
|
|
23576
|
+
stringifyArtifact: () => chunkCQNX4BTA_cjs.stringifyArtifact,
|
|
23577
|
+
toASM: () => chunkCQNX4BTA_cjs.toASM,
|
|
23578
|
+
validateProgram: () => chunkCQNX4BTA_cjs.validateProgram,
|
|
23579
|
+
witnessRefToBytes: () => chunkCQNX4BTA_cjs.witnessRefToBytes
|
|
23544
23580
|
});
|
|
23545
|
-
var isVtxoCoin = (input) =>
|
|
23581
|
+
var isVtxoCoin = (input) => chunkP53OHGXY_cjs.isVirtualCoin(input);
|
|
23546
23582
|
function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
|
|
23547
23583
|
let batchId;
|
|
23548
23584
|
let sweepTapTreeRoot;
|
|
@@ -23563,23 +23599,23 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
23563
23599
|
);
|
|
23564
23600
|
await arkProvider.confirmRegistration(intentId);
|
|
23565
23601
|
batchId = event.id;
|
|
23566
|
-
const sweepTapscript =
|
|
23602
|
+
const sweepTapscript = chunkP53OHGXY_cjs.CSVMultisigTapscript.encode({
|
|
23567
23603
|
timelock,
|
|
23568
|
-
pubkeys: [
|
|
23604
|
+
pubkeys: [chunkCQNX4BTA_cjs.toXOnly(base.hex.decode(info.forfeitPubkey), "forfeit key")]
|
|
23569
23605
|
}).script;
|
|
23570
23606
|
sweepTapTreeRoot = payment_js.tapLeafHash(sweepTapscript);
|
|
23571
23607
|
return { skip: false };
|
|
23572
23608
|
},
|
|
23573
23609
|
onTreeSigningStarted: async (event, vtxoTree) => {
|
|
23574
23610
|
const signerPubKey = await session.getPublicKey();
|
|
23575
|
-
const xonlySignerPubKey =
|
|
23611
|
+
const xonlySignerPubKey = chunkCQNX4BTA_cjs.toXOnly(signerPubKey, "signer key");
|
|
23576
23612
|
const xOnlyPubkeys = event.cosignersPublicKeys.map(
|
|
23577
|
-
(k) => base.hex.encode(
|
|
23613
|
+
(k) => base.hex.encode(chunkCQNX4BTA_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
|
|
23578
23614
|
);
|
|
23579
23615
|
if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
|
|
23580
23616
|
return { skip: true };
|
|
23581
23617
|
}
|
|
23582
|
-
const commitmentTx =
|
|
23618
|
+
const commitmentTx = chunkP53OHGXY_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
|
|
23583
23619
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
23584
23620
|
if (recipients && recipients.length > 0) {
|
|
23585
23621
|
validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
|
|
@@ -23617,7 +23653,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
23617
23653
|
if (connectorTree) {
|
|
23618
23654
|
validateConnectorsTxGraph(event.commitmentTx, connectorTree);
|
|
23619
23655
|
}
|
|
23620
|
-
let commitmentPsbt =
|
|
23656
|
+
let commitmentPsbt = chunkP53OHGXY_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
23621
23657
|
assertFinalCommitmentMatchesValidated(
|
|
23622
23658
|
commitmentPsbt,
|
|
23623
23659
|
validatedCommitmentTxid,
|
|
@@ -23659,7 +23695,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
23659
23695
|
boardingIndices.push(boardingIdx);
|
|
23660
23696
|
continue;
|
|
23661
23697
|
}
|
|
23662
|
-
if (
|
|
23698
|
+
if (chunkP53OHGXY_cjs.isRecoverable(input) || isSubdust(input, info.dust)) {
|
|
23663
23699
|
continue;
|
|
23664
23700
|
}
|
|
23665
23701
|
if (connectorIndex >= connectorLeaves.length) {
|
|
@@ -23680,7 +23716,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
23680
23716
|
index: input.vout,
|
|
23681
23717
|
witnessUtxo: {
|
|
23682
23718
|
amount: BigInt(input.value),
|
|
23683
|
-
script:
|
|
23719
|
+
script: chunkP53OHGXY_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
23684
23720
|
},
|
|
23685
23721
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
23686
23722
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -23771,16 +23807,16 @@ var Arkade = class _Arkade {
|
|
|
23771
23807
|
/** Connect and resolve the server key, checkpoint closure and (if present) the co-signer key. */
|
|
23772
23808
|
static async connect(opts) {
|
|
23773
23809
|
const info = await opts.arkade.getInfo();
|
|
23774
|
-
const serverKey =
|
|
23775
|
-
const checkpoint =
|
|
23776
|
-
const network = opts.network ?? (Object.hasOwn(
|
|
23810
|
+
const serverKey = chunkCQNX4BTA_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
|
|
23811
|
+
const checkpoint = chunkP53OHGXY_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
23812
|
+
const network = opts.network ?? (Object.hasOwn(chunkP53OHGXY_cjs.networks, info.network) ? chunkP53OHGXY_cjs.getNetwork(info.network) : chunkP53OHGXY_cjs.DEFAULT_NETWORK);
|
|
23777
23813
|
let emulatorKey;
|
|
23778
23814
|
if (opts.emulator) {
|
|
23779
|
-
emulatorKey = base.hex.decode(
|
|
23815
|
+
emulatorKey = base.hex.decode(chunkP53OHGXY_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
|
|
23780
23816
|
}
|
|
23781
23817
|
let userKey;
|
|
23782
23818
|
if (opts.identity) {
|
|
23783
|
-
userKey =
|
|
23819
|
+
userKey = chunkCQNX4BTA_cjs.toXOnly(await opts.identity.xOnlyPublicKey(), "identity key");
|
|
23784
23820
|
}
|
|
23785
23821
|
return new _Arkade({
|
|
23786
23822
|
arkProvider: opts.arkade,
|
|
@@ -23806,7 +23842,7 @@ var Arkade = class _Arkade {
|
|
|
23806
23842
|
* key respectively; explicit args always win.
|
|
23807
23843
|
*/
|
|
23808
23844
|
contract(program, args = {}) {
|
|
23809
|
-
const declared = (program.params ?? []).map(
|
|
23845
|
+
const declared = (program.params ?? []).map(chunkCQNX4BTA_cjs.inputName);
|
|
23810
23846
|
if (declared.includes("server") && args.server === void 0) {
|
|
23811
23847
|
args = { ...args, server: this.serverKey };
|
|
23812
23848
|
}
|
|
@@ -23826,7 +23862,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
23826
23862
|
userKey: client.userKey,
|
|
23827
23863
|
emulatorKey: client.emulatorKey
|
|
23828
23864
|
};
|
|
23829
|
-
this.vtxoScript = new
|
|
23865
|
+
this.vtxoScript = new chunkCQNX4BTA_cjs.ArkadeProgramScript(program, args, this.keys);
|
|
23830
23866
|
this.tapTree = this.vtxoScript.encode();
|
|
23831
23867
|
this.compiled = this.vtxoScript.compiled;
|
|
23832
23868
|
}
|
|
@@ -23854,7 +23890,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
23854
23890
|
`ArkadeContract.fromContract: expected contract type 'arkade', got '${contract.type}'`
|
|
23855
23891
|
);
|
|
23856
23892
|
}
|
|
23857
|
-
const typed =
|
|
23893
|
+
const typed = chunkCQNX4BTA_cjs.deserializeArkadeContractParams(contract.params);
|
|
23858
23894
|
return new _ArkadeContract(client, typed.program, typed.args, {
|
|
23859
23895
|
serverKey: typed.serverKey,
|
|
23860
23896
|
userKey: typed.userKey,
|
|
@@ -23895,7 +23931,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
23895
23931
|
toContractParams() {
|
|
23896
23932
|
return {
|
|
23897
23933
|
type: "arkade",
|
|
23898
|
-
params:
|
|
23934
|
+
params: chunkCQNX4BTA_cjs.serializeArkadeContractParams({
|
|
23899
23935
|
program: this.program,
|
|
23900
23936
|
args: this.args,
|
|
23901
23937
|
serverKey: this.keys.serverKey,
|
|
@@ -23945,18 +23981,18 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
23945
23981
|
if (registered) {
|
|
23946
23982
|
const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
|
|
23947
23983
|
return (withVtxos?.vtxos ?? []).filter(
|
|
23948
|
-
(v) => !
|
|
23984
|
+
(v) => !chunkP53OHGXY_cjs.hasTerminalSpend(v) && !v.isUnrolled
|
|
23949
23985
|
);
|
|
23950
23986
|
}
|
|
23951
23987
|
}
|
|
23952
23988
|
if (!this.client.indexer) {
|
|
23953
23989
|
throw new Error("ArkadeContract.getUtxos: an indexer is required");
|
|
23954
23990
|
}
|
|
23955
|
-
const { vtxos } = await
|
|
23991
|
+
const { vtxos } = await chunkP53OHGXY_cjs.getNormalizedVtxos(this.client.indexer, {
|
|
23956
23992
|
scripts: [scriptHex],
|
|
23957
23993
|
spendableOnly: true
|
|
23958
23994
|
});
|
|
23959
|
-
return vtxos.filter((v) => !
|
|
23995
|
+
return vtxos.filter((v) => !chunkP53OHGXY_cjs.hasTerminalSpend(v) && !v.isUnrolled);
|
|
23960
23996
|
}
|
|
23961
23997
|
/** Total spendable balance (requires an indexer). */
|
|
23962
23998
|
async getBalance() {
|
|
@@ -24054,7 +24090,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
24054
24090
|
this.contract.client.checkpoint
|
|
24055
24091
|
);
|
|
24056
24092
|
if (coin.sourceTx) {
|
|
24057
|
-
|
|
24093
|
+
chunkP53OHGXY_cjs.setArkPsbtField(arkTx, 0, chunkP53OHGXY_cjs.PrevArkTxField, coin.sourceTx);
|
|
24058
24094
|
}
|
|
24059
24095
|
if (this.fn.arkadeScript) {
|
|
24060
24096
|
const indexer = this.contract.client.indexer;
|
|
@@ -24071,8 +24107,8 @@ var ArkadeTransactionBuilder = class {
|
|
|
24071
24107
|
}
|
|
24072
24108
|
const condition = (def.tapscript.witness ?? []).map((w) => this.witnessBytes(w));
|
|
24073
24109
|
if (condition.length > 0) {
|
|
24074
|
-
|
|
24075
|
-
|
|
24110
|
+
chunkP53OHGXY_cjs.setArkPsbtField(arkTx, 0, chunkP53OHGXY_cjs.ConditionWitness, condition);
|
|
24111
|
+
chunkP53OHGXY_cjs.setArkPsbtField(checkpoints[0], 0, chunkP53OHGXY_cjs.ConditionWitness, condition);
|
|
24076
24112
|
}
|
|
24077
24113
|
const packets = [];
|
|
24078
24114
|
if (this.assetSpecs.length > 0) {
|
|
@@ -24111,7 +24147,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
24111
24147
|
base.base64.encode(signedArk2.toPSBT()),
|
|
24112
24148
|
signedCps.map((c) => base.base64.encode(c.toPSBT()))
|
|
24113
24149
|
);
|
|
24114
|
-
const txid =
|
|
24150
|
+
const txid = chunkP53OHGXY_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
|
|
24115
24151
|
return {
|
|
24116
24152
|
txid,
|
|
24117
24153
|
signedArkTx: res2.signedArkTx,
|
|
@@ -24170,23 +24206,23 @@ var ArkadeTransactionBuilder = class {
|
|
|
24170
24206
|
}
|
|
24171
24207
|
buildAssetPacket() {
|
|
24172
24208
|
const groups = this.assetSpecs.map((s) => {
|
|
24173
|
-
const id = typeof s.assetId === "string" ?
|
|
24174
|
-
return
|
|
24209
|
+
const id = typeof s.assetId === "string" ? chunkT327OEMV_cjs.AssetId.fromString(s.assetId) : chunkT327OEMV_cjs.AssetId.fromBytes(s.assetId);
|
|
24210
|
+
return chunkT327OEMV_cjs.AssetGroup.create(
|
|
24175
24211
|
id,
|
|
24176
24212
|
null,
|
|
24177
|
-
s.inputs.map((i) =>
|
|
24178
|
-
s.outputs.map((o) =>
|
|
24179
|
-
(s.metadata ?? []).map((m) =>
|
|
24213
|
+
s.inputs.map((i) => chunkT327OEMV_cjs.AssetInput.create(i.vin, i.amount)),
|
|
24214
|
+
s.outputs.map((o) => chunkT327OEMV_cjs.AssetOutput.create(o.vout, o.amount)),
|
|
24215
|
+
(s.metadata ?? []).map((m) => chunkT327OEMV_cjs.Metadata.create(m.key, m.value))
|
|
24180
24216
|
);
|
|
24181
24217
|
});
|
|
24182
|
-
return
|
|
24218
|
+
return chunkT327OEMV_cjs.Packet.create(groups);
|
|
24183
24219
|
}
|
|
24184
24220
|
witnessBytes(ref) {
|
|
24185
|
-
return
|
|
24221
|
+
return chunkCQNX4BTA_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
|
|
24186
24222
|
}
|
|
24187
24223
|
};
|
|
24188
24224
|
function bindInputs(fn, callArgs) {
|
|
24189
|
-
const names = (fn.def.inputs ?? []).map(
|
|
24225
|
+
const names = (fn.def.inputs ?? []).map(chunkCQNX4BTA_cjs.inputName);
|
|
24190
24226
|
if (callArgs.length !== names.length) {
|
|
24191
24227
|
throw new Error(`${fn.name}: expected ${names.length} argument(s), got ${callArgs.length}`);
|
|
24192
24228
|
}
|
|
@@ -24221,6 +24257,7 @@ var BIP21Error = /* @__PURE__ */ ((BIP21Error2) => {
|
|
|
24221
24257
|
BIP21Error2["INVALID_ADDRESS"] = "Invalid address";
|
|
24222
24258
|
return BIP21Error2;
|
|
24223
24259
|
})(BIP21Error || {});
|
|
24260
|
+
var formatAmount = (btc) => btc.toFixed(8).replace(/\.?0+$/, "");
|
|
24224
24261
|
var BIP21 = class _BIP21 {
|
|
24225
24262
|
/**
|
|
24226
24263
|
* Create a BIP21 URI from the provided parameters.
|
|
@@ -24242,7 +24279,7 @@ var BIP21 = class _BIP21 {
|
|
|
24242
24279
|
if (amount < 0) {
|
|
24243
24280
|
continue;
|
|
24244
24281
|
}
|
|
24245
|
-
queryParams[key] =
|
|
24282
|
+
queryParams[key] = formatAmount(amount);
|
|
24246
24283
|
} else if (key === "ark") {
|
|
24247
24284
|
if (typeof value === "string" && (value.startsWith("ark") || value.startsWith("tark"))) {
|
|
24248
24285
|
queryParams[key] = value;
|
|
@@ -24598,17 +24635,17 @@ var walletFeeSource = (wallet) => async () => (await wallet.arkProvider.getInfo(
|
|
|
24598
24635
|
function offchainInputFees(vtxos, fees) {
|
|
24599
24636
|
const estimator = new Estimator(fees?.intentFee ?? {});
|
|
24600
24637
|
return vtxos.reduce(
|
|
24601
|
-
(total, vtxo) => total + estimator.evalOffchainInput(
|
|
24638
|
+
(total, vtxo) => total + estimator.evalOffchainInput(chunkP53OHGXY_cjs.toOffchainInputFeeParams(vtxo)).satoshis,
|
|
24602
24639
|
0
|
|
24603
24640
|
);
|
|
24604
24641
|
}
|
|
24605
24642
|
async function changeOutputFee(wallet, inputs, needed, fees) {
|
|
24606
24643
|
const estimator = new Estimator(fees?.intentFee ?? {});
|
|
24607
24644
|
const net = inputs.reduce(
|
|
24608
|
-
(total, vtxo) => total + BigInt(vtxo.value) - BigInt(estimator.evalOffchainInput(
|
|
24645
|
+
(total, vtxo) => total + BigInt(vtxo.value) - BigInt(estimator.evalOffchainInput(chunkP53OHGXY_cjs.toOffchainInputFeeParams(vtxo)).satoshis),
|
|
24609
24646
|
0n
|
|
24610
24647
|
);
|
|
24611
|
-
const script = base.hex.encode(
|
|
24648
|
+
const script = base.hex.encode(chunkP53OHGXY_cjs.ArkAddress.decode(await wallet.getAddress()).pkScript);
|
|
24612
24649
|
return changeAfterOutputFee(
|
|
24613
24650
|
net - needed,
|
|
24614
24651
|
(amount) => BigInt(estimator.evalOffchainOutput({ amount, script }).satoshis)
|
|
@@ -24908,5 +24945,5 @@ exports.waitForIncomingFunds = waitForIncomingFunds;
|
|
|
24908
24945
|
exports.walletFeeSource = walletFeeSource;
|
|
24909
24946
|
exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
|
|
24910
24947
|
exports.withPrevTxs = withPrevTxs;
|
|
24911
|
-
//# sourceMappingURL=chunk-
|
|
24912
|
-
//# sourceMappingURL=chunk-
|
|
24948
|
+
//# sourceMappingURL=chunk-LHSVPDFJ.cjs.map
|
|
24949
|
+
//# sourceMappingURL=chunk-LHSVPDFJ.cjs.map
|