@arkade-os/sdk 0.4.57 → 0.4.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/expo.cjs +5 -5
- package/dist/adapters/expo.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +3 -3
- package/dist/adapters/indexedDB.cjs +5 -5
- package/dist/adapters/indexedDB.js +4 -4
- package/dist/{ark-CJgH_pmn.d.cts → ark-ClaVUg4e.d.cts} +11 -0
- package/dist/{ark-CJgH_pmn.d.ts → ark-ClaVUg4e.d.ts} +11 -0
- package/dist/{asyncStorageTaskQueue-BeeZbf-Q.d.ts → asyncStorageTaskQueue-Bgau-mvD.d.ts} +1 -1
- package/dist/{asyncStorageTaskQueue-BlrsUUX_.d.cts → asyncStorageTaskQueue-CnYrhpS-.d.cts} +1 -1
- package/dist/{chunk-KEG4AAKX.cjs → chunk-6PY4WYXI.cjs} +485 -394
- package/dist/chunk-6PY4WYXI.cjs.map +1 -0
- package/dist/{chunk-CPS7V4A3.js → chunk-AGWZXGG2.js} +4 -4
- package/dist/{chunk-CPS7V4A3.js.map → chunk-AGWZXGG2.js.map} +1 -1
- package/dist/{chunk-OWTKOMJZ.cjs → chunk-COLJARV4.cjs} +40 -40
- package/dist/{chunk-OWTKOMJZ.cjs.map → chunk-COLJARV4.cjs.map} +1 -1
- package/dist/{chunk-KUN5ZRMW.cjs → chunk-D6RGHPZ5.cjs} +3 -3
- package/dist/{chunk-KUN5ZRMW.cjs.map → chunk-D6RGHPZ5.cjs.map} +1 -1
- package/dist/{chunk-YK6NP5KX.cjs → chunk-F4C67JYB.cjs} +15 -15
- package/dist/{chunk-YK6NP5KX.cjs.map → chunk-F4C67JYB.cjs.map} +1 -1
- package/dist/{chunk-EZBKSWEL.cjs → chunk-I4YEGI2R.cjs} +17 -17
- package/dist/{chunk-EZBKSWEL.cjs.map → chunk-I4YEGI2R.cjs.map} +1 -1
- package/dist/{chunk-P6L2W5IL.js → chunk-IPPASJE5.js} +3 -3
- package/dist/{chunk-P6L2W5IL.js.map → chunk-IPPASJE5.js.map} +1 -1
- package/dist/{chunk-NIZPFPUM.js → chunk-S3BFUTC5.js} +112 -21
- package/dist/chunk-S3BFUTC5.js.map +1 -0
- package/dist/{chunk-C4SVRVNM.js → chunk-SGWMB4W2.js} +4 -4
- package/dist/{chunk-C4SVRVNM.js.map → chunk-SGWMB4W2.js.map} +1 -1
- package/dist/{chunk-A7TOVUYG.cjs → chunk-SYZEQF5D.cjs} +9 -9
- package/dist/{chunk-A7TOVUYG.cjs.map → chunk-SYZEQF5D.cjs.map} +1 -1
- package/dist/{chunk-ASUJNZ63.js → chunk-TV2RLVOB.js} +3 -3
- package/dist/{chunk-ASUJNZ63.js.map → chunk-TV2RLVOB.js.map} +1 -1
- package/dist/{chunk-PUNBWFIV.js → chunk-VROHHJL4.js} +3 -3
- package/dist/{chunk-PUNBWFIV.js.map → chunk-VROHHJL4.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-Dk-OJVdf.d.cts → delegate-CVrkEepn.d.cts} +1 -1
- package/dist/{delegate-DM3YECSY.d.ts → delegate-YDYq1El_.d.ts} +1 -1
- package/dist/{index-Cig0RkTf.d.cts → index-BmqkJBAf.d.cts} +2 -2
- package/dist/{index-CnE7Gnvb.d.ts → index-CuSHBkq7.d.ts} +2 -2
- package/dist/index.cjs +223 -223
- package/dist/index.d.cts +25 -8
- package/dist/index.d.ts +25 -8
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +19 -19
- package/dist/repositories/realm/index.d.cts +2 -2
- package/dist/repositories/realm/index.d.ts +2 -2
- package/dist/repositories/realm/index.js +5 -5
- package/dist/repositories/sqlite/index.cjs +18 -18
- package/dist/repositories/sqlite/index.d.cts +2 -2
- package/dist/repositories/sqlite/index.d.ts +2 -2
- package/dist/repositories/sqlite/index.js +5 -5
- package/dist/{taskRunner-F7tWzsrC.d.ts → taskRunner-CFN61bBM.d.ts} +1 -1
- package/dist/{taskRunner-CnGSTaAJ.d.cts → taskRunner-CFkGkD85.d.cts} +1 -1
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +6 -6
- package/dist/wallet/expo/index.cjs +14 -14
- package/dist/wallet/expo/index.d.cts +4 -4
- package/dist/wallet/expo/index.d.ts +4 -4
- package/dist/wallet/expo/index.js +5 -5
- package/dist/{wallet-D6_S0n6B.d.ts → wallet-DnK09TtT.d.ts} +2 -2
- package/dist/{wallet-DvRIQBBY.d.cts → wallet-hQp2qC_M.d.cts} +2 -2
- package/dist/worker/expo/index.cjs +9 -9
- package/dist/worker/expo/index.d.cts +4 -4
- package/dist/worker/expo/index.d.ts +4 -4
- package/dist/worker/expo/index.js +5 -5
- package/package.json +2 -2
- package/dist/chunk-KEG4AAKX.cjs.map +0 -1
- package/dist/chunk-NIZPFPUM.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkF4C67JYB_cjs = require('./chunk-F4C67JYB.cjs');
|
|
4
|
+
var chunkCOLJARV4_cjs = require('./chunk-COLJARV4.cjs');
|
|
5
|
+
var chunkD6RGHPZ5_cjs = require('./chunk-D6RGHPZ5.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 = chunkD6RGHPZ5_cjs.getArkPsbtFields(tx.root, 0, chunkD6RGHPZ5_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 = chunkD6RGHPZ5_cjs.getArkPsbtFields(g.root, 0, chunkD6RGHPZ5_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 = chunkCOLJARV4_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 chunkCOLJARV4_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 = chunkCOLJARV4_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 = chunkCOLJARV4_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 chunkCOLJARV4_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 chunkCOLJARV4_cjs.deriveDescriptorLeafPubKey(this.descriptor);
|
|
855
855
|
}
|
|
856
856
|
async compressedPublicKey() {
|
|
857
|
-
return
|
|
857
|
+
return chunkCOLJARV4_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 chunkD6RGHPZ5_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: chunkD6RGHPZ5_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 chunkD6RGHPZ5_cjs.rateGate.runHttp(url, () => chunkD6RGHPZ5_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[chunkD6RGHPZ5_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 chunkD6RGHPZ5_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 chunkD6RGHPZ5_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 chunkD6RGHPZ5_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 chunkD6RGHPZ5_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 chunkD6RGHPZ5_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 chunkD6RGHPZ5_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 chunkD6RGHPZ5_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 chunkD6RGHPZ5_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 chunkD6RGHPZ5_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 chunkD6RGHPZ5_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 chunkD6RGHPZ5_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 = chunkD6RGHPZ5_cjs.getArkPsbtFields(child.root, 0, chunkD6RGHPZ5_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 chunkF4C67JYB_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 chunkF4C67JYB_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 chunkF4C67JYB_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 chunkF4C67JYB_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 chunkF4C67JYB_cjs.Packet.PACKET_TYPE:
|
|
1858
|
+
return chunkF4C67JYB_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 chunkD6RGHPZ5_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
|
|
1906
|
+
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkD6RGHPZ5_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 chunkD6RGHPZ5_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
|
|
1910
|
+
var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkD6RGHPZ5_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 chunkD6RGHPZ5_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
|
|
1914
|
+
var ErrUnvalidatedOffchainOutput = (address) => new chunkD6RGHPZ5_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 chunkD6RGHPZ5_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 = chunkD6RGHPZ5_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
|
+
chunkD6RGHPZ5_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(chunkF4C67JYB_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
|
+
chunkF4C67JYB_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
|
+
chunkF4C67JYB_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
|
+
chunkF4C67JYB_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 = chunkF4C67JYB_cjs.AssetId.fromString(assetIdStr);
|
|
2252
|
+
const group = chunkF4C67JYB_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
|
|
2253
2253
|
groups.push(group);
|
|
2254
2254
|
}
|
|
2255
|
-
return
|
|
2255
|
+
return chunkF4C67JYB_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));
|
|
@@ -2337,13 +2337,13 @@ var toTimelock = (value) => ({
|
|
|
2337
2337
|
var toSeconds = (t) => t.type === "seconds" ? t.value : t.value * NOMINAL_BLOCK_SECONDS;
|
|
2338
2338
|
function assertTimelockInPolicy(timelock, policy, label) {
|
|
2339
2339
|
if (policy.requireSeconds && timelock.type === "blocks") {
|
|
2340
|
-
throw new
|
|
2340
|
+
throw new chunkD6RGHPZ5_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
|
|
2346
|
+
throw new chunkD6RGHPZ5_cjs.ServerResponseMismatchError(
|
|
2347
2347
|
`${label} rejected: ${timelock.value} ${timelock.type} is below the ${policy.minSeconds}s floor`
|
|
2348
2348
|
);
|
|
2349
2349
|
}
|
|
@@ -2364,7 +2364,7 @@ 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 chunkD6RGHPZ5_cjs.ServerResponseMismatchError(
|
|
2368
2368
|
`batch expiry rejected: ${batchExpiry} does not match the advertised vtxoTreeExpiry ${policy.advertisedVtxoTreeExpiry}`
|
|
2369
2369
|
);
|
|
2370
2370
|
}
|
|
@@ -2381,21 +2381,21 @@ function resolveCheckpointExitDelayPolicy(network, overrides) {
|
|
|
2381
2381
|
function assertValidServerUnrollScript(checkpointTapscript, policy) {
|
|
2382
2382
|
let script;
|
|
2383
2383
|
try {
|
|
2384
|
-
script =
|
|
2384
|
+
script = chunkD6RGHPZ5_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
|
|
2385
2385
|
} catch (e) {
|
|
2386
|
-
throw new
|
|
2386
|
+
throw new chunkD6RGHPZ5_cjs.ServerResponseMismatchError(
|
|
2387
2387
|
`checkpoint exit delay rejected: invalid checkpointTapscript from server (${e instanceof Error ? e.message : String(e)})`
|
|
2388
2388
|
);
|
|
2389
2389
|
}
|
|
2390
2390
|
if (policy.advertisedForfeitPubkey !== void 0) {
|
|
2391
2391
|
const { pubkeys } = script.params;
|
|
2392
2392
|
if (pubkeys.length !== 1) {
|
|
2393
|
-
throw new
|
|
2393
|
+
throw new chunkD6RGHPZ5_cjs.ServerResponseMismatchError(
|
|
2394
2394
|
`checkpoint exit delay rejected: checkpointTapscript must commit to exactly one pubkey, got ${pubkeys.length} [${pubkeys.map(base.hex.encode).join(", ")}]`
|
|
2395
2395
|
);
|
|
2396
2396
|
}
|
|
2397
2397
|
if (!utils_js.equalBytes(pubkeys[0], policy.advertisedForfeitPubkey)) {
|
|
2398
|
-
throw new
|
|
2398
|
+
throw new chunkD6RGHPZ5_cjs.ServerResponseMismatchError(
|
|
2399
2399
|
`checkpoint exit delay rejected: checkpointTapscript pubkey ${base.hex.encode(pubkeys[0])} does not match the advertised forfeitPubkey ${base.hex.encode(policy.advertisedForfeitPubkey)}`
|
|
2400
2400
|
);
|
|
2401
2401
|
}
|
|
@@ -2434,8 +2434,8 @@ function buildOffchainTx(inputs, outputs, serverUnrollScript) {
|
|
|
2434
2434
|
function buildVirtualTx(inputs, outputs) {
|
|
2435
2435
|
let lockTime = 0n;
|
|
2436
2436
|
for (const input of inputs) {
|
|
2437
|
-
const tapscript =
|
|
2438
|
-
if (
|
|
2437
|
+
const tapscript = chunkD6RGHPZ5_cjs.decodeTapscript(chunkD6RGHPZ5_cjs.scriptFromTapLeafScript(input.tapLeafScript));
|
|
2438
|
+
if (chunkD6RGHPZ5_cjs.CLTVMultisigTapscript.is(tapscript)) {
|
|
2439
2439
|
if (lockTime !== 0n) {
|
|
2440
2440
|
if (isSeconds(lockTime) !== isSeconds(tapscript.params.absoluteTimelock)) {
|
|
2441
2441
|
throw new Error("cannot mix seconds and blocks locktime");
|
|
@@ -2446,7 +2446,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
2446
2446
|
}
|
|
2447
2447
|
}
|
|
2448
2448
|
}
|
|
2449
|
-
const tx = new
|
|
2449
|
+
const tx = new chunkD6RGHPZ5_cjs.Transaction({
|
|
2450
2450
|
version: 3,
|
|
2451
2451
|
lockTime: Number(lockTime)
|
|
2452
2452
|
});
|
|
@@ -2456,12 +2456,12 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
2456
2456
|
index: input.vout,
|
|
2457
2457
|
sequence: lockTime ? btcSigner.DEFAULT_SEQUENCE - 1 : void 0,
|
|
2458
2458
|
witnessUtxo: {
|
|
2459
|
-
script:
|
|
2459
|
+
script: chunkD6RGHPZ5_cjs.VtxoScript.decode(input.tapTree).pkScript,
|
|
2460
2460
|
amount: BigInt(input.value)
|
|
2461
2461
|
},
|
|
2462
2462
|
tapLeafScript: [input.tapLeafScript]
|
|
2463
2463
|
});
|
|
2464
|
-
|
|
2464
|
+
chunkD6RGHPZ5_cjs.setArkPsbtField(tx, i, chunkD6RGHPZ5_cjs.VtxoTaprootTree, input.tapTree);
|
|
2465
2465
|
}
|
|
2466
2466
|
for (const output of outputs) {
|
|
2467
2467
|
tx.addOutput(output);
|
|
@@ -2470,8 +2470,8 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
2470
2470
|
return tx;
|
|
2471
2471
|
}
|
|
2472
2472
|
function buildCheckpointTx(vtxo, serverUnrollScript) {
|
|
2473
|
-
const collaborativeClosure =
|
|
2474
|
-
const checkpointVtxoScript = new
|
|
2473
|
+
const collaborativeClosure = chunkD6RGHPZ5_cjs.decodeTapscript(chunkD6RGHPZ5_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
|
|
2474
|
+
const checkpointVtxoScript = new chunkD6RGHPZ5_cjs.VtxoScript([
|
|
2475
2475
|
serverUnrollScript.script,
|
|
2476
2476
|
collaborativeClosure.script
|
|
2477
2477
|
]);
|
|
@@ -2624,7 +2624,7 @@ function combineTapscriptSigs(signedTx, originalTx) {
|
|
|
2624
2624
|
}
|
|
2625
2625
|
function isValidArkAddress(address) {
|
|
2626
2626
|
try {
|
|
2627
|
-
|
|
2627
|
+
chunkD6RGHPZ5_cjs.ArkAddress.decode(address);
|
|
2628
2628
|
return true;
|
|
2629
2629
|
} catch (e) {
|
|
2630
2630
|
return false;
|
|
@@ -2632,16 +2632,16 @@ function isValidArkAddress(address) {
|
|
|
2632
2632
|
}
|
|
2633
2633
|
function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, context) {
|
|
2634
2634
|
if (serverCheckpointTxs.length !== expectedCheckpoints.length) {
|
|
2635
|
-
throw new
|
|
2635
|
+
throw new chunkD6RGHPZ5_cjs.ServerResponseMismatchError(
|
|
2636
2636
|
`${context} returned ${serverCheckpointTxs.length} checkpoints, expected ${expectedCheckpoints.length}`
|
|
2637
2637
|
);
|
|
2638
2638
|
}
|
|
2639
2639
|
const byTxid = new Map(expectedCheckpoints.map((c) => [c.id, c]));
|
|
2640
2640
|
return serverCheckpointTxs.map((encoded, index) => {
|
|
2641
|
-
const server =
|
|
2641
|
+
const server = chunkD6RGHPZ5_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
|
|
2642
2642
|
const local = byTxid.get(server.id);
|
|
2643
2643
|
if (!local) {
|
|
2644
|
-
throw new
|
|
2644
|
+
throw new chunkD6RGHPZ5_cjs.ServerResponseMismatchError(
|
|
2645
2645
|
`${context} checkpoint ${index} txid ${server.id} does not match any submitted checkpoint`
|
|
2646
2646
|
);
|
|
2647
2647
|
}
|
|
@@ -2651,14 +2651,14 @@ function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, contex
|
|
|
2651
2651
|
}
|
|
2652
2652
|
function assertSubmittedArkTxid(response, signedArkTx, context) {
|
|
2653
2653
|
if (response.arkTxid !== signedArkTx.id) {
|
|
2654
|
-
throw new
|
|
2654
|
+
throw new chunkD6RGHPZ5_cjs.ServerResponseMismatchError(
|
|
2655
2655
|
`${context} returned ark txid ${response.arkTxid}, expected ${signedArkTx.id}`
|
|
2656
2656
|
);
|
|
2657
2657
|
}
|
|
2658
2658
|
if (response.finalArkTx === void 0) return;
|
|
2659
|
-
const finalTxid =
|
|
2659
|
+
const finalTxid = chunkD6RGHPZ5_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
|
|
2660
2660
|
if (finalTxid !== signedArkTx.id) {
|
|
2661
|
-
throw new
|
|
2661
|
+
throw new chunkD6RGHPZ5_cjs.ServerResponseMismatchError(
|
|
2662
2662
|
`${context} returned final ark tx ${finalTxid}, expected ${signedArkTx.id}`
|
|
2663
2663
|
);
|
|
2664
2664
|
}
|
|
@@ -2667,20 +2667,20 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
2667
2667
|
const byOutpoint = new Map(inputs.map((input) => [`${input.txid}:${input.vout}`, input]));
|
|
2668
2668
|
for (const [index, checkpoint] of checkpoints.entries()) {
|
|
2669
2669
|
if (checkpoint.inputsLength !== 1) {
|
|
2670
|
-
throw new
|
|
2670
|
+
throw new chunkD6RGHPZ5_cjs.ServerResponseMismatchError(
|
|
2671
2671
|
`${context}: checkpoint ${index} spends ${checkpoint.inputsLength} inputs, expected 1`
|
|
2672
2672
|
);
|
|
2673
2673
|
}
|
|
2674
2674
|
const spent = checkpoint.getInput(0);
|
|
2675
2675
|
if (!spent.txid || spent.index === void 0) {
|
|
2676
|
-
throw new
|
|
2676
|
+
throw new chunkD6RGHPZ5_cjs.ServerResponseMismatchError(
|
|
2677
2677
|
`${context}: checkpoint ${index} has no input outpoint`
|
|
2678
2678
|
);
|
|
2679
2679
|
}
|
|
2680
2680
|
const outpoint = `${base.hex.encode(spent.txid)}:${spent.index}`;
|
|
2681
2681
|
const input = byOutpoint.get(outpoint);
|
|
2682
2682
|
if (!input) {
|
|
2683
|
-
throw new
|
|
2683
|
+
throw new chunkD6RGHPZ5_cjs.ServerResponseMismatchError(
|
|
2684
2684
|
`${context}: checkpoint ${index} spends ${outpoint}, which is not one of the requested virtual outputs`
|
|
2685
2685
|
);
|
|
2686
2686
|
}
|
|
@@ -2688,7 +2688,7 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
2688
2688
|
(unroll) => buildCheckpointTx(input, unroll).tx.id === checkpoint.id
|
|
2689
2689
|
);
|
|
2690
2690
|
if (!rebuilt) {
|
|
2691
|
-
throw new
|
|
2691
|
+
throw new chunkD6RGHPZ5_cjs.ServerResponseMismatchError(
|
|
2692
2692
|
`${context}: checkpoint ${index} txid ${checkpoint.id} differs from the checkpoint built locally for ${outpoint}`
|
|
2693
2693
|
);
|
|
2694
2694
|
}
|
|
@@ -2922,7 +2922,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
|
|
|
2922
2922
|
};
|
|
2923
2923
|
}
|
|
2924
2924
|
function deriveContractTapscripts(contract) {
|
|
2925
|
-
const handler =
|
|
2925
|
+
const handler = chunkCOLJARV4_cjs.contractHandlers.get(contract.type);
|
|
2926
2926
|
if (!handler) {
|
|
2927
2927
|
throw new Error(`No handler for contract type '${contract.type}'`);
|
|
2928
2928
|
}
|
|
@@ -2993,7 +2993,7 @@ function getRandomId() {
|
|
|
2993
2993
|
}
|
|
2994
2994
|
function isValidArkAddress2(address) {
|
|
2995
2995
|
try {
|
|
2996
|
-
|
|
2996
|
+
chunkD6RGHPZ5_cjs.ArkAddress.decode(address);
|
|
2997
2997
|
return true;
|
|
2998
2998
|
} catch (e) {
|
|
2999
2999
|
return false;
|
|
@@ -3023,7 +3023,7 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
3023
3023
|
for (const recipient of recipients) {
|
|
3024
3024
|
let address;
|
|
3025
3025
|
try {
|
|
3026
|
-
address =
|
|
3026
|
+
address = chunkD6RGHPZ5_cjs.ArkAddress.decode(recipient.address);
|
|
3027
3027
|
} catch (e) {
|
|
3028
3028
|
throw new Error(`Invalid Arkade address: ${recipient.address}`);
|
|
3029
3029
|
}
|
|
@@ -3052,7 +3052,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
|
|
|
3052
3052
|
continue;
|
|
3053
3053
|
}
|
|
3054
3054
|
for (const v of vtxos) {
|
|
3055
|
-
if (!
|
|
3055
|
+
if (!chunkD6RGHPZ5_cjs.hasTerminalSpend(v) && !v.isSwept) out.add(`${v.txid}:${v.vout}`);
|
|
3056
3056
|
}
|
|
3057
3057
|
}
|
|
3058
3058
|
return out;
|
|
@@ -3085,10 +3085,10 @@ function byValueDescending(vtxos) {
|
|
|
3085
3085
|
return [...vtxos].sort((a, b) => b.value - a.value);
|
|
3086
3086
|
}
|
|
3087
3087
|
async function fetchTimeHeight(wallet) {
|
|
3088
|
-
return
|
|
3088
|
+
return chunkD6RGHPZ5_cjs.resolveTimeHeight(wallet.onchainProvider);
|
|
3089
3089
|
}
|
|
3090
3090
|
function canMigrateBySend(vtxo, now) {
|
|
3091
|
-
if (!
|
|
3091
|
+
if (!chunkD6RGHPZ5_cjs.canSpendOffchain(vtxo, now)) return false;
|
|
3092
3092
|
return vtxo.expiresAt !== void 0 || vtxo.expiresAtHeight !== void 0;
|
|
3093
3093
|
}
|
|
3094
3094
|
function byExpiryAscending(vtxos, now) {
|
|
@@ -3096,7 +3096,7 @@ function byExpiryAscending(vtxos, now) {
|
|
|
3096
3096
|
if (vtxo.isSwept) return -Infinity;
|
|
3097
3097
|
if (vtxo.expiresAt !== void 0) return vtxo.expiresAt.getTime();
|
|
3098
3098
|
if (vtxo.expiresAtHeight !== void 0) {
|
|
3099
|
-
return
|
|
3099
|
+
return chunkD6RGHPZ5_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
|
|
3100
3100
|
}
|
|
3101
3101
|
return Infinity;
|
|
3102
3102
|
};
|
|
@@ -3119,6 +3119,40 @@ function capSettlementBatch(sorted, maxAmount) {
|
|
|
3119
3119
|
}
|
|
3120
3120
|
return batch;
|
|
3121
3121
|
}
|
|
3122
|
+
function priceSettlementInputs(vtxos, estimator) {
|
|
3123
|
+
const payable = [];
|
|
3124
|
+
const net = /* @__PURE__ */ new Map();
|
|
3125
|
+
for (const vtxo of vtxos) {
|
|
3126
|
+
const inputFee = estimator.evalOffchainInput(chunkD6RGHPZ5_cjs.toOffchainInputFeeParams(vtxo));
|
|
3127
|
+
if (inputFee.satoshis >= vtxo.value) {
|
|
3128
|
+
continue;
|
|
3129
|
+
}
|
|
3130
|
+
payable.push(vtxo);
|
|
3131
|
+
net.set(`${vtxo.txid}:${vtxo.vout}`, BigInt(vtxo.value - inputFee.satoshis));
|
|
3132
|
+
}
|
|
3133
|
+
return { payable, net };
|
|
3134
|
+
}
|
|
3135
|
+
function subtotalOf(vtxos, net) {
|
|
3136
|
+
let subtotal = 0n;
|
|
3137
|
+
for (const vtxo of vtxos) {
|
|
3138
|
+
const priced = net.get(`${vtxo.txid}:${vtxo.vout}`);
|
|
3139
|
+
if (priced === void 0) {
|
|
3140
|
+
throw new Error(`Unpriced settlement input ${vtxo.txid}:${vtxo.vout}`);
|
|
3141
|
+
}
|
|
3142
|
+
subtotal += priced;
|
|
3143
|
+
}
|
|
3144
|
+
return subtotal;
|
|
3145
|
+
}
|
|
3146
|
+
function deductOffchainOutputFee(subtotal, estimator, arkAddress) {
|
|
3147
|
+
if (!estimator.config.offchainOutput) {
|
|
3148
|
+
return subtotal;
|
|
3149
|
+
}
|
|
3150
|
+
const outputFee = estimator.evalOffchainOutput({
|
|
3151
|
+
amount: subtotal,
|
|
3152
|
+
script: base.hex.encode(chunkD6RGHPZ5_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
3153
|
+
});
|
|
3154
|
+
return subtotal - BigInt(outputFee.satoshis);
|
|
3155
|
+
}
|
|
3122
3156
|
var DEFAULT_THRESHOLD_SECONDS = 259200;
|
|
3123
3157
|
var DEFAULT_THRESHOLD_MS = DEFAULT_THRESHOLD_SECONDS * 1e3;
|
|
3124
3158
|
var DEFAULT_RENEWAL_CONFIG = {
|
|
@@ -3133,10 +3167,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
|
|
|
3133
3167
|
};
|
|
3134
3168
|
function getRecoverableVtxos(vtxos, dustAmount, now) {
|
|
3135
3169
|
return vtxos.filter((vtxo) => {
|
|
3136
|
-
if (
|
|
3170
|
+
if (chunkD6RGHPZ5_cjs.canRecoverOnchain(vtxo, now)) {
|
|
3137
3171
|
return true;
|
|
3138
3172
|
}
|
|
3139
|
-
if (
|
|
3173
|
+
if (chunkD6RGHPZ5_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
|
|
3140
3174
|
return true;
|
|
3141
3175
|
}
|
|
3142
3176
|
return false;
|
|
@@ -3167,7 +3201,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
|
|
|
3167
3201
|
}
|
|
3168
3202
|
function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
3169
3203
|
const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
|
|
3170
|
-
const expiresAt =
|
|
3204
|
+
const expiresAt = chunkD6RGHPZ5_cjs.normalizeVtxo(vtxo).expiresAt;
|
|
3171
3205
|
if (expiresAt === void 0) return false;
|
|
3172
3206
|
const now = Date.now();
|
|
3173
3207
|
const batchExpiry = expiresAt.getTime();
|
|
@@ -3176,7 +3210,7 @@ function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
|
3176
3210
|
}
|
|
3177
3211
|
function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
|
|
3178
3212
|
return vtxos.filter(
|
|
3179
|
-
(vtxo) => isVtxoExpiringSoon(vtxo, thresholdMs) ||
|
|
3213
|
+
(vtxo) => isVtxoExpiringSoon(vtxo, thresholdMs) || chunkD6RGHPZ5_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount)
|
|
3180
3214
|
);
|
|
3181
3215
|
}
|
|
3182
3216
|
function isMigrationCapable(wallet) {
|
|
@@ -3326,19 +3360,27 @@ var VtxoManager = class _VtxoManager {
|
|
|
3326
3360
|
});
|
|
3327
3361
|
const dustAmount = getDustAmount(this.wallet);
|
|
3328
3362
|
const now = await fetchTimeHeight(this.wallet);
|
|
3329
|
-
let { vtxosToRecover
|
|
3363
|
+
let { vtxosToRecover } = getRecoverableWithSubdust(allVtxos, dustAmount, now);
|
|
3330
3364
|
if (vtxosToRecover.length === 0) {
|
|
3331
3365
|
throw new Error("No recoverable VTXOs found");
|
|
3332
3366
|
}
|
|
3333
3367
|
const info = await this.getInfoProvider()?.getInfo();
|
|
3334
3368
|
const vtxoMaxAmount = info?.vtxoMaxAmount ?? -1n;
|
|
3335
|
-
const
|
|
3369
|
+
const estimator = new Estimator(info?.fees.intentFee ?? {});
|
|
3370
|
+
const { payable, net } = priceSettlementInputs(vtxosToRecover, estimator);
|
|
3371
|
+
const capped = capSettlementBatch(byValueDescending(payable), vtxoMaxAmount);
|
|
3336
3372
|
if (capped.length < vtxosToRecover.length) {
|
|
3337
3373
|
const recoverableCount = vtxosToRecover.length;
|
|
3338
|
-
|
|
3374
|
+
const cappedAway = capped.length < payable.length;
|
|
3375
|
+
({ vtxosToRecover } = getRecoverableWithSubdust(capped, dustAmount, now));
|
|
3339
3376
|
if (vtxosToRecover.length === 0) {
|
|
3377
|
+
if (!cappedAway) {
|
|
3378
|
+
throw new Error(
|
|
3379
|
+
`All ${recoverableCount} recoverable VTXOs that can pay their own intent fee total less than the dust threshold ${dustAmount}`
|
|
3380
|
+
);
|
|
3381
|
+
}
|
|
3340
3382
|
throw new Error(
|
|
3341
|
-
`Capped recovery batch (highest-value subset of ${recoverableCount} recoverable VTXOs within the ${MAX_VTXOS_PER_SETTLEMENT}-input and ${vtxoMaxAmount}-sat limits) is below the dust threshold ${dustAmount}`
|
|
3383
|
+
`Capped recovery batch (highest-value subset of ${recoverableCount} recoverable VTXOs within the ${MAX_VTXOS_PER_SETTLEMENT}-input and ${vtxoMaxAmount}-sat limits, net of intent fees) is below the dust threshold ${dustAmount}`
|
|
3342
3384
|
);
|
|
3343
3385
|
}
|
|
3344
3386
|
}
|
|
@@ -3346,6 +3388,16 @@ var VtxoManager = class _VtxoManager {
|
|
|
3346
3388
|
await this.rotateForRecoverableInputs(vtxosToRecover, info);
|
|
3347
3389
|
}
|
|
3348
3390
|
const arkAddress = await this.wallet.getAddress();
|
|
3391
|
+
const totalAmount = deductOffchainOutputFee(
|
|
3392
|
+
subtotalOf(vtxosToRecover, net),
|
|
3393
|
+
estimator,
|
|
3394
|
+
arkAddress
|
|
3395
|
+
);
|
|
3396
|
+
if (totalAmount < dustAmount) {
|
|
3397
|
+
throw new Error(
|
|
3398
|
+
`Recoverable amount ${totalAmount} net of intent fees is below dust threshold ${dustAmount}`
|
|
3399
|
+
);
|
|
3400
|
+
}
|
|
3349
3401
|
return this.wallet.settle(
|
|
3350
3402
|
{
|
|
3351
3403
|
inputs: vtxosToRecover,
|
|
@@ -3364,6 +3416,17 @@ var VtxoManager = class _VtxoManager {
|
|
|
3364
3416
|
*
|
|
3365
3417
|
* Useful for displaying to users before they decide to recover funds.
|
|
3366
3418
|
*
|
|
3419
|
+
* Both amounts are net of the operator's intent fees, so `recoverable` is
|
|
3420
|
+
* what {@link recoverVtxos} would actually hand back rather than the gross
|
|
3421
|
+
* sum of the inputs. `subdust` is net of the per-input fees only — the
|
|
3422
|
+
* output fee is charged on the batch as a whole and is not attributed per
|
|
3423
|
+
* coin — so it reports what the subdust coins are worth once each has paid
|
|
3424
|
+
* its own way, and is not strictly a slice of `recoverable`. It can exceed
|
|
3425
|
+
* `recoverable` where a flat output fee meets a wholly subdust wallet.
|
|
3426
|
+
*
|
|
3427
|
+
* The batch size caps are not applied here: they defer the overflow to the
|
|
3428
|
+
* next cycle rather than reducing what is recoverable.
|
|
3429
|
+
*
|
|
3367
3430
|
* @returns Object containing recoverable amounts and subdust information
|
|
3368
3431
|
*
|
|
3369
3432
|
* @example
|
|
@@ -3385,17 +3448,29 @@ var VtxoManager = class _VtxoManager {
|
|
|
3385
3448
|
withUnrolled: false
|
|
3386
3449
|
});
|
|
3387
3450
|
const dustAmount = getDustAmount(this.wallet);
|
|
3388
|
-
const { vtxosToRecover, includesSubdust
|
|
3451
|
+
const { vtxosToRecover, includesSubdust } = getRecoverableWithSubdust(
|
|
3389
3452
|
allVtxos,
|
|
3390
3453
|
dustAmount,
|
|
3391
3454
|
await fetchTimeHeight(this.wallet)
|
|
3392
3455
|
);
|
|
3393
|
-
const
|
|
3456
|
+
const info = await this.getInfoProvider()?.getInfo();
|
|
3457
|
+
const estimator = new Estimator(info?.fees.intentFee ?? {});
|
|
3458
|
+
const { payable, net } = priceSettlementInputs(vtxosToRecover, estimator);
|
|
3459
|
+
const priced = deductOffchainOutputFee(
|
|
3460
|
+
subtotalOf(payable, net),
|
|
3461
|
+
estimator,
|
|
3462
|
+
await this.wallet.getAddress()
|
|
3463
|
+
);
|
|
3464
|
+
const recoverable = priced > 0n ? priced : 0n;
|
|
3465
|
+
const subdustAmount = subtotalOf(
|
|
3466
|
+
payable.filter((v) => BigInt(v.value) < dustAmount),
|
|
3467
|
+
net
|
|
3468
|
+
);
|
|
3394
3469
|
return {
|
|
3395
|
-
recoverable
|
|
3470
|
+
recoverable,
|
|
3396
3471
|
subdust: subdustAmount,
|
|
3397
3472
|
includesSubdust,
|
|
3398
|
-
vtxoCount:
|
|
3473
|
+
vtxoCount: payable.length
|
|
3399
3474
|
};
|
|
3400
3475
|
}
|
|
3401
3476
|
// ========== Renewal Methods ==========
|
|
@@ -3513,6 +3588,14 @@ var VtxoManager = class _VtxoManager {
|
|
|
3513
3588
|
}
|
|
3514
3589
|
const info = await this.getInfoProvider()?.getInfo();
|
|
3515
3590
|
const vtxoMaxAmount = info?.vtxoMaxAmount ?? -1n;
|
|
3591
|
+
const estimator = new Estimator(info?.fees.intentFee ?? {});
|
|
3592
|
+
const { payable, net } = priceSettlementInputs(vtxos, estimator);
|
|
3593
|
+
vtxos = payable;
|
|
3594
|
+
if (vtxos.length === 0) {
|
|
3595
|
+
throw new Error(
|
|
3596
|
+
"No VTXOs available to renew: every expiring VTXO is worth less than its own intent fee"
|
|
3597
|
+
);
|
|
3598
|
+
}
|
|
3516
3599
|
const capped = capSettlementBatch(byExpiryAscending(vtxos, now), vtxoMaxAmount);
|
|
3517
3600
|
if (vtxoMaxAmount >= 0n) {
|
|
3518
3601
|
const oversized = vtxos.filter((vtxo) => BigInt(vtxo.value) > vtxoMaxAmount);
|
|
@@ -3530,24 +3613,28 @@ var VtxoManager = class _VtxoManager {
|
|
|
3530
3613
|
);
|
|
3531
3614
|
}
|
|
3532
3615
|
}
|
|
3533
|
-
const totalAmount = vtxos.reduce((sum, vtxo) => sum + vtxo.value, 0);
|
|
3534
3616
|
const dustAmount = getDustAmount(this.wallet);
|
|
3535
|
-
if (BigInt(totalAmount) < dustAmount) {
|
|
3536
|
-
throw new Error(
|
|
3537
|
-
`Total amount ${totalAmount} is below dust threshold ${dustAmount}`
|
|
3538
|
-
);
|
|
3539
|
-
}
|
|
3540
3617
|
if (info && isMigrationCapable(this.wallet)) {
|
|
3541
3618
|
await this.rotateForRecoverableInputs(vtxos, info);
|
|
3542
3619
|
}
|
|
3543
3620
|
const arkAddress = await this.wallet.getAddress();
|
|
3621
|
+
const totalAmount = deductOffchainOutputFee(
|
|
3622
|
+
subtotalOf(vtxos, net),
|
|
3623
|
+
estimator,
|
|
3624
|
+
arkAddress
|
|
3625
|
+
);
|
|
3626
|
+
if (totalAmount < dustAmount) {
|
|
3627
|
+
throw new Error(
|
|
3628
|
+
`Total amount ${totalAmount} is below dust threshold ${dustAmount}`
|
|
3629
|
+
);
|
|
3630
|
+
}
|
|
3544
3631
|
const txid = await this.wallet.settle(
|
|
3545
3632
|
{
|
|
3546
3633
|
inputs: vtxos,
|
|
3547
3634
|
outputs: [
|
|
3548
3635
|
{
|
|
3549
3636
|
address: arkAddress,
|
|
3550
|
-
amount:
|
|
3637
|
+
amount: totalAmount
|
|
3551
3638
|
}
|
|
3552
3639
|
]
|
|
3553
3640
|
},
|
|
@@ -3658,11 +3745,11 @@ var VtxoManager = class _VtxoManager {
|
|
|
3658
3745
|
`Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
|
|
3659
3746
|
);
|
|
3660
3747
|
}
|
|
3661
|
-
const tx = new
|
|
3748
|
+
const tx = new chunkD6RGHPZ5_cjs.Transaction();
|
|
3662
3749
|
for (const utxo of expiredUtxos) {
|
|
3663
|
-
const utxoScript =
|
|
3750
|
+
const utxoScript = chunkD6RGHPZ5_cjs.VtxoScript.decode(utxo.tapTree);
|
|
3664
3751
|
const utxoExitLeaf = utxoScript.leaves.find(
|
|
3665
|
-
(leaf) =>
|
|
3752
|
+
(leaf) => chunkD6RGHPZ5_cjs.CSVMultisigTapscript.isScriptValid(chunkD6RGHPZ5_cjs.scriptFromTapLeafScript(leaf)) === true
|
|
3666
3753
|
);
|
|
3667
3754
|
if (!utxoExitLeaf) {
|
|
3668
3755
|
throw new Error(
|
|
@@ -3677,7 +3764,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
3677
3764
|
amount: BigInt(utxo.value)
|
|
3678
3765
|
},
|
|
3679
3766
|
tapLeafScript: [utxoExitLeaf],
|
|
3680
|
-
sequence:
|
|
3767
|
+
sequence: chunkD6RGHPZ5_cjs.getSequence(utxoExitLeaf)
|
|
3681
3768
|
});
|
|
3682
3769
|
}
|
|
3683
3770
|
tx.addOutputAddress(boardingAddress, outputAmount, this.getNetwork());
|
|
@@ -3911,8 +3998,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
3911
3998
|
if (!serverPubKey) continue;
|
|
3912
3999
|
const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
|
|
3913
4000
|
if (cls.status === "CURRENT") continue;
|
|
3914
|
-
const recoverable = vtxos.filter((v) => v.isSwept && !
|
|
3915
|
-
const spendable = vtxos.filter((v) => !
|
|
4001
|
+
const recoverable = vtxos.filter((v) => v.isSwept && !chunkD6RGHPZ5_cjs.hasTerminalSpend(v));
|
|
4002
|
+
const spendable = vtxos.filter((v) => !chunkD6RGHPZ5_cjs.hasTerminalSpend(v) && !v.isSwept);
|
|
3916
4003
|
const value = spendable.reduce((sum, v) => sum + v.value, 0);
|
|
3917
4004
|
let recoverableCount = 0;
|
|
3918
4005
|
let recoverableValue = 0;
|
|
@@ -3925,7 +4012,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
3925
4012
|
awaitingSweepCount = spendable.length;
|
|
3926
4013
|
awaitingSweepValue = value;
|
|
3927
4014
|
for (const v of spendable) {
|
|
3928
|
-
const exp =
|
|
4015
|
+
const exp = chunkD6RGHPZ5_cjs.toBatchExpiry(v);
|
|
3929
4016
|
if (exp !== void 0 && (nextSweepEta === void 0 || exp < nextSweepEta)) {
|
|
3930
4017
|
nextSweepEta = exp;
|
|
3931
4018
|
}
|
|
@@ -4186,7 +4273,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4186
4273
|
/** Decodes the boarding tapscript exit path to extract the CSV timelock. */
|
|
4187
4274
|
getBoardingTimelock() {
|
|
4188
4275
|
const wallet = this.getSweepWallet();
|
|
4189
|
-
const exitScript =
|
|
4276
|
+
const exitScript = chunkD6RGHPZ5_cjs.CSVMultisigTapscript.decode(
|
|
4190
4277
|
base.hex.decode(wallet.boardingTapscript.exitScript)
|
|
4191
4278
|
);
|
|
4192
4279
|
return exitScript.params.timelock;
|
|
@@ -4317,8 +4404,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
4317
4404
|
* or doesn't carry the metadata.
|
|
4318
4405
|
*/
|
|
4319
4406
|
extractSpentOutpoint(error) {
|
|
4320
|
-
const ark =
|
|
4321
|
-
if (!
|
|
4407
|
+
const ark = chunkD6RGHPZ5_cjs.maybeArkError(error);
|
|
4408
|
+
if (!chunkD6RGHPZ5_cjs.isArkError(ark, chunkD6RGHPZ5_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
|
|
4322
4409
|
const raw = ark.metadata?.vtxo_outpoint;
|
|
4323
4410
|
if (typeof raw !== "string") return void 0;
|
|
4324
4411
|
const [txid, voutStr] = raw.split(":");
|
|
@@ -4508,7 +4595,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4508
4595
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
4509
4596
|
break;
|
|
4510
4597
|
}
|
|
4511
|
-
const inputFee = estimator.evalOffchainInput(
|
|
4598
|
+
const inputFee = estimator.evalOffchainInput(chunkD6RGHPZ5_cjs.toOffchainInputFeeParams(v));
|
|
4512
4599
|
if (inputFee.satoshis >= v.value) {
|
|
4513
4600
|
continue;
|
|
4514
4601
|
}
|
|
@@ -4528,7 +4615,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4528
4615
|
const arkAddress = await this.wallet.getAddress();
|
|
4529
4616
|
const outputFee = estimator.evalOffchainOutput({
|
|
4530
4617
|
amount: totalAmount,
|
|
4531
|
-
script: base.hex.encode(
|
|
4618
|
+
script: base.hex.encode(chunkD6RGHPZ5_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
4532
4619
|
});
|
|
4533
4620
|
totalAmount -= BigInt(outputFee.satoshis);
|
|
4534
4621
|
if (totalAmount < dustAmount) return;
|
|
@@ -4608,7 +4695,7 @@ var ArkNote = class _ArkNote {
|
|
|
4608
4695
|
this.value = value;
|
|
4609
4696
|
this.HRP = HRP;
|
|
4610
4697
|
const preimageHash = utils_js.sha256(this.preimage);
|
|
4611
|
-
this.vtxoScript = new
|
|
4698
|
+
this.vtxoScript = new chunkD6RGHPZ5_cjs.VtxoScript([noteTapscript(preimageHash)]);
|
|
4612
4699
|
const leaf = this.vtxoScript.leaves[0];
|
|
4613
4700
|
this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
|
|
4614
4701
|
this.tapTree = this.vtxoScript.encode();
|
|
@@ -4775,7 +4862,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
4775
4862
|
const privateKey = data.slice(1, 33);
|
|
4776
4863
|
const serverPubKey = data.slice(33, 65);
|
|
4777
4864
|
const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
|
|
4778
|
-
const csvTimelock =
|
|
4865
|
+
const csvTimelock = chunkD6RGHPZ5_cjs.sequenceToTimelock(sequence);
|
|
4779
4866
|
return new _ArkadeCash(privateKey, serverPubKey, csvTimelock, decoded.prefix);
|
|
4780
4867
|
}
|
|
4781
4868
|
toString() {
|
|
@@ -4783,7 +4870,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
4783
4870
|
data[0] = _ArkadeCash.Version;
|
|
4784
4871
|
data.set(this._privateKey, 1);
|
|
4785
4872
|
data.set(this._serverPubKey, 33);
|
|
4786
|
-
const sequence =
|
|
4873
|
+
const sequence = chunkD6RGHPZ5_cjs.timelockToSequence(this.csvTimelock);
|
|
4787
4874
|
new DataView(data.buffer, data.byteOffset + 65, 4).setUint32(0, sequence, false);
|
|
4788
4875
|
const words = base.bech32m.toWords(data);
|
|
4789
4876
|
return base.bech32m.encode(this.hrp, words, 1023);
|
|
@@ -4792,7 +4879,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
4792
4879
|
return SingleKey.fromPrivateKey(this._privateKey);
|
|
4793
4880
|
}
|
|
4794
4881
|
get vtxoScript() {
|
|
4795
|
-
return new
|
|
4882
|
+
return new chunkCOLJARV4_cjs.DefaultVtxo.Script({
|
|
4796
4883
|
pubKey: this._publicKey,
|
|
4797
4884
|
serverPubKey: this._serverPubKey,
|
|
4798
4885
|
csvTimelock: this.csvTimelock
|
|
@@ -5053,7 +5140,7 @@ async function captureExitBranch(params) {
|
|
|
5053
5140
|
const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
|
|
5054
5141
|
if (nonCommitment.length > 0) {
|
|
5055
5142
|
for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
|
|
5056
|
-
psbtByTxid.set(
|
|
5143
|
+
psbtByTxid.set(chunkD6RGHPZ5_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
5057
5144
|
}
|
|
5058
5145
|
}
|
|
5059
5146
|
}
|
|
@@ -5096,10 +5183,10 @@ var IndexerExitDataSource = class {
|
|
|
5096
5183
|
while (hasMore) {
|
|
5097
5184
|
const { chain: page, page: meta } = await this.indexer.getVtxoChain(
|
|
5098
5185
|
{ txid: vtxo.txid, vout: vtxo.vout },
|
|
5099
|
-
{ pageIndex, pageSize:
|
|
5186
|
+
{ pageIndex, pageSize: chunkD6RGHPZ5_cjs.DEFAULT_PAGE_SIZE }
|
|
5100
5187
|
);
|
|
5101
5188
|
chain.push(...page);
|
|
5102
|
-
hasMore = meta ? page.length ===
|
|
5189
|
+
hasMore = meta ? page.length === chunkD6RGHPZ5_cjs.DEFAULT_PAGE_SIZE : false;
|
|
5103
5190
|
pageIndex++;
|
|
5104
5191
|
}
|
|
5105
5192
|
return chain;
|
|
@@ -5111,12 +5198,12 @@ var IndexerExitDataSource = class {
|
|
|
5111
5198
|
while (hasMore) {
|
|
5112
5199
|
const { txs, page } = await this.indexer.getVirtualTxs(txids, {
|
|
5113
5200
|
pageIndex,
|
|
5114
|
-
pageSize:
|
|
5201
|
+
pageSize: chunkD6RGHPZ5_cjs.DEFAULT_PAGE_SIZE
|
|
5115
5202
|
});
|
|
5116
5203
|
for (const psbt of txs) {
|
|
5117
|
-
out.set(
|
|
5204
|
+
out.set(chunkD6RGHPZ5_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
5118
5205
|
}
|
|
5119
|
-
hasMore = page ? txs.length ===
|
|
5206
|
+
hasMore = page ? txs.length === chunkD6RGHPZ5_cjs.DEFAULT_PAGE_SIZE : false;
|
|
5120
5207
|
pageIndex++;
|
|
5121
5208
|
}
|
|
5122
5209
|
return out;
|
|
@@ -5137,7 +5224,7 @@ function chainedTxTypeToChainTxType(t) {
|
|
|
5137
5224
|
}
|
|
5138
5225
|
}
|
|
5139
5226
|
function psbtInputTxids(psbtBase64) {
|
|
5140
|
-
const tx =
|
|
5227
|
+
const tx = chunkD6RGHPZ5_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
5141
5228
|
const ids = [];
|
|
5142
5229
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
5143
5230
|
const txid = tx.getInput(i).txid;
|
|
@@ -5490,10 +5577,10 @@ async function resolveArkInfo(arkProvider, walletRepository) {
|
|
|
5490
5577
|
try {
|
|
5491
5578
|
info = await arkProvider.getInfo();
|
|
5492
5579
|
} catch (err) {
|
|
5493
|
-
if (!
|
|
5580
|
+
if (!chunkD6RGHPZ5_cjs.isRetryableProviderError(err)) throw err;
|
|
5494
5581
|
const snapshot = await loadArkInfoSnapshot(walletRepository);
|
|
5495
5582
|
if (!snapshot) {
|
|
5496
|
-
throw new
|
|
5583
|
+
throw new chunkD6RGHPZ5_cjs.ProviderUnavailableError(
|
|
5497
5584
|
"Arkade server info is unavailable and no cached snapshot exists",
|
|
5498
5585
|
{ cause: err }
|
|
5499
5586
|
);
|
|
@@ -5876,7 +5963,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos) {
|
|
|
5876
5963
|
return [...txids];
|
|
5877
5964
|
}
|
|
5878
5965
|
async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt) {
|
|
5879
|
-
const fromOldestVtxo = vtxos.map(
|
|
5966
|
+
const fromOldestVtxo = vtxos.map(chunkD6RGHPZ5_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
5880
5967
|
const txidsNeedingCreatedAt = resolveTxCreatedAt ? collectArkTxidsNeedingCreatedAt(fromOldestVtxo) : [];
|
|
5881
5968
|
const resolvedCreatedAt = resolveTxCreatedAt && txidsNeedingCreatedAt.length > 0 ? await resolveTxCreatedAt(txidsNeedingCreatedAt) : /* @__PURE__ */ new Map();
|
|
5882
5969
|
const unmatchedSettledBoardingTxs = allBoardingTxs.filter(isSettledBoardingReceive).sort((a, b) => a.createdAt - b.createdAt);
|
|
@@ -6040,7 +6127,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6040
6127
|
const virtualCoins = await this.wallet.getVtxos({
|
|
6041
6128
|
withRecoverable: false
|
|
6042
6129
|
});
|
|
6043
|
-
const controlAssetRef = params.controlAssetId ?
|
|
6130
|
+
const controlAssetRef = params.controlAssetId ? chunkF4C67JYB_cjs.AssetRef.fromId(chunkF4C67JYB_cjs.AssetId.fromString(params.controlAssetId)) : null;
|
|
6044
6131
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
6045
6132
|
let totalBtcSelected = 0n;
|
|
6046
6133
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -6053,8 +6140,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6053
6140
|
}
|
|
6054
6141
|
}
|
|
6055
6142
|
const groups = [];
|
|
6056
|
-
const issuedAssetOutput =
|
|
6057
|
-
const issuedAssetGroup =
|
|
6143
|
+
const issuedAssetOutput = chunkF4C67JYB_cjs.AssetOutput.create(0, params.amount);
|
|
6144
|
+
const issuedAssetGroup = chunkF4C67JYB_cjs.AssetGroup.create(
|
|
6058
6145
|
null,
|
|
6059
6146
|
controlAssetRef,
|
|
6060
6147
|
[],
|
|
@@ -6069,28 +6156,28 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6069
6156
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6070
6157
|
for (const asset of assets) {
|
|
6071
6158
|
if (asset.assetId !== assetId) continue;
|
|
6072
|
-
changeInputs.push(
|
|
6159
|
+
changeInputs.push(chunkF4C67JYB_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6073
6160
|
}
|
|
6074
6161
|
}
|
|
6075
6162
|
groups.push(
|
|
6076
|
-
|
|
6077
|
-
|
|
6163
|
+
chunkF4C67JYB_cjs.AssetGroup.create(
|
|
6164
|
+
chunkF4C67JYB_cjs.AssetId.fromString(assetId),
|
|
6078
6165
|
null,
|
|
6079
6166
|
changeInputs,
|
|
6080
|
-
[
|
|
6167
|
+
[chunkF4C67JYB_cjs.AssetOutput.create(0, amount)],
|
|
6081
6168
|
[]
|
|
6082
6169
|
)
|
|
6083
6170
|
);
|
|
6084
6171
|
}
|
|
6085
6172
|
}
|
|
6086
6173
|
const address = await this.wallet.getAddress();
|
|
6087
|
-
const outputAddress =
|
|
6174
|
+
const outputAddress = chunkD6RGHPZ5_cjs.ArkAddress.decode(address);
|
|
6088
6175
|
const outputs = [
|
|
6089
6176
|
{
|
|
6090
6177
|
script: outputAddress.pkScript,
|
|
6091
6178
|
amount: BigInt(totalBtcSelected)
|
|
6092
6179
|
},
|
|
6093
|
-
Extension.create([
|
|
6180
|
+
Extension.create([chunkF4C67JYB_cjs.Packet.create(groups)]).txOut()
|
|
6094
6181
|
];
|
|
6095
6182
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
|
|
6096
6183
|
coinSelection.inputs,
|
|
@@ -6098,7 +6185,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6098
6185
|
);
|
|
6099
6186
|
return {
|
|
6100
6187
|
arkTxId: arkTxid,
|
|
6101
|
-
assetId:
|
|
6188
|
+
assetId: chunkF4C67JYB_cjs.AssetId.create(arkTxid, 0).toString()
|
|
6102
6189
|
};
|
|
6103
6190
|
}
|
|
6104
6191
|
/**
|
|
@@ -6170,16 +6257,16 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6170
6257
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6171
6258
|
for (const asset of assets) {
|
|
6172
6259
|
if (asset.assetId !== params.assetId) continue;
|
|
6173
|
-
reissueInputs.push(
|
|
6260
|
+
reissueInputs.push(chunkF4C67JYB_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6174
6261
|
}
|
|
6175
6262
|
}
|
|
6176
6263
|
const totalAssetAmount = assetToReissueAmount + params.amount;
|
|
6177
|
-
const reissueAssetIdObj =
|
|
6178
|
-
const reissueAssetGroup =
|
|
6264
|
+
const reissueAssetIdObj = chunkF4C67JYB_cjs.AssetId.fromString(params.assetId);
|
|
6265
|
+
const reissueAssetGroup = chunkF4C67JYB_cjs.AssetGroup.create(
|
|
6179
6266
|
reissueAssetIdObj,
|
|
6180
6267
|
null,
|
|
6181
6268
|
reissueInputs,
|
|
6182
|
-
[
|
|
6269
|
+
[chunkF4C67JYB_cjs.AssetOutput.create(0, totalAssetAmount)],
|
|
6183
6270
|
[]
|
|
6184
6271
|
);
|
|
6185
6272
|
const groups = [reissueAssetGroup];
|
|
@@ -6188,27 +6275,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6188
6275
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6189
6276
|
for (const asset of assets) {
|
|
6190
6277
|
if (asset.assetId !== assetId) continue;
|
|
6191
|
-
changeInputs.push(
|
|
6278
|
+
changeInputs.push(chunkF4C67JYB_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6192
6279
|
}
|
|
6193
6280
|
}
|
|
6194
6281
|
groups.push(
|
|
6195
|
-
|
|
6196
|
-
|
|
6282
|
+
chunkF4C67JYB_cjs.AssetGroup.create(
|
|
6283
|
+
chunkF4C67JYB_cjs.AssetId.fromString(assetId),
|
|
6197
6284
|
null,
|
|
6198
6285
|
changeInputs,
|
|
6199
|
-
[
|
|
6286
|
+
[chunkF4C67JYB_cjs.AssetOutput.create(0, amount)],
|
|
6200
6287
|
[]
|
|
6201
6288
|
)
|
|
6202
6289
|
);
|
|
6203
6290
|
}
|
|
6204
6291
|
const address = await this.wallet.getAddress();
|
|
6205
|
-
const outputAddress =
|
|
6292
|
+
const outputAddress = chunkD6RGHPZ5_cjs.ArkAddress.decode(address);
|
|
6206
6293
|
const outputs = [
|
|
6207
6294
|
{
|
|
6208
6295
|
script: outputAddress.pkScript,
|
|
6209
6296
|
amount: BigInt(totalBtcSelected)
|
|
6210
6297
|
},
|
|
6211
|
-
Extension.create([
|
|
6298
|
+
Extension.create([chunkF4C67JYB_cjs.Packet.create(groups)]).txOut()
|
|
6212
6299
|
];
|
|
6213
6300
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
6214
6301
|
return arkTxid;
|
|
@@ -6275,27 +6362,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6275
6362
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6276
6363
|
for (const asset of assets) {
|
|
6277
6364
|
if (asset.assetId !== assetId) continue;
|
|
6278
|
-
changeInputs.push(
|
|
6365
|
+
changeInputs.push(chunkF4C67JYB_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6279
6366
|
}
|
|
6280
6367
|
}
|
|
6281
6368
|
groups.push(
|
|
6282
|
-
|
|
6283
|
-
|
|
6369
|
+
chunkF4C67JYB_cjs.AssetGroup.create(
|
|
6370
|
+
chunkF4C67JYB_cjs.AssetId.fromString(assetId),
|
|
6284
6371
|
null,
|
|
6285
6372
|
changeInputs,
|
|
6286
|
-
amount > 0n ? [
|
|
6373
|
+
amount > 0n ? [chunkF4C67JYB_cjs.AssetOutput.create(0, amount)] : [],
|
|
6287
6374
|
[]
|
|
6288
6375
|
)
|
|
6289
6376
|
);
|
|
6290
6377
|
}
|
|
6291
6378
|
const address = await this.wallet.getAddress();
|
|
6292
|
-
const outputAddress =
|
|
6379
|
+
const outputAddress = chunkD6RGHPZ5_cjs.ArkAddress.decode(address);
|
|
6293
6380
|
const outputs = [
|
|
6294
6381
|
{
|
|
6295
6382
|
script: outputAddress.pkScript,
|
|
6296
6383
|
amount: BigInt(totalBtcSelected)
|
|
6297
6384
|
},
|
|
6298
|
-
Extension.create([
|
|
6385
|
+
Extension.create([chunkF4C67JYB_cjs.Packet.create(groups)]).txOut()
|
|
6299
6386
|
];
|
|
6300
6387
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
6301
6388
|
return arkTxid;
|
|
@@ -6320,7 +6407,7 @@ function castMetadata(metadata) {
|
|
|
6320
6407
|
} else {
|
|
6321
6408
|
throw new Error("Invalid metadata value type");
|
|
6322
6409
|
}
|
|
6323
|
-
md.push(
|
|
6410
|
+
md.push(chunkF4C67JYB_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
|
|
6324
6411
|
}
|
|
6325
6412
|
return md;
|
|
6326
6413
|
}
|
|
@@ -6341,10 +6428,10 @@ var DelegateManagerImpl = class {
|
|
|
6341
6428
|
if (vtxos.length === 0) {
|
|
6342
6429
|
return { delegated: [], failed: [] };
|
|
6343
6430
|
}
|
|
6344
|
-
const destinationScript =
|
|
6431
|
+
const destinationScript = chunkD6RGHPZ5_cjs.ArkAddress.decode(destination).pkScript;
|
|
6345
6432
|
const arkInfo = await this.arkInfoProvider.getInfo();
|
|
6346
6433
|
const delegateInfo = await this.delegateProvider.getDelegateInfo();
|
|
6347
|
-
const eligible = vtxos.map(
|
|
6434
|
+
const eligible = vtxos.map(chunkD6RGHPZ5_cjs.normalizeVtxo).filter(
|
|
6348
6435
|
(v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
|
|
6349
6436
|
);
|
|
6350
6437
|
if (eligible.length === 0) {
|
|
@@ -6373,11 +6460,11 @@ var DelegateManagerImpl = class {
|
|
|
6373
6460
|
const groupByExpiry = /* @__PURE__ */ new Map();
|
|
6374
6461
|
let recoverableVtxos = [];
|
|
6375
6462
|
for (const vtxo of eligible) {
|
|
6376
|
-
if (
|
|
6463
|
+
if (chunkD6RGHPZ5_cjs.canRecoverOnchain(vtxo, now)) {
|
|
6377
6464
|
recoverableVtxos.push(vtxo);
|
|
6378
6465
|
continue;
|
|
6379
6466
|
}
|
|
6380
|
-
const expiry =
|
|
6467
|
+
const expiry = chunkD6RGHPZ5_cjs.toBatchExpiry(vtxo);
|
|
6381
6468
|
if (!expiry) continue;
|
|
6382
6469
|
const dayKey = getDayTimestamp(expiry);
|
|
6383
6470
|
groupByExpiry.set(dayKey, [...groupByExpiry.get(dayKey) ?? [], vtxo]);
|
|
@@ -6442,7 +6529,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6442
6529
|
}
|
|
6443
6530
|
if (!delegateAt) {
|
|
6444
6531
|
const now = { timestamp: /* @__PURE__ */ new Date() };
|
|
6445
|
-
const expiryTimestamp = vtxos.filter((coin) => !
|
|
6532
|
+
const expiryTimestamp = vtxos.filter((coin) => !chunkD6RGHPZ5_cjs.canRecoverOnchain(coin, now) && chunkD6RGHPZ5_cjs.toBatchExpiry(coin)).reduce((min, coin) => Math.min(min, chunkD6RGHPZ5_cjs.toBatchExpiry(coin)), Number.MAX_SAFE_INTEGER);
|
|
6446
6533
|
if (!expiryTimestamp || expiryTimestamp === Number.MAX_SAFE_INTEGER) {
|
|
6447
6534
|
delegateAt = new Date(Date.now() + 1 * 60 * 1e3);
|
|
6448
6535
|
} else {
|
|
@@ -6471,7 +6558,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6471
6558
|
let amount = 0n;
|
|
6472
6559
|
for (const coin of vtxos) {
|
|
6473
6560
|
const inputFee = estimator.evalOffchainInput({
|
|
6474
|
-
...
|
|
6561
|
+
...chunkD6RGHPZ5_cjs.toOffchainInputFeeParams(coin),
|
|
6475
6562
|
type: "vtxo"
|
|
6476
6563
|
});
|
|
6477
6564
|
if (inputFee.value >= coin.value) {
|
|
@@ -6485,7 +6572,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6485
6572
|
const delegateFee = BigInt(Number(fee));
|
|
6486
6573
|
if (delegateFee > 0n) {
|
|
6487
6574
|
outputs.push({
|
|
6488
|
-
script:
|
|
6575
|
+
script: chunkD6RGHPZ5_cjs.ArkAddress.decode(delegateAddress).pkScript,
|
|
6489
6576
|
amount: delegateFee
|
|
6490
6577
|
});
|
|
6491
6578
|
}
|
|
@@ -6518,10 +6605,10 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6518
6605
|
destinationScript
|
|
6519
6606
|
);
|
|
6520
6607
|
const forfeitOutputScript = btcSigner.OutScript.encode(
|
|
6521
|
-
btcSigner.Address(
|
|
6608
|
+
btcSigner.Address(chunkD6RGHPZ5_cjs.getNetwork(network)).decode(forfeitAddress)
|
|
6522
6609
|
);
|
|
6523
6610
|
const forfeits = await Promise.all(
|
|
6524
|
-
vtxos.filter((v) => !
|
|
6611
|
+
vtxos.filter((v) => !chunkD6RGHPZ5_cjs.canRecoverOnchain(v, { timestamp: /* @__PURE__ */ new Date() })).map(async (coin) => {
|
|
6525
6612
|
const forfeit = await makeDelegateForfeitTx(
|
|
6526
6613
|
coin,
|
|
6527
6614
|
dust,
|
|
@@ -6546,7 +6633,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
|
|
|
6546
6633
|
index: input.vout,
|
|
6547
6634
|
witnessUtxo: {
|
|
6548
6635
|
amount: BigInt(input.value),
|
|
6549
|
-
script:
|
|
6636
|
+
script: chunkD6RGHPZ5_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
6550
6637
|
},
|
|
6551
6638
|
sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
|
|
6552
6639
|
tapLeafScript: [delegateTapLeaf]
|
|
@@ -6604,7 +6691,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
6604
6691
|
expire_at: 0,
|
|
6605
6692
|
cosigners_public_keys: cosignerPubKeys
|
|
6606
6693
|
};
|
|
6607
|
-
const proof =
|
|
6694
|
+
const proof = chunkD6RGHPZ5_cjs.Intent.create(message, coins, outputs);
|
|
6608
6695
|
const signedProof = await identity.sign(proof);
|
|
6609
6696
|
return {
|
|
6610
6697
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -6622,10 +6709,10 @@ function getDayTimestamp(timestamp) {
|
|
|
6622
6709
|
function findDelegateTapLeaf(vtxo, delegatePubkey) {
|
|
6623
6710
|
if (!vtxo.tapTree) return void 0;
|
|
6624
6711
|
const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
|
|
6625
|
-
const vtxoScript =
|
|
6712
|
+
const vtxoScript = chunkD6RGHPZ5_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
6626
6713
|
return vtxoScript.leaves.find((tapLeaf) => {
|
|
6627
|
-
const arkTapscript =
|
|
6628
|
-
if (!
|
|
6714
|
+
const arkTapscript = chunkD6RGHPZ5_cjs.decodeTapscript(chunkD6RGHPZ5_cjs.scriptFromTapLeafScript(tapLeaf));
|
|
6715
|
+
if (!chunkD6RGHPZ5_cjs.MultisigTapscript.is(arkTapscript)) return false;
|
|
6629
6716
|
return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
|
|
6630
6717
|
});
|
|
6631
6718
|
}
|
|
@@ -6813,7 +6900,7 @@ async function closeDatabase(dbName) {
|
|
|
6813
6900
|
return true;
|
|
6814
6901
|
}
|
|
6815
6902
|
function scriptFromArkAddress(address) {
|
|
6816
|
-
return base.hex.encode(
|
|
6903
|
+
return base.hex.encode(chunkD6RGHPZ5_cjs.ArkAddress.decode(address).pkScript);
|
|
6817
6904
|
}
|
|
6818
6905
|
|
|
6819
6906
|
// src/repositories/indexedDB/schema.ts
|
|
@@ -7310,7 +7397,7 @@ function validateVtxosForScript(vtxos, script, context) {
|
|
|
7310
7397
|
}
|
|
7311
7398
|
async function getVtxosForContract(repo, contract) {
|
|
7312
7399
|
const vtxos = repo.getVtxosForScript ? await repo.getVtxosForScript(contract.script) : filterVtxosForScript(await repo.getVtxos(contract.address), contract.script);
|
|
7313
|
-
return vtxos.map(
|
|
7400
|
+
return vtxos.map(chunkD6RGHPZ5_cjs.normalizeVtxo);
|
|
7314
7401
|
}
|
|
7315
7402
|
async function saveVtxosForContract(repo, contract, vtxos) {
|
|
7316
7403
|
if (repo.saveVtxosForScript) {
|
|
@@ -7514,7 +7601,7 @@ var deserializeTapLeaf = (t) => {
|
|
|
7514
7601
|
const s = base.hex.decode(t.s);
|
|
7515
7602
|
return [cb, s];
|
|
7516
7603
|
};
|
|
7517
|
-
var deserializeVtxo = (o) =>
|
|
7604
|
+
var deserializeVtxo = (o) => chunkD6RGHPZ5_cjs.normalizeVtxo({
|
|
7518
7605
|
...o,
|
|
7519
7606
|
createdAt: new Date(o.createdAt),
|
|
7520
7607
|
tapTree: base.hex.decode(o.tapTree),
|
|
@@ -8653,7 +8740,7 @@ var ContractWatcher = class {
|
|
|
8653
8740
|
this.connectionState = "connected";
|
|
8654
8741
|
this.reconnectAttempts = 0;
|
|
8655
8742
|
this.listenLoop().catch((e) => {
|
|
8656
|
-
if (
|
|
8743
|
+
if (chunkD6RGHPZ5_cjs.isEventSourceError(e)) {
|
|
8657
8744
|
console.debug("ContractWatcher subscription disconnected; reconnecting");
|
|
8658
8745
|
} else {
|
|
8659
8746
|
console.error(e);
|
|
@@ -8882,14 +8969,14 @@ var ContractWatcher = class {
|
|
|
8882
8969
|
const timestamp = Date.now();
|
|
8883
8970
|
if (update.newVtxos?.length) {
|
|
8884
8971
|
this.processSubscriptionVtxos(
|
|
8885
|
-
update.newVtxos.map(
|
|
8972
|
+
update.newVtxos.map(chunkD6RGHPZ5_cjs.normalizeVtxo),
|
|
8886
8973
|
"vtxo_received",
|
|
8887
8974
|
timestamp
|
|
8888
8975
|
);
|
|
8889
8976
|
}
|
|
8890
8977
|
if (update.spentVtxos?.length) {
|
|
8891
8978
|
this.processSubscriptionVtxos(
|
|
8892
|
-
update.spentVtxos.map(
|
|
8979
|
+
update.spentVtxos.map(chunkD6RGHPZ5_cjs.normalizeVtxo),
|
|
8893
8980
|
"vtxo_spent",
|
|
8894
8981
|
timestamp
|
|
8895
8982
|
);
|
|
@@ -9022,7 +9109,7 @@ async function reconcileIntents(deps) {
|
|
|
9022
9109
|
let vtxosByOutpoint = /* @__PURE__ */ new Map();
|
|
9023
9110
|
if (outpoints.length > 0) {
|
|
9024
9111
|
try {
|
|
9025
|
-
const { vtxos } = await
|
|
9112
|
+
const { vtxos } = await chunkD6RGHPZ5_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
|
|
9026
9113
|
vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
|
|
9027
9114
|
} catch (e) {
|
|
9028
9115
|
console.error("reconcileIntents: failed to fetch input VTXO state", e);
|
|
@@ -9142,7 +9229,7 @@ var ContractManager = class _ContractManager {
|
|
|
9142
9229
|
await this.reconcileWatched();
|
|
9143
9230
|
this.markSyncOnline();
|
|
9144
9231
|
} catch (err) {
|
|
9145
|
-
if (!
|
|
9232
|
+
if (!chunkD6RGHPZ5_cjs.isRetryableProviderError(err)) throw err;
|
|
9146
9233
|
this.markSyncDegraded(err);
|
|
9147
9234
|
}
|
|
9148
9235
|
this.initialized = true;
|
|
@@ -9254,7 +9341,7 @@ var ContractManager = class _ContractManager {
|
|
|
9254
9341
|
const from = Math.max(0, watermark - lookAhead.size);
|
|
9255
9342
|
const to = watermark + lookAhead.size;
|
|
9256
9343
|
const deps = lookAhead.candidateDeps();
|
|
9257
|
-
const handlers =
|
|
9344
|
+
const handlers = chunkCOLJARV4_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkCOLJARV4_cjs.contractHandlers.get(t)).filter(hasCandidates);
|
|
9258
9345
|
const band = /* @__PURE__ */ new Map();
|
|
9259
9346
|
for (let index = from; index <= to; index++) {
|
|
9260
9347
|
const descriptor = lookAhead.materialize(index);
|
|
@@ -9265,7 +9352,7 @@ var ContractManager = class _ContractManager {
|
|
|
9265
9352
|
index,
|
|
9266
9353
|
params: {
|
|
9267
9354
|
...candidate,
|
|
9268
|
-
...
|
|
9355
|
+
...chunkCOLJARV4_cjs.speculativeReceiveMetadata(descriptor)
|
|
9269
9356
|
}
|
|
9270
9357
|
});
|
|
9271
9358
|
}
|
|
@@ -9325,7 +9412,7 @@ var ContractManager = class _ContractManager {
|
|
|
9325
9412
|
});
|
|
9326
9413
|
for (const entry of pending) entry.catchUpPending = false;
|
|
9327
9414
|
} catch (err) {
|
|
9328
|
-
if (!
|
|
9415
|
+
if (!chunkD6RGHPZ5_cjs.isRetryableProviderError(err)) throw err;
|
|
9329
9416
|
this.markSyncDegraded(err);
|
|
9330
9417
|
}
|
|
9331
9418
|
}
|
|
@@ -9369,7 +9456,7 @@ var ContractManager = class _ContractManager {
|
|
|
9369
9456
|
await this.fetchContractVxosFromIndexer([contract]);
|
|
9370
9457
|
this.markSyncOnline();
|
|
9371
9458
|
} catch (err) {
|
|
9372
|
-
if (!
|
|
9459
|
+
if (!chunkD6RGHPZ5_cjs.isRetryableProviderError(err)) throw err;
|
|
9373
9460
|
this.markSyncDegraded(err);
|
|
9374
9461
|
}
|
|
9375
9462
|
await this.watcher.addContract(contract);
|
|
@@ -9406,7 +9493,7 @@ var ContractManager = class _ContractManager {
|
|
|
9406
9493
|
return result;
|
|
9407
9494
|
}
|
|
9408
9495
|
async upsertContractRow(params) {
|
|
9409
|
-
const handler =
|
|
9496
|
+
const handler = chunkCOLJARV4_cjs.contractHandlers.get(params.type);
|
|
9410
9497
|
if (!handler) {
|
|
9411
9498
|
throw new Error(`No handler registered for contract type '${params.type}'`);
|
|
9412
9499
|
}
|
|
@@ -9506,7 +9593,7 @@ var ContractManager = class _ContractManager {
|
|
|
9506
9593
|
`scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
|
|
9507
9594
|
);
|
|
9508
9595
|
}
|
|
9509
|
-
const registered =
|
|
9596
|
+
const registered = chunkCOLJARV4_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkCOLJARV4_cjs.contractHandlers.get(t)).filter(isDiscoverable);
|
|
9510
9597
|
const discoverables = [
|
|
9511
9598
|
...registered.filter((h) => h.type === "boarding"),
|
|
9512
9599
|
...registered.filter((h) => h.type !== "boarding")
|
|
@@ -9641,7 +9728,7 @@ var ContractManager = class _ContractManager {
|
|
|
9641
9728
|
await this.syncContracts({ contracts, pageSize });
|
|
9642
9729
|
this.markSyncOnline();
|
|
9643
9730
|
} catch (err) {
|
|
9644
|
-
if (!
|
|
9731
|
+
if (!chunkD6RGHPZ5_cjs.isRetryableProviderError(err)) throw err;
|
|
9645
9732
|
this.markSyncDegraded(err);
|
|
9646
9733
|
}
|
|
9647
9734
|
const vtxos = await this.getVtxosForContracts(contracts);
|
|
@@ -9662,7 +9749,7 @@ var ContractManager = class _ContractManager {
|
|
|
9662
9749
|
}
|
|
9663
9750
|
const tapscriptCache = /* @__PURE__ */ new Map();
|
|
9664
9751
|
return vtxos.map(
|
|
9665
|
-
(vtxo) => extendVirtualCoinForContract(
|
|
9752
|
+
(vtxo) => extendVirtualCoinForContract(chunkD6RGHPZ5_cjs.normalizeVtxo(vtxo), byScript, tapscriptCache)
|
|
9666
9753
|
);
|
|
9667
9754
|
}
|
|
9668
9755
|
buildContractsDbFilter(filter) {
|
|
@@ -9747,7 +9834,7 @@ var ContractManager = class _ContractManager {
|
|
|
9747
9834
|
const { contractScript, collaborative = true, walletPubKey, vtxo } = options;
|
|
9748
9835
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
9749
9836
|
if (!contract) return [];
|
|
9750
|
-
const handler =
|
|
9837
|
+
const handler = chunkCOLJARV4_cjs.contractHandlers.get(contract.type);
|
|
9751
9838
|
if (!handler) return [];
|
|
9752
9839
|
const script = handler.createScript(contract.params);
|
|
9753
9840
|
const context = {
|
|
@@ -9767,7 +9854,7 @@ var ContractManager = class _ContractManager {
|
|
|
9767
9854
|
const { contractScript, collaborative = true, walletPubKey } = options;
|
|
9768
9855
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
9769
9856
|
if (!contract) return [];
|
|
9770
|
-
const handler =
|
|
9857
|
+
const handler = chunkCOLJARV4_cjs.contractHandlers.get(contract.type);
|
|
9771
9858
|
if (!handler) return [];
|
|
9772
9859
|
const script = handler.createScript(contract.params);
|
|
9773
9860
|
const context = {
|
|
@@ -9823,7 +9910,7 @@ var ContractManager = class _ContractManager {
|
|
|
9823
9910
|
}
|
|
9824
9911
|
async refreshOutpoints(outpoints) {
|
|
9825
9912
|
if (outpoints.length === 0) return;
|
|
9826
|
-
const { vtxos } = await
|
|
9913
|
+
const { vtxos } = await chunkD6RGHPZ5_cjs.getNormalizedVtxos(this.config.indexerProvider, {
|
|
9827
9914
|
outpoints
|
|
9828
9915
|
});
|
|
9829
9916
|
if (vtxos.length === 0) return;
|
|
@@ -9901,7 +9988,7 @@ var ContractManager = class _ContractManager {
|
|
|
9901
9988
|
break;
|
|
9902
9989
|
}
|
|
9903
9990
|
} catch (err) {
|
|
9904
|
-
if (!
|
|
9991
|
+
if (!chunkD6RGHPZ5_cjs.isRetryableProviderError(err)) throw err;
|
|
9905
9992
|
this.markSyncDegraded(err);
|
|
9906
9993
|
}
|
|
9907
9994
|
this.emitEvent(event);
|
|
@@ -9950,7 +10037,7 @@ var ContractManager = class _ContractManager {
|
|
|
9950
10037
|
*/
|
|
9951
10038
|
async reconcilePendingFrontier(contracts) {
|
|
9952
10039
|
const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
|
|
9953
|
-
const vtxos = await
|
|
10040
|
+
const vtxos = await chunkD6RGHPZ5_cjs.getAllNormalizedVtxos(
|
|
9954
10041
|
this.config.indexerProvider,
|
|
9955
10042
|
contracts.map((c) => c.script),
|
|
9956
10043
|
{ pendingOnly: true }
|
|
@@ -10031,7 +10118,7 @@ var ContractManager = class _ContractManager {
|
|
|
10031
10118
|
}
|
|
10032
10119
|
return result;
|
|
10033
10120
|
}
|
|
10034
|
-
async fetchContractVtxosBulk(contracts, pageSize =
|
|
10121
|
+
async fetchContractVtxosBulk(contracts, pageSize = chunkD6RGHPZ5_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
|
|
10035
10122
|
if (contracts.length === 0) {
|
|
10036
10123
|
return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
|
|
10037
10124
|
}
|
|
@@ -10047,7 +10134,7 @@ var ContractManager = class _ContractManager {
|
|
|
10047
10134
|
before: syncWindow.before
|
|
10048
10135
|
}
|
|
10049
10136
|
} : {};
|
|
10050
|
-
const vtxos = await
|
|
10137
|
+
const vtxos = await chunkD6RGHPZ5_cjs.getAllNormalizedVtxos(
|
|
10051
10138
|
this.config.indexerProvider,
|
|
10052
10139
|
contracts.map((c) => c.script),
|
|
10053
10140
|
{ ...windowOpts, pageSize }
|
|
@@ -10214,7 +10301,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
10214
10301
|
*/
|
|
10215
10302
|
materializeDescriptorAt(index) {
|
|
10216
10303
|
const descriptor = this.identity.descriptor;
|
|
10217
|
-
const network =
|
|
10304
|
+
const network = chunkCOLJARV4_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
10218
10305
|
const expansion = descriptorsScure.expand({ descriptor, network, index });
|
|
10219
10306
|
const keyInfo = expansion.expansionMap?.["@0"];
|
|
10220
10307
|
if (!keyInfo?.keyExpression) {
|
|
@@ -10358,7 +10445,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
10358
10445
|
const provider = await resolveDescriptorProvider(config, setup.walletRepository);
|
|
10359
10446
|
if (!provider) return void 0;
|
|
10360
10447
|
const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
|
|
10361
|
-
const expectedContractType = setup.offchainTapscript instanceof
|
|
10448
|
+
const expectedContractType = setup.offchainTapscript instanceof chunkCOLJARV4_cjs.DelegateVtxo.Script ? "delegate" : "default";
|
|
10362
10449
|
const factoryOpts = {
|
|
10363
10450
|
walletRepository: setup.walletRepository,
|
|
10364
10451
|
contractRepository: setup.contractRepository,
|
|
@@ -10557,7 +10644,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
10557
10644
|
};
|
|
10558
10645
|
function deriveLeafPubkey(descriptor) {
|
|
10559
10646
|
try {
|
|
10560
|
-
return
|
|
10647
|
+
return chunkCOLJARV4_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
10561
10648
|
} catch (e) {
|
|
10562
10649
|
throw new NonRangeableDescriptorError(
|
|
10563
10650
|
"Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
|
|
@@ -10569,7 +10656,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
10569
10656
|
const pubKey = deriveLeafPubkey(descriptor);
|
|
10570
10657
|
const tapscript = rebuildTapscript(current, pubKey);
|
|
10571
10658
|
const serverPubKey = tapscript.options.serverPubKey;
|
|
10572
|
-
const csvTimelock =
|
|
10659
|
+
const csvTimelock = chunkD6RGHPZ5_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
|
|
10573
10660
|
const base$1 = {
|
|
10574
10661
|
script: base.hex.encode(tapscript.pkScript),
|
|
10575
10662
|
address: tapscript.address(hrp, serverPubKey).encode(),
|
|
@@ -10580,11 +10667,11 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
10580
10667
|
// index-0 key. Without it, spends produce unsigned PSBTs that the
|
|
10581
10668
|
// server rejects with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
10582
10669
|
metadata: {
|
|
10583
|
-
...{ source:
|
|
10670
|
+
...{ source: chunkCOLJARV4_cjs.WALLET_RECEIVE_SOURCE },
|
|
10584
10671
|
signingDescriptor: descriptor
|
|
10585
10672
|
}
|
|
10586
10673
|
};
|
|
10587
|
-
const params = tapscript instanceof
|
|
10674
|
+
const params = tapscript instanceof chunkCOLJARV4_cjs.DelegateVtxo.Script ? {
|
|
10588
10675
|
...base$1,
|
|
10589
10676
|
type: "delegate",
|
|
10590
10677
|
params: {
|
|
@@ -10605,10 +10692,10 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
10605
10692
|
return { tapscript, params };
|
|
10606
10693
|
}
|
|
10607
10694
|
function rebuildTapscript(current, pubKey) {
|
|
10608
|
-
if (current instanceof
|
|
10609
|
-
return new
|
|
10695
|
+
if (current instanceof chunkCOLJARV4_cjs.DelegateVtxo.Script) {
|
|
10696
|
+
return new chunkCOLJARV4_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
|
|
10610
10697
|
}
|
|
10611
|
-
return new
|
|
10698
|
+
return new chunkCOLJARV4_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
|
|
10612
10699
|
}
|
|
10613
10700
|
async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
|
|
10614
10701
|
const candidates = await contractRepository.getContracts({
|
|
@@ -10617,7 +10704,7 @@ async function pickActiveReceive(contractRepository, serverPubKey, expectedType)
|
|
|
10617
10704
|
});
|
|
10618
10705
|
const serverPubKeyHex = base.hex.encode(serverPubKey);
|
|
10619
10706
|
const matching = candidates.filter(
|
|
10620
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
10707
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkCOLJARV4_cjs.WALLET_RECEIVE_SOURCE
|
|
10621
10708
|
).sort((a, b) => {
|
|
10622
10709
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
10623
10710
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -10793,12 +10880,12 @@ var InputSignerRouter = class {
|
|
|
10793
10880
|
};
|
|
10794
10881
|
|
|
10795
10882
|
// src/wallet/wallet.ts
|
|
10796
|
-
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl ||
|
|
10883
|
+
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl || chunkD6RGHPZ5_cjs.DEFAULT_ARKADE_SERVER_URL;
|
|
10797
10884
|
function intentProofJobs(coins) {
|
|
10798
10885
|
if (coins.length === 0) return [];
|
|
10799
10886
|
const coinJobs = coins.map((coin, i) => ({
|
|
10800
10887
|
index: i + 1,
|
|
10801
|
-
lookupScript:
|
|
10888
|
+
lookupScript: chunkD6RGHPZ5_cjs.VtxoScript.decode(coin.tapTree).pkScript
|
|
10802
10889
|
}));
|
|
10803
10890
|
return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
|
|
10804
10891
|
}
|
|
@@ -10823,7 +10910,7 @@ function dedupeTimelocks(timelocks) {
|
|
|
10823
10910
|
const seen = /* @__PURE__ */ new Set();
|
|
10824
10911
|
const deduped = [];
|
|
10825
10912
|
for (const timelock of timelocks) {
|
|
10826
|
-
const sequence =
|
|
10913
|
+
const sequence = chunkD6RGHPZ5_cjs.timelockToSequence(timelock).toString();
|
|
10827
10914
|
if (seen.has(sequence)) continue;
|
|
10828
10915
|
seen.add(sequence);
|
|
10829
10916
|
deduped.push(timelock);
|
|
@@ -10840,7 +10927,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
10840
10927
|
state: "active"
|
|
10841
10928
|
});
|
|
10842
10929
|
const newest = candidates.filter(
|
|
10843
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
10930
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkCOLJARV4_cjs.WALLET_RECEIVE_SOURCE
|
|
10844
10931
|
).sort((a, b) => {
|
|
10845
10932
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
10846
10933
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -10848,7 +10935,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
10848
10935
|
if (!newest?.params.pubKey) return baseline;
|
|
10849
10936
|
try {
|
|
10850
10937
|
const pubKey = base.hex.decode(newest.params.pubKey);
|
|
10851
|
-
return new
|
|
10938
|
+
return new chunkCOLJARV4_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
|
|
10852
10939
|
} catch (e) {
|
|
10853
10940
|
console.warn("Skipping malformed boarding contract at boot", newest.script, e);
|
|
10854
10941
|
return baseline;
|
|
@@ -11182,7 +11269,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11182
11269
|
*/
|
|
11183
11270
|
static async setupWalletConfig(config, pubKey) {
|
|
11184
11271
|
const arkadeServerUrl = getArkadeServerUrl(config);
|
|
11185
|
-
const arkProvider = config.arkProvider || new
|
|
11272
|
+
const arkProvider = config.arkProvider || new chunkD6RGHPZ5_cjs.RestArkProvider(arkadeServerUrl);
|
|
11186
11273
|
let indexerProvider = config.indexerProvider;
|
|
11187
11274
|
if (!indexerProvider) {
|
|
11188
11275
|
let indexerUrl = config.indexerUrl;
|
|
@@ -11199,7 +11286,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11199
11286
|
indexerUrl = arkadeServerUrl;
|
|
11200
11287
|
}
|
|
11201
11288
|
}
|
|
11202
|
-
indexerProvider = new
|
|
11289
|
+
indexerProvider = new chunkF4C67JYB_cjs.RestIndexerProvider(indexerUrl);
|
|
11203
11290
|
}
|
|
11204
11291
|
const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
11205
11292
|
const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
@@ -11208,7 +11295,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11208
11295
|
source: serverInfoSource,
|
|
11209
11296
|
lastOnlineAt: serverInfoLastOnlineAt
|
|
11210
11297
|
} = await resolveArkInfo(arkProvider, walletRepository);
|
|
11211
|
-
const network =
|
|
11298
|
+
const network = chunkD6RGHPZ5_cjs.getNetwork(info.network);
|
|
11212
11299
|
if ("descriptor" in config.identity) {
|
|
11213
11300
|
const descriptor = config.identity.descriptor;
|
|
11214
11301
|
const identityIsMainnet = !descriptor.includes("tpub");
|
|
@@ -11255,11 +11342,11 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11255
11342
|
serverPubKey,
|
|
11256
11343
|
csvTimelock: exitTimelock
|
|
11257
11344
|
};
|
|
11258
|
-
const offchainTapscript = !delegatePubKey ? new
|
|
11259
|
-
const boardingTapscript =
|
|
11345
|
+
const offchainTapscript = !delegatePubKey ? new chunkCOLJARV4_cjs.DefaultVtxo.Script(offchainOptions) : new chunkCOLJARV4_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
|
|
11346
|
+
const boardingTapscript = chunkCOLJARV4_cjs.BoardingContractHandler.createScript({
|
|
11260
11347
|
pubKey: base.hex.encode(pubKey),
|
|
11261
11348
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
11262
|
-
csvTimelock:
|
|
11349
|
+
csvTimelock: chunkD6RGHPZ5_cjs.timelockToSequence(boardingTimelock).toString()
|
|
11263
11350
|
});
|
|
11264
11351
|
return {
|
|
11265
11352
|
arkProvider,
|
|
@@ -11365,19 +11452,19 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11365
11452
|
let pendingRecovery = 0;
|
|
11366
11453
|
const now = { timestamp: /* @__PURE__ */ new Date() };
|
|
11367
11454
|
const settled = vtxos.filter(
|
|
11368
|
-
(coin) =>
|
|
11455
|
+
(coin) => chunkD6RGHPZ5_cjs.canSpendOffchain(coin, now) && !coin.isPreconfirmed && !isPendingRecovery(coin)
|
|
11369
11456
|
).reduce((sum, coin) => sum + coin.value, 0);
|
|
11370
11457
|
const preconfirmed = vtxos.filter(
|
|
11371
|
-
(coin) =>
|
|
11458
|
+
(coin) => chunkD6RGHPZ5_cjs.canSpendOffchain(coin, now) && coin.isPreconfirmed && !isPendingRecovery(coin)
|
|
11372
11459
|
).reduce((sum, coin) => sum + coin.value, 0);
|
|
11373
|
-
const available = unlockedVtxos.filter((coin) =>
|
|
11374
|
-
recoverable = vtxos.filter((coin) =>
|
|
11460
|
+
const available = unlockedVtxos.filter((coin) => chunkD6RGHPZ5_cjs.canSpendOffchain(coin, now) && !isPendingRecovery(coin)).reduce((sum, coin) => sum + coin.value, 0);
|
|
11461
|
+
recoverable = vtxos.filter((coin) => chunkD6RGHPZ5_cjs.canRecoverOnchain(coin, now) && !isPendingRecovery(coin)).reduce((sum, coin) => sum + coin.value, 0);
|
|
11375
11462
|
pendingRecovery = vtxos.filter(isPendingRecovery).reduce((sum, coin) => sum + coin.value, 0);
|
|
11376
11463
|
const totalBoarding = confirmed + unconfirmed;
|
|
11377
11464
|
const totalOffchain = settled + preconfirmed + recoverable + pendingRecovery;
|
|
11378
11465
|
const assetBalances = /* @__PURE__ */ new Map();
|
|
11379
11466
|
for (const vtxo of vtxos) {
|
|
11380
|
-
if (
|
|
11467
|
+
if (chunkD6RGHPZ5_cjs.hasTerminalSpend(vtxo)) continue;
|
|
11381
11468
|
if (vtxo.assets) {
|
|
11382
11469
|
for (const a of vtxo.assets) {
|
|
11383
11470
|
const current = assetBalances.get(a.assetId) ?? 0n;
|
|
@@ -11418,8 +11505,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11418
11505
|
if (this._pendingSpendOutpoints.has(`${vtxo.txid}:${vtxo.vout}`)) {
|
|
11419
11506
|
return false;
|
|
11420
11507
|
}
|
|
11421
|
-
if (!
|
|
11422
|
-
if (!f.withRecoverable &&
|
|
11508
|
+
if (!chunkD6RGHPZ5_cjs.hasTerminalSpend(vtxo)) {
|
|
11509
|
+
if (!f.withRecoverable && chunkD6RGHPZ5_cjs.canRecoverOnchain(vtxo, now)) {
|
|
11423
11510
|
return false;
|
|
11424
11511
|
}
|
|
11425
11512
|
return true;
|
|
@@ -11452,7 +11539,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11452
11539
|
const response = await contractManager.getContractsWithVtxos();
|
|
11453
11540
|
const allVtxos = response.flatMap((_) => _.vtxos);
|
|
11454
11541
|
const { boardingTxs, commitmentsToIgnore } = await this.getBoardingTxs();
|
|
11455
|
-
const resolveTxCreatedAt = (txids) =>
|
|
11542
|
+
const resolveTxCreatedAt = (txids) => chunkD6RGHPZ5_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
|
|
11456
11543
|
return buildTransactionHistory(
|
|
11457
11544
|
allVtxos,
|
|
11458
11545
|
boardingTxs,
|
|
@@ -11546,7 +11633,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11546
11633
|
},
|
|
11547
11634
|
isUnrolled: true,
|
|
11548
11635
|
...boardingFacts,
|
|
11549
|
-
virtualStatus:
|
|
11636
|
+
virtualStatus: chunkD6RGHPZ5_cjs.toVirtualStatus(boardingFacts),
|
|
11550
11637
|
spentBy: "",
|
|
11551
11638
|
createdAt: tx.status.confirmed ? new Date(tx.status.block_time * 1e3) : /* @__PURE__ */ new Date(0),
|
|
11552
11639
|
script: scriptHex
|
|
@@ -11602,9 +11689,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11602
11689
|
async getBoardingTapscripts(allowedSigners) {
|
|
11603
11690
|
const byScript = /* @__PURE__ */ new Map();
|
|
11604
11691
|
const add = (s) => byScript.set(base.hex.encode(s.pkScript), s);
|
|
11605
|
-
const boardingCsv = this.boardingTapscript.options.csvTimelock ??
|
|
11692
|
+
const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkCOLJARV4_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
11606
11693
|
add(
|
|
11607
|
-
new
|
|
11694
|
+
new chunkCOLJARV4_cjs.DefaultVtxo.Script({
|
|
11608
11695
|
pubKey: await this.identity.xOnlyPublicKey(),
|
|
11609
11696
|
serverPubKey: this.boardingTapscript.options.serverPubKey,
|
|
11610
11697
|
csvTimelock: boardingCsv
|
|
@@ -11619,7 +11706,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11619
11706
|
for (const c of boardingContracts) {
|
|
11620
11707
|
if (!allowed.has(toXOnlySignerHex(c.params.serverPubKey))) continue;
|
|
11621
11708
|
try {
|
|
11622
|
-
add(
|
|
11709
|
+
add(chunkCOLJARV4_cjs.BoardingContractHandler.createScript(c.params));
|
|
11623
11710
|
} catch (e) {
|
|
11624
11711
|
console.warn("Skipping malformed boarding contract", c.script, e);
|
|
11625
11712
|
}
|
|
@@ -11657,7 +11744,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11657
11744
|
// Per-row CSV delay decoded from THIS tapscript's exit leaf —
|
|
11658
11745
|
// not the wallet's current boarding timelock, which a signer
|
|
11659
11746
|
// rotation may have changed.
|
|
11660
|
-
csvTimelock:
|
|
11747
|
+
csvTimelock: chunkD6RGHPZ5_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
|
|
11661
11748
|
coins: utxos
|
|
11662
11749
|
});
|
|
11663
11750
|
}
|
|
@@ -11790,7 +11877,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11790
11877
|
/** Fetch Arkade transaction ids that are still pending final settlement. */
|
|
11791
11878
|
async fetchPendingTxs() {
|
|
11792
11879
|
const scripts = await this.getWalletScripts();
|
|
11793
|
-
const vtxos = await
|
|
11880
|
+
const vtxos = await chunkD6RGHPZ5_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
|
|
11794
11881
|
return vtxos.filter(
|
|
11795
11882
|
(vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
|
|
11796
11883
|
).map((_) => _.arkTxId);
|
|
@@ -11821,7 +11908,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11821
11908
|
});
|
|
11822
11909
|
for (const contract of contracts) {
|
|
11823
11910
|
if (map.has(contract.script)) continue;
|
|
11824
|
-
const handler =
|
|
11911
|
+
const handler = chunkCOLJARV4_cjs.contractHandlers.get(contract.type);
|
|
11825
11912
|
if (handler) {
|
|
11826
11913
|
const script = handler.createScript(contract.params);
|
|
11827
11914
|
map.set(contract.script, script);
|
|
@@ -11924,7 +12011,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11924
12011
|
lookAhead: this.lookAheadConfig()
|
|
11925
12012
|
});
|
|
11926
12013
|
const baselinePubkey = await this.identity.xOnlyPublicKey();
|
|
11927
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
12014
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkCOLJARV4_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
11928
12015
|
const baselineSigners = [
|
|
11929
12016
|
this.offchainTapscript.options.serverPubKey,
|
|
11930
12017
|
...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
|
|
@@ -11932,8 +12019,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11932
12019
|
const seenBaselineScripts = /* @__PURE__ */ new Set();
|
|
11933
12020
|
for (const serverPubKey of baselineSigners) {
|
|
11934
12021
|
for (const csvTimelock of this.walletContractTimelocks) {
|
|
11935
|
-
const csvTimelockStr =
|
|
11936
|
-
const defaultScript = new
|
|
12022
|
+
const csvTimelockStr = chunkD6RGHPZ5_cjs.timelockToSequence(csvTimelock).toString();
|
|
12023
|
+
const defaultScript = new chunkCOLJARV4_cjs.DefaultVtxo.Script({
|
|
11937
12024
|
pubKey: baselinePubkey,
|
|
11938
12025
|
serverPubKey,
|
|
11939
12026
|
csvTimelock
|
|
@@ -11954,7 +12041,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11954
12041
|
});
|
|
11955
12042
|
}
|
|
11956
12043
|
if (delegatePubKey) {
|
|
11957
|
-
const delegateScript = new
|
|
12044
|
+
const delegateScript = new chunkCOLJARV4_cjs.DelegateVtxo.Script({
|
|
11958
12045
|
pubKey: baselinePubkey,
|
|
11959
12046
|
serverPubKey,
|
|
11960
12047
|
delegatePubKey,
|
|
@@ -11978,9 +12065,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11978
12065
|
}
|
|
11979
12066
|
}
|
|
11980
12067
|
}
|
|
11981
|
-
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ??
|
|
12068
|
+
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkCOLJARV4_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
11982
12069
|
for (const serverPubKey of baselineSigners) {
|
|
11983
|
-
const baselineBoarding = new
|
|
12070
|
+
const baselineBoarding = new chunkCOLJARV4_cjs.DefaultVtxo.Script({
|
|
11984
12071
|
pubKey: baselinePubkey,
|
|
11985
12072
|
serverPubKey,
|
|
11986
12073
|
csvTimelock: boardingCsvTimelock
|
|
@@ -11993,7 +12080,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11993
12080
|
params: {
|
|
11994
12081
|
pubKey: base.hex.encode(baselineBoarding.options.pubKey),
|
|
11995
12082
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
11996
|
-
csvTimelock:
|
|
12083
|
+
csvTimelock: chunkD6RGHPZ5_cjs.timelockToSequence(boardingCsvTimelock).toString()
|
|
11997
12084
|
},
|
|
11998
12085
|
script: boardingScriptHex,
|
|
11999
12086
|
address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
|
|
@@ -12171,7 +12258,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12171
12258
|
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
12172
12259
|
deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
|
|
12173
12260
|
csvTimelocks: this.walletContractTimelocks,
|
|
12174
|
-
delegatePubKey: this.offchainTapscript instanceof
|
|
12261
|
+
delegatePubKey: this.offchainTapscript instanceof chunkCOLJARV4_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
|
|
12175
12262
|
};
|
|
12176
12263
|
}
|
|
12177
12264
|
_signerRouter;
|
|
@@ -12263,25 +12350,25 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12263
12350
|
return this.getBoardingAddress();
|
|
12264
12351
|
}
|
|
12265
12352
|
const descriptor = await provider.getNextSigningDescriptor();
|
|
12266
|
-
const pubKey =
|
|
12267
|
-
const newBoarding = new
|
|
12353
|
+
const pubKey = chunkCOLJARV4_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
12354
|
+
const newBoarding = new chunkCOLJARV4_cjs.DefaultVtxo.Script({
|
|
12268
12355
|
...this._boardingTapscript.options,
|
|
12269
12356
|
pubKey
|
|
12270
12357
|
});
|
|
12271
|
-
const csvTimelock = newBoarding.options.csvTimelock ??
|
|
12358
|
+
const csvTimelock = newBoarding.options.csvTimelock ?? chunkCOLJARV4_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
12272
12359
|
const manager = await this.getContractManager();
|
|
12273
12360
|
await manager.createContract({
|
|
12274
12361
|
type: "boarding",
|
|
12275
12362
|
params: {
|
|
12276
12363
|
pubKey: base.hex.encode(pubKey),
|
|
12277
12364
|
serverPubKey: base.hex.encode(newBoarding.options.serverPubKey),
|
|
12278
|
-
csvTimelock:
|
|
12365
|
+
csvTimelock: chunkD6RGHPZ5_cjs.timelockToSequence(csvTimelock).toString()
|
|
12279
12366
|
},
|
|
12280
12367
|
script: base.hex.encode(newBoarding.pkScript),
|
|
12281
12368
|
address: newBoarding.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
12282
12369
|
state: "active",
|
|
12283
12370
|
metadata: {
|
|
12284
|
-
source:
|
|
12371
|
+
source: chunkCOLJARV4_cjs.WALLET_RECEIVE_SOURCE,
|
|
12285
12372
|
signingDescriptor: descriptor
|
|
12286
12373
|
}
|
|
12287
12374
|
});
|
|
@@ -12396,21 +12483,21 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12396
12483
|
const [currentBoardingRow] = await manager.getContracts({
|
|
12397
12484
|
script: currentBoardingScript
|
|
12398
12485
|
});
|
|
12399
|
-
const newOffchain = this.offchainTapscript instanceof
|
|
12486
|
+
const newOffchain = this.offchainTapscript instanceof chunkCOLJARV4_cjs.DelegateVtxo.Script ? new chunkCOLJARV4_cjs.DelegateVtxo.Script({
|
|
12400
12487
|
...this.offchainTapscript.options,
|
|
12401
12488
|
serverPubKey: xonly
|
|
12402
|
-
}) : new
|
|
12489
|
+
}) : new chunkCOLJARV4_cjs.DefaultVtxo.Script({
|
|
12403
12490
|
...this.offchainTapscript.options,
|
|
12404
12491
|
serverPubKey: xonly
|
|
12405
12492
|
});
|
|
12406
|
-
const newBoarding = new
|
|
12493
|
+
const newBoarding = new chunkCOLJARV4_cjs.DefaultVtxo.Script({
|
|
12407
12494
|
...this._boardingTapscript.options,
|
|
12408
12495
|
serverPubKey: xonly
|
|
12409
12496
|
});
|
|
12410
|
-
const offchainCsv =
|
|
12497
|
+
const offchainCsv = chunkD6RGHPZ5_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
|
|
12411
12498
|
const newOffchainScript = base.hex.encode(newOffchain.pkScript);
|
|
12412
12499
|
const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
|
|
12413
|
-
if (newOffchain instanceof
|
|
12500
|
+
if (newOffchain instanceof chunkCOLJARV4_cjs.DelegateVtxo.Script) {
|
|
12414
12501
|
await manager.createContract({
|
|
12415
12502
|
type: "delegate",
|
|
12416
12503
|
params: {
|
|
@@ -12438,13 +12525,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12438
12525
|
metadata: currentOffchainRow?.metadata
|
|
12439
12526
|
});
|
|
12440
12527
|
}
|
|
12441
|
-
const boardingCsv = newBoarding.options.csvTimelock ??
|
|
12528
|
+
const boardingCsv = newBoarding.options.csvTimelock ?? chunkCOLJARV4_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
12442
12529
|
await manager.createContract({
|
|
12443
12530
|
type: "boarding",
|
|
12444
12531
|
params: {
|
|
12445
12532
|
pubKey: base.hex.encode(newBoarding.options.pubKey),
|
|
12446
12533
|
serverPubKey: base.hex.encode(xonly),
|
|
12447
|
-
csvTimelock:
|
|
12534
|
+
csvTimelock: chunkD6RGHPZ5_cjs.timelockToSequence(boardingCsv).toString()
|
|
12448
12535
|
},
|
|
12449
12536
|
script: base.hex.encode(newBoarding.pkScript),
|
|
12450
12537
|
address: newBoarding.address(this.network.hrp, xonly).encode(),
|
|
@@ -12477,14 +12564,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12477
12564
|
_restoreInFlight;
|
|
12478
12565
|
_addPendingSpends(inputs) {
|
|
12479
12566
|
for (const input of inputs) {
|
|
12480
|
-
if (
|
|
12567
|
+
if (chunkD6RGHPZ5_cjs.isVirtualCoin(input)) {
|
|
12481
12568
|
this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
|
|
12482
12569
|
}
|
|
12483
12570
|
}
|
|
12484
12571
|
}
|
|
12485
12572
|
_removePendingSpends(inputs) {
|
|
12486
12573
|
for (const input of inputs) {
|
|
12487
|
-
if (
|
|
12574
|
+
if (chunkD6RGHPZ5_cjs.isVirtualCoin(input)) {
|
|
12488
12575
|
this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
|
|
12489
12576
|
}
|
|
12490
12577
|
}
|
|
@@ -12544,7 +12631,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12544
12631
|
const hd = provider instanceof HDDescriptorProvider;
|
|
12545
12632
|
const staticDescriptor = hd ? void 0 : `tr(${base.hex.encode(await this.identity.xOnlyPublicKey())})`;
|
|
12546
12633
|
const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
|
|
12547
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
12634
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkCOLJARV4_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
12548
12635
|
const arkInfo = await this.arkProvider.getInfo();
|
|
12549
12636
|
const currentSignerPubKey = toXOnlyPubKey(base.hex.decode(arkInfo.signerPubkey));
|
|
12550
12637
|
const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
|
|
@@ -12563,7 +12650,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12563
12650
|
csvTimelocks: this.walletContractTimelocks,
|
|
12564
12651
|
// Boarding-exit CSV so the boarding handler can build its
|
|
12565
12652
|
// candidate script (distinct from the unilateral-exit matrix).
|
|
12566
|
-
boardingTimelock: this.boardingTapscript.options.csvTimelock ??
|
|
12653
|
+
boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkCOLJARV4_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
|
|
12567
12654
|
delegatePubKey
|
|
12568
12655
|
};
|
|
12569
12656
|
const result = await manager.scanContracts({
|
|
@@ -12825,7 +12912,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12825
12912
|
inputs: params.selectedVtxos,
|
|
12826
12913
|
changeAmount: BigInt(changeAmount)
|
|
12827
12914
|
};
|
|
12828
|
-
const outputAddress =
|
|
12915
|
+
const outputAddress = chunkD6RGHPZ5_cjs.ArkAddress.decode(params.address);
|
|
12829
12916
|
assertRecipientArkAddress(
|
|
12830
12917
|
params.address,
|
|
12831
12918
|
outputAddress,
|
|
@@ -12883,13 +12970,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12883
12970
|
}
|
|
12884
12971
|
}
|
|
12885
12972
|
const offchainAddress = await this.getAddress();
|
|
12886
|
-
const offchainPkScript =
|
|
12973
|
+
const offchainPkScript = chunkD6RGHPZ5_cjs.ArkAddress.decode(offchainAddress).pkScript;
|
|
12887
12974
|
const offchainOutputScript = base.hex.encode(offchainPkScript);
|
|
12888
12975
|
if (!params) {
|
|
12889
12976
|
const { fees, vtxoMaxAmount } = await this.arkProvider.getInfo();
|
|
12890
12977
|
const estimator = new Estimator(fees.intentFee);
|
|
12891
12978
|
let amount = 0;
|
|
12892
|
-
const exitScript =
|
|
12979
|
+
const exitScript = chunkD6RGHPZ5_cjs.CSVMultisigTapscript.decode(
|
|
12893
12980
|
base.hex.decode(this.boardingTapscript.exitScript)
|
|
12894
12981
|
);
|
|
12895
12982
|
const boardingTimelock = exitScript.params.timelock;
|
|
@@ -12918,7 +13005,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12918
13005
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
12919
13006
|
break;
|
|
12920
13007
|
}
|
|
12921
|
-
const inputFee = estimator.evalOffchainInput(
|
|
13008
|
+
const inputFee = estimator.evalOffchainInput(chunkD6RGHPZ5_cjs.toOffchainInputFeeParams(vtxo));
|
|
12922
13009
|
if (inputFee.satoshis >= vtxo.value) {
|
|
12923
13010
|
continue;
|
|
12924
13011
|
}
|
|
@@ -12965,7 +13052,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12965
13052
|
let script;
|
|
12966
13053
|
let arkAddress;
|
|
12967
13054
|
try {
|
|
12968
|
-
arkAddress =
|
|
13055
|
+
arkAddress = chunkD6RGHPZ5_cjs.ArkAddress.decode(output.address);
|
|
12969
13056
|
} catch {
|
|
12970
13057
|
arkAddress = void 0;
|
|
12971
13058
|
}
|
|
@@ -13157,7 +13244,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13157
13244
|
async maybeRotateBoardingAfterBoard(inputs) {
|
|
13158
13245
|
if (!this._descriptorProvider) return;
|
|
13159
13246
|
const consumedBoarding = inputs.some(
|
|
13160
|
-
(input) => typeof input !== "string" && !
|
|
13247
|
+
(input) => typeof input !== "string" && !chunkD6RGHPZ5_cjs.isVirtualCoin(input)
|
|
13161
13248
|
);
|
|
13162
13249
|
if (!consumedBoarding) return;
|
|
13163
13250
|
try {
|
|
@@ -13181,7 +13268,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13181
13268
|
let connectorIndex = 0;
|
|
13182
13269
|
const connectorsLeaves = connectorsGraph?.leaves() || [];
|
|
13183
13270
|
for (const input of inputs) {
|
|
13184
|
-
if (!
|
|
13271
|
+
if (!chunkD6RGHPZ5_cjs.isVirtualCoin(input)) {
|
|
13185
13272
|
for (let i = 0; i < settlementPsbt.inputsLength; i++) {
|
|
13186
13273
|
const settlementInput = settlementPsbt.getInput(i);
|
|
13187
13274
|
if (!settlementInput.txid || settlementInput.index === void 0) {
|
|
@@ -13212,7 +13299,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13212
13299
|
}
|
|
13213
13300
|
continue;
|
|
13214
13301
|
}
|
|
13215
|
-
if (
|
|
13302
|
+
if (chunkD6RGHPZ5_cjs.canRecoverOnchain(input, { timestamp: /* @__PURE__ */ new Date() }) || isSubdust({ value: input.value }, this.dustAmount)) {
|
|
13216
13303
|
continue;
|
|
13217
13304
|
}
|
|
13218
13305
|
if (connectorsLeaves.length === 0) {
|
|
@@ -13240,7 +13327,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13240
13327
|
index: input.vout,
|
|
13241
13328
|
witnessUtxo: {
|
|
13242
13329
|
amount: BigInt(input.value),
|
|
13243
|
-
script:
|
|
13330
|
+
script: chunkD6RGHPZ5_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
13244
13331
|
},
|
|
13245
13332
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
13246
13333
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -13259,7 +13346,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13259
13346
|
forfeitTx = await this._signerRouter.sign(forfeitTx, [
|
|
13260
13347
|
{
|
|
13261
13348
|
index: 0,
|
|
13262
|
-
lookupScript:
|
|
13349
|
+
lookupScript: chunkD6RGHPZ5_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
13263
13350
|
}
|
|
13264
13351
|
]);
|
|
13265
13352
|
signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
|
|
@@ -13317,7 +13404,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13317
13404
|
resolveBatchExpiryPolicy(this.network, this.batchExpiryPolicy)
|
|
13318
13405
|
);
|
|
13319
13406
|
await this.arkProvider.confirmRegistration(intentId);
|
|
13320
|
-
const sweepTapscript =
|
|
13407
|
+
const sweepTapscript = chunkD6RGHPZ5_cjs.CSVMultisigTapscript.encode({
|
|
13321
13408
|
timelock,
|
|
13322
13409
|
pubkeys: [this.forfeitPubkey]
|
|
13323
13410
|
}).script;
|
|
@@ -13423,9 +13510,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13423
13510
|
...existing ?? {},
|
|
13424
13511
|
intentTxId,
|
|
13425
13512
|
registerProof: intent.proof,
|
|
13426
|
-
registerProofMessage:
|
|
13513
|
+
registerProofMessage: chunkD6RGHPZ5_cjs.Intent.encodeMessage(intent.message),
|
|
13427
13514
|
deleteProof: deleteIntent.proof,
|
|
13428
|
-
deleteProofMessage:
|
|
13515
|
+
deleteProofMessage: chunkD6RGHPZ5_cjs.Intent.encodeMessage(deleteIntent.message),
|
|
13429
13516
|
intentVtxos: inputs.map((i) => ({
|
|
13430
13517
|
txid: i.txid,
|
|
13431
13518
|
vout: i.vout
|
|
@@ -13457,7 +13544,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13457
13544
|
try {
|
|
13458
13545
|
return await this.arkProvider.registerIntent(intent);
|
|
13459
13546
|
} catch (error) {
|
|
13460
|
-
if (error instanceof
|
|
13547
|
+
if (error instanceof chunkD6RGHPZ5_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
|
|
13461
13548
|
const deleteIntent = await this.makeDeleteIntentSignature(inputs);
|
|
13462
13549
|
await this.arkProvider.deleteIntent(deleteIntent);
|
|
13463
13550
|
return this.arkProvider.registerIntent(intent);
|
|
@@ -13473,7 +13560,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13473
13560
|
expire_at: 0,
|
|
13474
13561
|
cosigners_public_keys: cosignerPubKeys
|
|
13475
13562
|
};
|
|
13476
|
-
const proof =
|
|
13563
|
+
const proof = chunkD6RGHPZ5_cjs.Intent.create(message, coins, outputs);
|
|
13477
13564
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
13478
13565
|
return {
|
|
13479
13566
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -13485,7 +13572,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13485
13572
|
type: "delete",
|
|
13486
13573
|
expire_at: 0
|
|
13487
13574
|
};
|
|
13488
|
-
const proof =
|
|
13575
|
+
const proof = chunkD6RGHPZ5_cjs.Intent.create(message, coins, []);
|
|
13489
13576
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
13490
13577
|
return {
|
|
13491
13578
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -13497,7 +13584,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13497
13584
|
type: "get-pending-tx",
|
|
13498
13585
|
expire_at: 0
|
|
13499
13586
|
};
|
|
13500
|
-
const proof =
|
|
13587
|
+
const proof = chunkD6RGHPZ5_cjs.Intent.create(message, coins, []);
|
|
13501
13588
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
13502
13589
|
return {
|
|
13503
13590
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -13518,7 +13605,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13518
13605
|
if (!vtxos || vtxos.length === 0) {
|
|
13519
13606
|
const scriptMap = await this.getScriptMap();
|
|
13520
13607
|
const allExtended = [];
|
|
13521
|
-
const fetchedVtxos = await
|
|
13608
|
+
const fetchedVtxos = await chunkD6RGHPZ5_cjs.getAllNormalizedVtxos(this.indexerProvider, [
|
|
13522
13609
|
...scriptMap.keys()
|
|
13523
13610
|
]);
|
|
13524
13611
|
for (const vtxo of fetchedVtxos) {
|
|
@@ -13632,11 +13719,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13632
13719
|
* against the current key alone would leave it pending forever.
|
|
13633
13720
|
*/
|
|
13634
13721
|
checkpointUnrollCandidates(info) {
|
|
13635
|
-
const current =
|
|
13722
|
+
const current = chunkD6RGHPZ5_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
13636
13723
|
const candidates = [this._serverUnrollScript, current];
|
|
13637
13724
|
for (const deprecated of signerSetFromInfo(info).deprecated.keys()) {
|
|
13638
13725
|
candidates.push(
|
|
13639
|
-
|
|
13726
|
+
chunkD6RGHPZ5_cjs.CSVMultisigTapscript.encode({
|
|
13640
13727
|
...current.params,
|
|
13641
13728
|
pubkeys: [base.hex.decode(deprecated)]
|
|
13642
13729
|
})
|
|
@@ -13727,7 +13814,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13727
13814
|
if (vtxos.length === 0) {
|
|
13728
13815
|
throw new Error("No VTXOs found for this arkadeCash");
|
|
13729
13816
|
}
|
|
13730
|
-
const myPkScript =
|
|
13817
|
+
const myPkScript = chunkD6RGHPZ5_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
|
|
13731
13818
|
let { spendable, unclaimed } = this.classifyCashVtxos(vtxos);
|
|
13732
13819
|
let swept = 0;
|
|
13733
13820
|
const drainable = vtxos.filter((vtxo) => !isSubdust(vtxo, this.dustAmount));
|
|
@@ -13801,7 +13888,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13801
13888
|
const spendable = [];
|
|
13802
13889
|
const unclaimed = [];
|
|
13803
13890
|
for (const vtxo of vtxos) {
|
|
13804
|
-
if (
|
|
13891
|
+
if (chunkD6RGHPZ5_cjs.hasTerminalSpend(vtxo)) {
|
|
13805
13892
|
unclaimed.push(cashReport(vtxo, "already-spent"));
|
|
13806
13893
|
} else if (isSubdust(vtxo, this.dustAmount)) {
|
|
13807
13894
|
unclaimed.push(cashReport(vtxo, "subdust"));
|
|
@@ -13821,7 +13908,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13821
13908
|
const all = [];
|
|
13822
13909
|
const seen = /* @__PURE__ */ new Set();
|
|
13823
13910
|
for (let pageIndex = 0; ; pageIndex++) {
|
|
13824
|
-
const { vtxos, page } = await
|
|
13911
|
+
const { vtxos, page } = await chunkD6RGHPZ5_cjs.getNormalizedVtxos(this.indexerProvider, {
|
|
13825
13912
|
scripts,
|
|
13826
13913
|
pageIndex,
|
|
13827
13914
|
pageSize
|
|
@@ -13868,7 +13955,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13868
13955
|
for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
|
|
13869
13956
|
const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
|
|
13870
13957
|
const message = { type: "get-pending-tx", expire_at: 0 };
|
|
13871
|
-
const proof =
|
|
13958
|
+
const proof = chunkD6RGHPZ5_cjs.Intent.create(message, batch, []);
|
|
13872
13959
|
const signedProof = await identity.sign(
|
|
13873
13960
|
proof,
|
|
13874
13961
|
Array.from({ length: batch.length + 1 }, (_, j) => j)
|
|
@@ -14178,10 +14265,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14178
14265
|
const serverPubKey = this.arkServerPublicKey;
|
|
14179
14266
|
const serverUnrollScript = this.serverUnrollScript;
|
|
14180
14267
|
const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
|
|
14181
|
-
const normalizedInputs = inputs.map(
|
|
14182
|
-
const at = now ?? await
|
|
14268
|
+
const normalizedInputs = inputs.map(chunkD6RGHPZ5_cjs.normalizeVtxo);
|
|
14269
|
+
const at = now ?? await chunkD6RGHPZ5_cjs.resolveTimeHeight(this.onchainProvider);
|
|
14183
14270
|
for (const input of normalizedInputs) {
|
|
14184
|
-
if (!
|
|
14271
|
+
if (!chunkD6RGHPZ5_cjs.canSpendOffchain(input, at)) {
|
|
14185
14272
|
throw new Error(
|
|
14186
14273
|
`sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
|
|
14187
14274
|
);
|
|
@@ -14246,7 +14333,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14246
14333
|
);
|
|
14247
14334
|
const arkTxJobs = inputs.map((input, index) => ({
|
|
14248
14335
|
index,
|
|
14249
|
-
lookupScript:
|
|
14336
|
+
lookupScript: chunkD6RGHPZ5_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
14250
14337
|
}));
|
|
14251
14338
|
const identity = this.identity;
|
|
14252
14339
|
const signer = {
|
|
@@ -14332,14 +14419,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14332
14419
|
const spentBy = checkpointIdByOutpoint.get(`${vtxo.txid}:${vtxo.vout}`);
|
|
14333
14420
|
spentVtxos.push({
|
|
14334
14421
|
...spentFacts,
|
|
14335
|
-
virtualStatus:
|
|
14422
|
+
virtualStatus: chunkD6RGHPZ5_cjs.toVirtualStatus(spentFacts),
|
|
14336
14423
|
...spentBy ? { spentBy } : {},
|
|
14337
14424
|
arkTxId: arkTxid
|
|
14338
14425
|
});
|
|
14339
14426
|
for (const id of vtxo.commitmentTxIds) {
|
|
14340
14427
|
commitmentTxIds.add(id);
|
|
14341
14428
|
}
|
|
14342
|
-
const vtxoExpiry =
|
|
14429
|
+
const vtxoExpiry = chunkD6RGHPZ5_cjs.toBatchExpiry(vtxo);
|
|
14343
14430
|
if (vtxoExpiry) {
|
|
14344
14431
|
batchExpiry = Math.min(batchExpiry, vtxoExpiry);
|
|
14345
14432
|
}
|
|
@@ -14352,7 +14439,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14352
14439
|
isSwept: false,
|
|
14353
14440
|
isPreconfirmed: true,
|
|
14354
14441
|
commitmentTxIds: Array.from(commitmentTxIds),
|
|
14355
|
-
...
|
|
14442
|
+
...chunkD6RGHPZ5_cjs.parseLegacyExpiry(batchExpiry)
|
|
14356
14443
|
};
|
|
14357
14444
|
changeVtxo = {
|
|
14358
14445
|
txid: arkTxid,
|
|
@@ -14364,7 +14451,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14364
14451
|
tapTree: offchainTapscript.encode(),
|
|
14365
14452
|
value: Number(changeAmount),
|
|
14366
14453
|
...changeFacts,
|
|
14367
|
-
virtualStatus:
|
|
14454
|
+
virtualStatus: chunkD6RGHPZ5_cjs.toVirtualStatus(changeFacts),
|
|
14368
14455
|
spentBy: "",
|
|
14369
14456
|
status: {
|
|
14370
14457
|
confirmed: false
|
|
@@ -14433,12 +14520,12 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14433
14520
|
const spentVtxos = [];
|
|
14434
14521
|
const inputArkTxIds = /* @__PURE__ */ new Set();
|
|
14435
14522
|
const boardingRemovalsByAddress = /* @__PURE__ */ new Map();
|
|
14436
|
-
const vtxoInputs = inputs.filter(
|
|
14523
|
+
const vtxoInputs = inputs.filter(chunkD6RGHPZ5_cjs.isVirtualCoin);
|
|
14437
14524
|
const cm = await this.getContractManager();
|
|
14438
14525
|
const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
|
|
14439
14526
|
const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
|
|
14440
14527
|
for (const input of inputs) {
|
|
14441
|
-
if (
|
|
14528
|
+
if (chunkD6RGHPZ5_cjs.isVirtualCoin(input)) {
|
|
14442
14529
|
const outpoint = `${input.txid}:${input.vout}`;
|
|
14443
14530
|
const vtxo = annotatedByKey.get(outpoint);
|
|
14444
14531
|
if (!vtxo) {
|
|
@@ -14450,13 +14537,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14450
14537
|
const settledFacts = { ...vtxo, isSpent: true };
|
|
14451
14538
|
spentVtxos.push({
|
|
14452
14539
|
...settledFacts,
|
|
14453
|
-
virtualStatus:
|
|
14540
|
+
virtualStatus: chunkD6RGHPZ5_cjs.toVirtualStatus(settledFacts),
|
|
14454
14541
|
settledBy: commitmentTxid
|
|
14455
14542
|
});
|
|
14456
14543
|
} else {
|
|
14457
14544
|
let sourceAddress;
|
|
14458
14545
|
try {
|
|
14459
|
-
sourceAddress =
|
|
14546
|
+
sourceAddress = chunkD6RGHPZ5_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
|
|
14460
14547
|
this.network
|
|
14461
14548
|
);
|
|
14462
14549
|
} catch {
|
|
@@ -14514,9 +14601,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14514
14601
|
}
|
|
14515
14602
|
};
|
|
14516
14603
|
function selectVirtualCoins(coins, targetAmount) {
|
|
14517
|
-
const sortedCoins = coins.map(
|
|
14518
|
-
const expiryA =
|
|
14519
|
-
const expiryB =
|
|
14604
|
+
const sortedCoins = coins.map(chunkD6RGHPZ5_cjs.normalizeVtxo).sort((a, b) => {
|
|
14605
|
+
const expiryA = chunkD6RGHPZ5_cjs.toBatchExpiry(a) || Number.MAX_SAFE_INTEGER;
|
|
14606
|
+
const expiryB = chunkD6RGHPZ5_cjs.toBatchExpiry(b) || Number.MAX_SAFE_INTEGER;
|
|
14520
14607
|
if (expiryA !== expiryB) {
|
|
14521
14608
|
return expiryA - expiryB;
|
|
14522
14609
|
}
|
|
@@ -14773,7 +14860,7 @@ var MessageBus = class {
|
|
|
14773
14860
|
this.initialized = true;
|
|
14774
14861
|
}
|
|
14775
14862
|
async buildServices(config) {
|
|
14776
|
-
const arkProvider = new
|
|
14863
|
+
const arkProvider = new chunkD6RGHPZ5_cjs.RestArkProvider(config.arkServer.url);
|
|
14777
14864
|
const storage = {
|
|
14778
14865
|
walletRepository: this.walletRepository,
|
|
14779
14866
|
contractRepository: this.contractRepository
|
|
@@ -14793,7 +14880,9 @@ var MessageBus = class {
|
|
|
14793
14880
|
settlementConfig: config.settlementConfig,
|
|
14794
14881
|
walletMode: config.walletMode,
|
|
14795
14882
|
watcherConfig: config.watcherConfig,
|
|
14796
|
-
lookAheadWindow: config.lookAheadWindow
|
|
14883
|
+
lookAheadWindow: config.lookAheadWindow,
|
|
14884
|
+
minBatchExpirySeconds: config.minBatchExpirySeconds,
|
|
14885
|
+
minCheckpointExitDelaySeconds: config.minCheckpointExitDelaySeconds
|
|
14797
14886
|
});
|
|
14798
14887
|
return { wallet, arkProvider, readonlyWallet: wallet };
|
|
14799
14888
|
}
|
|
@@ -15112,7 +15201,7 @@ var offboardNetworkNames = [
|
|
|
15112
15201
|
function offboardDestinationScript(destinationAddress) {
|
|
15113
15202
|
for (const networkName of offboardNetworkNames) {
|
|
15114
15203
|
try {
|
|
15115
|
-
const network =
|
|
15204
|
+
const network = chunkD6RGHPZ5_cjs.networks[networkName];
|
|
15116
15205
|
const addr = btcSigner.Address(network).decode(destinationAddress);
|
|
15117
15206
|
return btcSigner.OutScript.encode(addr);
|
|
15118
15207
|
} catch {
|
|
@@ -15176,7 +15265,7 @@ var Ramps = class {
|
|
|
15176
15265
|
}
|
|
15177
15266
|
amount = amount ?? totalAmount;
|
|
15178
15267
|
const offchainAddress = await this.wallet.getAddress();
|
|
15179
|
-
const offchainAddr =
|
|
15268
|
+
const offchainAddr = chunkD6RGHPZ5_cjs.ArkAddress.decode(offchainAddress);
|
|
15180
15269
|
const offchainScript = base.hex.encode(offchainAddr.pkScript);
|
|
15181
15270
|
const outputFee = estimator.evalOffchainOutput({
|
|
15182
15271
|
amount,
|
|
@@ -15236,7 +15325,7 @@ var Ramps = class {
|
|
|
15236
15325
|
const filteredVtxos = [];
|
|
15237
15326
|
let totalAmount = 0n;
|
|
15238
15327
|
for (const vtxo of vtxos) {
|
|
15239
|
-
const inputFee = estimator.evalOffchainInput(
|
|
15328
|
+
const inputFee = estimator.evalOffchainInput(chunkD6RGHPZ5_cjs.toOffchainInputFeeParams(vtxo));
|
|
15240
15329
|
if (inputFee.satoshis >= vtxo.value) {
|
|
15241
15330
|
continue;
|
|
15242
15331
|
}
|
|
@@ -15933,7 +16022,7 @@ var WalletMessageHandler = class {
|
|
|
15933
16022
|
// Wallet methods
|
|
15934
16023
|
async handleInitWallet({ payload }) {
|
|
15935
16024
|
const { arkServerUrl } = payload;
|
|
15936
|
-
this.indexerProvider = new
|
|
16025
|
+
this.indexerProvider = new chunkF4C67JYB_cjs.RestIndexerProvider(arkServerUrl);
|
|
15937
16026
|
await this.onWalletInitialized();
|
|
15938
16027
|
}
|
|
15939
16028
|
async handleGetBalance() {
|
|
@@ -15957,12 +16046,12 @@ var WalletMessageHandler = class {
|
|
|
15957
16046
|
let recoverable = 0;
|
|
15958
16047
|
let pendingRecovery = 0;
|
|
15959
16048
|
for (const vtxo of allVtxos) {
|
|
15960
|
-
if (
|
|
16049
|
+
if (chunkD6RGHPZ5_cjs.hasTerminalSpend(vtxo)) continue;
|
|
15961
16050
|
if (pendingOutpoints.has(`${vtxo.txid}:${vtxo.vout}`)) {
|
|
15962
16051
|
pendingRecovery += vtxo.value;
|
|
15963
|
-
} else if (
|
|
16052
|
+
} else if (chunkD6RGHPZ5_cjs.canRecoverOnchain(vtxo, now)) {
|
|
15964
16053
|
recoverable += vtxo.value;
|
|
15965
|
-
} else if (
|
|
16054
|
+
} else if (chunkD6RGHPZ5_cjs.canSpendOffchain(vtxo, now)) {
|
|
15966
16055
|
if (vtxo.isPreconfirmed) {
|
|
15967
16056
|
preconfirmed += vtxo.value;
|
|
15968
16057
|
} else {
|
|
@@ -15974,7 +16063,7 @@ var WalletMessageHandler = class {
|
|
|
15974
16063
|
const totalOffchain = settled + preconfirmed + recoverable + pendingRecovery;
|
|
15975
16064
|
const assetBalances = /* @__PURE__ */ new Map();
|
|
15976
16065
|
for (const vtxo of allVtxos) {
|
|
15977
|
-
if (
|
|
16066
|
+
if (chunkD6RGHPZ5_cjs.hasTerminalSpend(vtxo)) continue;
|
|
15978
16067
|
if (vtxo.assets) {
|
|
15979
16068
|
for (const a of vtxo.assets) {
|
|
15980
16069
|
const current = assetBalances.get(a.assetId) ?? 0n;
|
|
@@ -16010,7 +16099,7 @@ var WalletMessageHandler = class {
|
|
|
16010
16099
|
*/
|
|
16011
16100
|
async getSpendableVtxos() {
|
|
16012
16101
|
const vtxos = await this.getVtxosFromRepo();
|
|
16013
|
-
return vtxos.filter((v) => !
|
|
16102
|
+
return vtxos.filter((v) => !chunkD6RGHPZ5_cjs.hasTerminalSpend(v));
|
|
16014
16103
|
}
|
|
16015
16104
|
async onWalletInitialized() {
|
|
16016
16105
|
if (!this.readonlyWallet || !this.arkProvider || !this.indexerProvider || !this.walletRepository) {
|
|
@@ -16222,10 +16311,10 @@ var WalletMessageHandler = class {
|
|
|
16222
16311
|
if (dustAmount != null && isSubdust(v, dustAmount)) {
|
|
16223
16312
|
return false;
|
|
16224
16313
|
}
|
|
16225
|
-
if (
|
|
16314
|
+
if (chunkD6RGHPZ5_cjs.isRecoverable(v)) {
|
|
16226
16315
|
return false;
|
|
16227
16316
|
}
|
|
16228
|
-
if (
|
|
16317
|
+
if (chunkD6RGHPZ5_cjs.isExpired(v)) {
|
|
16229
16318
|
return false;
|
|
16230
16319
|
}
|
|
16231
16320
|
return true;
|
|
@@ -16297,7 +16386,7 @@ var WalletMessageHandler = class {
|
|
|
16297
16386
|
if (!this.readonlyWallet) return null;
|
|
16298
16387
|
const { boardingTxs, commitmentsToIgnore } = await this.readonlyWallet.getBoardingTxs();
|
|
16299
16388
|
const indexerProvider = this.indexerProvider;
|
|
16300
|
-
const resolveTxCreatedAt = indexerProvider ? (txids) =>
|
|
16389
|
+
const resolveTxCreatedAt = indexerProvider ? (txids) => chunkD6RGHPZ5_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
|
|
16301
16390
|
return buildTransactionHistory(vtxos, boardingTxs, commitmentsToIgnore, resolveTxCreatedAt);
|
|
16302
16391
|
}
|
|
16303
16392
|
async ensureContractEventBroadcasting() {
|
|
@@ -16982,7 +17071,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
16982
17071
|
};
|
|
16983
17072
|
try {
|
|
16984
17073
|
const response = await this.sendMessage(message);
|
|
16985
|
-
return response.payload.vtxos.map(
|
|
17074
|
+
return response.payload.vtxos.map(chunkD6RGHPZ5_cjs.normalizeVtxo);
|
|
16986
17075
|
} catch (error) {
|
|
16987
17076
|
throw new Error(`Failed to get vtxos: ${error}`);
|
|
16988
17077
|
}
|
|
@@ -17095,7 +17184,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
17095
17184
|
};
|
|
17096
17185
|
try {
|
|
17097
17186
|
const response = await sendContractMessage(message);
|
|
17098
|
-
return response.payload.vtxos.map(
|
|
17187
|
+
return response.payload.vtxos.map(chunkD6RGHPZ5_cjs.normalizeVtxo);
|
|
17099
17188
|
} catch (e) {
|
|
17100
17189
|
throw new Error("Failed to annotate vtxos");
|
|
17101
17190
|
}
|
|
@@ -17326,6 +17415,8 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
17326
17415
|
walletMode: options.walletMode,
|
|
17327
17416
|
watcherConfig: options.watcherConfig,
|
|
17328
17417
|
lookAheadWindow: options.lookAheadWindow,
|
|
17418
|
+
minBatchExpirySeconds: options.minBatchExpirySeconds,
|
|
17419
|
+
minCheckpointExitDelaySeconds: options.minCheckpointExitDelaySeconds,
|
|
17329
17420
|
messageTimeouts
|
|
17330
17421
|
};
|
|
17331
17422
|
await initializeMessageBus(
|
|
@@ -17549,7 +17640,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
17549
17640
|
};
|
|
17550
17641
|
try {
|
|
17551
17642
|
const response = await wallet.sendMessage(message);
|
|
17552
|
-
return response.payload.vtxos.map(
|
|
17643
|
+
return response.payload.vtxos.map(chunkD6RGHPZ5_cjs.normalizeVtxo);
|
|
17553
17644
|
} catch (e) {
|
|
17554
17645
|
throw new Error(`Failed to get expiring vtxos: ${e}`);
|
|
17555
17646
|
}
|
|
@@ -17661,12 +17752,12 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
17661
17752
|
* @returns Configured onchain wallet
|
|
17662
17753
|
* @throws Error if the configured identity cannot produce a valid x-only public key
|
|
17663
17754
|
*/
|
|
17664
|
-
static async create(identity, networkName =
|
|
17755
|
+
static async create(identity, networkName = chunkD6RGHPZ5_cjs.DEFAULT_NETWORK_NAME, provider) {
|
|
17665
17756
|
const pubkey = await identity.xOnlyPublicKey();
|
|
17666
17757
|
if (!pubkey) {
|
|
17667
17758
|
throw new Error("Invalid configured public key");
|
|
17668
17759
|
}
|
|
17669
|
-
const network =
|
|
17760
|
+
const network = chunkD6RGHPZ5_cjs.getNetwork(networkName);
|
|
17670
17761
|
const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
|
|
17671
17762
|
const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
|
|
17672
17763
|
return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
|
|
@@ -17772,7 +17863,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
17772
17863
|
if (!inputs) {
|
|
17773
17864
|
throw new Error("Fee estimation failed");
|
|
17774
17865
|
}
|
|
17775
|
-
let tx = new
|
|
17866
|
+
let tx = new chunkD6RGHPZ5_cjs.Transaction();
|
|
17776
17867
|
for (const input of inputs) {
|
|
17777
17868
|
tx.addInput({
|
|
17778
17869
|
txid: input.txid,
|
|
@@ -17830,7 +17921,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
17830
17921
|
* @throws If the parent has no anchor, or funding cannot be selected/signed
|
|
17831
17922
|
*/
|
|
17832
17923
|
async bumpAnchor(parentHex, feeRate) {
|
|
17833
|
-
const parent =
|
|
17924
|
+
const parent = chunkD6RGHPZ5_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
|
|
17834
17925
|
const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
|
|
17835
17926
|
const child = await this.buildBumpPackage(parent, feeRate, coins);
|
|
17836
17927
|
return [parent.hex, child.hex];
|
|
@@ -18595,7 +18686,7 @@ exports.BIP322 = void 0;
|
|
|
18595
18686
|
async function sign2(message, identity, network) {
|
|
18596
18687
|
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
18597
18688
|
const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
|
|
18598
|
-
const toSpend =
|
|
18689
|
+
const toSpend = chunkD6RGHPZ5_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
18599
18690
|
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
18600
18691
|
const signed = await identity.sign(toSign, [0]);
|
|
18601
18692
|
signed.finalizeIdx(0);
|
|
@@ -18653,7 +18744,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
|
18653
18744
|
if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
|
|
18654
18745
|
return false;
|
|
18655
18746
|
}
|
|
18656
|
-
const toSpend =
|
|
18747
|
+
const toSpend = chunkD6RGHPZ5_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
18657
18748
|
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
|
|
18658
18749
|
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
18659
18750
|
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
@@ -18674,7 +18765,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
|
18674
18765
|
}
|
|
18675
18766
|
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
18676
18767
|
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
18677
|
-
const toSpend =
|
|
18768
|
+
const toSpend = chunkD6RGHPZ5_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
18678
18769
|
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
18679
18770
|
const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
|
|
18680
18771
|
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
@@ -18727,7 +18818,7 @@ function encodeCompactSize(n) {
|
|
|
18727
18818
|
return buf;
|
|
18728
18819
|
}
|
|
18729
18820
|
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
18730
|
-
const tx = new
|
|
18821
|
+
const tx = new chunkD6RGHPZ5_cjs.Transaction({ version: 0 });
|
|
18731
18822
|
tx.addInput({
|
|
18732
18823
|
txid: toSpend.id,
|
|
18733
18824
|
index: 0,
|
|
@@ -18741,12 +18832,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
|
18741
18832
|
});
|
|
18742
18833
|
tx.addOutput({
|
|
18743
18834
|
amount: 0n,
|
|
18744
|
-
script:
|
|
18835
|
+
script: chunkD6RGHPZ5_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
18745
18836
|
});
|
|
18746
18837
|
return tx;
|
|
18747
18838
|
}
|
|
18748
18839
|
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
18749
|
-
const tx = new
|
|
18840
|
+
const tx = new chunkD6RGHPZ5_cjs.Transaction({ version: 0 });
|
|
18750
18841
|
tx.addInput({
|
|
18751
18842
|
txid: toSpend.id,
|
|
18752
18843
|
index: 0,
|
|
@@ -18758,7 +18849,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
|
18758
18849
|
});
|
|
18759
18850
|
tx.addOutput({
|
|
18760
18851
|
amount: 0n,
|
|
18761
|
-
script:
|
|
18852
|
+
script: chunkD6RGHPZ5_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
18762
18853
|
});
|
|
18763
18854
|
return tx;
|
|
18764
18855
|
}
|
|
@@ -18889,7 +18980,7 @@ var RestEmulatorProvider = class {
|
|
|
18889
18980
|
}
|
|
18890
18981
|
};
|
|
18891
18982
|
function finalizeVirtualTx(type, psbtBase64) {
|
|
18892
|
-
const tx =
|
|
18983
|
+
const tx = chunkD6RGHPZ5_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
18893
18984
|
if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
|
|
18894
18985
|
const input = tx.getInput(0);
|
|
18895
18986
|
if (!input) {
|
|
@@ -18916,14 +19007,14 @@ var ExitPathError = class extends Error {
|
|
|
18916
19007
|
reason;
|
|
18917
19008
|
};
|
|
18918
19009
|
function delayWeight(sequence) {
|
|
18919
|
-
const t =
|
|
19010
|
+
const t = chunkD6RGHPZ5_cjs.sequenceToTimelock(sequence);
|
|
18920
19011
|
return t.type === "blocks" ? Number(t.value) : Number(t.value) / 600;
|
|
18921
19012
|
}
|
|
18922
19013
|
async function resolveUnilateralPath(params) {
|
|
18923
19014
|
const { vtxo, scriptHex, contractRepository } = params;
|
|
18924
19015
|
const contract = contractRepository ? (await contractRepository.getContracts({ script: scriptHex }))[0] : void 0;
|
|
18925
19016
|
if (contract) {
|
|
18926
|
-
const handler =
|
|
19017
|
+
const handler = chunkCOLJARV4_cjs.contractHandlers.get(contract.type);
|
|
18927
19018
|
if (!handler) {
|
|
18928
19019
|
throw new ExitPathError(
|
|
18929
19020
|
"no-handler",
|
|
@@ -18946,12 +19037,12 @@ async function resolveUnilateralPath(params) {
|
|
|
18946
19037
|
paths.sort((a, b) => delayWeight(a.sequence) - delayWeight(b.sequence));
|
|
18947
19038
|
return { selection: paths[0], label: `${contract.type}:unilateral` };
|
|
18948
19039
|
}
|
|
18949
|
-
const decoded =
|
|
19040
|
+
const decoded = chunkD6RGHPZ5_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
18950
19041
|
let best;
|
|
18951
19042
|
for (const exit of decoded.exitPaths()) {
|
|
18952
19043
|
const leaf = decoded.findLeaf(base.hex.encode(exit.script));
|
|
18953
19044
|
if (!leaf) continue;
|
|
18954
|
-
const sequence =
|
|
19045
|
+
const sequence = chunkD6RGHPZ5_cjs.timelockToSequence(exit.params.timelock);
|
|
18955
19046
|
const weight = delayWeight(sequence);
|
|
18956
19047
|
if (!best || weight < best.weight) {
|
|
18957
19048
|
best = { selection: { leaf, sequence }, weight };
|
|
@@ -19137,14 +19228,14 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
19137
19228
|
}
|
|
19138
19229
|
const resolved = await resolveUnilateralPath({
|
|
19139
19230
|
vtxo,
|
|
19140
|
-
scriptHex: base.hex.encode(
|
|
19231
|
+
scriptHex: base.hex.encode(chunkD6RGHPZ5_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
19141
19232
|
contractRepository: wallet.contractRepository,
|
|
19142
19233
|
walletPubKeyHex: base.hex.encode(await wallet.identity.xOnlyPublicKey()),
|
|
19143
19234
|
currentTime: Date.now()
|
|
19144
19235
|
});
|
|
19145
19236
|
const spendingLeaf = resolved.selection.leaf;
|
|
19146
19237
|
const sequence = resolved.selection.sequence;
|
|
19147
|
-
const timelock =
|
|
19238
|
+
const timelock = chunkD6RGHPZ5_cjs.sequenceToTimelock(sequence);
|
|
19148
19239
|
const elapsed = timelock.type === "blocks" ? chainTip.height >= txStatus.blockHeight + Number(timelock.value) : chainTip.time >= txStatus.blockTime + Number(timelock.value);
|
|
19149
19240
|
if (!elapsed) {
|
|
19150
19241
|
throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
|
|
@@ -19157,7 +19248,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
19157
19248
|
sequence,
|
|
19158
19249
|
witnessUtxo: {
|
|
19159
19250
|
amount: BigInt(vtxo.value),
|
|
19160
|
-
script:
|
|
19251
|
+
script: chunkD6RGHPZ5_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
|
|
19161
19252
|
},
|
|
19162
19253
|
sighashType: btcSigner.SigHash.DEFAULT
|
|
19163
19254
|
});
|
|
@@ -19167,7 +19258,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
19167
19258
|
btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
|
|
19168
19259
|
);
|
|
19169
19260
|
}
|
|
19170
|
-
const tx = new
|
|
19261
|
+
const tx = new chunkD6RGHPZ5_cjs.Transaction({ version: 2 });
|
|
19171
19262
|
for (const input of inputs) {
|
|
19172
19263
|
tx.addInput(input);
|
|
19173
19264
|
}
|
|
@@ -19234,7 +19325,7 @@ async function buildSignedSweep(params) {
|
|
|
19234
19325
|
`uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
|
|
19235
19326
|
);
|
|
19236
19327
|
}
|
|
19237
|
-
const tx = new
|
|
19328
|
+
const tx = new chunkD6RGHPZ5_cjs.Transaction({ version: 2 });
|
|
19238
19329
|
tx.addInput({
|
|
19239
19330
|
txid: vtxo.txid,
|
|
19240
19331
|
index: vtxo.vout,
|
|
@@ -19259,7 +19350,7 @@ async function buildSignedSweep(params) {
|
|
|
19259
19350
|
finalScriptWitness: [
|
|
19260
19351
|
tapScriptSig[0][1],
|
|
19261
19352
|
...path.extraWitness,
|
|
19262
|
-
|
|
19353
|
+
chunkD6RGHPZ5_cjs.scriptFromTapLeafScript(path.leaf),
|
|
19263
19354
|
btcSigner.TaprootControlBlock.encode(controlBlock)
|
|
19264
19355
|
]
|
|
19265
19356
|
});
|
|
@@ -19289,7 +19380,7 @@ async function resolveFeeRate(opts) {
|
|
|
19289
19380
|
}
|
|
19290
19381
|
async function selectExitVtxos(opts) {
|
|
19291
19382
|
if (!opts.vtxos) return opts.wallet.getVtxos();
|
|
19292
|
-
const res = await
|
|
19383
|
+
const res = await chunkD6RGHPZ5_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
|
|
19293
19384
|
const tapTrees = /* @__PURE__ */ new Map();
|
|
19294
19385
|
const out = [];
|
|
19295
19386
|
for (const vtxo of res.vtxos) {
|
|
@@ -19304,7 +19395,7 @@ async function selectExitVtxos(opts) {
|
|
|
19304
19395
|
`no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
|
|
19305
19396
|
);
|
|
19306
19397
|
}
|
|
19307
|
-
const handler =
|
|
19398
|
+
const handler = chunkCOLJARV4_cjs.contractHandlers.get(contract.type);
|
|
19308
19399
|
if (!handler) {
|
|
19309
19400
|
throw new Error(`no contract handler registered for type '${contract.type}'`);
|
|
19310
19401
|
}
|
|
@@ -19334,7 +19425,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
19334
19425
|
if (pendingNodes.length > 0) {
|
|
19335
19426
|
const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
|
|
19336
19427
|
for (const psbt of txs) {
|
|
19337
|
-
psbts.set(
|
|
19428
|
+
psbts.set(chunkD6RGHPZ5_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
19338
19429
|
}
|
|
19339
19430
|
}
|
|
19340
19431
|
const childVsize = Number(
|
|
@@ -19370,7 +19461,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
19370
19461
|
try {
|
|
19371
19462
|
const resolved = await resolveUnilateralPath({
|
|
19372
19463
|
vtxo,
|
|
19373
|
-
scriptHex: base.hex.encode(
|
|
19464
|
+
scriptHex: base.hex.encode(chunkD6RGHPZ5_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
19374
19465
|
contractRepository: wallet.contractRepository,
|
|
19375
19466
|
walletPubKeyHex,
|
|
19376
19467
|
currentTime: Date.now()
|
|
@@ -19389,7 +19480,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
19389
19480
|
});
|
|
19390
19481
|
continue;
|
|
19391
19482
|
}
|
|
19392
|
-
const t =
|
|
19483
|
+
const t = chunkD6RGHPZ5_cjs.sequenceToTimelock(resolved.selection.sequence);
|
|
19393
19484
|
const delay = { type: t.type, value: Number(t.value) };
|
|
19394
19485
|
infos.push({ outpoint, value: vtxo.value, sweepFee, path: resolved.label, delay });
|
|
19395
19486
|
sweeps.push({ vtxo, resolved, sweepFee, delay });
|
|
@@ -19728,7 +19819,7 @@ async function prepare(opts) {
|
|
|
19728
19819
|
txid: sweep.vtxo.txid,
|
|
19729
19820
|
vout: sweep.vtxo.vout,
|
|
19730
19821
|
value: sweep.vtxo.value,
|
|
19731
|
-
pkScript:
|
|
19822
|
+
pkScript: chunkD6RGHPZ5_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
|
|
19732
19823
|
},
|
|
19733
19824
|
path: sweep.resolved.selection,
|
|
19734
19825
|
outputAddress: opts.sweepAddress,
|
|
@@ -19813,7 +19904,7 @@ async function prepare(opts) {
|
|
|
19813
19904
|
if (newFee <= splitterFee) break;
|
|
19814
19905
|
splitterFee = newFee;
|
|
19815
19906
|
}
|
|
19816
|
-
const splitter = new
|
|
19907
|
+
const splitter = new chunkD6RGHPZ5_cjs.Transaction({ version: 2 });
|
|
19817
19908
|
for (const coin of selected.inputs) {
|
|
19818
19909
|
splitter.addInput({
|
|
19819
19910
|
txid: coin.txid,
|
|
@@ -19956,41 +20047,41 @@ var UnilateralExit = {
|
|
|
19956
20047
|
// src/arkade/index.ts
|
|
19957
20048
|
var arkade_exports = {};
|
|
19958
20049
|
chunk5BLDMQED_cjs.__export(arkade_exports, {
|
|
19959
|
-
ARKADE_OP: () =>
|
|
19960
|
-
ARKADE_OPCODES: () =>
|
|
19961
|
-
ARKADE_OPCODE_NAMES: () =>
|
|
19962
|
-
ARKADE_OPCODE_VALUES: () =>
|
|
19963
|
-
ARKADE_OPS: () =>
|
|
20050
|
+
ARKADE_OP: () => chunkCOLJARV4_cjs.ARKADE_OP,
|
|
20051
|
+
ARKADE_OPCODES: () => chunkCOLJARV4_cjs.ARKADE_OPCODES,
|
|
20052
|
+
ARKADE_OPCODE_NAMES: () => chunkCOLJARV4_cjs.ARKADE_OPCODE_NAMES,
|
|
20053
|
+
ARKADE_OPCODE_VALUES: () => chunkCOLJARV4_cjs.ARKADE_OPCODE_VALUES,
|
|
20054
|
+
ARKADE_OPS: () => chunkCOLJARV4_cjs.ARKADE_OPS,
|
|
19964
20055
|
Arkade: () => Arkade,
|
|
19965
20056
|
ArkadeContract: () => ArkadeContract,
|
|
19966
|
-
ArkadeProgramScript: () =>
|
|
19967
|
-
ArkadeScript: () =>
|
|
20057
|
+
ArkadeProgramScript: () => chunkCOLJARV4_cjs.ArkadeProgramScript,
|
|
20058
|
+
ArkadeScript: () => chunkCOLJARV4_cjs.ArkadeScript,
|
|
19968
20059
|
ArkadeTransactionBuilder: () => ArkadeTransactionBuilder,
|
|
19969
|
-
BigNum: () =>
|
|
20060
|
+
BigNum: () => chunkCOLJARV4_cjs.bignum_exports,
|
|
19970
20061
|
OP: () => btcSigner.OP,
|
|
19971
|
-
OPCODE_NAMES: () =>
|
|
19972
|
-
OPCODE_VALUES: () =>
|
|
19973
|
-
SUPPORTED_PROGRAM_VERSION: () =>
|
|
20062
|
+
OPCODE_NAMES: () => chunkCOLJARV4_cjs.OPCODE_NAMES,
|
|
20063
|
+
OPCODE_VALUES: () => chunkCOLJARV4_cjs.OPCODE_VALUES,
|
|
20064
|
+
SUPPORTED_PROGRAM_VERSION: () => chunkCOLJARV4_cjs.SUPPORTED_PROGRAM_VERSION,
|
|
19974
20065
|
Script: () => btcSigner.Script,
|
|
19975
|
-
arkadeScriptHash: () =>
|
|
19976
|
-
arkadeWitnessHash: () =>
|
|
19977
|
-
asmToBytes: () =>
|
|
19978
|
-
bytesToASM: () =>
|
|
19979
|
-
computeArkadeScriptPublicKey: () =>
|
|
20066
|
+
arkadeScriptHash: () => chunkCOLJARV4_cjs.arkadeScriptHash,
|
|
20067
|
+
arkadeWitnessHash: () => chunkCOLJARV4_cjs.arkadeWitnessHash,
|
|
20068
|
+
asmToBytes: () => chunkCOLJARV4_cjs.asmToBytes,
|
|
20069
|
+
bytesToASM: () => chunkCOLJARV4_cjs.bytesToASM,
|
|
20070
|
+
computeArkadeScriptPublicKey: () => chunkCOLJARV4_cjs.computeArkadeScriptPublicKey,
|
|
19980
20071
|
createArkadeBatchHandler: () => createArkadeBatchHandler,
|
|
19981
|
-
deserializeArkadeContractParams: () =>
|
|
19982
|
-
fromASM: () =>
|
|
19983
|
-
getOpcodeName: () =>
|
|
19984
|
-
getOpcodeValue: () =>
|
|
19985
|
-
parseArtifact: () =>
|
|
19986
|
-
resolveAsm: () =>
|
|
19987
|
-
serializeArkadeContractParams: () =>
|
|
19988
|
-
stringifyArtifact: () =>
|
|
19989
|
-
toASM: () =>
|
|
19990
|
-
validateProgram: () =>
|
|
19991
|
-
witnessRefToBytes: () =>
|
|
20072
|
+
deserializeArkadeContractParams: () => chunkCOLJARV4_cjs.deserializeArkadeContractParams,
|
|
20073
|
+
fromASM: () => chunkCOLJARV4_cjs.fromASM,
|
|
20074
|
+
getOpcodeName: () => chunkCOLJARV4_cjs.getOpcodeName,
|
|
20075
|
+
getOpcodeValue: () => chunkCOLJARV4_cjs.getOpcodeValue,
|
|
20076
|
+
parseArtifact: () => chunkCOLJARV4_cjs.parseArtifact,
|
|
20077
|
+
resolveAsm: () => chunkCOLJARV4_cjs.resolveAsm,
|
|
20078
|
+
serializeArkadeContractParams: () => chunkCOLJARV4_cjs.serializeArkadeContractParams,
|
|
20079
|
+
stringifyArtifact: () => chunkCOLJARV4_cjs.stringifyArtifact,
|
|
20080
|
+
toASM: () => chunkCOLJARV4_cjs.toASM,
|
|
20081
|
+
validateProgram: () => chunkCOLJARV4_cjs.validateProgram,
|
|
20082
|
+
witnessRefToBytes: () => chunkCOLJARV4_cjs.witnessRefToBytes
|
|
19992
20083
|
});
|
|
19993
|
-
var isVtxoCoin = (input) =>
|
|
20084
|
+
var isVtxoCoin = (input) => chunkD6RGHPZ5_cjs.isVirtualCoin(input);
|
|
19994
20085
|
function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
|
|
19995
20086
|
let batchId;
|
|
19996
20087
|
let sweepTapTreeRoot;
|
|
@@ -20011,7 +20102,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
20011
20102
|
);
|
|
20012
20103
|
await arkProvider.confirmRegistration(intentId);
|
|
20013
20104
|
batchId = event.id;
|
|
20014
|
-
const sweepTapscript =
|
|
20105
|
+
const sweepTapscript = chunkD6RGHPZ5_cjs.CSVMultisigTapscript.encode({
|
|
20015
20106
|
timelock,
|
|
20016
20107
|
pubkeys: [base.hex.decode(info.forfeitPubkey).subarray(1)]
|
|
20017
20108
|
}).script;
|
|
@@ -20025,7 +20116,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
20025
20116
|
if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
|
|
20026
20117
|
return { skip: true };
|
|
20027
20118
|
}
|
|
20028
|
-
const commitmentTx =
|
|
20119
|
+
const commitmentTx = chunkD6RGHPZ5_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
|
|
20029
20120
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
20030
20121
|
if (recipients && recipients.length > 0) {
|
|
20031
20122
|
validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
|
|
@@ -20057,7 +20148,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
20057
20148
|
if (connectorTree) {
|
|
20058
20149
|
validateConnectorsTxGraph(event.commitmentTx, connectorTree);
|
|
20059
20150
|
}
|
|
20060
|
-
let commitmentPsbt =
|
|
20151
|
+
let commitmentPsbt = chunkD6RGHPZ5_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
20061
20152
|
assertFinalCommitmentMatchesValidated(
|
|
20062
20153
|
commitmentPsbt,
|
|
20063
20154
|
validatedCommitmentTxid,
|
|
@@ -20092,7 +20183,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
20092
20183
|
boardingIndices.push(boardingIdx);
|
|
20093
20184
|
continue;
|
|
20094
20185
|
}
|
|
20095
|
-
if (
|
|
20186
|
+
if (chunkD6RGHPZ5_cjs.isRecoverable(input) || isSubdust(input, info.dust)) {
|
|
20096
20187
|
continue;
|
|
20097
20188
|
}
|
|
20098
20189
|
if (connectorIndex >= connectorLeaves.length) {
|
|
@@ -20113,7 +20204,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
20113
20204
|
index: input.vout,
|
|
20114
20205
|
witnessUtxo: {
|
|
20115
20206
|
amount: BigInt(input.value),
|
|
20116
|
-
script:
|
|
20207
|
+
script: chunkD6RGHPZ5_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
20117
20208
|
},
|
|
20118
20209
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
20119
20210
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -20196,7 +20287,7 @@ var Arkade = class _Arkade {
|
|
|
20196
20287
|
static async connect(opts) {
|
|
20197
20288
|
const info = await opts.arkade.getInfo();
|
|
20198
20289
|
const serverKey = base.hex.decode(info.signerPubkey).slice(1);
|
|
20199
|
-
const checkpoint =
|
|
20290
|
+
const checkpoint = chunkD6RGHPZ5_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
20200
20291
|
let emulatorKey;
|
|
20201
20292
|
if (opts.emulator) {
|
|
20202
20293
|
const eInfo = await opts.emulator.getInfo();
|
|
@@ -20210,7 +20301,7 @@ var Arkade = class _Arkade {
|
|
|
20210
20301
|
return new _Arkade({
|
|
20211
20302
|
arkProvider: opts.arkade,
|
|
20212
20303
|
emulator: opts.emulator,
|
|
20213
|
-
network: opts.network ??
|
|
20304
|
+
network: opts.network ?? chunkD6RGHPZ5_cjs.DEFAULT_NETWORK,
|
|
20214
20305
|
serverKey,
|
|
20215
20306
|
emulatorKey,
|
|
20216
20307
|
checkpoint,
|
|
@@ -20231,7 +20322,7 @@ var Arkade = class _Arkade {
|
|
|
20231
20322
|
* key respectively; explicit args always win.
|
|
20232
20323
|
*/
|
|
20233
20324
|
contract(program, args = {}) {
|
|
20234
|
-
const declared = (program.params ?? []).map(
|
|
20325
|
+
const declared = (program.params ?? []).map(chunkCOLJARV4_cjs.inputName);
|
|
20235
20326
|
if (declared.includes("server") && args.server === void 0) {
|
|
20236
20327
|
args = { ...args, server: this.serverKey };
|
|
20237
20328
|
}
|
|
@@ -20251,7 +20342,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
20251
20342
|
userKey: client.userKey,
|
|
20252
20343
|
emulatorKey: client.emulatorKey
|
|
20253
20344
|
};
|
|
20254
|
-
this.vtxoScript = new
|
|
20345
|
+
this.vtxoScript = new chunkCOLJARV4_cjs.ArkadeProgramScript(program, args, this.keys);
|
|
20255
20346
|
this.tapTree = this.vtxoScript.encode();
|
|
20256
20347
|
this.compiled = this.vtxoScript.compiled;
|
|
20257
20348
|
}
|
|
@@ -20279,7 +20370,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
20279
20370
|
`ArkadeContract.fromContract: expected contract type 'arkade', got '${contract.type}'`
|
|
20280
20371
|
);
|
|
20281
20372
|
}
|
|
20282
|
-
const typed =
|
|
20373
|
+
const typed = chunkCOLJARV4_cjs.deserializeArkadeContractParams(contract.params);
|
|
20283
20374
|
return new _ArkadeContract(client, typed.program, typed.args, {
|
|
20284
20375
|
serverKey: typed.serverKey,
|
|
20285
20376
|
userKey: typed.userKey,
|
|
@@ -20320,7 +20411,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
20320
20411
|
toContractParams() {
|
|
20321
20412
|
return {
|
|
20322
20413
|
type: "arkade",
|
|
20323
|
-
params:
|
|
20414
|
+
params: chunkCOLJARV4_cjs.serializeArkadeContractParams({
|
|
20324
20415
|
program: this.program,
|
|
20325
20416
|
args: this.args,
|
|
20326
20417
|
serverKey: this.keys.serverKey,
|
|
@@ -20365,13 +20456,13 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
20365
20456
|
const [registered] = await manager.getContracts({ script: scriptHex });
|
|
20366
20457
|
if (registered) {
|
|
20367
20458
|
const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
|
|
20368
|
-
return (withVtxos?.vtxos ?? []).filter((v) => !
|
|
20459
|
+
return (withVtxos?.vtxos ?? []).filter((v) => !chunkD6RGHPZ5_cjs.hasTerminalSpend(v));
|
|
20369
20460
|
}
|
|
20370
20461
|
}
|
|
20371
20462
|
if (!this.client.indexer) {
|
|
20372
20463
|
throw new Error("ArkadeContract.getUtxos: an indexer is required");
|
|
20373
20464
|
}
|
|
20374
|
-
const { vtxos } = await
|
|
20465
|
+
const { vtxos } = await chunkD6RGHPZ5_cjs.getNormalizedVtxos(this.client.indexer, {
|
|
20375
20466
|
scripts: [scriptHex],
|
|
20376
20467
|
spendableOnly: true
|
|
20377
20468
|
});
|
|
@@ -20473,12 +20564,12 @@ var ArkadeTransactionBuilder = class {
|
|
|
20473
20564
|
this.contract.client.checkpoint
|
|
20474
20565
|
);
|
|
20475
20566
|
if (coin.sourceTx) {
|
|
20476
|
-
|
|
20567
|
+
chunkD6RGHPZ5_cjs.setArkPsbtField(arkTx, 0, chunkD6RGHPZ5_cjs.PrevArkTxField, coin.sourceTx);
|
|
20477
20568
|
}
|
|
20478
20569
|
const condition = (def.tapscript.witness ?? []).map((w) => this.witnessBytes(w));
|
|
20479
20570
|
if (condition.length > 0) {
|
|
20480
|
-
|
|
20481
|
-
|
|
20571
|
+
chunkD6RGHPZ5_cjs.setArkPsbtField(arkTx, 0, chunkD6RGHPZ5_cjs.ConditionWitness, condition);
|
|
20572
|
+
chunkD6RGHPZ5_cjs.setArkPsbtField(checkpoints[0], 0, chunkD6RGHPZ5_cjs.ConditionWitness, condition);
|
|
20482
20573
|
}
|
|
20483
20574
|
const packets = [];
|
|
20484
20575
|
if (this.assetSpecs.length > 0) {
|
|
@@ -20517,7 +20608,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
20517
20608
|
base.base64.encode(signedArk2.toPSBT()),
|
|
20518
20609
|
signedCps.map((c) => base.base64.encode(c.toPSBT()))
|
|
20519
20610
|
);
|
|
20520
|
-
const txid =
|
|
20611
|
+
const txid = chunkD6RGHPZ5_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
|
|
20521
20612
|
return {
|
|
20522
20613
|
txid,
|
|
20523
20614
|
signedArkTx: res2.signedArkTx,
|
|
@@ -20576,23 +20667,23 @@ var ArkadeTransactionBuilder = class {
|
|
|
20576
20667
|
}
|
|
20577
20668
|
buildAssetPacket() {
|
|
20578
20669
|
const groups = this.assetSpecs.map((s) => {
|
|
20579
|
-
const id = typeof s.assetId === "string" ?
|
|
20580
|
-
return
|
|
20670
|
+
const id = typeof s.assetId === "string" ? chunkF4C67JYB_cjs.AssetId.fromString(s.assetId) : chunkF4C67JYB_cjs.AssetId.fromBytes(s.assetId);
|
|
20671
|
+
return chunkF4C67JYB_cjs.AssetGroup.create(
|
|
20581
20672
|
id,
|
|
20582
20673
|
null,
|
|
20583
|
-
s.inputs.map((i) =>
|
|
20584
|
-
s.outputs.map((o) =>
|
|
20585
|
-
(s.metadata ?? []).map((m) =>
|
|
20674
|
+
s.inputs.map((i) => chunkF4C67JYB_cjs.AssetInput.create(i.vin, i.amount)),
|
|
20675
|
+
s.outputs.map((o) => chunkF4C67JYB_cjs.AssetOutput.create(o.vout, o.amount)),
|
|
20676
|
+
(s.metadata ?? []).map((m) => chunkF4C67JYB_cjs.Metadata.create(m.key, m.value))
|
|
20586
20677
|
);
|
|
20587
20678
|
});
|
|
20588
|
-
return
|
|
20679
|
+
return chunkF4C67JYB_cjs.Packet.create(groups);
|
|
20589
20680
|
}
|
|
20590
20681
|
witnessBytes(ref) {
|
|
20591
|
-
return
|
|
20682
|
+
return chunkCOLJARV4_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
|
|
20592
20683
|
}
|
|
20593
20684
|
};
|
|
20594
20685
|
function bindInputs(fn, callArgs) {
|
|
20595
|
-
const names = (fn.def.inputs ?? []).map(
|
|
20686
|
+
const names = (fn.def.inputs ?? []).map(chunkCOLJARV4_cjs.inputName);
|
|
20596
20687
|
if (callArgs.length !== names.length) {
|
|
20597
20688
|
throw new Error(`${fn.name}: expected ${names.length} argument(s), got ${callArgs.length}`);
|
|
20598
20689
|
}
|
|
@@ -20999,7 +21090,7 @@ function decodeArkContract(encoded) {
|
|
|
20999
21090
|
}
|
|
21000
21091
|
function contractFromArkContract(encoded, options = {}) {
|
|
21001
21092
|
const parsed = decodeArkContract(encoded);
|
|
21002
|
-
const handler =
|
|
21093
|
+
const handler = chunkCOLJARV4_cjs.contractHandlers.get(parsed.type);
|
|
21003
21094
|
if (!handler) {
|
|
21004
21095
|
throw new Error(`No handler registered for contract type '${parsed.type}'`);
|
|
21005
21096
|
}
|
|
@@ -21013,9 +21104,9 @@ function contractFromArkContract(encoded, options = {}) {
|
|
|
21013
21104
|
metadata: options.metadata
|
|
21014
21105
|
};
|
|
21015
21106
|
}
|
|
21016
|
-
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix =
|
|
21107
|
+
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkD6RGHPZ5_cjs.DEFAULT_NETWORK.hrp, options = {}) {
|
|
21017
21108
|
const parsed = decodeArkContract(encoded);
|
|
21018
|
-
const handler =
|
|
21109
|
+
const handler = chunkCOLJARV4_cjs.contractHandlers.getOrThrow(parsed.type);
|
|
21019
21110
|
const params = parsed.data;
|
|
21020
21111
|
const vtxoScript = handler.createScript(params);
|
|
21021
21112
|
return {
|
|
@@ -21200,5 +21291,5 @@ exports.validateVtxoTxGraph = validateVtxoTxGraph;
|
|
|
21200
21291
|
exports.verifyTapscriptSignatures = verifyTapscriptSignatures;
|
|
21201
21292
|
exports.waitForIncomingFunds = waitForIncomingFunds;
|
|
21202
21293
|
exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
|
|
21203
|
-
//# sourceMappingURL=chunk-
|
|
21204
|
-
//# sourceMappingURL=chunk-
|
|
21294
|
+
//# sourceMappingURL=chunk-6PY4WYXI.cjs.map
|
|
21295
|
+
//# sourceMappingURL=chunk-6PY4WYXI.cjs.map
|