@arkade-os/sdk 0.4.57 → 0.4.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/expo.cjs +5 -5
- package/dist/adapters/expo.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +3 -3
- package/dist/adapters/indexedDB.cjs +5 -5
- package/dist/adapters/indexedDB.js +4 -4
- package/dist/{ark-CJgH_pmn.d.cts → ark-C9DsPSm8.d.cts} +83 -3
- package/dist/{ark-CJgH_pmn.d.ts → ark-C9DsPSm8.d.ts} +83 -3
- package/dist/{asyncStorageTaskQueue-BeeZbf-Q.d.ts → asyncStorageTaskQueue-BwuWQ1Qc.d.ts} +1 -1
- package/dist/{asyncStorageTaskQueue-BlrsUUX_.d.cts → asyncStorageTaskQueue-CYHXFfvn.d.cts} +1 -1
- package/dist/{chunk-OWTKOMJZ.cjs → chunk-2XO43UHI.cjs} +40 -40
- package/dist/{chunk-OWTKOMJZ.cjs.map → chunk-2XO43UHI.cjs.map} +1 -1
- package/dist/{chunk-EZBKSWEL.cjs → chunk-7FA36NOA.cjs} +17 -17
- package/dist/{chunk-EZBKSWEL.cjs.map → chunk-7FA36NOA.cjs.map} +1 -1
- package/dist/{chunk-KUN5ZRMW.cjs → chunk-DSTYXT2D.cjs} +45 -10
- package/dist/chunk-DSTYXT2D.cjs.map +1 -0
- package/dist/{chunk-KEG4AAKX.cjs → chunk-DYNB6POO.cjs} +524 -404
- package/dist/chunk-DYNB6POO.cjs.map +1 -0
- package/dist/{chunk-PUNBWFIV.js → chunk-FIMOVH25.js} +41 -11
- package/dist/chunk-FIMOVH25.js.map +1 -0
- package/dist/{chunk-C4SVRVNM.js → chunk-H342JPPZ.js} +4 -4
- package/dist/{chunk-C4SVRVNM.js.map → chunk-H342JPPZ.js.map} +1 -1
- package/dist/{chunk-A7TOVUYG.cjs → chunk-IPFGYVF3.cjs} +9 -9
- package/dist/{chunk-A7TOVUYG.cjs.map → chunk-IPFGYVF3.cjs.map} +1 -1
- package/dist/{chunk-NIZPFPUM.js → chunk-OVSNY3HC.js} +151 -33
- package/dist/chunk-OVSNY3HC.js.map +1 -0
- package/dist/{chunk-P6L2W5IL.js → chunk-PN5RD7ZI.js} +3 -3
- package/dist/{chunk-P6L2W5IL.js.map → chunk-PN5RD7ZI.js.map} +1 -1
- package/dist/{chunk-YK6NP5KX.cjs → chunk-V2KENVN6.cjs} +15 -15
- package/dist/{chunk-YK6NP5KX.cjs.map → chunk-V2KENVN6.cjs.map} +1 -1
- package/dist/{chunk-CPS7V4A3.js → chunk-VSHY5TBY.js} +4 -4
- package/dist/{chunk-CPS7V4A3.js.map → chunk-VSHY5TBY.js.map} +1 -1
- package/dist/{chunk-ASUJNZ63.js → chunk-YEHGCHIL.js} +3 -3
- package/dist/{chunk-ASUJNZ63.js.map → chunk-YEHGCHIL.js.map} +1 -1
- package/dist/contracts/handlers/index.cjs +8 -8
- 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-DM3YECSY.d.ts → delegate-B_oKWm1k.d.ts} +1 -1
- package/dist/{delegate-Dk-OJVdf.d.cts → delegate-D0eGaz3J.d.cts} +1 -1
- package/dist/{index-Cig0RkTf.d.cts → index-BG2AL2Ie.d.cts} +2 -2
- package/dist/{index-CnE7Gnvb.d.ts → index-BmK6tEqf.d.ts} +2 -2
- package/dist/index.cjs +251 -223
- package/dist/index.d.cts +48 -9
- package/dist/index.d.ts +48 -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 +18 -18
- package/dist/repositories/sqlite/index.d.cts +2 -2
- package/dist/repositories/sqlite/index.d.ts +2 -2
- package/dist/repositories/sqlite/index.js +5 -5
- package/dist/{taskRunner-CnGSTaAJ.d.cts → taskRunner-CBvKIttE.d.cts} +1 -1
- package/dist/{taskRunner-F7tWzsrC.d.ts → taskRunner-Cy4Gh8n7.d.ts} +1 -1
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +6 -6
- package/dist/wallet/expo/index.cjs +14 -14
- package/dist/wallet/expo/index.d.cts +4 -4
- package/dist/wallet/expo/index.d.ts +4 -4
- package/dist/wallet/expo/index.js +5 -5
- package/dist/{wallet-DvRIQBBY.d.cts → wallet-DlXemAzP.d.cts} +24 -3
- package/dist/{wallet-D6_S0n6B.d.ts → wallet-EyVDhqzP.d.ts} +24 -3
- 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 +7 -2
- package/dist/chunk-KEG4AAKX.cjs.map +0 -1
- package/dist/chunk-KUN5ZRMW.cjs.map +0 -1
- package/dist/chunk-NIZPFPUM.js.map +0 -1
- package/dist/chunk-PUNBWFIV.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkV2KENVN6_cjs = require('./chunk-V2KENVN6.cjs');
|
|
4
|
+
var chunk2XO43UHI_cjs = require('./chunk-2XO43UHI.cjs');
|
|
5
|
+
var chunkDSTYXT2D_cjs = require('./chunk-DSTYXT2D.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 = chunkDSTYXT2D_cjs.getArkPsbtFields(tx.root, 0, chunkDSTYXT2D_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 = chunkDSTYXT2D_cjs.getArkPsbtFields(g.root, 0, chunkDSTYXT2D_cjs.CosignerPublicKey).map((c) => c.key);
|
|
244
244
|
const { finalKey } = aggregateKeys(cosigners, true, {
|
|
245
245
|
taprootTweak: this.scriptRoot
|
|
246
246
|
});
|
|
@@ -419,7 +419,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
419
419
|
let network;
|
|
420
420
|
if ("descriptor" in opts && typeof opts.descriptor === "string") {
|
|
421
421
|
descriptor = opts.descriptor;
|
|
422
|
-
network =
|
|
422
|
+
network = chunk2XO43UHI_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
423
423
|
} else {
|
|
424
424
|
network = opts.isMainnet ?? true ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
425
425
|
descriptor = descriptorsScure.scriptExpressions.trBIP32({
|
|
@@ -504,7 +504,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
504
504
|
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
505
505
|
*/
|
|
506
506
|
isOurs(descriptor) {
|
|
507
|
-
return
|
|
507
|
+
return chunk2XO43UHI_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
|
|
508
508
|
}
|
|
509
509
|
/**
|
|
510
510
|
* Signs each request with the key derived from its descriptor.
|
|
@@ -553,7 +553,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
553
553
|
}
|
|
554
554
|
// ── internal helpers ─────────────────────────────────────────────
|
|
555
555
|
derivePrivateKeyForDescriptor(descriptor) {
|
|
556
|
-
const network =
|
|
556
|
+
const network = chunk2XO43UHI_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
557
557
|
const expansion = descriptorsScure.expand({ descriptor, network });
|
|
558
558
|
if (expansion.isRanged) {
|
|
559
559
|
throw new Error(
|
|
@@ -639,7 +639,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
639
639
|
*/
|
|
640
640
|
descriptor;
|
|
641
641
|
constructor(descriptor) {
|
|
642
|
-
const network =
|
|
642
|
+
const network = chunk2XO43UHI_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
643
643
|
let expansion;
|
|
644
644
|
try {
|
|
645
645
|
expansion = descriptorsScure.expand({ descriptor, network, index: 0 });
|
|
@@ -689,7 +689,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
689
689
|
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
690
690
|
*/
|
|
691
691
|
isOurs(descriptor) {
|
|
692
|
-
return
|
|
692
|
+
return chunk2XO43UHI_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
|
|
693
693
|
}
|
|
694
694
|
};
|
|
695
695
|
function serializeSeedOwnedSigningIdentity(identity) {
|
|
@@ -851,10 +851,10 @@ var DescriptorIdentity = class {
|
|
|
851
851
|
this.base = base;
|
|
852
852
|
}
|
|
853
853
|
async xOnlyPublicKey() {
|
|
854
|
-
return
|
|
854
|
+
return chunk2XO43UHI_cjs.deriveDescriptorLeafPubKey(this.descriptor);
|
|
855
855
|
}
|
|
856
856
|
async compressedPublicKey() {
|
|
857
|
-
return
|
|
857
|
+
return chunk2XO43UHI_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
|
|
858
858
|
}
|
|
859
859
|
async sign(tx, inputIndexes) {
|
|
860
860
|
const [signed] = await this.signer.signWithDescriptor([
|
|
@@ -1061,14 +1061,14 @@ var RestDelegateProvider = class {
|
|
|
1061
1061
|
*/
|
|
1062
1062
|
async delegate(intent, forfeitTxs, options) {
|
|
1063
1063
|
const url = `${this.url}/v1/delegate`;
|
|
1064
|
-
const response = await
|
|
1064
|
+
const response = await chunkDSTYXT2D_cjs.baseFetch(url, {
|
|
1065
1065
|
method: "POST",
|
|
1066
1066
|
headers: {
|
|
1067
1067
|
"Content-Type": "application/json"
|
|
1068
1068
|
},
|
|
1069
1069
|
body: JSON.stringify({
|
|
1070
1070
|
intent: {
|
|
1071
|
-
message:
|
|
1071
|
+
message: chunkDSTYXT2D_cjs.Intent.encodeMessage(intent.message),
|
|
1072
1072
|
proof: intent.proof
|
|
1073
1073
|
},
|
|
1074
1074
|
forfeit_txs: forfeitTxs,
|
|
@@ -1088,7 +1088,7 @@ var RestDelegateProvider = class {
|
|
|
1088
1088
|
*/
|
|
1089
1089
|
async getDelegateInfo() {
|
|
1090
1090
|
const url = `${this.url}/v1/delegator/info`;
|
|
1091
|
-
const response = await
|
|
1091
|
+
const response = await chunkDSTYXT2D_cjs.rateGate.runHttp(url, () => chunkDSTYXT2D_cjs.baseFetch(url));
|
|
1092
1092
|
if (!response.ok) {
|
|
1093
1093
|
const errorText2 = await response.text();
|
|
1094
1094
|
throw new Error(`Failed to get delegate info: ${errorText2}`);
|
|
@@ -1115,7 +1115,7 @@ var ESPLORA_URL = {
|
|
|
1115
1115
|
regtest: "http://localhost:3000/api"
|
|
1116
1116
|
};
|
|
1117
1117
|
var EsploraProvider = class {
|
|
1118
|
-
constructor(baseUrl = ESPLORA_URL[
|
|
1118
|
+
constructor(baseUrl = ESPLORA_URL[chunkDSTYXT2D_cjs.DEFAULT_NETWORK_NAME], opts) {
|
|
1119
1119
|
this.baseUrl = baseUrl;
|
|
1120
1120
|
this.pollingInterval = opts?.pollingInterval ?? 15e3;
|
|
1121
1121
|
this.forcePolling = opts?.forcePolling ?? false;
|
|
@@ -1124,14 +1124,14 @@ var EsploraProvider = class {
|
|
|
1124
1124
|
pollingInterval;
|
|
1125
1125
|
forcePolling;
|
|
1126
1126
|
async getCoins(address) {
|
|
1127
|
-
const response = await
|
|
1127
|
+
const response = await chunkDSTYXT2D_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
|
|
1128
1128
|
if (!response.ok) {
|
|
1129
1129
|
throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
|
|
1130
1130
|
}
|
|
1131
1131
|
return response.json();
|
|
1132
1132
|
}
|
|
1133
1133
|
async getFeeRate() {
|
|
1134
|
-
const response = await
|
|
1134
|
+
const response = await chunkDSTYXT2D_cjs.baseFetch(`${this.baseUrl}/fee-estimates`);
|
|
1135
1135
|
if (response.status === 404) {
|
|
1136
1136
|
return void 0;
|
|
1137
1137
|
}
|
|
@@ -1152,7 +1152,7 @@ var EsploraProvider = class {
|
|
|
1152
1152
|
}
|
|
1153
1153
|
}
|
|
1154
1154
|
async getTxOutspends(txid) {
|
|
1155
|
-
const response = await
|
|
1155
|
+
const response = await chunkDSTYXT2D_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
|
|
1156
1156
|
if (!response.ok) {
|
|
1157
1157
|
const error = await response.text();
|
|
1158
1158
|
throw new Error(`Failed to get transaction outspends: ${error}`);
|
|
@@ -1160,7 +1160,7 @@ var EsploraProvider = class {
|
|
|
1160
1160
|
return response.json();
|
|
1161
1161
|
}
|
|
1162
1162
|
async getTransactions(address) {
|
|
1163
|
-
const response = await
|
|
1163
|
+
const response = await chunkDSTYXT2D_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
|
|
1164
1164
|
if (!response.ok) {
|
|
1165
1165
|
const error = await response.text();
|
|
1166
1166
|
throw new Error(`Failed to get transactions: ${error}`);
|
|
@@ -1168,7 +1168,7 @@ var EsploraProvider = class {
|
|
|
1168
1168
|
return response.json();
|
|
1169
1169
|
}
|
|
1170
1170
|
async getTxStatus(txid) {
|
|
1171
|
-
const txresponse = await
|
|
1171
|
+
const txresponse = await chunkDSTYXT2D_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
|
|
1172
1172
|
if (!txresponse.ok) {
|
|
1173
1173
|
throw new Error(txresponse.statusText);
|
|
1174
1174
|
}
|
|
@@ -1176,7 +1176,7 @@ var EsploraProvider = class {
|
|
|
1176
1176
|
if (!tx.status.confirmed) {
|
|
1177
1177
|
return { confirmed: false };
|
|
1178
1178
|
}
|
|
1179
|
-
const response = await
|
|
1179
|
+
const response = await chunkDSTYXT2D_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
|
|
1180
1180
|
if (!response.ok) {
|
|
1181
1181
|
throw new Error(`Failed to get transaction status: ${response.statusText}`);
|
|
1182
1182
|
}
|
|
@@ -1260,7 +1260,7 @@ var EsploraProvider = class {
|
|
|
1260
1260
|
return stopFunc;
|
|
1261
1261
|
}
|
|
1262
1262
|
async getChainTip() {
|
|
1263
|
-
const tipBlocks = await
|
|
1263
|
+
const tipBlocks = await chunkDSTYXT2D_cjs.baseFetch(`${this.baseUrl}/blocks`);
|
|
1264
1264
|
if (!tipBlocks.ok) {
|
|
1265
1265
|
throw new Error(`Failed to get chain tip: ${tipBlocks.statusText}`);
|
|
1266
1266
|
}
|
|
@@ -1279,7 +1279,7 @@ var EsploraProvider = class {
|
|
|
1279
1279
|
};
|
|
1280
1280
|
}
|
|
1281
1281
|
async broadcastPackage(parent, child) {
|
|
1282
|
-
const response = await
|
|
1282
|
+
const response = await chunkDSTYXT2D_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
|
|
1283
1283
|
method: "POST",
|
|
1284
1284
|
headers: {
|
|
1285
1285
|
"Content-Type": "application/json"
|
|
@@ -1293,7 +1293,7 @@ var EsploraProvider = class {
|
|
|
1293
1293
|
return response.json();
|
|
1294
1294
|
}
|
|
1295
1295
|
async broadcastTx(tx) {
|
|
1296
|
-
const response = await
|
|
1296
|
+
const response = await chunkDSTYXT2D_cjs.baseFetch(`${this.baseUrl}/tx`, {
|
|
1297
1297
|
method: "POST",
|
|
1298
1298
|
headers: {
|
|
1299
1299
|
"Content-Type": "text/plain"
|
|
@@ -1455,7 +1455,7 @@ function findP2AOutput(tx) {
|
|
|
1455
1455
|
var CHILD_DUST_AMOUNT = 546;
|
|
1456
1456
|
function buildAnchorChild(params) {
|
|
1457
1457
|
const { parent, feeRate, fundingCoins, changeAddress, tapInternalKey, network } = params;
|
|
1458
|
-
const child = new
|
|
1458
|
+
const child = new chunkDSTYXT2D_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
|
|
1459
1459
|
child.addInput(findP2AOutput(parent));
|
|
1460
1460
|
const estimator = TxWeightEstimator.create().addP2AInput();
|
|
1461
1461
|
for (const _ of fundingCoins) {
|
|
@@ -1503,7 +1503,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
|
|
|
1503
1503
|
);
|
|
1504
1504
|
}
|
|
1505
1505
|
function buildForfeitTxWithOutput(inputs, output, txLocktime) {
|
|
1506
|
-
const tx = new
|
|
1506
|
+
const tx = new chunkDSTYXT2D_cjs.Transaction({
|
|
1507
1507
|
version: 3,
|
|
1508
1508
|
lockTime: txLocktime
|
|
1509
1509
|
});
|
|
@@ -1579,7 +1579,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
|
|
|
1579
1579
|
if (previousScriptKey.length !== 32) {
|
|
1580
1580
|
throw new Error(`parent output ${childIndex} has invalid script`);
|
|
1581
1581
|
}
|
|
1582
|
-
const cosigners =
|
|
1582
|
+
const cosigners = chunkDSTYXT2D_cjs.getArkPsbtFields(child.root, 0, chunkDSTYXT2D_cjs.CosignerPublicKey);
|
|
1583
1583
|
if (cosigners.length === 0) {
|
|
1584
1584
|
throw ErrMissingCosignersPublicKeys;
|
|
1585
1585
|
}
|
|
@@ -1637,7 +1637,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
1637
1637
|
return new _EmulatorPacket(entries);
|
|
1638
1638
|
}
|
|
1639
1639
|
static fromBytes(data) {
|
|
1640
|
-
const reader = new
|
|
1640
|
+
const reader = new chunkV2KENVN6_cjs.BufferReader(data);
|
|
1641
1641
|
const entryCount = reader.readCompactSize();
|
|
1642
1642
|
const entries = [];
|
|
1643
1643
|
for (let i = 0; i < entryCount; i++) {
|
|
@@ -1655,7 +1655,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
1655
1655
|
return _EmulatorPacket.PACKET_TYPE;
|
|
1656
1656
|
}
|
|
1657
1657
|
serialize() {
|
|
1658
|
-
const writer = new
|
|
1658
|
+
const writer = new chunkV2KENVN6_cjs.BufferWriter();
|
|
1659
1659
|
writer.writeCompactSize(this.entries.length);
|
|
1660
1660
|
for (const entry of this.entries) {
|
|
1661
1661
|
writer.writeUint16LE(entry.vin);
|
|
@@ -1742,7 +1742,7 @@ var Extension = class _Extension {
|
|
|
1742
1742
|
`expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
|
|
1743
1743
|
);
|
|
1744
1744
|
}
|
|
1745
|
-
const reader = new
|
|
1745
|
+
const reader = new chunkV2KENVN6_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
|
|
1746
1746
|
const packets = [];
|
|
1747
1747
|
while (reader.remaining() > 0) {
|
|
1748
1748
|
const packetType = reader.readByte();
|
|
@@ -1816,7 +1816,7 @@ var Extension = class _Extension {
|
|
|
1816
1816
|
*/
|
|
1817
1817
|
getAssetPacket() {
|
|
1818
1818
|
for (const p of this.packets) {
|
|
1819
|
-
if (p instanceof
|
|
1819
|
+
if (p instanceof chunkV2KENVN6_cjs.Packet) {
|
|
1820
1820
|
return p;
|
|
1821
1821
|
}
|
|
1822
1822
|
}
|
|
@@ -1854,8 +1854,8 @@ var Extension = class _Extension {
|
|
|
1854
1854
|
};
|
|
1855
1855
|
function parsePacket(packetType, data) {
|
|
1856
1856
|
switch (packetType) {
|
|
1857
|
-
case
|
|
1858
|
-
return
|
|
1857
|
+
case chunkV2KENVN6_cjs.Packet.PACKET_TYPE:
|
|
1858
|
+
return chunkV2KENVN6_cjs.Packet.fromBytes(data);
|
|
1859
1859
|
case EmulatorPacket.PACKET_TYPE:
|
|
1860
1860
|
return EmulatorPacket.fromBytes(data);
|
|
1861
1861
|
default:
|
|
@@ -1902,16 +1902,16 @@ function buildOpReturnScript(data) {
|
|
|
1902
1902
|
}
|
|
1903
1903
|
return script;
|
|
1904
1904
|
}
|
|
1905
|
-
var ErrOffchainOutputNotFound = (address) => new
|
|
1906
|
-
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new
|
|
1905
|
+
var ErrOffchainOutputNotFound = (address) => new chunkDSTYXT2D_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
|
|
1906
|
+
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkDSTYXT2D_cjs.ServerResponseMismatchError(
|
|
1907
1907
|
`invalid asset output amount for ${assetId}: got ${got}, want ${want}`
|
|
1908
1908
|
);
|
|
1909
|
-
var ErrAssetGroupNotFound = (assetId) => new
|
|
1910
|
-
var ErrAssetOutputNotFound = (assetId, outputIndex) => new
|
|
1909
|
+
var ErrAssetGroupNotFound = (assetId) => new chunkDSTYXT2D_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
|
|
1910
|
+
var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkDSTYXT2D_cjs.ServerResponseMismatchError(
|
|
1911
1911
|
`asset output not found in asset group ${assetId} at index ${outputIndex}`
|
|
1912
1912
|
);
|
|
1913
|
-
var ErrOnchainOutputNotFound = (address) => new
|
|
1914
|
-
var ErrUnvalidatedOffchainOutput = (address) => new
|
|
1913
|
+
var ErrOnchainOutputNotFound = (address) => new chunkDSTYXT2D_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
|
|
1914
|
+
var ErrUnvalidatedOffchainOutput = (address) => new chunkDSTYXT2D_cjs.ServerResponseMismatchError(
|
|
1915
1915
|
`offchain output ${address} cannot be validated: virtual output tree signing did not run`
|
|
1916
1916
|
);
|
|
1917
1917
|
var ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
|
|
@@ -1920,7 +1920,7 @@ var ErrInvalidOffchainOutputAmount = (address) => new Error(`invalid offchain ou
|
|
|
1920
1920
|
function assertFinalCommitmentMatchesValidated(finalCommitmentTx, validatedCommitmentTxid, context) {
|
|
1921
1921
|
if (!validatedCommitmentTxid) return;
|
|
1922
1922
|
if (finalCommitmentTx.id === validatedCommitmentTxid) return;
|
|
1923
|
-
throw new
|
|
1923
|
+
throw new chunkDSTYXT2D_cjs.ServerResponseMismatchError(
|
|
1924
1924
|
`${context}: finalization commitment tx ${finalCommitmentTx.id} differs from the validated commitment tx ${validatedCommitmentTxid}`
|
|
1925
1925
|
);
|
|
1926
1926
|
}
|
|
@@ -1930,7 +1930,7 @@ function validateBatchRecipients(commitmentTx, vtxoTreeLeaves, recipients, netwo
|
|
|
1930
1930
|
for (const recipient of recipients) {
|
|
1931
1931
|
let arkAddress;
|
|
1932
1932
|
try {
|
|
1933
|
-
arkAddress =
|
|
1933
|
+
arkAddress = chunkDSTYXT2D_cjs.ArkAddress.decode(recipient.address);
|
|
1934
1934
|
} catch {
|
|
1935
1935
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
1936
1936
|
continue;
|
|
@@ -1942,7 +1942,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
|
|
|
1942
1942
|
const usedOnchainOutputs = /* @__PURE__ */ new Set();
|
|
1943
1943
|
for (const recipient of recipients) {
|
|
1944
1944
|
try {
|
|
1945
|
-
|
|
1945
|
+
chunkDSTYXT2D_cjs.ArkAddress.decode(recipient.address);
|
|
1946
1946
|
} catch {
|
|
1947
1947
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
1948
1948
|
continue;
|
|
@@ -2173,7 +2173,7 @@ function assetMintResolver() {
|
|
|
2173
2173
|
if (!tx.assets?.length || !tx.key.arkTxid) return void 0;
|
|
2174
2174
|
const minted = tx.assets.filter((a) => {
|
|
2175
2175
|
try {
|
|
2176
|
-
return base.hex.encode(
|
|
2176
|
+
return base.hex.encode(chunkV2KENVN6_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
|
|
2177
2177
|
} catch {
|
|
2178
2178
|
return false;
|
|
2179
2179
|
}
|
|
@@ -2216,7 +2216,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2216
2216
|
const existing = inputsByAssetId.get(asset.assetId);
|
|
2217
2217
|
inputsByAssetId.set(asset.assetId, [
|
|
2218
2218
|
...existing ?? [],
|
|
2219
|
-
|
|
2219
|
+
chunkV2KENVN6_cjs.AssetInput.create(inputIndex, asset.amount)
|
|
2220
2220
|
]);
|
|
2221
2221
|
}
|
|
2222
2222
|
}
|
|
@@ -2228,7 +2228,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2228
2228
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
2229
2229
|
outputsByAssetId.set(asset.assetId, [
|
|
2230
2230
|
...existing ?? [],
|
|
2231
|
-
|
|
2231
|
+
chunkV2KENVN6_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
2232
2232
|
]);
|
|
2233
2233
|
}
|
|
2234
2234
|
}
|
|
@@ -2239,7 +2239,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2239
2239
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
2240
2240
|
outputsByAssetId.set(asset.assetId, [
|
|
2241
2241
|
...existing ?? [],
|
|
2242
|
-
|
|
2242
|
+
chunkV2KENVN6_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
2243
2243
|
]);
|
|
2244
2244
|
}
|
|
2245
2245
|
}
|
|
@@ -2248,11 +2248,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2248
2248
|
for (const assetIdStr of allAssetIds) {
|
|
2249
2249
|
const inputs = inputsByAssetId.get(assetIdStr);
|
|
2250
2250
|
const outputs = outputsByAssetId.get(assetIdStr);
|
|
2251
|
-
const assetId =
|
|
2252
|
-
const group =
|
|
2251
|
+
const assetId = chunkV2KENVN6_cjs.AssetId.fromString(assetIdStr);
|
|
2252
|
+
const group = chunkV2KENVN6_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
|
|
2253
2253
|
groups.push(group);
|
|
2254
2254
|
}
|
|
2255
|
-
return
|
|
2255
|
+
return chunkV2KENVN6_cjs.Packet.create(groups);
|
|
2256
2256
|
}
|
|
2257
2257
|
function selectCoinsWithAsset(coins, assetId, requiredAmount) {
|
|
2258
2258
|
const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
|
|
@@ -2335,22 +2335,22 @@ var toTimelock = (value) => ({
|
|
|
2335
2335
|
type: value >= 512n ? "seconds" : "blocks"
|
|
2336
2336
|
});
|
|
2337
2337
|
var toSeconds = (t) => t.type === "seconds" ? t.value : t.value * NOMINAL_BLOCK_SECONDS;
|
|
2338
|
-
function assertTimelockInPolicy(timelock, policy, label) {
|
|
2338
|
+
function assertTimelockInPolicy(timelock, policy, label, overrideOption) {
|
|
2339
2339
|
if (policy.requireSeconds && timelock.type === "blocks") {
|
|
2340
|
-
throw new
|
|
2340
|
+
throw new chunkDSTYXT2D_cjs.ServerResponseMismatchError(
|
|
2341
2341
|
`${label} rejected: block-typed timelocks are not accepted (got ${timelock.value})`
|
|
2342
2342
|
);
|
|
2343
2343
|
}
|
|
2344
2344
|
const seconds = toSeconds(timelock);
|
|
2345
2345
|
if (seconds < policy.minSeconds) {
|
|
2346
|
-
throw new
|
|
2347
|
-
`${label} rejected: ${timelock.value} ${timelock.type} is below the ${policy.minSeconds}s floor`
|
|
2346
|
+
throw new chunkDSTYXT2D_cjs.ServerResponseMismatchError(
|
|
2347
|
+
`${label} rejected: ${timelock.value} ${timelock.type} is below the ${policy.minSeconds}s floor; pass ${overrideOption}: ${seconds}n to Wallet.create to lower it`
|
|
2348
2348
|
);
|
|
2349
2349
|
}
|
|
2350
2350
|
return timelock;
|
|
2351
2351
|
}
|
|
2352
|
-
function assertTimelockWithinFloor(value, policy, label) {
|
|
2353
|
-
return assertTimelockInPolicy(toTimelock(value), policy, label);
|
|
2352
|
+
function assertTimelockWithinFloor(value, policy, label, overrideOption) {
|
|
2353
|
+
return assertTimelockInPolicy(toTimelock(value), policy, label, overrideOption);
|
|
2354
2354
|
}
|
|
2355
2355
|
|
|
2356
2356
|
// src/wallet/batchExpiry.ts
|
|
@@ -2364,16 +2364,29 @@ function resolveBatchExpiryPolicy(network, overrides) {
|
|
|
2364
2364
|
}
|
|
2365
2365
|
function assertValidBatchExpiry(batchExpiry, policy) {
|
|
2366
2366
|
if (policy.advertisedVtxoTreeExpiry !== void 0 && batchExpiry !== policy.advertisedVtxoTreeExpiry) {
|
|
2367
|
-
throw new
|
|
2367
|
+
throw new chunkDSTYXT2D_cjs.ServerResponseMismatchError(
|
|
2368
2368
|
`batch expiry rejected: ${batchExpiry} does not match the advertised vtxoTreeExpiry ${policy.advertisedVtxoTreeExpiry}`
|
|
2369
2369
|
);
|
|
2370
2370
|
}
|
|
2371
|
-
return assertTimelockWithinFloor(batchExpiry, policy, "batch expiry");
|
|
2371
|
+
return assertTimelockWithinFloor(batchExpiry, policy, "batch expiry", "minBatchExpirySeconds");
|
|
2372
2372
|
}
|
|
2373
2373
|
var DEFAULT_MIN_CHECKPOINT_EXIT_DELAY_SECONDS = 86400n;
|
|
2374
2374
|
var REGTEST_MIN_CHECKPOINT_EXIT_DELAY_SECONDS = 1200n;
|
|
2375
|
+
var MUTINYNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS = 4096n;
|
|
2376
|
+
var SIGNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS = 86016n;
|
|
2377
|
+
var HOSTED_MIN_CHECKPOINT_EXIT_DELAY_SECONDS = {
|
|
2378
|
+
signet: SIGNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS,
|
|
2379
|
+
mutinynet: MUTINYNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS
|
|
2380
|
+
};
|
|
2375
2381
|
function defaultCheckpointExitDelayPolicy(network) {
|
|
2376
|
-
|
|
2382
|
+
if (isRegtest(network)) {
|
|
2383
|
+
return { minSeconds: REGTEST_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, requireSeconds: false };
|
|
2384
|
+
}
|
|
2385
|
+
const hosted = network.name ? HOSTED_MIN_CHECKPOINT_EXIT_DELAY_SECONDS[network.name] : void 0;
|
|
2386
|
+
return {
|
|
2387
|
+
minSeconds: hosted ?? DEFAULT_MIN_CHECKPOINT_EXIT_DELAY_SECONDS,
|
|
2388
|
+
requireSeconds: true
|
|
2389
|
+
};
|
|
2377
2390
|
}
|
|
2378
2391
|
function resolveCheckpointExitDelayPolicy(network, overrides) {
|
|
2379
2392
|
return { ...defaultCheckpointExitDelayPolicy(network), ...overrides };
|
|
@@ -2381,26 +2394,31 @@ function resolveCheckpointExitDelayPolicy(network, overrides) {
|
|
|
2381
2394
|
function assertValidServerUnrollScript(checkpointTapscript, policy) {
|
|
2382
2395
|
let script;
|
|
2383
2396
|
try {
|
|
2384
|
-
script =
|
|
2397
|
+
script = chunkDSTYXT2D_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
|
|
2385
2398
|
} catch (e) {
|
|
2386
|
-
throw new
|
|
2399
|
+
throw new chunkDSTYXT2D_cjs.ServerResponseMismatchError(
|
|
2387
2400
|
`checkpoint exit delay rejected: invalid checkpointTapscript from server (${e instanceof Error ? e.message : String(e)})`
|
|
2388
2401
|
);
|
|
2389
2402
|
}
|
|
2390
2403
|
if (policy.advertisedForfeitPubkey !== void 0) {
|
|
2391
2404
|
const { pubkeys } = script.params;
|
|
2392
2405
|
if (pubkeys.length !== 1) {
|
|
2393
|
-
throw new
|
|
2406
|
+
throw new chunkDSTYXT2D_cjs.ServerResponseMismatchError(
|
|
2394
2407
|
`checkpoint exit delay rejected: checkpointTapscript must commit to exactly one pubkey, got ${pubkeys.length} [${pubkeys.map(base.hex.encode).join(", ")}]`
|
|
2395
2408
|
);
|
|
2396
2409
|
}
|
|
2397
2410
|
if (!utils_js.equalBytes(pubkeys[0], policy.advertisedForfeitPubkey)) {
|
|
2398
|
-
throw new
|
|
2411
|
+
throw new chunkDSTYXT2D_cjs.ServerResponseMismatchError(
|
|
2399
2412
|
`checkpoint exit delay rejected: checkpointTapscript pubkey ${base.hex.encode(pubkeys[0])} does not match the advertised forfeitPubkey ${base.hex.encode(policy.advertisedForfeitPubkey)}`
|
|
2400
2413
|
);
|
|
2401
2414
|
}
|
|
2402
2415
|
}
|
|
2403
|
-
assertTimelockInPolicy(
|
|
2416
|
+
assertTimelockInPolicy(
|
|
2417
|
+
script.params.timelock,
|
|
2418
|
+
policy,
|
|
2419
|
+
"checkpoint exit delay",
|
|
2420
|
+
"minCheckpointExitDelaySeconds"
|
|
2421
|
+
);
|
|
2404
2422
|
return script;
|
|
2405
2423
|
}
|
|
2406
2424
|
function buildOffchainTx(inputs, outputs, serverUnrollScript) {
|
|
@@ -2434,8 +2452,8 @@ function buildOffchainTx(inputs, outputs, serverUnrollScript) {
|
|
|
2434
2452
|
function buildVirtualTx(inputs, outputs) {
|
|
2435
2453
|
let lockTime = 0n;
|
|
2436
2454
|
for (const input of inputs) {
|
|
2437
|
-
const tapscript =
|
|
2438
|
-
if (
|
|
2455
|
+
const tapscript = chunkDSTYXT2D_cjs.decodeTapscript(chunkDSTYXT2D_cjs.scriptFromTapLeafScript(input.tapLeafScript));
|
|
2456
|
+
if (chunkDSTYXT2D_cjs.CLTVMultisigTapscript.is(tapscript)) {
|
|
2439
2457
|
if (lockTime !== 0n) {
|
|
2440
2458
|
if (isSeconds(lockTime) !== isSeconds(tapscript.params.absoluteTimelock)) {
|
|
2441
2459
|
throw new Error("cannot mix seconds and blocks locktime");
|
|
@@ -2446,7 +2464,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
2446
2464
|
}
|
|
2447
2465
|
}
|
|
2448
2466
|
}
|
|
2449
|
-
const tx = new
|
|
2467
|
+
const tx = new chunkDSTYXT2D_cjs.Transaction({
|
|
2450
2468
|
version: 3,
|
|
2451
2469
|
lockTime: Number(lockTime)
|
|
2452
2470
|
});
|
|
@@ -2456,12 +2474,12 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
2456
2474
|
index: input.vout,
|
|
2457
2475
|
sequence: lockTime ? btcSigner.DEFAULT_SEQUENCE - 1 : void 0,
|
|
2458
2476
|
witnessUtxo: {
|
|
2459
|
-
script:
|
|
2477
|
+
script: chunkDSTYXT2D_cjs.VtxoScript.decode(input.tapTree).pkScript,
|
|
2460
2478
|
amount: BigInt(input.value)
|
|
2461
2479
|
},
|
|
2462
2480
|
tapLeafScript: [input.tapLeafScript]
|
|
2463
2481
|
});
|
|
2464
|
-
|
|
2482
|
+
chunkDSTYXT2D_cjs.setArkPsbtField(tx, i, chunkDSTYXT2D_cjs.VtxoTaprootTree, input.tapTree);
|
|
2465
2483
|
}
|
|
2466
2484
|
for (const output of outputs) {
|
|
2467
2485
|
tx.addOutput(output);
|
|
@@ -2470,8 +2488,8 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
2470
2488
|
return tx;
|
|
2471
2489
|
}
|
|
2472
2490
|
function buildCheckpointTx(vtxo, serverUnrollScript) {
|
|
2473
|
-
const collaborativeClosure =
|
|
2474
|
-
const checkpointVtxoScript = new
|
|
2491
|
+
const collaborativeClosure = chunkDSTYXT2D_cjs.decodeTapscript(chunkDSTYXT2D_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
|
|
2492
|
+
const checkpointVtxoScript = new chunkDSTYXT2D_cjs.VtxoScript([
|
|
2475
2493
|
serverUnrollScript.script,
|
|
2476
2494
|
collaborativeClosure.script
|
|
2477
2495
|
]);
|
|
@@ -2624,7 +2642,7 @@ function combineTapscriptSigs(signedTx, originalTx) {
|
|
|
2624
2642
|
}
|
|
2625
2643
|
function isValidArkAddress(address) {
|
|
2626
2644
|
try {
|
|
2627
|
-
|
|
2645
|
+
chunkDSTYXT2D_cjs.ArkAddress.decode(address);
|
|
2628
2646
|
return true;
|
|
2629
2647
|
} catch (e) {
|
|
2630
2648
|
return false;
|
|
@@ -2632,16 +2650,16 @@ function isValidArkAddress(address) {
|
|
|
2632
2650
|
}
|
|
2633
2651
|
function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, context) {
|
|
2634
2652
|
if (serverCheckpointTxs.length !== expectedCheckpoints.length) {
|
|
2635
|
-
throw new
|
|
2653
|
+
throw new chunkDSTYXT2D_cjs.ServerResponseMismatchError(
|
|
2636
2654
|
`${context} returned ${serverCheckpointTxs.length} checkpoints, expected ${expectedCheckpoints.length}`
|
|
2637
2655
|
);
|
|
2638
2656
|
}
|
|
2639
2657
|
const byTxid = new Map(expectedCheckpoints.map((c) => [c.id, c]));
|
|
2640
2658
|
return serverCheckpointTxs.map((encoded, index) => {
|
|
2641
|
-
const server =
|
|
2659
|
+
const server = chunkDSTYXT2D_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
|
|
2642
2660
|
const local = byTxid.get(server.id);
|
|
2643
2661
|
if (!local) {
|
|
2644
|
-
throw new
|
|
2662
|
+
throw new chunkDSTYXT2D_cjs.ServerResponseMismatchError(
|
|
2645
2663
|
`${context} checkpoint ${index} txid ${server.id} does not match any submitted checkpoint`
|
|
2646
2664
|
);
|
|
2647
2665
|
}
|
|
@@ -2651,14 +2669,14 @@ function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, contex
|
|
|
2651
2669
|
}
|
|
2652
2670
|
function assertSubmittedArkTxid(response, signedArkTx, context) {
|
|
2653
2671
|
if (response.arkTxid !== signedArkTx.id) {
|
|
2654
|
-
throw new
|
|
2672
|
+
throw new chunkDSTYXT2D_cjs.ServerResponseMismatchError(
|
|
2655
2673
|
`${context} returned ark txid ${response.arkTxid}, expected ${signedArkTx.id}`
|
|
2656
2674
|
);
|
|
2657
2675
|
}
|
|
2658
2676
|
if (response.finalArkTx === void 0) return;
|
|
2659
|
-
const finalTxid =
|
|
2677
|
+
const finalTxid = chunkDSTYXT2D_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
|
|
2660
2678
|
if (finalTxid !== signedArkTx.id) {
|
|
2661
|
-
throw new
|
|
2679
|
+
throw new chunkDSTYXT2D_cjs.ServerResponseMismatchError(
|
|
2662
2680
|
`${context} returned final ark tx ${finalTxid}, expected ${signedArkTx.id}`
|
|
2663
2681
|
);
|
|
2664
2682
|
}
|
|
@@ -2667,20 +2685,20 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
2667
2685
|
const byOutpoint = new Map(inputs.map((input) => [`${input.txid}:${input.vout}`, input]));
|
|
2668
2686
|
for (const [index, checkpoint] of checkpoints.entries()) {
|
|
2669
2687
|
if (checkpoint.inputsLength !== 1) {
|
|
2670
|
-
throw new
|
|
2688
|
+
throw new chunkDSTYXT2D_cjs.ServerResponseMismatchError(
|
|
2671
2689
|
`${context}: checkpoint ${index} spends ${checkpoint.inputsLength} inputs, expected 1`
|
|
2672
2690
|
);
|
|
2673
2691
|
}
|
|
2674
2692
|
const spent = checkpoint.getInput(0);
|
|
2675
2693
|
if (!spent.txid || spent.index === void 0) {
|
|
2676
|
-
throw new
|
|
2694
|
+
throw new chunkDSTYXT2D_cjs.ServerResponseMismatchError(
|
|
2677
2695
|
`${context}: checkpoint ${index} has no input outpoint`
|
|
2678
2696
|
);
|
|
2679
2697
|
}
|
|
2680
2698
|
const outpoint = `${base.hex.encode(spent.txid)}:${spent.index}`;
|
|
2681
2699
|
const input = byOutpoint.get(outpoint);
|
|
2682
2700
|
if (!input) {
|
|
2683
|
-
throw new
|
|
2701
|
+
throw new chunkDSTYXT2D_cjs.ServerResponseMismatchError(
|
|
2684
2702
|
`${context}: checkpoint ${index} spends ${outpoint}, which is not one of the requested virtual outputs`
|
|
2685
2703
|
);
|
|
2686
2704
|
}
|
|
@@ -2688,7 +2706,7 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
2688
2706
|
(unroll) => buildCheckpointTx(input, unroll).tx.id === checkpoint.id
|
|
2689
2707
|
);
|
|
2690
2708
|
if (!rebuilt) {
|
|
2691
|
-
throw new
|
|
2709
|
+
throw new chunkDSTYXT2D_cjs.ServerResponseMismatchError(
|
|
2692
2710
|
`${context}: checkpoint ${index} txid ${checkpoint.id} differs from the checkpoint built locally for ${outpoint}`
|
|
2693
2711
|
);
|
|
2694
2712
|
}
|
|
@@ -2922,7 +2940,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
|
|
|
2922
2940
|
};
|
|
2923
2941
|
}
|
|
2924
2942
|
function deriveContractTapscripts(contract) {
|
|
2925
|
-
const handler =
|
|
2943
|
+
const handler = chunk2XO43UHI_cjs.contractHandlers.get(contract.type);
|
|
2926
2944
|
if (!handler) {
|
|
2927
2945
|
throw new Error(`No handler for contract type '${contract.type}'`);
|
|
2928
2946
|
}
|
|
@@ -2993,7 +3011,7 @@ function getRandomId() {
|
|
|
2993
3011
|
}
|
|
2994
3012
|
function isValidArkAddress2(address) {
|
|
2995
3013
|
try {
|
|
2996
|
-
|
|
3014
|
+
chunkDSTYXT2D_cjs.ArkAddress.decode(address);
|
|
2997
3015
|
return true;
|
|
2998
3016
|
} catch (e) {
|
|
2999
3017
|
return false;
|
|
@@ -3023,7 +3041,7 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
3023
3041
|
for (const recipient of recipients) {
|
|
3024
3042
|
let address;
|
|
3025
3043
|
try {
|
|
3026
|
-
address =
|
|
3044
|
+
address = chunkDSTYXT2D_cjs.ArkAddress.decode(recipient.address);
|
|
3027
3045
|
} catch (e) {
|
|
3028
3046
|
throw new Error(`Invalid Arkade address: ${recipient.address}`);
|
|
3029
3047
|
}
|
|
@@ -3052,7 +3070,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
|
|
|
3052
3070
|
continue;
|
|
3053
3071
|
}
|
|
3054
3072
|
for (const v of vtxos) {
|
|
3055
|
-
if (!
|
|
3073
|
+
if (!chunkDSTYXT2D_cjs.hasTerminalSpend(v) && !v.isSwept) out.add(`${v.txid}:${v.vout}`);
|
|
3056
3074
|
}
|
|
3057
3075
|
}
|
|
3058
3076
|
return out;
|
|
@@ -3085,10 +3103,10 @@ function byValueDescending(vtxos) {
|
|
|
3085
3103
|
return [...vtxos].sort((a, b) => b.value - a.value);
|
|
3086
3104
|
}
|
|
3087
3105
|
async function fetchTimeHeight(wallet) {
|
|
3088
|
-
return
|
|
3106
|
+
return chunkDSTYXT2D_cjs.resolveTimeHeight(wallet.onchainProvider);
|
|
3089
3107
|
}
|
|
3090
3108
|
function canMigrateBySend(vtxo, now) {
|
|
3091
|
-
if (!
|
|
3109
|
+
if (!chunkDSTYXT2D_cjs.canSpendOffchain(vtxo, now)) return false;
|
|
3092
3110
|
return vtxo.expiresAt !== void 0 || vtxo.expiresAtHeight !== void 0;
|
|
3093
3111
|
}
|
|
3094
3112
|
function byExpiryAscending(vtxos, now) {
|
|
@@ -3096,7 +3114,7 @@ function byExpiryAscending(vtxos, now) {
|
|
|
3096
3114
|
if (vtxo.isSwept) return -Infinity;
|
|
3097
3115
|
if (vtxo.expiresAt !== void 0) return vtxo.expiresAt.getTime();
|
|
3098
3116
|
if (vtxo.expiresAtHeight !== void 0) {
|
|
3099
|
-
return
|
|
3117
|
+
return chunkDSTYXT2D_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
|
|
3100
3118
|
}
|
|
3101
3119
|
return Infinity;
|
|
3102
3120
|
};
|
|
@@ -3119,6 +3137,40 @@ function capSettlementBatch(sorted, maxAmount) {
|
|
|
3119
3137
|
}
|
|
3120
3138
|
return batch;
|
|
3121
3139
|
}
|
|
3140
|
+
function priceSettlementInputs(vtxos, estimator) {
|
|
3141
|
+
const payable = [];
|
|
3142
|
+
const net = /* @__PURE__ */ new Map();
|
|
3143
|
+
for (const vtxo of vtxos) {
|
|
3144
|
+
const inputFee = estimator.evalOffchainInput(chunkDSTYXT2D_cjs.toOffchainInputFeeParams(vtxo));
|
|
3145
|
+
if (inputFee.satoshis >= vtxo.value) {
|
|
3146
|
+
continue;
|
|
3147
|
+
}
|
|
3148
|
+
payable.push(vtxo);
|
|
3149
|
+
net.set(`${vtxo.txid}:${vtxo.vout}`, BigInt(vtxo.value - inputFee.satoshis));
|
|
3150
|
+
}
|
|
3151
|
+
return { payable, net };
|
|
3152
|
+
}
|
|
3153
|
+
function subtotalOf(vtxos, net) {
|
|
3154
|
+
let subtotal = 0n;
|
|
3155
|
+
for (const vtxo of vtxos) {
|
|
3156
|
+
const priced = net.get(`${vtxo.txid}:${vtxo.vout}`);
|
|
3157
|
+
if (priced === void 0) {
|
|
3158
|
+
throw new Error(`Unpriced settlement input ${vtxo.txid}:${vtxo.vout}`);
|
|
3159
|
+
}
|
|
3160
|
+
subtotal += priced;
|
|
3161
|
+
}
|
|
3162
|
+
return subtotal;
|
|
3163
|
+
}
|
|
3164
|
+
function deductOffchainOutputFee(subtotal, estimator, arkAddress) {
|
|
3165
|
+
if (!estimator.config.offchainOutput) {
|
|
3166
|
+
return subtotal;
|
|
3167
|
+
}
|
|
3168
|
+
const outputFee = estimator.evalOffchainOutput({
|
|
3169
|
+
amount: subtotal,
|
|
3170
|
+
script: base.hex.encode(chunkDSTYXT2D_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
3171
|
+
});
|
|
3172
|
+
return subtotal - BigInt(outputFee.satoshis);
|
|
3173
|
+
}
|
|
3122
3174
|
var DEFAULT_THRESHOLD_SECONDS = 259200;
|
|
3123
3175
|
var DEFAULT_THRESHOLD_MS = DEFAULT_THRESHOLD_SECONDS * 1e3;
|
|
3124
3176
|
var DEFAULT_RENEWAL_CONFIG = {
|
|
@@ -3133,10 +3185,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
|
|
|
3133
3185
|
};
|
|
3134
3186
|
function getRecoverableVtxos(vtxos, dustAmount, now) {
|
|
3135
3187
|
return vtxos.filter((vtxo) => {
|
|
3136
|
-
if (
|
|
3188
|
+
if (chunkDSTYXT2D_cjs.canRecoverOnchain(vtxo, now)) {
|
|
3137
3189
|
return true;
|
|
3138
3190
|
}
|
|
3139
|
-
if (
|
|
3191
|
+
if (chunkDSTYXT2D_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
|
|
3140
3192
|
return true;
|
|
3141
3193
|
}
|
|
3142
3194
|
return false;
|
|
@@ -3167,7 +3219,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
|
|
|
3167
3219
|
}
|
|
3168
3220
|
function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
3169
3221
|
const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
|
|
3170
|
-
const expiresAt =
|
|
3222
|
+
const expiresAt = chunkDSTYXT2D_cjs.normalizeVtxo(vtxo).expiresAt;
|
|
3171
3223
|
if (expiresAt === void 0) return false;
|
|
3172
3224
|
const now = Date.now();
|
|
3173
3225
|
const batchExpiry = expiresAt.getTime();
|
|
@@ -3176,7 +3228,7 @@ function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
|
3176
3228
|
}
|
|
3177
3229
|
function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
|
|
3178
3230
|
return vtxos.filter(
|
|
3179
|
-
(vtxo) => isVtxoExpiringSoon(vtxo, thresholdMs) ||
|
|
3231
|
+
(vtxo) => isVtxoExpiringSoon(vtxo, thresholdMs) || chunkDSTYXT2D_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount)
|
|
3180
3232
|
);
|
|
3181
3233
|
}
|
|
3182
3234
|
function isMigrationCapable(wallet) {
|
|
@@ -3326,19 +3378,27 @@ var VtxoManager = class _VtxoManager {
|
|
|
3326
3378
|
});
|
|
3327
3379
|
const dustAmount = getDustAmount(this.wallet);
|
|
3328
3380
|
const now = await fetchTimeHeight(this.wallet);
|
|
3329
|
-
let { vtxosToRecover
|
|
3381
|
+
let { vtxosToRecover } = getRecoverableWithSubdust(allVtxos, dustAmount, now);
|
|
3330
3382
|
if (vtxosToRecover.length === 0) {
|
|
3331
3383
|
throw new Error("No recoverable VTXOs found");
|
|
3332
3384
|
}
|
|
3333
3385
|
const info = await this.getInfoProvider()?.getInfo();
|
|
3334
3386
|
const vtxoMaxAmount = info?.vtxoMaxAmount ?? -1n;
|
|
3335
|
-
const
|
|
3387
|
+
const estimator = new Estimator(info?.fees.intentFee ?? {});
|
|
3388
|
+
const { payable, net } = priceSettlementInputs(vtxosToRecover, estimator);
|
|
3389
|
+
const capped = capSettlementBatch(byValueDescending(payable), vtxoMaxAmount);
|
|
3336
3390
|
if (capped.length < vtxosToRecover.length) {
|
|
3337
3391
|
const recoverableCount = vtxosToRecover.length;
|
|
3338
|
-
|
|
3392
|
+
const cappedAway = capped.length < payable.length;
|
|
3393
|
+
({ vtxosToRecover } = getRecoverableWithSubdust(capped, dustAmount, now));
|
|
3339
3394
|
if (vtxosToRecover.length === 0) {
|
|
3395
|
+
if (!cappedAway) {
|
|
3396
|
+
throw new Error(
|
|
3397
|
+
`All ${recoverableCount} recoverable VTXOs that can pay their own intent fee total less than the dust threshold ${dustAmount}`
|
|
3398
|
+
);
|
|
3399
|
+
}
|
|
3340
3400
|
throw new Error(
|
|
3341
|
-
`Capped recovery batch (highest-value subset of ${recoverableCount} recoverable VTXOs within the ${MAX_VTXOS_PER_SETTLEMENT}-input and ${vtxoMaxAmount}-sat limits) is below the dust threshold ${dustAmount}`
|
|
3401
|
+
`Capped recovery batch (highest-value subset of ${recoverableCount} recoverable VTXOs within the ${MAX_VTXOS_PER_SETTLEMENT}-input and ${vtxoMaxAmount}-sat limits, net of intent fees) is below the dust threshold ${dustAmount}`
|
|
3342
3402
|
);
|
|
3343
3403
|
}
|
|
3344
3404
|
}
|
|
@@ -3346,6 +3406,16 @@ var VtxoManager = class _VtxoManager {
|
|
|
3346
3406
|
await this.rotateForRecoverableInputs(vtxosToRecover, info);
|
|
3347
3407
|
}
|
|
3348
3408
|
const arkAddress = await this.wallet.getAddress();
|
|
3409
|
+
const totalAmount = deductOffchainOutputFee(
|
|
3410
|
+
subtotalOf(vtxosToRecover, net),
|
|
3411
|
+
estimator,
|
|
3412
|
+
arkAddress
|
|
3413
|
+
);
|
|
3414
|
+
if (totalAmount < dustAmount) {
|
|
3415
|
+
throw new Error(
|
|
3416
|
+
`Recoverable amount ${totalAmount} net of intent fees is below dust threshold ${dustAmount}`
|
|
3417
|
+
);
|
|
3418
|
+
}
|
|
3349
3419
|
return this.wallet.settle(
|
|
3350
3420
|
{
|
|
3351
3421
|
inputs: vtxosToRecover,
|
|
@@ -3364,6 +3434,17 @@ var VtxoManager = class _VtxoManager {
|
|
|
3364
3434
|
*
|
|
3365
3435
|
* Useful for displaying to users before they decide to recover funds.
|
|
3366
3436
|
*
|
|
3437
|
+
* Both amounts are net of the operator's intent fees, so `recoverable` is
|
|
3438
|
+
* what {@link recoverVtxos} would actually hand back rather than the gross
|
|
3439
|
+
* sum of the inputs. `subdust` is net of the per-input fees only — the
|
|
3440
|
+
* output fee is charged on the batch as a whole and is not attributed per
|
|
3441
|
+
* coin — so it reports what the subdust coins are worth once each has paid
|
|
3442
|
+
* its own way, and is not strictly a slice of `recoverable`. It can exceed
|
|
3443
|
+
* `recoverable` where a flat output fee meets a wholly subdust wallet.
|
|
3444
|
+
*
|
|
3445
|
+
* The batch size caps are not applied here: they defer the overflow to the
|
|
3446
|
+
* next cycle rather than reducing what is recoverable.
|
|
3447
|
+
*
|
|
3367
3448
|
* @returns Object containing recoverable amounts and subdust information
|
|
3368
3449
|
*
|
|
3369
3450
|
* @example
|
|
@@ -3385,17 +3466,29 @@ var VtxoManager = class _VtxoManager {
|
|
|
3385
3466
|
withUnrolled: false
|
|
3386
3467
|
});
|
|
3387
3468
|
const dustAmount = getDustAmount(this.wallet);
|
|
3388
|
-
const { vtxosToRecover, includesSubdust
|
|
3469
|
+
const { vtxosToRecover, includesSubdust } = getRecoverableWithSubdust(
|
|
3389
3470
|
allVtxos,
|
|
3390
3471
|
dustAmount,
|
|
3391
3472
|
await fetchTimeHeight(this.wallet)
|
|
3392
3473
|
);
|
|
3393
|
-
const
|
|
3474
|
+
const info = await this.getInfoProvider()?.getInfo();
|
|
3475
|
+
const estimator = new Estimator(info?.fees.intentFee ?? {});
|
|
3476
|
+
const { payable, net } = priceSettlementInputs(vtxosToRecover, estimator);
|
|
3477
|
+
const priced = deductOffchainOutputFee(
|
|
3478
|
+
subtotalOf(payable, net),
|
|
3479
|
+
estimator,
|
|
3480
|
+
await this.wallet.getAddress()
|
|
3481
|
+
);
|
|
3482
|
+
const recoverable = priced > 0n ? priced : 0n;
|
|
3483
|
+
const subdustAmount = subtotalOf(
|
|
3484
|
+
payable.filter((v) => BigInt(v.value) < dustAmount),
|
|
3485
|
+
net
|
|
3486
|
+
);
|
|
3394
3487
|
return {
|
|
3395
|
-
recoverable
|
|
3488
|
+
recoverable,
|
|
3396
3489
|
subdust: subdustAmount,
|
|
3397
3490
|
includesSubdust,
|
|
3398
|
-
vtxoCount:
|
|
3491
|
+
vtxoCount: payable.length
|
|
3399
3492
|
};
|
|
3400
3493
|
}
|
|
3401
3494
|
// ========== Renewal Methods ==========
|
|
@@ -3513,6 +3606,14 @@ var VtxoManager = class _VtxoManager {
|
|
|
3513
3606
|
}
|
|
3514
3607
|
const info = await this.getInfoProvider()?.getInfo();
|
|
3515
3608
|
const vtxoMaxAmount = info?.vtxoMaxAmount ?? -1n;
|
|
3609
|
+
const estimator = new Estimator(info?.fees.intentFee ?? {});
|
|
3610
|
+
const { payable, net } = priceSettlementInputs(vtxos, estimator);
|
|
3611
|
+
vtxos = payable;
|
|
3612
|
+
if (vtxos.length === 0) {
|
|
3613
|
+
throw new Error(
|
|
3614
|
+
"No VTXOs available to renew: every expiring VTXO is worth less than its own intent fee"
|
|
3615
|
+
);
|
|
3616
|
+
}
|
|
3516
3617
|
const capped = capSettlementBatch(byExpiryAscending(vtxos, now), vtxoMaxAmount);
|
|
3517
3618
|
if (vtxoMaxAmount >= 0n) {
|
|
3518
3619
|
const oversized = vtxos.filter((vtxo) => BigInt(vtxo.value) > vtxoMaxAmount);
|
|
@@ -3530,24 +3631,28 @@ var VtxoManager = class _VtxoManager {
|
|
|
3530
3631
|
);
|
|
3531
3632
|
}
|
|
3532
3633
|
}
|
|
3533
|
-
const totalAmount = vtxos.reduce((sum, vtxo) => sum + vtxo.value, 0);
|
|
3534
3634
|
const dustAmount = getDustAmount(this.wallet);
|
|
3535
|
-
if (BigInt(totalAmount) < dustAmount) {
|
|
3536
|
-
throw new Error(
|
|
3537
|
-
`Total amount ${totalAmount} is below dust threshold ${dustAmount}`
|
|
3538
|
-
);
|
|
3539
|
-
}
|
|
3540
3635
|
if (info && isMigrationCapable(this.wallet)) {
|
|
3541
3636
|
await this.rotateForRecoverableInputs(vtxos, info);
|
|
3542
3637
|
}
|
|
3543
3638
|
const arkAddress = await this.wallet.getAddress();
|
|
3639
|
+
const totalAmount = deductOffchainOutputFee(
|
|
3640
|
+
subtotalOf(vtxos, net),
|
|
3641
|
+
estimator,
|
|
3642
|
+
arkAddress
|
|
3643
|
+
);
|
|
3644
|
+
if (totalAmount < dustAmount) {
|
|
3645
|
+
throw new Error(
|
|
3646
|
+
`Total amount ${totalAmount} is below dust threshold ${dustAmount}`
|
|
3647
|
+
);
|
|
3648
|
+
}
|
|
3544
3649
|
const txid = await this.wallet.settle(
|
|
3545
3650
|
{
|
|
3546
3651
|
inputs: vtxos,
|
|
3547
3652
|
outputs: [
|
|
3548
3653
|
{
|
|
3549
3654
|
address: arkAddress,
|
|
3550
|
-
amount:
|
|
3655
|
+
amount: totalAmount
|
|
3551
3656
|
}
|
|
3552
3657
|
]
|
|
3553
3658
|
},
|
|
@@ -3658,11 +3763,11 @@ var VtxoManager = class _VtxoManager {
|
|
|
3658
3763
|
`Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
|
|
3659
3764
|
);
|
|
3660
3765
|
}
|
|
3661
|
-
const tx = new
|
|
3766
|
+
const tx = new chunkDSTYXT2D_cjs.Transaction();
|
|
3662
3767
|
for (const utxo of expiredUtxos) {
|
|
3663
|
-
const utxoScript =
|
|
3768
|
+
const utxoScript = chunkDSTYXT2D_cjs.VtxoScript.decode(utxo.tapTree);
|
|
3664
3769
|
const utxoExitLeaf = utxoScript.leaves.find(
|
|
3665
|
-
(leaf) =>
|
|
3770
|
+
(leaf) => chunkDSTYXT2D_cjs.CSVMultisigTapscript.isScriptValid(chunkDSTYXT2D_cjs.scriptFromTapLeafScript(leaf)) === true
|
|
3666
3771
|
);
|
|
3667
3772
|
if (!utxoExitLeaf) {
|
|
3668
3773
|
throw new Error(
|
|
@@ -3677,7 +3782,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
3677
3782
|
amount: BigInt(utxo.value)
|
|
3678
3783
|
},
|
|
3679
3784
|
tapLeafScript: [utxoExitLeaf],
|
|
3680
|
-
sequence:
|
|
3785
|
+
sequence: chunkDSTYXT2D_cjs.getSequence(utxoExitLeaf)
|
|
3681
3786
|
});
|
|
3682
3787
|
}
|
|
3683
3788
|
tx.addOutputAddress(boardingAddress, outputAmount, this.getNetwork());
|
|
@@ -3911,8 +4016,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
3911
4016
|
if (!serverPubKey) continue;
|
|
3912
4017
|
const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
|
|
3913
4018
|
if (cls.status === "CURRENT") continue;
|
|
3914
|
-
const recoverable = vtxos.filter((v) => v.isSwept && !
|
|
3915
|
-
const spendable = vtxos.filter((v) => !
|
|
4019
|
+
const recoverable = vtxos.filter((v) => v.isSwept && !chunkDSTYXT2D_cjs.hasTerminalSpend(v));
|
|
4020
|
+
const spendable = vtxos.filter((v) => !chunkDSTYXT2D_cjs.hasTerminalSpend(v) && !v.isSwept);
|
|
3916
4021
|
const value = spendable.reduce((sum, v) => sum + v.value, 0);
|
|
3917
4022
|
let recoverableCount = 0;
|
|
3918
4023
|
let recoverableValue = 0;
|
|
@@ -3925,7 +4030,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
3925
4030
|
awaitingSweepCount = spendable.length;
|
|
3926
4031
|
awaitingSweepValue = value;
|
|
3927
4032
|
for (const v of spendable) {
|
|
3928
|
-
const exp =
|
|
4033
|
+
const exp = chunkDSTYXT2D_cjs.toBatchExpiry(v);
|
|
3929
4034
|
if (exp !== void 0 && (nextSweepEta === void 0 || exp < nextSweepEta)) {
|
|
3930
4035
|
nextSweepEta = exp;
|
|
3931
4036
|
}
|
|
@@ -4186,7 +4291,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4186
4291
|
/** Decodes the boarding tapscript exit path to extract the CSV timelock. */
|
|
4187
4292
|
getBoardingTimelock() {
|
|
4188
4293
|
const wallet = this.getSweepWallet();
|
|
4189
|
-
const exitScript =
|
|
4294
|
+
const exitScript = chunkDSTYXT2D_cjs.CSVMultisigTapscript.decode(
|
|
4190
4295
|
base.hex.decode(wallet.boardingTapscript.exitScript)
|
|
4191
4296
|
);
|
|
4192
4297
|
return exitScript.params.timelock;
|
|
@@ -4317,8 +4422,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
4317
4422
|
* or doesn't carry the metadata.
|
|
4318
4423
|
*/
|
|
4319
4424
|
extractSpentOutpoint(error) {
|
|
4320
|
-
const ark =
|
|
4321
|
-
if (!
|
|
4425
|
+
const ark = chunkDSTYXT2D_cjs.maybeArkError(error);
|
|
4426
|
+
if (!chunkDSTYXT2D_cjs.isArkError(ark, chunkDSTYXT2D_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
|
|
4322
4427
|
const raw = ark.metadata?.vtxo_outpoint;
|
|
4323
4428
|
if (typeof raw !== "string") return void 0;
|
|
4324
4429
|
const [txid, voutStr] = raw.split(":");
|
|
@@ -4508,7 +4613,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4508
4613
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
4509
4614
|
break;
|
|
4510
4615
|
}
|
|
4511
|
-
const inputFee = estimator.evalOffchainInput(
|
|
4616
|
+
const inputFee = estimator.evalOffchainInput(chunkDSTYXT2D_cjs.toOffchainInputFeeParams(v));
|
|
4512
4617
|
if (inputFee.satoshis >= v.value) {
|
|
4513
4618
|
continue;
|
|
4514
4619
|
}
|
|
@@ -4528,7 +4633,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4528
4633
|
const arkAddress = await this.wallet.getAddress();
|
|
4529
4634
|
const outputFee = estimator.evalOffchainOutput({
|
|
4530
4635
|
amount: totalAmount,
|
|
4531
|
-
script: base.hex.encode(
|
|
4636
|
+
script: base.hex.encode(chunkDSTYXT2D_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
4532
4637
|
});
|
|
4533
4638
|
totalAmount -= BigInt(outputFee.satoshis);
|
|
4534
4639
|
if (totalAmount < dustAmount) return;
|
|
@@ -4608,7 +4713,7 @@ var ArkNote = class _ArkNote {
|
|
|
4608
4713
|
this.value = value;
|
|
4609
4714
|
this.HRP = HRP;
|
|
4610
4715
|
const preimageHash = utils_js.sha256(this.preimage);
|
|
4611
|
-
this.vtxoScript = new
|
|
4716
|
+
this.vtxoScript = new chunkDSTYXT2D_cjs.VtxoScript([noteTapscript(preimageHash)]);
|
|
4612
4717
|
const leaf = this.vtxoScript.leaves[0];
|
|
4613
4718
|
this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
|
|
4614
4719
|
this.tapTree = this.vtxoScript.encode();
|
|
@@ -4775,7 +4880,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
4775
4880
|
const privateKey = data.slice(1, 33);
|
|
4776
4881
|
const serverPubKey = data.slice(33, 65);
|
|
4777
4882
|
const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
|
|
4778
|
-
const csvTimelock =
|
|
4883
|
+
const csvTimelock = chunkDSTYXT2D_cjs.sequenceToTimelock(sequence);
|
|
4779
4884
|
return new _ArkadeCash(privateKey, serverPubKey, csvTimelock, decoded.prefix);
|
|
4780
4885
|
}
|
|
4781
4886
|
toString() {
|
|
@@ -4783,7 +4888,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
4783
4888
|
data[0] = _ArkadeCash.Version;
|
|
4784
4889
|
data.set(this._privateKey, 1);
|
|
4785
4890
|
data.set(this._serverPubKey, 33);
|
|
4786
|
-
const sequence =
|
|
4891
|
+
const sequence = chunkDSTYXT2D_cjs.timelockToSequence(this.csvTimelock);
|
|
4787
4892
|
new DataView(data.buffer, data.byteOffset + 65, 4).setUint32(0, sequence, false);
|
|
4788
4893
|
const words = base.bech32m.toWords(data);
|
|
4789
4894
|
return base.bech32m.encode(this.hrp, words, 1023);
|
|
@@ -4792,7 +4897,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
4792
4897
|
return SingleKey.fromPrivateKey(this._privateKey);
|
|
4793
4898
|
}
|
|
4794
4899
|
get vtxoScript() {
|
|
4795
|
-
return new
|
|
4900
|
+
return new chunk2XO43UHI_cjs.DefaultVtxo.Script({
|
|
4796
4901
|
pubKey: this._publicKey,
|
|
4797
4902
|
serverPubKey: this._serverPubKey,
|
|
4798
4903
|
csvTimelock: this.csvTimelock
|
|
@@ -5053,7 +5158,7 @@ async function captureExitBranch(params) {
|
|
|
5053
5158
|
const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
|
|
5054
5159
|
if (nonCommitment.length > 0) {
|
|
5055
5160
|
for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
|
|
5056
|
-
psbtByTxid.set(
|
|
5161
|
+
psbtByTxid.set(chunkDSTYXT2D_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
5057
5162
|
}
|
|
5058
5163
|
}
|
|
5059
5164
|
}
|
|
@@ -5096,10 +5201,10 @@ var IndexerExitDataSource = class {
|
|
|
5096
5201
|
while (hasMore) {
|
|
5097
5202
|
const { chain: page, page: meta } = await this.indexer.getVtxoChain(
|
|
5098
5203
|
{ txid: vtxo.txid, vout: vtxo.vout },
|
|
5099
|
-
{ pageIndex, pageSize:
|
|
5204
|
+
{ pageIndex, pageSize: chunkDSTYXT2D_cjs.DEFAULT_PAGE_SIZE }
|
|
5100
5205
|
);
|
|
5101
5206
|
chain.push(...page);
|
|
5102
|
-
hasMore = meta ? page.length ===
|
|
5207
|
+
hasMore = meta ? page.length === chunkDSTYXT2D_cjs.DEFAULT_PAGE_SIZE : false;
|
|
5103
5208
|
pageIndex++;
|
|
5104
5209
|
}
|
|
5105
5210
|
return chain;
|
|
@@ -5111,12 +5216,12 @@ var IndexerExitDataSource = class {
|
|
|
5111
5216
|
while (hasMore) {
|
|
5112
5217
|
const { txs, page } = await this.indexer.getVirtualTxs(txids, {
|
|
5113
5218
|
pageIndex,
|
|
5114
|
-
pageSize:
|
|
5219
|
+
pageSize: chunkDSTYXT2D_cjs.DEFAULT_PAGE_SIZE
|
|
5115
5220
|
});
|
|
5116
5221
|
for (const psbt of txs) {
|
|
5117
|
-
out.set(
|
|
5222
|
+
out.set(chunkDSTYXT2D_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
5118
5223
|
}
|
|
5119
|
-
hasMore = page ? txs.length ===
|
|
5224
|
+
hasMore = page ? txs.length === chunkDSTYXT2D_cjs.DEFAULT_PAGE_SIZE : false;
|
|
5120
5225
|
pageIndex++;
|
|
5121
5226
|
}
|
|
5122
5227
|
return out;
|
|
@@ -5137,7 +5242,7 @@ function chainedTxTypeToChainTxType(t) {
|
|
|
5137
5242
|
}
|
|
5138
5243
|
}
|
|
5139
5244
|
function psbtInputTxids(psbtBase64) {
|
|
5140
|
-
const tx =
|
|
5245
|
+
const tx = chunkDSTYXT2D_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
5141
5246
|
const ids = [];
|
|
5142
5247
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
5143
5248
|
const txid = tx.getInput(i).txid;
|
|
@@ -5490,10 +5595,10 @@ async function resolveArkInfo(arkProvider, walletRepository) {
|
|
|
5490
5595
|
try {
|
|
5491
5596
|
info = await arkProvider.getInfo();
|
|
5492
5597
|
} catch (err) {
|
|
5493
|
-
if (!
|
|
5598
|
+
if (!chunkDSTYXT2D_cjs.isRetryableProviderError(err)) throw err;
|
|
5494
5599
|
const snapshot = await loadArkInfoSnapshot(walletRepository);
|
|
5495
5600
|
if (!snapshot) {
|
|
5496
|
-
throw new
|
|
5601
|
+
throw new chunkDSTYXT2D_cjs.ProviderUnavailableError(
|
|
5497
5602
|
"Arkade server info is unavailable and no cached snapshot exists",
|
|
5498
5603
|
{ cause: err }
|
|
5499
5604
|
);
|
|
@@ -5876,7 +5981,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos) {
|
|
|
5876
5981
|
return [...txids];
|
|
5877
5982
|
}
|
|
5878
5983
|
async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt) {
|
|
5879
|
-
const fromOldestVtxo = vtxos.map(
|
|
5984
|
+
const fromOldestVtxo = vtxos.map(chunkDSTYXT2D_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
5880
5985
|
const txidsNeedingCreatedAt = resolveTxCreatedAt ? collectArkTxidsNeedingCreatedAt(fromOldestVtxo) : [];
|
|
5881
5986
|
const resolvedCreatedAt = resolveTxCreatedAt && txidsNeedingCreatedAt.length > 0 ? await resolveTxCreatedAt(txidsNeedingCreatedAt) : /* @__PURE__ */ new Map();
|
|
5882
5987
|
const unmatchedSettledBoardingTxs = allBoardingTxs.filter(isSettledBoardingReceive).sort((a, b) => a.createdAt - b.createdAt);
|
|
@@ -6040,7 +6145,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6040
6145
|
const virtualCoins = await this.wallet.getVtxos({
|
|
6041
6146
|
withRecoverable: false
|
|
6042
6147
|
});
|
|
6043
|
-
const controlAssetRef = params.controlAssetId ?
|
|
6148
|
+
const controlAssetRef = params.controlAssetId ? chunkV2KENVN6_cjs.AssetRef.fromId(chunkV2KENVN6_cjs.AssetId.fromString(params.controlAssetId)) : null;
|
|
6044
6149
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
6045
6150
|
let totalBtcSelected = 0n;
|
|
6046
6151
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -6053,8 +6158,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6053
6158
|
}
|
|
6054
6159
|
}
|
|
6055
6160
|
const groups = [];
|
|
6056
|
-
const issuedAssetOutput =
|
|
6057
|
-
const issuedAssetGroup =
|
|
6161
|
+
const issuedAssetOutput = chunkV2KENVN6_cjs.AssetOutput.create(0, params.amount);
|
|
6162
|
+
const issuedAssetGroup = chunkV2KENVN6_cjs.AssetGroup.create(
|
|
6058
6163
|
null,
|
|
6059
6164
|
controlAssetRef,
|
|
6060
6165
|
[],
|
|
@@ -6069,28 +6174,28 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6069
6174
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6070
6175
|
for (const asset of assets) {
|
|
6071
6176
|
if (asset.assetId !== assetId) continue;
|
|
6072
|
-
changeInputs.push(
|
|
6177
|
+
changeInputs.push(chunkV2KENVN6_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6073
6178
|
}
|
|
6074
6179
|
}
|
|
6075
6180
|
groups.push(
|
|
6076
|
-
|
|
6077
|
-
|
|
6181
|
+
chunkV2KENVN6_cjs.AssetGroup.create(
|
|
6182
|
+
chunkV2KENVN6_cjs.AssetId.fromString(assetId),
|
|
6078
6183
|
null,
|
|
6079
6184
|
changeInputs,
|
|
6080
|
-
[
|
|
6185
|
+
[chunkV2KENVN6_cjs.AssetOutput.create(0, amount)],
|
|
6081
6186
|
[]
|
|
6082
6187
|
)
|
|
6083
6188
|
);
|
|
6084
6189
|
}
|
|
6085
6190
|
}
|
|
6086
6191
|
const address = await this.wallet.getAddress();
|
|
6087
|
-
const outputAddress =
|
|
6192
|
+
const outputAddress = chunkDSTYXT2D_cjs.ArkAddress.decode(address);
|
|
6088
6193
|
const outputs = [
|
|
6089
6194
|
{
|
|
6090
6195
|
script: outputAddress.pkScript,
|
|
6091
6196
|
amount: BigInt(totalBtcSelected)
|
|
6092
6197
|
},
|
|
6093
|
-
Extension.create([
|
|
6198
|
+
Extension.create([chunkV2KENVN6_cjs.Packet.create(groups)]).txOut()
|
|
6094
6199
|
];
|
|
6095
6200
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
|
|
6096
6201
|
coinSelection.inputs,
|
|
@@ -6098,7 +6203,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6098
6203
|
);
|
|
6099
6204
|
return {
|
|
6100
6205
|
arkTxId: arkTxid,
|
|
6101
|
-
assetId:
|
|
6206
|
+
assetId: chunkV2KENVN6_cjs.AssetId.create(arkTxid, 0).toString()
|
|
6102
6207
|
};
|
|
6103
6208
|
}
|
|
6104
6209
|
/**
|
|
@@ -6170,16 +6275,16 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6170
6275
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6171
6276
|
for (const asset of assets) {
|
|
6172
6277
|
if (asset.assetId !== params.assetId) continue;
|
|
6173
|
-
reissueInputs.push(
|
|
6278
|
+
reissueInputs.push(chunkV2KENVN6_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6174
6279
|
}
|
|
6175
6280
|
}
|
|
6176
6281
|
const totalAssetAmount = assetToReissueAmount + params.amount;
|
|
6177
|
-
const reissueAssetIdObj =
|
|
6178
|
-
const reissueAssetGroup =
|
|
6282
|
+
const reissueAssetIdObj = chunkV2KENVN6_cjs.AssetId.fromString(params.assetId);
|
|
6283
|
+
const reissueAssetGroup = chunkV2KENVN6_cjs.AssetGroup.create(
|
|
6179
6284
|
reissueAssetIdObj,
|
|
6180
6285
|
null,
|
|
6181
6286
|
reissueInputs,
|
|
6182
|
-
[
|
|
6287
|
+
[chunkV2KENVN6_cjs.AssetOutput.create(0, totalAssetAmount)],
|
|
6183
6288
|
[]
|
|
6184
6289
|
);
|
|
6185
6290
|
const groups = [reissueAssetGroup];
|
|
@@ -6188,27 +6293,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6188
6293
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6189
6294
|
for (const asset of assets) {
|
|
6190
6295
|
if (asset.assetId !== assetId) continue;
|
|
6191
|
-
changeInputs.push(
|
|
6296
|
+
changeInputs.push(chunkV2KENVN6_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6192
6297
|
}
|
|
6193
6298
|
}
|
|
6194
6299
|
groups.push(
|
|
6195
|
-
|
|
6196
|
-
|
|
6300
|
+
chunkV2KENVN6_cjs.AssetGroup.create(
|
|
6301
|
+
chunkV2KENVN6_cjs.AssetId.fromString(assetId),
|
|
6197
6302
|
null,
|
|
6198
6303
|
changeInputs,
|
|
6199
|
-
[
|
|
6304
|
+
[chunkV2KENVN6_cjs.AssetOutput.create(0, amount)],
|
|
6200
6305
|
[]
|
|
6201
6306
|
)
|
|
6202
6307
|
);
|
|
6203
6308
|
}
|
|
6204
6309
|
const address = await this.wallet.getAddress();
|
|
6205
|
-
const outputAddress =
|
|
6310
|
+
const outputAddress = chunkDSTYXT2D_cjs.ArkAddress.decode(address);
|
|
6206
6311
|
const outputs = [
|
|
6207
6312
|
{
|
|
6208
6313
|
script: outputAddress.pkScript,
|
|
6209
6314
|
amount: BigInt(totalBtcSelected)
|
|
6210
6315
|
},
|
|
6211
|
-
Extension.create([
|
|
6316
|
+
Extension.create([chunkV2KENVN6_cjs.Packet.create(groups)]).txOut()
|
|
6212
6317
|
];
|
|
6213
6318
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
6214
6319
|
return arkTxid;
|
|
@@ -6275,27 +6380,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6275
6380
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6276
6381
|
for (const asset of assets) {
|
|
6277
6382
|
if (asset.assetId !== assetId) continue;
|
|
6278
|
-
changeInputs.push(
|
|
6383
|
+
changeInputs.push(chunkV2KENVN6_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6279
6384
|
}
|
|
6280
6385
|
}
|
|
6281
6386
|
groups.push(
|
|
6282
|
-
|
|
6283
|
-
|
|
6387
|
+
chunkV2KENVN6_cjs.AssetGroup.create(
|
|
6388
|
+
chunkV2KENVN6_cjs.AssetId.fromString(assetId),
|
|
6284
6389
|
null,
|
|
6285
6390
|
changeInputs,
|
|
6286
|
-
amount > 0n ? [
|
|
6391
|
+
amount > 0n ? [chunkV2KENVN6_cjs.AssetOutput.create(0, amount)] : [],
|
|
6287
6392
|
[]
|
|
6288
6393
|
)
|
|
6289
6394
|
);
|
|
6290
6395
|
}
|
|
6291
6396
|
const address = await this.wallet.getAddress();
|
|
6292
|
-
const outputAddress =
|
|
6397
|
+
const outputAddress = chunkDSTYXT2D_cjs.ArkAddress.decode(address);
|
|
6293
6398
|
const outputs = [
|
|
6294
6399
|
{
|
|
6295
6400
|
script: outputAddress.pkScript,
|
|
6296
6401
|
amount: BigInt(totalBtcSelected)
|
|
6297
6402
|
},
|
|
6298
|
-
Extension.create([
|
|
6403
|
+
Extension.create([chunkV2KENVN6_cjs.Packet.create(groups)]).txOut()
|
|
6299
6404
|
];
|
|
6300
6405
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
6301
6406
|
return arkTxid;
|
|
@@ -6320,7 +6425,7 @@ function castMetadata(metadata) {
|
|
|
6320
6425
|
} else {
|
|
6321
6426
|
throw new Error("Invalid metadata value type");
|
|
6322
6427
|
}
|
|
6323
|
-
md.push(
|
|
6428
|
+
md.push(chunkV2KENVN6_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
|
|
6324
6429
|
}
|
|
6325
6430
|
return md;
|
|
6326
6431
|
}
|
|
@@ -6341,10 +6446,10 @@ var DelegateManagerImpl = class {
|
|
|
6341
6446
|
if (vtxos.length === 0) {
|
|
6342
6447
|
return { delegated: [], failed: [] };
|
|
6343
6448
|
}
|
|
6344
|
-
const destinationScript =
|
|
6449
|
+
const destinationScript = chunkDSTYXT2D_cjs.ArkAddress.decode(destination).pkScript;
|
|
6345
6450
|
const arkInfo = await this.arkInfoProvider.getInfo();
|
|
6346
6451
|
const delegateInfo = await this.delegateProvider.getDelegateInfo();
|
|
6347
|
-
const eligible = vtxos.map(
|
|
6452
|
+
const eligible = vtxos.map(chunkDSTYXT2D_cjs.normalizeVtxo).filter(
|
|
6348
6453
|
(v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
|
|
6349
6454
|
);
|
|
6350
6455
|
if (eligible.length === 0) {
|
|
@@ -6373,11 +6478,11 @@ var DelegateManagerImpl = class {
|
|
|
6373
6478
|
const groupByExpiry = /* @__PURE__ */ new Map();
|
|
6374
6479
|
let recoverableVtxos = [];
|
|
6375
6480
|
for (const vtxo of eligible) {
|
|
6376
|
-
if (
|
|
6481
|
+
if (chunkDSTYXT2D_cjs.canRecoverOnchain(vtxo, now)) {
|
|
6377
6482
|
recoverableVtxos.push(vtxo);
|
|
6378
6483
|
continue;
|
|
6379
6484
|
}
|
|
6380
|
-
const expiry =
|
|
6485
|
+
const expiry = chunkDSTYXT2D_cjs.toBatchExpiry(vtxo);
|
|
6381
6486
|
if (!expiry) continue;
|
|
6382
6487
|
const dayKey = getDayTimestamp(expiry);
|
|
6383
6488
|
groupByExpiry.set(dayKey, [...groupByExpiry.get(dayKey) ?? [], vtxo]);
|
|
@@ -6442,7 +6547,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6442
6547
|
}
|
|
6443
6548
|
if (!delegateAt) {
|
|
6444
6549
|
const now = { timestamp: /* @__PURE__ */ new Date() };
|
|
6445
|
-
const expiryTimestamp = vtxos.filter((coin) => !
|
|
6550
|
+
const expiryTimestamp = vtxos.filter((coin) => !chunkDSTYXT2D_cjs.canRecoverOnchain(coin, now) && chunkDSTYXT2D_cjs.toBatchExpiry(coin)).reduce((min, coin) => Math.min(min, chunkDSTYXT2D_cjs.toBatchExpiry(coin)), Number.MAX_SAFE_INTEGER);
|
|
6446
6551
|
if (!expiryTimestamp || expiryTimestamp === Number.MAX_SAFE_INTEGER) {
|
|
6447
6552
|
delegateAt = new Date(Date.now() + 1 * 60 * 1e3);
|
|
6448
6553
|
} else {
|
|
@@ -6471,7 +6576,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6471
6576
|
let amount = 0n;
|
|
6472
6577
|
for (const coin of vtxos) {
|
|
6473
6578
|
const inputFee = estimator.evalOffchainInput({
|
|
6474
|
-
...
|
|
6579
|
+
...chunkDSTYXT2D_cjs.toOffchainInputFeeParams(coin),
|
|
6475
6580
|
type: "vtxo"
|
|
6476
6581
|
});
|
|
6477
6582
|
if (inputFee.value >= coin.value) {
|
|
@@ -6485,7 +6590,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6485
6590
|
const delegateFee = BigInt(Number(fee));
|
|
6486
6591
|
if (delegateFee > 0n) {
|
|
6487
6592
|
outputs.push({
|
|
6488
|
-
script:
|
|
6593
|
+
script: chunkDSTYXT2D_cjs.ArkAddress.decode(delegateAddress).pkScript,
|
|
6489
6594
|
amount: delegateFee
|
|
6490
6595
|
});
|
|
6491
6596
|
}
|
|
@@ -6518,10 +6623,10 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6518
6623
|
destinationScript
|
|
6519
6624
|
);
|
|
6520
6625
|
const forfeitOutputScript = btcSigner.OutScript.encode(
|
|
6521
|
-
btcSigner.Address(
|
|
6626
|
+
btcSigner.Address(chunkDSTYXT2D_cjs.getNetwork(network)).decode(forfeitAddress)
|
|
6522
6627
|
);
|
|
6523
6628
|
const forfeits = await Promise.all(
|
|
6524
|
-
vtxos.filter((v) => !
|
|
6629
|
+
vtxos.filter((v) => !chunkDSTYXT2D_cjs.canRecoverOnchain(v, { timestamp: /* @__PURE__ */ new Date() })).map(async (coin) => {
|
|
6525
6630
|
const forfeit = await makeDelegateForfeitTx(
|
|
6526
6631
|
coin,
|
|
6527
6632
|
dust,
|
|
@@ -6546,7 +6651,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
|
|
|
6546
6651
|
index: input.vout,
|
|
6547
6652
|
witnessUtxo: {
|
|
6548
6653
|
amount: BigInt(input.value),
|
|
6549
|
-
script:
|
|
6654
|
+
script: chunkDSTYXT2D_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
6550
6655
|
},
|
|
6551
6656
|
sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
|
|
6552
6657
|
tapLeafScript: [delegateTapLeaf]
|
|
@@ -6604,7 +6709,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
6604
6709
|
expire_at: 0,
|
|
6605
6710
|
cosigners_public_keys: cosignerPubKeys
|
|
6606
6711
|
};
|
|
6607
|
-
const proof =
|
|
6712
|
+
const proof = chunkDSTYXT2D_cjs.Intent.create(message, coins, outputs);
|
|
6608
6713
|
const signedProof = await identity.sign(proof);
|
|
6609
6714
|
return {
|
|
6610
6715
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -6622,10 +6727,10 @@ function getDayTimestamp(timestamp) {
|
|
|
6622
6727
|
function findDelegateTapLeaf(vtxo, delegatePubkey) {
|
|
6623
6728
|
if (!vtxo.tapTree) return void 0;
|
|
6624
6729
|
const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
|
|
6625
|
-
const vtxoScript =
|
|
6730
|
+
const vtxoScript = chunkDSTYXT2D_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
6626
6731
|
return vtxoScript.leaves.find((tapLeaf) => {
|
|
6627
|
-
const arkTapscript =
|
|
6628
|
-
if (!
|
|
6732
|
+
const arkTapscript = chunkDSTYXT2D_cjs.decodeTapscript(chunkDSTYXT2D_cjs.scriptFromTapLeafScript(tapLeaf));
|
|
6733
|
+
if (!chunkDSTYXT2D_cjs.MultisigTapscript.is(arkTapscript)) return false;
|
|
6629
6734
|
return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
|
|
6630
6735
|
});
|
|
6631
6736
|
}
|
|
@@ -6813,7 +6918,7 @@ async function closeDatabase(dbName) {
|
|
|
6813
6918
|
return true;
|
|
6814
6919
|
}
|
|
6815
6920
|
function scriptFromArkAddress(address) {
|
|
6816
|
-
return base.hex.encode(
|
|
6921
|
+
return base.hex.encode(chunkDSTYXT2D_cjs.ArkAddress.decode(address).pkScript);
|
|
6817
6922
|
}
|
|
6818
6923
|
|
|
6819
6924
|
// src/repositories/indexedDB/schema.ts
|
|
@@ -7310,7 +7415,7 @@ function validateVtxosForScript(vtxos, script, context) {
|
|
|
7310
7415
|
}
|
|
7311
7416
|
async function getVtxosForContract(repo, contract) {
|
|
7312
7417
|
const vtxos = repo.getVtxosForScript ? await repo.getVtxosForScript(contract.script) : filterVtxosForScript(await repo.getVtxos(contract.address), contract.script);
|
|
7313
|
-
return vtxos.map(
|
|
7418
|
+
return vtxos.map(chunkDSTYXT2D_cjs.normalizeVtxo);
|
|
7314
7419
|
}
|
|
7315
7420
|
async function saveVtxosForContract(repo, contract, vtxos) {
|
|
7316
7421
|
if (repo.saveVtxosForScript) {
|
|
@@ -7514,7 +7619,7 @@ var deserializeTapLeaf = (t) => {
|
|
|
7514
7619
|
const s = base.hex.decode(t.s);
|
|
7515
7620
|
return [cb, s];
|
|
7516
7621
|
};
|
|
7517
|
-
var deserializeVtxo = (o) =>
|
|
7622
|
+
var deserializeVtxo = (o) => chunkDSTYXT2D_cjs.normalizeVtxo({
|
|
7518
7623
|
...o,
|
|
7519
7624
|
createdAt: new Date(o.createdAt),
|
|
7520
7625
|
tapTree: base.hex.decode(o.tapTree),
|
|
@@ -8653,7 +8758,7 @@ var ContractWatcher = class {
|
|
|
8653
8758
|
this.connectionState = "connected";
|
|
8654
8759
|
this.reconnectAttempts = 0;
|
|
8655
8760
|
this.listenLoop().catch((e) => {
|
|
8656
|
-
if (
|
|
8761
|
+
if (chunkDSTYXT2D_cjs.isEventSourceError(e)) {
|
|
8657
8762
|
console.debug("ContractWatcher subscription disconnected; reconnecting");
|
|
8658
8763
|
} else {
|
|
8659
8764
|
console.error(e);
|
|
@@ -8882,14 +8987,14 @@ var ContractWatcher = class {
|
|
|
8882
8987
|
const timestamp = Date.now();
|
|
8883
8988
|
if (update.newVtxos?.length) {
|
|
8884
8989
|
this.processSubscriptionVtxos(
|
|
8885
|
-
update.newVtxos.map(
|
|
8990
|
+
update.newVtxos.map(chunkDSTYXT2D_cjs.normalizeVtxo),
|
|
8886
8991
|
"vtxo_received",
|
|
8887
8992
|
timestamp
|
|
8888
8993
|
);
|
|
8889
8994
|
}
|
|
8890
8995
|
if (update.spentVtxos?.length) {
|
|
8891
8996
|
this.processSubscriptionVtxos(
|
|
8892
|
-
update.spentVtxos.map(
|
|
8997
|
+
update.spentVtxos.map(chunkDSTYXT2D_cjs.normalizeVtxo),
|
|
8893
8998
|
"vtxo_spent",
|
|
8894
8999
|
timestamp
|
|
8895
9000
|
);
|
|
@@ -9022,7 +9127,7 @@ async function reconcileIntents(deps) {
|
|
|
9022
9127
|
let vtxosByOutpoint = /* @__PURE__ */ new Map();
|
|
9023
9128
|
if (outpoints.length > 0) {
|
|
9024
9129
|
try {
|
|
9025
|
-
const { vtxos } = await
|
|
9130
|
+
const { vtxos } = await chunkDSTYXT2D_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
|
|
9026
9131
|
vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
|
|
9027
9132
|
} catch (e) {
|
|
9028
9133
|
console.error("reconcileIntents: failed to fetch input VTXO state", e);
|
|
@@ -9142,7 +9247,7 @@ var ContractManager = class _ContractManager {
|
|
|
9142
9247
|
await this.reconcileWatched();
|
|
9143
9248
|
this.markSyncOnline();
|
|
9144
9249
|
} catch (err) {
|
|
9145
|
-
if (!
|
|
9250
|
+
if (!chunkDSTYXT2D_cjs.isRetryableProviderError(err)) throw err;
|
|
9146
9251
|
this.markSyncDegraded(err);
|
|
9147
9252
|
}
|
|
9148
9253
|
this.initialized = true;
|
|
@@ -9254,7 +9359,7 @@ var ContractManager = class _ContractManager {
|
|
|
9254
9359
|
const from = Math.max(0, watermark - lookAhead.size);
|
|
9255
9360
|
const to = watermark + lookAhead.size;
|
|
9256
9361
|
const deps = lookAhead.candidateDeps();
|
|
9257
|
-
const handlers =
|
|
9362
|
+
const handlers = chunk2XO43UHI_cjs.contractHandlers.getRegisteredTypes().map((t) => chunk2XO43UHI_cjs.contractHandlers.get(t)).filter(hasCandidates);
|
|
9258
9363
|
const band = /* @__PURE__ */ new Map();
|
|
9259
9364
|
for (let index = from; index <= to; index++) {
|
|
9260
9365
|
const descriptor = lookAhead.materialize(index);
|
|
@@ -9265,7 +9370,7 @@ var ContractManager = class _ContractManager {
|
|
|
9265
9370
|
index,
|
|
9266
9371
|
params: {
|
|
9267
9372
|
...candidate,
|
|
9268
|
-
...
|
|
9373
|
+
...chunk2XO43UHI_cjs.speculativeReceiveMetadata(descriptor)
|
|
9269
9374
|
}
|
|
9270
9375
|
});
|
|
9271
9376
|
}
|
|
@@ -9325,7 +9430,7 @@ var ContractManager = class _ContractManager {
|
|
|
9325
9430
|
});
|
|
9326
9431
|
for (const entry of pending) entry.catchUpPending = false;
|
|
9327
9432
|
} catch (err) {
|
|
9328
|
-
if (!
|
|
9433
|
+
if (!chunkDSTYXT2D_cjs.isRetryableProviderError(err)) throw err;
|
|
9329
9434
|
this.markSyncDegraded(err);
|
|
9330
9435
|
}
|
|
9331
9436
|
}
|
|
@@ -9369,7 +9474,7 @@ var ContractManager = class _ContractManager {
|
|
|
9369
9474
|
await this.fetchContractVxosFromIndexer([contract]);
|
|
9370
9475
|
this.markSyncOnline();
|
|
9371
9476
|
} catch (err) {
|
|
9372
|
-
if (!
|
|
9477
|
+
if (!chunkDSTYXT2D_cjs.isRetryableProviderError(err)) throw err;
|
|
9373
9478
|
this.markSyncDegraded(err);
|
|
9374
9479
|
}
|
|
9375
9480
|
await this.watcher.addContract(contract);
|
|
@@ -9406,7 +9511,7 @@ var ContractManager = class _ContractManager {
|
|
|
9406
9511
|
return result;
|
|
9407
9512
|
}
|
|
9408
9513
|
async upsertContractRow(params) {
|
|
9409
|
-
const handler =
|
|
9514
|
+
const handler = chunk2XO43UHI_cjs.contractHandlers.get(params.type);
|
|
9410
9515
|
if (!handler) {
|
|
9411
9516
|
throw new Error(`No handler registered for contract type '${params.type}'`);
|
|
9412
9517
|
}
|
|
@@ -9506,7 +9611,7 @@ var ContractManager = class _ContractManager {
|
|
|
9506
9611
|
`scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
|
|
9507
9612
|
);
|
|
9508
9613
|
}
|
|
9509
|
-
const registered =
|
|
9614
|
+
const registered = chunk2XO43UHI_cjs.contractHandlers.getRegisteredTypes().map((t) => chunk2XO43UHI_cjs.contractHandlers.get(t)).filter(isDiscoverable);
|
|
9510
9615
|
const discoverables = [
|
|
9511
9616
|
...registered.filter((h) => h.type === "boarding"),
|
|
9512
9617
|
...registered.filter((h) => h.type !== "boarding")
|
|
@@ -9641,7 +9746,7 @@ var ContractManager = class _ContractManager {
|
|
|
9641
9746
|
await this.syncContracts({ contracts, pageSize });
|
|
9642
9747
|
this.markSyncOnline();
|
|
9643
9748
|
} catch (err) {
|
|
9644
|
-
if (!
|
|
9749
|
+
if (!chunkDSTYXT2D_cjs.isRetryableProviderError(err)) throw err;
|
|
9645
9750
|
this.markSyncDegraded(err);
|
|
9646
9751
|
}
|
|
9647
9752
|
const vtxos = await this.getVtxosForContracts(contracts);
|
|
@@ -9662,7 +9767,7 @@ var ContractManager = class _ContractManager {
|
|
|
9662
9767
|
}
|
|
9663
9768
|
const tapscriptCache = /* @__PURE__ */ new Map();
|
|
9664
9769
|
return vtxos.map(
|
|
9665
|
-
(vtxo) => extendVirtualCoinForContract(
|
|
9770
|
+
(vtxo) => extendVirtualCoinForContract(chunkDSTYXT2D_cjs.normalizeVtxo(vtxo), byScript, tapscriptCache)
|
|
9666
9771
|
);
|
|
9667
9772
|
}
|
|
9668
9773
|
buildContractsDbFilter(filter) {
|
|
@@ -9747,7 +9852,7 @@ var ContractManager = class _ContractManager {
|
|
|
9747
9852
|
const { contractScript, collaborative = true, walletPubKey, vtxo } = options;
|
|
9748
9853
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
9749
9854
|
if (!contract) return [];
|
|
9750
|
-
const handler =
|
|
9855
|
+
const handler = chunk2XO43UHI_cjs.contractHandlers.get(contract.type);
|
|
9751
9856
|
if (!handler) return [];
|
|
9752
9857
|
const script = handler.createScript(contract.params);
|
|
9753
9858
|
const context = {
|
|
@@ -9767,7 +9872,7 @@ var ContractManager = class _ContractManager {
|
|
|
9767
9872
|
const { contractScript, collaborative = true, walletPubKey } = options;
|
|
9768
9873
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
9769
9874
|
if (!contract) return [];
|
|
9770
|
-
const handler =
|
|
9875
|
+
const handler = chunk2XO43UHI_cjs.contractHandlers.get(contract.type);
|
|
9771
9876
|
if (!handler) return [];
|
|
9772
9877
|
const script = handler.createScript(contract.params);
|
|
9773
9878
|
const context = {
|
|
@@ -9823,7 +9928,7 @@ var ContractManager = class _ContractManager {
|
|
|
9823
9928
|
}
|
|
9824
9929
|
async refreshOutpoints(outpoints) {
|
|
9825
9930
|
if (outpoints.length === 0) return;
|
|
9826
|
-
const { vtxos } = await
|
|
9931
|
+
const { vtxos } = await chunkDSTYXT2D_cjs.getNormalizedVtxos(this.config.indexerProvider, {
|
|
9827
9932
|
outpoints
|
|
9828
9933
|
});
|
|
9829
9934
|
if (vtxos.length === 0) return;
|
|
@@ -9901,7 +10006,7 @@ var ContractManager = class _ContractManager {
|
|
|
9901
10006
|
break;
|
|
9902
10007
|
}
|
|
9903
10008
|
} catch (err) {
|
|
9904
|
-
if (!
|
|
10009
|
+
if (!chunkDSTYXT2D_cjs.isRetryableProviderError(err)) throw err;
|
|
9905
10010
|
this.markSyncDegraded(err);
|
|
9906
10011
|
}
|
|
9907
10012
|
this.emitEvent(event);
|
|
@@ -9950,7 +10055,7 @@ var ContractManager = class _ContractManager {
|
|
|
9950
10055
|
*/
|
|
9951
10056
|
async reconcilePendingFrontier(contracts) {
|
|
9952
10057
|
const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
|
|
9953
|
-
const vtxos = await
|
|
10058
|
+
const vtxos = await chunkDSTYXT2D_cjs.getAllNormalizedVtxos(
|
|
9954
10059
|
this.config.indexerProvider,
|
|
9955
10060
|
contracts.map((c) => c.script),
|
|
9956
10061
|
{ pendingOnly: true }
|
|
@@ -10031,7 +10136,7 @@ var ContractManager = class _ContractManager {
|
|
|
10031
10136
|
}
|
|
10032
10137
|
return result;
|
|
10033
10138
|
}
|
|
10034
|
-
async fetchContractVtxosBulk(contracts, pageSize =
|
|
10139
|
+
async fetchContractVtxosBulk(contracts, pageSize = chunkDSTYXT2D_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
|
|
10035
10140
|
if (contracts.length === 0) {
|
|
10036
10141
|
return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
|
|
10037
10142
|
}
|
|
@@ -10047,7 +10152,7 @@ var ContractManager = class _ContractManager {
|
|
|
10047
10152
|
before: syncWindow.before
|
|
10048
10153
|
}
|
|
10049
10154
|
} : {};
|
|
10050
|
-
const vtxos = await
|
|
10155
|
+
const vtxos = await chunkDSTYXT2D_cjs.getAllNormalizedVtxos(
|
|
10051
10156
|
this.config.indexerProvider,
|
|
10052
10157
|
contracts.map((c) => c.script),
|
|
10053
10158
|
{ ...windowOpts, pageSize }
|
|
@@ -10214,7 +10319,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
10214
10319
|
*/
|
|
10215
10320
|
materializeDescriptorAt(index) {
|
|
10216
10321
|
const descriptor = this.identity.descriptor;
|
|
10217
|
-
const network =
|
|
10322
|
+
const network = chunk2XO43UHI_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
10218
10323
|
const expansion = descriptorsScure.expand({ descriptor, network, index });
|
|
10219
10324
|
const keyInfo = expansion.expansionMap?.["@0"];
|
|
10220
10325
|
if (!keyInfo?.keyExpression) {
|
|
@@ -10358,7 +10463,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
10358
10463
|
const provider = await resolveDescriptorProvider(config, setup.walletRepository);
|
|
10359
10464
|
if (!provider) return void 0;
|
|
10360
10465
|
const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
|
|
10361
|
-
const expectedContractType = setup.offchainTapscript instanceof
|
|
10466
|
+
const expectedContractType = setup.offchainTapscript instanceof chunk2XO43UHI_cjs.DelegateVtxo.Script ? "delegate" : "default";
|
|
10362
10467
|
const factoryOpts = {
|
|
10363
10468
|
walletRepository: setup.walletRepository,
|
|
10364
10469
|
contractRepository: setup.contractRepository,
|
|
@@ -10557,7 +10662,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
10557
10662
|
};
|
|
10558
10663
|
function deriveLeafPubkey(descriptor) {
|
|
10559
10664
|
try {
|
|
10560
|
-
return
|
|
10665
|
+
return chunk2XO43UHI_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
10561
10666
|
} catch (e) {
|
|
10562
10667
|
throw new NonRangeableDescriptorError(
|
|
10563
10668
|
"Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
|
|
@@ -10569,7 +10674,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
10569
10674
|
const pubKey = deriveLeafPubkey(descriptor);
|
|
10570
10675
|
const tapscript = rebuildTapscript(current, pubKey);
|
|
10571
10676
|
const serverPubKey = tapscript.options.serverPubKey;
|
|
10572
|
-
const csvTimelock =
|
|
10677
|
+
const csvTimelock = chunkDSTYXT2D_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
|
|
10573
10678
|
const base$1 = {
|
|
10574
10679
|
script: base.hex.encode(tapscript.pkScript),
|
|
10575
10680
|
address: tapscript.address(hrp, serverPubKey).encode(),
|
|
@@ -10580,11 +10685,11 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
10580
10685
|
// index-0 key. Without it, spends produce unsigned PSBTs that the
|
|
10581
10686
|
// server rejects with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
10582
10687
|
metadata: {
|
|
10583
|
-
...{ source:
|
|
10688
|
+
...{ source: chunk2XO43UHI_cjs.WALLET_RECEIVE_SOURCE },
|
|
10584
10689
|
signingDescriptor: descriptor
|
|
10585
10690
|
}
|
|
10586
10691
|
};
|
|
10587
|
-
const params = tapscript instanceof
|
|
10692
|
+
const params = tapscript instanceof chunk2XO43UHI_cjs.DelegateVtxo.Script ? {
|
|
10588
10693
|
...base$1,
|
|
10589
10694
|
type: "delegate",
|
|
10590
10695
|
params: {
|
|
@@ -10605,10 +10710,10 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
10605
10710
|
return { tapscript, params };
|
|
10606
10711
|
}
|
|
10607
10712
|
function rebuildTapscript(current, pubKey) {
|
|
10608
|
-
if (current instanceof
|
|
10609
|
-
return new
|
|
10713
|
+
if (current instanceof chunk2XO43UHI_cjs.DelegateVtxo.Script) {
|
|
10714
|
+
return new chunk2XO43UHI_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
|
|
10610
10715
|
}
|
|
10611
|
-
return new
|
|
10716
|
+
return new chunk2XO43UHI_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
|
|
10612
10717
|
}
|
|
10613
10718
|
async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
|
|
10614
10719
|
const candidates = await contractRepository.getContracts({
|
|
@@ -10617,7 +10722,7 @@ async function pickActiveReceive(contractRepository, serverPubKey, expectedType)
|
|
|
10617
10722
|
});
|
|
10618
10723
|
const serverPubKeyHex = base.hex.encode(serverPubKey);
|
|
10619
10724
|
const matching = candidates.filter(
|
|
10620
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
10725
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunk2XO43UHI_cjs.WALLET_RECEIVE_SOURCE
|
|
10621
10726
|
).sort((a, b) => {
|
|
10622
10727
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
10623
10728
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -10793,12 +10898,12 @@ var InputSignerRouter = class {
|
|
|
10793
10898
|
};
|
|
10794
10899
|
|
|
10795
10900
|
// src/wallet/wallet.ts
|
|
10796
|
-
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl ||
|
|
10901
|
+
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl || chunkDSTYXT2D_cjs.DEFAULT_ARKADE_SERVER_URL;
|
|
10797
10902
|
function intentProofJobs(coins) {
|
|
10798
10903
|
if (coins.length === 0) return [];
|
|
10799
10904
|
const coinJobs = coins.map((coin, i) => ({
|
|
10800
10905
|
index: i + 1,
|
|
10801
|
-
lookupScript:
|
|
10906
|
+
lookupScript: chunkDSTYXT2D_cjs.VtxoScript.decode(coin.tapTree).pkScript
|
|
10802
10907
|
}));
|
|
10803
10908
|
return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
|
|
10804
10909
|
}
|
|
@@ -10823,7 +10928,7 @@ function dedupeTimelocks(timelocks) {
|
|
|
10823
10928
|
const seen = /* @__PURE__ */ new Set();
|
|
10824
10929
|
const deduped = [];
|
|
10825
10930
|
for (const timelock of timelocks) {
|
|
10826
|
-
const sequence =
|
|
10931
|
+
const sequence = chunkDSTYXT2D_cjs.timelockToSequence(timelock).toString();
|
|
10827
10932
|
if (seen.has(sequence)) continue;
|
|
10828
10933
|
seen.add(sequence);
|
|
10829
10934
|
deduped.push(timelock);
|
|
@@ -10840,7 +10945,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
10840
10945
|
state: "active"
|
|
10841
10946
|
});
|
|
10842
10947
|
const newest = candidates.filter(
|
|
10843
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
10948
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunk2XO43UHI_cjs.WALLET_RECEIVE_SOURCE
|
|
10844
10949
|
).sort((a, b) => {
|
|
10845
10950
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
10846
10951
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -10848,7 +10953,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
10848
10953
|
if (!newest?.params.pubKey) return baseline;
|
|
10849
10954
|
try {
|
|
10850
10955
|
const pubKey = base.hex.decode(newest.params.pubKey);
|
|
10851
|
-
return new
|
|
10956
|
+
return new chunk2XO43UHI_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
|
|
10852
10957
|
} catch (e) {
|
|
10853
10958
|
console.warn("Skipping malformed boarding contract at boot", newest.script, e);
|
|
10854
10959
|
return baseline;
|
|
@@ -11182,7 +11287,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11182
11287
|
*/
|
|
11183
11288
|
static async setupWalletConfig(config, pubKey) {
|
|
11184
11289
|
const arkadeServerUrl = getArkadeServerUrl(config);
|
|
11185
|
-
const arkProvider = config.arkProvider || new
|
|
11290
|
+
const arkProvider = config.arkProvider || new chunkDSTYXT2D_cjs.RestArkProvider(arkadeServerUrl);
|
|
11186
11291
|
let indexerProvider = config.indexerProvider;
|
|
11187
11292
|
if (!indexerProvider) {
|
|
11188
11293
|
let indexerUrl = config.indexerUrl;
|
|
@@ -11199,7 +11304,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11199
11304
|
indexerUrl = arkadeServerUrl;
|
|
11200
11305
|
}
|
|
11201
11306
|
}
|
|
11202
|
-
indexerProvider = new
|
|
11307
|
+
indexerProvider = new chunkV2KENVN6_cjs.RestIndexerProvider(indexerUrl);
|
|
11203
11308
|
}
|
|
11204
11309
|
const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
11205
11310
|
const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
@@ -11208,7 +11313,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11208
11313
|
source: serverInfoSource,
|
|
11209
11314
|
lastOnlineAt: serverInfoLastOnlineAt
|
|
11210
11315
|
} = await resolveArkInfo(arkProvider, walletRepository);
|
|
11211
|
-
const network =
|
|
11316
|
+
const network = chunkDSTYXT2D_cjs.getNetwork(info.network);
|
|
11212
11317
|
if ("descriptor" in config.identity) {
|
|
11213
11318
|
const descriptor = config.identity.descriptor;
|
|
11214
11319
|
const identityIsMainnet = !descriptor.includes("tpub");
|
|
@@ -11255,11 +11360,11 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11255
11360
|
serverPubKey,
|
|
11256
11361
|
csvTimelock: exitTimelock
|
|
11257
11362
|
};
|
|
11258
|
-
const offchainTapscript = !delegatePubKey ? new
|
|
11259
|
-
const boardingTapscript =
|
|
11363
|
+
const offchainTapscript = !delegatePubKey ? new chunk2XO43UHI_cjs.DefaultVtxo.Script(offchainOptions) : new chunk2XO43UHI_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
|
|
11364
|
+
const boardingTapscript = chunk2XO43UHI_cjs.BoardingContractHandler.createScript({
|
|
11260
11365
|
pubKey: base.hex.encode(pubKey),
|
|
11261
11366
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
11262
|
-
csvTimelock:
|
|
11367
|
+
csvTimelock: chunkDSTYXT2D_cjs.timelockToSequence(boardingTimelock).toString()
|
|
11263
11368
|
});
|
|
11264
11369
|
return {
|
|
11265
11370
|
arkProvider,
|
|
@@ -11365,19 +11470,19 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11365
11470
|
let pendingRecovery = 0;
|
|
11366
11471
|
const now = { timestamp: /* @__PURE__ */ new Date() };
|
|
11367
11472
|
const settled = vtxos.filter(
|
|
11368
|
-
(coin) =>
|
|
11473
|
+
(coin) => chunkDSTYXT2D_cjs.canSpendOffchain(coin, now) && !coin.isPreconfirmed && !isPendingRecovery(coin)
|
|
11369
11474
|
).reduce((sum, coin) => sum + coin.value, 0);
|
|
11370
11475
|
const preconfirmed = vtxos.filter(
|
|
11371
|
-
(coin) =>
|
|
11476
|
+
(coin) => chunkDSTYXT2D_cjs.canSpendOffchain(coin, now) && coin.isPreconfirmed && !isPendingRecovery(coin)
|
|
11372
11477
|
).reduce((sum, coin) => sum + coin.value, 0);
|
|
11373
|
-
const available = unlockedVtxos.filter((coin) =>
|
|
11374
|
-
recoverable = vtxos.filter((coin) =>
|
|
11478
|
+
const available = unlockedVtxos.filter((coin) => chunkDSTYXT2D_cjs.canSpendOffchain(coin, now) && !isPendingRecovery(coin)).reduce((sum, coin) => sum + coin.value, 0);
|
|
11479
|
+
recoverable = vtxos.filter((coin) => chunkDSTYXT2D_cjs.canRecoverOnchain(coin, now) && !isPendingRecovery(coin)).reduce((sum, coin) => sum + coin.value, 0);
|
|
11375
11480
|
pendingRecovery = vtxos.filter(isPendingRecovery).reduce((sum, coin) => sum + coin.value, 0);
|
|
11376
11481
|
const totalBoarding = confirmed + unconfirmed;
|
|
11377
11482
|
const totalOffchain = settled + preconfirmed + recoverable + pendingRecovery;
|
|
11378
11483
|
const assetBalances = /* @__PURE__ */ new Map();
|
|
11379
11484
|
for (const vtxo of vtxos) {
|
|
11380
|
-
if (
|
|
11485
|
+
if (chunkDSTYXT2D_cjs.hasTerminalSpend(vtxo)) continue;
|
|
11381
11486
|
if (vtxo.assets) {
|
|
11382
11487
|
for (const a of vtxo.assets) {
|
|
11383
11488
|
const current = assetBalances.get(a.assetId) ?? 0n;
|
|
@@ -11418,8 +11523,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11418
11523
|
if (this._pendingSpendOutpoints.has(`${vtxo.txid}:${vtxo.vout}`)) {
|
|
11419
11524
|
return false;
|
|
11420
11525
|
}
|
|
11421
|
-
if (!
|
|
11422
|
-
if (!f.withRecoverable &&
|
|
11526
|
+
if (!chunkDSTYXT2D_cjs.hasTerminalSpend(vtxo)) {
|
|
11527
|
+
if (!f.withRecoverable && chunkDSTYXT2D_cjs.canRecoverOnchain(vtxo, now)) {
|
|
11423
11528
|
return false;
|
|
11424
11529
|
}
|
|
11425
11530
|
return true;
|
|
@@ -11452,7 +11557,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11452
11557
|
const response = await contractManager.getContractsWithVtxos();
|
|
11453
11558
|
const allVtxos = response.flatMap((_) => _.vtxos);
|
|
11454
11559
|
const { boardingTxs, commitmentsToIgnore } = await this.getBoardingTxs();
|
|
11455
|
-
const resolveTxCreatedAt = (txids) =>
|
|
11560
|
+
const resolveTxCreatedAt = (txids) => chunkDSTYXT2D_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
|
|
11456
11561
|
return buildTransactionHistory(
|
|
11457
11562
|
allVtxos,
|
|
11458
11563
|
boardingTxs,
|
|
@@ -11546,7 +11651,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11546
11651
|
},
|
|
11547
11652
|
isUnrolled: true,
|
|
11548
11653
|
...boardingFacts,
|
|
11549
|
-
virtualStatus:
|
|
11654
|
+
virtualStatus: chunkDSTYXT2D_cjs.toVirtualStatus(boardingFacts),
|
|
11550
11655
|
spentBy: "",
|
|
11551
11656
|
createdAt: tx.status.confirmed ? new Date(tx.status.block_time * 1e3) : /* @__PURE__ */ new Date(0),
|
|
11552
11657
|
script: scriptHex
|
|
@@ -11602,9 +11707,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11602
11707
|
async getBoardingTapscripts(allowedSigners) {
|
|
11603
11708
|
const byScript = /* @__PURE__ */ new Map();
|
|
11604
11709
|
const add = (s) => byScript.set(base.hex.encode(s.pkScript), s);
|
|
11605
|
-
const boardingCsv = this.boardingTapscript.options.csvTimelock ??
|
|
11710
|
+
const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunk2XO43UHI_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
11606
11711
|
add(
|
|
11607
|
-
new
|
|
11712
|
+
new chunk2XO43UHI_cjs.DefaultVtxo.Script({
|
|
11608
11713
|
pubKey: await this.identity.xOnlyPublicKey(),
|
|
11609
11714
|
serverPubKey: this.boardingTapscript.options.serverPubKey,
|
|
11610
11715
|
csvTimelock: boardingCsv
|
|
@@ -11619,7 +11724,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11619
11724
|
for (const c of boardingContracts) {
|
|
11620
11725
|
if (!allowed.has(toXOnlySignerHex(c.params.serverPubKey))) continue;
|
|
11621
11726
|
try {
|
|
11622
|
-
add(
|
|
11727
|
+
add(chunk2XO43UHI_cjs.BoardingContractHandler.createScript(c.params));
|
|
11623
11728
|
} catch (e) {
|
|
11624
11729
|
console.warn("Skipping malformed boarding contract", c.script, e);
|
|
11625
11730
|
}
|
|
@@ -11657,7 +11762,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11657
11762
|
// Per-row CSV delay decoded from THIS tapscript's exit leaf —
|
|
11658
11763
|
// not the wallet's current boarding timelock, which a signer
|
|
11659
11764
|
// rotation may have changed.
|
|
11660
|
-
csvTimelock:
|
|
11765
|
+
csvTimelock: chunkDSTYXT2D_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
|
|
11661
11766
|
coins: utxos
|
|
11662
11767
|
});
|
|
11663
11768
|
}
|
|
@@ -11790,7 +11895,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11790
11895
|
/** Fetch Arkade transaction ids that are still pending final settlement. */
|
|
11791
11896
|
async fetchPendingTxs() {
|
|
11792
11897
|
const scripts = await this.getWalletScripts();
|
|
11793
|
-
const vtxos = await
|
|
11898
|
+
const vtxos = await chunkDSTYXT2D_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
|
|
11794
11899
|
return vtxos.filter(
|
|
11795
11900
|
(vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
|
|
11796
11901
|
).map((_) => _.arkTxId);
|
|
@@ -11821,7 +11926,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11821
11926
|
});
|
|
11822
11927
|
for (const contract of contracts) {
|
|
11823
11928
|
if (map.has(contract.script)) continue;
|
|
11824
|
-
const handler =
|
|
11929
|
+
const handler = chunk2XO43UHI_cjs.contractHandlers.get(contract.type);
|
|
11825
11930
|
if (handler) {
|
|
11826
11931
|
const script = handler.createScript(contract.params);
|
|
11827
11932
|
map.set(contract.script, script);
|
|
@@ -11924,7 +12029,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11924
12029
|
lookAhead: this.lookAheadConfig()
|
|
11925
12030
|
});
|
|
11926
12031
|
const baselinePubkey = await this.identity.xOnlyPublicKey();
|
|
11927
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
12032
|
+
const delegatePubKey = this.offchainTapscript instanceof chunk2XO43UHI_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
11928
12033
|
const baselineSigners = [
|
|
11929
12034
|
this.offchainTapscript.options.serverPubKey,
|
|
11930
12035
|
...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
|
|
@@ -11932,8 +12037,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11932
12037
|
const seenBaselineScripts = /* @__PURE__ */ new Set();
|
|
11933
12038
|
for (const serverPubKey of baselineSigners) {
|
|
11934
12039
|
for (const csvTimelock of this.walletContractTimelocks) {
|
|
11935
|
-
const csvTimelockStr =
|
|
11936
|
-
const defaultScript = new
|
|
12040
|
+
const csvTimelockStr = chunkDSTYXT2D_cjs.timelockToSequence(csvTimelock).toString();
|
|
12041
|
+
const defaultScript = new chunk2XO43UHI_cjs.DefaultVtxo.Script({
|
|
11937
12042
|
pubKey: baselinePubkey,
|
|
11938
12043
|
serverPubKey,
|
|
11939
12044
|
csvTimelock
|
|
@@ -11954,7 +12059,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11954
12059
|
});
|
|
11955
12060
|
}
|
|
11956
12061
|
if (delegatePubKey) {
|
|
11957
|
-
const delegateScript = new
|
|
12062
|
+
const delegateScript = new chunk2XO43UHI_cjs.DelegateVtxo.Script({
|
|
11958
12063
|
pubKey: baselinePubkey,
|
|
11959
12064
|
serverPubKey,
|
|
11960
12065
|
delegatePubKey,
|
|
@@ -11978,9 +12083,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11978
12083
|
}
|
|
11979
12084
|
}
|
|
11980
12085
|
}
|
|
11981
|
-
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ??
|
|
12086
|
+
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunk2XO43UHI_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
11982
12087
|
for (const serverPubKey of baselineSigners) {
|
|
11983
|
-
const baselineBoarding = new
|
|
12088
|
+
const baselineBoarding = new chunk2XO43UHI_cjs.DefaultVtxo.Script({
|
|
11984
12089
|
pubKey: baselinePubkey,
|
|
11985
12090
|
serverPubKey,
|
|
11986
12091
|
csvTimelock: boardingCsvTimelock
|
|
@@ -11993,7 +12098,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11993
12098
|
params: {
|
|
11994
12099
|
pubKey: base.hex.encode(baselineBoarding.options.pubKey),
|
|
11995
12100
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
11996
|
-
csvTimelock:
|
|
12101
|
+
csvTimelock: chunkDSTYXT2D_cjs.timelockToSequence(boardingCsvTimelock).toString()
|
|
11997
12102
|
},
|
|
11998
12103
|
script: boardingScriptHex,
|
|
11999
12104
|
address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
|
|
@@ -12171,7 +12276,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12171
12276
|
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
12172
12277
|
deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
|
|
12173
12278
|
csvTimelocks: this.walletContractTimelocks,
|
|
12174
|
-
delegatePubKey: this.offchainTapscript instanceof
|
|
12279
|
+
delegatePubKey: this.offchainTapscript instanceof chunk2XO43UHI_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
|
|
12175
12280
|
};
|
|
12176
12281
|
}
|
|
12177
12282
|
_signerRouter;
|
|
@@ -12263,25 +12368,25 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12263
12368
|
return this.getBoardingAddress();
|
|
12264
12369
|
}
|
|
12265
12370
|
const descriptor = await provider.getNextSigningDescriptor();
|
|
12266
|
-
const pubKey =
|
|
12267
|
-
const newBoarding = new
|
|
12371
|
+
const pubKey = chunk2XO43UHI_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
12372
|
+
const newBoarding = new chunk2XO43UHI_cjs.DefaultVtxo.Script({
|
|
12268
12373
|
...this._boardingTapscript.options,
|
|
12269
12374
|
pubKey
|
|
12270
12375
|
});
|
|
12271
|
-
const csvTimelock = newBoarding.options.csvTimelock ??
|
|
12376
|
+
const csvTimelock = newBoarding.options.csvTimelock ?? chunk2XO43UHI_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
12272
12377
|
const manager = await this.getContractManager();
|
|
12273
12378
|
await manager.createContract({
|
|
12274
12379
|
type: "boarding",
|
|
12275
12380
|
params: {
|
|
12276
12381
|
pubKey: base.hex.encode(pubKey),
|
|
12277
12382
|
serverPubKey: base.hex.encode(newBoarding.options.serverPubKey),
|
|
12278
|
-
csvTimelock:
|
|
12383
|
+
csvTimelock: chunkDSTYXT2D_cjs.timelockToSequence(csvTimelock).toString()
|
|
12279
12384
|
},
|
|
12280
12385
|
script: base.hex.encode(newBoarding.pkScript),
|
|
12281
12386
|
address: newBoarding.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
12282
12387
|
state: "active",
|
|
12283
12388
|
metadata: {
|
|
12284
|
-
source:
|
|
12389
|
+
source: chunk2XO43UHI_cjs.WALLET_RECEIVE_SOURCE,
|
|
12285
12390
|
signingDescriptor: descriptor
|
|
12286
12391
|
}
|
|
12287
12392
|
});
|
|
@@ -12396,21 +12501,21 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12396
12501
|
const [currentBoardingRow] = await manager.getContracts({
|
|
12397
12502
|
script: currentBoardingScript
|
|
12398
12503
|
});
|
|
12399
|
-
const newOffchain = this.offchainTapscript instanceof
|
|
12504
|
+
const newOffchain = this.offchainTapscript instanceof chunk2XO43UHI_cjs.DelegateVtxo.Script ? new chunk2XO43UHI_cjs.DelegateVtxo.Script({
|
|
12400
12505
|
...this.offchainTapscript.options,
|
|
12401
12506
|
serverPubKey: xonly
|
|
12402
|
-
}) : new
|
|
12507
|
+
}) : new chunk2XO43UHI_cjs.DefaultVtxo.Script({
|
|
12403
12508
|
...this.offchainTapscript.options,
|
|
12404
12509
|
serverPubKey: xonly
|
|
12405
12510
|
});
|
|
12406
|
-
const newBoarding = new
|
|
12511
|
+
const newBoarding = new chunk2XO43UHI_cjs.DefaultVtxo.Script({
|
|
12407
12512
|
...this._boardingTapscript.options,
|
|
12408
12513
|
serverPubKey: xonly
|
|
12409
12514
|
});
|
|
12410
|
-
const offchainCsv =
|
|
12515
|
+
const offchainCsv = chunkDSTYXT2D_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
|
|
12411
12516
|
const newOffchainScript = base.hex.encode(newOffchain.pkScript);
|
|
12412
12517
|
const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
|
|
12413
|
-
if (newOffchain instanceof
|
|
12518
|
+
if (newOffchain instanceof chunk2XO43UHI_cjs.DelegateVtxo.Script) {
|
|
12414
12519
|
await manager.createContract({
|
|
12415
12520
|
type: "delegate",
|
|
12416
12521
|
params: {
|
|
@@ -12438,13 +12543,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12438
12543
|
metadata: currentOffchainRow?.metadata
|
|
12439
12544
|
});
|
|
12440
12545
|
}
|
|
12441
|
-
const boardingCsv = newBoarding.options.csvTimelock ??
|
|
12546
|
+
const boardingCsv = newBoarding.options.csvTimelock ?? chunk2XO43UHI_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
12442
12547
|
await manager.createContract({
|
|
12443
12548
|
type: "boarding",
|
|
12444
12549
|
params: {
|
|
12445
12550
|
pubKey: base.hex.encode(newBoarding.options.pubKey),
|
|
12446
12551
|
serverPubKey: base.hex.encode(xonly),
|
|
12447
|
-
csvTimelock:
|
|
12552
|
+
csvTimelock: chunkDSTYXT2D_cjs.timelockToSequence(boardingCsv).toString()
|
|
12448
12553
|
},
|
|
12449
12554
|
script: base.hex.encode(newBoarding.pkScript),
|
|
12450
12555
|
address: newBoarding.address(this.network.hrp, xonly).encode(),
|
|
@@ -12477,14 +12582,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12477
12582
|
_restoreInFlight;
|
|
12478
12583
|
_addPendingSpends(inputs) {
|
|
12479
12584
|
for (const input of inputs) {
|
|
12480
|
-
if (
|
|
12585
|
+
if (chunkDSTYXT2D_cjs.isVirtualCoin(input)) {
|
|
12481
12586
|
this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
|
|
12482
12587
|
}
|
|
12483
12588
|
}
|
|
12484
12589
|
}
|
|
12485
12590
|
_removePendingSpends(inputs) {
|
|
12486
12591
|
for (const input of inputs) {
|
|
12487
|
-
if (
|
|
12592
|
+
if (chunkDSTYXT2D_cjs.isVirtualCoin(input)) {
|
|
12488
12593
|
this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
|
|
12489
12594
|
}
|
|
12490
12595
|
}
|
|
@@ -12544,7 +12649,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12544
12649
|
const hd = provider instanceof HDDescriptorProvider;
|
|
12545
12650
|
const staticDescriptor = hd ? void 0 : `tr(${base.hex.encode(await this.identity.xOnlyPublicKey())})`;
|
|
12546
12651
|
const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
|
|
12547
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
12652
|
+
const delegatePubKey = this.offchainTapscript instanceof chunk2XO43UHI_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
12548
12653
|
const arkInfo = await this.arkProvider.getInfo();
|
|
12549
12654
|
const currentSignerPubKey = toXOnlyPubKey(base.hex.decode(arkInfo.signerPubkey));
|
|
12550
12655
|
const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
|
|
@@ -12563,7 +12668,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12563
12668
|
csvTimelocks: this.walletContractTimelocks,
|
|
12564
12669
|
// Boarding-exit CSV so the boarding handler can build its
|
|
12565
12670
|
// candidate script (distinct from the unilateral-exit matrix).
|
|
12566
|
-
boardingTimelock: this.boardingTapscript.options.csvTimelock ??
|
|
12671
|
+
boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunk2XO43UHI_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
|
|
12567
12672
|
delegatePubKey
|
|
12568
12673
|
};
|
|
12569
12674
|
const result = await manager.scanContracts({
|
|
@@ -12825,7 +12930,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12825
12930
|
inputs: params.selectedVtxos,
|
|
12826
12931
|
changeAmount: BigInt(changeAmount)
|
|
12827
12932
|
};
|
|
12828
|
-
const outputAddress =
|
|
12933
|
+
const outputAddress = chunkDSTYXT2D_cjs.ArkAddress.decode(params.address);
|
|
12829
12934
|
assertRecipientArkAddress(
|
|
12830
12935
|
params.address,
|
|
12831
12936
|
outputAddress,
|
|
@@ -12883,13 +12988,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12883
12988
|
}
|
|
12884
12989
|
}
|
|
12885
12990
|
const offchainAddress = await this.getAddress();
|
|
12886
|
-
const offchainPkScript =
|
|
12991
|
+
const offchainPkScript = chunkDSTYXT2D_cjs.ArkAddress.decode(offchainAddress).pkScript;
|
|
12887
12992
|
const offchainOutputScript = base.hex.encode(offchainPkScript);
|
|
12888
12993
|
if (!params) {
|
|
12889
12994
|
const { fees, vtxoMaxAmount } = await this.arkProvider.getInfo();
|
|
12890
12995
|
const estimator = new Estimator(fees.intentFee);
|
|
12891
12996
|
let amount = 0;
|
|
12892
|
-
const exitScript =
|
|
12997
|
+
const exitScript = chunkDSTYXT2D_cjs.CSVMultisigTapscript.decode(
|
|
12893
12998
|
base.hex.decode(this.boardingTapscript.exitScript)
|
|
12894
12999
|
);
|
|
12895
13000
|
const boardingTimelock = exitScript.params.timelock;
|
|
@@ -12918,7 +13023,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12918
13023
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
12919
13024
|
break;
|
|
12920
13025
|
}
|
|
12921
|
-
const inputFee = estimator.evalOffchainInput(
|
|
13026
|
+
const inputFee = estimator.evalOffchainInput(chunkDSTYXT2D_cjs.toOffchainInputFeeParams(vtxo));
|
|
12922
13027
|
if (inputFee.satoshis >= vtxo.value) {
|
|
12923
13028
|
continue;
|
|
12924
13029
|
}
|
|
@@ -12965,7 +13070,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12965
13070
|
let script;
|
|
12966
13071
|
let arkAddress;
|
|
12967
13072
|
try {
|
|
12968
|
-
arkAddress =
|
|
13073
|
+
arkAddress = chunkDSTYXT2D_cjs.ArkAddress.decode(output.address);
|
|
12969
13074
|
} catch {
|
|
12970
13075
|
arkAddress = void 0;
|
|
12971
13076
|
}
|
|
@@ -13157,7 +13262,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13157
13262
|
async maybeRotateBoardingAfterBoard(inputs) {
|
|
13158
13263
|
if (!this._descriptorProvider) return;
|
|
13159
13264
|
const consumedBoarding = inputs.some(
|
|
13160
|
-
(input) => typeof input !== "string" && !
|
|
13265
|
+
(input) => typeof input !== "string" && !chunkDSTYXT2D_cjs.isVirtualCoin(input)
|
|
13161
13266
|
);
|
|
13162
13267
|
if (!consumedBoarding) return;
|
|
13163
13268
|
try {
|
|
@@ -13181,7 +13286,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13181
13286
|
let connectorIndex = 0;
|
|
13182
13287
|
const connectorsLeaves = connectorsGraph?.leaves() || [];
|
|
13183
13288
|
for (const input of inputs) {
|
|
13184
|
-
if (!
|
|
13289
|
+
if (!chunkDSTYXT2D_cjs.isVirtualCoin(input)) {
|
|
13185
13290
|
for (let i = 0; i < settlementPsbt.inputsLength; i++) {
|
|
13186
13291
|
const settlementInput = settlementPsbt.getInput(i);
|
|
13187
13292
|
if (!settlementInput.txid || settlementInput.index === void 0) {
|
|
@@ -13212,7 +13317,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13212
13317
|
}
|
|
13213
13318
|
continue;
|
|
13214
13319
|
}
|
|
13215
|
-
if (
|
|
13320
|
+
if (chunkDSTYXT2D_cjs.canRecoverOnchain(input, { timestamp: /* @__PURE__ */ new Date() }) || isSubdust({ value: input.value }, this.dustAmount)) {
|
|
13216
13321
|
continue;
|
|
13217
13322
|
}
|
|
13218
13323
|
if (connectorsLeaves.length === 0) {
|
|
@@ -13240,7 +13345,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13240
13345
|
index: input.vout,
|
|
13241
13346
|
witnessUtxo: {
|
|
13242
13347
|
amount: BigInt(input.value),
|
|
13243
|
-
script:
|
|
13348
|
+
script: chunkDSTYXT2D_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
13244
13349
|
},
|
|
13245
13350
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
13246
13351
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -13259,7 +13364,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13259
13364
|
forfeitTx = await this._signerRouter.sign(forfeitTx, [
|
|
13260
13365
|
{
|
|
13261
13366
|
index: 0,
|
|
13262
|
-
lookupScript:
|
|
13367
|
+
lookupScript: chunkDSTYXT2D_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
13263
13368
|
}
|
|
13264
13369
|
]);
|
|
13265
13370
|
signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
|
|
@@ -13317,7 +13422,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13317
13422
|
resolveBatchExpiryPolicy(this.network, this.batchExpiryPolicy)
|
|
13318
13423
|
);
|
|
13319
13424
|
await this.arkProvider.confirmRegistration(intentId);
|
|
13320
|
-
const sweepTapscript =
|
|
13425
|
+
const sweepTapscript = chunkDSTYXT2D_cjs.CSVMultisigTapscript.encode({
|
|
13321
13426
|
timelock,
|
|
13322
13427
|
pubkeys: [this.forfeitPubkey]
|
|
13323
13428
|
}).script;
|
|
@@ -13423,9 +13528,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13423
13528
|
...existing ?? {},
|
|
13424
13529
|
intentTxId,
|
|
13425
13530
|
registerProof: intent.proof,
|
|
13426
|
-
registerProofMessage:
|
|
13531
|
+
registerProofMessage: chunkDSTYXT2D_cjs.Intent.encodeMessage(intent.message),
|
|
13427
13532
|
deleteProof: deleteIntent.proof,
|
|
13428
|
-
deleteProofMessage:
|
|
13533
|
+
deleteProofMessage: chunkDSTYXT2D_cjs.Intent.encodeMessage(deleteIntent.message),
|
|
13429
13534
|
intentVtxos: inputs.map((i) => ({
|
|
13430
13535
|
txid: i.txid,
|
|
13431
13536
|
vout: i.vout
|
|
@@ -13457,7 +13562,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13457
13562
|
try {
|
|
13458
13563
|
return await this.arkProvider.registerIntent(intent);
|
|
13459
13564
|
} catch (error) {
|
|
13460
|
-
if (error instanceof
|
|
13565
|
+
if (error instanceof chunkDSTYXT2D_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
|
|
13461
13566
|
const deleteIntent = await this.makeDeleteIntentSignature(inputs);
|
|
13462
13567
|
await this.arkProvider.deleteIntent(deleteIntent);
|
|
13463
13568
|
return this.arkProvider.registerIntent(intent);
|
|
@@ -13473,7 +13578,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13473
13578
|
expire_at: 0,
|
|
13474
13579
|
cosigners_public_keys: cosignerPubKeys
|
|
13475
13580
|
};
|
|
13476
|
-
const proof =
|
|
13581
|
+
const proof = chunkDSTYXT2D_cjs.Intent.create(message, coins, outputs);
|
|
13477
13582
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
13478
13583
|
return {
|
|
13479
13584
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -13485,7 +13590,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13485
13590
|
type: "delete",
|
|
13486
13591
|
expire_at: 0
|
|
13487
13592
|
};
|
|
13488
|
-
const proof =
|
|
13593
|
+
const proof = chunkDSTYXT2D_cjs.Intent.create(message, coins, []);
|
|
13489
13594
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
13490
13595
|
return {
|
|
13491
13596
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -13497,7 +13602,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13497
13602
|
type: "get-pending-tx",
|
|
13498
13603
|
expire_at: 0
|
|
13499
13604
|
};
|
|
13500
|
-
const proof =
|
|
13605
|
+
const proof = chunkDSTYXT2D_cjs.Intent.create(message, coins, []);
|
|
13501
13606
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
13502
13607
|
return {
|
|
13503
13608
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -13518,7 +13623,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13518
13623
|
if (!vtxos || vtxos.length === 0) {
|
|
13519
13624
|
const scriptMap = await this.getScriptMap();
|
|
13520
13625
|
const allExtended = [];
|
|
13521
|
-
const fetchedVtxos = await
|
|
13626
|
+
const fetchedVtxos = await chunkDSTYXT2D_cjs.getAllNormalizedVtxos(this.indexerProvider, [
|
|
13522
13627
|
...scriptMap.keys()
|
|
13523
13628
|
]);
|
|
13524
13629
|
for (const vtxo of fetchedVtxos) {
|
|
@@ -13632,11 +13737,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13632
13737
|
* against the current key alone would leave it pending forever.
|
|
13633
13738
|
*/
|
|
13634
13739
|
checkpointUnrollCandidates(info) {
|
|
13635
|
-
const current =
|
|
13740
|
+
const current = chunkDSTYXT2D_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
13636
13741
|
const candidates = [this._serverUnrollScript, current];
|
|
13637
13742
|
for (const deprecated of signerSetFromInfo(info).deprecated.keys()) {
|
|
13638
13743
|
candidates.push(
|
|
13639
|
-
|
|
13744
|
+
chunkDSTYXT2D_cjs.CSVMultisigTapscript.encode({
|
|
13640
13745
|
...current.params,
|
|
13641
13746
|
pubkeys: [base.hex.decode(deprecated)]
|
|
13642
13747
|
})
|
|
@@ -13727,7 +13832,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13727
13832
|
if (vtxos.length === 0) {
|
|
13728
13833
|
throw new Error("No VTXOs found for this arkadeCash");
|
|
13729
13834
|
}
|
|
13730
|
-
const myPkScript =
|
|
13835
|
+
const myPkScript = chunkDSTYXT2D_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
|
|
13731
13836
|
let { spendable, unclaimed } = this.classifyCashVtxos(vtxos);
|
|
13732
13837
|
let swept = 0;
|
|
13733
13838
|
const drainable = vtxos.filter((vtxo) => !isSubdust(vtxo, this.dustAmount));
|
|
@@ -13801,7 +13906,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13801
13906
|
const spendable = [];
|
|
13802
13907
|
const unclaimed = [];
|
|
13803
13908
|
for (const vtxo of vtxos) {
|
|
13804
|
-
if (
|
|
13909
|
+
if (chunkDSTYXT2D_cjs.hasTerminalSpend(vtxo)) {
|
|
13805
13910
|
unclaimed.push(cashReport(vtxo, "already-spent"));
|
|
13806
13911
|
} else if (isSubdust(vtxo, this.dustAmount)) {
|
|
13807
13912
|
unclaimed.push(cashReport(vtxo, "subdust"));
|
|
@@ -13821,7 +13926,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13821
13926
|
const all = [];
|
|
13822
13927
|
const seen = /* @__PURE__ */ new Set();
|
|
13823
13928
|
for (let pageIndex = 0; ; pageIndex++) {
|
|
13824
|
-
const { vtxos, page } = await
|
|
13929
|
+
const { vtxos, page } = await chunkDSTYXT2D_cjs.getNormalizedVtxos(this.indexerProvider, {
|
|
13825
13930
|
scripts,
|
|
13826
13931
|
pageIndex,
|
|
13827
13932
|
pageSize
|
|
@@ -13868,7 +13973,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13868
13973
|
for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
|
|
13869
13974
|
const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
|
|
13870
13975
|
const message = { type: "get-pending-tx", expire_at: 0 };
|
|
13871
|
-
const proof =
|
|
13976
|
+
const proof = chunkDSTYXT2D_cjs.Intent.create(message, batch, []);
|
|
13872
13977
|
const signedProof = await identity.sign(
|
|
13873
13978
|
proof,
|
|
13874
13979
|
Array.from({ length: batch.length + 1 }, (_, j) => j)
|
|
@@ -14178,10 +14283,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14178
14283
|
const serverPubKey = this.arkServerPublicKey;
|
|
14179
14284
|
const serverUnrollScript = this.serverUnrollScript;
|
|
14180
14285
|
const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
|
|
14181
|
-
const normalizedInputs = inputs.map(
|
|
14182
|
-
const at = now ?? await
|
|
14286
|
+
const normalizedInputs = inputs.map(chunkDSTYXT2D_cjs.normalizeVtxo);
|
|
14287
|
+
const at = now ?? await chunkDSTYXT2D_cjs.resolveTimeHeight(this.onchainProvider);
|
|
14183
14288
|
for (const input of normalizedInputs) {
|
|
14184
|
-
if (!
|
|
14289
|
+
if (!chunkDSTYXT2D_cjs.canSpendOffchain(input, at)) {
|
|
14185
14290
|
throw new Error(
|
|
14186
14291
|
`sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
|
|
14187
14292
|
);
|
|
@@ -14246,7 +14351,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14246
14351
|
);
|
|
14247
14352
|
const arkTxJobs = inputs.map((input, index) => ({
|
|
14248
14353
|
index,
|
|
14249
|
-
lookupScript:
|
|
14354
|
+
lookupScript: chunkDSTYXT2D_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
14250
14355
|
}));
|
|
14251
14356
|
const identity = this.identity;
|
|
14252
14357
|
const signer = {
|
|
@@ -14332,14 +14437,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14332
14437
|
const spentBy = checkpointIdByOutpoint.get(`${vtxo.txid}:${vtxo.vout}`);
|
|
14333
14438
|
spentVtxos.push({
|
|
14334
14439
|
...spentFacts,
|
|
14335
|
-
virtualStatus:
|
|
14440
|
+
virtualStatus: chunkDSTYXT2D_cjs.toVirtualStatus(spentFacts),
|
|
14336
14441
|
...spentBy ? { spentBy } : {},
|
|
14337
14442
|
arkTxId: arkTxid
|
|
14338
14443
|
});
|
|
14339
14444
|
for (const id of vtxo.commitmentTxIds) {
|
|
14340
14445
|
commitmentTxIds.add(id);
|
|
14341
14446
|
}
|
|
14342
|
-
const vtxoExpiry =
|
|
14447
|
+
const vtxoExpiry = chunkDSTYXT2D_cjs.toBatchExpiry(vtxo);
|
|
14343
14448
|
if (vtxoExpiry) {
|
|
14344
14449
|
batchExpiry = Math.min(batchExpiry, vtxoExpiry);
|
|
14345
14450
|
}
|
|
@@ -14352,7 +14457,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14352
14457
|
isSwept: false,
|
|
14353
14458
|
isPreconfirmed: true,
|
|
14354
14459
|
commitmentTxIds: Array.from(commitmentTxIds),
|
|
14355
|
-
...
|
|
14460
|
+
...chunkDSTYXT2D_cjs.parseLegacyExpiry(batchExpiry)
|
|
14356
14461
|
};
|
|
14357
14462
|
changeVtxo = {
|
|
14358
14463
|
txid: arkTxid,
|
|
@@ -14364,7 +14469,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14364
14469
|
tapTree: offchainTapscript.encode(),
|
|
14365
14470
|
value: Number(changeAmount),
|
|
14366
14471
|
...changeFacts,
|
|
14367
|
-
virtualStatus:
|
|
14472
|
+
virtualStatus: chunkDSTYXT2D_cjs.toVirtualStatus(changeFacts),
|
|
14368
14473
|
spentBy: "",
|
|
14369
14474
|
status: {
|
|
14370
14475
|
confirmed: false
|
|
@@ -14433,12 +14538,12 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14433
14538
|
const spentVtxos = [];
|
|
14434
14539
|
const inputArkTxIds = /* @__PURE__ */ new Set();
|
|
14435
14540
|
const boardingRemovalsByAddress = /* @__PURE__ */ new Map();
|
|
14436
|
-
const vtxoInputs = inputs.filter(
|
|
14541
|
+
const vtxoInputs = inputs.filter(chunkDSTYXT2D_cjs.isVirtualCoin);
|
|
14437
14542
|
const cm = await this.getContractManager();
|
|
14438
14543
|
const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
|
|
14439
14544
|
const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
|
|
14440
14545
|
for (const input of inputs) {
|
|
14441
|
-
if (
|
|
14546
|
+
if (chunkDSTYXT2D_cjs.isVirtualCoin(input)) {
|
|
14442
14547
|
const outpoint = `${input.txid}:${input.vout}`;
|
|
14443
14548
|
const vtxo = annotatedByKey.get(outpoint);
|
|
14444
14549
|
if (!vtxo) {
|
|
@@ -14450,13 +14555,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14450
14555
|
const settledFacts = { ...vtxo, isSpent: true };
|
|
14451
14556
|
spentVtxos.push({
|
|
14452
14557
|
...settledFacts,
|
|
14453
|
-
virtualStatus:
|
|
14558
|
+
virtualStatus: chunkDSTYXT2D_cjs.toVirtualStatus(settledFacts),
|
|
14454
14559
|
settledBy: commitmentTxid
|
|
14455
14560
|
});
|
|
14456
14561
|
} else {
|
|
14457
14562
|
let sourceAddress;
|
|
14458
14563
|
try {
|
|
14459
|
-
sourceAddress =
|
|
14564
|
+
sourceAddress = chunkDSTYXT2D_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
|
|
14460
14565
|
this.network
|
|
14461
14566
|
);
|
|
14462
14567
|
} catch {
|
|
@@ -14514,9 +14619,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14514
14619
|
}
|
|
14515
14620
|
};
|
|
14516
14621
|
function selectVirtualCoins(coins, targetAmount) {
|
|
14517
|
-
const sortedCoins = coins.map(
|
|
14518
|
-
const expiryA =
|
|
14519
|
-
const expiryB =
|
|
14622
|
+
const sortedCoins = coins.map(chunkDSTYXT2D_cjs.normalizeVtxo).sort((a, b) => {
|
|
14623
|
+
const expiryA = chunkDSTYXT2D_cjs.toBatchExpiry(a) || Number.MAX_SAFE_INTEGER;
|
|
14624
|
+
const expiryB = chunkDSTYXT2D_cjs.toBatchExpiry(b) || Number.MAX_SAFE_INTEGER;
|
|
14520
14625
|
if (expiryA !== expiryB) {
|
|
14521
14626
|
return expiryA - expiryB;
|
|
14522
14627
|
}
|
|
@@ -14773,7 +14878,7 @@ var MessageBus = class {
|
|
|
14773
14878
|
this.initialized = true;
|
|
14774
14879
|
}
|
|
14775
14880
|
async buildServices(config) {
|
|
14776
|
-
const arkProvider = new
|
|
14881
|
+
const arkProvider = new chunkDSTYXT2D_cjs.RestArkProvider(config.arkServer.url);
|
|
14777
14882
|
const storage = {
|
|
14778
14883
|
walletRepository: this.walletRepository,
|
|
14779
14884
|
contractRepository: this.contractRepository
|
|
@@ -14793,7 +14898,9 @@ var MessageBus = class {
|
|
|
14793
14898
|
settlementConfig: config.settlementConfig,
|
|
14794
14899
|
walletMode: config.walletMode,
|
|
14795
14900
|
watcherConfig: config.watcherConfig,
|
|
14796
|
-
lookAheadWindow: config.lookAheadWindow
|
|
14901
|
+
lookAheadWindow: config.lookAheadWindow,
|
|
14902
|
+
minBatchExpirySeconds: config.minBatchExpirySeconds,
|
|
14903
|
+
minCheckpointExitDelaySeconds: config.minCheckpointExitDelaySeconds
|
|
14797
14904
|
});
|
|
14798
14905
|
return { wallet, arkProvider, readonlyWallet: wallet };
|
|
14799
14906
|
}
|
|
@@ -15112,7 +15219,7 @@ var offboardNetworkNames = [
|
|
|
15112
15219
|
function offboardDestinationScript(destinationAddress) {
|
|
15113
15220
|
for (const networkName of offboardNetworkNames) {
|
|
15114
15221
|
try {
|
|
15115
|
-
const network =
|
|
15222
|
+
const network = chunkDSTYXT2D_cjs.networks[networkName];
|
|
15116
15223
|
const addr = btcSigner.Address(network).decode(destinationAddress);
|
|
15117
15224
|
return btcSigner.OutScript.encode(addr);
|
|
15118
15225
|
} catch {
|
|
@@ -15176,7 +15283,7 @@ var Ramps = class {
|
|
|
15176
15283
|
}
|
|
15177
15284
|
amount = amount ?? totalAmount;
|
|
15178
15285
|
const offchainAddress = await this.wallet.getAddress();
|
|
15179
|
-
const offchainAddr =
|
|
15286
|
+
const offchainAddr = chunkDSTYXT2D_cjs.ArkAddress.decode(offchainAddress);
|
|
15180
15287
|
const offchainScript = base.hex.encode(offchainAddr.pkScript);
|
|
15181
15288
|
const outputFee = estimator.evalOffchainOutput({
|
|
15182
15289
|
amount,
|
|
@@ -15236,7 +15343,7 @@ var Ramps = class {
|
|
|
15236
15343
|
const filteredVtxos = [];
|
|
15237
15344
|
let totalAmount = 0n;
|
|
15238
15345
|
for (const vtxo of vtxos) {
|
|
15239
|
-
const inputFee = estimator.evalOffchainInput(
|
|
15346
|
+
const inputFee = estimator.evalOffchainInput(chunkDSTYXT2D_cjs.toOffchainInputFeeParams(vtxo));
|
|
15240
15347
|
if (inputFee.satoshis >= vtxo.value) {
|
|
15241
15348
|
continue;
|
|
15242
15349
|
}
|
|
@@ -15933,7 +16040,7 @@ var WalletMessageHandler = class {
|
|
|
15933
16040
|
// Wallet methods
|
|
15934
16041
|
async handleInitWallet({ payload }) {
|
|
15935
16042
|
const { arkServerUrl } = payload;
|
|
15936
|
-
this.indexerProvider = new
|
|
16043
|
+
this.indexerProvider = new chunkV2KENVN6_cjs.RestIndexerProvider(arkServerUrl);
|
|
15937
16044
|
await this.onWalletInitialized();
|
|
15938
16045
|
}
|
|
15939
16046
|
async handleGetBalance() {
|
|
@@ -15957,12 +16064,12 @@ var WalletMessageHandler = class {
|
|
|
15957
16064
|
let recoverable = 0;
|
|
15958
16065
|
let pendingRecovery = 0;
|
|
15959
16066
|
for (const vtxo of allVtxos) {
|
|
15960
|
-
if (
|
|
16067
|
+
if (chunkDSTYXT2D_cjs.hasTerminalSpend(vtxo)) continue;
|
|
15961
16068
|
if (pendingOutpoints.has(`${vtxo.txid}:${vtxo.vout}`)) {
|
|
15962
16069
|
pendingRecovery += vtxo.value;
|
|
15963
|
-
} else if (
|
|
16070
|
+
} else if (chunkDSTYXT2D_cjs.canRecoverOnchain(vtxo, now)) {
|
|
15964
16071
|
recoverable += vtxo.value;
|
|
15965
|
-
} else if (
|
|
16072
|
+
} else if (chunkDSTYXT2D_cjs.canSpendOffchain(vtxo, now)) {
|
|
15966
16073
|
if (vtxo.isPreconfirmed) {
|
|
15967
16074
|
preconfirmed += vtxo.value;
|
|
15968
16075
|
} else {
|
|
@@ -15974,7 +16081,7 @@ var WalletMessageHandler = class {
|
|
|
15974
16081
|
const totalOffchain = settled + preconfirmed + recoverable + pendingRecovery;
|
|
15975
16082
|
const assetBalances = /* @__PURE__ */ new Map();
|
|
15976
16083
|
for (const vtxo of allVtxos) {
|
|
15977
|
-
if (
|
|
16084
|
+
if (chunkDSTYXT2D_cjs.hasTerminalSpend(vtxo)) continue;
|
|
15978
16085
|
if (vtxo.assets) {
|
|
15979
16086
|
for (const a of vtxo.assets) {
|
|
15980
16087
|
const current = assetBalances.get(a.assetId) ?? 0n;
|
|
@@ -16010,7 +16117,7 @@ var WalletMessageHandler = class {
|
|
|
16010
16117
|
*/
|
|
16011
16118
|
async getSpendableVtxos() {
|
|
16012
16119
|
const vtxos = await this.getVtxosFromRepo();
|
|
16013
|
-
return vtxos.filter((v) => !
|
|
16120
|
+
return vtxos.filter((v) => !chunkDSTYXT2D_cjs.hasTerminalSpend(v));
|
|
16014
16121
|
}
|
|
16015
16122
|
async onWalletInitialized() {
|
|
16016
16123
|
if (!this.readonlyWallet || !this.arkProvider || !this.indexerProvider || !this.walletRepository) {
|
|
@@ -16222,10 +16329,10 @@ var WalletMessageHandler = class {
|
|
|
16222
16329
|
if (dustAmount != null && isSubdust(v, dustAmount)) {
|
|
16223
16330
|
return false;
|
|
16224
16331
|
}
|
|
16225
|
-
if (
|
|
16332
|
+
if (chunkDSTYXT2D_cjs.isRecoverable(v)) {
|
|
16226
16333
|
return false;
|
|
16227
16334
|
}
|
|
16228
|
-
if (
|
|
16335
|
+
if (chunkDSTYXT2D_cjs.isExpired(v)) {
|
|
16229
16336
|
return false;
|
|
16230
16337
|
}
|
|
16231
16338
|
return true;
|
|
@@ -16297,7 +16404,7 @@ var WalletMessageHandler = class {
|
|
|
16297
16404
|
if (!this.readonlyWallet) return null;
|
|
16298
16405
|
const { boardingTxs, commitmentsToIgnore } = await this.readonlyWallet.getBoardingTxs();
|
|
16299
16406
|
const indexerProvider = this.indexerProvider;
|
|
16300
|
-
const resolveTxCreatedAt = indexerProvider ? (txids) =>
|
|
16407
|
+
const resolveTxCreatedAt = indexerProvider ? (txids) => chunkDSTYXT2D_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
|
|
16301
16408
|
return buildTransactionHistory(vtxos, boardingTxs, commitmentsToIgnore, resolveTxCreatedAt);
|
|
16302
16409
|
}
|
|
16303
16410
|
async ensureContractEventBroadcasting() {
|
|
@@ -16982,7 +17089,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
16982
17089
|
};
|
|
16983
17090
|
try {
|
|
16984
17091
|
const response = await this.sendMessage(message);
|
|
16985
|
-
return response.payload.vtxos.map(
|
|
17092
|
+
return response.payload.vtxos.map(chunkDSTYXT2D_cjs.normalizeVtxo);
|
|
16986
17093
|
} catch (error) {
|
|
16987
17094
|
throw new Error(`Failed to get vtxos: ${error}`);
|
|
16988
17095
|
}
|
|
@@ -17095,7 +17202,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
17095
17202
|
};
|
|
17096
17203
|
try {
|
|
17097
17204
|
const response = await sendContractMessage(message);
|
|
17098
|
-
return response.payload.vtxos.map(
|
|
17205
|
+
return response.payload.vtxos.map(chunkDSTYXT2D_cjs.normalizeVtxo);
|
|
17099
17206
|
} catch (e) {
|
|
17100
17207
|
throw new Error("Failed to annotate vtxos");
|
|
17101
17208
|
}
|
|
@@ -17326,6 +17433,8 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
17326
17433
|
walletMode: options.walletMode,
|
|
17327
17434
|
watcherConfig: options.watcherConfig,
|
|
17328
17435
|
lookAheadWindow: options.lookAheadWindow,
|
|
17436
|
+
minBatchExpirySeconds: options.minBatchExpirySeconds,
|
|
17437
|
+
minCheckpointExitDelaySeconds: options.minCheckpointExitDelaySeconds,
|
|
17329
17438
|
messageTimeouts
|
|
17330
17439
|
};
|
|
17331
17440
|
await initializeMessageBus(
|
|
@@ -17549,7 +17658,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
17549
17658
|
};
|
|
17550
17659
|
try {
|
|
17551
17660
|
const response = await wallet.sendMessage(message);
|
|
17552
|
-
return response.payload.vtxos.map(
|
|
17661
|
+
return response.payload.vtxos.map(chunkDSTYXT2D_cjs.normalizeVtxo);
|
|
17553
17662
|
} catch (e) {
|
|
17554
17663
|
throw new Error(`Failed to get expiring vtxos: ${e}`);
|
|
17555
17664
|
}
|
|
@@ -17661,12 +17770,12 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
17661
17770
|
* @returns Configured onchain wallet
|
|
17662
17771
|
* @throws Error if the configured identity cannot produce a valid x-only public key
|
|
17663
17772
|
*/
|
|
17664
|
-
static async create(identity, networkName =
|
|
17773
|
+
static async create(identity, networkName = chunkDSTYXT2D_cjs.DEFAULT_NETWORK_NAME, provider) {
|
|
17665
17774
|
const pubkey = await identity.xOnlyPublicKey();
|
|
17666
17775
|
if (!pubkey) {
|
|
17667
17776
|
throw new Error("Invalid configured public key");
|
|
17668
17777
|
}
|
|
17669
|
-
const network =
|
|
17778
|
+
const network = chunkDSTYXT2D_cjs.getNetwork(networkName);
|
|
17670
17779
|
const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
|
|
17671
17780
|
const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
|
|
17672
17781
|
return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
|
|
@@ -17772,7 +17881,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
17772
17881
|
if (!inputs) {
|
|
17773
17882
|
throw new Error("Fee estimation failed");
|
|
17774
17883
|
}
|
|
17775
|
-
let tx = new
|
|
17884
|
+
let tx = new chunkDSTYXT2D_cjs.Transaction();
|
|
17776
17885
|
for (const input of inputs) {
|
|
17777
17886
|
tx.addInput({
|
|
17778
17887
|
txid: input.txid,
|
|
@@ -17830,7 +17939,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
17830
17939
|
* @throws If the parent has no anchor, or funding cannot be selected/signed
|
|
17831
17940
|
*/
|
|
17832
17941
|
async bumpAnchor(parentHex, feeRate) {
|
|
17833
|
-
const parent =
|
|
17942
|
+
const parent = chunkDSTYXT2D_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
|
|
17834
17943
|
const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
|
|
17835
17944
|
const child = await this.buildBumpPackage(parent, feeRate, coins);
|
|
17836
17945
|
return [parent.hex, child.hex];
|
|
@@ -18595,7 +18704,7 @@ exports.BIP322 = void 0;
|
|
|
18595
18704
|
async function sign2(message, identity, network) {
|
|
18596
18705
|
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
18597
18706
|
const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
|
|
18598
|
-
const toSpend =
|
|
18707
|
+
const toSpend = chunkDSTYXT2D_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
18599
18708
|
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
18600
18709
|
const signed = await identity.sign(toSign, [0]);
|
|
18601
18710
|
signed.finalizeIdx(0);
|
|
@@ -18653,7 +18762,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
|
18653
18762
|
if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
|
|
18654
18763
|
return false;
|
|
18655
18764
|
}
|
|
18656
|
-
const toSpend =
|
|
18765
|
+
const toSpend = chunkDSTYXT2D_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
18657
18766
|
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
|
|
18658
18767
|
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
18659
18768
|
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
@@ -18674,7 +18783,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
|
18674
18783
|
}
|
|
18675
18784
|
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
18676
18785
|
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
18677
|
-
const toSpend =
|
|
18786
|
+
const toSpend = chunkDSTYXT2D_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
18678
18787
|
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
18679
18788
|
const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
|
|
18680
18789
|
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
@@ -18727,7 +18836,7 @@ function encodeCompactSize(n) {
|
|
|
18727
18836
|
return buf;
|
|
18728
18837
|
}
|
|
18729
18838
|
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
18730
|
-
const tx = new
|
|
18839
|
+
const tx = new chunkDSTYXT2D_cjs.Transaction({ version: 0 });
|
|
18731
18840
|
tx.addInput({
|
|
18732
18841
|
txid: toSpend.id,
|
|
18733
18842
|
index: 0,
|
|
@@ -18741,12 +18850,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
|
18741
18850
|
});
|
|
18742
18851
|
tx.addOutput({
|
|
18743
18852
|
amount: 0n,
|
|
18744
|
-
script:
|
|
18853
|
+
script: chunkDSTYXT2D_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
18745
18854
|
});
|
|
18746
18855
|
return tx;
|
|
18747
18856
|
}
|
|
18748
18857
|
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
18749
|
-
const tx = new
|
|
18858
|
+
const tx = new chunkDSTYXT2D_cjs.Transaction({ version: 0 });
|
|
18750
18859
|
tx.addInput({
|
|
18751
18860
|
txid: toSpend.id,
|
|
18752
18861
|
index: 0,
|
|
@@ -18758,7 +18867,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
|
18758
18867
|
});
|
|
18759
18868
|
tx.addOutput({
|
|
18760
18869
|
amount: 0n,
|
|
18761
|
-
script:
|
|
18870
|
+
script: chunkDSTYXT2D_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
18762
18871
|
});
|
|
18763
18872
|
return tx;
|
|
18764
18873
|
}
|
|
@@ -18889,7 +18998,7 @@ var RestEmulatorProvider = class {
|
|
|
18889
18998
|
}
|
|
18890
18999
|
};
|
|
18891
19000
|
function finalizeVirtualTx(type, psbtBase64) {
|
|
18892
|
-
const tx =
|
|
19001
|
+
const tx = chunkDSTYXT2D_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
18893
19002
|
if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
|
|
18894
19003
|
const input = tx.getInput(0);
|
|
18895
19004
|
if (!input) {
|
|
@@ -18916,14 +19025,14 @@ var ExitPathError = class extends Error {
|
|
|
18916
19025
|
reason;
|
|
18917
19026
|
};
|
|
18918
19027
|
function delayWeight(sequence) {
|
|
18919
|
-
const t =
|
|
19028
|
+
const t = chunkDSTYXT2D_cjs.sequenceToTimelock(sequence);
|
|
18920
19029
|
return t.type === "blocks" ? Number(t.value) : Number(t.value) / 600;
|
|
18921
19030
|
}
|
|
18922
19031
|
async function resolveUnilateralPath(params) {
|
|
18923
19032
|
const { vtxo, scriptHex, contractRepository } = params;
|
|
18924
19033
|
const contract = contractRepository ? (await contractRepository.getContracts({ script: scriptHex }))[0] : void 0;
|
|
18925
19034
|
if (contract) {
|
|
18926
|
-
const handler =
|
|
19035
|
+
const handler = chunk2XO43UHI_cjs.contractHandlers.get(contract.type);
|
|
18927
19036
|
if (!handler) {
|
|
18928
19037
|
throw new ExitPathError(
|
|
18929
19038
|
"no-handler",
|
|
@@ -18946,12 +19055,12 @@ async function resolveUnilateralPath(params) {
|
|
|
18946
19055
|
paths.sort((a, b) => delayWeight(a.sequence) - delayWeight(b.sequence));
|
|
18947
19056
|
return { selection: paths[0], label: `${contract.type}:unilateral` };
|
|
18948
19057
|
}
|
|
18949
|
-
const decoded =
|
|
19058
|
+
const decoded = chunkDSTYXT2D_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
18950
19059
|
let best;
|
|
18951
19060
|
for (const exit of decoded.exitPaths()) {
|
|
18952
19061
|
const leaf = decoded.findLeaf(base.hex.encode(exit.script));
|
|
18953
19062
|
if (!leaf) continue;
|
|
18954
|
-
const sequence =
|
|
19063
|
+
const sequence = chunkDSTYXT2D_cjs.timelockToSequence(exit.params.timelock);
|
|
18955
19064
|
const weight = delayWeight(sequence);
|
|
18956
19065
|
if (!best || weight < best.weight) {
|
|
18957
19066
|
best = { selection: { leaf, sequence }, weight };
|
|
@@ -19137,14 +19246,14 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
19137
19246
|
}
|
|
19138
19247
|
const resolved = await resolveUnilateralPath({
|
|
19139
19248
|
vtxo,
|
|
19140
|
-
scriptHex: base.hex.encode(
|
|
19249
|
+
scriptHex: base.hex.encode(chunkDSTYXT2D_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
19141
19250
|
contractRepository: wallet.contractRepository,
|
|
19142
19251
|
walletPubKeyHex: base.hex.encode(await wallet.identity.xOnlyPublicKey()),
|
|
19143
19252
|
currentTime: Date.now()
|
|
19144
19253
|
});
|
|
19145
19254
|
const spendingLeaf = resolved.selection.leaf;
|
|
19146
19255
|
const sequence = resolved.selection.sequence;
|
|
19147
|
-
const timelock =
|
|
19256
|
+
const timelock = chunkDSTYXT2D_cjs.sequenceToTimelock(sequence);
|
|
19148
19257
|
const elapsed = timelock.type === "blocks" ? chainTip.height >= txStatus.blockHeight + Number(timelock.value) : chainTip.time >= txStatus.blockTime + Number(timelock.value);
|
|
19149
19258
|
if (!elapsed) {
|
|
19150
19259
|
throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
|
|
@@ -19157,7 +19266,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
19157
19266
|
sequence,
|
|
19158
19267
|
witnessUtxo: {
|
|
19159
19268
|
amount: BigInt(vtxo.value),
|
|
19160
|
-
script:
|
|
19269
|
+
script: chunkDSTYXT2D_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
|
|
19161
19270
|
},
|
|
19162
19271
|
sighashType: btcSigner.SigHash.DEFAULT
|
|
19163
19272
|
});
|
|
@@ -19167,7 +19276,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
19167
19276
|
btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
|
|
19168
19277
|
);
|
|
19169
19278
|
}
|
|
19170
|
-
const tx = new
|
|
19279
|
+
const tx = new chunkDSTYXT2D_cjs.Transaction({ version: 2 });
|
|
19171
19280
|
for (const input of inputs) {
|
|
19172
19281
|
tx.addInput(input);
|
|
19173
19282
|
}
|
|
@@ -19234,7 +19343,7 @@ async function buildSignedSweep(params) {
|
|
|
19234
19343
|
`uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
|
|
19235
19344
|
);
|
|
19236
19345
|
}
|
|
19237
|
-
const tx = new
|
|
19346
|
+
const tx = new chunkDSTYXT2D_cjs.Transaction({ version: 2 });
|
|
19238
19347
|
tx.addInput({
|
|
19239
19348
|
txid: vtxo.txid,
|
|
19240
19349
|
index: vtxo.vout,
|
|
@@ -19259,7 +19368,7 @@ async function buildSignedSweep(params) {
|
|
|
19259
19368
|
finalScriptWitness: [
|
|
19260
19369
|
tapScriptSig[0][1],
|
|
19261
19370
|
...path.extraWitness,
|
|
19262
|
-
|
|
19371
|
+
chunkDSTYXT2D_cjs.scriptFromTapLeafScript(path.leaf),
|
|
19263
19372
|
btcSigner.TaprootControlBlock.encode(controlBlock)
|
|
19264
19373
|
]
|
|
19265
19374
|
});
|
|
@@ -19289,7 +19398,7 @@ async function resolveFeeRate(opts) {
|
|
|
19289
19398
|
}
|
|
19290
19399
|
async function selectExitVtxos(opts) {
|
|
19291
19400
|
if (!opts.vtxos) return opts.wallet.getVtxos();
|
|
19292
|
-
const res = await
|
|
19401
|
+
const res = await chunkDSTYXT2D_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
|
|
19293
19402
|
const tapTrees = /* @__PURE__ */ new Map();
|
|
19294
19403
|
const out = [];
|
|
19295
19404
|
for (const vtxo of res.vtxos) {
|
|
@@ -19304,7 +19413,7 @@ async function selectExitVtxos(opts) {
|
|
|
19304
19413
|
`no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
|
|
19305
19414
|
);
|
|
19306
19415
|
}
|
|
19307
|
-
const handler =
|
|
19416
|
+
const handler = chunk2XO43UHI_cjs.contractHandlers.get(contract.type);
|
|
19308
19417
|
if (!handler) {
|
|
19309
19418
|
throw new Error(`no contract handler registered for type '${contract.type}'`);
|
|
19310
19419
|
}
|
|
@@ -19334,7 +19443,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
19334
19443
|
if (pendingNodes.length > 0) {
|
|
19335
19444
|
const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
|
|
19336
19445
|
for (const psbt of txs) {
|
|
19337
|
-
psbts.set(
|
|
19446
|
+
psbts.set(chunkDSTYXT2D_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
19338
19447
|
}
|
|
19339
19448
|
}
|
|
19340
19449
|
const childVsize = Number(
|
|
@@ -19370,7 +19479,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
19370
19479
|
try {
|
|
19371
19480
|
const resolved = await resolveUnilateralPath({
|
|
19372
19481
|
vtxo,
|
|
19373
|
-
scriptHex: base.hex.encode(
|
|
19482
|
+
scriptHex: base.hex.encode(chunkDSTYXT2D_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
19374
19483
|
contractRepository: wallet.contractRepository,
|
|
19375
19484
|
walletPubKeyHex,
|
|
19376
19485
|
currentTime: Date.now()
|
|
@@ -19389,7 +19498,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
19389
19498
|
});
|
|
19390
19499
|
continue;
|
|
19391
19500
|
}
|
|
19392
|
-
const t =
|
|
19501
|
+
const t = chunkDSTYXT2D_cjs.sequenceToTimelock(resolved.selection.sequence);
|
|
19393
19502
|
const delay = { type: t.type, value: Number(t.value) };
|
|
19394
19503
|
infos.push({ outpoint, value: vtxo.value, sweepFee, path: resolved.label, delay });
|
|
19395
19504
|
sweeps.push({ vtxo, resolved, sweepFee, delay });
|
|
@@ -19728,7 +19837,7 @@ async function prepare(opts) {
|
|
|
19728
19837
|
txid: sweep.vtxo.txid,
|
|
19729
19838
|
vout: sweep.vtxo.vout,
|
|
19730
19839
|
value: sweep.vtxo.value,
|
|
19731
|
-
pkScript:
|
|
19840
|
+
pkScript: chunkDSTYXT2D_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
|
|
19732
19841
|
},
|
|
19733
19842
|
path: sweep.resolved.selection,
|
|
19734
19843
|
outputAddress: opts.sweepAddress,
|
|
@@ -19813,7 +19922,7 @@ async function prepare(opts) {
|
|
|
19813
19922
|
if (newFee <= splitterFee) break;
|
|
19814
19923
|
splitterFee = newFee;
|
|
19815
19924
|
}
|
|
19816
|
-
const splitter = new
|
|
19925
|
+
const splitter = new chunkDSTYXT2D_cjs.Transaction({ version: 2 });
|
|
19817
19926
|
for (const coin of selected.inputs) {
|
|
19818
19927
|
splitter.addInput({
|
|
19819
19928
|
txid: coin.txid,
|
|
@@ -19956,41 +20065,41 @@ var UnilateralExit = {
|
|
|
19956
20065
|
// src/arkade/index.ts
|
|
19957
20066
|
var arkade_exports = {};
|
|
19958
20067
|
chunk5BLDMQED_cjs.__export(arkade_exports, {
|
|
19959
|
-
ARKADE_OP: () =>
|
|
19960
|
-
ARKADE_OPCODES: () =>
|
|
19961
|
-
ARKADE_OPCODE_NAMES: () =>
|
|
19962
|
-
ARKADE_OPCODE_VALUES: () =>
|
|
19963
|
-
ARKADE_OPS: () =>
|
|
20068
|
+
ARKADE_OP: () => chunk2XO43UHI_cjs.ARKADE_OP,
|
|
20069
|
+
ARKADE_OPCODES: () => chunk2XO43UHI_cjs.ARKADE_OPCODES,
|
|
20070
|
+
ARKADE_OPCODE_NAMES: () => chunk2XO43UHI_cjs.ARKADE_OPCODE_NAMES,
|
|
20071
|
+
ARKADE_OPCODE_VALUES: () => chunk2XO43UHI_cjs.ARKADE_OPCODE_VALUES,
|
|
20072
|
+
ARKADE_OPS: () => chunk2XO43UHI_cjs.ARKADE_OPS,
|
|
19964
20073
|
Arkade: () => Arkade,
|
|
19965
20074
|
ArkadeContract: () => ArkadeContract,
|
|
19966
|
-
ArkadeProgramScript: () =>
|
|
19967
|
-
ArkadeScript: () =>
|
|
20075
|
+
ArkadeProgramScript: () => chunk2XO43UHI_cjs.ArkadeProgramScript,
|
|
20076
|
+
ArkadeScript: () => chunk2XO43UHI_cjs.ArkadeScript,
|
|
19968
20077
|
ArkadeTransactionBuilder: () => ArkadeTransactionBuilder,
|
|
19969
|
-
BigNum: () =>
|
|
20078
|
+
BigNum: () => chunk2XO43UHI_cjs.bignum_exports,
|
|
19970
20079
|
OP: () => btcSigner.OP,
|
|
19971
|
-
OPCODE_NAMES: () =>
|
|
19972
|
-
OPCODE_VALUES: () =>
|
|
19973
|
-
SUPPORTED_PROGRAM_VERSION: () =>
|
|
20080
|
+
OPCODE_NAMES: () => chunk2XO43UHI_cjs.OPCODE_NAMES,
|
|
20081
|
+
OPCODE_VALUES: () => chunk2XO43UHI_cjs.OPCODE_VALUES,
|
|
20082
|
+
SUPPORTED_PROGRAM_VERSION: () => chunk2XO43UHI_cjs.SUPPORTED_PROGRAM_VERSION,
|
|
19974
20083
|
Script: () => btcSigner.Script,
|
|
19975
|
-
arkadeScriptHash: () =>
|
|
19976
|
-
arkadeWitnessHash: () =>
|
|
19977
|
-
asmToBytes: () =>
|
|
19978
|
-
bytesToASM: () =>
|
|
19979
|
-
computeArkadeScriptPublicKey: () =>
|
|
20084
|
+
arkadeScriptHash: () => chunk2XO43UHI_cjs.arkadeScriptHash,
|
|
20085
|
+
arkadeWitnessHash: () => chunk2XO43UHI_cjs.arkadeWitnessHash,
|
|
20086
|
+
asmToBytes: () => chunk2XO43UHI_cjs.asmToBytes,
|
|
20087
|
+
bytesToASM: () => chunk2XO43UHI_cjs.bytesToASM,
|
|
20088
|
+
computeArkadeScriptPublicKey: () => chunk2XO43UHI_cjs.computeArkadeScriptPublicKey,
|
|
19980
20089
|
createArkadeBatchHandler: () => createArkadeBatchHandler,
|
|
19981
|
-
deserializeArkadeContractParams: () =>
|
|
19982
|
-
fromASM: () =>
|
|
19983
|
-
getOpcodeName: () =>
|
|
19984
|
-
getOpcodeValue: () =>
|
|
19985
|
-
parseArtifact: () =>
|
|
19986
|
-
resolveAsm: () =>
|
|
19987
|
-
serializeArkadeContractParams: () =>
|
|
19988
|
-
stringifyArtifact: () =>
|
|
19989
|
-
toASM: () =>
|
|
19990
|
-
validateProgram: () =>
|
|
19991
|
-
witnessRefToBytes: () =>
|
|
20090
|
+
deserializeArkadeContractParams: () => chunk2XO43UHI_cjs.deserializeArkadeContractParams,
|
|
20091
|
+
fromASM: () => chunk2XO43UHI_cjs.fromASM,
|
|
20092
|
+
getOpcodeName: () => chunk2XO43UHI_cjs.getOpcodeName,
|
|
20093
|
+
getOpcodeValue: () => chunk2XO43UHI_cjs.getOpcodeValue,
|
|
20094
|
+
parseArtifact: () => chunk2XO43UHI_cjs.parseArtifact,
|
|
20095
|
+
resolveAsm: () => chunk2XO43UHI_cjs.resolveAsm,
|
|
20096
|
+
serializeArkadeContractParams: () => chunk2XO43UHI_cjs.serializeArkadeContractParams,
|
|
20097
|
+
stringifyArtifact: () => chunk2XO43UHI_cjs.stringifyArtifact,
|
|
20098
|
+
toASM: () => chunk2XO43UHI_cjs.toASM,
|
|
20099
|
+
validateProgram: () => chunk2XO43UHI_cjs.validateProgram,
|
|
20100
|
+
witnessRefToBytes: () => chunk2XO43UHI_cjs.witnessRefToBytes
|
|
19992
20101
|
});
|
|
19993
|
-
var isVtxoCoin = (input) =>
|
|
20102
|
+
var isVtxoCoin = (input) => chunkDSTYXT2D_cjs.isVirtualCoin(input);
|
|
19994
20103
|
function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
|
|
19995
20104
|
let batchId;
|
|
19996
20105
|
let sweepTapTreeRoot;
|
|
@@ -20011,7 +20120,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
20011
20120
|
);
|
|
20012
20121
|
await arkProvider.confirmRegistration(intentId);
|
|
20013
20122
|
batchId = event.id;
|
|
20014
|
-
const sweepTapscript =
|
|
20123
|
+
const sweepTapscript = chunkDSTYXT2D_cjs.CSVMultisigTapscript.encode({
|
|
20015
20124
|
timelock,
|
|
20016
20125
|
pubkeys: [base.hex.decode(info.forfeitPubkey).subarray(1)]
|
|
20017
20126
|
}).script;
|
|
@@ -20025,7 +20134,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
20025
20134
|
if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
|
|
20026
20135
|
return { skip: true };
|
|
20027
20136
|
}
|
|
20028
|
-
const commitmentTx =
|
|
20137
|
+
const commitmentTx = chunkDSTYXT2D_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
|
|
20029
20138
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
20030
20139
|
if (recipients && recipients.length > 0) {
|
|
20031
20140
|
validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
|
|
@@ -20057,7 +20166,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
20057
20166
|
if (connectorTree) {
|
|
20058
20167
|
validateConnectorsTxGraph(event.commitmentTx, connectorTree);
|
|
20059
20168
|
}
|
|
20060
|
-
let commitmentPsbt =
|
|
20169
|
+
let commitmentPsbt = chunkDSTYXT2D_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
20061
20170
|
assertFinalCommitmentMatchesValidated(
|
|
20062
20171
|
commitmentPsbt,
|
|
20063
20172
|
validatedCommitmentTxid,
|
|
@@ -20092,7 +20201,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
20092
20201
|
boardingIndices.push(boardingIdx);
|
|
20093
20202
|
continue;
|
|
20094
20203
|
}
|
|
20095
|
-
if (
|
|
20204
|
+
if (chunkDSTYXT2D_cjs.isRecoverable(input) || isSubdust(input, info.dust)) {
|
|
20096
20205
|
continue;
|
|
20097
20206
|
}
|
|
20098
20207
|
if (connectorIndex >= connectorLeaves.length) {
|
|
@@ -20113,7 +20222,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
20113
20222
|
index: input.vout,
|
|
20114
20223
|
witnessUtxo: {
|
|
20115
20224
|
amount: BigInt(input.value),
|
|
20116
|
-
script:
|
|
20225
|
+
script: chunkDSTYXT2D_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
20117
20226
|
},
|
|
20118
20227
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
20119
20228
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -20171,7 +20280,16 @@ var Arkade = class _Arkade {
|
|
|
20171
20280
|
emulator;
|
|
20172
20281
|
network;
|
|
20173
20282
|
serverKey;
|
|
20174
|
-
/**
|
|
20283
|
+
/**
|
|
20284
|
+
* The co-signer key covenants are built against (33-byte compressed),
|
|
20285
|
+
* present only when an emulator is configured.
|
|
20286
|
+
*
|
|
20287
|
+
* Resolved from the network — or from `emulatorPubkey` — never from the
|
|
20288
|
+
* emulator's own report. When a claim is refused because the co-signer
|
|
20289
|
+
* disagrees, compare `hex.encode(arkade.emulatorKey)` against the
|
|
20290
|
+
* `signerPubkey` your emulator serves on `/v1/info`: if they differ, the
|
|
20291
|
+
* network rotated and this SDK's pin is stale.
|
|
20292
|
+
*/
|
|
20175
20293
|
emulatorKey;
|
|
20176
20294
|
checkpoint;
|
|
20177
20295
|
indexer;
|
|
@@ -20196,11 +20314,11 @@ var Arkade = class _Arkade {
|
|
|
20196
20314
|
static async connect(opts) {
|
|
20197
20315
|
const info = await opts.arkade.getInfo();
|
|
20198
20316
|
const serverKey = base.hex.decode(info.signerPubkey).slice(1);
|
|
20199
|
-
const checkpoint =
|
|
20317
|
+
const checkpoint = chunkDSTYXT2D_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
20318
|
+
const network = opts.network ?? chunkDSTYXT2D_cjs.DEFAULT_NETWORK;
|
|
20200
20319
|
let emulatorKey;
|
|
20201
20320
|
if (opts.emulator) {
|
|
20202
|
-
|
|
20203
|
-
emulatorKey = base.hex.decode(eInfo.signerPubkey);
|
|
20321
|
+
emulatorKey = base.hex.decode(chunkDSTYXT2D_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
|
|
20204
20322
|
}
|
|
20205
20323
|
let userKey;
|
|
20206
20324
|
if (opts.identity) {
|
|
@@ -20210,7 +20328,7 @@ var Arkade = class _Arkade {
|
|
|
20210
20328
|
return new _Arkade({
|
|
20211
20329
|
arkProvider: opts.arkade,
|
|
20212
20330
|
emulator: opts.emulator,
|
|
20213
|
-
network
|
|
20331
|
+
network,
|
|
20214
20332
|
serverKey,
|
|
20215
20333
|
emulatorKey,
|
|
20216
20334
|
checkpoint,
|
|
@@ -20231,7 +20349,7 @@ var Arkade = class _Arkade {
|
|
|
20231
20349
|
* key respectively; explicit args always win.
|
|
20232
20350
|
*/
|
|
20233
20351
|
contract(program, args = {}) {
|
|
20234
|
-
const declared = (program.params ?? []).map(
|
|
20352
|
+
const declared = (program.params ?? []).map(chunk2XO43UHI_cjs.inputName);
|
|
20235
20353
|
if (declared.includes("server") && args.server === void 0) {
|
|
20236
20354
|
args = { ...args, server: this.serverKey };
|
|
20237
20355
|
}
|
|
@@ -20251,7 +20369,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
20251
20369
|
userKey: client.userKey,
|
|
20252
20370
|
emulatorKey: client.emulatorKey
|
|
20253
20371
|
};
|
|
20254
|
-
this.vtxoScript = new
|
|
20372
|
+
this.vtxoScript = new chunk2XO43UHI_cjs.ArkadeProgramScript(program, args, this.keys);
|
|
20255
20373
|
this.tapTree = this.vtxoScript.encode();
|
|
20256
20374
|
this.compiled = this.vtxoScript.compiled;
|
|
20257
20375
|
}
|
|
@@ -20279,7 +20397,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
20279
20397
|
`ArkadeContract.fromContract: expected contract type 'arkade', got '${contract.type}'`
|
|
20280
20398
|
);
|
|
20281
20399
|
}
|
|
20282
|
-
const typed =
|
|
20400
|
+
const typed = chunk2XO43UHI_cjs.deserializeArkadeContractParams(contract.params);
|
|
20283
20401
|
return new _ArkadeContract(client, typed.program, typed.args, {
|
|
20284
20402
|
serverKey: typed.serverKey,
|
|
20285
20403
|
userKey: typed.userKey,
|
|
@@ -20320,7 +20438,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
20320
20438
|
toContractParams() {
|
|
20321
20439
|
return {
|
|
20322
20440
|
type: "arkade",
|
|
20323
|
-
params:
|
|
20441
|
+
params: chunk2XO43UHI_cjs.serializeArkadeContractParams({
|
|
20324
20442
|
program: this.program,
|
|
20325
20443
|
args: this.args,
|
|
20326
20444
|
serverKey: this.keys.serverKey,
|
|
@@ -20365,13 +20483,13 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
20365
20483
|
const [registered] = await manager.getContracts({ script: scriptHex });
|
|
20366
20484
|
if (registered) {
|
|
20367
20485
|
const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
|
|
20368
|
-
return (withVtxos?.vtxos ?? []).filter((v) => !
|
|
20486
|
+
return (withVtxos?.vtxos ?? []).filter((v) => !chunkDSTYXT2D_cjs.hasTerminalSpend(v));
|
|
20369
20487
|
}
|
|
20370
20488
|
}
|
|
20371
20489
|
if (!this.client.indexer) {
|
|
20372
20490
|
throw new Error("ArkadeContract.getUtxos: an indexer is required");
|
|
20373
20491
|
}
|
|
20374
|
-
const { vtxos } = await
|
|
20492
|
+
const { vtxos } = await chunkDSTYXT2D_cjs.getNormalizedVtxos(this.client.indexer, {
|
|
20375
20493
|
scripts: [scriptHex],
|
|
20376
20494
|
spendableOnly: true
|
|
20377
20495
|
});
|
|
@@ -20473,12 +20591,12 @@ var ArkadeTransactionBuilder = class {
|
|
|
20473
20591
|
this.contract.client.checkpoint
|
|
20474
20592
|
);
|
|
20475
20593
|
if (coin.sourceTx) {
|
|
20476
|
-
|
|
20594
|
+
chunkDSTYXT2D_cjs.setArkPsbtField(arkTx, 0, chunkDSTYXT2D_cjs.PrevArkTxField, coin.sourceTx);
|
|
20477
20595
|
}
|
|
20478
20596
|
const condition = (def.tapscript.witness ?? []).map((w) => this.witnessBytes(w));
|
|
20479
20597
|
if (condition.length > 0) {
|
|
20480
|
-
|
|
20481
|
-
|
|
20598
|
+
chunkDSTYXT2D_cjs.setArkPsbtField(arkTx, 0, chunkDSTYXT2D_cjs.ConditionWitness, condition);
|
|
20599
|
+
chunkDSTYXT2D_cjs.setArkPsbtField(checkpoints[0], 0, chunkDSTYXT2D_cjs.ConditionWitness, condition);
|
|
20482
20600
|
}
|
|
20483
20601
|
const packets = [];
|
|
20484
20602
|
if (this.assetSpecs.length > 0) {
|
|
@@ -20517,7 +20635,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
20517
20635
|
base.base64.encode(signedArk2.toPSBT()),
|
|
20518
20636
|
signedCps.map((c) => base.base64.encode(c.toPSBT()))
|
|
20519
20637
|
);
|
|
20520
|
-
const txid =
|
|
20638
|
+
const txid = chunkDSTYXT2D_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
|
|
20521
20639
|
return {
|
|
20522
20640
|
txid,
|
|
20523
20641
|
signedArkTx: res2.signedArkTx,
|
|
@@ -20576,23 +20694,23 @@ var ArkadeTransactionBuilder = class {
|
|
|
20576
20694
|
}
|
|
20577
20695
|
buildAssetPacket() {
|
|
20578
20696
|
const groups = this.assetSpecs.map((s) => {
|
|
20579
|
-
const id = typeof s.assetId === "string" ?
|
|
20580
|
-
return
|
|
20697
|
+
const id = typeof s.assetId === "string" ? chunkV2KENVN6_cjs.AssetId.fromString(s.assetId) : chunkV2KENVN6_cjs.AssetId.fromBytes(s.assetId);
|
|
20698
|
+
return chunkV2KENVN6_cjs.AssetGroup.create(
|
|
20581
20699
|
id,
|
|
20582
20700
|
null,
|
|
20583
|
-
s.inputs.map((i) =>
|
|
20584
|
-
s.outputs.map((o) =>
|
|
20585
|
-
(s.metadata ?? []).map((m) =>
|
|
20701
|
+
s.inputs.map((i) => chunkV2KENVN6_cjs.AssetInput.create(i.vin, i.amount)),
|
|
20702
|
+
s.outputs.map((o) => chunkV2KENVN6_cjs.AssetOutput.create(o.vout, o.amount)),
|
|
20703
|
+
(s.metadata ?? []).map((m) => chunkV2KENVN6_cjs.Metadata.create(m.key, m.value))
|
|
20586
20704
|
);
|
|
20587
20705
|
});
|
|
20588
|
-
return
|
|
20706
|
+
return chunkV2KENVN6_cjs.Packet.create(groups);
|
|
20589
20707
|
}
|
|
20590
20708
|
witnessBytes(ref) {
|
|
20591
|
-
return
|
|
20709
|
+
return chunk2XO43UHI_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
|
|
20592
20710
|
}
|
|
20593
20711
|
};
|
|
20594
20712
|
function bindInputs(fn, callArgs) {
|
|
20595
|
-
const names = (fn.def.inputs ?? []).map(
|
|
20713
|
+
const names = (fn.def.inputs ?? []).map(chunk2XO43UHI_cjs.inputName);
|
|
20596
20714
|
if (callArgs.length !== names.length) {
|
|
20597
20715
|
throw new Error(`${fn.name}: expected ${names.length} argument(s), got ${callArgs.length}`);
|
|
20598
20716
|
}
|
|
@@ -20999,7 +21117,7 @@ function decodeArkContract(encoded) {
|
|
|
20999
21117
|
}
|
|
21000
21118
|
function contractFromArkContract(encoded, options = {}) {
|
|
21001
21119
|
const parsed = decodeArkContract(encoded);
|
|
21002
|
-
const handler =
|
|
21120
|
+
const handler = chunk2XO43UHI_cjs.contractHandlers.get(parsed.type);
|
|
21003
21121
|
if (!handler) {
|
|
21004
21122
|
throw new Error(`No handler registered for contract type '${parsed.type}'`);
|
|
21005
21123
|
}
|
|
@@ -21013,9 +21131,9 @@ function contractFromArkContract(encoded, options = {}) {
|
|
|
21013
21131
|
metadata: options.metadata
|
|
21014
21132
|
};
|
|
21015
21133
|
}
|
|
21016
|
-
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix =
|
|
21134
|
+
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkDSTYXT2D_cjs.DEFAULT_NETWORK.hrp, options = {}) {
|
|
21017
21135
|
const parsed = decodeArkContract(encoded);
|
|
21018
|
-
const handler =
|
|
21136
|
+
const handler = chunk2XO43UHI_cjs.contractHandlers.getOrThrow(parsed.type);
|
|
21019
21137
|
const params = parsed.data;
|
|
21020
21138
|
const vtxoScript = handler.createScript(params);
|
|
21021
21139
|
return {
|
|
@@ -21079,6 +21197,7 @@ exports.IndexedDBWalletRepository = IndexedDBWalletRepository;
|
|
|
21079
21197
|
exports.MESSAGE_BUS_INITIALIZING = MESSAGE_BUS_INITIALIZING;
|
|
21080
21198
|
exports.MESSAGE_BUS_NOT_INITIALIZED = MESSAGE_BUS_NOT_INITIALIZED;
|
|
21081
21199
|
exports.MIGRATION_KEY = MIGRATION_KEY;
|
|
21200
|
+
exports.MUTINYNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS = MUTINYNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS;
|
|
21082
21201
|
exports.MessageBus = MessageBus;
|
|
21083
21202
|
exports.MessageBusInitializingError = MessageBusInitializingError;
|
|
21084
21203
|
exports.MessageBusNotInitializedError = MessageBusNotInitializedError;
|
|
@@ -21098,6 +21217,7 @@ exports.ReadonlyWalletError = ReadonlyWalletError;
|
|
|
21098
21217
|
exports.RestDelegateProvider = RestDelegateProvider;
|
|
21099
21218
|
exports.RestDelegatorProvider = RestDelegatorProvider;
|
|
21100
21219
|
exports.RestEmulatorProvider = RestEmulatorProvider;
|
|
21220
|
+
exports.SIGNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS = SIGNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS;
|
|
21101
21221
|
exports.SeedIdentity = SeedIdentity;
|
|
21102
21222
|
exports.ServiceWorkerReadonlyWallet = ServiceWorkerReadonlyWallet;
|
|
21103
21223
|
exports.ServiceWorkerTimeoutError = ServiceWorkerTimeoutError;
|
|
@@ -21200,5 +21320,5 @@ exports.validateVtxoTxGraph = validateVtxoTxGraph;
|
|
|
21200
21320
|
exports.verifyTapscriptSignatures = verifyTapscriptSignatures;
|
|
21201
21321
|
exports.waitForIncomingFunds = waitForIncomingFunds;
|
|
21202
21322
|
exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
|
|
21203
|
-
//# sourceMappingURL=chunk-
|
|
21204
|
-
//# sourceMappingURL=chunk-
|
|
21323
|
+
//# sourceMappingURL=chunk-DYNB6POO.cjs.map
|
|
21324
|
+
//# sourceMappingURL=chunk-DYNB6POO.cjs.map
|