@arkade-os/sdk 0.4.55 → 0.4.56
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-Do9Lqfsp.d.cts → ark-Cgsd9tMd.d.cts} +6 -2
- package/dist/{ark-Do9Lqfsp.d.ts → ark-Cgsd9tMd.d.ts} +6 -2
- package/dist/{asyncStorageTaskQueue-C3DYxvAT.d.cts → asyncStorageTaskQueue-C0ZsDE60.d.cts} +1 -1
- package/dist/{asyncStorageTaskQueue-DOnBOEDn.d.ts → asyncStorageTaskQueue-CXz4PRBW.d.ts} +1 -1
- package/dist/{chunk-G7DOBFQN.cjs → chunk-24YNIQSW.cjs} +15 -15
- package/dist/{chunk-G7DOBFQN.cjs.map → chunk-24YNIQSW.cjs.map} +1 -1
- package/dist/{chunk-V2TOHHPW.cjs → chunk-37XKN5DZ.cjs} +40 -40
- package/dist/{chunk-V2TOHHPW.cjs.map → chunk-37XKN5DZ.cjs.map} +1 -1
- package/dist/{chunk-LAONNMM5.js → chunk-5IMBONCK.js} +4 -4
- package/dist/{chunk-LAONNMM5.js.map → chunk-5IMBONCK.js.map} +1 -1
- package/dist/{chunk-OWCPXRGP.cjs → chunk-CDWLZQQW.cjs} +3 -3
- package/dist/{chunk-OWCPXRGP.cjs.map → chunk-CDWLZQQW.cjs.map} +1 -1
- package/dist/{chunk-ZPL34T2Q.cjs → chunk-ENRRZFZ4.cjs} +431 -378
- package/dist/chunk-ENRRZFZ4.cjs.map +1 -0
- package/dist/{chunk-JCJ5WFS3.js → chunk-IFGN2GB2.js} +3 -3
- package/dist/{chunk-JCJ5WFS3.js.map → chunk-IFGN2GB2.js.map} +1 -1
- package/dist/{chunk-C6UYPHTQ.cjs → chunk-IMVKQQHU.cjs} +9 -9
- package/dist/{chunk-C6UYPHTQ.cjs.map → chunk-IMVKQQHU.cjs.map} +1 -1
- package/dist/{chunk-CSS74VCN.cjs → chunk-MXPBHDOI.cjs} +17 -17
- package/dist/{chunk-CSS74VCN.cjs.map → chunk-MXPBHDOI.cjs.map} +1 -1
- package/dist/{chunk-ENWR2F2P.js → chunk-NN7BNNF5.js} +3 -3
- package/dist/{chunk-ENWR2F2P.js.map → chunk-NN7BNNF5.js.map} +1 -1
- package/dist/{chunk-QMPNPZ2T.js → chunk-OOPDT2WV.js} +3 -3
- package/dist/{chunk-QMPNPZ2T.js.map → chunk-OOPDT2WV.js.map} +1 -1
- package/dist/{chunk-QO3IKBYL.js → chunk-T22257HW.js} +62 -11
- package/dist/chunk-T22257HW.js.map +1 -0
- package/dist/{chunk-SG4X7SEC.js → chunk-VNDVUM2W.js} +4 -4
- package/dist/{chunk-SG4X7SEC.js.map → chunk-VNDVUM2W.js.map} +1 -1
- package/dist/contracts/handlers/index.cjs +8 -8
- package/dist/contracts/handlers/index.d.cts +3 -3
- package/dist/contracts/handlers/index.d.ts +3 -3
- package/dist/contracts/handlers/index.js +2 -2
- package/dist/{delegate-DmhFrtdq.d.ts → delegate-CZPXtd2F.d.ts} +1 -1
- package/dist/{delegate-C0iIBxen.d.cts → delegate-xXT8O-Kn.d.cts} +1 -1
- package/dist/{index-BNt4wcSh.d.ts → index-BBJ466mM.d.ts} +2 -2
- package/dist/{index-BnLM1XxA.d.cts → index-BYG2eKOA.d.cts} +2 -2
- package/dist/index.cjs +219 -211
- package/dist/index.d.cts +40 -11
- package/dist/index.d.ts +40 -11
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +19 -19
- package/dist/repositories/realm/index.d.cts +2 -2
- package/dist/repositories/realm/index.d.ts +2 -2
- package/dist/repositories/realm/index.js +5 -5
- package/dist/repositories/sqlite/index.cjs +18 -18
- package/dist/repositories/sqlite/index.d.cts +2 -2
- package/dist/repositories/sqlite/index.d.ts +2 -2
- package/dist/repositories/sqlite/index.js +5 -5
- package/dist/{taskRunner-RwUvgQ5M.d.cts → taskRunner-BG1PRFps.d.cts} +1 -1
- package/dist/{taskRunner-Bgs-0I3x.d.ts → taskRunner-C46NnRsY.d.ts} +1 -1
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +6 -6
- package/dist/wallet/expo/index.cjs +14 -14
- package/dist/wallet/expo/index.d.cts +4 -4
- package/dist/wallet/expo/index.d.ts +4 -4
- package/dist/wallet/expo/index.js +5 -5
- package/dist/{wallet-Ck7BH8zR.d.cts → wallet-1yWg75gN.d.cts} +20 -3
- package/dist/{wallet-5Aou-V5n.d.ts → wallet-DuCm55EC.d.ts} +20 -3
- package/dist/worker/expo/index.cjs +9 -9
- package/dist/worker/expo/index.d.cts +4 -4
- package/dist/worker/expo/index.d.ts +4 -4
- package/dist/worker/expo/index.js +5 -5
- package/package.json +1 -1
- package/dist/chunk-QO3IKBYL.js.map +0 -1
- package/dist/chunk-ZPL34T2Q.cjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunk24YNIQSW_cjs = require('./chunk-24YNIQSW.cjs');
|
|
4
|
+
var chunk37XKN5DZ_cjs = require('./chunk-37XKN5DZ.cjs');
|
|
5
|
+
var chunkCDWLZQQW_cjs = require('./chunk-CDWLZQQW.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 = chunkCDWLZQQW_cjs.getArkPsbtFields(tx.root, 0, chunkCDWLZQQW_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 = chunkCDWLZQQW_cjs.getArkPsbtFields(g.root, 0, chunkCDWLZQQW_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 = chunk37XKN5DZ_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 chunk37XKN5DZ_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 = chunk37XKN5DZ_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 = chunk37XKN5DZ_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 chunk37XKN5DZ_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 chunk37XKN5DZ_cjs.deriveDescriptorLeafPubKey(this.descriptor);
|
|
855
855
|
}
|
|
856
856
|
async compressedPublicKey() {
|
|
857
|
-
return
|
|
857
|
+
return chunk37XKN5DZ_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 chunkCDWLZQQW_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: chunkCDWLZQQW_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 chunkCDWLZQQW_cjs.rateGate.runHttp(url, () => chunkCDWLZQQW_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[chunkCDWLZQQW_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 chunkCDWLZQQW_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 chunkCDWLZQQW_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 chunkCDWLZQQW_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 chunkCDWLZQQW_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 chunkCDWLZQQW_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 chunkCDWLZQQW_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 chunkCDWLZQQW_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 chunkCDWLZQQW_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 chunkCDWLZQQW_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 chunkCDWLZQQW_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 chunkCDWLZQQW_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 = chunkCDWLZQQW_cjs.getArkPsbtFields(child.root, 0, chunkCDWLZQQW_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 chunk24YNIQSW_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 chunk24YNIQSW_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 chunk24YNIQSW_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 chunk24YNIQSW_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 chunk24YNIQSW_cjs.Packet.PACKET_TYPE:
|
|
1858
|
+
return chunk24YNIQSW_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 chunkCDWLZQQW_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
|
|
1906
|
+
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkCDWLZQQW_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 chunkCDWLZQQW_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
|
|
1910
|
+
var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkCDWLZQQW_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 chunkCDWLZQQW_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
|
|
1914
|
+
var ErrUnvalidatedOffchainOutput = (address) => new chunkCDWLZQQW_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 chunkCDWLZQQW_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 = chunkCDWLZQQW_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
|
+
chunkCDWLZQQW_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(chunk24YNIQSW_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
|
+
chunk24YNIQSW_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
|
+
chunk24YNIQSW_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
|
+
chunk24YNIQSW_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 = chunk24YNIQSW_cjs.AssetId.fromString(assetIdStr);
|
|
2252
|
+
const group = chunk24YNIQSW_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
|
|
2253
2253
|
groups.push(group);
|
|
2254
2254
|
}
|
|
2255
|
-
return
|
|
2255
|
+
return chunk24YNIQSW_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));
|
|
@@ -2357,8 +2357,8 @@ function buildOffchainTx(inputs, outputs, serverUnrollScript) {
|
|
|
2357
2357
|
function buildVirtualTx(inputs, outputs) {
|
|
2358
2358
|
let lockTime = 0n;
|
|
2359
2359
|
for (const input of inputs) {
|
|
2360
|
-
const tapscript =
|
|
2361
|
-
if (
|
|
2360
|
+
const tapscript = chunkCDWLZQQW_cjs.decodeTapscript(chunkCDWLZQQW_cjs.scriptFromTapLeafScript(input.tapLeafScript));
|
|
2361
|
+
if (chunkCDWLZQQW_cjs.CLTVMultisigTapscript.is(tapscript)) {
|
|
2362
2362
|
if (lockTime !== 0n) {
|
|
2363
2363
|
if (isSeconds(lockTime) !== isSeconds(tapscript.params.absoluteTimelock)) {
|
|
2364
2364
|
throw new Error("cannot mix seconds and blocks locktime");
|
|
@@ -2369,7 +2369,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
2369
2369
|
}
|
|
2370
2370
|
}
|
|
2371
2371
|
}
|
|
2372
|
-
const tx = new
|
|
2372
|
+
const tx = new chunkCDWLZQQW_cjs.Transaction({
|
|
2373
2373
|
version: 3,
|
|
2374
2374
|
lockTime: Number(lockTime)
|
|
2375
2375
|
});
|
|
@@ -2379,12 +2379,12 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
2379
2379
|
index: input.vout,
|
|
2380
2380
|
sequence: lockTime ? btcSigner.DEFAULT_SEQUENCE - 1 : void 0,
|
|
2381
2381
|
witnessUtxo: {
|
|
2382
|
-
script:
|
|
2382
|
+
script: chunkCDWLZQQW_cjs.VtxoScript.decode(input.tapTree).pkScript,
|
|
2383
2383
|
amount: BigInt(input.value)
|
|
2384
2384
|
},
|
|
2385
2385
|
tapLeafScript: [input.tapLeafScript]
|
|
2386
2386
|
});
|
|
2387
|
-
|
|
2387
|
+
chunkCDWLZQQW_cjs.setArkPsbtField(tx, i, chunkCDWLZQQW_cjs.VtxoTaprootTree, input.tapTree);
|
|
2388
2388
|
}
|
|
2389
2389
|
for (const output of outputs) {
|
|
2390
2390
|
tx.addOutput(output);
|
|
@@ -2393,8 +2393,8 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
2393
2393
|
return tx;
|
|
2394
2394
|
}
|
|
2395
2395
|
function buildCheckpointTx(vtxo, serverUnrollScript) {
|
|
2396
|
-
const collaborativeClosure =
|
|
2397
|
-
const checkpointVtxoScript = new
|
|
2396
|
+
const collaborativeClosure = chunkCDWLZQQW_cjs.decodeTapscript(chunkCDWLZQQW_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
|
|
2397
|
+
const checkpointVtxoScript = new chunkCDWLZQQW_cjs.VtxoScript([
|
|
2398
2398
|
serverUnrollScript.script,
|
|
2399
2399
|
collaborativeClosure.script
|
|
2400
2400
|
]);
|
|
@@ -2547,7 +2547,7 @@ function combineTapscriptSigs(signedTx, originalTx) {
|
|
|
2547
2547
|
}
|
|
2548
2548
|
function isValidArkAddress(address) {
|
|
2549
2549
|
try {
|
|
2550
|
-
|
|
2550
|
+
chunkCDWLZQQW_cjs.ArkAddress.decode(address);
|
|
2551
2551
|
return true;
|
|
2552
2552
|
} catch (e) {
|
|
2553
2553
|
return false;
|
|
@@ -2555,16 +2555,16 @@ function isValidArkAddress(address) {
|
|
|
2555
2555
|
}
|
|
2556
2556
|
function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, context) {
|
|
2557
2557
|
if (serverCheckpointTxs.length !== expectedCheckpoints.length) {
|
|
2558
|
-
throw new
|
|
2558
|
+
throw new chunkCDWLZQQW_cjs.ServerResponseMismatchError(
|
|
2559
2559
|
`${context} returned ${serverCheckpointTxs.length} checkpoints, expected ${expectedCheckpoints.length}`
|
|
2560
2560
|
);
|
|
2561
2561
|
}
|
|
2562
2562
|
const byTxid = new Map(expectedCheckpoints.map((c) => [c.id, c]));
|
|
2563
2563
|
return serverCheckpointTxs.map((encoded, index) => {
|
|
2564
|
-
const server =
|
|
2564
|
+
const server = chunkCDWLZQQW_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
|
|
2565
2565
|
const local = byTxid.get(server.id);
|
|
2566
2566
|
if (!local) {
|
|
2567
|
-
throw new
|
|
2567
|
+
throw new chunkCDWLZQQW_cjs.ServerResponseMismatchError(
|
|
2568
2568
|
`${context} checkpoint ${index} txid ${server.id} does not match any submitted checkpoint`
|
|
2569
2569
|
);
|
|
2570
2570
|
}
|
|
@@ -2574,14 +2574,14 @@ function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, contex
|
|
|
2574
2574
|
}
|
|
2575
2575
|
function assertSubmittedArkTxid(response, signedArkTx, context) {
|
|
2576
2576
|
if (response.arkTxid !== signedArkTx.id) {
|
|
2577
|
-
throw new
|
|
2577
|
+
throw new chunkCDWLZQQW_cjs.ServerResponseMismatchError(
|
|
2578
2578
|
`${context} returned ark txid ${response.arkTxid}, expected ${signedArkTx.id}`
|
|
2579
2579
|
);
|
|
2580
2580
|
}
|
|
2581
2581
|
if (response.finalArkTx === void 0) return;
|
|
2582
|
-
const finalTxid =
|
|
2582
|
+
const finalTxid = chunkCDWLZQQW_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
|
|
2583
2583
|
if (finalTxid !== signedArkTx.id) {
|
|
2584
|
-
throw new
|
|
2584
|
+
throw new chunkCDWLZQQW_cjs.ServerResponseMismatchError(
|
|
2585
2585
|
`${context} returned final ark tx ${finalTxid}, expected ${signedArkTx.id}`
|
|
2586
2586
|
);
|
|
2587
2587
|
}
|
|
@@ -2590,20 +2590,20 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
2590
2590
|
const byOutpoint = new Map(inputs.map((input) => [`${input.txid}:${input.vout}`, input]));
|
|
2591
2591
|
for (const [index, checkpoint] of checkpoints.entries()) {
|
|
2592
2592
|
if (checkpoint.inputsLength !== 1) {
|
|
2593
|
-
throw new
|
|
2593
|
+
throw new chunkCDWLZQQW_cjs.ServerResponseMismatchError(
|
|
2594
2594
|
`${context}: checkpoint ${index} spends ${checkpoint.inputsLength} inputs, expected 1`
|
|
2595
2595
|
);
|
|
2596
2596
|
}
|
|
2597
2597
|
const spent = checkpoint.getInput(0);
|
|
2598
2598
|
if (!spent.txid || spent.index === void 0) {
|
|
2599
|
-
throw new
|
|
2599
|
+
throw new chunkCDWLZQQW_cjs.ServerResponseMismatchError(
|
|
2600
2600
|
`${context}: checkpoint ${index} has no input outpoint`
|
|
2601
2601
|
);
|
|
2602
2602
|
}
|
|
2603
2603
|
const outpoint = `${base.hex.encode(spent.txid)}:${spent.index}`;
|
|
2604
2604
|
const input = byOutpoint.get(outpoint);
|
|
2605
2605
|
if (!input) {
|
|
2606
|
-
throw new
|
|
2606
|
+
throw new chunkCDWLZQQW_cjs.ServerResponseMismatchError(
|
|
2607
2607
|
`${context}: checkpoint ${index} spends ${outpoint}, which is not one of the requested virtual outputs`
|
|
2608
2608
|
);
|
|
2609
2609
|
}
|
|
@@ -2611,7 +2611,7 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
2611
2611
|
(unroll) => buildCheckpointTx(input, unroll).tx.id === checkpoint.id
|
|
2612
2612
|
);
|
|
2613
2613
|
if (!rebuilt) {
|
|
2614
|
-
throw new
|
|
2614
|
+
throw new chunkCDWLZQQW_cjs.ServerResponseMismatchError(
|
|
2615
2615
|
`${context}: checkpoint ${index} txid ${checkpoint.id} differs from the checkpoint built locally for ${outpoint}`
|
|
2616
2616
|
);
|
|
2617
2617
|
}
|
|
@@ -2845,7 +2845,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
|
|
|
2845
2845
|
};
|
|
2846
2846
|
}
|
|
2847
2847
|
function deriveContractTapscripts(contract) {
|
|
2848
|
-
const handler =
|
|
2848
|
+
const handler = chunk37XKN5DZ_cjs.contractHandlers.get(contract.type);
|
|
2849
2849
|
if (!handler) {
|
|
2850
2850
|
throw new Error(`No handler for contract type '${contract.type}'`);
|
|
2851
2851
|
}
|
|
@@ -2916,21 +2916,41 @@ function getRandomId() {
|
|
|
2916
2916
|
}
|
|
2917
2917
|
function isValidArkAddress2(address) {
|
|
2918
2918
|
try {
|
|
2919
|
-
|
|
2919
|
+
chunkCDWLZQQW_cjs.ArkAddress.decode(address);
|
|
2920
2920
|
return true;
|
|
2921
2921
|
} catch (e) {
|
|
2922
2922
|
return false;
|
|
2923
2923
|
}
|
|
2924
2924
|
}
|
|
2925
|
-
function
|
|
2925
|
+
function assertRecipientArkAddress(encoded, address, context) {
|
|
2926
|
+
if (address.hrp !== context.hrp) {
|
|
2927
|
+
throw new Error(
|
|
2928
|
+
`Invalid Arkade address ${encoded}: expected prefix "${context.hrp}", got "${address.hrp}"`
|
|
2929
|
+
);
|
|
2930
|
+
}
|
|
2931
|
+
const { status } = classifyAgainstSignerSet(
|
|
2932
|
+
base.hex.encode(address.serverPubKey),
|
|
2933
|
+
context.signerSet
|
|
2934
|
+
);
|
|
2935
|
+
if (status === "UNKNOWN_SIGNER") {
|
|
2936
|
+
throw new Error(`Invalid Arkade address ${encoded}: unknown operator signer key`);
|
|
2937
|
+
}
|
|
2938
|
+
if (status === "EXPIRED") {
|
|
2939
|
+
throw new Error(
|
|
2940
|
+
`Invalid Arkade address ${encoded}: operator signer key is past its rotation cutoff`
|
|
2941
|
+
);
|
|
2942
|
+
}
|
|
2943
|
+
}
|
|
2944
|
+
function validateRecipients(recipients, dustAmount, context) {
|
|
2926
2945
|
const validatedRecipients = [];
|
|
2927
2946
|
for (const recipient of recipients) {
|
|
2928
2947
|
let address;
|
|
2929
2948
|
try {
|
|
2930
|
-
address =
|
|
2949
|
+
address = chunkCDWLZQQW_cjs.ArkAddress.decode(recipient.address);
|
|
2931
2950
|
} catch (e) {
|
|
2932
2951
|
throw new Error(`Invalid Arkade address: ${recipient.address}`);
|
|
2933
2952
|
}
|
|
2953
|
+
assertRecipientArkAddress(recipient.address, address, context);
|
|
2934
2954
|
const amount = recipient.amount || dustAmount;
|
|
2935
2955
|
if (amount <= 0) {
|
|
2936
2956
|
throw new Error("Amount must be positive");
|
|
@@ -2955,7 +2975,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
|
|
|
2955
2975
|
continue;
|
|
2956
2976
|
}
|
|
2957
2977
|
for (const v of vtxos) {
|
|
2958
|
-
if (!
|
|
2978
|
+
if (!chunkCDWLZQQW_cjs.hasTerminalSpend(v) && !v.isSwept) out.add(`${v.txid}:${v.vout}`);
|
|
2959
2979
|
}
|
|
2960
2980
|
}
|
|
2961
2981
|
return out;
|
|
@@ -2988,10 +3008,10 @@ function byValueDescending(vtxos) {
|
|
|
2988
3008
|
return [...vtxos].sort((a, b) => b.value - a.value);
|
|
2989
3009
|
}
|
|
2990
3010
|
async function fetchTimeHeight(wallet) {
|
|
2991
|
-
return
|
|
3011
|
+
return chunkCDWLZQQW_cjs.resolveTimeHeight(wallet.onchainProvider);
|
|
2992
3012
|
}
|
|
2993
3013
|
function canMigrateBySend(vtxo, now) {
|
|
2994
|
-
if (!
|
|
3014
|
+
if (!chunkCDWLZQQW_cjs.canSpendOffchain(vtxo, now)) return false;
|
|
2995
3015
|
return vtxo.expiresAt !== void 0 || vtxo.expiresAtHeight !== void 0;
|
|
2996
3016
|
}
|
|
2997
3017
|
function byExpiryAscending(vtxos, now) {
|
|
@@ -2999,7 +3019,7 @@ function byExpiryAscending(vtxos, now) {
|
|
|
2999
3019
|
if (vtxo.isSwept) return -Infinity;
|
|
3000
3020
|
if (vtxo.expiresAt !== void 0) return vtxo.expiresAt.getTime();
|
|
3001
3021
|
if (vtxo.expiresAtHeight !== void 0) {
|
|
3002
|
-
return
|
|
3022
|
+
return chunkCDWLZQQW_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
|
|
3003
3023
|
}
|
|
3004
3024
|
return Infinity;
|
|
3005
3025
|
};
|
|
@@ -3036,10 +3056,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
|
|
|
3036
3056
|
};
|
|
3037
3057
|
function getRecoverableVtxos(vtxos, dustAmount, now) {
|
|
3038
3058
|
return vtxos.filter((vtxo) => {
|
|
3039
|
-
if (
|
|
3059
|
+
if (chunkCDWLZQQW_cjs.canRecoverOnchain(vtxo, now)) {
|
|
3040
3060
|
return true;
|
|
3041
3061
|
}
|
|
3042
|
-
if (
|
|
3062
|
+
if (chunkCDWLZQQW_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
|
|
3043
3063
|
return true;
|
|
3044
3064
|
}
|
|
3045
3065
|
return false;
|
|
@@ -3070,7 +3090,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
|
|
|
3070
3090
|
}
|
|
3071
3091
|
function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
3072
3092
|
const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
|
|
3073
|
-
const expiresAt =
|
|
3093
|
+
const expiresAt = chunkCDWLZQQW_cjs.normalizeVtxo(vtxo).expiresAt;
|
|
3074
3094
|
if (expiresAt === void 0) return false;
|
|
3075
3095
|
const now = Date.now();
|
|
3076
3096
|
const batchExpiry = expiresAt.getTime();
|
|
@@ -3079,7 +3099,7 @@ function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
|
3079
3099
|
}
|
|
3080
3100
|
function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
|
|
3081
3101
|
return vtxos.filter(
|
|
3082
|
-
(vtxo) => isVtxoExpiringSoon(vtxo, thresholdMs) ||
|
|
3102
|
+
(vtxo) => isVtxoExpiringSoon(vtxo, thresholdMs) || chunkCDWLZQQW_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount)
|
|
3083
3103
|
);
|
|
3084
3104
|
}
|
|
3085
3105
|
function isMigrationCapable(wallet) {
|
|
@@ -3561,11 +3581,11 @@ var VtxoManager = class _VtxoManager {
|
|
|
3561
3581
|
`Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
|
|
3562
3582
|
);
|
|
3563
3583
|
}
|
|
3564
|
-
const tx = new
|
|
3584
|
+
const tx = new chunkCDWLZQQW_cjs.Transaction();
|
|
3565
3585
|
for (const utxo of expiredUtxos) {
|
|
3566
|
-
const utxoScript =
|
|
3586
|
+
const utxoScript = chunkCDWLZQQW_cjs.VtxoScript.decode(utxo.tapTree);
|
|
3567
3587
|
const utxoExitLeaf = utxoScript.leaves.find(
|
|
3568
|
-
(leaf) =>
|
|
3588
|
+
(leaf) => chunkCDWLZQQW_cjs.CSVMultisigTapscript.isScriptValid(chunkCDWLZQQW_cjs.scriptFromTapLeafScript(leaf)) === true
|
|
3569
3589
|
);
|
|
3570
3590
|
if (!utxoExitLeaf) {
|
|
3571
3591
|
throw new Error(
|
|
@@ -3580,7 +3600,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
3580
3600
|
amount: BigInt(utxo.value)
|
|
3581
3601
|
},
|
|
3582
3602
|
tapLeafScript: [utxoExitLeaf],
|
|
3583
|
-
sequence:
|
|
3603
|
+
sequence: chunkCDWLZQQW_cjs.getSequence(utxoExitLeaf)
|
|
3584
3604
|
});
|
|
3585
3605
|
}
|
|
3586
3606
|
tx.addOutputAddress(boardingAddress, outputAmount, this.getNetwork());
|
|
@@ -3814,8 +3834,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
3814
3834
|
if (!serverPubKey) continue;
|
|
3815
3835
|
const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
|
|
3816
3836
|
if (cls.status === "CURRENT") continue;
|
|
3817
|
-
const recoverable = vtxos.filter((v) => v.isSwept && !
|
|
3818
|
-
const spendable = vtxos.filter((v) => !
|
|
3837
|
+
const recoverable = vtxos.filter((v) => v.isSwept && !chunkCDWLZQQW_cjs.hasTerminalSpend(v));
|
|
3838
|
+
const spendable = vtxos.filter((v) => !chunkCDWLZQQW_cjs.hasTerminalSpend(v) && !v.isSwept);
|
|
3819
3839
|
const value = spendable.reduce((sum, v) => sum + v.value, 0);
|
|
3820
3840
|
let recoverableCount = 0;
|
|
3821
3841
|
let recoverableValue = 0;
|
|
@@ -3828,7 +3848,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
3828
3848
|
awaitingSweepCount = spendable.length;
|
|
3829
3849
|
awaitingSweepValue = value;
|
|
3830
3850
|
for (const v of spendable) {
|
|
3831
|
-
const exp =
|
|
3851
|
+
const exp = chunkCDWLZQQW_cjs.toBatchExpiry(v);
|
|
3832
3852
|
if (exp !== void 0 && (nextSweepEta === void 0 || exp < nextSweepEta)) {
|
|
3833
3853
|
nextSweepEta = exp;
|
|
3834
3854
|
}
|
|
@@ -4089,7 +4109,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4089
4109
|
/** Decodes the boarding tapscript exit path to extract the CSV timelock. */
|
|
4090
4110
|
getBoardingTimelock() {
|
|
4091
4111
|
const wallet = this.getSweepWallet();
|
|
4092
|
-
const exitScript =
|
|
4112
|
+
const exitScript = chunkCDWLZQQW_cjs.CSVMultisigTapscript.decode(
|
|
4093
4113
|
base.hex.decode(wallet.boardingTapscript.exitScript)
|
|
4094
4114
|
);
|
|
4095
4115
|
return exitScript.params.timelock;
|
|
@@ -4220,8 +4240,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
4220
4240
|
* or doesn't carry the metadata.
|
|
4221
4241
|
*/
|
|
4222
4242
|
extractSpentOutpoint(error) {
|
|
4223
|
-
const ark =
|
|
4224
|
-
if (!
|
|
4243
|
+
const ark = chunkCDWLZQQW_cjs.maybeArkError(error);
|
|
4244
|
+
if (!chunkCDWLZQQW_cjs.isArkError(ark, chunkCDWLZQQW_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
|
|
4225
4245
|
const raw = ark.metadata?.vtxo_outpoint;
|
|
4226
4246
|
if (typeof raw !== "string") return void 0;
|
|
4227
4247
|
const [txid, voutStr] = raw.split(":");
|
|
@@ -4411,7 +4431,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4411
4431
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
4412
4432
|
break;
|
|
4413
4433
|
}
|
|
4414
|
-
const inputFee = estimator.evalOffchainInput(
|
|
4434
|
+
const inputFee = estimator.evalOffchainInput(chunkCDWLZQQW_cjs.toOffchainInputFeeParams(v));
|
|
4415
4435
|
if (inputFee.satoshis >= v.value) {
|
|
4416
4436
|
continue;
|
|
4417
4437
|
}
|
|
@@ -4431,7 +4451,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4431
4451
|
const arkAddress = await this.wallet.getAddress();
|
|
4432
4452
|
const outputFee = estimator.evalOffchainOutput({
|
|
4433
4453
|
amount: totalAmount,
|
|
4434
|
-
script: base.hex.encode(
|
|
4454
|
+
script: base.hex.encode(chunkCDWLZQQW_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
4435
4455
|
});
|
|
4436
4456
|
totalAmount -= BigInt(outputFee.satoshis);
|
|
4437
4457
|
if (totalAmount < dustAmount) return;
|
|
@@ -4511,7 +4531,7 @@ var ArkNote = class _ArkNote {
|
|
|
4511
4531
|
this.value = value;
|
|
4512
4532
|
this.HRP = HRP;
|
|
4513
4533
|
const preimageHash = utils_js.sha256(this.preimage);
|
|
4514
|
-
this.vtxoScript = new
|
|
4534
|
+
this.vtxoScript = new chunkCDWLZQQW_cjs.VtxoScript([noteTapscript(preimageHash)]);
|
|
4515
4535
|
const leaf = this.vtxoScript.leaves[0];
|
|
4516
4536
|
this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
|
|
4517
4537
|
this.tapTree = this.vtxoScript.encode();
|
|
@@ -4678,7 +4698,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
4678
4698
|
const privateKey = data.slice(1, 33);
|
|
4679
4699
|
const serverPubKey = data.slice(33, 65);
|
|
4680
4700
|
const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
|
|
4681
|
-
const csvTimelock =
|
|
4701
|
+
const csvTimelock = chunkCDWLZQQW_cjs.sequenceToTimelock(sequence);
|
|
4682
4702
|
return new _ArkadeCash(privateKey, serverPubKey, csvTimelock, decoded.prefix);
|
|
4683
4703
|
}
|
|
4684
4704
|
toString() {
|
|
@@ -4686,7 +4706,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
4686
4706
|
data[0] = _ArkadeCash.Version;
|
|
4687
4707
|
data.set(this._privateKey, 1);
|
|
4688
4708
|
data.set(this._serverPubKey, 33);
|
|
4689
|
-
const sequence =
|
|
4709
|
+
const sequence = chunkCDWLZQQW_cjs.timelockToSequence(this.csvTimelock);
|
|
4690
4710
|
new DataView(data.buffer, data.byteOffset + 65, 4).setUint32(0, sequence, false);
|
|
4691
4711
|
const words = base.bech32m.toWords(data);
|
|
4692
4712
|
return base.bech32m.encode(this.hrp, words, 1023);
|
|
@@ -4695,7 +4715,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
4695
4715
|
return SingleKey.fromPrivateKey(this._privateKey);
|
|
4696
4716
|
}
|
|
4697
4717
|
get vtxoScript() {
|
|
4698
|
-
return new
|
|
4718
|
+
return new chunk37XKN5DZ_cjs.DefaultVtxo.Script({
|
|
4699
4719
|
pubKey: this._publicKey,
|
|
4700
4720
|
serverPubKey: this._serverPubKey,
|
|
4701
4721
|
csvTimelock: this.csvTimelock
|
|
@@ -4956,7 +4976,7 @@ async function captureExitBranch(params) {
|
|
|
4956
4976
|
const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
|
|
4957
4977
|
if (nonCommitment.length > 0) {
|
|
4958
4978
|
for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
|
|
4959
|
-
psbtByTxid.set(
|
|
4979
|
+
psbtByTxid.set(chunkCDWLZQQW_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
4960
4980
|
}
|
|
4961
4981
|
}
|
|
4962
4982
|
}
|
|
@@ -4999,10 +5019,10 @@ var IndexerExitDataSource = class {
|
|
|
4999
5019
|
while (hasMore) {
|
|
5000
5020
|
const { chain: page, page: meta } = await this.indexer.getVtxoChain(
|
|
5001
5021
|
{ txid: vtxo.txid, vout: vtxo.vout },
|
|
5002
|
-
{ pageIndex, pageSize:
|
|
5022
|
+
{ pageIndex, pageSize: chunkCDWLZQQW_cjs.DEFAULT_PAGE_SIZE }
|
|
5003
5023
|
);
|
|
5004
5024
|
chain.push(...page);
|
|
5005
|
-
hasMore = meta ? page.length ===
|
|
5025
|
+
hasMore = meta ? page.length === chunkCDWLZQQW_cjs.DEFAULT_PAGE_SIZE : false;
|
|
5006
5026
|
pageIndex++;
|
|
5007
5027
|
}
|
|
5008
5028
|
return chain;
|
|
@@ -5014,12 +5034,12 @@ var IndexerExitDataSource = class {
|
|
|
5014
5034
|
while (hasMore) {
|
|
5015
5035
|
const { txs, page } = await this.indexer.getVirtualTxs(txids, {
|
|
5016
5036
|
pageIndex,
|
|
5017
|
-
pageSize:
|
|
5037
|
+
pageSize: chunkCDWLZQQW_cjs.DEFAULT_PAGE_SIZE
|
|
5018
5038
|
});
|
|
5019
5039
|
for (const psbt of txs) {
|
|
5020
|
-
out.set(
|
|
5040
|
+
out.set(chunkCDWLZQQW_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
5021
5041
|
}
|
|
5022
|
-
hasMore = page ? txs.length ===
|
|
5042
|
+
hasMore = page ? txs.length === chunkCDWLZQQW_cjs.DEFAULT_PAGE_SIZE : false;
|
|
5023
5043
|
pageIndex++;
|
|
5024
5044
|
}
|
|
5025
5045
|
return out;
|
|
@@ -5040,7 +5060,7 @@ function chainedTxTypeToChainTxType(t) {
|
|
|
5040
5060
|
}
|
|
5041
5061
|
}
|
|
5042
5062
|
function psbtInputTxids(psbtBase64) {
|
|
5043
|
-
const tx =
|
|
5063
|
+
const tx = chunkCDWLZQQW_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
5044
5064
|
const ids = [];
|
|
5045
5065
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
5046
5066
|
const txid = tx.getInput(i).txid;
|
|
@@ -5388,10 +5408,10 @@ async function resolveArkInfo(arkProvider, walletRepository) {
|
|
|
5388
5408
|
try {
|
|
5389
5409
|
info = await arkProvider.getInfo();
|
|
5390
5410
|
} catch (err) {
|
|
5391
|
-
if (!
|
|
5411
|
+
if (!chunkCDWLZQQW_cjs.isRetryableProviderError(err)) throw err;
|
|
5392
5412
|
const snapshot = await loadArkInfoSnapshot(walletRepository);
|
|
5393
5413
|
if (!snapshot) {
|
|
5394
|
-
throw new
|
|
5414
|
+
throw new chunkCDWLZQQW_cjs.ProviderUnavailableError(
|
|
5395
5415
|
"Arkade server info is unavailable and no cached snapshot exists",
|
|
5396
5416
|
{ cause: err }
|
|
5397
5417
|
);
|
|
@@ -5774,7 +5794,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos) {
|
|
|
5774
5794
|
return [...txids];
|
|
5775
5795
|
}
|
|
5776
5796
|
async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt) {
|
|
5777
|
-
const fromOldestVtxo = vtxos.map(
|
|
5797
|
+
const fromOldestVtxo = vtxos.map(chunkCDWLZQQW_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
5778
5798
|
const txidsNeedingCreatedAt = resolveTxCreatedAt ? collectArkTxidsNeedingCreatedAt(fromOldestVtxo) : [];
|
|
5779
5799
|
const resolvedCreatedAt = resolveTxCreatedAt && txidsNeedingCreatedAt.length > 0 ? await resolveTxCreatedAt(txidsNeedingCreatedAt) : /* @__PURE__ */ new Map();
|
|
5780
5800
|
const unmatchedSettledBoardingTxs = allBoardingTxs.filter(isSettledBoardingReceive).sort((a, b) => a.createdAt - b.createdAt);
|
|
@@ -5938,7 +5958,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5938
5958
|
const virtualCoins = await this.wallet.getVtxos({
|
|
5939
5959
|
withRecoverable: false
|
|
5940
5960
|
});
|
|
5941
|
-
const controlAssetRef = params.controlAssetId ?
|
|
5961
|
+
const controlAssetRef = params.controlAssetId ? chunk24YNIQSW_cjs.AssetRef.fromId(chunk24YNIQSW_cjs.AssetId.fromString(params.controlAssetId)) : null;
|
|
5942
5962
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
5943
5963
|
let totalBtcSelected = 0n;
|
|
5944
5964
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -5951,8 +5971,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5951
5971
|
}
|
|
5952
5972
|
}
|
|
5953
5973
|
const groups = [];
|
|
5954
|
-
const issuedAssetOutput =
|
|
5955
|
-
const issuedAssetGroup =
|
|
5974
|
+
const issuedAssetOutput = chunk24YNIQSW_cjs.AssetOutput.create(0, params.amount);
|
|
5975
|
+
const issuedAssetGroup = chunk24YNIQSW_cjs.AssetGroup.create(
|
|
5956
5976
|
null,
|
|
5957
5977
|
controlAssetRef,
|
|
5958
5978
|
[],
|
|
@@ -5967,28 +5987,28 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5967
5987
|
for (const [inputIndex, assets] of assetInputs) {
|
|
5968
5988
|
for (const asset of assets) {
|
|
5969
5989
|
if (asset.assetId !== assetId) continue;
|
|
5970
|
-
changeInputs.push(
|
|
5990
|
+
changeInputs.push(chunk24YNIQSW_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
5971
5991
|
}
|
|
5972
5992
|
}
|
|
5973
5993
|
groups.push(
|
|
5974
|
-
|
|
5975
|
-
|
|
5994
|
+
chunk24YNIQSW_cjs.AssetGroup.create(
|
|
5995
|
+
chunk24YNIQSW_cjs.AssetId.fromString(assetId),
|
|
5976
5996
|
null,
|
|
5977
5997
|
changeInputs,
|
|
5978
|
-
[
|
|
5998
|
+
[chunk24YNIQSW_cjs.AssetOutput.create(0, amount)],
|
|
5979
5999
|
[]
|
|
5980
6000
|
)
|
|
5981
6001
|
);
|
|
5982
6002
|
}
|
|
5983
6003
|
}
|
|
5984
6004
|
const address = await this.wallet.getAddress();
|
|
5985
|
-
const outputAddress =
|
|
6005
|
+
const outputAddress = chunkCDWLZQQW_cjs.ArkAddress.decode(address);
|
|
5986
6006
|
const outputs = [
|
|
5987
6007
|
{
|
|
5988
6008
|
script: outputAddress.pkScript,
|
|
5989
6009
|
amount: BigInt(totalBtcSelected)
|
|
5990
6010
|
},
|
|
5991
|
-
Extension.create([
|
|
6011
|
+
Extension.create([chunk24YNIQSW_cjs.Packet.create(groups)]).txOut()
|
|
5992
6012
|
];
|
|
5993
6013
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
|
|
5994
6014
|
coinSelection.inputs,
|
|
@@ -5996,7 +6016,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5996
6016
|
);
|
|
5997
6017
|
return {
|
|
5998
6018
|
arkTxId: arkTxid,
|
|
5999
|
-
assetId:
|
|
6019
|
+
assetId: chunk24YNIQSW_cjs.AssetId.create(arkTxid, 0).toString()
|
|
6000
6020
|
};
|
|
6001
6021
|
}
|
|
6002
6022
|
/**
|
|
@@ -6068,16 +6088,16 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6068
6088
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6069
6089
|
for (const asset of assets) {
|
|
6070
6090
|
if (asset.assetId !== params.assetId) continue;
|
|
6071
|
-
reissueInputs.push(
|
|
6091
|
+
reissueInputs.push(chunk24YNIQSW_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6072
6092
|
}
|
|
6073
6093
|
}
|
|
6074
6094
|
const totalAssetAmount = assetToReissueAmount + params.amount;
|
|
6075
|
-
const reissueAssetIdObj =
|
|
6076
|
-
const reissueAssetGroup =
|
|
6095
|
+
const reissueAssetIdObj = chunk24YNIQSW_cjs.AssetId.fromString(params.assetId);
|
|
6096
|
+
const reissueAssetGroup = chunk24YNIQSW_cjs.AssetGroup.create(
|
|
6077
6097
|
reissueAssetIdObj,
|
|
6078
6098
|
null,
|
|
6079
6099
|
reissueInputs,
|
|
6080
|
-
[
|
|
6100
|
+
[chunk24YNIQSW_cjs.AssetOutput.create(0, totalAssetAmount)],
|
|
6081
6101
|
[]
|
|
6082
6102
|
);
|
|
6083
6103
|
const groups = [reissueAssetGroup];
|
|
@@ -6086,27 +6106,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6086
6106
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6087
6107
|
for (const asset of assets) {
|
|
6088
6108
|
if (asset.assetId !== assetId) continue;
|
|
6089
|
-
changeInputs.push(
|
|
6109
|
+
changeInputs.push(chunk24YNIQSW_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6090
6110
|
}
|
|
6091
6111
|
}
|
|
6092
6112
|
groups.push(
|
|
6093
|
-
|
|
6094
|
-
|
|
6113
|
+
chunk24YNIQSW_cjs.AssetGroup.create(
|
|
6114
|
+
chunk24YNIQSW_cjs.AssetId.fromString(assetId),
|
|
6095
6115
|
null,
|
|
6096
6116
|
changeInputs,
|
|
6097
|
-
[
|
|
6117
|
+
[chunk24YNIQSW_cjs.AssetOutput.create(0, amount)],
|
|
6098
6118
|
[]
|
|
6099
6119
|
)
|
|
6100
6120
|
);
|
|
6101
6121
|
}
|
|
6102
6122
|
const address = await this.wallet.getAddress();
|
|
6103
|
-
const outputAddress =
|
|
6123
|
+
const outputAddress = chunkCDWLZQQW_cjs.ArkAddress.decode(address);
|
|
6104
6124
|
const outputs = [
|
|
6105
6125
|
{
|
|
6106
6126
|
script: outputAddress.pkScript,
|
|
6107
6127
|
amount: BigInt(totalBtcSelected)
|
|
6108
6128
|
},
|
|
6109
|
-
Extension.create([
|
|
6129
|
+
Extension.create([chunk24YNIQSW_cjs.Packet.create(groups)]).txOut()
|
|
6110
6130
|
];
|
|
6111
6131
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
6112
6132
|
return arkTxid;
|
|
@@ -6173,27 +6193,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
6173
6193
|
for (const [inputIndex, assets] of assetInputs) {
|
|
6174
6194
|
for (const asset of assets) {
|
|
6175
6195
|
if (asset.assetId !== assetId) continue;
|
|
6176
|
-
changeInputs.push(
|
|
6196
|
+
changeInputs.push(chunk24YNIQSW_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
6177
6197
|
}
|
|
6178
6198
|
}
|
|
6179
6199
|
groups.push(
|
|
6180
|
-
|
|
6181
|
-
|
|
6200
|
+
chunk24YNIQSW_cjs.AssetGroup.create(
|
|
6201
|
+
chunk24YNIQSW_cjs.AssetId.fromString(assetId),
|
|
6182
6202
|
null,
|
|
6183
6203
|
changeInputs,
|
|
6184
|
-
amount > 0n ? [
|
|
6204
|
+
amount > 0n ? [chunk24YNIQSW_cjs.AssetOutput.create(0, amount)] : [],
|
|
6185
6205
|
[]
|
|
6186
6206
|
)
|
|
6187
6207
|
);
|
|
6188
6208
|
}
|
|
6189
6209
|
const address = await this.wallet.getAddress();
|
|
6190
|
-
const outputAddress =
|
|
6210
|
+
const outputAddress = chunkCDWLZQQW_cjs.ArkAddress.decode(address);
|
|
6191
6211
|
const outputs = [
|
|
6192
6212
|
{
|
|
6193
6213
|
script: outputAddress.pkScript,
|
|
6194
6214
|
amount: BigInt(totalBtcSelected)
|
|
6195
6215
|
},
|
|
6196
|
-
Extension.create([
|
|
6216
|
+
Extension.create([chunk24YNIQSW_cjs.Packet.create(groups)]).txOut()
|
|
6197
6217
|
];
|
|
6198
6218
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
6199
6219
|
return arkTxid;
|
|
@@ -6218,7 +6238,7 @@ function castMetadata(metadata) {
|
|
|
6218
6238
|
} else {
|
|
6219
6239
|
throw new Error("Invalid metadata value type");
|
|
6220
6240
|
}
|
|
6221
|
-
md.push(
|
|
6241
|
+
md.push(chunk24YNIQSW_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
|
|
6222
6242
|
}
|
|
6223
6243
|
return md;
|
|
6224
6244
|
}
|
|
@@ -6239,10 +6259,10 @@ var DelegateManagerImpl = class {
|
|
|
6239
6259
|
if (vtxos.length === 0) {
|
|
6240
6260
|
return { delegated: [], failed: [] };
|
|
6241
6261
|
}
|
|
6242
|
-
const destinationScript =
|
|
6262
|
+
const destinationScript = chunkCDWLZQQW_cjs.ArkAddress.decode(destination).pkScript;
|
|
6243
6263
|
const arkInfo = await this.arkInfoProvider.getInfo();
|
|
6244
6264
|
const delegateInfo = await this.delegateProvider.getDelegateInfo();
|
|
6245
|
-
const eligible = vtxos.map(
|
|
6265
|
+
const eligible = vtxos.map(chunkCDWLZQQW_cjs.normalizeVtxo).filter(
|
|
6246
6266
|
(v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
|
|
6247
6267
|
);
|
|
6248
6268
|
if (eligible.length === 0) {
|
|
@@ -6271,11 +6291,11 @@ var DelegateManagerImpl = class {
|
|
|
6271
6291
|
const groupByExpiry = /* @__PURE__ */ new Map();
|
|
6272
6292
|
let recoverableVtxos = [];
|
|
6273
6293
|
for (const vtxo of eligible) {
|
|
6274
|
-
if (
|
|
6294
|
+
if (chunkCDWLZQQW_cjs.canRecoverOnchain(vtxo, now)) {
|
|
6275
6295
|
recoverableVtxos.push(vtxo);
|
|
6276
6296
|
continue;
|
|
6277
6297
|
}
|
|
6278
|
-
const expiry =
|
|
6298
|
+
const expiry = chunkCDWLZQQW_cjs.toBatchExpiry(vtxo);
|
|
6279
6299
|
if (!expiry) continue;
|
|
6280
6300
|
const dayKey = getDayTimestamp(expiry);
|
|
6281
6301
|
groupByExpiry.set(dayKey, [...groupByExpiry.get(dayKey) ?? [], vtxo]);
|
|
@@ -6340,7 +6360,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6340
6360
|
}
|
|
6341
6361
|
if (!delegateAt) {
|
|
6342
6362
|
const now = { timestamp: /* @__PURE__ */ new Date() };
|
|
6343
|
-
const expiryTimestamp = vtxos.filter((coin) => !
|
|
6363
|
+
const expiryTimestamp = vtxos.filter((coin) => !chunkCDWLZQQW_cjs.canRecoverOnchain(coin, now) && chunkCDWLZQQW_cjs.toBatchExpiry(coin)).reduce((min, coin) => Math.min(min, chunkCDWLZQQW_cjs.toBatchExpiry(coin)), Number.MAX_SAFE_INTEGER);
|
|
6344
6364
|
if (!expiryTimestamp || expiryTimestamp === Number.MAX_SAFE_INTEGER) {
|
|
6345
6365
|
delegateAt = new Date(Date.now() + 1 * 60 * 1e3);
|
|
6346
6366
|
} else {
|
|
@@ -6369,7 +6389,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6369
6389
|
let amount = 0n;
|
|
6370
6390
|
for (const coin of vtxos) {
|
|
6371
6391
|
const inputFee = estimator.evalOffchainInput({
|
|
6372
|
-
...
|
|
6392
|
+
...chunkCDWLZQQW_cjs.toOffchainInputFeeParams(coin),
|
|
6373
6393
|
type: "vtxo"
|
|
6374
6394
|
});
|
|
6375
6395
|
if (inputFee.value >= coin.value) {
|
|
@@ -6383,7 +6403,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6383
6403
|
const delegateFee = BigInt(Number(fee));
|
|
6384
6404
|
if (delegateFee > 0n) {
|
|
6385
6405
|
outputs.push({
|
|
6386
|
-
script:
|
|
6406
|
+
script: chunkCDWLZQQW_cjs.ArkAddress.decode(delegateAddress).pkScript,
|
|
6387
6407
|
amount: delegateFee
|
|
6388
6408
|
});
|
|
6389
6409
|
}
|
|
@@ -6416,10 +6436,10 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6416
6436
|
destinationScript
|
|
6417
6437
|
);
|
|
6418
6438
|
const forfeitOutputScript = btcSigner.OutScript.encode(
|
|
6419
|
-
btcSigner.Address(
|
|
6439
|
+
btcSigner.Address(chunkCDWLZQQW_cjs.getNetwork(network)).decode(forfeitAddress)
|
|
6420
6440
|
);
|
|
6421
6441
|
const forfeits = await Promise.all(
|
|
6422
|
-
vtxos.filter((v) => !
|
|
6442
|
+
vtxos.filter((v) => !chunkCDWLZQQW_cjs.canRecoverOnchain(v, { timestamp: /* @__PURE__ */ new Date() })).map(async (coin) => {
|
|
6423
6443
|
const forfeit = await makeDelegateForfeitTx(
|
|
6424
6444
|
coin,
|
|
6425
6445
|
dust,
|
|
@@ -6444,7 +6464,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
|
|
|
6444
6464
|
index: input.vout,
|
|
6445
6465
|
witnessUtxo: {
|
|
6446
6466
|
amount: BigInt(input.value),
|
|
6447
|
-
script:
|
|
6467
|
+
script: chunkCDWLZQQW_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
6448
6468
|
},
|
|
6449
6469
|
sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
|
|
6450
6470
|
tapLeafScript: [delegateTapLeaf]
|
|
@@ -6502,7 +6522,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
6502
6522
|
expire_at: 0,
|
|
6503
6523
|
cosigners_public_keys: cosignerPubKeys
|
|
6504
6524
|
};
|
|
6505
|
-
const proof =
|
|
6525
|
+
const proof = chunkCDWLZQQW_cjs.Intent.create(message, coins, outputs);
|
|
6506
6526
|
const signedProof = await identity.sign(proof);
|
|
6507
6527
|
return {
|
|
6508
6528
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -6520,10 +6540,10 @@ function getDayTimestamp(timestamp) {
|
|
|
6520
6540
|
function findDelegateTapLeaf(vtxo, delegatePubkey) {
|
|
6521
6541
|
if (!vtxo.tapTree) return void 0;
|
|
6522
6542
|
const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
|
|
6523
|
-
const vtxoScript =
|
|
6543
|
+
const vtxoScript = chunkCDWLZQQW_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
6524
6544
|
return vtxoScript.leaves.find((tapLeaf) => {
|
|
6525
|
-
const arkTapscript =
|
|
6526
|
-
if (!
|
|
6545
|
+
const arkTapscript = chunkCDWLZQQW_cjs.decodeTapscript(chunkCDWLZQQW_cjs.scriptFromTapLeafScript(tapLeaf));
|
|
6546
|
+
if (!chunkCDWLZQQW_cjs.MultisigTapscript.is(arkTapscript)) return false;
|
|
6527
6547
|
return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
|
|
6528
6548
|
});
|
|
6529
6549
|
}
|
|
@@ -6711,7 +6731,7 @@ async function closeDatabase(dbName) {
|
|
|
6711
6731
|
return true;
|
|
6712
6732
|
}
|
|
6713
6733
|
function scriptFromArkAddress(address) {
|
|
6714
|
-
return base.hex.encode(
|
|
6734
|
+
return base.hex.encode(chunkCDWLZQQW_cjs.ArkAddress.decode(address).pkScript);
|
|
6715
6735
|
}
|
|
6716
6736
|
|
|
6717
6737
|
// src/repositories/indexedDB/schema.ts
|
|
@@ -7208,7 +7228,7 @@ function validateVtxosForScript(vtxos, script, context) {
|
|
|
7208
7228
|
}
|
|
7209
7229
|
async function getVtxosForContract(repo, contract) {
|
|
7210
7230
|
const vtxos = repo.getVtxosForScript ? await repo.getVtxosForScript(contract.script) : filterVtxosForScript(await repo.getVtxos(contract.address), contract.script);
|
|
7211
|
-
return vtxos.map(
|
|
7231
|
+
return vtxos.map(chunkCDWLZQQW_cjs.normalizeVtxo);
|
|
7212
7232
|
}
|
|
7213
7233
|
async function saveVtxosForContract(repo, contract, vtxos) {
|
|
7214
7234
|
if (repo.saveVtxosForScript) {
|
|
@@ -7412,7 +7432,7 @@ var deserializeTapLeaf = (t) => {
|
|
|
7412
7432
|
const s = base.hex.decode(t.s);
|
|
7413
7433
|
return [cb, s];
|
|
7414
7434
|
};
|
|
7415
|
-
var deserializeVtxo = (o) =>
|
|
7435
|
+
var deserializeVtxo = (o) => chunkCDWLZQQW_cjs.normalizeVtxo({
|
|
7416
7436
|
...o,
|
|
7417
7437
|
createdAt: new Date(o.createdAt),
|
|
7418
7438
|
tapTree: base.hex.decode(o.tapTree),
|
|
@@ -8551,7 +8571,7 @@ var ContractWatcher = class {
|
|
|
8551
8571
|
this.connectionState = "connected";
|
|
8552
8572
|
this.reconnectAttempts = 0;
|
|
8553
8573
|
this.listenLoop().catch((e) => {
|
|
8554
|
-
if (
|
|
8574
|
+
if (chunkCDWLZQQW_cjs.isEventSourceError(e)) {
|
|
8555
8575
|
console.debug("ContractWatcher subscription disconnected; reconnecting");
|
|
8556
8576
|
} else {
|
|
8557
8577
|
console.error(e);
|
|
@@ -8780,14 +8800,14 @@ var ContractWatcher = class {
|
|
|
8780
8800
|
const timestamp = Date.now();
|
|
8781
8801
|
if (update.newVtxos?.length) {
|
|
8782
8802
|
this.processSubscriptionVtxos(
|
|
8783
|
-
update.newVtxos.map(
|
|
8803
|
+
update.newVtxos.map(chunkCDWLZQQW_cjs.normalizeVtxo),
|
|
8784
8804
|
"vtxo_received",
|
|
8785
8805
|
timestamp
|
|
8786
8806
|
);
|
|
8787
8807
|
}
|
|
8788
8808
|
if (update.spentVtxos?.length) {
|
|
8789
8809
|
this.processSubscriptionVtxos(
|
|
8790
|
-
update.spentVtxos.map(
|
|
8810
|
+
update.spentVtxos.map(chunkCDWLZQQW_cjs.normalizeVtxo),
|
|
8791
8811
|
"vtxo_spent",
|
|
8792
8812
|
timestamp
|
|
8793
8813
|
);
|
|
@@ -8920,7 +8940,7 @@ async function reconcileIntents(deps) {
|
|
|
8920
8940
|
let vtxosByOutpoint = /* @__PURE__ */ new Map();
|
|
8921
8941
|
if (outpoints.length > 0) {
|
|
8922
8942
|
try {
|
|
8923
|
-
const { vtxos } = await
|
|
8943
|
+
const { vtxos } = await chunkCDWLZQQW_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
|
|
8924
8944
|
vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
|
|
8925
8945
|
} catch (e) {
|
|
8926
8946
|
console.error("reconcileIntents: failed to fetch input VTXO state", e);
|
|
@@ -9040,7 +9060,7 @@ var ContractManager = class _ContractManager {
|
|
|
9040
9060
|
await this.reconcileWatched();
|
|
9041
9061
|
this.markSyncOnline();
|
|
9042
9062
|
} catch (err) {
|
|
9043
|
-
if (!
|
|
9063
|
+
if (!chunkCDWLZQQW_cjs.isRetryableProviderError(err)) throw err;
|
|
9044
9064
|
this.markSyncDegraded(err);
|
|
9045
9065
|
}
|
|
9046
9066
|
this.initialized = true;
|
|
@@ -9152,7 +9172,7 @@ var ContractManager = class _ContractManager {
|
|
|
9152
9172
|
const from = Math.max(0, watermark - lookAhead.size);
|
|
9153
9173
|
const to = watermark + lookAhead.size;
|
|
9154
9174
|
const deps = lookAhead.candidateDeps();
|
|
9155
|
-
const handlers =
|
|
9175
|
+
const handlers = chunk37XKN5DZ_cjs.contractHandlers.getRegisteredTypes().map((t) => chunk37XKN5DZ_cjs.contractHandlers.get(t)).filter(hasCandidates);
|
|
9156
9176
|
const band = /* @__PURE__ */ new Map();
|
|
9157
9177
|
for (let index = from; index <= to; index++) {
|
|
9158
9178
|
const descriptor = lookAhead.materialize(index);
|
|
@@ -9163,7 +9183,7 @@ var ContractManager = class _ContractManager {
|
|
|
9163
9183
|
index,
|
|
9164
9184
|
params: {
|
|
9165
9185
|
...candidate,
|
|
9166
|
-
...
|
|
9186
|
+
...chunk37XKN5DZ_cjs.speculativeReceiveMetadata(descriptor)
|
|
9167
9187
|
}
|
|
9168
9188
|
});
|
|
9169
9189
|
}
|
|
@@ -9223,7 +9243,7 @@ var ContractManager = class _ContractManager {
|
|
|
9223
9243
|
});
|
|
9224
9244
|
for (const entry of pending) entry.catchUpPending = false;
|
|
9225
9245
|
} catch (err) {
|
|
9226
|
-
if (!
|
|
9246
|
+
if (!chunkCDWLZQQW_cjs.isRetryableProviderError(err)) throw err;
|
|
9227
9247
|
this.markSyncDegraded(err);
|
|
9228
9248
|
}
|
|
9229
9249
|
}
|
|
@@ -9267,7 +9287,7 @@ var ContractManager = class _ContractManager {
|
|
|
9267
9287
|
await this.fetchContractVxosFromIndexer([contract]);
|
|
9268
9288
|
this.markSyncOnline();
|
|
9269
9289
|
} catch (err) {
|
|
9270
|
-
if (!
|
|
9290
|
+
if (!chunkCDWLZQQW_cjs.isRetryableProviderError(err)) throw err;
|
|
9271
9291
|
this.markSyncDegraded(err);
|
|
9272
9292
|
}
|
|
9273
9293
|
await this.watcher.addContract(contract);
|
|
@@ -9304,7 +9324,7 @@ var ContractManager = class _ContractManager {
|
|
|
9304
9324
|
return result;
|
|
9305
9325
|
}
|
|
9306
9326
|
async upsertContractRow(params) {
|
|
9307
|
-
const handler =
|
|
9327
|
+
const handler = chunk37XKN5DZ_cjs.contractHandlers.get(params.type);
|
|
9308
9328
|
if (!handler) {
|
|
9309
9329
|
throw new Error(`No handler registered for contract type '${params.type}'`);
|
|
9310
9330
|
}
|
|
@@ -9404,7 +9424,7 @@ var ContractManager = class _ContractManager {
|
|
|
9404
9424
|
`scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
|
|
9405
9425
|
);
|
|
9406
9426
|
}
|
|
9407
|
-
const registered =
|
|
9427
|
+
const registered = chunk37XKN5DZ_cjs.contractHandlers.getRegisteredTypes().map((t) => chunk37XKN5DZ_cjs.contractHandlers.get(t)).filter(isDiscoverable);
|
|
9408
9428
|
const discoverables = [
|
|
9409
9429
|
...registered.filter((h) => h.type === "boarding"),
|
|
9410
9430
|
...registered.filter((h) => h.type !== "boarding")
|
|
@@ -9539,7 +9559,7 @@ var ContractManager = class _ContractManager {
|
|
|
9539
9559
|
await this.syncContracts({ contracts, pageSize });
|
|
9540
9560
|
this.markSyncOnline();
|
|
9541
9561
|
} catch (err) {
|
|
9542
|
-
if (!
|
|
9562
|
+
if (!chunkCDWLZQQW_cjs.isRetryableProviderError(err)) throw err;
|
|
9543
9563
|
this.markSyncDegraded(err);
|
|
9544
9564
|
}
|
|
9545
9565
|
const vtxos = await this.getVtxosForContracts(contracts);
|
|
@@ -9560,7 +9580,7 @@ var ContractManager = class _ContractManager {
|
|
|
9560
9580
|
}
|
|
9561
9581
|
const tapscriptCache = /* @__PURE__ */ new Map();
|
|
9562
9582
|
return vtxos.map(
|
|
9563
|
-
(vtxo) => extendVirtualCoinForContract(
|
|
9583
|
+
(vtxo) => extendVirtualCoinForContract(chunkCDWLZQQW_cjs.normalizeVtxo(vtxo), byScript, tapscriptCache)
|
|
9564
9584
|
);
|
|
9565
9585
|
}
|
|
9566
9586
|
buildContractsDbFilter(filter) {
|
|
@@ -9645,7 +9665,7 @@ var ContractManager = class _ContractManager {
|
|
|
9645
9665
|
const { contractScript, collaborative = true, walletPubKey, vtxo } = options;
|
|
9646
9666
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
9647
9667
|
if (!contract) return [];
|
|
9648
|
-
const handler =
|
|
9668
|
+
const handler = chunk37XKN5DZ_cjs.contractHandlers.get(contract.type);
|
|
9649
9669
|
if (!handler) return [];
|
|
9650
9670
|
const script = handler.createScript(contract.params);
|
|
9651
9671
|
const context = {
|
|
@@ -9665,7 +9685,7 @@ var ContractManager = class _ContractManager {
|
|
|
9665
9685
|
const { contractScript, collaborative = true, walletPubKey } = options;
|
|
9666
9686
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
9667
9687
|
if (!contract) return [];
|
|
9668
|
-
const handler =
|
|
9688
|
+
const handler = chunk37XKN5DZ_cjs.contractHandlers.get(contract.type);
|
|
9669
9689
|
if (!handler) return [];
|
|
9670
9690
|
const script = handler.createScript(contract.params);
|
|
9671
9691
|
const context = {
|
|
@@ -9721,7 +9741,7 @@ var ContractManager = class _ContractManager {
|
|
|
9721
9741
|
}
|
|
9722
9742
|
async refreshOutpoints(outpoints) {
|
|
9723
9743
|
if (outpoints.length === 0) return;
|
|
9724
|
-
const { vtxos } = await
|
|
9744
|
+
const { vtxos } = await chunkCDWLZQQW_cjs.getNormalizedVtxos(this.config.indexerProvider, {
|
|
9725
9745
|
outpoints
|
|
9726
9746
|
});
|
|
9727
9747
|
if (vtxos.length === 0) return;
|
|
@@ -9799,7 +9819,7 @@ var ContractManager = class _ContractManager {
|
|
|
9799
9819
|
break;
|
|
9800
9820
|
}
|
|
9801
9821
|
} catch (err) {
|
|
9802
|
-
if (!
|
|
9822
|
+
if (!chunkCDWLZQQW_cjs.isRetryableProviderError(err)) throw err;
|
|
9803
9823
|
this.markSyncDegraded(err);
|
|
9804
9824
|
}
|
|
9805
9825
|
this.emitEvent(event);
|
|
@@ -9848,7 +9868,7 @@ var ContractManager = class _ContractManager {
|
|
|
9848
9868
|
*/
|
|
9849
9869
|
async reconcilePendingFrontier(contracts) {
|
|
9850
9870
|
const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
|
|
9851
|
-
const vtxos = await
|
|
9871
|
+
const vtxos = await chunkCDWLZQQW_cjs.getAllNormalizedVtxos(
|
|
9852
9872
|
this.config.indexerProvider,
|
|
9853
9873
|
contracts.map((c) => c.script),
|
|
9854
9874
|
{ pendingOnly: true }
|
|
@@ -9929,7 +9949,7 @@ var ContractManager = class _ContractManager {
|
|
|
9929
9949
|
}
|
|
9930
9950
|
return result;
|
|
9931
9951
|
}
|
|
9932
|
-
async fetchContractVtxosBulk(contracts, pageSize =
|
|
9952
|
+
async fetchContractVtxosBulk(contracts, pageSize = chunkCDWLZQQW_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
|
|
9933
9953
|
if (contracts.length === 0) {
|
|
9934
9954
|
return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
|
|
9935
9955
|
}
|
|
@@ -9945,7 +9965,7 @@ var ContractManager = class _ContractManager {
|
|
|
9945
9965
|
before: syncWindow.before
|
|
9946
9966
|
}
|
|
9947
9967
|
} : {};
|
|
9948
|
-
const vtxos = await
|
|
9968
|
+
const vtxos = await chunkCDWLZQQW_cjs.getAllNormalizedVtxos(
|
|
9949
9969
|
this.config.indexerProvider,
|
|
9950
9970
|
contracts.map((c) => c.script),
|
|
9951
9971
|
{ ...windowOpts, pageSize }
|
|
@@ -10112,7 +10132,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
10112
10132
|
*/
|
|
10113
10133
|
materializeDescriptorAt(index) {
|
|
10114
10134
|
const descriptor = this.identity.descriptor;
|
|
10115
|
-
const network =
|
|
10135
|
+
const network = chunk37XKN5DZ_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
10116
10136
|
const expansion = descriptorsScure.expand({ descriptor, network, index });
|
|
10117
10137
|
const keyInfo = expansion.expansionMap?.["@0"];
|
|
10118
10138
|
if (!keyInfo?.keyExpression) {
|
|
@@ -10256,7 +10276,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
10256
10276
|
const provider = await resolveDescriptorProvider(config, setup.walletRepository);
|
|
10257
10277
|
if (!provider) return void 0;
|
|
10258
10278
|
const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
|
|
10259
|
-
const expectedContractType = setup.offchainTapscript instanceof
|
|
10279
|
+
const expectedContractType = setup.offchainTapscript instanceof chunk37XKN5DZ_cjs.DelegateVtxo.Script ? "delegate" : "default";
|
|
10260
10280
|
const factoryOpts = {
|
|
10261
10281
|
walletRepository: setup.walletRepository,
|
|
10262
10282
|
contractRepository: setup.contractRepository,
|
|
@@ -10455,7 +10475,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
10455
10475
|
};
|
|
10456
10476
|
function deriveLeafPubkey(descriptor) {
|
|
10457
10477
|
try {
|
|
10458
|
-
return
|
|
10478
|
+
return chunk37XKN5DZ_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
10459
10479
|
} catch (e) {
|
|
10460
10480
|
throw new NonRangeableDescriptorError(
|
|
10461
10481
|
"Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
|
|
@@ -10467,7 +10487,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
10467
10487
|
const pubKey = deriveLeafPubkey(descriptor);
|
|
10468
10488
|
const tapscript = rebuildTapscript(current, pubKey);
|
|
10469
10489
|
const serverPubKey = tapscript.options.serverPubKey;
|
|
10470
|
-
const csvTimelock =
|
|
10490
|
+
const csvTimelock = chunkCDWLZQQW_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
|
|
10471
10491
|
const base$1 = {
|
|
10472
10492
|
script: base.hex.encode(tapscript.pkScript),
|
|
10473
10493
|
address: tapscript.address(hrp, serverPubKey).encode(),
|
|
@@ -10478,11 +10498,11 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
10478
10498
|
// index-0 key. Without it, spends produce unsigned PSBTs that the
|
|
10479
10499
|
// server rejects with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
10480
10500
|
metadata: {
|
|
10481
|
-
...{ source:
|
|
10501
|
+
...{ source: chunk37XKN5DZ_cjs.WALLET_RECEIVE_SOURCE },
|
|
10482
10502
|
signingDescriptor: descriptor
|
|
10483
10503
|
}
|
|
10484
10504
|
};
|
|
10485
|
-
const params = tapscript instanceof
|
|
10505
|
+
const params = tapscript instanceof chunk37XKN5DZ_cjs.DelegateVtxo.Script ? {
|
|
10486
10506
|
...base$1,
|
|
10487
10507
|
type: "delegate",
|
|
10488
10508
|
params: {
|
|
@@ -10503,10 +10523,10 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
10503
10523
|
return { tapscript, params };
|
|
10504
10524
|
}
|
|
10505
10525
|
function rebuildTapscript(current, pubKey) {
|
|
10506
|
-
if (current instanceof
|
|
10507
|
-
return new
|
|
10526
|
+
if (current instanceof chunk37XKN5DZ_cjs.DelegateVtxo.Script) {
|
|
10527
|
+
return new chunk37XKN5DZ_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
|
|
10508
10528
|
}
|
|
10509
|
-
return new
|
|
10529
|
+
return new chunk37XKN5DZ_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
|
|
10510
10530
|
}
|
|
10511
10531
|
async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
|
|
10512
10532
|
const candidates = await contractRepository.getContracts({
|
|
@@ -10515,7 +10535,7 @@ async function pickActiveReceive(contractRepository, serverPubKey, expectedType)
|
|
|
10515
10535
|
});
|
|
10516
10536
|
const serverPubKeyHex = base.hex.encode(serverPubKey);
|
|
10517
10537
|
const matching = candidates.filter(
|
|
10518
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
10538
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunk37XKN5DZ_cjs.WALLET_RECEIVE_SOURCE
|
|
10519
10539
|
).sort((a, b) => {
|
|
10520
10540
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
10521
10541
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -10691,12 +10711,12 @@ var InputSignerRouter = class {
|
|
|
10691
10711
|
};
|
|
10692
10712
|
|
|
10693
10713
|
// src/wallet/wallet.ts
|
|
10694
|
-
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl ||
|
|
10714
|
+
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl || chunkCDWLZQQW_cjs.DEFAULT_ARKADE_SERVER_URL;
|
|
10695
10715
|
function intentProofJobs(coins) {
|
|
10696
10716
|
if (coins.length === 0) return [];
|
|
10697
10717
|
const coinJobs = coins.map((coin, i) => ({
|
|
10698
10718
|
index: i + 1,
|
|
10699
|
-
lookupScript:
|
|
10719
|
+
lookupScript: chunkCDWLZQQW_cjs.VtxoScript.decode(coin.tapTree).pkScript
|
|
10700
10720
|
}));
|
|
10701
10721
|
return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
|
|
10702
10722
|
}
|
|
@@ -10721,7 +10741,7 @@ function dedupeTimelocks(timelocks) {
|
|
|
10721
10741
|
const seen = /* @__PURE__ */ new Set();
|
|
10722
10742
|
const deduped = [];
|
|
10723
10743
|
for (const timelock of timelocks) {
|
|
10724
|
-
const sequence =
|
|
10744
|
+
const sequence = chunkCDWLZQQW_cjs.timelockToSequence(timelock).toString();
|
|
10725
10745
|
if (seen.has(sequence)) continue;
|
|
10726
10746
|
seen.add(sequence);
|
|
10727
10747
|
deduped.push(timelock);
|
|
@@ -10738,7 +10758,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
10738
10758
|
state: "active"
|
|
10739
10759
|
});
|
|
10740
10760
|
const newest = candidates.filter(
|
|
10741
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
10761
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunk37XKN5DZ_cjs.WALLET_RECEIVE_SOURCE
|
|
10742
10762
|
).sort((a, b) => {
|
|
10743
10763
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
10744
10764
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -10746,7 +10766,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
10746
10766
|
if (!newest?.params.pubKey) return baseline;
|
|
10747
10767
|
try {
|
|
10748
10768
|
const pubKey = base.hex.decode(newest.params.pubKey);
|
|
10749
|
-
return new
|
|
10769
|
+
return new chunk37XKN5DZ_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
|
|
10750
10770
|
} catch (e) {
|
|
10751
10771
|
console.warn("Skipping malformed boarding contract at boot", newest.script, e);
|
|
10752
10772
|
return baseline;
|
|
@@ -10996,6 +11016,20 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
10996
11016
|
...this._deprecatedSigners.keys()
|
|
10997
11017
|
]);
|
|
10998
11018
|
}
|
|
11019
|
+
/**
|
|
11020
|
+
* `serverPubKey` defaults to the live key; spend paths that snapshot it
|
|
11021
|
+
* against mid-flight rotation pass their snapshot, so the check reads from
|
|
11022
|
+
* one rotation epoch.
|
|
11023
|
+
*/
|
|
11024
|
+
recipientAddressContext(serverPubKey = this._arkServerPublicKey) {
|
|
11025
|
+
return {
|
|
11026
|
+
hrp: this.network.hrp,
|
|
11027
|
+
signerSet: {
|
|
11028
|
+
active: toXOnlySignerHex(base.hex.encode(serverPubKey)),
|
|
11029
|
+
deprecated: this._deprecatedSigners
|
|
11030
|
+
}
|
|
11031
|
+
};
|
|
11032
|
+
}
|
|
10999
11033
|
/**
|
|
11000
11034
|
* Currently-active receive tapscript. Read-only from the outside;
|
|
11001
11035
|
* mutated only via {@link Wallet.setOffchainTapscriptForRotation}
|
|
@@ -11066,7 +11100,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11066
11100
|
*/
|
|
11067
11101
|
static async setupWalletConfig(config, pubKey) {
|
|
11068
11102
|
const arkadeServerUrl = getArkadeServerUrl(config);
|
|
11069
|
-
const arkProvider = config.arkProvider || new
|
|
11103
|
+
const arkProvider = config.arkProvider || new chunkCDWLZQQW_cjs.RestArkProvider(arkadeServerUrl);
|
|
11070
11104
|
let indexerProvider = config.indexerProvider;
|
|
11071
11105
|
if (!indexerProvider) {
|
|
11072
11106
|
let indexerUrl = config.indexerUrl;
|
|
@@ -11083,7 +11117,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11083
11117
|
indexerUrl = arkadeServerUrl;
|
|
11084
11118
|
}
|
|
11085
11119
|
}
|
|
11086
|
-
indexerProvider = new
|
|
11120
|
+
indexerProvider = new chunk24YNIQSW_cjs.RestIndexerProvider(indexerUrl);
|
|
11087
11121
|
}
|
|
11088
11122
|
const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
11089
11123
|
const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
@@ -11092,7 +11126,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11092
11126
|
source: serverInfoSource,
|
|
11093
11127
|
lastOnlineAt: serverInfoLastOnlineAt
|
|
11094
11128
|
} = await resolveArkInfo(arkProvider, walletRepository);
|
|
11095
|
-
const network =
|
|
11129
|
+
const network = chunkCDWLZQQW_cjs.getNetwork(info.network);
|
|
11096
11130
|
if ("descriptor" in config.identity) {
|
|
11097
11131
|
const descriptor = config.identity.descriptor;
|
|
11098
11132
|
const identityIsMainnet = !descriptor.includes("tpub");
|
|
@@ -11139,11 +11173,11 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11139
11173
|
serverPubKey,
|
|
11140
11174
|
csvTimelock: exitTimelock
|
|
11141
11175
|
};
|
|
11142
|
-
const offchainTapscript = !delegatePubKey ? new
|
|
11143
|
-
const boardingTapscript =
|
|
11176
|
+
const offchainTapscript = !delegatePubKey ? new chunk37XKN5DZ_cjs.DefaultVtxo.Script(offchainOptions) : new chunk37XKN5DZ_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
|
|
11177
|
+
const boardingTapscript = chunk37XKN5DZ_cjs.BoardingContractHandler.createScript({
|
|
11144
11178
|
pubKey: base.hex.encode(pubKey),
|
|
11145
11179
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
11146
|
-
csvTimelock:
|
|
11180
|
+
csvTimelock: chunkCDWLZQQW_cjs.timelockToSequence(boardingTimelock).toString()
|
|
11147
11181
|
});
|
|
11148
11182
|
return {
|
|
11149
11183
|
arkProvider,
|
|
@@ -11249,19 +11283,19 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11249
11283
|
let pendingRecovery = 0;
|
|
11250
11284
|
const now = { timestamp: /* @__PURE__ */ new Date() };
|
|
11251
11285
|
const settled = vtxos.filter(
|
|
11252
|
-
(coin) =>
|
|
11286
|
+
(coin) => chunkCDWLZQQW_cjs.canSpendOffchain(coin, now) && !coin.isPreconfirmed && !isPendingRecovery(coin)
|
|
11253
11287
|
).reduce((sum, coin) => sum + coin.value, 0);
|
|
11254
11288
|
const preconfirmed = vtxos.filter(
|
|
11255
|
-
(coin) =>
|
|
11289
|
+
(coin) => chunkCDWLZQQW_cjs.canSpendOffchain(coin, now) && coin.isPreconfirmed && !isPendingRecovery(coin)
|
|
11256
11290
|
).reduce((sum, coin) => sum + coin.value, 0);
|
|
11257
|
-
const available = unlockedVtxos.filter((coin) =>
|
|
11258
|
-
recoverable = vtxos.filter((coin) =>
|
|
11291
|
+
const available = unlockedVtxos.filter((coin) => chunkCDWLZQQW_cjs.canSpendOffchain(coin, now) && !isPendingRecovery(coin)).reduce((sum, coin) => sum + coin.value, 0);
|
|
11292
|
+
recoverable = vtxos.filter((coin) => chunkCDWLZQQW_cjs.canRecoverOnchain(coin, now) && !isPendingRecovery(coin)).reduce((sum, coin) => sum + coin.value, 0);
|
|
11259
11293
|
pendingRecovery = vtxos.filter(isPendingRecovery).reduce((sum, coin) => sum + coin.value, 0);
|
|
11260
11294
|
const totalBoarding = confirmed + unconfirmed;
|
|
11261
11295
|
const totalOffchain = settled + preconfirmed + recoverable + pendingRecovery;
|
|
11262
11296
|
const assetBalances = /* @__PURE__ */ new Map();
|
|
11263
11297
|
for (const vtxo of vtxos) {
|
|
11264
|
-
if (
|
|
11298
|
+
if (chunkCDWLZQQW_cjs.hasTerminalSpend(vtxo)) continue;
|
|
11265
11299
|
if (vtxo.assets) {
|
|
11266
11300
|
for (const a of vtxo.assets) {
|
|
11267
11301
|
const current = assetBalances.get(a.assetId) ?? 0n;
|
|
@@ -11302,8 +11336,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11302
11336
|
if (this._pendingSpendOutpoints.has(`${vtxo.txid}:${vtxo.vout}`)) {
|
|
11303
11337
|
return false;
|
|
11304
11338
|
}
|
|
11305
|
-
if (!
|
|
11306
|
-
if (!f.withRecoverable &&
|
|
11339
|
+
if (!chunkCDWLZQQW_cjs.hasTerminalSpend(vtxo)) {
|
|
11340
|
+
if (!f.withRecoverable && chunkCDWLZQQW_cjs.canRecoverOnchain(vtxo, now)) {
|
|
11307
11341
|
return false;
|
|
11308
11342
|
}
|
|
11309
11343
|
return true;
|
|
@@ -11336,7 +11370,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11336
11370
|
const response = await contractManager.getContractsWithVtxos();
|
|
11337
11371
|
const allVtxos = response.flatMap((_) => _.vtxos);
|
|
11338
11372
|
const { boardingTxs, commitmentsToIgnore } = await this.getBoardingTxs();
|
|
11339
|
-
const resolveTxCreatedAt = (txids) =>
|
|
11373
|
+
const resolveTxCreatedAt = (txids) => chunkCDWLZQQW_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
|
|
11340
11374
|
return buildTransactionHistory(
|
|
11341
11375
|
allVtxos,
|
|
11342
11376
|
boardingTxs,
|
|
@@ -11430,7 +11464,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11430
11464
|
},
|
|
11431
11465
|
isUnrolled: true,
|
|
11432
11466
|
...boardingFacts,
|
|
11433
|
-
virtualStatus:
|
|
11467
|
+
virtualStatus: chunkCDWLZQQW_cjs.toVirtualStatus(boardingFacts),
|
|
11434
11468
|
spentBy: "",
|
|
11435
11469
|
createdAt: tx.status.confirmed ? new Date(tx.status.block_time * 1e3) : /* @__PURE__ */ new Date(0),
|
|
11436
11470
|
script: scriptHex
|
|
@@ -11486,9 +11520,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11486
11520
|
async getBoardingTapscripts(allowedSigners) {
|
|
11487
11521
|
const byScript = /* @__PURE__ */ new Map();
|
|
11488
11522
|
const add = (s) => byScript.set(base.hex.encode(s.pkScript), s);
|
|
11489
|
-
const boardingCsv = this.boardingTapscript.options.csvTimelock ??
|
|
11523
|
+
const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunk37XKN5DZ_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
11490
11524
|
add(
|
|
11491
|
-
new
|
|
11525
|
+
new chunk37XKN5DZ_cjs.DefaultVtxo.Script({
|
|
11492
11526
|
pubKey: await this.identity.xOnlyPublicKey(),
|
|
11493
11527
|
serverPubKey: this.boardingTapscript.options.serverPubKey,
|
|
11494
11528
|
csvTimelock: boardingCsv
|
|
@@ -11503,7 +11537,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11503
11537
|
for (const c of boardingContracts) {
|
|
11504
11538
|
if (!allowed.has(toXOnlySignerHex(c.params.serverPubKey))) continue;
|
|
11505
11539
|
try {
|
|
11506
|
-
add(
|
|
11540
|
+
add(chunk37XKN5DZ_cjs.BoardingContractHandler.createScript(c.params));
|
|
11507
11541
|
} catch (e) {
|
|
11508
11542
|
console.warn("Skipping malformed boarding contract", c.script, e);
|
|
11509
11543
|
}
|
|
@@ -11541,7 +11575,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11541
11575
|
// Per-row CSV delay decoded from THIS tapscript's exit leaf —
|
|
11542
11576
|
// not the wallet's current boarding timelock, which a signer
|
|
11543
11577
|
// rotation may have changed.
|
|
11544
|
-
csvTimelock:
|
|
11578
|
+
csvTimelock: chunkCDWLZQQW_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
|
|
11545
11579
|
coins: utxos
|
|
11546
11580
|
});
|
|
11547
11581
|
}
|
|
@@ -11674,7 +11708,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11674
11708
|
/** Fetch Arkade transaction ids that are still pending final settlement. */
|
|
11675
11709
|
async fetchPendingTxs() {
|
|
11676
11710
|
const scripts = await this.getWalletScripts();
|
|
11677
|
-
const vtxos = await
|
|
11711
|
+
const vtxos = await chunkCDWLZQQW_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
|
|
11678
11712
|
return vtxos.filter(
|
|
11679
11713
|
(vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
|
|
11680
11714
|
).map((_) => _.arkTxId);
|
|
@@ -11705,7 +11739,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11705
11739
|
});
|
|
11706
11740
|
for (const contract of contracts) {
|
|
11707
11741
|
if (map.has(contract.script)) continue;
|
|
11708
|
-
const handler =
|
|
11742
|
+
const handler = chunk37XKN5DZ_cjs.contractHandlers.get(contract.type);
|
|
11709
11743
|
if (handler) {
|
|
11710
11744
|
const script = handler.createScript(contract.params);
|
|
11711
11745
|
map.set(contract.script, script);
|
|
@@ -11808,7 +11842,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11808
11842
|
lookAhead: this.lookAheadConfig()
|
|
11809
11843
|
});
|
|
11810
11844
|
const baselinePubkey = await this.identity.xOnlyPublicKey();
|
|
11811
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
11845
|
+
const delegatePubKey = this.offchainTapscript instanceof chunk37XKN5DZ_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
11812
11846
|
const baselineSigners = [
|
|
11813
11847
|
this.offchainTapscript.options.serverPubKey,
|
|
11814
11848
|
...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
|
|
@@ -11816,8 +11850,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11816
11850
|
const seenBaselineScripts = /* @__PURE__ */ new Set();
|
|
11817
11851
|
for (const serverPubKey of baselineSigners) {
|
|
11818
11852
|
for (const csvTimelock of this.walletContractTimelocks) {
|
|
11819
|
-
const csvTimelockStr =
|
|
11820
|
-
const defaultScript = new
|
|
11853
|
+
const csvTimelockStr = chunkCDWLZQQW_cjs.timelockToSequence(csvTimelock).toString();
|
|
11854
|
+
const defaultScript = new chunk37XKN5DZ_cjs.DefaultVtxo.Script({
|
|
11821
11855
|
pubKey: baselinePubkey,
|
|
11822
11856
|
serverPubKey,
|
|
11823
11857
|
csvTimelock
|
|
@@ -11838,7 +11872,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11838
11872
|
});
|
|
11839
11873
|
}
|
|
11840
11874
|
if (delegatePubKey) {
|
|
11841
|
-
const delegateScript = new
|
|
11875
|
+
const delegateScript = new chunk37XKN5DZ_cjs.DelegateVtxo.Script({
|
|
11842
11876
|
pubKey: baselinePubkey,
|
|
11843
11877
|
serverPubKey,
|
|
11844
11878
|
delegatePubKey,
|
|
@@ -11862,9 +11896,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11862
11896
|
}
|
|
11863
11897
|
}
|
|
11864
11898
|
}
|
|
11865
|
-
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ??
|
|
11899
|
+
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunk37XKN5DZ_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
11866
11900
|
for (const serverPubKey of baselineSigners) {
|
|
11867
|
-
const baselineBoarding = new
|
|
11901
|
+
const baselineBoarding = new chunk37XKN5DZ_cjs.DefaultVtxo.Script({
|
|
11868
11902
|
pubKey: baselinePubkey,
|
|
11869
11903
|
serverPubKey,
|
|
11870
11904
|
csvTimelock: boardingCsvTimelock
|
|
@@ -11877,7 +11911,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11877
11911
|
params: {
|
|
11878
11912
|
pubKey: base.hex.encode(baselineBoarding.options.pubKey),
|
|
11879
11913
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
11880
|
-
csvTimelock:
|
|
11914
|
+
csvTimelock: chunkCDWLZQQW_cjs.timelockToSequence(boardingCsvTimelock).toString()
|
|
11881
11915
|
},
|
|
11882
11916
|
script: boardingScriptHex,
|
|
11883
11917
|
address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
|
|
@@ -12051,7 +12085,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12051
12085
|
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
12052
12086
|
deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
|
|
12053
12087
|
csvTimelocks: this.walletContractTimelocks,
|
|
12054
|
-
delegatePubKey: this.offchainTapscript instanceof
|
|
12088
|
+
delegatePubKey: this.offchainTapscript instanceof chunk37XKN5DZ_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
|
|
12055
12089
|
};
|
|
12056
12090
|
}
|
|
12057
12091
|
_signerRouter;
|
|
@@ -12143,25 +12177,25 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12143
12177
|
return this.getBoardingAddress();
|
|
12144
12178
|
}
|
|
12145
12179
|
const descriptor = await provider.getNextSigningDescriptor();
|
|
12146
|
-
const pubKey =
|
|
12147
|
-
const newBoarding = new
|
|
12180
|
+
const pubKey = chunk37XKN5DZ_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
12181
|
+
const newBoarding = new chunk37XKN5DZ_cjs.DefaultVtxo.Script({
|
|
12148
12182
|
...this._boardingTapscript.options,
|
|
12149
12183
|
pubKey
|
|
12150
12184
|
});
|
|
12151
|
-
const csvTimelock = newBoarding.options.csvTimelock ??
|
|
12185
|
+
const csvTimelock = newBoarding.options.csvTimelock ?? chunk37XKN5DZ_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
12152
12186
|
const manager = await this.getContractManager();
|
|
12153
12187
|
await manager.createContract({
|
|
12154
12188
|
type: "boarding",
|
|
12155
12189
|
params: {
|
|
12156
12190
|
pubKey: base.hex.encode(pubKey),
|
|
12157
12191
|
serverPubKey: base.hex.encode(newBoarding.options.serverPubKey),
|
|
12158
|
-
csvTimelock:
|
|
12192
|
+
csvTimelock: chunkCDWLZQQW_cjs.timelockToSequence(csvTimelock).toString()
|
|
12159
12193
|
},
|
|
12160
12194
|
script: base.hex.encode(newBoarding.pkScript),
|
|
12161
12195
|
address: newBoarding.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
12162
12196
|
state: "active",
|
|
12163
12197
|
metadata: {
|
|
12164
|
-
source:
|
|
12198
|
+
source: chunk37XKN5DZ_cjs.WALLET_RECEIVE_SOURCE,
|
|
12165
12199
|
signingDescriptor: descriptor
|
|
12166
12200
|
}
|
|
12167
12201
|
});
|
|
@@ -12250,7 +12284,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12250
12284
|
const xonly = toXOnlyPubKey(newServerPubKey);
|
|
12251
12285
|
let newServerUnrollScript;
|
|
12252
12286
|
try {
|
|
12253
|
-
newServerUnrollScript =
|
|
12287
|
+
newServerUnrollScript = chunkCDWLZQQW_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
|
|
12254
12288
|
} catch (e) {
|
|
12255
12289
|
throw new Error("Invalid checkpointTapscript from server");
|
|
12256
12290
|
}
|
|
@@ -12278,21 +12312,21 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12278
12312
|
const [currentBoardingRow] = await manager.getContracts({
|
|
12279
12313
|
script: currentBoardingScript
|
|
12280
12314
|
});
|
|
12281
|
-
const newOffchain = this.offchainTapscript instanceof
|
|
12315
|
+
const newOffchain = this.offchainTapscript instanceof chunk37XKN5DZ_cjs.DelegateVtxo.Script ? new chunk37XKN5DZ_cjs.DelegateVtxo.Script({
|
|
12282
12316
|
...this.offchainTapscript.options,
|
|
12283
12317
|
serverPubKey: xonly
|
|
12284
|
-
}) : new
|
|
12318
|
+
}) : new chunk37XKN5DZ_cjs.DefaultVtxo.Script({
|
|
12285
12319
|
...this.offchainTapscript.options,
|
|
12286
12320
|
serverPubKey: xonly
|
|
12287
12321
|
});
|
|
12288
|
-
const newBoarding = new
|
|
12322
|
+
const newBoarding = new chunk37XKN5DZ_cjs.DefaultVtxo.Script({
|
|
12289
12323
|
...this._boardingTapscript.options,
|
|
12290
12324
|
serverPubKey: xonly
|
|
12291
12325
|
});
|
|
12292
|
-
const offchainCsv =
|
|
12326
|
+
const offchainCsv = chunkCDWLZQQW_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
|
|
12293
12327
|
const newOffchainScript = base.hex.encode(newOffchain.pkScript);
|
|
12294
12328
|
const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
|
|
12295
|
-
if (newOffchain instanceof
|
|
12329
|
+
if (newOffchain instanceof chunk37XKN5DZ_cjs.DelegateVtxo.Script) {
|
|
12296
12330
|
await manager.createContract({
|
|
12297
12331
|
type: "delegate",
|
|
12298
12332
|
params: {
|
|
@@ -12320,13 +12354,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12320
12354
|
metadata: currentOffchainRow?.metadata
|
|
12321
12355
|
});
|
|
12322
12356
|
}
|
|
12323
|
-
const boardingCsv = newBoarding.options.csvTimelock ??
|
|
12357
|
+
const boardingCsv = newBoarding.options.csvTimelock ?? chunk37XKN5DZ_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
12324
12358
|
await manager.createContract({
|
|
12325
12359
|
type: "boarding",
|
|
12326
12360
|
params: {
|
|
12327
12361
|
pubKey: base.hex.encode(newBoarding.options.pubKey),
|
|
12328
12362
|
serverPubKey: base.hex.encode(xonly),
|
|
12329
|
-
csvTimelock:
|
|
12363
|
+
csvTimelock: chunkCDWLZQQW_cjs.timelockToSequence(boardingCsv).toString()
|
|
12330
12364
|
},
|
|
12331
12365
|
script: base.hex.encode(newBoarding.pkScript),
|
|
12332
12366
|
address: newBoarding.address(this.network.hrp, xonly).encode(),
|
|
@@ -12359,14 +12393,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12359
12393
|
_restoreInFlight;
|
|
12360
12394
|
_addPendingSpends(inputs) {
|
|
12361
12395
|
for (const input of inputs) {
|
|
12362
|
-
if (
|
|
12396
|
+
if (chunkCDWLZQQW_cjs.isVirtualCoin(input)) {
|
|
12363
12397
|
this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
|
|
12364
12398
|
}
|
|
12365
12399
|
}
|
|
12366
12400
|
}
|
|
12367
12401
|
_removePendingSpends(inputs) {
|
|
12368
12402
|
for (const input of inputs) {
|
|
12369
|
-
if (
|
|
12403
|
+
if (chunkCDWLZQQW_cjs.isVirtualCoin(input)) {
|
|
12370
12404
|
this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
|
|
12371
12405
|
}
|
|
12372
12406
|
}
|
|
@@ -12426,7 +12460,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12426
12460
|
const hd = provider instanceof HDDescriptorProvider;
|
|
12427
12461
|
const staticDescriptor = hd ? void 0 : `tr(${base.hex.encode(await this.identity.xOnlyPublicKey())})`;
|
|
12428
12462
|
const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
|
|
12429
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
12463
|
+
const delegatePubKey = this.offchainTapscript instanceof chunk37XKN5DZ_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
12430
12464
|
const arkInfo = await this.arkProvider.getInfo();
|
|
12431
12465
|
const currentSignerPubKey = toXOnlyPubKey(base.hex.decode(arkInfo.signerPubkey));
|
|
12432
12466
|
const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
|
|
@@ -12445,7 +12479,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12445
12479
|
csvTimelocks: this.walletContractTimelocks,
|
|
12446
12480
|
// Boarding-exit CSV so the boarding handler can build its
|
|
12447
12481
|
// candidate script (distinct from the unilateral-exit matrix).
|
|
12448
|
-
boardingTimelock: this.boardingTapscript.options.csvTimelock ??
|
|
12482
|
+
boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunk37XKN5DZ_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
|
|
12449
12483
|
delegatePubKey
|
|
12450
12484
|
};
|
|
12451
12485
|
const result = await manager.scanContracts({
|
|
@@ -12562,7 +12596,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12562
12596
|
let serverUnrollScript;
|
|
12563
12597
|
try {
|
|
12564
12598
|
const raw = base.hex.decode(setup.info.checkpointTapscript);
|
|
12565
|
-
serverUnrollScript =
|
|
12599
|
+
serverUnrollScript = chunkCDWLZQQW_cjs.CSVMultisigTapscript.decode(raw);
|
|
12566
12600
|
} catch (e) {
|
|
12567
12601
|
throw new Error("Invalid checkpointTapscript from server");
|
|
12568
12602
|
}
|
|
@@ -12700,7 +12734,12 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12700
12734
|
inputs: params.selectedVtxos,
|
|
12701
12735
|
changeAmount: BigInt(changeAmount)
|
|
12702
12736
|
};
|
|
12703
|
-
const outputAddress =
|
|
12737
|
+
const outputAddress = chunkCDWLZQQW_cjs.ArkAddress.decode(params.address);
|
|
12738
|
+
assertRecipientArkAddress(
|
|
12739
|
+
params.address,
|
|
12740
|
+
outputAddress,
|
|
12741
|
+
this.recipientAddressContext(serverPubKey)
|
|
12742
|
+
);
|
|
12704
12743
|
const outputScript = BigInt(params.amount) < this.dustAmount ? outputAddress.subdustPkScript : outputAddress.pkScript;
|
|
12705
12744
|
const outputs = [
|
|
12706
12745
|
{
|
|
@@ -12753,13 +12792,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12753
12792
|
}
|
|
12754
12793
|
}
|
|
12755
12794
|
const offchainAddress = await this.getAddress();
|
|
12756
|
-
const offchainPkScript =
|
|
12795
|
+
const offchainPkScript = chunkCDWLZQQW_cjs.ArkAddress.decode(offchainAddress).pkScript;
|
|
12757
12796
|
const offchainOutputScript = base.hex.encode(offchainPkScript);
|
|
12758
12797
|
if (!params) {
|
|
12759
12798
|
const { fees, vtxoMaxAmount } = await this.arkProvider.getInfo();
|
|
12760
12799
|
const estimator = new Estimator(fees.intentFee);
|
|
12761
12800
|
let amount = 0;
|
|
12762
|
-
const exitScript =
|
|
12801
|
+
const exitScript = chunkCDWLZQQW_cjs.CSVMultisigTapscript.decode(
|
|
12763
12802
|
base.hex.decode(this.boardingTapscript.exitScript)
|
|
12764
12803
|
);
|
|
12765
12804
|
const boardingTimelock = exitScript.params.timelock;
|
|
@@ -12788,7 +12827,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12788
12827
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
12789
12828
|
break;
|
|
12790
12829
|
}
|
|
12791
|
-
const inputFee = estimator.evalOffchainInput(
|
|
12830
|
+
const inputFee = estimator.evalOffchainInput(chunkCDWLZQQW_cjs.toOffchainInputFeeParams(vtxo));
|
|
12792
12831
|
if (inputFee.satoshis >= vtxo.value) {
|
|
12793
12832
|
continue;
|
|
12794
12833
|
}
|
|
@@ -12830,13 +12869,21 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12830
12869
|
const onchainOutputIndexes = [];
|
|
12831
12870
|
const outputs = [];
|
|
12832
12871
|
let hasOffchainOutputs = false;
|
|
12872
|
+
let recipientContext;
|
|
12833
12873
|
for (const [index, output] of params.outputs.entries()) {
|
|
12834
12874
|
let script;
|
|
12875
|
+
let arkAddress;
|
|
12835
12876
|
try {
|
|
12836
|
-
|
|
12837
|
-
script = addr.pkScript;
|
|
12838
|
-
hasOffchainOutputs = true;
|
|
12877
|
+
arkAddress = chunkCDWLZQQW_cjs.ArkAddress.decode(output.address);
|
|
12839
12878
|
} catch {
|
|
12879
|
+
arkAddress = void 0;
|
|
12880
|
+
}
|
|
12881
|
+
if (arkAddress) {
|
|
12882
|
+
recipientContext ??= this.recipientAddressContext();
|
|
12883
|
+
assertRecipientArkAddress(output.address, arkAddress, recipientContext);
|
|
12884
|
+
script = arkAddress.pkScript;
|
|
12885
|
+
hasOffchainOutputs = true;
|
|
12886
|
+
} else {
|
|
12840
12887
|
const addr = btcSigner.Address(this.network).decode(output.address);
|
|
12841
12888
|
script = btcSigner.OutScript.encode(addr);
|
|
12842
12889
|
onchainOutputIndexes.push(index);
|
|
@@ -13019,7 +13066,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13019
13066
|
async maybeRotateBoardingAfterBoard(inputs) {
|
|
13020
13067
|
if (!this._descriptorProvider) return;
|
|
13021
13068
|
const consumedBoarding = inputs.some(
|
|
13022
|
-
(input) => typeof input !== "string" && !
|
|
13069
|
+
(input) => typeof input !== "string" && !chunkCDWLZQQW_cjs.isVirtualCoin(input)
|
|
13023
13070
|
);
|
|
13024
13071
|
if (!consumedBoarding) return;
|
|
13025
13072
|
try {
|
|
@@ -13043,7 +13090,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13043
13090
|
let connectorIndex = 0;
|
|
13044
13091
|
const connectorsLeaves = connectorsGraph?.leaves() || [];
|
|
13045
13092
|
for (const input of inputs) {
|
|
13046
|
-
if (!
|
|
13093
|
+
if (!chunkCDWLZQQW_cjs.isVirtualCoin(input)) {
|
|
13047
13094
|
for (let i = 0; i < settlementPsbt.inputsLength; i++) {
|
|
13048
13095
|
const settlementInput = settlementPsbt.getInput(i);
|
|
13049
13096
|
if (!settlementInput.txid || settlementInput.index === void 0) {
|
|
@@ -13074,7 +13121,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13074
13121
|
}
|
|
13075
13122
|
continue;
|
|
13076
13123
|
}
|
|
13077
|
-
if (
|
|
13124
|
+
if (chunkCDWLZQQW_cjs.canRecoverOnchain(input, { timestamp: /* @__PURE__ */ new Date() }) || isSubdust({ value: input.value }, this.dustAmount)) {
|
|
13078
13125
|
continue;
|
|
13079
13126
|
}
|
|
13080
13127
|
if (connectorsLeaves.length === 0) {
|
|
@@ -13102,7 +13149,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13102
13149
|
index: input.vout,
|
|
13103
13150
|
witnessUtxo: {
|
|
13104
13151
|
amount: BigInt(input.value),
|
|
13105
|
-
script:
|
|
13152
|
+
script: chunkCDWLZQQW_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
13106
13153
|
},
|
|
13107
13154
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
13108
13155
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -13121,7 +13168,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13121
13168
|
forfeitTx = await this._signerRouter.sign(forfeitTx, [
|
|
13122
13169
|
{
|
|
13123
13170
|
index: 0,
|
|
13124
|
-
lookupScript:
|
|
13171
|
+
lookupScript: chunkCDWLZQQW_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
13125
13172
|
}
|
|
13126
13173
|
]);
|
|
13127
13174
|
signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
|
|
@@ -13180,7 +13227,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13180
13227
|
if (skip) {
|
|
13181
13228
|
return { skip };
|
|
13182
13229
|
}
|
|
13183
|
-
const sweepTapscript =
|
|
13230
|
+
const sweepTapscript = chunkCDWLZQQW_cjs.CSVMultisigTapscript.encode({
|
|
13184
13231
|
timelock: {
|
|
13185
13232
|
value: event.batchExpiry,
|
|
13186
13233
|
type: event.batchExpiry >= 512n ? "seconds" : "blocks"
|
|
@@ -13289,9 +13336,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13289
13336
|
...existing ?? {},
|
|
13290
13337
|
intentTxId,
|
|
13291
13338
|
registerProof: intent.proof,
|
|
13292
|
-
registerProofMessage:
|
|
13339
|
+
registerProofMessage: chunkCDWLZQQW_cjs.Intent.encodeMessage(intent.message),
|
|
13293
13340
|
deleteProof: deleteIntent.proof,
|
|
13294
|
-
deleteProofMessage:
|
|
13341
|
+
deleteProofMessage: chunkCDWLZQQW_cjs.Intent.encodeMessage(deleteIntent.message),
|
|
13295
13342
|
intentVtxos: inputs.map((i) => ({
|
|
13296
13343
|
txid: i.txid,
|
|
13297
13344
|
vout: i.vout
|
|
@@ -13323,7 +13370,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13323
13370
|
try {
|
|
13324
13371
|
return await this.arkProvider.registerIntent(intent);
|
|
13325
13372
|
} catch (error) {
|
|
13326
|
-
if (error instanceof
|
|
13373
|
+
if (error instanceof chunkCDWLZQQW_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
|
|
13327
13374
|
const deleteIntent = await this.makeDeleteIntentSignature(inputs);
|
|
13328
13375
|
await this.arkProvider.deleteIntent(deleteIntent);
|
|
13329
13376
|
return this.arkProvider.registerIntent(intent);
|
|
@@ -13339,7 +13386,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13339
13386
|
expire_at: 0,
|
|
13340
13387
|
cosigners_public_keys: cosignerPubKeys
|
|
13341
13388
|
};
|
|
13342
|
-
const proof =
|
|
13389
|
+
const proof = chunkCDWLZQQW_cjs.Intent.create(message, coins, outputs);
|
|
13343
13390
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
13344
13391
|
return {
|
|
13345
13392
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -13351,7 +13398,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13351
13398
|
type: "delete",
|
|
13352
13399
|
expire_at: 0
|
|
13353
13400
|
};
|
|
13354
|
-
const proof =
|
|
13401
|
+
const proof = chunkCDWLZQQW_cjs.Intent.create(message, coins, []);
|
|
13355
13402
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
13356
13403
|
return {
|
|
13357
13404
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -13363,7 +13410,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13363
13410
|
type: "get-pending-tx",
|
|
13364
13411
|
expire_at: 0
|
|
13365
13412
|
};
|
|
13366
|
-
const proof =
|
|
13413
|
+
const proof = chunkCDWLZQQW_cjs.Intent.create(message, coins, []);
|
|
13367
13414
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
13368
13415
|
return {
|
|
13369
13416
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -13384,7 +13431,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13384
13431
|
if (!vtxos || vtxos.length === 0) {
|
|
13385
13432
|
const scriptMap = await this.getScriptMap();
|
|
13386
13433
|
const allExtended = [];
|
|
13387
|
-
const fetchedVtxos = await
|
|
13434
|
+
const fetchedVtxos = await chunkCDWLZQQW_cjs.getAllNormalizedVtxos(this.indexerProvider, [
|
|
13388
13435
|
...scriptMap.keys()
|
|
13389
13436
|
]);
|
|
13390
13437
|
for (const vtxo of fetchedVtxos) {
|
|
@@ -13498,11 +13545,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13498
13545
|
* against the current key alone would leave it pending forever.
|
|
13499
13546
|
*/
|
|
13500
13547
|
checkpointUnrollCandidates(info) {
|
|
13501
|
-
const current =
|
|
13548
|
+
const current = chunkCDWLZQQW_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
13502
13549
|
const candidates = [this._serverUnrollScript, current];
|
|
13503
13550
|
for (const deprecated of signerSetFromInfo(info).deprecated.keys()) {
|
|
13504
13551
|
candidates.push(
|
|
13505
|
-
|
|
13552
|
+
chunkCDWLZQQW_cjs.CSVMultisigTapscript.encode({
|
|
13506
13553
|
...current.params,
|
|
13507
13554
|
pubkeys: [base.hex.decode(deprecated)]
|
|
13508
13555
|
})
|
|
@@ -13593,7 +13640,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13593
13640
|
if (vtxos.length === 0) {
|
|
13594
13641
|
throw new Error("No VTXOs found for this arkadeCash");
|
|
13595
13642
|
}
|
|
13596
|
-
const myPkScript =
|
|
13643
|
+
const myPkScript = chunkCDWLZQQW_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
|
|
13597
13644
|
let { spendable, unclaimed } = this.classifyCashVtxos(vtxos);
|
|
13598
13645
|
let swept = 0;
|
|
13599
13646
|
const drainable = vtxos.filter((vtxo) => !isSubdust(vtxo, this.dustAmount));
|
|
@@ -13620,7 +13667,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13620
13667
|
}
|
|
13621
13668
|
if (spendable.length > 0) {
|
|
13622
13669
|
const info = await this.arkProvider.getInfo();
|
|
13623
|
-
const serverUnrollScript =
|
|
13670
|
+
const serverUnrollScript = chunkCDWLZQQW_cjs.CSVMultisigTapscript.decode(
|
|
13624
13671
|
base.hex.decode(info.checkpointTapscript)
|
|
13625
13672
|
);
|
|
13626
13673
|
for (const vtxo of spendable) {
|
|
@@ -13666,7 +13713,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13666
13713
|
const spendable = [];
|
|
13667
13714
|
const unclaimed = [];
|
|
13668
13715
|
for (const vtxo of vtxos) {
|
|
13669
|
-
if (
|
|
13716
|
+
if (chunkCDWLZQQW_cjs.hasTerminalSpend(vtxo)) {
|
|
13670
13717
|
unclaimed.push(cashReport(vtxo, "already-spent"));
|
|
13671
13718
|
} else if (isSubdust(vtxo, this.dustAmount)) {
|
|
13672
13719
|
unclaimed.push(cashReport(vtxo, "subdust"));
|
|
@@ -13686,7 +13733,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13686
13733
|
const all = [];
|
|
13687
13734
|
const seen = /* @__PURE__ */ new Set();
|
|
13688
13735
|
for (let pageIndex = 0; ; pageIndex++) {
|
|
13689
|
-
const { vtxos, page } = await
|
|
13736
|
+
const { vtxos, page } = await chunkCDWLZQQW_cjs.getNormalizedVtxos(this.indexerProvider, {
|
|
13690
13737
|
scripts,
|
|
13691
13738
|
pageIndex,
|
|
13692
13739
|
pageSize
|
|
@@ -13733,7 +13780,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13733
13780
|
for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
|
|
13734
13781
|
const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
|
|
13735
13782
|
const message = { type: "get-pending-tx", expire_at: 0 };
|
|
13736
|
-
const proof =
|
|
13783
|
+
const proof = chunkCDWLZQQW_cjs.Intent.create(message, batch, []);
|
|
13737
13784
|
const signedProof = await identity.sign(
|
|
13738
13785
|
proof,
|
|
13739
13786
|
Array.from({ length: batch.length + 1 }, (_, j) => j)
|
|
@@ -13829,7 +13876,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13829
13876
|
const serverUnrollScript = this.serverUnrollScript;
|
|
13830
13877
|
const outputAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
|
|
13831
13878
|
const address = outputAddress.encode();
|
|
13832
|
-
const recipients = validateRecipients(
|
|
13879
|
+
const recipients = validateRecipients(
|
|
13880
|
+
args,
|
|
13881
|
+
Number(this.dustAmount),
|
|
13882
|
+
this.recipientAddressContext(serverPubKey)
|
|
13883
|
+
);
|
|
13833
13884
|
const allVirtualCoins = await this.getVtxos({
|
|
13834
13885
|
withRecoverable: false
|
|
13835
13886
|
});
|
|
@@ -14039,10 +14090,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14039
14090
|
const serverPubKey = this.arkServerPublicKey;
|
|
14040
14091
|
const serverUnrollScript = this.serverUnrollScript;
|
|
14041
14092
|
const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
|
|
14042
|
-
const normalizedInputs = inputs.map(
|
|
14043
|
-
const at = now ?? await
|
|
14093
|
+
const normalizedInputs = inputs.map(chunkCDWLZQQW_cjs.normalizeVtxo);
|
|
14094
|
+
const at = now ?? await chunkCDWLZQQW_cjs.resolveTimeHeight(this.onchainProvider);
|
|
14044
14095
|
for (const input of normalizedInputs) {
|
|
14045
|
-
if (!
|
|
14096
|
+
if (!chunkCDWLZQQW_cjs.canSpendOffchain(input, at)) {
|
|
14046
14097
|
throw new Error(
|
|
14047
14098
|
`sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
|
|
14048
14099
|
);
|
|
@@ -14107,7 +14158,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14107
14158
|
);
|
|
14108
14159
|
const arkTxJobs = inputs.map((input, index) => ({
|
|
14109
14160
|
index,
|
|
14110
|
-
lookupScript:
|
|
14161
|
+
lookupScript: chunkCDWLZQQW_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
14111
14162
|
}));
|
|
14112
14163
|
const identity = this.identity;
|
|
14113
14164
|
const signer = {
|
|
@@ -14193,14 +14244,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14193
14244
|
const spentBy = checkpointIdByOutpoint.get(`${vtxo.txid}:${vtxo.vout}`);
|
|
14194
14245
|
spentVtxos.push({
|
|
14195
14246
|
...spentFacts,
|
|
14196
|
-
virtualStatus:
|
|
14247
|
+
virtualStatus: chunkCDWLZQQW_cjs.toVirtualStatus(spentFacts),
|
|
14197
14248
|
...spentBy ? { spentBy } : {},
|
|
14198
14249
|
arkTxId: arkTxid
|
|
14199
14250
|
});
|
|
14200
14251
|
for (const id of vtxo.commitmentTxIds) {
|
|
14201
14252
|
commitmentTxIds.add(id);
|
|
14202
14253
|
}
|
|
14203
|
-
const vtxoExpiry =
|
|
14254
|
+
const vtxoExpiry = chunkCDWLZQQW_cjs.toBatchExpiry(vtxo);
|
|
14204
14255
|
if (vtxoExpiry) {
|
|
14205
14256
|
batchExpiry = Math.min(batchExpiry, vtxoExpiry);
|
|
14206
14257
|
}
|
|
@@ -14213,7 +14264,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14213
14264
|
isSwept: false,
|
|
14214
14265
|
isPreconfirmed: true,
|
|
14215
14266
|
commitmentTxIds: Array.from(commitmentTxIds),
|
|
14216
|
-
...
|
|
14267
|
+
...chunkCDWLZQQW_cjs.parseLegacyExpiry(batchExpiry)
|
|
14217
14268
|
};
|
|
14218
14269
|
changeVtxo = {
|
|
14219
14270
|
txid: arkTxid,
|
|
@@ -14225,7 +14276,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14225
14276
|
tapTree: offchainTapscript.encode(),
|
|
14226
14277
|
value: Number(changeAmount),
|
|
14227
14278
|
...changeFacts,
|
|
14228
|
-
virtualStatus:
|
|
14279
|
+
virtualStatus: chunkCDWLZQQW_cjs.toVirtualStatus(changeFacts),
|
|
14229
14280
|
spentBy: "",
|
|
14230
14281
|
status: {
|
|
14231
14282
|
confirmed: false
|
|
@@ -14294,12 +14345,12 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14294
14345
|
const spentVtxos = [];
|
|
14295
14346
|
const inputArkTxIds = /* @__PURE__ */ new Set();
|
|
14296
14347
|
const boardingRemovalsByAddress = /* @__PURE__ */ new Map();
|
|
14297
|
-
const vtxoInputs = inputs.filter(
|
|
14348
|
+
const vtxoInputs = inputs.filter(chunkCDWLZQQW_cjs.isVirtualCoin);
|
|
14298
14349
|
const cm = await this.getContractManager();
|
|
14299
14350
|
const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
|
|
14300
14351
|
const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
|
|
14301
14352
|
for (const input of inputs) {
|
|
14302
|
-
if (
|
|
14353
|
+
if (chunkCDWLZQQW_cjs.isVirtualCoin(input)) {
|
|
14303
14354
|
const outpoint = `${input.txid}:${input.vout}`;
|
|
14304
14355
|
const vtxo = annotatedByKey.get(outpoint);
|
|
14305
14356
|
if (!vtxo) {
|
|
@@ -14311,13 +14362,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14311
14362
|
const settledFacts = { ...vtxo, isSpent: true };
|
|
14312
14363
|
spentVtxos.push({
|
|
14313
14364
|
...settledFacts,
|
|
14314
|
-
virtualStatus:
|
|
14365
|
+
virtualStatus: chunkCDWLZQQW_cjs.toVirtualStatus(settledFacts),
|
|
14315
14366
|
settledBy: commitmentTxid
|
|
14316
14367
|
});
|
|
14317
14368
|
} else {
|
|
14318
14369
|
let sourceAddress;
|
|
14319
14370
|
try {
|
|
14320
|
-
sourceAddress =
|
|
14371
|
+
sourceAddress = chunkCDWLZQQW_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
|
|
14321
14372
|
this.network
|
|
14322
14373
|
);
|
|
14323
14374
|
} catch {
|
|
@@ -14375,9 +14426,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14375
14426
|
}
|
|
14376
14427
|
};
|
|
14377
14428
|
function selectVirtualCoins(coins, targetAmount) {
|
|
14378
|
-
const sortedCoins = coins.map(
|
|
14379
|
-
const expiryA =
|
|
14380
|
-
const expiryB =
|
|
14429
|
+
const sortedCoins = coins.map(chunkCDWLZQQW_cjs.normalizeVtxo).sort((a, b) => {
|
|
14430
|
+
const expiryA = chunkCDWLZQQW_cjs.toBatchExpiry(a) || Number.MAX_SAFE_INTEGER;
|
|
14431
|
+
const expiryB = chunkCDWLZQQW_cjs.toBatchExpiry(b) || Number.MAX_SAFE_INTEGER;
|
|
14381
14432
|
if (expiryA !== expiryB) {
|
|
14382
14433
|
return expiryA - expiryB;
|
|
14383
14434
|
}
|
|
@@ -14634,7 +14685,7 @@ var MessageBus = class {
|
|
|
14634
14685
|
this.initialized = true;
|
|
14635
14686
|
}
|
|
14636
14687
|
async buildServices(config) {
|
|
14637
|
-
const arkProvider = new
|
|
14688
|
+
const arkProvider = new chunkCDWLZQQW_cjs.RestArkProvider(config.arkServer.url);
|
|
14638
14689
|
const storage = {
|
|
14639
14690
|
walletRepository: this.walletRepository,
|
|
14640
14691
|
contractRepository: this.contractRepository
|
|
@@ -14973,7 +15024,7 @@ var offboardNetworkNames = [
|
|
|
14973
15024
|
function offboardDestinationScript(destinationAddress) {
|
|
14974
15025
|
for (const networkName of offboardNetworkNames) {
|
|
14975
15026
|
try {
|
|
14976
|
-
const network =
|
|
15027
|
+
const network = chunkCDWLZQQW_cjs.networks[networkName];
|
|
14977
15028
|
const addr = btcSigner.Address(network).decode(destinationAddress);
|
|
14978
15029
|
return btcSigner.OutScript.encode(addr);
|
|
14979
15030
|
} catch {
|
|
@@ -15037,7 +15088,7 @@ var Ramps = class {
|
|
|
15037
15088
|
}
|
|
15038
15089
|
amount = amount ?? totalAmount;
|
|
15039
15090
|
const offchainAddress = await this.wallet.getAddress();
|
|
15040
|
-
const offchainAddr =
|
|
15091
|
+
const offchainAddr = chunkCDWLZQQW_cjs.ArkAddress.decode(offchainAddress);
|
|
15041
15092
|
const offchainScript = base.hex.encode(offchainAddr.pkScript);
|
|
15042
15093
|
const outputFee = estimator.evalOffchainOutput({
|
|
15043
15094
|
amount,
|
|
@@ -15097,7 +15148,7 @@ var Ramps = class {
|
|
|
15097
15148
|
const filteredVtxos = [];
|
|
15098
15149
|
let totalAmount = 0n;
|
|
15099
15150
|
for (const vtxo of vtxos) {
|
|
15100
|
-
const inputFee = estimator.evalOffchainInput(
|
|
15151
|
+
const inputFee = estimator.evalOffchainInput(chunkCDWLZQQW_cjs.toOffchainInputFeeParams(vtxo));
|
|
15101
15152
|
if (inputFee.satoshis >= vtxo.value) {
|
|
15102
15153
|
continue;
|
|
15103
15154
|
}
|
|
@@ -15794,7 +15845,7 @@ var WalletMessageHandler = class {
|
|
|
15794
15845
|
// Wallet methods
|
|
15795
15846
|
async handleInitWallet({ payload }) {
|
|
15796
15847
|
const { arkServerUrl } = payload;
|
|
15797
|
-
this.indexerProvider = new
|
|
15848
|
+
this.indexerProvider = new chunk24YNIQSW_cjs.RestIndexerProvider(arkServerUrl);
|
|
15798
15849
|
await this.onWalletInitialized();
|
|
15799
15850
|
}
|
|
15800
15851
|
async handleGetBalance() {
|
|
@@ -15818,12 +15869,12 @@ var WalletMessageHandler = class {
|
|
|
15818
15869
|
let recoverable = 0;
|
|
15819
15870
|
let pendingRecovery = 0;
|
|
15820
15871
|
for (const vtxo of allVtxos) {
|
|
15821
|
-
if (
|
|
15872
|
+
if (chunkCDWLZQQW_cjs.hasTerminalSpend(vtxo)) continue;
|
|
15822
15873
|
if (pendingOutpoints.has(`${vtxo.txid}:${vtxo.vout}`)) {
|
|
15823
15874
|
pendingRecovery += vtxo.value;
|
|
15824
|
-
} else if (
|
|
15875
|
+
} else if (chunkCDWLZQQW_cjs.canRecoverOnchain(vtxo, now)) {
|
|
15825
15876
|
recoverable += vtxo.value;
|
|
15826
|
-
} else if (
|
|
15877
|
+
} else if (chunkCDWLZQQW_cjs.canSpendOffchain(vtxo, now)) {
|
|
15827
15878
|
if (vtxo.isPreconfirmed) {
|
|
15828
15879
|
preconfirmed += vtxo.value;
|
|
15829
15880
|
} else {
|
|
@@ -15835,7 +15886,7 @@ var WalletMessageHandler = class {
|
|
|
15835
15886
|
const totalOffchain = settled + preconfirmed + recoverable + pendingRecovery;
|
|
15836
15887
|
const assetBalances = /* @__PURE__ */ new Map();
|
|
15837
15888
|
for (const vtxo of allVtxos) {
|
|
15838
|
-
if (
|
|
15889
|
+
if (chunkCDWLZQQW_cjs.hasTerminalSpend(vtxo)) continue;
|
|
15839
15890
|
if (vtxo.assets) {
|
|
15840
15891
|
for (const a of vtxo.assets) {
|
|
15841
15892
|
const current = assetBalances.get(a.assetId) ?? 0n;
|
|
@@ -15871,7 +15922,7 @@ var WalletMessageHandler = class {
|
|
|
15871
15922
|
*/
|
|
15872
15923
|
async getSpendableVtxos() {
|
|
15873
15924
|
const vtxos = await this.getVtxosFromRepo();
|
|
15874
|
-
return vtxos.filter((v) => !
|
|
15925
|
+
return vtxos.filter((v) => !chunkCDWLZQQW_cjs.hasTerminalSpend(v));
|
|
15875
15926
|
}
|
|
15876
15927
|
async onWalletInitialized() {
|
|
15877
15928
|
if (!this.readonlyWallet || !this.arkProvider || !this.indexerProvider || !this.walletRepository) {
|
|
@@ -16083,10 +16134,10 @@ var WalletMessageHandler = class {
|
|
|
16083
16134
|
if (dustAmount != null && isSubdust(v, dustAmount)) {
|
|
16084
16135
|
return false;
|
|
16085
16136
|
}
|
|
16086
|
-
if (
|
|
16137
|
+
if (chunkCDWLZQQW_cjs.isRecoverable(v)) {
|
|
16087
16138
|
return false;
|
|
16088
16139
|
}
|
|
16089
|
-
if (
|
|
16140
|
+
if (chunkCDWLZQQW_cjs.isExpired(v)) {
|
|
16090
16141
|
return false;
|
|
16091
16142
|
}
|
|
16092
16143
|
return true;
|
|
@@ -16158,7 +16209,7 @@ var WalletMessageHandler = class {
|
|
|
16158
16209
|
if (!this.readonlyWallet) return null;
|
|
16159
16210
|
const { boardingTxs, commitmentsToIgnore } = await this.readonlyWallet.getBoardingTxs();
|
|
16160
16211
|
const indexerProvider = this.indexerProvider;
|
|
16161
|
-
const resolveTxCreatedAt = indexerProvider ? (txids) =>
|
|
16212
|
+
const resolveTxCreatedAt = indexerProvider ? (txids) => chunkCDWLZQQW_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
|
|
16162
16213
|
return buildTransactionHistory(vtxos, boardingTxs, commitmentsToIgnore, resolveTxCreatedAt);
|
|
16163
16214
|
}
|
|
16164
16215
|
async ensureContractEventBroadcasting() {
|
|
@@ -16843,7 +16894,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
16843
16894
|
};
|
|
16844
16895
|
try {
|
|
16845
16896
|
const response = await this.sendMessage(message);
|
|
16846
|
-
return response.payload.vtxos.map(
|
|
16897
|
+
return response.payload.vtxos.map(chunkCDWLZQQW_cjs.normalizeVtxo);
|
|
16847
16898
|
} catch (error) {
|
|
16848
16899
|
throw new Error(`Failed to get vtxos: ${error}`);
|
|
16849
16900
|
}
|
|
@@ -16956,7 +17007,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
16956
17007
|
};
|
|
16957
17008
|
try {
|
|
16958
17009
|
const response = await sendContractMessage(message);
|
|
16959
|
-
return response.payload.vtxos.map(
|
|
17010
|
+
return response.payload.vtxos.map(chunkCDWLZQQW_cjs.normalizeVtxo);
|
|
16960
17011
|
} catch (e) {
|
|
16961
17012
|
throw new Error("Failed to annotate vtxos");
|
|
16962
17013
|
}
|
|
@@ -17410,7 +17461,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
17410
17461
|
};
|
|
17411
17462
|
try {
|
|
17412
17463
|
const response = await wallet.sendMessage(message);
|
|
17413
|
-
return response.payload.vtxos.map(
|
|
17464
|
+
return response.payload.vtxos.map(chunkCDWLZQQW_cjs.normalizeVtxo);
|
|
17414
17465
|
} catch (e) {
|
|
17415
17466
|
throw new Error(`Failed to get expiring vtxos: ${e}`);
|
|
17416
17467
|
}
|
|
@@ -17522,12 +17573,12 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
17522
17573
|
* @returns Configured onchain wallet
|
|
17523
17574
|
* @throws Error if the configured identity cannot produce a valid x-only public key
|
|
17524
17575
|
*/
|
|
17525
|
-
static async create(identity, networkName =
|
|
17576
|
+
static async create(identity, networkName = chunkCDWLZQQW_cjs.DEFAULT_NETWORK_NAME, provider) {
|
|
17526
17577
|
const pubkey = await identity.xOnlyPublicKey();
|
|
17527
17578
|
if (!pubkey) {
|
|
17528
17579
|
throw new Error("Invalid configured public key");
|
|
17529
17580
|
}
|
|
17530
|
-
const network =
|
|
17581
|
+
const network = chunkCDWLZQQW_cjs.getNetwork(networkName);
|
|
17531
17582
|
const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
|
|
17532
17583
|
const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
|
|
17533
17584
|
return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
|
|
@@ -17633,7 +17684,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
17633
17684
|
if (!inputs) {
|
|
17634
17685
|
throw new Error("Fee estimation failed");
|
|
17635
17686
|
}
|
|
17636
|
-
let tx = new
|
|
17687
|
+
let tx = new chunkCDWLZQQW_cjs.Transaction();
|
|
17637
17688
|
for (const input of inputs) {
|
|
17638
17689
|
tx.addInput({
|
|
17639
17690
|
txid: input.txid,
|
|
@@ -17691,7 +17742,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
17691
17742
|
* @throws If the parent has no anchor, or funding cannot be selected/signed
|
|
17692
17743
|
*/
|
|
17693
17744
|
async bumpAnchor(parentHex, feeRate) {
|
|
17694
|
-
const parent =
|
|
17745
|
+
const parent = chunkCDWLZQQW_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
|
|
17695
17746
|
const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
|
|
17696
17747
|
const child = await this.buildBumpPackage(parent, feeRate, coins);
|
|
17697
17748
|
return [parent.hex, child.hex];
|
|
@@ -18456,7 +18507,7 @@ exports.BIP322 = void 0;
|
|
|
18456
18507
|
async function sign2(message, identity, network) {
|
|
18457
18508
|
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
18458
18509
|
const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
|
|
18459
|
-
const toSpend =
|
|
18510
|
+
const toSpend = chunkCDWLZQQW_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
18460
18511
|
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
18461
18512
|
const signed = await identity.sign(toSign, [0]);
|
|
18462
18513
|
signed.finalizeIdx(0);
|
|
@@ -18514,7 +18565,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
|
18514
18565
|
if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
|
|
18515
18566
|
return false;
|
|
18516
18567
|
}
|
|
18517
|
-
const toSpend =
|
|
18568
|
+
const toSpend = chunkCDWLZQQW_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
18518
18569
|
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
|
|
18519
18570
|
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
18520
18571
|
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
@@ -18535,7 +18586,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
|
18535
18586
|
}
|
|
18536
18587
|
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
18537
18588
|
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
18538
|
-
const toSpend =
|
|
18589
|
+
const toSpend = chunkCDWLZQQW_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
18539
18590
|
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
18540
18591
|
const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
|
|
18541
18592
|
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
@@ -18588,7 +18639,7 @@ function encodeCompactSize(n) {
|
|
|
18588
18639
|
return buf;
|
|
18589
18640
|
}
|
|
18590
18641
|
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
18591
|
-
const tx = new
|
|
18642
|
+
const tx = new chunkCDWLZQQW_cjs.Transaction({ version: 0 });
|
|
18592
18643
|
tx.addInput({
|
|
18593
18644
|
txid: toSpend.id,
|
|
18594
18645
|
index: 0,
|
|
@@ -18602,12 +18653,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
|
18602
18653
|
});
|
|
18603
18654
|
tx.addOutput({
|
|
18604
18655
|
amount: 0n,
|
|
18605
|
-
script:
|
|
18656
|
+
script: chunkCDWLZQQW_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
18606
18657
|
});
|
|
18607
18658
|
return tx;
|
|
18608
18659
|
}
|
|
18609
18660
|
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
18610
|
-
const tx = new
|
|
18661
|
+
const tx = new chunkCDWLZQQW_cjs.Transaction({ version: 0 });
|
|
18611
18662
|
tx.addInput({
|
|
18612
18663
|
txid: toSpend.id,
|
|
18613
18664
|
index: 0,
|
|
@@ -18619,7 +18670,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
|
18619
18670
|
});
|
|
18620
18671
|
tx.addOutput({
|
|
18621
18672
|
amount: 0n,
|
|
18622
|
-
script:
|
|
18673
|
+
script: chunkCDWLZQQW_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
18623
18674
|
});
|
|
18624
18675
|
return tx;
|
|
18625
18676
|
}
|
|
@@ -18750,7 +18801,7 @@ var RestEmulatorProvider = class {
|
|
|
18750
18801
|
}
|
|
18751
18802
|
};
|
|
18752
18803
|
function finalizeVirtualTx(type, psbtBase64) {
|
|
18753
|
-
const tx =
|
|
18804
|
+
const tx = chunkCDWLZQQW_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
18754
18805
|
if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
|
|
18755
18806
|
const input = tx.getInput(0);
|
|
18756
18807
|
if (!input) {
|
|
@@ -18777,14 +18828,14 @@ var ExitPathError = class extends Error {
|
|
|
18777
18828
|
reason;
|
|
18778
18829
|
};
|
|
18779
18830
|
function delayWeight(sequence) {
|
|
18780
|
-
const t =
|
|
18831
|
+
const t = chunkCDWLZQQW_cjs.sequenceToTimelock(sequence);
|
|
18781
18832
|
return t.type === "blocks" ? Number(t.value) : Number(t.value) / 600;
|
|
18782
18833
|
}
|
|
18783
18834
|
async function resolveUnilateralPath(params) {
|
|
18784
18835
|
const { vtxo, scriptHex, contractRepository } = params;
|
|
18785
18836
|
const contract = contractRepository ? (await contractRepository.getContracts({ script: scriptHex }))[0] : void 0;
|
|
18786
18837
|
if (contract) {
|
|
18787
|
-
const handler =
|
|
18838
|
+
const handler = chunk37XKN5DZ_cjs.contractHandlers.get(contract.type);
|
|
18788
18839
|
if (!handler) {
|
|
18789
18840
|
throw new ExitPathError(
|
|
18790
18841
|
"no-handler",
|
|
@@ -18807,12 +18858,12 @@ async function resolveUnilateralPath(params) {
|
|
|
18807
18858
|
paths.sort((a, b) => delayWeight(a.sequence) - delayWeight(b.sequence));
|
|
18808
18859
|
return { selection: paths[0], label: `${contract.type}:unilateral` };
|
|
18809
18860
|
}
|
|
18810
|
-
const decoded =
|
|
18861
|
+
const decoded = chunkCDWLZQQW_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
18811
18862
|
let best;
|
|
18812
18863
|
for (const exit of decoded.exitPaths()) {
|
|
18813
18864
|
const leaf = decoded.findLeaf(base.hex.encode(exit.script));
|
|
18814
18865
|
if (!leaf) continue;
|
|
18815
|
-
const sequence =
|
|
18866
|
+
const sequence = chunkCDWLZQQW_cjs.timelockToSequence(exit.params.timelock);
|
|
18816
18867
|
const weight = delayWeight(sequence);
|
|
18817
18868
|
if (!best || weight < best.weight) {
|
|
18818
18869
|
best = { selection: { leaf, sequence }, weight };
|
|
@@ -18998,14 +19049,14 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
18998
19049
|
}
|
|
18999
19050
|
const resolved = await resolveUnilateralPath({
|
|
19000
19051
|
vtxo,
|
|
19001
|
-
scriptHex: base.hex.encode(
|
|
19052
|
+
scriptHex: base.hex.encode(chunkCDWLZQQW_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
19002
19053
|
contractRepository: wallet.contractRepository,
|
|
19003
19054
|
walletPubKeyHex: base.hex.encode(await wallet.identity.xOnlyPublicKey()),
|
|
19004
19055
|
currentTime: Date.now()
|
|
19005
19056
|
});
|
|
19006
19057
|
const spendingLeaf = resolved.selection.leaf;
|
|
19007
19058
|
const sequence = resolved.selection.sequence;
|
|
19008
|
-
const timelock =
|
|
19059
|
+
const timelock = chunkCDWLZQQW_cjs.sequenceToTimelock(sequence);
|
|
19009
19060
|
const elapsed = timelock.type === "blocks" ? chainTip.height >= txStatus.blockHeight + Number(timelock.value) : chainTip.time >= txStatus.blockTime + Number(timelock.value);
|
|
19010
19061
|
if (!elapsed) {
|
|
19011
19062
|
throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
|
|
@@ -19018,7 +19069,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
19018
19069
|
sequence,
|
|
19019
19070
|
witnessUtxo: {
|
|
19020
19071
|
amount: BigInt(vtxo.value),
|
|
19021
|
-
script:
|
|
19072
|
+
script: chunkCDWLZQQW_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
|
|
19022
19073
|
},
|
|
19023
19074
|
sighashType: btcSigner.SigHash.DEFAULT
|
|
19024
19075
|
});
|
|
@@ -19028,7 +19079,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
19028
19079
|
btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
|
|
19029
19080
|
);
|
|
19030
19081
|
}
|
|
19031
|
-
const tx = new
|
|
19082
|
+
const tx = new chunkCDWLZQQW_cjs.Transaction({ version: 2 });
|
|
19032
19083
|
for (const input of inputs) {
|
|
19033
19084
|
tx.addInput(input);
|
|
19034
19085
|
}
|
|
@@ -19095,7 +19146,7 @@ async function buildSignedSweep(params) {
|
|
|
19095
19146
|
`uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
|
|
19096
19147
|
);
|
|
19097
19148
|
}
|
|
19098
|
-
const tx = new
|
|
19149
|
+
const tx = new chunkCDWLZQQW_cjs.Transaction({ version: 2 });
|
|
19099
19150
|
tx.addInput({
|
|
19100
19151
|
txid: vtxo.txid,
|
|
19101
19152
|
index: vtxo.vout,
|
|
@@ -19120,7 +19171,7 @@ async function buildSignedSweep(params) {
|
|
|
19120
19171
|
finalScriptWitness: [
|
|
19121
19172
|
tapScriptSig[0][1],
|
|
19122
19173
|
...path.extraWitness,
|
|
19123
|
-
|
|
19174
|
+
chunkCDWLZQQW_cjs.scriptFromTapLeafScript(path.leaf),
|
|
19124
19175
|
btcSigner.TaprootControlBlock.encode(controlBlock)
|
|
19125
19176
|
]
|
|
19126
19177
|
});
|
|
@@ -19150,7 +19201,7 @@ async function resolveFeeRate(opts) {
|
|
|
19150
19201
|
}
|
|
19151
19202
|
async function selectExitVtxos(opts) {
|
|
19152
19203
|
if (!opts.vtxos) return opts.wallet.getVtxos();
|
|
19153
|
-
const res = await
|
|
19204
|
+
const res = await chunkCDWLZQQW_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
|
|
19154
19205
|
const tapTrees = /* @__PURE__ */ new Map();
|
|
19155
19206
|
const out = [];
|
|
19156
19207
|
for (const vtxo of res.vtxos) {
|
|
@@ -19165,7 +19216,7 @@ async function selectExitVtxos(opts) {
|
|
|
19165
19216
|
`no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
|
|
19166
19217
|
);
|
|
19167
19218
|
}
|
|
19168
|
-
const handler =
|
|
19219
|
+
const handler = chunk37XKN5DZ_cjs.contractHandlers.get(contract.type);
|
|
19169
19220
|
if (!handler) {
|
|
19170
19221
|
throw new Error(`no contract handler registered for type '${contract.type}'`);
|
|
19171
19222
|
}
|
|
@@ -19195,7 +19246,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
19195
19246
|
if (pendingNodes.length > 0) {
|
|
19196
19247
|
const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
|
|
19197
19248
|
for (const psbt of txs) {
|
|
19198
|
-
psbts.set(
|
|
19249
|
+
psbts.set(chunkCDWLZQQW_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
19199
19250
|
}
|
|
19200
19251
|
}
|
|
19201
19252
|
const childVsize = Number(
|
|
@@ -19231,7 +19282,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
19231
19282
|
try {
|
|
19232
19283
|
const resolved = await resolveUnilateralPath({
|
|
19233
19284
|
vtxo,
|
|
19234
|
-
scriptHex: base.hex.encode(
|
|
19285
|
+
scriptHex: base.hex.encode(chunkCDWLZQQW_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
19235
19286
|
contractRepository: wallet.contractRepository,
|
|
19236
19287
|
walletPubKeyHex,
|
|
19237
19288
|
currentTime: Date.now()
|
|
@@ -19250,7 +19301,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
19250
19301
|
});
|
|
19251
19302
|
continue;
|
|
19252
19303
|
}
|
|
19253
|
-
const t =
|
|
19304
|
+
const t = chunkCDWLZQQW_cjs.sequenceToTimelock(resolved.selection.sequence);
|
|
19254
19305
|
const delay = { type: t.type, value: Number(t.value) };
|
|
19255
19306
|
infos.push({ outpoint, value: vtxo.value, sweepFee, path: resolved.label, delay });
|
|
19256
19307
|
sweeps.push({ vtxo, resolved, sweepFee, delay });
|
|
@@ -19589,7 +19640,7 @@ async function prepare(opts) {
|
|
|
19589
19640
|
txid: sweep.vtxo.txid,
|
|
19590
19641
|
vout: sweep.vtxo.vout,
|
|
19591
19642
|
value: sweep.vtxo.value,
|
|
19592
|
-
pkScript:
|
|
19643
|
+
pkScript: chunkCDWLZQQW_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
|
|
19593
19644
|
},
|
|
19594
19645
|
path: sweep.resolved.selection,
|
|
19595
19646
|
outputAddress: opts.sweepAddress,
|
|
@@ -19674,7 +19725,7 @@ async function prepare(opts) {
|
|
|
19674
19725
|
if (newFee <= splitterFee) break;
|
|
19675
19726
|
splitterFee = newFee;
|
|
19676
19727
|
}
|
|
19677
|
-
const splitter = new
|
|
19728
|
+
const splitter = new chunkCDWLZQQW_cjs.Transaction({ version: 2 });
|
|
19678
19729
|
for (const coin of selected.inputs) {
|
|
19679
19730
|
splitter.addInput({
|
|
19680
19731
|
txid: coin.txid,
|
|
@@ -19817,41 +19868,41 @@ var UnilateralExit = {
|
|
|
19817
19868
|
// src/arkade/index.ts
|
|
19818
19869
|
var arkade_exports = {};
|
|
19819
19870
|
chunk5BLDMQED_cjs.__export(arkade_exports, {
|
|
19820
|
-
ARKADE_OP: () =>
|
|
19821
|
-
ARKADE_OPCODES: () =>
|
|
19822
|
-
ARKADE_OPCODE_NAMES: () =>
|
|
19823
|
-
ARKADE_OPCODE_VALUES: () =>
|
|
19824
|
-
ARKADE_OPS: () =>
|
|
19871
|
+
ARKADE_OP: () => chunk37XKN5DZ_cjs.ARKADE_OP,
|
|
19872
|
+
ARKADE_OPCODES: () => chunk37XKN5DZ_cjs.ARKADE_OPCODES,
|
|
19873
|
+
ARKADE_OPCODE_NAMES: () => chunk37XKN5DZ_cjs.ARKADE_OPCODE_NAMES,
|
|
19874
|
+
ARKADE_OPCODE_VALUES: () => chunk37XKN5DZ_cjs.ARKADE_OPCODE_VALUES,
|
|
19875
|
+
ARKADE_OPS: () => chunk37XKN5DZ_cjs.ARKADE_OPS,
|
|
19825
19876
|
Arkade: () => Arkade,
|
|
19826
19877
|
ArkadeContract: () => ArkadeContract,
|
|
19827
|
-
ArkadeProgramScript: () =>
|
|
19828
|
-
ArkadeScript: () =>
|
|
19878
|
+
ArkadeProgramScript: () => chunk37XKN5DZ_cjs.ArkadeProgramScript,
|
|
19879
|
+
ArkadeScript: () => chunk37XKN5DZ_cjs.ArkadeScript,
|
|
19829
19880
|
ArkadeTransactionBuilder: () => ArkadeTransactionBuilder,
|
|
19830
|
-
BigNum: () =>
|
|
19881
|
+
BigNum: () => chunk37XKN5DZ_cjs.bignum_exports,
|
|
19831
19882
|
OP: () => btcSigner.OP,
|
|
19832
|
-
OPCODE_NAMES: () =>
|
|
19833
|
-
OPCODE_VALUES: () =>
|
|
19834
|
-
SUPPORTED_PROGRAM_VERSION: () =>
|
|
19883
|
+
OPCODE_NAMES: () => chunk37XKN5DZ_cjs.OPCODE_NAMES,
|
|
19884
|
+
OPCODE_VALUES: () => chunk37XKN5DZ_cjs.OPCODE_VALUES,
|
|
19885
|
+
SUPPORTED_PROGRAM_VERSION: () => chunk37XKN5DZ_cjs.SUPPORTED_PROGRAM_VERSION,
|
|
19835
19886
|
Script: () => btcSigner.Script,
|
|
19836
|
-
arkadeScriptHash: () =>
|
|
19837
|
-
arkadeWitnessHash: () =>
|
|
19838
|
-
asmToBytes: () =>
|
|
19839
|
-
bytesToASM: () =>
|
|
19840
|
-
computeArkadeScriptPublicKey: () =>
|
|
19887
|
+
arkadeScriptHash: () => chunk37XKN5DZ_cjs.arkadeScriptHash,
|
|
19888
|
+
arkadeWitnessHash: () => chunk37XKN5DZ_cjs.arkadeWitnessHash,
|
|
19889
|
+
asmToBytes: () => chunk37XKN5DZ_cjs.asmToBytes,
|
|
19890
|
+
bytesToASM: () => chunk37XKN5DZ_cjs.bytesToASM,
|
|
19891
|
+
computeArkadeScriptPublicKey: () => chunk37XKN5DZ_cjs.computeArkadeScriptPublicKey,
|
|
19841
19892
|
createArkadeBatchHandler: () => createArkadeBatchHandler,
|
|
19842
|
-
deserializeArkadeContractParams: () =>
|
|
19843
|
-
fromASM: () =>
|
|
19844
|
-
getOpcodeName: () =>
|
|
19845
|
-
getOpcodeValue: () =>
|
|
19846
|
-
parseArtifact: () =>
|
|
19847
|
-
resolveAsm: () =>
|
|
19848
|
-
serializeArkadeContractParams: () =>
|
|
19849
|
-
stringifyArtifact: () =>
|
|
19850
|
-
toASM: () =>
|
|
19851
|
-
validateProgram: () =>
|
|
19852
|
-
witnessRefToBytes: () =>
|
|
19893
|
+
deserializeArkadeContractParams: () => chunk37XKN5DZ_cjs.deserializeArkadeContractParams,
|
|
19894
|
+
fromASM: () => chunk37XKN5DZ_cjs.fromASM,
|
|
19895
|
+
getOpcodeName: () => chunk37XKN5DZ_cjs.getOpcodeName,
|
|
19896
|
+
getOpcodeValue: () => chunk37XKN5DZ_cjs.getOpcodeValue,
|
|
19897
|
+
parseArtifact: () => chunk37XKN5DZ_cjs.parseArtifact,
|
|
19898
|
+
resolveAsm: () => chunk37XKN5DZ_cjs.resolveAsm,
|
|
19899
|
+
serializeArkadeContractParams: () => chunk37XKN5DZ_cjs.serializeArkadeContractParams,
|
|
19900
|
+
stringifyArtifact: () => chunk37XKN5DZ_cjs.stringifyArtifact,
|
|
19901
|
+
toASM: () => chunk37XKN5DZ_cjs.toASM,
|
|
19902
|
+
validateProgram: () => chunk37XKN5DZ_cjs.validateProgram,
|
|
19903
|
+
witnessRefToBytes: () => chunk37XKN5DZ_cjs.witnessRefToBytes
|
|
19853
19904
|
});
|
|
19854
|
-
var isVtxoCoin = (input) =>
|
|
19905
|
+
var isVtxoCoin = (input) => chunkCDWLZQQW_cjs.isVirtualCoin(input);
|
|
19855
19906
|
function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients) {
|
|
19856
19907
|
let batchId;
|
|
19857
19908
|
let sweepTapTreeRoot;
|
|
@@ -19864,7 +19915,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
19864
19915
|
if (!event.intentIdHashes.includes(intentIdHashStr)) return { skip: true };
|
|
19865
19916
|
await arkProvider.confirmRegistration(intentId);
|
|
19866
19917
|
batchId = event.id;
|
|
19867
|
-
const sweepTapscript =
|
|
19918
|
+
const sweepTapscript = chunkCDWLZQQW_cjs.CSVMultisigTapscript.encode({
|
|
19868
19919
|
timelock: {
|
|
19869
19920
|
value: event.batchExpiry,
|
|
19870
19921
|
// BIP-65: values >= 512 are interpreted as seconds, below as blocks
|
|
@@ -19882,7 +19933,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
19882
19933
|
if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
|
|
19883
19934
|
return { skip: true };
|
|
19884
19935
|
}
|
|
19885
|
-
const commitmentTx =
|
|
19936
|
+
const commitmentTx = chunkCDWLZQQW_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
|
|
19886
19937
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
19887
19938
|
if (recipients && recipients.length > 0) {
|
|
19888
19939
|
validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
|
|
@@ -19914,7 +19965,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
19914
19965
|
if (connectorTree) {
|
|
19915
19966
|
validateConnectorsTxGraph(event.commitmentTx, connectorTree);
|
|
19916
19967
|
}
|
|
19917
|
-
let commitmentPsbt =
|
|
19968
|
+
let commitmentPsbt = chunkCDWLZQQW_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
19918
19969
|
assertFinalCommitmentMatchesValidated(
|
|
19919
19970
|
commitmentPsbt,
|
|
19920
19971
|
validatedCommitmentTxid,
|
|
@@ -19949,7 +20000,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
19949
20000
|
boardingIndices.push(boardingIdx);
|
|
19950
20001
|
continue;
|
|
19951
20002
|
}
|
|
19952
|
-
if (
|
|
20003
|
+
if (chunkCDWLZQQW_cjs.isRecoverable(input) || isSubdust(input, info.dust)) {
|
|
19953
20004
|
continue;
|
|
19954
20005
|
}
|
|
19955
20006
|
if (connectorIndex >= connectorLeaves.length) {
|
|
@@ -19970,7 +20021,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
19970
20021
|
index: input.vout,
|
|
19971
20022
|
witnessUtxo: {
|
|
19972
20023
|
amount: BigInt(input.value),
|
|
19973
|
-
script:
|
|
20024
|
+
script: chunkCDWLZQQW_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
19974
20025
|
},
|
|
19975
20026
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
19976
20027
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -20053,7 +20104,7 @@ var Arkade = class _Arkade {
|
|
|
20053
20104
|
static async connect(opts) {
|
|
20054
20105
|
const info = await opts.arkade.getInfo();
|
|
20055
20106
|
const serverKey = base.hex.decode(info.signerPubkey).slice(1);
|
|
20056
|
-
const checkpoint =
|
|
20107
|
+
const checkpoint = chunkCDWLZQQW_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
20057
20108
|
let emulatorKey;
|
|
20058
20109
|
if (opts.emulator) {
|
|
20059
20110
|
const eInfo = await opts.emulator.getInfo();
|
|
@@ -20067,7 +20118,7 @@ var Arkade = class _Arkade {
|
|
|
20067
20118
|
return new _Arkade({
|
|
20068
20119
|
arkProvider: opts.arkade,
|
|
20069
20120
|
emulator: opts.emulator,
|
|
20070
|
-
network: opts.network ??
|
|
20121
|
+
network: opts.network ?? chunkCDWLZQQW_cjs.DEFAULT_NETWORK,
|
|
20071
20122
|
serverKey,
|
|
20072
20123
|
emulatorKey,
|
|
20073
20124
|
checkpoint,
|
|
@@ -20088,7 +20139,7 @@ var Arkade = class _Arkade {
|
|
|
20088
20139
|
* key respectively; explicit args always win.
|
|
20089
20140
|
*/
|
|
20090
20141
|
contract(program, args = {}) {
|
|
20091
|
-
const declared = (program.params ?? []).map(
|
|
20142
|
+
const declared = (program.params ?? []).map(chunk37XKN5DZ_cjs.inputName);
|
|
20092
20143
|
if (declared.includes("server") && args.server === void 0) {
|
|
20093
20144
|
args = { ...args, server: this.serverKey };
|
|
20094
20145
|
}
|
|
@@ -20108,7 +20159,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
20108
20159
|
userKey: client.userKey,
|
|
20109
20160
|
emulatorKey: client.emulatorKey
|
|
20110
20161
|
};
|
|
20111
|
-
this.vtxoScript = new
|
|
20162
|
+
this.vtxoScript = new chunk37XKN5DZ_cjs.ArkadeProgramScript(program, args, this.keys);
|
|
20112
20163
|
this.tapTree = this.vtxoScript.encode();
|
|
20113
20164
|
this.compiled = this.vtxoScript.compiled;
|
|
20114
20165
|
}
|
|
@@ -20136,7 +20187,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
20136
20187
|
`ArkadeContract.fromContract: expected contract type 'arkade', got '${contract.type}'`
|
|
20137
20188
|
);
|
|
20138
20189
|
}
|
|
20139
|
-
const typed =
|
|
20190
|
+
const typed = chunk37XKN5DZ_cjs.deserializeArkadeContractParams(contract.params);
|
|
20140
20191
|
return new _ArkadeContract(client, typed.program, typed.args, {
|
|
20141
20192
|
serverKey: typed.serverKey,
|
|
20142
20193
|
userKey: typed.userKey,
|
|
@@ -20177,7 +20228,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
20177
20228
|
toContractParams() {
|
|
20178
20229
|
return {
|
|
20179
20230
|
type: "arkade",
|
|
20180
|
-
params:
|
|
20231
|
+
params: chunk37XKN5DZ_cjs.serializeArkadeContractParams({
|
|
20181
20232
|
program: this.program,
|
|
20182
20233
|
args: this.args,
|
|
20183
20234
|
serverKey: this.keys.serverKey,
|
|
@@ -20222,13 +20273,13 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
20222
20273
|
const [registered] = await manager.getContracts({ script: scriptHex });
|
|
20223
20274
|
if (registered) {
|
|
20224
20275
|
const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
|
|
20225
|
-
return (withVtxos?.vtxos ?? []).filter((v) => !
|
|
20276
|
+
return (withVtxos?.vtxos ?? []).filter((v) => !chunkCDWLZQQW_cjs.hasTerminalSpend(v));
|
|
20226
20277
|
}
|
|
20227
20278
|
}
|
|
20228
20279
|
if (!this.client.indexer) {
|
|
20229
20280
|
throw new Error("ArkadeContract.getUtxos: an indexer is required");
|
|
20230
20281
|
}
|
|
20231
|
-
const { vtxos } = await
|
|
20282
|
+
const { vtxos } = await chunkCDWLZQQW_cjs.getNormalizedVtxos(this.client.indexer, {
|
|
20232
20283
|
scripts: [scriptHex],
|
|
20233
20284
|
spendableOnly: true
|
|
20234
20285
|
});
|
|
@@ -20330,12 +20381,12 @@ var ArkadeTransactionBuilder = class {
|
|
|
20330
20381
|
this.contract.client.checkpoint
|
|
20331
20382
|
);
|
|
20332
20383
|
if (coin.sourceTx) {
|
|
20333
|
-
|
|
20384
|
+
chunkCDWLZQQW_cjs.setArkPsbtField(arkTx, 0, chunkCDWLZQQW_cjs.PrevArkTxField, coin.sourceTx);
|
|
20334
20385
|
}
|
|
20335
20386
|
const condition = (def.tapscript.witness ?? []).map((w) => this.witnessBytes(w));
|
|
20336
20387
|
if (condition.length > 0) {
|
|
20337
|
-
|
|
20338
|
-
|
|
20388
|
+
chunkCDWLZQQW_cjs.setArkPsbtField(arkTx, 0, chunkCDWLZQQW_cjs.ConditionWitness, condition);
|
|
20389
|
+
chunkCDWLZQQW_cjs.setArkPsbtField(checkpoints[0], 0, chunkCDWLZQQW_cjs.ConditionWitness, condition);
|
|
20339
20390
|
}
|
|
20340
20391
|
const packets = [];
|
|
20341
20392
|
if (this.assetSpecs.length > 0) {
|
|
@@ -20374,7 +20425,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
20374
20425
|
base.base64.encode(signedArk2.toPSBT()),
|
|
20375
20426
|
signedCps.map((c) => base.base64.encode(c.toPSBT()))
|
|
20376
20427
|
);
|
|
20377
|
-
const txid =
|
|
20428
|
+
const txid = chunkCDWLZQQW_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
|
|
20378
20429
|
return {
|
|
20379
20430
|
txid,
|
|
20380
20431
|
signedArkTx: res2.signedArkTx,
|
|
@@ -20433,23 +20484,23 @@ var ArkadeTransactionBuilder = class {
|
|
|
20433
20484
|
}
|
|
20434
20485
|
buildAssetPacket() {
|
|
20435
20486
|
const groups = this.assetSpecs.map((s) => {
|
|
20436
|
-
const id = typeof s.assetId === "string" ?
|
|
20437
|
-
return
|
|
20487
|
+
const id = typeof s.assetId === "string" ? chunk24YNIQSW_cjs.AssetId.fromString(s.assetId) : chunk24YNIQSW_cjs.AssetId.fromBytes(s.assetId);
|
|
20488
|
+
return chunk24YNIQSW_cjs.AssetGroup.create(
|
|
20438
20489
|
id,
|
|
20439
20490
|
null,
|
|
20440
|
-
s.inputs.map((i) =>
|
|
20441
|
-
s.outputs.map((o) =>
|
|
20442
|
-
(s.metadata ?? []).map((m) =>
|
|
20491
|
+
s.inputs.map((i) => chunk24YNIQSW_cjs.AssetInput.create(i.vin, i.amount)),
|
|
20492
|
+
s.outputs.map((o) => chunk24YNIQSW_cjs.AssetOutput.create(o.vout, o.amount)),
|
|
20493
|
+
(s.metadata ?? []).map((m) => chunk24YNIQSW_cjs.Metadata.create(m.key, m.value))
|
|
20443
20494
|
);
|
|
20444
20495
|
});
|
|
20445
|
-
return
|
|
20496
|
+
return chunk24YNIQSW_cjs.Packet.create(groups);
|
|
20446
20497
|
}
|
|
20447
20498
|
witnessBytes(ref) {
|
|
20448
|
-
return
|
|
20499
|
+
return chunk37XKN5DZ_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
|
|
20449
20500
|
}
|
|
20450
20501
|
};
|
|
20451
20502
|
function bindInputs(fn, callArgs) {
|
|
20452
|
-
const names = (fn.def.inputs ?? []).map(
|
|
20503
|
+
const names = (fn.def.inputs ?? []).map(chunk37XKN5DZ_cjs.inputName);
|
|
20453
20504
|
if (callArgs.length !== names.length) {
|
|
20454
20505
|
throw new Error(`${fn.name}: expected ${names.length} argument(s), got ${callArgs.length}`);
|
|
20455
20506
|
}
|
|
@@ -20856,7 +20907,7 @@ function decodeArkContract(encoded) {
|
|
|
20856
20907
|
}
|
|
20857
20908
|
function contractFromArkContract(encoded, options = {}) {
|
|
20858
20909
|
const parsed = decodeArkContract(encoded);
|
|
20859
|
-
const handler =
|
|
20910
|
+
const handler = chunk37XKN5DZ_cjs.contractHandlers.get(parsed.type);
|
|
20860
20911
|
if (!handler) {
|
|
20861
20912
|
throw new Error(`No handler registered for contract type '${parsed.type}'`);
|
|
20862
20913
|
}
|
|
@@ -20870,9 +20921,9 @@ function contractFromArkContract(encoded, options = {}) {
|
|
|
20870
20921
|
metadata: options.metadata
|
|
20871
20922
|
};
|
|
20872
20923
|
}
|
|
20873
|
-
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix =
|
|
20924
|
+
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkCDWLZQQW_cjs.DEFAULT_NETWORK.hrp, options = {}) {
|
|
20874
20925
|
const parsed = decodeArkContract(encoded);
|
|
20875
|
-
const handler =
|
|
20926
|
+
const handler = chunk37XKN5DZ_cjs.contractHandlers.getOrThrow(parsed.type);
|
|
20876
20927
|
const params = parsed.data;
|
|
20877
20928
|
const vtxoScript = handler.createScript(params);
|
|
20878
20929
|
return {
|
|
@@ -20970,6 +21021,7 @@ exports.WsElectrumChainSource = WsElectrumChainSource;
|
|
|
20970
21021
|
exports.arkRail = arkRail;
|
|
20971
21022
|
exports.arkTarget = arkTarget;
|
|
20972
21023
|
exports.arkade_exports = arkade_exports;
|
|
21024
|
+
exports.assertFinalCommitmentMatchesValidated = assertFinalCommitmentMatchesValidated;
|
|
20973
21025
|
exports.assertIntentIdUnique = assertIntentIdUnique;
|
|
20974
21026
|
exports.assertSendableAmount = assertSendableAmount;
|
|
20975
21027
|
exports.assertSubmittedArkTxid = assertSubmittedArkTxid;
|
|
@@ -21040,10 +21092,11 @@ exports.setupServiceWorker = setupServiceWorker;
|
|
|
21040
21092
|
exports.signerSetFromInfo = signerSetFromInfo;
|
|
21041
21093
|
exports.toXOnlySignerHex = toXOnlySignerHex;
|
|
21042
21094
|
exports.tryResolveSendAmount = tryResolveSendAmount;
|
|
21095
|
+
exports.validateBatchRecipients = validateBatchRecipients;
|
|
21043
21096
|
exports.validateConnectorsTxGraph = validateConnectorsTxGraph;
|
|
21044
21097
|
exports.validateVtxoTxGraph = validateVtxoTxGraph;
|
|
21045
21098
|
exports.verifyTapscriptSignatures = verifyTapscriptSignatures;
|
|
21046
21099
|
exports.waitForIncomingFunds = waitForIncomingFunds;
|
|
21047
21100
|
exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
|
|
21048
|
-
//# sourceMappingURL=chunk-
|
|
21049
|
-
//# sourceMappingURL=chunk-
|
|
21101
|
+
//# sourceMappingURL=chunk-ENRRZFZ4.cjs.map
|
|
21102
|
+
//# sourceMappingURL=chunk-ENRRZFZ4.cjs.map
|