@arkade-os/sdk 0.4.54 → 0.4.55
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-acFuA57I.d.cts → ark-Do9Lqfsp.d.cts} +35 -2
- package/dist/{ark-acFuA57I.d.ts → ark-Do9Lqfsp.d.ts} +35 -2
- package/dist/{asyncStorageTaskQueue-BO3cvMpP.d.cts → asyncStorageTaskQueue-C3DYxvAT.d.cts} +2 -2
- package/dist/{asyncStorageTaskQueue-DACXtP0I.d.ts → asyncStorageTaskQueue-DOnBOEDn.d.ts} +2 -2
- package/dist/{chunk-YRLBZJYO.cjs → chunk-C6UYPHTQ.cjs} +9 -9
- package/dist/{chunk-YRLBZJYO.cjs.map → chunk-C6UYPHTQ.cjs.map} +1 -1
- package/dist/{chunk-BYJJIITU.cjs → chunk-CSS74VCN.cjs} +17 -17
- package/dist/{chunk-BYJJIITU.cjs.map → chunk-CSS74VCN.cjs.map} +1 -1
- package/dist/{chunk-ZOY5JSVA.js → chunk-ENWR2F2P.js} +3 -3
- package/dist/{chunk-ZOY5JSVA.js.map → chunk-ENWR2F2P.js.map} +1 -1
- package/dist/{chunk-RNECH3TA.cjs → chunk-G7DOBFQN.cjs} +15 -15
- package/dist/{chunk-RNECH3TA.cjs.map → chunk-G7DOBFQN.cjs.map} +1 -1
- package/dist/{chunk-4EIKOJLD.js → chunk-JCJ5WFS3.js} +11 -4
- package/dist/chunk-JCJ5WFS3.js.map +1 -0
- package/dist/{chunk-7L3P3EP5.js → chunk-LAONNMM5.js} +4 -4
- package/dist/{chunk-7L3P3EP5.js.map → chunk-LAONNMM5.js.map} +1 -1
- package/dist/{chunk-GMUVWKOK.cjs → chunk-OWCPXRGP.cjs} +11 -3
- package/dist/chunk-OWCPXRGP.cjs.map +1 -0
- package/dist/{chunk-A37WVZ5T.js → chunk-QMPNPZ2T.js} +23 -4
- package/dist/chunk-QMPNPZ2T.js.map +1 -0
- package/dist/{chunk-TEHJCEF3.js → chunk-QO3IKBYL.js} +366 -51
- package/dist/chunk-QO3IKBYL.js.map +1 -0
- package/dist/{chunk-QY2YVFZT.js → chunk-SG4X7SEC.js} +4 -4
- package/dist/{chunk-QY2YVFZT.js.map → chunk-SG4X7SEC.js.map} +1 -1
- package/dist/{chunk-53XNU2EL.cjs → chunk-V2TOHHPW.cjs} +60 -40
- package/dist/chunk-V2TOHHPW.cjs.map +1 -0
- package/dist/{chunk-D5LUPJJP.cjs → chunk-ZPL34T2Q.cjs} +717 -395
- package/dist/chunk-ZPL34T2Q.cjs.map +1 -0
- package/dist/contracts/handlers/index.cjs +8 -8
- package/dist/contracts/handlers/index.d.cts +3 -3
- package/dist/contracts/handlers/index.d.ts +3 -3
- package/dist/contracts/handlers/index.js +2 -2
- package/dist/{delegate-Ca_wXiYE.d.cts → delegate-C0iIBxen.d.cts} +1 -1
- package/dist/{delegate-DjwZZi6L.d.ts → delegate-DmhFrtdq.d.ts} +1 -1
- package/dist/{index-Ddq0mIKX.d.ts → index-BNt4wcSh.d.ts} +2 -2
- package/dist/{index-DFfefdpc.d.cts → index-BnLM1XxA.d.cts} +2 -2
- package/dist/index.cjs +238 -202
- package/dist/index.d.cts +138 -14
- package/dist/index.d.ts +138 -14
- 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-DbCNRP31.d.ts → taskRunner-Bgs-0I3x.d.ts} +2 -2
- package/dist/{taskRunner-DEwlrgId.d.cts → taskRunner-RwUvgQ5M.d.cts} +2 -2
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +6 -6
- package/dist/wallet/expo/index.cjs +14 -14
- package/dist/wallet/expo/index.d.cts +5 -5
- package/dist/wallet/expo/index.d.ts +5 -5
- package/dist/wallet/expo/index.js +5 -5
- package/dist/{wallet-ByjM6L20.d.cts → wallet-5Aou-V5n.d.ts} +83 -6
- package/dist/{wallet-B9rpddG2.d.ts → wallet-Ck7BH8zR.d.cts} +83 -6
- 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-4EIKOJLD.js.map +0 -1
- package/dist/chunk-53XNU2EL.cjs.map +0 -1
- package/dist/chunk-A37WVZ5T.js.map +0 -1
- package/dist/chunk-D5LUPJJP.cjs.map +0 -1
- package/dist/chunk-GMUVWKOK.cjs.map +0 -1
- package/dist/chunk-TEHJCEF3.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkG7DOBFQN_cjs = require('./chunk-G7DOBFQN.cjs');
|
|
4
|
+
var chunkV2TOHHPW_cjs = require('./chunk-V2TOHHPW.cjs');
|
|
5
|
+
var chunkOWCPXRGP_cjs = require('./chunk-OWCPXRGP.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 = chunkOWCPXRGP_cjs.getArkPsbtFields(tx.root, 0, chunkOWCPXRGP_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 = chunkOWCPXRGP_cjs.getArkPsbtFields(g.root, 0, chunkOWCPXRGP_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 = chunkV2TOHHPW_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 chunkV2TOHHPW_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.
|
|
@@ -539,9 +539,21 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
539
539
|
const key = this.derivePrivateKeyForDescriptor(descriptor);
|
|
540
540
|
return this.signMessageWithKey(key, message, signatureType);
|
|
541
541
|
}
|
|
542
|
+
/**
|
|
543
|
+
* BIP-340 sign `messageHash` with the key derived from `descriptor`,
|
|
544
|
+
* aux_rand = 0. Backs {@link DescriptorIdentity.signSchnorrDeterministic},
|
|
545
|
+
* which swap preimage derivation reads through.
|
|
546
|
+
*/
|
|
547
|
+
async signSchnorrDeterministicWithDescriptor(descriptor, messageHash) {
|
|
548
|
+
if (!this.isOurs(descriptor)) {
|
|
549
|
+
throw new Error(`Descriptor ${descriptor} does not belong to this identity`);
|
|
550
|
+
}
|
|
551
|
+
const key = this.derivePrivateKeyForDescriptor(descriptor);
|
|
552
|
+
return secp256k1.schnorr.signAsync(messageHash, key, new Uint8Array(32));
|
|
553
|
+
}
|
|
542
554
|
// ── internal helpers ─────────────────────────────────────────────
|
|
543
555
|
derivePrivateKeyForDescriptor(descriptor) {
|
|
544
|
-
const network =
|
|
556
|
+
const network = chunkV2TOHHPW_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
545
557
|
const expansion = descriptorsScure.expand({ descriptor, network });
|
|
546
558
|
if (expansion.isRanged) {
|
|
547
559
|
throw new Error(
|
|
@@ -627,7 +639,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
627
639
|
*/
|
|
628
640
|
descriptor;
|
|
629
641
|
constructor(descriptor) {
|
|
630
|
-
const network =
|
|
642
|
+
const network = chunkV2TOHHPW_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
631
643
|
let expansion;
|
|
632
644
|
try {
|
|
633
645
|
expansion = descriptorsScure.expand({ descriptor, network, index: 0 });
|
|
@@ -677,7 +689,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
677
689
|
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
678
690
|
*/
|
|
679
691
|
isOurs(descriptor) {
|
|
680
|
-
return
|
|
692
|
+
return chunkV2TOHHPW_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
|
|
681
693
|
}
|
|
682
694
|
};
|
|
683
695
|
function serializeSeedOwnedSigningIdentity(identity) {
|
|
@@ -825,6 +837,59 @@ function assertValidSerializedIdentity(s) {
|
|
|
825
837
|
}
|
|
826
838
|
}
|
|
827
839
|
|
|
840
|
+
// src/identity/descriptorIdentity.ts
|
|
841
|
+
function isHDDeterministicSignCapable(value) {
|
|
842
|
+
return typeof value === "object" && value !== null && typeof value.signSchnorrDeterministicWithDescriptor === "function";
|
|
843
|
+
}
|
|
844
|
+
var DescriptorIdentity = class {
|
|
845
|
+
descriptor;
|
|
846
|
+
signer;
|
|
847
|
+
base;
|
|
848
|
+
constructor({ descriptor, signer, base }) {
|
|
849
|
+
this.descriptor = descriptor;
|
|
850
|
+
this.signer = signer;
|
|
851
|
+
this.base = base;
|
|
852
|
+
}
|
|
853
|
+
async xOnlyPublicKey() {
|
|
854
|
+
return chunkV2TOHHPW_cjs.deriveDescriptorLeafPubKey(this.descriptor);
|
|
855
|
+
}
|
|
856
|
+
async compressedPublicKey() {
|
|
857
|
+
return chunkV2TOHHPW_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
|
|
858
|
+
}
|
|
859
|
+
async sign(tx, inputIndexes) {
|
|
860
|
+
const [signed] = await this.signer.signWithDescriptor([
|
|
861
|
+
{ descriptor: this.descriptor, tx, inputIndexes }
|
|
862
|
+
]);
|
|
863
|
+
if (!signed) {
|
|
864
|
+
throw new Error(`Descriptor signer returned no transaction for ${this.descriptor}`);
|
|
865
|
+
}
|
|
866
|
+
return signed;
|
|
867
|
+
}
|
|
868
|
+
async signMessage(message, signatureType = "schnorr") {
|
|
869
|
+
return this.signer.signMessageWithDescriptor(this.descriptor, message, signatureType);
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* Delegated: `TreeSignerSession.random()` consults no key material, so the
|
|
873
|
+
* session is index-independent.
|
|
874
|
+
*/
|
|
875
|
+
signerSession() {
|
|
876
|
+
return this.base.signerSession();
|
|
877
|
+
}
|
|
878
|
+
/**
|
|
879
|
+
* Throws rather than falling back to the baseline key: a preimage derived
|
|
880
|
+
* from the wrong index is unrecoverable, and callers probe this member
|
|
881
|
+
* through a structural guard that cannot tell the two apart.
|
|
882
|
+
*/
|
|
883
|
+
async signSchnorrDeterministic(messageHash) {
|
|
884
|
+
if (!isHDDeterministicSignCapable(this.base)) {
|
|
885
|
+
throw new Error(
|
|
886
|
+
`Identity cannot sign deterministically for descriptor ${this.descriptor}`
|
|
887
|
+
);
|
|
888
|
+
}
|
|
889
|
+
return this.base.signSchnorrDeterministicWithDescriptor(this.descriptor, messageHash);
|
|
890
|
+
}
|
|
891
|
+
};
|
|
892
|
+
|
|
828
893
|
// src/identity/hdCapableIdentity.ts
|
|
829
894
|
function isHDCapableIdentity(value) {
|
|
830
895
|
if (typeof value !== "object" || value === null) return false;
|
|
@@ -837,6 +902,13 @@ function isBatchSignable(identity) {
|
|
|
837
902
|
return "signMultiple" in identity && typeof identity.signMultiple === "function";
|
|
838
903
|
}
|
|
839
904
|
|
|
905
|
+
// src/wallet/hdWalletCapable.ts
|
|
906
|
+
function isHDWalletCapable(value) {
|
|
907
|
+
if (typeof value !== "object" || value === null) return false;
|
|
908
|
+
const v = value;
|
|
909
|
+
return typeof v.getCurrentSigningDescriptor === "function" && typeof v.getUsedSigningDescriptors === "function" && typeof v.signerForDescriptor === "function";
|
|
910
|
+
}
|
|
911
|
+
|
|
840
912
|
// src/worker/browser/service-worker-manager.ts
|
|
841
913
|
var registrations = /* @__PURE__ */ new Map();
|
|
842
914
|
var handshakes = /* @__PURE__ */ new WeakSet();
|
|
@@ -989,14 +1061,14 @@ var RestDelegateProvider = class {
|
|
|
989
1061
|
*/
|
|
990
1062
|
async delegate(intent, forfeitTxs, options) {
|
|
991
1063
|
const url = `${this.url}/v1/delegate`;
|
|
992
|
-
const response = await
|
|
1064
|
+
const response = await chunkOWCPXRGP_cjs.baseFetch(url, {
|
|
993
1065
|
method: "POST",
|
|
994
1066
|
headers: {
|
|
995
1067
|
"Content-Type": "application/json"
|
|
996
1068
|
},
|
|
997
1069
|
body: JSON.stringify({
|
|
998
1070
|
intent: {
|
|
999
|
-
message:
|
|
1071
|
+
message: chunkOWCPXRGP_cjs.Intent.encodeMessage(intent.message),
|
|
1000
1072
|
proof: intent.proof
|
|
1001
1073
|
},
|
|
1002
1074
|
forfeit_txs: forfeitTxs,
|
|
@@ -1016,7 +1088,7 @@ var RestDelegateProvider = class {
|
|
|
1016
1088
|
*/
|
|
1017
1089
|
async getDelegateInfo() {
|
|
1018
1090
|
const url = `${this.url}/v1/delegator/info`;
|
|
1019
|
-
const response = await
|
|
1091
|
+
const response = await chunkOWCPXRGP_cjs.rateGate.runHttp(url, () => chunkOWCPXRGP_cjs.baseFetch(url));
|
|
1020
1092
|
if (!response.ok) {
|
|
1021
1093
|
const errorText2 = await response.text();
|
|
1022
1094
|
throw new Error(`Failed to get delegate info: ${errorText2}`);
|
|
@@ -1043,7 +1115,7 @@ var ESPLORA_URL = {
|
|
|
1043
1115
|
regtest: "http://localhost:3000/api"
|
|
1044
1116
|
};
|
|
1045
1117
|
var EsploraProvider = class {
|
|
1046
|
-
constructor(baseUrl = ESPLORA_URL[
|
|
1118
|
+
constructor(baseUrl = ESPLORA_URL[chunkOWCPXRGP_cjs.DEFAULT_NETWORK_NAME], opts) {
|
|
1047
1119
|
this.baseUrl = baseUrl;
|
|
1048
1120
|
this.pollingInterval = opts?.pollingInterval ?? 15e3;
|
|
1049
1121
|
this.forcePolling = opts?.forcePolling ?? false;
|
|
@@ -1052,14 +1124,14 @@ var EsploraProvider = class {
|
|
|
1052
1124
|
pollingInterval;
|
|
1053
1125
|
forcePolling;
|
|
1054
1126
|
async getCoins(address) {
|
|
1055
|
-
const response = await
|
|
1127
|
+
const response = await chunkOWCPXRGP_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
|
|
1056
1128
|
if (!response.ok) {
|
|
1057
1129
|
throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
|
|
1058
1130
|
}
|
|
1059
1131
|
return response.json();
|
|
1060
1132
|
}
|
|
1061
1133
|
async getFeeRate() {
|
|
1062
|
-
const response = await
|
|
1134
|
+
const response = await chunkOWCPXRGP_cjs.baseFetch(`${this.baseUrl}/fee-estimates`);
|
|
1063
1135
|
if (response.status === 404) {
|
|
1064
1136
|
return void 0;
|
|
1065
1137
|
}
|
|
@@ -1080,7 +1152,7 @@ var EsploraProvider = class {
|
|
|
1080
1152
|
}
|
|
1081
1153
|
}
|
|
1082
1154
|
async getTxOutspends(txid) {
|
|
1083
|
-
const response = await
|
|
1155
|
+
const response = await chunkOWCPXRGP_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
|
|
1084
1156
|
if (!response.ok) {
|
|
1085
1157
|
const error = await response.text();
|
|
1086
1158
|
throw new Error(`Failed to get transaction outspends: ${error}`);
|
|
@@ -1088,7 +1160,7 @@ var EsploraProvider = class {
|
|
|
1088
1160
|
return response.json();
|
|
1089
1161
|
}
|
|
1090
1162
|
async getTransactions(address) {
|
|
1091
|
-
const response = await
|
|
1163
|
+
const response = await chunkOWCPXRGP_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
|
|
1092
1164
|
if (!response.ok) {
|
|
1093
1165
|
const error = await response.text();
|
|
1094
1166
|
throw new Error(`Failed to get transactions: ${error}`);
|
|
@@ -1096,7 +1168,7 @@ var EsploraProvider = class {
|
|
|
1096
1168
|
return response.json();
|
|
1097
1169
|
}
|
|
1098
1170
|
async getTxStatus(txid) {
|
|
1099
|
-
const txresponse = await
|
|
1171
|
+
const txresponse = await chunkOWCPXRGP_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
|
|
1100
1172
|
if (!txresponse.ok) {
|
|
1101
1173
|
throw new Error(txresponse.statusText);
|
|
1102
1174
|
}
|
|
@@ -1104,7 +1176,7 @@ var EsploraProvider = class {
|
|
|
1104
1176
|
if (!tx.status.confirmed) {
|
|
1105
1177
|
return { confirmed: false };
|
|
1106
1178
|
}
|
|
1107
|
-
const response = await
|
|
1179
|
+
const response = await chunkOWCPXRGP_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
|
|
1108
1180
|
if (!response.ok) {
|
|
1109
1181
|
throw new Error(`Failed to get transaction status: ${response.statusText}`);
|
|
1110
1182
|
}
|
|
@@ -1188,7 +1260,7 @@ var EsploraProvider = class {
|
|
|
1188
1260
|
return stopFunc;
|
|
1189
1261
|
}
|
|
1190
1262
|
async getChainTip() {
|
|
1191
|
-
const tipBlocks = await
|
|
1263
|
+
const tipBlocks = await chunkOWCPXRGP_cjs.baseFetch(`${this.baseUrl}/blocks`);
|
|
1192
1264
|
if (!tipBlocks.ok) {
|
|
1193
1265
|
throw new Error(`Failed to get chain tip: ${tipBlocks.statusText}`);
|
|
1194
1266
|
}
|
|
@@ -1207,7 +1279,7 @@ var EsploraProvider = class {
|
|
|
1207
1279
|
};
|
|
1208
1280
|
}
|
|
1209
1281
|
async broadcastPackage(parent, child) {
|
|
1210
|
-
const response = await
|
|
1282
|
+
const response = await chunkOWCPXRGP_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
|
|
1211
1283
|
method: "POST",
|
|
1212
1284
|
headers: {
|
|
1213
1285
|
"Content-Type": "application/json"
|
|
@@ -1221,7 +1293,7 @@ var EsploraProvider = class {
|
|
|
1221
1293
|
return response.json();
|
|
1222
1294
|
}
|
|
1223
1295
|
async broadcastTx(tx) {
|
|
1224
|
-
const response = await
|
|
1296
|
+
const response = await chunkOWCPXRGP_cjs.baseFetch(`${this.baseUrl}/tx`, {
|
|
1225
1297
|
method: "POST",
|
|
1226
1298
|
headers: {
|
|
1227
1299
|
"Content-Type": "text/plain"
|
|
@@ -1383,7 +1455,7 @@ function findP2AOutput(tx) {
|
|
|
1383
1455
|
var CHILD_DUST_AMOUNT = 546;
|
|
1384
1456
|
function buildAnchorChild(params) {
|
|
1385
1457
|
const { parent, feeRate, fundingCoins, changeAddress, tapInternalKey, network } = params;
|
|
1386
|
-
const child = new
|
|
1458
|
+
const child = new chunkOWCPXRGP_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
|
|
1387
1459
|
child.addInput(findP2AOutput(parent));
|
|
1388
1460
|
const estimator = TxWeightEstimator.create().addP2AInput();
|
|
1389
1461
|
for (const _ of fundingCoins) {
|
|
@@ -1431,7 +1503,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
|
|
|
1431
1503
|
);
|
|
1432
1504
|
}
|
|
1433
1505
|
function buildForfeitTxWithOutput(inputs, output, txLocktime) {
|
|
1434
|
-
const tx = new
|
|
1506
|
+
const tx = new chunkOWCPXRGP_cjs.Transaction({
|
|
1435
1507
|
version: 3,
|
|
1436
1508
|
lockTime: txLocktime
|
|
1437
1509
|
});
|
|
@@ -1507,7 +1579,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
|
|
|
1507
1579
|
if (previousScriptKey.length !== 32) {
|
|
1508
1580
|
throw new Error(`parent output ${childIndex} has invalid script`);
|
|
1509
1581
|
}
|
|
1510
|
-
const cosigners =
|
|
1582
|
+
const cosigners = chunkOWCPXRGP_cjs.getArkPsbtFields(child.root, 0, chunkOWCPXRGP_cjs.CosignerPublicKey);
|
|
1511
1583
|
if (cosigners.length === 0) {
|
|
1512
1584
|
throw ErrMissingCosignersPublicKeys;
|
|
1513
1585
|
}
|
|
@@ -1565,7 +1637,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
1565
1637
|
return new _EmulatorPacket(entries);
|
|
1566
1638
|
}
|
|
1567
1639
|
static fromBytes(data) {
|
|
1568
|
-
const reader = new
|
|
1640
|
+
const reader = new chunkG7DOBFQN_cjs.BufferReader(data);
|
|
1569
1641
|
const entryCount = reader.readCompactSize();
|
|
1570
1642
|
const entries = [];
|
|
1571
1643
|
for (let i = 0; i < entryCount; i++) {
|
|
@@ -1583,7 +1655,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
1583
1655
|
return _EmulatorPacket.PACKET_TYPE;
|
|
1584
1656
|
}
|
|
1585
1657
|
serialize() {
|
|
1586
|
-
const writer = new
|
|
1658
|
+
const writer = new chunkG7DOBFQN_cjs.BufferWriter();
|
|
1587
1659
|
writer.writeCompactSize(this.entries.length);
|
|
1588
1660
|
for (const entry of this.entries) {
|
|
1589
1661
|
writer.writeUint16LE(entry.vin);
|
|
@@ -1670,7 +1742,7 @@ var Extension = class _Extension {
|
|
|
1670
1742
|
`expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
|
|
1671
1743
|
);
|
|
1672
1744
|
}
|
|
1673
|
-
const reader = new
|
|
1745
|
+
const reader = new chunkG7DOBFQN_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
|
|
1674
1746
|
const packets = [];
|
|
1675
1747
|
while (reader.remaining() > 0) {
|
|
1676
1748
|
const packetType = reader.readByte();
|
|
@@ -1744,7 +1816,7 @@ var Extension = class _Extension {
|
|
|
1744
1816
|
*/
|
|
1745
1817
|
getAssetPacket() {
|
|
1746
1818
|
for (const p of this.packets) {
|
|
1747
|
-
if (p instanceof
|
|
1819
|
+
if (p instanceof chunkG7DOBFQN_cjs.Packet) {
|
|
1748
1820
|
return p;
|
|
1749
1821
|
}
|
|
1750
1822
|
}
|
|
@@ -1782,8 +1854,8 @@ var Extension = class _Extension {
|
|
|
1782
1854
|
};
|
|
1783
1855
|
function parsePacket(packetType, data) {
|
|
1784
1856
|
switch (packetType) {
|
|
1785
|
-
case
|
|
1786
|
-
return
|
|
1857
|
+
case chunkG7DOBFQN_cjs.Packet.PACKET_TYPE:
|
|
1858
|
+
return chunkG7DOBFQN_cjs.Packet.fromBytes(data);
|
|
1787
1859
|
case EmulatorPacket.PACKET_TYPE:
|
|
1788
1860
|
return EmulatorPacket.fromBytes(data);
|
|
1789
1861
|
default:
|
|
@@ -1830,21 +1902,35 @@ function buildOpReturnScript(data) {
|
|
|
1830
1902
|
}
|
|
1831
1903
|
return script;
|
|
1832
1904
|
}
|
|
1833
|
-
var ErrOffchainOutputNotFound = (address) => new
|
|
1834
|
-
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new
|
|
1835
|
-
|
|
1836
|
-
|
|
1905
|
+
var ErrOffchainOutputNotFound = (address) => new chunkOWCPXRGP_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
|
|
1906
|
+
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkOWCPXRGP_cjs.ServerResponseMismatchError(
|
|
1907
|
+
`invalid asset output amount for ${assetId}: got ${got}, want ${want}`
|
|
1908
|
+
);
|
|
1909
|
+
var ErrAssetGroupNotFound = (assetId) => new chunkOWCPXRGP_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
|
|
1910
|
+
var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkOWCPXRGP_cjs.ServerResponseMismatchError(
|
|
1911
|
+
`asset output not found in asset group ${assetId} at index ${outputIndex}`
|
|
1912
|
+
);
|
|
1913
|
+
var ErrOnchainOutputNotFound = (address) => new chunkOWCPXRGP_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
|
|
1914
|
+
var ErrUnvalidatedOffchainOutput = (address) => new chunkOWCPXRGP_cjs.ServerResponseMismatchError(
|
|
1915
|
+
`offchain output ${address} cannot be validated: virtual output tree signing did not run`
|
|
1916
|
+
);
|
|
1837
1917
|
var ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
|
|
1838
1918
|
var ErrInvalidOnchainOutputAssets = (address) => new Error(`onchain output ${address} cannot have assets`);
|
|
1839
|
-
var ErrOnchainOutputNotFound = (address) => new Error(`onchain output not found: ${address}`);
|
|
1840
1919
|
var ErrInvalidOffchainOutputAmount = (address) => new Error(`invalid offchain output ${address}, missing amount`);
|
|
1920
|
+
function assertFinalCommitmentMatchesValidated(finalCommitmentTx, validatedCommitmentTxid, context) {
|
|
1921
|
+
if (!validatedCommitmentTxid) return;
|
|
1922
|
+
if (finalCommitmentTx.id === validatedCommitmentTxid) return;
|
|
1923
|
+
throw new chunkOWCPXRGP_cjs.ServerResponseMismatchError(
|
|
1924
|
+
`${context}: finalization commitment tx ${finalCommitmentTx.id} differs from the validated commitment tx ${validatedCommitmentTxid}`
|
|
1925
|
+
);
|
|
1926
|
+
}
|
|
1841
1927
|
function validateBatchRecipients(commitmentTx, vtxoTreeLeaves, recipients, network) {
|
|
1842
1928
|
const usedOutputs = /* @__PURE__ */ new Set();
|
|
1843
1929
|
const usedOnchainOutputs = /* @__PURE__ */ new Set();
|
|
1844
1930
|
for (const recipient of recipients) {
|
|
1845
1931
|
let arkAddress;
|
|
1846
1932
|
try {
|
|
1847
|
-
arkAddress =
|
|
1933
|
+
arkAddress = chunkOWCPXRGP_cjs.ArkAddress.decode(recipient.address);
|
|
1848
1934
|
} catch {
|
|
1849
1935
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
1850
1936
|
continue;
|
|
@@ -1852,6 +1938,18 @@ function validateBatchRecipients(commitmentTx, vtxoTreeLeaves, recipients, netwo
|
|
|
1852
1938
|
validateOffchainRecipient(vtxoTreeLeaves, arkAddress, recipient, usedOutputs);
|
|
1853
1939
|
}
|
|
1854
1940
|
}
|
|
1941
|
+
function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
|
|
1942
|
+
const usedOnchainOutputs = /* @__PURE__ */ new Set();
|
|
1943
|
+
for (const recipient of recipients) {
|
|
1944
|
+
try {
|
|
1945
|
+
chunkOWCPXRGP_cjs.ArkAddress.decode(recipient.address);
|
|
1946
|
+
} catch {
|
|
1947
|
+
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
1948
|
+
continue;
|
|
1949
|
+
}
|
|
1950
|
+
throw ErrUnvalidatedOffchainOutput(recipient.address);
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1855
1953
|
function validateOnchainRecipient(commitmentTx, recipient, network, usedOutputs) {
|
|
1856
1954
|
const addr = btcSigner.Address(network).decode(recipient.address);
|
|
1857
1955
|
const expectedPkScript = btcSigner.OutScript.encode(addr);
|
|
@@ -1944,8 +2042,6 @@ function validateAssetGroupOutput(packet, outputIndex, assetId, expectedAmount)
|
|
|
1944
2042
|
throw ErrInvalidAssetOutputAmount(assetOutput.amount, expectedAmount, assetId);
|
|
1945
2043
|
}
|
|
1946
2044
|
}
|
|
1947
|
-
|
|
1948
|
-
// src/wallet/activity.ts
|
|
1949
2045
|
async function buildActivities(txs, resolvers) {
|
|
1950
2046
|
const preparedResolvers = (await Promise.all(
|
|
1951
2047
|
resolvers.map(async (r) => {
|
|
@@ -2055,9 +2151,49 @@ function boardingResolver() {
|
|
|
2055
2151
|
}
|
|
2056
2152
|
};
|
|
2057
2153
|
}
|
|
2154
|
+
function collabExitResolver() {
|
|
2155
|
+
return {
|
|
2156
|
+
id: "collab-exit",
|
|
2157
|
+
resolve(tx) {
|
|
2158
|
+
if (tx.tag !== "exit" || !tx.key.commitmentTxid) return void 0;
|
|
2159
|
+
return [
|
|
2160
|
+
{
|
|
2161
|
+
groupId: `exit:${tx.key.commitmentTxid}`,
|
|
2162
|
+
label: "Collaborative exit",
|
|
2163
|
+
kind: "exit"
|
|
2164
|
+
}
|
|
2165
|
+
];
|
|
2166
|
+
}
|
|
2167
|
+
};
|
|
2168
|
+
}
|
|
2169
|
+
function assetMintResolver() {
|
|
2170
|
+
return {
|
|
2171
|
+
id: "asset-mint",
|
|
2172
|
+
resolve(tx) {
|
|
2173
|
+
if (!tx.assets?.length || !tx.key.arkTxid) return void 0;
|
|
2174
|
+
const minted = tx.assets.filter((a) => {
|
|
2175
|
+
try {
|
|
2176
|
+
return base.hex.encode(chunkG7DOBFQN_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
|
|
2177
|
+
} catch {
|
|
2178
|
+
return false;
|
|
2179
|
+
}
|
|
2180
|
+
});
|
|
2181
|
+
if (minted.length === 0) return void 0;
|
|
2182
|
+
const received = tx.type === "RECEIVED" /* TxReceived */;
|
|
2183
|
+
return minted.map((a) => ({
|
|
2184
|
+
groupId: `mint:${a.assetId}`,
|
|
2185
|
+
label: received ? "Asset receive" : "Asset mint",
|
|
2186
|
+
kind: received ? "asset-receive" : "asset-mint",
|
|
2187
|
+
metadata: { assetId: a.assetId, amount: a.amount.toString() }
|
|
2188
|
+
}));
|
|
2189
|
+
}
|
|
2190
|
+
};
|
|
2191
|
+
}
|
|
2058
2192
|
function createDefaultActivityRegistry() {
|
|
2059
2193
|
const registry = new ActivityRegistry();
|
|
2060
2194
|
registry.use(boardingResolver());
|
|
2195
|
+
registry.use(collabExitResolver());
|
|
2196
|
+
registry.use(assetMintResolver());
|
|
2061
2197
|
return registry;
|
|
2062
2198
|
}
|
|
2063
2199
|
|
|
@@ -2080,7 +2216,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2080
2216
|
const existing = inputsByAssetId.get(asset.assetId);
|
|
2081
2217
|
inputsByAssetId.set(asset.assetId, [
|
|
2082
2218
|
...existing ?? [],
|
|
2083
|
-
|
|
2219
|
+
chunkG7DOBFQN_cjs.AssetInput.create(inputIndex, asset.amount)
|
|
2084
2220
|
]);
|
|
2085
2221
|
}
|
|
2086
2222
|
}
|
|
@@ -2092,7 +2228,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2092
2228
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
2093
2229
|
outputsByAssetId.set(asset.assetId, [
|
|
2094
2230
|
...existing ?? [],
|
|
2095
|
-
|
|
2231
|
+
chunkG7DOBFQN_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
2096
2232
|
]);
|
|
2097
2233
|
}
|
|
2098
2234
|
}
|
|
@@ -2103,7 +2239,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2103
2239
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
2104
2240
|
outputsByAssetId.set(asset.assetId, [
|
|
2105
2241
|
...existing ?? [],
|
|
2106
|
-
|
|
2242
|
+
chunkG7DOBFQN_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
2107
2243
|
]);
|
|
2108
2244
|
}
|
|
2109
2245
|
}
|
|
@@ -2112,11 +2248,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
2112
2248
|
for (const assetIdStr of allAssetIds) {
|
|
2113
2249
|
const inputs = inputsByAssetId.get(assetIdStr);
|
|
2114
2250
|
const outputs = outputsByAssetId.get(assetIdStr);
|
|
2115
|
-
const assetId =
|
|
2116
|
-
const group =
|
|
2251
|
+
const assetId = chunkG7DOBFQN_cjs.AssetId.fromString(assetIdStr);
|
|
2252
|
+
const group = chunkG7DOBFQN_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
|
|
2117
2253
|
groups.push(group);
|
|
2118
2254
|
}
|
|
2119
|
-
return
|
|
2255
|
+
return chunkG7DOBFQN_cjs.Packet.create(groups);
|
|
2120
2256
|
}
|
|
2121
2257
|
function selectCoinsWithAsset(coins, assetId, requiredAmount) {
|
|
2122
2258
|
const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
|
|
@@ -2221,8 +2357,8 @@ function buildOffchainTx(inputs, outputs, serverUnrollScript) {
|
|
|
2221
2357
|
function buildVirtualTx(inputs, outputs) {
|
|
2222
2358
|
let lockTime = 0n;
|
|
2223
2359
|
for (const input of inputs) {
|
|
2224
|
-
const tapscript =
|
|
2225
|
-
if (
|
|
2360
|
+
const tapscript = chunkOWCPXRGP_cjs.decodeTapscript(chunkOWCPXRGP_cjs.scriptFromTapLeafScript(input.tapLeafScript));
|
|
2361
|
+
if (chunkOWCPXRGP_cjs.CLTVMultisigTapscript.is(tapscript)) {
|
|
2226
2362
|
if (lockTime !== 0n) {
|
|
2227
2363
|
if (isSeconds(lockTime) !== isSeconds(tapscript.params.absoluteTimelock)) {
|
|
2228
2364
|
throw new Error("cannot mix seconds and blocks locktime");
|
|
@@ -2233,7 +2369,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
2233
2369
|
}
|
|
2234
2370
|
}
|
|
2235
2371
|
}
|
|
2236
|
-
const tx = new
|
|
2372
|
+
const tx = new chunkOWCPXRGP_cjs.Transaction({
|
|
2237
2373
|
version: 3,
|
|
2238
2374
|
lockTime: Number(lockTime)
|
|
2239
2375
|
});
|
|
@@ -2243,12 +2379,12 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
2243
2379
|
index: input.vout,
|
|
2244
2380
|
sequence: lockTime ? btcSigner.DEFAULT_SEQUENCE - 1 : void 0,
|
|
2245
2381
|
witnessUtxo: {
|
|
2246
|
-
script:
|
|
2382
|
+
script: chunkOWCPXRGP_cjs.VtxoScript.decode(input.tapTree).pkScript,
|
|
2247
2383
|
amount: BigInt(input.value)
|
|
2248
2384
|
},
|
|
2249
2385
|
tapLeafScript: [input.tapLeafScript]
|
|
2250
2386
|
});
|
|
2251
|
-
|
|
2387
|
+
chunkOWCPXRGP_cjs.setArkPsbtField(tx, i, chunkOWCPXRGP_cjs.VtxoTaprootTree, input.tapTree);
|
|
2252
2388
|
}
|
|
2253
2389
|
for (const output of outputs) {
|
|
2254
2390
|
tx.addOutput(output);
|
|
@@ -2257,8 +2393,8 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
2257
2393
|
return tx;
|
|
2258
2394
|
}
|
|
2259
2395
|
function buildCheckpointTx(vtxo, serverUnrollScript) {
|
|
2260
|
-
const collaborativeClosure =
|
|
2261
|
-
const checkpointVtxoScript = new
|
|
2396
|
+
const collaborativeClosure = chunkOWCPXRGP_cjs.decodeTapscript(chunkOWCPXRGP_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
|
|
2397
|
+
const checkpointVtxoScript = new chunkOWCPXRGP_cjs.VtxoScript([
|
|
2262
2398
|
serverUnrollScript.script,
|
|
2263
2399
|
collaborativeClosure.script
|
|
2264
2400
|
]);
|
|
@@ -2411,12 +2547,76 @@ function combineTapscriptSigs(signedTx, originalTx) {
|
|
|
2411
2547
|
}
|
|
2412
2548
|
function isValidArkAddress(address) {
|
|
2413
2549
|
try {
|
|
2414
|
-
|
|
2550
|
+
chunkOWCPXRGP_cjs.ArkAddress.decode(address);
|
|
2415
2551
|
return true;
|
|
2416
2552
|
} catch (e) {
|
|
2417
2553
|
return false;
|
|
2418
2554
|
}
|
|
2419
2555
|
}
|
|
2556
|
+
function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, context) {
|
|
2557
|
+
if (serverCheckpointTxs.length !== expectedCheckpoints.length) {
|
|
2558
|
+
throw new chunkOWCPXRGP_cjs.ServerResponseMismatchError(
|
|
2559
|
+
`${context} returned ${serverCheckpointTxs.length} checkpoints, expected ${expectedCheckpoints.length}`
|
|
2560
|
+
);
|
|
2561
|
+
}
|
|
2562
|
+
const byTxid = new Map(expectedCheckpoints.map((c) => [c.id, c]));
|
|
2563
|
+
return serverCheckpointTxs.map((encoded, index) => {
|
|
2564
|
+
const server = chunkOWCPXRGP_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
|
|
2565
|
+
const local = byTxid.get(server.id);
|
|
2566
|
+
if (!local) {
|
|
2567
|
+
throw new chunkOWCPXRGP_cjs.ServerResponseMismatchError(
|
|
2568
|
+
`${context} checkpoint ${index} txid ${server.id} does not match any submitted checkpoint`
|
|
2569
|
+
);
|
|
2570
|
+
}
|
|
2571
|
+
byTxid.delete(server.id);
|
|
2572
|
+
return { server, local };
|
|
2573
|
+
});
|
|
2574
|
+
}
|
|
2575
|
+
function assertSubmittedArkTxid(response, signedArkTx, context) {
|
|
2576
|
+
if (response.arkTxid !== signedArkTx.id) {
|
|
2577
|
+
throw new chunkOWCPXRGP_cjs.ServerResponseMismatchError(
|
|
2578
|
+
`${context} returned ark txid ${response.arkTxid}, expected ${signedArkTx.id}`
|
|
2579
|
+
);
|
|
2580
|
+
}
|
|
2581
|
+
if (response.finalArkTx === void 0) return;
|
|
2582
|
+
const finalTxid = chunkOWCPXRGP_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
|
|
2583
|
+
if (finalTxid !== signedArkTx.id) {
|
|
2584
|
+
throw new chunkOWCPXRGP_cjs.ServerResponseMismatchError(
|
|
2585
|
+
`${context} returned final ark tx ${finalTxid}, expected ${signedArkTx.id}`
|
|
2586
|
+
);
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2589
|
+
function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, context) {
|
|
2590
|
+
const byOutpoint = new Map(inputs.map((input) => [`${input.txid}:${input.vout}`, input]));
|
|
2591
|
+
for (const [index, checkpoint] of checkpoints.entries()) {
|
|
2592
|
+
if (checkpoint.inputsLength !== 1) {
|
|
2593
|
+
throw new chunkOWCPXRGP_cjs.ServerResponseMismatchError(
|
|
2594
|
+
`${context}: checkpoint ${index} spends ${checkpoint.inputsLength} inputs, expected 1`
|
|
2595
|
+
);
|
|
2596
|
+
}
|
|
2597
|
+
const spent = checkpoint.getInput(0);
|
|
2598
|
+
if (!spent.txid || spent.index === void 0) {
|
|
2599
|
+
throw new chunkOWCPXRGP_cjs.ServerResponseMismatchError(
|
|
2600
|
+
`${context}: checkpoint ${index} has no input outpoint`
|
|
2601
|
+
);
|
|
2602
|
+
}
|
|
2603
|
+
const outpoint = `${base.hex.encode(spent.txid)}:${spent.index}`;
|
|
2604
|
+
const input = byOutpoint.get(outpoint);
|
|
2605
|
+
if (!input) {
|
|
2606
|
+
throw new chunkOWCPXRGP_cjs.ServerResponseMismatchError(
|
|
2607
|
+
`${context}: checkpoint ${index} spends ${outpoint}, which is not one of the requested virtual outputs`
|
|
2608
|
+
);
|
|
2609
|
+
}
|
|
2610
|
+
const rebuilt = unrollCandidates.some(
|
|
2611
|
+
(unroll) => buildCheckpointTx(input, unroll).tx.id === checkpoint.id
|
|
2612
|
+
);
|
|
2613
|
+
if (!rebuilt) {
|
|
2614
|
+
throw new chunkOWCPXRGP_cjs.ServerResponseMismatchError(
|
|
2615
|
+
`${context}: checkpoint ${index} txid ${checkpoint.id} differs from the checkpoint built locally for ${outpoint}`
|
|
2616
|
+
);
|
|
2617
|
+
}
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2420
2620
|
async function submitOffchainTx(provider, offchainTx, signer, hooks) {
|
|
2421
2621
|
const { arkTx: signedArkTx, userSignedCheckpoints } = await signer.signArkTx(
|
|
2422
2622
|
offchainTx.arkTx,
|
|
@@ -2428,27 +2628,26 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks) {
|
|
|
2428
2628
|
);
|
|
2429
2629
|
}
|
|
2430
2630
|
await hooks?.beforeSubmit?.();
|
|
2431
|
-
const
|
|
2631
|
+
const response = await provider.submitTx(
|
|
2432
2632
|
base.base64.encode(signedArkTx.toPSBT()),
|
|
2433
2633
|
offchainTx.checkpoints.map((c) => base.base64.encode(c.toPSBT()))
|
|
2434
2634
|
);
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
);
|
|
2439
|
-
}
|
|
2635
|
+
assertSubmittedArkTxid(response, signedArkTx, "submitTx");
|
|
2636
|
+
const { arkTxid, signedCheckpointTxs } = response;
|
|
2637
|
+
const matched = matchServerCheckpoints(signedCheckpointTxs, offchainTx.checkpoints, "submitTx");
|
|
2440
2638
|
let finalCheckpoints;
|
|
2441
2639
|
if (userSignedCheckpoints) {
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2640
|
+
const userByTxid = new Map(
|
|
2641
|
+
userSignedCheckpoints.map((c, i) => [offchainTx.checkpoints[i].id, c])
|
|
2642
|
+
);
|
|
2643
|
+
finalCheckpoints = matched.map(({ server, local }) => {
|
|
2644
|
+
combineTapscriptSigs(userByTxid.get(local.id), server);
|
|
2645
|
+
return base.base64.encode(server.toPSBT());
|
|
2446
2646
|
});
|
|
2447
2647
|
} else {
|
|
2448
2648
|
finalCheckpoints = await Promise.all(
|
|
2449
|
-
|
|
2450
|
-
const
|
|
2451
|
-
const signed = await signer.signCheckpoint(tx);
|
|
2649
|
+
matched.map(async ({ server }) => {
|
|
2650
|
+
const signed = await signer.signCheckpoint(server);
|
|
2452
2651
|
return base.base64.encode(signed.toPSBT());
|
|
2453
2652
|
})
|
|
2454
2653
|
);
|
|
@@ -2646,7 +2845,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
|
|
|
2646
2845
|
};
|
|
2647
2846
|
}
|
|
2648
2847
|
function deriveContractTapscripts(contract) {
|
|
2649
|
-
const handler =
|
|
2848
|
+
const handler = chunkV2TOHHPW_cjs.contractHandlers.get(contract.type);
|
|
2650
2849
|
if (!handler) {
|
|
2651
2850
|
throw new Error(`No handler for contract type '${contract.type}'`);
|
|
2652
2851
|
}
|
|
@@ -2717,7 +2916,7 @@ function getRandomId() {
|
|
|
2717
2916
|
}
|
|
2718
2917
|
function isValidArkAddress2(address) {
|
|
2719
2918
|
try {
|
|
2720
|
-
|
|
2919
|
+
chunkOWCPXRGP_cjs.ArkAddress.decode(address);
|
|
2721
2920
|
return true;
|
|
2722
2921
|
} catch (e) {
|
|
2723
2922
|
return false;
|
|
@@ -2728,7 +2927,7 @@ function validateRecipients(recipients, dustAmount) {
|
|
|
2728
2927
|
for (const recipient of recipients) {
|
|
2729
2928
|
let address;
|
|
2730
2929
|
try {
|
|
2731
|
-
address =
|
|
2930
|
+
address = chunkOWCPXRGP_cjs.ArkAddress.decode(recipient.address);
|
|
2732
2931
|
} catch (e) {
|
|
2733
2932
|
throw new Error(`Invalid Arkade address: ${recipient.address}`);
|
|
2734
2933
|
}
|
|
@@ -2756,7 +2955,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
|
|
|
2756
2955
|
continue;
|
|
2757
2956
|
}
|
|
2758
2957
|
for (const v of vtxos) {
|
|
2759
|
-
if (!
|
|
2958
|
+
if (!chunkOWCPXRGP_cjs.hasTerminalSpend(v) && !v.isSwept) out.add(`${v.txid}:${v.vout}`);
|
|
2760
2959
|
}
|
|
2761
2960
|
}
|
|
2762
2961
|
return out;
|
|
@@ -2789,10 +2988,10 @@ function byValueDescending(vtxos) {
|
|
|
2789
2988
|
return [...vtxos].sort((a, b) => b.value - a.value);
|
|
2790
2989
|
}
|
|
2791
2990
|
async function fetchTimeHeight(wallet) {
|
|
2792
|
-
return
|
|
2991
|
+
return chunkOWCPXRGP_cjs.resolveTimeHeight(wallet.onchainProvider);
|
|
2793
2992
|
}
|
|
2794
2993
|
function canMigrateBySend(vtxo, now) {
|
|
2795
|
-
if (!
|
|
2994
|
+
if (!chunkOWCPXRGP_cjs.canSpendOffchain(vtxo, now)) return false;
|
|
2796
2995
|
return vtxo.expiresAt !== void 0 || vtxo.expiresAtHeight !== void 0;
|
|
2797
2996
|
}
|
|
2798
2997
|
function byExpiryAscending(vtxos, now) {
|
|
@@ -2800,7 +2999,7 @@ function byExpiryAscending(vtxos, now) {
|
|
|
2800
2999
|
if (vtxo.isSwept) return -Infinity;
|
|
2801
3000
|
if (vtxo.expiresAt !== void 0) return vtxo.expiresAt.getTime();
|
|
2802
3001
|
if (vtxo.expiresAtHeight !== void 0) {
|
|
2803
|
-
return
|
|
3002
|
+
return chunkOWCPXRGP_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
|
|
2804
3003
|
}
|
|
2805
3004
|
return Infinity;
|
|
2806
3005
|
};
|
|
@@ -2837,10 +3036,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
|
|
|
2837
3036
|
};
|
|
2838
3037
|
function getRecoverableVtxos(vtxos, dustAmount, now) {
|
|
2839
3038
|
return vtxos.filter((vtxo) => {
|
|
2840
|
-
if (
|
|
3039
|
+
if (chunkOWCPXRGP_cjs.canRecoverOnchain(vtxo, now)) {
|
|
2841
3040
|
return true;
|
|
2842
3041
|
}
|
|
2843
|
-
if (
|
|
3042
|
+
if (chunkOWCPXRGP_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
|
|
2844
3043
|
return true;
|
|
2845
3044
|
}
|
|
2846
3045
|
return false;
|
|
@@ -2871,7 +3070,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
|
|
|
2871
3070
|
}
|
|
2872
3071
|
function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
2873
3072
|
const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
|
|
2874
|
-
const expiresAt =
|
|
3073
|
+
const expiresAt = chunkOWCPXRGP_cjs.normalizeVtxo(vtxo).expiresAt;
|
|
2875
3074
|
if (expiresAt === void 0) return false;
|
|
2876
3075
|
const now = Date.now();
|
|
2877
3076
|
const batchExpiry = expiresAt.getTime();
|
|
@@ -2880,7 +3079,7 @@ function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
|
2880
3079
|
}
|
|
2881
3080
|
function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
|
|
2882
3081
|
return vtxos.filter(
|
|
2883
|
-
(vtxo) => isVtxoExpiringSoon(vtxo, thresholdMs) ||
|
|
3082
|
+
(vtxo) => isVtxoExpiringSoon(vtxo, thresholdMs) || chunkOWCPXRGP_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount)
|
|
2884
3083
|
);
|
|
2885
3084
|
}
|
|
2886
3085
|
function isMigrationCapable(wallet) {
|
|
@@ -3362,11 +3561,11 @@ var VtxoManager = class _VtxoManager {
|
|
|
3362
3561
|
`Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
|
|
3363
3562
|
);
|
|
3364
3563
|
}
|
|
3365
|
-
const tx = new
|
|
3564
|
+
const tx = new chunkOWCPXRGP_cjs.Transaction();
|
|
3366
3565
|
for (const utxo of expiredUtxos) {
|
|
3367
|
-
const utxoScript =
|
|
3566
|
+
const utxoScript = chunkOWCPXRGP_cjs.VtxoScript.decode(utxo.tapTree);
|
|
3368
3567
|
const utxoExitLeaf = utxoScript.leaves.find(
|
|
3369
|
-
(leaf) =>
|
|
3568
|
+
(leaf) => chunkOWCPXRGP_cjs.CSVMultisigTapscript.isScriptValid(chunkOWCPXRGP_cjs.scriptFromTapLeafScript(leaf)) === true
|
|
3370
3569
|
);
|
|
3371
3570
|
if (!utxoExitLeaf) {
|
|
3372
3571
|
throw new Error(
|
|
@@ -3381,7 +3580,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
3381
3580
|
amount: BigInt(utxo.value)
|
|
3382
3581
|
},
|
|
3383
3582
|
tapLeafScript: [utxoExitLeaf],
|
|
3384
|
-
sequence:
|
|
3583
|
+
sequence: chunkOWCPXRGP_cjs.getSequence(utxoExitLeaf)
|
|
3385
3584
|
});
|
|
3386
3585
|
}
|
|
3387
3586
|
tx.addOutputAddress(boardingAddress, outputAmount, this.getNetwork());
|
|
@@ -3615,8 +3814,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
3615
3814
|
if (!serverPubKey) continue;
|
|
3616
3815
|
const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
|
|
3617
3816
|
if (cls.status === "CURRENT") continue;
|
|
3618
|
-
const recoverable = vtxos.filter((v) => v.isSwept && !
|
|
3619
|
-
const spendable = vtxos.filter((v) => !
|
|
3817
|
+
const recoverable = vtxos.filter((v) => v.isSwept && !chunkOWCPXRGP_cjs.hasTerminalSpend(v));
|
|
3818
|
+
const spendable = vtxos.filter((v) => !chunkOWCPXRGP_cjs.hasTerminalSpend(v) && !v.isSwept);
|
|
3620
3819
|
const value = spendable.reduce((sum, v) => sum + v.value, 0);
|
|
3621
3820
|
let recoverableCount = 0;
|
|
3622
3821
|
let recoverableValue = 0;
|
|
@@ -3629,7 +3828,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
3629
3828
|
awaitingSweepCount = spendable.length;
|
|
3630
3829
|
awaitingSweepValue = value;
|
|
3631
3830
|
for (const v of spendable) {
|
|
3632
|
-
const exp =
|
|
3831
|
+
const exp = chunkOWCPXRGP_cjs.toBatchExpiry(v);
|
|
3633
3832
|
if (exp !== void 0 && (nextSweepEta === void 0 || exp < nextSweepEta)) {
|
|
3634
3833
|
nextSweepEta = exp;
|
|
3635
3834
|
}
|
|
@@ -3890,7 +4089,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
3890
4089
|
/** Decodes the boarding tapscript exit path to extract the CSV timelock. */
|
|
3891
4090
|
getBoardingTimelock() {
|
|
3892
4091
|
const wallet = this.getSweepWallet();
|
|
3893
|
-
const exitScript =
|
|
4092
|
+
const exitScript = chunkOWCPXRGP_cjs.CSVMultisigTapscript.decode(
|
|
3894
4093
|
base.hex.decode(wallet.boardingTapscript.exitScript)
|
|
3895
4094
|
);
|
|
3896
4095
|
return exitScript.params.timelock;
|
|
@@ -4021,8 +4220,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
4021
4220
|
* or doesn't carry the metadata.
|
|
4022
4221
|
*/
|
|
4023
4222
|
extractSpentOutpoint(error) {
|
|
4024
|
-
const ark =
|
|
4025
|
-
if (!
|
|
4223
|
+
const ark = chunkOWCPXRGP_cjs.maybeArkError(error);
|
|
4224
|
+
if (!chunkOWCPXRGP_cjs.isArkError(ark, chunkOWCPXRGP_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
|
|
4026
4225
|
const raw = ark.metadata?.vtxo_outpoint;
|
|
4027
4226
|
if (typeof raw !== "string") return void 0;
|
|
4028
4227
|
const [txid, voutStr] = raw.split(":");
|
|
@@ -4212,7 +4411,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4212
4411
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
4213
4412
|
break;
|
|
4214
4413
|
}
|
|
4215
|
-
const inputFee = estimator.evalOffchainInput(
|
|
4414
|
+
const inputFee = estimator.evalOffchainInput(chunkOWCPXRGP_cjs.toOffchainInputFeeParams(v));
|
|
4216
4415
|
if (inputFee.satoshis >= v.value) {
|
|
4217
4416
|
continue;
|
|
4218
4417
|
}
|
|
@@ -4232,7 +4431,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4232
4431
|
const arkAddress = await this.wallet.getAddress();
|
|
4233
4432
|
const outputFee = estimator.evalOffchainOutput({
|
|
4234
4433
|
amount: totalAmount,
|
|
4235
|
-
script: base.hex.encode(
|
|
4434
|
+
script: base.hex.encode(chunkOWCPXRGP_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
4236
4435
|
});
|
|
4237
4436
|
totalAmount -= BigInt(outputFee.satoshis);
|
|
4238
4437
|
if (totalAmount < dustAmount) return;
|
|
@@ -4312,7 +4511,7 @@ var ArkNote = class _ArkNote {
|
|
|
4312
4511
|
this.value = value;
|
|
4313
4512
|
this.HRP = HRP;
|
|
4314
4513
|
const preimageHash = utils_js.sha256(this.preimage);
|
|
4315
|
-
this.vtxoScript = new
|
|
4514
|
+
this.vtxoScript = new chunkOWCPXRGP_cjs.VtxoScript([noteTapscript(preimageHash)]);
|
|
4316
4515
|
const leaf = this.vtxoScript.leaves[0];
|
|
4317
4516
|
this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
|
|
4318
4517
|
this.tapTree = this.vtxoScript.encode();
|
|
@@ -4479,7 +4678,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
4479
4678
|
const privateKey = data.slice(1, 33);
|
|
4480
4679
|
const serverPubKey = data.slice(33, 65);
|
|
4481
4680
|
const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
|
|
4482
|
-
const csvTimelock =
|
|
4681
|
+
const csvTimelock = chunkOWCPXRGP_cjs.sequenceToTimelock(sequence);
|
|
4483
4682
|
return new _ArkadeCash(privateKey, serverPubKey, csvTimelock, decoded.prefix);
|
|
4484
4683
|
}
|
|
4485
4684
|
toString() {
|
|
@@ -4487,7 +4686,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
4487
4686
|
data[0] = _ArkadeCash.Version;
|
|
4488
4687
|
data.set(this._privateKey, 1);
|
|
4489
4688
|
data.set(this._serverPubKey, 33);
|
|
4490
|
-
const sequence =
|
|
4689
|
+
const sequence = chunkOWCPXRGP_cjs.timelockToSequence(this.csvTimelock);
|
|
4491
4690
|
new DataView(data.buffer, data.byteOffset + 65, 4).setUint32(0, sequence, false);
|
|
4492
4691
|
const words = base.bech32m.toWords(data);
|
|
4493
4692
|
return base.bech32m.encode(this.hrp, words, 1023);
|
|
@@ -4496,7 +4695,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
4496
4695
|
return SingleKey.fromPrivateKey(this._privateKey);
|
|
4497
4696
|
}
|
|
4498
4697
|
get vtxoScript() {
|
|
4499
|
-
return new
|
|
4698
|
+
return new chunkV2TOHHPW_cjs.DefaultVtxo.Script({
|
|
4500
4699
|
pubKey: this._publicKey,
|
|
4501
4700
|
serverPubKey: this._serverPubKey,
|
|
4502
4701
|
csvTimelock: this.csvTimelock
|
|
@@ -4757,7 +4956,7 @@ async function captureExitBranch(params) {
|
|
|
4757
4956
|
const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
|
|
4758
4957
|
if (nonCommitment.length > 0) {
|
|
4759
4958
|
for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
|
|
4760
|
-
psbtByTxid.set(
|
|
4959
|
+
psbtByTxid.set(chunkOWCPXRGP_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
4761
4960
|
}
|
|
4762
4961
|
}
|
|
4763
4962
|
}
|
|
@@ -4800,10 +4999,10 @@ var IndexerExitDataSource = class {
|
|
|
4800
4999
|
while (hasMore) {
|
|
4801
5000
|
const { chain: page, page: meta } = await this.indexer.getVtxoChain(
|
|
4802
5001
|
{ txid: vtxo.txid, vout: vtxo.vout },
|
|
4803
|
-
{ pageIndex, pageSize:
|
|
5002
|
+
{ pageIndex, pageSize: chunkOWCPXRGP_cjs.DEFAULT_PAGE_SIZE }
|
|
4804
5003
|
);
|
|
4805
5004
|
chain.push(...page);
|
|
4806
|
-
hasMore = meta ? page.length ===
|
|
5005
|
+
hasMore = meta ? page.length === chunkOWCPXRGP_cjs.DEFAULT_PAGE_SIZE : false;
|
|
4807
5006
|
pageIndex++;
|
|
4808
5007
|
}
|
|
4809
5008
|
return chain;
|
|
@@ -4815,12 +5014,12 @@ var IndexerExitDataSource = class {
|
|
|
4815
5014
|
while (hasMore) {
|
|
4816
5015
|
const { txs, page } = await this.indexer.getVirtualTxs(txids, {
|
|
4817
5016
|
pageIndex,
|
|
4818
|
-
pageSize:
|
|
5017
|
+
pageSize: chunkOWCPXRGP_cjs.DEFAULT_PAGE_SIZE
|
|
4819
5018
|
});
|
|
4820
5019
|
for (const psbt of txs) {
|
|
4821
|
-
out.set(
|
|
5020
|
+
out.set(chunkOWCPXRGP_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
4822
5021
|
}
|
|
4823
|
-
hasMore = page ? txs.length ===
|
|
5022
|
+
hasMore = page ? txs.length === chunkOWCPXRGP_cjs.DEFAULT_PAGE_SIZE : false;
|
|
4824
5023
|
pageIndex++;
|
|
4825
5024
|
}
|
|
4826
5025
|
return out;
|
|
@@ -4841,7 +5040,7 @@ function chainedTxTypeToChainTxType(t) {
|
|
|
4841
5040
|
}
|
|
4842
5041
|
}
|
|
4843
5042
|
function psbtInputTxids(psbtBase64) {
|
|
4844
|
-
const tx =
|
|
5043
|
+
const tx = chunkOWCPXRGP_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
4845
5044
|
const ids = [];
|
|
4846
5045
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
4847
5046
|
const txid = tx.getInput(i).txid;
|
|
@@ -5189,10 +5388,10 @@ async function resolveArkInfo(arkProvider, walletRepository) {
|
|
|
5189
5388
|
try {
|
|
5190
5389
|
info = await arkProvider.getInfo();
|
|
5191
5390
|
} catch (err) {
|
|
5192
|
-
if (!
|
|
5391
|
+
if (!chunkOWCPXRGP_cjs.isRetryableProviderError(err)) throw err;
|
|
5193
5392
|
const snapshot = await loadArkInfoSnapshot(walletRepository);
|
|
5194
5393
|
if (!snapshot) {
|
|
5195
|
-
throw new
|
|
5394
|
+
throw new chunkOWCPXRGP_cjs.ProviderUnavailableError(
|
|
5196
5395
|
"Arkade server info is unavailable and no cached snapshot exists",
|
|
5197
5396
|
{ cause: err }
|
|
5198
5397
|
);
|
|
@@ -5575,7 +5774,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos) {
|
|
|
5575
5774
|
return [...txids];
|
|
5576
5775
|
}
|
|
5577
5776
|
async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt) {
|
|
5578
|
-
const fromOldestVtxo = vtxos.map(
|
|
5777
|
+
const fromOldestVtxo = vtxos.map(chunkOWCPXRGP_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
5579
5778
|
const txidsNeedingCreatedAt = resolveTxCreatedAt ? collectArkTxidsNeedingCreatedAt(fromOldestVtxo) : [];
|
|
5580
5779
|
const resolvedCreatedAt = resolveTxCreatedAt && txidsNeedingCreatedAt.length > 0 ? await resolveTxCreatedAt(txidsNeedingCreatedAt) : /* @__PURE__ */ new Map();
|
|
5581
5780
|
const unmatchedSettledBoardingTxs = allBoardingTxs.filter(isSettledBoardingReceive).sort((a, b) => a.createdAt - b.createdAt);
|
|
@@ -5739,7 +5938,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5739
5938
|
const virtualCoins = await this.wallet.getVtxos({
|
|
5740
5939
|
withRecoverable: false
|
|
5741
5940
|
});
|
|
5742
|
-
const controlAssetRef = params.controlAssetId ?
|
|
5941
|
+
const controlAssetRef = params.controlAssetId ? chunkG7DOBFQN_cjs.AssetRef.fromId(chunkG7DOBFQN_cjs.AssetId.fromString(params.controlAssetId)) : null;
|
|
5743
5942
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
5744
5943
|
let totalBtcSelected = 0n;
|
|
5745
5944
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -5752,8 +5951,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5752
5951
|
}
|
|
5753
5952
|
}
|
|
5754
5953
|
const groups = [];
|
|
5755
|
-
const issuedAssetOutput =
|
|
5756
|
-
const issuedAssetGroup =
|
|
5954
|
+
const issuedAssetOutput = chunkG7DOBFQN_cjs.AssetOutput.create(0, params.amount);
|
|
5955
|
+
const issuedAssetGroup = chunkG7DOBFQN_cjs.AssetGroup.create(
|
|
5757
5956
|
null,
|
|
5758
5957
|
controlAssetRef,
|
|
5759
5958
|
[],
|
|
@@ -5768,28 +5967,28 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5768
5967
|
for (const [inputIndex, assets] of assetInputs) {
|
|
5769
5968
|
for (const asset of assets) {
|
|
5770
5969
|
if (asset.assetId !== assetId) continue;
|
|
5771
|
-
changeInputs.push(
|
|
5970
|
+
changeInputs.push(chunkG7DOBFQN_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
5772
5971
|
}
|
|
5773
5972
|
}
|
|
5774
5973
|
groups.push(
|
|
5775
|
-
|
|
5776
|
-
|
|
5974
|
+
chunkG7DOBFQN_cjs.AssetGroup.create(
|
|
5975
|
+
chunkG7DOBFQN_cjs.AssetId.fromString(assetId),
|
|
5777
5976
|
null,
|
|
5778
5977
|
changeInputs,
|
|
5779
|
-
[
|
|
5978
|
+
[chunkG7DOBFQN_cjs.AssetOutput.create(0, amount)],
|
|
5780
5979
|
[]
|
|
5781
5980
|
)
|
|
5782
5981
|
);
|
|
5783
5982
|
}
|
|
5784
5983
|
}
|
|
5785
5984
|
const address = await this.wallet.getAddress();
|
|
5786
|
-
const outputAddress =
|
|
5985
|
+
const outputAddress = chunkOWCPXRGP_cjs.ArkAddress.decode(address);
|
|
5787
5986
|
const outputs = [
|
|
5788
5987
|
{
|
|
5789
5988
|
script: outputAddress.pkScript,
|
|
5790
5989
|
amount: BigInt(totalBtcSelected)
|
|
5791
5990
|
},
|
|
5792
|
-
Extension.create([
|
|
5991
|
+
Extension.create([chunkG7DOBFQN_cjs.Packet.create(groups)]).txOut()
|
|
5793
5992
|
];
|
|
5794
5993
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
|
|
5795
5994
|
coinSelection.inputs,
|
|
@@ -5797,7 +5996,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5797
5996
|
);
|
|
5798
5997
|
return {
|
|
5799
5998
|
arkTxId: arkTxid,
|
|
5800
|
-
assetId:
|
|
5999
|
+
assetId: chunkG7DOBFQN_cjs.AssetId.create(arkTxid, 0).toString()
|
|
5801
6000
|
};
|
|
5802
6001
|
}
|
|
5803
6002
|
/**
|
|
@@ -5869,16 +6068,16 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5869
6068
|
for (const [inputIndex, assets] of assetInputs) {
|
|
5870
6069
|
for (const asset of assets) {
|
|
5871
6070
|
if (asset.assetId !== params.assetId) continue;
|
|
5872
|
-
reissueInputs.push(
|
|
6071
|
+
reissueInputs.push(chunkG7DOBFQN_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
5873
6072
|
}
|
|
5874
6073
|
}
|
|
5875
6074
|
const totalAssetAmount = assetToReissueAmount + params.amount;
|
|
5876
|
-
const reissueAssetIdObj =
|
|
5877
|
-
const reissueAssetGroup =
|
|
6075
|
+
const reissueAssetIdObj = chunkG7DOBFQN_cjs.AssetId.fromString(params.assetId);
|
|
6076
|
+
const reissueAssetGroup = chunkG7DOBFQN_cjs.AssetGroup.create(
|
|
5878
6077
|
reissueAssetIdObj,
|
|
5879
6078
|
null,
|
|
5880
6079
|
reissueInputs,
|
|
5881
|
-
[
|
|
6080
|
+
[chunkG7DOBFQN_cjs.AssetOutput.create(0, totalAssetAmount)],
|
|
5882
6081
|
[]
|
|
5883
6082
|
);
|
|
5884
6083
|
const groups = [reissueAssetGroup];
|
|
@@ -5887,27 +6086,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5887
6086
|
for (const [inputIndex, assets] of assetInputs) {
|
|
5888
6087
|
for (const asset of assets) {
|
|
5889
6088
|
if (asset.assetId !== assetId) continue;
|
|
5890
|
-
changeInputs.push(
|
|
6089
|
+
changeInputs.push(chunkG7DOBFQN_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
5891
6090
|
}
|
|
5892
6091
|
}
|
|
5893
6092
|
groups.push(
|
|
5894
|
-
|
|
5895
|
-
|
|
6093
|
+
chunkG7DOBFQN_cjs.AssetGroup.create(
|
|
6094
|
+
chunkG7DOBFQN_cjs.AssetId.fromString(assetId),
|
|
5896
6095
|
null,
|
|
5897
6096
|
changeInputs,
|
|
5898
|
-
[
|
|
6097
|
+
[chunkG7DOBFQN_cjs.AssetOutput.create(0, amount)],
|
|
5899
6098
|
[]
|
|
5900
6099
|
)
|
|
5901
6100
|
);
|
|
5902
6101
|
}
|
|
5903
6102
|
const address = await this.wallet.getAddress();
|
|
5904
|
-
const outputAddress =
|
|
6103
|
+
const outputAddress = chunkOWCPXRGP_cjs.ArkAddress.decode(address);
|
|
5905
6104
|
const outputs = [
|
|
5906
6105
|
{
|
|
5907
6106
|
script: outputAddress.pkScript,
|
|
5908
6107
|
amount: BigInt(totalBtcSelected)
|
|
5909
6108
|
},
|
|
5910
|
-
Extension.create([
|
|
6109
|
+
Extension.create([chunkG7DOBFQN_cjs.Packet.create(groups)]).txOut()
|
|
5911
6110
|
];
|
|
5912
6111
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
5913
6112
|
return arkTxid;
|
|
@@ -5974,27 +6173,27 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
5974
6173
|
for (const [inputIndex, assets] of assetInputs) {
|
|
5975
6174
|
for (const asset of assets) {
|
|
5976
6175
|
if (asset.assetId !== assetId) continue;
|
|
5977
|
-
changeInputs.push(
|
|
6176
|
+
changeInputs.push(chunkG7DOBFQN_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
5978
6177
|
}
|
|
5979
6178
|
}
|
|
5980
6179
|
groups.push(
|
|
5981
|
-
|
|
5982
|
-
|
|
6180
|
+
chunkG7DOBFQN_cjs.AssetGroup.create(
|
|
6181
|
+
chunkG7DOBFQN_cjs.AssetId.fromString(assetId),
|
|
5983
6182
|
null,
|
|
5984
6183
|
changeInputs,
|
|
5985
|
-
amount > 0n ? [
|
|
6184
|
+
amount > 0n ? [chunkG7DOBFQN_cjs.AssetOutput.create(0, amount)] : [],
|
|
5986
6185
|
[]
|
|
5987
6186
|
)
|
|
5988
6187
|
);
|
|
5989
6188
|
}
|
|
5990
6189
|
const address = await this.wallet.getAddress();
|
|
5991
|
-
const outputAddress =
|
|
6190
|
+
const outputAddress = chunkOWCPXRGP_cjs.ArkAddress.decode(address);
|
|
5992
6191
|
const outputs = [
|
|
5993
6192
|
{
|
|
5994
6193
|
script: outputAddress.pkScript,
|
|
5995
6194
|
amount: BigInt(totalBtcSelected)
|
|
5996
6195
|
},
|
|
5997
|
-
Extension.create([
|
|
6196
|
+
Extension.create([chunkG7DOBFQN_cjs.Packet.create(groups)]).txOut()
|
|
5998
6197
|
];
|
|
5999
6198
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
6000
6199
|
return arkTxid;
|
|
@@ -6019,7 +6218,7 @@ function castMetadata(metadata) {
|
|
|
6019
6218
|
} else {
|
|
6020
6219
|
throw new Error("Invalid metadata value type");
|
|
6021
6220
|
}
|
|
6022
|
-
md.push(
|
|
6221
|
+
md.push(chunkG7DOBFQN_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
|
|
6023
6222
|
}
|
|
6024
6223
|
return md;
|
|
6025
6224
|
}
|
|
@@ -6040,10 +6239,10 @@ var DelegateManagerImpl = class {
|
|
|
6040
6239
|
if (vtxos.length === 0) {
|
|
6041
6240
|
return { delegated: [], failed: [] };
|
|
6042
6241
|
}
|
|
6043
|
-
const destinationScript =
|
|
6242
|
+
const destinationScript = chunkOWCPXRGP_cjs.ArkAddress.decode(destination).pkScript;
|
|
6044
6243
|
const arkInfo = await this.arkInfoProvider.getInfo();
|
|
6045
6244
|
const delegateInfo = await this.delegateProvider.getDelegateInfo();
|
|
6046
|
-
const eligible = vtxos.map(
|
|
6245
|
+
const eligible = vtxos.map(chunkOWCPXRGP_cjs.normalizeVtxo).filter(
|
|
6047
6246
|
(v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
|
|
6048
6247
|
);
|
|
6049
6248
|
if (eligible.length === 0) {
|
|
@@ -6072,11 +6271,11 @@ var DelegateManagerImpl = class {
|
|
|
6072
6271
|
const groupByExpiry = /* @__PURE__ */ new Map();
|
|
6073
6272
|
let recoverableVtxos = [];
|
|
6074
6273
|
for (const vtxo of eligible) {
|
|
6075
|
-
if (
|
|
6274
|
+
if (chunkOWCPXRGP_cjs.canRecoverOnchain(vtxo, now)) {
|
|
6076
6275
|
recoverableVtxos.push(vtxo);
|
|
6077
6276
|
continue;
|
|
6078
6277
|
}
|
|
6079
|
-
const expiry =
|
|
6278
|
+
const expiry = chunkOWCPXRGP_cjs.toBatchExpiry(vtxo);
|
|
6080
6279
|
if (!expiry) continue;
|
|
6081
6280
|
const dayKey = getDayTimestamp(expiry);
|
|
6082
6281
|
groupByExpiry.set(dayKey, [...groupByExpiry.get(dayKey) ?? [], vtxo]);
|
|
@@ -6141,7 +6340,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6141
6340
|
}
|
|
6142
6341
|
if (!delegateAt) {
|
|
6143
6342
|
const now = { timestamp: /* @__PURE__ */ new Date() };
|
|
6144
|
-
const expiryTimestamp = vtxos.filter((coin) => !
|
|
6343
|
+
const expiryTimestamp = vtxos.filter((coin) => !chunkOWCPXRGP_cjs.canRecoverOnchain(coin, now) && chunkOWCPXRGP_cjs.toBatchExpiry(coin)).reduce((min, coin) => Math.min(min, chunkOWCPXRGP_cjs.toBatchExpiry(coin)), Number.MAX_SAFE_INTEGER);
|
|
6145
6344
|
if (!expiryTimestamp || expiryTimestamp === Number.MAX_SAFE_INTEGER) {
|
|
6146
6345
|
delegateAt = new Date(Date.now() + 1 * 60 * 1e3);
|
|
6147
6346
|
} else {
|
|
@@ -6170,7 +6369,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6170
6369
|
let amount = 0n;
|
|
6171
6370
|
for (const coin of vtxos) {
|
|
6172
6371
|
const inputFee = estimator.evalOffchainInput({
|
|
6173
|
-
...
|
|
6372
|
+
...chunkOWCPXRGP_cjs.toOffchainInputFeeParams(coin),
|
|
6174
6373
|
type: "vtxo"
|
|
6175
6374
|
});
|
|
6176
6375
|
if (inputFee.value >= coin.value) {
|
|
@@ -6184,7 +6383,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6184
6383
|
const delegateFee = BigInt(Number(fee));
|
|
6185
6384
|
if (delegateFee > 0n) {
|
|
6186
6385
|
outputs.push({
|
|
6187
|
-
script:
|
|
6386
|
+
script: chunkOWCPXRGP_cjs.ArkAddress.decode(delegateAddress).pkScript,
|
|
6188
6387
|
amount: delegateFee
|
|
6189
6388
|
});
|
|
6190
6389
|
}
|
|
@@ -6217,10 +6416,10 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
6217
6416
|
destinationScript
|
|
6218
6417
|
);
|
|
6219
6418
|
const forfeitOutputScript = btcSigner.OutScript.encode(
|
|
6220
|
-
btcSigner.Address(
|
|
6419
|
+
btcSigner.Address(chunkOWCPXRGP_cjs.getNetwork(network)).decode(forfeitAddress)
|
|
6221
6420
|
);
|
|
6222
6421
|
const forfeits = await Promise.all(
|
|
6223
|
-
vtxos.filter((v) => !
|
|
6422
|
+
vtxos.filter((v) => !chunkOWCPXRGP_cjs.canRecoverOnchain(v, { timestamp: /* @__PURE__ */ new Date() })).map(async (coin) => {
|
|
6224
6423
|
const forfeit = await makeDelegateForfeitTx(
|
|
6225
6424
|
coin,
|
|
6226
6425
|
dust,
|
|
@@ -6245,7 +6444,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
|
|
|
6245
6444
|
index: input.vout,
|
|
6246
6445
|
witnessUtxo: {
|
|
6247
6446
|
amount: BigInt(input.value),
|
|
6248
|
-
script:
|
|
6447
|
+
script: chunkOWCPXRGP_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
6249
6448
|
},
|
|
6250
6449
|
sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
|
|
6251
6450
|
tapLeafScript: [delegateTapLeaf]
|
|
@@ -6303,7 +6502,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
6303
6502
|
expire_at: 0,
|
|
6304
6503
|
cosigners_public_keys: cosignerPubKeys
|
|
6305
6504
|
};
|
|
6306
|
-
const proof =
|
|
6505
|
+
const proof = chunkOWCPXRGP_cjs.Intent.create(message, coins, outputs);
|
|
6307
6506
|
const signedProof = await identity.sign(proof);
|
|
6308
6507
|
return {
|
|
6309
6508
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -6321,10 +6520,10 @@ function getDayTimestamp(timestamp) {
|
|
|
6321
6520
|
function findDelegateTapLeaf(vtxo, delegatePubkey) {
|
|
6322
6521
|
if (!vtxo.tapTree) return void 0;
|
|
6323
6522
|
const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
|
|
6324
|
-
const vtxoScript =
|
|
6523
|
+
const vtxoScript = chunkOWCPXRGP_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
6325
6524
|
return vtxoScript.leaves.find((tapLeaf) => {
|
|
6326
|
-
const arkTapscript =
|
|
6327
|
-
if (!
|
|
6525
|
+
const arkTapscript = chunkOWCPXRGP_cjs.decodeTapscript(chunkOWCPXRGP_cjs.scriptFromTapLeafScript(tapLeaf));
|
|
6526
|
+
if (!chunkOWCPXRGP_cjs.MultisigTapscript.is(arkTapscript)) return false;
|
|
6328
6527
|
return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
|
|
6329
6528
|
});
|
|
6330
6529
|
}
|
|
@@ -6512,7 +6711,7 @@ async function closeDatabase(dbName) {
|
|
|
6512
6711
|
return true;
|
|
6513
6712
|
}
|
|
6514
6713
|
function scriptFromArkAddress(address) {
|
|
6515
|
-
return base.hex.encode(
|
|
6714
|
+
return base.hex.encode(chunkOWCPXRGP_cjs.ArkAddress.decode(address).pkScript);
|
|
6516
6715
|
}
|
|
6517
6716
|
|
|
6518
6717
|
// src/repositories/indexedDB/schema.ts
|
|
@@ -7009,7 +7208,7 @@ function validateVtxosForScript(vtxos, script, context) {
|
|
|
7009
7208
|
}
|
|
7010
7209
|
async function getVtxosForContract(repo, contract) {
|
|
7011
7210
|
const vtxos = repo.getVtxosForScript ? await repo.getVtxosForScript(contract.script) : filterVtxosForScript(await repo.getVtxos(contract.address), contract.script);
|
|
7012
|
-
return vtxos.map(
|
|
7211
|
+
return vtxos.map(chunkOWCPXRGP_cjs.normalizeVtxo);
|
|
7013
7212
|
}
|
|
7014
7213
|
async function saveVtxosForContract(repo, contract, vtxos) {
|
|
7015
7214
|
if (repo.saveVtxosForScript) {
|
|
@@ -7213,7 +7412,7 @@ var deserializeTapLeaf = (t) => {
|
|
|
7213
7412
|
const s = base.hex.decode(t.s);
|
|
7214
7413
|
return [cb, s];
|
|
7215
7414
|
};
|
|
7216
|
-
var deserializeVtxo = (o) =>
|
|
7415
|
+
var deserializeVtxo = (o) => chunkOWCPXRGP_cjs.normalizeVtxo({
|
|
7217
7416
|
...o,
|
|
7218
7417
|
createdAt: new Date(o.createdAt),
|
|
7219
7418
|
tapTree: base.hex.decode(o.tapTree),
|
|
@@ -8352,7 +8551,7 @@ var ContractWatcher = class {
|
|
|
8352
8551
|
this.connectionState = "connected";
|
|
8353
8552
|
this.reconnectAttempts = 0;
|
|
8354
8553
|
this.listenLoop().catch((e) => {
|
|
8355
|
-
if (
|
|
8554
|
+
if (chunkOWCPXRGP_cjs.isEventSourceError(e)) {
|
|
8356
8555
|
console.debug("ContractWatcher subscription disconnected; reconnecting");
|
|
8357
8556
|
} else {
|
|
8358
8557
|
console.error(e);
|
|
@@ -8581,14 +8780,14 @@ var ContractWatcher = class {
|
|
|
8581
8780
|
const timestamp = Date.now();
|
|
8582
8781
|
if (update.newVtxos?.length) {
|
|
8583
8782
|
this.processSubscriptionVtxos(
|
|
8584
|
-
update.newVtxos.map(
|
|
8783
|
+
update.newVtxos.map(chunkOWCPXRGP_cjs.normalizeVtxo),
|
|
8585
8784
|
"vtxo_received",
|
|
8586
8785
|
timestamp
|
|
8587
8786
|
);
|
|
8588
8787
|
}
|
|
8589
8788
|
if (update.spentVtxos?.length) {
|
|
8590
8789
|
this.processSubscriptionVtxos(
|
|
8591
|
-
update.spentVtxos.map(
|
|
8790
|
+
update.spentVtxos.map(chunkOWCPXRGP_cjs.normalizeVtxo),
|
|
8592
8791
|
"vtxo_spent",
|
|
8593
8792
|
timestamp
|
|
8594
8793
|
);
|
|
@@ -8721,7 +8920,7 @@ async function reconcileIntents(deps) {
|
|
|
8721
8920
|
let vtxosByOutpoint = /* @__PURE__ */ new Map();
|
|
8722
8921
|
if (outpoints.length > 0) {
|
|
8723
8922
|
try {
|
|
8724
|
-
const { vtxos } = await
|
|
8923
|
+
const { vtxos } = await chunkOWCPXRGP_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
|
|
8725
8924
|
vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
|
|
8726
8925
|
} catch (e) {
|
|
8727
8926
|
console.error("reconcileIntents: failed to fetch input VTXO state", e);
|
|
@@ -8841,7 +9040,7 @@ var ContractManager = class _ContractManager {
|
|
|
8841
9040
|
await this.reconcileWatched();
|
|
8842
9041
|
this.markSyncOnline();
|
|
8843
9042
|
} catch (err) {
|
|
8844
|
-
if (!
|
|
9043
|
+
if (!chunkOWCPXRGP_cjs.isRetryableProviderError(err)) throw err;
|
|
8845
9044
|
this.markSyncDegraded(err);
|
|
8846
9045
|
}
|
|
8847
9046
|
this.initialized = true;
|
|
@@ -8953,7 +9152,7 @@ var ContractManager = class _ContractManager {
|
|
|
8953
9152
|
const from = Math.max(0, watermark - lookAhead.size);
|
|
8954
9153
|
const to = watermark + lookAhead.size;
|
|
8955
9154
|
const deps = lookAhead.candidateDeps();
|
|
8956
|
-
const handlers =
|
|
9155
|
+
const handlers = chunkV2TOHHPW_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkV2TOHHPW_cjs.contractHandlers.get(t)).filter(hasCandidates);
|
|
8957
9156
|
const band = /* @__PURE__ */ new Map();
|
|
8958
9157
|
for (let index = from; index <= to; index++) {
|
|
8959
9158
|
const descriptor = lookAhead.materialize(index);
|
|
@@ -8964,7 +9163,7 @@ var ContractManager = class _ContractManager {
|
|
|
8964
9163
|
index,
|
|
8965
9164
|
params: {
|
|
8966
9165
|
...candidate,
|
|
8967
|
-
...
|
|
9166
|
+
...chunkV2TOHHPW_cjs.speculativeReceiveMetadata(descriptor)
|
|
8968
9167
|
}
|
|
8969
9168
|
});
|
|
8970
9169
|
}
|
|
@@ -9024,7 +9223,7 @@ var ContractManager = class _ContractManager {
|
|
|
9024
9223
|
});
|
|
9025
9224
|
for (const entry of pending) entry.catchUpPending = false;
|
|
9026
9225
|
} catch (err) {
|
|
9027
|
-
if (!
|
|
9226
|
+
if (!chunkOWCPXRGP_cjs.isRetryableProviderError(err)) throw err;
|
|
9028
9227
|
this.markSyncDegraded(err);
|
|
9029
9228
|
}
|
|
9030
9229
|
}
|
|
@@ -9068,7 +9267,7 @@ var ContractManager = class _ContractManager {
|
|
|
9068
9267
|
await this.fetchContractVxosFromIndexer([contract]);
|
|
9069
9268
|
this.markSyncOnline();
|
|
9070
9269
|
} catch (err) {
|
|
9071
|
-
if (!
|
|
9270
|
+
if (!chunkOWCPXRGP_cjs.isRetryableProviderError(err)) throw err;
|
|
9072
9271
|
this.markSyncDegraded(err);
|
|
9073
9272
|
}
|
|
9074
9273
|
await this.watcher.addContract(contract);
|
|
@@ -9105,7 +9304,7 @@ var ContractManager = class _ContractManager {
|
|
|
9105
9304
|
return result;
|
|
9106
9305
|
}
|
|
9107
9306
|
async upsertContractRow(params) {
|
|
9108
|
-
const handler =
|
|
9307
|
+
const handler = chunkV2TOHHPW_cjs.contractHandlers.get(params.type);
|
|
9109
9308
|
if (!handler) {
|
|
9110
9309
|
throw new Error(`No handler registered for contract type '${params.type}'`);
|
|
9111
9310
|
}
|
|
@@ -9205,7 +9404,7 @@ var ContractManager = class _ContractManager {
|
|
|
9205
9404
|
`scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
|
|
9206
9405
|
);
|
|
9207
9406
|
}
|
|
9208
|
-
const registered =
|
|
9407
|
+
const registered = chunkV2TOHHPW_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkV2TOHHPW_cjs.contractHandlers.get(t)).filter(isDiscoverable);
|
|
9209
9408
|
const discoverables = [
|
|
9210
9409
|
...registered.filter((h) => h.type === "boarding"),
|
|
9211
9410
|
...registered.filter((h) => h.type !== "boarding")
|
|
@@ -9340,7 +9539,7 @@ var ContractManager = class _ContractManager {
|
|
|
9340
9539
|
await this.syncContracts({ contracts, pageSize });
|
|
9341
9540
|
this.markSyncOnline();
|
|
9342
9541
|
} catch (err) {
|
|
9343
|
-
if (!
|
|
9542
|
+
if (!chunkOWCPXRGP_cjs.isRetryableProviderError(err)) throw err;
|
|
9344
9543
|
this.markSyncDegraded(err);
|
|
9345
9544
|
}
|
|
9346
9545
|
const vtxos = await this.getVtxosForContracts(contracts);
|
|
@@ -9361,7 +9560,7 @@ var ContractManager = class _ContractManager {
|
|
|
9361
9560
|
}
|
|
9362
9561
|
const tapscriptCache = /* @__PURE__ */ new Map();
|
|
9363
9562
|
return vtxos.map(
|
|
9364
|
-
(vtxo) => extendVirtualCoinForContract(
|
|
9563
|
+
(vtxo) => extendVirtualCoinForContract(chunkOWCPXRGP_cjs.normalizeVtxo(vtxo), byScript, tapscriptCache)
|
|
9365
9564
|
);
|
|
9366
9565
|
}
|
|
9367
9566
|
buildContractsDbFilter(filter) {
|
|
@@ -9446,7 +9645,7 @@ var ContractManager = class _ContractManager {
|
|
|
9446
9645
|
const { contractScript, collaborative = true, walletPubKey, vtxo } = options;
|
|
9447
9646
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
9448
9647
|
if (!contract) return [];
|
|
9449
|
-
const handler =
|
|
9648
|
+
const handler = chunkV2TOHHPW_cjs.contractHandlers.get(contract.type);
|
|
9450
9649
|
if (!handler) return [];
|
|
9451
9650
|
const script = handler.createScript(contract.params);
|
|
9452
9651
|
const context = {
|
|
@@ -9466,7 +9665,7 @@ var ContractManager = class _ContractManager {
|
|
|
9466
9665
|
const { contractScript, collaborative = true, walletPubKey } = options;
|
|
9467
9666
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
9468
9667
|
if (!contract) return [];
|
|
9469
|
-
const handler =
|
|
9668
|
+
const handler = chunkV2TOHHPW_cjs.contractHandlers.get(contract.type);
|
|
9470
9669
|
if (!handler) return [];
|
|
9471
9670
|
const script = handler.createScript(contract.params);
|
|
9472
9671
|
const context = {
|
|
@@ -9522,7 +9721,7 @@ var ContractManager = class _ContractManager {
|
|
|
9522
9721
|
}
|
|
9523
9722
|
async refreshOutpoints(outpoints) {
|
|
9524
9723
|
if (outpoints.length === 0) return;
|
|
9525
|
-
const { vtxos } = await
|
|
9724
|
+
const { vtxos } = await chunkOWCPXRGP_cjs.getNormalizedVtxos(this.config.indexerProvider, {
|
|
9526
9725
|
outpoints
|
|
9527
9726
|
});
|
|
9528
9727
|
if (vtxos.length === 0) return;
|
|
@@ -9600,7 +9799,7 @@ var ContractManager = class _ContractManager {
|
|
|
9600
9799
|
break;
|
|
9601
9800
|
}
|
|
9602
9801
|
} catch (err) {
|
|
9603
|
-
if (!
|
|
9802
|
+
if (!chunkOWCPXRGP_cjs.isRetryableProviderError(err)) throw err;
|
|
9604
9803
|
this.markSyncDegraded(err);
|
|
9605
9804
|
}
|
|
9606
9805
|
this.emitEvent(event);
|
|
@@ -9649,7 +9848,7 @@ var ContractManager = class _ContractManager {
|
|
|
9649
9848
|
*/
|
|
9650
9849
|
async reconcilePendingFrontier(contracts) {
|
|
9651
9850
|
const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
|
|
9652
|
-
const vtxos = await
|
|
9851
|
+
const vtxos = await chunkOWCPXRGP_cjs.getAllNormalizedVtxos(
|
|
9653
9852
|
this.config.indexerProvider,
|
|
9654
9853
|
contracts.map((c) => c.script),
|
|
9655
9854
|
{ pendingOnly: true }
|
|
@@ -9730,7 +9929,7 @@ var ContractManager = class _ContractManager {
|
|
|
9730
9929
|
}
|
|
9731
9930
|
return result;
|
|
9732
9931
|
}
|
|
9733
|
-
async fetchContractVtxosBulk(contracts, pageSize =
|
|
9932
|
+
async fetchContractVtxosBulk(contracts, pageSize = chunkOWCPXRGP_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
|
|
9734
9933
|
if (contracts.length === 0) {
|
|
9735
9934
|
return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
|
|
9736
9935
|
}
|
|
@@ -9746,7 +9945,7 @@ var ContractManager = class _ContractManager {
|
|
|
9746
9945
|
before: syncWindow.before
|
|
9747
9946
|
}
|
|
9748
9947
|
} : {};
|
|
9749
|
-
const vtxos = await
|
|
9948
|
+
const vtxos = await chunkOWCPXRGP_cjs.getAllNormalizedVtxos(
|
|
9750
9949
|
this.config.indexerProvider,
|
|
9751
9950
|
contracts.map((c) => c.script),
|
|
9752
9951
|
{ ...windowOpts, pageSize }
|
|
@@ -9913,7 +10112,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
9913
10112
|
*/
|
|
9914
10113
|
materializeDescriptorAt(index) {
|
|
9915
10114
|
const descriptor = this.identity.descriptor;
|
|
9916
|
-
const network =
|
|
10115
|
+
const network = chunkV2TOHHPW_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
9917
10116
|
const expansion = descriptorsScure.expand({ descriptor, network, index });
|
|
9918
10117
|
const keyInfo = expansion.expansionMap?.["@0"];
|
|
9919
10118
|
if (!keyInfo?.keyExpression) {
|
|
@@ -10057,7 +10256,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
10057
10256
|
const provider = await resolveDescriptorProvider(config, setup.walletRepository);
|
|
10058
10257
|
if (!provider) return void 0;
|
|
10059
10258
|
const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
|
|
10060
|
-
const expectedContractType = setup.offchainTapscript instanceof
|
|
10259
|
+
const expectedContractType = setup.offchainTapscript instanceof chunkV2TOHHPW_cjs.DelegateVtxo.Script ? "delegate" : "default";
|
|
10061
10260
|
const factoryOpts = {
|
|
10062
10261
|
walletRepository: setup.walletRepository,
|
|
10063
10262
|
contractRepository: setup.contractRepository,
|
|
@@ -10256,7 +10455,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
10256
10455
|
};
|
|
10257
10456
|
function deriveLeafPubkey(descriptor) {
|
|
10258
10457
|
try {
|
|
10259
|
-
return
|
|
10458
|
+
return chunkV2TOHHPW_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
10260
10459
|
} catch (e) {
|
|
10261
10460
|
throw new NonRangeableDescriptorError(
|
|
10262
10461
|
"Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
|
|
@@ -10268,7 +10467,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
10268
10467
|
const pubKey = deriveLeafPubkey(descriptor);
|
|
10269
10468
|
const tapscript = rebuildTapscript(current, pubKey);
|
|
10270
10469
|
const serverPubKey = tapscript.options.serverPubKey;
|
|
10271
|
-
const csvTimelock =
|
|
10470
|
+
const csvTimelock = chunkOWCPXRGP_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
|
|
10272
10471
|
const base$1 = {
|
|
10273
10472
|
script: base.hex.encode(tapscript.pkScript),
|
|
10274
10473
|
address: tapscript.address(hrp, serverPubKey).encode(),
|
|
@@ -10279,11 +10478,11 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
10279
10478
|
// index-0 key. Without it, spends produce unsigned PSBTs that the
|
|
10280
10479
|
// server rejects with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
10281
10480
|
metadata: {
|
|
10282
|
-
...{ source:
|
|
10481
|
+
...{ source: chunkV2TOHHPW_cjs.WALLET_RECEIVE_SOURCE },
|
|
10283
10482
|
signingDescriptor: descriptor
|
|
10284
10483
|
}
|
|
10285
10484
|
};
|
|
10286
|
-
const params = tapscript instanceof
|
|
10485
|
+
const params = tapscript instanceof chunkV2TOHHPW_cjs.DelegateVtxo.Script ? {
|
|
10287
10486
|
...base$1,
|
|
10288
10487
|
type: "delegate",
|
|
10289
10488
|
params: {
|
|
@@ -10304,10 +10503,10 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
10304
10503
|
return { tapscript, params };
|
|
10305
10504
|
}
|
|
10306
10505
|
function rebuildTapscript(current, pubKey) {
|
|
10307
|
-
if (current instanceof
|
|
10308
|
-
return new
|
|
10506
|
+
if (current instanceof chunkV2TOHHPW_cjs.DelegateVtxo.Script) {
|
|
10507
|
+
return new chunkV2TOHHPW_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
|
|
10309
10508
|
}
|
|
10310
|
-
return new
|
|
10509
|
+
return new chunkV2TOHHPW_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
|
|
10311
10510
|
}
|
|
10312
10511
|
async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
|
|
10313
10512
|
const candidates = await contractRepository.getContracts({
|
|
@@ -10316,7 +10515,7 @@ async function pickActiveReceive(contractRepository, serverPubKey, expectedType)
|
|
|
10316
10515
|
});
|
|
10317
10516
|
const serverPubKeyHex = base.hex.encode(serverPubKey);
|
|
10318
10517
|
const matching = candidates.filter(
|
|
10319
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
10518
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkV2TOHHPW_cjs.WALLET_RECEIVE_SOURCE
|
|
10320
10519
|
).sort((a, b) => {
|
|
10321
10520
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
10322
10521
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -10492,12 +10691,12 @@ var InputSignerRouter = class {
|
|
|
10492
10691
|
};
|
|
10493
10692
|
|
|
10494
10693
|
// src/wallet/wallet.ts
|
|
10495
|
-
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl ||
|
|
10694
|
+
var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl || chunkOWCPXRGP_cjs.DEFAULT_ARKADE_SERVER_URL;
|
|
10496
10695
|
function intentProofJobs(coins) {
|
|
10497
10696
|
if (coins.length === 0) return [];
|
|
10498
10697
|
const coinJobs = coins.map((coin, i) => ({
|
|
10499
10698
|
index: i + 1,
|
|
10500
|
-
lookupScript:
|
|
10699
|
+
lookupScript: chunkOWCPXRGP_cjs.VtxoScript.decode(coin.tapTree).pkScript
|
|
10501
10700
|
}));
|
|
10502
10701
|
return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
|
|
10503
10702
|
}
|
|
@@ -10522,7 +10721,7 @@ function dedupeTimelocks(timelocks) {
|
|
|
10522
10721
|
const seen = /* @__PURE__ */ new Set();
|
|
10523
10722
|
const deduped = [];
|
|
10524
10723
|
for (const timelock of timelocks) {
|
|
10525
|
-
const sequence =
|
|
10724
|
+
const sequence = chunkOWCPXRGP_cjs.timelockToSequence(timelock).toString();
|
|
10526
10725
|
if (seen.has(sequence)) continue;
|
|
10527
10726
|
seen.add(sequence);
|
|
10528
10727
|
deduped.push(timelock);
|
|
@@ -10539,7 +10738,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
10539
10738
|
state: "active"
|
|
10540
10739
|
});
|
|
10541
10740
|
const newest = candidates.filter(
|
|
10542
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
10741
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkV2TOHHPW_cjs.WALLET_RECEIVE_SOURCE
|
|
10543
10742
|
).sort((a, b) => {
|
|
10544
10743
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
10545
10744
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -10547,7 +10746,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
10547
10746
|
if (!newest?.params.pubKey) return baseline;
|
|
10548
10747
|
try {
|
|
10549
10748
|
const pubKey = base.hex.decode(newest.params.pubKey);
|
|
10550
|
-
return new
|
|
10749
|
+
return new chunkV2TOHHPW_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
|
|
10551
10750
|
} catch (e) {
|
|
10552
10751
|
console.warn("Skipping malformed boarding contract at boot", newest.script, e);
|
|
10553
10752
|
return baseline;
|
|
@@ -10867,7 +11066,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
10867
11066
|
*/
|
|
10868
11067
|
static async setupWalletConfig(config, pubKey) {
|
|
10869
11068
|
const arkadeServerUrl = getArkadeServerUrl(config);
|
|
10870
|
-
const arkProvider = config.arkProvider || new
|
|
11069
|
+
const arkProvider = config.arkProvider || new chunkOWCPXRGP_cjs.RestArkProvider(arkadeServerUrl);
|
|
10871
11070
|
let indexerProvider = config.indexerProvider;
|
|
10872
11071
|
if (!indexerProvider) {
|
|
10873
11072
|
let indexerUrl = config.indexerUrl;
|
|
@@ -10884,7 +11083,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
10884
11083
|
indexerUrl = arkadeServerUrl;
|
|
10885
11084
|
}
|
|
10886
11085
|
}
|
|
10887
|
-
indexerProvider = new
|
|
11086
|
+
indexerProvider = new chunkG7DOBFQN_cjs.RestIndexerProvider(indexerUrl);
|
|
10888
11087
|
}
|
|
10889
11088
|
const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
10890
11089
|
const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
@@ -10893,7 +11092,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
10893
11092
|
source: serverInfoSource,
|
|
10894
11093
|
lastOnlineAt: serverInfoLastOnlineAt
|
|
10895
11094
|
} = await resolveArkInfo(arkProvider, walletRepository);
|
|
10896
|
-
const network =
|
|
11095
|
+
const network = chunkOWCPXRGP_cjs.getNetwork(info.network);
|
|
10897
11096
|
if ("descriptor" in config.identity) {
|
|
10898
11097
|
const descriptor = config.identity.descriptor;
|
|
10899
11098
|
const identityIsMainnet = !descriptor.includes("tpub");
|
|
@@ -10940,11 +11139,11 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
10940
11139
|
serverPubKey,
|
|
10941
11140
|
csvTimelock: exitTimelock
|
|
10942
11141
|
};
|
|
10943
|
-
const offchainTapscript = !delegatePubKey ? new
|
|
10944
|
-
const boardingTapscript =
|
|
11142
|
+
const offchainTapscript = !delegatePubKey ? new chunkV2TOHHPW_cjs.DefaultVtxo.Script(offchainOptions) : new chunkV2TOHHPW_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
|
|
11143
|
+
const boardingTapscript = chunkV2TOHHPW_cjs.BoardingContractHandler.createScript({
|
|
10945
11144
|
pubKey: base.hex.encode(pubKey),
|
|
10946
11145
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
10947
|
-
csvTimelock:
|
|
11146
|
+
csvTimelock: chunkOWCPXRGP_cjs.timelockToSequence(boardingTimelock).toString()
|
|
10948
11147
|
});
|
|
10949
11148
|
return {
|
|
10950
11149
|
arkProvider,
|
|
@@ -11050,19 +11249,19 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11050
11249
|
let pendingRecovery = 0;
|
|
11051
11250
|
const now = { timestamp: /* @__PURE__ */ new Date() };
|
|
11052
11251
|
const settled = vtxos.filter(
|
|
11053
|
-
(coin) =>
|
|
11252
|
+
(coin) => chunkOWCPXRGP_cjs.canSpendOffchain(coin, now) && !coin.isPreconfirmed && !isPendingRecovery(coin)
|
|
11054
11253
|
).reduce((sum, coin) => sum + coin.value, 0);
|
|
11055
11254
|
const preconfirmed = vtxos.filter(
|
|
11056
|
-
(coin) =>
|
|
11255
|
+
(coin) => chunkOWCPXRGP_cjs.canSpendOffchain(coin, now) && coin.isPreconfirmed && !isPendingRecovery(coin)
|
|
11057
11256
|
).reduce((sum, coin) => sum + coin.value, 0);
|
|
11058
|
-
const available = unlockedVtxos.filter((coin) =>
|
|
11059
|
-
recoverable = vtxos.filter((coin) =>
|
|
11257
|
+
const available = unlockedVtxos.filter((coin) => chunkOWCPXRGP_cjs.canSpendOffchain(coin, now) && !isPendingRecovery(coin)).reduce((sum, coin) => sum + coin.value, 0);
|
|
11258
|
+
recoverable = vtxos.filter((coin) => chunkOWCPXRGP_cjs.canRecoverOnchain(coin, now) && !isPendingRecovery(coin)).reduce((sum, coin) => sum + coin.value, 0);
|
|
11060
11259
|
pendingRecovery = vtxos.filter(isPendingRecovery).reduce((sum, coin) => sum + coin.value, 0);
|
|
11061
11260
|
const totalBoarding = confirmed + unconfirmed;
|
|
11062
11261
|
const totalOffchain = settled + preconfirmed + recoverable + pendingRecovery;
|
|
11063
11262
|
const assetBalances = /* @__PURE__ */ new Map();
|
|
11064
11263
|
for (const vtxo of vtxos) {
|
|
11065
|
-
if (
|
|
11264
|
+
if (chunkOWCPXRGP_cjs.hasTerminalSpend(vtxo)) continue;
|
|
11066
11265
|
if (vtxo.assets) {
|
|
11067
11266
|
for (const a of vtxo.assets) {
|
|
11068
11267
|
const current = assetBalances.get(a.assetId) ?? 0n;
|
|
@@ -11103,8 +11302,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11103
11302
|
if (this._pendingSpendOutpoints.has(`${vtxo.txid}:${vtxo.vout}`)) {
|
|
11104
11303
|
return false;
|
|
11105
11304
|
}
|
|
11106
|
-
if (!
|
|
11107
|
-
if (!f.withRecoverable &&
|
|
11305
|
+
if (!chunkOWCPXRGP_cjs.hasTerminalSpend(vtxo)) {
|
|
11306
|
+
if (!f.withRecoverable && chunkOWCPXRGP_cjs.canRecoverOnchain(vtxo, now)) {
|
|
11108
11307
|
return false;
|
|
11109
11308
|
}
|
|
11110
11309
|
return true;
|
|
@@ -11137,7 +11336,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11137
11336
|
const response = await contractManager.getContractsWithVtxos();
|
|
11138
11337
|
const allVtxos = response.flatMap((_) => _.vtxos);
|
|
11139
11338
|
const { boardingTxs, commitmentsToIgnore } = await this.getBoardingTxs();
|
|
11140
|
-
const resolveTxCreatedAt = (txids) =>
|
|
11339
|
+
const resolveTxCreatedAt = (txids) => chunkOWCPXRGP_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
|
|
11141
11340
|
return buildTransactionHistory(
|
|
11142
11341
|
allVtxos,
|
|
11143
11342
|
boardingTxs,
|
|
@@ -11231,7 +11430,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11231
11430
|
},
|
|
11232
11431
|
isUnrolled: true,
|
|
11233
11432
|
...boardingFacts,
|
|
11234
|
-
virtualStatus:
|
|
11433
|
+
virtualStatus: chunkOWCPXRGP_cjs.toVirtualStatus(boardingFacts),
|
|
11235
11434
|
spentBy: "",
|
|
11236
11435
|
createdAt: tx.status.confirmed ? new Date(tx.status.block_time * 1e3) : /* @__PURE__ */ new Date(0),
|
|
11237
11436
|
script: scriptHex
|
|
@@ -11287,9 +11486,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11287
11486
|
async getBoardingTapscripts(allowedSigners) {
|
|
11288
11487
|
const byScript = /* @__PURE__ */ new Map();
|
|
11289
11488
|
const add = (s) => byScript.set(base.hex.encode(s.pkScript), s);
|
|
11290
|
-
const boardingCsv = this.boardingTapscript.options.csvTimelock ??
|
|
11489
|
+
const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkV2TOHHPW_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
11291
11490
|
add(
|
|
11292
|
-
new
|
|
11491
|
+
new chunkV2TOHHPW_cjs.DefaultVtxo.Script({
|
|
11293
11492
|
pubKey: await this.identity.xOnlyPublicKey(),
|
|
11294
11493
|
serverPubKey: this.boardingTapscript.options.serverPubKey,
|
|
11295
11494
|
csvTimelock: boardingCsv
|
|
@@ -11304,7 +11503,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11304
11503
|
for (const c of boardingContracts) {
|
|
11305
11504
|
if (!allowed.has(toXOnlySignerHex(c.params.serverPubKey))) continue;
|
|
11306
11505
|
try {
|
|
11307
|
-
add(
|
|
11506
|
+
add(chunkV2TOHHPW_cjs.BoardingContractHandler.createScript(c.params));
|
|
11308
11507
|
} catch (e) {
|
|
11309
11508
|
console.warn("Skipping malformed boarding contract", c.script, e);
|
|
11310
11509
|
}
|
|
@@ -11342,7 +11541,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11342
11541
|
// Per-row CSV delay decoded from THIS tapscript's exit leaf —
|
|
11343
11542
|
// not the wallet's current boarding timelock, which a signer
|
|
11344
11543
|
// rotation may have changed.
|
|
11345
|
-
csvTimelock:
|
|
11544
|
+
csvTimelock: chunkOWCPXRGP_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
|
|
11346
11545
|
coins: utxos
|
|
11347
11546
|
});
|
|
11348
11547
|
}
|
|
@@ -11475,7 +11674,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11475
11674
|
/** Fetch Arkade transaction ids that are still pending final settlement. */
|
|
11476
11675
|
async fetchPendingTxs() {
|
|
11477
11676
|
const scripts = await this.getWalletScripts();
|
|
11478
|
-
const vtxos = await
|
|
11677
|
+
const vtxos = await chunkOWCPXRGP_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
|
|
11479
11678
|
return vtxos.filter(
|
|
11480
11679
|
(vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
|
|
11481
11680
|
).map((_) => _.arkTxId);
|
|
@@ -11506,7 +11705,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11506
11705
|
});
|
|
11507
11706
|
for (const contract of contracts) {
|
|
11508
11707
|
if (map.has(contract.script)) continue;
|
|
11509
|
-
const handler =
|
|
11708
|
+
const handler = chunkV2TOHHPW_cjs.contractHandlers.get(contract.type);
|
|
11510
11709
|
if (handler) {
|
|
11511
11710
|
const script = handler.createScript(contract.params);
|
|
11512
11711
|
map.set(contract.script, script);
|
|
@@ -11609,7 +11808,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11609
11808
|
lookAhead: this.lookAheadConfig()
|
|
11610
11809
|
});
|
|
11611
11810
|
const baselinePubkey = await this.identity.xOnlyPublicKey();
|
|
11612
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
11811
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkV2TOHHPW_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
11613
11812
|
const baselineSigners = [
|
|
11614
11813
|
this.offchainTapscript.options.serverPubKey,
|
|
11615
11814
|
...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
|
|
@@ -11617,8 +11816,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11617
11816
|
const seenBaselineScripts = /* @__PURE__ */ new Set();
|
|
11618
11817
|
for (const serverPubKey of baselineSigners) {
|
|
11619
11818
|
for (const csvTimelock of this.walletContractTimelocks) {
|
|
11620
|
-
const csvTimelockStr =
|
|
11621
|
-
const defaultScript = new
|
|
11819
|
+
const csvTimelockStr = chunkOWCPXRGP_cjs.timelockToSequence(csvTimelock).toString();
|
|
11820
|
+
const defaultScript = new chunkV2TOHHPW_cjs.DefaultVtxo.Script({
|
|
11622
11821
|
pubKey: baselinePubkey,
|
|
11623
11822
|
serverPubKey,
|
|
11624
11823
|
csvTimelock
|
|
@@ -11639,7 +11838,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11639
11838
|
});
|
|
11640
11839
|
}
|
|
11641
11840
|
if (delegatePubKey) {
|
|
11642
|
-
const delegateScript = new
|
|
11841
|
+
const delegateScript = new chunkV2TOHHPW_cjs.DelegateVtxo.Script({
|
|
11643
11842
|
pubKey: baselinePubkey,
|
|
11644
11843
|
serverPubKey,
|
|
11645
11844
|
delegatePubKey,
|
|
@@ -11663,9 +11862,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11663
11862
|
}
|
|
11664
11863
|
}
|
|
11665
11864
|
}
|
|
11666
|
-
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ??
|
|
11865
|
+
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkV2TOHHPW_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
11667
11866
|
for (const serverPubKey of baselineSigners) {
|
|
11668
|
-
const baselineBoarding = new
|
|
11867
|
+
const baselineBoarding = new chunkV2TOHHPW_cjs.DefaultVtxo.Script({
|
|
11669
11868
|
pubKey: baselinePubkey,
|
|
11670
11869
|
serverPubKey,
|
|
11671
11870
|
csvTimelock: boardingCsvTimelock
|
|
@@ -11678,7 +11877,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
11678
11877
|
params: {
|
|
11679
11878
|
pubKey: base.hex.encode(baselineBoarding.options.pubKey),
|
|
11680
11879
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
11681
|
-
csvTimelock:
|
|
11880
|
+
csvTimelock: chunkOWCPXRGP_cjs.timelockToSequence(boardingCsvTimelock).toString()
|
|
11682
11881
|
},
|
|
11683
11882
|
script: boardingScriptHex,
|
|
11684
11883
|
address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
|
|
@@ -11852,7 +12051,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
11852
12051
|
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
11853
12052
|
deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
|
|
11854
12053
|
csvTimelocks: this.walletContractTimelocks,
|
|
11855
|
-
delegatePubKey: this.offchainTapscript instanceof
|
|
12054
|
+
delegatePubKey: this.offchainTapscript instanceof chunkV2TOHHPW_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
|
|
11856
12055
|
};
|
|
11857
12056
|
}
|
|
11858
12057
|
_signerRouter;
|
|
@@ -11944,25 +12143,25 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
11944
12143
|
return this.getBoardingAddress();
|
|
11945
12144
|
}
|
|
11946
12145
|
const descriptor = await provider.getNextSigningDescriptor();
|
|
11947
|
-
const pubKey =
|
|
11948
|
-
const newBoarding = new
|
|
12146
|
+
const pubKey = chunkV2TOHHPW_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
12147
|
+
const newBoarding = new chunkV2TOHHPW_cjs.DefaultVtxo.Script({
|
|
11949
12148
|
...this._boardingTapscript.options,
|
|
11950
12149
|
pubKey
|
|
11951
12150
|
});
|
|
11952
|
-
const csvTimelock = newBoarding.options.csvTimelock ??
|
|
12151
|
+
const csvTimelock = newBoarding.options.csvTimelock ?? chunkV2TOHHPW_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
11953
12152
|
const manager = await this.getContractManager();
|
|
11954
12153
|
await manager.createContract({
|
|
11955
12154
|
type: "boarding",
|
|
11956
12155
|
params: {
|
|
11957
12156
|
pubKey: base.hex.encode(pubKey),
|
|
11958
12157
|
serverPubKey: base.hex.encode(newBoarding.options.serverPubKey),
|
|
11959
|
-
csvTimelock:
|
|
12158
|
+
csvTimelock: chunkOWCPXRGP_cjs.timelockToSequence(csvTimelock).toString()
|
|
11960
12159
|
},
|
|
11961
12160
|
script: base.hex.encode(newBoarding.pkScript),
|
|
11962
12161
|
address: newBoarding.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
11963
12162
|
state: "active",
|
|
11964
12163
|
metadata: {
|
|
11965
|
-
source:
|
|
12164
|
+
source: chunkV2TOHHPW_cjs.WALLET_RECEIVE_SOURCE,
|
|
11966
12165
|
signingDescriptor: descriptor
|
|
11967
12166
|
}
|
|
11968
12167
|
});
|
|
@@ -11974,6 +12173,51 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
11974
12173
|
}
|
|
11975
12174
|
return newBoarding.onchainAddress(this.network);
|
|
11976
12175
|
}
|
|
12176
|
+
/**
|
|
12177
|
+
* @see HDWalletCapable.getCurrentSigningDescriptor
|
|
12178
|
+
*/
|
|
12179
|
+
async getCurrentSigningDescriptor() {
|
|
12180
|
+
const provider = this._descriptorProvider;
|
|
12181
|
+
if (!(provider instanceof HDDescriptorProvider)) return void 0;
|
|
12182
|
+
return provider.getCurrentSigningDescriptor();
|
|
12183
|
+
}
|
|
12184
|
+
/**
|
|
12185
|
+
* @see HDWalletCapable.getUsedSigningDescriptors
|
|
12186
|
+
*
|
|
12187
|
+
* Union of the watermark band and the descriptors persisted on contracts:
|
|
12188
|
+
* the band alone would miss rows a restore scan wrote, and the contracts
|
|
12189
|
+
* alone would miss indices allocated for something the wallet never
|
|
12190
|
+
* persisted (a swap, an externally issued invoice).
|
|
12191
|
+
*/
|
|
12192
|
+
async getUsedSigningDescriptors() {
|
|
12193
|
+
const provider = this._descriptorProvider;
|
|
12194
|
+
const descriptors = /* @__PURE__ */ new Set();
|
|
12195
|
+
if (provider instanceof HDDescriptorProvider) {
|
|
12196
|
+
const lastIndexUsed = await provider.getLastIndexUsed();
|
|
12197
|
+
for (let i = 0; i <= (lastIndexUsed ?? -1); i++) {
|
|
12198
|
+
descriptors.add(provider.materializeDescriptorAt(i));
|
|
12199
|
+
}
|
|
12200
|
+
}
|
|
12201
|
+
for (const contract of await this.contractRepository.getContracts()) {
|
|
12202
|
+
const descriptor = contract.metadata?.signingDescriptor;
|
|
12203
|
+
if (typeof descriptor === "string" && descriptor.length > 0) {
|
|
12204
|
+
descriptors.add(descriptor);
|
|
12205
|
+
}
|
|
12206
|
+
}
|
|
12207
|
+
return [...descriptors].sort(
|
|
12208
|
+
(a, b) => signingDescriptorIndex(a) - signingDescriptorIndex(b)
|
|
12209
|
+
);
|
|
12210
|
+
}
|
|
12211
|
+
/**
|
|
12212
|
+
* @see HDWalletCapable.signerForDescriptor
|
|
12213
|
+
*/
|
|
12214
|
+
async signerForDescriptor(descriptor) {
|
|
12215
|
+
const provider = this._descriptorProvider;
|
|
12216
|
+
if (!(provider instanceof HDDescriptorProvider) || !provider.isOurs(descriptor)) {
|
|
12217
|
+
return this.identity;
|
|
12218
|
+
}
|
|
12219
|
+
return new DescriptorIdentity({ descriptor, signer: provider, base: this.identity });
|
|
12220
|
+
}
|
|
11977
12221
|
/**
|
|
11978
12222
|
* Mid-session server-signer rotation (plan §4). When arkd rotates its
|
|
11979
12223
|
* active signer mid-session — the case the long-lived service worker and
|
|
@@ -12006,7 +12250,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12006
12250
|
const xonly = toXOnlyPubKey(newServerPubKey);
|
|
12007
12251
|
let newServerUnrollScript;
|
|
12008
12252
|
try {
|
|
12009
|
-
newServerUnrollScript =
|
|
12253
|
+
newServerUnrollScript = chunkOWCPXRGP_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
|
|
12010
12254
|
} catch (e) {
|
|
12011
12255
|
throw new Error("Invalid checkpointTapscript from server");
|
|
12012
12256
|
}
|
|
@@ -12034,21 +12278,21 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12034
12278
|
const [currentBoardingRow] = await manager.getContracts({
|
|
12035
12279
|
script: currentBoardingScript
|
|
12036
12280
|
});
|
|
12037
|
-
const newOffchain = this.offchainTapscript instanceof
|
|
12281
|
+
const newOffchain = this.offchainTapscript instanceof chunkV2TOHHPW_cjs.DelegateVtxo.Script ? new chunkV2TOHHPW_cjs.DelegateVtxo.Script({
|
|
12038
12282
|
...this.offchainTapscript.options,
|
|
12039
12283
|
serverPubKey: xonly
|
|
12040
|
-
}) : new
|
|
12284
|
+
}) : new chunkV2TOHHPW_cjs.DefaultVtxo.Script({
|
|
12041
12285
|
...this.offchainTapscript.options,
|
|
12042
12286
|
serverPubKey: xonly
|
|
12043
12287
|
});
|
|
12044
|
-
const newBoarding = new
|
|
12288
|
+
const newBoarding = new chunkV2TOHHPW_cjs.DefaultVtxo.Script({
|
|
12045
12289
|
...this._boardingTapscript.options,
|
|
12046
12290
|
serverPubKey: xonly
|
|
12047
12291
|
});
|
|
12048
|
-
const offchainCsv =
|
|
12292
|
+
const offchainCsv = chunkOWCPXRGP_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
|
|
12049
12293
|
const newOffchainScript = base.hex.encode(newOffchain.pkScript);
|
|
12050
12294
|
const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
|
|
12051
|
-
if (newOffchain instanceof
|
|
12295
|
+
if (newOffchain instanceof chunkV2TOHHPW_cjs.DelegateVtxo.Script) {
|
|
12052
12296
|
await manager.createContract({
|
|
12053
12297
|
type: "delegate",
|
|
12054
12298
|
params: {
|
|
@@ -12076,13 +12320,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12076
12320
|
metadata: currentOffchainRow?.metadata
|
|
12077
12321
|
});
|
|
12078
12322
|
}
|
|
12079
|
-
const boardingCsv = newBoarding.options.csvTimelock ??
|
|
12323
|
+
const boardingCsv = newBoarding.options.csvTimelock ?? chunkV2TOHHPW_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
12080
12324
|
await manager.createContract({
|
|
12081
12325
|
type: "boarding",
|
|
12082
12326
|
params: {
|
|
12083
12327
|
pubKey: base.hex.encode(newBoarding.options.pubKey),
|
|
12084
12328
|
serverPubKey: base.hex.encode(xonly),
|
|
12085
|
-
csvTimelock:
|
|
12329
|
+
csvTimelock: chunkOWCPXRGP_cjs.timelockToSequence(boardingCsv).toString()
|
|
12086
12330
|
},
|
|
12087
12331
|
script: base.hex.encode(newBoarding.pkScript),
|
|
12088
12332
|
address: newBoarding.address(this.network.hrp, xonly).encode(),
|
|
@@ -12115,14 +12359,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12115
12359
|
_restoreInFlight;
|
|
12116
12360
|
_addPendingSpends(inputs) {
|
|
12117
12361
|
for (const input of inputs) {
|
|
12118
|
-
if (
|
|
12362
|
+
if (chunkOWCPXRGP_cjs.isVirtualCoin(input)) {
|
|
12119
12363
|
this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
|
|
12120
12364
|
}
|
|
12121
12365
|
}
|
|
12122
12366
|
}
|
|
12123
12367
|
_removePendingSpends(inputs) {
|
|
12124
12368
|
for (const input of inputs) {
|
|
12125
|
-
if (
|
|
12369
|
+
if (chunkOWCPXRGP_cjs.isVirtualCoin(input)) {
|
|
12126
12370
|
this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
|
|
12127
12371
|
}
|
|
12128
12372
|
}
|
|
@@ -12182,7 +12426,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12182
12426
|
const hd = provider instanceof HDDescriptorProvider;
|
|
12183
12427
|
const staticDescriptor = hd ? void 0 : `tr(${base.hex.encode(await this.identity.xOnlyPublicKey())})`;
|
|
12184
12428
|
const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
|
|
12185
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
12429
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkV2TOHHPW_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
12186
12430
|
const arkInfo = await this.arkProvider.getInfo();
|
|
12187
12431
|
const currentSignerPubKey = toXOnlyPubKey(base.hex.decode(arkInfo.signerPubkey));
|
|
12188
12432
|
const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
|
|
@@ -12201,7 +12445,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12201
12445
|
csvTimelocks: this.walletContractTimelocks,
|
|
12202
12446
|
// Boarding-exit CSV so the boarding handler can build its
|
|
12203
12447
|
// candidate script (distinct from the unilateral-exit matrix).
|
|
12204
|
-
boardingTimelock: this.boardingTapscript.options.csvTimelock ??
|
|
12448
|
+
boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkV2TOHHPW_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
|
|
12205
12449
|
delegatePubKey
|
|
12206
12450
|
};
|
|
12207
12451
|
const result = await manager.scanContracts({
|
|
@@ -12318,7 +12562,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12318
12562
|
let serverUnrollScript;
|
|
12319
12563
|
try {
|
|
12320
12564
|
const raw = base.hex.decode(setup.info.checkpointTapscript);
|
|
12321
|
-
serverUnrollScript =
|
|
12565
|
+
serverUnrollScript = chunkOWCPXRGP_cjs.CSVMultisigTapscript.decode(raw);
|
|
12322
12566
|
} catch (e) {
|
|
12323
12567
|
throw new Error("Invalid checkpointTapscript from server");
|
|
12324
12568
|
}
|
|
@@ -12456,7 +12700,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12456
12700
|
inputs: params.selectedVtxos,
|
|
12457
12701
|
changeAmount: BigInt(changeAmount)
|
|
12458
12702
|
};
|
|
12459
|
-
const outputAddress =
|
|
12703
|
+
const outputAddress = chunkOWCPXRGP_cjs.ArkAddress.decode(params.address);
|
|
12460
12704
|
const outputScript = BigInt(params.amount) < this.dustAmount ? outputAddress.subdustPkScript : outputAddress.pkScript;
|
|
12461
12705
|
const outputs = [
|
|
12462
12706
|
{
|
|
@@ -12509,13 +12753,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12509
12753
|
}
|
|
12510
12754
|
}
|
|
12511
12755
|
const offchainAddress = await this.getAddress();
|
|
12512
|
-
const offchainPkScript =
|
|
12756
|
+
const offchainPkScript = chunkOWCPXRGP_cjs.ArkAddress.decode(offchainAddress).pkScript;
|
|
12513
12757
|
const offchainOutputScript = base.hex.encode(offchainPkScript);
|
|
12514
12758
|
if (!params) {
|
|
12515
12759
|
const { fees, vtxoMaxAmount } = await this.arkProvider.getInfo();
|
|
12516
12760
|
const estimator = new Estimator(fees.intentFee);
|
|
12517
12761
|
let amount = 0;
|
|
12518
|
-
const exitScript =
|
|
12762
|
+
const exitScript = chunkOWCPXRGP_cjs.CSVMultisigTapscript.decode(
|
|
12519
12763
|
base.hex.decode(this.boardingTapscript.exitScript)
|
|
12520
12764
|
);
|
|
12521
12765
|
const boardingTimelock = exitScript.params.timelock;
|
|
@@ -12544,7 +12788,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12544
12788
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
12545
12789
|
break;
|
|
12546
12790
|
}
|
|
12547
|
-
const inputFee = estimator.evalOffchainInput(
|
|
12791
|
+
const inputFee = estimator.evalOffchainInput(chunkOWCPXRGP_cjs.toOffchainInputFeeParams(vtxo));
|
|
12548
12792
|
if (inputFee.satoshis >= vtxo.value) {
|
|
12549
12793
|
continue;
|
|
12550
12794
|
}
|
|
@@ -12589,7 +12833,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12589
12833
|
for (const [index, output] of params.outputs.entries()) {
|
|
12590
12834
|
let script;
|
|
12591
12835
|
try {
|
|
12592
|
-
const addr =
|
|
12836
|
+
const addr = chunkOWCPXRGP_cjs.ArkAddress.decode(output.address);
|
|
12593
12837
|
script = addr.pkScript;
|
|
12594
12838
|
hasOffchainOutputs = true;
|
|
12595
12839
|
} catch {
|
|
@@ -12775,7 +13019,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12775
13019
|
async maybeRotateBoardingAfterBoard(inputs) {
|
|
12776
13020
|
if (!this._descriptorProvider) return;
|
|
12777
13021
|
const consumedBoarding = inputs.some(
|
|
12778
|
-
(input) => typeof input !== "string" && !
|
|
13022
|
+
(input) => typeof input !== "string" && !chunkOWCPXRGP_cjs.isVirtualCoin(input)
|
|
12779
13023
|
);
|
|
12780
13024
|
if (!consumedBoarding) return;
|
|
12781
13025
|
try {
|
|
@@ -12784,14 +13028,22 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12784
13028
|
console.warn("Failed to rotate boarding address after board", e);
|
|
12785
13029
|
}
|
|
12786
13030
|
}
|
|
12787
|
-
async handleSettlementFinalizationEvent(event, inputs, forfeitOutputScript, connectorsGraph) {
|
|
13031
|
+
async handleSettlementFinalizationEvent(event, inputs, forfeitOutputScript, expectedRecipients, connectorsGraph, validatedCommitmentTxid) {
|
|
12788
13032
|
const signedForfeits = [];
|
|
12789
13033
|
let settlementPsbt = btcSigner.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
13034
|
+
assertFinalCommitmentMatchesValidated(
|
|
13035
|
+
settlementPsbt,
|
|
13036
|
+
validatedCommitmentTxid,
|
|
13037
|
+
"settlement finalization"
|
|
13038
|
+
);
|
|
13039
|
+
if (!validatedCommitmentTxid && expectedRecipients.length > 0) {
|
|
13040
|
+
validateBatchRecipientsWithoutTree(settlementPsbt, expectedRecipients, this.network);
|
|
13041
|
+
}
|
|
12790
13042
|
let hasBoardingUtxos = false;
|
|
12791
13043
|
let connectorIndex = 0;
|
|
12792
13044
|
const connectorsLeaves = connectorsGraph?.leaves() || [];
|
|
12793
13045
|
for (const input of inputs) {
|
|
12794
|
-
if (!
|
|
13046
|
+
if (!chunkOWCPXRGP_cjs.isVirtualCoin(input)) {
|
|
12795
13047
|
for (let i = 0; i < settlementPsbt.inputsLength; i++) {
|
|
12796
13048
|
const settlementInput = settlementPsbt.getInput(i);
|
|
12797
13049
|
if (!settlementInput.txid || settlementInput.index === void 0) {
|
|
@@ -12822,7 +13074,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12822
13074
|
}
|
|
12823
13075
|
continue;
|
|
12824
13076
|
}
|
|
12825
|
-
if (
|
|
13077
|
+
if (chunkOWCPXRGP_cjs.canRecoverOnchain(input, { timestamp: /* @__PURE__ */ new Date() }) || isSubdust({ value: input.value }, this.dustAmount)) {
|
|
12826
13078
|
continue;
|
|
12827
13079
|
}
|
|
12828
13080
|
if (connectorsLeaves.length === 0) {
|
|
@@ -12850,7 +13102,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12850
13102
|
index: input.vout,
|
|
12851
13103
|
witnessUtxo: {
|
|
12852
13104
|
amount: BigInt(input.value),
|
|
12853
|
-
script:
|
|
13105
|
+
script: chunkOWCPXRGP_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
12854
13106
|
},
|
|
12855
13107
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
12856
13108
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -12869,7 +13121,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12869
13121
|
forfeitTx = await this._signerRouter.sign(forfeitTx, [
|
|
12870
13122
|
{
|
|
12871
13123
|
index: 0,
|
|
12872
|
-
lookupScript:
|
|
13124
|
+
lookupScript: chunkOWCPXRGP_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
12873
13125
|
}
|
|
12874
13126
|
]);
|
|
12875
13127
|
signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
|
|
@@ -12909,6 +13161,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12909
13161
|
*/
|
|
12910
13162
|
createBatchHandler(intentId, inputs, expectedRecipients, session) {
|
|
12911
13163
|
let sweepTapTreeRoot;
|
|
13164
|
+
let validatedCommitmentTxid;
|
|
12912
13165
|
return {
|
|
12913
13166
|
onBatchStarted: async (event) => {
|
|
12914
13167
|
const utf8IntentId = new TextEncoder().encode(intentId);
|
|
@@ -12927,7 +13180,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12927
13180
|
if (skip) {
|
|
12928
13181
|
return { skip };
|
|
12929
13182
|
}
|
|
12930
|
-
const sweepTapscript =
|
|
13183
|
+
const sweepTapscript = chunkOWCPXRGP_cjs.CSVMultisigTapscript.encode({
|
|
12931
13184
|
timelock: {
|
|
12932
13185
|
value: event.batchExpiry,
|
|
12933
13186
|
type: event.batchExpiry >= 512n ? "seconds" : "blocks"
|
|
@@ -12966,6 +13219,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12966
13219
|
if (!sharedOutput?.amount) {
|
|
12967
13220
|
throw new Error("Shared output not found");
|
|
12968
13221
|
}
|
|
13222
|
+
validatedCommitmentTxid = commitmentTx.id;
|
|
12969
13223
|
await session.init(vtxoTree, sweepTapTreeRoot, sharedOutput.amount);
|
|
12970
13224
|
const pubkey = base.hex.encode(await session.getPublicKey());
|
|
12971
13225
|
const nonces = await session.getNonces();
|
|
@@ -12994,7 +13248,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
12994
13248
|
event,
|
|
12995
13249
|
inputs,
|
|
12996
13250
|
this.forfeitOutputScript,
|
|
12997
|
-
|
|
13251
|
+
expectedRecipients,
|
|
13252
|
+
connectorTree,
|
|
13253
|
+
validatedCommitmentTxid
|
|
12998
13254
|
);
|
|
12999
13255
|
}
|
|
13000
13256
|
};
|
|
@@ -13033,9 +13289,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13033
13289
|
...existing ?? {},
|
|
13034
13290
|
intentTxId,
|
|
13035
13291
|
registerProof: intent.proof,
|
|
13036
|
-
registerProofMessage:
|
|
13292
|
+
registerProofMessage: chunkOWCPXRGP_cjs.Intent.encodeMessage(intent.message),
|
|
13037
13293
|
deleteProof: deleteIntent.proof,
|
|
13038
|
-
deleteProofMessage:
|
|
13294
|
+
deleteProofMessage: chunkOWCPXRGP_cjs.Intent.encodeMessage(deleteIntent.message),
|
|
13039
13295
|
intentVtxos: inputs.map((i) => ({
|
|
13040
13296
|
txid: i.txid,
|
|
13041
13297
|
vout: i.vout
|
|
@@ -13067,7 +13323,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13067
13323
|
try {
|
|
13068
13324
|
return await this.arkProvider.registerIntent(intent);
|
|
13069
13325
|
} catch (error) {
|
|
13070
|
-
if (error instanceof
|
|
13326
|
+
if (error instanceof chunkOWCPXRGP_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
|
|
13071
13327
|
const deleteIntent = await this.makeDeleteIntentSignature(inputs);
|
|
13072
13328
|
await this.arkProvider.deleteIntent(deleteIntent);
|
|
13073
13329
|
return this.arkProvider.registerIntent(intent);
|
|
@@ -13083,7 +13339,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13083
13339
|
expire_at: 0,
|
|
13084
13340
|
cosigners_public_keys: cosignerPubKeys
|
|
13085
13341
|
};
|
|
13086
|
-
const proof =
|
|
13342
|
+
const proof = chunkOWCPXRGP_cjs.Intent.create(message, coins, outputs);
|
|
13087
13343
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
13088
13344
|
return {
|
|
13089
13345
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -13095,7 +13351,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13095
13351
|
type: "delete",
|
|
13096
13352
|
expire_at: 0
|
|
13097
13353
|
};
|
|
13098
|
-
const proof =
|
|
13354
|
+
const proof = chunkOWCPXRGP_cjs.Intent.create(message, coins, []);
|
|
13099
13355
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
13100
13356
|
return {
|
|
13101
13357
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -13107,7 +13363,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13107
13363
|
type: "get-pending-tx",
|
|
13108
13364
|
expire_at: 0
|
|
13109
13365
|
};
|
|
13110
|
-
const proof =
|
|
13366
|
+
const proof = chunkOWCPXRGP_cjs.Intent.create(message, coins, []);
|
|
13111
13367
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
13112
13368
|
return {
|
|
13113
13369
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -13128,7 +13384,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13128
13384
|
if (!vtxos || vtxos.length === 0) {
|
|
13129
13385
|
const scriptMap = await this.getScriptMap();
|
|
13130
13386
|
const allExtended = [];
|
|
13131
|
-
const fetchedVtxos = await
|
|
13387
|
+
const fetchedVtxos = await chunkOWCPXRGP_cjs.getAllNormalizedVtxos(this.indexerProvider, [
|
|
13132
13388
|
...scriptMap.keys()
|
|
13133
13389
|
]);
|
|
13134
13390
|
for (const vtxo of fetchedVtxos) {
|
|
@@ -13153,6 +13409,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13153
13409
|
for (let i = 0; i < vtxos.length; i += MAX_INPUTS_PER_INTENT) {
|
|
13154
13410
|
batches.push(vtxos.slice(i, i + MAX_INPUTS_PER_INTENT));
|
|
13155
13411
|
}
|
|
13412
|
+
const unrollCandidates = this.checkpointUnrollCandidates(await this.arkProvider.getInfo());
|
|
13413
|
+
const checkpointInputs = vtxos.map((vtxo) => ({
|
|
13414
|
+
...vtxo,
|
|
13415
|
+
tapLeafScript: vtxo.forfeitTapLeafScript
|
|
13416
|
+
}));
|
|
13156
13417
|
const seen = /* @__PURE__ */ new Set();
|
|
13157
13418
|
const results = await Promise.all(
|
|
13158
13419
|
batches.map(async (batch) => {
|
|
@@ -13168,6 +13429,12 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13168
13429
|
const checkpointTxs = pendingTx.signedCheckpointTxs.map(
|
|
13169
13430
|
(c) => btcSigner.Transaction.fromPSBT(base.base64.decode(c))
|
|
13170
13431
|
);
|
|
13432
|
+
assertCheckpointsMatchInputs(
|
|
13433
|
+
checkpointTxs,
|
|
13434
|
+
checkpointInputs,
|
|
13435
|
+
unrollCandidates,
|
|
13436
|
+
`pending tx ${pendingTx.arkTxid}`
|
|
13437
|
+
);
|
|
13171
13438
|
const checkpointJobs = checkpointTxs.map(
|
|
13172
13439
|
(tx) => this.inputSigningJobsFromWitnessUtxos(tx)
|
|
13173
13440
|
);
|
|
@@ -13223,6 +13490,32 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13223
13490
|
}
|
|
13224
13491
|
return { finalized, pending };
|
|
13225
13492
|
}
|
|
13493
|
+
/**
|
|
13494
|
+
* The server unroll scripts a pending checkpoint may legitimately have been
|
|
13495
|
+
* built under: this wallet's configured one, the server's current one, and
|
|
13496
|
+
* one per deprecated signer (same closure, deprecated key). A tx submitted
|
|
13497
|
+
* before a signer rotation was built under the old key, so rebuilding
|
|
13498
|
+
* against the current key alone would leave it pending forever.
|
|
13499
|
+
*/
|
|
13500
|
+
checkpointUnrollCandidates(info) {
|
|
13501
|
+
const current = chunkOWCPXRGP_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
13502
|
+
const candidates = [this._serverUnrollScript, current];
|
|
13503
|
+
for (const deprecated of signerSetFromInfo(info).deprecated.keys()) {
|
|
13504
|
+
candidates.push(
|
|
13505
|
+
chunkOWCPXRGP_cjs.CSVMultisigTapscript.encode({
|
|
13506
|
+
...current.params,
|
|
13507
|
+
pubkeys: [base.hex.decode(deprecated)]
|
|
13508
|
+
})
|
|
13509
|
+
);
|
|
13510
|
+
}
|
|
13511
|
+
const seen = /* @__PURE__ */ new Set();
|
|
13512
|
+
return candidates.filter((candidate) => {
|
|
13513
|
+
const script = base.hex.encode(candidate.script);
|
|
13514
|
+
if (seen.has(script)) return false;
|
|
13515
|
+
seen.add(script);
|
|
13516
|
+
return true;
|
|
13517
|
+
});
|
|
13518
|
+
}
|
|
13226
13519
|
async hasPendingTxFlag() {
|
|
13227
13520
|
const state = await this.walletRepository.getWalletState();
|
|
13228
13521
|
return state?.settings?.hasPendingTx === true;
|
|
@@ -13300,7 +13593,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13300
13593
|
if (vtxos.length === 0) {
|
|
13301
13594
|
throw new Error("No VTXOs found for this arkadeCash");
|
|
13302
13595
|
}
|
|
13303
|
-
const myPkScript =
|
|
13596
|
+
const myPkScript = chunkOWCPXRGP_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
|
|
13304
13597
|
let { spendable, unclaimed } = this.classifyCashVtxos(vtxos);
|
|
13305
13598
|
let swept = 0;
|
|
13306
13599
|
const drainable = vtxos.filter((vtxo) => !isSubdust(vtxo, this.dustAmount));
|
|
@@ -13327,7 +13620,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13327
13620
|
}
|
|
13328
13621
|
if (spendable.length > 0) {
|
|
13329
13622
|
const info = await this.arkProvider.getInfo();
|
|
13330
|
-
const serverUnrollScript =
|
|
13623
|
+
const serverUnrollScript = chunkOWCPXRGP_cjs.CSVMultisigTapscript.decode(
|
|
13331
13624
|
base.hex.decode(info.checkpointTapscript)
|
|
13332
13625
|
);
|
|
13333
13626
|
for (const vtxo of spendable) {
|
|
@@ -13373,7 +13666,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13373
13666
|
const spendable = [];
|
|
13374
13667
|
const unclaimed = [];
|
|
13375
13668
|
for (const vtxo of vtxos) {
|
|
13376
|
-
if (
|
|
13669
|
+
if (chunkOWCPXRGP_cjs.hasTerminalSpend(vtxo)) {
|
|
13377
13670
|
unclaimed.push(cashReport(vtxo, "already-spent"));
|
|
13378
13671
|
} else if (isSubdust(vtxo, this.dustAmount)) {
|
|
13379
13672
|
unclaimed.push(cashReport(vtxo, "subdust"));
|
|
@@ -13393,7 +13686,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13393
13686
|
const all = [];
|
|
13394
13687
|
const seen = /* @__PURE__ */ new Set();
|
|
13395
13688
|
for (let pageIndex = 0; ; pageIndex++) {
|
|
13396
|
-
const { vtxos, page } = await
|
|
13689
|
+
const { vtxos, page } = await chunkOWCPXRGP_cjs.getNormalizedVtxos(this.indexerProvider, {
|
|
13397
13690
|
scripts,
|
|
13398
13691
|
pageIndex,
|
|
13399
13692
|
pageSize
|
|
@@ -13440,7 +13733,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13440
13733
|
for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
|
|
13441
13734
|
const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
|
|
13442
13735
|
const message = { type: "get-pending-tx", expire_at: 0 };
|
|
13443
|
-
const proof =
|
|
13736
|
+
const proof = chunkOWCPXRGP_cjs.Intent.create(message, batch, []);
|
|
13444
13737
|
const signedProof = await identity.sign(
|
|
13445
13738
|
proof,
|
|
13446
13739
|
Array.from({ length: batch.length + 1 }, (_, j) => j)
|
|
@@ -13455,12 +13748,23 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13455
13748
|
pendingTxs.push(pendingTx);
|
|
13456
13749
|
}
|
|
13457
13750
|
}
|
|
13751
|
+
if (pendingTxs.length === 0) return result;
|
|
13458
13752
|
const myPkScriptHex = base.hex.encode(myPkScript);
|
|
13753
|
+
const unrollCandidates = this.checkpointUnrollCandidates(await this.arkProvider.getInfo());
|
|
13459
13754
|
for (const pendingTx of pendingTxs) {
|
|
13460
13755
|
try {
|
|
13461
13756
|
const checkpointTxs = pendingTx.signedCheckpointTxs.map(
|
|
13462
13757
|
(checkpoint) => btcSigner.Transaction.fromPSBT(base.base64.decode(checkpoint))
|
|
13463
13758
|
);
|
|
13759
|
+
assertCheckpointsMatchInputs(
|
|
13760
|
+
checkpointTxs,
|
|
13761
|
+
inputs.map((input) => ({
|
|
13762
|
+
...input,
|
|
13763
|
+
tapLeafScript: input.forfeitTapLeafScript
|
|
13764
|
+
})),
|
|
13765
|
+
unrollCandidates,
|
|
13766
|
+
`pending arkadeCash tx ${pendingTx.arkTxid}`
|
|
13767
|
+
);
|
|
13464
13768
|
const finalCheckpoints = await Promise.all(
|
|
13465
13769
|
checkpointTxs.map(
|
|
13466
13770
|
async (checkpoint) => base.base64.encode((await identity.sign(checkpoint)).toPSBT())
|
|
@@ -13735,10 +14039,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13735
14039
|
const serverPubKey = this.arkServerPublicKey;
|
|
13736
14040
|
const serverUnrollScript = this.serverUnrollScript;
|
|
13737
14041
|
const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
|
|
13738
|
-
const normalizedInputs = inputs.map(
|
|
13739
|
-
const at = now ?? await
|
|
14042
|
+
const normalizedInputs = inputs.map(chunkOWCPXRGP_cjs.normalizeVtxo);
|
|
14043
|
+
const at = now ?? await chunkOWCPXRGP_cjs.resolveTimeHeight(this.onchainProvider);
|
|
13740
14044
|
for (const input of normalizedInputs) {
|
|
13741
|
-
if (!
|
|
14045
|
+
if (!chunkOWCPXRGP_cjs.canSpendOffchain(input, at)) {
|
|
13742
14046
|
throw new Error(
|
|
13743
14047
|
`sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
|
|
13744
14048
|
);
|
|
@@ -13803,7 +14107,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13803
14107
|
);
|
|
13804
14108
|
const arkTxJobs = inputs.map((input, index) => ({
|
|
13805
14109
|
index,
|
|
13806
|
-
lookupScript:
|
|
14110
|
+
lookupScript: chunkOWCPXRGP_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
13807
14111
|
}));
|
|
13808
14112
|
const identity = this.identity;
|
|
13809
14113
|
const signer = {
|
|
@@ -13870,32 +14174,33 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13870
14174
|
`updateDbAfterOffchainTx: inputs length (${inputs.length}) differs from signedCheckpointTxs length (${signedCheckpointTxs.length})`
|
|
13871
14175
|
);
|
|
13872
14176
|
}
|
|
13873
|
-
const
|
|
14177
|
+
const checkpointIdByOutpoint = /* @__PURE__ */ new Map();
|
|
14178
|
+
for (const encoded of signedCheckpointTxs) {
|
|
14179
|
+
const checkpoint = btcSigner.Transaction.fromPSBT(base.base64.decode(encoded));
|
|
14180
|
+
for (let i = 0; i < checkpoint.inputsLength; i++) {
|
|
14181
|
+
const input = checkpoint.getInput(i);
|
|
14182
|
+
if (!input.txid) continue;
|
|
14183
|
+
checkpointIdByOutpoint.set(
|
|
14184
|
+
`${base.hex.encode(input.txid)}:${input.index}`,
|
|
14185
|
+
checkpoint.id
|
|
14186
|
+
);
|
|
14187
|
+
}
|
|
14188
|
+
}
|
|
13874
14189
|
const cm = await this.getContractManager();
|
|
13875
14190
|
const annotatedInputs = await cm.annotateVtxos(inputs);
|
|
13876
|
-
for (const
|
|
14191
|
+
for (const vtxo of annotatedInputs) {
|
|
13877
14192
|
const spentFacts = { ...vtxo, isSpent: true };
|
|
13878
|
-
|
|
13879
|
-
|
|
13880
|
-
|
|
13881
|
-
)
|
|
13882
|
-
|
|
13883
|
-
|
|
13884
|
-
|
|
13885
|
-
spentBy: checkpoint.id,
|
|
13886
|
-
arkTxId: arkTxid
|
|
13887
|
-
});
|
|
13888
|
-
} else {
|
|
13889
|
-
spentVtxos.push({
|
|
13890
|
-
...spentFacts,
|
|
13891
|
-
virtualStatus: chunkGMUVWKOK_cjs.toVirtualStatus(spentFacts),
|
|
13892
|
-
arkTxId: arkTxid
|
|
13893
|
-
});
|
|
13894
|
-
}
|
|
14193
|
+
const spentBy = checkpointIdByOutpoint.get(`${vtxo.txid}:${vtxo.vout}`);
|
|
14194
|
+
spentVtxos.push({
|
|
14195
|
+
...spentFacts,
|
|
14196
|
+
virtualStatus: chunkOWCPXRGP_cjs.toVirtualStatus(spentFacts),
|
|
14197
|
+
...spentBy ? { spentBy } : {},
|
|
14198
|
+
arkTxId: arkTxid
|
|
14199
|
+
});
|
|
13895
14200
|
for (const id of vtxo.commitmentTxIds) {
|
|
13896
14201
|
commitmentTxIds.add(id);
|
|
13897
14202
|
}
|
|
13898
|
-
const vtxoExpiry =
|
|
14203
|
+
const vtxoExpiry = chunkOWCPXRGP_cjs.toBatchExpiry(vtxo);
|
|
13899
14204
|
if (vtxoExpiry) {
|
|
13900
14205
|
batchExpiry = Math.min(batchExpiry, vtxoExpiry);
|
|
13901
14206
|
}
|
|
@@ -13908,7 +14213,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13908
14213
|
isSwept: false,
|
|
13909
14214
|
isPreconfirmed: true,
|
|
13910
14215
|
commitmentTxIds: Array.from(commitmentTxIds),
|
|
13911
|
-
...
|
|
14216
|
+
...chunkOWCPXRGP_cjs.parseLegacyExpiry(batchExpiry)
|
|
13912
14217
|
};
|
|
13913
14218
|
changeVtxo = {
|
|
13914
14219
|
txid: arkTxid,
|
|
@@ -13920,7 +14225,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13920
14225
|
tapTree: offchainTapscript.encode(),
|
|
13921
14226
|
value: Number(changeAmount),
|
|
13922
14227
|
...changeFacts,
|
|
13923
|
-
virtualStatus:
|
|
14228
|
+
virtualStatus: chunkOWCPXRGP_cjs.toVirtualStatus(changeFacts),
|
|
13924
14229
|
spentBy: "",
|
|
13925
14230
|
status: {
|
|
13926
14231
|
confirmed: false
|
|
@@ -13989,12 +14294,12 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
13989
14294
|
const spentVtxos = [];
|
|
13990
14295
|
const inputArkTxIds = /* @__PURE__ */ new Set();
|
|
13991
14296
|
const boardingRemovalsByAddress = /* @__PURE__ */ new Map();
|
|
13992
|
-
const vtxoInputs = inputs.filter(
|
|
14297
|
+
const vtxoInputs = inputs.filter(chunkOWCPXRGP_cjs.isVirtualCoin);
|
|
13993
14298
|
const cm = await this.getContractManager();
|
|
13994
14299
|
const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
|
|
13995
14300
|
const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
|
|
13996
14301
|
for (const input of inputs) {
|
|
13997
|
-
if (
|
|
14302
|
+
if (chunkOWCPXRGP_cjs.isVirtualCoin(input)) {
|
|
13998
14303
|
const outpoint = `${input.txid}:${input.vout}`;
|
|
13999
14304
|
const vtxo = annotatedByKey.get(outpoint);
|
|
14000
14305
|
if (!vtxo) {
|
|
@@ -14006,13 +14311,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14006
14311
|
const settledFacts = { ...vtxo, isSpent: true };
|
|
14007
14312
|
spentVtxos.push({
|
|
14008
14313
|
...settledFacts,
|
|
14009
|
-
virtualStatus:
|
|
14314
|
+
virtualStatus: chunkOWCPXRGP_cjs.toVirtualStatus(settledFacts),
|
|
14010
14315
|
settledBy: commitmentTxid
|
|
14011
14316
|
});
|
|
14012
14317
|
} else {
|
|
14013
14318
|
let sourceAddress;
|
|
14014
14319
|
try {
|
|
14015
|
-
sourceAddress =
|
|
14320
|
+
sourceAddress = chunkOWCPXRGP_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
|
|
14016
14321
|
this.network
|
|
14017
14322
|
);
|
|
14018
14323
|
} catch {
|
|
@@ -14070,9 +14375,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
14070
14375
|
}
|
|
14071
14376
|
};
|
|
14072
14377
|
function selectVirtualCoins(coins, targetAmount) {
|
|
14073
|
-
const sortedCoins = coins.map(
|
|
14074
|
-
const expiryA =
|
|
14075
|
-
const expiryB =
|
|
14378
|
+
const sortedCoins = coins.map(chunkOWCPXRGP_cjs.normalizeVtxo).sort((a, b) => {
|
|
14379
|
+
const expiryA = chunkOWCPXRGP_cjs.toBatchExpiry(a) || Number.MAX_SAFE_INTEGER;
|
|
14380
|
+
const expiryB = chunkOWCPXRGP_cjs.toBatchExpiry(b) || Number.MAX_SAFE_INTEGER;
|
|
14076
14381
|
if (expiryA !== expiryB) {
|
|
14077
14382
|
return expiryA - expiryB;
|
|
14078
14383
|
}
|
|
@@ -14329,7 +14634,7 @@ var MessageBus = class {
|
|
|
14329
14634
|
this.initialized = true;
|
|
14330
14635
|
}
|
|
14331
14636
|
async buildServices(config) {
|
|
14332
|
-
const arkProvider = new
|
|
14637
|
+
const arkProvider = new chunkOWCPXRGP_cjs.RestArkProvider(config.arkServer.url);
|
|
14333
14638
|
const storage = {
|
|
14334
14639
|
walletRepository: this.walletRepository,
|
|
14335
14640
|
contractRepository: this.contractRepository
|
|
@@ -14668,7 +14973,7 @@ var offboardNetworkNames = [
|
|
|
14668
14973
|
function offboardDestinationScript(destinationAddress) {
|
|
14669
14974
|
for (const networkName of offboardNetworkNames) {
|
|
14670
14975
|
try {
|
|
14671
|
-
const network =
|
|
14976
|
+
const network = chunkOWCPXRGP_cjs.networks[networkName];
|
|
14672
14977
|
const addr = btcSigner.Address(network).decode(destinationAddress);
|
|
14673
14978
|
return btcSigner.OutScript.encode(addr);
|
|
14674
14979
|
} catch {
|
|
@@ -14732,7 +15037,7 @@ var Ramps = class {
|
|
|
14732
15037
|
}
|
|
14733
15038
|
amount = amount ?? totalAmount;
|
|
14734
15039
|
const offchainAddress = await this.wallet.getAddress();
|
|
14735
|
-
const offchainAddr =
|
|
15040
|
+
const offchainAddr = chunkOWCPXRGP_cjs.ArkAddress.decode(offchainAddress);
|
|
14736
15041
|
const offchainScript = base.hex.encode(offchainAddr.pkScript);
|
|
14737
15042
|
const outputFee = estimator.evalOffchainOutput({
|
|
14738
15043
|
amount,
|
|
@@ -14792,7 +15097,7 @@ var Ramps = class {
|
|
|
14792
15097
|
const filteredVtxos = [];
|
|
14793
15098
|
let totalAmount = 0n;
|
|
14794
15099
|
for (const vtxo of vtxos) {
|
|
14795
|
-
const inputFee = estimator.evalOffchainInput(
|
|
15100
|
+
const inputFee = estimator.evalOffchainInput(chunkOWCPXRGP_cjs.toOffchainInputFeeParams(vtxo));
|
|
14796
15101
|
if (inputFee.satoshis >= vtxo.value) {
|
|
14797
15102
|
continue;
|
|
14798
15103
|
}
|
|
@@ -15489,7 +15794,7 @@ var WalletMessageHandler = class {
|
|
|
15489
15794
|
// Wallet methods
|
|
15490
15795
|
async handleInitWallet({ payload }) {
|
|
15491
15796
|
const { arkServerUrl } = payload;
|
|
15492
|
-
this.indexerProvider = new
|
|
15797
|
+
this.indexerProvider = new chunkG7DOBFQN_cjs.RestIndexerProvider(arkServerUrl);
|
|
15493
15798
|
await this.onWalletInitialized();
|
|
15494
15799
|
}
|
|
15495
15800
|
async handleGetBalance() {
|
|
@@ -15513,12 +15818,12 @@ var WalletMessageHandler = class {
|
|
|
15513
15818
|
let recoverable = 0;
|
|
15514
15819
|
let pendingRecovery = 0;
|
|
15515
15820
|
for (const vtxo of allVtxos) {
|
|
15516
|
-
if (
|
|
15821
|
+
if (chunkOWCPXRGP_cjs.hasTerminalSpend(vtxo)) continue;
|
|
15517
15822
|
if (pendingOutpoints.has(`${vtxo.txid}:${vtxo.vout}`)) {
|
|
15518
15823
|
pendingRecovery += vtxo.value;
|
|
15519
|
-
} else if (
|
|
15824
|
+
} else if (chunkOWCPXRGP_cjs.canRecoverOnchain(vtxo, now)) {
|
|
15520
15825
|
recoverable += vtxo.value;
|
|
15521
|
-
} else if (
|
|
15826
|
+
} else if (chunkOWCPXRGP_cjs.canSpendOffchain(vtxo, now)) {
|
|
15522
15827
|
if (vtxo.isPreconfirmed) {
|
|
15523
15828
|
preconfirmed += vtxo.value;
|
|
15524
15829
|
} else {
|
|
@@ -15530,7 +15835,7 @@ var WalletMessageHandler = class {
|
|
|
15530
15835
|
const totalOffchain = settled + preconfirmed + recoverable + pendingRecovery;
|
|
15531
15836
|
const assetBalances = /* @__PURE__ */ new Map();
|
|
15532
15837
|
for (const vtxo of allVtxos) {
|
|
15533
|
-
if (
|
|
15838
|
+
if (chunkOWCPXRGP_cjs.hasTerminalSpend(vtxo)) continue;
|
|
15534
15839
|
if (vtxo.assets) {
|
|
15535
15840
|
for (const a of vtxo.assets) {
|
|
15536
15841
|
const current = assetBalances.get(a.assetId) ?? 0n;
|
|
@@ -15566,7 +15871,7 @@ var WalletMessageHandler = class {
|
|
|
15566
15871
|
*/
|
|
15567
15872
|
async getSpendableVtxos() {
|
|
15568
15873
|
const vtxos = await this.getVtxosFromRepo();
|
|
15569
|
-
return vtxos.filter((v) => !
|
|
15874
|
+
return vtxos.filter((v) => !chunkOWCPXRGP_cjs.hasTerminalSpend(v));
|
|
15570
15875
|
}
|
|
15571
15876
|
async onWalletInitialized() {
|
|
15572
15877
|
if (!this.readonlyWallet || !this.arkProvider || !this.indexerProvider || !this.walletRepository) {
|
|
@@ -15778,10 +16083,10 @@ var WalletMessageHandler = class {
|
|
|
15778
16083
|
if (dustAmount != null && isSubdust(v, dustAmount)) {
|
|
15779
16084
|
return false;
|
|
15780
16085
|
}
|
|
15781
|
-
if (
|
|
16086
|
+
if (chunkOWCPXRGP_cjs.isRecoverable(v)) {
|
|
15782
16087
|
return false;
|
|
15783
16088
|
}
|
|
15784
|
-
if (
|
|
16089
|
+
if (chunkOWCPXRGP_cjs.isExpired(v)) {
|
|
15785
16090
|
return false;
|
|
15786
16091
|
}
|
|
15787
16092
|
return true;
|
|
@@ -15853,7 +16158,7 @@ var WalletMessageHandler = class {
|
|
|
15853
16158
|
if (!this.readonlyWallet) return null;
|
|
15854
16159
|
const { boardingTxs, commitmentsToIgnore } = await this.readonlyWallet.getBoardingTxs();
|
|
15855
16160
|
const indexerProvider = this.indexerProvider;
|
|
15856
|
-
const resolveTxCreatedAt = indexerProvider ? (txids) =>
|
|
16161
|
+
const resolveTxCreatedAt = indexerProvider ? (txids) => chunkOWCPXRGP_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
|
|
15857
16162
|
return buildTransactionHistory(vtxos, boardingTxs, commitmentsToIgnore, resolveTxCreatedAt);
|
|
15858
16163
|
}
|
|
15859
16164
|
async ensureContractEventBroadcasting() {
|
|
@@ -16538,7 +16843,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
16538
16843
|
};
|
|
16539
16844
|
try {
|
|
16540
16845
|
const response = await this.sendMessage(message);
|
|
16541
|
-
return response.payload.vtxos.map(
|
|
16846
|
+
return response.payload.vtxos.map(chunkOWCPXRGP_cjs.normalizeVtxo);
|
|
16542
16847
|
} catch (error) {
|
|
16543
16848
|
throw new Error(`Failed to get vtxos: ${error}`);
|
|
16544
16849
|
}
|
|
@@ -16651,7 +16956,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
16651
16956
|
};
|
|
16652
16957
|
try {
|
|
16653
16958
|
const response = await sendContractMessage(message);
|
|
16654
|
-
return response.payload.vtxos.map(
|
|
16959
|
+
return response.payload.vtxos.map(chunkOWCPXRGP_cjs.normalizeVtxo);
|
|
16655
16960
|
} catch (e) {
|
|
16656
16961
|
throw new Error("Failed to annotate vtxos");
|
|
16657
16962
|
}
|
|
@@ -17105,7 +17410,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
17105
17410
|
};
|
|
17106
17411
|
try {
|
|
17107
17412
|
const response = await wallet.sendMessage(message);
|
|
17108
|
-
return response.payload.vtxos.map(
|
|
17413
|
+
return response.payload.vtxos.map(chunkOWCPXRGP_cjs.normalizeVtxo);
|
|
17109
17414
|
} catch (e) {
|
|
17110
17415
|
throw new Error(`Failed to get expiring vtxos: ${e}`);
|
|
17111
17416
|
}
|
|
@@ -17217,12 +17522,12 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
17217
17522
|
* @returns Configured onchain wallet
|
|
17218
17523
|
* @throws Error if the configured identity cannot produce a valid x-only public key
|
|
17219
17524
|
*/
|
|
17220
|
-
static async create(identity, networkName =
|
|
17525
|
+
static async create(identity, networkName = chunkOWCPXRGP_cjs.DEFAULT_NETWORK_NAME, provider) {
|
|
17221
17526
|
const pubkey = await identity.xOnlyPublicKey();
|
|
17222
17527
|
if (!pubkey) {
|
|
17223
17528
|
throw new Error("Invalid configured public key");
|
|
17224
17529
|
}
|
|
17225
|
-
const network =
|
|
17530
|
+
const network = chunkOWCPXRGP_cjs.getNetwork(networkName);
|
|
17226
17531
|
const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
|
|
17227
17532
|
const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
|
|
17228
17533
|
return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
|
|
@@ -17328,7 +17633,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
17328
17633
|
if (!inputs) {
|
|
17329
17634
|
throw new Error("Fee estimation failed");
|
|
17330
17635
|
}
|
|
17331
|
-
let tx = new
|
|
17636
|
+
let tx = new chunkOWCPXRGP_cjs.Transaction();
|
|
17332
17637
|
for (const input of inputs) {
|
|
17333
17638
|
tx.addInput({
|
|
17334
17639
|
txid: input.txid,
|
|
@@ -17386,7 +17691,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
17386
17691
|
* @throws If the parent has no anchor, or funding cannot be selected/signed
|
|
17387
17692
|
*/
|
|
17388
17693
|
async bumpAnchor(parentHex, feeRate) {
|
|
17389
|
-
const parent =
|
|
17694
|
+
const parent = chunkOWCPXRGP_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
|
|
17390
17695
|
const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
|
|
17391
17696
|
const child = await this.buildBumpPackage(parent, feeRate, coins);
|
|
17392
17697
|
return [parent.hex, child.hex];
|
|
@@ -18151,7 +18456,7 @@ exports.BIP322 = void 0;
|
|
|
18151
18456
|
async function sign2(message, identity, network) {
|
|
18152
18457
|
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
18153
18458
|
const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
|
|
18154
|
-
const toSpend =
|
|
18459
|
+
const toSpend = chunkOWCPXRGP_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
18155
18460
|
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
18156
18461
|
const signed = await identity.sign(toSign, [0]);
|
|
18157
18462
|
signed.finalizeIdx(0);
|
|
@@ -18209,7 +18514,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
|
18209
18514
|
if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
|
|
18210
18515
|
return false;
|
|
18211
18516
|
}
|
|
18212
|
-
const toSpend =
|
|
18517
|
+
const toSpend = chunkOWCPXRGP_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
18213
18518
|
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
|
|
18214
18519
|
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
18215
18520
|
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
@@ -18230,7 +18535,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
|
18230
18535
|
}
|
|
18231
18536
|
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
18232
18537
|
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
18233
|
-
const toSpend =
|
|
18538
|
+
const toSpend = chunkOWCPXRGP_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
18234
18539
|
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
18235
18540
|
const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
|
|
18236
18541
|
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
@@ -18283,7 +18588,7 @@ function encodeCompactSize(n) {
|
|
|
18283
18588
|
return buf;
|
|
18284
18589
|
}
|
|
18285
18590
|
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
18286
|
-
const tx = new
|
|
18591
|
+
const tx = new chunkOWCPXRGP_cjs.Transaction({ version: 0 });
|
|
18287
18592
|
tx.addInput({
|
|
18288
18593
|
txid: toSpend.id,
|
|
18289
18594
|
index: 0,
|
|
@@ -18297,12 +18602,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
|
18297
18602
|
});
|
|
18298
18603
|
tx.addOutput({
|
|
18299
18604
|
amount: 0n,
|
|
18300
|
-
script:
|
|
18605
|
+
script: chunkOWCPXRGP_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
18301
18606
|
});
|
|
18302
18607
|
return tx;
|
|
18303
18608
|
}
|
|
18304
18609
|
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
18305
|
-
const tx = new
|
|
18610
|
+
const tx = new chunkOWCPXRGP_cjs.Transaction({ version: 0 });
|
|
18306
18611
|
tx.addInput({
|
|
18307
18612
|
txid: toSpend.id,
|
|
18308
18613
|
index: 0,
|
|
@@ -18314,7 +18619,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
|
18314
18619
|
});
|
|
18315
18620
|
tx.addOutput({
|
|
18316
18621
|
amount: 0n,
|
|
18317
|
-
script:
|
|
18622
|
+
script: chunkOWCPXRGP_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
18318
18623
|
});
|
|
18319
18624
|
return tx;
|
|
18320
18625
|
}
|
|
@@ -18445,7 +18750,7 @@ var RestEmulatorProvider = class {
|
|
|
18445
18750
|
}
|
|
18446
18751
|
};
|
|
18447
18752
|
function finalizeVirtualTx(type, psbtBase64) {
|
|
18448
|
-
const tx =
|
|
18753
|
+
const tx = chunkOWCPXRGP_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
18449
18754
|
if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
|
|
18450
18755
|
const input = tx.getInput(0);
|
|
18451
18756
|
if (!input) {
|
|
@@ -18472,14 +18777,14 @@ var ExitPathError = class extends Error {
|
|
|
18472
18777
|
reason;
|
|
18473
18778
|
};
|
|
18474
18779
|
function delayWeight(sequence) {
|
|
18475
|
-
const t =
|
|
18780
|
+
const t = chunkOWCPXRGP_cjs.sequenceToTimelock(sequence);
|
|
18476
18781
|
return t.type === "blocks" ? Number(t.value) : Number(t.value) / 600;
|
|
18477
18782
|
}
|
|
18478
18783
|
async function resolveUnilateralPath(params) {
|
|
18479
18784
|
const { vtxo, scriptHex, contractRepository } = params;
|
|
18480
18785
|
const contract = contractRepository ? (await contractRepository.getContracts({ script: scriptHex }))[0] : void 0;
|
|
18481
18786
|
if (contract) {
|
|
18482
|
-
const handler =
|
|
18787
|
+
const handler = chunkV2TOHHPW_cjs.contractHandlers.get(contract.type);
|
|
18483
18788
|
if (!handler) {
|
|
18484
18789
|
throw new ExitPathError(
|
|
18485
18790
|
"no-handler",
|
|
@@ -18502,12 +18807,12 @@ async function resolveUnilateralPath(params) {
|
|
|
18502
18807
|
paths.sort((a, b) => delayWeight(a.sequence) - delayWeight(b.sequence));
|
|
18503
18808
|
return { selection: paths[0], label: `${contract.type}:unilateral` };
|
|
18504
18809
|
}
|
|
18505
|
-
const decoded =
|
|
18810
|
+
const decoded = chunkOWCPXRGP_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
18506
18811
|
let best;
|
|
18507
18812
|
for (const exit of decoded.exitPaths()) {
|
|
18508
18813
|
const leaf = decoded.findLeaf(base.hex.encode(exit.script));
|
|
18509
18814
|
if (!leaf) continue;
|
|
18510
|
-
const sequence =
|
|
18815
|
+
const sequence = chunkOWCPXRGP_cjs.timelockToSequence(exit.params.timelock);
|
|
18511
18816
|
const weight = delayWeight(sequence);
|
|
18512
18817
|
if (!best || weight < best.weight) {
|
|
18513
18818
|
best = { selection: { leaf, sequence }, weight };
|
|
@@ -18693,14 +18998,14 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
18693
18998
|
}
|
|
18694
18999
|
const resolved = await resolveUnilateralPath({
|
|
18695
19000
|
vtxo,
|
|
18696
|
-
scriptHex: base.hex.encode(
|
|
19001
|
+
scriptHex: base.hex.encode(chunkOWCPXRGP_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
18697
19002
|
contractRepository: wallet.contractRepository,
|
|
18698
19003
|
walletPubKeyHex: base.hex.encode(await wallet.identity.xOnlyPublicKey()),
|
|
18699
19004
|
currentTime: Date.now()
|
|
18700
19005
|
});
|
|
18701
19006
|
const spendingLeaf = resolved.selection.leaf;
|
|
18702
19007
|
const sequence = resolved.selection.sequence;
|
|
18703
|
-
const timelock =
|
|
19008
|
+
const timelock = chunkOWCPXRGP_cjs.sequenceToTimelock(sequence);
|
|
18704
19009
|
const elapsed = timelock.type === "blocks" ? chainTip.height >= txStatus.blockHeight + Number(timelock.value) : chainTip.time >= txStatus.blockTime + Number(timelock.value);
|
|
18705
19010
|
if (!elapsed) {
|
|
18706
19011
|
throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
|
|
@@ -18713,7 +19018,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
18713
19018
|
sequence,
|
|
18714
19019
|
witnessUtxo: {
|
|
18715
19020
|
amount: BigInt(vtxo.value),
|
|
18716
|
-
script:
|
|
19021
|
+
script: chunkOWCPXRGP_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
|
|
18717
19022
|
},
|
|
18718
19023
|
sighashType: btcSigner.SigHash.DEFAULT
|
|
18719
19024
|
});
|
|
@@ -18723,7 +19028,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
18723
19028
|
btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
|
|
18724
19029
|
);
|
|
18725
19030
|
}
|
|
18726
|
-
const tx = new
|
|
19031
|
+
const tx = new chunkOWCPXRGP_cjs.Transaction({ version: 2 });
|
|
18727
19032
|
for (const input of inputs) {
|
|
18728
19033
|
tx.addInput(input);
|
|
18729
19034
|
}
|
|
@@ -18790,7 +19095,7 @@ async function buildSignedSweep(params) {
|
|
|
18790
19095
|
`uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
|
|
18791
19096
|
);
|
|
18792
19097
|
}
|
|
18793
|
-
const tx = new
|
|
19098
|
+
const tx = new chunkOWCPXRGP_cjs.Transaction({ version: 2 });
|
|
18794
19099
|
tx.addInput({
|
|
18795
19100
|
txid: vtxo.txid,
|
|
18796
19101
|
index: vtxo.vout,
|
|
@@ -18815,7 +19120,7 @@ async function buildSignedSweep(params) {
|
|
|
18815
19120
|
finalScriptWitness: [
|
|
18816
19121
|
tapScriptSig[0][1],
|
|
18817
19122
|
...path.extraWitness,
|
|
18818
|
-
|
|
19123
|
+
chunkOWCPXRGP_cjs.scriptFromTapLeafScript(path.leaf),
|
|
18819
19124
|
btcSigner.TaprootControlBlock.encode(controlBlock)
|
|
18820
19125
|
]
|
|
18821
19126
|
});
|
|
@@ -18845,7 +19150,7 @@ async function resolveFeeRate(opts) {
|
|
|
18845
19150
|
}
|
|
18846
19151
|
async function selectExitVtxos(opts) {
|
|
18847
19152
|
if (!opts.vtxos) return opts.wallet.getVtxos();
|
|
18848
|
-
const res = await
|
|
19153
|
+
const res = await chunkOWCPXRGP_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
|
|
18849
19154
|
const tapTrees = /* @__PURE__ */ new Map();
|
|
18850
19155
|
const out = [];
|
|
18851
19156
|
for (const vtxo of res.vtxos) {
|
|
@@ -18860,7 +19165,7 @@ async function selectExitVtxos(opts) {
|
|
|
18860
19165
|
`no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
|
|
18861
19166
|
);
|
|
18862
19167
|
}
|
|
18863
|
-
const handler =
|
|
19168
|
+
const handler = chunkV2TOHHPW_cjs.contractHandlers.get(contract.type);
|
|
18864
19169
|
if (!handler) {
|
|
18865
19170
|
throw new Error(`no contract handler registered for type '${contract.type}'`);
|
|
18866
19171
|
}
|
|
@@ -18890,7 +19195,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
18890
19195
|
if (pendingNodes.length > 0) {
|
|
18891
19196
|
const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
|
|
18892
19197
|
for (const psbt of txs) {
|
|
18893
|
-
psbts.set(
|
|
19198
|
+
psbts.set(chunkOWCPXRGP_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
18894
19199
|
}
|
|
18895
19200
|
}
|
|
18896
19201
|
const childVsize = Number(
|
|
@@ -18926,7 +19231,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
18926
19231
|
try {
|
|
18927
19232
|
const resolved = await resolveUnilateralPath({
|
|
18928
19233
|
vtxo,
|
|
18929
|
-
scriptHex: base.hex.encode(
|
|
19234
|
+
scriptHex: base.hex.encode(chunkOWCPXRGP_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
18930
19235
|
contractRepository: wallet.contractRepository,
|
|
18931
19236
|
walletPubKeyHex,
|
|
18932
19237
|
currentTime: Date.now()
|
|
@@ -18945,7 +19250,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
18945
19250
|
});
|
|
18946
19251
|
continue;
|
|
18947
19252
|
}
|
|
18948
|
-
const t =
|
|
19253
|
+
const t = chunkOWCPXRGP_cjs.sequenceToTimelock(resolved.selection.sequence);
|
|
18949
19254
|
const delay = { type: t.type, value: Number(t.value) };
|
|
18950
19255
|
infos.push({ outpoint, value: vtxo.value, sweepFee, path: resolved.label, delay });
|
|
18951
19256
|
sweeps.push({ vtxo, resolved, sweepFee, delay });
|
|
@@ -19284,7 +19589,7 @@ async function prepare(opts) {
|
|
|
19284
19589
|
txid: sweep.vtxo.txid,
|
|
19285
19590
|
vout: sweep.vtxo.vout,
|
|
19286
19591
|
value: sweep.vtxo.value,
|
|
19287
|
-
pkScript:
|
|
19592
|
+
pkScript: chunkOWCPXRGP_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
|
|
19288
19593
|
},
|
|
19289
19594
|
path: sweep.resolved.selection,
|
|
19290
19595
|
outputAddress: opts.sweepAddress,
|
|
@@ -19369,7 +19674,7 @@ async function prepare(opts) {
|
|
|
19369
19674
|
if (newFee <= splitterFee) break;
|
|
19370
19675
|
splitterFee = newFee;
|
|
19371
19676
|
}
|
|
19372
|
-
const splitter = new
|
|
19677
|
+
const splitter = new chunkOWCPXRGP_cjs.Transaction({ version: 2 });
|
|
19373
19678
|
for (const coin of selected.inputs) {
|
|
19374
19679
|
splitter.addInput({
|
|
19375
19680
|
txid: coin.txid,
|
|
@@ -19512,44 +19817,45 @@ var UnilateralExit = {
|
|
|
19512
19817
|
// src/arkade/index.ts
|
|
19513
19818
|
var arkade_exports = {};
|
|
19514
19819
|
chunk5BLDMQED_cjs.__export(arkade_exports, {
|
|
19515
|
-
ARKADE_OP: () =>
|
|
19516
|
-
ARKADE_OPCODES: () =>
|
|
19517
|
-
ARKADE_OPCODE_NAMES: () =>
|
|
19518
|
-
ARKADE_OPCODE_VALUES: () =>
|
|
19519
|
-
ARKADE_OPS: () =>
|
|
19820
|
+
ARKADE_OP: () => chunkV2TOHHPW_cjs.ARKADE_OP,
|
|
19821
|
+
ARKADE_OPCODES: () => chunkV2TOHHPW_cjs.ARKADE_OPCODES,
|
|
19822
|
+
ARKADE_OPCODE_NAMES: () => chunkV2TOHHPW_cjs.ARKADE_OPCODE_NAMES,
|
|
19823
|
+
ARKADE_OPCODE_VALUES: () => chunkV2TOHHPW_cjs.ARKADE_OPCODE_VALUES,
|
|
19824
|
+
ARKADE_OPS: () => chunkV2TOHHPW_cjs.ARKADE_OPS,
|
|
19520
19825
|
Arkade: () => Arkade,
|
|
19521
19826
|
ArkadeContract: () => ArkadeContract,
|
|
19522
|
-
ArkadeProgramScript: () =>
|
|
19523
|
-
ArkadeScript: () =>
|
|
19827
|
+
ArkadeProgramScript: () => chunkV2TOHHPW_cjs.ArkadeProgramScript,
|
|
19828
|
+
ArkadeScript: () => chunkV2TOHHPW_cjs.ArkadeScript,
|
|
19524
19829
|
ArkadeTransactionBuilder: () => ArkadeTransactionBuilder,
|
|
19525
|
-
BigNum: () =>
|
|
19830
|
+
BigNum: () => chunkV2TOHHPW_cjs.bignum_exports,
|
|
19526
19831
|
OP: () => btcSigner.OP,
|
|
19527
|
-
OPCODE_NAMES: () =>
|
|
19528
|
-
OPCODE_VALUES: () =>
|
|
19529
|
-
SUPPORTED_PROGRAM_VERSION: () =>
|
|
19832
|
+
OPCODE_NAMES: () => chunkV2TOHHPW_cjs.OPCODE_NAMES,
|
|
19833
|
+
OPCODE_VALUES: () => chunkV2TOHHPW_cjs.OPCODE_VALUES,
|
|
19834
|
+
SUPPORTED_PROGRAM_VERSION: () => chunkV2TOHHPW_cjs.SUPPORTED_PROGRAM_VERSION,
|
|
19530
19835
|
Script: () => btcSigner.Script,
|
|
19531
|
-
arkadeScriptHash: () =>
|
|
19532
|
-
arkadeWitnessHash: () =>
|
|
19533
|
-
asmToBytes: () =>
|
|
19534
|
-
bytesToASM: () =>
|
|
19535
|
-
computeArkadeScriptPublicKey: () =>
|
|
19836
|
+
arkadeScriptHash: () => chunkV2TOHHPW_cjs.arkadeScriptHash,
|
|
19837
|
+
arkadeWitnessHash: () => chunkV2TOHHPW_cjs.arkadeWitnessHash,
|
|
19838
|
+
asmToBytes: () => chunkV2TOHHPW_cjs.asmToBytes,
|
|
19839
|
+
bytesToASM: () => chunkV2TOHHPW_cjs.bytesToASM,
|
|
19840
|
+
computeArkadeScriptPublicKey: () => chunkV2TOHHPW_cjs.computeArkadeScriptPublicKey,
|
|
19536
19841
|
createArkadeBatchHandler: () => createArkadeBatchHandler,
|
|
19537
|
-
deserializeArkadeContractParams: () =>
|
|
19538
|
-
fromASM: () =>
|
|
19539
|
-
getOpcodeName: () =>
|
|
19540
|
-
getOpcodeValue: () =>
|
|
19541
|
-
parseArtifact: () =>
|
|
19542
|
-
resolveAsm: () =>
|
|
19543
|
-
serializeArkadeContractParams: () =>
|
|
19544
|
-
stringifyArtifact: () =>
|
|
19545
|
-
toASM: () =>
|
|
19546
|
-
validateProgram: () =>
|
|
19547
|
-
witnessRefToBytes: () =>
|
|
19842
|
+
deserializeArkadeContractParams: () => chunkV2TOHHPW_cjs.deserializeArkadeContractParams,
|
|
19843
|
+
fromASM: () => chunkV2TOHHPW_cjs.fromASM,
|
|
19844
|
+
getOpcodeName: () => chunkV2TOHHPW_cjs.getOpcodeName,
|
|
19845
|
+
getOpcodeValue: () => chunkV2TOHHPW_cjs.getOpcodeValue,
|
|
19846
|
+
parseArtifact: () => chunkV2TOHHPW_cjs.parseArtifact,
|
|
19847
|
+
resolveAsm: () => chunkV2TOHHPW_cjs.resolveAsm,
|
|
19848
|
+
serializeArkadeContractParams: () => chunkV2TOHHPW_cjs.serializeArkadeContractParams,
|
|
19849
|
+
stringifyArtifact: () => chunkV2TOHHPW_cjs.stringifyArtifact,
|
|
19850
|
+
toASM: () => chunkV2TOHHPW_cjs.toASM,
|
|
19851
|
+
validateProgram: () => chunkV2TOHHPW_cjs.validateProgram,
|
|
19852
|
+
witnessRefToBytes: () => chunkV2TOHHPW_cjs.witnessRefToBytes
|
|
19548
19853
|
});
|
|
19549
|
-
var isVtxoCoin = (input) =>
|
|
19854
|
+
var isVtxoCoin = (input) => chunkOWCPXRGP_cjs.isVirtualCoin(input);
|
|
19550
19855
|
function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients) {
|
|
19551
19856
|
let batchId;
|
|
19552
19857
|
let sweepTapTreeRoot;
|
|
19858
|
+
let validatedCommitmentTxid;
|
|
19553
19859
|
return {
|
|
19554
19860
|
onBatchStarted: async (event) => {
|
|
19555
19861
|
const utf8IntentId = new TextEncoder().encode(intentId);
|
|
@@ -19558,7 +19864,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
19558
19864
|
if (!event.intentIdHashes.includes(intentIdHashStr)) return { skip: true };
|
|
19559
19865
|
await arkProvider.confirmRegistration(intentId);
|
|
19560
19866
|
batchId = event.id;
|
|
19561
|
-
const sweepTapscript =
|
|
19867
|
+
const sweepTapscript = chunkOWCPXRGP_cjs.CSVMultisigTapscript.encode({
|
|
19562
19868
|
timelock: {
|
|
19563
19869
|
value: event.batchExpiry,
|
|
19564
19870
|
// BIP-65: values >= 512 are interpreted as seconds, below as blocks
|
|
@@ -19576,7 +19882,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
19576
19882
|
if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
|
|
19577
19883
|
return { skip: true };
|
|
19578
19884
|
}
|
|
19579
|
-
const commitmentTx =
|
|
19885
|
+
const commitmentTx = chunkOWCPXRGP_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
|
|
19580
19886
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
19581
19887
|
if (recipients && recipients.length > 0) {
|
|
19582
19888
|
validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
|
|
@@ -19585,6 +19891,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
19585
19891
|
if (!sharedOutput?.amount) {
|
|
19586
19892
|
throw new Error("Shared output not found");
|
|
19587
19893
|
}
|
|
19894
|
+
validatedCommitmentTxid = commitmentTx.id;
|
|
19588
19895
|
await session.init(vtxoTree, sweepTapTreeRoot, sharedOutput.amount);
|
|
19589
19896
|
const pubkey = base.hex.encode(await session.getPublicKey());
|
|
19590
19897
|
const nonces = await session.getNonces();
|
|
@@ -19607,7 +19914,15 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
19607
19914
|
if (connectorTree) {
|
|
19608
19915
|
validateConnectorsTxGraph(event.commitmentTx, connectorTree);
|
|
19609
19916
|
}
|
|
19610
|
-
let commitmentPsbt =
|
|
19917
|
+
let commitmentPsbt = chunkOWCPXRGP_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
19918
|
+
assertFinalCommitmentMatchesValidated(
|
|
19919
|
+
commitmentPsbt,
|
|
19920
|
+
validatedCommitmentTxid,
|
|
19921
|
+
"arkade batch finalization"
|
|
19922
|
+
);
|
|
19923
|
+
if (!validatedCommitmentTxid && recipients && recipients.length > 0) {
|
|
19924
|
+
validateBatchRecipientsWithoutTree(commitmentPsbt, recipients, network);
|
|
19925
|
+
}
|
|
19611
19926
|
const signedForfeits = [];
|
|
19612
19927
|
let connectorIndex = 0;
|
|
19613
19928
|
const connectorLeaves = connectorTree?.leaves() || [];
|
|
@@ -19634,7 +19949,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
19634
19949
|
boardingIndices.push(boardingIdx);
|
|
19635
19950
|
continue;
|
|
19636
19951
|
}
|
|
19637
|
-
if (
|
|
19952
|
+
if (chunkOWCPXRGP_cjs.isRecoverable(input) || isSubdust(input, info.dust)) {
|
|
19638
19953
|
continue;
|
|
19639
19954
|
}
|
|
19640
19955
|
if (connectorIndex >= connectorLeaves.length) {
|
|
@@ -19655,7 +19970,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
19655
19970
|
index: input.vout,
|
|
19656
19971
|
witnessUtxo: {
|
|
19657
19972
|
amount: BigInt(input.value),
|
|
19658
|
-
script:
|
|
19973
|
+
script: chunkOWCPXRGP_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
19659
19974
|
},
|
|
19660
19975
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
19661
19976
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -19738,7 +20053,7 @@ var Arkade = class _Arkade {
|
|
|
19738
20053
|
static async connect(opts) {
|
|
19739
20054
|
const info = await opts.arkade.getInfo();
|
|
19740
20055
|
const serverKey = base.hex.decode(info.signerPubkey).slice(1);
|
|
19741
|
-
const checkpoint =
|
|
20056
|
+
const checkpoint = chunkOWCPXRGP_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
19742
20057
|
let emulatorKey;
|
|
19743
20058
|
if (opts.emulator) {
|
|
19744
20059
|
const eInfo = await opts.emulator.getInfo();
|
|
@@ -19752,7 +20067,7 @@ var Arkade = class _Arkade {
|
|
|
19752
20067
|
return new _Arkade({
|
|
19753
20068
|
arkProvider: opts.arkade,
|
|
19754
20069
|
emulator: opts.emulator,
|
|
19755
|
-
network: opts.network ??
|
|
20070
|
+
network: opts.network ?? chunkOWCPXRGP_cjs.DEFAULT_NETWORK,
|
|
19756
20071
|
serverKey,
|
|
19757
20072
|
emulatorKey,
|
|
19758
20073
|
checkpoint,
|
|
@@ -19773,7 +20088,7 @@ var Arkade = class _Arkade {
|
|
|
19773
20088
|
* key respectively; explicit args always win.
|
|
19774
20089
|
*/
|
|
19775
20090
|
contract(program, args = {}) {
|
|
19776
|
-
const declared = (program.params ?? []).map(
|
|
20091
|
+
const declared = (program.params ?? []).map(chunkV2TOHHPW_cjs.inputName);
|
|
19777
20092
|
if (declared.includes("server") && args.server === void 0) {
|
|
19778
20093
|
args = { ...args, server: this.serverKey };
|
|
19779
20094
|
}
|
|
@@ -19793,7 +20108,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
19793
20108
|
userKey: client.userKey,
|
|
19794
20109
|
emulatorKey: client.emulatorKey
|
|
19795
20110
|
};
|
|
19796
|
-
this.vtxoScript = new
|
|
20111
|
+
this.vtxoScript = new chunkV2TOHHPW_cjs.ArkadeProgramScript(program, args, this.keys);
|
|
19797
20112
|
this.tapTree = this.vtxoScript.encode();
|
|
19798
20113
|
this.compiled = this.vtxoScript.compiled;
|
|
19799
20114
|
}
|
|
@@ -19821,7 +20136,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
19821
20136
|
`ArkadeContract.fromContract: expected contract type 'arkade', got '${contract.type}'`
|
|
19822
20137
|
);
|
|
19823
20138
|
}
|
|
19824
|
-
const typed =
|
|
20139
|
+
const typed = chunkV2TOHHPW_cjs.deserializeArkadeContractParams(contract.params);
|
|
19825
20140
|
return new _ArkadeContract(client, typed.program, typed.args, {
|
|
19826
20141
|
serverKey: typed.serverKey,
|
|
19827
20142
|
userKey: typed.userKey,
|
|
@@ -19862,7 +20177,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
19862
20177
|
toContractParams() {
|
|
19863
20178
|
return {
|
|
19864
20179
|
type: "arkade",
|
|
19865
|
-
params:
|
|
20180
|
+
params: chunkV2TOHHPW_cjs.serializeArkadeContractParams({
|
|
19866
20181
|
program: this.program,
|
|
19867
20182
|
args: this.args,
|
|
19868
20183
|
serverKey: this.keys.serverKey,
|
|
@@ -19907,13 +20222,13 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
19907
20222
|
const [registered] = await manager.getContracts({ script: scriptHex });
|
|
19908
20223
|
if (registered) {
|
|
19909
20224
|
const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
|
|
19910
|
-
return (withVtxos?.vtxos ?? []).filter((v) => !
|
|
20225
|
+
return (withVtxos?.vtxos ?? []).filter((v) => !chunkOWCPXRGP_cjs.hasTerminalSpend(v));
|
|
19911
20226
|
}
|
|
19912
20227
|
}
|
|
19913
20228
|
if (!this.client.indexer) {
|
|
19914
20229
|
throw new Error("ArkadeContract.getUtxos: an indexer is required");
|
|
19915
20230
|
}
|
|
19916
|
-
const { vtxos } = await
|
|
20231
|
+
const { vtxos } = await chunkOWCPXRGP_cjs.getNormalizedVtxos(this.client.indexer, {
|
|
19917
20232
|
scripts: [scriptHex],
|
|
19918
20233
|
spendableOnly: true
|
|
19919
20234
|
});
|
|
@@ -20015,12 +20330,12 @@ var ArkadeTransactionBuilder = class {
|
|
|
20015
20330
|
this.contract.client.checkpoint
|
|
20016
20331
|
);
|
|
20017
20332
|
if (coin.sourceTx) {
|
|
20018
|
-
|
|
20333
|
+
chunkOWCPXRGP_cjs.setArkPsbtField(arkTx, 0, chunkOWCPXRGP_cjs.PrevArkTxField, coin.sourceTx);
|
|
20019
20334
|
}
|
|
20020
20335
|
const condition = (def.tapscript.witness ?? []).map((w) => this.witnessBytes(w));
|
|
20021
20336
|
if (condition.length > 0) {
|
|
20022
|
-
|
|
20023
|
-
|
|
20337
|
+
chunkOWCPXRGP_cjs.setArkPsbtField(arkTx, 0, chunkOWCPXRGP_cjs.ConditionWitness, condition);
|
|
20338
|
+
chunkOWCPXRGP_cjs.setArkPsbtField(checkpoints[0], 0, chunkOWCPXRGP_cjs.ConditionWitness, condition);
|
|
20024
20339
|
}
|
|
20025
20340
|
const packets = [];
|
|
20026
20341
|
if (this.assetSpecs.length > 0) {
|
|
@@ -20059,7 +20374,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
20059
20374
|
base.base64.encode(signedArk2.toPSBT()),
|
|
20060
20375
|
signedCps.map((c) => base.base64.encode(c.toPSBT()))
|
|
20061
20376
|
);
|
|
20062
|
-
const txid =
|
|
20377
|
+
const txid = chunkOWCPXRGP_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
|
|
20063
20378
|
return {
|
|
20064
20379
|
txid,
|
|
20065
20380
|
signedArkTx: res2.signedArkTx,
|
|
@@ -20074,11 +20389,11 @@ var ArkadeTransactionBuilder = class {
|
|
|
20074
20389
|
base.base64.encode(signedArk.toPSBT()),
|
|
20075
20390
|
checkpoints.map((c) => base.base64.encode(c.toPSBT()))
|
|
20076
20391
|
);
|
|
20392
|
+
assertSubmittedArkTxid(res, signedArk, "submitTx");
|
|
20393
|
+
const matched = matchServerCheckpoints(res.signedCheckpointTxs, checkpoints, "submitTx");
|
|
20077
20394
|
const finalCps = await Promise.all(
|
|
20078
|
-
|
|
20079
|
-
async (
|
|
20080
|
-
(await client.identity.sign(chunkGMUVWKOK_cjs.Transaction.fromPSBT(base.base64.decode(b)), [0])).toPSBT()
|
|
20081
|
-
)
|
|
20395
|
+
matched.map(
|
|
20396
|
+
async ({ server }) => base.base64.encode((await client.identity.sign(server, [0])).toPSBT())
|
|
20082
20397
|
)
|
|
20083
20398
|
);
|
|
20084
20399
|
await client.arkProvider.finalizeTx(res.arkTxid, finalCps);
|
|
@@ -20118,23 +20433,23 @@ var ArkadeTransactionBuilder = class {
|
|
|
20118
20433
|
}
|
|
20119
20434
|
buildAssetPacket() {
|
|
20120
20435
|
const groups = this.assetSpecs.map((s) => {
|
|
20121
|
-
const id = typeof s.assetId === "string" ?
|
|
20122
|
-
return
|
|
20436
|
+
const id = typeof s.assetId === "string" ? chunkG7DOBFQN_cjs.AssetId.fromString(s.assetId) : chunkG7DOBFQN_cjs.AssetId.fromBytes(s.assetId);
|
|
20437
|
+
return chunkG7DOBFQN_cjs.AssetGroup.create(
|
|
20123
20438
|
id,
|
|
20124
20439
|
null,
|
|
20125
|
-
s.inputs.map((i) =>
|
|
20126
|
-
s.outputs.map((o) =>
|
|
20127
|
-
(s.metadata ?? []).map((m) =>
|
|
20440
|
+
s.inputs.map((i) => chunkG7DOBFQN_cjs.AssetInput.create(i.vin, i.amount)),
|
|
20441
|
+
s.outputs.map((o) => chunkG7DOBFQN_cjs.AssetOutput.create(o.vout, o.amount)),
|
|
20442
|
+
(s.metadata ?? []).map((m) => chunkG7DOBFQN_cjs.Metadata.create(m.key, m.value))
|
|
20128
20443
|
);
|
|
20129
20444
|
});
|
|
20130
|
-
return
|
|
20445
|
+
return chunkG7DOBFQN_cjs.Packet.create(groups);
|
|
20131
20446
|
}
|
|
20132
20447
|
witnessBytes(ref) {
|
|
20133
|
-
return
|
|
20448
|
+
return chunkV2TOHHPW_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
|
|
20134
20449
|
}
|
|
20135
20450
|
};
|
|
20136
20451
|
function bindInputs(fn, callArgs) {
|
|
20137
|
-
const names = (fn.def.inputs ?? []).map(
|
|
20452
|
+
const names = (fn.def.inputs ?? []).map(chunkV2TOHHPW_cjs.inputName);
|
|
20138
20453
|
if (callArgs.length !== names.length) {
|
|
20139
20454
|
throw new Error(`${fn.name}: expected ${names.length} argument(s), got ${callArgs.length}`);
|
|
20140
20455
|
}
|
|
@@ -20541,7 +20856,7 @@ function decodeArkContract(encoded) {
|
|
|
20541
20856
|
}
|
|
20542
20857
|
function contractFromArkContract(encoded, options = {}) {
|
|
20543
20858
|
const parsed = decodeArkContract(encoded);
|
|
20544
|
-
const handler =
|
|
20859
|
+
const handler = chunkV2TOHHPW_cjs.contractHandlers.get(parsed.type);
|
|
20545
20860
|
if (!handler) {
|
|
20546
20861
|
throw new Error(`No handler registered for contract type '${parsed.type}'`);
|
|
20547
20862
|
}
|
|
@@ -20555,9 +20870,9 @@ function contractFromArkContract(encoded, options = {}) {
|
|
|
20555
20870
|
metadata: options.metadata
|
|
20556
20871
|
};
|
|
20557
20872
|
}
|
|
20558
|
-
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix =
|
|
20873
|
+
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkOWCPXRGP_cjs.DEFAULT_NETWORK.hrp, options = {}) {
|
|
20559
20874
|
const parsed = decodeArkContract(encoded);
|
|
20560
|
-
const handler =
|
|
20875
|
+
const handler = chunkV2TOHHPW_cjs.contractHandlers.getOrThrow(parsed.type);
|
|
20561
20876
|
const params = parsed.data;
|
|
20562
20877
|
const vtxoScript = handler.createScript(params);
|
|
20563
20878
|
return {
|
|
@@ -20594,6 +20909,7 @@ exports.DelegateManagerImpl = DelegateManagerImpl;
|
|
|
20594
20909
|
exports.DelegateNotConfiguredError = DelegateNotConfiguredError;
|
|
20595
20910
|
exports.DelegatorManagerImpl = DelegatorManagerImpl;
|
|
20596
20911
|
exports.DelegatorNotConfiguredError = DelegatorNotConfiguredError;
|
|
20912
|
+
exports.DescriptorIdentity = DescriptorIdentity;
|
|
20597
20913
|
exports.DescriptorSigningProviderMissingError = DescriptorSigningProviderMissingError;
|
|
20598
20914
|
exports.DustChangeError = DustChangeError;
|
|
20599
20915
|
exports.ELECTRUM_TCP_HOST = ELECTRUM_TCP_HOST;
|
|
@@ -20656,6 +20972,8 @@ exports.arkTarget = arkTarget;
|
|
|
20656
20972
|
exports.arkade_exports = arkade_exports;
|
|
20657
20973
|
exports.assertIntentIdUnique = assertIntentIdUnique;
|
|
20658
20974
|
exports.assertSendableAmount = assertSendableAmount;
|
|
20975
|
+
exports.assertSubmittedArkTxid = assertSubmittedArkTxid;
|
|
20976
|
+
exports.assetMintResolver = assetMintResolver;
|
|
20659
20977
|
exports.boardingResolver = boardingResolver;
|
|
20660
20978
|
exports.btcTarget = btcTarget;
|
|
20661
20979
|
exports.buildForfeitTx = buildForfeitTx;
|
|
@@ -20663,6 +20981,7 @@ exports.buildOffchainTx = buildOffchainTx;
|
|
|
20663
20981
|
exports.classifyAgainstSignerSet = classifyAgainstSignerSet;
|
|
20664
20982
|
exports.classifyContractSigner = classifyContractSigner;
|
|
20665
20983
|
exports.closeDatabase = closeDatabase;
|
|
20984
|
+
exports.collabExitResolver = collabExitResolver;
|
|
20666
20985
|
exports.combineTapscriptSigs = combineTapscriptSigs;
|
|
20667
20986
|
exports.contractFromArkContract = contractFromArkContract;
|
|
20668
20987
|
exports.contractFromArkContractWithAddress = contractFromArkContractWithAddress;
|
|
@@ -20689,6 +21008,8 @@ exports.isBatchSignable = isBatchSignable;
|
|
|
20689
21008
|
exports.isBtcAddress = isBtcAddress;
|
|
20690
21009
|
exports.isCooperativelyMigratable = isCooperativelyMigratable;
|
|
20691
21010
|
exports.isDiscoverable = isDiscoverable;
|
|
21011
|
+
exports.isHDDeterministicSignCapable = isHDDeterministicSignCapable;
|
|
21012
|
+
exports.isHDWalletCapable = isHDWalletCapable;
|
|
20692
21013
|
exports.isLightningInvoice = isLightningInvoice;
|
|
20693
21014
|
exports.isLnurl = isLnurl;
|
|
20694
21015
|
exports.isMessageBusInitializingError = isMessageBusInitializingError;
|
|
@@ -20699,6 +21020,7 @@ exports.isValidArkAddress = isValidArkAddress;
|
|
|
20699
21020
|
exports.isVtxoExpiringSoon = isVtxoExpiringSoon;
|
|
20700
21021
|
exports.isVtxoForScript = isVtxoForScript;
|
|
20701
21022
|
exports.makeHandle = makeHandle;
|
|
21023
|
+
exports.matchServerCheckpoints = matchServerCheckpoints;
|
|
20702
21024
|
exports.mergeChainedTxType = mergeChainedTxType;
|
|
20703
21025
|
exports.migrateWalletRepository = migrateWalletRepository;
|
|
20704
21026
|
exports.onchainRail = onchainRail;
|
|
@@ -20723,5 +21045,5 @@ exports.validateVtxoTxGraph = validateVtxoTxGraph;
|
|
|
20723
21045
|
exports.verifyTapscriptSignatures = verifyTapscriptSignatures;
|
|
20724
21046
|
exports.waitForIncomingFunds = waitForIncomingFunds;
|
|
20725
21047
|
exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
|
|
20726
|
-
//# sourceMappingURL=chunk-
|
|
20727
|
-
//# sourceMappingURL=chunk-
|
|
21048
|
+
//# sourceMappingURL=chunk-ZPL34T2Q.cjs.map
|
|
21049
|
+
//# sourceMappingURL=chunk-ZPL34T2Q.cjs.map
|