@arkade-os/sdk 0.4.32 → 0.4.33
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 +4 -4
- package/dist/adapters/expo.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +2 -2
- package/dist/adapters/indexedDB.cjs +4 -4
- package/dist/adapters/indexedDB.js +3 -3
- package/dist/{ark-ibLW4Hte.d.cts → ark-DEsDMYGv.d.cts} +17 -4
- package/dist/{ark-ibLW4Hte.d.ts → ark-DEsDMYGv.d.ts} +17 -4
- package/dist/{asyncStorageTaskQueue-BEOFPNc0.d.ts → asyncStorageTaskQueue-CMrTYlKG.d.ts} +1 -1
- package/dist/{asyncStorageTaskQueue-VGHXWR9F.d.cts → asyncStorageTaskQueue-D8T1VXEx.d.cts} +1 -1
- package/dist/{chunk-GIGILVVP.cjs → chunk-5CCRRL5S.cjs} +8 -8
- package/dist/{chunk-GIGILVVP.cjs.map → chunk-5CCRRL5S.cjs.map} +1 -1
- package/dist/{chunk-KQK4PP6L.cjs → chunk-7K3ROJF6.cjs} +276 -131
- package/dist/chunk-7K3ROJF6.cjs.map +1 -0
- package/dist/{chunk-YA4G7RFB.js → chunk-AOJUURHM.js} +30 -6
- package/dist/chunk-AOJUURHM.js.map +1 -0
- package/dist/{chunk-SHEBNWOQ.js → chunk-BU3BU6XK.js} +3 -3
- package/dist/{chunk-SHEBNWOQ.js.map → chunk-BU3BU6XK.js.map} +1 -1
- package/dist/{chunk-XROGFOPX.js → chunk-DSS2GQUG.js} +185 -40
- package/dist/chunk-DSS2GQUG.js.map +1 -0
- package/dist/{chunk-6NWNOLL3.js → chunk-E22HEKLN.js} +3 -3
- package/dist/chunk-E22HEKLN.js.map +1 -0
- package/dist/{chunk-IEO3XDKI.cjs → chunk-GYSK5R57.cjs} +32 -5
- package/dist/chunk-GYSK5R57.cjs.map +1 -0
- package/dist/{chunk-I2UIKZM5.cjs → chunk-HAVA4XB7.cjs} +7 -7
- package/dist/{chunk-I2UIKZM5.cjs.map → chunk-HAVA4XB7.cjs.map} +1 -1
- package/dist/{chunk-ABWRLTX5.js → chunk-L6ZETTX3.js} +3 -3
- package/dist/{chunk-ABWRLTX5.js.map → chunk-L6ZETTX3.js.map} +1 -1
- package/dist/{chunk-6FLL2Q36.cjs → chunk-SPDNHPM4.cjs} +3 -3
- package/dist/chunk-SPDNHPM4.cjs.map +1 -0
- package/dist/contracts/handlers/index.cjs +9 -5
- package/dist/contracts/handlers/index.d.cts +3 -3
- package/dist/contracts/handlers/index.d.ts +3 -3
- package/dist/contracts/handlers/index.js +1 -1
- package/dist/{delegate-BvNTw44a.d.cts → delegate-BJeBNP5a.d.cts} +10 -2
- package/dist/{delegate-BXaR1RNG.d.ts → delegate-EXN2mfkb.d.ts} +10 -2
- package/dist/{index-BusKawmy.d.ts → index-BG2ooYKO.d.ts} +57 -3
- package/dist/{index-C-5Tw7VA.d.cts → index-DHjEeHEp.d.cts} +57 -3
- package/dist/index.cjs +125 -113
- package/dist/index.d.cts +33 -9
- package/dist/index.d.ts +33 -9
- package/dist/index.js +3 -3
- package/dist/repositories/realm/index.cjs +12 -12
- package/dist/repositories/realm/index.d.cts +1 -1
- package/dist/repositories/realm/index.d.ts +1 -1
- package/dist/repositories/realm/index.js +3 -3
- package/dist/repositories/sqlite/index.cjs +12 -12
- package/dist/repositories/sqlite/index.d.cts +1 -1
- package/dist/repositories/sqlite/index.d.ts +1 -1
- package/dist/repositories/sqlite/index.js +3 -3
- package/dist/{taskRunner-B1igKGAo.d.ts → taskRunner-B7lBU45X.d.ts} +1 -1
- package/dist/{taskRunner-By92TQ1m.d.cts → taskRunner-pIGyarFG.d.cts} +1 -1
- package/dist/wallet/expo/background.cjs +13 -13
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +5 -5
- package/dist/wallet/expo/index.cjs +13 -13
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +4 -4
- package/dist/wallet/expo/index.d.ts +4 -4
- package/dist/wallet/expo/index.js +5 -5
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/{wallet-CyM4F7Bs.d.ts → wallet-C4L_X0i6.d.ts} +2 -2
- package/dist/{wallet-B_rxgQTu.d.cts → wallet-D4Dll5Gu.d.cts} +2 -2
- package/dist/worker/expo/index.cjs +8 -8
- package/dist/worker/expo/index.d.cts +4 -4
- package/dist/worker/expo/index.d.ts +4 -4
- package/dist/worker/expo/index.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-6FLL2Q36.cjs.map +0 -1
- package/dist/chunk-6NWNOLL3.js.map +0 -1
- package/dist/chunk-IEO3XDKI.cjs.map +0 -1
- package/dist/chunk-KQK4PP6L.cjs.map +0 -1
- package/dist/chunk-XROGFOPX.js.map +0 -1
- package/dist/chunk-YA4G7RFB.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkSPDNHPM4_cjs = require('./chunk-SPDNHPM4.cjs');
|
|
4
|
+
var chunkGYSK5R57_cjs = require('./chunk-GYSK5R57.cjs');
|
|
5
5
|
var chunkWMIPYZSB_cjs = require('./chunk-WMIPYZSB.cjs');
|
|
6
6
|
var utils_js = require('@scure/btc-signer/utils.js');
|
|
7
7
|
var btcSigner = require('@scure/btc-signer');
|
|
@@ -181,7 +181,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
181
181
|
noncesByPubkey.set(base.hex.encode(myPublicKey.subarray(1)), myNonce);
|
|
182
182
|
const tx = this.graph.find(txid);
|
|
183
183
|
if (!tx) throw new Error(`missing tx for txid ${txid}`);
|
|
184
|
-
const cosigners =
|
|
184
|
+
const cosigners = chunkSPDNHPM4_cjs.getArkPsbtFields(tx.root, 0, chunkSPDNHPM4_cjs.CosignerPublicKey).map(
|
|
185
185
|
(c) => base.hex.encode(c.key.subarray(1))
|
|
186
186
|
// xonly pubkey
|
|
187
187
|
);
|
|
@@ -233,7 +233,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
233
233
|
if (!aggNonce) throw new Error("missing aggregate nonce");
|
|
234
234
|
const prevoutAmounts = [];
|
|
235
235
|
const prevoutScripts = [];
|
|
236
|
-
const cosigners =
|
|
236
|
+
const cosigners = chunkSPDNHPM4_cjs.getArkPsbtFields(g.root, 0, chunkSPDNHPM4_cjs.CosignerPublicKey).map((c) => c.key);
|
|
237
237
|
const { finalKey } = aggregateKeys(cosigners, true, {
|
|
238
238
|
taprootTweak: this.scriptRoot
|
|
239
239
|
});
|
|
@@ -411,7 +411,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
411
411
|
let network;
|
|
412
412
|
if ("descriptor" in opts && typeof opts.descriptor === "string") {
|
|
413
413
|
descriptor = opts.descriptor;
|
|
414
|
-
network =
|
|
414
|
+
network = chunkGYSK5R57_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
415
415
|
} else {
|
|
416
416
|
network = opts.isMainnet ?? true ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
417
417
|
descriptor = descriptorsScure.scriptExpressions.trBIP32({
|
|
@@ -496,7 +496,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
496
496
|
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
497
497
|
*/
|
|
498
498
|
isOurs(descriptor) {
|
|
499
|
-
return
|
|
499
|
+
return chunkGYSK5R57_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
|
|
500
500
|
}
|
|
501
501
|
/**
|
|
502
502
|
* Signs each request with the key derived from its descriptor.
|
|
@@ -533,7 +533,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
533
533
|
}
|
|
534
534
|
// ── internal helpers ─────────────────────────────────────────────
|
|
535
535
|
derivePrivateKeyForDescriptor(descriptor) {
|
|
536
|
-
const network =
|
|
536
|
+
const network = chunkGYSK5R57_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
537
537
|
const expansion = descriptorsScure.expand({ descriptor, network });
|
|
538
538
|
if (expansion.isRanged) {
|
|
539
539
|
throw new Error(
|
|
@@ -619,7 +619,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
619
619
|
*/
|
|
620
620
|
descriptor;
|
|
621
621
|
constructor(descriptor) {
|
|
622
|
-
const network =
|
|
622
|
+
const network = chunkGYSK5R57_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
623
623
|
let expansion;
|
|
624
624
|
try {
|
|
625
625
|
expansion = descriptorsScure.expand({ descriptor, network, index: 0 });
|
|
@@ -669,7 +669,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
669
669
|
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
670
670
|
*/
|
|
671
671
|
isOurs(descriptor) {
|
|
672
|
-
return
|
|
672
|
+
return chunkGYSK5R57_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
|
|
673
673
|
}
|
|
674
674
|
};
|
|
675
675
|
function serializeSeedOwnedSigningIdentity(identity) {
|
|
@@ -987,7 +987,7 @@ var RestDelegateProvider = class {
|
|
|
987
987
|
},
|
|
988
988
|
body: JSON.stringify({
|
|
989
989
|
intent: {
|
|
990
|
-
message:
|
|
990
|
+
message: chunkSPDNHPM4_cjs.Intent.encodeMessage(intent.message),
|
|
991
991
|
proof: intent.proof
|
|
992
992
|
},
|
|
993
993
|
forfeit_txs: forfeitTxs,
|
|
@@ -1277,7 +1277,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
|
|
|
1277
1277
|
);
|
|
1278
1278
|
}
|
|
1279
1279
|
function buildForfeitTxWithOutput(inputs, output, txLocktime) {
|
|
1280
|
-
const tx = new
|
|
1280
|
+
const tx = new chunkSPDNHPM4_cjs.Transaction({
|
|
1281
1281
|
version: 3,
|
|
1282
1282
|
lockTime: txLocktime
|
|
1283
1283
|
});
|
|
@@ -1353,7 +1353,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
|
|
|
1353
1353
|
if (previousScriptKey.length !== 32) {
|
|
1354
1354
|
throw new Error(`parent output ${childIndex} has invalid script`);
|
|
1355
1355
|
}
|
|
1356
|
-
const cosigners =
|
|
1356
|
+
const cosigners = chunkSPDNHPM4_cjs.getArkPsbtFields(child.root, 0, chunkSPDNHPM4_cjs.CosignerPublicKey);
|
|
1357
1357
|
if (cosigners.length === 0) {
|
|
1358
1358
|
throw ErrMissingCosignersPublicKeys;
|
|
1359
1359
|
}
|
|
@@ -1453,7 +1453,7 @@ var Extension = class _Extension {
|
|
|
1453
1453
|
`expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
|
|
1454
1454
|
);
|
|
1455
1455
|
}
|
|
1456
|
-
const reader = new
|
|
1456
|
+
const reader = new chunkSPDNHPM4_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
|
|
1457
1457
|
const packets = [];
|
|
1458
1458
|
while (reader.remaining() > 0) {
|
|
1459
1459
|
const packetType = reader.readByte();
|
|
@@ -1527,7 +1527,7 @@ var Extension = class _Extension {
|
|
|
1527
1527
|
*/
|
|
1528
1528
|
getAssetPacket() {
|
|
1529
1529
|
for (const p of this.packets) {
|
|
1530
|
-
if (p instanceof
|
|
1530
|
+
if (p instanceof chunkSPDNHPM4_cjs.Packet) {
|
|
1531
1531
|
return p;
|
|
1532
1532
|
}
|
|
1533
1533
|
}
|
|
@@ -1535,8 +1535,8 @@ var Extension = class _Extension {
|
|
|
1535
1535
|
}
|
|
1536
1536
|
};
|
|
1537
1537
|
function parsePacket(packetType, data) {
|
|
1538
|
-
if (packetType ===
|
|
1539
|
-
return
|
|
1538
|
+
if (packetType === chunkSPDNHPM4_cjs.Packet.PACKET_TYPE) {
|
|
1539
|
+
return chunkSPDNHPM4_cjs.Packet.fromBytes(data);
|
|
1540
1540
|
}
|
|
1541
1541
|
return new UnknownPacket(packetType, data);
|
|
1542
1542
|
}
|
|
@@ -1727,7 +1727,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
1727
1727
|
const existing = inputsByAssetId.get(asset.assetId);
|
|
1728
1728
|
inputsByAssetId.set(asset.assetId, [
|
|
1729
1729
|
...existing ?? [],
|
|
1730
|
-
|
|
1730
|
+
chunkSPDNHPM4_cjs.AssetInput.create(inputIndex, asset.amount)
|
|
1731
1731
|
]);
|
|
1732
1732
|
}
|
|
1733
1733
|
}
|
|
@@ -1739,7 +1739,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
1739
1739
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
1740
1740
|
outputsByAssetId.set(asset.assetId, [
|
|
1741
1741
|
...existing ?? [],
|
|
1742
|
-
|
|
1742
|
+
chunkSPDNHPM4_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
1743
1743
|
]);
|
|
1744
1744
|
}
|
|
1745
1745
|
}
|
|
@@ -1750,7 +1750,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
1750
1750
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
1751
1751
|
outputsByAssetId.set(asset.assetId, [
|
|
1752
1752
|
...existing ?? [],
|
|
1753
|
-
|
|
1753
|
+
chunkSPDNHPM4_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
1754
1754
|
]);
|
|
1755
1755
|
}
|
|
1756
1756
|
}
|
|
@@ -1759,11 +1759,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
1759
1759
|
for (const assetIdStr of allAssetIds) {
|
|
1760
1760
|
const inputs = inputsByAssetId.get(assetIdStr);
|
|
1761
1761
|
const outputs = outputsByAssetId.get(assetIdStr);
|
|
1762
|
-
const assetId =
|
|
1763
|
-
const group =
|
|
1762
|
+
const assetId = chunkSPDNHPM4_cjs.AssetId.fromString(assetIdStr);
|
|
1763
|
+
const group = chunkSPDNHPM4_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
|
|
1764
1764
|
groups.push(group);
|
|
1765
1765
|
}
|
|
1766
|
-
return
|
|
1766
|
+
return chunkSPDNHPM4_cjs.Packet.create(groups);
|
|
1767
1767
|
}
|
|
1768
1768
|
function selectCoinsWithAsset(coins, assetId, requiredAmount) {
|
|
1769
1769
|
const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
|
|
@@ -1841,7 +1841,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
1841
1841
|
}
|
|
1842
1842
|
}
|
|
1843
1843
|
}
|
|
1844
|
-
const tx = new
|
|
1844
|
+
const tx = new chunkSPDNHPM4_cjs.Transaction({
|
|
1845
1845
|
version: 3,
|
|
1846
1846
|
lockTime: Number(lockTime)
|
|
1847
1847
|
});
|
|
@@ -1856,7 +1856,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
1856
1856
|
},
|
|
1857
1857
|
tapLeafScript: [input.tapLeafScript]
|
|
1858
1858
|
});
|
|
1859
|
-
|
|
1859
|
+
chunkSPDNHPM4_cjs.setArkPsbtField(tx, i, chunkSPDNHPM4_cjs.VtxoTaprootTree, input.tapTree);
|
|
1860
1860
|
}
|
|
1861
1861
|
for (const output of outputs) {
|
|
1862
1862
|
tx.addOutput(output);
|
|
@@ -1988,12 +1988,22 @@ function verifyTapscriptSignatures(tx, inputIndex, requiredSigners, excludePubke
|
|
|
1988
1988
|
}
|
|
1989
1989
|
}
|
|
1990
1990
|
function combineTapscriptSigs(signedTx, originalTx) {
|
|
1991
|
+
if (signedTx.inputsLength !== originalTx.inputsLength) {
|
|
1992
|
+
throw new Error(
|
|
1993
|
+
`combineTapscriptSigs: input count mismatch (signedTx ${signedTx.inputsLength}, originalTx ${originalTx.inputsLength})`
|
|
1994
|
+
);
|
|
1995
|
+
}
|
|
1991
1996
|
for (let i = 0; i < signedTx.inputsLength; i++) {
|
|
1992
1997
|
const input = originalTx.getInput(i);
|
|
1993
1998
|
const signedInput = signedTx.getInput(i);
|
|
1994
|
-
if (!input.tapScriptSig)
|
|
1999
|
+
if (!input.tapScriptSig) {
|
|
2000
|
+
throw new Error(`combineTapscriptSigs: originalTx input ${i} has no tapScriptSig`);
|
|
2001
|
+
}
|
|
2002
|
+
if (!signedInput.tapScriptSig) {
|
|
2003
|
+
throw new Error(`combineTapscriptSigs: signedTx input ${i} has no tapScriptSig`);
|
|
2004
|
+
}
|
|
1995
2005
|
originalTx.updateInput(i, {
|
|
1996
|
-
tapScriptSig: input.tapScriptSig
|
|
2006
|
+
tapScriptSig: input.tapScriptSig.concat(signedInput.tapScriptSig)
|
|
1997
2007
|
});
|
|
1998
2008
|
}
|
|
1999
2009
|
return originalTx;
|
|
@@ -2279,7 +2289,7 @@ function extendCoin(wallet, utxo) {
|
|
|
2279
2289
|
};
|
|
2280
2290
|
}
|
|
2281
2291
|
function deriveContractTapscripts(contract) {
|
|
2282
|
-
const handler =
|
|
2292
|
+
const handler = chunkGYSK5R57_cjs.contractHandlers.get(contract.type);
|
|
2283
2293
|
if (!handler) {
|
|
2284
2294
|
throw new Error(`No handler for contract type '${contract.type}'`);
|
|
2285
2295
|
}
|
|
@@ -2828,7 +2838,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
2828
2838
|
`Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
|
|
2829
2839
|
);
|
|
2830
2840
|
}
|
|
2831
|
-
const tx = new
|
|
2841
|
+
const tx = new chunkSPDNHPM4_cjs.Transaction();
|
|
2832
2842
|
for (const utxo of expiredUtxos) {
|
|
2833
2843
|
tx.addInput({
|
|
2834
2844
|
txid: utxo.txid,
|
|
@@ -2989,7 +2999,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
2989
2999
|
* or doesn't carry the metadata.
|
|
2990
3000
|
*/
|
|
2991
3001
|
extractSpentOutpoint(error) {
|
|
2992
|
-
const ark =
|
|
3002
|
+
const ark = chunkSPDNHPM4_cjs.maybeArkError(error);
|
|
2993
3003
|
if (!ark || ark.name !== "VTXO_ALREADY_SPENT") return void 0;
|
|
2994
3004
|
const raw = ark.metadata?.vtxo_outpoint;
|
|
2995
3005
|
if (typeof raw !== "string") return void 0;
|
|
@@ -3884,7 +3894,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
3884
3894
|
const virtualCoins = await this.wallet.getVtxos({
|
|
3885
3895
|
withRecoverable: false
|
|
3886
3896
|
});
|
|
3887
|
-
const controlAssetRef = params.controlAssetId ?
|
|
3897
|
+
const controlAssetRef = params.controlAssetId ? chunkSPDNHPM4_cjs.AssetRef.fromId(chunkSPDNHPM4_cjs.AssetId.fromString(params.controlAssetId)) : null;
|
|
3888
3898
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
3889
3899
|
let totalBtcSelected = 0n;
|
|
3890
3900
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -3897,8 +3907,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
3897
3907
|
}
|
|
3898
3908
|
}
|
|
3899
3909
|
const groups = [];
|
|
3900
|
-
const issuedAssetOutput =
|
|
3901
|
-
const issuedAssetGroup =
|
|
3910
|
+
const issuedAssetOutput = chunkSPDNHPM4_cjs.AssetOutput.create(0, params.amount);
|
|
3911
|
+
const issuedAssetGroup = chunkSPDNHPM4_cjs.AssetGroup.create(
|
|
3902
3912
|
null,
|
|
3903
3913
|
controlAssetRef,
|
|
3904
3914
|
[],
|
|
@@ -3913,15 +3923,15 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
3913
3923
|
for (const [inputIndex, assets] of assetInputs) {
|
|
3914
3924
|
for (const asset of assets) {
|
|
3915
3925
|
if (asset.assetId !== assetId) continue;
|
|
3916
|
-
changeInputs.push(
|
|
3926
|
+
changeInputs.push(chunkSPDNHPM4_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
3917
3927
|
}
|
|
3918
3928
|
}
|
|
3919
3929
|
groups.push(
|
|
3920
|
-
|
|
3921
|
-
|
|
3930
|
+
chunkSPDNHPM4_cjs.AssetGroup.create(
|
|
3931
|
+
chunkSPDNHPM4_cjs.AssetId.fromString(assetId),
|
|
3922
3932
|
null,
|
|
3923
3933
|
changeInputs,
|
|
3924
|
-
[
|
|
3934
|
+
[chunkSPDNHPM4_cjs.AssetOutput.create(0, amount)],
|
|
3925
3935
|
[]
|
|
3926
3936
|
)
|
|
3927
3937
|
);
|
|
@@ -3934,7 +3944,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
3934
3944
|
script: outputAddress.pkScript,
|
|
3935
3945
|
amount: BigInt(totalBtcSelected)
|
|
3936
3946
|
},
|
|
3937
|
-
Extension.create([
|
|
3947
|
+
Extension.create([chunkSPDNHPM4_cjs.Packet.create(groups)]).txOut()
|
|
3938
3948
|
];
|
|
3939
3949
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
|
|
3940
3950
|
coinSelection.inputs,
|
|
@@ -3942,7 +3952,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
3942
3952
|
);
|
|
3943
3953
|
return {
|
|
3944
3954
|
arkTxId: arkTxid,
|
|
3945
|
-
assetId:
|
|
3955
|
+
assetId: chunkSPDNHPM4_cjs.AssetId.create(arkTxid, 0).toString()
|
|
3946
3956
|
};
|
|
3947
3957
|
}
|
|
3948
3958
|
/**
|
|
@@ -4014,16 +4024,16 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
4014
4024
|
for (const [inputIndex, assets] of assetInputs) {
|
|
4015
4025
|
for (const asset of assets) {
|
|
4016
4026
|
if (asset.assetId !== params.assetId) continue;
|
|
4017
|
-
reissueInputs.push(
|
|
4027
|
+
reissueInputs.push(chunkSPDNHPM4_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
4018
4028
|
}
|
|
4019
4029
|
}
|
|
4020
4030
|
const totalAssetAmount = assetToReissueAmount + params.amount;
|
|
4021
|
-
const reissueAssetIdObj =
|
|
4022
|
-
const reissueAssetGroup =
|
|
4031
|
+
const reissueAssetIdObj = chunkSPDNHPM4_cjs.AssetId.fromString(params.assetId);
|
|
4032
|
+
const reissueAssetGroup = chunkSPDNHPM4_cjs.AssetGroup.create(
|
|
4023
4033
|
reissueAssetIdObj,
|
|
4024
4034
|
null,
|
|
4025
4035
|
reissueInputs,
|
|
4026
|
-
[
|
|
4036
|
+
[chunkSPDNHPM4_cjs.AssetOutput.create(0, totalAssetAmount)],
|
|
4027
4037
|
[]
|
|
4028
4038
|
);
|
|
4029
4039
|
const groups = [reissueAssetGroup];
|
|
@@ -4032,15 +4042,15 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
4032
4042
|
for (const [inputIndex, assets] of assetInputs) {
|
|
4033
4043
|
for (const asset of assets) {
|
|
4034
4044
|
if (asset.assetId !== assetId) continue;
|
|
4035
|
-
changeInputs.push(
|
|
4045
|
+
changeInputs.push(chunkSPDNHPM4_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
4036
4046
|
}
|
|
4037
4047
|
}
|
|
4038
4048
|
groups.push(
|
|
4039
|
-
|
|
4040
|
-
|
|
4049
|
+
chunkSPDNHPM4_cjs.AssetGroup.create(
|
|
4050
|
+
chunkSPDNHPM4_cjs.AssetId.fromString(assetId),
|
|
4041
4051
|
null,
|
|
4042
4052
|
changeInputs,
|
|
4043
|
-
[
|
|
4053
|
+
[chunkSPDNHPM4_cjs.AssetOutput.create(0, amount)],
|
|
4044
4054
|
[]
|
|
4045
4055
|
)
|
|
4046
4056
|
);
|
|
@@ -4052,7 +4062,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
4052
4062
|
script: outputAddress.pkScript,
|
|
4053
4063
|
amount: BigInt(totalBtcSelected)
|
|
4054
4064
|
},
|
|
4055
|
-
Extension.create([
|
|
4065
|
+
Extension.create([chunkSPDNHPM4_cjs.Packet.create(groups)]).txOut()
|
|
4056
4066
|
];
|
|
4057
4067
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
4058
4068
|
return arkTxid;
|
|
@@ -4119,15 +4129,15 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
4119
4129
|
for (const [inputIndex, assets] of assetInputs) {
|
|
4120
4130
|
for (const asset of assets) {
|
|
4121
4131
|
if (asset.assetId !== assetId) continue;
|
|
4122
|
-
changeInputs.push(
|
|
4132
|
+
changeInputs.push(chunkSPDNHPM4_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
4123
4133
|
}
|
|
4124
4134
|
}
|
|
4125
4135
|
groups.push(
|
|
4126
|
-
|
|
4127
|
-
|
|
4136
|
+
chunkSPDNHPM4_cjs.AssetGroup.create(
|
|
4137
|
+
chunkSPDNHPM4_cjs.AssetId.fromString(assetId),
|
|
4128
4138
|
null,
|
|
4129
4139
|
changeInputs,
|
|
4130
|
-
amount > 0n ? [
|
|
4140
|
+
amount > 0n ? [chunkSPDNHPM4_cjs.AssetOutput.create(0, amount)] : [],
|
|
4131
4141
|
[]
|
|
4132
4142
|
)
|
|
4133
4143
|
);
|
|
@@ -4139,7 +4149,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
4139
4149
|
script: outputAddress.pkScript,
|
|
4140
4150
|
amount: BigInt(totalBtcSelected)
|
|
4141
4151
|
},
|
|
4142
|
-
Extension.create([
|
|
4152
|
+
Extension.create([chunkSPDNHPM4_cjs.Packet.create(groups)]).txOut()
|
|
4143
4153
|
];
|
|
4144
4154
|
const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
|
|
4145
4155
|
return arkTxid;
|
|
@@ -4164,7 +4174,7 @@ function castMetadata(metadata) {
|
|
|
4164
4174
|
} else {
|
|
4165
4175
|
throw new Error("Invalid metadata value type");
|
|
4166
4176
|
}
|
|
4167
|
-
md.push(
|
|
4177
|
+
md.push(chunkSPDNHPM4_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
|
|
4168
4178
|
}
|
|
4169
4179
|
return md;
|
|
4170
4180
|
}
|
|
@@ -4449,7 +4459,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
4449
4459
|
expire_at: 0,
|
|
4450
4460
|
cosigners_public_keys: cosignerPubKeys
|
|
4451
4461
|
};
|
|
4452
|
-
const proof =
|
|
4462
|
+
const proof = chunkSPDNHPM4_cjs.Intent.create(message, coins, outputs);
|
|
4453
4463
|
const signedProof = await identity.sign(proof);
|
|
4454
4464
|
return {
|
|
4455
4465
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -6189,7 +6199,7 @@ var ContractWatcher = class {
|
|
|
6189
6199
|
this.connectionState = "connected";
|
|
6190
6200
|
this.reconnectAttempts = 0;
|
|
6191
6201
|
this.listenLoop().catch((e) => {
|
|
6192
|
-
if (
|
|
6202
|
+
if (chunkSPDNHPM4_cjs.isEventSourceError(e)) {
|
|
6193
6203
|
console.debug("ContractWatcher subscription disconnected; reconnecting");
|
|
6194
6204
|
} else {
|
|
6195
6205
|
console.error(e);
|
|
@@ -6629,7 +6639,7 @@ var ContractManager = class _ContractManager {
|
|
|
6629
6639
|
* `persisted` is `true`.
|
|
6630
6640
|
*/
|
|
6631
6641
|
async upsertContract(params) {
|
|
6632
|
-
const handler =
|
|
6642
|
+
const handler = chunkGYSK5R57_cjs.contractHandlers.get(params.type);
|
|
6633
6643
|
if (!handler) {
|
|
6634
6644
|
throw new Error(`No handler registered for contract type '${params.type}'`);
|
|
6635
6645
|
}
|
|
@@ -6690,7 +6700,7 @@ var ContractManager = class _ContractManager {
|
|
|
6690
6700
|
`scanContracts: gapLimit must be a positive integer (got ${String(opts.gapLimit)})`
|
|
6691
6701
|
);
|
|
6692
6702
|
}
|
|
6693
|
-
const discoverables =
|
|
6703
|
+
const discoverables = chunkGYSK5R57_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkGYSK5R57_cjs.contractHandlers.get(t)).filter(isDiscoverable);
|
|
6694
6704
|
const maxIdx = opts.hd ? SCAN_MAX_INDEX : 0;
|
|
6695
6705
|
const handlerErrors = [];
|
|
6696
6706
|
let lastIndexUsed = -1;
|
|
@@ -6846,7 +6856,7 @@ var ContractManager = class _ContractManager {
|
|
|
6846
6856
|
const { contractScript, collaborative = true, walletPubKey, vtxo } = options;
|
|
6847
6857
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
6848
6858
|
if (!contract) return [];
|
|
6849
|
-
const handler =
|
|
6859
|
+
const handler = chunkGYSK5R57_cjs.contractHandlers.get(contract.type);
|
|
6850
6860
|
if (!handler) return [];
|
|
6851
6861
|
const script = handler.createScript(contract.params);
|
|
6852
6862
|
const context = {
|
|
@@ -6866,7 +6876,7 @@ var ContractManager = class _ContractManager {
|
|
|
6866
6876
|
const { contractScript, collaborative = true, walletPubKey } = options;
|
|
6867
6877
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
6868
6878
|
if (!contract) return [];
|
|
6869
|
-
const handler =
|
|
6879
|
+
const handler = chunkGYSK5R57_cjs.contractHandlers.get(contract.type);
|
|
6870
6880
|
if (!handler) return [];
|
|
6871
6881
|
const script = handler.createScript(contract.params);
|
|
6872
6882
|
const context = {
|
|
@@ -7276,7 +7286,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
7276
7286
|
*/
|
|
7277
7287
|
materializeDescriptorAt(index) {
|
|
7278
7288
|
const descriptor = this.identity.descriptor;
|
|
7279
|
-
const network =
|
|
7289
|
+
const network = chunkGYSK5R57_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
7280
7290
|
const expansion = descriptorsScure.expand({ descriptor, network, index });
|
|
7281
7291
|
const keyInfo = expansion.expansionMap?.["@0"];
|
|
7282
7292
|
if (!keyInfo?.keyExpression) {
|
|
@@ -7419,7 +7429,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
7419
7429
|
const provider = await resolveDescriptorProvider(config, setup.walletRepository);
|
|
7420
7430
|
if (!provider) return void 0;
|
|
7421
7431
|
const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
|
|
7422
|
-
const expectedContractType = setup.offchainTapscript instanceof
|
|
7432
|
+
const expectedContractType = setup.offchainTapscript instanceof chunkGYSK5R57_cjs.DelegateVtxo.Script ? "delegate" : "default";
|
|
7423
7433
|
const factoryOpts = {
|
|
7424
7434
|
walletRepository: setup.walletRepository,
|
|
7425
7435
|
contractRepository: setup.contractRepository,
|
|
@@ -7581,7 +7591,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
7581
7591
|
const newScript = base.hex.encode(newTapscript.pkScript);
|
|
7582
7592
|
const newAddress = newTapscript.address(wallet.network.hrp, wallet.arkServerPublicKey).encode();
|
|
7583
7593
|
const manager = await wallet.getContractManager();
|
|
7584
|
-
const csvTimelock = newTapscript.options.csvTimelock
|
|
7594
|
+
const csvTimelock = newTapscript.options.csvTimelock;
|
|
7585
7595
|
const csvTimelockStr = chunkWMIPYZSB_cjs.timelockToSequence(csvTimelock).toString();
|
|
7586
7596
|
const serverPubKeyHex = base.hex.encode(newTapscript.options.serverPubKey);
|
|
7587
7597
|
const baseParams = {
|
|
@@ -7596,11 +7606,11 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
7596
7606
|
// produce unsigned PSBTs that the server rejects with
|
|
7597
7607
|
// `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
7598
7608
|
metadata: {
|
|
7599
|
-
source:
|
|
7609
|
+
source: chunkGYSK5R57_cjs.WALLET_RECEIVE_SOURCE,
|
|
7600
7610
|
signingDescriptor: descriptor
|
|
7601
7611
|
}
|
|
7602
7612
|
};
|
|
7603
|
-
if (newTapscript instanceof
|
|
7613
|
+
if (newTapscript instanceof chunkGYSK5R57_cjs.DelegateVtxo.Script) {
|
|
7604
7614
|
await manager.createContract({
|
|
7605
7615
|
...baseParams,
|
|
7606
7616
|
type: "delegate",
|
|
@@ -7632,7 +7642,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
7632
7642
|
};
|
|
7633
7643
|
function deriveLeafPubkey(descriptor) {
|
|
7634
7644
|
try {
|
|
7635
|
-
return
|
|
7645
|
+
return chunkGYSK5R57_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
7636
7646
|
} catch (e) {
|
|
7637
7647
|
throw new NonRangeableDescriptorError(
|
|
7638
7648
|
"Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
|
|
@@ -7641,10 +7651,10 @@ function deriveLeafPubkey(descriptor) {
|
|
|
7641
7651
|
}
|
|
7642
7652
|
}
|
|
7643
7653
|
function rebuildTapscript(current, pubKey) {
|
|
7644
|
-
if (current instanceof
|
|
7645
|
-
return new
|
|
7654
|
+
if (current instanceof chunkGYSK5R57_cjs.DelegateVtxo.Script) {
|
|
7655
|
+
return new chunkGYSK5R57_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
|
|
7646
7656
|
}
|
|
7647
|
-
return new
|
|
7657
|
+
return new chunkGYSK5R57_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
|
|
7648
7658
|
}
|
|
7649
7659
|
async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
|
|
7650
7660
|
const candidates = await contractRepository.getContracts({
|
|
@@ -7653,7 +7663,7 @@ async function pickActiveReceive(contractRepository, serverPubKey, expectedType)
|
|
|
7653
7663
|
});
|
|
7654
7664
|
const serverPubKeyHex = base.hex.encode(serverPubKey);
|
|
7655
7665
|
const matching = candidates.filter(
|
|
7656
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
7666
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkGYSK5R57_cjs.WALLET_RECEIVE_SOURCE
|
|
7657
7667
|
).sort((a, b) => {
|
|
7658
7668
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
7659
7669
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -7714,8 +7724,24 @@ var InputSignerRouter = class {
|
|
|
7714
7724
|
constructor(deps) {
|
|
7715
7725
|
this.deps = deps;
|
|
7716
7726
|
}
|
|
7717
|
-
|
|
7718
|
-
|
|
7727
|
+
/**
|
|
7728
|
+
* Resolve each job to its target signer without invoking signing. The
|
|
7729
|
+
* returned plan is the single source of truth for both {@link sign} and
|
|
7730
|
+
* the batch-eligibility predicate {@link canBatch} — callers that want
|
|
7731
|
+
* to pre-flight a batch path call {@link canBatch} (which delegates
|
|
7732
|
+
* here) so the routing rules never live in two places.
|
|
7733
|
+
*
|
|
7734
|
+
* Throws {@link MissingSigningDescriptorError} for a non-baseline
|
|
7735
|
+
* default/delegate contract whose `metadata.signingDescriptor` is
|
|
7736
|
+
* missing — the same condition that would later abort signing. Failing
|
|
7737
|
+
* here moves the failure earlier, before any PSBT is mutated.
|
|
7738
|
+
*/
|
|
7739
|
+
async classify(jobs) {
|
|
7740
|
+
const identityIndexes = [];
|
|
7741
|
+
const descriptorGroups = /* @__PURE__ */ new Map();
|
|
7742
|
+
if (jobs.length === 0) {
|
|
7743
|
+
return { identityIndexes, descriptorGroups };
|
|
7744
|
+
}
|
|
7719
7745
|
const distinctScripts = Array.from(new Set(jobs.map((j) => base.hex.encode(j.lookupScript))));
|
|
7720
7746
|
const contracts = await this.deps.contractRepository.getContracts({
|
|
7721
7747
|
script: distinctScripts
|
|
@@ -7728,8 +7754,6 @@ var InputSignerRouter = class {
|
|
|
7728
7754
|
}
|
|
7729
7755
|
const baselinePubKeyHex = base.hex.encode(await this.deps.identity.xOnlyPublicKey());
|
|
7730
7756
|
const boardingScriptHex = base.hex.encode(this.deps.boardingPkScript);
|
|
7731
|
-
const identityIndexes = [];
|
|
7732
|
-
const descriptorGroups = /* @__PURE__ */ new Map();
|
|
7733
7757
|
for (const job of jobs) {
|
|
7734
7758
|
const scriptHex = base.hex.encode(job.lookupScript);
|
|
7735
7759
|
const contract = scriptToContract.get(scriptHex);
|
|
@@ -7762,6 +7786,31 @@ var InputSignerRouter = class {
|
|
|
7762
7786
|
descriptorGroups.set(descriptor, [job.index]);
|
|
7763
7787
|
}
|
|
7764
7788
|
}
|
|
7789
|
+
return { identityIndexes, descriptorGroups };
|
|
7790
|
+
}
|
|
7791
|
+
/**
|
|
7792
|
+
* Returns `true` when every signable input across all `jobSets` resolves
|
|
7793
|
+
* to the baseline {@link Identity} key — i.e. the descriptor provider
|
|
7794
|
+
* would not be invoked. Used by the wallet's send/recovery paths to
|
|
7795
|
+
* pre-flight the {@link BatchSignableIdentity.signMultiple} fast path,
|
|
7796
|
+
* which can only fold work a single identity key can sign.
|
|
7797
|
+
*
|
|
7798
|
+
* Accepts several job sets (e.g. an arkTx's jobs plus one set per
|
|
7799
|
+
* checkpoint) and classifies their union in a single pass. Eligibility
|
|
7800
|
+
* is monotonic — the union routes entirely to the baseline key iff every
|
|
7801
|
+
* set does — so this returns the same answer as ANDing the per-set
|
|
7802
|
+
* results, but with one {@link classify} (one repo round-trip + one
|
|
7803
|
+
* `xOnlyPublicKey` call) instead of one per set. Only the routing buckets
|
|
7804
|
+
* matter here, so the input-index collisions produced by flattening jobs
|
|
7805
|
+
* from different transactions are irrelevant.
|
|
7806
|
+
*/
|
|
7807
|
+
async canBatch(...jobSets) {
|
|
7808
|
+
const plan = await this.classify(jobSets.flat());
|
|
7809
|
+
return plan.descriptorGroups.size === 0;
|
|
7810
|
+
}
|
|
7811
|
+
async sign(tx, jobs) {
|
|
7812
|
+
if (jobs.length === 0) return tx;
|
|
7813
|
+
const { identityIndexes, descriptorGroups } = await this.classify(jobs);
|
|
7765
7814
|
let signed = tx;
|
|
7766
7815
|
if (identityIndexes.length > 0) {
|
|
7767
7816
|
signed = await this.deps.identity.sign(signed, identityIndexes);
|
|
@@ -7819,6 +7868,20 @@ function dedupeTimelocks(timelocks) {
|
|
|
7819
7868
|
}
|
|
7820
7869
|
return deduped;
|
|
7821
7870
|
}
|
|
7871
|
+
function areSameScriptBaselineTypesCompatible(existingType, requestedType) {
|
|
7872
|
+
if (existingType === requestedType) return true;
|
|
7873
|
+
return existingType === "default" && requestedType === "boarding" || existingType === "boarding" && requestedType === "default";
|
|
7874
|
+
}
|
|
7875
|
+
async function ensureWalletContract(manager, params) {
|
|
7876
|
+
const [existing] = await manager.getContracts({ script: params.script });
|
|
7877
|
+
if (existing && existing.type !== params.type && areSameScriptBaselineTypesCompatible(existing.type, params.type)) {
|
|
7878
|
+
if (params.type === "default" && existing.type === "boarding") {
|
|
7879
|
+
await manager.updateContract(params.script, { type: "default" });
|
|
7880
|
+
}
|
|
7881
|
+
return;
|
|
7882
|
+
}
|
|
7883
|
+
await manager.createContract(params);
|
|
7884
|
+
}
|
|
7822
7885
|
function hasToReadonly(identity) {
|
|
7823
7886
|
return typeof identity === "object" && identity !== null && "toReadonly" in identity && typeof identity.toReadonly === "function";
|
|
7824
7887
|
}
|
|
@@ -7847,9 +7910,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
7847
7910
|
this._offchainTapscript = offchainTapscript;
|
|
7848
7911
|
this.watcherConfig = watcherConfig;
|
|
7849
7912
|
this._assetManager = new ReadonlyAssetManager(this.indexerProvider);
|
|
7850
|
-
this.walletContractTimelocks = walletContractTimelocks && walletContractTimelocks.length > 0 ? dedupeTimelocks(walletContractTimelocks) : [
|
|
7851
|
-
this.offchainTapscript.options.csvTimelock ?? chunkIEO3XDKI_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK
|
|
7852
|
-
];
|
|
7913
|
+
this.walletContractTimelocks = walletContractTimelocks && walletContractTimelocks.length > 0 ? dedupeTimelocks(walletContractTimelocks) : [this.offchainTapscript.options.csvTimelock];
|
|
7853
7914
|
}
|
|
7854
7915
|
_contractManager;
|
|
7855
7916
|
_contractManagerInitializing;
|
|
@@ -7887,7 +7948,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
7887
7948
|
*/
|
|
7888
7949
|
static async setupWalletConfig(config, pubKey) {
|
|
7889
7950
|
const arkadeServerUrl = getArkadeServerUrl(config);
|
|
7890
|
-
const arkProvider = config.arkProvider || new
|
|
7951
|
+
const arkProvider = config.arkProvider || new chunkSPDNHPM4_cjs.RestArkProvider(arkadeServerUrl);
|
|
7891
7952
|
let indexerProvider = config.indexerProvider;
|
|
7892
7953
|
if (!indexerProvider) {
|
|
7893
7954
|
let indexerUrl = config.indexerUrl;
|
|
@@ -7904,7 +7965,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
7904
7965
|
indexerUrl = arkadeServerUrl;
|
|
7905
7966
|
}
|
|
7906
7967
|
}
|
|
7907
|
-
indexerProvider = new
|
|
7968
|
+
indexerProvider = new chunkSPDNHPM4_cjs.RestIndexerProvider(indexerUrl);
|
|
7908
7969
|
}
|
|
7909
7970
|
const info = await arkProvider.getInfo();
|
|
7910
7971
|
const network = chunkWMIPYZSB_cjs.getNetwork(info.network);
|
|
@@ -7954,10 +8015,11 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
7954
8015
|
serverPubKey,
|
|
7955
8016
|
csvTimelock: exitTimelock
|
|
7956
8017
|
};
|
|
7957
|
-
const offchainTapscript = !delegatePubKey ? new
|
|
7958
|
-
const boardingTapscript =
|
|
7959
|
-
|
|
7960
|
-
|
|
8018
|
+
const offchainTapscript = !delegatePubKey ? new chunkGYSK5R57_cjs.DefaultVtxo.Script(offchainOptions) : new chunkGYSK5R57_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
|
|
8019
|
+
const boardingTapscript = chunkGYSK5R57_cjs.BoardingContractHandler.createScript({
|
|
8020
|
+
pubKey: base.hex.encode(pubKey),
|
|
8021
|
+
serverPubKey: base.hex.encode(serverPubKey),
|
|
8022
|
+
csvTimelock: chunkWMIPYZSB_cjs.timelockToSequence(boardingTimelock).toString()
|
|
7961
8023
|
});
|
|
7962
8024
|
const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
7963
8025
|
const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
@@ -8297,7 +8359,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
8297
8359
|
});
|
|
8298
8360
|
for (const contract of contracts) {
|
|
8299
8361
|
if (map.has(contract.script)) continue;
|
|
8300
|
-
const handler =
|
|
8362
|
+
const handler = chunkGYSK5R57_cjs.contractHandlers.get(contract.type);
|
|
8301
8363
|
if (handler) {
|
|
8302
8364
|
const script = handler.createScript(contract.params);
|
|
8303
8365
|
map.set(contract.script, script);
|
|
@@ -8364,13 +8426,13 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
8364
8426
|
const baselinePubkey = await this.identity.xOnlyPublicKey();
|
|
8365
8427
|
for (const csvTimelock of this.walletContractTimelocks) {
|
|
8366
8428
|
const csvTimelockStr = chunkWMIPYZSB_cjs.timelockToSequence(csvTimelock).toString();
|
|
8367
|
-
const defaultScript = new
|
|
8429
|
+
const defaultScript = new chunkGYSK5R57_cjs.DefaultVtxo.Script({
|
|
8368
8430
|
pubKey: baselinePubkey,
|
|
8369
8431
|
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
8370
8432
|
csvTimelock
|
|
8371
8433
|
});
|
|
8372
8434
|
const defaultScriptHex = base.hex.encode(defaultScript.pkScript);
|
|
8373
|
-
await manager
|
|
8435
|
+
await ensureWalletContract(manager, {
|
|
8374
8436
|
type: "default",
|
|
8375
8437
|
params: {
|
|
8376
8438
|
pubKey: base.hex.encode(defaultScript.options.pubKey),
|
|
@@ -8381,8 +8443,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
8381
8443
|
address: defaultScript.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
8382
8444
|
state: "active"
|
|
8383
8445
|
});
|
|
8384
|
-
if (this.offchainTapscript instanceof
|
|
8385
|
-
const delegateScript = new
|
|
8446
|
+
if (this.offchainTapscript instanceof chunkGYSK5R57_cjs.DelegateVtxo.Script) {
|
|
8447
|
+
const delegateScript = new chunkGYSK5R57_cjs.DelegateVtxo.Script({
|
|
8386
8448
|
pubKey: baselinePubkey,
|
|
8387
8449
|
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
8388
8450
|
delegatePubKey: this.offchainTapscript.options.delegatePubKey,
|
|
@@ -8403,6 +8465,19 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
8403
8465
|
});
|
|
8404
8466
|
}
|
|
8405
8467
|
}
|
|
8468
|
+
const boardingScriptHex = base.hex.encode(this.boardingTapscript.pkScript);
|
|
8469
|
+
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkGYSK5R57_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
8470
|
+
await ensureWalletContract(manager, {
|
|
8471
|
+
type: "boarding",
|
|
8472
|
+
params: {
|
|
8473
|
+
pubKey: base.hex.encode(this.boardingTapscript.options.pubKey),
|
|
8474
|
+
serverPubKey: base.hex.encode(this.boardingTapscript.options.serverPubKey),
|
|
8475
|
+
csvTimelock: chunkWMIPYZSB_cjs.timelockToSequence(boardingCsvTimelock).toString()
|
|
8476
|
+
},
|
|
8477
|
+
script: boardingScriptHex,
|
|
8478
|
+
address: this.boardingTapscript.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
8479
|
+
state: "active"
|
|
8480
|
+
});
|
|
8406
8481
|
return manager;
|
|
8407
8482
|
}
|
|
8408
8483
|
/** Dispose wallet-owned managers and release background resources. */
|
|
@@ -8583,7 +8658,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
8583
8658
|
const hd = provider instanceof HDDescriptorProvider;
|
|
8584
8659
|
const staticDescriptor = hd ? void 0 : `tr(${base.hex.encode(await this.identity.xOnlyPublicKey())})`;
|
|
8585
8660
|
const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
|
|
8586
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
8661
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkGYSK5R57_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
8587
8662
|
const deps = {
|
|
8588
8663
|
indexerProvider: this.indexerProvider,
|
|
8589
8664
|
onchainProvider: this.onchainProvider,
|
|
@@ -9252,7 +9327,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
9252
9327
|
try {
|
|
9253
9328
|
return await this.arkProvider.registerIntent(intent);
|
|
9254
9329
|
} catch (error) {
|
|
9255
|
-
if (error instanceof
|
|
9330
|
+
if (error instanceof chunkSPDNHPM4_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
|
|
9256
9331
|
const deleteIntent = await this.makeDeleteIntentSignature(inputs);
|
|
9257
9332
|
await this.arkProvider.deleteIntent(deleteIntent);
|
|
9258
9333
|
return this.arkProvider.registerIntent(intent);
|
|
@@ -9268,7 +9343,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
9268
9343
|
expire_at: 0,
|
|
9269
9344
|
cosigners_public_keys: cosignerPubKeys
|
|
9270
9345
|
};
|
|
9271
|
-
const proof =
|
|
9346
|
+
const proof = chunkSPDNHPM4_cjs.Intent.create(message, coins, outputs);
|
|
9272
9347
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
9273
9348
|
return {
|
|
9274
9349
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -9280,7 +9355,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
9280
9355
|
type: "delete",
|
|
9281
9356
|
expire_at: 0
|
|
9282
9357
|
};
|
|
9283
|
-
const proof =
|
|
9358
|
+
const proof = chunkSPDNHPM4_cjs.Intent.create(message, coins, []);
|
|
9284
9359
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
9285
9360
|
return {
|
|
9286
9361
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -9292,7 +9367,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
9292
9367
|
type: "get-pending-tx",
|
|
9293
9368
|
expire_at: 0
|
|
9294
9369
|
};
|
|
9295
|
-
const proof =
|
|
9370
|
+
const proof = chunkSPDNHPM4_cjs.Intent.create(message, coins, []);
|
|
9296
9371
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
9297
9372
|
return {
|
|
9298
9373
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -9352,16 +9427,38 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
9352
9427
|
seen.add(pendingTx.arkTxid);
|
|
9353
9428
|
batchPending.push(pendingTx.arkTxid);
|
|
9354
9429
|
try {
|
|
9355
|
-
const
|
|
9356
|
-
|
|
9357
|
-
const tx = btcSigner.Transaction.fromPSBT(base.base64.decode(c));
|
|
9358
|
-
const signedCheckpoint = await this._signerRouter.sign(
|
|
9359
|
-
tx,
|
|
9360
|
-
this.inputSigningJobsFromWitnessUtxos(tx)
|
|
9361
|
-
);
|
|
9362
|
-
return base.base64.encode(signedCheckpoint.toPSBT());
|
|
9363
|
-
})
|
|
9430
|
+
const checkpointTxs = pendingTx.signedCheckpointTxs.map(
|
|
9431
|
+
(c) => btcSigner.Transaction.fromPSBT(base.base64.decode(c))
|
|
9364
9432
|
);
|
|
9433
|
+
const checkpointJobs = checkpointTxs.map(
|
|
9434
|
+
(tx) => this.inputSigningJobsFromWitnessUtxos(tx)
|
|
9435
|
+
);
|
|
9436
|
+
const identity = this.identity;
|
|
9437
|
+
const batchEligible = isBatchSignable(identity) && await this._signerRouter.canBatch(...checkpointJobs);
|
|
9438
|
+
let finalCheckpoints;
|
|
9439
|
+
if (batchEligible) {
|
|
9440
|
+
const requests = checkpointTxs.map((tx, i) => ({
|
|
9441
|
+
tx,
|
|
9442
|
+
inputIndexes: checkpointJobs[i].map((j) => j.index)
|
|
9443
|
+
}));
|
|
9444
|
+
const signed = await identity.signMultiple(requests);
|
|
9445
|
+
if (signed.length !== requests.length) {
|
|
9446
|
+
throw new Error(
|
|
9447
|
+
`signMultiple returned ${signed.length} transactions, expected ${requests.length}`
|
|
9448
|
+
);
|
|
9449
|
+
}
|
|
9450
|
+
finalCheckpoints = signed.map((tx) => base.base64.encode(tx.toPSBT()));
|
|
9451
|
+
} else {
|
|
9452
|
+
finalCheckpoints = await Promise.all(
|
|
9453
|
+
checkpointTxs.map(async (tx, i) => {
|
|
9454
|
+
const signedCheckpoint = await this._signerRouter.sign(
|
|
9455
|
+
tx,
|
|
9456
|
+
checkpointJobs[i]
|
|
9457
|
+
);
|
|
9458
|
+
return base.base64.encode(signedCheckpoint.toPSBT());
|
|
9459
|
+
})
|
|
9460
|
+
);
|
|
9461
|
+
}
|
|
9365
9462
|
await this.arkProvider.finalizeTx(pendingTx.arkTxid, finalCheckpoints);
|
|
9366
9463
|
batchFinalized.push(pendingTx.arkTxid);
|
|
9367
9464
|
} catch (error) {
|
|
@@ -9589,22 +9686,65 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
|
|
|
9589
9686
|
index,
|
|
9590
9687
|
lookupScript: chunkWMIPYZSB_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
9591
9688
|
}));
|
|
9592
|
-
const
|
|
9689
|
+
const checkpointJobs = offchainTx.checkpoints.map(
|
|
9690
|
+
(c) => this.inputSigningJobsFromWitnessUtxos(c)
|
|
9691
|
+
);
|
|
9692
|
+
let signedVirtualTx;
|
|
9693
|
+
let userSignedCheckpoints;
|
|
9694
|
+
const identity = this.identity;
|
|
9695
|
+
const batchEligible = isBatchSignable(identity) && await this._signerRouter.canBatch(arkTxJobs, ...checkpointJobs);
|
|
9696
|
+
if (batchEligible) {
|
|
9697
|
+
const requests = [
|
|
9698
|
+
{
|
|
9699
|
+
tx: offchainTx.arkTx.clone(),
|
|
9700
|
+
inputIndexes: arkTxJobs.map((j) => j.index)
|
|
9701
|
+
},
|
|
9702
|
+
...offchainTx.checkpoints.map((c, i) => ({
|
|
9703
|
+
tx: c.clone(),
|
|
9704
|
+
inputIndexes: checkpointJobs[i].map((j) => j.index)
|
|
9705
|
+
}))
|
|
9706
|
+
];
|
|
9707
|
+
const signed = await identity.signMultiple(requests);
|
|
9708
|
+
if (signed.length !== requests.length) {
|
|
9709
|
+
throw new Error(
|
|
9710
|
+
`signMultiple returned ${signed.length} transactions, expected ${requests.length}`
|
|
9711
|
+
);
|
|
9712
|
+
}
|
|
9713
|
+
const [firstSignedTx, ...signedCheckpoints] = signed;
|
|
9714
|
+
signedVirtualTx = firstSignedTx;
|
|
9715
|
+
userSignedCheckpoints = signedCheckpoints;
|
|
9716
|
+
} else {
|
|
9717
|
+
signedVirtualTx = await this._signerRouter.sign(offchainTx.arkTx, arkTxJobs);
|
|
9718
|
+
}
|
|
9593
9719
|
await this.setPendingTxFlag(true);
|
|
9594
9720
|
const { arkTxid, signedCheckpointTxs } = await this.arkProvider.submitTx(
|
|
9595
9721
|
base.base64.encode(signedVirtualTx.toPSBT()),
|
|
9596
9722
|
offchainTx.checkpoints.map((c) => base.base64.encode(c.toPSBT()))
|
|
9597
9723
|
);
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
9601
|
-
|
|
9602
|
-
|
|
9603
|
-
this.inputSigningJobsFromWitnessUtxos(tx)
|
|
9724
|
+
let finalCheckpoints;
|
|
9725
|
+
if (userSignedCheckpoints) {
|
|
9726
|
+
if (signedCheckpointTxs.length !== userSignedCheckpoints.length) {
|
|
9727
|
+
throw new Error(
|
|
9728
|
+
`submitTx returned ${signedCheckpointTxs.length} checkpoints, expected ${userSignedCheckpoints.length}`
|
|
9604
9729
|
);
|
|
9605
|
-
|
|
9606
|
-
|
|
9607
|
-
|
|
9730
|
+
}
|
|
9731
|
+
finalCheckpoints = signedCheckpointTxs.map((c, i) => {
|
|
9732
|
+
const serverSigned = btcSigner.Transaction.fromPSBT(base.base64.decode(c));
|
|
9733
|
+
combineTapscriptSigs(userSignedCheckpoints[i], serverSigned);
|
|
9734
|
+
return base.base64.encode(serverSigned.toPSBT());
|
|
9735
|
+
});
|
|
9736
|
+
} else {
|
|
9737
|
+
finalCheckpoints = await Promise.all(
|
|
9738
|
+
signedCheckpointTxs.map(async (c) => {
|
|
9739
|
+
const tx = btcSigner.Transaction.fromPSBT(base.base64.decode(c));
|
|
9740
|
+
const signedCheckpoint = await this._signerRouter.sign(
|
|
9741
|
+
tx,
|
|
9742
|
+
this.inputSigningJobsFromWitnessUtxos(tx)
|
|
9743
|
+
);
|
|
9744
|
+
return base.base64.encode(signedCheckpoint.toPSBT());
|
|
9745
|
+
})
|
|
9746
|
+
);
|
|
9747
|
+
}
|
|
9608
9748
|
await this.arkProvider.finalizeTx(arkTxid, finalCheckpoints);
|
|
9609
9749
|
try {
|
|
9610
9750
|
await this.setPendingTxFlag(false);
|
|
@@ -9854,12 +9994,17 @@ function selectVirtualCoins(coins, targetAmount) {
|
|
|
9854
9994
|
}
|
|
9855
9995
|
async function waitForIncomingFunds(wallet) {
|
|
9856
9996
|
let stopFunc;
|
|
9997
|
+
let settled = false;
|
|
9857
9998
|
return new Promise((resolve) => {
|
|
9858
|
-
wallet.notifyIncomingFunds((
|
|
9859
|
-
|
|
9860
|
-
if (
|
|
9999
|
+
wallet.notifyIncomingFunds((funds) => {
|
|
10000
|
+
const hasFunds = funds.type === "utxo" ? funds.coins.length > 0 : funds.newVtxos.length > 0;
|
|
10001
|
+
if (settled || !hasFunds) return;
|
|
10002
|
+
settled = true;
|
|
10003
|
+
resolve(funds);
|
|
10004
|
+
stopFunc?.();
|
|
9861
10005
|
}).then((stop) => {
|
|
9862
10006
|
stopFunc = stop;
|
|
10007
|
+
if (settled) stop();
|
|
9863
10008
|
});
|
|
9864
10009
|
});
|
|
9865
10010
|
}
|
|
@@ -10016,7 +10161,7 @@ var MessageBus = class {
|
|
|
10016
10161
|
this.initialized = true;
|
|
10017
10162
|
}
|
|
10018
10163
|
async buildServices(config) {
|
|
10019
|
-
const arkProvider = new
|
|
10164
|
+
const arkProvider = new chunkSPDNHPM4_cjs.RestArkProvider(config.arkServer.url);
|
|
10020
10165
|
const storage = {
|
|
10021
10166
|
walletRepository: this.walletRepository,
|
|
10022
10167
|
contractRepository: this.contractRepository
|
|
@@ -11059,7 +11204,7 @@ var WalletMessageHandler = class {
|
|
|
11059
11204
|
// Wallet methods
|
|
11060
11205
|
async handleInitWallet({ payload }) {
|
|
11061
11206
|
const { arkServerUrl } = payload;
|
|
11062
|
-
this.indexerProvider = new
|
|
11207
|
+
this.indexerProvider = new chunkSPDNHPM4_cjs.RestIndexerProvider(arkServerUrl);
|
|
11063
11208
|
await this.onWalletInitialized();
|
|
11064
11209
|
}
|
|
11065
11210
|
async handleGetBalance() {
|
|
@@ -12803,7 +12948,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
12803
12948
|
if (!inputs) {
|
|
12804
12949
|
throw new Error("Fee estimation failed");
|
|
12805
12950
|
}
|
|
12806
|
-
let tx = new
|
|
12951
|
+
let tx = new chunkSPDNHPM4_cjs.Transaction();
|
|
12807
12952
|
for (const input of inputs) {
|
|
12808
12953
|
tx.addInput({
|
|
12809
12954
|
txid: input.txid,
|
|
@@ -12834,7 +12979,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
12834
12979
|
*/
|
|
12835
12980
|
async bumpP2A(parent) {
|
|
12836
12981
|
const parentVsize = parent.vsize;
|
|
12837
|
-
let child = new
|
|
12982
|
+
let child = new chunkSPDNHPM4_cjs.Transaction({
|
|
12838
12983
|
version: 3,
|
|
12839
12984
|
allowLegacyWitnessUtxo: true
|
|
12840
12985
|
});
|
|
@@ -13591,7 +13736,7 @@ exports.BIP322 = void 0;
|
|
|
13591
13736
|
async function sign2(message, identity, network) {
|
|
13592
13737
|
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
13593
13738
|
const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
|
|
13594
|
-
const toSpend =
|
|
13739
|
+
const toSpend = chunkSPDNHPM4_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
13595
13740
|
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
13596
13741
|
const signed = await identity.sign(toSign, [0]);
|
|
13597
13742
|
signed.finalizeIdx(0);
|
|
@@ -13649,7 +13794,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
|
13649
13794
|
if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
|
|
13650
13795
|
return false;
|
|
13651
13796
|
}
|
|
13652
|
-
const toSpend =
|
|
13797
|
+
const toSpend = chunkSPDNHPM4_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
13653
13798
|
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
|
|
13654
13799
|
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
13655
13800
|
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
@@ -13670,7 +13815,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
|
13670
13815
|
}
|
|
13671
13816
|
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
13672
13817
|
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
13673
|
-
const toSpend =
|
|
13818
|
+
const toSpend = chunkSPDNHPM4_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
13674
13819
|
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
13675
13820
|
const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
|
|
13676
13821
|
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
@@ -13723,7 +13868,7 @@ function encodeCompactSize(n) {
|
|
|
13723
13868
|
return buf;
|
|
13724
13869
|
}
|
|
13725
13870
|
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
13726
|
-
const tx = new
|
|
13871
|
+
const tx = new chunkSPDNHPM4_cjs.Transaction({ version: 0 });
|
|
13727
13872
|
tx.addInput({
|
|
13728
13873
|
txid: toSpend.id,
|
|
13729
13874
|
index: 0,
|
|
@@ -13737,12 +13882,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
|
13737
13882
|
});
|
|
13738
13883
|
tx.addOutput({
|
|
13739
13884
|
amount: 0n,
|
|
13740
|
-
script:
|
|
13885
|
+
script: chunkSPDNHPM4_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
13741
13886
|
});
|
|
13742
13887
|
return tx;
|
|
13743
13888
|
}
|
|
13744
13889
|
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
13745
|
-
const tx = new
|
|
13890
|
+
const tx = new chunkSPDNHPM4_cjs.Transaction({ version: 0 });
|
|
13746
13891
|
tx.addInput({
|
|
13747
13892
|
txid: toSpend.id,
|
|
13748
13893
|
index: 0,
|
|
@@ -13754,7 +13899,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
|
13754
13899
|
});
|
|
13755
13900
|
tx.addOutput({
|
|
13756
13901
|
amount: 0n,
|
|
13757
|
-
script:
|
|
13902
|
+
script: chunkSPDNHPM4_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
13758
13903
|
});
|
|
13759
13904
|
return tx;
|
|
13760
13905
|
}
|
|
@@ -13815,7 +13960,7 @@ exports.Unroll = void 0;
|
|
|
13815
13960
|
if (virtualTxs.txs.length === 0) {
|
|
13816
13961
|
throw new Error(`Tx ${nextTxToBroadcast.txid} not found`);
|
|
13817
13962
|
}
|
|
13818
|
-
const tx =
|
|
13963
|
+
const tx = chunkSPDNHPM4_cjs.Transaction.fromPSBT(base.base64.decode(virtualTxs.txs[0]));
|
|
13819
13964
|
if (nextTxToBroadcast.type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
|
|
13820
13965
|
const input = tx.getInput(0);
|
|
13821
13966
|
if (!input) {
|
|
@@ -13915,7 +14060,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
13915
14060
|
btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
|
|
13916
14061
|
);
|
|
13917
14062
|
}
|
|
13918
|
-
const tx = new
|
|
14063
|
+
const tx = new chunkSPDNHPM4_cjs.Transaction({ version: 2 });
|
|
13919
14064
|
for (const input of inputs) {
|
|
13920
14065
|
tx.addInput(input);
|
|
13921
14066
|
}
|
|
@@ -14001,7 +14146,7 @@ function decodeArkContract(encoded) {
|
|
|
14001
14146
|
}
|
|
14002
14147
|
function contractFromArkContract(encoded, options = {}) {
|
|
14003
14148
|
const parsed = decodeArkContract(encoded);
|
|
14004
|
-
const handler =
|
|
14149
|
+
const handler = chunkGYSK5R57_cjs.contractHandlers.get(parsed.type);
|
|
14005
14150
|
if (!handler) {
|
|
14006
14151
|
throw new Error(`No handler registered for contract type '${parsed.type}'`);
|
|
14007
14152
|
}
|
|
@@ -14017,7 +14162,7 @@ function contractFromArkContract(encoded, options = {}) {
|
|
|
14017
14162
|
}
|
|
14018
14163
|
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkWMIPYZSB_cjs.DEFAULT_NETWORK.hrp, options = {}) {
|
|
14019
14164
|
const parsed = decodeArkContract(encoded);
|
|
14020
|
-
const handler =
|
|
14165
|
+
const handler = chunkGYSK5R57_cjs.contractHandlers.getOrThrow(parsed.type);
|
|
14021
14166
|
const params = parsed.data;
|
|
14022
14167
|
const vtxoScript = handler.createScript(params);
|
|
14023
14168
|
return {
|
|
@@ -14129,5 +14274,5 @@ exports.validateVtxoTxGraph = validateVtxoTxGraph;
|
|
|
14129
14274
|
exports.verifyTapscriptSignatures = verifyTapscriptSignatures;
|
|
14130
14275
|
exports.waitForIncomingFunds = waitForIncomingFunds;
|
|
14131
14276
|
exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
|
|
14132
|
-
//# sourceMappingURL=chunk-
|
|
14133
|
-
//# sourceMappingURL=chunk-
|
|
14277
|
+
//# sourceMappingURL=chunk-7K3ROJF6.cjs.map
|
|
14278
|
+
//# sourceMappingURL=chunk-7K3ROJF6.cjs.map
|