@arkade-os/sdk 0.4.56 → 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-Cgsd9tMd.d.cts → ark-ClaVUg4e.d.cts} +31 -1
- package/dist/{ark-Cgsd9tMd.d.ts → ark-ClaVUg4e.d.ts} +31 -1
- package/dist/{asyncStorageTaskQueue-CXz4PRBW.d.ts → asyncStorageTaskQueue-Bgau-mvD.d.ts} +2 -2
- package/dist/{asyncStorageTaskQueue-C0ZsDE60.d.cts → asyncStorageTaskQueue-CnYrhpS-.d.cts} +2 -2
- package/dist/{chunk-ENRRZFZ4.cjs → chunk-6PY4WYXI.cjs} +618 -425
- package/dist/chunk-6PY4WYXI.cjs.map +1 -0
- package/dist/{chunk-VNDVUM2W.js → chunk-AGWZXGG2.js} +4 -4
- package/dist/{chunk-VNDVUM2W.js.map → chunk-AGWZXGG2.js.map} +1 -1
- package/dist/{chunk-37XKN5DZ.cjs → chunk-COLJARV4.cjs} +40 -40
- package/dist/{chunk-37XKN5DZ.cjs.map → chunk-COLJARV4.cjs.map} +1 -1
- package/dist/{chunk-CDWLZQQW.cjs → chunk-D6RGHPZ5.cjs} +4 -3
- package/dist/chunk-D6RGHPZ5.cjs.map +1 -0
- package/dist/{chunk-24YNIQSW.cjs → chunk-F4C67JYB.cjs} +15 -15
- package/dist/{chunk-24YNIQSW.cjs.map → chunk-F4C67JYB.cjs.map} +1 -1
- package/dist/{chunk-MXPBHDOI.cjs → chunk-I4YEGI2R.cjs} +17 -17
- package/dist/{chunk-MXPBHDOI.cjs.map → chunk-I4YEGI2R.cjs.map} +1 -1
- package/dist/{chunk-OOPDT2WV.js → chunk-IPPASJE5.js} +3 -3
- package/dist/{chunk-OOPDT2WV.js.map → chunk-IPPASJE5.js.map} +1 -1
- package/dist/{chunk-T22257HW.js → chunk-S3BFUTC5.js} +243 -60
- package/dist/chunk-S3BFUTC5.js.map +1 -0
- package/dist/{chunk-5IMBONCK.js → chunk-SGWMB4W2.js} +4 -4
- package/dist/{chunk-5IMBONCK.js.map → chunk-SGWMB4W2.js.map} +1 -1
- package/dist/{chunk-IMVKQQHU.cjs → chunk-SYZEQF5D.cjs} +9 -9
- package/dist/{chunk-IMVKQQHU.cjs.map → chunk-SYZEQF5D.cjs.map} +1 -1
- package/dist/{chunk-NN7BNNF5.js → chunk-TV2RLVOB.js} +3 -3
- package/dist/{chunk-NN7BNNF5.js.map → chunk-TV2RLVOB.js.map} +1 -1
- package/dist/{chunk-IFGN2GB2.js → chunk-VROHHJL4.js} +4 -3
- package/dist/chunk-VROHHJL4.js.map +1 -0
- 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-xXT8O-Kn.d.cts → delegate-CVrkEepn.d.cts} +1 -1
- package/dist/{delegate-CZPXtd2F.d.ts → delegate-YDYq1El_.d.ts} +1 -1
- package/dist/{index-BYG2eKOA.d.cts → index-BmqkJBAf.d.cts} +2 -2
- package/dist/{index-BBJ466mM.d.ts → index-CuSHBkq7.d.ts} +2 -2
- package/dist/index.cjs +253 -213
- package/dist/index.d.cts +29 -10
- package/dist/index.d.ts +29 -10
- 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-C46NnRsY.d.ts → taskRunner-CFN61bBM.d.ts} +2 -2
- package/dist/{taskRunner-BG1PRFps.d.cts → taskRunner-CFkGkD85.d.cts} +2 -2
- 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-DuCm55EC.d.ts → wallet-DnK09TtT.d.ts} +107 -4
- package/dist/{wallet-1yWg75gN.d.cts → wallet-hQp2qC_M.d.cts} +107 -4
- 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-CDWLZQQW.cjs.map +0 -1
- package/dist/chunk-ENRRZFZ4.cjs.map +0 -1
- package/dist/chunk-IFGN2GB2.js.map +0 -1
- package/dist/chunk-T22257HW.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));
|
|
@@ -2326,6 +2326,83 @@ function classifyContractSigner(contractServerPubKeyHex, info, nowSeconds = Math
|
|
|
2326
2326
|
function isCooperativelyMigratable(status) {
|
|
2327
2327
|
return status === "MIGRATABLE" || status === "DUE_NOW";
|
|
2328
2328
|
}
|
|
2329
|
+
|
|
2330
|
+
// src/wallet/timelockPolicy.ts
|
|
2331
|
+
var isRegtest = (network) => network.bech32 === "bcrt";
|
|
2332
|
+
var NOMINAL_BLOCK_SECONDS = 600n;
|
|
2333
|
+
var toTimelock = (value) => ({
|
|
2334
|
+
value,
|
|
2335
|
+
type: value >= 512n ? "seconds" : "blocks"
|
|
2336
|
+
});
|
|
2337
|
+
var toSeconds = (t) => t.type === "seconds" ? t.value : t.value * NOMINAL_BLOCK_SECONDS;
|
|
2338
|
+
function assertTimelockInPolicy(timelock, policy, label) {
|
|
2339
|
+
if (policy.requireSeconds && timelock.type === "blocks") {
|
|
2340
|
+
throw new chunkD6RGHPZ5_cjs.ServerResponseMismatchError(
|
|
2341
|
+
`${label} rejected: block-typed timelocks are not accepted (got ${timelock.value})`
|
|
2342
|
+
);
|
|
2343
|
+
}
|
|
2344
|
+
const seconds = toSeconds(timelock);
|
|
2345
|
+
if (seconds < policy.minSeconds) {
|
|
2346
|
+
throw new chunkD6RGHPZ5_cjs.ServerResponseMismatchError(
|
|
2347
|
+
`${label} rejected: ${timelock.value} ${timelock.type} is below the ${policy.minSeconds}s floor`
|
|
2348
|
+
);
|
|
2349
|
+
}
|
|
2350
|
+
return timelock;
|
|
2351
|
+
}
|
|
2352
|
+
function assertTimelockWithinFloor(value, policy, label) {
|
|
2353
|
+
return assertTimelockInPolicy(toTimelock(value), policy, label);
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
// src/wallet/batchExpiry.ts
|
|
2357
|
+
var DEFAULT_MIN_BATCH_EXPIRY_SECONDS = 86400n;
|
|
2358
|
+
var REGTEST_MIN_BATCH_EXPIRY_SECONDS = 6000n;
|
|
2359
|
+
function defaultBatchExpiryPolicy(network) {
|
|
2360
|
+
return isRegtest(network) ? { minSeconds: REGTEST_MIN_BATCH_EXPIRY_SECONDS, requireSeconds: false } : { minSeconds: DEFAULT_MIN_BATCH_EXPIRY_SECONDS, requireSeconds: true };
|
|
2361
|
+
}
|
|
2362
|
+
function resolveBatchExpiryPolicy(network, overrides) {
|
|
2363
|
+
return { ...defaultBatchExpiryPolicy(network), ...overrides };
|
|
2364
|
+
}
|
|
2365
|
+
function assertValidBatchExpiry(batchExpiry, policy) {
|
|
2366
|
+
if (policy.advertisedVtxoTreeExpiry !== void 0 && batchExpiry !== policy.advertisedVtxoTreeExpiry) {
|
|
2367
|
+
throw new chunkD6RGHPZ5_cjs.ServerResponseMismatchError(
|
|
2368
|
+
`batch expiry rejected: ${batchExpiry} does not match the advertised vtxoTreeExpiry ${policy.advertisedVtxoTreeExpiry}`
|
|
2369
|
+
);
|
|
2370
|
+
}
|
|
2371
|
+
return assertTimelockWithinFloor(batchExpiry, policy, "batch expiry");
|
|
2372
|
+
}
|
|
2373
|
+
var DEFAULT_MIN_CHECKPOINT_EXIT_DELAY_SECONDS = 86400n;
|
|
2374
|
+
var REGTEST_MIN_CHECKPOINT_EXIT_DELAY_SECONDS = 1200n;
|
|
2375
|
+
function defaultCheckpointExitDelayPolicy(network) {
|
|
2376
|
+
return isRegtest(network) ? { minSeconds: REGTEST_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, requireSeconds: false } : { minSeconds: DEFAULT_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, requireSeconds: true };
|
|
2377
|
+
}
|
|
2378
|
+
function resolveCheckpointExitDelayPolicy(network, overrides) {
|
|
2379
|
+
return { ...defaultCheckpointExitDelayPolicy(network), ...overrides };
|
|
2380
|
+
}
|
|
2381
|
+
function assertValidServerUnrollScript(checkpointTapscript, policy) {
|
|
2382
|
+
let script;
|
|
2383
|
+
try {
|
|
2384
|
+
script = chunkD6RGHPZ5_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
|
|
2385
|
+
} catch (e) {
|
|
2386
|
+
throw new chunkD6RGHPZ5_cjs.ServerResponseMismatchError(
|
|
2387
|
+
`checkpoint exit delay rejected: invalid checkpointTapscript from server (${e instanceof Error ? e.message : String(e)})`
|
|
2388
|
+
);
|
|
2389
|
+
}
|
|
2390
|
+
if (policy.advertisedForfeitPubkey !== void 0) {
|
|
2391
|
+
const { pubkeys } = script.params;
|
|
2392
|
+
if (pubkeys.length !== 1) {
|
|
2393
|
+
throw new chunkD6RGHPZ5_cjs.ServerResponseMismatchError(
|
|
2394
|
+
`checkpoint exit delay rejected: checkpointTapscript must commit to exactly one pubkey, got ${pubkeys.length} [${pubkeys.map(base.hex.encode).join(", ")}]`
|
|
2395
|
+
);
|
|
2396
|
+
}
|
|
2397
|
+
if (!utils_js.equalBytes(pubkeys[0], policy.advertisedForfeitPubkey)) {
|
|
2398
|
+
throw new chunkD6RGHPZ5_cjs.ServerResponseMismatchError(
|
|
2399
|
+
`checkpoint exit delay rejected: checkpointTapscript pubkey ${base.hex.encode(pubkeys[0])} does not match the advertised forfeitPubkey ${base.hex.encode(policy.advertisedForfeitPubkey)}`
|
|
2400
|
+
);
|
|
2401
|
+
}
|
|
2402
|
+
}
|
|
2403
|
+
assertTimelockInPolicy(script.params.timelock, policy, "checkpoint exit delay");
|
|
2404
|
+
return script;
|
|
2405
|
+
}
|
|
2329
2406
|
function buildOffchainTx(inputs, outputs, serverUnrollScript) {
|
|
2330
2407
|
const MAX_OP_RETURN = 2;
|
|
2331
2408
|
let countOpReturn = 0;
|
|
@@ -2357,8 +2434,8 @@ function buildOffchainTx(inputs, outputs, serverUnrollScript) {
|
|
|
2357
2434
|
function buildVirtualTx(inputs, outputs) {
|
|
2358
2435
|
let lockTime = 0n;
|
|
2359
2436
|
for (const input of inputs) {
|
|
2360
|
-
const tapscript =
|
|
2361
|
-
if (
|
|
2437
|
+
const tapscript = chunkD6RGHPZ5_cjs.decodeTapscript(chunkD6RGHPZ5_cjs.scriptFromTapLeafScript(input.tapLeafScript));
|
|
2438
|
+
if (chunkD6RGHPZ5_cjs.CLTVMultisigTapscript.is(tapscript)) {
|
|
2362
2439
|
if (lockTime !== 0n) {
|
|
2363
2440
|
if (isSeconds(lockTime) !== isSeconds(tapscript.params.absoluteTimelock)) {
|
|
2364
2441
|
throw new Error("cannot mix seconds and blocks locktime");
|
|
@@ -2369,7 +2446,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
2369
2446
|
}
|
|
2370
2447
|
}
|
|
2371
2448
|
}
|
|
2372
|
-
const tx = new
|
|
2449
|
+
const tx = new chunkD6RGHPZ5_cjs.Transaction({
|
|
2373
2450
|
version: 3,
|
|
2374
2451
|
lockTime: Number(lockTime)
|
|
2375
2452
|
});
|
|
@@ -2379,12 +2456,12 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
2379
2456
|
index: input.vout,
|
|
2380
2457
|
sequence: lockTime ? btcSigner.DEFAULT_SEQUENCE - 1 : void 0,
|
|
2381
2458
|
witnessUtxo: {
|
|
2382
|
-
script:
|
|
2459
|
+
script: chunkD6RGHPZ5_cjs.VtxoScript.decode(input.tapTree).pkScript,
|
|
2383
2460
|
amount: BigInt(input.value)
|
|
2384
2461
|
},
|
|
2385
2462
|
tapLeafScript: [input.tapLeafScript]
|
|
2386
2463
|
});
|
|
2387
|
-
|
|
2464
|
+
chunkD6RGHPZ5_cjs.setArkPsbtField(tx, i, chunkD6RGHPZ5_cjs.VtxoTaprootTree, input.tapTree);
|
|
2388
2465
|
}
|
|
2389
2466
|
for (const output of outputs) {
|
|
2390
2467
|
tx.addOutput(output);
|
|
@@ -2393,8 +2470,8 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
2393
2470
|
return tx;
|
|
2394
2471
|
}
|
|
2395
2472
|
function buildCheckpointTx(vtxo, serverUnrollScript) {
|
|
2396
|
-
const collaborativeClosure =
|
|
2397
|
-
const checkpointVtxoScript = new
|
|
2473
|
+
const collaborativeClosure = chunkD6RGHPZ5_cjs.decodeTapscript(chunkD6RGHPZ5_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
|
|
2474
|
+
const checkpointVtxoScript = new chunkD6RGHPZ5_cjs.VtxoScript([
|
|
2398
2475
|
serverUnrollScript.script,
|
|
2399
2476
|
collaborativeClosure.script
|
|
2400
2477
|
]);
|
|
@@ -2547,7 +2624,7 @@ function combineTapscriptSigs(signedTx, originalTx) {
|
|
|
2547
2624
|
}
|
|
2548
2625
|
function isValidArkAddress(address) {
|
|
2549
2626
|
try {
|
|
2550
|
-
|
|
2627
|
+
chunkD6RGHPZ5_cjs.ArkAddress.decode(address);
|
|
2551
2628
|
return true;
|
|
2552
2629
|
} catch (e) {
|
|
2553
2630
|
return false;
|
|
@@ -2555,16 +2632,16 @@ function isValidArkAddress(address) {
|
|
|
2555
2632
|
}
|
|
2556
2633
|
function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, context) {
|
|
2557
2634
|
if (serverCheckpointTxs.length !== expectedCheckpoints.length) {
|
|
2558
|
-
throw new
|
|
2635
|
+
throw new chunkD6RGHPZ5_cjs.ServerResponseMismatchError(
|
|
2559
2636
|
`${context} returned ${serverCheckpointTxs.length} checkpoints, expected ${expectedCheckpoints.length}`
|
|
2560
2637
|
);
|
|
2561
2638
|
}
|
|
2562
2639
|
const byTxid = new Map(expectedCheckpoints.map((c) => [c.id, c]));
|
|
2563
2640
|
return serverCheckpointTxs.map((encoded, index) => {
|
|
2564
|
-
const server =
|
|
2641
|
+
const server = chunkD6RGHPZ5_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
|
|
2565
2642
|
const local = byTxid.get(server.id);
|
|
2566
2643
|
if (!local) {
|
|
2567
|
-
throw new
|
|
2644
|
+
throw new chunkD6RGHPZ5_cjs.ServerResponseMismatchError(
|
|
2568
2645
|
`${context} checkpoint ${index} txid ${server.id} does not match any submitted checkpoint`
|
|
2569
2646
|
);
|
|
2570
2647
|
}
|
|
@@ -2574,14 +2651,14 @@ function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, contex
|
|
|
2574
2651
|
}
|
|
2575
2652
|
function assertSubmittedArkTxid(response, signedArkTx, context) {
|
|
2576
2653
|
if (response.arkTxid !== signedArkTx.id) {
|
|
2577
|
-
throw new
|
|
2654
|
+
throw new chunkD6RGHPZ5_cjs.ServerResponseMismatchError(
|
|
2578
2655
|
`${context} returned ark txid ${response.arkTxid}, expected ${signedArkTx.id}`
|
|
2579
2656
|
);
|
|
2580
2657
|
}
|
|
2581
2658
|
if (response.finalArkTx === void 0) return;
|
|
2582
|
-
const finalTxid =
|
|
2659
|
+
const finalTxid = chunkD6RGHPZ5_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
|
|
2583
2660
|
if (finalTxid !== signedArkTx.id) {
|
|
2584
|
-
throw new
|
|
2661
|
+
throw new chunkD6RGHPZ5_cjs.ServerResponseMismatchError(
|
|
2585
2662
|
`${context} returned final ark tx ${finalTxid}, expected ${signedArkTx.id}`
|
|
2586
2663
|
);
|
|
2587
2664
|
}
|
|
@@ -2590,20 +2667,20 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
2590
2667
|
const byOutpoint = new Map(inputs.map((input) => [`${input.txid}:${input.vout}`, input]));
|
|
2591
2668
|
for (const [index, checkpoint] of checkpoints.entries()) {
|
|
2592
2669
|
if (checkpoint.inputsLength !== 1) {
|
|
2593
|
-
throw new
|
|
2670
|
+
throw new chunkD6RGHPZ5_cjs.ServerResponseMismatchError(
|
|
2594
2671
|
`${context}: checkpoint ${index} spends ${checkpoint.inputsLength} inputs, expected 1`
|
|
2595
2672
|
);
|
|
2596
2673
|
}
|
|
2597
2674
|
const spent = checkpoint.getInput(0);
|
|
2598
2675
|
if (!spent.txid || spent.index === void 0) {
|
|
2599
|
-
throw new
|
|
2676
|
+
throw new chunkD6RGHPZ5_cjs.ServerResponseMismatchError(
|
|
2600
2677
|
`${context}: checkpoint ${index} has no input outpoint`
|
|
2601
2678
|
);
|
|
2602
2679
|
}
|
|
2603
2680
|
const outpoint = `${base.hex.encode(spent.txid)}:${spent.index}`;
|
|
2604
2681
|
const input = byOutpoint.get(outpoint);
|
|
2605
2682
|
if (!input) {
|
|
2606
|
-
throw new
|
|
2683
|
+
throw new chunkD6RGHPZ5_cjs.ServerResponseMismatchError(
|
|
2607
2684
|
`${context}: checkpoint ${index} spends ${outpoint}, which is not one of the requested virtual outputs`
|
|
2608
2685
|
);
|
|
2609
2686
|
}
|
|
@@ -2611,7 +2688,7 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
2611
2688
|
(unroll) => buildCheckpointTx(input, unroll).tx.id === checkpoint.id
|
|
2612
2689
|
);
|
|
2613
2690
|
if (!rebuilt) {
|
|
2614
|
-
throw new
|
|
2691
|
+
throw new chunkD6RGHPZ5_cjs.ServerResponseMismatchError(
|
|
2615
2692
|
`${context}: checkpoint ${index} txid ${checkpoint.id} differs from the checkpoint built locally for ${outpoint}`
|
|
2616
2693
|
);
|
|
2617
2694
|
}
|
|
@@ -2845,7 +2922,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
|
|
|
2845
2922
|
};
|
|
2846
2923
|
}
|
|
2847
2924
|
function deriveContractTapscripts(contract) {
|
|
2848
|
-
const handler =
|
|
2925
|
+
const handler = chunkCOLJARV4_cjs.contractHandlers.get(contract.type);
|
|
2849
2926
|
if (!handler) {
|
|
2850
2927
|
throw new Error(`No handler for contract type '${contract.type}'`);
|
|
2851
2928
|
}
|
|
@@ -2916,7 +2993,7 @@ function getRandomId() {
|
|
|
2916
2993
|
}
|
|
2917
2994
|
function isValidArkAddress2(address) {
|
|
2918
2995
|
try {
|
|
2919
|
-
|
|
2996
|
+
chunkD6RGHPZ5_cjs.ArkAddress.decode(address);
|
|
2920
2997
|
return true;
|
|
2921
2998
|
} catch (e) {
|
|
2922
2999
|
return false;
|
|
@@ -2946,7 +3023,7 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
2946
3023
|
for (const recipient of recipients) {
|
|
2947
3024
|
let address;
|
|
2948
3025
|
try {
|
|
2949
|
-
address =
|
|
3026
|
+
address = chunkD6RGHPZ5_cjs.ArkAddress.decode(recipient.address);
|
|
2950
3027
|
} catch (e) {
|
|
2951
3028
|
throw new Error(`Invalid Arkade address: ${recipient.address}`);
|
|
2952
3029
|
}
|
|
@@ -2975,7 +3052,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
|
|
|
2975
3052
|
continue;
|
|
2976
3053
|
}
|
|
2977
3054
|
for (const v of vtxos) {
|
|
2978
|
-
if (!
|
|
3055
|
+
if (!chunkD6RGHPZ5_cjs.hasTerminalSpend(v) && !v.isSwept) out.add(`${v.txid}:${v.vout}`);
|
|
2979
3056
|
}
|
|
2980
3057
|
}
|
|
2981
3058
|
return out;
|
|
@@ -3008,10 +3085,10 @@ function byValueDescending(vtxos) {
|
|
|
3008
3085
|
return [...vtxos].sort((a, b) => b.value - a.value);
|
|
3009
3086
|
}
|
|
3010
3087
|
async function fetchTimeHeight(wallet) {
|
|
3011
|
-
return
|
|
3088
|
+
return chunkD6RGHPZ5_cjs.resolveTimeHeight(wallet.onchainProvider);
|
|
3012
3089
|
}
|
|
3013
3090
|
function canMigrateBySend(vtxo, now) {
|
|
3014
|
-
if (!
|
|
3091
|
+
if (!chunkD6RGHPZ5_cjs.canSpendOffchain(vtxo, now)) return false;
|
|
3015
3092
|
return vtxo.expiresAt !== void 0 || vtxo.expiresAtHeight !== void 0;
|
|
3016
3093
|
}
|
|
3017
3094
|
function byExpiryAscending(vtxos, now) {
|
|
@@ -3019,7 +3096,7 @@ function byExpiryAscending(vtxos, now) {
|
|
|
3019
3096
|
if (vtxo.isSwept) return -Infinity;
|
|
3020
3097
|
if (vtxo.expiresAt !== void 0) return vtxo.expiresAt.getTime();
|
|
3021
3098
|
if (vtxo.expiresAtHeight !== void 0) {
|
|
3022
|
-
return
|
|
3099
|
+
return chunkD6RGHPZ5_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
|
|
3023
3100
|
}
|
|
3024
3101
|
return Infinity;
|
|
3025
3102
|
};
|
|
@@ -3042,6 +3119,40 @@ function capSettlementBatch(sorted, maxAmount) {
|
|
|
3042
3119
|
}
|
|
3043
3120
|
return batch;
|
|
3044
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
|
+
}
|
|
3045
3156
|
var DEFAULT_THRESHOLD_SECONDS = 259200;
|
|
3046
3157
|
var DEFAULT_THRESHOLD_MS = DEFAULT_THRESHOLD_SECONDS * 1e3;
|
|
3047
3158
|
var DEFAULT_RENEWAL_CONFIG = {
|
|
@@ -3056,10 +3167,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
|
|
|
3056
3167
|
};
|
|
3057
3168
|
function getRecoverableVtxos(vtxos, dustAmount, now) {
|
|
3058
3169
|
return vtxos.filter((vtxo) => {
|
|
3059
|
-
if (
|
|
3170
|
+
if (chunkD6RGHPZ5_cjs.canRecoverOnchain(vtxo, now)) {
|
|
3060
3171
|
return true;
|
|
3061
3172
|
}
|
|
3062
|
-
if (
|
|
3173
|
+
if (chunkD6RGHPZ5_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
|
|
3063
3174
|
return true;
|
|
3064
3175
|
}
|
|
3065
3176
|
return false;
|
|
@@ -3090,7 +3201,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
|
|
|
3090
3201
|
}
|
|
3091
3202
|
function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
3092
3203
|
const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
|
|
3093
|
-
const expiresAt =
|
|
3204
|
+
const expiresAt = chunkD6RGHPZ5_cjs.normalizeVtxo(vtxo).expiresAt;
|
|
3094
3205
|
if (expiresAt === void 0) return false;
|
|
3095
3206
|
const now = Date.now();
|
|
3096
3207
|
const batchExpiry = expiresAt.getTime();
|
|
@@ -3099,7 +3210,7 @@ function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
|
3099
3210
|
}
|
|
3100
3211
|
function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
|
|
3101
3212
|
return vtxos.filter(
|
|
3102
|
-
(vtxo) => isVtxoExpiringSoon(vtxo, thresholdMs) ||
|
|
3213
|
+
(vtxo) => isVtxoExpiringSoon(vtxo, thresholdMs) || chunkD6RGHPZ5_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount)
|
|
3103
3214
|
);
|
|
3104
3215
|
}
|
|
3105
3216
|
function isMigrationCapable(wallet) {
|
|
@@ -3249,19 +3360,27 @@ var VtxoManager = class _VtxoManager {
|
|
|
3249
3360
|
});
|
|
3250
3361
|
const dustAmount = getDustAmount(this.wallet);
|
|
3251
3362
|
const now = await fetchTimeHeight(this.wallet);
|
|
3252
|
-
let { vtxosToRecover
|
|
3363
|
+
let { vtxosToRecover } = getRecoverableWithSubdust(allVtxos, dustAmount, now);
|
|
3253
3364
|
if (vtxosToRecover.length === 0) {
|
|
3254
3365
|
throw new Error("No recoverable VTXOs found");
|
|
3255
3366
|
}
|
|
3256
3367
|
const info = await this.getInfoProvider()?.getInfo();
|
|
3257
3368
|
const vtxoMaxAmount = info?.vtxoMaxAmount ?? -1n;
|
|
3258
|
-
const
|
|
3369
|
+
const estimator = new Estimator(info?.fees.intentFee ?? {});
|
|
3370
|
+
const { payable, net } = priceSettlementInputs(vtxosToRecover, estimator);
|
|
3371
|
+
const capped = capSettlementBatch(byValueDescending(payable), vtxoMaxAmount);
|
|
3259
3372
|
if (capped.length < vtxosToRecover.length) {
|
|
3260
3373
|
const recoverableCount = vtxosToRecover.length;
|
|
3261
|
-
|
|
3374
|
+
const cappedAway = capped.length < payable.length;
|
|
3375
|
+
({ vtxosToRecover } = getRecoverableWithSubdust(capped, dustAmount, now));
|
|
3262
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
|
+
}
|
|
3263
3382
|
throw new Error(
|
|
3264
|
-
`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}`
|
|
3265
3384
|
);
|
|
3266
3385
|
}
|
|
3267
3386
|
}
|
|
@@ -3269,6 +3388,16 @@ var VtxoManager = class _VtxoManager {
|
|
|
3269
3388
|
await this.rotateForRecoverableInputs(vtxosToRecover, info);
|
|
3270
3389
|
}
|
|
3271
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
|
+
}
|
|
3272
3401
|
return this.wallet.settle(
|
|
3273
3402
|
{
|
|
3274
3403
|
inputs: vtxosToRecover,
|
|
@@ -3287,6 +3416,17 @@ var VtxoManager = class _VtxoManager {
|
|
|
3287
3416
|
*
|
|
3288
3417
|
* Useful for displaying to users before they decide to recover funds.
|
|
3289
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
|
+
*
|
|
3290
3430
|
* @returns Object containing recoverable amounts and subdust information
|
|
3291
3431
|
*
|
|
3292
3432
|
* @example
|
|
@@ -3308,17 +3448,29 @@ var VtxoManager = class _VtxoManager {
|
|
|
3308
3448
|
withUnrolled: false
|
|
3309
3449
|
});
|
|
3310
3450
|
const dustAmount = getDustAmount(this.wallet);
|
|
3311
|
-
const { vtxosToRecover, includesSubdust
|
|
3451
|
+
const { vtxosToRecover, includesSubdust } = getRecoverableWithSubdust(
|
|
3312
3452
|
allVtxos,
|
|
3313
3453
|
dustAmount,
|
|
3314
3454
|
await fetchTimeHeight(this.wallet)
|
|
3315
3455
|
);
|
|
3316
|
-
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
|
+
);
|
|
3317
3469
|
return {
|
|
3318
|
-
recoverable
|
|
3470
|
+
recoverable,
|
|
3319
3471
|
subdust: subdustAmount,
|
|
3320
3472
|
includesSubdust,
|
|
3321
|
-
vtxoCount:
|
|
3473
|
+
vtxoCount: payable.length
|
|
3322
3474
|
};
|
|
3323
3475
|
}
|
|
3324
3476
|
// ========== Renewal Methods ==========
|
|
@@ -3436,6 +3588,14 @@ var VtxoManager = class _VtxoManager {
|
|
|
3436
3588
|
}
|
|
3437
3589
|
const info = await this.getInfoProvider()?.getInfo();
|
|
3438
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
|
+
}
|
|
3439
3599
|
const capped = capSettlementBatch(byExpiryAscending(vtxos, now), vtxoMaxAmount);
|
|
3440
3600
|
if (vtxoMaxAmount >= 0n) {
|
|
3441
3601
|
const oversized = vtxos.filter((vtxo) => BigInt(vtxo.value) > vtxoMaxAmount);
|
|
@@ -3453,24 +3613,28 @@ var VtxoManager = class _VtxoManager {
|
|
|
3453
3613
|
);
|
|
3454
3614
|
}
|
|
3455
3615
|
}
|
|
3456
|
-
const totalAmount = vtxos.reduce((sum, vtxo) => sum + vtxo.value, 0);
|
|
3457
3616
|
const dustAmount = getDustAmount(this.wallet);
|
|
3458
|
-
if (BigInt(totalAmount) < dustAmount) {
|
|
3459
|
-
throw new Error(
|
|
3460
|
-
`Total amount ${totalAmount} is below dust threshold ${dustAmount}`
|
|
3461
|
-
);
|
|
3462
|
-
}
|
|
3463
3617
|
if (info && isMigrationCapable(this.wallet)) {
|
|
3464
3618
|
await this.rotateForRecoverableInputs(vtxos, info);
|
|
3465
3619
|
}
|
|
3466
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
|
+
}
|
|
3467
3631
|
const txid = await this.wallet.settle(
|
|
3468
3632
|
{
|
|
3469
3633
|
inputs: vtxos,
|
|
3470
3634
|
outputs: [
|
|
3471
3635
|
{
|
|
3472
3636
|
address: arkAddress,
|
|
3473
|
-
amount:
|
|
3637
|
+
amount: totalAmount
|
|
3474
3638
|
}
|
|
3475
3639
|
]
|
|
3476
3640
|
},
|
|
@@ -3581,11 +3745,11 @@ var VtxoManager = class _VtxoManager {
|
|
|
3581
3745
|
`Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
|
|
3582
3746
|
);
|
|
3583
3747
|
}
|
|
3584
|
-
const tx = new
|
|
3748
|
+
const tx = new chunkD6RGHPZ5_cjs.Transaction();
|
|
3585
3749
|
for (const utxo of expiredUtxos) {
|
|
3586
|
-
const utxoScript =
|
|
3750
|
+
const utxoScript = chunkD6RGHPZ5_cjs.VtxoScript.decode(utxo.tapTree);
|
|
3587
3751
|
const utxoExitLeaf = utxoScript.leaves.find(
|
|
3588
|
-
(leaf) =>
|
|
3752
|
+
(leaf) => chunkD6RGHPZ5_cjs.CSVMultisigTapscript.isScriptValid(chunkD6RGHPZ5_cjs.scriptFromTapLeafScript(leaf)) === true
|
|
3589
3753
|
);
|
|
3590
3754
|
if (!utxoExitLeaf) {
|
|
3591
3755
|
throw new Error(
|
|
@@ -3600,7 +3764,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
3600
3764
|
amount: BigInt(utxo.value)
|
|
3601
3765
|
},
|
|
3602
3766
|
tapLeafScript: [utxoExitLeaf],
|
|
3603
|
-
sequence:
|
|
3767
|
+
sequence: chunkD6RGHPZ5_cjs.getSequence(utxoExitLeaf)
|
|
3604
3768
|
});
|
|
3605
3769
|
}
|
|
3606
3770
|
tx.addOutputAddress(boardingAddress, outputAmount, this.getNetwork());
|
|
@@ -3834,8 +3998,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
3834
3998
|
if (!serverPubKey) continue;
|
|
3835
3999
|
const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
|
|
3836
4000
|
if (cls.status === "CURRENT") continue;
|
|
3837
|
-
const recoverable = vtxos.filter((v) => v.isSwept && !
|
|
3838
|
-
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);
|
|
3839
4003
|
const value = spendable.reduce((sum, v) => sum + v.value, 0);
|
|
3840
4004
|
let recoverableCount = 0;
|
|
3841
4005
|
let recoverableValue = 0;
|
|
@@ -3848,7 +4012,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
3848
4012
|
awaitingSweepCount = spendable.length;
|
|
3849
4013
|
awaitingSweepValue = value;
|
|
3850
4014
|
for (const v of spendable) {
|
|
3851
|
-
const exp =
|
|
4015
|
+
const exp = chunkD6RGHPZ5_cjs.toBatchExpiry(v);
|
|
3852
4016
|
if (exp !== void 0 && (nextSweepEta === void 0 || exp < nextSweepEta)) {
|
|
3853
4017
|
nextSweepEta = exp;
|
|
3854
4018
|
}
|
|
@@ -4109,7 +4273,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4109
4273
|
/** Decodes the boarding tapscript exit path to extract the CSV timelock. */
|
|
4110
4274
|
getBoardingTimelock() {
|
|
4111
4275
|
const wallet = this.getSweepWallet();
|
|
4112
|
-
const exitScript =
|
|
4276
|
+
const exitScript = chunkD6RGHPZ5_cjs.CSVMultisigTapscript.decode(
|
|
4113
4277
|
base.hex.decode(wallet.boardingTapscript.exitScript)
|
|
4114
4278
|
);
|
|
4115
4279
|
return exitScript.params.timelock;
|
|
@@ -4240,8 +4404,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
4240
4404
|
* or doesn't carry the metadata.
|
|
4241
4405
|
*/
|
|
4242
4406
|
extractSpentOutpoint(error) {
|
|
4243
|
-
const ark =
|
|
4244
|
-
if (!
|
|
4407
|
+
const ark = chunkD6RGHPZ5_cjs.maybeArkError(error);
|
|
4408
|
+
if (!chunkD6RGHPZ5_cjs.isArkError(ark, chunkD6RGHPZ5_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
|
|
4245
4409
|
const raw = ark.metadata?.vtxo_outpoint;
|
|
4246
4410
|
if (typeof raw !== "string") return void 0;
|
|
4247
4411
|
const [txid, voutStr] = raw.split(":");
|
|
@@ -4431,7 +4595,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4431
4595
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
4432
4596
|
break;
|
|
4433
4597
|
}
|
|
4434
|
-
const inputFee = estimator.evalOffchainInput(
|
|
4598
|
+
const inputFee = estimator.evalOffchainInput(chunkD6RGHPZ5_cjs.toOffchainInputFeeParams(v));
|
|
4435
4599
|
if (inputFee.satoshis >= v.value) {
|
|
4436
4600
|
continue;
|
|
4437
4601
|
}
|
|
@@ -4451,7 +4615,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4451
4615
|
const arkAddress = await this.wallet.getAddress();
|
|
4452
4616
|
const outputFee = estimator.evalOffchainOutput({
|
|
4453
4617
|
amount: totalAmount,
|
|
4454
|
-
script: base.hex.encode(
|
|
4618
|
+
script: base.hex.encode(chunkD6RGHPZ5_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
4455
4619
|
});
|
|
4456
4620
|
totalAmount -= BigInt(outputFee.satoshis);
|
|
4457
4621
|
if (totalAmount < dustAmount) return;
|
|
@@ -4531,7 +4695,7 @@ var ArkNote = class _ArkNote {
|
|
|
4531
4695
|
this.value = value;
|
|
4532
4696
|
this.HRP = HRP;
|
|
4533
4697
|
const preimageHash = utils_js.sha256(this.preimage);
|
|
4534
|
-
this.vtxoScript = new
|
|
4698
|
+
this.vtxoScript = new chunkD6RGHPZ5_cjs.VtxoScript([noteTapscript(preimageHash)]);
|
|
4535
4699
|
const leaf = this.vtxoScript.leaves[0];
|
|
4536
4700
|
this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
|
|
4537
4701
|
this.tapTree = this.vtxoScript.encode();
|
|
@@ -4698,7 +4862,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
4698
4862
|
const privateKey = data.slice(1, 33);
|
|
4699
4863
|
const serverPubKey = data.slice(33, 65);
|
|
4700
4864
|
const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
|
|
4701
|
-
const csvTimelock =
|
|
4865
|
+
const csvTimelock = chunkD6RGHPZ5_cjs.sequenceToTimelock(sequence);
|
|
4702
4866
|
return new _ArkadeCash(privateKey, serverPubKey, csvTimelock, decoded.prefix);
|
|
4703
4867
|
}
|
|
4704
4868
|
toString() {
|
|
@@ -4706,7 +4870,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
4706
4870
|
data[0] = _ArkadeCash.Version;
|
|
4707
4871
|
data.set(this._privateKey, 1);
|
|
4708
4872
|
data.set(this._serverPubKey, 33);
|
|
4709
|
-
const sequence =
|
|
4873
|
+
const sequence = chunkD6RGHPZ5_cjs.timelockToSequence(this.csvTimelock);
|
|
4710
4874
|
new DataView(data.buffer, data.byteOffset + 65, 4).setUint32(0, sequence, false);
|
|
4711
4875
|
const words = base.bech32m.toWords(data);
|
|
4712
4876
|
return base.bech32m.encode(this.hrp, words, 1023);
|
|
@@ -4715,7 +4879,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
4715
4879
|
return SingleKey.fromPrivateKey(this._privateKey);
|
|
4716
4880
|
}
|
|
4717
4881
|
get vtxoScript() {
|
|
4718
|
-
return new
|
|
4882
|
+
return new chunkCOLJARV4_cjs.DefaultVtxo.Script({
|
|
4719
4883
|
pubKey: this._publicKey,
|
|
4720
4884
|
serverPubKey: this._serverPubKey,
|
|
4721
4885
|
csvTimelock: this.csvTimelock
|
|
@@ -4976,7 +5140,7 @@ async function captureExitBranch(params) {
|
|
|
4976
5140
|
const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
|
|
4977
5141
|
if (nonCommitment.length > 0) {
|
|
4978
5142
|
for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
|
|
4979
|
-
psbtByTxid.set(
|
|
5143
|
+
psbtByTxid.set(chunkD6RGHPZ5_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
4980
5144
|
}
|
|
4981
5145
|
}
|
|
4982
5146
|
}
|
|
@@ -5019,10 +5183,10 @@ var IndexerExitDataSource = class {
|
|
|
5019
5183
|
while (hasMore) {
|
|
5020
5184
|
const { chain: page, page: meta } = await this.indexer.getVtxoChain(
|
|
5021
5185
|
{ txid: vtxo.txid, vout: vtxo.vout },
|
|
5022
|
-
{ pageIndex, pageSize:
|
|
5186
|
+
{ pageIndex, pageSize: chunkD6RGHPZ5_cjs.DEFAULT_PAGE_SIZE }
|
|
5023
5187
|
);
|
|
5024
5188
|
chain.push(...page);
|
|
5025
|
-
hasMore = meta ? page.length ===
|
|
5189
|
+
hasMore = meta ? page.length === chunkD6RGHPZ5_cjs.DEFAULT_PAGE_SIZE : false;
|
|
5026
5190
|
pageIndex++;
|
|
5027
5191
|
}
|
|
5028
5192
|
return chain;
|
|
@@ -5034,12 +5198,12 @@ var IndexerExitDataSource = class {
|
|
|
5034
5198
|
while (hasMore) {
|
|
5035
5199
|
const { txs, page } = await this.indexer.getVirtualTxs(txids, {
|
|
5036
5200
|
pageIndex,
|
|
5037
|
-
pageSize:
|
|
5201
|
+
pageSize: chunkD6RGHPZ5_cjs.DEFAULT_PAGE_SIZE
|
|
5038
5202
|
});
|
|
5039
5203
|
for (const psbt of txs) {
|
|
5040
|
-
out.set(
|
|
5204
|
+
out.set(chunkD6RGHPZ5_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
5041
5205
|
}
|
|
5042
|
-
hasMore = page ? txs.length ===
|
|
5206
|
+
hasMore = page ? txs.length === chunkD6RGHPZ5_cjs.DEFAULT_PAGE_SIZE : false;
|
|
5043
5207
|
pageIndex++;
|
|
5044
5208
|
}
|
|
5045
5209
|
return out;
|
|
@@ -5060,7 +5224,7 @@ function chainedTxTypeToChainTxType(t) {
|
|
|
5060
5224
|
}
|
|
5061
5225
|
}
|
|
5062
5226
|
function psbtInputTxids(psbtBase64) {
|
|
5063
|
-
const tx =
|
|
5227
|
+
const tx = chunkD6RGHPZ5_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
5064
5228
|
const ids = [];
|
|
5065
5229
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
5066
5230
|
const txid = tx.getInput(i).txid;
|
|
@@ -5240,6 +5404,7 @@ function serializeArkInfoSnapshot(info, savedAt) {
|
|
|
5240
5404
|
forfeitPubkey: info.forfeitPubkey,
|
|
5241
5405
|
unilateralExitDelay: info.unilateralExitDelay.toString(),
|
|
5242
5406
|
boardingExitDelay: info.boardingExitDelay.toString(),
|
|
5407
|
+
vtxoTreeExpiry: info.vtxoTreeExpiry?.toString(),
|
|
5243
5408
|
sessionDuration: info.sessionDuration.toString(),
|
|
5244
5409
|
dust: info.dust.toString(),
|
|
5245
5410
|
fees: info.fees,
|
|
@@ -5289,6 +5454,7 @@ function hydrateArkInfo(snapshot) {
|
|
|
5289
5454
|
sessionDuration: BigInt(a.sessionDuration),
|
|
5290
5455
|
signerPubkey: a.signerPubkey,
|
|
5291
5456
|
unilateralExitDelay: BigInt(a.unilateralExitDelay),
|
|
5457
|
+
vtxoTreeExpiry: a.vtxoTreeExpiry !== void 0 ? BigInt(a.vtxoTreeExpiry) : void 0,
|
|
5292
5458
|
utxoMaxAmount: BigInt(a.utxoMaxAmount),
|
|
5293
5459
|
utxoMinAmount: BigInt(a.utxoMinAmount),
|
|
5294
5460
|
version: a.version,
|
|
@@ -5361,6 +5527,9 @@ function parseStoredArkInfoSnapshot(raw) {
|
|
|
5361
5527
|
]) {
|
|
5362
5528
|
assertDecimalString(a[field], `arkInfo.${field}`);
|
|
5363
5529
|
}
|
|
5530
|
+
if (a.vtxoTreeExpiry !== void 0) {
|
|
5531
|
+
assertDecimalString(a.vtxoTreeExpiry, "arkInfo.vtxoTreeExpiry");
|
|
5532
|
+
}
|
|
5364
5533
|
assertFeeInfo(a.fees, "arkInfo.fees");
|
|
5365
5534
|
if (!Array.isArray(a.deprecatedSigners)) {
|
|
5366
5535
|
throw new MalformedArkInfoSnapshotError("arkInfo.deprecatedSigners must be an array");
|
|
@@ -5408,10 +5577,10 @@ async function resolveArkInfo(arkProvider, walletRepository) {
|
|
|
5408
5577
|
try {
|
|
5409
5578
|
info = await arkProvider.getInfo();
|
|
5410
5579
|
} catch (err) {
|
|
5411
|
-
if (!
|
|
5580
|
+
if (!chunkD6RGHPZ5_cjs.isRetryableProviderError(err)) throw err;
|
|
5412
5581
|
const snapshot = await loadArkInfoSnapshot(walletRepository);
|
|
5413
5582
|
if (!snapshot) {
|
|
5414
|
-
throw new
|
|
5583
|
+
throw new chunkD6RGHPZ5_cjs.ProviderUnavailableError(
|
|
5415
5584
|
"Arkade server info is unavailable and no cached snapshot exists",
|
|
5416
5585
|
{ cause: err }
|
|
5417
5586
|
);
|
|
@@ -5794,7 +5963,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos) {
|
|
|
5794
5963
|
return [...txids];
|
|
5795
5964
|
}
|
|
5796
5965
|
async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt) {
|
|
5797
|
-
const fromOldestVtxo = vtxos.map(
|
|
5966
|
+
const fromOldestVtxo = vtxos.map(chunkD6RGHPZ5_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
5798
5967
|
const txidsNeedingCreatedAt = resolveTxCreatedAt ? collectArkTxidsNeedingCreatedAt(fromOldestVtxo) : [];
|
|
5799
5968
|
const resolvedCreatedAt = resolveTxCreatedAt && txidsNeedingCreatedAt.length > 0 ? await resolveTxCreatedAt(txidsNeedingCreatedAt) : /* @__PURE__ */ new Map();
|
|
5800
5969
|
const unmatchedSettledBoardingTxs = allBoardingTxs.filter(isSettledBoardingReceive).sort((a, b) => a.createdAt - b.createdAt);
|
|
@@ -5958,7 +6127,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5958
6127
|
const virtualCoins = await this.wallet.getVtxos({
|
|
5959
6128
|
withRecoverable: false
|
|
5960
6129
|
});
|
|
5961
|
-
const controlAssetRef = params.controlAssetId ?
|
|
6130
|
+
const controlAssetRef = params.controlAssetId ? chunkF4C67JYB_cjs.AssetRef.fromId(chunkF4C67JYB_cjs.AssetId.fromString(params.controlAssetId)) : null;
|
|
5962
6131
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
5963
6132
|
let totalBtcSelected = 0n;
|
|
5964
6133
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -5971,8 +6140,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5971
6140
|
}
|
|
5972
6141
|
}
|
|
5973
6142
|
const groups = [];
|
|
5974
|
-
const issuedAssetOutput =
|
|
5975
|
-
const issuedAssetGroup =
|
|
6143
|
+
const issuedAssetOutput = chunkF4C67JYB_cjs.AssetOutput.create(0, params.amount);
|
|
6144
|
+
const issuedAssetGroup = chunkF4C67JYB_cjs.AssetGroup.create(
|
|
5976
6145
|
null,
|
|
5977
6146
|
controlAssetRef,
|
|
5978
6147
|
[],
|
|
@@ -5987,28 +6156,28 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5987
6156
|
for (const [inputIndex, assets] of assetInputs) {
|
|
5988
6157
|
for (const asset of assets) {
|
|
5989
6158
|
if (asset.assetId !== assetId) continue;
|
|
5990
|
-
changeInputs.push(
|
|
6159
|
+
changeInputs.push(chunkF4C67JYB_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
5991
6160
|
}
|
|
5992
6161
|
}
|
|
5993
6162
|
groups.push(
|
|
5994
|
-
|
|
5995
|
-
|
|
6163
|
+
chunkF4C67JYB_cjs.AssetGroup.create(
|
|
6164
|
+
chunkF4C67JYB_cjs.AssetId.fromString(assetId),
|
|
5996
6165
|
null,
|
|
5997
6166
|
changeInputs,
|
|
5998
|
-
[
|
|
6167
|
+
[chunkF4C67JYB_cjs.AssetOutput.create(0, amount)],
|
|
5999
6168
|
[]
|
|
6000
6169
|
)
|
|
6001
6170
|
);
|
|
6002
6171
|
}
|
|
6003
6172
|
}
|
|
6004
6173
|
const address = await this.wallet.getAddress();
|
|
6005
|
-
const outputAddress =
|
|
6174
|
+
const outputAddress = chunkD6RGHPZ5_cjs.ArkAddress.decode(address);
|
|
6006
6175
|
const outputs = [
|
|
6007
6176
|
{
|
|
6008
6177
|
script: outputAddress.pkScript,
|
|
6009
6178
|
amount: BigInt(totalBtcSelected)
|
|
6010
6179
|
},
|
|
6011
|
-
Extension.create([
|
|
6180
|
+
Extension.create([chunkF4C67JYB_cjs.Packet.create(groups)]).txOut()
|
|
6012
6181
|
];
|
|
6013
6182
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
|
|
6014
6183
|
coinSelection.inputs,
|
|
@@ -6016,7 +6185,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6016
6185
|
);
|
|
6017
6186
|
return {
|
|
6018
6187
|
arkTxId: arkTxid,
|
|
6019
|
-
assetId:
|
|
6188
|
+
assetId: chunkF4C67JYB_cjs.AssetId.create(arkTxid, 0).toString()
|
|
6020
6189
|
};
|
|
6021
6190
|
}
|
|
6022
6191
|
/**
|
|
@@ -6088,16 +6257,16 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6088
6257
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6089
6258
|
for (const asset of assets) {
|
|
6090
6259
|
if (asset.assetId !== params.assetId) continue;
|
|
6091
|
-
reissueInputs.push(
|
|
6260
|
+
reissueInputs.push(chunkF4C67JYB_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6092
6261
|
}
|
|
6093
6262
|
}
|
|
6094
6263
|
const totalAssetAmount = assetToReissueAmount + params.amount;
|
|
6095
|
-
const reissueAssetIdObj =
|
|
6096
|
-
const reissueAssetGroup =
|
|
6264
|
+
const reissueAssetIdObj = chunkF4C67JYB_cjs.AssetId.fromString(params.assetId);
|
|
6265
|
+
const reissueAssetGroup = chunkF4C67JYB_cjs.AssetGroup.create(
|
|
6097
6266
|
reissueAssetIdObj,
|
|
6098
6267
|
null,
|
|
6099
6268
|
reissueInputs,
|
|
6100
|
-
[
|
|
6269
|
+
[chunkF4C67JYB_cjs.AssetOutput.create(0, totalAssetAmount)],
|
|
6101
6270
|
[]
|
|
6102
6271
|
);
|
|
6103
6272
|
const groups = [reissueAssetGroup];
|
|
@@ -6106,27 +6275,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6106
6275
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6107
6276
|
for (const asset of assets) {
|
|
6108
6277
|
if (asset.assetId !== assetId) continue;
|
|
6109
|
-
changeInputs.push(
|
|
6278
|
+
changeInputs.push(chunkF4C67JYB_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6110
6279
|
}
|
|
6111
6280
|
}
|
|
6112
6281
|
groups.push(
|
|
6113
|
-
|
|
6114
|
-
|
|
6282
|
+
chunkF4C67JYB_cjs.AssetGroup.create(
|
|
6283
|
+
chunkF4C67JYB_cjs.AssetId.fromString(assetId),
|
|
6115
6284
|
null,
|
|
6116
6285
|
changeInputs,
|
|
6117
|
-
[
|
|
6286
|
+
[chunkF4C67JYB_cjs.AssetOutput.create(0, amount)],
|
|
6118
6287
|
[]
|
|
6119
6288
|
)
|
|
6120
6289
|
);
|
|
6121
6290
|
}
|
|
6122
6291
|
const address = await this.wallet.getAddress();
|
|
6123
|
-
const outputAddress =
|
|
6292
|
+
const outputAddress = chunkD6RGHPZ5_cjs.ArkAddress.decode(address);
|
|
6124
6293
|
const outputs = [
|
|
6125
6294
|
{
|
|
6126
6295
|
script: outputAddress.pkScript,
|
|
6127
6296
|
amount: BigInt(totalBtcSelected)
|
|
6128
6297
|
},
|
|
6129
|
-
Extension.create([
|
|
6298
|
+
Extension.create([chunkF4C67JYB_cjs.Packet.create(groups)]).txOut()
|
|
6130
6299
|
];
|
|
6131
6300
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
6132
6301
|
return arkTxid;
|
|
@@ -6193,27 +6362,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6193
6362
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6194
6363
|
for (const asset of assets) {
|
|
6195
6364
|
if (asset.assetId !== assetId) continue;
|
|
6196
|
-
changeInputs.push(
|
|
6365
|
+
changeInputs.push(chunkF4C67JYB_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6197
6366
|
}
|
|
6198
6367
|
}
|
|
6199
6368
|
groups.push(
|
|
6200
|
-
|
|
6201
|
-
|
|
6369
|
+
chunkF4C67JYB_cjs.AssetGroup.create(
|
|
6370
|
+
chunkF4C67JYB_cjs.AssetId.fromString(assetId),
|
|
6202
6371
|
null,
|
|
6203
6372
|
changeInputs,
|
|
6204
|
-
amount > 0n ? [
|
|
6373
|
+
amount > 0n ? [chunkF4C67JYB_cjs.AssetOutput.create(0, amount)] : [],
|
|
6205
6374
|
[]
|
|
6206
6375
|
)
|
|
6207
6376
|
);
|
|
6208
6377
|
}
|
|
6209
6378
|
const address = await this.wallet.getAddress();
|
|
6210
|
-
const outputAddress =
|
|
6379
|
+
const outputAddress = chunkD6RGHPZ5_cjs.ArkAddress.decode(address);
|
|
6211
6380
|
const outputs = [
|
|
6212
6381
|
{
|
|
6213
6382
|
script: outputAddress.pkScript,
|
|
6214
6383
|
amount: BigInt(totalBtcSelected)
|
|
6215
6384
|
},
|
|
6216
|
-
Extension.create([
|
|
6385
|
+
Extension.create([chunkF4C67JYB_cjs.Packet.create(groups)]).txOut()
|
|
6217
6386
|
];
|
|
6218
6387
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
6219
6388
|
return arkTxid;
|
|
@@ -6238,7 +6407,7 @@ function castMetadata(metadata) {
|
|
|
6238
6407
|
} else {
|
|
6239
6408
|
throw new Error("Invalid metadata value type");
|
|
6240
6409
|
}
|
|
6241
|
-
md.push(
|
|
6410
|
+
md.push(chunkF4C67JYB_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
|
|
6242
6411
|
}
|
|
6243
6412
|
return md;
|
|
6244
6413
|
}
|
|
@@ -6259,10 +6428,10 @@ var DelegateManagerImpl = class {
|
|
|
6259
6428
|
if (vtxos.length === 0) {
|
|
6260
6429
|
return { delegated: [], failed: [] };
|
|
6261
6430
|
}
|
|
6262
|
-
const destinationScript =
|
|
6431
|
+
const destinationScript = chunkD6RGHPZ5_cjs.ArkAddress.decode(destination).pkScript;
|
|
6263
6432
|
const arkInfo = await this.arkInfoProvider.getInfo();
|
|
6264
6433
|
const delegateInfo = await this.delegateProvider.getDelegateInfo();
|
|
6265
|
-
const eligible = vtxos.map(
|
|
6434
|
+
const eligible = vtxos.map(chunkD6RGHPZ5_cjs.normalizeVtxo).filter(
|
|
6266
6435
|
(v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
|
|
6267
6436
|
);
|
|
6268
6437
|
if (eligible.length === 0) {
|
|
@@ -6291,11 +6460,11 @@ var DelegateManagerImpl = class {
|
|
|
6291
6460
|
const groupByExpiry = /* @__PURE__ */ new Map();
|
|
6292
6461
|
let recoverableVtxos = [];
|
|
6293
6462
|
for (const vtxo of eligible) {
|
|
6294
|
-
if (
|
|
6463
|
+
if (chunkD6RGHPZ5_cjs.canRecoverOnchain(vtxo, now)) {
|
|
6295
6464
|
recoverableVtxos.push(vtxo);
|
|
6296
6465
|
continue;
|
|
6297
6466
|
}
|
|
6298
|
-
const expiry =
|
|
6467
|
+
const expiry = chunkD6RGHPZ5_cjs.toBatchExpiry(vtxo);
|
|
6299
6468
|
if (!expiry) continue;
|
|
6300
6469
|
const dayKey = getDayTimestamp(expiry);
|
|
6301
6470
|
groupByExpiry.set(dayKey, [...groupByExpiry.get(dayKey) ?? [], vtxo]);
|
|
@@ -6360,7 +6529,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6360
6529
|
}
|
|
6361
6530
|
if (!delegateAt) {
|
|
6362
6531
|
const now = { timestamp: /* @__PURE__ */ new Date() };
|
|
6363
|
-
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);
|
|
6364
6533
|
if (!expiryTimestamp || expiryTimestamp === Number.MAX_SAFE_INTEGER) {
|
|
6365
6534
|
delegateAt = new Date(Date.now() + 1 * 60 * 1e3);
|
|
6366
6535
|
} else {
|
|
@@ -6389,7 +6558,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6389
6558
|
let amount = 0n;
|
|
6390
6559
|
for (const coin of vtxos) {
|
|
6391
6560
|
const inputFee = estimator.evalOffchainInput({
|
|
6392
|
-
...
|
|
6561
|
+
...chunkD6RGHPZ5_cjs.toOffchainInputFeeParams(coin),
|
|
6393
6562
|
type: "vtxo"
|
|
6394
6563
|
});
|
|
6395
6564
|
if (inputFee.value >= coin.value) {
|
|
@@ -6403,7 +6572,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6403
6572
|
const delegateFee = BigInt(Number(fee));
|
|
6404
6573
|
if (delegateFee > 0n) {
|
|
6405
6574
|
outputs.push({
|
|
6406
|
-
script:
|
|
6575
|
+
script: chunkD6RGHPZ5_cjs.ArkAddress.decode(delegateAddress).pkScript,
|
|
6407
6576
|
amount: delegateFee
|
|
6408
6577
|
});
|
|
6409
6578
|
}
|
|
@@ -6436,10 +6605,10 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6436
6605
|
destinationScript
|
|
6437
6606
|
);
|
|
6438
6607
|
const forfeitOutputScript = btcSigner.OutScript.encode(
|
|
6439
|
-
btcSigner.Address(
|
|
6608
|
+
btcSigner.Address(chunkD6RGHPZ5_cjs.getNetwork(network)).decode(forfeitAddress)
|
|
6440
6609
|
);
|
|
6441
6610
|
const forfeits = await Promise.all(
|
|
6442
|
-
vtxos.filter((v) => !
|
|
6611
|
+
vtxos.filter((v) => !chunkD6RGHPZ5_cjs.canRecoverOnchain(v, { timestamp: /* @__PURE__ */ new Date() })).map(async (coin) => {
|
|
6443
6612
|
const forfeit = await makeDelegateForfeitTx(
|
|
6444
6613
|
coin,
|
|
6445
6614
|
dust,
|
|
@@ -6464,7 +6633,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
|
|
|
6464
6633
|
index: input.vout,
|
|
6465
6634
|
witnessUtxo: {
|
|
6466
6635
|
amount: BigInt(input.value),
|
|
6467
|
-
script:
|
|
6636
|
+
script: chunkD6RGHPZ5_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
6468
6637
|
},
|
|
6469
6638
|
sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
|
|
6470
6639
|
tapLeafScript: [delegateTapLeaf]
|
|
@@ -6522,7 +6691,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
6522
6691
|
expire_at: 0,
|
|
6523
6692
|
cosigners_public_keys: cosignerPubKeys
|
|
6524
6693
|
};
|
|
6525
|
-
const proof =
|
|
6694
|
+
const proof = chunkD6RGHPZ5_cjs.Intent.create(message, coins, outputs);
|
|
6526
6695
|
const signedProof = await identity.sign(proof);
|
|
6527
6696
|
return {
|
|
6528
6697
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -6540,10 +6709,10 @@ function getDayTimestamp(timestamp) {
|
|
|
6540
6709
|
function findDelegateTapLeaf(vtxo, delegatePubkey) {
|
|
6541
6710
|
if (!vtxo.tapTree) return void 0;
|
|
6542
6711
|
const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
|
|
6543
|
-
const vtxoScript =
|
|
6712
|
+
const vtxoScript = chunkD6RGHPZ5_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
6544
6713
|
return vtxoScript.leaves.find((tapLeaf) => {
|
|
6545
|
-
const arkTapscript =
|
|
6546
|
-
if (!
|
|
6714
|
+
const arkTapscript = chunkD6RGHPZ5_cjs.decodeTapscript(chunkD6RGHPZ5_cjs.scriptFromTapLeafScript(tapLeaf));
|
|
6715
|
+
if (!chunkD6RGHPZ5_cjs.MultisigTapscript.is(arkTapscript)) return false;
|
|
6547
6716
|
return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
|
|
6548
6717
|
});
|
|
6549
6718
|
}
|
|
@@ -6731,7 +6900,7 @@ async function closeDatabase(dbName) {
|
|
|
6731
6900
|
return true;
|
|
6732
6901
|
}
|
|
6733
6902
|
function scriptFromArkAddress(address) {
|
|
6734
|
-
return base.hex.encode(
|
|
6903
|
+
return base.hex.encode(chunkD6RGHPZ5_cjs.ArkAddress.decode(address).pkScript);
|
|
6735
6904
|
}
|
|
6736
6905
|
|
|
6737
6906
|
// src/repositories/indexedDB/schema.ts
|
|
@@ -7228,7 +7397,7 @@ function validateVtxosForScript(vtxos, script, context) {
|
|
|
7228
7397
|
}
|
|
7229
7398
|
async function getVtxosForContract(repo, contract) {
|
|
7230
7399
|
const vtxos = repo.getVtxosForScript ? await repo.getVtxosForScript(contract.script) : filterVtxosForScript(await repo.getVtxos(contract.address), contract.script);
|
|
7231
|
-
return vtxos.map(
|
|
7400
|
+
return vtxos.map(chunkD6RGHPZ5_cjs.normalizeVtxo);
|
|
7232
7401
|
}
|
|
7233
7402
|
async function saveVtxosForContract(repo, contract, vtxos) {
|
|
7234
7403
|
if (repo.saveVtxosForScript) {
|
|
@@ -7432,7 +7601,7 @@ var deserializeTapLeaf = (t) => {
|
|
|
7432
7601
|
const s = base.hex.decode(t.s);
|
|
7433
7602
|
return [cb, s];
|
|
7434
7603
|
};
|
|
7435
|
-
var deserializeVtxo = (o) =>
|
|
7604
|
+
var deserializeVtxo = (o) => chunkD6RGHPZ5_cjs.normalizeVtxo({
|
|
7436
7605
|
...o,
|
|
7437
7606
|
createdAt: new Date(o.createdAt),
|
|
7438
7607
|
tapTree: base.hex.decode(o.tapTree),
|
|
@@ -8571,7 +8740,7 @@ var ContractWatcher = class {
|
|
|
8571
8740
|
this.connectionState = "connected";
|
|
8572
8741
|
this.reconnectAttempts = 0;
|
|
8573
8742
|
this.listenLoop().catch((e) => {
|
|
8574
|
-
if (
|
|
8743
|
+
if (chunkD6RGHPZ5_cjs.isEventSourceError(e)) {
|
|
8575
8744
|
console.debug("ContractWatcher subscription disconnected; reconnecting");
|
|
8576
8745
|
} else {
|
|
8577
8746
|
console.error(e);
|
|
@@ -8800,14 +8969,14 @@ var ContractWatcher = class {
|
|
|
8800
8969
|
const timestamp = Date.now();
|
|
8801
8970
|
if (update.newVtxos?.length) {
|
|
8802
8971
|
this.processSubscriptionVtxos(
|
|
8803
|
-
update.newVtxos.map(
|
|
8972
|
+
update.newVtxos.map(chunkD6RGHPZ5_cjs.normalizeVtxo),
|
|
8804
8973
|
"vtxo_received",
|
|
8805
8974
|
timestamp
|
|
8806
8975
|
);
|
|
8807
8976
|
}
|
|
8808
8977
|
if (update.spentVtxos?.length) {
|
|
8809
8978
|
this.processSubscriptionVtxos(
|
|
8810
|
-
update.spentVtxos.map(
|
|
8979
|
+
update.spentVtxos.map(chunkD6RGHPZ5_cjs.normalizeVtxo),
|
|
8811
8980
|
"vtxo_spent",
|
|
8812
8981
|
timestamp
|
|
8813
8982
|
);
|
|
@@ -8940,7 +9109,7 @@ async function reconcileIntents(deps) {
|
|
|
8940
9109
|
let vtxosByOutpoint = /* @__PURE__ */ new Map();
|
|
8941
9110
|
if (outpoints.length > 0) {
|
|
8942
9111
|
try {
|
|
8943
|
-
const { vtxos } = await
|
|
9112
|
+
const { vtxos } = await chunkD6RGHPZ5_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
|
|
8944
9113
|
vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
|
|
8945
9114
|
} catch (e) {
|
|
8946
9115
|
console.error("reconcileIntents: failed to fetch input VTXO state", e);
|
|
@@ -9060,7 +9229,7 @@ var ContractManager = class _ContractManager {
|
|
|
9060
9229
|
await this.reconcileWatched();
|
|
9061
9230
|
this.markSyncOnline();
|
|
9062
9231
|
} catch (err) {
|
|
9063
|
-
if (!
|
|
9232
|
+
if (!chunkD6RGHPZ5_cjs.isRetryableProviderError(err)) throw err;
|
|
9064
9233
|
this.markSyncDegraded(err);
|
|
9065
9234
|
}
|
|
9066
9235
|
this.initialized = true;
|
|
@@ -9172,7 +9341,7 @@ var ContractManager = class _ContractManager {
|
|
|
9172
9341
|
const from = Math.max(0, watermark - lookAhead.size);
|
|
9173
9342
|
const to = watermark + lookAhead.size;
|
|
9174
9343
|
const deps = lookAhead.candidateDeps();
|
|
9175
|
-
const handlers =
|
|
9344
|
+
const handlers = chunkCOLJARV4_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkCOLJARV4_cjs.contractHandlers.get(t)).filter(hasCandidates);
|
|
9176
9345
|
const band = /* @__PURE__ */ new Map();
|
|
9177
9346
|
for (let index = from; index <= to; index++) {
|
|
9178
9347
|
const descriptor = lookAhead.materialize(index);
|
|
@@ -9183,7 +9352,7 @@ var ContractManager = class _ContractManager {
|
|
|
9183
9352
|
index,
|
|
9184
9353
|
params: {
|
|
9185
9354
|
...candidate,
|
|
9186
|
-
...
|
|
9355
|
+
...chunkCOLJARV4_cjs.speculativeReceiveMetadata(descriptor)
|
|
9187
9356
|
}
|
|
9188
9357
|
});
|
|
9189
9358
|
}
|
|
@@ -9243,7 +9412,7 @@ var ContractManager = class _ContractManager {
|
|
|
9243
9412
|
});
|
|
9244
9413
|
for (const entry of pending) entry.catchUpPending = false;
|
|
9245
9414
|
} catch (err) {
|
|
9246
|
-
if (!
|
|
9415
|
+
if (!chunkD6RGHPZ5_cjs.isRetryableProviderError(err)) throw err;
|
|
9247
9416
|
this.markSyncDegraded(err);
|
|
9248
9417
|
}
|
|
9249
9418
|
}
|
|
@@ -9287,7 +9456,7 @@ var ContractManager = class _ContractManager {
|
|
|
9287
9456
|
await this.fetchContractVxosFromIndexer([contract]);
|
|
9288
9457
|
this.markSyncOnline();
|
|
9289
9458
|
} catch (err) {
|
|
9290
|
-
if (!
|
|
9459
|
+
if (!chunkD6RGHPZ5_cjs.isRetryableProviderError(err)) throw err;
|
|
9291
9460
|
this.markSyncDegraded(err);
|
|
9292
9461
|
}
|
|
9293
9462
|
await this.watcher.addContract(contract);
|
|
@@ -9324,7 +9493,7 @@ var ContractManager = class _ContractManager {
|
|
|
9324
9493
|
return result;
|
|
9325
9494
|
}
|
|
9326
9495
|
async upsertContractRow(params) {
|
|
9327
|
-
const handler =
|
|
9496
|
+
const handler = chunkCOLJARV4_cjs.contractHandlers.get(params.type);
|
|
9328
9497
|
if (!handler) {
|
|
9329
9498
|
throw new Error(`No handler registered for contract type '${params.type}'`);
|
|
9330
9499
|
}
|
|
@@ -9424,7 +9593,7 @@ var ContractManager = class _ContractManager {
|
|
|
9424
9593
|
`scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
|
|
9425
9594
|
);
|
|
9426
9595
|
}
|
|
9427
|
-
const registered =
|
|
9596
|
+
const registered = chunkCOLJARV4_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkCOLJARV4_cjs.contractHandlers.get(t)).filter(isDiscoverable);
|
|
9428
9597
|
const discoverables = [
|
|
9429
9598
|
...registered.filter((h) => h.type === "boarding"),
|
|
9430
9599
|
...registered.filter((h) => h.type !== "boarding")
|
|
@@ -9559,7 +9728,7 @@ var ContractManager = class _ContractManager {
|
|
|
9559
9728
|
await this.syncContracts({ contracts, pageSize });
|
|
9560
9729
|
this.markSyncOnline();
|
|
9561
9730
|
} catch (err) {
|
|
9562
|
-
if (!
|
|
9731
|
+
if (!chunkD6RGHPZ5_cjs.isRetryableProviderError(err)) throw err;
|
|
9563
9732
|
this.markSyncDegraded(err);
|
|
9564
9733
|
}
|
|
9565
9734
|
const vtxos = await this.getVtxosForContracts(contracts);
|
|
@@ -9580,7 +9749,7 @@ var ContractManager = class _ContractManager {
|
|
|
9580
9749
|
}
|
|
9581
9750
|
const tapscriptCache = /* @__PURE__ */ new Map();
|
|
9582
9751
|
return vtxos.map(
|
|
9583
|
-
(vtxo) => extendVirtualCoinForContract(
|
|
9752
|
+
(vtxo) => extendVirtualCoinForContract(chunkD6RGHPZ5_cjs.normalizeVtxo(vtxo), byScript, tapscriptCache)
|
|
9584
9753
|
);
|
|
9585
9754
|
}
|
|
9586
9755
|
buildContractsDbFilter(filter) {
|
|
@@ -9665,7 +9834,7 @@ var ContractManager = class _ContractManager {
|
|
|
9665
9834
|
const { contractScript, collaborative = true, walletPubKey, vtxo } = options;
|
|
9666
9835
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
9667
9836
|
if (!contract) return [];
|
|
9668
|
-
const handler =
|
|
9837
|
+
const handler = chunkCOLJARV4_cjs.contractHandlers.get(contract.type);
|
|
9669
9838
|
if (!handler) return [];
|
|
9670
9839
|
const script = handler.createScript(contract.params);
|
|
9671
9840
|
const context = {
|
|
@@ -9685,7 +9854,7 @@ var ContractManager = class _ContractManager {
|
|
|
9685
9854
|
const { contractScript, collaborative = true, walletPubKey } = options;
|
|
9686
9855
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
9687
9856
|
if (!contract) return [];
|
|
9688
|
-
const handler =
|
|
9857
|
+
const handler = chunkCOLJARV4_cjs.contractHandlers.get(contract.type);
|
|
9689
9858
|
if (!handler) return [];
|
|
9690
9859
|
const script = handler.createScript(contract.params);
|
|
9691
9860
|
const context = {
|
|
@@ -9741,7 +9910,7 @@ var ContractManager = class _ContractManager {
|
|
|
9741
9910
|
}
|
|
9742
9911
|
async refreshOutpoints(outpoints) {
|
|
9743
9912
|
if (outpoints.length === 0) return;
|
|
9744
|
-
const { vtxos } = await
|
|
9913
|
+
const { vtxos } = await chunkD6RGHPZ5_cjs.getNormalizedVtxos(this.config.indexerProvider, {
|
|
9745
9914
|
outpoints
|
|
9746
9915
|
});
|
|
9747
9916
|
if (vtxos.length === 0) return;
|
|
@@ -9819,7 +9988,7 @@ var ContractManager = class _ContractManager {
|
|
|
9819
9988
|
break;
|
|
9820
9989
|
}
|
|
9821
9990
|
} catch (err) {
|
|
9822
|
-
if (!
|
|
9991
|
+
if (!chunkD6RGHPZ5_cjs.isRetryableProviderError(err)) throw err;
|
|
9823
9992
|
this.markSyncDegraded(err);
|
|
9824
9993
|
}
|
|
9825
9994
|
this.emitEvent(event);
|
|
@@ -9868,7 +10037,7 @@ var ContractManager = class _ContractManager {
|
|
|
9868
10037
|
*/
|
|
9869
10038
|
async reconcilePendingFrontier(contracts) {
|
|
9870
10039
|
const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
|
|
9871
|
-
const vtxos = await
|
|
10040
|
+
const vtxos = await chunkD6RGHPZ5_cjs.getAllNormalizedVtxos(
|
|
9872
10041
|
this.config.indexerProvider,
|
|
9873
10042
|
contracts.map((c) => c.script),
|
|
9874
10043
|
{ pendingOnly: true }
|
|
@@ -9949,7 +10118,7 @@ var ContractManager = class _ContractManager {
|
|
|
9949
10118
|
}
|
|
9950
10119
|
return result;
|
|
9951
10120
|
}
|
|
9952
|
-
async fetchContractVtxosBulk(contracts, pageSize =
|
|
10121
|
+
async fetchContractVtxosBulk(contracts, pageSize = chunkD6RGHPZ5_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
|
|
9953
10122
|
if (contracts.length === 0) {
|
|
9954
10123
|
return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
|
|
9955
10124
|
}
|
|
@@ -9965,7 +10134,7 @@ var ContractManager = class _ContractManager {
|
|
|
9965
10134
|
before: syncWindow.before
|
|
9966
10135
|
}
|
|
9967
10136
|
} : {};
|
|
9968
|
-
const vtxos = await
|
|
10137
|
+
const vtxos = await chunkD6RGHPZ5_cjs.getAllNormalizedVtxos(
|
|
9969
10138
|
this.config.indexerProvider,
|
|
9970
10139
|
contracts.map((c) => c.script),
|
|
9971
10140
|
{ ...windowOpts, pageSize }
|
|
@@ -10132,7 +10301,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
10132
10301
|
*/
|
|
10133
10302
|
materializeDescriptorAt(index) {
|
|
10134
10303
|
const descriptor = this.identity.descriptor;
|
|
10135
|
-
const network =
|
|
10304
|
+
const network = chunkCOLJARV4_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
10136
10305
|
const expansion = descriptorsScure.expand({ descriptor, network, index });
|
|
10137
10306
|
const keyInfo = expansion.expansionMap?.["@0"];
|
|
10138
10307
|
if (!keyInfo?.keyExpression) {
|
|
@@ -10276,7 +10445,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
10276
10445
|
const provider = await resolveDescriptorProvider(config, setup.walletRepository);
|
|
10277
10446
|
if (!provider) return void 0;
|
|
10278
10447
|
const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
|
|
10279
|
-
const expectedContractType = setup.offchainTapscript instanceof
|
|
10448
|
+
const expectedContractType = setup.offchainTapscript instanceof chunkCOLJARV4_cjs.DelegateVtxo.Script ? "delegate" : "default";
|
|
10280
10449
|
const factoryOpts = {
|
|
10281
10450
|
walletRepository: setup.walletRepository,
|
|
10282
10451
|
contractRepository: setup.contractRepository,
|
|
@@ -10475,7 +10644,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
10475
10644
|
};
|
|
10476
10645
|
function deriveLeafPubkey(descriptor) {
|
|
10477
10646
|
try {
|
|
10478
|
-
return
|
|
10647
|
+
return chunkCOLJARV4_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
10479
10648
|
} catch (e) {
|
|
10480
10649
|
throw new NonRangeableDescriptorError(
|
|
10481
10650
|
"Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
|
|
@@ -10487,7 +10656,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
10487
10656
|
const pubKey = deriveLeafPubkey(descriptor);
|
|
10488
10657
|
const tapscript = rebuildTapscript(current, pubKey);
|
|
10489
10658
|
const serverPubKey = tapscript.options.serverPubKey;
|
|
10490
|
-
const csvTimelock =
|
|
10659
|
+
const csvTimelock = chunkD6RGHPZ5_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
|
|
10491
10660
|
const base$1 = {
|
|
10492
10661
|
script: base.hex.encode(tapscript.pkScript),
|
|
10493
10662
|
address: tapscript.address(hrp, serverPubKey).encode(),
|
|
@@ -10498,11 +10667,11 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
10498
10667
|
// index-0 key. Without it, spends produce unsigned PSBTs that the
|
|
10499
10668
|
// server rejects with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
10500
10669
|
metadata: {
|
|
10501
|
-
...{ source:
|
|
10670
|
+
...{ source: chunkCOLJARV4_cjs.WALLET_RECEIVE_SOURCE },
|
|
10502
10671
|
signingDescriptor: descriptor
|
|
10503
10672
|
}
|
|
10504
10673
|
};
|
|
10505
|
-
const params = tapscript instanceof
|
|
10674
|
+
const params = tapscript instanceof chunkCOLJARV4_cjs.DelegateVtxo.Script ? {
|
|
10506
10675
|
...base$1,
|
|
10507
10676
|
type: "delegate",
|
|
10508
10677
|
params: {
|
|
@@ -10523,10 +10692,10 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
10523
10692
|
return { tapscript, params };
|
|
10524
10693
|
}
|
|
10525
10694
|
function rebuildTapscript(current, pubKey) {
|
|
10526
|
-
if (current instanceof
|
|
10527
|
-
return new
|
|
10695
|
+
if (current instanceof chunkCOLJARV4_cjs.DelegateVtxo.Script) {
|
|
10696
|
+
return new chunkCOLJARV4_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
|
|
10528
10697
|
}
|
|
10529
|
-
return new
|
|
10698
|
+
return new chunkCOLJARV4_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
|
|
10530
10699
|
}
|
|
10531
10700
|
async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
|
|
10532
10701
|
const candidates = await contractRepository.getContracts({
|
|
@@ -10535,7 +10704,7 @@ async function pickActiveReceive(contractRepository, serverPubKey, expectedType)
|
|
|
10535
10704
|
});
|
|
10536
10705
|
const serverPubKeyHex = base.hex.encode(serverPubKey);
|
|
10537
10706
|
const matching = candidates.filter(
|
|
10538
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
10707
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkCOLJARV4_cjs.WALLET_RECEIVE_SOURCE
|
|
10539
10708
|
).sort((a, b) => {
|
|
10540
10709
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
10541
10710
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -10711,12 +10880,12 @@ var InputSignerRouter = class {
|
|
|
10711
10880
|
};
|
|
10712
10881
|
|
|
10713
10882
|
// src/wallet/wallet.ts
|
|
10714
|
-
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl ||
|
|
10883
|
+
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl || chunkD6RGHPZ5_cjs.DEFAULT_ARKADE_SERVER_URL;
|
|
10715
10884
|
function intentProofJobs(coins) {
|
|
10716
10885
|
if (coins.length === 0) return [];
|
|
10717
10886
|
const coinJobs = coins.map((coin, i) => ({
|
|
10718
10887
|
index: i + 1,
|
|
10719
|
-
lookupScript:
|
|
10888
|
+
lookupScript: chunkD6RGHPZ5_cjs.VtxoScript.decode(coin.tapTree).pkScript
|
|
10720
10889
|
}));
|
|
10721
10890
|
return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
|
|
10722
10891
|
}
|
|
@@ -10741,7 +10910,7 @@ function dedupeTimelocks(timelocks) {
|
|
|
10741
10910
|
const seen = /* @__PURE__ */ new Set();
|
|
10742
10911
|
const deduped = [];
|
|
10743
10912
|
for (const timelock of timelocks) {
|
|
10744
|
-
const sequence =
|
|
10913
|
+
const sequence = chunkD6RGHPZ5_cjs.timelockToSequence(timelock).toString();
|
|
10745
10914
|
if (seen.has(sequence)) continue;
|
|
10746
10915
|
seen.add(sequence);
|
|
10747
10916
|
deduped.push(timelock);
|
|
@@ -10758,7 +10927,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
10758
10927
|
state: "active"
|
|
10759
10928
|
});
|
|
10760
10929
|
const newest = candidates.filter(
|
|
10761
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
10930
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkCOLJARV4_cjs.WALLET_RECEIVE_SOURCE
|
|
10762
10931
|
).sort((a, b) => {
|
|
10763
10932
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
10764
10933
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -10766,7 +10935,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
10766
10935
|
if (!newest?.params.pubKey) return baseline;
|
|
10767
10936
|
try {
|
|
10768
10937
|
const pubKey = base.hex.decode(newest.params.pubKey);
|
|
10769
|
-
return new
|
|
10938
|
+
return new chunkCOLJARV4_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
|
|
10770
10939
|
} catch (e) {
|
|
10771
10940
|
console.warn("Skipping malformed boarding contract at boot", newest.script, e);
|
|
10772
10941
|
return baseline;
|
|
@@ -11100,7 +11269,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11100
11269
|
*/
|
|
11101
11270
|
static async setupWalletConfig(config, pubKey) {
|
|
11102
11271
|
const arkadeServerUrl = getArkadeServerUrl(config);
|
|
11103
|
-
const arkProvider = config.arkProvider || new
|
|
11272
|
+
const arkProvider = config.arkProvider || new chunkD6RGHPZ5_cjs.RestArkProvider(arkadeServerUrl);
|
|
11104
11273
|
let indexerProvider = config.indexerProvider;
|
|
11105
11274
|
if (!indexerProvider) {
|
|
11106
11275
|
let indexerUrl = config.indexerUrl;
|
|
@@ -11117,7 +11286,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11117
11286
|
indexerUrl = arkadeServerUrl;
|
|
11118
11287
|
}
|
|
11119
11288
|
}
|
|
11120
|
-
indexerProvider = new
|
|
11289
|
+
indexerProvider = new chunkF4C67JYB_cjs.RestIndexerProvider(indexerUrl);
|
|
11121
11290
|
}
|
|
11122
11291
|
const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
11123
11292
|
const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
@@ -11126,7 +11295,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11126
11295
|
source: serverInfoSource,
|
|
11127
11296
|
lastOnlineAt: serverInfoLastOnlineAt
|
|
11128
11297
|
} = await resolveArkInfo(arkProvider, walletRepository);
|
|
11129
|
-
const network =
|
|
11298
|
+
const network = chunkD6RGHPZ5_cjs.getNetwork(info.network);
|
|
11130
11299
|
if ("descriptor" in config.identity) {
|
|
11131
11300
|
const descriptor = config.identity.descriptor;
|
|
11132
11301
|
const identityIsMainnet = !descriptor.includes("tpub");
|
|
@@ -11173,11 +11342,11 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11173
11342
|
serverPubKey,
|
|
11174
11343
|
csvTimelock: exitTimelock
|
|
11175
11344
|
};
|
|
11176
|
-
const offchainTapscript = !delegatePubKey ? new
|
|
11177
|
-
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({
|
|
11178
11347
|
pubKey: base.hex.encode(pubKey),
|
|
11179
11348
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
11180
|
-
csvTimelock:
|
|
11349
|
+
csvTimelock: chunkD6RGHPZ5_cjs.timelockToSequence(boardingTimelock).toString()
|
|
11181
11350
|
});
|
|
11182
11351
|
return {
|
|
11183
11352
|
arkProvider,
|
|
@@ -11283,19 +11452,19 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11283
11452
|
let pendingRecovery = 0;
|
|
11284
11453
|
const now = { timestamp: /* @__PURE__ */ new Date() };
|
|
11285
11454
|
const settled = vtxos.filter(
|
|
11286
|
-
(coin) =>
|
|
11455
|
+
(coin) => chunkD6RGHPZ5_cjs.canSpendOffchain(coin, now) && !coin.isPreconfirmed && !isPendingRecovery(coin)
|
|
11287
11456
|
).reduce((sum, coin) => sum + coin.value, 0);
|
|
11288
11457
|
const preconfirmed = vtxos.filter(
|
|
11289
|
-
(coin) =>
|
|
11458
|
+
(coin) => chunkD6RGHPZ5_cjs.canSpendOffchain(coin, now) && coin.isPreconfirmed && !isPendingRecovery(coin)
|
|
11290
11459
|
).reduce((sum, coin) => sum + coin.value, 0);
|
|
11291
|
-
const available = unlockedVtxos.filter((coin) =>
|
|
11292
|
-
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);
|
|
11293
11462
|
pendingRecovery = vtxos.filter(isPendingRecovery).reduce((sum, coin) => sum + coin.value, 0);
|
|
11294
11463
|
const totalBoarding = confirmed + unconfirmed;
|
|
11295
11464
|
const totalOffchain = settled + preconfirmed + recoverable + pendingRecovery;
|
|
11296
11465
|
const assetBalances = /* @__PURE__ */ new Map();
|
|
11297
11466
|
for (const vtxo of vtxos) {
|
|
11298
|
-
if (
|
|
11467
|
+
if (chunkD6RGHPZ5_cjs.hasTerminalSpend(vtxo)) continue;
|
|
11299
11468
|
if (vtxo.assets) {
|
|
11300
11469
|
for (const a of vtxo.assets) {
|
|
11301
11470
|
const current = assetBalances.get(a.assetId) ?? 0n;
|
|
@@ -11336,8 +11505,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11336
11505
|
if (this._pendingSpendOutpoints.has(`${vtxo.txid}:${vtxo.vout}`)) {
|
|
11337
11506
|
return false;
|
|
11338
11507
|
}
|
|
11339
|
-
if (!
|
|
11340
|
-
if (!f.withRecoverable &&
|
|
11508
|
+
if (!chunkD6RGHPZ5_cjs.hasTerminalSpend(vtxo)) {
|
|
11509
|
+
if (!f.withRecoverable && chunkD6RGHPZ5_cjs.canRecoverOnchain(vtxo, now)) {
|
|
11341
11510
|
return false;
|
|
11342
11511
|
}
|
|
11343
11512
|
return true;
|
|
@@ -11370,7 +11539,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11370
11539
|
const response = await contractManager.getContractsWithVtxos();
|
|
11371
11540
|
const allVtxos = response.flatMap((_) => _.vtxos);
|
|
11372
11541
|
const { boardingTxs, commitmentsToIgnore } = await this.getBoardingTxs();
|
|
11373
|
-
const resolveTxCreatedAt = (txids) =>
|
|
11542
|
+
const resolveTxCreatedAt = (txids) => chunkD6RGHPZ5_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
|
|
11374
11543
|
return buildTransactionHistory(
|
|
11375
11544
|
allVtxos,
|
|
11376
11545
|
boardingTxs,
|
|
@@ -11464,7 +11633,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11464
11633
|
},
|
|
11465
11634
|
isUnrolled: true,
|
|
11466
11635
|
...boardingFacts,
|
|
11467
|
-
virtualStatus:
|
|
11636
|
+
virtualStatus: chunkD6RGHPZ5_cjs.toVirtualStatus(boardingFacts),
|
|
11468
11637
|
spentBy: "",
|
|
11469
11638
|
createdAt: tx.status.confirmed ? new Date(tx.status.block_time * 1e3) : /* @__PURE__ */ new Date(0),
|
|
11470
11639
|
script: scriptHex
|
|
@@ -11520,9 +11689,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11520
11689
|
async getBoardingTapscripts(allowedSigners) {
|
|
11521
11690
|
const byScript = /* @__PURE__ */ new Map();
|
|
11522
11691
|
const add = (s) => byScript.set(base.hex.encode(s.pkScript), s);
|
|
11523
|
-
const boardingCsv = this.boardingTapscript.options.csvTimelock ??
|
|
11692
|
+
const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkCOLJARV4_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
11524
11693
|
add(
|
|
11525
|
-
new
|
|
11694
|
+
new chunkCOLJARV4_cjs.DefaultVtxo.Script({
|
|
11526
11695
|
pubKey: await this.identity.xOnlyPublicKey(),
|
|
11527
11696
|
serverPubKey: this.boardingTapscript.options.serverPubKey,
|
|
11528
11697
|
csvTimelock: boardingCsv
|
|
@@ -11537,7 +11706,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11537
11706
|
for (const c of boardingContracts) {
|
|
11538
11707
|
if (!allowed.has(toXOnlySignerHex(c.params.serverPubKey))) continue;
|
|
11539
11708
|
try {
|
|
11540
|
-
add(
|
|
11709
|
+
add(chunkCOLJARV4_cjs.BoardingContractHandler.createScript(c.params));
|
|
11541
11710
|
} catch (e) {
|
|
11542
11711
|
console.warn("Skipping malformed boarding contract", c.script, e);
|
|
11543
11712
|
}
|
|
@@ -11575,7 +11744,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11575
11744
|
// Per-row CSV delay decoded from THIS tapscript's exit leaf —
|
|
11576
11745
|
// not the wallet's current boarding timelock, which a signer
|
|
11577
11746
|
// rotation may have changed.
|
|
11578
|
-
csvTimelock:
|
|
11747
|
+
csvTimelock: chunkD6RGHPZ5_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
|
|
11579
11748
|
coins: utxos
|
|
11580
11749
|
});
|
|
11581
11750
|
}
|
|
@@ -11708,7 +11877,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11708
11877
|
/** Fetch Arkade transaction ids that are still pending final settlement. */
|
|
11709
11878
|
async fetchPendingTxs() {
|
|
11710
11879
|
const scripts = await this.getWalletScripts();
|
|
11711
|
-
const vtxos = await
|
|
11880
|
+
const vtxos = await chunkD6RGHPZ5_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
|
|
11712
11881
|
return vtxos.filter(
|
|
11713
11882
|
(vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
|
|
11714
11883
|
).map((_) => _.arkTxId);
|
|
@@ -11739,7 +11908,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11739
11908
|
});
|
|
11740
11909
|
for (const contract of contracts) {
|
|
11741
11910
|
if (map.has(contract.script)) continue;
|
|
11742
|
-
const handler =
|
|
11911
|
+
const handler = chunkCOLJARV4_cjs.contractHandlers.get(contract.type);
|
|
11743
11912
|
if (handler) {
|
|
11744
11913
|
const script = handler.createScript(contract.params);
|
|
11745
11914
|
map.set(contract.script, script);
|
|
@@ -11842,7 +12011,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11842
12011
|
lookAhead: this.lookAheadConfig()
|
|
11843
12012
|
});
|
|
11844
12013
|
const baselinePubkey = await this.identity.xOnlyPublicKey();
|
|
11845
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
12014
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkCOLJARV4_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
11846
12015
|
const baselineSigners = [
|
|
11847
12016
|
this.offchainTapscript.options.serverPubKey,
|
|
11848
12017
|
...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
|
|
@@ -11850,8 +12019,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11850
12019
|
const seenBaselineScripts = /* @__PURE__ */ new Set();
|
|
11851
12020
|
for (const serverPubKey of baselineSigners) {
|
|
11852
12021
|
for (const csvTimelock of this.walletContractTimelocks) {
|
|
11853
|
-
const csvTimelockStr =
|
|
11854
|
-
const defaultScript = new
|
|
12022
|
+
const csvTimelockStr = chunkD6RGHPZ5_cjs.timelockToSequence(csvTimelock).toString();
|
|
12023
|
+
const defaultScript = new chunkCOLJARV4_cjs.DefaultVtxo.Script({
|
|
11855
12024
|
pubKey: baselinePubkey,
|
|
11856
12025
|
serverPubKey,
|
|
11857
12026
|
csvTimelock
|
|
@@ -11872,7 +12041,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11872
12041
|
});
|
|
11873
12042
|
}
|
|
11874
12043
|
if (delegatePubKey) {
|
|
11875
|
-
const delegateScript = new
|
|
12044
|
+
const delegateScript = new chunkCOLJARV4_cjs.DelegateVtxo.Script({
|
|
11876
12045
|
pubKey: baselinePubkey,
|
|
11877
12046
|
serverPubKey,
|
|
11878
12047
|
delegatePubKey,
|
|
@@ -11896,9 +12065,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11896
12065
|
}
|
|
11897
12066
|
}
|
|
11898
12067
|
}
|
|
11899
|
-
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ??
|
|
12068
|
+
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkCOLJARV4_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
11900
12069
|
for (const serverPubKey of baselineSigners) {
|
|
11901
|
-
const baselineBoarding = new
|
|
12070
|
+
const baselineBoarding = new chunkCOLJARV4_cjs.DefaultVtxo.Script({
|
|
11902
12071
|
pubKey: baselinePubkey,
|
|
11903
12072
|
serverPubKey,
|
|
11904
12073
|
csvTimelock: boardingCsvTimelock
|
|
@@ -11911,7 +12080,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11911
12080
|
params: {
|
|
11912
12081
|
pubKey: base.hex.encode(baselineBoarding.options.pubKey),
|
|
11913
12082
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
11914
|
-
csvTimelock:
|
|
12083
|
+
csvTimelock: chunkD6RGHPZ5_cjs.timelockToSequence(boardingCsvTimelock).toString()
|
|
11915
12084
|
},
|
|
11916
12085
|
script: boardingScriptHex,
|
|
11917
12086
|
address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
|
|
@@ -11933,7 +12102,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11933
12102
|
}
|
|
11934
12103
|
};
|
|
11935
12104
|
var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
11936
|
-
constructor(identity, network, onchainProvider, arkProvider, indexerProvider, arkServerPublicKey, offchainTapscript, boardingTapscript, serverUnrollScript, forfeitOutputScript, forfeitPubkey, dustAmount, walletRepository, contractRepository, renewalConfig, delegateProvider, watcherConfig, settlementConfig, walletContractTimelocks, receiveRotator, descriptorProvider, lookAheadWindow) {
|
|
12105
|
+
constructor(identity, network, onchainProvider, arkProvider, indexerProvider, arkServerPublicKey, offchainTapscript, boardingTapscript, serverUnrollScript, forfeitOutputScript, forfeitPubkey, dustAmount, walletRepository, contractRepository, renewalConfig, delegateProvider, watcherConfig, settlementConfig, walletContractTimelocks, receiveRotator, descriptorProvider, lookAheadWindow, batchExpiryPolicy, checkpointExitDelayPolicy) {
|
|
11937
12106
|
super(
|
|
11938
12107
|
identity,
|
|
11939
12108
|
network,
|
|
@@ -11952,6 +12121,8 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
11952
12121
|
this.arkProvider = arkProvider;
|
|
11953
12122
|
this.forfeitOutputScript = forfeitOutputScript;
|
|
11954
12123
|
this.forfeitPubkey = forfeitPubkey;
|
|
12124
|
+
this.batchExpiryPolicy = batchExpiryPolicy;
|
|
12125
|
+
this.checkpointExitDelayPolicy = checkpointExitDelayPolicy;
|
|
11955
12126
|
this.identity = identity;
|
|
11956
12127
|
this.renewalConfig = {
|
|
11957
12128
|
enabled: renewalConfig?.enabled ?? false,
|
|
@@ -11984,6 +12155,8 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
11984
12155
|
arkProvider;
|
|
11985
12156
|
forfeitOutputScript;
|
|
11986
12157
|
forfeitPubkey;
|
|
12158
|
+
batchExpiryPolicy;
|
|
12159
|
+
checkpointExitDelayPolicy;
|
|
11987
12160
|
static MIN_FEE_RATE = 1;
|
|
11988
12161
|
// sats/vbyte
|
|
11989
12162
|
identity;
|
|
@@ -12085,7 +12258,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12085
12258
|
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
12086
12259
|
deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
|
|
12087
12260
|
csvTimelocks: this.walletContractTimelocks,
|
|
12088
|
-
delegatePubKey: this.offchainTapscript instanceof
|
|
12261
|
+
delegatePubKey: this.offchainTapscript instanceof chunkCOLJARV4_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
|
|
12089
12262
|
};
|
|
12090
12263
|
}
|
|
12091
12264
|
_signerRouter;
|
|
@@ -12177,25 +12350,25 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12177
12350
|
return this.getBoardingAddress();
|
|
12178
12351
|
}
|
|
12179
12352
|
const descriptor = await provider.getNextSigningDescriptor();
|
|
12180
|
-
const pubKey =
|
|
12181
|
-
const newBoarding = new
|
|
12353
|
+
const pubKey = chunkCOLJARV4_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
12354
|
+
const newBoarding = new chunkCOLJARV4_cjs.DefaultVtxo.Script({
|
|
12182
12355
|
...this._boardingTapscript.options,
|
|
12183
12356
|
pubKey
|
|
12184
12357
|
});
|
|
12185
|
-
const csvTimelock = newBoarding.options.csvTimelock ??
|
|
12358
|
+
const csvTimelock = newBoarding.options.csvTimelock ?? chunkCOLJARV4_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
12186
12359
|
const manager = await this.getContractManager();
|
|
12187
12360
|
await manager.createContract({
|
|
12188
12361
|
type: "boarding",
|
|
12189
12362
|
params: {
|
|
12190
12363
|
pubKey: base.hex.encode(pubKey),
|
|
12191
12364
|
serverPubKey: base.hex.encode(newBoarding.options.serverPubKey),
|
|
12192
|
-
csvTimelock:
|
|
12365
|
+
csvTimelock: chunkD6RGHPZ5_cjs.timelockToSequence(csvTimelock).toString()
|
|
12193
12366
|
},
|
|
12194
12367
|
script: base.hex.encode(newBoarding.pkScript),
|
|
12195
12368
|
address: newBoarding.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
12196
12369
|
state: "active",
|
|
12197
12370
|
metadata: {
|
|
12198
|
-
source:
|
|
12371
|
+
source: chunkCOLJARV4_cjs.WALLET_RECEIVE_SOURCE,
|
|
12199
12372
|
signingDescriptor: descriptor
|
|
12200
12373
|
}
|
|
12201
12374
|
});
|
|
@@ -12282,12 +12455,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12282
12455
|
*/
|
|
12283
12456
|
async rotateServerSigner(newServerPubKey, checkpointTapscript) {
|
|
12284
12457
|
const xonly = toXOnlyPubKey(newServerPubKey);
|
|
12285
|
-
|
|
12286
|
-
|
|
12287
|
-
|
|
12288
|
-
|
|
12289
|
-
throw new Error("Invalid checkpointTapscript from server");
|
|
12290
|
-
}
|
|
12458
|
+
const newServerUnrollScript = assertValidServerUnrollScript(
|
|
12459
|
+
checkpointTapscript,
|
|
12460
|
+
resolveCheckpointExitDelayPolicy(this.network, this.checkpointExitDelayPolicy)
|
|
12461
|
+
);
|
|
12291
12462
|
if (utils_js.equalBytes(xonly, this.arkServerPublicKey)) return;
|
|
12292
12463
|
if (this._receiveRotator) {
|
|
12293
12464
|
await this._receiveRotator.runExclusive(
|
|
@@ -12312,21 +12483,21 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12312
12483
|
const [currentBoardingRow] = await manager.getContracts({
|
|
12313
12484
|
script: currentBoardingScript
|
|
12314
12485
|
});
|
|
12315
|
-
const newOffchain = this.offchainTapscript instanceof
|
|
12486
|
+
const newOffchain = this.offchainTapscript instanceof chunkCOLJARV4_cjs.DelegateVtxo.Script ? new chunkCOLJARV4_cjs.DelegateVtxo.Script({
|
|
12316
12487
|
...this.offchainTapscript.options,
|
|
12317
12488
|
serverPubKey: xonly
|
|
12318
|
-
}) : new
|
|
12489
|
+
}) : new chunkCOLJARV4_cjs.DefaultVtxo.Script({
|
|
12319
12490
|
...this.offchainTapscript.options,
|
|
12320
12491
|
serverPubKey: xonly
|
|
12321
12492
|
});
|
|
12322
|
-
const newBoarding = new
|
|
12493
|
+
const newBoarding = new chunkCOLJARV4_cjs.DefaultVtxo.Script({
|
|
12323
12494
|
...this._boardingTapscript.options,
|
|
12324
12495
|
serverPubKey: xonly
|
|
12325
12496
|
});
|
|
12326
|
-
const offchainCsv =
|
|
12497
|
+
const offchainCsv = chunkD6RGHPZ5_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
|
|
12327
12498
|
const newOffchainScript = base.hex.encode(newOffchain.pkScript);
|
|
12328
12499
|
const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
|
|
12329
|
-
if (newOffchain instanceof
|
|
12500
|
+
if (newOffchain instanceof chunkCOLJARV4_cjs.DelegateVtxo.Script) {
|
|
12330
12501
|
await manager.createContract({
|
|
12331
12502
|
type: "delegate",
|
|
12332
12503
|
params: {
|
|
@@ -12354,13 +12525,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12354
12525
|
metadata: currentOffchainRow?.metadata
|
|
12355
12526
|
});
|
|
12356
12527
|
}
|
|
12357
|
-
const boardingCsv = newBoarding.options.csvTimelock ??
|
|
12528
|
+
const boardingCsv = newBoarding.options.csvTimelock ?? chunkCOLJARV4_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
12358
12529
|
await manager.createContract({
|
|
12359
12530
|
type: "boarding",
|
|
12360
12531
|
params: {
|
|
12361
12532
|
pubKey: base.hex.encode(newBoarding.options.pubKey),
|
|
12362
12533
|
serverPubKey: base.hex.encode(xonly),
|
|
12363
|
-
csvTimelock:
|
|
12534
|
+
csvTimelock: chunkD6RGHPZ5_cjs.timelockToSequence(boardingCsv).toString()
|
|
12364
12535
|
},
|
|
12365
12536
|
script: base.hex.encode(newBoarding.pkScript),
|
|
12366
12537
|
address: newBoarding.address(this.network.hrp, xonly).encode(),
|
|
@@ -12393,14 +12564,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12393
12564
|
_restoreInFlight;
|
|
12394
12565
|
_addPendingSpends(inputs) {
|
|
12395
12566
|
for (const input of inputs) {
|
|
12396
|
-
if (
|
|
12567
|
+
if (chunkD6RGHPZ5_cjs.isVirtualCoin(input)) {
|
|
12397
12568
|
this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
|
|
12398
12569
|
}
|
|
12399
12570
|
}
|
|
12400
12571
|
}
|
|
12401
12572
|
_removePendingSpends(inputs) {
|
|
12402
12573
|
for (const input of inputs) {
|
|
12403
|
-
if (
|
|
12574
|
+
if (chunkD6RGHPZ5_cjs.isVirtualCoin(input)) {
|
|
12404
12575
|
this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
|
|
12405
12576
|
}
|
|
12406
12577
|
}
|
|
@@ -12460,7 +12631,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12460
12631
|
const hd = provider instanceof HDDescriptorProvider;
|
|
12461
12632
|
const staticDescriptor = hd ? void 0 : `tr(${base.hex.encode(await this.identity.xOnlyPublicKey())})`;
|
|
12462
12633
|
const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
|
|
12463
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
12634
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkCOLJARV4_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
12464
12635
|
const arkInfo = await this.arkProvider.getInfo();
|
|
12465
12636
|
const currentSignerPubKey = toXOnlyPubKey(base.hex.decode(arkInfo.signerPubkey));
|
|
12466
12637
|
const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
|
|
@@ -12479,7 +12650,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12479
12650
|
csvTimelocks: this.walletContractTimelocks,
|
|
12480
12651
|
// Boarding-exit CSV so the boarding handler can build its
|
|
12481
12652
|
// candidate script (distinct from the unilateral-exit matrix).
|
|
12482
|
-
boardingTimelock: this.boardingTapscript.options.csvTimelock ??
|
|
12653
|
+
boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkCOLJARV4_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
|
|
12483
12654
|
delegatePubKey
|
|
12484
12655
|
};
|
|
12485
12656
|
const result = await manager.scanContracts({
|
|
@@ -12593,16 +12764,17 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12593
12764
|
throw new Error("Invalid configured public key");
|
|
12594
12765
|
}
|
|
12595
12766
|
const setup = await ReadonlyWallet.setupWalletConfig(config, pubkey);
|
|
12596
|
-
let serverUnrollScript;
|
|
12597
|
-
try {
|
|
12598
|
-
const raw = base.hex.decode(setup.info.checkpointTapscript);
|
|
12599
|
-
serverUnrollScript = chunkCDWLZQQW_cjs.CSVMultisigTapscript.decode(raw);
|
|
12600
|
-
} catch (e) {
|
|
12601
|
-
throw new Error("Invalid checkpointTapscript from server");
|
|
12602
|
-
}
|
|
12603
12767
|
const forfeitPubkey = base.hex.decode(setup.info.forfeitPubkey).slice(1);
|
|
12604
12768
|
const forfeitAddress = btcSigner.Address(setup.network).decode(setup.info.forfeitAddress);
|
|
12605
12769
|
const forfeitOutputScript = btcSigner.OutScript.encode(forfeitAddress);
|
|
12770
|
+
const checkpointExitDelayOverrides = {
|
|
12771
|
+
advertisedForfeitPubkey: forfeitPubkey,
|
|
12772
|
+
...config.minCheckpointExitDelaySeconds !== void 0 ? { minSeconds: config.minCheckpointExitDelaySeconds } : {}
|
|
12773
|
+
};
|
|
12774
|
+
const serverUnrollScript = assertValidServerUnrollScript(
|
|
12775
|
+
setup.info.checkpointTapscript,
|
|
12776
|
+
resolveCheckpointExitDelayPolicy(setup.network, checkpointExitDelayOverrides)
|
|
12777
|
+
);
|
|
12606
12778
|
const boot = await WalletReceiveRotator.resolveBoot(config, setup);
|
|
12607
12779
|
const wallet = new _Wallet(
|
|
12608
12780
|
config.identity,
|
|
@@ -12626,7 +12798,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12626
12798
|
setup.walletContractTimelocks,
|
|
12627
12799
|
boot?.rotator,
|
|
12628
12800
|
boot?.provider,
|
|
12629
|
-
config.lookAheadWindow
|
|
12801
|
+
config.lookAheadWindow,
|
|
12802
|
+
// Pinned at setup rather than refetched per round.
|
|
12803
|
+
{
|
|
12804
|
+
advertisedVtxoTreeExpiry: setup.info.vtxoTreeExpiry,
|
|
12805
|
+
...config.minBatchExpirySeconds !== void 0 ? { minSeconds: config.minBatchExpirySeconds } : {}
|
|
12806
|
+
},
|
|
12807
|
+
checkpointExitDelayOverrides
|
|
12630
12808
|
);
|
|
12631
12809
|
wallet._serverInfoSource = setup.serverInfoSource;
|
|
12632
12810
|
if (setup.serverInfoSource === "live") {
|
|
@@ -12734,7 +12912,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12734
12912
|
inputs: params.selectedVtxos,
|
|
12735
12913
|
changeAmount: BigInt(changeAmount)
|
|
12736
12914
|
};
|
|
12737
|
-
const outputAddress =
|
|
12915
|
+
const outputAddress = chunkD6RGHPZ5_cjs.ArkAddress.decode(params.address);
|
|
12738
12916
|
assertRecipientArkAddress(
|
|
12739
12917
|
params.address,
|
|
12740
12918
|
outputAddress,
|
|
@@ -12792,13 +12970,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12792
12970
|
}
|
|
12793
12971
|
}
|
|
12794
12972
|
const offchainAddress = await this.getAddress();
|
|
12795
|
-
const offchainPkScript =
|
|
12973
|
+
const offchainPkScript = chunkD6RGHPZ5_cjs.ArkAddress.decode(offchainAddress).pkScript;
|
|
12796
12974
|
const offchainOutputScript = base.hex.encode(offchainPkScript);
|
|
12797
12975
|
if (!params) {
|
|
12798
12976
|
const { fees, vtxoMaxAmount } = await this.arkProvider.getInfo();
|
|
12799
12977
|
const estimator = new Estimator(fees.intentFee);
|
|
12800
12978
|
let amount = 0;
|
|
12801
|
-
const exitScript =
|
|
12979
|
+
const exitScript = chunkD6RGHPZ5_cjs.CSVMultisigTapscript.decode(
|
|
12802
12980
|
base.hex.decode(this.boardingTapscript.exitScript)
|
|
12803
12981
|
);
|
|
12804
12982
|
const boardingTimelock = exitScript.params.timelock;
|
|
@@ -12827,7 +13005,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12827
13005
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
12828
13006
|
break;
|
|
12829
13007
|
}
|
|
12830
|
-
const inputFee = estimator.evalOffchainInput(
|
|
13008
|
+
const inputFee = estimator.evalOffchainInput(chunkD6RGHPZ5_cjs.toOffchainInputFeeParams(vtxo));
|
|
12831
13009
|
if (inputFee.satoshis >= vtxo.value) {
|
|
12832
13010
|
continue;
|
|
12833
13011
|
}
|
|
@@ -12874,7 +13052,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12874
13052
|
let script;
|
|
12875
13053
|
let arkAddress;
|
|
12876
13054
|
try {
|
|
12877
|
-
arkAddress =
|
|
13055
|
+
arkAddress = chunkD6RGHPZ5_cjs.ArkAddress.decode(output.address);
|
|
12878
13056
|
} catch {
|
|
12879
13057
|
arkAddress = void 0;
|
|
12880
13058
|
}
|
|
@@ -13066,7 +13244,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13066
13244
|
async maybeRotateBoardingAfterBoard(inputs) {
|
|
13067
13245
|
if (!this._descriptorProvider) return;
|
|
13068
13246
|
const consumedBoarding = inputs.some(
|
|
13069
|
-
(input) => typeof input !== "string" && !
|
|
13247
|
+
(input) => typeof input !== "string" && !chunkD6RGHPZ5_cjs.isVirtualCoin(input)
|
|
13070
13248
|
);
|
|
13071
13249
|
if (!consumedBoarding) return;
|
|
13072
13250
|
try {
|
|
@@ -13090,7 +13268,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13090
13268
|
let connectorIndex = 0;
|
|
13091
13269
|
const connectorsLeaves = connectorsGraph?.leaves() || [];
|
|
13092
13270
|
for (const input of inputs) {
|
|
13093
|
-
if (!
|
|
13271
|
+
if (!chunkD6RGHPZ5_cjs.isVirtualCoin(input)) {
|
|
13094
13272
|
for (let i = 0; i < settlementPsbt.inputsLength; i++) {
|
|
13095
13273
|
const settlementInput = settlementPsbt.getInput(i);
|
|
13096
13274
|
if (!settlementInput.txid || settlementInput.index === void 0) {
|
|
@@ -13121,7 +13299,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13121
13299
|
}
|
|
13122
13300
|
continue;
|
|
13123
13301
|
}
|
|
13124
|
-
if (
|
|
13302
|
+
if (chunkD6RGHPZ5_cjs.canRecoverOnchain(input, { timestamp: /* @__PURE__ */ new Date() }) || isSubdust({ value: input.value }, this.dustAmount)) {
|
|
13125
13303
|
continue;
|
|
13126
13304
|
}
|
|
13127
13305
|
if (connectorsLeaves.length === 0) {
|
|
@@ -13149,7 +13327,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13149
13327
|
index: input.vout,
|
|
13150
13328
|
witnessUtxo: {
|
|
13151
13329
|
amount: BigInt(input.value),
|
|
13152
|
-
script:
|
|
13330
|
+
script: chunkD6RGHPZ5_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
13153
13331
|
},
|
|
13154
13332
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
13155
13333
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -13168,7 +13346,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13168
13346
|
forfeitTx = await this._signerRouter.sign(forfeitTx, [
|
|
13169
13347
|
{
|
|
13170
13348
|
index: 0,
|
|
13171
|
-
lookupScript:
|
|
13349
|
+
lookupScript: chunkD6RGHPZ5_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
13172
13350
|
}
|
|
13173
13351
|
]);
|
|
13174
13352
|
signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
|
|
@@ -13214,24 +13392,20 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13214
13392
|
const utf8IntentId = new TextEncoder().encode(intentId);
|
|
13215
13393
|
const intentIdHash = utils_js.sha256(utf8IntentId);
|
|
13216
13394
|
const intentIdHashStr = base.hex.encode(intentIdHash);
|
|
13217
|
-
|
|
13218
|
-
for (const idHash of event.intentIdHashes) {
|
|
13219
|
-
if (idHash === intentIdHashStr) {
|
|
13220
|
-
if (!this.arkProvider) {
|
|
13221
|
-
throw new Error("Arkade provider not configured");
|
|
13222
|
-
}
|
|
13223
|
-
await this.arkProvider.confirmRegistration(intentId);
|
|
13224
|
-
skip = false;
|
|
13225
|
-
}
|
|
13226
|
-
}
|
|
13395
|
+
const skip = !event.intentIdHashes.includes(intentIdHashStr);
|
|
13227
13396
|
if (skip) {
|
|
13228
13397
|
return { skip };
|
|
13229
13398
|
}
|
|
13230
|
-
|
|
13231
|
-
|
|
13232
|
-
|
|
13233
|
-
|
|
13234
|
-
|
|
13399
|
+
if (!this.arkProvider) {
|
|
13400
|
+
throw new Error("Arkade provider not configured");
|
|
13401
|
+
}
|
|
13402
|
+
const timelock = assertValidBatchExpiry(
|
|
13403
|
+
event.batchExpiry,
|
|
13404
|
+
resolveBatchExpiryPolicy(this.network, this.batchExpiryPolicy)
|
|
13405
|
+
);
|
|
13406
|
+
await this.arkProvider.confirmRegistration(intentId);
|
|
13407
|
+
const sweepTapscript = chunkD6RGHPZ5_cjs.CSVMultisigTapscript.encode({
|
|
13408
|
+
timelock,
|
|
13235
13409
|
pubkeys: [this.forfeitPubkey]
|
|
13236
13410
|
}).script;
|
|
13237
13411
|
sweepTapTreeRoot = payment_js.tapLeafHash(sweepTapscript);
|
|
@@ -13336,9 +13510,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13336
13510
|
...existing ?? {},
|
|
13337
13511
|
intentTxId,
|
|
13338
13512
|
registerProof: intent.proof,
|
|
13339
|
-
registerProofMessage:
|
|
13513
|
+
registerProofMessage: chunkD6RGHPZ5_cjs.Intent.encodeMessage(intent.message),
|
|
13340
13514
|
deleteProof: deleteIntent.proof,
|
|
13341
|
-
deleteProofMessage:
|
|
13515
|
+
deleteProofMessage: chunkD6RGHPZ5_cjs.Intent.encodeMessage(deleteIntent.message),
|
|
13342
13516
|
intentVtxos: inputs.map((i) => ({
|
|
13343
13517
|
txid: i.txid,
|
|
13344
13518
|
vout: i.vout
|
|
@@ -13370,7 +13544,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13370
13544
|
try {
|
|
13371
13545
|
return await this.arkProvider.registerIntent(intent);
|
|
13372
13546
|
} catch (error) {
|
|
13373
|
-
if (error instanceof
|
|
13547
|
+
if (error instanceof chunkD6RGHPZ5_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
|
|
13374
13548
|
const deleteIntent = await this.makeDeleteIntentSignature(inputs);
|
|
13375
13549
|
await this.arkProvider.deleteIntent(deleteIntent);
|
|
13376
13550
|
return this.arkProvider.registerIntent(intent);
|
|
@@ -13386,7 +13560,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13386
13560
|
expire_at: 0,
|
|
13387
13561
|
cosigners_public_keys: cosignerPubKeys
|
|
13388
13562
|
};
|
|
13389
|
-
const proof =
|
|
13563
|
+
const proof = chunkD6RGHPZ5_cjs.Intent.create(message, coins, outputs);
|
|
13390
13564
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
13391
13565
|
return {
|
|
13392
13566
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -13398,7 +13572,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13398
13572
|
type: "delete",
|
|
13399
13573
|
expire_at: 0
|
|
13400
13574
|
};
|
|
13401
|
-
const proof =
|
|
13575
|
+
const proof = chunkD6RGHPZ5_cjs.Intent.create(message, coins, []);
|
|
13402
13576
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
13403
13577
|
return {
|
|
13404
13578
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -13410,7 +13584,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13410
13584
|
type: "get-pending-tx",
|
|
13411
13585
|
expire_at: 0
|
|
13412
13586
|
};
|
|
13413
|
-
const proof =
|
|
13587
|
+
const proof = chunkD6RGHPZ5_cjs.Intent.create(message, coins, []);
|
|
13414
13588
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
13415
13589
|
return {
|
|
13416
13590
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -13431,7 +13605,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13431
13605
|
if (!vtxos || vtxos.length === 0) {
|
|
13432
13606
|
const scriptMap = await this.getScriptMap();
|
|
13433
13607
|
const allExtended = [];
|
|
13434
|
-
const fetchedVtxos = await
|
|
13608
|
+
const fetchedVtxos = await chunkD6RGHPZ5_cjs.getAllNormalizedVtxos(this.indexerProvider, [
|
|
13435
13609
|
...scriptMap.keys()
|
|
13436
13610
|
]);
|
|
13437
13611
|
for (const vtxo of fetchedVtxos) {
|
|
@@ -13545,11 +13719,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13545
13719
|
* against the current key alone would leave it pending forever.
|
|
13546
13720
|
*/
|
|
13547
13721
|
checkpointUnrollCandidates(info) {
|
|
13548
|
-
const current =
|
|
13722
|
+
const current = chunkD6RGHPZ5_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
13549
13723
|
const candidates = [this._serverUnrollScript, current];
|
|
13550
13724
|
for (const deprecated of signerSetFromInfo(info).deprecated.keys()) {
|
|
13551
13725
|
candidates.push(
|
|
13552
|
-
|
|
13726
|
+
chunkD6RGHPZ5_cjs.CSVMultisigTapscript.encode({
|
|
13553
13727
|
...current.params,
|
|
13554
13728
|
pubkeys: [base.hex.decode(deprecated)]
|
|
13555
13729
|
})
|
|
@@ -13640,7 +13814,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13640
13814
|
if (vtxos.length === 0) {
|
|
13641
13815
|
throw new Error("No VTXOs found for this arkadeCash");
|
|
13642
13816
|
}
|
|
13643
|
-
const myPkScript =
|
|
13817
|
+
const myPkScript = chunkD6RGHPZ5_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
|
|
13644
13818
|
let { spendable, unclaimed } = this.classifyCashVtxos(vtxos);
|
|
13645
13819
|
let swept = 0;
|
|
13646
13820
|
const drainable = vtxos.filter((vtxo) => !isSubdust(vtxo, this.dustAmount));
|
|
@@ -13667,8 +13841,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13667
13841
|
}
|
|
13668
13842
|
if (spendable.length > 0) {
|
|
13669
13843
|
const info = await this.arkProvider.getInfo();
|
|
13670
|
-
const serverUnrollScript =
|
|
13671
|
-
|
|
13844
|
+
const serverUnrollScript = assertValidServerUnrollScript(
|
|
13845
|
+
info.checkpointTapscript,
|
|
13846
|
+
resolveCheckpointExitDelayPolicy(this.network, this.checkpointExitDelayPolicy)
|
|
13672
13847
|
);
|
|
13673
13848
|
for (const vtxo of spendable) {
|
|
13674
13849
|
try {
|
|
@@ -13713,7 +13888,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13713
13888
|
const spendable = [];
|
|
13714
13889
|
const unclaimed = [];
|
|
13715
13890
|
for (const vtxo of vtxos) {
|
|
13716
|
-
if (
|
|
13891
|
+
if (chunkD6RGHPZ5_cjs.hasTerminalSpend(vtxo)) {
|
|
13717
13892
|
unclaimed.push(cashReport(vtxo, "already-spent"));
|
|
13718
13893
|
} else if (isSubdust(vtxo, this.dustAmount)) {
|
|
13719
13894
|
unclaimed.push(cashReport(vtxo, "subdust"));
|
|
@@ -13733,7 +13908,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13733
13908
|
const all = [];
|
|
13734
13909
|
const seen = /* @__PURE__ */ new Set();
|
|
13735
13910
|
for (let pageIndex = 0; ; pageIndex++) {
|
|
13736
|
-
const { vtxos, page } = await
|
|
13911
|
+
const { vtxos, page } = await chunkD6RGHPZ5_cjs.getNormalizedVtxos(this.indexerProvider, {
|
|
13737
13912
|
scripts,
|
|
13738
13913
|
pageIndex,
|
|
13739
13914
|
pageSize
|
|
@@ -13780,7 +13955,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13780
13955
|
for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
|
|
13781
13956
|
const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
|
|
13782
13957
|
const message = { type: "get-pending-tx", expire_at: 0 };
|
|
13783
|
-
const proof =
|
|
13958
|
+
const proof = chunkD6RGHPZ5_cjs.Intent.create(message, batch, []);
|
|
13784
13959
|
const signedProof = await identity.sign(
|
|
13785
13960
|
proof,
|
|
13786
13961
|
Array.from({ length: batch.length + 1 }, (_, j) => j)
|
|
@@ -14090,10 +14265,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14090
14265
|
const serverPubKey = this.arkServerPublicKey;
|
|
14091
14266
|
const serverUnrollScript = this.serverUnrollScript;
|
|
14092
14267
|
const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
|
|
14093
|
-
const normalizedInputs = inputs.map(
|
|
14094
|
-
const at = now ?? await
|
|
14268
|
+
const normalizedInputs = inputs.map(chunkD6RGHPZ5_cjs.normalizeVtxo);
|
|
14269
|
+
const at = now ?? await chunkD6RGHPZ5_cjs.resolveTimeHeight(this.onchainProvider);
|
|
14095
14270
|
for (const input of normalizedInputs) {
|
|
14096
|
-
if (!
|
|
14271
|
+
if (!chunkD6RGHPZ5_cjs.canSpendOffchain(input, at)) {
|
|
14097
14272
|
throw new Error(
|
|
14098
14273
|
`sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
|
|
14099
14274
|
);
|
|
@@ -14158,7 +14333,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14158
14333
|
);
|
|
14159
14334
|
const arkTxJobs = inputs.map((input, index) => ({
|
|
14160
14335
|
index,
|
|
14161
|
-
lookupScript:
|
|
14336
|
+
lookupScript: chunkD6RGHPZ5_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
14162
14337
|
}));
|
|
14163
14338
|
const identity = this.identity;
|
|
14164
14339
|
const signer = {
|
|
@@ -14244,14 +14419,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14244
14419
|
const spentBy = checkpointIdByOutpoint.get(`${vtxo.txid}:${vtxo.vout}`);
|
|
14245
14420
|
spentVtxos.push({
|
|
14246
14421
|
...spentFacts,
|
|
14247
|
-
virtualStatus:
|
|
14422
|
+
virtualStatus: chunkD6RGHPZ5_cjs.toVirtualStatus(spentFacts),
|
|
14248
14423
|
...spentBy ? { spentBy } : {},
|
|
14249
14424
|
arkTxId: arkTxid
|
|
14250
14425
|
});
|
|
14251
14426
|
for (const id of vtxo.commitmentTxIds) {
|
|
14252
14427
|
commitmentTxIds.add(id);
|
|
14253
14428
|
}
|
|
14254
|
-
const vtxoExpiry =
|
|
14429
|
+
const vtxoExpiry = chunkD6RGHPZ5_cjs.toBatchExpiry(vtxo);
|
|
14255
14430
|
if (vtxoExpiry) {
|
|
14256
14431
|
batchExpiry = Math.min(batchExpiry, vtxoExpiry);
|
|
14257
14432
|
}
|
|
@@ -14264,7 +14439,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14264
14439
|
isSwept: false,
|
|
14265
14440
|
isPreconfirmed: true,
|
|
14266
14441
|
commitmentTxIds: Array.from(commitmentTxIds),
|
|
14267
|
-
...
|
|
14442
|
+
...chunkD6RGHPZ5_cjs.parseLegacyExpiry(batchExpiry)
|
|
14268
14443
|
};
|
|
14269
14444
|
changeVtxo = {
|
|
14270
14445
|
txid: arkTxid,
|
|
@@ -14276,7 +14451,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14276
14451
|
tapTree: offchainTapscript.encode(),
|
|
14277
14452
|
value: Number(changeAmount),
|
|
14278
14453
|
...changeFacts,
|
|
14279
|
-
virtualStatus:
|
|
14454
|
+
virtualStatus: chunkD6RGHPZ5_cjs.toVirtualStatus(changeFacts),
|
|
14280
14455
|
spentBy: "",
|
|
14281
14456
|
status: {
|
|
14282
14457
|
confirmed: false
|
|
@@ -14345,12 +14520,12 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14345
14520
|
const spentVtxos = [];
|
|
14346
14521
|
const inputArkTxIds = /* @__PURE__ */ new Set();
|
|
14347
14522
|
const boardingRemovalsByAddress = /* @__PURE__ */ new Map();
|
|
14348
|
-
const vtxoInputs = inputs.filter(
|
|
14523
|
+
const vtxoInputs = inputs.filter(chunkD6RGHPZ5_cjs.isVirtualCoin);
|
|
14349
14524
|
const cm = await this.getContractManager();
|
|
14350
14525
|
const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
|
|
14351
14526
|
const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
|
|
14352
14527
|
for (const input of inputs) {
|
|
14353
|
-
if (
|
|
14528
|
+
if (chunkD6RGHPZ5_cjs.isVirtualCoin(input)) {
|
|
14354
14529
|
const outpoint = `${input.txid}:${input.vout}`;
|
|
14355
14530
|
const vtxo = annotatedByKey.get(outpoint);
|
|
14356
14531
|
if (!vtxo) {
|
|
@@ -14362,13 +14537,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14362
14537
|
const settledFacts = { ...vtxo, isSpent: true };
|
|
14363
14538
|
spentVtxos.push({
|
|
14364
14539
|
...settledFacts,
|
|
14365
|
-
virtualStatus:
|
|
14540
|
+
virtualStatus: chunkD6RGHPZ5_cjs.toVirtualStatus(settledFacts),
|
|
14366
14541
|
settledBy: commitmentTxid
|
|
14367
14542
|
});
|
|
14368
14543
|
} else {
|
|
14369
14544
|
let sourceAddress;
|
|
14370
14545
|
try {
|
|
14371
|
-
sourceAddress =
|
|
14546
|
+
sourceAddress = chunkD6RGHPZ5_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
|
|
14372
14547
|
this.network
|
|
14373
14548
|
);
|
|
14374
14549
|
} catch {
|
|
@@ -14426,9 +14601,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14426
14601
|
}
|
|
14427
14602
|
};
|
|
14428
14603
|
function selectVirtualCoins(coins, targetAmount) {
|
|
14429
|
-
const sortedCoins = coins.map(
|
|
14430
|
-
const expiryA =
|
|
14431
|
-
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;
|
|
14432
14607
|
if (expiryA !== expiryB) {
|
|
14433
14608
|
return expiryA - expiryB;
|
|
14434
14609
|
}
|
|
@@ -14685,7 +14860,7 @@ var MessageBus = class {
|
|
|
14685
14860
|
this.initialized = true;
|
|
14686
14861
|
}
|
|
14687
14862
|
async buildServices(config) {
|
|
14688
|
-
const arkProvider = new
|
|
14863
|
+
const arkProvider = new chunkD6RGHPZ5_cjs.RestArkProvider(config.arkServer.url);
|
|
14689
14864
|
const storage = {
|
|
14690
14865
|
walletRepository: this.walletRepository,
|
|
14691
14866
|
contractRepository: this.contractRepository
|
|
@@ -14705,7 +14880,9 @@ var MessageBus = class {
|
|
|
14705
14880
|
settlementConfig: config.settlementConfig,
|
|
14706
14881
|
walletMode: config.walletMode,
|
|
14707
14882
|
watcherConfig: config.watcherConfig,
|
|
14708
|
-
lookAheadWindow: config.lookAheadWindow
|
|
14883
|
+
lookAheadWindow: config.lookAheadWindow,
|
|
14884
|
+
minBatchExpirySeconds: config.minBatchExpirySeconds,
|
|
14885
|
+
minCheckpointExitDelaySeconds: config.minCheckpointExitDelaySeconds
|
|
14709
14886
|
});
|
|
14710
14887
|
return { wallet, arkProvider, readonlyWallet: wallet };
|
|
14711
14888
|
}
|
|
@@ -15024,7 +15201,7 @@ var offboardNetworkNames = [
|
|
|
15024
15201
|
function offboardDestinationScript(destinationAddress) {
|
|
15025
15202
|
for (const networkName of offboardNetworkNames) {
|
|
15026
15203
|
try {
|
|
15027
|
-
const network =
|
|
15204
|
+
const network = chunkD6RGHPZ5_cjs.networks[networkName];
|
|
15028
15205
|
const addr = btcSigner.Address(network).decode(destinationAddress);
|
|
15029
15206
|
return btcSigner.OutScript.encode(addr);
|
|
15030
15207
|
} catch {
|
|
@@ -15088,7 +15265,7 @@ var Ramps = class {
|
|
|
15088
15265
|
}
|
|
15089
15266
|
amount = amount ?? totalAmount;
|
|
15090
15267
|
const offchainAddress = await this.wallet.getAddress();
|
|
15091
|
-
const offchainAddr =
|
|
15268
|
+
const offchainAddr = chunkD6RGHPZ5_cjs.ArkAddress.decode(offchainAddress);
|
|
15092
15269
|
const offchainScript = base.hex.encode(offchainAddr.pkScript);
|
|
15093
15270
|
const outputFee = estimator.evalOffchainOutput({
|
|
15094
15271
|
amount,
|
|
@@ -15148,7 +15325,7 @@ var Ramps = class {
|
|
|
15148
15325
|
const filteredVtxos = [];
|
|
15149
15326
|
let totalAmount = 0n;
|
|
15150
15327
|
for (const vtxo of vtxos) {
|
|
15151
|
-
const inputFee = estimator.evalOffchainInput(
|
|
15328
|
+
const inputFee = estimator.evalOffchainInput(chunkD6RGHPZ5_cjs.toOffchainInputFeeParams(vtxo));
|
|
15152
15329
|
if (inputFee.satoshis >= vtxo.value) {
|
|
15153
15330
|
continue;
|
|
15154
15331
|
}
|
|
@@ -15845,7 +16022,7 @@ var WalletMessageHandler = class {
|
|
|
15845
16022
|
// Wallet methods
|
|
15846
16023
|
async handleInitWallet({ payload }) {
|
|
15847
16024
|
const { arkServerUrl } = payload;
|
|
15848
|
-
this.indexerProvider = new
|
|
16025
|
+
this.indexerProvider = new chunkF4C67JYB_cjs.RestIndexerProvider(arkServerUrl);
|
|
15849
16026
|
await this.onWalletInitialized();
|
|
15850
16027
|
}
|
|
15851
16028
|
async handleGetBalance() {
|
|
@@ -15869,12 +16046,12 @@ var WalletMessageHandler = class {
|
|
|
15869
16046
|
let recoverable = 0;
|
|
15870
16047
|
let pendingRecovery = 0;
|
|
15871
16048
|
for (const vtxo of allVtxos) {
|
|
15872
|
-
if (
|
|
16049
|
+
if (chunkD6RGHPZ5_cjs.hasTerminalSpend(vtxo)) continue;
|
|
15873
16050
|
if (pendingOutpoints.has(`${vtxo.txid}:${vtxo.vout}`)) {
|
|
15874
16051
|
pendingRecovery += vtxo.value;
|
|
15875
|
-
} else if (
|
|
16052
|
+
} else if (chunkD6RGHPZ5_cjs.canRecoverOnchain(vtxo, now)) {
|
|
15876
16053
|
recoverable += vtxo.value;
|
|
15877
|
-
} else if (
|
|
16054
|
+
} else if (chunkD6RGHPZ5_cjs.canSpendOffchain(vtxo, now)) {
|
|
15878
16055
|
if (vtxo.isPreconfirmed) {
|
|
15879
16056
|
preconfirmed += vtxo.value;
|
|
15880
16057
|
} else {
|
|
@@ -15886,7 +16063,7 @@ var WalletMessageHandler = class {
|
|
|
15886
16063
|
const totalOffchain = settled + preconfirmed + recoverable + pendingRecovery;
|
|
15887
16064
|
const assetBalances = /* @__PURE__ */ new Map();
|
|
15888
16065
|
for (const vtxo of allVtxos) {
|
|
15889
|
-
if (
|
|
16066
|
+
if (chunkD6RGHPZ5_cjs.hasTerminalSpend(vtxo)) continue;
|
|
15890
16067
|
if (vtxo.assets) {
|
|
15891
16068
|
for (const a of vtxo.assets) {
|
|
15892
16069
|
const current = assetBalances.get(a.assetId) ?? 0n;
|
|
@@ -15922,7 +16099,7 @@ var WalletMessageHandler = class {
|
|
|
15922
16099
|
*/
|
|
15923
16100
|
async getSpendableVtxos() {
|
|
15924
16101
|
const vtxos = await this.getVtxosFromRepo();
|
|
15925
|
-
return vtxos.filter((v) => !
|
|
16102
|
+
return vtxos.filter((v) => !chunkD6RGHPZ5_cjs.hasTerminalSpend(v));
|
|
15926
16103
|
}
|
|
15927
16104
|
async onWalletInitialized() {
|
|
15928
16105
|
if (!this.readonlyWallet || !this.arkProvider || !this.indexerProvider || !this.walletRepository) {
|
|
@@ -16134,10 +16311,10 @@ var WalletMessageHandler = class {
|
|
|
16134
16311
|
if (dustAmount != null && isSubdust(v, dustAmount)) {
|
|
16135
16312
|
return false;
|
|
16136
16313
|
}
|
|
16137
|
-
if (
|
|
16314
|
+
if (chunkD6RGHPZ5_cjs.isRecoverable(v)) {
|
|
16138
16315
|
return false;
|
|
16139
16316
|
}
|
|
16140
|
-
if (
|
|
16317
|
+
if (chunkD6RGHPZ5_cjs.isExpired(v)) {
|
|
16141
16318
|
return false;
|
|
16142
16319
|
}
|
|
16143
16320
|
return true;
|
|
@@ -16209,7 +16386,7 @@ var WalletMessageHandler = class {
|
|
|
16209
16386
|
if (!this.readonlyWallet) return null;
|
|
16210
16387
|
const { boardingTxs, commitmentsToIgnore } = await this.readonlyWallet.getBoardingTxs();
|
|
16211
16388
|
const indexerProvider = this.indexerProvider;
|
|
16212
|
-
const resolveTxCreatedAt = indexerProvider ? (txids) =>
|
|
16389
|
+
const resolveTxCreatedAt = indexerProvider ? (txids) => chunkD6RGHPZ5_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
|
|
16213
16390
|
return buildTransactionHistory(vtxos, boardingTxs, commitmentsToIgnore, resolveTxCreatedAt);
|
|
16214
16391
|
}
|
|
16215
16392
|
async ensureContractEventBroadcasting() {
|
|
@@ -16894,7 +17071,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
16894
17071
|
};
|
|
16895
17072
|
try {
|
|
16896
17073
|
const response = await this.sendMessage(message);
|
|
16897
|
-
return response.payload.vtxos.map(
|
|
17074
|
+
return response.payload.vtxos.map(chunkD6RGHPZ5_cjs.normalizeVtxo);
|
|
16898
17075
|
} catch (error) {
|
|
16899
17076
|
throw new Error(`Failed to get vtxos: ${error}`);
|
|
16900
17077
|
}
|
|
@@ -17007,7 +17184,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
17007
17184
|
};
|
|
17008
17185
|
try {
|
|
17009
17186
|
const response = await sendContractMessage(message);
|
|
17010
|
-
return response.payload.vtxos.map(
|
|
17187
|
+
return response.payload.vtxos.map(chunkD6RGHPZ5_cjs.normalizeVtxo);
|
|
17011
17188
|
} catch (e) {
|
|
17012
17189
|
throw new Error("Failed to annotate vtxos");
|
|
17013
17190
|
}
|
|
@@ -17238,6 +17415,8 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
17238
17415
|
walletMode: options.walletMode,
|
|
17239
17416
|
watcherConfig: options.watcherConfig,
|
|
17240
17417
|
lookAheadWindow: options.lookAheadWindow,
|
|
17418
|
+
minBatchExpirySeconds: options.minBatchExpirySeconds,
|
|
17419
|
+
minCheckpointExitDelaySeconds: options.minCheckpointExitDelaySeconds,
|
|
17241
17420
|
messageTimeouts
|
|
17242
17421
|
};
|
|
17243
17422
|
await initializeMessageBus(
|
|
@@ -17461,7 +17640,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
17461
17640
|
};
|
|
17462
17641
|
try {
|
|
17463
17642
|
const response = await wallet.sendMessage(message);
|
|
17464
|
-
return response.payload.vtxos.map(
|
|
17643
|
+
return response.payload.vtxos.map(chunkD6RGHPZ5_cjs.normalizeVtxo);
|
|
17465
17644
|
} catch (e) {
|
|
17466
17645
|
throw new Error(`Failed to get expiring vtxos: ${e}`);
|
|
17467
17646
|
}
|
|
@@ -17573,12 +17752,12 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
17573
17752
|
* @returns Configured onchain wallet
|
|
17574
17753
|
* @throws Error if the configured identity cannot produce a valid x-only public key
|
|
17575
17754
|
*/
|
|
17576
|
-
static async create(identity, networkName =
|
|
17755
|
+
static async create(identity, networkName = chunkD6RGHPZ5_cjs.DEFAULT_NETWORK_NAME, provider) {
|
|
17577
17756
|
const pubkey = await identity.xOnlyPublicKey();
|
|
17578
17757
|
if (!pubkey) {
|
|
17579
17758
|
throw new Error("Invalid configured public key");
|
|
17580
17759
|
}
|
|
17581
|
-
const network =
|
|
17760
|
+
const network = chunkD6RGHPZ5_cjs.getNetwork(networkName);
|
|
17582
17761
|
const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
|
|
17583
17762
|
const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
|
|
17584
17763
|
return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
|
|
@@ -17684,7 +17863,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
17684
17863
|
if (!inputs) {
|
|
17685
17864
|
throw new Error("Fee estimation failed");
|
|
17686
17865
|
}
|
|
17687
|
-
let tx = new
|
|
17866
|
+
let tx = new chunkD6RGHPZ5_cjs.Transaction();
|
|
17688
17867
|
for (const input of inputs) {
|
|
17689
17868
|
tx.addInput({
|
|
17690
17869
|
txid: input.txid,
|
|
@@ -17742,7 +17921,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
17742
17921
|
* @throws If the parent has no anchor, or funding cannot be selected/signed
|
|
17743
17922
|
*/
|
|
17744
17923
|
async bumpAnchor(parentHex, feeRate) {
|
|
17745
|
-
const parent =
|
|
17924
|
+
const parent = chunkD6RGHPZ5_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
|
|
17746
17925
|
const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
|
|
17747
17926
|
const child = await this.buildBumpPackage(parent, feeRate, coins);
|
|
17748
17927
|
return [parent.hex, child.hex];
|
|
@@ -18507,7 +18686,7 @@ exports.BIP322 = void 0;
|
|
|
18507
18686
|
async function sign2(message, identity, network) {
|
|
18508
18687
|
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
18509
18688
|
const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
|
|
18510
|
-
const toSpend =
|
|
18689
|
+
const toSpend = chunkD6RGHPZ5_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
18511
18690
|
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
18512
18691
|
const signed = await identity.sign(toSign, [0]);
|
|
18513
18692
|
signed.finalizeIdx(0);
|
|
@@ -18565,7 +18744,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
|
18565
18744
|
if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
|
|
18566
18745
|
return false;
|
|
18567
18746
|
}
|
|
18568
|
-
const toSpend =
|
|
18747
|
+
const toSpend = chunkD6RGHPZ5_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
18569
18748
|
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
|
|
18570
18749
|
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
18571
18750
|
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
@@ -18586,7 +18765,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
|
18586
18765
|
}
|
|
18587
18766
|
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
18588
18767
|
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
18589
|
-
const toSpend =
|
|
18768
|
+
const toSpend = chunkD6RGHPZ5_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
18590
18769
|
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
18591
18770
|
const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
|
|
18592
18771
|
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
@@ -18639,7 +18818,7 @@ function encodeCompactSize(n) {
|
|
|
18639
18818
|
return buf;
|
|
18640
18819
|
}
|
|
18641
18820
|
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
18642
|
-
const tx = new
|
|
18821
|
+
const tx = new chunkD6RGHPZ5_cjs.Transaction({ version: 0 });
|
|
18643
18822
|
tx.addInput({
|
|
18644
18823
|
txid: toSpend.id,
|
|
18645
18824
|
index: 0,
|
|
@@ -18653,12 +18832,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
|
18653
18832
|
});
|
|
18654
18833
|
tx.addOutput({
|
|
18655
18834
|
amount: 0n,
|
|
18656
|
-
script:
|
|
18835
|
+
script: chunkD6RGHPZ5_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
18657
18836
|
});
|
|
18658
18837
|
return tx;
|
|
18659
18838
|
}
|
|
18660
18839
|
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
18661
|
-
const tx = new
|
|
18840
|
+
const tx = new chunkD6RGHPZ5_cjs.Transaction({ version: 0 });
|
|
18662
18841
|
tx.addInput({
|
|
18663
18842
|
txid: toSpend.id,
|
|
18664
18843
|
index: 0,
|
|
@@ -18670,7 +18849,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
|
18670
18849
|
});
|
|
18671
18850
|
tx.addOutput({
|
|
18672
18851
|
amount: 0n,
|
|
18673
|
-
script:
|
|
18852
|
+
script: chunkD6RGHPZ5_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
18674
18853
|
});
|
|
18675
18854
|
return tx;
|
|
18676
18855
|
}
|
|
@@ -18801,7 +18980,7 @@ var RestEmulatorProvider = class {
|
|
|
18801
18980
|
}
|
|
18802
18981
|
};
|
|
18803
18982
|
function finalizeVirtualTx(type, psbtBase64) {
|
|
18804
|
-
const tx =
|
|
18983
|
+
const tx = chunkD6RGHPZ5_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
18805
18984
|
if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
|
|
18806
18985
|
const input = tx.getInput(0);
|
|
18807
18986
|
if (!input) {
|
|
@@ -18828,14 +19007,14 @@ var ExitPathError = class extends Error {
|
|
|
18828
19007
|
reason;
|
|
18829
19008
|
};
|
|
18830
19009
|
function delayWeight(sequence) {
|
|
18831
|
-
const t =
|
|
19010
|
+
const t = chunkD6RGHPZ5_cjs.sequenceToTimelock(sequence);
|
|
18832
19011
|
return t.type === "blocks" ? Number(t.value) : Number(t.value) / 600;
|
|
18833
19012
|
}
|
|
18834
19013
|
async function resolveUnilateralPath(params) {
|
|
18835
19014
|
const { vtxo, scriptHex, contractRepository } = params;
|
|
18836
19015
|
const contract = contractRepository ? (await contractRepository.getContracts({ script: scriptHex }))[0] : void 0;
|
|
18837
19016
|
if (contract) {
|
|
18838
|
-
const handler =
|
|
19017
|
+
const handler = chunkCOLJARV4_cjs.contractHandlers.get(contract.type);
|
|
18839
19018
|
if (!handler) {
|
|
18840
19019
|
throw new ExitPathError(
|
|
18841
19020
|
"no-handler",
|
|
@@ -18858,12 +19037,12 @@ async function resolveUnilateralPath(params) {
|
|
|
18858
19037
|
paths.sort((a, b) => delayWeight(a.sequence) - delayWeight(b.sequence));
|
|
18859
19038
|
return { selection: paths[0], label: `${contract.type}:unilateral` };
|
|
18860
19039
|
}
|
|
18861
|
-
const decoded =
|
|
19040
|
+
const decoded = chunkD6RGHPZ5_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
18862
19041
|
let best;
|
|
18863
19042
|
for (const exit of decoded.exitPaths()) {
|
|
18864
19043
|
const leaf = decoded.findLeaf(base.hex.encode(exit.script));
|
|
18865
19044
|
if (!leaf) continue;
|
|
18866
|
-
const sequence =
|
|
19045
|
+
const sequence = chunkD6RGHPZ5_cjs.timelockToSequence(exit.params.timelock);
|
|
18867
19046
|
const weight = delayWeight(sequence);
|
|
18868
19047
|
if (!best || weight < best.weight) {
|
|
18869
19048
|
best = { selection: { leaf, sequence }, weight };
|
|
@@ -19049,14 +19228,14 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
19049
19228
|
}
|
|
19050
19229
|
const resolved = await resolveUnilateralPath({
|
|
19051
19230
|
vtxo,
|
|
19052
|
-
scriptHex: base.hex.encode(
|
|
19231
|
+
scriptHex: base.hex.encode(chunkD6RGHPZ5_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
19053
19232
|
contractRepository: wallet.contractRepository,
|
|
19054
19233
|
walletPubKeyHex: base.hex.encode(await wallet.identity.xOnlyPublicKey()),
|
|
19055
19234
|
currentTime: Date.now()
|
|
19056
19235
|
});
|
|
19057
19236
|
const spendingLeaf = resolved.selection.leaf;
|
|
19058
19237
|
const sequence = resolved.selection.sequence;
|
|
19059
|
-
const timelock =
|
|
19238
|
+
const timelock = chunkD6RGHPZ5_cjs.sequenceToTimelock(sequence);
|
|
19060
19239
|
const elapsed = timelock.type === "blocks" ? chainTip.height >= txStatus.blockHeight + Number(timelock.value) : chainTip.time >= txStatus.blockTime + Number(timelock.value);
|
|
19061
19240
|
if (!elapsed) {
|
|
19062
19241
|
throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
|
|
@@ -19069,7 +19248,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
19069
19248
|
sequence,
|
|
19070
19249
|
witnessUtxo: {
|
|
19071
19250
|
amount: BigInt(vtxo.value),
|
|
19072
|
-
script:
|
|
19251
|
+
script: chunkD6RGHPZ5_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
|
|
19073
19252
|
},
|
|
19074
19253
|
sighashType: btcSigner.SigHash.DEFAULT
|
|
19075
19254
|
});
|
|
@@ -19079,7 +19258,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
19079
19258
|
btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
|
|
19080
19259
|
);
|
|
19081
19260
|
}
|
|
19082
|
-
const tx = new
|
|
19261
|
+
const tx = new chunkD6RGHPZ5_cjs.Transaction({ version: 2 });
|
|
19083
19262
|
for (const input of inputs) {
|
|
19084
19263
|
tx.addInput(input);
|
|
19085
19264
|
}
|
|
@@ -19146,7 +19325,7 @@ async function buildSignedSweep(params) {
|
|
|
19146
19325
|
`uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
|
|
19147
19326
|
);
|
|
19148
19327
|
}
|
|
19149
|
-
const tx = new
|
|
19328
|
+
const tx = new chunkD6RGHPZ5_cjs.Transaction({ version: 2 });
|
|
19150
19329
|
tx.addInput({
|
|
19151
19330
|
txid: vtxo.txid,
|
|
19152
19331
|
index: vtxo.vout,
|
|
@@ -19171,7 +19350,7 @@ async function buildSignedSweep(params) {
|
|
|
19171
19350
|
finalScriptWitness: [
|
|
19172
19351
|
tapScriptSig[0][1],
|
|
19173
19352
|
...path.extraWitness,
|
|
19174
|
-
|
|
19353
|
+
chunkD6RGHPZ5_cjs.scriptFromTapLeafScript(path.leaf),
|
|
19175
19354
|
btcSigner.TaprootControlBlock.encode(controlBlock)
|
|
19176
19355
|
]
|
|
19177
19356
|
});
|
|
@@ -19201,7 +19380,7 @@ async function resolveFeeRate(opts) {
|
|
|
19201
19380
|
}
|
|
19202
19381
|
async function selectExitVtxos(opts) {
|
|
19203
19382
|
if (!opts.vtxos) return opts.wallet.getVtxos();
|
|
19204
|
-
const res = await
|
|
19383
|
+
const res = await chunkD6RGHPZ5_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
|
|
19205
19384
|
const tapTrees = /* @__PURE__ */ new Map();
|
|
19206
19385
|
const out = [];
|
|
19207
19386
|
for (const vtxo of res.vtxos) {
|
|
@@ -19216,7 +19395,7 @@ async function selectExitVtxos(opts) {
|
|
|
19216
19395
|
`no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
|
|
19217
19396
|
);
|
|
19218
19397
|
}
|
|
19219
|
-
const handler =
|
|
19398
|
+
const handler = chunkCOLJARV4_cjs.contractHandlers.get(contract.type);
|
|
19220
19399
|
if (!handler) {
|
|
19221
19400
|
throw new Error(`no contract handler registered for type '${contract.type}'`);
|
|
19222
19401
|
}
|
|
@@ -19246,7 +19425,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
19246
19425
|
if (pendingNodes.length > 0) {
|
|
19247
19426
|
const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
|
|
19248
19427
|
for (const psbt of txs) {
|
|
19249
|
-
psbts.set(
|
|
19428
|
+
psbts.set(chunkD6RGHPZ5_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
19250
19429
|
}
|
|
19251
19430
|
}
|
|
19252
19431
|
const childVsize = Number(
|
|
@@ -19282,7 +19461,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
19282
19461
|
try {
|
|
19283
19462
|
const resolved = await resolveUnilateralPath({
|
|
19284
19463
|
vtxo,
|
|
19285
|
-
scriptHex: base.hex.encode(
|
|
19464
|
+
scriptHex: base.hex.encode(chunkD6RGHPZ5_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
19286
19465
|
contractRepository: wallet.contractRepository,
|
|
19287
19466
|
walletPubKeyHex,
|
|
19288
19467
|
currentTime: Date.now()
|
|
@@ -19301,7 +19480,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
19301
19480
|
});
|
|
19302
19481
|
continue;
|
|
19303
19482
|
}
|
|
19304
|
-
const t =
|
|
19483
|
+
const t = chunkD6RGHPZ5_cjs.sequenceToTimelock(resolved.selection.sequence);
|
|
19305
19484
|
const delay = { type: t.type, value: Number(t.value) };
|
|
19306
19485
|
infos.push({ outpoint, value: vtxo.value, sweepFee, path: resolved.label, delay });
|
|
19307
19486
|
sweeps.push({ vtxo, resolved, sweepFee, delay });
|
|
@@ -19640,7 +19819,7 @@ async function prepare(opts) {
|
|
|
19640
19819
|
txid: sweep.vtxo.txid,
|
|
19641
19820
|
vout: sweep.vtxo.vout,
|
|
19642
19821
|
value: sweep.vtxo.value,
|
|
19643
|
-
pkScript:
|
|
19822
|
+
pkScript: chunkD6RGHPZ5_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
|
|
19644
19823
|
},
|
|
19645
19824
|
path: sweep.resolved.selection,
|
|
19646
19825
|
outputAddress: opts.sweepAddress,
|
|
@@ -19725,7 +19904,7 @@ async function prepare(opts) {
|
|
|
19725
19904
|
if (newFee <= splitterFee) break;
|
|
19726
19905
|
splitterFee = newFee;
|
|
19727
19906
|
}
|
|
19728
|
-
const splitter = new
|
|
19907
|
+
const splitter = new chunkD6RGHPZ5_cjs.Transaction({ version: 2 });
|
|
19729
19908
|
for (const coin of selected.inputs) {
|
|
19730
19909
|
splitter.addInput({
|
|
19731
19910
|
txid: coin.txid,
|
|
@@ -19868,42 +20047,42 @@ var UnilateralExit = {
|
|
|
19868
20047
|
// src/arkade/index.ts
|
|
19869
20048
|
var arkade_exports = {};
|
|
19870
20049
|
chunk5BLDMQED_cjs.__export(arkade_exports, {
|
|
19871
|
-
ARKADE_OP: () =>
|
|
19872
|
-
ARKADE_OPCODES: () =>
|
|
19873
|
-
ARKADE_OPCODE_NAMES: () =>
|
|
19874
|
-
ARKADE_OPCODE_VALUES: () =>
|
|
19875
|
-
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,
|
|
19876
20055
|
Arkade: () => Arkade,
|
|
19877
20056
|
ArkadeContract: () => ArkadeContract,
|
|
19878
|
-
ArkadeProgramScript: () =>
|
|
19879
|
-
ArkadeScript: () =>
|
|
20057
|
+
ArkadeProgramScript: () => chunkCOLJARV4_cjs.ArkadeProgramScript,
|
|
20058
|
+
ArkadeScript: () => chunkCOLJARV4_cjs.ArkadeScript,
|
|
19880
20059
|
ArkadeTransactionBuilder: () => ArkadeTransactionBuilder,
|
|
19881
|
-
BigNum: () =>
|
|
20060
|
+
BigNum: () => chunkCOLJARV4_cjs.bignum_exports,
|
|
19882
20061
|
OP: () => btcSigner.OP,
|
|
19883
|
-
OPCODE_NAMES: () =>
|
|
19884
|
-
OPCODE_VALUES: () =>
|
|
19885
|
-
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,
|
|
19886
20065
|
Script: () => btcSigner.Script,
|
|
19887
|
-
arkadeScriptHash: () =>
|
|
19888
|
-
arkadeWitnessHash: () =>
|
|
19889
|
-
asmToBytes: () =>
|
|
19890
|
-
bytesToASM: () =>
|
|
19891
|
-
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,
|
|
19892
20071
|
createArkadeBatchHandler: () => createArkadeBatchHandler,
|
|
19893
|
-
deserializeArkadeContractParams: () =>
|
|
19894
|
-
fromASM: () =>
|
|
19895
|
-
getOpcodeName: () =>
|
|
19896
|
-
getOpcodeValue: () =>
|
|
19897
|
-
parseArtifact: () =>
|
|
19898
|
-
resolveAsm: () =>
|
|
19899
|
-
serializeArkadeContractParams: () =>
|
|
19900
|
-
stringifyArtifact: () =>
|
|
19901
|
-
toASM: () =>
|
|
19902
|
-
validateProgram: () =>
|
|
19903
|
-
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
|
|
19904
20083
|
});
|
|
19905
|
-
var isVtxoCoin = (input) =>
|
|
19906
|
-
function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients) {
|
|
20084
|
+
var isVtxoCoin = (input) => chunkD6RGHPZ5_cjs.isVirtualCoin(input);
|
|
20085
|
+
function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
|
|
19907
20086
|
let batchId;
|
|
19908
20087
|
let sweepTapTreeRoot;
|
|
19909
20088
|
let validatedCommitmentTxid;
|
|
@@ -19913,15 +20092,19 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
19913
20092
|
const intentIdHash = utils_js.sha256(utf8IntentId);
|
|
19914
20093
|
const intentIdHashStr = base.hex.encode(intentIdHash);
|
|
19915
20094
|
if (!event.intentIdHashes.includes(intentIdHashStr)) return { skip: true };
|
|
20095
|
+
const info = await arkProvider.getInfo();
|
|
20096
|
+
const timelock = assertValidBatchExpiry(
|
|
20097
|
+
event.batchExpiry,
|
|
20098
|
+
resolveBatchExpiryPolicy(network, {
|
|
20099
|
+
advertisedVtxoTreeExpiry: info.vtxoTreeExpiry,
|
|
20100
|
+
...batchExpiryPolicy
|
|
20101
|
+
})
|
|
20102
|
+
);
|
|
19916
20103
|
await arkProvider.confirmRegistration(intentId);
|
|
19917
20104
|
batchId = event.id;
|
|
19918
|
-
const sweepTapscript =
|
|
19919
|
-
timelock
|
|
19920
|
-
|
|
19921
|
-
// BIP-65: values >= 512 are interpreted as seconds, below as blocks
|
|
19922
|
-
type: event.batchExpiry >= 512n ? "seconds" : "blocks"
|
|
19923
|
-
},
|
|
19924
|
-
pubkeys: [base.hex.decode((await arkProvider.getInfo()).forfeitPubkey).subarray(1)]
|
|
20105
|
+
const sweepTapscript = chunkD6RGHPZ5_cjs.CSVMultisigTapscript.encode({
|
|
20106
|
+
timelock,
|
|
20107
|
+
pubkeys: [base.hex.decode(info.forfeitPubkey).subarray(1)]
|
|
19925
20108
|
}).script;
|
|
19926
20109
|
sweepTapTreeRoot = payment_js.tapLeafHash(sweepTapscript);
|
|
19927
20110
|
return { skip: false };
|
|
@@ -19933,7 +20116,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
19933
20116
|
if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
|
|
19934
20117
|
return { skip: true };
|
|
19935
20118
|
}
|
|
19936
|
-
const commitmentTx =
|
|
20119
|
+
const commitmentTx = chunkD6RGHPZ5_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
|
|
19937
20120
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
19938
20121
|
if (recipients && recipients.length > 0) {
|
|
19939
20122
|
validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
|
|
@@ -19965,7 +20148,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
19965
20148
|
if (connectorTree) {
|
|
19966
20149
|
validateConnectorsTxGraph(event.commitmentTx, connectorTree);
|
|
19967
20150
|
}
|
|
19968
|
-
let commitmentPsbt =
|
|
20151
|
+
let commitmentPsbt = chunkD6RGHPZ5_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
19969
20152
|
assertFinalCommitmentMatchesValidated(
|
|
19970
20153
|
commitmentPsbt,
|
|
19971
20154
|
validatedCommitmentTxid,
|
|
@@ -20000,7 +20183,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
20000
20183
|
boardingIndices.push(boardingIdx);
|
|
20001
20184
|
continue;
|
|
20002
20185
|
}
|
|
20003
|
-
if (
|
|
20186
|
+
if (chunkD6RGHPZ5_cjs.isRecoverable(input) || isSubdust(input, info.dust)) {
|
|
20004
20187
|
continue;
|
|
20005
20188
|
}
|
|
20006
20189
|
if (connectorIndex >= connectorLeaves.length) {
|
|
@@ -20021,7 +20204,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
20021
20204
|
index: input.vout,
|
|
20022
20205
|
witnessUtxo: {
|
|
20023
20206
|
amount: BigInt(input.value),
|
|
20024
|
-
script:
|
|
20207
|
+
script: chunkD6RGHPZ5_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
20025
20208
|
},
|
|
20026
20209
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
20027
20210
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -20104,7 +20287,7 @@ var Arkade = class _Arkade {
|
|
|
20104
20287
|
static async connect(opts) {
|
|
20105
20288
|
const info = await opts.arkade.getInfo();
|
|
20106
20289
|
const serverKey = base.hex.decode(info.signerPubkey).slice(1);
|
|
20107
|
-
const checkpoint =
|
|
20290
|
+
const checkpoint = chunkD6RGHPZ5_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
20108
20291
|
let emulatorKey;
|
|
20109
20292
|
if (opts.emulator) {
|
|
20110
20293
|
const eInfo = await opts.emulator.getInfo();
|
|
@@ -20118,7 +20301,7 @@ var Arkade = class _Arkade {
|
|
|
20118
20301
|
return new _Arkade({
|
|
20119
20302
|
arkProvider: opts.arkade,
|
|
20120
20303
|
emulator: opts.emulator,
|
|
20121
|
-
network: opts.network ??
|
|
20304
|
+
network: opts.network ?? chunkD6RGHPZ5_cjs.DEFAULT_NETWORK,
|
|
20122
20305
|
serverKey,
|
|
20123
20306
|
emulatorKey,
|
|
20124
20307
|
checkpoint,
|
|
@@ -20139,7 +20322,7 @@ var Arkade = class _Arkade {
|
|
|
20139
20322
|
* key respectively; explicit args always win.
|
|
20140
20323
|
*/
|
|
20141
20324
|
contract(program, args = {}) {
|
|
20142
|
-
const declared = (program.params ?? []).map(
|
|
20325
|
+
const declared = (program.params ?? []).map(chunkCOLJARV4_cjs.inputName);
|
|
20143
20326
|
if (declared.includes("server") && args.server === void 0) {
|
|
20144
20327
|
args = { ...args, server: this.serverKey };
|
|
20145
20328
|
}
|
|
@@ -20159,7 +20342,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
20159
20342
|
userKey: client.userKey,
|
|
20160
20343
|
emulatorKey: client.emulatorKey
|
|
20161
20344
|
};
|
|
20162
|
-
this.vtxoScript = new
|
|
20345
|
+
this.vtxoScript = new chunkCOLJARV4_cjs.ArkadeProgramScript(program, args, this.keys);
|
|
20163
20346
|
this.tapTree = this.vtxoScript.encode();
|
|
20164
20347
|
this.compiled = this.vtxoScript.compiled;
|
|
20165
20348
|
}
|
|
@@ -20187,7 +20370,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
20187
20370
|
`ArkadeContract.fromContract: expected contract type 'arkade', got '${contract.type}'`
|
|
20188
20371
|
);
|
|
20189
20372
|
}
|
|
20190
|
-
const typed =
|
|
20373
|
+
const typed = chunkCOLJARV4_cjs.deserializeArkadeContractParams(contract.params);
|
|
20191
20374
|
return new _ArkadeContract(client, typed.program, typed.args, {
|
|
20192
20375
|
serverKey: typed.serverKey,
|
|
20193
20376
|
userKey: typed.userKey,
|
|
@@ -20228,7 +20411,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
20228
20411
|
toContractParams() {
|
|
20229
20412
|
return {
|
|
20230
20413
|
type: "arkade",
|
|
20231
|
-
params:
|
|
20414
|
+
params: chunkCOLJARV4_cjs.serializeArkadeContractParams({
|
|
20232
20415
|
program: this.program,
|
|
20233
20416
|
args: this.args,
|
|
20234
20417
|
serverKey: this.keys.serverKey,
|
|
@@ -20273,13 +20456,13 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
20273
20456
|
const [registered] = await manager.getContracts({ script: scriptHex });
|
|
20274
20457
|
if (registered) {
|
|
20275
20458
|
const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
|
|
20276
|
-
return (withVtxos?.vtxos ?? []).filter((v) => !
|
|
20459
|
+
return (withVtxos?.vtxos ?? []).filter((v) => !chunkD6RGHPZ5_cjs.hasTerminalSpend(v));
|
|
20277
20460
|
}
|
|
20278
20461
|
}
|
|
20279
20462
|
if (!this.client.indexer) {
|
|
20280
20463
|
throw new Error("ArkadeContract.getUtxos: an indexer is required");
|
|
20281
20464
|
}
|
|
20282
|
-
const { vtxos } = await
|
|
20465
|
+
const { vtxos } = await chunkD6RGHPZ5_cjs.getNormalizedVtxos(this.client.indexer, {
|
|
20283
20466
|
scripts: [scriptHex],
|
|
20284
20467
|
spendableOnly: true
|
|
20285
20468
|
});
|
|
@@ -20381,12 +20564,12 @@ var ArkadeTransactionBuilder = class {
|
|
|
20381
20564
|
this.contract.client.checkpoint
|
|
20382
20565
|
);
|
|
20383
20566
|
if (coin.sourceTx) {
|
|
20384
|
-
|
|
20567
|
+
chunkD6RGHPZ5_cjs.setArkPsbtField(arkTx, 0, chunkD6RGHPZ5_cjs.PrevArkTxField, coin.sourceTx);
|
|
20385
20568
|
}
|
|
20386
20569
|
const condition = (def.tapscript.witness ?? []).map((w) => this.witnessBytes(w));
|
|
20387
20570
|
if (condition.length > 0) {
|
|
20388
|
-
|
|
20389
|
-
|
|
20571
|
+
chunkD6RGHPZ5_cjs.setArkPsbtField(arkTx, 0, chunkD6RGHPZ5_cjs.ConditionWitness, condition);
|
|
20572
|
+
chunkD6RGHPZ5_cjs.setArkPsbtField(checkpoints[0], 0, chunkD6RGHPZ5_cjs.ConditionWitness, condition);
|
|
20390
20573
|
}
|
|
20391
20574
|
const packets = [];
|
|
20392
20575
|
if (this.assetSpecs.length > 0) {
|
|
@@ -20425,7 +20608,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
20425
20608
|
base.base64.encode(signedArk2.toPSBT()),
|
|
20426
20609
|
signedCps.map((c) => base.base64.encode(c.toPSBT()))
|
|
20427
20610
|
);
|
|
20428
|
-
const txid =
|
|
20611
|
+
const txid = chunkD6RGHPZ5_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
|
|
20429
20612
|
return {
|
|
20430
20613
|
txid,
|
|
20431
20614
|
signedArkTx: res2.signedArkTx,
|
|
@@ -20484,23 +20667,23 @@ var ArkadeTransactionBuilder = class {
|
|
|
20484
20667
|
}
|
|
20485
20668
|
buildAssetPacket() {
|
|
20486
20669
|
const groups = this.assetSpecs.map((s) => {
|
|
20487
|
-
const id = typeof s.assetId === "string" ?
|
|
20488
|
-
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(
|
|
20489
20672
|
id,
|
|
20490
20673
|
null,
|
|
20491
|
-
s.inputs.map((i) =>
|
|
20492
|
-
s.outputs.map((o) =>
|
|
20493
|
-
(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))
|
|
20494
20677
|
);
|
|
20495
20678
|
});
|
|
20496
|
-
return
|
|
20679
|
+
return chunkF4C67JYB_cjs.Packet.create(groups);
|
|
20497
20680
|
}
|
|
20498
20681
|
witnessBytes(ref) {
|
|
20499
|
-
return
|
|
20682
|
+
return chunkCOLJARV4_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
|
|
20500
20683
|
}
|
|
20501
20684
|
};
|
|
20502
20685
|
function bindInputs(fn, callArgs) {
|
|
20503
|
-
const names = (fn.def.inputs ?? []).map(
|
|
20686
|
+
const names = (fn.def.inputs ?? []).map(chunkCOLJARV4_cjs.inputName);
|
|
20504
20687
|
if (callArgs.length !== names.length) {
|
|
20505
20688
|
throw new Error(`${fn.name}: expected ${names.length} argument(s), got ${callArgs.length}`);
|
|
20506
20689
|
}
|
|
@@ -20907,7 +21090,7 @@ function decodeArkContract(encoded) {
|
|
|
20907
21090
|
}
|
|
20908
21091
|
function contractFromArkContract(encoded, options = {}) {
|
|
20909
21092
|
const parsed = decodeArkContract(encoded);
|
|
20910
|
-
const handler =
|
|
21093
|
+
const handler = chunkCOLJARV4_cjs.contractHandlers.get(parsed.type);
|
|
20911
21094
|
if (!handler) {
|
|
20912
21095
|
throw new Error(`No handler registered for contract type '${parsed.type}'`);
|
|
20913
21096
|
}
|
|
@@ -20921,9 +21104,9 @@ function contractFromArkContract(encoded, options = {}) {
|
|
|
20921
21104
|
metadata: options.metadata
|
|
20922
21105
|
};
|
|
20923
21106
|
}
|
|
20924
|
-
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix =
|
|
21107
|
+
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkD6RGHPZ5_cjs.DEFAULT_NETWORK.hrp, options = {}) {
|
|
20925
21108
|
const parsed = decodeArkContract(encoded);
|
|
20926
|
-
const handler =
|
|
21109
|
+
const handler = chunkCOLJARV4_cjs.contractHandlers.getOrThrow(parsed.type);
|
|
20927
21110
|
const params = parsed.data;
|
|
20928
21111
|
const vtxoScript = handler.createScript(params);
|
|
20929
21112
|
return {
|
|
@@ -20956,6 +21139,8 @@ exports.ContractRepositoryImpl = ContractRepositoryImpl;
|
|
|
20956
21139
|
exports.ContractWatcher = ContractWatcher;
|
|
20957
21140
|
exports.DB_VERSION = DB_VERSION;
|
|
20958
21141
|
exports.DEFAULT_MESSAGE_TIMEOUTS = DEFAULT_MESSAGE_TIMEOUTS;
|
|
21142
|
+
exports.DEFAULT_MIN_BATCH_EXPIRY_SECONDS = DEFAULT_MIN_BATCH_EXPIRY_SECONDS;
|
|
21143
|
+
exports.DEFAULT_MIN_CHECKPOINT_EXIT_DELAY_SECONDS = DEFAULT_MIN_CHECKPOINT_EXIT_DELAY_SECONDS;
|
|
20959
21144
|
exports.DelegateManagerImpl = DelegateManagerImpl;
|
|
20960
21145
|
exports.DelegateNotConfiguredError = DelegateNotConfiguredError;
|
|
20961
21146
|
exports.DelegatorManagerImpl = DelegatorManagerImpl;
|
|
@@ -20993,6 +21178,8 @@ exports.MnemonicIdentity = MnemonicIdentity;
|
|
|
20993
21178
|
exports.OnchainWallet = OnchainWallet;
|
|
20994
21179
|
exports.P2A = P2A;
|
|
20995
21180
|
exports.PaymentRouter = PaymentRouter;
|
|
21181
|
+
exports.REGTEST_MIN_BATCH_EXPIRY_SECONDS = REGTEST_MIN_BATCH_EXPIRY_SECONDS;
|
|
21182
|
+
exports.REGTEST_MIN_CHECKPOINT_EXIT_DELAY_SECONDS = REGTEST_MIN_CHECKPOINT_EXIT_DELAY_SECONDS;
|
|
20996
21183
|
exports.Ramps = Ramps;
|
|
20997
21184
|
exports.ReadonlyAssetManager = ReadonlyAssetManager;
|
|
20998
21185
|
exports.ReadonlyDescriptorIdentity = ReadonlyDescriptorIdentity;
|
|
@@ -21025,6 +21212,8 @@ exports.assertFinalCommitmentMatchesValidated = assertFinalCommitmentMatchesVali
|
|
|
21025
21212
|
exports.assertIntentIdUnique = assertIntentIdUnique;
|
|
21026
21213
|
exports.assertSendableAmount = assertSendableAmount;
|
|
21027
21214
|
exports.assertSubmittedArkTxid = assertSubmittedArkTxid;
|
|
21215
|
+
exports.assertValidBatchExpiry = assertValidBatchExpiry;
|
|
21216
|
+
exports.assertValidServerUnrollScript = assertValidServerUnrollScript;
|
|
21028
21217
|
exports.assetMintResolver = assetMintResolver;
|
|
21029
21218
|
exports.boardingResolver = boardingResolver;
|
|
21030
21219
|
exports.btcTarget = btcTarget;
|
|
@@ -21042,6 +21231,8 @@ exports.createDefaultActivityRegistry = createDefaultActivityRegistry;
|
|
|
21042
21231
|
exports.createDefaultPaymentRouter = createDefaultPaymentRouter;
|
|
21043
21232
|
exports.createExitChainResolver = createExitChainResolver;
|
|
21044
21233
|
exports.decodeArkContract = decodeArkContract;
|
|
21234
|
+
exports.defaultBatchExpiryPolicy = defaultBatchExpiryPolicy;
|
|
21235
|
+
exports.defaultCheckpointExitDelayPolicy = defaultCheckpointExitDelayPolicy;
|
|
21045
21236
|
exports.deserializeAssets = deserializeAssets;
|
|
21046
21237
|
exports.deserializeExitPackage = deserializeExitPackage;
|
|
21047
21238
|
exports.deserializeUtxo = deserializeUtxo;
|
|
@@ -21078,6 +21269,8 @@ exports.migrateWalletRepository = migrateWalletRepository;
|
|
|
21078
21269
|
exports.onchainRail = onchainRail;
|
|
21079
21270
|
exports.openDatabase = openDatabase;
|
|
21080
21271
|
exports.requiresMigration = requiresMigration;
|
|
21272
|
+
exports.resolveBatchExpiryPolicy = resolveBatchExpiryPolicy;
|
|
21273
|
+
exports.resolveCheckpointExitDelayPolicy = resolveCheckpointExitDelayPolicy;
|
|
21081
21274
|
exports.resolveSendAmount = resolveSendAmount;
|
|
21082
21275
|
exports.rollbackMigration = rollbackMigration;
|
|
21083
21276
|
exports.saveVtxosForContract = saveVtxosForContract;
|
|
@@ -21098,5 +21291,5 @@ exports.validateVtxoTxGraph = validateVtxoTxGraph;
|
|
|
21098
21291
|
exports.verifyTapscriptSignatures = verifyTapscriptSignatures;
|
|
21099
21292
|
exports.waitForIncomingFunds = waitForIncomingFunds;
|
|
21100
21293
|
exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
|
|
21101
|
-
//# sourceMappingURL=chunk-
|
|
21102
|
-
//# sourceMappingURL=chunk-
|
|
21294
|
+
//# sourceMappingURL=chunk-6PY4WYXI.cjs.map
|
|
21295
|
+
//# sourceMappingURL=chunk-6PY4WYXI.cjs.map
|