@arkade-os/sdk 0.4.62 → 0.4.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -0
- 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-B53mOTCw.d.cts → asyncStorageTaskQueue-Chwe60Ce.d.cts} +1 -1
- package/dist/{asyncStorageTaskQueue-Df-CTfTE.d.ts → asyncStorageTaskQueue-Dq_UcvDx.d.ts} +1 -1
- package/dist/{chunk-PWWA4DBL.cjs → chunk-35YIP6OA.cjs} +10 -10
- package/dist/{chunk-PWWA4DBL.cjs.map → chunk-35YIP6OA.cjs.map} +1 -1
- package/dist/{chunk-QRSR4HV4.cjs → chunk-4N45WCSJ.cjs} +17 -17
- package/dist/{chunk-QRSR4HV4.cjs.map → chunk-4N45WCSJ.cjs.map} +1 -1
- package/dist/{chunk-OH2XLTXE.cjs → chunk-FZFSGOTZ.cjs} +3 -3
- package/dist/{chunk-OH2XLTXE.cjs.map → chunk-FZFSGOTZ.cjs.map} +1 -1
- package/dist/{chunk-RMBI6P4N.js → chunk-HQ2DDMQN.js} +3 -3
- package/dist/{chunk-RMBI6P4N.js.map → chunk-HQ2DDMQN.js.map} +1 -1
- package/dist/{chunk-L7S5KC5B.js → chunk-LN2VZP63.js} +3 -3
- package/dist/{chunk-L7S5KC5B.js.map → chunk-LN2VZP63.js.map} +1 -1
- package/dist/{chunk-Z2OZMKFV.cjs → chunk-LPEE2H2M.cjs} +405 -400
- package/dist/chunk-LPEE2H2M.cjs.map +1 -0
- package/dist/{chunk-I6EDUE75.cjs → chunk-RXITDAV4.cjs} +17 -17
- package/dist/{chunk-I6EDUE75.cjs.map → chunk-RXITDAV4.cjs.map} +1 -1
- package/dist/{chunk-I7RLG6VX.js → chunk-USXWE2EJ.js} +4 -4
- package/dist/{chunk-I7RLG6VX.js.map → chunk-USXWE2EJ.js.map} +1 -1
- package/dist/{chunk-2IZW6AEK.js → chunk-WJN2BLEI.js} +10 -5
- package/dist/chunk-WJN2BLEI.js.map +1 -0
- package/dist/{chunk-G53HASDV.cjs → chunk-WXCVS6PD.cjs} +48 -48
- package/dist/{chunk-G53HASDV.cjs.map → chunk-WXCVS6PD.cjs.map} +1 -1
- package/dist/{chunk-URT2RVGB.js → chunk-XJCBV4AA.js} +3 -3
- package/dist/{chunk-URT2RVGB.js.map → chunk-XJCBV4AA.js.map} +1 -1
- package/dist/{chunk-H2ZAJOQA.js → chunk-ZUEGFM3T.js} +4 -4
- package/dist/{chunk-H2ZAJOQA.js.map → chunk-ZUEGFM3T.js.map} +1 -1
- 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-CC1gcvuC.d.cts → delegate-BBQW61ym.d.cts} +1 -1
- package/dist/{delegate-BjYJJsml.d.ts → delegate-Dv_9OVHv.d.ts} +1 -1
- package/dist/{index-C888wFEV.d.ts → index-Bxe9kBFs.d.ts} +2 -2
- package/dist/{index-CwBr7qzV.d.ts → index-CFOMyVMt.d.cts} +19 -2
- package/dist/{index-CwBr7qzV.d.cts → index-CFOMyVMt.d.ts} +19 -2
- package/dist/{index-Cz5_WaQP.d.cts → index-aZycGEsQ.d.cts} +2 -2
- package/dist/index.cjs +268 -268
- package/dist/index.d.cts +19 -9
- package/dist/index.d.ts +19 -9
- 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 +27 -18
- package/dist/repositories/sqlite/index.cjs.map +1 -1
- package/dist/repositories/sqlite/index.d.cts +20 -3
- package/dist/repositories/sqlite/index.d.ts +20 -3
- package/dist/repositories/sqlite/index.js +13 -6
- package/dist/repositories/sqlite/index.js.map +1 -1
- package/dist/{taskRunner-DZWUsSzA.d.ts → taskRunner-BDzWbpct.d.ts} +1 -1
- package/dist/{taskRunner-BMUndClz.d.cts → taskRunner-CIKOS2OO.d.cts} +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/{wallet-H3f14est.d.cts → wallet-C2NvHjWB.d.cts} +2 -2
- package/dist/{wallet-Dpjx6CJ7.d.ts → wallet-DJUnN939.d.ts} +2 -2
- 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-2IZW6AEK.js.map +0 -1
- package/dist/chunk-Z2OZMKFV.cjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkRXITDAV4_cjs = require('./chunk-RXITDAV4.cjs');
|
|
4
|
+
var chunkWXCVS6PD_cjs = require('./chunk-WXCVS6PD.cjs');
|
|
5
|
+
var chunkFZFSGOTZ_cjs = require('./chunk-FZFSGOTZ.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 = chunkFZFSGOTZ_cjs.getArkPsbtFields(tx.root, 0, chunkFZFSGOTZ_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 = chunkFZFSGOTZ_cjs.getArkPsbtFields(g.root, 0, chunkFZFSGOTZ_cjs.CosignerPublicKey).map((c) => c.key);
|
|
244
244
|
const { finalKey } = aggregateKeys(cosigners, true, {
|
|
245
245
|
taprootTweak: this.scriptRoot
|
|
246
246
|
});
|
|
@@ -431,7 +431,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
431
431
|
let network;
|
|
432
432
|
if ("descriptor" in opts && typeof opts.descriptor === "string") {
|
|
433
433
|
descriptor = opts.descriptor;
|
|
434
|
-
network =
|
|
434
|
+
network = chunkWXCVS6PD_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
435
435
|
} else {
|
|
436
436
|
network = opts.isMainnet ?? true ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
437
437
|
descriptor = descriptorsScure.scriptExpressions.trBIP32({
|
|
@@ -529,7 +529,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
529
529
|
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
530
530
|
*/
|
|
531
531
|
isOurs(descriptor) {
|
|
532
|
-
return
|
|
532
|
+
return chunkWXCVS6PD_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
|
|
533
533
|
}
|
|
534
534
|
/**
|
|
535
535
|
* Signs each request with the key derived from its descriptor.
|
|
@@ -578,7 +578,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
578
578
|
}
|
|
579
579
|
// ── internal helpers ─────────────────────────────────────────────
|
|
580
580
|
derivePrivateKeyForDescriptor(descriptor) {
|
|
581
|
-
const network =
|
|
581
|
+
const network = chunkWXCVS6PD_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
582
582
|
const expansion = descriptorsScure.expand({ descriptor, network });
|
|
583
583
|
if (expansion.isRanged) {
|
|
584
584
|
throw new Error(
|
|
@@ -664,7 +664,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
664
664
|
*/
|
|
665
665
|
descriptor;
|
|
666
666
|
constructor(descriptor) {
|
|
667
|
-
const network =
|
|
667
|
+
const network = chunkWXCVS6PD_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
668
668
|
let expansion;
|
|
669
669
|
try {
|
|
670
670
|
expansion = descriptorsScure.expand({ descriptor, network, index: 0 });
|
|
@@ -714,7 +714,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
714
714
|
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
715
715
|
*/
|
|
716
716
|
isOurs(descriptor) {
|
|
717
|
-
return
|
|
717
|
+
return chunkWXCVS6PD_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
|
|
718
718
|
}
|
|
719
719
|
};
|
|
720
720
|
function serializeSeedOwnedSigningIdentity(identity) {
|
|
@@ -876,10 +876,10 @@ var DescriptorIdentity = class {
|
|
|
876
876
|
this.base = base;
|
|
877
877
|
}
|
|
878
878
|
async xOnlyPublicKey() {
|
|
879
|
-
return
|
|
879
|
+
return chunkWXCVS6PD_cjs.deriveDescriptorLeafPubKey(this.descriptor);
|
|
880
880
|
}
|
|
881
881
|
async compressedPublicKey() {
|
|
882
|
-
return
|
|
882
|
+
return chunkWXCVS6PD_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
|
|
883
883
|
}
|
|
884
884
|
async sign(tx, inputIndexes) {
|
|
885
885
|
const [signed] = await this.signer.signWithDescriptor([
|
|
@@ -941,12 +941,12 @@ var ForeignDescriptorError = class extends Error {
|
|
|
941
941
|
};
|
|
942
942
|
async function resolveDescriptorSigner(descriptor, identity, provider) {
|
|
943
943
|
const owner = provider?.isOurs(descriptor) ? provider : isHDCapableIdentity(identity) && identity.isOurs(descriptor) ? identity : void 0;
|
|
944
|
-
if (owner &&
|
|
944
|
+
if (owner && chunkWXCVS6PD_cjs.parseHDDescriptor(descriptor)) {
|
|
945
945
|
return new DescriptorIdentity({ descriptor, signer: owner, base: identity });
|
|
946
946
|
}
|
|
947
947
|
let key;
|
|
948
948
|
try {
|
|
949
|
-
key =
|
|
949
|
+
key = chunkWXCVS6PD_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
950
950
|
} catch {
|
|
951
951
|
throw new ForeignDescriptorError(descriptor);
|
|
952
952
|
}
|
|
@@ -1317,11 +1317,11 @@ function buildSaltedPreimageMessage(xonly, salt) {
|
|
|
1317
1317
|
}
|
|
1318
1318
|
var PREIMAGE_INDEX = 0;
|
|
1319
1319
|
function isPerArtifactDescriptor(descriptor) {
|
|
1320
|
-
return
|
|
1320
|
+
return chunkWXCVS6PD_cjs.parseHDDescriptor(descriptor) !== null;
|
|
1321
1321
|
}
|
|
1322
1322
|
async function provisionDescriptor(wallet) {
|
|
1323
1323
|
const allocated = isHDAllocationCapable(wallet) ? await wallet.getNextSigningDescriptor() : void 0;
|
|
1324
|
-
return allocated ?? await
|
|
1324
|
+
return allocated ?? await chunkWXCVS6PD_cjs.identityDescriptor(wallet.identity);
|
|
1325
1325
|
}
|
|
1326
1326
|
async function provisionRefundKey(wallet) {
|
|
1327
1327
|
const descriptor = await provisionDescriptor(wallet);
|
|
@@ -1369,7 +1369,7 @@ async function contractSigner(wallet, descriptor) {
|
|
|
1369
1369
|
const signer = isHDWalletCapable(wallet) ? await wallet.signerForDescriptor(descriptor) : wallet.identity;
|
|
1370
1370
|
let expected;
|
|
1371
1371
|
try {
|
|
1372
|
-
expected =
|
|
1372
|
+
expected = chunkWXCVS6PD_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
1373
1373
|
} catch (cause) {
|
|
1374
1374
|
throw new ForeignDescriptorError(descriptor, { cause });
|
|
1375
1375
|
}
|
|
@@ -1588,14 +1588,14 @@ var RestDelegateProvider = class {
|
|
|
1588
1588
|
*/
|
|
1589
1589
|
async delegate(intent, forfeitTxs, options) {
|
|
1590
1590
|
const url = `${this.url}/v1/delegate`;
|
|
1591
|
-
const response = await
|
|
1591
|
+
const response = await chunkFZFSGOTZ_cjs.baseFetch(url, {
|
|
1592
1592
|
method: "POST",
|
|
1593
1593
|
headers: {
|
|
1594
1594
|
"Content-Type": "application/json"
|
|
1595
1595
|
},
|
|
1596
1596
|
body: JSON.stringify({
|
|
1597
1597
|
intent: {
|
|
1598
|
-
message:
|
|
1598
|
+
message: chunkFZFSGOTZ_cjs.Intent.encodeMessage(intent.message),
|
|
1599
1599
|
proof: intent.proof
|
|
1600
1600
|
},
|
|
1601
1601
|
forfeit_txs: forfeitTxs,
|
|
@@ -1615,7 +1615,7 @@ var RestDelegateProvider = class {
|
|
|
1615
1615
|
*/
|
|
1616
1616
|
async getDelegateInfo() {
|
|
1617
1617
|
const url = `${this.url}/v1/delegator/info`;
|
|
1618
|
-
const response = await
|
|
1618
|
+
const response = await chunkFZFSGOTZ_cjs.rateGate.runHttp(url, () => chunkFZFSGOTZ_cjs.baseFetch(url));
|
|
1619
1619
|
if (!response.ok) {
|
|
1620
1620
|
const errorText2 = await response.text();
|
|
1621
1621
|
throw new Error(`Failed to get delegate info: ${errorText2}`);
|
|
@@ -1642,7 +1642,7 @@ var ESPLORA_URL = {
|
|
|
1642
1642
|
regtest: "http://localhost:3000/api"
|
|
1643
1643
|
};
|
|
1644
1644
|
var EsploraProvider = class {
|
|
1645
|
-
constructor(baseUrl = ESPLORA_URL[
|
|
1645
|
+
constructor(baseUrl = ESPLORA_URL[chunkFZFSGOTZ_cjs.DEFAULT_NETWORK_NAME], opts) {
|
|
1646
1646
|
this.baseUrl = baseUrl;
|
|
1647
1647
|
this.pollingInterval = opts?.pollingInterval ?? 15e3;
|
|
1648
1648
|
this.forcePolling = opts?.forcePolling ?? false;
|
|
@@ -1651,14 +1651,14 @@ var EsploraProvider = class {
|
|
|
1651
1651
|
pollingInterval;
|
|
1652
1652
|
forcePolling;
|
|
1653
1653
|
async getCoins(address) {
|
|
1654
|
-
const response = await
|
|
1654
|
+
const response = await chunkFZFSGOTZ_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
|
|
1655
1655
|
if (!response.ok) {
|
|
1656
1656
|
throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
|
|
1657
1657
|
}
|
|
1658
1658
|
return response.json();
|
|
1659
1659
|
}
|
|
1660
1660
|
async getFeeRate() {
|
|
1661
|
-
const response = await
|
|
1661
|
+
const response = await chunkFZFSGOTZ_cjs.baseFetch(`${this.baseUrl}/fee-estimates`);
|
|
1662
1662
|
if (response.status === 404) {
|
|
1663
1663
|
return void 0;
|
|
1664
1664
|
}
|
|
@@ -1679,7 +1679,7 @@ var EsploraProvider = class {
|
|
|
1679
1679
|
}
|
|
1680
1680
|
}
|
|
1681
1681
|
async getTxOutspends(txid) {
|
|
1682
|
-
const response = await
|
|
1682
|
+
const response = await chunkFZFSGOTZ_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
|
|
1683
1683
|
if (!response.ok) {
|
|
1684
1684
|
const error = await response.text();
|
|
1685
1685
|
throw new Error(`Failed to get transaction outspends: ${error}`);
|
|
@@ -1687,7 +1687,7 @@ var EsploraProvider = class {
|
|
|
1687
1687
|
return response.json();
|
|
1688
1688
|
}
|
|
1689
1689
|
async getTransactions(address) {
|
|
1690
|
-
const response = await
|
|
1690
|
+
const response = await chunkFZFSGOTZ_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
|
|
1691
1691
|
if (!response.ok) {
|
|
1692
1692
|
const error = await response.text();
|
|
1693
1693
|
throw new Error(`Failed to get transactions: ${error}`);
|
|
@@ -1695,7 +1695,7 @@ var EsploraProvider = class {
|
|
|
1695
1695
|
return response.json();
|
|
1696
1696
|
}
|
|
1697
1697
|
async getTxStatus(txid) {
|
|
1698
|
-
const txresponse = await
|
|
1698
|
+
const txresponse = await chunkFZFSGOTZ_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
|
|
1699
1699
|
if (!txresponse.ok) {
|
|
1700
1700
|
throw new Error(txresponse.statusText);
|
|
1701
1701
|
}
|
|
@@ -1703,7 +1703,7 @@ var EsploraProvider = class {
|
|
|
1703
1703
|
if (!tx.status.confirmed) {
|
|
1704
1704
|
return { confirmed: false };
|
|
1705
1705
|
}
|
|
1706
|
-
const response = await
|
|
1706
|
+
const response = await chunkFZFSGOTZ_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
|
|
1707
1707
|
if (!response.ok) {
|
|
1708
1708
|
throw new Error(`Failed to get transaction status: ${response.statusText}`);
|
|
1709
1709
|
}
|
|
@@ -1787,7 +1787,7 @@ var EsploraProvider = class {
|
|
|
1787
1787
|
return stopFunc;
|
|
1788
1788
|
}
|
|
1789
1789
|
async getChainTip() {
|
|
1790
|
-
const tipBlocks = await
|
|
1790
|
+
const tipBlocks = await chunkFZFSGOTZ_cjs.baseFetch(`${this.baseUrl}/blocks`);
|
|
1791
1791
|
if (!tipBlocks.ok) {
|
|
1792
1792
|
throw new Error(`Failed to get chain tip: ${tipBlocks.statusText}`);
|
|
1793
1793
|
}
|
|
@@ -1806,7 +1806,7 @@ var EsploraProvider = class {
|
|
|
1806
1806
|
};
|
|
1807
1807
|
}
|
|
1808
1808
|
async broadcastPackage(parent, child) {
|
|
1809
|
-
const response = await
|
|
1809
|
+
const response = await chunkFZFSGOTZ_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
|
|
1810
1810
|
method: "POST",
|
|
1811
1811
|
headers: {
|
|
1812
1812
|
"Content-Type": "application/json"
|
|
@@ -1820,7 +1820,7 @@ var EsploraProvider = class {
|
|
|
1820
1820
|
return response.json();
|
|
1821
1821
|
}
|
|
1822
1822
|
async broadcastTx(tx) {
|
|
1823
|
-
const response = await
|
|
1823
|
+
const response = await chunkFZFSGOTZ_cjs.baseFetch(`${this.baseUrl}/tx`, {
|
|
1824
1824
|
method: "POST",
|
|
1825
1825
|
headers: {
|
|
1826
1826
|
"Content-Type": "text/plain"
|
|
@@ -1982,7 +1982,7 @@ function findP2AOutput(tx) {
|
|
|
1982
1982
|
var CHILD_DUST_AMOUNT = 546;
|
|
1983
1983
|
function buildAnchorChild(params) {
|
|
1984
1984
|
const { parent, feeRate, fundingCoins, changeAddress, tapInternalKey, network } = params;
|
|
1985
|
-
const child = new
|
|
1985
|
+
const child = new chunkFZFSGOTZ_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
|
|
1986
1986
|
child.addInput(findP2AOutput(parent));
|
|
1987
1987
|
const estimator = TxWeightEstimator.create().addP2AInput();
|
|
1988
1988
|
for (const _ of fundingCoins) {
|
|
@@ -2030,7 +2030,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
|
|
|
2030
2030
|
);
|
|
2031
2031
|
}
|
|
2032
2032
|
function buildForfeitTxWithOutput(inputs, output, txLocktime) {
|
|
2033
|
-
const tx = new
|
|
2033
|
+
const tx = new chunkFZFSGOTZ_cjs.Transaction({
|
|
2034
2034
|
version: 3,
|
|
2035
2035
|
lockTime: txLocktime
|
|
2036
2036
|
});
|
|
@@ -2106,7 +2106,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
|
|
|
2106
2106
|
if (previousScriptKey.length !== 32) {
|
|
2107
2107
|
throw new Error(`parent output ${childIndex} has invalid script`);
|
|
2108
2108
|
}
|
|
2109
|
-
const cosigners =
|
|
2109
|
+
const cosigners = chunkFZFSGOTZ_cjs.getArkPsbtFields(child.root, 0, chunkFZFSGOTZ_cjs.CosignerPublicKey);
|
|
2110
2110
|
if (cosigners.length === 0) {
|
|
2111
2111
|
throw ErrMissingCosignersPublicKeys;
|
|
2112
2112
|
}
|
|
@@ -2164,7 +2164,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
2164
2164
|
return new _EmulatorPacket(entries);
|
|
2165
2165
|
}
|
|
2166
2166
|
static fromBytes(data) {
|
|
2167
|
-
const reader = new
|
|
2167
|
+
const reader = new chunkRXITDAV4_cjs.BufferReader(data);
|
|
2168
2168
|
const entryCount = reader.readCompactSize();
|
|
2169
2169
|
const entries = [];
|
|
2170
2170
|
for (let i = 0; i < entryCount; i++) {
|
|
@@ -2182,7 +2182,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
2182
2182
|
return _EmulatorPacket.PACKET_TYPE;
|
|
2183
2183
|
}
|
|
2184
2184
|
serialize() {
|
|
2185
|
-
const writer = new
|
|
2185
|
+
const writer = new chunkRXITDAV4_cjs.BufferWriter();
|
|
2186
2186
|
writer.writeCompactSize(this.entries.length);
|
|
2187
2187
|
for (const entry of this.entries) {
|
|
2188
2188
|
writer.writeUint16LE(entry.vin);
|
|
@@ -2269,7 +2269,7 @@ var Extension = class _Extension {
|
|
|
2269
2269
|
`expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
|
|
2270
2270
|
);
|
|
2271
2271
|
}
|
|
2272
|
-
const reader = new
|
|
2272
|
+
const reader = new chunkRXITDAV4_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
|
|
2273
2273
|
const packets = [];
|
|
2274
2274
|
while (reader.remaining() > 0) {
|
|
2275
2275
|
const packetType = reader.readByte();
|
|
@@ -2343,7 +2343,7 @@ var Extension = class _Extension {
|
|
|
2343
2343
|
*/
|
|
2344
2344
|
getAssetPacket() {
|
|
2345
2345
|
for (const p of this.packets) {
|
|
2346
|
-
if (p instanceof
|
|
2346
|
+
if (p instanceof chunkRXITDAV4_cjs.Packet) {
|
|
2347
2347
|
return p;
|
|
2348
2348
|
}
|
|
2349
2349
|
}
|
|
@@ -2381,8 +2381,8 @@ var Extension = class _Extension {
|
|
|
2381
2381
|
};
|
|
2382
2382
|
function parsePacket(packetType, data) {
|
|
2383
2383
|
switch (packetType) {
|
|
2384
|
-
case
|
|
2385
|
-
return
|
|
2384
|
+
case chunkRXITDAV4_cjs.Packet.PACKET_TYPE:
|
|
2385
|
+
return chunkRXITDAV4_cjs.Packet.fromBytes(data);
|
|
2386
2386
|
case EmulatorPacket.PACKET_TYPE:
|
|
2387
2387
|
return EmulatorPacket.fromBytes(data);
|
|
2388
2388
|
default:
|
|
@@ -2429,16 +2429,16 @@ function buildOpReturnScript(data) {
|
|
|
2429
2429
|
}
|
|
2430
2430
|
return script;
|
|
2431
2431
|
}
|
|
2432
|
-
var ErrOffchainOutputNotFound = (address) => new
|
|
2433
|
-
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new
|
|
2432
|
+
var ErrOffchainOutputNotFound = (address) => new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
|
|
2433
|
+
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
2434
2434
|
`invalid asset output amount for ${assetId}: got ${got}, want ${want}`
|
|
2435
2435
|
);
|
|
2436
|
-
var ErrAssetGroupNotFound = (assetId) => new
|
|
2437
|
-
var ErrAssetOutputNotFound = (assetId, outputIndex) => new
|
|
2436
|
+
var ErrAssetGroupNotFound = (assetId) => new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
|
|
2437
|
+
var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
2438
2438
|
`asset output not found in asset group ${assetId} at index ${outputIndex}`
|
|
2439
2439
|
);
|
|
2440
|
-
var ErrOnchainOutputNotFound = (address) => new
|
|
2441
|
-
var ErrUnvalidatedOffchainOutput = (address) => new
|
|
2440
|
+
var ErrOnchainOutputNotFound = (address) => new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
|
|
2441
|
+
var ErrUnvalidatedOffchainOutput = (address) => new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
2442
2442
|
`offchain output ${address} cannot be validated: virtual output tree signing did not run`
|
|
2443
2443
|
);
|
|
2444
2444
|
var ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
|
|
@@ -2447,7 +2447,7 @@ var ErrInvalidOffchainOutputAmount = (address) => new Error(`invalid offchain ou
|
|
|
2447
2447
|
function assertFinalCommitmentMatchesValidated(finalCommitmentTx, validatedCommitmentTxid, context) {
|
|
2448
2448
|
if (!validatedCommitmentTxid) return;
|
|
2449
2449
|
if (finalCommitmentTx.id === validatedCommitmentTxid) return;
|
|
2450
|
-
throw new
|
|
2450
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
2451
2451
|
`${context}: finalization commitment tx ${finalCommitmentTx.id} differs from the validated commitment tx ${validatedCommitmentTxid}`
|
|
2452
2452
|
);
|
|
2453
2453
|
}
|
|
@@ -2457,7 +2457,7 @@ function validateBatchRecipients(commitmentTx, vtxoTreeLeaves, recipients, netwo
|
|
|
2457
2457
|
for (const recipient of recipients) {
|
|
2458
2458
|
let arkAddress;
|
|
2459
2459
|
try {
|
|
2460
|
-
arkAddress =
|
|
2460
|
+
arkAddress = chunkFZFSGOTZ_cjs.ArkAddress.decode(recipient.address);
|
|
2461
2461
|
} catch {
|
|
2462
2462
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
2463
2463
|
continue;
|
|
@@ -2469,7 +2469,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
|
|
|
2469
2469
|
const usedOnchainOutputs = /* @__PURE__ */ new Set();
|
|
2470
2470
|
for (const recipient of recipients) {
|
|
2471
2471
|
try {
|
|
2472
|
-
|
|
2472
|
+
chunkFZFSGOTZ_cjs.ArkAddress.decode(recipient.address);
|
|
2473
2473
|
} catch {
|
|
2474
2474
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
2475
2475
|
continue;
|
|
@@ -2585,6 +2585,7 @@ async function buildActivities(txs, resolvers) {
|
|
|
2585
2585
|
groupId: a.groupId,
|
|
2586
2586
|
label: a.label ?? b.label,
|
|
2587
2587
|
kind: a.kind ?? b.kind,
|
|
2588
|
+
outcome: a.outcome ?? b.outcome,
|
|
2588
2589
|
metadata: { ...b.metadata, ...a.metadata },
|
|
2589
2590
|
amount: a.amount ?? b.amount
|
|
2590
2591
|
});
|
|
@@ -2622,6 +2623,7 @@ async function buildActivities(txs, resolvers) {
|
|
|
2622
2623
|
b.intent = {
|
|
2623
2624
|
label: b.intent?.label ?? m.label,
|
|
2624
2625
|
kind: b.intent?.kind ?? m.kind,
|
|
2626
|
+
outcome: b.intent?.outcome ?? m.outcome,
|
|
2625
2627
|
metadata: { ...m.metadata, ...b.intent?.metadata }
|
|
2626
2628
|
};
|
|
2627
2629
|
b.members.push({ tx, amount: signedAmount(tx, m.amount ?? tx.amount) });
|
|
@@ -2700,7 +2702,7 @@ function assetMintResolver() {
|
|
|
2700
2702
|
if (!tx.assets?.length || !tx.key.arkTxid) return void 0;
|
|
2701
2703
|
const minted = tx.assets.filter((a) => {
|
|
2702
2704
|
try {
|
|
2703
|
-
return base.hex.encode(
|
|
2705
|
+
return base.hex.encode(chunkRXITDAV4_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
|
|
2704
2706
|
} catch {
|
|
2705
2707
|
return false;
|
|
2706
2708
|
}
|
|
@@ -2743,7 +2745,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2743
2745
|
const existing = inputsByAssetId.get(asset.assetId);
|
|
2744
2746
|
inputsByAssetId.set(asset.assetId, [
|
|
2745
2747
|
...existing ?? [],
|
|
2746
|
-
|
|
2748
|
+
chunkRXITDAV4_cjs.AssetInput.create(inputIndex, asset.amount)
|
|
2747
2749
|
]);
|
|
2748
2750
|
}
|
|
2749
2751
|
}
|
|
@@ -2755,7 +2757,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2755
2757
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
2756
2758
|
outputsByAssetId.set(asset.assetId, [
|
|
2757
2759
|
...existing ?? [],
|
|
2758
|
-
|
|
2760
|
+
chunkRXITDAV4_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
2759
2761
|
]);
|
|
2760
2762
|
}
|
|
2761
2763
|
}
|
|
@@ -2766,7 +2768,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2766
2768
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
2767
2769
|
outputsByAssetId.set(asset.assetId, [
|
|
2768
2770
|
...existing ?? [],
|
|
2769
|
-
|
|
2771
|
+
chunkRXITDAV4_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
2770
2772
|
]);
|
|
2771
2773
|
}
|
|
2772
2774
|
}
|
|
@@ -2775,11 +2777,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2775
2777
|
for (const assetIdStr of allAssetIds) {
|
|
2776
2778
|
const inputs = inputsByAssetId.get(assetIdStr);
|
|
2777
2779
|
const outputs = outputsByAssetId.get(assetIdStr);
|
|
2778
|
-
const assetId =
|
|
2779
|
-
const group =
|
|
2780
|
+
const assetId = chunkRXITDAV4_cjs.AssetId.fromString(assetIdStr);
|
|
2781
|
+
const group = chunkRXITDAV4_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
|
|
2780
2782
|
groups.push(group);
|
|
2781
2783
|
}
|
|
2782
|
-
return
|
|
2784
|
+
return chunkRXITDAV4_cjs.Packet.create(groups);
|
|
2783
2785
|
}
|
|
2784
2786
|
function selectCoinsWithAsset(coins, assetId, requiredAmount) {
|
|
2785
2787
|
const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
|
|
@@ -2864,13 +2866,13 @@ var toTimelock = (value) => ({
|
|
|
2864
2866
|
var toSeconds = (t) => t.type === "seconds" ? t.value : t.value * NOMINAL_BLOCK_SECONDS;
|
|
2865
2867
|
function assertTimelockInPolicy(timelock, policy, label, overrideOption) {
|
|
2866
2868
|
if (policy.requireSeconds && timelock.type === "blocks") {
|
|
2867
|
-
throw new
|
|
2869
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
2868
2870
|
`${label} rejected: block-typed timelocks are not accepted (got ${timelock.value})`
|
|
2869
2871
|
);
|
|
2870
2872
|
}
|
|
2871
2873
|
const seconds = toSeconds(timelock);
|
|
2872
2874
|
if (seconds < policy.minSeconds) {
|
|
2873
|
-
throw new
|
|
2875
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
2874
2876
|
`${label} rejected: ${timelock.value} ${timelock.type} is below the ${policy.minSeconds}s floor; pass ${overrideOption}: ${seconds}n to Wallet.create to lower it`
|
|
2875
2877
|
);
|
|
2876
2878
|
}
|
|
@@ -2891,7 +2893,7 @@ function resolveBatchExpiryPolicy(network, overrides) {
|
|
|
2891
2893
|
}
|
|
2892
2894
|
function assertValidBatchExpiry(batchExpiry, policy) {
|
|
2893
2895
|
if (policy.advertisedVtxoTreeExpiry !== void 0 && batchExpiry !== policy.advertisedVtxoTreeExpiry) {
|
|
2894
|
-
throw new
|
|
2896
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
2895
2897
|
`batch expiry rejected: ${batchExpiry} does not match the advertised vtxoTreeExpiry ${policy.advertisedVtxoTreeExpiry}`
|
|
2896
2898
|
);
|
|
2897
2899
|
}
|
|
@@ -2921,21 +2923,21 @@ function resolveCheckpointExitDelayPolicy(network, overrides) {
|
|
|
2921
2923
|
function assertValidServerUnrollScript(checkpointTapscript, policy) {
|
|
2922
2924
|
let script;
|
|
2923
2925
|
try {
|
|
2924
|
-
script =
|
|
2926
|
+
script = chunkFZFSGOTZ_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
|
|
2925
2927
|
} catch (e) {
|
|
2926
|
-
throw new
|
|
2928
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
2927
2929
|
`checkpoint exit delay rejected: invalid checkpointTapscript from server (${e instanceof Error ? e.message : String(e)})`
|
|
2928
2930
|
);
|
|
2929
2931
|
}
|
|
2930
2932
|
if (policy.advertisedForfeitPubkey !== void 0) {
|
|
2931
2933
|
const { pubkeys } = script.params;
|
|
2932
2934
|
if (pubkeys.length !== 1) {
|
|
2933
|
-
throw new
|
|
2935
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
2934
2936
|
`checkpoint exit delay rejected: checkpointTapscript must commit to exactly one pubkey, got ${pubkeys.length} [${pubkeys.map(base.hex.encode).join(", ")}]`
|
|
2935
2937
|
);
|
|
2936
2938
|
}
|
|
2937
2939
|
if (!utils_js.equalBytes(pubkeys[0], policy.advertisedForfeitPubkey)) {
|
|
2938
|
-
throw new
|
|
2940
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
2939
2941
|
`checkpoint exit delay rejected: checkpointTapscript pubkey ${base.hex.encode(pubkeys[0])} does not match the advertised forfeitPubkey ${base.hex.encode(policy.advertisedForfeitPubkey)}`
|
|
2940
2942
|
);
|
|
2941
2943
|
}
|
|
@@ -2979,8 +2981,8 @@ function buildOffchainTx(inputs, outputs, serverUnrollScript) {
|
|
|
2979
2981
|
function buildVirtualTx(inputs, outputs) {
|
|
2980
2982
|
let lockTime = 0n;
|
|
2981
2983
|
for (const input of inputs) {
|
|
2982
|
-
const tapscript =
|
|
2983
|
-
if (
|
|
2984
|
+
const tapscript = chunkFZFSGOTZ_cjs.decodeTapscript(chunkFZFSGOTZ_cjs.scriptFromTapLeafScript(input.tapLeafScript));
|
|
2985
|
+
if (chunkFZFSGOTZ_cjs.CLTVMultisigTapscript.is(tapscript)) {
|
|
2984
2986
|
if (lockTime !== 0n) {
|
|
2985
2987
|
if (isSeconds(lockTime) !== isSeconds(tapscript.params.absoluteTimelock)) {
|
|
2986
2988
|
throw new Error("cannot mix seconds and blocks locktime");
|
|
@@ -2991,7 +2993,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
2991
2993
|
}
|
|
2992
2994
|
}
|
|
2993
2995
|
}
|
|
2994
|
-
const tx = new
|
|
2996
|
+
const tx = new chunkFZFSGOTZ_cjs.Transaction({
|
|
2995
2997
|
version: 3,
|
|
2996
2998
|
lockTime: Number(lockTime)
|
|
2997
2999
|
});
|
|
@@ -3001,12 +3003,12 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3001
3003
|
index: input.vout,
|
|
3002
3004
|
sequence: lockTime ? btcSigner.DEFAULT_SEQUENCE - 1 : void 0,
|
|
3003
3005
|
witnessUtxo: {
|
|
3004
|
-
script:
|
|
3006
|
+
script: chunkFZFSGOTZ_cjs.VtxoScript.decode(input.tapTree).pkScript,
|
|
3005
3007
|
amount: BigInt(input.value)
|
|
3006
3008
|
},
|
|
3007
3009
|
tapLeafScript: [input.tapLeafScript]
|
|
3008
3010
|
});
|
|
3009
|
-
|
|
3011
|
+
chunkFZFSGOTZ_cjs.setArkPsbtField(tx, i, chunkFZFSGOTZ_cjs.VtxoTaprootTree, input.tapTree);
|
|
3010
3012
|
}
|
|
3011
3013
|
for (const output of outputs) {
|
|
3012
3014
|
tx.addOutput(output);
|
|
@@ -3015,8 +3017,8 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3015
3017
|
return tx;
|
|
3016
3018
|
}
|
|
3017
3019
|
function buildCheckpointTx(vtxo, serverUnrollScript) {
|
|
3018
|
-
const collaborativeClosure =
|
|
3019
|
-
const checkpointVtxoScript = new
|
|
3020
|
+
const collaborativeClosure = chunkFZFSGOTZ_cjs.decodeTapscript(chunkFZFSGOTZ_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
|
|
3021
|
+
const checkpointVtxoScript = new chunkFZFSGOTZ_cjs.VtxoScript([
|
|
3020
3022
|
serverUnrollScript.script,
|
|
3021
3023
|
collaborativeClosure.script
|
|
3022
3024
|
]);
|
|
@@ -3169,7 +3171,7 @@ function combineTapscriptSigs(signedTx, originalTx) {
|
|
|
3169
3171
|
}
|
|
3170
3172
|
function isValidArkAddress(address) {
|
|
3171
3173
|
try {
|
|
3172
|
-
|
|
3174
|
+
chunkFZFSGOTZ_cjs.ArkAddress.decode(address);
|
|
3173
3175
|
return true;
|
|
3174
3176
|
} catch (e) {
|
|
3175
3177
|
return false;
|
|
@@ -3177,16 +3179,16 @@ function isValidArkAddress(address) {
|
|
|
3177
3179
|
}
|
|
3178
3180
|
function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, context) {
|
|
3179
3181
|
if (serverCheckpointTxs.length !== expectedCheckpoints.length) {
|
|
3180
|
-
throw new
|
|
3182
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
3181
3183
|
`${context} returned ${serverCheckpointTxs.length} checkpoints, expected ${expectedCheckpoints.length}`
|
|
3182
3184
|
);
|
|
3183
3185
|
}
|
|
3184
3186
|
const byTxid = new Map(expectedCheckpoints.map((c) => [c.id, c]));
|
|
3185
3187
|
return serverCheckpointTxs.map((encoded, index) => {
|
|
3186
|
-
const server =
|
|
3188
|
+
const server = chunkFZFSGOTZ_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
|
|
3187
3189
|
const local = byTxid.get(server.id);
|
|
3188
3190
|
if (!local) {
|
|
3189
|
-
throw new
|
|
3191
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
3190
3192
|
`${context} checkpoint ${index} txid ${server.id} does not match any submitted checkpoint`
|
|
3191
3193
|
);
|
|
3192
3194
|
}
|
|
@@ -3196,14 +3198,14 @@ function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, contex
|
|
|
3196
3198
|
}
|
|
3197
3199
|
function assertSubmittedArkTxid(response, signedArkTx, context) {
|
|
3198
3200
|
if (response.arkTxid !== signedArkTx.id) {
|
|
3199
|
-
throw new
|
|
3201
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
3200
3202
|
`${context} returned ark txid ${response.arkTxid}, expected ${signedArkTx.id}`
|
|
3201
3203
|
);
|
|
3202
3204
|
}
|
|
3203
3205
|
if (response.finalArkTx === void 0) return;
|
|
3204
|
-
const finalTxid =
|
|
3206
|
+
const finalTxid = chunkFZFSGOTZ_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
|
|
3205
3207
|
if (finalTxid !== signedArkTx.id) {
|
|
3206
|
-
throw new
|
|
3208
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
3207
3209
|
`${context} returned final ark tx ${finalTxid}, expected ${signedArkTx.id}`
|
|
3208
3210
|
);
|
|
3209
3211
|
}
|
|
@@ -3222,10 +3224,10 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeyHex,
|
|
|
3222
3224
|
[serverPubkeyHex],
|
|
3223
3225
|
void 0,
|
|
3224
3226
|
void 0,
|
|
3225
|
-
payment_js.tapLeafHash(
|
|
3227
|
+
payment_js.tapLeafHash(chunkFZFSGOTZ_cjs.scriptFromTapLeafScript(leaf))
|
|
3226
3228
|
);
|
|
3227
3229
|
} catch (error) {
|
|
3228
|
-
throw new
|
|
3230
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
3229
3231
|
`${context}: input ${inputIndex} is not signed by the server on the leaf being spent (${error instanceof Error ? error.message : String(error)})`
|
|
3230
3232
|
);
|
|
3231
3233
|
}
|
|
@@ -3234,20 +3236,20 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
3234
3236
|
const byOutpoint = new Map(inputs.map((input) => [`${input.txid}:${input.vout}`, input]));
|
|
3235
3237
|
for (const [index, checkpoint] of checkpoints.entries()) {
|
|
3236
3238
|
if (checkpoint.inputsLength !== 1) {
|
|
3237
|
-
throw new
|
|
3239
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
3238
3240
|
`${context}: checkpoint ${index} spends ${checkpoint.inputsLength} inputs, expected 1`
|
|
3239
3241
|
);
|
|
3240
3242
|
}
|
|
3241
3243
|
const spent = checkpoint.getInput(0);
|
|
3242
3244
|
if (!spent.txid || spent.index === void 0) {
|
|
3243
|
-
throw new
|
|
3245
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
3244
3246
|
`${context}: checkpoint ${index} has no input outpoint`
|
|
3245
3247
|
);
|
|
3246
3248
|
}
|
|
3247
3249
|
const outpoint = `${base.hex.encode(spent.txid)}:${spent.index}`;
|
|
3248
3250
|
const input = byOutpoint.get(outpoint);
|
|
3249
3251
|
if (!input) {
|
|
3250
|
-
throw new
|
|
3252
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
3251
3253
|
`${context}: checkpoint ${index} spends ${outpoint}, which is not one of the requested virtual outputs`
|
|
3252
3254
|
);
|
|
3253
3255
|
}
|
|
@@ -3255,7 +3257,7 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
3255
3257
|
(unroll) => buildCheckpointTx(input, unroll).tx.id === checkpoint.id
|
|
3256
3258
|
);
|
|
3257
3259
|
if (!rebuilt) {
|
|
3258
|
-
throw new
|
|
3260
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
3259
3261
|
`${context}: checkpoint ${index} txid ${checkpoint.id} differs from the checkpoint built locally for ${outpoint}`
|
|
3260
3262
|
);
|
|
3261
3263
|
}
|
|
@@ -3282,11 +3284,11 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
3282
3284
|
const verify = options?.verifyServerSignatures;
|
|
3283
3285
|
if (verify) {
|
|
3284
3286
|
if (response.finalArkTx === void 0) {
|
|
3285
|
-
throw new
|
|
3287
|
+
throw new chunkFZFSGOTZ_cjs.ServerResponseMismatchError(
|
|
3286
3288
|
"submitTx: server returned no final ark tx to verify its signatures against"
|
|
3287
3289
|
);
|
|
3288
3290
|
}
|
|
3289
|
-
const finalArkTx =
|
|
3291
|
+
const finalArkTx = chunkFZFSGOTZ_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
|
|
3290
3292
|
const serverPubkeyHex = base.hex.encode(
|
|
3291
3293
|
verify.serverPubkey.length === 33 ? verify.serverPubkey.subarray(1) : verify.serverPubkey
|
|
3292
3294
|
);
|
|
@@ -3345,12 +3347,12 @@ function claimWithPreimageIdentity(identity, preimage) {
|
|
|
3345
3347
|
return {
|
|
3346
3348
|
...identity,
|
|
3347
3349
|
sign: async (tx, inputIndexes) => {
|
|
3348
|
-
const signed =
|
|
3350
|
+
const signed = chunkFZFSGOTZ_cjs.Transaction.fromPSBT(
|
|
3349
3351
|
(await identity.sign(tx.clone(), inputIndexes)).toPSBT()
|
|
3350
3352
|
);
|
|
3351
3353
|
const indexes = inputIndexes ?? Array.from({ length: signed.inputsLength }, (_, i) => i);
|
|
3352
3354
|
for (const index of indexes) {
|
|
3353
|
-
|
|
3355
|
+
chunkFZFSGOTZ_cjs.setArkPsbtField(signed, index, chunkFZFSGOTZ_cjs.ConditionWitness, [preimage]);
|
|
3354
3356
|
}
|
|
3355
3357
|
return signed;
|
|
3356
3358
|
}
|
|
@@ -3542,7 +3544,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
|
|
|
3542
3544
|
};
|
|
3543
3545
|
}
|
|
3544
3546
|
function deriveContractTapscripts(contract) {
|
|
3545
|
-
const handler =
|
|
3547
|
+
const handler = chunkWXCVS6PD_cjs.contractHandlers.get(contract.type);
|
|
3546
3548
|
if (!handler) {
|
|
3547
3549
|
throw new Error(`No handler for contract type '${contract.type}'`);
|
|
3548
3550
|
}
|
|
@@ -3613,7 +3615,7 @@ function getRandomId() {
|
|
|
3613
3615
|
}
|
|
3614
3616
|
function isValidArkAddress2(address) {
|
|
3615
3617
|
try {
|
|
3616
|
-
|
|
3618
|
+
chunkFZFSGOTZ_cjs.ArkAddress.decode(address);
|
|
3617
3619
|
return true;
|
|
3618
3620
|
} catch (e) {
|
|
3619
3621
|
return false;
|
|
@@ -3641,7 +3643,7 @@ function assertRecipientArkAddress(encoded, address, context) {
|
|
|
3641
3643
|
function assertTapTreeDerivesAddress(encoded, tapTree, address) {
|
|
3642
3644
|
let derived;
|
|
3643
3645
|
try {
|
|
3644
|
-
derived =
|
|
3646
|
+
derived = chunkFZFSGOTZ_cjs.VtxoScript.decode(tapTree).pkScript;
|
|
3645
3647
|
} catch (e) {
|
|
3646
3648
|
throw new Error(
|
|
3647
3649
|
`Invalid tapTree for ${encoded}: ${e instanceof Error ? e.message : String(e)}`
|
|
@@ -3658,7 +3660,7 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
3658
3660
|
for (const recipient of recipients) {
|
|
3659
3661
|
let address;
|
|
3660
3662
|
try {
|
|
3661
|
-
address =
|
|
3663
|
+
address = chunkFZFSGOTZ_cjs.ArkAddress.decode(recipient.address);
|
|
3662
3664
|
} catch (e) {
|
|
3663
3665
|
throw new Error(`Invalid Arkade address: ${recipient.address}`);
|
|
3664
3666
|
}
|
|
@@ -3683,7 +3685,7 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
3683
3685
|
|
|
3684
3686
|
// src/contracts/spendability.ts
|
|
3685
3687
|
function isContractGenericallySpendable(contract) {
|
|
3686
|
-
return
|
|
3688
|
+
return chunkWXCVS6PD_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
|
|
3687
3689
|
}
|
|
3688
3690
|
function gatedContracts(contracts) {
|
|
3689
3691
|
const gated = /* @__PURE__ */ new Map();
|
|
@@ -3696,6 +3698,9 @@ function gateExclusion(gated) {
|
|
|
3696
3698
|
return (vtxo) => {
|
|
3697
3699
|
const type = vtxo.script === void 0 ? void 0 : gated.get(vtxo.script);
|
|
3698
3700
|
if (type === void 0) return void 0;
|
|
3701
|
+
if (!chunkWXCVS6PD_cjs.contractHandlers.has(type)) {
|
|
3702
|
+
return `at ${vtxo.script} (contract type '${type}') has no handler registered in this build`;
|
|
3703
|
+
}
|
|
3699
3704
|
return `at ${vtxo.script} (contract type '${type}') is not generically spendable`;
|
|
3700
3705
|
};
|
|
3701
3706
|
}
|
|
@@ -3729,7 +3734,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
|
|
|
3729
3734
|
continue;
|
|
3730
3735
|
}
|
|
3731
3736
|
for (const v of vtxos) {
|
|
3732
|
-
if (!
|
|
3737
|
+
if (!chunkFZFSGOTZ_cjs.hasTerminalSpend(v) && !v.isSwept) out.add(`${v.txid}:${v.vout}`);
|
|
3733
3738
|
}
|
|
3734
3739
|
}
|
|
3735
3740
|
return out;
|
|
@@ -3762,10 +3767,10 @@ function byValueDescending(vtxos) {
|
|
|
3762
3767
|
return [...vtxos].sort((a, b) => b.value - a.value);
|
|
3763
3768
|
}
|
|
3764
3769
|
async function fetchTimeHeight(wallet) {
|
|
3765
|
-
return
|
|
3770
|
+
return chunkFZFSGOTZ_cjs.resolveTimeHeight(wallet.onchainProvider);
|
|
3766
3771
|
}
|
|
3767
3772
|
function canMigrateBySend(vtxo, now) {
|
|
3768
|
-
if (!
|
|
3773
|
+
if (!chunkFZFSGOTZ_cjs.canSpendOffchain(vtxo, now)) return false;
|
|
3769
3774
|
return vtxo.expiresAt !== void 0 || vtxo.expiresAtHeight !== void 0;
|
|
3770
3775
|
}
|
|
3771
3776
|
function byExpiryAscending(vtxos, now) {
|
|
@@ -3773,7 +3778,7 @@ function byExpiryAscending(vtxos, now) {
|
|
|
3773
3778
|
if (vtxo.isSwept) return -Infinity;
|
|
3774
3779
|
if (vtxo.expiresAt !== void 0) return vtxo.expiresAt.getTime();
|
|
3775
3780
|
if (vtxo.expiresAtHeight !== void 0) {
|
|
3776
|
-
return
|
|
3781
|
+
return chunkFZFSGOTZ_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
|
|
3777
3782
|
}
|
|
3778
3783
|
return Infinity;
|
|
3779
3784
|
};
|
|
@@ -3800,7 +3805,7 @@ function priceSettlementInputs(vtxos, estimator) {
|
|
|
3800
3805
|
const payable = [];
|
|
3801
3806
|
const net = /* @__PURE__ */ new Map();
|
|
3802
3807
|
for (const vtxo of vtxos) {
|
|
3803
|
-
const inputFee = estimator.evalOffchainInput(
|
|
3808
|
+
const inputFee = estimator.evalOffchainInput(chunkFZFSGOTZ_cjs.toOffchainInputFeeParams(vtxo));
|
|
3804
3809
|
if (inputFee.satoshis >= vtxo.value) {
|
|
3805
3810
|
continue;
|
|
3806
3811
|
}
|
|
@@ -3826,7 +3831,7 @@ function deductOffchainOutputFee(subtotal, estimator, arkAddress) {
|
|
|
3826
3831
|
}
|
|
3827
3832
|
const outputFee = estimator.evalOffchainOutput({
|
|
3828
3833
|
amount: subtotal,
|
|
3829
|
-
script: base.hex.encode(
|
|
3834
|
+
script: base.hex.encode(chunkFZFSGOTZ_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
3830
3835
|
});
|
|
3831
3836
|
return subtotal - BigInt(outputFee.satoshis);
|
|
3832
3837
|
}
|
|
@@ -3844,10 +3849,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
|
|
|
3844
3849
|
};
|
|
3845
3850
|
function getRecoverableVtxos(vtxos, dustAmount, now) {
|
|
3846
3851
|
return vtxos.filter((vtxo) => {
|
|
3847
|
-
if (
|
|
3852
|
+
if (chunkFZFSGOTZ_cjs.canRecoverOnchain(vtxo, now)) {
|
|
3848
3853
|
return true;
|
|
3849
3854
|
}
|
|
3850
|
-
if (
|
|
3855
|
+
if (chunkFZFSGOTZ_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
|
|
3851
3856
|
return true;
|
|
3852
3857
|
}
|
|
3853
3858
|
return false;
|
|
@@ -3878,7 +3883,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
|
|
|
3878
3883
|
}
|
|
3879
3884
|
function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
3880
3885
|
const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
|
|
3881
|
-
const expiresAt =
|
|
3886
|
+
const expiresAt = chunkFZFSGOTZ_cjs.normalizeVtxo(vtxo).expiresAt;
|
|
3882
3887
|
if (expiresAt === void 0) return false;
|
|
3883
3888
|
const now = Date.now();
|
|
3884
3889
|
const batchExpiry = expiresAt.getTime();
|
|
@@ -3887,7 +3892,7 @@ function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
|
3887
3892
|
}
|
|
3888
3893
|
function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
|
|
3889
3894
|
return vtxos.filter(
|
|
3890
|
-
(vtxo) => isVtxoExpiringSoon(vtxo, thresholdMs) ||
|
|
3895
|
+
(vtxo) => isVtxoExpiringSoon(vtxo, thresholdMs) || chunkFZFSGOTZ_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount)
|
|
3891
3896
|
);
|
|
3892
3897
|
}
|
|
3893
3898
|
function isMigrationCapable(wallet) {
|
|
@@ -4486,11 +4491,11 @@ var VtxoManager = class _VtxoManager {
|
|
|
4486
4491
|
`Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
|
|
4487
4492
|
);
|
|
4488
4493
|
}
|
|
4489
|
-
const tx = new
|
|
4494
|
+
const tx = new chunkFZFSGOTZ_cjs.Transaction();
|
|
4490
4495
|
for (const utxo of expiredUtxos) {
|
|
4491
|
-
const utxoScript =
|
|
4496
|
+
const utxoScript = chunkFZFSGOTZ_cjs.VtxoScript.decode(utxo.tapTree);
|
|
4492
4497
|
const utxoExitLeaf = utxoScript.leaves.find(
|
|
4493
|
-
(leaf) =>
|
|
4498
|
+
(leaf) => chunkFZFSGOTZ_cjs.CSVMultisigTapscript.isScriptValid(chunkFZFSGOTZ_cjs.scriptFromTapLeafScript(leaf)) === true
|
|
4494
4499
|
);
|
|
4495
4500
|
if (!utxoExitLeaf) {
|
|
4496
4501
|
throw new Error(
|
|
@@ -4505,7 +4510,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4505
4510
|
amount: BigInt(utxo.value)
|
|
4506
4511
|
},
|
|
4507
4512
|
tapLeafScript: [utxoExitLeaf],
|
|
4508
|
-
sequence:
|
|
4513
|
+
sequence: chunkFZFSGOTZ_cjs.getSequence(utxoExitLeaf)
|
|
4509
4514
|
});
|
|
4510
4515
|
}
|
|
4511
4516
|
tx.addOutputAddress(boardingAddress, outputAmount, this.getNetwork());
|
|
@@ -4739,8 +4744,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
4739
4744
|
if (!serverPubKey) continue;
|
|
4740
4745
|
const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
|
|
4741
4746
|
if (cls.status === "CURRENT") continue;
|
|
4742
|
-
const recoverable = vtxos.filter((v) => v.isSwept && !
|
|
4743
|
-
const spendable = vtxos.filter((v) => !
|
|
4747
|
+
const recoverable = vtxos.filter((v) => v.isSwept && !chunkFZFSGOTZ_cjs.hasTerminalSpend(v));
|
|
4748
|
+
const spendable = vtxos.filter((v) => !chunkFZFSGOTZ_cjs.hasTerminalSpend(v) && !v.isSwept);
|
|
4744
4749
|
const value = spendable.reduce((sum, v) => sum + v.value, 0);
|
|
4745
4750
|
let recoverableCount = 0;
|
|
4746
4751
|
let recoverableValue = 0;
|
|
@@ -4753,7 +4758,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4753
4758
|
awaitingSweepCount = spendable.length;
|
|
4754
4759
|
awaitingSweepValue = value;
|
|
4755
4760
|
for (const v of spendable) {
|
|
4756
|
-
const exp =
|
|
4761
|
+
const exp = chunkFZFSGOTZ_cjs.toBatchExpiry(v);
|
|
4757
4762
|
if (exp !== void 0 && (nextSweepEta === void 0 || exp < nextSweepEta)) {
|
|
4758
4763
|
nextSweepEta = exp;
|
|
4759
4764
|
}
|
|
@@ -5014,7 +5019,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5014
5019
|
/** Decodes the boarding tapscript exit path to extract the CSV timelock. */
|
|
5015
5020
|
getBoardingTimelock() {
|
|
5016
5021
|
const wallet = this.getSweepWallet();
|
|
5017
|
-
const exitScript =
|
|
5022
|
+
const exitScript = chunkFZFSGOTZ_cjs.CSVMultisigTapscript.decode(
|
|
5018
5023
|
base.hex.decode(wallet.boardingTapscript.exitScript)
|
|
5019
5024
|
);
|
|
5020
5025
|
return exitScript.params.timelock;
|
|
@@ -5145,8 +5150,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
5145
5150
|
* or doesn't carry the metadata.
|
|
5146
5151
|
*/
|
|
5147
5152
|
extractSpentOutpoint(error) {
|
|
5148
|
-
const ark =
|
|
5149
|
-
if (!
|
|
5153
|
+
const ark = chunkFZFSGOTZ_cjs.maybeArkError(error);
|
|
5154
|
+
if (!chunkFZFSGOTZ_cjs.isArkError(ark, chunkFZFSGOTZ_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
|
|
5150
5155
|
const raw = ark.metadata?.vtxo_outpoint;
|
|
5151
5156
|
if (typeof raw !== "string") return void 0;
|
|
5152
5157
|
const [txid, voutStr] = raw.split(":");
|
|
@@ -5336,7 +5341,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5336
5341
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
5337
5342
|
break;
|
|
5338
5343
|
}
|
|
5339
|
-
const inputFee = estimator.evalOffchainInput(
|
|
5344
|
+
const inputFee = estimator.evalOffchainInput(chunkFZFSGOTZ_cjs.toOffchainInputFeeParams(v));
|
|
5340
5345
|
if (inputFee.satoshis >= v.value) {
|
|
5341
5346
|
continue;
|
|
5342
5347
|
}
|
|
@@ -5356,7 +5361,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5356
5361
|
const arkAddress = await this.wallet.getAddress();
|
|
5357
5362
|
const outputFee = estimator.evalOffchainOutput({
|
|
5358
5363
|
amount: totalAmount,
|
|
5359
|
-
script: base.hex.encode(
|
|
5364
|
+
script: base.hex.encode(chunkFZFSGOTZ_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
5360
5365
|
});
|
|
5361
5366
|
totalAmount -= BigInt(outputFee.satoshis);
|
|
5362
5367
|
if (totalAmount < dustAmount) return;
|
|
@@ -5436,7 +5441,7 @@ var ArkNote = class _ArkNote {
|
|
|
5436
5441
|
this.value = value;
|
|
5437
5442
|
this.HRP = HRP;
|
|
5438
5443
|
const preimageHash = utils_js.sha256(this.preimage);
|
|
5439
|
-
this.vtxoScript = new
|
|
5444
|
+
this.vtxoScript = new chunkFZFSGOTZ_cjs.VtxoScript([noteTapscript(preimageHash)]);
|
|
5440
5445
|
const leaf = this.vtxoScript.leaves[0];
|
|
5441
5446
|
this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
|
|
5442
5447
|
this.tapTree = this.vtxoScript.encode();
|
|
@@ -5603,7 +5608,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
5603
5608
|
const privateKey = data.slice(1, 33);
|
|
5604
5609
|
const serverPubKey = data.slice(33, 65);
|
|
5605
5610
|
const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
|
|
5606
|
-
const csvTimelock =
|
|
5611
|
+
const csvTimelock = chunkFZFSGOTZ_cjs.sequenceToTimelock(sequence);
|
|
5607
5612
|
return new _ArkadeCash(privateKey, serverPubKey, csvTimelock, decoded.prefix);
|
|
5608
5613
|
}
|
|
5609
5614
|
toString() {
|
|
@@ -5611,7 +5616,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
5611
5616
|
data[0] = _ArkadeCash.Version;
|
|
5612
5617
|
data.set(this._privateKey, 1);
|
|
5613
5618
|
data.set(this._serverPubKey, 33);
|
|
5614
|
-
const sequence =
|
|
5619
|
+
const sequence = chunkFZFSGOTZ_cjs.timelockToSequence(this.csvTimelock);
|
|
5615
5620
|
new DataView(data.buffer, data.byteOffset + 65, 4).setUint32(0, sequence, false);
|
|
5616
5621
|
const words = base.bech32m.toWords(data);
|
|
5617
5622
|
return base.bech32m.encode(this.hrp, words, 1023);
|
|
@@ -5620,7 +5625,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
5620
5625
|
return SingleKey.fromPrivateKey(this._privateKey);
|
|
5621
5626
|
}
|
|
5622
5627
|
get vtxoScript() {
|
|
5623
|
-
return new
|
|
5628
|
+
return new chunkWXCVS6PD_cjs.DefaultVtxo.Script({
|
|
5624
5629
|
pubKey: this._publicKey,
|
|
5625
5630
|
serverPubKey: this._serverPubKey,
|
|
5626
5631
|
csvTimelock: this.csvTimelock
|
|
@@ -5881,7 +5886,7 @@ async function captureExitBranch(params) {
|
|
|
5881
5886
|
const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
|
|
5882
5887
|
if (nonCommitment.length > 0) {
|
|
5883
5888
|
for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
|
|
5884
|
-
psbtByTxid.set(
|
|
5889
|
+
psbtByTxid.set(chunkFZFSGOTZ_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
5885
5890
|
}
|
|
5886
5891
|
}
|
|
5887
5892
|
}
|
|
@@ -5924,10 +5929,10 @@ var IndexerExitDataSource = class {
|
|
|
5924
5929
|
while (hasMore) {
|
|
5925
5930
|
const { chain: page, page: meta } = await this.indexer.getVtxoChain(
|
|
5926
5931
|
{ txid: vtxo.txid, vout: vtxo.vout },
|
|
5927
|
-
{ pageIndex, pageSize:
|
|
5932
|
+
{ pageIndex, pageSize: chunkFZFSGOTZ_cjs.DEFAULT_PAGE_SIZE }
|
|
5928
5933
|
);
|
|
5929
5934
|
chain.push(...page);
|
|
5930
|
-
hasMore = meta ? page.length ===
|
|
5935
|
+
hasMore = meta ? page.length === chunkFZFSGOTZ_cjs.DEFAULT_PAGE_SIZE : false;
|
|
5931
5936
|
pageIndex++;
|
|
5932
5937
|
}
|
|
5933
5938
|
return chain;
|
|
@@ -5939,12 +5944,12 @@ var IndexerExitDataSource = class {
|
|
|
5939
5944
|
while (hasMore) {
|
|
5940
5945
|
const { txs, page } = await this.indexer.getVirtualTxs(txids, {
|
|
5941
5946
|
pageIndex,
|
|
5942
|
-
pageSize:
|
|
5947
|
+
pageSize: chunkFZFSGOTZ_cjs.DEFAULT_PAGE_SIZE
|
|
5943
5948
|
});
|
|
5944
5949
|
for (const psbt of txs) {
|
|
5945
|
-
out.set(
|
|
5950
|
+
out.set(chunkFZFSGOTZ_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
5946
5951
|
}
|
|
5947
|
-
hasMore = page ? txs.length ===
|
|
5952
|
+
hasMore = page ? txs.length === chunkFZFSGOTZ_cjs.DEFAULT_PAGE_SIZE : false;
|
|
5948
5953
|
pageIndex++;
|
|
5949
5954
|
}
|
|
5950
5955
|
return out;
|
|
@@ -5965,7 +5970,7 @@ function chainedTxTypeToChainTxType(t) {
|
|
|
5965
5970
|
}
|
|
5966
5971
|
}
|
|
5967
5972
|
function psbtInputTxids(psbtBase64) {
|
|
5968
|
-
const tx =
|
|
5973
|
+
const tx = chunkFZFSGOTZ_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
5969
5974
|
const ids = [];
|
|
5970
5975
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
5971
5976
|
const txid = tx.getInput(i).txid;
|
|
@@ -6318,10 +6323,10 @@ async function resolveArkInfo(arkProvider, walletRepository) {
|
|
|
6318
6323
|
try {
|
|
6319
6324
|
info = await arkProvider.getInfo();
|
|
6320
6325
|
} catch (err) {
|
|
6321
|
-
if (!
|
|
6326
|
+
if (!chunkFZFSGOTZ_cjs.isRetryableProviderError(err)) throw err;
|
|
6322
6327
|
const snapshot = await loadArkInfoSnapshot(walletRepository);
|
|
6323
6328
|
if (!snapshot) {
|
|
6324
|
-
throw new
|
|
6329
|
+
throw new chunkFZFSGOTZ_cjs.ProviderUnavailableError(
|
|
6325
6330
|
"Arkade server info is unavailable and no cached snapshot exists",
|
|
6326
6331
|
{ cause: err }
|
|
6327
6332
|
);
|
|
@@ -6704,7 +6709,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos) {
|
|
|
6704
6709
|
return [...txids];
|
|
6705
6710
|
}
|
|
6706
6711
|
async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt) {
|
|
6707
|
-
const fromOldestVtxo = vtxos.map(
|
|
6712
|
+
const fromOldestVtxo = vtxos.map(chunkFZFSGOTZ_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
6708
6713
|
const txidsNeedingCreatedAt = resolveTxCreatedAt ? collectArkTxidsNeedingCreatedAt(fromOldestVtxo) : [];
|
|
6709
6714
|
const resolvedCreatedAt = resolveTxCreatedAt && txidsNeedingCreatedAt.length > 0 ? await resolveTxCreatedAt(txidsNeedingCreatedAt) : /* @__PURE__ */ new Map();
|
|
6710
6715
|
const unmatchedSettledBoardingTxs = allBoardingTxs.filter(isSettledBoardingReceive).sort((a, b) => a.createdAt - b.createdAt);
|
|
@@ -6868,7 +6873,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6868
6873
|
const virtualCoins = await this.wallet.getSpendableVtxos({
|
|
6869
6874
|
withRecoverable: false
|
|
6870
6875
|
});
|
|
6871
|
-
const controlAssetRef = params.controlAssetId ?
|
|
6876
|
+
const controlAssetRef = params.controlAssetId ? chunkRXITDAV4_cjs.AssetRef.fromId(chunkRXITDAV4_cjs.AssetId.fromString(params.controlAssetId)) : null;
|
|
6872
6877
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
6873
6878
|
let totalBtcSelected = 0n;
|
|
6874
6879
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -6881,8 +6886,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6881
6886
|
}
|
|
6882
6887
|
}
|
|
6883
6888
|
const groups = [];
|
|
6884
|
-
const issuedAssetOutput =
|
|
6885
|
-
const issuedAssetGroup =
|
|
6889
|
+
const issuedAssetOutput = chunkRXITDAV4_cjs.AssetOutput.create(0, params.amount);
|
|
6890
|
+
const issuedAssetGroup = chunkRXITDAV4_cjs.AssetGroup.create(
|
|
6886
6891
|
null,
|
|
6887
6892
|
controlAssetRef,
|
|
6888
6893
|
[],
|
|
@@ -6897,28 +6902,28 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6897
6902
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6898
6903
|
for (const asset of assets) {
|
|
6899
6904
|
if (asset.assetId !== assetId) continue;
|
|
6900
|
-
changeInputs.push(
|
|
6905
|
+
changeInputs.push(chunkRXITDAV4_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6901
6906
|
}
|
|
6902
6907
|
}
|
|
6903
6908
|
groups.push(
|
|
6904
|
-
|
|
6905
|
-
|
|
6909
|
+
chunkRXITDAV4_cjs.AssetGroup.create(
|
|
6910
|
+
chunkRXITDAV4_cjs.AssetId.fromString(assetId),
|
|
6906
6911
|
null,
|
|
6907
6912
|
changeInputs,
|
|
6908
|
-
[
|
|
6913
|
+
[chunkRXITDAV4_cjs.AssetOutput.create(0, amount)],
|
|
6909
6914
|
[]
|
|
6910
6915
|
)
|
|
6911
6916
|
);
|
|
6912
6917
|
}
|
|
6913
6918
|
}
|
|
6914
6919
|
const address = await this.wallet.getAddress();
|
|
6915
|
-
const outputAddress =
|
|
6920
|
+
const outputAddress = chunkFZFSGOTZ_cjs.ArkAddress.decode(address);
|
|
6916
6921
|
const outputs = [
|
|
6917
6922
|
{
|
|
6918
6923
|
script: outputAddress.pkScript,
|
|
6919
6924
|
amount: BigInt(totalBtcSelected)
|
|
6920
6925
|
},
|
|
6921
|
-
Extension.create([
|
|
6926
|
+
Extension.create([chunkRXITDAV4_cjs.Packet.create(groups)]).txOut()
|
|
6922
6927
|
];
|
|
6923
6928
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
|
|
6924
6929
|
coinSelection.inputs,
|
|
@@ -6926,7 +6931,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6926
6931
|
);
|
|
6927
6932
|
return {
|
|
6928
6933
|
arkTxId: arkTxid,
|
|
6929
|
-
assetId:
|
|
6934
|
+
assetId: chunkRXITDAV4_cjs.AssetId.create(arkTxid, 0).toString()
|
|
6930
6935
|
};
|
|
6931
6936
|
}
|
|
6932
6937
|
/**
|
|
@@ -6998,16 +7003,16 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6998
7003
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6999
7004
|
for (const asset of assets) {
|
|
7000
7005
|
if (asset.assetId !== params.assetId) continue;
|
|
7001
|
-
reissueInputs.push(
|
|
7006
|
+
reissueInputs.push(chunkRXITDAV4_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7002
7007
|
}
|
|
7003
7008
|
}
|
|
7004
7009
|
const totalAssetAmount = assetToReissueAmount + params.amount;
|
|
7005
|
-
const reissueAssetIdObj =
|
|
7006
|
-
const reissueAssetGroup =
|
|
7010
|
+
const reissueAssetIdObj = chunkRXITDAV4_cjs.AssetId.fromString(params.assetId);
|
|
7011
|
+
const reissueAssetGroup = chunkRXITDAV4_cjs.AssetGroup.create(
|
|
7007
7012
|
reissueAssetIdObj,
|
|
7008
7013
|
null,
|
|
7009
7014
|
reissueInputs,
|
|
7010
|
-
[
|
|
7015
|
+
[chunkRXITDAV4_cjs.AssetOutput.create(0, totalAssetAmount)],
|
|
7011
7016
|
[]
|
|
7012
7017
|
);
|
|
7013
7018
|
const groups = [reissueAssetGroup];
|
|
@@ -7016,27 +7021,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7016
7021
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7017
7022
|
for (const asset of assets) {
|
|
7018
7023
|
if (asset.assetId !== assetId) continue;
|
|
7019
|
-
changeInputs.push(
|
|
7024
|
+
changeInputs.push(chunkRXITDAV4_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7020
7025
|
}
|
|
7021
7026
|
}
|
|
7022
7027
|
groups.push(
|
|
7023
|
-
|
|
7024
|
-
|
|
7028
|
+
chunkRXITDAV4_cjs.AssetGroup.create(
|
|
7029
|
+
chunkRXITDAV4_cjs.AssetId.fromString(assetId),
|
|
7025
7030
|
null,
|
|
7026
7031
|
changeInputs,
|
|
7027
|
-
[
|
|
7032
|
+
[chunkRXITDAV4_cjs.AssetOutput.create(0, amount)],
|
|
7028
7033
|
[]
|
|
7029
7034
|
)
|
|
7030
7035
|
);
|
|
7031
7036
|
}
|
|
7032
7037
|
const address = await this.wallet.getAddress();
|
|
7033
|
-
const outputAddress =
|
|
7038
|
+
const outputAddress = chunkFZFSGOTZ_cjs.ArkAddress.decode(address);
|
|
7034
7039
|
const outputs = [
|
|
7035
7040
|
{
|
|
7036
7041
|
script: outputAddress.pkScript,
|
|
7037
7042
|
amount: BigInt(totalBtcSelected)
|
|
7038
7043
|
},
|
|
7039
|
-
Extension.create([
|
|
7044
|
+
Extension.create([chunkRXITDAV4_cjs.Packet.create(groups)]).txOut()
|
|
7040
7045
|
];
|
|
7041
7046
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
7042
7047
|
return arkTxid;
|
|
@@ -7103,27 +7108,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7103
7108
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7104
7109
|
for (const asset of assets) {
|
|
7105
7110
|
if (asset.assetId !== assetId) continue;
|
|
7106
|
-
changeInputs.push(
|
|
7111
|
+
changeInputs.push(chunkRXITDAV4_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7107
7112
|
}
|
|
7108
7113
|
}
|
|
7109
7114
|
groups.push(
|
|
7110
|
-
|
|
7111
|
-
|
|
7115
|
+
chunkRXITDAV4_cjs.AssetGroup.create(
|
|
7116
|
+
chunkRXITDAV4_cjs.AssetId.fromString(assetId),
|
|
7112
7117
|
null,
|
|
7113
7118
|
changeInputs,
|
|
7114
|
-
amount > 0n ? [
|
|
7119
|
+
amount > 0n ? [chunkRXITDAV4_cjs.AssetOutput.create(0, amount)] : [],
|
|
7115
7120
|
[]
|
|
7116
7121
|
)
|
|
7117
7122
|
);
|
|
7118
7123
|
}
|
|
7119
7124
|
const address = await this.wallet.getAddress();
|
|
7120
|
-
const outputAddress =
|
|
7125
|
+
const outputAddress = chunkFZFSGOTZ_cjs.ArkAddress.decode(address);
|
|
7121
7126
|
const outputs = [
|
|
7122
7127
|
{
|
|
7123
7128
|
script: outputAddress.pkScript,
|
|
7124
7129
|
amount: BigInt(totalBtcSelected)
|
|
7125
7130
|
},
|
|
7126
|
-
Extension.create([
|
|
7131
|
+
Extension.create([chunkRXITDAV4_cjs.Packet.create(groups)]).txOut()
|
|
7127
7132
|
];
|
|
7128
7133
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
7129
7134
|
return arkTxid;
|
|
@@ -7148,7 +7153,7 @@ function castMetadata(metadata) {
|
|
|
7148
7153
|
} else {
|
|
7149
7154
|
throw new Error("Invalid metadata value type");
|
|
7150
7155
|
}
|
|
7151
|
-
md.push(
|
|
7156
|
+
md.push(chunkRXITDAV4_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
|
|
7152
7157
|
}
|
|
7153
7158
|
return md;
|
|
7154
7159
|
}
|
|
@@ -7169,10 +7174,10 @@ var DelegateManagerImpl = class {
|
|
|
7169
7174
|
if (vtxos.length === 0) {
|
|
7170
7175
|
return { delegated: [], failed: [] };
|
|
7171
7176
|
}
|
|
7172
|
-
const destinationScript =
|
|
7177
|
+
const destinationScript = chunkFZFSGOTZ_cjs.ArkAddress.decode(destination).pkScript;
|
|
7173
7178
|
const arkInfo = await this.arkInfoProvider.getInfo();
|
|
7174
7179
|
const delegateInfo = await this.delegateProvider.getDelegateInfo();
|
|
7175
|
-
const eligible = vtxos.map(
|
|
7180
|
+
const eligible = vtxos.map(chunkFZFSGOTZ_cjs.normalizeVtxo).filter(
|
|
7176
7181
|
(v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
|
|
7177
7182
|
);
|
|
7178
7183
|
if (eligible.length === 0) {
|
|
@@ -7201,11 +7206,11 @@ var DelegateManagerImpl = class {
|
|
|
7201
7206
|
const groupByExpiry = /* @__PURE__ */ new Map();
|
|
7202
7207
|
let recoverableVtxos = [];
|
|
7203
7208
|
for (const vtxo of eligible) {
|
|
7204
|
-
if (
|
|
7209
|
+
if (chunkFZFSGOTZ_cjs.canRecoverOnchain(vtxo, now)) {
|
|
7205
7210
|
recoverableVtxos.push(vtxo);
|
|
7206
7211
|
continue;
|
|
7207
7212
|
}
|
|
7208
|
-
const expiry =
|
|
7213
|
+
const expiry = chunkFZFSGOTZ_cjs.toBatchExpiry(vtxo);
|
|
7209
7214
|
if (!expiry) continue;
|
|
7210
7215
|
const dayKey = getDayTimestamp(expiry);
|
|
7211
7216
|
groupByExpiry.set(dayKey, [...groupByExpiry.get(dayKey) ?? [], vtxo]);
|
|
@@ -7270,7 +7275,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7270
7275
|
}
|
|
7271
7276
|
if (!delegateAt) {
|
|
7272
7277
|
const now = { timestamp: /* @__PURE__ */ new Date() };
|
|
7273
|
-
const expiryTimestamp = vtxos.filter((coin) => !
|
|
7278
|
+
const expiryTimestamp = vtxos.filter((coin) => !chunkFZFSGOTZ_cjs.canRecoverOnchain(coin, now) && chunkFZFSGOTZ_cjs.toBatchExpiry(coin)).reduce((min, coin) => Math.min(min, chunkFZFSGOTZ_cjs.toBatchExpiry(coin)), Number.MAX_SAFE_INTEGER);
|
|
7274
7279
|
if (!expiryTimestamp || expiryTimestamp === Number.MAX_SAFE_INTEGER) {
|
|
7275
7280
|
delegateAt = new Date(Date.now() + 1 * 60 * 1e3);
|
|
7276
7281
|
} else {
|
|
@@ -7299,7 +7304,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7299
7304
|
let amount = 0n;
|
|
7300
7305
|
for (const coin of vtxos) {
|
|
7301
7306
|
const inputFee = estimator.evalOffchainInput({
|
|
7302
|
-
...
|
|
7307
|
+
...chunkFZFSGOTZ_cjs.toOffchainInputFeeParams(coin),
|
|
7303
7308
|
type: "vtxo"
|
|
7304
7309
|
});
|
|
7305
7310
|
if (inputFee.value >= coin.value) {
|
|
@@ -7313,7 +7318,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7313
7318
|
const delegateFee = BigInt(Number(fee));
|
|
7314
7319
|
if (delegateFee > 0n) {
|
|
7315
7320
|
outputs.push({
|
|
7316
|
-
script:
|
|
7321
|
+
script: chunkFZFSGOTZ_cjs.ArkAddress.decode(delegateAddress).pkScript,
|
|
7317
7322
|
amount: delegateFee
|
|
7318
7323
|
});
|
|
7319
7324
|
}
|
|
@@ -7346,10 +7351,10 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7346
7351
|
destinationScript
|
|
7347
7352
|
);
|
|
7348
7353
|
const forfeitOutputScript = btcSigner.OutScript.encode(
|
|
7349
|
-
btcSigner.Address(
|
|
7354
|
+
btcSigner.Address(chunkFZFSGOTZ_cjs.getNetwork(network)).decode(forfeitAddress)
|
|
7350
7355
|
);
|
|
7351
7356
|
const forfeits = await Promise.all(
|
|
7352
|
-
vtxos.filter((v) => !
|
|
7357
|
+
vtxos.filter((v) => !chunkFZFSGOTZ_cjs.canRecoverOnchain(v, { timestamp: /* @__PURE__ */ new Date() })).map(async (coin) => {
|
|
7353
7358
|
const forfeit = await makeDelegateForfeitTx(
|
|
7354
7359
|
coin,
|
|
7355
7360
|
dust,
|
|
@@ -7374,7 +7379,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
|
|
|
7374
7379
|
index: input.vout,
|
|
7375
7380
|
witnessUtxo: {
|
|
7376
7381
|
amount: BigInt(input.value),
|
|
7377
|
-
script:
|
|
7382
|
+
script: chunkFZFSGOTZ_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
7378
7383
|
},
|
|
7379
7384
|
sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
|
|
7380
7385
|
tapLeafScript: [delegateTapLeaf]
|
|
@@ -7432,7 +7437,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
7432
7437
|
expire_at: 0,
|
|
7433
7438
|
cosigners_public_keys: cosignerPubKeys
|
|
7434
7439
|
};
|
|
7435
|
-
const proof =
|
|
7440
|
+
const proof = chunkFZFSGOTZ_cjs.Intent.create(message, coins, outputs);
|
|
7436
7441
|
const signedProof = await identity.sign(proof);
|
|
7437
7442
|
return {
|
|
7438
7443
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -7450,10 +7455,10 @@ function getDayTimestamp(timestamp) {
|
|
|
7450
7455
|
function findDelegateTapLeaf(vtxo, delegatePubkey) {
|
|
7451
7456
|
if (!vtxo.tapTree) return void 0;
|
|
7452
7457
|
const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
|
|
7453
|
-
const vtxoScript =
|
|
7458
|
+
const vtxoScript = chunkFZFSGOTZ_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
7454
7459
|
return vtxoScript.leaves.find((tapLeaf) => {
|
|
7455
|
-
const arkTapscript =
|
|
7456
|
-
if (!
|
|
7460
|
+
const arkTapscript = chunkFZFSGOTZ_cjs.decodeTapscript(chunkFZFSGOTZ_cjs.scriptFromTapLeafScript(tapLeaf));
|
|
7461
|
+
if (!chunkFZFSGOTZ_cjs.MultisigTapscript.is(arkTapscript)) return false;
|
|
7457
7462
|
return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
|
|
7458
7463
|
});
|
|
7459
7464
|
}
|
|
@@ -7641,7 +7646,7 @@ async function closeDatabase(dbName) {
|
|
|
7641
7646
|
return true;
|
|
7642
7647
|
}
|
|
7643
7648
|
function scriptFromArkAddress(address) {
|
|
7644
|
-
return base.hex.encode(
|
|
7649
|
+
return base.hex.encode(chunkFZFSGOTZ_cjs.ArkAddress.decode(address).pkScript);
|
|
7645
7650
|
}
|
|
7646
7651
|
|
|
7647
7652
|
// src/repositories/indexedDB/schema.ts
|
|
@@ -8138,7 +8143,7 @@ function validateVtxosForScript(vtxos, script, context) {
|
|
|
8138
8143
|
}
|
|
8139
8144
|
async function getVtxosForContract(repo, contract) {
|
|
8140
8145
|
const vtxos = repo.getVtxosForScript ? await repo.getVtxosForScript(contract.script) : filterVtxosForScript(await repo.getVtxos(contract.address), contract.script);
|
|
8141
|
-
return vtxos.map(
|
|
8146
|
+
return vtxos.map(chunkFZFSGOTZ_cjs.normalizeVtxo);
|
|
8142
8147
|
}
|
|
8143
8148
|
async function saveVtxosForContract(repo, contract, vtxos) {
|
|
8144
8149
|
if (repo.saveVtxosForScript) {
|
|
@@ -8280,7 +8285,7 @@ function decodeArkContract(encoded) {
|
|
|
8280
8285
|
}
|
|
8281
8286
|
function contractFromArkContract(encoded, options = {}) {
|
|
8282
8287
|
const parsed = decodeArkContract(encoded);
|
|
8283
|
-
const handler =
|
|
8288
|
+
const handler = chunkWXCVS6PD_cjs.contractHandlers.get(parsed.type);
|
|
8284
8289
|
if (!handler) {
|
|
8285
8290
|
throw new Error(`No handler registered for contract type '${parsed.type}'`);
|
|
8286
8291
|
}
|
|
@@ -8294,9 +8299,9 @@ function contractFromArkContract(encoded, options = {}) {
|
|
|
8294
8299
|
metadata: options.metadata
|
|
8295
8300
|
};
|
|
8296
8301
|
}
|
|
8297
|
-
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix =
|
|
8302
|
+
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkFZFSGOTZ_cjs.DEFAULT_NETWORK.hrp, options = {}) {
|
|
8298
8303
|
const parsed = decodeArkContract(encoded);
|
|
8299
|
-
const handler =
|
|
8304
|
+
const handler = chunkWXCVS6PD_cjs.contractHandlers.getOrThrow(parsed.type);
|
|
8300
8305
|
const params = parsed.data;
|
|
8301
8306
|
const vtxoScript = handler.createScript(params);
|
|
8302
8307
|
return {
|
|
@@ -8550,9 +8555,9 @@ var ContractWatcher = class {
|
|
|
8550
8555
|
this.connectionState = "connected";
|
|
8551
8556
|
this.reconnectAttempts = 0;
|
|
8552
8557
|
this.listenLoop().catch((e) => {
|
|
8553
|
-
if (
|
|
8558
|
+
if (chunkFZFSGOTZ_cjs.isEventSourceError(e)) {
|
|
8554
8559
|
console.debug("ContractWatcher subscription disconnected; reconnecting");
|
|
8555
|
-
} else if (!
|
|
8560
|
+
} else if (!chunkFZFSGOTZ_cjs.isEventSourceUnavailableError(e)) {
|
|
8556
8561
|
console.error(e);
|
|
8557
8562
|
}
|
|
8558
8563
|
this.connectionState = "disconnected";
|
|
@@ -8564,7 +8569,7 @@ var ContractWatcher = class {
|
|
|
8564
8569
|
this.scheduleReconnect();
|
|
8565
8570
|
});
|
|
8566
8571
|
} catch (error) {
|
|
8567
|
-
if (!
|
|
8572
|
+
if (!chunkFZFSGOTZ_cjs.isEventSourceUnavailableError(error)) {
|
|
8568
8573
|
console.error("ContractWatcher connection failed:", error);
|
|
8569
8574
|
}
|
|
8570
8575
|
this.connectionState = "disconnected";
|
|
@@ -8590,7 +8595,7 @@ var ContractWatcher = class {
|
|
|
8590
8595
|
* slower; what it loses is push latency.
|
|
8591
8596
|
*/
|
|
8592
8597
|
reportEventSourceUnavailable(error) {
|
|
8593
|
-
if (!
|
|
8598
|
+
if (!chunkFZFSGOTZ_cjs.isEventSourceUnavailableError(error)) return false;
|
|
8594
8599
|
if (!this.eventSourceReported) {
|
|
8595
8600
|
this.eventSourceReported = true;
|
|
8596
8601
|
console.warn(
|
|
@@ -8806,14 +8811,14 @@ var ContractWatcher = class {
|
|
|
8806
8811
|
const timestamp = Date.now();
|
|
8807
8812
|
if (update.newVtxos?.length) {
|
|
8808
8813
|
this.processSubscriptionVtxos(
|
|
8809
|
-
update.newVtxos.map(
|
|
8814
|
+
update.newVtxos.map(chunkFZFSGOTZ_cjs.normalizeVtxo),
|
|
8810
8815
|
"vtxo_received",
|
|
8811
8816
|
timestamp
|
|
8812
8817
|
);
|
|
8813
8818
|
}
|
|
8814
8819
|
if (update.spentVtxos?.length) {
|
|
8815
8820
|
this.processSubscriptionVtxos(
|
|
8816
|
-
update.spentVtxos.map(
|
|
8821
|
+
update.spentVtxos.map(chunkFZFSGOTZ_cjs.normalizeVtxo),
|
|
8817
8822
|
"vtxo_spent",
|
|
8818
8823
|
timestamp
|
|
8819
8824
|
);
|
|
@@ -8946,7 +8951,7 @@ async function reconcileIntents(deps) {
|
|
|
8946
8951
|
let vtxosByOutpoint = /* @__PURE__ */ new Map();
|
|
8947
8952
|
if (outpoints.length > 0) {
|
|
8948
8953
|
try {
|
|
8949
|
-
const { vtxos } = await
|
|
8954
|
+
const { vtxos } = await chunkFZFSGOTZ_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
|
|
8950
8955
|
vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
|
|
8951
8956
|
} catch (e) {
|
|
8952
8957
|
console.error("reconcileIntents: failed to fetch input VTXO state", e);
|
|
@@ -9120,7 +9125,7 @@ var ContractManager = class _ContractManager {
|
|
|
9120
9125
|
await this.reconcileWatched();
|
|
9121
9126
|
this.markSyncOnline();
|
|
9122
9127
|
} catch (err) {
|
|
9123
|
-
if (!
|
|
9128
|
+
if (!chunkFZFSGOTZ_cjs.isRetryableProviderError(err)) throw err;
|
|
9124
9129
|
this.markSyncDegraded(err);
|
|
9125
9130
|
}
|
|
9126
9131
|
this.initialized = true;
|
|
@@ -9252,7 +9257,7 @@ var ContractManager = class _ContractManager {
|
|
|
9252
9257
|
const from = Math.max(0, watermark - lookAhead.size);
|
|
9253
9258
|
const to = watermark + lookAhead.size;
|
|
9254
9259
|
const deps = lookAhead.candidateDeps();
|
|
9255
|
-
const handlers =
|
|
9260
|
+
const handlers = chunkWXCVS6PD_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkWXCVS6PD_cjs.contractHandlers.get(t)).filter(hasCandidates);
|
|
9256
9261
|
const band = /* @__PURE__ */ new Map();
|
|
9257
9262
|
for (let index = from; index <= to; index++) {
|
|
9258
9263
|
const descriptor = lookAhead.materialize(index);
|
|
@@ -9263,7 +9268,7 @@ var ContractManager = class _ContractManager {
|
|
|
9263
9268
|
index,
|
|
9264
9269
|
params: {
|
|
9265
9270
|
...candidate,
|
|
9266
|
-
...
|
|
9271
|
+
...chunkWXCVS6PD_cjs.speculativeReceiveMetadata(descriptor)
|
|
9267
9272
|
}
|
|
9268
9273
|
});
|
|
9269
9274
|
}
|
|
@@ -9325,7 +9330,7 @@ var ContractManager = class _ContractManager {
|
|
|
9325
9330
|
});
|
|
9326
9331
|
for (const entry of pending) entry.catchUpPending = false;
|
|
9327
9332
|
} catch (err) {
|
|
9328
|
-
if (!
|
|
9333
|
+
if (!chunkFZFSGOTZ_cjs.isRetryableProviderError(err)) throw err;
|
|
9329
9334
|
this.markSyncDegraded(err);
|
|
9330
9335
|
}
|
|
9331
9336
|
}
|
|
@@ -9375,7 +9380,7 @@ var ContractManager = class _ContractManager {
|
|
|
9375
9380
|
await this.fetchContractVxosFromIndexer([contract]);
|
|
9376
9381
|
this.markSyncOnline();
|
|
9377
9382
|
} catch (err) {
|
|
9378
|
-
if (!
|
|
9383
|
+
if (!chunkFZFSGOTZ_cjs.isRetryableProviderError(err)) throw err;
|
|
9379
9384
|
this.markSyncDegraded(err);
|
|
9380
9385
|
}
|
|
9381
9386
|
await this.watcher.addContract(contract);
|
|
@@ -9412,7 +9417,7 @@ var ContractManager = class _ContractManager {
|
|
|
9412
9417
|
return result;
|
|
9413
9418
|
}
|
|
9414
9419
|
async upsertContractRow(params) {
|
|
9415
|
-
const handler =
|
|
9420
|
+
const handler = chunkWXCVS6PD_cjs.contractHandlers.get(params.type);
|
|
9416
9421
|
if (!handler) {
|
|
9417
9422
|
throw new Error(`No handler registered for contract type '${params.type}'`);
|
|
9418
9423
|
}
|
|
@@ -9512,7 +9517,7 @@ var ContractManager = class _ContractManager {
|
|
|
9512
9517
|
`scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
|
|
9513
9518
|
);
|
|
9514
9519
|
}
|
|
9515
|
-
const registered =
|
|
9520
|
+
const registered = chunkWXCVS6PD_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkWXCVS6PD_cjs.contractHandlers.get(t)).filter(isDiscoverable);
|
|
9516
9521
|
const discoverables = [
|
|
9517
9522
|
...registered.filter((h) => h.type === "boarding"),
|
|
9518
9523
|
...registered.filter((h) => h.type !== "boarding")
|
|
@@ -9647,7 +9652,7 @@ var ContractManager = class _ContractManager {
|
|
|
9647
9652
|
await this.syncContracts({ contracts, pageSize });
|
|
9648
9653
|
this.markSyncOnline();
|
|
9649
9654
|
} catch (err) {
|
|
9650
|
-
if (!
|
|
9655
|
+
if (!chunkFZFSGOTZ_cjs.isRetryableProviderError(err)) throw err;
|
|
9651
9656
|
this.markSyncDegraded(err);
|
|
9652
9657
|
}
|
|
9653
9658
|
const vtxos = await this.getVtxosForContracts(contracts);
|
|
@@ -9668,7 +9673,7 @@ var ContractManager = class _ContractManager {
|
|
|
9668
9673
|
}
|
|
9669
9674
|
const tapscriptCache = tapscripts ?? /* @__PURE__ */ new Map();
|
|
9670
9675
|
return vtxos.map(
|
|
9671
|
-
(vtxo) => extendVirtualCoinForContract(
|
|
9676
|
+
(vtxo) => extendVirtualCoinForContract(chunkFZFSGOTZ_cjs.normalizeVtxo(vtxo), byScript, tapscriptCache)
|
|
9672
9677
|
);
|
|
9673
9678
|
}
|
|
9674
9679
|
/** @inheritdoc */
|
|
@@ -9712,14 +9717,14 @@ var ContractManager = class _ContractManager {
|
|
|
9712
9717
|
const byScript = new Map(contracts.map((contract) => [contract.script, contract]));
|
|
9713
9718
|
const asking = vtxos.filter((vtxo) => {
|
|
9714
9719
|
const contract = byScript.get(vtxo.script);
|
|
9715
|
-
return contract !== void 0 &&
|
|
9720
|
+
return contract !== void 0 && chunkWXCVS6PD_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
|
|
9716
9721
|
});
|
|
9717
9722
|
if (asking.length === 0) return refused;
|
|
9718
9723
|
const tip = await this.currentChainTip();
|
|
9719
9724
|
const walletKey = await walletPubKey?.();
|
|
9720
9725
|
for (const vtxo of asking) {
|
|
9721
9726
|
const contract = byScript.get(vtxo.script);
|
|
9722
|
-
const handler =
|
|
9727
|
+
const handler = chunkWXCVS6PD_cjs.contractHandlers.get(contract.type);
|
|
9723
9728
|
if (!handler?.assertSpendableNow) continue;
|
|
9724
9729
|
const context = {
|
|
9725
9730
|
collaborative: true,
|
|
@@ -9734,7 +9739,7 @@ var ContractManager = class _ContractManager {
|
|
|
9734
9739
|
// the next handler to answer a CSV question would meet a
|
|
9735
9740
|
// TypeError instead of a `false`. Carry the coin only when it
|
|
9736
9741
|
// really is one.
|
|
9737
|
-
vtxo:
|
|
9742
|
+
vtxo: chunkFZFSGOTZ_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
|
|
9738
9743
|
};
|
|
9739
9744
|
try {
|
|
9740
9745
|
await handler.assertSpendableNow(
|
|
@@ -9890,7 +9895,7 @@ var ContractManager = class _ContractManager {
|
|
|
9890
9895
|
const { contractScript, collaborative = true, walletPubKey, vtxo } = options;
|
|
9891
9896
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
9892
9897
|
if (!contract) return [];
|
|
9893
|
-
const handler =
|
|
9898
|
+
const handler = chunkWXCVS6PD_cjs.contractHandlers.get(contract.type);
|
|
9894
9899
|
if (!handler) return [];
|
|
9895
9900
|
const script = handler.createScript(contract.params);
|
|
9896
9901
|
const tip = await this.currentChainTip();
|
|
@@ -9918,7 +9923,7 @@ var ContractManager = class _ContractManager {
|
|
|
9918
9923
|
const { contractScript, collaborative = true, walletPubKey } = options;
|
|
9919
9924
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
9920
9925
|
if (!contract) return [];
|
|
9921
|
-
const handler =
|
|
9926
|
+
const handler = chunkWXCVS6PD_cjs.contractHandlers.get(contract.type);
|
|
9922
9927
|
if (!handler) return [];
|
|
9923
9928
|
const script = handler.createScript(contract.params);
|
|
9924
9929
|
const context = {
|
|
@@ -9974,7 +9979,7 @@ var ContractManager = class _ContractManager {
|
|
|
9974
9979
|
}
|
|
9975
9980
|
async refreshOutpoints(outpoints) {
|
|
9976
9981
|
if (outpoints.length === 0) return;
|
|
9977
|
-
const { vtxos } = await
|
|
9982
|
+
const { vtxos } = await chunkFZFSGOTZ_cjs.getNormalizedVtxos(this.config.indexerProvider, {
|
|
9978
9983
|
outpoints
|
|
9979
9984
|
});
|
|
9980
9985
|
if (vtxos.length === 0) return;
|
|
@@ -10053,7 +10058,7 @@ var ContractManager = class _ContractManager {
|
|
|
10053
10058
|
break;
|
|
10054
10059
|
}
|
|
10055
10060
|
} catch (err) {
|
|
10056
|
-
if (!
|
|
10061
|
+
if (!chunkFZFSGOTZ_cjs.isRetryableProviderError(err)) throw err;
|
|
10057
10062
|
this.markSyncDegraded(err);
|
|
10058
10063
|
}
|
|
10059
10064
|
this.emitEvent(event);
|
|
@@ -10132,7 +10137,7 @@ var ContractManager = class _ContractManager {
|
|
|
10132
10137
|
*/
|
|
10133
10138
|
async reconcilePendingFrontier(contracts) {
|
|
10134
10139
|
const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
|
|
10135
|
-
const vtxos = await
|
|
10140
|
+
const vtxos = await chunkFZFSGOTZ_cjs.getAllNormalizedVtxos(
|
|
10136
10141
|
this.config.indexerProvider,
|
|
10137
10142
|
contracts.map((c) => c.script),
|
|
10138
10143
|
{ pendingOnly: true }
|
|
@@ -10215,7 +10220,7 @@ var ContractManager = class _ContractManager {
|
|
|
10215
10220
|
}
|
|
10216
10221
|
return result;
|
|
10217
10222
|
}
|
|
10218
|
-
async fetchContractVtxosBulk(contracts, pageSize =
|
|
10223
|
+
async fetchContractVtxosBulk(contracts, pageSize = chunkFZFSGOTZ_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
|
|
10219
10224
|
if (contracts.length === 0) {
|
|
10220
10225
|
return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
|
|
10221
10226
|
}
|
|
@@ -10231,7 +10236,7 @@ var ContractManager = class _ContractManager {
|
|
|
10231
10236
|
before: syncWindow.before
|
|
10232
10237
|
}
|
|
10233
10238
|
} : {};
|
|
10234
|
-
const vtxos = await
|
|
10239
|
+
const vtxos = await chunkFZFSGOTZ_cjs.getAllNormalizedVtxos(
|
|
10235
10240
|
this.config.indexerProvider,
|
|
10236
10241
|
contracts.map((c) => c.script),
|
|
10237
10242
|
{ ...windowOpts, pageSize }
|
|
@@ -10376,7 +10381,7 @@ var deserializeTapLeaf = (t) => {
|
|
|
10376
10381
|
const s = base.hex.decode(t.s);
|
|
10377
10382
|
return [cb, s];
|
|
10378
10383
|
};
|
|
10379
|
-
var deserializeVtxo = (o) =>
|
|
10384
|
+
var deserializeVtxo = (o) => chunkFZFSGOTZ_cjs.normalizeVtxo({
|
|
10380
10385
|
...o,
|
|
10381
10386
|
createdAt: new Date(o.createdAt),
|
|
10382
10387
|
tapTree: base.hex.decode(o.tapTree),
|
|
@@ -11417,7 +11422,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
11417
11422
|
*/
|
|
11418
11423
|
materializeDescriptorAt(index) {
|
|
11419
11424
|
const descriptor = this.identity.descriptor;
|
|
11420
|
-
const network =
|
|
11425
|
+
const network = chunkWXCVS6PD_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
11421
11426
|
const expansion = descriptorsScure.expand({ descriptor, network, index });
|
|
11422
11427
|
const keyInfo = expansion.expansionMap?.["@0"];
|
|
11423
11428
|
if (!keyInfo?.keyExpression) {
|
|
@@ -11565,7 +11570,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
11565
11570
|
const provider = await resolveDescriptorProvider(config, setup.walletRepository);
|
|
11566
11571
|
if (!provider) return void 0;
|
|
11567
11572
|
const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
|
|
11568
|
-
const expectedContractType = setup.offchainTapscript instanceof
|
|
11573
|
+
const expectedContractType = setup.offchainTapscript instanceof chunkWXCVS6PD_cjs.DelegateVtxo.Script ? "delegate" : "default";
|
|
11569
11574
|
const factoryOpts = {
|
|
11570
11575
|
walletRepository: setup.walletRepository,
|
|
11571
11576
|
contractRepository: setup.contractRepository,
|
|
@@ -11764,7 +11769,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
11764
11769
|
};
|
|
11765
11770
|
function deriveLeafPubkey(descriptor) {
|
|
11766
11771
|
try {
|
|
11767
|
-
return
|
|
11772
|
+
return chunkWXCVS6PD_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
11768
11773
|
} catch (e) {
|
|
11769
11774
|
throw new NonRangeableDescriptorError(
|
|
11770
11775
|
"Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
|
|
@@ -11776,7 +11781,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
11776
11781
|
const pubKey = deriveLeafPubkey(descriptor);
|
|
11777
11782
|
const tapscript = rebuildTapscript(current, pubKey);
|
|
11778
11783
|
const serverPubKey = tapscript.options.serverPubKey;
|
|
11779
|
-
const csvTimelock =
|
|
11784
|
+
const csvTimelock = chunkFZFSGOTZ_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
|
|
11780
11785
|
const base$1 = {
|
|
11781
11786
|
script: base.hex.encode(tapscript.pkScript),
|
|
11782
11787
|
address: tapscript.address(hrp, serverPubKey).encode(),
|
|
@@ -11787,11 +11792,11 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
11787
11792
|
// index-0 key. Without it, spends produce unsigned PSBTs that the
|
|
11788
11793
|
// server rejects with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
11789
11794
|
metadata: {
|
|
11790
|
-
...{ source:
|
|
11795
|
+
...{ source: chunkWXCVS6PD_cjs.WALLET_RECEIVE_SOURCE },
|
|
11791
11796
|
signingDescriptor: descriptor
|
|
11792
11797
|
}
|
|
11793
11798
|
};
|
|
11794
|
-
const params = tapscript instanceof
|
|
11799
|
+
const params = tapscript instanceof chunkWXCVS6PD_cjs.DelegateVtxo.Script ? {
|
|
11795
11800
|
...base$1,
|
|
11796
11801
|
type: "delegate",
|
|
11797
11802
|
params: {
|
|
@@ -11812,10 +11817,10 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
11812
11817
|
return { tapscript, params };
|
|
11813
11818
|
}
|
|
11814
11819
|
function rebuildTapscript(current, pubKey) {
|
|
11815
|
-
if (current instanceof
|
|
11816
|
-
return new
|
|
11820
|
+
if (current instanceof chunkWXCVS6PD_cjs.DelegateVtxo.Script) {
|
|
11821
|
+
return new chunkWXCVS6PD_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
|
|
11817
11822
|
}
|
|
11818
|
-
return new
|
|
11823
|
+
return new chunkWXCVS6PD_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
|
|
11819
11824
|
}
|
|
11820
11825
|
async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
|
|
11821
11826
|
const candidates = await contractRepository.getContracts({
|
|
@@ -11824,7 +11829,7 @@ async function pickActiveReceive(contractRepository, serverPubKey, expectedType)
|
|
|
11824
11829
|
});
|
|
11825
11830
|
const serverPubKeyHex = base.hex.encode(serverPubKey);
|
|
11826
11831
|
const matching = candidates.filter(
|
|
11827
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
11832
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkWXCVS6PD_cjs.WALLET_RECEIVE_SOURCE
|
|
11828
11833
|
).sort((a, b) => {
|
|
11829
11834
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
11830
11835
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -11879,17 +11884,17 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
11879
11884
|
}
|
|
11880
11885
|
};
|
|
11881
11886
|
for (const vtxo of vtxos) {
|
|
11882
|
-
if (
|
|
11887
|
+
if (chunkFZFSGOTZ_cjs.hasTerminalSpend(vtxo)) continue;
|
|
11883
11888
|
addAssets(owned, vtxo);
|
|
11884
11889
|
if (isPendingRecovery(vtxo)) {
|
|
11885
11890
|
pendingRecovery += vtxo.value;
|
|
11886
11891
|
continue;
|
|
11887
11892
|
}
|
|
11888
|
-
if (
|
|
11893
|
+
if (chunkFZFSGOTZ_cjs.canRecoverOnchain(vtxo, now)) {
|
|
11889
11894
|
recoverable += vtxo.value;
|
|
11890
11895
|
continue;
|
|
11891
11896
|
}
|
|
11892
|
-
if (!
|
|
11897
|
+
if (!chunkFZFSGOTZ_cjs.canSpendOffchain(vtxo, now)) continue;
|
|
11893
11898
|
if (vtxo.isPreconfirmed) {
|
|
11894
11899
|
preconfirmed += vtxo.value;
|
|
11895
11900
|
} else {
|
|
@@ -12058,12 +12063,12 @@ var InputSignerRouter = class {
|
|
|
12058
12063
|
};
|
|
12059
12064
|
|
|
12060
12065
|
// src/wallet/wallet.ts
|
|
12061
|
-
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl ||
|
|
12066
|
+
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl || chunkFZFSGOTZ_cjs.DEFAULT_ARKADE_SERVER_URL;
|
|
12062
12067
|
function intentProofJobs(coins) {
|
|
12063
12068
|
if (coins.length === 0) return [];
|
|
12064
12069
|
const coinJobs = coins.map((coin, i) => ({
|
|
12065
12070
|
index: i + 1,
|
|
12066
|
-
lookupScript:
|
|
12071
|
+
lookupScript: chunkFZFSGOTZ_cjs.VtxoScript.decode(coin.tapTree).pkScript
|
|
12067
12072
|
}));
|
|
12068
12073
|
return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
|
|
12069
12074
|
}
|
|
@@ -12100,7 +12105,7 @@ function dedupeTimelocks(timelocks) {
|
|
|
12100
12105
|
const seen = /* @__PURE__ */ new Set();
|
|
12101
12106
|
const deduped = [];
|
|
12102
12107
|
for (const timelock of timelocks) {
|
|
12103
|
-
const sequence =
|
|
12108
|
+
const sequence = chunkFZFSGOTZ_cjs.timelockToSequence(timelock).toString();
|
|
12104
12109
|
if (seen.has(sequence)) continue;
|
|
12105
12110
|
seen.add(sequence);
|
|
12106
12111
|
deduped.push(timelock);
|
|
@@ -12117,7 +12122,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
12117
12122
|
state: "active"
|
|
12118
12123
|
});
|
|
12119
12124
|
const newest = candidates.filter(
|
|
12120
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
12125
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkWXCVS6PD_cjs.WALLET_RECEIVE_SOURCE
|
|
12121
12126
|
).sort((a, b) => {
|
|
12122
12127
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
12123
12128
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -12125,7 +12130,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
12125
12130
|
if (!newest?.params.pubKey) return baseline;
|
|
12126
12131
|
try {
|
|
12127
12132
|
const pubKey = base.hex.decode(newest.params.pubKey);
|
|
12128
|
-
return new
|
|
12133
|
+
return new chunkWXCVS6PD_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
|
|
12129
12134
|
} catch (e) {
|
|
12130
12135
|
console.warn("Skipping malformed boarding contract at boot", newest.script, e);
|
|
12131
12136
|
return baseline;
|
|
@@ -12141,8 +12146,8 @@ function filterSnapshotVtxos(snapshot, filter, pendingSpendOutpoints) {
|
|
|
12141
12146
|
if (pendingSpendOutpoints.has(`${vtxo.txid}:${vtxo.vout}`)) {
|
|
12142
12147
|
return false;
|
|
12143
12148
|
}
|
|
12144
|
-
if (!
|
|
12145
|
-
if (!f.withRecoverable &&
|
|
12149
|
+
if (!chunkFZFSGOTZ_cjs.hasTerminalSpend(vtxo)) {
|
|
12150
|
+
if (!f.withRecoverable && chunkFZFSGOTZ_cjs.canRecoverOnchain(vtxo, now)) {
|
|
12146
12151
|
return false;
|
|
12147
12152
|
}
|
|
12148
12153
|
return true;
|
|
@@ -12483,7 +12488,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12483
12488
|
*/
|
|
12484
12489
|
static async setupWalletConfig(config, pubKey) {
|
|
12485
12490
|
const arkadeServerUrl = getArkadeServerUrl(config);
|
|
12486
|
-
const arkProvider = config.arkProvider || new
|
|
12491
|
+
const arkProvider = config.arkProvider || new chunkFZFSGOTZ_cjs.RestArkProvider(arkadeServerUrl);
|
|
12487
12492
|
let indexerProvider = config.indexerProvider;
|
|
12488
12493
|
if (!indexerProvider) {
|
|
12489
12494
|
let indexerUrl = config.indexerUrl;
|
|
@@ -12500,7 +12505,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12500
12505
|
indexerUrl = arkadeServerUrl;
|
|
12501
12506
|
}
|
|
12502
12507
|
}
|
|
12503
|
-
indexerProvider = new
|
|
12508
|
+
indexerProvider = new chunkRXITDAV4_cjs.RestIndexerProvider(indexerUrl);
|
|
12504
12509
|
}
|
|
12505
12510
|
const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
12506
12511
|
const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
@@ -12509,7 +12514,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12509
12514
|
source: serverInfoSource,
|
|
12510
12515
|
lastOnlineAt: serverInfoLastOnlineAt
|
|
12511
12516
|
} = await resolveArkInfo(arkProvider, walletRepository);
|
|
12512
|
-
const network =
|
|
12517
|
+
const network = chunkFZFSGOTZ_cjs.getNetwork(info.network);
|
|
12513
12518
|
if ("descriptor" in config.identity) {
|
|
12514
12519
|
const descriptor = config.identity.descriptor;
|
|
12515
12520
|
const identityIsMainnet = !descriptor.includes("tpub");
|
|
@@ -12556,11 +12561,11 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12556
12561
|
serverPubKey,
|
|
12557
12562
|
csvTimelock: exitTimelock
|
|
12558
12563
|
};
|
|
12559
|
-
const offchainTapscript = !delegatePubKey ? new
|
|
12560
|
-
const boardingTapscript =
|
|
12564
|
+
const offchainTapscript = !delegatePubKey ? new chunkWXCVS6PD_cjs.DefaultVtxo.Script(offchainOptions) : new chunkWXCVS6PD_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
|
|
12565
|
+
const boardingTapscript = chunkWXCVS6PD_cjs.BoardingContractHandler.createScript({
|
|
12561
12566
|
pubKey: base.hex.encode(pubKey),
|
|
12562
12567
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
12563
|
-
csvTimelock:
|
|
12568
|
+
csvTimelock: chunkFZFSGOTZ_cjs.timelockToSequence(boardingTimelock).toString()
|
|
12564
12569
|
});
|
|
12565
12570
|
return {
|
|
12566
12571
|
arkProvider,
|
|
@@ -12857,7 +12862,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12857
12862
|
const response = await contractManager.getContractsWithVtxos();
|
|
12858
12863
|
const allVtxos = response.flatMap((_) => _.vtxos);
|
|
12859
12864
|
const { boardingTxs, commitmentsToIgnore } = await this.getBoardingTxs();
|
|
12860
|
-
const resolveTxCreatedAt = (txids) =>
|
|
12865
|
+
const resolveTxCreatedAt = (txids) => chunkFZFSGOTZ_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
|
|
12861
12866
|
return buildTransactionHistory(
|
|
12862
12867
|
allVtxos,
|
|
12863
12868
|
boardingTxs,
|
|
@@ -12951,7 +12956,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12951
12956
|
},
|
|
12952
12957
|
isUnrolled: true,
|
|
12953
12958
|
...boardingFacts,
|
|
12954
|
-
virtualStatus:
|
|
12959
|
+
virtualStatus: chunkFZFSGOTZ_cjs.toVirtualStatus(boardingFacts),
|
|
12955
12960
|
spentBy: "",
|
|
12956
12961
|
createdAt: tx.status.confirmed ? new Date(tx.status.block_time * 1e3) : /* @__PURE__ */ new Date(0),
|
|
12957
12962
|
script: scriptHex
|
|
@@ -13007,9 +13012,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13007
13012
|
async getBoardingTapscripts(allowedSigners) {
|
|
13008
13013
|
const byScript = /* @__PURE__ */ new Map();
|
|
13009
13014
|
const add = (s) => byScript.set(base.hex.encode(s.pkScript), s);
|
|
13010
|
-
const boardingCsv = this.boardingTapscript.options.csvTimelock ??
|
|
13015
|
+
const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkWXCVS6PD_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
13011
13016
|
add(
|
|
13012
|
-
new
|
|
13017
|
+
new chunkWXCVS6PD_cjs.DefaultVtxo.Script({
|
|
13013
13018
|
pubKey: await this.identity.xOnlyPublicKey(),
|
|
13014
13019
|
serverPubKey: this.boardingTapscript.options.serverPubKey,
|
|
13015
13020
|
csvTimelock: boardingCsv
|
|
@@ -13024,7 +13029,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13024
13029
|
for (const c of boardingContracts) {
|
|
13025
13030
|
if (!allowed.has(toXOnlySignerHex(c.params.serverPubKey))) continue;
|
|
13026
13031
|
try {
|
|
13027
|
-
add(
|
|
13032
|
+
add(chunkWXCVS6PD_cjs.BoardingContractHandler.createScript(c.params));
|
|
13028
13033
|
} catch (e) {
|
|
13029
13034
|
console.warn("Skipping malformed boarding contract", c.script, e);
|
|
13030
13035
|
}
|
|
@@ -13062,7 +13067,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13062
13067
|
// Per-row CSV delay decoded from THIS tapscript's exit leaf —
|
|
13063
13068
|
// not the wallet's current boarding timelock, which a signer
|
|
13064
13069
|
// rotation may have changed.
|
|
13065
|
-
csvTimelock:
|
|
13070
|
+
csvTimelock: chunkFZFSGOTZ_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
|
|
13066
13071
|
coins: utxos
|
|
13067
13072
|
});
|
|
13068
13073
|
}
|
|
@@ -13195,7 +13200,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13195
13200
|
/** Fetch Arkade transaction ids that are still pending final settlement. */
|
|
13196
13201
|
async fetchPendingTxs() {
|
|
13197
13202
|
const scripts = await this.getWalletScripts();
|
|
13198
|
-
const vtxos = await
|
|
13203
|
+
const vtxos = await chunkFZFSGOTZ_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
|
|
13199
13204
|
return vtxos.filter(
|
|
13200
13205
|
(vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
|
|
13201
13206
|
).map((_) => _.arkTxId);
|
|
@@ -13226,7 +13231,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13226
13231
|
});
|
|
13227
13232
|
for (const contract of contracts) {
|
|
13228
13233
|
if (map.has(contract.script)) continue;
|
|
13229
|
-
const handler =
|
|
13234
|
+
const handler = chunkWXCVS6PD_cjs.contractHandlers.get(contract.type);
|
|
13230
13235
|
if (handler) {
|
|
13231
13236
|
const script = handler.createScript(contract.params);
|
|
13232
13237
|
map.set(contract.script, script);
|
|
@@ -13338,7 +13343,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13338
13343
|
}
|
|
13339
13344
|
});
|
|
13340
13345
|
const baselinePubkey = await this.identity.xOnlyPublicKey();
|
|
13341
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
13346
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkWXCVS6PD_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
13342
13347
|
const baselineSigners = [
|
|
13343
13348
|
this.offchainTapscript.options.serverPubKey,
|
|
13344
13349
|
...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
|
|
@@ -13346,8 +13351,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13346
13351
|
const seenBaselineScripts = /* @__PURE__ */ new Set();
|
|
13347
13352
|
for (const serverPubKey of baselineSigners) {
|
|
13348
13353
|
for (const csvTimelock of this.walletContractTimelocks) {
|
|
13349
|
-
const csvTimelockStr =
|
|
13350
|
-
const defaultScript = new
|
|
13354
|
+
const csvTimelockStr = chunkFZFSGOTZ_cjs.timelockToSequence(csvTimelock).toString();
|
|
13355
|
+
const defaultScript = new chunkWXCVS6PD_cjs.DefaultVtxo.Script({
|
|
13351
13356
|
pubKey: baselinePubkey,
|
|
13352
13357
|
serverPubKey,
|
|
13353
13358
|
csvTimelock
|
|
@@ -13368,7 +13373,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13368
13373
|
});
|
|
13369
13374
|
}
|
|
13370
13375
|
if (delegatePubKey) {
|
|
13371
|
-
const delegateScript = new
|
|
13376
|
+
const delegateScript = new chunkWXCVS6PD_cjs.DelegateVtxo.Script({
|
|
13372
13377
|
pubKey: baselinePubkey,
|
|
13373
13378
|
serverPubKey,
|
|
13374
13379
|
delegatePubKey,
|
|
@@ -13392,9 +13397,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13392
13397
|
}
|
|
13393
13398
|
}
|
|
13394
13399
|
}
|
|
13395
|
-
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ??
|
|
13400
|
+
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkWXCVS6PD_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
13396
13401
|
for (const serverPubKey of baselineSigners) {
|
|
13397
|
-
const baselineBoarding = new
|
|
13402
|
+
const baselineBoarding = new chunkWXCVS6PD_cjs.DefaultVtxo.Script({
|
|
13398
13403
|
pubKey: baselinePubkey,
|
|
13399
13404
|
serverPubKey,
|
|
13400
13405
|
csvTimelock: boardingCsvTimelock
|
|
@@ -13407,7 +13412,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13407
13412
|
params: {
|
|
13408
13413
|
pubKey: base.hex.encode(baselineBoarding.options.pubKey),
|
|
13409
13414
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
13410
|
-
csvTimelock:
|
|
13415
|
+
csvTimelock: chunkFZFSGOTZ_cjs.timelockToSequence(boardingCsvTimelock).toString()
|
|
13411
13416
|
},
|
|
13412
13417
|
script: boardingScriptHex,
|
|
13413
13418
|
address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
|
|
@@ -13586,7 +13591,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13586
13591
|
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
13587
13592
|
deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
|
|
13588
13593
|
csvTimelocks: this.walletContractTimelocks,
|
|
13589
|
-
delegatePubKey: this.offchainTapscript instanceof
|
|
13594
|
+
delegatePubKey: this.offchainTapscript instanceof chunkWXCVS6PD_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
|
|
13590
13595
|
};
|
|
13591
13596
|
}
|
|
13592
13597
|
_signerRouter;
|
|
@@ -13680,24 +13685,24 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13680
13685
|
const manager = await this.getContractManager();
|
|
13681
13686
|
const descriptor = await manager.getNextSigningDescriptor();
|
|
13682
13687
|
if (!descriptor) return this.getBoardingAddress();
|
|
13683
|
-
const pubKey =
|
|
13684
|
-
const newBoarding = new
|
|
13688
|
+
const pubKey = chunkWXCVS6PD_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
13689
|
+
const newBoarding = new chunkWXCVS6PD_cjs.DefaultVtxo.Script({
|
|
13685
13690
|
...this._boardingTapscript.options,
|
|
13686
13691
|
pubKey
|
|
13687
13692
|
});
|
|
13688
|
-
const csvTimelock = newBoarding.options.csvTimelock ??
|
|
13693
|
+
const csvTimelock = newBoarding.options.csvTimelock ?? chunkWXCVS6PD_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
13689
13694
|
await manager.createContract({
|
|
13690
13695
|
type: "boarding",
|
|
13691
13696
|
params: {
|
|
13692
13697
|
pubKey: base.hex.encode(pubKey),
|
|
13693
13698
|
serverPubKey: base.hex.encode(newBoarding.options.serverPubKey),
|
|
13694
|
-
csvTimelock:
|
|
13699
|
+
csvTimelock: chunkFZFSGOTZ_cjs.timelockToSequence(csvTimelock).toString()
|
|
13695
13700
|
},
|
|
13696
13701
|
script: base.hex.encode(newBoarding.pkScript),
|
|
13697
13702
|
address: newBoarding.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
13698
13703
|
state: "active",
|
|
13699
13704
|
metadata: {
|
|
13700
|
-
source:
|
|
13705
|
+
source: chunkWXCVS6PD_cjs.WALLET_RECEIVE_SOURCE,
|
|
13701
13706
|
signingDescriptor: descriptor
|
|
13702
13707
|
}
|
|
13703
13708
|
});
|
|
@@ -13732,7 +13737,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13732
13737
|
if (this._descriptorProvider instanceof HDDescriptorProvider) {
|
|
13733
13738
|
return (await this.getContractManager()).getNextSigningDescriptor();
|
|
13734
13739
|
}
|
|
13735
|
-
return
|
|
13740
|
+
return chunkWXCVS6PD_cjs.identityDescriptor(this.identity);
|
|
13736
13741
|
}
|
|
13737
13742
|
/**
|
|
13738
13743
|
* @see HDAllocationCapable.advanceSigningDescriptorWatermark
|
|
@@ -13857,21 +13862,21 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13857
13862
|
const [currentBoardingRow] = await manager.getContracts({
|
|
13858
13863
|
script: currentBoardingScript
|
|
13859
13864
|
});
|
|
13860
|
-
const newOffchain = this.offchainTapscript instanceof
|
|
13865
|
+
const newOffchain = this.offchainTapscript instanceof chunkWXCVS6PD_cjs.DelegateVtxo.Script ? new chunkWXCVS6PD_cjs.DelegateVtxo.Script({
|
|
13861
13866
|
...this.offchainTapscript.options,
|
|
13862
13867
|
serverPubKey: xonly
|
|
13863
|
-
}) : new
|
|
13868
|
+
}) : new chunkWXCVS6PD_cjs.DefaultVtxo.Script({
|
|
13864
13869
|
...this.offchainTapscript.options,
|
|
13865
13870
|
serverPubKey: xonly
|
|
13866
13871
|
});
|
|
13867
|
-
const newBoarding = new
|
|
13872
|
+
const newBoarding = new chunkWXCVS6PD_cjs.DefaultVtxo.Script({
|
|
13868
13873
|
...this._boardingTapscript.options,
|
|
13869
13874
|
serverPubKey: xonly
|
|
13870
13875
|
});
|
|
13871
|
-
const offchainCsv =
|
|
13876
|
+
const offchainCsv = chunkFZFSGOTZ_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
|
|
13872
13877
|
const newOffchainScript = base.hex.encode(newOffchain.pkScript);
|
|
13873
13878
|
const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
|
|
13874
|
-
if (newOffchain instanceof
|
|
13879
|
+
if (newOffchain instanceof chunkWXCVS6PD_cjs.DelegateVtxo.Script) {
|
|
13875
13880
|
await manager.createContract({
|
|
13876
13881
|
type: "delegate",
|
|
13877
13882
|
params: {
|
|
@@ -13899,13 +13904,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13899
13904
|
metadata: currentOffchainRow?.metadata
|
|
13900
13905
|
});
|
|
13901
13906
|
}
|
|
13902
|
-
const boardingCsv = newBoarding.options.csvTimelock ??
|
|
13907
|
+
const boardingCsv = newBoarding.options.csvTimelock ?? chunkWXCVS6PD_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
13903
13908
|
await manager.createContract({
|
|
13904
13909
|
type: "boarding",
|
|
13905
13910
|
params: {
|
|
13906
13911
|
pubKey: base.hex.encode(newBoarding.options.pubKey),
|
|
13907
13912
|
serverPubKey: base.hex.encode(xonly),
|
|
13908
|
-
csvTimelock:
|
|
13913
|
+
csvTimelock: chunkFZFSGOTZ_cjs.timelockToSequence(boardingCsv).toString()
|
|
13909
13914
|
},
|
|
13910
13915
|
script: base.hex.encode(newBoarding.pkScript),
|
|
13911
13916
|
address: newBoarding.address(this.network.hrp, xonly).encode(),
|
|
@@ -13938,14 +13943,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13938
13943
|
_restoreInFlight;
|
|
13939
13944
|
_addPendingSpends(inputs) {
|
|
13940
13945
|
for (const input of inputs) {
|
|
13941
|
-
if (
|
|
13946
|
+
if (chunkFZFSGOTZ_cjs.isVirtualCoin(input)) {
|
|
13942
13947
|
this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
|
|
13943
13948
|
}
|
|
13944
13949
|
}
|
|
13945
13950
|
}
|
|
13946
13951
|
_removePendingSpends(inputs) {
|
|
13947
13952
|
for (const input of inputs) {
|
|
13948
|
-
if (
|
|
13953
|
+
if (chunkFZFSGOTZ_cjs.isVirtualCoin(input)) {
|
|
13949
13954
|
this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
|
|
13950
13955
|
}
|
|
13951
13956
|
}
|
|
@@ -14003,9 +14008,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14003
14008
|
const manager = await this.getContractManager();
|
|
14004
14009
|
const provider = this._descriptorProvider;
|
|
14005
14010
|
const hd = provider instanceof HDDescriptorProvider;
|
|
14006
|
-
const staticDescriptor = hd ? void 0 : await
|
|
14011
|
+
const staticDescriptor = hd ? void 0 : await chunkWXCVS6PD_cjs.identityDescriptor(this.identity);
|
|
14007
14012
|
const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
|
|
14008
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
14013
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkWXCVS6PD_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
14009
14014
|
const arkInfo = await this.arkProvider.getInfo();
|
|
14010
14015
|
const currentSignerPubKey = toXOnlyPubKey(base.hex.decode(arkInfo.signerPubkey));
|
|
14011
14016
|
const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
|
|
@@ -14024,7 +14029,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14024
14029
|
csvTimelocks: this.walletContractTimelocks,
|
|
14025
14030
|
// Boarding-exit CSV so the boarding handler can build its
|
|
14026
14031
|
// candidate script (distinct from the unilateral-exit matrix).
|
|
14027
|
-
boardingTimelock: this.boardingTapscript.options.csvTimelock ??
|
|
14032
|
+
boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkWXCVS6PD_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
|
|
14028
14033
|
delegatePubKey
|
|
14029
14034
|
};
|
|
14030
14035
|
const result = await manager.scanContracts({
|
|
@@ -14287,7 +14292,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14287
14292
|
inputs: params.selectedVtxos,
|
|
14288
14293
|
changeAmount: BigInt(changeAmount)
|
|
14289
14294
|
};
|
|
14290
|
-
const outputAddress =
|
|
14295
|
+
const outputAddress = chunkFZFSGOTZ_cjs.ArkAddress.decode(params.address);
|
|
14291
14296
|
assertRecipientArkAddress(
|
|
14292
14297
|
params.address,
|
|
14293
14298
|
outputAddress,
|
|
@@ -14353,13 +14358,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14353
14358
|
void this.logUngatedInputs("settle({ inputs })", params.inputs);
|
|
14354
14359
|
}
|
|
14355
14360
|
const offchainAddress = await this.getAddress();
|
|
14356
|
-
const offchainPkScript =
|
|
14361
|
+
const offchainPkScript = chunkFZFSGOTZ_cjs.ArkAddress.decode(offchainAddress).pkScript;
|
|
14357
14362
|
const offchainOutputScript = base.hex.encode(offchainPkScript);
|
|
14358
14363
|
if (!params) {
|
|
14359
14364
|
const { fees, vtxoMaxAmount } = await this.arkProvider.getInfo();
|
|
14360
14365
|
const estimator = new Estimator(fees.intentFee);
|
|
14361
14366
|
let amount = 0;
|
|
14362
|
-
const exitScript =
|
|
14367
|
+
const exitScript = chunkFZFSGOTZ_cjs.CSVMultisigTapscript.decode(
|
|
14363
14368
|
base.hex.decode(this.boardingTapscript.exitScript)
|
|
14364
14369
|
);
|
|
14365
14370
|
const boardingTimelock = exitScript.params.timelock;
|
|
@@ -14388,7 +14393,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14388
14393
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
14389
14394
|
break;
|
|
14390
14395
|
}
|
|
14391
|
-
const inputFee = estimator.evalOffchainInput(
|
|
14396
|
+
const inputFee = estimator.evalOffchainInput(chunkFZFSGOTZ_cjs.toOffchainInputFeeParams(vtxo));
|
|
14392
14397
|
if (inputFee.satoshis >= vtxo.value) {
|
|
14393
14398
|
continue;
|
|
14394
14399
|
}
|
|
@@ -14435,7 +14440,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14435
14440
|
let script;
|
|
14436
14441
|
let arkAddress;
|
|
14437
14442
|
try {
|
|
14438
|
-
arkAddress =
|
|
14443
|
+
arkAddress = chunkFZFSGOTZ_cjs.ArkAddress.decode(output.address);
|
|
14439
14444
|
} catch {
|
|
14440
14445
|
arkAddress = void 0;
|
|
14441
14446
|
}
|
|
@@ -14525,7 +14530,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14525
14530
|
const abortController = new AbortController();
|
|
14526
14531
|
let stream;
|
|
14527
14532
|
let committedTxid;
|
|
14528
|
-
const settleInputVtxos = params.inputs.filter(
|
|
14533
|
+
const settleInputVtxos = params.inputs.filter(chunkFZFSGOTZ_cjs.isVirtualCoin);
|
|
14529
14534
|
const contractManager = await this.getContractManager();
|
|
14530
14535
|
await contractManager.assertAnnotatable(settleInputVtxos);
|
|
14531
14536
|
await contractManager.assertSpendableNow?.(
|
|
@@ -14634,7 +14639,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14634
14639
|
async maybeRotateBoardingAfterBoard(inputs) {
|
|
14635
14640
|
if (!this._descriptorProvider) return;
|
|
14636
14641
|
const consumedBoarding = inputs.some(
|
|
14637
|
-
(input) => typeof input !== "string" && !
|
|
14642
|
+
(input) => typeof input !== "string" && !chunkFZFSGOTZ_cjs.isVirtualCoin(input)
|
|
14638
14643
|
);
|
|
14639
14644
|
if (!consumedBoarding) return;
|
|
14640
14645
|
try {
|
|
@@ -14658,7 +14663,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14658
14663
|
let connectorIndex = 0;
|
|
14659
14664
|
const connectorsLeaves = connectorsGraph?.leaves() || [];
|
|
14660
14665
|
for (const input of inputs) {
|
|
14661
|
-
if (!
|
|
14666
|
+
if (!chunkFZFSGOTZ_cjs.isVirtualCoin(input)) {
|
|
14662
14667
|
for (let i = 0; i < settlementPsbt.inputsLength; i++) {
|
|
14663
14668
|
const settlementInput = settlementPsbt.getInput(i);
|
|
14664
14669
|
if (!settlementInput.txid || settlementInput.index === void 0) {
|
|
@@ -14689,7 +14694,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14689
14694
|
}
|
|
14690
14695
|
continue;
|
|
14691
14696
|
}
|
|
14692
|
-
if (
|
|
14697
|
+
if (chunkFZFSGOTZ_cjs.canRecoverOnchain(input, { timestamp: /* @__PURE__ */ new Date() }) || isSubdust({ value: input.value }, this.dustAmount)) {
|
|
14693
14698
|
continue;
|
|
14694
14699
|
}
|
|
14695
14700
|
if (connectorsLeaves.length === 0) {
|
|
@@ -14717,7 +14722,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14717
14722
|
index: input.vout,
|
|
14718
14723
|
witnessUtxo: {
|
|
14719
14724
|
amount: BigInt(input.value),
|
|
14720
|
-
script:
|
|
14725
|
+
script: chunkFZFSGOTZ_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
14721
14726
|
},
|
|
14722
14727
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
14723
14728
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -14736,7 +14741,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14736
14741
|
forfeitTx = await this._signerRouter.sign(forfeitTx, [
|
|
14737
14742
|
{
|
|
14738
14743
|
index: 0,
|
|
14739
|
-
lookupScript:
|
|
14744
|
+
lookupScript: chunkFZFSGOTZ_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
14740
14745
|
}
|
|
14741
14746
|
]);
|
|
14742
14747
|
signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
|
|
@@ -14794,7 +14799,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14794
14799
|
resolveBatchExpiryPolicy(this.network, this.batchExpiryPolicy)
|
|
14795
14800
|
);
|
|
14796
14801
|
await this.arkProvider.confirmRegistration(intentId);
|
|
14797
|
-
const sweepTapscript =
|
|
14802
|
+
const sweepTapscript = chunkFZFSGOTZ_cjs.CSVMultisigTapscript.encode({
|
|
14798
14803
|
timelock,
|
|
14799
14804
|
pubkeys: [this.forfeitPubkey]
|
|
14800
14805
|
}).script;
|
|
@@ -14900,9 +14905,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14900
14905
|
...existing ?? {},
|
|
14901
14906
|
intentTxId,
|
|
14902
14907
|
registerProof: intent.proof,
|
|
14903
|
-
registerProofMessage:
|
|
14908
|
+
registerProofMessage: chunkFZFSGOTZ_cjs.Intent.encodeMessage(intent.message),
|
|
14904
14909
|
deleteProof: deleteIntent.proof,
|
|
14905
|
-
deleteProofMessage:
|
|
14910
|
+
deleteProofMessage: chunkFZFSGOTZ_cjs.Intent.encodeMessage(deleteIntent.message),
|
|
14906
14911
|
intentVtxos: inputs.map((i) => ({
|
|
14907
14912
|
txid: i.txid,
|
|
14908
14913
|
vout: i.vout
|
|
@@ -14934,7 +14939,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14934
14939
|
try {
|
|
14935
14940
|
return await this.arkProvider.registerIntent(intent);
|
|
14936
14941
|
} catch (error) {
|
|
14937
|
-
if (error instanceof
|
|
14942
|
+
if (error instanceof chunkFZFSGOTZ_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
|
|
14938
14943
|
const deleteIntent = await this.makeDeleteIntentSignature(inputs);
|
|
14939
14944
|
await this.arkProvider.deleteIntent(deleteIntent);
|
|
14940
14945
|
return this.arkProvider.registerIntent(intent);
|
|
@@ -14950,7 +14955,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14950
14955
|
expire_at: 0,
|
|
14951
14956
|
cosigners_public_keys: cosignerPubKeys
|
|
14952
14957
|
};
|
|
14953
|
-
const proof =
|
|
14958
|
+
const proof = chunkFZFSGOTZ_cjs.Intent.create(message, coins, outputs);
|
|
14954
14959
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
14955
14960
|
return {
|
|
14956
14961
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -14962,7 +14967,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14962
14967
|
type: "delete",
|
|
14963
14968
|
expire_at: 0
|
|
14964
14969
|
};
|
|
14965
|
-
const proof =
|
|
14970
|
+
const proof = chunkFZFSGOTZ_cjs.Intent.create(message, coins, []);
|
|
14966
14971
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
14967
14972
|
return {
|
|
14968
14973
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -14974,7 +14979,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14974
14979
|
type: "get-pending-tx",
|
|
14975
14980
|
expire_at: 0
|
|
14976
14981
|
};
|
|
14977
|
-
const proof =
|
|
14982
|
+
const proof = chunkFZFSGOTZ_cjs.Intent.create(message, coins, []);
|
|
14978
14983
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
14979
14984
|
return {
|
|
14980
14985
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -14995,7 +15000,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14995
15000
|
if (!vtxos || vtxos.length === 0) {
|
|
14996
15001
|
const scriptMap = await this.getScriptMap();
|
|
14997
15002
|
const allExtended = [];
|
|
14998
|
-
const fetchedVtxos = await
|
|
15003
|
+
const fetchedVtxos = await chunkFZFSGOTZ_cjs.getAllNormalizedVtxos(this.indexerProvider, [
|
|
14999
15004
|
...scriptMap.keys()
|
|
15000
15005
|
]);
|
|
15001
15006
|
for (const vtxo of fetchedVtxos) {
|
|
@@ -15109,11 +15114,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15109
15114
|
* against the current key alone would leave it pending forever.
|
|
15110
15115
|
*/
|
|
15111
15116
|
checkpointUnrollCandidates(info) {
|
|
15112
|
-
const current =
|
|
15117
|
+
const current = chunkFZFSGOTZ_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
15113
15118
|
const candidates = [this._serverUnrollScript, current];
|
|
15114
15119
|
for (const deprecated of signerSetFromInfo(info).deprecated.keys()) {
|
|
15115
15120
|
candidates.push(
|
|
15116
|
-
|
|
15121
|
+
chunkFZFSGOTZ_cjs.CSVMultisigTapscript.encode({
|
|
15117
15122
|
...current.params,
|
|
15118
15123
|
pubkeys: [base.hex.decode(deprecated)]
|
|
15119
15124
|
})
|
|
@@ -15204,7 +15209,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15204
15209
|
if (vtxos.length === 0) {
|
|
15205
15210
|
throw new Error("No VTXOs found for this arkadeCash");
|
|
15206
15211
|
}
|
|
15207
|
-
const myPkScript =
|
|
15212
|
+
const myPkScript = chunkFZFSGOTZ_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
|
|
15208
15213
|
let { spendable, unclaimed } = this.classifyCashVtxos(vtxos);
|
|
15209
15214
|
let swept = 0;
|
|
15210
15215
|
const drainable = vtxos.filter((vtxo) => !isSubdust(vtxo, this.dustAmount));
|
|
@@ -15278,7 +15283,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15278
15283
|
const spendable = [];
|
|
15279
15284
|
const unclaimed = [];
|
|
15280
15285
|
for (const vtxo of vtxos) {
|
|
15281
|
-
if (
|
|
15286
|
+
if (chunkFZFSGOTZ_cjs.hasTerminalSpend(vtxo)) {
|
|
15282
15287
|
unclaimed.push(cashReport(vtxo, "already-spent"));
|
|
15283
15288
|
} else if (isSubdust(vtxo, this.dustAmount)) {
|
|
15284
15289
|
unclaimed.push(cashReport(vtxo, "subdust"));
|
|
@@ -15298,7 +15303,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15298
15303
|
const all = [];
|
|
15299
15304
|
const seen = /* @__PURE__ */ new Set();
|
|
15300
15305
|
for (let pageIndex = 0; ; pageIndex++) {
|
|
15301
|
-
const { vtxos, page } = await
|
|
15306
|
+
const { vtxos, page } = await chunkFZFSGOTZ_cjs.getNormalizedVtxos(this.indexerProvider, {
|
|
15302
15307
|
scripts,
|
|
15303
15308
|
pageIndex,
|
|
15304
15309
|
pageSize
|
|
@@ -15345,7 +15350,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15345
15350
|
for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
|
|
15346
15351
|
const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
|
|
15347
15352
|
const message = { type: "get-pending-tx", expire_at: 0 };
|
|
15348
|
-
const proof =
|
|
15353
|
+
const proof = chunkFZFSGOTZ_cjs.Intent.create(message, batch, []);
|
|
15349
15354
|
const signedProof = await identity.sign(
|
|
15350
15355
|
proof,
|
|
15351
15356
|
Array.from({ length: batch.length + 1 }, (_, j) => j)
|
|
@@ -15564,7 +15569,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15564
15569
|
script: recipient.script,
|
|
15565
15570
|
amount: BigInt(recipient.amount),
|
|
15566
15571
|
// Already checked against the recipient address in `validateRecipients`.
|
|
15567
|
-
...recipient.tapTree ? { tapTree:
|
|
15572
|
+
...recipient.tapTree ? { tapTree: chunkFZFSGOTZ_cjs.TapTreeCoder.decode(recipient.tapTree) } : {}
|
|
15568
15573
|
}));
|
|
15569
15574
|
const totalBtcOutput = outputs.reduce((sum, o) => sum + Number(o.amount), 0);
|
|
15570
15575
|
let changeAmount = totalBtcSelected - totalBtcOutput;
|
|
@@ -15708,10 +15713,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15708
15713
|
const serverPubKey = this.arkServerPublicKey;
|
|
15709
15714
|
const serverUnrollScript = this.serverUnrollScript;
|
|
15710
15715
|
const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
|
|
15711
|
-
const normalizedInputs = inputs.map(
|
|
15712
|
-
const at = now ?? await
|
|
15716
|
+
const normalizedInputs = inputs.map(chunkFZFSGOTZ_cjs.normalizeVtxo);
|
|
15717
|
+
const at = now ?? await chunkFZFSGOTZ_cjs.resolveTimeHeight(this.onchainProvider);
|
|
15713
15718
|
for (const input of normalizedInputs) {
|
|
15714
|
-
if (!
|
|
15719
|
+
if (!chunkFZFSGOTZ_cjs.canSpendOffchain(input, at)) {
|
|
15715
15720
|
throw new Error(
|
|
15716
15721
|
`sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
|
|
15717
15722
|
);
|
|
@@ -15781,7 +15786,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15781
15786
|
);
|
|
15782
15787
|
const arkTxJobs = inputs.map((input, index) => ({
|
|
15783
15788
|
index,
|
|
15784
|
-
lookupScript:
|
|
15789
|
+
lookupScript: chunkFZFSGOTZ_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
15785
15790
|
}));
|
|
15786
15791
|
const identity = this.identity;
|
|
15787
15792
|
const signer = {
|
|
@@ -15867,14 +15872,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15867
15872
|
const spentBy = checkpointIdByOutpoint.get(`${vtxo.txid}:${vtxo.vout}`);
|
|
15868
15873
|
spentVtxos.push({
|
|
15869
15874
|
...spentFacts,
|
|
15870
|
-
virtualStatus:
|
|
15875
|
+
virtualStatus: chunkFZFSGOTZ_cjs.toVirtualStatus(spentFacts),
|
|
15871
15876
|
...spentBy ? { spentBy } : {},
|
|
15872
15877
|
arkTxId: arkTxid
|
|
15873
15878
|
});
|
|
15874
15879
|
for (const id of vtxo.commitmentTxIds) {
|
|
15875
15880
|
commitmentTxIds.add(id);
|
|
15876
15881
|
}
|
|
15877
|
-
const vtxoExpiry =
|
|
15882
|
+
const vtxoExpiry = chunkFZFSGOTZ_cjs.toBatchExpiry(vtxo);
|
|
15878
15883
|
if (vtxoExpiry) {
|
|
15879
15884
|
batchExpiry = Math.min(batchExpiry, vtxoExpiry);
|
|
15880
15885
|
}
|
|
@@ -15887,7 +15892,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15887
15892
|
isSwept: false,
|
|
15888
15893
|
isPreconfirmed: true,
|
|
15889
15894
|
commitmentTxIds: Array.from(commitmentTxIds),
|
|
15890
|
-
...
|
|
15895
|
+
...chunkFZFSGOTZ_cjs.parseLegacyExpiry(batchExpiry)
|
|
15891
15896
|
};
|
|
15892
15897
|
changeVtxo = {
|
|
15893
15898
|
txid: arkTxid,
|
|
@@ -15899,7 +15904,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15899
15904
|
tapTree: offchainTapscript.encode(),
|
|
15900
15905
|
value: Number(changeAmount),
|
|
15901
15906
|
...changeFacts,
|
|
15902
|
-
virtualStatus:
|
|
15907
|
+
virtualStatus: chunkFZFSGOTZ_cjs.toVirtualStatus(changeFacts),
|
|
15903
15908
|
spentBy: "",
|
|
15904
15909
|
status: {
|
|
15905
15910
|
confirmed: false
|
|
@@ -15968,12 +15973,12 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15968
15973
|
const spentVtxos = [];
|
|
15969
15974
|
const inputArkTxIds = /* @__PURE__ */ new Set();
|
|
15970
15975
|
const boardingRemovalsByAddress = /* @__PURE__ */ new Map();
|
|
15971
|
-
const vtxoInputs = inputs.filter(
|
|
15976
|
+
const vtxoInputs = inputs.filter(chunkFZFSGOTZ_cjs.isVirtualCoin);
|
|
15972
15977
|
const cm = await this.getContractManager();
|
|
15973
15978
|
const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
|
|
15974
15979
|
const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
|
|
15975
15980
|
for (const input of inputs) {
|
|
15976
|
-
if (
|
|
15981
|
+
if (chunkFZFSGOTZ_cjs.isVirtualCoin(input)) {
|
|
15977
15982
|
const outpoint = `${input.txid}:${input.vout}`;
|
|
15978
15983
|
const vtxo = annotatedByKey.get(outpoint);
|
|
15979
15984
|
if (!vtxo) {
|
|
@@ -15985,13 +15990,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
15985
15990
|
const settledFacts = { ...vtxo, isSpent: true };
|
|
15986
15991
|
spentVtxos.push({
|
|
15987
15992
|
...settledFacts,
|
|
15988
|
-
virtualStatus:
|
|
15993
|
+
virtualStatus: chunkFZFSGOTZ_cjs.toVirtualStatus(settledFacts),
|
|
15989
15994
|
settledBy: commitmentTxid
|
|
15990
15995
|
});
|
|
15991
15996
|
} else {
|
|
15992
15997
|
let sourceAddress;
|
|
15993
15998
|
try {
|
|
15994
|
-
sourceAddress =
|
|
15999
|
+
sourceAddress = chunkFZFSGOTZ_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
|
|
15995
16000
|
this.network
|
|
15996
16001
|
);
|
|
15997
16002
|
} catch {
|
|
@@ -16049,9 +16054,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
16049
16054
|
}
|
|
16050
16055
|
};
|
|
16051
16056
|
function selectVirtualCoins(coins, targetAmount) {
|
|
16052
|
-
const sortedCoins = coins.map(
|
|
16053
|
-
const expiryA =
|
|
16054
|
-
const expiryB =
|
|
16057
|
+
const sortedCoins = coins.map(chunkFZFSGOTZ_cjs.normalizeVtxo).sort((a, b) => {
|
|
16058
|
+
const expiryA = chunkFZFSGOTZ_cjs.toBatchExpiry(a) || Number.MAX_SAFE_INTEGER;
|
|
16059
|
+
const expiryB = chunkFZFSGOTZ_cjs.toBatchExpiry(b) || Number.MAX_SAFE_INTEGER;
|
|
16055
16060
|
if (expiryA !== expiryB) {
|
|
16056
16061
|
return expiryA - expiryB;
|
|
16057
16062
|
}
|
|
@@ -16311,7 +16316,7 @@ var MessageBus = class {
|
|
|
16311
16316
|
this.initialized = true;
|
|
16312
16317
|
}
|
|
16313
16318
|
async buildServices(config) {
|
|
16314
|
-
const arkProvider = new
|
|
16319
|
+
const arkProvider = new chunkFZFSGOTZ_cjs.RestArkProvider(config.arkServer.url);
|
|
16315
16320
|
const storage = {
|
|
16316
16321
|
walletRepository: this.walletRepository,
|
|
16317
16322
|
contractRepository: this.contractRepository,
|
|
@@ -16653,7 +16658,7 @@ var offboardNetworkNames = [
|
|
|
16653
16658
|
function offboardDestinationScript(destinationAddress) {
|
|
16654
16659
|
for (const networkName of offboardNetworkNames) {
|
|
16655
16660
|
try {
|
|
16656
|
-
const network =
|
|
16661
|
+
const network = chunkFZFSGOTZ_cjs.networks[networkName];
|
|
16657
16662
|
const addr = btcSigner.Address(network).decode(destinationAddress);
|
|
16658
16663
|
return btcSigner.OutScript.encode(addr);
|
|
16659
16664
|
} catch {
|
|
@@ -16717,7 +16722,7 @@ var Ramps = class {
|
|
|
16717
16722
|
}
|
|
16718
16723
|
amount = amount ?? totalAmount;
|
|
16719
16724
|
const offchainAddress = await this.wallet.getAddress();
|
|
16720
|
-
const offchainAddr =
|
|
16725
|
+
const offchainAddr = chunkFZFSGOTZ_cjs.ArkAddress.decode(offchainAddress);
|
|
16721
16726
|
const offchainScript = base.hex.encode(offchainAddr.pkScript);
|
|
16722
16727
|
const outputFee = estimator.evalOffchainOutput({
|
|
16723
16728
|
amount,
|
|
@@ -16777,7 +16782,7 @@ var Ramps = class {
|
|
|
16777
16782
|
const filteredVtxos = [];
|
|
16778
16783
|
let totalAmount = 0n;
|
|
16779
16784
|
for (const vtxo of vtxos) {
|
|
16780
|
-
const inputFee = estimator.evalOffchainInput(
|
|
16785
|
+
const inputFee = estimator.evalOffchainInput(chunkFZFSGOTZ_cjs.toOffchainInputFeeParams(vtxo));
|
|
16781
16786
|
if (inputFee.satoshis >= vtxo.value) {
|
|
16782
16787
|
continue;
|
|
16783
16788
|
}
|
|
@@ -17544,7 +17549,7 @@ var WalletMessageHandler = class {
|
|
|
17544
17549
|
// Wallet methods
|
|
17545
17550
|
async handleInitWallet({ payload }) {
|
|
17546
17551
|
const { arkServerUrl } = payload;
|
|
17547
|
-
this.indexerProvider = new
|
|
17552
|
+
this.indexerProvider = new chunkRXITDAV4_cjs.RestIndexerProvider(arkServerUrl);
|
|
17548
17553
|
await this.onWalletInitialized();
|
|
17549
17554
|
}
|
|
17550
17555
|
/**
|
|
@@ -17811,17 +17816,17 @@ var WalletMessageHandler = class {
|
|
|
17811
17816
|
throw new WalletNotInitializedError();
|
|
17812
17817
|
}
|
|
17813
17818
|
const allVtxos = await this.getVtxosFromRepo();
|
|
17814
|
-
const vtxos = allVtxos.filter((v) => !
|
|
17819
|
+
const vtxos = allVtxos.filter((v) => !chunkFZFSGOTZ_cjs.hasTerminalSpend(v));
|
|
17815
17820
|
const dustAmount = this.readonlyWallet.dustAmount;
|
|
17816
17821
|
const includeRecoverable = message.payload.filter?.withRecoverable ?? false;
|
|
17817
17822
|
const filteredVtxos = includeRecoverable ? vtxos : vtxos.filter((v) => {
|
|
17818
17823
|
if (dustAmount != null && isSubdust(v, dustAmount)) {
|
|
17819
17824
|
return false;
|
|
17820
17825
|
}
|
|
17821
|
-
if (
|
|
17826
|
+
if (chunkFZFSGOTZ_cjs.isRecoverable(v)) {
|
|
17822
17827
|
return false;
|
|
17823
17828
|
}
|
|
17824
|
-
if (
|
|
17829
|
+
if (chunkFZFSGOTZ_cjs.isExpired(v)) {
|
|
17825
17830
|
return false;
|
|
17826
17831
|
}
|
|
17827
17832
|
return true;
|
|
@@ -17829,7 +17834,7 @@ var WalletMessageHandler = class {
|
|
|
17829
17834
|
if (!message.payload.filter?.withUnrolled) {
|
|
17830
17835
|
return filteredVtxos;
|
|
17831
17836
|
}
|
|
17832
|
-
return filteredVtxos.concat(allVtxos.filter((v) =>
|
|
17837
|
+
return filteredVtxos.concat(allVtxos.filter((v) => chunkFZFSGOTZ_cjs.hasTerminalSpend(v) && v.isUnrolled));
|
|
17833
17838
|
}
|
|
17834
17839
|
/** Tear down handler subscriptions, then delegate the full wipe to the wallet. */
|
|
17835
17840
|
async clear() {
|
|
@@ -17919,7 +17924,7 @@ var WalletMessageHandler = class {
|
|
|
17919
17924
|
if (!this.readonlyWallet) return null;
|
|
17920
17925
|
const { boardingTxs, commitmentsToIgnore } = await this.readonlyWallet.getBoardingTxs();
|
|
17921
17926
|
const indexerProvider = this.indexerProvider;
|
|
17922
|
-
const resolveTxCreatedAt = indexerProvider ? (txids) =>
|
|
17927
|
+
const resolveTxCreatedAt = indexerProvider ? (txids) => chunkFZFSGOTZ_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
|
|
17923
17928
|
return buildTransactionHistory(vtxos, boardingTxs, commitmentsToIgnore, resolveTxCreatedAt);
|
|
17924
17929
|
}
|
|
17925
17930
|
async ensureContractEventBroadcasting() {
|
|
@@ -18608,7 +18613,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
18608
18613
|
};
|
|
18609
18614
|
try {
|
|
18610
18615
|
const response = await this.sendMessage(message);
|
|
18611
|
-
return response.payload.vtxos.map(
|
|
18616
|
+
return response.payload.vtxos.map(chunkFZFSGOTZ_cjs.normalizeVtxo);
|
|
18612
18617
|
} catch (error) {
|
|
18613
18618
|
throw new Error(`Failed to get vtxos: ${error}`);
|
|
18614
18619
|
}
|
|
@@ -18633,7 +18638,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
18633
18638
|
};
|
|
18634
18639
|
try {
|
|
18635
18640
|
const response = await this.sendMessage(message);
|
|
18636
|
-
return response.payload.vtxos.map(
|
|
18641
|
+
return response.payload.vtxos.map(chunkFZFSGOTZ_cjs.normalizeVtxo);
|
|
18637
18642
|
} catch (error) {
|
|
18638
18643
|
throw new Error(`Failed to get spendable vtxos: ${error}`);
|
|
18639
18644
|
}
|
|
@@ -18764,7 +18769,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
18764
18769
|
};
|
|
18765
18770
|
try {
|
|
18766
18771
|
const response = await sendContractMessage(message);
|
|
18767
|
-
return response.payload.vtxos.map(
|
|
18772
|
+
return response.payload.vtxos.map(chunkFZFSGOTZ_cjs.normalizeVtxo);
|
|
18768
18773
|
} catch (e) {
|
|
18769
18774
|
throw new Error("Failed to annotate vtxos");
|
|
18770
18775
|
}
|
|
@@ -19336,7 +19341,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
19336
19341
|
};
|
|
19337
19342
|
try {
|
|
19338
19343
|
const response = await wallet.sendMessage(message);
|
|
19339
|
-
return response.payload.vtxos.map(
|
|
19344
|
+
return response.payload.vtxos.map(chunkFZFSGOTZ_cjs.normalizeVtxo);
|
|
19340
19345
|
} catch (e) {
|
|
19341
19346
|
throw new Error(`Failed to get expiring vtxos: ${e}`);
|
|
19342
19347
|
}
|
|
@@ -19448,12 +19453,12 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
19448
19453
|
* @returns Configured onchain wallet
|
|
19449
19454
|
* @throws Error if the configured identity cannot produce a valid x-only public key
|
|
19450
19455
|
*/
|
|
19451
|
-
static async create(identity, networkName =
|
|
19456
|
+
static async create(identity, networkName = chunkFZFSGOTZ_cjs.DEFAULT_NETWORK_NAME, provider) {
|
|
19452
19457
|
const pubkey = await identity.xOnlyPublicKey();
|
|
19453
19458
|
if (!pubkey) {
|
|
19454
19459
|
throw new Error("Invalid configured public key");
|
|
19455
19460
|
}
|
|
19456
|
-
const network =
|
|
19461
|
+
const network = chunkFZFSGOTZ_cjs.getNetwork(networkName);
|
|
19457
19462
|
const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
|
|
19458
19463
|
const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
|
|
19459
19464
|
return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
|
|
@@ -19559,7 +19564,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
19559
19564
|
if (!inputs) {
|
|
19560
19565
|
throw new Error("Fee estimation failed");
|
|
19561
19566
|
}
|
|
19562
|
-
let tx = new
|
|
19567
|
+
let tx = new chunkFZFSGOTZ_cjs.Transaction();
|
|
19563
19568
|
for (const input of inputs) {
|
|
19564
19569
|
tx.addInput({
|
|
19565
19570
|
txid: input.txid,
|
|
@@ -19617,7 +19622,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
19617
19622
|
* @throws If the parent has no anchor, or funding cannot be selected/signed
|
|
19618
19623
|
*/
|
|
19619
19624
|
async bumpAnchor(parentHex, feeRate) {
|
|
19620
|
-
const parent =
|
|
19625
|
+
const parent = chunkFZFSGOTZ_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
|
|
19621
19626
|
const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
|
|
19622
19627
|
const child = await this.buildBumpPackage(parent, feeRate, coins);
|
|
19623
19628
|
return [parent.hex, child.hex];
|
|
@@ -20382,7 +20387,7 @@ exports.BIP322 = void 0;
|
|
|
20382
20387
|
async function sign2(message, identity, network) {
|
|
20383
20388
|
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
20384
20389
|
const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
|
|
20385
|
-
const toSpend =
|
|
20390
|
+
const toSpend = chunkFZFSGOTZ_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
20386
20391
|
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
20387
20392
|
const signed = await identity.sign(toSign, [0]);
|
|
20388
20393
|
signed.finalizeIdx(0);
|
|
@@ -20440,7 +20445,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
|
20440
20445
|
if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
|
|
20441
20446
|
return false;
|
|
20442
20447
|
}
|
|
20443
|
-
const toSpend =
|
|
20448
|
+
const toSpend = chunkFZFSGOTZ_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
20444
20449
|
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
|
|
20445
20450
|
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
20446
20451
|
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
@@ -20461,7 +20466,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
|
20461
20466
|
}
|
|
20462
20467
|
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
20463
20468
|
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
20464
|
-
const toSpend =
|
|
20469
|
+
const toSpend = chunkFZFSGOTZ_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
20465
20470
|
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
20466
20471
|
const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
|
|
20467
20472
|
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
@@ -20514,7 +20519,7 @@ function encodeCompactSize(n) {
|
|
|
20514
20519
|
return buf;
|
|
20515
20520
|
}
|
|
20516
20521
|
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
20517
|
-
const tx = new
|
|
20522
|
+
const tx = new chunkFZFSGOTZ_cjs.Transaction({ version: 0 });
|
|
20518
20523
|
tx.addInput({
|
|
20519
20524
|
txid: toSpend.id,
|
|
20520
20525
|
index: 0,
|
|
@@ -20528,12 +20533,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
|
20528
20533
|
});
|
|
20529
20534
|
tx.addOutput({
|
|
20530
20535
|
amount: 0n,
|
|
20531
|
-
script:
|
|
20536
|
+
script: chunkFZFSGOTZ_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
20532
20537
|
});
|
|
20533
20538
|
return tx;
|
|
20534
20539
|
}
|
|
20535
20540
|
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
20536
|
-
const tx = new
|
|
20541
|
+
const tx = new chunkFZFSGOTZ_cjs.Transaction({ version: 0 });
|
|
20537
20542
|
tx.addInput({
|
|
20538
20543
|
txid: toSpend.id,
|
|
20539
20544
|
index: 0,
|
|
@@ -20545,7 +20550,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
|
20545
20550
|
});
|
|
20546
20551
|
tx.addOutput({
|
|
20547
20552
|
amount: 0n,
|
|
20548
|
-
script:
|
|
20553
|
+
script: chunkFZFSGOTZ_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
20549
20554
|
});
|
|
20550
20555
|
return tx;
|
|
20551
20556
|
}
|
|
@@ -20676,7 +20681,7 @@ var RestEmulatorProvider = class {
|
|
|
20676
20681
|
}
|
|
20677
20682
|
};
|
|
20678
20683
|
function finalizeVirtualTx(type, psbtBase64) {
|
|
20679
|
-
const tx =
|
|
20684
|
+
const tx = chunkFZFSGOTZ_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
20680
20685
|
if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
|
|
20681
20686
|
const input = tx.getInput(0);
|
|
20682
20687
|
if (!input) {
|
|
@@ -20703,14 +20708,14 @@ var ExitPathError = class extends Error {
|
|
|
20703
20708
|
reason;
|
|
20704
20709
|
};
|
|
20705
20710
|
function delayWeight(sequence) {
|
|
20706
|
-
const t =
|
|
20711
|
+
const t = chunkFZFSGOTZ_cjs.sequenceToTimelock(sequence);
|
|
20707
20712
|
return t.type === "blocks" ? Number(t.value) : Number(t.value) / 600;
|
|
20708
20713
|
}
|
|
20709
20714
|
async function resolveUnilateralPath(params) {
|
|
20710
20715
|
const { vtxo, scriptHex, contractRepository } = params;
|
|
20711
20716
|
const contract = contractRepository ? (await contractRepository.getContracts({ script: scriptHex }))[0] : void 0;
|
|
20712
20717
|
if (contract) {
|
|
20713
|
-
const handler =
|
|
20718
|
+
const handler = chunkWXCVS6PD_cjs.contractHandlers.get(contract.type);
|
|
20714
20719
|
if (!handler) {
|
|
20715
20720
|
throw new ExitPathError(
|
|
20716
20721
|
"no-handler",
|
|
@@ -20733,12 +20738,12 @@ async function resolveUnilateralPath(params) {
|
|
|
20733
20738
|
paths.sort((a, b) => delayWeight(a.sequence) - delayWeight(b.sequence));
|
|
20734
20739
|
return { selection: paths[0], label: `${contract.type}:unilateral` };
|
|
20735
20740
|
}
|
|
20736
|
-
const decoded =
|
|
20741
|
+
const decoded = chunkFZFSGOTZ_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
20737
20742
|
let best;
|
|
20738
20743
|
for (const exit of decoded.exitPaths()) {
|
|
20739
20744
|
const leaf = decoded.findLeaf(base.hex.encode(exit.script));
|
|
20740
20745
|
if (!leaf) continue;
|
|
20741
|
-
const sequence =
|
|
20746
|
+
const sequence = chunkFZFSGOTZ_cjs.timelockToSequence(exit.params.timelock);
|
|
20742
20747
|
const weight = delayWeight(sequence);
|
|
20743
20748
|
if (!best || weight < best.weight) {
|
|
20744
20749
|
best = { selection: { leaf, sequence }, weight };
|
|
@@ -20924,14 +20929,14 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
20924
20929
|
}
|
|
20925
20930
|
const resolved = await resolveUnilateralPath({
|
|
20926
20931
|
vtxo,
|
|
20927
|
-
scriptHex: base.hex.encode(
|
|
20932
|
+
scriptHex: base.hex.encode(chunkFZFSGOTZ_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
20928
20933
|
contractRepository: wallet.contractRepository,
|
|
20929
20934
|
walletPubKeyHex: base.hex.encode(await wallet.identity.xOnlyPublicKey()),
|
|
20930
20935
|
currentTime: Date.now()
|
|
20931
20936
|
});
|
|
20932
20937
|
const spendingLeaf = resolved.selection.leaf;
|
|
20933
20938
|
const sequence = resolved.selection.sequence;
|
|
20934
|
-
const timelock =
|
|
20939
|
+
const timelock = chunkFZFSGOTZ_cjs.sequenceToTimelock(sequence);
|
|
20935
20940
|
const elapsed = timelock.type === "blocks" ? chainTip.height >= txStatus.blockHeight + Number(timelock.value) : chainTip.time >= txStatus.blockTime + Number(timelock.value);
|
|
20936
20941
|
if (!elapsed) {
|
|
20937
20942
|
throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
|
|
@@ -20944,7 +20949,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
20944
20949
|
sequence,
|
|
20945
20950
|
witnessUtxo: {
|
|
20946
20951
|
amount: BigInt(vtxo.value),
|
|
20947
|
-
script:
|
|
20952
|
+
script: chunkFZFSGOTZ_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
|
|
20948
20953
|
},
|
|
20949
20954
|
sighashType: btcSigner.SigHash.DEFAULT
|
|
20950
20955
|
});
|
|
@@ -20954,7 +20959,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
20954
20959
|
btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
|
|
20955
20960
|
);
|
|
20956
20961
|
}
|
|
20957
|
-
const tx = new
|
|
20962
|
+
const tx = new chunkFZFSGOTZ_cjs.Transaction({ version: 2 });
|
|
20958
20963
|
for (const input of inputs) {
|
|
20959
20964
|
tx.addInput(input);
|
|
20960
20965
|
}
|
|
@@ -21021,7 +21026,7 @@ async function buildSignedSweep(params) {
|
|
|
21021
21026
|
`uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
|
|
21022
21027
|
);
|
|
21023
21028
|
}
|
|
21024
|
-
const tx = new
|
|
21029
|
+
const tx = new chunkFZFSGOTZ_cjs.Transaction({ version: 2 });
|
|
21025
21030
|
tx.addInput({
|
|
21026
21031
|
txid: vtxo.txid,
|
|
21027
21032
|
index: vtxo.vout,
|
|
@@ -21046,7 +21051,7 @@ async function buildSignedSweep(params) {
|
|
|
21046
21051
|
finalScriptWitness: [
|
|
21047
21052
|
tapScriptSig[0][1],
|
|
21048
21053
|
...path.extraWitness,
|
|
21049
|
-
|
|
21054
|
+
chunkFZFSGOTZ_cjs.scriptFromTapLeafScript(path.leaf),
|
|
21050
21055
|
btcSigner.TaprootControlBlock.encode(controlBlock)
|
|
21051
21056
|
]
|
|
21052
21057
|
});
|
|
@@ -21076,7 +21081,7 @@ async function resolveFeeRate(opts) {
|
|
|
21076
21081
|
}
|
|
21077
21082
|
async function selectExitVtxos(opts) {
|
|
21078
21083
|
if (!opts.vtxos) return opts.wallet.getVtxos();
|
|
21079
|
-
const res = await
|
|
21084
|
+
const res = await chunkFZFSGOTZ_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
|
|
21080
21085
|
const tapTrees = /* @__PURE__ */ new Map();
|
|
21081
21086
|
const out = [];
|
|
21082
21087
|
for (const vtxo of res.vtxos) {
|
|
@@ -21091,7 +21096,7 @@ async function selectExitVtxos(opts) {
|
|
|
21091
21096
|
`no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
|
|
21092
21097
|
);
|
|
21093
21098
|
}
|
|
21094
|
-
const handler =
|
|
21099
|
+
const handler = chunkWXCVS6PD_cjs.contractHandlers.get(contract.type);
|
|
21095
21100
|
if (!handler) {
|
|
21096
21101
|
throw new Error(`no contract handler registered for type '${contract.type}'`);
|
|
21097
21102
|
}
|
|
@@ -21121,7 +21126,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
21121
21126
|
if (pendingNodes.length > 0) {
|
|
21122
21127
|
const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
|
|
21123
21128
|
for (const psbt of txs) {
|
|
21124
|
-
psbts.set(
|
|
21129
|
+
psbts.set(chunkFZFSGOTZ_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
21125
21130
|
}
|
|
21126
21131
|
}
|
|
21127
21132
|
const childVsize = Number(
|
|
@@ -21157,7 +21162,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
21157
21162
|
try {
|
|
21158
21163
|
const resolved = await resolveUnilateralPath({
|
|
21159
21164
|
vtxo,
|
|
21160
|
-
scriptHex: base.hex.encode(
|
|
21165
|
+
scriptHex: base.hex.encode(chunkFZFSGOTZ_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
21161
21166
|
contractRepository: wallet.contractRepository,
|
|
21162
21167
|
walletPubKeyHex,
|
|
21163
21168
|
currentTime: Date.now()
|
|
@@ -21176,7 +21181,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
21176
21181
|
});
|
|
21177
21182
|
continue;
|
|
21178
21183
|
}
|
|
21179
|
-
const t =
|
|
21184
|
+
const t = chunkFZFSGOTZ_cjs.sequenceToTimelock(resolved.selection.sequence);
|
|
21180
21185
|
const delay = { type: t.type, value: Number(t.value) };
|
|
21181
21186
|
infos.push({ outpoint, value: vtxo.value, sweepFee, path: resolved.label, delay });
|
|
21182
21187
|
sweeps.push({ vtxo, resolved, sweepFee, delay });
|
|
@@ -21515,7 +21520,7 @@ async function prepare(opts) {
|
|
|
21515
21520
|
txid: sweep.vtxo.txid,
|
|
21516
21521
|
vout: sweep.vtxo.vout,
|
|
21517
21522
|
value: sweep.vtxo.value,
|
|
21518
|
-
pkScript:
|
|
21523
|
+
pkScript: chunkFZFSGOTZ_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
|
|
21519
21524
|
},
|
|
21520
21525
|
path: sweep.resolved.selection,
|
|
21521
21526
|
outputAddress: opts.sweepAddress,
|
|
@@ -21600,7 +21605,7 @@ async function prepare(opts) {
|
|
|
21600
21605
|
if (newFee <= splitterFee) break;
|
|
21601
21606
|
splitterFee = newFee;
|
|
21602
21607
|
}
|
|
21603
|
-
const splitter = new
|
|
21608
|
+
const splitter = new chunkFZFSGOTZ_cjs.Transaction({ version: 2 });
|
|
21604
21609
|
for (const coin of selected.inputs) {
|
|
21605
21610
|
splitter.addInput({
|
|
21606
21611
|
txid: coin.txid,
|
|
@@ -21743,41 +21748,41 @@ var UnilateralExit = {
|
|
|
21743
21748
|
// src/arkade/index.ts
|
|
21744
21749
|
var arkade_exports = {};
|
|
21745
21750
|
chunk5BLDMQED_cjs.__export(arkade_exports, {
|
|
21746
|
-
ARKADE_OP: () =>
|
|
21747
|
-
ARKADE_OPCODES: () =>
|
|
21748
|
-
ARKADE_OPCODE_NAMES: () =>
|
|
21749
|
-
ARKADE_OPCODE_VALUES: () =>
|
|
21750
|
-
ARKADE_OPS: () =>
|
|
21751
|
+
ARKADE_OP: () => chunkWXCVS6PD_cjs.ARKADE_OP,
|
|
21752
|
+
ARKADE_OPCODES: () => chunkWXCVS6PD_cjs.ARKADE_OPCODES,
|
|
21753
|
+
ARKADE_OPCODE_NAMES: () => chunkWXCVS6PD_cjs.ARKADE_OPCODE_NAMES,
|
|
21754
|
+
ARKADE_OPCODE_VALUES: () => chunkWXCVS6PD_cjs.ARKADE_OPCODE_VALUES,
|
|
21755
|
+
ARKADE_OPS: () => chunkWXCVS6PD_cjs.ARKADE_OPS,
|
|
21751
21756
|
Arkade: () => Arkade,
|
|
21752
21757
|
ArkadeContract: () => ArkadeContract,
|
|
21753
|
-
ArkadeProgramScript: () =>
|
|
21754
|
-
ArkadeScript: () =>
|
|
21758
|
+
ArkadeProgramScript: () => chunkWXCVS6PD_cjs.ArkadeProgramScript,
|
|
21759
|
+
ArkadeScript: () => chunkWXCVS6PD_cjs.ArkadeScript,
|
|
21755
21760
|
ArkadeTransactionBuilder: () => ArkadeTransactionBuilder,
|
|
21756
|
-
BigNum: () =>
|
|
21761
|
+
BigNum: () => chunkWXCVS6PD_cjs.bignum_exports,
|
|
21757
21762
|
OP: () => btcSigner.OP,
|
|
21758
|
-
OPCODE_NAMES: () =>
|
|
21759
|
-
OPCODE_VALUES: () =>
|
|
21760
|
-
SUPPORTED_PROGRAM_VERSION: () =>
|
|
21763
|
+
OPCODE_NAMES: () => chunkWXCVS6PD_cjs.OPCODE_NAMES,
|
|
21764
|
+
OPCODE_VALUES: () => chunkWXCVS6PD_cjs.OPCODE_VALUES,
|
|
21765
|
+
SUPPORTED_PROGRAM_VERSION: () => chunkWXCVS6PD_cjs.SUPPORTED_PROGRAM_VERSION,
|
|
21761
21766
|
Script: () => btcSigner.Script,
|
|
21762
|
-
arkadeScriptHash: () =>
|
|
21763
|
-
arkadeWitnessHash: () =>
|
|
21764
|
-
asmToBytes: () =>
|
|
21765
|
-
bytesToASM: () =>
|
|
21766
|
-
computeArkadeScriptPublicKey: () =>
|
|
21767
|
+
arkadeScriptHash: () => chunkWXCVS6PD_cjs.arkadeScriptHash,
|
|
21768
|
+
arkadeWitnessHash: () => chunkWXCVS6PD_cjs.arkadeWitnessHash,
|
|
21769
|
+
asmToBytes: () => chunkWXCVS6PD_cjs.asmToBytes,
|
|
21770
|
+
bytesToASM: () => chunkWXCVS6PD_cjs.bytesToASM,
|
|
21771
|
+
computeArkadeScriptPublicKey: () => chunkWXCVS6PD_cjs.computeArkadeScriptPublicKey,
|
|
21767
21772
|
createArkadeBatchHandler: () => createArkadeBatchHandler,
|
|
21768
|
-
deserializeArkadeContractParams: () =>
|
|
21769
|
-
fromASM: () =>
|
|
21770
|
-
getOpcodeName: () =>
|
|
21771
|
-
getOpcodeValue: () =>
|
|
21772
|
-
parseArtifact: () =>
|
|
21773
|
-
resolveAsm: () =>
|
|
21774
|
-
serializeArkadeContractParams: () =>
|
|
21775
|
-
stringifyArtifact: () =>
|
|
21776
|
-
toASM: () =>
|
|
21777
|
-
validateProgram: () =>
|
|
21778
|
-
witnessRefToBytes: () =>
|
|
21773
|
+
deserializeArkadeContractParams: () => chunkWXCVS6PD_cjs.deserializeArkadeContractParams,
|
|
21774
|
+
fromASM: () => chunkWXCVS6PD_cjs.fromASM,
|
|
21775
|
+
getOpcodeName: () => chunkWXCVS6PD_cjs.getOpcodeName,
|
|
21776
|
+
getOpcodeValue: () => chunkWXCVS6PD_cjs.getOpcodeValue,
|
|
21777
|
+
parseArtifact: () => chunkWXCVS6PD_cjs.parseArtifact,
|
|
21778
|
+
resolveAsm: () => chunkWXCVS6PD_cjs.resolveAsm,
|
|
21779
|
+
serializeArkadeContractParams: () => chunkWXCVS6PD_cjs.serializeArkadeContractParams,
|
|
21780
|
+
stringifyArtifact: () => chunkWXCVS6PD_cjs.stringifyArtifact,
|
|
21781
|
+
toASM: () => chunkWXCVS6PD_cjs.toASM,
|
|
21782
|
+
validateProgram: () => chunkWXCVS6PD_cjs.validateProgram,
|
|
21783
|
+
witnessRefToBytes: () => chunkWXCVS6PD_cjs.witnessRefToBytes
|
|
21779
21784
|
});
|
|
21780
|
-
var isVtxoCoin = (input) =>
|
|
21785
|
+
var isVtxoCoin = (input) => chunkFZFSGOTZ_cjs.isVirtualCoin(input);
|
|
21781
21786
|
function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
|
|
21782
21787
|
let batchId;
|
|
21783
21788
|
let sweepTapTreeRoot;
|
|
@@ -21798,7 +21803,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
21798
21803
|
);
|
|
21799
21804
|
await arkProvider.confirmRegistration(intentId);
|
|
21800
21805
|
batchId = event.id;
|
|
21801
|
-
const sweepTapscript =
|
|
21806
|
+
const sweepTapscript = chunkFZFSGOTZ_cjs.CSVMultisigTapscript.encode({
|
|
21802
21807
|
timelock,
|
|
21803
21808
|
pubkeys: [base.hex.decode(info.forfeitPubkey).subarray(1)]
|
|
21804
21809
|
}).script;
|
|
@@ -21812,7 +21817,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
21812
21817
|
if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
|
|
21813
21818
|
return { skip: true };
|
|
21814
21819
|
}
|
|
21815
|
-
const commitmentTx =
|
|
21820
|
+
const commitmentTx = chunkFZFSGOTZ_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
|
|
21816
21821
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
21817
21822
|
if (recipients && recipients.length > 0) {
|
|
21818
21823
|
validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
|
|
@@ -21844,7 +21849,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
21844
21849
|
if (connectorTree) {
|
|
21845
21850
|
validateConnectorsTxGraph(event.commitmentTx, connectorTree);
|
|
21846
21851
|
}
|
|
21847
|
-
let commitmentPsbt =
|
|
21852
|
+
let commitmentPsbt = chunkFZFSGOTZ_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
21848
21853
|
assertFinalCommitmentMatchesValidated(
|
|
21849
21854
|
commitmentPsbt,
|
|
21850
21855
|
validatedCommitmentTxid,
|
|
@@ -21879,7 +21884,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
21879
21884
|
boardingIndices.push(boardingIdx);
|
|
21880
21885
|
continue;
|
|
21881
21886
|
}
|
|
21882
|
-
if (
|
|
21887
|
+
if (chunkFZFSGOTZ_cjs.isRecoverable(input) || isSubdust(input, info.dust)) {
|
|
21883
21888
|
continue;
|
|
21884
21889
|
}
|
|
21885
21890
|
if (connectorIndex >= connectorLeaves.length) {
|
|
@@ -21900,7 +21905,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
21900
21905
|
index: input.vout,
|
|
21901
21906
|
witnessUtxo: {
|
|
21902
21907
|
amount: BigInt(input.value),
|
|
21903
|
-
script:
|
|
21908
|
+
script: chunkFZFSGOTZ_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
21904
21909
|
},
|
|
21905
21910
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
21906
21911
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -21992,11 +21997,11 @@ var Arkade = class _Arkade {
|
|
|
21992
21997
|
static async connect(opts) {
|
|
21993
21998
|
const info = await opts.arkade.getInfo();
|
|
21994
21999
|
const serverKey = base.hex.decode(info.signerPubkey).slice(1);
|
|
21995
|
-
const checkpoint =
|
|
21996
|
-
const network = opts.network ??
|
|
22000
|
+
const checkpoint = chunkFZFSGOTZ_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
22001
|
+
const network = opts.network ?? chunkFZFSGOTZ_cjs.DEFAULT_NETWORK;
|
|
21997
22002
|
let emulatorKey;
|
|
21998
22003
|
if (opts.emulator) {
|
|
21999
|
-
emulatorKey = base.hex.decode(
|
|
22004
|
+
emulatorKey = base.hex.decode(chunkFZFSGOTZ_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
|
|
22000
22005
|
}
|
|
22001
22006
|
let userKey;
|
|
22002
22007
|
if (opts.identity) {
|
|
@@ -22027,7 +22032,7 @@ var Arkade = class _Arkade {
|
|
|
22027
22032
|
* key respectively; explicit args always win.
|
|
22028
22033
|
*/
|
|
22029
22034
|
contract(program, args = {}) {
|
|
22030
|
-
const declared = (program.params ?? []).map(
|
|
22035
|
+
const declared = (program.params ?? []).map(chunkWXCVS6PD_cjs.inputName);
|
|
22031
22036
|
if (declared.includes("server") && args.server === void 0) {
|
|
22032
22037
|
args = { ...args, server: this.serverKey };
|
|
22033
22038
|
}
|
|
@@ -22047,7 +22052,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
22047
22052
|
userKey: client.userKey,
|
|
22048
22053
|
emulatorKey: client.emulatorKey
|
|
22049
22054
|
};
|
|
22050
|
-
this.vtxoScript = new
|
|
22055
|
+
this.vtxoScript = new chunkWXCVS6PD_cjs.ArkadeProgramScript(program, args, this.keys);
|
|
22051
22056
|
this.tapTree = this.vtxoScript.encode();
|
|
22052
22057
|
this.compiled = this.vtxoScript.compiled;
|
|
22053
22058
|
}
|
|
@@ -22075,7 +22080,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
22075
22080
|
`ArkadeContract.fromContract: expected contract type 'arkade', got '${contract.type}'`
|
|
22076
22081
|
);
|
|
22077
22082
|
}
|
|
22078
|
-
const typed =
|
|
22083
|
+
const typed = chunkWXCVS6PD_cjs.deserializeArkadeContractParams(contract.params);
|
|
22079
22084
|
return new _ArkadeContract(client, typed.program, typed.args, {
|
|
22080
22085
|
serverKey: typed.serverKey,
|
|
22081
22086
|
userKey: typed.userKey,
|
|
@@ -22116,7 +22121,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
22116
22121
|
toContractParams() {
|
|
22117
22122
|
return {
|
|
22118
22123
|
type: "arkade",
|
|
22119
|
-
params:
|
|
22124
|
+
params: chunkWXCVS6PD_cjs.serializeArkadeContractParams({
|
|
22120
22125
|
program: this.program,
|
|
22121
22126
|
args: this.args,
|
|
22122
22127
|
serverKey: this.keys.serverKey,
|
|
@@ -22161,13 +22166,13 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
22161
22166
|
const [registered] = await manager.getContracts({ script: scriptHex });
|
|
22162
22167
|
if (registered) {
|
|
22163
22168
|
const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
|
|
22164
|
-
return (withVtxos?.vtxos ?? []).filter((v) => !
|
|
22169
|
+
return (withVtxos?.vtxos ?? []).filter((v) => !chunkFZFSGOTZ_cjs.hasTerminalSpend(v));
|
|
22165
22170
|
}
|
|
22166
22171
|
}
|
|
22167
22172
|
if (!this.client.indexer) {
|
|
22168
22173
|
throw new Error("ArkadeContract.getUtxos: an indexer is required");
|
|
22169
22174
|
}
|
|
22170
|
-
const { vtxos } = await
|
|
22175
|
+
const { vtxos } = await chunkFZFSGOTZ_cjs.getNormalizedVtxos(this.client.indexer, {
|
|
22171
22176
|
scripts: [scriptHex],
|
|
22172
22177
|
spendableOnly: true
|
|
22173
22178
|
});
|
|
@@ -22269,12 +22274,12 @@ var ArkadeTransactionBuilder = class {
|
|
|
22269
22274
|
this.contract.client.checkpoint
|
|
22270
22275
|
);
|
|
22271
22276
|
if (coin.sourceTx) {
|
|
22272
|
-
|
|
22277
|
+
chunkFZFSGOTZ_cjs.setArkPsbtField(arkTx, 0, chunkFZFSGOTZ_cjs.PrevArkTxField, coin.sourceTx);
|
|
22273
22278
|
}
|
|
22274
22279
|
const condition = (def.tapscript.witness ?? []).map((w) => this.witnessBytes(w));
|
|
22275
22280
|
if (condition.length > 0) {
|
|
22276
|
-
|
|
22277
|
-
|
|
22281
|
+
chunkFZFSGOTZ_cjs.setArkPsbtField(arkTx, 0, chunkFZFSGOTZ_cjs.ConditionWitness, condition);
|
|
22282
|
+
chunkFZFSGOTZ_cjs.setArkPsbtField(checkpoints[0], 0, chunkFZFSGOTZ_cjs.ConditionWitness, condition);
|
|
22278
22283
|
}
|
|
22279
22284
|
const packets = [];
|
|
22280
22285
|
if (this.assetSpecs.length > 0) {
|
|
@@ -22313,7 +22318,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
22313
22318
|
base.base64.encode(signedArk2.toPSBT()),
|
|
22314
22319
|
signedCps.map((c) => base.base64.encode(c.toPSBT()))
|
|
22315
22320
|
);
|
|
22316
|
-
const txid =
|
|
22321
|
+
const txid = chunkFZFSGOTZ_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
|
|
22317
22322
|
return {
|
|
22318
22323
|
txid,
|
|
22319
22324
|
signedArkTx: res2.signedArkTx,
|
|
@@ -22372,23 +22377,23 @@ var ArkadeTransactionBuilder = class {
|
|
|
22372
22377
|
}
|
|
22373
22378
|
buildAssetPacket() {
|
|
22374
22379
|
const groups = this.assetSpecs.map((s) => {
|
|
22375
|
-
const id = typeof s.assetId === "string" ?
|
|
22376
|
-
return
|
|
22380
|
+
const id = typeof s.assetId === "string" ? chunkRXITDAV4_cjs.AssetId.fromString(s.assetId) : chunkRXITDAV4_cjs.AssetId.fromBytes(s.assetId);
|
|
22381
|
+
return chunkRXITDAV4_cjs.AssetGroup.create(
|
|
22377
22382
|
id,
|
|
22378
22383
|
null,
|
|
22379
|
-
s.inputs.map((i) =>
|
|
22380
|
-
s.outputs.map((o) =>
|
|
22381
|
-
(s.metadata ?? []).map((m) =>
|
|
22384
|
+
s.inputs.map((i) => chunkRXITDAV4_cjs.AssetInput.create(i.vin, i.amount)),
|
|
22385
|
+
s.outputs.map((o) => chunkRXITDAV4_cjs.AssetOutput.create(o.vout, o.amount)),
|
|
22386
|
+
(s.metadata ?? []).map((m) => chunkRXITDAV4_cjs.Metadata.create(m.key, m.value))
|
|
22382
22387
|
);
|
|
22383
22388
|
});
|
|
22384
|
-
return
|
|
22389
|
+
return chunkRXITDAV4_cjs.Packet.create(groups);
|
|
22385
22390
|
}
|
|
22386
22391
|
witnessBytes(ref) {
|
|
22387
|
-
return
|
|
22392
|
+
return chunkWXCVS6PD_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
|
|
22388
22393
|
}
|
|
22389
22394
|
};
|
|
22390
22395
|
function bindInputs(fn, callArgs) {
|
|
22391
|
-
const names = (fn.def.inputs ?? []).map(
|
|
22396
|
+
const names = (fn.def.inputs ?? []).map(chunkWXCVS6PD_cjs.inputName);
|
|
22392
22397
|
if (callArgs.length !== names.length) {
|
|
22393
22398
|
throw new Error(`${fn.name}: expected ${names.length} argument(s), got ${callArgs.length}`);
|
|
22394
22399
|
}
|
|
@@ -22974,5 +22979,5 @@ exports.validateVtxoTxGraph = validateVtxoTxGraph;
|
|
|
22974
22979
|
exports.verifyTapscriptSignatures = verifyTapscriptSignatures;
|
|
22975
22980
|
exports.waitForIncomingFunds = waitForIncomingFunds;
|
|
22976
22981
|
exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
|
|
22977
|
-
//# sourceMappingURL=chunk-
|
|
22978
|
-
//# sourceMappingURL=chunk-
|
|
22982
|
+
//# sourceMappingURL=chunk-LPEE2H2M.cjs.map
|
|
22983
|
+
//# sourceMappingURL=chunk-LPEE2H2M.cjs.map
|