@arkade-os/sdk 0.4.58 → 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-ClaVUg4e.d.cts → ark-C9DsPSm8.d.cts} +72 -3
- package/dist/{ark-ClaVUg4e.d.ts → ark-C9DsPSm8.d.ts} +72 -3
- package/dist/{asyncStorageTaskQueue-Bgau-mvD.d.ts → asyncStorageTaskQueue-BwuWQ1Qc.d.ts} +1 -1
- package/dist/{asyncStorageTaskQueue-CnYrhpS-.d.cts → asyncStorageTaskQueue-CYHXFfvn.d.cts} +1 -1
- package/dist/{chunk-COLJARV4.cjs → chunk-2XO43UHI.cjs} +40 -40
- package/dist/{chunk-COLJARV4.cjs.map → chunk-2XO43UHI.cjs.map} +1 -1
- package/dist/{chunk-I4YEGI2R.cjs → chunk-7FA36NOA.cjs} +17 -17
- package/dist/{chunk-I4YEGI2R.cjs.map → chunk-7FA36NOA.cjs.map} +1 -1
- package/dist/{chunk-D6RGHPZ5.cjs → chunk-DSTYXT2D.cjs} +45 -10
- package/dist/chunk-DSTYXT2D.cjs.map +1 -0
- package/dist/{chunk-6PY4WYXI.cjs → chunk-DYNB6POO.cjs} +419 -390
- package/dist/chunk-DYNB6POO.cjs.map +1 -0
- package/dist/{chunk-VROHHJL4.js → chunk-FIMOVH25.js} +41 -11
- package/dist/chunk-FIMOVH25.js.map +1 -0
- package/dist/{chunk-SGWMB4W2.js → chunk-H342JPPZ.js} +4 -4
- package/dist/{chunk-SGWMB4W2.js.map → chunk-H342JPPZ.js.map} +1 -1
- package/dist/{chunk-SYZEQF5D.cjs → chunk-IPFGYVF3.cjs} +9 -9
- package/dist/{chunk-SYZEQF5D.cjs.map → chunk-IPFGYVF3.cjs.map} +1 -1
- package/dist/{chunk-S3BFUTC5.js → chunk-OVSNY3HC.js} +44 -17
- package/dist/chunk-OVSNY3HC.js.map +1 -0
- package/dist/{chunk-IPPASJE5.js → chunk-PN5RD7ZI.js} +3 -3
- package/dist/{chunk-IPPASJE5.js.map → chunk-PN5RD7ZI.js.map} +1 -1
- package/dist/{chunk-F4C67JYB.cjs → chunk-V2KENVN6.cjs} +15 -15
- package/dist/{chunk-F4C67JYB.cjs.map → chunk-V2KENVN6.cjs.map} +1 -1
- package/dist/{chunk-AGWZXGG2.js → chunk-VSHY5TBY.js} +4 -4
- package/dist/{chunk-AGWZXGG2.js.map → chunk-VSHY5TBY.js.map} +1 -1
- package/dist/{chunk-TV2RLVOB.js → chunk-YEHGCHIL.js} +3 -3
- package/dist/{chunk-TV2RLVOB.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-YDYq1El_.d.ts → delegate-B_oKWm1k.d.ts} +1 -1
- package/dist/{delegate-CVrkEepn.d.cts → delegate-D0eGaz3J.d.cts} +1 -1
- package/dist/{index-BmqkJBAf.d.cts → index-BG2AL2Ie.d.cts} +2 -2
- package/dist/{index-CuSHBkq7.d.ts → index-BmK6tEqf.d.ts} +2 -2
- package/dist/index.cjs +251 -223
- package/dist/index.d.cts +33 -11
- package/dist/index.d.ts +33 -11
- 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-CFkGkD85.d.cts → taskRunner-CBvKIttE.d.cts} +1 -1
- package/dist/{taskRunner-CFN61bBM.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-DnK09TtT.d.ts → wallet-DlXemAzP.d.cts} +24 -3
- package/dist/{wallet-hQp2qC_M.d.cts → 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 +6 -1
- package/dist/chunk-6PY4WYXI.cjs.map +0 -1
- package/dist/chunk-D6RGHPZ5.cjs.map +0 -1
- package/dist/chunk-S3BFUTC5.js.map +0 -1
- package/dist/chunk-VROHHJL4.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
|
};
|
|
@@ -3123,7 +3141,7 @@ function priceSettlementInputs(vtxos, estimator) {
|
|
|
3123
3141
|
const payable = [];
|
|
3124
3142
|
const net = /* @__PURE__ */ new Map();
|
|
3125
3143
|
for (const vtxo of vtxos) {
|
|
3126
|
-
const inputFee = estimator.evalOffchainInput(
|
|
3144
|
+
const inputFee = estimator.evalOffchainInput(chunkDSTYXT2D_cjs.toOffchainInputFeeParams(vtxo));
|
|
3127
3145
|
if (inputFee.satoshis >= vtxo.value) {
|
|
3128
3146
|
continue;
|
|
3129
3147
|
}
|
|
@@ -3149,7 +3167,7 @@ function deductOffchainOutputFee(subtotal, estimator, arkAddress) {
|
|
|
3149
3167
|
}
|
|
3150
3168
|
const outputFee = estimator.evalOffchainOutput({
|
|
3151
3169
|
amount: subtotal,
|
|
3152
|
-
script: base.hex.encode(
|
|
3170
|
+
script: base.hex.encode(chunkDSTYXT2D_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
3153
3171
|
});
|
|
3154
3172
|
return subtotal - BigInt(outputFee.satoshis);
|
|
3155
3173
|
}
|
|
@@ -3167,10 +3185,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
|
|
|
3167
3185
|
};
|
|
3168
3186
|
function getRecoverableVtxos(vtxos, dustAmount, now) {
|
|
3169
3187
|
return vtxos.filter((vtxo) => {
|
|
3170
|
-
if (
|
|
3188
|
+
if (chunkDSTYXT2D_cjs.canRecoverOnchain(vtxo, now)) {
|
|
3171
3189
|
return true;
|
|
3172
3190
|
}
|
|
3173
|
-
if (
|
|
3191
|
+
if (chunkDSTYXT2D_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
|
|
3174
3192
|
return true;
|
|
3175
3193
|
}
|
|
3176
3194
|
return false;
|
|
@@ -3201,7 +3219,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
|
|
|
3201
3219
|
}
|
|
3202
3220
|
function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
3203
3221
|
const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
|
|
3204
|
-
const expiresAt =
|
|
3222
|
+
const expiresAt = chunkDSTYXT2D_cjs.normalizeVtxo(vtxo).expiresAt;
|
|
3205
3223
|
if (expiresAt === void 0) return false;
|
|
3206
3224
|
const now = Date.now();
|
|
3207
3225
|
const batchExpiry = expiresAt.getTime();
|
|
@@ -3210,7 +3228,7 @@ function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
|
3210
3228
|
}
|
|
3211
3229
|
function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
|
|
3212
3230
|
return vtxos.filter(
|
|
3213
|
-
(vtxo) => isVtxoExpiringSoon(vtxo, thresholdMs) ||
|
|
3231
|
+
(vtxo) => isVtxoExpiringSoon(vtxo, thresholdMs) || chunkDSTYXT2D_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount)
|
|
3214
3232
|
);
|
|
3215
3233
|
}
|
|
3216
3234
|
function isMigrationCapable(wallet) {
|
|
@@ -3745,11 +3763,11 @@ var VtxoManager = class _VtxoManager {
|
|
|
3745
3763
|
`Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
|
|
3746
3764
|
);
|
|
3747
3765
|
}
|
|
3748
|
-
const tx = new
|
|
3766
|
+
const tx = new chunkDSTYXT2D_cjs.Transaction();
|
|
3749
3767
|
for (const utxo of expiredUtxos) {
|
|
3750
|
-
const utxoScript =
|
|
3768
|
+
const utxoScript = chunkDSTYXT2D_cjs.VtxoScript.decode(utxo.tapTree);
|
|
3751
3769
|
const utxoExitLeaf = utxoScript.leaves.find(
|
|
3752
|
-
(leaf) =>
|
|
3770
|
+
(leaf) => chunkDSTYXT2D_cjs.CSVMultisigTapscript.isScriptValid(chunkDSTYXT2D_cjs.scriptFromTapLeafScript(leaf)) === true
|
|
3753
3771
|
);
|
|
3754
3772
|
if (!utxoExitLeaf) {
|
|
3755
3773
|
throw new Error(
|
|
@@ -3764,7 +3782,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
3764
3782
|
amount: BigInt(utxo.value)
|
|
3765
3783
|
},
|
|
3766
3784
|
tapLeafScript: [utxoExitLeaf],
|
|
3767
|
-
sequence:
|
|
3785
|
+
sequence: chunkDSTYXT2D_cjs.getSequence(utxoExitLeaf)
|
|
3768
3786
|
});
|
|
3769
3787
|
}
|
|
3770
3788
|
tx.addOutputAddress(boardingAddress, outputAmount, this.getNetwork());
|
|
@@ -3998,8 +4016,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
3998
4016
|
if (!serverPubKey) continue;
|
|
3999
4017
|
const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
|
|
4000
4018
|
if (cls.status === "CURRENT") continue;
|
|
4001
|
-
const recoverable = vtxos.filter((v) => v.isSwept && !
|
|
4002
|
-
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);
|
|
4003
4021
|
const value = spendable.reduce((sum, v) => sum + v.value, 0);
|
|
4004
4022
|
let recoverableCount = 0;
|
|
4005
4023
|
let recoverableValue = 0;
|
|
@@ -4012,7 +4030,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4012
4030
|
awaitingSweepCount = spendable.length;
|
|
4013
4031
|
awaitingSweepValue = value;
|
|
4014
4032
|
for (const v of spendable) {
|
|
4015
|
-
const exp =
|
|
4033
|
+
const exp = chunkDSTYXT2D_cjs.toBatchExpiry(v);
|
|
4016
4034
|
if (exp !== void 0 && (nextSweepEta === void 0 || exp < nextSweepEta)) {
|
|
4017
4035
|
nextSweepEta = exp;
|
|
4018
4036
|
}
|
|
@@ -4273,7 +4291,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4273
4291
|
/** Decodes the boarding tapscript exit path to extract the CSV timelock. */
|
|
4274
4292
|
getBoardingTimelock() {
|
|
4275
4293
|
const wallet = this.getSweepWallet();
|
|
4276
|
-
const exitScript =
|
|
4294
|
+
const exitScript = chunkDSTYXT2D_cjs.CSVMultisigTapscript.decode(
|
|
4277
4295
|
base.hex.decode(wallet.boardingTapscript.exitScript)
|
|
4278
4296
|
);
|
|
4279
4297
|
return exitScript.params.timelock;
|
|
@@ -4404,8 +4422,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
4404
4422
|
* or doesn't carry the metadata.
|
|
4405
4423
|
*/
|
|
4406
4424
|
extractSpentOutpoint(error) {
|
|
4407
|
-
const ark =
|
|
4408
|
-
if (!
|
|
4425
|
+
const ark = chunkDSTYXT2D_cjs.maybeArkError(error);
|
|
4426
|
+
if (!chunkDSTYXT2D_cjs.isArkError(ark, chunkDSTYXT2D_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
|
|
4409
4427
|
const raw = ark.metadata?.vtxo_outpoint;
|
|
4410
4428
|
if (typeof raw !== "string") return void 0;
|
|
4411
4429
|
const [txid, voutStr] = raw.split(":");
|
|
@@ -4595,7 +4613,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4595
4613
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
4596
4614
|
break;
|
|
4597
4615
|
}
|
|
4598
|
-
const inputFee = estimator.evalOffchainInput(
|
|
4616
|
+
const inputFee = estimator.evalOffchainInput(chunkDSTYXT2D_cjs.toOffchainInputFeeParams(v));
|
|
4599
4617
|
if (inputFee.satoshis >= v.value) {
|
|
4600
4618
|
continue;
|
|
4601
4619
|
}
|
|
@@ -4615,7 +4633,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4615
4633
|
const arkAddress = await this.wallet.getAddress();
|
|
4616
4634
|
const outputFee = estimator.evalOffchainOutput({
|
|
4617
4635
|
amount: totalAmount,
|
|
4618
|
-
script: base.hex.encode(
|
|
4636
|
+
script: base.hex.encode(chunkDSTYXT2D_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
4619
4637
|
});
|
|
4620
4638
|
totalAmount -= BigInt(outputFee.satoshis);
|
|
4621
4639
|
if (totalAmount < dustAmount) return;
|
|
@@ -4695,7 +4713,7 @@ var ArkNote = class _ArkNote {
|
|
|
4695
4713
|
this.value = value;
|
|
4696
4714
|
this.HRP = HRP;
|
|
4697
4715
|
const preimageHash = utils_js.sha256(this.preimage);
|
|
4698
|
-
this.vtxoScript = new
|
|
4716
|
+
this.vtxoScript = new chunkDSTYXT2D_cjs.VtxoScript([noteTapscript(preimageHash)]);
|
|
4699
4717
|
const leaf = this.vtxoScript.leaves[0];
|
|
4700
4718
|
this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
|
|
4701
4719
|
this.tapTree = this.vtxoScript.encode();
|
|
@@ -4862,7 +4880,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
4862
4880
|
const privateKey = data.slice(1, 33);
|
|
4863
4881
|
const serverPubKey = data.slice(33, 65);
|
|
4864
4882
|
const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
|
|
4865
|
-
const csvTimelock =
|
|
4883
|
+
const csvTimelock = chunkDSTYXT2D_cjs.sequenceToTimelock(sequence);
|
|
4866
4884
|
return new _ArkadeCash(privateKey, serverPubKey, csvTimelock, decoded.prefix);
|
|
4867
4885
|
}
|
|
4868
4886
|
toString() {
|
|
@@ -4870,7 +4888,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
4870
4888
|
data[0] = _ArkadeCash.Version;
|
|
4871
4889
|
data.set(this._privateKey, 1);
|
|
4872
4890
|
data.set(this._serverPubKey, 33);
|
|
4873
|
-
const sequence =
|
|
4891
|
+
const sequence = chunkDSTYXT2D_cjs.timelockToSequence(this.csvTimelock);
|
|
4874
4892
|
new DataView(data.buffer, data.byteOffset + 65, 4).setUint32(0, sequence, false);
|
|
4875
4893
|
const words = base.bech32m.toWords(data);
|
|
4876
4894
|
return base.bech32m.encode(this.hrp, words, 1023);
|
|
@@ -4879,7 +4897,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
4879
4897
|
return SingleKey.fromPrivateKey(this._privateKey);
|
|
4880
4898
|
}
|
|
4881
4899
|
get vtxoScript() {
|
|
4882
|
-
return new
|
|
4900
|
+
return new chunk2XO43UHI_cjs.DefaultVtxo.Script({
|
|
4883
4901
|
pubKey: this._publicKey,
|
|
4884
4902
|
serverPubKey: this._serverPubKey,
|
|
4885
4903
|
csvTimelock: this.csvTimelock
|
|
@@ -5140,7 +5158,7 @@ async function captureExitBranch(params) {
|
|
|
5140
5158
|
const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
|
|
5141
5159
|
if (nonCommitment.length > 0) {
|
|
5142
5160
|
for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
|
|
5143
|
-
psbtByTxid.set(
|
|
5161
|
+
psbtByTxid.set(chunkDSTYXT2D_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
5144
5162
|
}
|
|
5145
5163
|
}
|
|
5146
5164
|
}
|
|
@@ -5183,10 +5201,10 @@ var IndexerExitDataSource = class {
|
|
|
5183
5201
|
while (hasMore) {
|
|
5184
5202
|
const { chain: page, page: meta } = await this.indexer.getVtxoChain(
|
|
5185
5203
|
{ txid: vtxo.txid, vout: vtxo.vout },
|
|
5186
|
-
{ pageIndex, pageSize:
|
|
5204
|
+
{ pageIndex, pageSize: chunkDSTYXT2D_cjs.DEFAULT_PAGE_SIZE }
|
|
5187
5205
|
);
|
|
5188
5206
|
chain.push(...page);
|
|
5189
|
-
hasMore = meta ? page.length ===
|
|
5207
|
+
hasMore = meta ? page.length === chunkDSTYXT2D_cjs.DEFAULT_PAGE_SIZE : false;
|
|
5190
5208
|
pageIndex++;
|
|
5191
5209
|
}
|
|
5192
5210
|
return chain;
|
|
@@ -5198,12 +5216,12 @@ var IndexerExitDataSource = class {
|
|
|
5198
5216
|
while (hasMore) {
|
|
5199
5217
|
const { txs, page } = await this.indexer.getVirtualTxs(txids, {
|
|
5200
5218
|
pageIndex,
|
|
5201
|
-
pageSize:
|
|
5219
|
+
pageSize: chunkDSTYXT2D_cjs.DEFAULT_PAGE_SIZE
|
|
5202
5220
|
});
|
|
5203
5221
|
for (const psbt of txs) {
|
|
5204
|
-
out.set(
|
|
5222
|
+
out.set(chunkDSTYXT2D_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
5205
5223
|
}
|
|
5206
|
-
hasMore = page ? txs.length ===
|
|
5224
|
+
hasMore = page ? txs.length === chunkDSTYXT2D_cjs.DEFAULT_PAGE_SIZE : false;
|
|
5207
5225
|
pageIndex++;
|
|
5208
5226
|
}
|
|
5209
5227
|
return out;
|
|
@@ -5224,7 +5242,7 @@ function chainedTxTypeToChainTxType(t) {
|
|
|
5224
5242
|
}
|
|
5225
5243
|
}
|
|
5226
5244
|
function psbtInputTxids(psbtBase64) {
|
|
5227
|
-
const tx =
|
|
5245
|
+
const tx = chunkDSTYXT2D_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
5228
5246
|
const ids = [];
|
|
5229
5247
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
5230
5248
|
const txid = tx.getInput(i).txid;
|
|
@@ -5577,10 +5595,10 @@ async function resolveArkInfo(arkProvider, walletRepository) {
|
|
|
5577
5595
|
try {
|
|
5578
5596
|
info = await arkProvider.getInfo();
|
|
5579
5597
|
} catch (err) {
|
|
5580
|
-
if (!
|
|
5598
|
+
if (!chunkDSTYXT2D_cjs.isRetryableProviderError(err)) throw err;
|
|
5581
5599
|
const snapshot = await loadArkInfoSnapshot(walletRepository);
|
|
5582
5600
|
if (!snapshot) {
|
|
5583
|
-
throw new
|
|
5601
|
+
throw new chunkDSTYXT2D_cjs.ProviderUnavailableError(
|
|
5584
5602
|
"Arkade server info is unavailable and no cached snapshot exists",
|
|
5585
5603
|
{ cause: err }
|
|
5586
5604
|
);
|
|
@@ -5963,7 +5981,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos) {
|
|
|
5963
5981
|
return [...txids];
|
|
5964
5982
|
}
|
|
5965
5983
|
async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt) {
|
|
5966
|
-
const fromOldestVtxo = vtxos.map(
|
|
5984
|
+
const fromOldestVtxo = vtxos.map(chunkDSTYXT2D_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
5967
5985
|
const txidsNeedingCreatedAt = resolveTxCreatedAt ? collectArkTxidsNeedingCreatedAt(fromOldestVtxo) : [];
|
|
5968
5986
|
const resolvedCreatedAt = resolveTxCreatedAt && txidsNeedingCreatedAt.length > 0 ? await resolveTxCreatedAt(txidsNeedingCreatedAt) : /* @__PURE__ */ new Map();
|
|
5969
5987
|
const unmatchedSettledBoardingTxs = allBoardingTxs.filter(isSettledBoardingReceive).sort((a, b) => a.createdAt - b.createdAt);
|
|
@@ -6127,7 +6145,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6127
6145
|
const virtualCoins = await this.wallet.getVtxos({
|
|
6128
6146
|
withRecoverable: false
|
|
6129
6147
|
});
|
|
6130
|
-
const controlAssetRef = params.controlAssetId ?
|
|
6148
|
+
const controlAssetRef = params.controlAssetId ? chunkV2KENVN6_cjs.AssetRef.fromId(chunkV2KENVN6_cjs.AssetId.fromString(params.controlAssetId)) : null;
|
|
6131
6149
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
6132
6150
|
let totalBtcSelected = 0n;
|
|
6133
6151
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -6140,8 +6158,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6140
6158
|
}
|
|
6141
6159
|
}
|
|
6142
6160
|
const groups = [];
|
|
6143
|
-
const issuedAssetOutput =
|
|
6144
|
-
const issuedAssetGroup =
|
|
6161
|
+
const issuedAssetOutput = chunkV2KENVN6_cjs.AssetOutput.create(0, params.amount);
|
|
6162
|
+
const issuedAssetGroup = chunkV2KENVN6_cjs.AssetGroup.create(
|
|
6145
6163
|
null,
|
|
6146
6164
|
controlAssetRef,
|
|
6147
6165
|
[],
|
|
@@ -6156,28 +6174,28 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6156
6174
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6157
6175
|
for (const asset of assets) {
|
|
6158
6176
|
if (asset.assetId !== assetId) continue;
|
|
6159
|
-
changeInputs.push(
|
|
6177
|
+
changeInputs.push(chunkV2KENVN6_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6160
6178
|
}
|
|
6161
6179
|
}
|
|
6162
6180
|
groups.push(
|
|
6163
|
-
|
|
6164
|
-
|
|
6181
|
+
chunkV2KENVN6_cjs.AssetGroup.create(
|
|
6182
|
+
chunkV2KENVN6_cjs.AssetId.fromString(assetId),
|
|
6165
6183
|
null,
|
|
6166
6184
|
changeInputs,
|
|
6167
|
-
[
|
|
6185
|
+
[chunkV2KENVN6_cjs.AssetOutput.create(0, amount)],
|
|
6168
6186
|
[]
|
|
6169
6187
|
)
|
|
6170
6188
|
);
|
|
6171
6189
|
}
|
|
6172
6190
|
}
|
|
6173
6191
|
const address = await this.wallet.getAddress();
|
|
6174
|
-
const outputAddress =
|
|
6192
|
+
const outputAddress = chunkDSTYXT2D_cjs.ArkAddress.decode(address);
|
|
6175
6193
|
const outputs = [
|
|
6176
6194
|
{
|
|
6177
6195
|
script: outputAddress.pkScript,
|
|
6178
6196
|
amount: BigInt(totalBtcSelected)
|
|
6179
6197
|
},
|
|
6180
|
-
Extension.create([
|
|
6198
|
+
Extension.create([chunkV2KENVN6_cjs.Packet.create(groups)]).txOut()
|
|
6181
6199
|
];
|
|
6182
6200
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
|
|
6183
6201
|
coinSelection.inputs,
|
|
@@ -6185,7 +6203,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6185
6203
|
);
|
|
6186
6204
|
return {
|
|
6187
6205
|
arkTxId: arkTxid,
|
|
6188
|
-
assetId:
|
|
6206
|
+
assetId: chunkV2KENVN6_cjs.AssetId.create(arkTxid, 0).toString()
|
|
6189
6207
|
};
|
|
6190
6208
|
}
|
|
6191
6209
|
/**
|
|
@@ -6257,16 +6275,16 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6257
6275
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6258
6276
|
for (const asset of assets) {
|
|
6259
6277
|
if (asset.assetId !== params.assetId) continue;
|
|
6260
|
-
reissueInputs.push(
|
|
6278
|
+
reissueInputs.push(chunkV2KENVN6_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6261
6279
|
}
|
|
6262
6280
|
}
|
|
6263
6281
|
const totalAssetAmount = assetToReissueAmount + params.amount;
|
|
6264
|
-
const reissueAssetIdObj =
|
|
6265
|
-
const reissueAssetGroup =
|
|
6282
|
+
const reissueAssetIdObj = chunkV2KENVN6_cjs.AssetId.fromString(params.assetId);
|
|
6283
|
+
const reissueAssetGroup = chunkV2KENVN6_cjs.AssetGroup.create(
|
|
6266
6284
|
reissueAssetIdObj,
|
|
6267
6285
|
null,
|
|
6268
6286
|
reissueInputs,
|
|
6269
|
-
[
|
|
6287
|
+
[chunkV2KENVN6_cjs.AssetOutput.create(0, totalAssetAmount)],
|
|
6270
6288
|
[]
|
|
6271
6289
|
);
|
|
6272
6290
|
const groups = [reissueAssetGroup];
|
|
@@ -6275,27 +6293,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6275
6293
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6276
6294
|
for (const asset of assets) {
|
|
6277
6295
|
if (asset.assetId !== assetId) continue;
|
|
6278
|
-
changeInputs.push(
|
|
6296
|
+
changeInputs.push(chunkV2KENVN6_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6279
6297
|
}
|
|
6280
6298
|
}
|
|
6281
6299
|
groups.push(
|
|
6282
|
-
|
|
6283
|
-
|
|
6300
|
+
chunkV2KENVN6_cjs.AssetGroup.create(
|
|
6301
|
+
chunkV2KENVN6_cjs.AssetId.fromString(assetId),
|
|
6284
6302
|
null,
|
|
6285
6303
|
changeInputs,
|
|
6286
|
-
[
|
|
6304
|
+
[chunkV2KENVN6_cjs.AssetOutput.create(0, amount)],
|
|
6287
6305
|
[]
|
|
6288
6306
|
)
|
|
6289
6307
|
);
|
|
6290
6308
|
}
|
|
6291
6309
|
const address = await this.wallet.getAddress();
|
|
6292
|
-
const outputAddress =
|
|
6310
|
+
const outputAddress = chunkDSTYXT2D_cjs.ArkAddress.decode(address);
|
|
6293
6311
|
const outputs = [
|
|
6294
6312
|
{
|
|
6295
6313
|
script: outputAddress.pkScript,
|
|
6296
6314
|
amount: BigInt(totalBtcSelected)
|
|
6297
6315
|
},
|
|
6298
|
-
Extension.create([
|
|
6316
|
+
Extension.create([chunkV2KENVN6_cjs.Packet.create(groups)]).txOut()
|
|
6299
6317
|
];
|
|
6300
6318
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
6301
6319
|
return arkTxid;
|
|
@@ -6362,27 +6380,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6362
6380
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6363
6381
|
for (const asset of assets) {
|
|
6364
6382
|
if (asset.assetId !== assetId) continue;
|
|
6365
|
-
changeInputs.push(
|
|
6383
|
+
changeInputs.push(chunkV2KENVN6_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6366
6384
|
}
|
|
6367
6385
|
}
|
|
6368
6386
|
groups.push(
|
|
6369
|
-
|
|
6370
|
-
|
|
6387
|
+
chunkV2KENVN6_cjs.AssetGroup.create(
|
|
6388
|
+
chunkV2KENVN6_cjs.AssetId.fromString(assetId),
|
|
6371
6389
|
null,
|
|
6372
6390
|
changeInputs,
|
|
6373
|
-
amount > 0n ? [
|
|
6391
|
+
amount > 0n ? [chunkV2KENVN6_cjs.AssetOutput.create(0, amount)] : [],
|
|
6374
6392
|
[]
|
|
6375
6393
|
)
|
|
6376
6394
|
);
|
|
6377
6395
|
}
|
|
6378
6396
|
const address = await this.wallet.getAddress();
|
|
6379
|
-
const outputAddress =
|
|
6397
|
+
const outputAddress = chunkDSTYXT2D_cjs.ArkAddress.decode(address);
|
|
6380
6398
|
const outputs = [
|
|
6381
6399
|
{
|
|
6382
6400
|
script: outputAddress.pkScript,
|
|
6383
6401
|
amount: BigInt(totalBtcSelected)
|
|
6384
6402
|
},
|
|
6385
|
-
Extension.create([
|
|
6403
|
+
Extension.create([chunkV2KENVN6_cjs.Packet.create(groups)]).txOut()
|
|
6386
6404
|
];
|
|
6387
6405
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
6388
6406
|
return arkTxid;
|
|
@@ -6407,7 +6425,7 @@ function castMetadata(metadata) {
|
|
|
6407
6425
|
} else {
|
|
6408
6426
|
throw new Error("Invalid metadata value type");
|
|
6409
6427
|
}
|
|
6410
|
-
md.push(
|
|
6428
|
+
md.push(chunkV2KENVN6_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
|
|
6411
6429
|
}
|
|
6412
6430
|
return md;
|
|
6413
6431
|
}
|
|
@@ -6428,10 +6446,10 @@ var DelegateManagerImpl = class {
|
|
|
6428
6446
|
if (vtxos.length === 0) {
|
|
6429
6447
|
return { delegated: [], failed: [] };
|
|
6430
6448
|
}
|
|
6431
|
-
const destinationScript =
|
|
6449
|
+
const destinationScript = chunkDSTYXT2D_cjs.ArkAddress.decode(destination).pkScript;
|
|
6432
6450
|
const arkInfo = await this.arkInfoProvider.getInfo();
|
|
6433
6451
|
const delegateInfo = await this.delegateProvider.getDelegateInfo();
|
|
6434
|
-
const eligible = vtxos.map(
|
|
6452
|
+
const eligible = vtxos.map(chunkDSTYXT2D_cjs.normalizeVtxo).filter(
|
|
6435
6453
|
(v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
|
|
6436
6454
|
);
|
|
6437
6455
|
if (eligible.length === 0) {
|
|
@@ -6460,11 +6478,11 @@ var DelegateManagerImpl = class {
|
|
|
6460
6478
|
const groupByExpiry = /* @__PURE__ */ new Map();
|
|
6461
6479
|
let recoverableVtxos = [];
|
|
6462
6480
|
for (const vtxo of eligible) {
|
|
6463
|
-
if (
|
|
6481
|
+
if (chunkDSTYXT2D_cjs.canRecoverOnchain(vtxo, now)) {
|
|
6464
6482
|
recoverableVtxos.push(vtxo);
|
|
6465
6483
|
continue;
|
|
6466
6484
|
}
|
|
6467
|
-
const expiry =
|
|
6485
|
+
const expiry = chunkDSTYXT2D_cjs.toBatchExpiry(vtxo);
|
|
6468
6486
|
if (!expiry) continue;
|
|
6469
6487
|
const dayKey = getDayTimestamp(expiry);
|
|
6470
6488
|
groupByExpiry.set(dayKey, [...groupByExpiry.get(dayKey) ?? [], vtxo]);
|
|
@@ -6529,7 +6547,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6529
6547
|
}
|
|
6530
6548
|
if (!delegateAt) {
|
|
6531
6549
|
const now = { timestamp: /* @__PURE__ */ new Date() };
|
|
6532
|
-
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);
|
|
6533
6551
|
if (!expiryTimestamp || expiryTimestamp === Number.MAX_SAFE_INTEGER) {
|
|
6534
6552
|
delegateAt = new Date(Date.now() + 1 * 60 * 1e3);
|
|
6535
6553
|
} else {
|
|
@@ -6558,7 +6576,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6558
6576
|
let amount = 0n;
|
|
6559
6577
|
for (const coin of vtxos) {
|
|
6560
6578
|
const inputFee = estimator.evalOffchainInput({
|
|
6561
|
-
...
|
|
6579
|
+
...chunkDSTYXT2D_cjs.toOffchainInputFeeParams(coin),
|
|
6562
6580
|
type: "vtxo"
|
|
6563
6581
|
});
|
|
6564
6582
|
if (inputFee.value >= coin.value) {
|
|
@@ -6572,7 +6590,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6572
6590
|
const delegateFee = BigInt(Number(fee));
|
|
6573
6591
|
if (delegateFee > 0n) {
|
|
6574
6592
|
outputs.push({
|
|
6575
|
-
script:
|
|
6593
|
+
script: chunkDSTYXT2D_cjs.ArkAddress.decode(delegateAddress).pkScript,
|
|
6576
6594
|
amount: delegateFee
|
|
6577
6595
|
});
|
|
6578
6596
|
}
|
|
@@ -6605,10 +6623,10 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6605
6623
|
destinationScript
|
|
6606
6624
|
);
|
|
6607
6625
|
const forfeitOutputScript = btcSigner.OutScript.encode(
|
|
6608
|
-
btcSigner.Address(
|
|
6626
|
+
btcSigner.Address(chunkDSTYXT2D_cjs.getNetwork(network)).decode(forfeitAddress)
|
|
6609
6627
|
);
|
|
6610
6628
|
const forfeits = await Promise.all(
|
|
6611
|
-
vtxos.filter((v) => !
|
|
6629
|
+
vtxos.filter((v) => !chunkDSTYXT2D_cjs.canRecoverOnchain(v, { timestamp: /* @__PURE__ */ new Date() })).map(async (coin) => {
|
|
6612
6630
|
const forfeit = await makeDelegateForfeitTx(
|
|
6613
6631
|
coin,
|
|
6614
6632
|
dust,
|
|
@@ -6633,7 +6651,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
|
|
|
6633
6651
|
index: input.vout,
|
|
6634
6652
|
witnessUtxo: {
|
|
6635
6653
|
amount: BigInt(input.value),
|
|
6636
|
-
script:
|
|
6654
|
+
script: chunkDSTYXT2D_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
6637
6655
|
},
|
|
6638
6656
|
sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
|
|
6639
6657
|
tapLeafScript: [delegateTapLeaf]
|
|
@@ -6691,7 +6709,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
6691
6709
|
expire_at: 0,
|
|
6692
6710
|
cosigners_public_keys: cosignerPubKeys
|
|
6693
6711
|
};
|
|
6694
|
-
const proof =
|
|
6712
|
+
const proof = chunkDSTYXT2D_cjs.Intent.create(message, coins, outputs);
|
|
6695
6713
|
const signedProof = await identity.sign(proof);
|
|
6696
6714
|
return {
|
|
6697
6715
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -6709,10 +6727,10 @@ function getDayTimestamp(timestamp) {
|
|
|
6709
6727
|
function findDelegateTapLeaf(vtxo, delegatePubkey) {
|
|
6710
6728
|
if (!vtxo.tapTree) return void 0;
|
|
6711
6729
|
const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
|
|
6712
|
-
const vtxoScript =
|
|
6730
|
+
const vtxoScript = chunkDSTYXT2D_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
6713
6731
|
return vtxoScript.leaves.find((tapLeaf) => {
|
|
6714
|
-
const arkTapscript =
|
|
6715
|
-
if (!
|
|
6732
|
+
const arkTapscript = chunkDSTYXT2D_cjs.decodeTapscript(chunkDSTYXT2D_cjs.scriptFromTapLeafScript(tapLeaf));
|
|
6733
|
+
if (!chunkDSTYXT2D_cjs.MultisigTapscript.is(arkTapscript)) return false;
|
|
6716
6734
|
return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
|
|
6717
6735
|
});
|
|
6718
6736
|
}
|
|
@@ -6900,7 +6918,7 @@ async function closeDatabase(dbName) {
|
|
|
6900
6918
|
return true;
|
|
6901
6919
|
}
|
|
6902
6920
|
function scriptFromArkAddress(address) {
|
|
6903
|
-
return base.hex.encode(
|
|
6921
|
+
return base.hex.encode(chunkDSTYXT2D_cjs.ArkAddress.decode(address).pkScript);
|
|
6904
6922
|
}
|
|
6905
6923
|
|
|
6906
6924
|
// src/repositories/indexedDB/schema.ts
|
|
@@ -7397,7 +7415,7 @@ function validateVtxosForScript(vtxos, script, context) {
|
|
|
7397
7415
|
}
|
|
7398
7416
|
async function getVtxosForContract(repo, contract) {
|
|
7399
7417
|
const vtxos = repo.getVtxosForScript ? await repo.getVtxosForScript(contract.script) : filterVtxosForScript(await repo.getVtxos(contract.address), contract.script);
|
|
7400
|
-
return vtxos.map(
|
|
7418
|
+
return vtxos.map(chunkDSTYXT2D_cjs.normalizeVtxo);
|
|
7401
7419
|
}
|
|
7402
7420
|
async function saveVtxosForContract(repo, contract, vtxos) {
|
|
7403
7421
|
if (repo.saveVtxosForScript) {
|
|
@@ -7601,7 +7619,7 @@ var deserializeTapLeaf = (t) => {
|
|
|
7601
7619
|
const s = base.hex.decode(t.s);
|
|
7602
7620
|
return [cb, s];
|
|
7603
7621
|
};
|
|
7604
|
-
var deserializeVtxo = (o) =>
|
|
7622
|
+
var deserializeVtxo = (o) => chunkDSTYXT2D_cjs.normalizeVtxo({
|
|
7605
7623
|
...o,
|
|
7606
7624
|
createdAt: new Date(o.createdAt),
|
|
7607
7625
|
tapTree: base.hex.decode(o.tapTree),
|
|
@@ -8740,7 +8758,7 @@ var ContractWatcher = class {
|
|
|
8740
8758
|
this.connectionState = "connected";
|
|
8741
8759
|
this.reconnectAttempts = 0;
|
|
8742
8760
|
this.listenLoop().catch((e) => {
|
|
8743
|
-
if (
|
|
8761
|
+
if (chunkDSTYXT2D_cjs.isEventSourceError(e)) {
|
|
8744
8762
|
console.debug("ContractWatcher subscription disconnected; reconnecting");
|
|
8745
8763
|
} else {
|
|
8746
8764
|
console.error(e);
|
|
@@ -8969,14 +8987,14 @@ var ContractWatcher = class {
|
|
|
8969
8987
|
const timestamp = Date.now();
|
|
8970
8988
|
if (update.newVtxos?.length) {
|
|
8971
8989
|
this.processSubscriptionVtxos(
|
|
8972
|
-
update.newVtxos.map(
|
|
8990
|
+
update.newVtxos.map(chunkDSTYXT2D_cjs.normalizeVtxo),
|
|
8973
8991
|
"vtxo_received",
|
|
8974
8992
|
timestamp
|
|
8975
8993
|
);
|
|
8976
8994
|
}
|
|
8977
8995
|
if (update.spentVtxos?.length) {
|
|
8978
8996
|
this.processSubscriptionVtxos(
|
|
8979
|
-
update.spentVtxos.map(
|
|
8997
|
+
update.spentVtxos.map(chunkDSTYXT2D_cjs.normalizeVtxo),
|
|
8980
8998
|
"vtxo_spent",
|
|
8981
8999
|
timestamp
|
|
8982
9000
|
);
|
|
@@ -9109,7 +9127,7 @@ async function reconcileIntents(deps) {
|
|
|
9109
9127
|
let vtxosByOutpoint = /* @__PURE__ */ new Map();
|
|
9110
9128
|
if (outpoints.length > 0) {
|
|
9111
9129
|
try {
|
|
9112
|
-
const { vtxos } = await
|
|
9130
|
+
const { vtxos } = await chunkDSTYXT2D_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
|
|
9113
9131
|
vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
|
|
9114
9132
|
} catch (e) {
|
|
9115
9133
|
console.error("reconcileIntents: failed to fetch input VTXO state", e);
|
|
@@ -9229,7 +9247,7 @@ var ContractManager = class _ContractManager {
|
|
|
9229
9247
|
await this.reconcileWatched();
|
|
9230
9248
|
this.markSyncOnline();
|
|
9231
9249
|
} catch (err) {
|
|
9232
|
-
if (!
|
|
9250
|
+
if (!chunkDSTYXT2D_cjs.isRetryableProviderError(err)) throw err;
|
|
9233
9251
|
this.markSyncDegraded(err);
|
|
9234
9252
|
}
|
|
9235
9253
|
this.initialized = true;
|
|
@@ -9341,7 +9359,7 @@ var ContractManager = class _ContractManager {
|
|
|
9341
9359
|
const from = Math.max(0, watermark - lookAhead.size);
|
|
9342
9360
|
const to = watermark + lookAhead.size;
|
|
9343
9361
|
const deps = lookAhead.candidateDeps();
|
|
9344
|
-
const handlers =
|
|
9362
|
+
const handlers = chunk2XO43UHI_cjs.contractHandlers.getRegisteredTypes().map((t) => chunk2XO43UHI_cjs.contractHandlers.get(t)).filter(hasCandidates);
|
|
9345
9363
|
const band = /* @__PURE__ */ new Map();
|
|
9346
9364
|
for (let index = from; index <= to; index++) {
|
|
9347
9365
|
const descriptor = lookAhead.materialize(index);
|
|
@@ -9352,7 +9370,7 @@ var ContractManager = class _ContractManager {
|
|
|
9352
9370
|
index,
|
|
9353
9371
|
params: {
|
|
9354
9372
|
...candidate,
|
|
9355
|
-
...
|
|
9373
|
+
...chunk2XO43UHI_cjs.speculativeReceiveMetadata(descriptor)
|
|
9356
9374
|
}
|
|
9357
9375
|
});
|
|
9358
9376
|
}
|
|
@@ -9412,7 +9430,7 @@ var ContractManager = class _ContractManager {
|
|
|
9412
9430
|
});
|
|
9413
9431
|
for (const entry of pending) entry.catchUpPending = false;
|
|
9414
9432
|
} catch (err) {
|
|
9415
|
-
if (!
|
|
9433
|
+
if (!chunkDSTYXT2D_cjs.isRetryableProviderError(err)) throw err;
|
|
9416
9434
|
this.markSyncDegraded(err);
|
|
9417
9435
|
}
|
|
9418
9436
|
}
|
|
@@ -9456,7 +9474,7 @@ var ContractManager = class _ContractManager {
|
|
|
9456
9474
|
await this.fetchContractVxosFromIndexer([contract]);
|
|
9457
9475
|
this.markSyncOnline();
|
|
9458
9476
|
} catch (err) {
|
|
9459
|
-
if (!
|
|
9477
|
+
if (!chunkDSTYXT2D_cjs.isRetryableProviderError(err)) throw err;
|
|
9460
9478
|
this.markSyncDegraded(err);
|
|
9461
9479
|
}
|
|
9462
9480
|
await this.watcher.addContract(contract);
|
|
@@ -9493,7 +9511,7 @@ var ContractManager = class _ContractManager {
|
|
|
9493
9511
|
return result;
|
|
9494
9512
|
}
|
|
9495
9513
|
async upsertContractRow(params) {
|
|
9496
|
-
const handler =
|
|
9514
|
+
const handler = chunk2XO43UHI_cjs.contractHandlers.get(params.type);
|
|
9497
9515
|
if (!handler) {
|
|
9498
9516
|
throw new Error(`No handler registered for contract type '${params.type}'`);
|
|
9499
9517
|
}
|
|
@@ -9593,7 +9611,7 @@ var ContractManager = class _ContractManager {
|
|
|
9593
9611
|
`scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
|
|
9594
9612
|
);
|
|
9595
9613
|
}
|
|
9596
|
-
const registered =
|
|
9614
|
+
const registered = chunk2XO43UHI_cjs.contractHandlers.getRegisteredTypes().map((t) => chunk2XO43UHI_cjs.contractHandlers.get(t)).filter(isDiscoverable);
|
|
9597
9615
|
const discoverables = [
|
|
9598
9616
|
...registered.filter((h) => h.type === "boarding"),
|
|
9599
9617
|
...registered.filter((h) => h.type !== "boarding")
|
|
@@ -9728,7 +9746,7 @@ var ContractManager = class _ContractManager {
|
|
|
9728
9746
|
await this.syncContracts({ contracts, pageSize });
|
|
9729
9747
|
this.markSyncOnline();
|
|
9730
9748
|
} catch (err) {
|
|
9731
|
-
if (!
|
|
9749
|
+
if (!chunkDSTYXT2D_cjs.isRetryableProviderError(err)) throw err;
|
|
9732
9750
|
this.markSyncDegraded(err);
|
|
9733
9751
|
}
|
|
9734
9752
|
const vtxos = await this.getVtxosForContracts(contracts);
|
|
@@ -9749,7 +9767,7 @@ var ContractManager = class _ContractManager {
|
|
|
9749
9767
|
}
|
|
9750
9768
|
const tapscriptCache = /* @__PURE__ */ new Map();
|
|
9751
9769
|
return vtxos.map(
|
|
9752
|
-
(vtxo) => extendVirtualCoinForContract(
|
|
9770
|
+
(vtxo) => extendVirtualCoinForContract(chunkDSTYXT2D_cjs.normalizeVtxo(vtxo), byScript, tapscriptCache)
|
|
9753
9771
|
);
|
|
9754
9772
|
}
|
|
9755
9773
|
buildContractsDbFilter(filter) {
|
|
@@ -9834,7 +9852,7 @@ var ContractManager = class _ContractManager {
|
|
|
9834
9852
|
const { contractScript, collaborative = true, walletPubKey, vtxo } = options;
|
|
9835
9853
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
9836
9854
|
if (!contract) return [];
|
|
9837
|
-
const handler =
|
|
9855
|
+
const handler = chunk2XO43UHI_cjs.contractHandlers.get(contract.type);
|
|
9838
9856
|
if (!handler) return [];
|
|
9839
9857
|
const script = handler.createScript(contract.params);
|
|
9840
9858
|
const context = {
|
|
@@ -9854,7 +9872,7 @@ var ContractManager = class _ContractManager {
|
|
|
9854
9872
|
const { contractScript, collaborative = true, walletPubKey } = options;
|
|
9855
9873
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
9856
9874
|
if (!contract) return [];
|
|
9857
|
-
const handler =
|
|
9875
|
+
const handler = chunk2XO43UHI_cjs.contractHandlers.get(contract.type);
|
|
9858
9876
|
if (!handler) return [];
|
|
9859
9877
|
const script = handler.createScript(contract.params);
|
|
9860
9878
|
const context = {
|
|
@@ -9910,7 +9928,7 @@ var ContractManager = class _ContractManager {
|
|
|
9910
9928
|
}
|
|
9911
9929
|
async refreshOutpoints(outpoints) {
|
|
9912
9930
|
if (outpoints.length === 0) return;
|
|
9913
|
-
const { vtxos } = await
|
|
9931
|
+
const { vtxos } = await chunkDSTYXT2D_cjs.getNormalizedVtxos(this.config.indexerProvider, {
|
|
9914
9932
|
outpoints
|
|
9915
9933
|
});
|
|
9916
9934
|
if (vtxos.length === 0) return;
|
|
@@ -9988,7 +10006,7 @@ var ContractManager = class _ContractManager {
|
|
|
9988
10006
|
break;
|
|
9989
10007
|
}
|
|
9990
10008
|
} catch (err) {
|
|
9991
|
-
if (!
|
|
10009
|
+
if (!chunkDSTYXT2D_cjs.isRetryableProviderError(err)) throw err;
|
|
9992
10010
|
this.markSyncDegraded(err);
|
|
9993
10011
|
}
|
|
9994
10012
|
this.emitEvent(event);
|
|
@@ -10037,7 +10055,7 @@ var ContractManager = class _ContractManager {
|
|
|
10037
10055
|
*/
|
|
10038
10056
|
async reconcilePendingFrontier(contracts) {
|
|
10039
10057
|
const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
|
|
10040
|
-
const vtxos = await
|
|
10058
|
+
const vtxos = await chunkDSTYXT2D_cjs.getAllNormalizedVtxos(
|
|
10041
10059
|
this.config.indexerProvider,
|
|
10042
10060
|
contracts.map((c) => c.script),
|
|
10043
10061
|
{ pendingOnly: true }
|
|
@@ -10118,7 +10136,7 @@ var ContractManager = class _ContractManager {
|
|
|
10118
10136
|
}
|
|
10119
10137
|
return result;
|
|
10120
10138
|
}
|
|
10121
|
-
async fetchContractVtxosBulk(contracts, pageSize =
|
|
10139
|
+
async fetchContractVtxosBulk(contracts, pageSize = chunkDSTYXT2D_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
|
|
10122
10140
|
if (contracts.length === 0) {
|
|
10123
10141
|
return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
|
|
10124
10142
|
}
|
|
@@ -10134,7 +10152,7 @@ var ContractManager = class _ContractManager {
|
|
|
10134
10152
|
before: syncWindow.before
|
|
10135
10153
|
}
|
|
10136
10154
|
} : {};
|
|
10137
|
-
const vtxos = await
|
|
10155
|
+
const vtxos = await chunkDSTYXT2D_cjs.getAllNormalizedVtxos(
|
|
10138
10156
|
this.config.indexerProvider,
|
|
10139
10157
|
contracts.map((c) => c.script),
|
|
10140
10158
|
{ ...windowOpts, pageSize }
|
|
@@ -10301,7 +10319,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
10301
10319
|
*/
|
|
10302
10320
|
materializeDescriptorAt(index) {
|
|
10303
10321
|
const descriptor = this.identity.descriptor;
|
|
10304
|
-
const network =
|
|
10322
|
+
const network = chunk2XO43UHI_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
10305
10323
|
const expansion = descriptorsScure.expand({ descriptor, network, index });
|
|
10306
10324
|
const keyInfo = expansion.expansionMap?.["@0"];
|
|
10307
10325
|
if (!keyInfo?.keyExpression) {
|
|
@@ -10445,7 +10463,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
10445
10463
|
const provider = await resolveDescriptorProvider(config, setup.walletRepository);
|
|
10446
10464
|
if (!provider) return void 0;
|
|
10447
10465
|
const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
|
|
10448
|
-
const expectedContractType = setup.offchainTapscript instanceof
|
|
10466
|
+
const expectedContractType = setup.offchainTapscript instanceof chunk2XO43UHI_cjs.DelegateVtxo.Script ? "delegate" : "default";
|
|
10449
10467
|
const factoryOpts = {
|
|
10450
10468
|
walletRepository: setup.walletRepository,
|
|
10451
10469
|
contractRepository: setup.contractRepository,
|
|
@@ -10644,7 +10662,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
10644
10662
|
};
|
|
10645
10663
|
function deriveLeafPubkey(descriptor) {
|
|
10646
10664
|
try {
|
|
10647
|
-
return
|
|
10665
|
+
return chunk2XO43UHI_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
10648
10666
|
} catch (e) {
|
|
10649
10667
|
throw new NonRangeableDescriptorError(
|
|
10650
10668
|
"Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
|
|
@@ -10656,7 +10674,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
10656
10674
|
const pubKey = deriveLeafPubkey(descriptor);
|
|
10657
10675
|
const tapscript = rebuildTapscript(current, pubKey);
|
|
10658
10676
|
const serverPubKey = tapscript.options.serverPubKey;
|
|
10659
|
-
const csvTimelock =
|
|
10677
|
+
const csvTimelock = chunkDSTYXT2D_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
|
|
10660
10678
|
const base$1 = {
|
|
10661
10679
|
script: base.hex.encode(tapscript.pkScript),
|
|
10662
10680
|
address: tapscript.address(hrp, serverPubKey).encode(),
|
|
@@ -10667,11 +10685,11 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
10667
10685
|
// index-0 key. Without it, spends produce unsigned PSBTs that the
|
|
10668
10686
|
// server rejects with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
10669
10687
|
metadata: {
|
|
10670
|
-
...{ source:
|
|
10688
|
+
...{ source: chunk2XO43UHI_cjs.WALLET_RECEIVE_SOURCE },
|
|
10671
10689
|
signingDescriptor: descriptor
|
|
10672
10690
|
}
|
|
10673
10691
|
};
|
|
10674
|
-
const params = tapscript instanceof
|
|
10692
|
+
const params = tapscript instanceof chunk2XO43UHI_cjs.DelegateVtxo.Script ? {
|
|
10675
10693
|
...base$1,
|
|
10676
10694
|
type: "delegate",
|
|
10677
10695
|
params: {
|
|
@@ -10692,10 +10710,10 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
10692
10710
|
return { tapscript, params };
|
|
10693
10711
|
}
|
|
10694
10712
|
function rebuildTapscript(current, pubKey) {
|
|
10695
|
-
if (current instanceof
|
|
10696
|
-
return new
|
|
10713
|
+
if (current instanceof chunk2XO43UHI_cjs.DelegateVtxo.Script) {
|
|
10714
|
+
return new chunk2XO43UHI_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
|
|
10697
10715
|
}
|
|
10698
|
-
return new
|
|
10716
|
+
return new chunk2XO43UHI_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
|
|
10699
10717
|
}
|
|
10700
10718
|
async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
|
|
10701
10719
|
const candidates = await contractRepository.getContracts({
|
|
@@ -10704,7 +10722,7 @@ async function pickActiveReceive(contractRepository, serverPubKey, expectedType)
|
|
|
10704
10722
|
});
|
|
10705
10723
|
const serverPubKeyHex = base.hex.encode(serverPubKey);
|
|
10706
10724
|
const matching = candidates.filter(
|
|
10707
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
10725
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunk2XO43UHI_cjs.WALLET_RECEIVE_SOURCE
|
|
10708
10726
|
).sort((a, b) => {
|
|
10709
10727
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
10710
10728
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -10880,12 +10898,12 @@ var InputSignerRouter = class {
|
|
|
10880
10898
|
};
|
|
10881
10899
|
|
|
10882
10900
|
// src/wallet/wallet.ts
|
|
10883
|
-
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl ||
|
|
10901
|
+
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl || chunkDSTYXT2D_cjs.DEFAULT_ARKADE_SERVER_URL;
|
|
10884
10902
|
function intentProofJobs(coins) {
|
|
10885
10903
|
if (coins.length === 0) return [];
|
|
10886
10904
|
const coinJobs = coins.map((coin, i) => ({
|
|
10887
10905
|
index: i + 1,
|
|
10888
|
-
lookupScript:
|
|
10906
|
+
lookupScript: chunkDSTYXT2D_cjs.VtxoScript.decode(coin.tapTree).pkScript
|
|
10889
10907
|
}));
|
|
10890
10908
|
return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
|
|
10891
10909
|
}
|
|
@@ -10910,7 +10928,7 @@ function dedupeTimelocks(timelocks) {
|
|
|
10910
10928
|
const seen = /* @__PURE__ */ new Set();
|
|
10911
10929
|
const deduped = [];
|
|
10912
10930
|
for (const timelock of timelocks) {
|
|
10913
|
-
const sequence =
|
|
10931
|
+
const sequence = chunkDSTYXT2D_cjs.timelockToSequence(timelock).toString();
|
|
10914
10932
|
if (seen.has(sequence)) continue;
|
|
10915
10933
|
seen.add(sequence);
|
|
10916
10934
|
deduped.push(timelock);
|
|
@@ -10927,7 +10945,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
10927
10945
|
state: "active"
|
|
10928
10946
|
});
|
|
10929
10947
|
const newest = candidates.filter(
|
|
10930
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
10948
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunk2XO43UHI_cjs.WALLET_RECEIVE_SOURCE
|
|
10931
10949
|
).sort((a, b) => {
|
|
10932
10950
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
10933
10951
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -10935,7 +10953,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
10935
10953
|
if (!newest?.params.pubKey) return baseline;
|
|
10936
10954
|
try {
|
|
10937
10955
|
const pubKey = base.hex.decode(newest.params.pubKey);
|
|
10938
|
-
return new
|
|
10956
|
+
return new chunk2XO43UHI_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
|
|
10939
10957
|
} catch (e) {
|
|
10940
10958
|
console.warn("Skipping malformed boarding contract at boot", newest.script, e);
|
|
10941
10959
|
return baseline;
|
|
@@ -11269,7 +11287,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11269
11287
|
*/
|
|
11270
11288
|
static async setupWalletConfig(config, pubKey) {
|
|
11271
11289
|
const arkadeServerUrl = getArkadeServerUrl(config);
|
|
11272
|
-
const arkProvider = config.arkProvider || new
|
|
11290
|
+
const arkProvider = config.arkProvider || new chunkDSTYXT2D_cjs.RestArkProvider(arkadeServerUrl);
|
|
11273
11291
|
let indexerProvider = config.indexerProvider;
|
|
11274
11292
|
if (!indexerProvider) {
|
|
11275
11293
|
let indexerUrl = config.indexerUrl;
|
|
@@ -11286,7 +11304,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11286
11304
|
indexerUrl = arkadeServerUrl;
|
|
11287
11305
|
}
|
|
11288
11306
|
}
|
|
11289
|
-
indexerProvider = new
|
|
11307
|
+
indexerProvider = new chunkV2KENVN6_cjs.RestIndexerProvider(indexerUrl);
|
|
11290
11308
|
}
|
|
11291
11309
|
const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
11292
11310
|
const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
@@ -11295,7 +11313,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11295
11313
|
source: serverInfoSource,
|
|
11296
11314
|
lastOnlineAt: serverInfoLastOnlineAt
|
|
11297
11315
|
} = await resolveArkInfo(arkProvider, walletRepository);
|
|
11298
|
-
const network =
|
|
11316
|
+
const network = chunkDSTYXT2D_cjs.getNetwork(info.network);
|
|
11299
11317
|
if ("descriptor" in config.identity) {
|
|
11300
11318
|
const descriptor = config.identity.descriptor;
|
|
11301
11319
|
const identityIsMainnet = !descriptor.includes("tpub");
|
|
@@ -11342,11 +11360,11 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11342
11360
|
serverPubKey,
|
|
11343
11361
|
csvTimelock: exitTimelock
|
|
11344
11362
|
};
|
|
11345
|
-
const offchainTapscript = !delegatePubKey ? new
|
|
11346
|
-
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({
|
|
11347
11365
|
pubKey: base.hex.encode(pubKey),
|
|
11348
11366
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
11349
|
-
csvTimelock:
|
|
11367
|
+
csvTimelock: chunkDSTYXT2D_cjs.timelockToSequence(boardingTimelock).toString()
|
|
11350
11368
|
});
|
|
11351
11369
|
return {
|
|
11352
11370
|
arkProvider,
|
|
@@ -11452,19 +11470,19 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11452
11470
|
let pendingRecovery = 0;
|
|
11453
11471
|
const now = { timestamp: /* @__PURE__ */ new Date() };
|
|
11454
11472
|
const settled = vtxos.filter(
|
|
11455
|
-
(coin) =>
|
|
11473
|
+
(coin) => chunkDSTYXT2D_cjs.canSpendOffchain(coin, now) && !coin.isPreconfirmed && !isPendingRecovery(coin)
|
|
11456
11474
|
).reduce((sum, coin) => sum + coin.value, 0);
|
|
11457
11475
|
const preconfirmed = vtxos.filter(
|
|
11458
|
-
(coin) =>
|
|
11476
|
+
(coin) => chunkDSTYXT2D_cjs.canSpendOffchain(coin, now) && coin.isPreconfirmed && !isPendingRecovery(coin)
|
|
11459
11477
|
).reduce((sum, coin) => sum + coin.value, 0);
|
|
11460
|
-
const available = unlockedVtxos.filter((coin) =>
|
|
11461
|
-
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);
|
|
11462
11480
|
pendingRecovery = vtxos.filter(isPendingRecovery).reduce((sum, coin) => sum + coin.value, 0);
|
|
11463
11481
|
const totalBoarding = confirmed + unconfirmed;
|
|
11464
11482
|
const totalOffchain = settled + preconfirmed + recoverable + pendingRecovery;
|
|
11465
11483
|
const assetBalances = /* @__PURE__ */ new Map();
|
|
11466
11484
|
for (const vtxo of vtxos) {
|
|
11467
|
-
if (
|
|
11485
|
+
if (chunkDSTYXT2D_cjs.hasTerminalSpend(vtxo)) continue;
|
|
11468
11486
|
if (vtxo.assets) {
|
|
11469
11487
|
for (const a of vtxo.assets) {
|
|
11470
11488
|
const current = assetBalances.get(a.assetId) ?? 0n;
|
|
@@ -11505,8 +11523,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11505
11523
|
if (this._pendingSpendOutpoints.has(`${vtxo.txid}:${vtxo.vout}`)) {
|
|
11506
11524
|
return false;
|
|
11507
11525
|
}
|
|
11508
|
-
if (!
|
|
11509
|
-
if (!f.withRecoverable &&
|
|
11526
|
+
if (!chunkDSTYXT2D_cjs.hasTerminalSpend(vtxo)) {
|
|
11527
|
+
if (!f.withRecoverable && chunkDSTYXT2D_cjs.canRecoverOnchain(vtxo, now)) {
|
|
11510
11528
|
return false;
|
|
11511
11529
|
}
|
|
11512
11530
|
return true;
|
|
@@ -11539,7 +11557,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11539
11557
|
const response = await contractManager.getContractsWithVtxos();
|
|
11540
11558
|
const allVtxos = response.flatMap((_) => _.vtxos);
|
|
11541
11559
|
const { boardingTxs, commitmentsToIgnore } = await this.getBoardingTxs();
|
|
11542
|
-
const resolveTxCreatedAt = (txids) =>
|
|
11560
|
+
const resolveTxCreatedAt = (txids) => chunkDSTYXT2D_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
|
|
11543
11561
|
return buildTransactionHistory(
|
|
11544
11562
|
allVtxos,
|
|
11545
11563
|
boardingTxs,
|
|
@@ -11633,7 +11651,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11633
11651
|
},
|
|
11634
11652
|
isUnrolled: true,
|
|
11635
11653
|
...boardingFacts,
|
|
11636
|
-
virtualStatus:
|
|
11654
|
+
virtualStatus: chunkDSTYXT2D_cjs.toVirtualStatus(boardingFacts),
|
|
11637
11655
|
spentBy: "",
|
|
11638
11656
|
createdAt: tx.status.confirmed ? new Date(tx.status.block_time * 1e3) : /* @__PURE__ */ new Date(0),
|
|
11639
11657
|
script: scriptHex
|
|
@@ -11689,9 +11707,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11689
11707
|
async getBoardingTapscripts(allowedSigners) {
|
|
11690
11708
|
const byScript = /* @__PURE__ */ new Map();
|
|
11691
11709
|
const add = (s) => byScript.set(base.hex.encode(s.pkScript), s);
|
|
11692
|
-
const boardingCsv = this.boardingTapscript.options.csvTimelock ??
|
|
11710
|
+
const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunk2XO43UHI_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
11693
11711
|
add(
|
|
11694
|
-
new
|
|
11712
|
+
new chunk2XO43UHI_cjs.DefaultVtxo.Script({
|
|
11695
11713
|
pubKey: await this.identity.xOnlyPublicKey(),
|
|
11696
11714
|
serverPubKey: this.boardingTapscript.options.serverPubKey,
|
|
11697
11715
|
csvTimelock: boardingCsv
|
|
@@ -11706,7 +11724,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11706
11724
|
for (const c of boardingContracts) {
|
|
11707
11725
|
if (!allowed.has(toXOnlySignerHex(c.params.serverPubKey))) continue;
|
|
11708
11726
|
try {
|
|
11709
|
-
add(
|
|
11727
|
+
add(chunk2XO43UHI_cjs.BoardingContractHandler.createScript(c.params));
|
|
11710
11728
|
} catch (e) {
|
|
11711
11729
|
console.warn("Skipping malformed boarding contract", c.script, e);
|
|
11712
11730
|
}
|
|
@@ -11744,7 +11762,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11744
11762
|
// Per-row CSV delay decoded from THIS tapscript's exit leaf —
|
|
11745
11763
|
// not the wallet's current boarding timelock, which a signer
|
|
11746
11764
|
// rotation may have changed.
|
|
11747
|
-
csvTimelock:
|
|
11765
|
+
csvTimelock: chunkDSTYXT2D_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
|
|
11748
11766
|
coins: utxos
|
|
11749
11767
|
});
|
|
11750
11768
|
}
|
|
@@ -11877,7 +11895,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11877
11895
|
/** Fetch Arkade transaction ids that are still pending final settlement. */
|
|
11878
11896
|
async fetchPendingTxs() {
|
|
11879
11897
|
const scripts = await this.getWalletScripts();
|
|
11880
|
-
const vtxos = await
|
|
11898
|
+
const vtxos = await chunkDSTYXT2D_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
|
|
11881
11899
|
return vtxos.filter(
|
|
11882
11900
|
(vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
|
|
11883
11901
|
).map((_) => _.arkTxId);
|
|
@@ -11908,7 +11926,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11908
11926
|
});
|
|
11909
11927
|
for (const contract of contracts) {
|
|
11910
11928
|
if (map.has(contract.script)) continue;
|
|
11911
|
-
const handler =
|
|
11929
|
+
const handler = chunk2XO43UHI_cjs.contractHandlers.get(contract.type);
|
|
11912
11930
|
if (handler) {
|
|
11913
11931
|
const script = handler.createScript(contract.params);
|
|
11914
11932
|
map.set(contract.script, script);
|
|
@@ -12011,7 +12029,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12011
12029
|
lookAhead: this.lookAheadConfig()
|
|
12012
12030
|
});
|
|
12013
12031
|
const baselinePubkey = await this.identity.xOnlyPublicKey();
|
|
12014
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
12032
|
+
const delegatePubKey = this.offchainTapscript instanceof chunk2XO43UHI_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
12015
12033
|
const baselineSigners = [
|
|
12016
12034
|
this.offchainTapscript.options.serverPubKey,
|
|
12017
12035
|
...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
|
|
@@ -12019,8 +12037,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12019
12037
|
const seenBaselineScripts = /* @__PURE__ */ new Set();
|
|
12020
12038
|
for (const serverPubKey of baselineSigners) {
|
|
12021
12039
|
for (const csvTimelock of this.walletContractTimelocks) {
|
|
12022
|
-
const csvTimelockStr =
|
|
12023
|
-
const defaultScript = new
|
|
12040
|
+
const csvTimelockStr = chunkDSTYXT2D_cjs.timelockToSequence(csvTimelock).toString();
|
|
12041
|
+
const defaultScript = new chunk2XO43UHI_cjs.DefaultVtxo.Script({
|
|
12024
12042
|
pubKey: baselinePubkey,
|
|
12025
12043
|
serverPubKey,
|
|
12026
12044
|
csvTimelock
|
|
@@ -12041,7 +12059,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12041
12059
|
});
|
|
12042
12060
|
}
|
|
12043
12061
|
if (delegatePubKey) {
|
|
12044
|
-
const delegateScript = new
|
|
12062
|
+
const delegateScript = new chunk2XO43UHI_cjs.DelegateVtxo.Script({
|
|
12045
12063
|
pubKey: baselinePubkey,
|
|
12046
12064
|
serverPubKey,
|
|
12047
12065
|
delegatePubKey,
|
|
@@ -12065,9 +12083,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12065
12083
|
}
|
|
12066
12084
|
}
|
|
12067
12085
|
}
|
|
12068
|
-
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ??
|
|
12086
|
+
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunk2XO43UHI_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
12069
12087
|
for (const serverPubKey of baselineSigners) {
|
|
12070
|
-
const baselineBoarding = new
|
|
12088
|
+
const baselineBoarding = new chunk2XO43UHI_cjs.DefaultVtxo.Script({
|
|
12071
12089
|
pubKey: baselinePubkey,
|
|
12072
12090
|
serverPubKey,
|
|
12073
12091
|
csvTimelock: boardingCsvTimelock
|
|
@@ -12080,7 +12098,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
12080
12098
|
params: {
|
|
12081
12099
|
pubKey: base.hex.encode(baselineBoarding.options.pubKey),
|
|
12082
12100
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
12083
|
-
csvTimelock:
|
|
12101
|
+
csvTimelock: chunkDSTYXT2D_cjs.timelockToSequence(boardingCsvTimelock).toString()
|
|
12084
12102
|
},
|
|
12085
12103
|
script: boardingScriptHex,
|
|
12086
12104
|
address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
|
|
@@ -12258,7 +12276,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12258
12276
|
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
12259
12277
|
deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
|
|
12260
12278
|
csvTimelocks: this.walletContractTimelocks,
|
|
12261
|
-
delegatePubKey: this.offchainTapscript instanceof
|
|
12279
|
+
delegatePubKey: this.offchainTapscript instanceof chunk2XO43UHI_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
|
|
12262
12280
|
};
|
|
12263
12281
|
}
|
|
12264
12282
|
_signerRouter;
|
|
@@ -12350,25 +12368,25 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12350
12368
|
return this.getBoardingAddress();
|
|
12351
12369
|
}
|
|
12352
12370
|
const descriptor = await provider.getNextSigningDescriptor();
|
|
12353
|
-
const pubKey =
|
|
12354
|
-
const newBoarding = new
|
|
12371
|
+
const pubKey = chunk2XO43UHI_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
12372
|
+
const newBoarding = new chunk2XO43UHI_cjs.DefaultVtxo.Script({
|
|
12355
12373
|
...this._boardingTapscript.options,
|
|
12356
12374
|
pubKey
|
|
12357
12375
|
});
|
|
12358
|
-
const csvTimelock = newBoarding.options.csvTimelock ??
|
|
12376
|
+
const csvTimelock = newBoarding.options.csvTimelock ?? chunk2XO43UHI_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
12359
12377
|
const manager = await this.getContractManager();
|
|
12360
12378
|
await manager.createContract({
|
|
12361
12379
|
type: "boarding",
|
|
12362
12380
|
params: {
|
|
12363
12381
|
pubKey: base.hex.encode(pubKey),
|
|
12364
12382
|
serverPubKey: base.hex.encode(newBoarding.options.serverPubKey),
|
|
12365
|
-
csvTimelock:
|
|
12383
|
+
csvTimelock: chunkDSTYXT2D_cjs.timelockToSequence(csvTimelock).toString()
|
|
12366
12384
|
},
|
|
12367
12385
|
script: base.hex.encode(newBoarding.pkScript),
|
|
12368
12386
|
address: newBoarding.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
12369
12387
|
state: "active",
|
|
12370
12388
|
metadata: {
|
|
12371
|
-
source:
|
|
12389
|
+
source: chunk2XO43UHI_cjs.WALLET_RECEIVE_SOURCE,
|
|
12372
12390
|
signingDescriptor: descriptor
|
|
12373
12391
|
}
|
|
12374
12392
|
});
|
|
@@ -12483,21 +12501,21 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12483
12501
|
const [currentBoardingRow] = await manager.getContracts({
|
|
12484
12502
|
script: currentBoardingScript
|
|
12485
12503
|
});
|
|
12486
|
-
const newOffchain = this.offchainTapscript instanceof
|
|
12504
|
+
const newOffchain = this.offchainTapscript instanceof chunk2XO43UHI_cjs.DelegateVtxo.Script ? new chunk2XO43UHI_cjs.DelegateVtxo.Script({
|
|
12487
12505
|
...this.offchainTapscript.options,
|
|
12488
12506
|
serverPubKey: xonly
|
|
12489
|
-
}) : new
|
|
12507
|
+
}) : new chunk2XO43UHI_cjs.DefaultVtxo.Script({
|
|
12490
12508
|
...this.offchainTapscript.options,
|
|
12491
12509
|
serverPubKey: xonly
|
|
12492
12510
|
});
|
|
12493
|
-
const newBoarding = new
|
|
12511
|
+
const newBoarding = new chunk2XO43UHI_cjs.DefaultVtxo.Script({
|
|
12494
12512
|
...this._boardingTapscript.options,
|
|
12495
12513
|
serverPubKey: xonly
|
|
12496
12514
|
});
|
|
12497
|
-
const offchainCsv =
|
|
12515
|
+
const offchainCsv = chunkDSTYXT2D_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
|
|
12498
12516
|
const newOffchainScript = base.hex.encode(newOffchain.pkScript);
|
|
12499
12517
|
const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
|
|
12500
|
-
if (newOffchain instanceof
|
|
12518
|
+
if (newOffchain instanceof chunk2XO43UHI_cjs.DelegateVtxo.Script) {
|
|
12501
12519
|
await manager.createContract({
|
|
12502
12520
|
type: "delegate",
|
|
12503
12521
|
params: {
|
|
@@ -12525,13 +12543,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12525
12543
|
metadata: currentOffchainRow?.metadata
|
|
12526
12544
|
});
|
|
12527
12545
|
}
|
|
12528
|
-
const boardingCsv = newBoarding.options.csvTimelock ??
|
|
12546
|
+
const boardingCsv = newBoarding.options.csvTimelock ?? chunk2XO43UHI_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
12529
12547
|
await manager.createContract({
|
|
12530
12548
|
type: "boarding",
|
|
12531
12549
|
params: {
|
|
12532
12550
|
pubKey: base.hex.encode(newBoarding.options.pubKey),
|
|
12533
12551
|
serverPubKey: base.hex.encode(xonly),
|
|
12534
|
-
csvTimelock:
|
|
12552
|
+
csvTimelock: chunkDSTYXT2D_cjs.timelockToSequence(boardingCsv).toString()
|
|
12535
12553
|
},
|
|
12536
12554
|
script: base.hex.encode(newBoarding.pkScript),
|
|
12537
12555
|
address: newBoarding.address(this.network.hrp, xonly).encode(),
|
|
@@ -12564,14 +12582,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12564
12582
|
_restoreInFlight;
|
|
12565
12583
|
_addPendingSpends(inputs) {
|
|
12566
12584
|
for (const input of inputs) {
|
|
12567
|
-
if (
|
|
12585
|
+
if (chunkDSTYXT2D_cjs.isVirtualCoin(input)) {
|
|
12568
12586
|
this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
|
|
12569
12587
|
}
|
|
12570
12588
|
}
|
|
12571
12589
|
}
|
|
12572
12590
|
_removePendingSpends(inputs) {
|
|
12573
12591
|
for (const input of inputs) {
|
|
12574
|
-
if (
|
|
12592
|
+
if (chunkDSTYXT2D_cjs.isVirtualCoin(input)) {
|
|
12575
12593
|
this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
|
|
12576
12594
|
}
|
|
12577
12595
|
}
|
|
@@ -12631,7 +12649,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12631
12649
|
const hd = provider instanceof HDDescriptorProvider;
|
|
12632
12650
|
const staticDescriptor = hd ? void 0 : `tr(${base.hex.encode(await this.identity.xOnlyPublicKey())})`;
|
|
12633
12651
|
const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
|
|
12634
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
12652
|
+
const delegatePubKey = this.offchainTapscript instanceof chunk2XO43UHI_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
12635
12653
|
const arkInfo = await this.arkProvider.getInfo();
|
|
12636
12654
|
const currentSignerPubKey = toXOnlyPubKey(base.hex.decode(arkInfo.signerPubkey));
|
|
12637
12655
|
const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
|
|
@@ -12650,7 +12668,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12650
12668
|
csvTimelocks: this.walletContractTimelocks,
|
|
12651
12669
|
// Boarding-exit CSV so the boarding handler can build its
|
|
12652
12670
|
// candidate script (distinct from the unilateral-exit matrix).
|
|
12653
|
-
boardingTimelock: this.boardingTapscript.options.csvTimelock ??
|
|
12671
|
+
boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunk2XO43UHI_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
|
|
12654
12672
|
delegatePubKey
|
|
12655
12673
|
};
|
|
12656
12674
|
const result = await manager.scanContracts({
|
|
@@ -12912,7 +12930,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12912
12930
|
inputs: params.selectedVtxos,
|
|
12913
12931
|
changeAmount: BigInt(changeAmount)
|
|
12914
12932
|
};
|
|
12915
|
-
const outputAddress =
|
|
12933
|
+
const outputAddress = chunkDSTYXT2D_cjs.ArkAddress.decode(params.address);
|
|
12916
12934
|
assertRecipientArkAddress(
|
|
12917
12935
|
params.address,
|
|
12918
12936
|
outputAddress,
|
|
@@ -12970,13 +12988,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12970
12988
|
}
|
|
12971
12989
|
}
|
|
12972
12990
|
const offchainAddress = await this.getAddress();
|
|
12973
|
-
const offchainPkScript =
|
|
12991
|
+
const offchainPkScript = chunkDSTYXT2D_cjs.ArkAddress.decode(offchainAddress).pkScript;
|
|
12974
12992
|
const offchainOutputScript = base.hex.encode(offchainPkScript);
|
|
12975
12993
|
if (!params) {
|
|
12976
12994
|
const { fees, vtxoMaxAmount } = await this.arkProvider.getInfo();
|
|
12977
12995
|
const estimator = new Estimator(fees.intentFee);
|
|
12978
12996
|
let amount = 0;
|
|
12979
|
-
const exitScript =
|
|
12997
|
+
const exitScript = chunkDSTYXT2D_cjs.CSVMultisigTapscript.decode(
|
|
12980
12998
|
base.hex.decode(this.boardingTapscript.exitScript)
|
|
12981
12999
|
);
|
|
12982
13000
|
const boardingTimelock = exitScript.params.timelock;
|
|
@@ -13005,7 +13023,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13005
13023
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
13006
13024
|
break;
|
|
13007
13025
|
}
|
|
13008
|
-
const inputFee = estimator.evalOffchainInput(
|
|
13026
|
+
const inputFee = estimator.evalOffchainInput(chunkDSTYXT2D_cjs.toOffchainInputFeeParams(vtxo));
|
|
13009
13027
|
if (inputFee.satoshis >= vtxo.value) {
|
|
13010
13028
|
continue;
|
|
13011
13029
|
}
|
|
@@ -13052,7 +13070,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13052
13070
|
let script;
|
|
13053
13071
|
let arkAddress;
|
|
13054
13072
|
try {
|
|
13055
|
-
arkAddress =
|
|
13073
|
+
arkAddress = chunkDSTYXT2D_cjs.ArkAddress.decode(output.address);
|
|
13056
13074
|
} catch {
|
|
13057
13075
|
arkAddress = void 0;
|
|
13058
13076
|
}
|
|
@@ -13244,7 +13262,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13244
13262
|
async maybeRotateBoardingAfterBoard(inputs) {
|
|
13245
13263
|
if (!this._descriptorProvider) return;
|
|
13246
13264
|
const consumedBoarding = inputs.some(
|
|
13247
|
-
(input) => typeof input !== "string" && !
|
|
13265
|
+
(input) => typeof input !== "string" && !chunkDSTYXT2D_cjs.isVirtualCoin(input)
|
|
13248
13266
|
);
|
|
13249
13267
|
if (!consumedBoarding) return;
|
|
13250
13268
|
try {
|
|
@@ -13268,7 +13286,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13268
13286
|
let connectorIndex = 0;
|
|
13269
13287
|
const connectorsLeaves = connectorsGraph?.leaves() || [];
|
|
13270
13288
|
for (const input of inputs) {
|
|
13271
|
-
if (!
|
|
13289
|
+
if (!chunkDSTYXT2D_cjs.isVirtualCoin(input)) {
|
|
13272
13290
|
for (let i = 0; i < settlementPsbt.inputsLength; i++) {
|
|
13273
13291
|
const settlementInput = settlementPsbt.getInput(i);
|
|
13274
13292
|
if (!settlementInput.txid || settlementInput.index === void 0) {
|
|
@@ -13299,7 +13317,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13299
13317
|
}
|
|
13300
13318
|
continue;
|
|
13301
13319
|
}
|
|
13302
|
-
if (
|
|
13320
|
+
if (chunkDSTYXT2D_cjs.canRecoverOnchain(input, { timestamp: /* @__PURE__ */ new Date() }) || isSubdust({ value: input.value }, this.dustAmount)) {
|
|
13303
13321
|
continue;
|
|
13304
13322
|
}
|
|
13305
13323
|
if (connectorsLeaves.length === 0) {
|
|
@@ -13327,7 +13345,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13327
13345
|
index: input.vout,
|
|
13328
13346
|
witnessUtxo: {
|
|
13329
13347
|
amount: BigInt(input.value),
|
|
13330
|
-
script:
|
|
13348
|
+
script: chunkDSTYXT2D_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
13331
13349
|
},
|
|
13332
13350
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
13333
13351
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -13346,7 +13364,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13346
13364
|
forfeitTx = await this._signerRouter.sign(forfeitTx, [
|
|
13347
13365
|
{
|
|
13348
13366
|
index: 0,
|
|
13349
|
-
lookupScript:
|
|
13367
|
+
lookupScript: chunkDSTYXT2D_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
13350
13368
|
}
|
|
13351
13369
|
]);
|
|
13352
13370
|
signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
|
|
@@ -13404,7 +13422,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13404
13422
|
resolveBatchExpiryPolicy(this.network, this.batchExpiryPolicy)
|
|
13405
13423
|
);
|
|
13406
13424
|
await this.arkProvider.confirmRegistration(intentId);
|
|
13407
|
-
const sweepTapscript =
|
|
13425
|
+
const sweepTapscript = chunkDSTYXT2D_cjs.CSVMultisigTapscript.encode({
|
|
13408
13426
|
timelock,
|
|
13409
13427
|
pubkeys: [this.forfeitPubkey]
|
|
13410
13428
|
}).script;
|
|
@@ -13510,9 +13528,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13510
13528
|
...existing ?? {},
|
|
13511
13529
|
intentTxId,
|
|
13512
13530
|
registerProof: intent.proof,
|
|
13513
|
-
registerProofMessage:
|
|
13531
|
+
registerProofMessage: chunkDSTYXT2D_cjs.Intent.encodeMessage(intent.message),
|
|
13514
13532
|
deleteProof: deleteIntent.proof,
|
|
13515
|
-
deleteProofMessage:
|
|
13533
|
+
deleteProofMessage: chunkDSTYXT2D_cjs.Intent.encodeMessage(deleteIntent.message),
|
|
13516
13534
|
intentVtxos: inputs.map((i) => ({
|
|
13517
13535
|
txid: i.txid,
|
|
13518
13536
|
vout: i.vout
|
|
@@ -13544,7 +13562,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13544
13562
|
try {
|
|
13545
13563
|
return await this.arkProvider.registerIntent(intent);
|
|
13546
13564
|
} catch (error) {
|
|
13547
|
-
if (error instanceof
|
|
13565
|
+
if (error instanceof chunkDSTYXT2D_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
|
|
13548
13566
|
const deleteIntent = await this.makeDeleteIntentSignature(inputs);
|
|
13549
13567
|
await this.arkProvider.deleteIntent(deleteIntent);
|
|
13550
13568
|
return this.arkProvider.registerIntent(intent);
|
|
@@ -13560,7 +13578,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13560
13578
|
expire_at: 0,
|
|
13561
13579
|
cosigners_public_keys: cosignerPubKeys
|
|
13562
13580
|
};
|
|
13563
|
-
const proof =
|
|
13581
|
+
const proof = chunkDSTYXT2D_cjs.Intent.create(message, coins, outputs);
|
|
13564
13582
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
13565
13583
|
return {
|
|
13566
13584
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -13572,7 +13590,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13572
13590
|
type: "delete",
|
|
13573
13591
|
expire_at: 0
|
|
13574
13592
|
};
|
|
13575
|
-
const proof =
|
|
13593
|
+
const proof = chunkDSTYXT2D_cjs.Intent.create(message, coins, []);
|
|
13576
13594
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
13577
13595
|
return {
|
|
13578
13596
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -13584,7 +13602,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13584
13602
|
type: "get-pending-tx",
|
|
13585
13603
|
expire_at: 0
|
|
13586
13604
|
};
|
|
13587
|
-
const proof =
|
|
13605
|
+
const proof = chunkDSTYXT2D_cjs.Intent.create(message, coins, []);
|
|
13588
13606
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
13589
13607
|
return {
|
|
13590
13608
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -13605,7 +13623,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13605
13623
|
if (!vtxos || vtxos.length === 0) {
|
|
13606
13624
|
const scriptMap = await this.getScriptMap();
|
|
13607
13625
|
const allExtended = [];
|
|
13608
|
-
const fetchedVtxos = await
|
|
13626
|
+
const fetchedVtxos = await chunkDSTYXT2D_cjs.getAllNormalizedVtxos(this.indexerProvider, [
|
|
13609
13627
|
...scriptMap.keys()
|
|
13610
13628
|
]);
|
|
13611
13629
|
for (const vtxo of fetchedVtxos) {
|
|
@@ -13719,11 +13737,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13719
13737
|
* against the current key alone would leave it pending forever.
|
|
13720
13738
|
*/
|
|
13721
13739
|
checkpointUnrollCandidates(info) {
|
|
13722
|
-
const current =
|
|
13740
|
+
const current = chunkDSTYXT2D_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
13723
13741
|
const candidates = [this._serverUnrollScript, current];
|
|
13724
13742
|
for (const deprecated of signerSetFromInfo(info).deprecated.keys()) {
|
|
13725
13743
|
candidates.push(
|
|
13726
|
-
|
|
13744
|
+
chunkDSTYXT2D_cjs.CSVMultisigTapscript.encode({
|
|
13727
13745
|
...current.params,
|
|
13728
13746
|
pubkeys: [base.hex.decode(deprecated)]
|
|
13729
13747
|
})
|
|
@@ -13814,7 +13832,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13814
13832
|
if (vtxos.length === 0) {
|
|
13815
13833
|
throw new Error("No VTXOs found for this arkadeCash");
|
|
13816
13834
|
}
|
|
13817
|
-
const myPkScript =
|
|
13835
|
+
const myPkScript = chunkDSTYXT2D_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
|
|
13818
13836
|
let { spendable, unclaimed } = this.classifyCashVtxos(vtxos);
|
|
13819
13837
|
let swept = 0;
|
|
13820
13838
|
const drainable = vtxos.filter((vtxo) => !isSubdust(vtxo, this.dustAmount));
|
|
@@ -13888,7 +13906,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13888
13906
|
const spendable = [];
|
|
13889
13907
|
const unclaimed = [];
|
|
13890
13908
|
for (const vtxo of vtxos) {
|
|
13891
|
-
if (
|
|
13909
|
+
if (chunkDSTYXT2D_cjs.hasTerminalSpend(vtxo)) {
|
|
13892
13910
|
unclaimed.push(cashReport(vtxo, "already-spent"));
|
|
13893
13911
|
} else if (isSubdust(vtxo, this.dustAmount)) {
|
|
13894
13912
|
unclaimed.push(cashReport(vtxo, "subdust"));
|
|
@@ -13908,7 +13926,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13908
13926
|
const all = [];
|
|
13909
13927
|
const seen = /* @__PURE__ */ new Set();
|
|
13910
13928
|
for (let pageIndex = 0; ; pageIndex++) {
|
|
13911
|
-
const { vtxos, page } = await
|
|
13929
|
+
const { vtxos, page } = await chunkDSTYXT2D_cjs.getNormalizedVtxos(this.indexerProvider, {
|
|
13912
13930
|
scripts,
|
|
13913
13931
|
pageIndex,
|
|
13914
13932
|
pageSize
|
|
@@ -13955,7 +13973,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13955
13973
|
for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
|
|
13956
13974
|
const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
|
|
13957
13975
|
const message = { type: "get-pending-tx", expire_at: 0 };
|
|
13958
|
-
const proof =
|
|
13976
|
+
const proof = chunkDSTYXT2D_cjs.Intent.create(message, batch, []);
|
|
13959
13977
|
const signedProof = await identity.sign(
|
|
13960
13978
|
proof,
|
|
13961
13979
|
Array.from({ length: batch.length + 1 }, (_, j) => j)
|
|
@@ -14265,10 +14283,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14265
14283
|
const serverPubKey = this.arkServerPublicKey;
|
|
14266
14284
|
const serverUnrollScript = this.serverUnrollScript;
|
|
14267
14285
|
const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
|
|
14268
|
-
const normalizedInputs = inputs.map(
|
|
14269
|
-
const at = now ?? await
|
|
14286
|
+
const normalizedInputs = inputs.map(chunkDSTYXT2D_cjs.normalizeVtxo);
|
|
14287
|
+
const at = now ?? await chunkDSTYXT2D_cjs.resolveTimeHeight(this.onchainProvider);
|
|
14270
14288
|
for (const input of normalizedInputs) {
|
|
14271
|
-
if (!
|
|
14289
|
+
if (!chunkDSTYXT2D_cjs.canSpendOffchain(input, at)) {
|
|
14272
14290
|
throw new Error(
|
|
14273
14291
|
`sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
|
|
14274
14292
|
);
|
|
@@ -14333,7 +14351,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14333
14351
|
);
|
|
14334
14352
|
const arkTxJobs = inputs.map((input, index) => ({
|
|
14335
14353
|
index,
|
|
14336
|
-
lookupScript:
|
|
14354
|
+
lookupScript: chunkDSTYXT2D_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
14337
14355
|
}));
|
|
14338
14356
|
const identity = this.identity;
|
|
14339
14357
|
const signer = {
|
|
@@ -14419,14 +14437,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14419
14437
|
const spentBy = checkpointIdByOutpoint.get(`${vtxo.txid}:${vtxo.vout}`);
|
|
14420
14438
|
spentVtxos.push({
|
|
14421
14439
|
...spentFacts,
|
|
14422
|
-
virtualStatus:
|
|
14440
|
+
virtualStatus: chunkDSTYXT2D_cjs.toVirtualStatus(spentFacts),
|
|
14423
14441
|
...spentBy ? { spentBy } : {},
|
|
14424
14442
|
arkTxId: arkTxid
|
|
14425
14443
|
});
|
|
14426
14444
|
for (const id of vtxo.commitmentTxIds) {
|
|
14427
14445
|
commitmentTxIds.add(id);
|
|
14428
14446
|
}
|
|
14429
|
-
const vtxoExpiry =
|
|
14447
|
+
const vtxoExpiry = chunkDSTYXT2D_cjs.toBatchExpiry(vtxo);
|
|
14430
14448
|
if (vtxoExpiry) {
|
|
14431
14449
|
batchExpiry = Math.min(batchExpiry, vtxoExpiry);
|
|
14432
14450
|
}
|
|
@@ -14439,7 +14457,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14439
14457
|
isSwept: false,
|
|
14440
14458
|
isPreconfirmed: true,
|
|
14441
14459
|
commitmentTxIds: Array.from(commitmentTxIds),
|
|
14442
|
-
...
|
|
14460
|
+
...chunkDSTYXT2D_cjs.parseLegacyExpiry(batchExpiry)
|
|
14443
14461
|
};
|
|
14444
14462
|
changeVtxo = {
|
|
14445
14463
|
txid: arkTxid,
|
|
@@ -14451,7 +14469,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14451
14469
|
tapTree: offchainTapscript.encode(),
|
|
14452
14470
|
value: Number(changeAmount),
|
|
14453
14471
|
...changeFacts,
|
|
14454
|
-
virtualStatus:
|
|
14472
|
+
virtualStatus: chunkDSTYXT2D_cjs.toVirtualStatus(changeFacts),
|
|
14455
14473
|
spentBy: "",
|
|
14456
14474
|
status: {
|
|
14457
14475
|
confirmed: false
|
|
@@ -14520,12 +14538,12 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14520
14538
|
const spentVtxos = [];
|
|
14521
14539
|
const inputArkTxIds = /* @__PURE__ */ new Set();
|
|
14522
14540
|
const boardingRemovalsByAddress = /* @__PURE__ */ new Map();
|
|
14523
|
-
const vtxoInputs = inputs.filter(
|
|
14541
|
+
const vtxoInputs = inputs.filter(chunkDSTYXT2D_cjs.isVirtualCoin);
|
|
14524
14542
|
const cm = await this.getContractManager();
|
|
14525
14543
|
const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
|
|
14526
14544
|
const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
|
|
14527
14545
|
for (const input of inputs) {
|
|
14528
|
-
if (
|
|
14546
|
+
if (chunkDSTYXT2D_cjs.isVirtualCoin(input)) {
|
|
14529
14547
|
const outpoint = `${input.txid}:${input.vout}`;
|
|
14530
14548
|
const vtxo = annotatedByKey.get(outpoint);
|
|
14531
14549
|
if (!vtxo) {
|
|
@@ -14537,13 +14555,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14537
14555
|
const settledFacts = { ...vtxo, isSpent: true };
|
|
14538
14556
|
spentVtxos.push({
|
|
14539
14557
|
...settledFacts,
|
|
14540
|
-
virtualStatus:
|
|
14558
|
+
virtualStatus: chunkDSTYXT2D_cjs.toVirtualStatus(settledFacts),
|
|
14541
14559
|
settledBy: commitmentTxid
|
|
14542
14560
|
});
|
|
14543
14561
|
} else {
|
|
14544
14562
|
let sourceAddress;
|
|
14545
14563
|
try {
|
|
14546
|
-
sourceAddress =
|
|
14564
|
+
sourceAddress = chunkDSTYXT2D_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
|
|
14547
14565
|
this.network
|
|
14548
14566
|
);
|
|
14549
14567
|
} catch {
|
|
@@ -14601,9 +14619,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14601
14619
|
}
|
|
14602
14620
|
};
|
|
14603
14621
|
function selectVirtualCoins(coins, targetAmount) {
|
|
14604
|
-
const sortedCoins = coins.map(
|
|
14605
|
-
const expiryA =
|
|
14606
|
-
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;
|
|
14607
14625
|
if (expiryA !== expiryB) {
|
|
14608
14626
|
return expiryA - expiryB;
|
|
14609
14627
|
}
|
|
@@ -14860,7 +14878,7 @@ var MessageBus = class {
|
|
|
14860
14878
|
this.initialized = true;
|
|
14861
14879
|
}
|
|
14862
14880
|
async buildServices(config) {
|
|
14863
|
-
const arkProvider = new
|
|
14881
|
+
const arkProvider = new chunkDSTYXT2D_cjs.RestArkProvider(config.arkServer.url);
|
|
14864
14882
|
const storage = {
|
|
14865
14883
|
walletRepository: this.walletRepository,
|
|
14866
14884
|
contractRepository: this.contractRepository
|
|
@@ -15201,7 +15219,7 @@ var offboardNetworkNames = [
|
|
|
15201
15219
|
function offboardDestinationScript(destinationAddress) {
|
|
15202
15220
|
for (const networkName of offboardNetworkNames) {
|
|
15203
15221
|
try {
|
|
15204
|
-
const network =
|
|
15222
|
+
const network = chunkDSTYXT2D_cjs.networks[networkName];
|
|
15205
15223
|
const addr = btcSigner.Address(network).decode(destinationAddress);
|
|
15206
15224
|
return btcSigner.OutScript.encode(addr);
|
|
15207
15225
|
} catch {
|
|
@@ -15265,7 +15283,7 @@ var Ramps = class {
|
|
|
15265
15283
|
}
|
|
15266
15284
|
amount = amount ?? totalAmount;
|
|
15267
15285
|
const offchainAddress = await this.wallet.getAddress();
|
|
15268
|
-
const offchainAddr =
|
|
15286
|
+
const offchainAddr = chunkDSTYXT2D_cjs.ArkAddress.decode(offchainAddress);
|
|
15269
15287
|
const offchainScript = base.hex.encode(offchainAddr.pkScript);
|
|
15270
15288
|
const outputFee = estimator.evalOffchainOutput({
|
|
15271
15289
|
amount,
|
|
@@ -15325,7 +15343,7 @@ var Ramps = class {
|
|
|
15325
15343
|
const filteredVtxos = [];
|
|
15326
15344
|
let totalAmount = 0n;
|
|
15327
15345
|
for (const vtxo of vtxos) {
|
|
15328
|
-
const inputFee = estimator.evalOffchainInput(
|
|
15346
|
+
const inputFee = estimator.evalOffchainInput(chunkDSTYXT2D_cjs.toOffchainInputFeeParams(vtxo));
|
|
15329
15347
|
if (inputFee.satoshis >= vtxo.value) {
|
|
15330
15348
|
continue;
|
|
15331
15349
|
}
|
|
@@ -16022,7 +16040,7 @@ var WalletMessageHandler = class {
|
|
|
16022
16040
|
// Wallet methods
|
|
16023
16041
|
async handleInitWallet({ payload }) {
|
|
16024
16042
|
const { arkServerUrl } = payload;
|
|
16025
|
-
this.indexerProvider = new
|
|
16043
|
+
this.indexerProvider = new chunkV2KENVN6_cjs.RestIndexerProvider(arkServerUrl);
|
|
16026
16044
|
await this.onWalletInitialized();
|
|
16027
16045
|
}
|
|
16028
16046
|
async handleGetBalance() {
|
|
@@ -16046,12 +16064,12 @@ var WalletMessageHandler = class {
|
|
|
16046
16064
|
let recoverable = 0;
|
|
16047
16065
|
let pendingRecovery = 0;
|
|
16048
16066
|
for (const vtxo of allVtxos) {
|
|
16049
|
-
if (
|
|
16067
|
+
if (chunkDSTYXT2D_cjs.hasTerminalSpend(vtxo)) continue;
|
|
16050
16068
|
if (pendingOutpoints.has(`${vtxo.txid}:${vtxo.vout}`)) {
|
|
16051
16069
|
pendingRecovery += vtxo.value;
|
|
16052
|
-
} else if (
|
|
16070
|
+
} else if (chunkDSTYXT2D_cjs.canRecoverOnchain(vtxo, now)) {
|
|
16053
16071
|
recoverable += vtxo.value;
|
|
16054
|
-
} else if (
|
|
16072
|
+
} else if (chunkDSTYXT2D_cjs.canSpendOffchain(vtxo, now)) {
|
|
16055
16073
|
if (vtxo.isPreconfirmed) {
|
|
16056
16074
|
preconfirmed += vtxo.value;
|
|
16057
16075
|
} else {
|
|
@@ -16063,7 +16081,7 @@ var WalletMessageHandler = class {
|
|
|
16063
16081
|
const totalOffchain = settled + preconfirmed + recoverable + pendingRecovery;
|
|
16064
16082
|
const assetBalances = /* @__PURE__ */ new Map();
|
|
16065
16083
|
for (const vtxo of allVtxos) {
|
|
16066
|
-
if (
|
|
16084
|
+
if (chunkDSTYXT2D_cjs.hasTerminalSpend(vtxo)) continue;
|
|
16067
16085
|
if (vtxo.assets) {
|
|
16068
16086
|
for (const a of vtxo.assets) {
|
|
16069
16087
|
const current = assetBalances.get(a.assetId) ?? 0n;
|
|
@@ -16099,7 +16117,7 @@ var WalletMessageHandler = class {
|
|
|
16099
16117
|
*/
|
|
16100
16118
|
async getSpendableVtxos() {
|
|
16101
16119
|
const vtxos = await this.getVtxosFromRepo();
|
|
16102
|
-
return vtxos.filter((v) => !
|
|
16120
|
+
return vtxos.filter((v) => !chunkDSTYXT2D_cjs.hasTerminalSpend(v));
|
|
16103
16121
|
}
|
|
16104
16122
|
async onWalletInitialized() {
|
|
16105
16123
|
if (!this.readonlyWallet || !this.arkProvider || !this.indexerProvider || !this.walletRepository) {
|
|
@@ -16311,10 +16329,10 @@ var WalletMessageHandler = class {
|
|
|
16311
16329
|
if (dustAmount != null && isSubdust(v, dustAmount)) {
|
|
16312
16330
|
return false;
|
|
16313
16331
|
}
|
|
16314
|
-
if (
|
|
16332
|
+
if (chunkDSTYXT2D_cjs.isRecoverable(v)) {
|
|
16315
16333
|
return false;
|
|
16316
16334
|
}
|
|
16317
|
-
if (
|
|
16335
|
+
if (chunkDSTYXT2D_cjs.isExpired(v)) {
|
|
16318
16336
|
return false;
|
|
16319
16337
|
}
|
|
16320
16338
|
return true;
|
|
@@ -16386,7 +16404,7 @@ var WalletMessageHandler = class {
|
|
|
16386
16404
|
if (!this.readonlyWallet) return null;
|
|
16387
16405
|
const { boardingTxs, commitmentsToIgnore } = await this.readonlyWallet.getBoardingTxs();
|
|
16388
16406
|
const indexerProvider = this.indexerProvider;
|
|
16389
|
-
const resolveTxCreatedAt = indexerProvider ? (txids) =>
|
|
16407
|
+
const resolveTxCreatedAt = indexerProvider ? (txids) => chunkDSTYXT2D_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
|
|
16390
16408
|
return buildTransactionHistory(vtxos, boardingTxs, commitmentsToIgnore, resolveTxCreatedAt);
|
|
16391
16409
|
}
|
|
16392
16410
|
async ensureContractEventBroadcasting() {
|
|
@@ -17071,7 +17089,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
17071
17089
|
};
|
|
17072
17090
|
try {
|
|
17073
17091
|
const response = await this.sendMessage(message);
|
|
17074
|
-
return response.payload.vtxos.map(
|
|
17092
|
+
return response.payload.vtxos.map(chunkDSTYXT2D_cjs.normalizeVtxo);
|
|
17075
17093
|
} catch (error) {
|
|
17076
17094
|
throw new Error(`Failed to get vtxos: ${error}`);
|
|
17077
17095
|
}
|
|
@@ -17184,7 +17202,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
17184
17202
|
};
|
|
17185
17203
|
try {
|
|
17186
17204
|
const response = await sendContractMessage(message);
|
|
17187
|
-
return response.payload.vtxos.map(
|
|
17205
|
+
return response.payload.vtxos.map(chunkDSTYXT2D_cjs.normalizeVtxo);
|
|
17188
17206
|
} catch (e) {
|
|
17189
17207
|
throw new Error("Failed to annotate vtxos");
|
|
17190
17208
|
}
|
|
@@ -17640,7 +17658,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
17640
17658
|
};
|
|
17641
17659
|
try {
|
|
17642
17660
|
const response = await wallet.sendMessage(message);
|
|
17643
|
-
return response.payload.vtxos.map(
|
|
17661
|
+
return response.payload.vtxos.map(chunkDSTYXT2D_cjs.normalizeVtxo);
|
|
17644
17662
|
} catch (e) {
|
|
17645
17663
|
throw new Error(`Failed to get expiring vtxos: ${e}`);
|
|
17646
17664
|
}
|
|
@@ -17752,12 +17770,12 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
17752
17770
|
* @returns Configured onchain wallet
|
|
17753
17771
|
* @throws Error if the configured identity cannot produce a valid x-only public key
|
|
17754
17772
|
*/
|
|
17755
|
-
static async create(identity, networkName =
|
|
17773
|
+
static async create(identity, networkName = chunkDSTYXT2D_cjs.DEFAULT_NETWORK_NAME, provider) {
|
|
17756
17774
|
const pubkey = await identity.xOnlyPublicKey();
|
|
17757
17775
|
if (!pubkey) {
|
|
17758
17776
|
throw new Error("Invalid configured public key");
|
|
17759
17777
|
}
|
|
17760
|
-
const network =
|
|
17778
|
+
const network = chunkDSTYXT2D_cjs.getNetwork(networkName);
|
|
17761
17779
|
const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
|
|
17762
17780
|
const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
|
|
17763
17781
|
return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
|
|
@@ -17863,7 +17881,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
17863
17881
|
if (!inputs) {
|
|
17864
17882
|
throw new Error("Fee estimation failed");
|
|
17865
17883
|
}
|
|
17866
|
-
let tx = new
|
|
17884
|
+
let tx = new chunkDSTYXT2D_cjs.Transaction();
|
|
17867
17885
|
for (const input of inputs) {
|
|
17868
17886
|
tx.addInput({
|
|
17869
17887
|
txid: input.txid,
|
|
@@ -17921,7 +17939,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
17921
17939
|
* @throws If the parent has no anchor, or funding cannot be selected/signed
|
|
17922
17940
|
*/
|
|
17923
17941
|
async bumpAnchor(parentHex, feeRate) {
|
|
17924
|
-
const parent =
|
|
17942
|
+
const parent = chunkDSTYXT2D_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
|
|
17925
17943
|
const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
|
|
17926
17944
|
const child = await this.buildBumpPackage(parent, feeRate, coins);
|
|
17927
17945
|
return [parent.hex, child.hex];
|
|
@@ -18686,7 +18704,7 @@ exports.BIP322 = void 0;
|
|
|
18686
18704
|
async function sign2(message, identity, network) {
|
|
18687
18705
|
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
18688
18706
|
const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
|
|
18689
|
-
const toSpend =
|
|
18707
|
+
const toSpend = chunkDSTYXT2D_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
18690
18708
|
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
18691
18709
|
const signed = await identity.sign(toSign, [0]);
|
|
18692
18710
|
signed.finalizeIdx(0);
|
|
@@ -18744,7 +18762,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
|
18744
18762
|
if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
|
|
18745
18763
|
return false;
|
|
18746
18764
|
}
|
|
18747
|
-
const toSpend =
|
|
18765
|
+
const toSpend = chunkDSTYXT2D_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
18748
18766
|
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
|
|
18749
18767
|
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
18750
18768
|
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
@@ -18765,7 +18783,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
|
18765
18783
|
}
|
|
18766
18784
|
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
18767
18785
|
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
18768
|
-
const toSpend =
|
|
18786
|
+
const toSpend = chunkDSTYXT2D_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
18769
18787
|
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
18770
18788
|
const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
|
|
18771
18789
|
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
@@ -18818,7 +18836,7 @@ function encodeCompactSize(n) {
|
|
|
18818
18836
|
return buf;
|
|
18819
18837
|
}
|
|
18820
18838
|
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
18821
|
-
const tx = new
|
|
18839
|
+
const tx = new chunkDSTYXT2D_cjs.Transaction({ version: 0 });
|
|
18822
18840
|
tx.addInput({
|
|
18823
18841
|
txid: toSpend.id,
|
|
18824
18842
|
index: 0,
|
|
@@ -18832,12 +18850,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
|
18832
18850
|
});
|
|
18833
18851
|
tx.addOutput({
|
|
18834
18852
|
amount: 0n,
|
|
18835
|
-
script:
|
|
18853
|
+
script: chunkDSTYXT2D_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
18836
18854
|
});
|
|
18837
18855
|
return tx;
|
|
18838
18856
|
}
|
|
18839
18857
|
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
18840
|
-
const tx = new
|
|
18858
|
+
const tx = new chunkDSTYXT2D_cjs.Transaction({ version: 0 });
|
|
18841
18859
|
tx.addInput({
|
|
18842
18860
|
txid: toSpend.id,
|
|
18843
18861
|
index: 0,
|
|
@@ -18849,7 +18867,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
|
18849
18867
|
});
|
|
18850
18868
|
tx.addOutput({
|
|
18851
18869
|
amount: 0n,
|
|
18852
|
-
script:
|
|
18870
|
+
script: chunkDSTYXT2D_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
18853
18871
|
});
|
|
18854
18872
|
return tx;
|
|
18855
18873
|
}
|
|
@@ -18980,7 +18998,7 @@ var RestEmulatorProvider = class {
|
|
|
18980
18998
|
}
|
|
18981
18999
|
};
|
|
18982
19000
|
function finalizeVirtualTx(type, psbtBase64) {
|
|
18983
|
-
const tx =
|
|
19001
|
+
const tx = chunkDSTYXT2D_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
18984
19002
|
if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
|
|
18985
19003
|
const input = tx.getInput(0);
|
|
18986
19004
|
if (!input) {
|
|
@@ -19007,14 +19025,14 @@ var ExitPathError = class extends Error {
|
|
|
19007
19025
|
reason;
|
|
19008
19026
|
};
|
|
19009
19027
|
function delayWeight(sequence) {
|
|
19010
|
-
const t =
|
|
19028
|
+
const t = chunkDSTYXT2D_cjs.sequenceToTimelock(sequence);
|
|
19011
19029
|
return t.type === "blocks" ? Number(t.value) : Number(t.value) / 600;
|
|
19012
19030
|
}
|
|
19013
19031
|
async function resolveUnilateralPath(params) {
|
|
19014
19032
|
const { vtxo, scriptHex, contractRepository } = params;
|
|
19015
19033
|
const contract = contractRepository ? (await contractRepository.getContracts({ script: scriptHex }))[0] : void 0;
|
|
19016
19034
|
if (contract) {
|
|
19017
|
-
const handler =
|
|
19035
|
+
const handler = chunk2XO43UHI_cjs.contractHandlers.get(contract.type);
|
|
19018
19036
|
if (!handler) {
|
|
19019
19037
|
throw new ExitPathError(
|
|
19020
19038
|
"no-handler",
|
|
@@ -19037,12 +19055,12 @@ async function resolveUnilateralPath(params) {
|
|
|
19037
19055
|
paths.sort((a, b) => delayWeight(a.sequence) - delayWeight(b.sequence));
|
|
19038
19056
|
return { selection: paths[0], label: `${contract.type}:unilateral` };
|
|
19039
19057
|
}
|
|
19040
|
-
const decoded =
|
|
19058
|
+
const decoded = chunkDSTYXT2D_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
19041
19059
|
let best;
|
|
19042
19060
|
for (const exit of decoded.exitPaths()) {
|
|
19043
19061
|
const leaf = decoded.findLeaf(base.hex.encode(exit.script));
|
|
19044
19062
|
if (!leaf) continue;
|
|
19045
|
-
const sequence =
|
|
19063
|
+
const sequence = chunkDSTYXT2D_cjs.timelockToSequence(exit.params.timelock);
|
|
19046
19064
|
const weight = delayWeight(sequence);
|
|
19047
19065
|
if (!best || weight < best.weight) {
|
|
19048
19066
|
best = { selection: { leaf, sequence }, weight };
|
|
@@ -19228,14 +19246,14 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
19228
19246
|
}
|
|
19229
19247
|
const resolved = await resolveUnilateralPath({
|
|
19230
19248
|
vtxo,
|
|
19231
|
-
scriptHex: base.hex.encode(
|
|
19249
|
+
scriptHex: base.hex.encode(chunkDSTYXT2D_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
19232
19250
|
contractRepository: wallet.contractRepository,
|
|
19233
19251
|
walletPubKeyHex: base.hex.encode(await wallet.identity.xOnlyPublicKey()),
|
|
19234
19252
|
currentTime: Date.now()
|
|
19235
19253
|
});
|
|
19236
19254
|
const spendingLeaf = resolved.selection.leaf;
|
|
19237
19255
|
const sequence = resolved.selection.sequence;
|
|
19238
|
-
const timelock =
|
|
19256
|
+
const timelock = chunkDSTYXT2D_cjs.sequenceToTimelock(sequence);
|
|
19239
19257
|
const elapsed = timelock.type === "blocks" ? chainTip.height >= txStatus.blockHeight + Number(timelock.value) : chainTip.time >= txStatus.blockTime + Number(timelock.value);
|
|
19240
19258
|
if (!elapsed) {
|
|
19241
19259
|
throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
|
|
@@ -19248,7 +19266,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
19248
19266
|
sequence,
|
|
19249
19267
|
witnessUtxo: {
|
|
19250
19268
|
amount: BigInt(vtxo.value),
|
|
19251
|
-
script:
|
|
19269
|
+
script: chunkDSTYXT2D_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
|
|
19252
19270
|
},
|
|
19253
19271
|
sighashType: btcSigner.SigHash.DEFAULT
|
|
19254
19272
|
});
|
|
@@ -19258,7 +19276,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
19258
19276
|
btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
|
|
19259
19277
|
);
|
|
19260
19278
|
}
|
|
19261
|
-
const tx = new
|
|
19279
|
+
const tx = new chunkDSTYXT2D_cjs.Transaction({ version: 2 });
|
|
19262
19280
|
for (const input of inputs) {
|
|
19263
19281
|
tx.addInput(input);
|
|
19264
19282
|
}
|
|
@@ -19325,7 +19343,7 @@ async function buildSignedSweep(params) {
|
|
|
19325
19343
|
`uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
|
|
19326
19344
|
);
|
|
19327
19345
|
}
|
|
19328
|
-
const tx = new
|
|
19346
|
+
const tx = new chunkDSTYXT2D_cjs.Transaction({ version: 2 });
|
|
19329
19347
|
tx.addInput({
|
|
19330
19348
|
txid: vtxo.txid,
|
|
19331
19349
|
index: vtxo.vout,
|
|
@@ -19350,7 +19368,7 @@ async function buildSignedSweep(params) {
|
|
|
19350
19368
|
finalScriptWitness: [
|
|
19351
19369
|
tapScriptSig[0][1],
|
|
19352
19370
|
...path.extraWitness,
|
|
19353
|
-
|
|
19371
|
+
chunkDSTYXT2D_cjs.scriptFromTapLeafScript(path.leaf),
|
|
19354
19372
|
btcSigner.TaprootControlBlock.encode(controlBlock)
|
|
19355
19373
|
]
|
|
19356
19374
|
});
|
|
@@ -19380,7 +19398,7 @@ async function resolveFeeRate(opts) {
|
|
|
19380
19398
|
}
|
|
19381
19399
|
async function selectExitVtxos(opts) {
|
|
19382
19400
|
if (!opts.vtxos) return opts.wallet.getVtxos();
|
|
19383
|
-
const res = await
|
|
19401
|
+
const res = await chunkDSTYXT2D_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
|
|
19384
19402
|
const tapTrees = /* @__PURE__ */ new Map();
|
|
19385
19403
|
const out = [];
|
|
19386
19404
|
for (const vtxo of res.vtxos) {
|
|
@@ -19395,7 +19413,7 @@ async function selectExitVtxos(opts) {
|
|
|
19395
19413
|
`no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
|
|
19396
19414
|
);
|
|
19397
19415
|
}
|
|
19398
|
-
const handler =
|
|
19416
|
+
const handler = chunk2XO43UHI_cjs.contractHandlers.get(contract.type);
|
|
19399
19417
|
if (!handler) {
|
|
19400
19418
|
throw new Error(`no contract handler registered for type '${contract.type}'`);
|
|
19401
19419
|
}
|
|
@@ -19425,7 +19443,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
19425
19443
|
if (pendingNodes.length > 0) {
|
|
19426
19444
|
const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
|
|
19427
19445
|
for (const psbt of txs) {
|
|
19428
|
-
psbts.set(
|
|
19446
|
+
psbts.set(chunkDSTYXT2D_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
19429
19447
|
}
|
|
19430
19448
|
}
|
|
19431
19449
|
const childVsize = Number(
|
|
@@ -19461,7 +19479,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
19461
19479
|
try {
|
|
19462
19480
|
const resolved = await resolveUnilateralPath({
|
|
19463
19481
|
vtxo,
|
|
19464
|
-
scriptHex: base.hex.encode(
|
|
19482
|
+
scriptHex: base.hex.encode(chunkDSTYXT2D_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
19465
19483
|
contractRepository: wallet.contractRepository,
|
|
19466
19484
|
walletPubKeyHex,
|
|
19467
19485
|
currentTime: Date.now()
|
|
@@ -19480,7 +19498,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
19480
19498
|
});
|
|
19481
19499
|
continue;
|
|
19482
19500
|
}
|
|
19483
|
-
const t =
|
|
19501
|
+
const t = chunkDSTYXT2D_cjs.sequenceToTimelock(resolved.selection.sequence);
|
|
19484
19502
|
const delay = { type: t.type, value: Number(t.value) };
|
|
19485
19503
|
infos.push({ outpoint, value: vtxo.value, sweepFee, path: resolved.label, delay });
|
|
19486
19504
|
sweeps.push({ vtxo, resolved, sweepFee, delay });
|
|
@@ -19819,7 +19837,7 @@ async function prepare(opts) {
|
|
|
19819
19837
|
txid: sweep.vtxo.txid,
|
|
19820
19838
|
vout: sweep.vtxo.vout,
|
|
19821
19839
|
value: sweep.vtxo.value,
|
|
19822
|
-
pkScript:
|
|
19840
|
+
pkScript: chunkDSTYXT2D_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
|
|
19823
19841
|
},
|
|
19824
19842
|
path: sweep.resolved.selection,
|
|
19825
19843
|
outputAddress: opts.sweepAddress,
|
|
@@ -19904,7 +19922,7 @@ async function prepare(opts) {
|
|
|
19904
19922
|
if (newFee <= splitterFee) break;
|
|
19905
19923
|
splitterFee = newFee;
|
|
19906
19924
|
}
|
|
19907
|
-
const splitter = new
|
|
19925
|
+
const splitter = new chunkDSTYXT2D_cjs.Transaction({ version: 2 });
|
|
19908
19926
|
for (const coin of selected.inputs) {
|
|
19909
19927
|
splitter.addInput({
|
|
19910
19928
|
txid: coin.txid,
|
|
@@ -20047,41 +20065,41 @@ var UnilateralExit = {
|
|
|
20047
20065
|
// src/arkade/index.ts
|
|
20048
20066
|
var arkade_exports = {};
|
|
20049
20067
|
chunk5BLDMQED_cjs.__export(arkade_exports, {
|
|
20050
|
-
ARKADE_OP: () =>
|
|
20051
|
-
ARKADE_OPCODES: () =>
|
|
20052
|
-
ARKADE_OPCODE_NAMES: () =>
|
|
20053
|
-
ARKADE_OPCODE_VALUES: () =>
|
|
20054
|
-
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,
|
|
20055
20073
|
Arkade: () => Arkade,
|
|
20056
20074
|
ArkadeContract: () => ArkadeContract,
|
|
20057
|
-
ArkadeProgramScript: () =>
|
|
20058
|
-
ArkadeScript: () =>
|
|
20075
|
+
ArkadeProgramScript: () => chunk2XO43UHI_cjs.ArkadeProgramScript,
|
|
20076
|
+
ArkadeScript: () => chunk2XO43UHI_cjs.ArkadeScript,
|
|
20059
20077
|
ArkadeTransactionBuilder: () => ArkadeTransactionBuilder,
|
|
20060
|
-
BigNum: () =>
|
|
20078
|
+
BigNum: () => chunk2XO43UHI_cjs.bignum_exports,
|
|
20061
20079
|
OP: () => btcSigner.OP,
|
|
20062
|
-
OPCODE_NAMES: () =>
|
|
20063
|
-
OPCODE_VALUES: () =>
|
|
20064
|
-
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,
|
|
20065
20083
|
Script: () => btcSigner.Script,
|
|
20066
|
-
arkadeScriptHash: () =>
|
|
20067
|
-
arkadeWitnessHash: () =>
|
|
20068
|
-
asmToBytes: () =>
|
|
20069
|
-
bytesToASM: () =>
|
|
20070
|
-
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,
|
|
20071
20089
|
createArkadeBatchHandler: () => createArkadeBatchHandler,
|
|
20072
|
-
deserializeArkadeContractParams: () =>
|
|
20073
|
-
fromASM: () =>
|
|
20074
|
-
getOpcodeName: () =>
|
|
20075
|
-
getOpcodeValue: () =>
|
|
20076
|
-
parseArtifact: () =>
|
|
20077
|
-
resolveAsm: () =>
|
|
20078
|
-
serializeArkadeContractParams: () =>
|
|
20079
|
-
stringifyArtifact: () =>
|
|
20080
|
-
toASM: () =>
|
|
20081
|
-
validateProgram: () =>
|
|
20082
|
-
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
|
|
20083
20101
|
});
|
|
20084
|
-
var isVtxoCoin = (input) =>
|
|
20102
|
+
var isVtxoCoin = (input) => chunkDSTYXT2D_cjs.isVirtualCoin(input);
|
|
20085
20103
|
function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
|
|
20086
20104
|
let batchId;
|
|
20087
20105
|
let sweepTapTreeRoot;
|
|
@@ -20102,7 +20120,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
20102
20120
|
);
|
|
20103
20121
|
await arkProvider.confirmRegistration(intentId);
|
|
20104
20122
|
batchId = event.id;
|
|
20105
|
-
const sweepTapscript =
|
|
20123
|
+
const sweepTapscript = chunkDSTYXT2D_cjs.CSVMultisigTapscript.encode({
|
|
20106
20124
|
timelock,
|
|
20107
20125
|
pubkeys: [base.hex.decode(info.forfeitPubkey).subarray(1)]
|
|
20108
20126
|
}).script;
|
|
@@ -20116,7 +20134,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
20116
20134
|
if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
|
|
20117
20135
|
return { skip: true };
|
|
20118
20136
|
}
|
|
20119
|
-
const commitmentTx =
|
|
20137
|
+
const commitmentTx = chunkDSTYXT2D_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
|
|
20120
20138
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
20121
20139
|
if (recipients && recipients.length > 0) {
|
|
20122
20140
|
validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
|
|
@@ -20148,7 +20166,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
20148
20166
|
if (connectorTree) {
|
|
20149
20167
|
validateConnectorsTxGraph(event.commitmentTx, connectorTree);
|
|
20150
20168
|
}
|
|
20151
|
-
let commitmentPsbt =
|
|
20169
|
+
let commitmentPsbt = chunkDSTYXT2D_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
20152
20170
|
assertFinalCommitmentMatchesValidated(
|
|
20153
20171
|
commitmentPsbt,
|
|
20154
20172
|
validatedCommitmentTxid,
|
|
@@ -20183,7 +20201,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
20183
20201
|
boardingIndices.push(boardingIdx);
|
|
20184
20202
|
continue;
|
|
20185
20203
|
}
|
|
20186
|
-
if (
|
|
20204
|
+
if (chunkDSTYXT2D_cjs.isRecoverable(input) || isSubdust(input, info.dust)) {
|
|
20187
20205
|
continue;
|
|
20188
20206
|
}
|
|
20189
20207
|
if (connectorIndex >= connectorLeaves.length) {
|
|
@@ -20204,7 +20222,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
20204
20222
|
index: input.vout,
|
|
20205
20223
|
witnessUtxo: {
|
|
20206
20224
|
amount: BigInt(input.value),
|
|
20207
|
-
script:
|
|
20225
|
+
script: chunkDSTYXT2D_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
20208
20226
|
},
|
|
20209
20227
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
20210
20228
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -20262,7 +20280,16 @@ var Arkade = class _Arkade {
|
|
|
20262
20280
|
emulator;
|
|
20263
20281
|
network;
|
|
20264
20282
|
serverKey;
|
|
20265
|
-
/**
|
|
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
|
+
*/
|
|
20266
20293
|
emulatorKey;
|
|
20267
20294
|
checkpoint;
|
|
20268
20295
|
indexer;
|
|
@@ -20287,11 +20314,11 @@ var Arkade = class _Arkade {
|
|
|
20287
20314
|
static async connect(opts) {
|
|
20288
20315
|
const info = await opts.arkade.getInfo();
|
|
20289
20316
|
const serverKey = base.hex.decode(info.signerPubkey).slice(1);
|
|
20290
|
-
const checkpoint =
|
|
20317
|
+
const checkpoint = chunkDSTYXT2D_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
20318
|
+
const network = opts.network ?? chunkDSTYXT2D_cjs.DEFAULT_NETWORK;
|
|
20291
20319
|
let emulatorKey;
|
|
20292
20320
|
if (opts.emulator) {
|
|
20293
|
-
|
|
20294
|
-
emulatorKey = base.hex.decode(eInfo.signerPubkey);
|
|
20321
|
+
emulatorKey = base.hex.decode(chunkDSTYXT2D_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
|
|
20295
20322
|
}
|
|
20296
20323
|
let userKey;
|
|
20297
20324
|
if (opts.identity) {
|
|
@@ -20301,7 +20328,7 @@ var Arkade = class _Arkade {
|
|
|
20301
20328
|
return new _Arkade({
|
|
20302
20329
|
arkProvider: opts.arkade,
|
|
20303
20330
|
emulator: opts.emulator,
|
|
20304
|
-
network
|
|
20331
|
+
network,
|
|
20305
20332
|
serverKey,
|
|
20306
20333
|
emulatorKey,
|
|
20307
20334
|
checkpoint,
|
|
@@ -20322,7 +20349,7 @@ var Arkade = class _Arkade {
|
|
|
20322
20349
|
* key respectively; explicit args always win.
|
|
20323
20350
|
*/
|
|
20324
20351
|
contract(program, args = {}) {
|
|
20325
|
-
const declared = (program.params ?? []).map(
|
|
20352
|
+
const declared = (program.params ?? []).map(chunk2XO43UHI_cjs.inputName);
|
|
20326
20353
|
if (declared.includes("server") && args.server === void 0) {
|
|
20327
20354
|
args = { ...args, server: this.serverKey };
|
|
20328
20355
|
}
|
|
@@ -20342,7 +20369,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
20342
20369
|
userKey: client.userKey,
|
|
20343
20370
|
emulatorKey: client.emulatorKey
|
|
20344
20371
|
};
|
|
20345
|
-
this.vtxoScript = new
|
|
20372
|
+
this.vtxoScript = new chunk2XO43UHI_cjs.ArkadeProgramScript(program, args, this.keys);
|
|
20346
20373
|
this.tapTree = this.vtxoScript.encode();
|
|
20347
20374
|
this.compiled = this.vtxoScript.compiled;
|
|
20348
20375
|
}
|
|
@@ -20370,7 +20397,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
20370
20397
|
`ArkadeContract.fromContract: expected contract type 'arkade', got '${contract.type}'`
|
|
20371
20398
|
);
|
|
20372
20399
|
}
|
|
20373
|
-
const typed =
|
|
20400
|
+
const typed = chunk2XO43UHI_cjs.deserializeArkadeContractParams(contract.params);
|
|
20374
20401
|
return new _ArkadeContract(client, typed.program, typed.args, {
|
|
20375
20402
|
serverKey: typed.serverKey,
|
|
20376
20403
|
userKey: typed.userKey,
|
|
@@ -20411,7 +20438,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
20411
20438
|
toContractParams() {
|
|
20412
20439
|
return {
|
|
20413
20440
|
type: "arkade",
|
|
20414
|
-
params:
|
|
20441
|
+
params: chunk2XO43UHI_cjs.serializeArkadeContractParams({
|
|
20415
20442
|
program: this.program,
|
|
20416
20443
|
args: this.args,
|
|
20417
20444
|
serverKey: this.keys.serverKey,
|
|
@@ -20456,13 +20483,13 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
20456
20483
|
const [registered] = await manager.getContracts({ script: scriptHex });
|
|
20457
20484
|
if (registered) {
|
|
20458
20485
|
const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
|
|
20459
|
-
return (withVtxos?.vtxos ?? []).filter((v) => !
|
|
20486
|
+
return (withVtxos?.vtxos ?? []).filter((v) => !chunkDSTYXT2D_cjs.hasTerminalSpend(v));
|
|
20460
20487
|
}
|
|
20461
20488
|
}
|
|
20462
20489
|
if (!this.client.indexer) {
|
|
20463
20490
|
throw new Error("ArkadeContract.getUtxos: an indexer is required");
|
|
20464
20491
|
}
|
|
20465
|
-
const { vtxos } = await
|
|
20492
|
+
const { vtxos } = await chunkDSTYXT2D_cjs.getNormalizedVtxos(this.client.indexer, {
|
|
20466
20493
|
scripts: [scriptHex],
|
|
20467
20494
|
spendableOnly: true
|
|
20468
20495
|
});
|
|
@@ -20564,12 +20591,12 @@ var ArkadeTransactionBuilder = class {
|
|
|
20564
20591
|
this.contract.client.checkpoint
|
|
20565
20592
|
);
|
|
20566
20593
|
if (coin.sourceTx) {
|
|
20567
|
-
|
|
20594
|
+
chunkDSTYXT2D_cjs.setArkPsbtField(arkTx, 0, chunkDSTYXT2D_cjs.PrevArkTxField, coin.sourceTx);
|
|
20568
20595
|
}
|
|
20569
20596
|
const condition = (def.tapscript.witness ?? []).map((w) => this.witnessBytes(w));
|
|
20570
20597
|
if (condition.length > 0) {
|
|
20571
|
-
|
|
20572
|
-
|
|
20598
|
+
chunkDSTYXT2D_cjs.setArkPsbtField(arkTx, 0, chunkDSTYXT2D_cjs.ConditionWitness, condition);
|
|
20599
|
+
chunkDSTYXT2D_cjs.setArkPsbtField(checkpoints[0], 0, chunkDSTYXT2D_cjs.ConditionWitness, condition);
|
|
20573
20600
|
}
|
|
20574
20601
|
const packets = [];
|
|
20575
20602
|
if (this.assetSpecs.length > 0) {
|
|
@@ -20608,7 +20635,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
20608
20635
|
base.base64.encode(signedArk2.toPSBT()),
|
|
20609
20636
|
signedCps.map((c) => base.base64.encode(c.toPSBT()))
|
|
20610
20637
|
);
|
|
20611
|
-
const txid =
|
|
20638
|
+
const txid = chunkDSTYXT2D_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
|
|
20612
20639
|
return {
|
|
20613
20640
|
txid,
|
|
20614
20641
|
signedArkTx: res2.signedArkTx,
|
|
@@ -20667,23 +20694,23 @@ var ArkadeTransactionBuilder = class {
|
|
|
20667
20694
|
}
|
|
20668
20695
|
buildAssetPacket() {
|
|
20669
20696
|
const groups = this.assetSpecs.map((s) => {
|
|
20670
|
-
const id = typeof s.assetId === "string" ?
|
|
20671
|
-
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(
|
|
20672
20699
|
id,
|
|
20673
20700
|
null,
|
|
20674
|
-
s.inputs.map((i) =>
|
|
20675
|
-
s.outputs.map((o) =>
|
|
20676
|
-
(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))
|
|
20677
20704
|
);
|
|
20678
20705
|
});
|
|
20679
|
-
return
|
|
20706
|
+
return chunkV2KENVN6_cjs.Packet.create(groups);
|
|
20680
20707
|
}
|
|
20681
20708
|
witnessBytes(ref) {
|
|
20682
|
-
return
|
|
20709
|
+
return chunk2XO43UHI_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
|
|
20683
20710
|
}
|
|
20684
20711
|
};
|
|
20685
20712
|
function bindInputs(fn, callArgs) {
|
|
20686
|
-
const names = (fn.def.inputs ?? []).map(
|
|
20713
|
+
const names = (fn.def.inputs ?? []).map(chunk2XO43UHI_cjs.inputName);
|
|
20687
20714
|
if (callArgs.length !== names.length) {
|
|
20688
20715
|
throw new Error(`${fn.name}: expected ${names.length} argument(s), got ${callArgs.length}`);
|
|
20689
20716
|
}
|
|
@@ -21090,7 +21117,7 @@ function decodeArkContract(encoded) {
|
|
|
21090
21117
|
}
|
|
21091
21118
|
function contractFromArkContract(encoded, options = {}) {
|
|
21092
21119
|
const parsed = decodeArkContract(encoded);
|
|
21093
|
-
const handler =
|
|
21120
|
+
const handler = chunk2XO43UHI_cjs.contractHandlers.get(parsed.type);
|
|
21094
21121
|
if (!handler) {
|
|
21095
21122
|
throw new Error(`No handler registered for contract type '${parsed.type}'`);
|
|
21096
21123
|
}
|
|
@@ -21104,9 +21131,9 @@ function contractFromArkContract(encoded, options = {}) {
|
|
|
21104
21131
|
metadata: options.metadata
|
|
21105
21132
|
};
|
|
21106
21133
|
}
|
|
21107
|
-
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix =
|
|
21134
|
+
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkDSTYXT2D_cjs.DEFAULT_NETWORK.hrp, options = {}) {
|
|
21108
21135
|
const parsed = decodeArkContract(encoded);
|
|
21109
|
-
const handler =
|
|
21136
|
+
const handler = chunk2XO43UHI_cjs.contractHandlers.getOrThrow(parsed.type);
|
|
21110
21137
|
const params = parsed.data;
|
|
21111
21138
|
const vtxoScript = handler.createScript(params);
|
|
21112
21139
|
return {
|
|
@@ -21170,6 +21197,7 @@ exports.IndexedDBWalletRepository = IndexedDBWalletRepository;
|
|
|
21170
21197
|
exports.MESSAGE_BUS_INITIALIZING = MESSAGE_BUS_INITIALIZING;
|
|
21171
21198
|
exports.MESSAGE_BUS_NOT_INITIALIZED = MESSAGE_BUS_NOT_INITIALIZED;
|
|
21172
21199
|
exports.MIGRATION_KEY = MIGRATION_KEY;
|
|
21200
|
+
exports.MUTINYNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS = MUTINYNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS;
|
|
21173
21201
|
exports.MessageBus = MessageBus;
|
|
21174
21202
|
exports.MessageBusInitializingError = MessageBusInitializingError;
|
|
21175
21203
|
exports.MessageBusNotInitializedError = MessageBusNotInitializedError;
|
|
@@ -21189,6 +21217,7 @@ exports.ReadonlyWalletError = ReadonlyWalletError;
|
|
|
21189
21217
|
exports.RestDelegateProvider = RestDelegateProvider;
|
|
21190
21218
|
exports.RestDelegatorProvider = RestDelegatorProvider;
|
|
21191
21219
|
exports.RestEmulatorProvider = RestEmulatorProvider;
|
|
21220
|
+
exports.SIGNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS = SIGNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS;
|
|
21192
21221
|
exports.SeedIdentity = SeedIdentity;
|
|
21193
21222
|
exports.ServiceWorkerReadonlyWallet = ServiceWorkerReadonlyWallet;
|
|
21194
21223
|
exports.ServiceWorkerTimeoutError = ServiceWorkerTimeoutError;
|
|
@@ -21291,5 +21320,5 @@ exports.validateVtxoTxGraph = validateVtxoTxGraph;
|
|
|
21291
21320
|
exports.verifyTapscriptSignatures = verifyTapscriptSignatures;
|
|
21292
21321
|
exports.waitForIncomingFunds = waitForIncomingFunds;
|
|
21293
21322
|
exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
|
|
21294
|
-
//# sourceMappingURL=chunk-
|
|
21295
|
-
//# sourceMappingURL=chunk-
|
|
21323
|
+
//# sourceMappingURL=chunk-DYNB6POO.cjs.map
|
|
21324
|
+
//# sourceMappingURL=chunk-DYNB6POO.cjs.map
|