@arkade-os/sdk 0.5.2 → 0.5.4
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/README.md +36 -34
- package/dist/adapters/expo.cjs +9 -5
- package/dist/adapters/expo.d.cts +11 -7
- package/dist/adapters/expo.d.ts +11 -7
- package/dist/adapters/expo.js +3 -3
- package/dist/{asyncStorageTaskQueue-DIn7bTqN.d.ts → asyncStorageTaskQueue-DHMIxY04.d.ts} +2 -2
- package/dist/{asyncStorageTaskQueue-BtEc3Qca.d.cts → asyncStorageTaskQueue-DTBa8EH7.d.cts} +2 -2
- package/dist/{chunk-LWRMSC4M.js → chunk-6CUP6ZIF.js} +4 -4
- package/dist/{chunk-LWRMSC4M.js.map → chunk-6CUP6ZIF.js.map} +1 -1
- package/dist/{chunk-HKG26NUT.js → chunk-AG4TFD6F.js} +140 -59
- package/dist/chunk-AG4TFD6F.js.map +1 -0
- package/dist/{chunk-PVFQFQBY.cjs → chunk-B6VNKGIH.cjs} +10 -10
- package/dist/chunk-B6VNKGIH.cjs.map +1 -0
- package/dist/{chunk-U5XG7SWA.js → chunk-BTRCN4JJ.js} +22 -19
- package/dist/chunk-BTRCN4JJ.js.map +1 -0
- package/dist/{chunk-TAIWH3HG.cjs → chunk-DNITZVNG.cjs} +28 -47
- package/dist/chunk-DNITZVNG.cjs.map +1 -0
- package/dist/{chunk-OM6FJ76H.cjs → chunk-E6OOJEHL.cjs} +49 -49
- package/dist/{chunk-OM6FJ76H.cjs.map → chunk-E6OOJEHL.cjs.map} +1 -1
- package/dist/{chunk-2OCYL6BJ.cjs → chunk-F3FAE7VJ.cjs} +850 -652
- package/dist/chunk-F3FAE7VJ.cjs.map +1 -0
- package/dist/{chunk-GGKR4O5X.cjs → chunk-GHUUT54D.cjs} +143 -58
- package/dist/chunk-GHUUT54D.cjs.map +1 -0
- package/dist/{chunk-MOBDJ7U2.js → chunk-MWVAWFX6.js} +4 -4
- package/dist/chunk-MWVAWFX6.js.map +1 -0
- package/dist/{chunk-2QRUQXLS.js → chunk-TUOLZBNC.js} +19 -39
- package/dist/chunk-TUOLZBNC.js.map +1 -0
- package/dist/{chunk-64R7CRKN.cjs → chunk-WXNSISXK.cjs} +37 -34
- package/dist/chunk-WXNSISXK.cjs.map +1 -0
- package/dist/{chunk-AJWXVQYG.js → chunk-ZJHLLDBP.js} +372 -177
- package/dist/chunk-ZJHLLDBP.js.map +1 -0
- package/dist/contracts/handlers/index.cjs +9 -9
- 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-CaL8EN4Q.d.cts → delegate-f4_t864Z.d.cts} +1 -1
- package/dist/{delegate-Jd4zs88Q.d.ts → delegate-xrSBNybC.d.ts} +1 -1
- package/dist/{index-D-xqVzf8.d.ts → index-BJDz15ms.d.ts} +5 -5
- package/dist/{index-BwdGzNSn.d.cts → index-BjiVGtp8.d.cts} +5 -5
- package/dist/{index-DdKxfC29.d.cts → index-DRwe0UDN.d.cts} +194 -114
- package/dist/{index-DdKxfC29.d.ts → index-DRwe0UDN.d.ts} +194 -114
- package/dist/index.cjs +333 -313
- package/dist/index.d.cts +80 -45
- package/dist/index.d.ts +80 -45
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +65 -36
- package/dist/repositories/realm/index.cjs.map +1 -1
- package/dist/repositories/realm/index.d.cts +7 -3
- package/dist/repositories/realm/index.d.ts +7 -3
- package/dist/repositories/realm/index.js +35 -6
- package/dist/repositories/realm/index.js.map +1 -1
- package/dist/repositories/sqlite/index.cjs +176 -110
- package/dist/repositories/sqlite/index.cjs.map +1 -1
- package/dist/repositories/sqlite/index.d.cts +23 -13
- package/dist/repositories/sqlite/index.d.ts +23 -13
- package/dist/repositories/sqlite/index.js +148 -83
- package/dist/repositories/sqlite/index.js.map +1 -1
- package/dist/{taskRunner-ZyGGjtIq.d.ts → taskRunner-BPPU-YHG.d.cts} +4 -4
- package/dist/{taskRunner-67YSEpsz.d.cts → taskRunner-CDlNeth0.d.ts} +4 -4
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.cjs.map +1 -1
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +7 -7
- package/dist/wallet/expo/background.js.map +1 -1
- package/dist/wallet/expo/index.cjs +18 -15
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +7 -6
- package/dist/wallet/expo/index.d.ts +7 -6
- package/dist/wallet/expo/index.js +9 -6
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/{wallet-bFS7VybL.d.ts → wallet-Oc3Wd5gv.d.ts} +27 -19
- package/dist/{wallet-B8LW7cV1.d.cts → wallet-jVBDQl6R.d.cts} +27 -19
- 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-2OCYL6BJ.cjs.map +0 -1
- package/dist/chunk-2QRUQXLS.js.map +0 -1
- package/dist/chunk-64R7CRKN.cjs.map +0 -1
- package/dist/chunk-AJWXVQYG.js.map +0 -1
- package/dist/chunk-GGKR4O5X.cjs.map +0 -1
- package/dist/chunk-HKG26NUT.js.map +0 -1
- package/dist/chunk-MOBDJ7U2.js.map +0 -1
- package/dist/chunk-PVFQFQBY.cjs.map +0 -1
- package/dist/chunk-TAIWH3HG.cjs.map +0 -1
- package/dist/chunk-U5XG7SWA.js.map +0 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Packet, AssetId, AssetGroup, AssetInput, AssetOutput, Metadata, RestIndexerProvider, BufferReader, BufferWriter, AssetRef } from './chunk-
|
|
2
|
-
import { witnessRefToBytes, validateProgram, toASM, stringifyArtifact, serializeArkadeContractParams, resolveAsm, parseArtifact, getOpcodeValue, getOpcodeName, fromASM, deserializeArkadeContractParams, computeArkadeScriptPublicKey, bytesToASM, asmToBytes, arkadeWitnessHash, arkadeScriptHash, UnsupportedProgramVersionError, SUPPORTED_PROGRAM_VERSION, OPCODE_VALUES, OPCODE_NAMES, bignum_exports, ArkadeScript, ArkadeProgramScript, ARKADE_OPS, ARKADE_OPCODE_VALUES, ARKADE_OPCODE_NAMES, ARKADE_OPCODES, ARKADE_OP, toXOnly, ARKADE_TYPE_ENCODINGS, validateParamValue, contractHandlers, speculativeReceiveMetadata, isMainnetDescriptor, descriptorIsOurs, deriveDescriptorLeafPubKey, deriveDescriptorLeafCompressedPubKey, normalizeToDescriptor, extractPubKey, parseHDDescriptor, identityDescriptor, DefaultVtxo, DelegateVtxo, WALLET_RECEIVE_SOURCE, BoardingContractHandler } from './chunk-
|
|
3
|
-
import { VtxoScript, __export, Transaction, requiresForfeit, CSVMultisigTapscript, networks, getNetwork, DEFAULT_NETWORK, resolveEmulatorPubkey, timelockToSequence, isVtxoSpent, getNormalizedVtxos, setArkPsbtField, PrevArkTxField, ConditionWitness,
|
|
4
|
-
import { sha256, equalBytes, hash160, sha256x2, concatBytes, randomPrivateKeyBytes, pubECDSA, pubSchnorr } from '@scure/btc-signer/utils.js';
|
|
5
|
-
import { SigHash, Script, OP, OutScript, Address, RawWitness, p2tr, p2wpkh, TaprootControlBlock, DEFAULT_SEQUENCE, Transaction as Transaction$1 } from '@scure/btc-signer';
|
|
6
|
-
import { hex, base58, base64, bech32m } from '@scure/base';
|
|
1
|
+
import { Packet, AssetId, AssetGroup, AssetInput, AssetOutput, Metadata, RestIndexerProvider, BufferReader, BufferWriter, AssetRef } from './chunk-BTRCN4JJ.js';
|
|
2
|
+
import { witnessRefToBytes, validateProgram, toASM, stringifyArtifact, serializeArkadeContractParams, resolveAsm, parseArtifact, getOpcodeValue, getOpcodeName, fromASM, deserializeArkadeContractParams, computeArkadeScriptPublicKey, bytesToASM, asmToBytes, arkadeWitnessHash, arkadeScriptHash, UnsupportedProgramVersionError, SUPPORTED_PROGRAM_VERSION, OPCODE_VALUES, OPCODE_NAMES, bignum_exports, ArkadeScript, ArkadeProgramScript, ARKADE_OPS, ARKADE_OPCODE_VALUES, ARKADE_OPCODE_NAMES, ARKADE_OPCODES, ARKADE_OP, toXOnly, ARKADE_TYPE_ENCODINGS, validateParamValue, contractHandlers, speculativeReceiveMetadata, isMainnetDescriptor, descriptorIsOurs, deriveDescriptorLeafPubKey, deriveDescriptorLeafCompressedPubKey, normalizeToDescriptor, extractPubKey, parseHDDescriptor, identityDescriptor, DefaultVtxo, DelegateVtxo, WALLET_RECEIVE_SOURCE, BoardingContractHandler } from './chunk-6CUP6ZIF.js';
|
|
3
|
+
import { VtxoScript, __export, Transaction, requiresForfeit, CSVMultisigTapscript, networks, getNetwork, DEFAULT_NETWORK, resolveEmulatorPubkey, timelockToSequence, isVtxoSpent, getNormalizedVtxos, setArkPsbtField, PrevArkTxField, ConditionWitness, craftToSpendTx, RestOperatorProvider, ArkAddress, isVirtualCoin, getArkPsbtFields, CosignerPublicKey, ServerResponseMismatchError, assertNonNegativeMs, isRetryableProviderError, getAllNormalizedVtxos, DEFAULT_PAGE_SIZE, assertAllowedSighashTypes, OP_RETURN_EMPTY_PKSCRIPT, canSweepOnchain, sequenceToTimelock, DEFAULT_ARKADE_SERVER_URL, baseFetch, DEFAULT_NETWORK_NAME, sequenceToCanonicalTimelock, assertTimerMs, isEventSourceError, isEventSourceUnavailableError, normalizeVtxo, isPastExpiry, decodeTapscript, scriptFromTapLeafScript, CLTVMultisigTapscript, VtxoTaprootTree, formatSighash, isArkError, ArkErrorName, Proof, rateGate, getSequence, maybeArkError, toOffchainInputFeeParams, canRecoverOnchain, MultisigTapscript, DEFAULT_ARKADE_EMULATOR_URL, networkFromArkadeInfo, Intent, ArkError, toBIP371TapTree, resolveTimeHeight, canSpendOffchain, INFO_FETCH_TIMEOUT_MS, PrevoutTxField, fetchVtxoCreatedAtByTxid, EXPIRY_MIN_PLAUSIBLE_MS, ProviderUnavailableError } from './chunk-AG4TFD6F.js';
|
|
7
4
|
import * as musig2 from '@scure/btc-signer/musig2.js';
|
|
5
|
+
import { hex, base58, base64, bech32m } from '@scure/base';
|
|
8
6
|
import { equalBytes as equalBytes$1, randomBytes, bytesToNumberBE } from '@noble/curves/utils.js';
|
|
9
7
|
import { signAsync, schnorr as schnorr$1, Point } from '@noble/secp256k1';
|
|
10
8
|
import { secp256k1, schnorr } from '@noble/curves/secp256k1.js';
|
|
11
9
|
import { Script as Script$1 } from '@scure/btc-signer/script.js';
|
|
12
10
|
import { SigHash as SigHash$1 } from '@scure/btc-signer/transaction.js';
|
|
11
|
+
import { sha256, equalBytes, hash160, sha256x2, concatBytes, randomPrivateKeyBytes, pubECDSA, pubSchnorr } from '@scure/btc-signer/utils.js';
|
|
12
|
+
import { SigHash, Script, OP, OutScript, Address, RawWitness, p2tr, p2wpkh, TaprootControlBlock, DEFAULT_SEQUENCE, Transaction as Transaction$1 } from '@scure/btc-signer';
|
|
13
13
|
import { mnemonicToSeedSync, validateMnemonic } from '@scure/bip39';
|
|
14
14
|
import { wordlist } from '@scure/bip39/wordlists/english.js';
|
|
15
15
|
import { networks as networks$1, scriptExpressions, HDKey, expand } from '@bitcoinerlab/descriptors-scure';
|
|
@@ -123,6 +123,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
123
123
|
graph = null;
|
|
124
124
|
scriptRoot = null;
|
|
125
125
|
rootSharedOutputAmount = null;
|
|
126
|
+
/** Use a fresh key/session per signing attempt; never reuse sessions or their nonces. */
|
|
126
127
|
static random() {
|
|
127
128
|
const secretKey = randomPrivateKeyBytes();
|
|
128
129
|
return new _TreeSignerSession(secretKey);
|
|
@@ -891,9 +892,14 @@ var OVERLAP_MS = 24 * 60 * 60 * 1e3;
|
|
|
891
892
|
var walletStateLocks = /* @__PURE__ */ new WeakMap();
|
|
892
893
|
var WALLET_STATE_LOCK_NAME = "arkade-wallet-state";
|
|
893
894
|
async function updateWalletState(repo, updater) {
|
|
895
|
+
const atomic = repo.atomicWalletState;
|
|
894
896
|
const prev = walletStateLocks.get(repo) ?? Promise.resolve();
|
|
895
897
|
const op = prev.then(
|
|
896
898
|
() => withWebLock(WALLET_STATE_LOCK_NAME, async () => {
|
|
899
|
+
if (atomic !== void 0) {
|
|
900
|
+
await atomic.update(updater);
|
|
901
|
+
return;
|
|
902
|
+
}
|
|
897
903
|
const state = await repo.getWalletState() ?? {};
|
|
898
904
|
await repo.saveWalletState(updater(state));
|
|
899
905
|
})
|
|
@@ -1603,7 +1609,7 @@ var RestDelegateProvider = class {
|
|
|
1603
1609
|
},
|
|
1604
1610
|
body: JSON.stringify({
|
|
1605
1611
|
intent: {
|
|
1606
|
-
message:
|
|
1612
|
+
message: Proof.encodeMessage(intent.message),
|
|
1607
1613
|
proof: intent.proof
|
|
1608
1614
|
},
|
|
1609
1615
|
forfeit_txs: forfeitTxs,
|
|
@@ -1700,6 +1706,15 @@ function assertHistoryPageFilter(filter) {
|
|
|
1700
1706
|
throw new RangeError("history since must be non-negative Unix milliseconds");
|
|
1701
1707
|
}
|
|
1702
1708
|
}
|
|
1709
|
+
function applyWalletStateUpdate(state, updater) {
|
|
1710
|
+
const updated = updater(state);
|
|
1711
|
+
if (updated && typeof updated.then === "function") {
|
|
1712
|
+
if (updated instanceof Promise) void updated.catch(() => {
|
|
1713
|
+
});
|
|
1714
|
+
throw new TypeError("wallet-state updater must be synchronous");
|
|
1715
|
+
}
|
|
1716
|
+
return updated;
|
|
1717
|
+
}
|
|
1703
1718
|
function compareScriptVtxoCursors(a, b) {
|
|
1704
1719
|
return a.address < b.address ? -1 : a.address > b.address ? 1 : compareOutpoints(a, b);
|
|
1705
1720
|
}
|
|
@@ -2862,10 +2877,10 @@ var ErrUnvalidatedOffchainOutput = (address) => new ServerResponseMismatchError(
|
|
|
2862
2877
|
`offchain output ${address} cannot be validated: virtual output tree signing did not run`
|
|
2863
2878
|
);
|
|
2864
2879
|
var ErrIntentOutputNotFound = (index, kind) => new ServerResponseMismatchError(
|
|
2865
|
-
`${kind} output ${index} of the
|
|
2880
|
+
`${kind} output ${index} of the proof is not present in what the server built`
|
|
2866
2881
|
);
|
|
2867
2882
|
var ErrUnvalidatedIntentOutput = (index) => new ServerResponseMismatchError(
|
|
2868
|
-
`offchain output ${index} of the
|
|
2883
|
+
`offchain output ${index} of the proof cannot be validated: virtual output tree signing did not run`
|
|
2869
2884
|
);
|
|
2870
2885
|
var ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
|
|
2871
2886
|
var ErrInvalidOnchainOutputAssets = (address) => new Error(`onchain output ${address} cannot have assets`);
|
|
@@ -3833,32 +3848,36 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
3833
3848
|
}
|
|
3834
3849
|
}
|
|
3835
3850
|
async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
3836
|
-
const
|
|
3851
|
+
const oneShot = options?.oneShot !== false;
|
|
3852
|
+
const { arkTx: signedArkTx, userSignedCheckpoints: batchSigned } = await signer.signArkTx(
|
|
3837
3853
|
offchainTx.arkTx,
|
|
3838
3854
|
offchainTx.checkpoints
|
|
3839
3855
|
);
|
|
3840
|
-
if (
|
|
3856
|
+
if (batchSigned && batchSigned.length !== offchainTx.checkpoints.length) {
|
|
3841
3857
|
throw new Error(
|
|
3842
|
-
`signer returned ${
|
|
3858
|
+
`signer returned ${batchSigned.length} signed checkpoints, expected ${offchainTx.checkpoints.length}`
|
|
3843
3859
|
);
|
|
3844
3860
|
}
|
|
3861
|
+
const userSignedCheckpoints = (batchSigned ?? (oneShot ? await Promise.all(offchainTx.checkpoints.map((c) => signer.signCheckpoint(c.clone()))) : void 0))?.map((c) => withArkInputWitness(c, signedArkTx));
|
|
3845
3862
|
await hooks?.beforeSubmit?.();
|
|
3846
3863
|
const response = await provider.submitTx(
|
|
3847
3864
|
base64.encode(signedArkTx.toPSBT()),
|
|
3848
|
-
offchainTx.checkpoints.map((c) => base64.encode(c.toPSBT()))
|
|
3865
|
+
(oneShot ? userSignedCheckpoints : offchainTx.checkpoints.map((c) => withArkInputWitness(c, signedArkTx))).map((c) => base64.encode(c.toPSBT()))
|
|
3849
3866
|
);
|
|
3850
3867
|
assertSubmittedArkTxid(response, signedArkTx, "submitTx");
|
|
3851
3868
|
const { arkTxid, signedCheckpointTxs } = response;
|
|
3852
3869
|
const matched = matchServerCheckpoints(signedCheckpointTxs, offchainTx.checkpoints, "submitTx");
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3870
|
+
if (!oneShot) {
|
|
3871
|
+
matched.forEach(({ server }, index) => {
|
|
3872
|
+
try {
|
|
3873
|
+
assertAllowedSighashTypes(server);
|
|
3874
|
+
} catch (error) {
|
|
3875
|
+
throw new ServerResponseMismatchError(
|
|
3876
|
+
`submitTx checkpoint ${index}: ${error instanceof Error ? error.message : String(error)}`
|
|
3877
|
+
);
|
|
3878
|
+
}
|
|
3879
|
+
});
|
|
3880
|
+
}
|
|
3862
3881
|
const verify = options?.verifyServerSignatures;
|
|
3863
3882
|
if (verify) {
|
|
3864
3883
|
if (response.finalArkTx === void 0) {
|
|
@@ -3885,26 +3904,62 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
3885
3904
|
({ server, local }, index) => assertServerSignedLeaf(server, local, 0, serverPubkeys, `submitTx checkpoint ${index}`)
|
|
3886
3905
|
);
|
|
3887
3906
|
}
|
|
3907
|
+
const result = { arkTxid, finalArkTx: response.finalArkTx, signedCheckpointTxs };
|
|
3888
3908
|
let finalCheckpoints;
|
|
3889
3909
|
if (userSignedCheckpoints) {
|
|
3890
3910
|
const userByTxid = new Map(
|
|
3891
3911
|
userSignedCheckpoints.map((c, i) => [offchainTx.checkpoints[i].id, c])
|
|
3892
3912
|
);
|
|
3913
|
+
if (oneShot && matched.every(
|
|
3914
|
+
({ server, local }) => carriesTapscriptSigs(server, userByTxid.get(local.id))
|
|
3915
|
+
)) {
|
|
3916
|
+
await hooks?.afterFinalize?.();
|
|
3917
|
+
return result;
|
|
3918
|
+
}
|
|
3893
3919
|
finalCheckpoints = matched.map(({ server, local }) => {
|
|
3894
|
-
|
|
3920
|
+
const userSigned = userByTxid.get(local.id);
|
|
3921
|
+
combineTapscriptSigs(userSigned, server);
|
|
3922
|
+
carryConditionWitness(userSigned, server);
|
|
3895
3923
|
return base64.encode(server.toPSBT());
|
|
3896
3924
|
});
|
|
3897
3925
|
} else {
|
|
3898
3926
|
finalCheckpoints = await Promise.all(
|
|
3899
|
-
matched.map(async ({ server }) => {
|
|
3927
|
+
matched.map(async ({ server, local }) => {
|
|
3900
3928
|
const signed = await signer.signCheckpoint(server);
|
|
3929
|
+
carryConditionWitness(local, signed);
|
|
3901
3930
|
return base64.encode(signed.toPSBT());
|
|
3902
3931
|
})
|
|
3903
3932
|
);
|
|
3904
3933
|
}
|
|
3905
3934
|
await provider.finalizeTx(arkTxid, finalCheckpoints);
|
|
3906
3935
|
await hooks?.afterFinalize?.();
|
|
3907
|
-
return
|
|
3936
|
+
return result;
|
|
3937
|
+
}
|
|
3938
|
+
function carryConditionWitness(ours, server) {
|
|
3939
|
+
if (getArkPsbtFields(server, 0, ConditionWitness).length > 0) return;
|
|
3940
|
+
const [witness] = getArkPsbtFields(ours, 0, ConditionWitness);
|
|
3941
|
+
if (witness) setArkPsbtField(server, 0, ConditionWitness, witness);
|
|
3942
|
+
}
|
|
3943
|
+
function withArkInputWitness(checkpoint, signedArkTx) {
|
|
3944
|
+
if (getArkPsbtFields(checkpoint, 0, ConditionWitness).length > 0) return checkpoint;
|
|
3945
|
+
for (let i = 0; i < signedArkTx.inputsLength; i++) {
|
|
3946
|
+
const { txid } = signedArkTx.getInput(i);
|
|
3947
|
+
if (!txid || hex.encode(txid) !== checkpoint.id) continue;
|
|
3948
|
+
const [witness] = getArkPsbtFields(signedArkTx, i, ConditionWitness);
|
|
3949
|
+
if (!witness) return checkpoint;
|
|
3950
|
+
const carried = checkpoint.clone();
|
|
3951
|
+
setArkPsbtField(carried, 0, ConditionWitness, witness);
|
|
3952
|
+
return carried;
|
|
3953
|
+
}
|
|
3954
|
+
return checkpoint;
|
|
3955
|
+
}
|
|
3956
|
+
function carriesTapscriptSigs(server, userSigned) {
|
|
3957
|
+
const entries = (tx) => (tx.getInput(0).tapScriptSig ?? []).map(
|
|
3958
|
+
([{ pubKey, leafHash }, sig]) => hex.encode(pubKey) + hex.encode(leafHash) + hex.encode(sig)
|
|
3959
|
+
);
|
|
3960
|
+
const have = new Set(entries(server));
|
|
3961
|
+
const want = entries(userSigned);
|
|
3962
|
+
return want.length > 0 && want.every((entry) => have.has(entry));
|
|
3908
3963
|
}
|
|
3909
3964
|
async function signAndSubmitOffchainTx(params) {
|
|
3910
3965
|
const offchainTx = buildOffchainTx(params.inputs, params.outputs, params.serverUnrollScript);
|
|
@@ -3913,7 +3968,8 @@ async function signAndSubmitOffchainTx(params) {
|
|
|
3913
3968
|
signCheckpoint: (checkpoint) => params.identity.sign(checkpoint)
|
|
3914
3969
|
};
|
|
3915
3970
|
const { arkTxid } = await submitOffchainTx(params.provider, offchainTx, signer, void 0, {
|
|
3916
|
-
verifyServerSignatures: params.verifyServerSignatures
|
|
3971
|
+
verifyServerSignatures: params.verifyServerSignatures,
|
|
3972
|
+
oneShot: params.oneShot
|
|
3917
3973
|
});
|
|
3918
3974
|
return arkTxid;
|
|
3919
3975
|
}
|
|
@@ -4363,7 +4419,7 @@ async function runWithCrossInstanceLock(name, fn) {
|
|
|
4363
4419
|
});
|
|
4364
4420
|
}
|
|
4365
4421
|
var MAX_VTXOS_PER_SETTLEMENT = 50;
|
|
4366
|
-
var
|
|
4422
|
+
var MAX_INPUTS_PER_PROOF = 20;
|
|
4367
4423
|
function byValueDescending(vtxos) {
|
|
4368
4424
|
return [...vtxos].sort((a, b) => b.value - a.value);
|
|
4369
4425
|
}
|
|
@@ -4947,7 +5003,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4947
5003
|
* ```typescript
|
|
4948
5004
|
* const wallet = await Wallet.create({
|
|
4949
5005
|
* identity,
|
|
4950
|
-
*
|
|
5006
|
+
* operatorProvider: new RestOperatorProvider(),
|
|
4951
5007
|
* settlementConfig: {
|
|
4952
5008
|
* vtxoThreshold: 86_400 // 24 hours
|
|
4953
5009
|
* },
|
|
@@ -5175,7 +5231,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5175
5231
|
* ```typescript
|
|
5176
5232
|
* const wallet = await Wallet.create({
|
|
5177
5233
|
* identity,
|
|
5178
|
-
*
|
|
5234
|
+
* operatorProvider: new RestOperatorProvider(),
|
|
5179
5235
|
* settlementConfig: {
|
|
5180
5236
|
* boardingUtxoSweep: true,
|
|
5181
5237
|
* },
|
|
@@ -5718,11 +5774,11 @@ var VtxoManager = class _VtxoManager {
|
|
|
5718
5774
|
getOnchainProvider() {
|
|
5719
5775
|
return this.getSweepWallet().onchainProvider;
|
|
5720
5776
|
}
|
|
5721
|
-
|
|
5777
|
+
getOperatorProvider() {
|
|
5722
5778
|
return this.getSweepWallet().arkProvider;
|
|
5723
5779
|
}
|
|
5724
5780
|
/**
|
|
5725
|
-
* Unlike {@link
|
|
5781
|
+
* Unlike {@link getOperatorProvider}, doesn't require boarding-sweep capability. Undefined when no
|
|
5726
5782
|
* provider is wired, which callers treat as "no limit".
|
|
5727
5783
|
*/
|
|
5728
5784
|
getInfoProvider() {
|
|
@@ -5973,7 +6029,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5973
6029
|
return;
|
|
5974
6030
|
}
|
|
5975
6031
|
const dustAmount = getDustAmount(this.wallet);
|
|
5976
|
-
const info = await this.
|
|
6032
|
+
const info = await this.getOperatorProvider().getInfo();
|
|
5977
6033
|
const { fees, vtxoMaxAmount } = info;
|
|
5978
6034
|
const estimator = new Estimator(fees.intentFee);
|
|
5979
6035
|
let totalAmount = 0n;
|
|
@@ -7366,6 +7422,16 @@ function gatedTouchpoints(gated) {
|
|
|
7366
7422
|
}
|
|
7367
7423
|
return { paidIn, paidOut };
|
|
7368
7424
|
}
|
|
7425
|
+
function groupBy(items, key) {
|
|
7426
|
+
const groups = /* @__PURE__ */ new Map();
|
|
7427
|
+
for (const item of items) {
|
|
7428
|
+
const k = key(item);
|
|
7429
|
+
const group = groups.get(k);
|
|
7430
|
+
if (group) group.push(item);
|
|
7431
|
+
else groups.set(k, [item]);
|
|
7432
|
+
}
|
|
7433
|
+
return groups;
|
|
7434
|
+
}
|
|
7369
7435
|
var txKey = {
|
|
7370
7436
|
commitmentTxid: "",
|
|
7371
7437
|
boardingTxid: "",
|
|
@@ -7423,6 +7489,15 @@ async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnor
|
|
|
7423
7489
|
const txidsNeedingCreatedAt = resolveTxCreatedAt ? collectArkTxidsNeedingCreatedAt(ownVtxos, localCreatedAt) : [];
|
|
7424
7490
|
const resolvedCreatedAt = resolveTxCreatedAt && txidsNeedingCreatedAt.length > 0 ? await resolveTxCreatedAt(txidsNeedingCreatedAt) : /* @__PURE__ */ new Map();
|
|
7425
7491
|
const unmatchedSettledBoardingTxs = allBoardingTxs.filter(isSettledBoardingReceive).sort((a, b) => a.createdAt - b.createdAt);
|
|
7492
|
+
const bySettledBy = groupBy(ownVtxos, (v) => v.settledBy);
|
|
7493
|
+
const byArkTxId = groupBy(ownVtxos, (v) => v.arkTxId);
|
|
7494
|
+
const byTxid = groupBy(ownVtxos, (v) => v.txid);
|
|
7495
|
+
const leavesBySoleCommitment = groupBy(
|
|
7496
|
+
ownVtxos,
|
|
7497
|
+
(v) => v.status.isLeaf && v.commitmentTxIds.length > 0 && v.commitmentTxIds.every((c) => c === v.commitmentTxIds[0]) ? v.commitmentTxIds[0] : void 0
|
|
7498
|
+
);
|
|
7499
|
+
const handledArkTxids = /* @__PURE__ */ new Set();
|
|
7500
|
+
const handledCommitments = /* @__PURE__ */ new Set();
|
|
7426
7501
|
const sent = [];
|
|
7427
7502
|
let received = [];
|
|
7428
7503
|
for (const vtxo of ownVtxos) {
|
|
@@ -7435,7 +7510,7 @@ async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnor
|
|
|
7435
7510
|
unmatchedSettledBoardingTxs,
|
|
7436
7511
|
(tx) => tx.createdAt <= vtxoCreatedAt && (tx.key.commitmentTxid === commitmentTxid || tx.key.commitmentTxid === vtxo.settledBy)
|
|
7437
7512
|
);
|
|
7438
|
-
} else if (
|
|
7513
|
+
} else if (!bySettledBy.has(vtxo.commitmentTxIds[0])) {
|
|
7439
7514
|
const duplicateBoardingReceive = consumeBoardingReceive(
|
|
7440
7515
|
unmatchedSettledBoardingTxs,
|
|
7441
7516
|
(tx) => tx.amount === vtxo.value && tx.createdAt <= vtxoCreatedAt
|
|
@@ -7456,7 +7531,7 @@ async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnor
|
|
|
7456
7531
|
});
|
|
7457
7532
|
}
|
|
7458
7533
|
}
|
|
7459
|
-
} else if (
|
|
7534
|
+
} else if (!byArkTxId.has(vtxo.txid)) {
|
|
7460
7535
|
const assets = subtractAssets([], [vtxo]);
|
|
7461
7536
|
received.push({
|
|
7462
7537
|
key: { ...txKey, arkTxid: vtxo.txid },
|
|
@@ -7472,9 +7547,10 @@ async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnor
|
|
|
7472
7547
|
});
|
|
7473
7548
|
}
|
|
7474
7549
|
if (vtxo.isSpent) {
|
|
7475
|
-
if (vtxo.arkTxId && !
|
|
7476
|
-
|
|
7477
|
-
const
|
|
7550
|
+
if (vtxo.arkTxId && !handledArkTxids.has(vtxo.arkTxId)) {
|
|
7551
|
+
handledArkTxids.add(vtxo.arkTxId);
|
|
7552
|
+
const changes = byTxid.get(vtxo.arkTxId) ?? [];
|
|
7553
|
+
const allSpent = byArkTxId.get(vtxo.arkTxId);
|
|
7478
7554
|
const spentAmount = allSpent.reduce((acc, v) => acc + v.value, 0);
|
|
7479
7555
|
let txAmount = 0;
|
|
7480
7556
|
let txTime = 0;
|
|
@@ -7502,11 +7578,10 @@ async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnor
|
|
|
7502
7578
|
});
|
|
7503
7579
|
}
|
|
7504
7580
|
}
|
|
7505
|
-
if (vtxo.settledBy && !commitmentsToIgnore.has(vtxo.settledBy) && !
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
);
|
|
7509
|
-
const forfeitVtxos = ownVtxos.filter((v) => v.settledBy === vtxo.settledBy);
|
|
7581
|
+
if (vtxo.settledBy && !commitmentsToIgnore.has(vtxo.settledBy) && !handledCommitments.has(vtxo.settledBy)) {
|
|
7582
|
+
handledCommitments.add(vtxo.settledBy);
|
|
7583
|
+
const changes = leavesBySoleCommitment.get(vtxo.settledBy) ?? [];
|
|
7584
|
+
const forfeitVtxos = bySettledBy.get(vtxo.settledBy);
|
|
7510
7585
|
const forfeitAmount = forfeitVtxos.reduce((acc, v) => acc + v.value, 0);
|
|
7511
7586
|
if (changes.length > 0) {
|
|
7512
7587
|
const settledAmount = changes.reduce((acc, v) => acc + v.value, 0);
|
|
@@ -8113,7 +8188,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
8113
8188
|
expire_at: 0,
|
|
8114
8189
|
cosigners_public_keys: cosignerPubKeys
|
|
8115
8190
|
};
|
|
8116
|
-
const proof =
|
|
8191
|
+
const proof = Proof.create(message, coins, outputs);
|
|
8117
8192
|
const signedProof = await identity.sign(proof);
|
|
8118
8193
|
return {
|
|
8119
8194
|
proof: base64.encode(signedProof.toPSBT()),
|
|
@@ -8785,6 +8860,21 @@ var InMemoryWalletRepository = class {
|
|
|
8785
8860
|
utxosByAddress = /* @__PURE__ */ new Map();
|
|
8786
8861
|
txsByAddress = /* @__PURE__ */ new Map();
|
|
8787
8862
|
walletState = null;
|
|
8863
|
+
atomicWalletState;
|
|
8864
|
+
constructor() {
|
|
8865
|
+
const clone2 = typeof globalThis.structuredClone === "function" ? globalThis.structuredClone.bind(globalThis) : void 0;
|
|
8866
|
+
if (clone2) {
|
|
8867
|
+
this.atomicWalletState = {
|
|
8868
|
+
version: 1,
|
|
8869
|
+
update: async (updater) => {
|
|
8870
|
+
this.walletState = applyWalletStateUpdate(
|
|
8871
|
+
clone2(this.walletState ?? {}),
|
|
8872
|
+
updater
|
|
8873
|
+
);
|
|
8874
|
+
}
|
|
8875
|
+
};
|
|
8876
|
+
}
|
|
8877
|
+
}
|
|
8788
8878
|
async getVtxosPage(address, page) {
|
|
8789
8879
|
return pageOutpoints(this.vtxosByAddress.get(address) ?? [], page);
|
|
8790
8880
|
}
|
|
@@ -11758,8 +11848,12 @@ var deserializeUtxo = (o) => ({
|
|
|
11758
11848
|
var IndexedDBWalletRepository = class {
|
|
11759
11849
|
version = 2;
|
|
11760
11850
|
connection;
|
|
11761
|
-
|
|
11851
|
+
/** persistentWalletState asserts persistence beyond this process; it cannot detect browser eviction. */
|
|
11852
|
+
constructor(dbName = DEFAULT_DB_NAME, options) {
|
|
11762
11853
|
this.connection = createManagedConnection(dbName, DB_VERSION, initDatabase);
|
|
11854
|
+
if (options?.persistentWalletState === true) {
|
|
11855
|
+
this.atomicWalletState = { ...this.atomicWalletState, persistent: true };
|
|
11856
|
+
}
|
|
11763
11857
|
}
|
|
11764
11858
|
async clear() {
|
|
11765
11859
|
try {
|
|
@@ -12028,6 +12122,47 @@ var IndexedDBWalletRepository = class {
|
|
|
12028
12122
|
throw error;
|
|
12029
12123
|
}
|
|
12030
12124
|
}
|
|
12125
|
+
atomicWalletState = {
|
|
12126
|
+
version: 1,
|
|
12127
|
+
update: async (updater) => {
|
|
12128
|
+
const db = await this.getDB();
|
|
12129
|
+
const transaction = db.transaction([STORE_WALLET_STATE], "readwrite");
|
|
12130
|
+
const completion = awaitTransaction(transaction);
|
|
12131
|
+
let failed = false;
|
|
12132
|
+
let failure;
|
|
12133
|
+
try {
|
|
12134
|
+
const store = transaction.objectStore(STORE_WALLET_STATE);
|
|
12135
|
+
const request = store.get("state");
|
|
12136
|
+
request.onerror = () => {
|
|
12137
|
+
failed = true;
|
|
12138
|
+
failure = request.error;
|
|
12139
|
+
};
|
|
12140
|
+
request.onsuccess = () => {
|
|
12141
|
+
try {
|
|
12142
|
+
const state = applyWalletStateUpdate(request.result?.data ?? {}, updater);
|
|
12143
|
+
const write = store.put({ key: "state", data: state });
|
|
12144
|
+
write.onerror = () => {
|
|
12145
|
+
failed = true;
|
|
12146
|
+
failure = write.error;
|
|
12147
|
+
};
|
|
12148
|
+
} catch (error) {
|
|
12149
|
+
failed = true;
|
|
12150
|
+
failure = error;
|
|
12151
|
+
transaction.abort();
|
|
12152
|
+
}
|
|
12153
|
+
};
|
|
12154
|
+
} catch (error) {
|
|
12155
|
+
failed = true;
|
|
12156
|
+
failure = error;
|
|
12157
|
+
transaction.abort();
|
|
12158
|
+
}
|
|
12159
|
+
try {
|
|
12160
|
+
await completion;
|
|
12161
|
+
} catch (error) {
|
|
12162
|
+
throw failed ? failure : error;
|
|
12163
|
+
}
|
|
12164
|
+
}
|
|
12165
|
+
};
|
|
12031
12166
|
async getWalletState() {
|
|
12032
12167
|
try {
|
|
12033
12168
|
const db = await this.getDB();
|
|
@@ -12038,7 +12173,7 @@ var IndexedDBWalletRepository = class {
|
|
|
12038
12173
|
return result?.data ?? null;
|
|
12039
12174
|
} catch (error) {
|
|
12040
12175
|
console.error("Failed to get wallet state:", error);
|
|
12041
|
-
|
|
12176
|
+
throw error;
|
|
12042
12177
|
}
|
|
12043
12178
|
}
|
|
12044
12179
|
async saveWalletState(state) {
|
|
@@ -12216,7 +12351,7 @@ function arkadeServiceUrl(service) {
|
|
|
12216
12351
|
}
|
|
12217
12352
|
async function resolveArkadeService(service, opts = {}) {
|
|
12218
12353
|
const operatorUrl = arkadeServiceUrl(service);
|
|
12219
|
-
const arkProvider = opts.arkProvider ?? new
|
|
12354
|
+
const arkProvider = opts.arkProvider ?? new RestOperatorProvider(operatorUrl);
|
|
12220
12355
|
const info = opts.info ?? await arkProvider.getInfo();
|
|
12221
12356
|
if ("network" in service && service.network !== info.network) {
|
|
12222
12357
|
throw new Error(
|
|
@@ -12953,7 +13088,7 @@ function asSendParams(args) {
|
|
|
12953
13088
|
}
|
|
12954
13089
|
return { recipients: args };
|
|
12955
13090
|
}
|
|
12956
|
-
function
|
|
13091
|
+
function extractOperatorProviderUrl(provider) {
|
|
12957
13092
|
const serverUrl = provider.serverUrl;
|
|
12958
13093
|
return typeof serverUrl === "string" && serverUrl.length > 0 ? serverUrl : void 0;
|
|
12959
13094
|
}
|
|
@@ -13383,18 +13518,22 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13383
13518
|
}
|
|
13384
13519
|
/** Shared setup for ReadonlyWallet.create() and Wallet.create(). */
|
|
13385
13520
|
static async setupWalletConfig(config, pubKey) {
|
|
13386
|
-
if (config.
|
|
13521
|
+
if (config.operatorProvider && config.arkProvider) {
|
|
13522
|
+
throw new Error("Pass either `operatorProvider` or `arkProvider`, not both");
|
|
13523
|
+
}
|
|
13524
|
+
const callerProvider = config.operatorProvider ?? config.arkProvider;
|
|
13525
|
+
if (config.service && (callerProvider || config.indexerProvider || config.onchainProvider)) {
|
|
13387
13526
|
throw new Error(
|
|
13388
|
-
"Pass either `service` or `
|
|
13527
|
+
"Pass either `service` or `operatorProvider`/`indexerProvider`/`onchainProvider`, not both"
|
|
13389
13528
|
);
|
|
13390
13529
|
}
|
|
13391
|
-
const arkProvider =
|
|
13530
|
+
const arkProvider = callerProvider || new RestOperatorProvider(config.service ? arkadeServiceUrl(config.service) : void 0);
|
|
13392
13531
|
let indexerProvider = config.indexerProvider;
|
|
13393
13532
|
if (!indexerProvider && !config.service) {
|
|
13394
|
-
const derived =
|
|
13395
|
-
if (!derived &&
|
|
13533
|
+
const derived = extractOperatorProviderUrl(arkProvider);
|
|
13534
|
+
if (!derived && callerProvider) {
|
|
13396
13535
|
throw new Error(
|
|
13397
|
-
"indexerProvider is required when
|
|
13536
|
+
"indexerProvider is required when operatorProvider is provided without a discoverable serverUrl"
|
|
13398
13537
|
);
|
|
13399
13538
|
}
|
|
13400
13539
|
indexerProvider = new RestIndexerProvider(derived ?? DEFAULT_ARKADE_SERVER_URL);
|
|
@@ -14319,85 +14458,90 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14319
14458
|
return { height, time };
|
|
14320
14459
|
}
|
|
14321
14460
|
});
|
|
14322
|
-
|
|
14323
|
-
|
|
14324
|
-
|
|
14325
|
-
|
|
14326
|
-
|
|
14327
|
-
|
|
14328
|
-
|
|
14329
|
-
|
|
14330
|
-
|
|
14331
|
-
for (const
|
|
14332
|
-
const
|
|
14333
|
-
|
|
14334
|
-
|
|
14335
|
-
serverPubKey,
|
|
14336
|
-
csvTimelock: csvTimelock2
|
|
14337
|
-
});
|
|
14338
|
-
const defaultScriptHex = hex.encode(defaultScript.pkScript);
|
|
14339
|
-
if (!seenBaselineScripts.has(defaultScriptHex)) {
|
|
14340
|
-
seenBaselineScripts.add(defaultScriptHex);
|
|
14341
|
-
baseline.push({
|
|
14342
|
-
type: "default",
|
|
14343
|
-
params: {
|
|
14344
|
-
pubKey: hex.encode(defaultScript.options.pubKey),
|
|
14345
|
-
serverPubKey: hex.encode(serverPubKey),
|
|
14346
|
-
csvTimelock: csvTimelockStr
|
|
14347
|
-
},
|
|
14348
|
-
script: defaultScriptHex,
|
|
14349
|
-
address: defaultScript.address(this.network.hrp, serverPubKey).encode(),
|
|
14350
|
-
state: "active"
|
|
14351
|
-
});
|
|
14352
|
-
}
|
|
14353
|
-
if (delegatePubKey) {
|
|
14354
|
-
const delegateScript = new DelegateVtxo.Script({
|
|
14461
|
+
try {
|
|
14462
|
+
const baselinePubkey = await baselinePubkeyPromise;
|
|
14463
|
+
const delegatePubKey = this.offchainTapscript instanceof DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
14464
|
+
const baselineSigners = [
|
|
14465
|
+
this.offchainTapscript.options.serverPubKey,
|
|
14466
|
+
...[...this._deprecatedSigners.keys()].map((h) => hex.decode(h))
|
|
14467
|
+
];
|
|
14468
|
+
const seenBaselineScripts = /* @__PURE__ */ new Set();
|
|
14469
|
+
const baseline = [];
|
|
14470
|
+
for (const serverPubKey of baselineSigners) {
|
|
14471
|
+
for (const csvTimelock2 of this.walletContractTimelocks) {
|
|
14472
|
+
const csvTimelockStr = timelockToSequence(csvTimelock2).toString();
|
|
14473
|
+
const defaultScript = new DefaultVtxo.Script({
|
|
14355
14474
|
pubKey: baselinePubkey,
|
|
14356
14475
|
serverPubKey,
|
|
14357
|
-
delegatePubKey,
|
|
14358
14476
|
csvTimelock: csvTimelock2
|
|
14359
14477
|
});
|
|
14360
|
-
const
|
|
14361
|
-
if (seenBaselineScripts.has(
|
|
14362
|
-
|
|
14363
|
-
|
|
14364
|
-
|
|
14365
|
-
|
|
14366
|
-
|
|
14367
|
-
|
|
14368
|
-
|
|
14369
|
-
|
|
14370
|
-
|
|
14371
|
-
|
|
14372
|
-
|
|
14373
|
-
|
|
14374
|
-
}
|
|
14478
|
+
const defaultScriptHex = hex.encode(defaultScript.pkScript);
|
|
14479
|
+
if (!seenBaselineScripts.has(defaultScriptHex)) {
|
|
14480
|
+
seenBaselineScripts.add(defaultScriptHex);
|
|
14481
|
+
baseline.push({
|
|
14482
|
+
type: "default",
|
|
14483
|
+
params: {
|
|
14484
|
+
pubKey: hex.encode(defaultScript.options.pubKey),
|
|
14485
|
+
serverPubKey: hex.encode(serverPubKey),
|
|
14486
|
+
csvTimelock: csvTimelockStr
|
|
14487
|
+
},
|
|
14488
|
+
script: defaultScriptHex,
|
|
14489
|
+
address: defaultScript.address(this.network.hrp, serverPubKey).encode(),
|
|
14490
|
+
state: "active"
|
|
14491
|
+
});
|
|
14492
|
+
}
|
|
14493
|
+
if (delegatePubKey) {
|
|
14494
|
+
const delegateScript = new DelegateVtxo.Script({
|
|
14495
|
+
pubKey: baselinePubkey,
|
|
14496
|
+
serverPubKey,
|
|
14497
|
+
delegatePubKey,
|
|
14498
|
+
csvTimelock: csvTimelock2
|
|
14499
|
+
});
|
|
14500
|
+
const delegateScriptHex = hex.encode(delegateScript.pkScript);
|
|
14501
|
+
if (seenBaselineScripts.has(delegateScriptHex)) continue;
|
|
14502
|
+
seenBaselineScripts.add(delegateScriptHex);
|
|
14503
|
+
baseline.push({
|
|
14504
|
+
type: "delegate",
|
|
14505
|
+
params: {
|
|
14506
|
+
pubKey: hex.encode(delegateScript.options.pubKey),
|
|
14507
|
+
serverPubKey: hex.encode(serverPubKey),
|
|
14508
|
+
delegatePubKey: hex.encode(delegateScript.options.delegatePubKey),
|
|
14509
|
+
csvTimelock: csvTimelockStr
|
|
14510
|
+
},
|
|
14511
|
+
script: delegateScriptHex,
|
|
14512
|
+
address: delegateScript.address(this.network.hrp, serverPubKey).encode(),
|
|
14513
|
+
state: "active"
|
|
14514
|
+
});
|
|
14515
|
+
}
|
|
14375
14516
|
}
|
|
14376
14517
|
}
|
|
14518
|
+
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
14519
|
+
for (const serverPubKey of baselineSigners) {
|
|
14520
|
+
const baselineBoarding = new DefaultVtxo.Script({
|
|
14521
|
+
pubKey: baselinePubkey,
|
|
14522
|
+
serverPubKey,
|
|
14523
|
+
csvTimelock: boardingCsvTimelock
|
|
14524
|
+
});
|
|
14525
|
+
const boardingScriptHex = hex.encode(baselineBoarding.pkScript);
|
|
14526
|
+
if (seenBaselineScripts.has(boardingScriptHex)) continue;
|
|
14527
|
+
seenBaselineScripts.add(boardingScriptHex);
|
|
14528
|
+
baseline.push({
|
|
14529
|
+
type: "boarding",
|
|
14530
|
+
params: {
|
|
14531
|
+
pubKey: hex.encode(baselineBoarding.options.pubKey),
|
|
14532
|
+
serverPubKey: hex.encode(serverPubKey),
|
|
14533
|
+
csvTimelock: timelockToSequence(boardingCsvTimelock).toString()
|
|
14534
|
+
},
|
|
14535
|
+
script: boardingScriptHex,
|
|
14536
|
+
address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
|
|
14537
|
+
state: "active"
|
|
14538
|
+
});
|
|
14539
|
+
}
|
|
14540
|
+
await manager.createContracts(baseline);
|
|
14541
|
+
} catch (error) {
|
|
14542
|
+
await manager.dispose().catch(() => void 0);
|
|
14543
|
+
throw error;
|
|
14377
14544
|
}
|
|
14378
|
-
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
14379
|
-
for (const serverPubKey of baselineSigners) {
|
|
14380
|
-
const baselineBoarding = new DefaultVtxo.Script({
|
|
14381
|
-
pubKey: baselinePubkey,
|
|
14382
|
-
serverPubKey,
|
|
14383
|
-
csvTimelock: boardingCsvTimelock
|
|
14384
|
-
});
|
|
14385
|
-
const boardingScriptHex = hex.encode(baselineBoarding.pkScript);
|
|
14386
|
-
if (seenBaselineScripts.has(boardingScriptHex)) continue;
|
|
14387
|
-
seenBaselineScripts.add(boardingScriptHex);
|
|
14388
|
-
baseline.push({
|
|
14389
|
-
type: "boarding",
|
|
14390
|
-
params: {
|
|
14391
|
-
pubKey: hex.encode(baselineBoarding.options.pubKey),
|
|
14392
|
-
serverPubKey: hex.encode(serverPubKey),
|
|
14393
|
-
csvTimelock: timelockToSequence(boardingCsvTimelock).toString()
|
|
14394
|
-
},
|
|
14395
|
-
script: boardingScriptHex,
|
|
14396
|
-
address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
|
|
14397
|
-
state: "active"
|
|
14398
|
-
});
|
|
14399
|
-
}
|
|
14400
|
-
await manager.createContracts(baseline);
|
|
14401
14545
|
return manager;
|
|
14402
14546
|
}
|
|
14403
14547
|
/** Dispose wallet-owned managers and release background resources. */
|
|
@@ -14413,7 +14557,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14413
14557
|
}
|
|
14414
14558
|
};
|
|
14415
14559
|
var Wallet2 = class extends ReadonlyWallet {
|
|
14416
|
-
constructor(identity, network, onchainProvider, arkProvider, indexerProvider, arkServerPublicKey, offchainTapscript, boardingTapscript, serverUnrollScript, forfeitOutputScript, forfeitPubkey, dustAmount, walletRepository, contractRepository, delegateProvider, watcherConfig, settlementConfig, walletContractTimelocks, receiveRotator, descriptorProvider, keyring, lookAheadWindow, batchExpiryPolicy) {
|
|
14560
|
+
constructor(identity, network, onchainProvider, arkProvider, indexerProvider, arkServerPublicKey, offchainTapscript, boardingTapscript, serverUnrollScript, forfeitOutputScript, forfeitPubkey, dustAmount, walletRepository, contractRepository, delegateProvider, watcherConfig, settlementConfig, walletContractTimelocks, receiveRotator, descriptorProvider, keyring, lookAheadWindow, batchExpiryPolicy, oneShotSubmit = true) {
|
|
14417
14561
|
super(
|
|
14418
14562
|
identity,
|
|
14419
14563
|
network,
|
|
@@ -14433,6 +14577,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14433
14577
|
this.forfeitOutputScript = forfeitOutputScript;
|
|
14434
14578
|
this.forfeitPubkey = forfeitPubkey;
|
|
14435
14579
|
this.batchExpiryPolicy = batchExpiryPolicy;
|
|
14580
|
+
this.oneShotSubmit = oneShotSubmit;
|
|
14436
14581
|
this.identity = identity;
|
|
14437
14582
|
this.settlementConfig = settlementConfig !== void 0 ? settlementConfig : { ...DEFAULT_SETTLEMENT_CONFIG };
|
|
14438
14583
|
this._delegateManager = delegateProvider ? new DelegateManagerImpl(delegateProvider, arkProvider, identity) : void 0;
|
|
@@ -14454,6 +14599,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14454
14599
|
forfeitOutputScript;
|
|
14455
14600
|
forfeitPubkey;
|
|
14456
14601
|
batchExpiryPolicy;
|
|
14602
|
+
oneShotSubmit;
|
|
14457
14603
|
static MIN_FEE_RATE = 1;
|
|
14458
14604
|
// sats/vbyte
|
|
14459
14605
|
identity;
|
|
@@ -15299,7 +15445,8 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15299
15445
|
{
|
|
15300
15446
|
advertisedVtxoTreeExpiry: setup.info.vtxoTreeExpiry,
|
|
15301
15447
|
...config.minBatchExpirySeconds !== void 0 ? { minSeconds: config.minBatchExpirySeconds } : {}
|
|
15302
|
-
}
|
|
15448
|
+
},
|
|
15449
|
+
config.oneShotSubmit
|
|
15303
15450
|
);
|
|
15304
15451
|
wallet.lazyInitialization = config.lazyInitialization ?? false;
|
|
15305
15452
|
wallet._serverInfoSource = setup.serverInfoSource;
|
|
@@ -15873,7 +16020,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15873
16020
|
return { skip };
|
|
15874
16021
|
}
|
|
15875
16022
|
if (!this.arkProvider) {
|
|
15876
|
-
throw new Error("
|
|
16023
|
+
throw new Error("Operator provider not configured");
|
|
15877
16024
|
}
|
|
15878
16025
|
const timelock = assertValidBatchExpiry(
|
|
15879
16026
|
event.batchExpiry,
|
|
@@ -15984,7 +16131,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15984
16131
|
...existing ?? {},
|
|
15985
16132
|
intentTxId,
|
|
15986
16133
|
registerProof: intent.proof,
|
|
15987
|
-
registerProofMessage:
|
|
16134
|
+
registerProofMessage: Proof.encodeMessage(intent.message),
|
|
15988
16135
|
deleteProof: deleteIntent.proof,
|
|
15989
16136
|
deleteProofMessage: Intent.encodeMessage(deleteIntent.message),
|
|
15990
16137
|
intentVtxos: inputs.map((i) => ({
|
|
@@ -16035,7 +16182,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16035
16182
|
expire_at: 0,
|
|
16036
16183
|
cosigners_public_keys: cosignerPubKeys
|
|
16037
16184
|
};
|
|
16038
|
-
const proof =
|
|
16185
|
+
const proof = Proof.create(message, coins, outputs);
|
|
16039
16186
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
16040
16187
|
return {
|
|
16041
16188
|
proof: base64.encode(signedProof.toPSBT()),
|
|
@@ -16047,7 +16194,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16047
16194
|
type: "delete",
|
|
16048
16195
|
expire_at: 0
|
|
16049
16196
|
};
|
|
16050
|
-
const proof =
|
|
16197
|
+
const proof = Proof.create(message, coins, []);
|
|
16051
16198
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
16052
16199
|
return {
|
|
16053
16200
|
proof: base64.encode(signedProof.toPSBT()),
|
|
@@ -16059,7 +16206,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16059
16206
|
type: "get-pending-tx",
|
|
16060
16207
|
expire_at: 0
|
|
16061
16208
|
};
|
|
16062
|
-
const proof =
|
|
16209
|
+
const proof = Proof.create(message, coins, []);
|
|
16063
16210
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
16064
16211
|
return {
|
|
16065
16212
|
proof: base64.encode(signedProof.toPSBT()),
|
|
@@ -16102,8 +16249,8 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16102
16249
|
vtxos = allExtended;
|
|
16103
16250
|
}
|
|
16104
16251
|
const batches = [];
|
|
16105
|
-
for (let i = 0; i < vtxos.length; i +=
|
|
16106
|
-
batches.push(vtxos.slice(i, i +
|
|
16252
|
+
for (let i = 0; i < vtxos.length; i += MAX_INPUTS_PER_PROOF) {
|
|
16253
|
+
batches.push(vtxos.slice(i, i + MAX_INPUTS_PER_PROOF));
|
|
16107
16254
|
}
|
|
16108
16255
|
const unrollCandidates = this.checkpointUnrollCandidates(await this.arkProvider.getInfo());
|
|
16109
16256
|
const checkpointInputs = vtxos.map((vtxo) => ({
|
|
@@ -16340,7 +16487,8 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16340
16487
|
}
|
|
16341
16488
|
],
|
|
16342
16489
|
outputs: [{ script: myPkScript, amount: BigInt(vtxo.value) }],
|
|
16343
|
-
serverUnrollScript
|
|
16490
|
+
serverUnrollScript,
|
|
16491
|
+
oneShot: this.oneShotSubmit
|
|
16344
16492
|
});
|
|
16345
16493
|
swept += vtxo.value;
|
|
16346
16494
|
} catch (error) {
|
|
@@ -16557,10 +16705,10 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16557
16705
|
const identity = cash.identity;
|
|
16558
16706
|
const seenTxids = /* @__PURE__ */ new Set();
|
|
16559
16707
|
const pendingTxs = [];
|
|
16560
|
-
for (let i = 0; i < inputs.length; i +=
|
|
16561
|
-
const batch = inputs.slice(i, i +
|
|
16708
|
+
for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_PROOF) {
|
|
16709
|
+
const batch = inputs.slice(i, i + MAX_INPUTS_PER_PROOF);
|
|
16562
16710
|
const message = { type: "get-pending-tx", expire_at: 0 };
|
|
16563
|
-
const proof =
|
|
16711
|
+
const proof = Proof.create(message, batch, []);
|
|
16564
16712
|
const signedProof = await identity.sign(
|
|
16565
16713
|
proof,
|
|
16566
16714
|
Array.from({ length: batch.length + 1 }, (_, j) => j)
|
|
@@ -17065,7 +17213,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17065
17213
|
}
|
|
17066
17214
|
/**
|
|
17067
17215
|
* Build an offchain transaction from the given inputs and outputs,
|
|
17068
|
-
* sign it, submit to the
|
|
17216
|
+
* sign it, submit to the operator provider, and finalize.
|
|
17069
17217
|
*
|
|
17070
17218
|
* Signs whatever it is handed, ungated — see {@link settle} for the trade.
|
|
17071
17219
|
*
|
|
@@ -17182,7 +17330,8 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17182
17330
|
deprecatedServerPubkeys: [...this._deprecatedSigners.keys()].map(
|
|
17183
17331
|
(h) => hex.decode(h)
|
|
17184
17332
|
)
|
|
17185
|
-
}
|
|
17333
|
+
},
|
|
17334
|
+
oneShot: this.oneShotSubmit
|
|
17186
17335
|
}
|
|
17187
17336
|
);
|
|
17188
17337
|
} finally {
|
|
@@ -17805,7 +17954,7 @@ var MessageBus = class {
|
|
|
17805
17954
|
this.initialized = true;
|
|
17806
17955
|
}
|
|
17807
17956
|
async buildServices(config) {
|
|
17808
|
-
const arkProvider = new
|
|
17957
|
+
const arkProvider = new RestOperatorProvider(config.arkServer.url);
|
|
17809
17958
|
const storage = {
|
|
17810
17959
|
walletRepository: this.walletRepository,
|
|
17811
17960
|
contractRepository: this.contractRepository,
|
|
@@ -17830,6 +17979,7 @@ var MessageBus = class {
|
|
|
17830
17979
|
lazyInitialization: config.lazyInitialization,
|
|
17831
17980
|
watcherConfig: config.watcherConfig,
|
|
17832
17981
|
lookAheadWindow: config.lookAheadWindow,
|
|
17982
|
+
oneShotSubmit: config.oneShotSubmit,
|
|
17833
17983
|
minBatchExpirySeconds: config.minBatchExpirySeconds
|
|
17834
17984
|
});
|
|
17835
17985
|
return { wallet, arkProvider, readonlyWallet: wallet };
|
|
@@ -21071,9 +21221,10 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
21071
21221
|
}
|
|
21072
21222
|
};
|
|
21073
21223
|
var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadonlyWallet {
|
|
21074
|
-
constructor(serviceWorker, identity, walletRepository, contractRepository, messageTag, hasDelegate) {
|
|
21224
|
+
constructor(serviceWorker, identity, walletRepository, contractRepository, messageTag, hasDelegate, oneShotSubmit) {
|
|
21075
21225
|
super(serviceWorker, identity, walletRepository, contractRepository, messageTag);
|
|
21076
21226
|
this.serviceWorker = serviceWorker;
|
|
21227
|
+
this.oneShotSubmit = oneShotSubmit;
|
|
21077
21228
|
this.identity = identity;
|
|
21078
21229
|
this.walletRepository = walletRepository;
|
|
21079
21230
|
this.contractRepository = contractRepository;
|
|
@@ -21084,6 +21235,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
21084
21235
|
this.hasDelegate = hasDelegate;
|
|
21085
21236
|
}
|
|
21086
21237
|
serviceWorker;
|
|
21238
|
+
oneShotSubmit;
|
|
21087
21239
|
walletRepository;
|
|
21088
21240
|
contractRepository;
|
|
21089
21241
|
identity;
|
|
@@ -21120,7 +21272,8 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
21120
21272
|
walletRepository,
|
|
21121
21273
|
contractRepository,
|
|
21122
21274
|
messageTag,
|
|
21123
|
-
!!options.delegateUrl
|
|
21275
|
+
!!options.delegateUrl,
|
|
21276
|
+
options.oneShotSubmit
|
|
21124
21277
|
);
|
|
21125
21278
|
wallet._concurrentSpending = options.concurrentSpending === true;
|
|
21126
21279
|
return _ServiceWorkerWallet.bootstrap(wallet, options, serializedWallet, {
|
|
@@ -21131,6 +21284,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
21131
21284
|
lazyInitialization: options.lazyInitialization,
|
|
21132
21285
|
watcherConfig: options.watcherConfig,
|
|
21133
21286
|
lookAheadWindow: options.lookAheadWindow,
|
|
21287
|
+
oneShotSubmit: options.oneShotSubmit,
|
|
21134
21288
|
minBatchExpirySeconds: options.minBatchExpirySeconds
|
|
21135
21289
|
});
|
|
21136
21290
|
}
|
|
@@ -22617,7 +22771,7 @@ function childTxidFromHex(txHex) {
|
|
|
22617
22771
|
|
|
22618
22772
|
// src/providers/cachingArk.ts
|
|
22619
22773
|
var DEFAULT_TTL_MS = 6e4;
|
|
22620
|
-
var
|
|
22774
|
+
var CachingOperatorProvider = class {
|
|
22621
22775
|
constructor(inner, ttlMs = DEFAULT_TTL_MS) {
|
|
22622
22776
|
this.inner = inner;
|
|
22623
22777
|
this.ttlMs = ttlMs;
|
|
@@ -22698,6 +22852,7 @@ var CachingArkProvider = class {
|
|
|
22698
22852
|
});
|
|
22699
22853
|
}
|
|
22700
22854
|
};
|
|
22855
|
+
var CachingArkProvider = CachingOperatorProvider;
|
|
22701
22856
|
var PrevTxUnavailableError = class extends Error {
|
|
22702
22857
|
constructor(message, txids = []) {
|
|
22703
22858
|
super(message);
|
|
@@ -24760,6 +24915,7 @@ var Arkade = class _Arkade {
|
|
|
24760
24915
|
userKey;
|
|
24761
24916
|
/** The contract manager, when contract persistence is wired up (passed in or owned). */
|
|
24762
24917
|
contractManager;
|
|
24918
|
+
oneShotSubmit;
|
|
24763
24919
|
/** Whether {@link connect} built {@link contractManager}, so {@link dispose} must stop it. */
|
|
24764
24920
|
ownsContractManager;
|
|
24765
24921
|
/** {@link ArkadeContract.on} handles by contract script (hex). */
|
|
@@ -24779,6 +24935,7 @@ var Arkade = class _Arkade {
|
|
|
24779
24935
|
this.identity = fields.identity;
|
|
24780
24936
|
this.userKey = fields.userKey;
|
|
24781
24937
|
this.contractManager = fields.contractManager;
|
|
24938
|
+
this.oneShotSubmit = fields.oneShotSubmit;
|
|
24782
24939
|
this.ownsContractManager = fields.ownsContractManager ?? false;
|
|
24783
24940
|
}
|
|
24784
24941
|
/**
|
|
@@ -24855,7 +25012,8 @@ var Arkade = class _Arkade {
|
|
|
24855
25012
|
identity: opts.identity,
|
|
24856
25013
|
userKey,
|
|
24857
25014
|
contractManager,
|
|
24858
|
-
ownsContractManager
|
|
25015
|
+
ownsContractManager,
|
|
25016
|
+
oneShotSubmit: opts.oneShotSubmit
|
|
24859
25017
|
});
|
|
24860
25018
|
}
|
|
24861
25019
|
/**
|
|
@@ -24921,6 +25079,7 @@ var Arkade = class _Arkade {
|
|
|
24921
25079
|
*
|
|
24922
25080
|
* Declared `server`/`user` params default to the client's keys. Compiler
|
|
24923
25081
|
* artifacts reserve the server key and exit delay to the connected server.
|
|
25082
|
+
* Struct and array params are passed whole by name (see {@link ArkadeNestedValue}).
|
|
24924
25083
|
*/
|
|
24925
25084
|
contract(program, args = {}) {
|
|
24926
25085
|
const declared = (program.params ?? []).map((p) => p.name);
|
|
@@ -24964,19 +25123,19 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
24964
25123
|
constructor(client, program, args = {}, keys) {
|
|
24965
25124
|
this.client = client;
|
|
24966
25125
|
this.program = program;
|
|
24967
|
-
this.args =
|
|
25126
|
+
this.args = /* @__PURE__ */ Object.create(null);
|
|
25127
|
+
for (const [name, value] of Object.entries(args)) flattenValue(name, value, this.args);
|
|
24968
25128
|
this.keys = keys ?? {
|
|
24969
25129
|
serverKey: client.serverKey,
|
|
24970
25130
|
userKey: client.userKey,
|
|
24971
25131
|
emulatorKey: client.emulatorKey
|
|
24972
25132
|
};
|
|
24973
|
-
this.vtxoScript = new ArkadeProgramScript(program, args, this.keys);
|
|
25133
|
+
this.vtxoScript = new ArkadeProgramScript(program, this.args, this.keys);
|
|
24974
25134
|
this.tapTree = this.vtxoScript.encode();
|
|
24975
25135
|
this.compiled = this.vtxoScript.compiled;
|
|
24976
25136
|
}
|
|
24977
25137
|
client;
|
|
24978
25138
|
program;
|
|
24979
|
-
args;
|
|
24980
25139
|
/** The compiled taproot tree of spending-path leaves. */
|
|
24981
25140
|
vtxoScript;
|
|
24982
25141
|
/** Encoded taproot tree (shared spend context for every path). */
|
|
@@ -24985,6 +25144,8 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
24985
25144
|
keys;
|
|
24986
25145
|
/** Spending paths in declaration order. */
|
|
24987
25146
|
compiled;
|
|
25147
|
+
/** Constructor bindings by flattened name (`owners.0.key`), as persisted. */
|
|
25148
|
+
args;
|
|
24988
25149
|
/**
|
|
24989
25150
|
* Rebuild a callable contract from a persisted `"arkade"` row. Compiles with the stored keys,
|
|
24990
25151
|
* not the client's current ones, so script and address survive a server signer rotation.
|
|
@@ -25392,7 +25553,8 @@ var ArkadeTransactionBuilder = class {
|
|
|
25392
25553
|
inputIndexes: userInputs
|
|
25393
25554
|
});
|
|
25394
25555
|
}
|
|
25395
|
-
|
|
25556
|
+
const identity = client.identity;
|
|
25557
|
+
if (!identity) {
|
|
25396
25558
|
throw new Error("a signing identity is required for non-covenant spends");
|
|
25397
25559
|
}
|
|
25398
25560
|
const ark = client.arkProvider;
|
|
@@ -25401,26 +25563,19 @@ var ArkadeTransactionBuilder = class {
|
|
|
25401
25563
|
"broadcasting requires an `arkade` provider with `submitTx`/`finalizeTx` on the Arkade client"
|
|
25402
25564
|
);
|
|
25403
25565
|
}
|
|
25404
|
-
const
|
|
25405
|
-
|
|
25406
|
-
|
|
25407
|
-
|
|
25408
|
-
|
|
25409
|
-
|
|
25410
|
-
|
|
25411
|
-
|
|
25412
|
-
|
|
25413
|
-
const signed = await client.identity.sign(server, [0]);
|
|
25414
|
-
const [condition] = getArkPsbtFields(local, 0, ConditionWitness);
|
|
25415
|
-
if (condition && getArkPsbtFields(signed, 0, ConditionWitness).length === 0) {
|
|
25416
|
-
setArkPsbtField(signed, 0, ConditionWitness, condition);
|
|
25417
|
-
}
|
|
25418
|
-
return base64.encode(signed.toPSBT());
|
|
25419
|
-
})
|
|
25566
|
+
const res = await submitOffchainTx(
|
|
25567
|
+
ark,
|
|
25568
|
+
{ arkTx, checkpoints },
|
|
25569
|
+
{
|
|
25570
|
+
signArkTx: async (tx) => ({ arkTx: await this.signArk(tx, userInputs) }),
|
|
25571
|
+
signCheckpoint: (checkpoint) => identity.sign(checkpoint, [0])
|
|
25572
|
+
},
|
|
25573
|
+
void 0,
|
|
25574
|
+
{ oneShot: client.oneShotSubmit }
|
|
25420
25575
|
);
|
|
25421
|
-
await ark.finalizeTx(res.arkTxid, finalCps);
|
|
25422
25576
|
return {
|
|
25423
25577
|
txid: res.arkTxid,
|
|
25578
|
+
// Required by ArkadeBroadcaster; RestOperatorProvider.submitTx rejects a response without it.
|
|
25424
25579
|
signedArkTx: res.finalArkTx,
|
|
25425
25580
|
signedCheckpointTxs: res.signedCheckpointTxs
|
|
25426
25581
|
};
|
|
@@ -25488,20 +25643,60 @@ function unspendable(coin, now) {
|
|
|
25488
25643
|
function witnessBytes({ contract, args }, ref) {
|
|
25489
25644
|
return witnessRefToBytes(ref, args, contract.args);
|
|
25490
25645
|
}
|
|
25646
|
+
function flattenValue(name, value, out, ancestors = /* @__PURE__ */ new Set()) {
|
|
25647
|
+
if (typeof value !== "object" || value === null || ArrayBuffer.isView(value)) {
|
|
25648
|
+
if (Object.hasOwn(out, name)) throw new Error(`duplicate argument '${name}'`);
|
|
25649
|
+
out[name] = value;
|
|
25650
|
+
return;
|
|
25651
|
+
}
|
|
25652
|
+
if (ancestors.has(value)) throw new Error(`argument '${name}' must not be cyclic`);
|
|
25653
|
+
if (Array.isArray(value)) {
|
|
25654
|
+
for (let i = 0; i < value.length; i++) {
|
|
25655
|
+
if (!Object.hasOwn(value, i))
|
|
25656
|
+
throw new Error(`argument '${name}.${i}' is a sparse array element`);
|
|
25657
|
+
}
|
|
25658
|
+
}
|
|
25659
|
+
const entries = Object.entries(value);
|
|
25660
|
+
if (entries.length === 0) {
|
|
25661
|
+
const proto = Object.getPrototypeOf(value);
|
|
25662
|
+
if (proto !== Object.prototype && proto !== Array.prototype && proto !== null)
|
|
25663
|
+
throw new Error(`argument '${name}' must be bytes, a number, a struct or an array`);
|
|
25664
|
+
throw new Error(`argument '${name}' must not be an empty struct or array`);
|
|
25665
|
+
}
|
|
25666
|
+
ancestors.add(value);
|
|
25667
|
+
for (const [key, item] of entries) flattenValue(`${name}.${key}`, item, out, ancestors);
|
|
25668
|
+
ancestors.delete(value);
|
|
25669
|
+
}
|
|
25491
25670
|
function bindInputs(fn, callArgs) {
|
|
25492
25671
|
const inputs = fn.def.inputs ?? [];
|
|
25493
|
-
|
|
25672
|
+
const declared = /* @__PURE__ */ new Set();
|
|
25673
|
+
for (const def of inputs) {
|
|
25674
|
+
if (declared.has(def.name)) throw new Error(`${fn.name}: duplicate input '${def.name}'`);
|
|
25675
|
+
declared.add(def.name);
|
|
25676
|
+
}
|
|
25677
|
+
const params = [
|
|
25678
|
+
...new Map(
|
|
25679
|
+
inputs.map(({ name }) => {
|
|
25680
|
+
const root = name.split(".")[0];
|
|
25681
|
+
return [name.includes(".") ? `${root}.` : root, root];
|
|
25682
|
+
})
|
|
25683
|
+
).values()
|
|
25684
|
+
];
|
|
25685
|
+
if (callArgs.length !== params.length) {
|
|
25494
25686
|
throw new Error(
|
|
25495
|
-
`${fn.name}: expected ${
|
|
25687
|
+
`${fn.name}: expected ${params.length} argument(s), got ${callArgs.length}`
|
|
25496
25688
|
);
|
|
25497
25689
|
}
|
|
25498
25690
|
const bound = /* @__PURE__ */ Object.create(null);
|
|
25499
|
-
|
|
25500
|
-
|
|
25501
|
-
|
|
25502
|
-
|
|
25503
|
-
|
|
25504
|
-
|
|
25691
|
+
params.forEach((param, i) => flattenValue(param, callArgs[i], bound));
|
|
25692
|
+
for (const name of Object.keys(bound)) {
|
|
25693
|
+
if (!declared.has(name)) throw new Error(`${fn.name}: unexpected input '${name}'`);
|
|
25694
|
+
}
|
|
25695
|
+
for (const def of inputs) {
|
|
25696
|
+
if (bound[def.name] === void 0)
|
|
25697
|
+
throw new Error(`${fn.name}: missing input '${def.name}'`);
|
|
25698
|
+
validateParamValue(def, bound[def.name]);
|
|
25699
|
+
}
|
|
25505
25700
|
return bound;
|
|
25506
25701
|
}
|
|
25507
25702
|
function attachExtension(tx, newPackets) {
|
|
@@ -25986,6 +26181,6 @@ function createDefaultPaymentRouter(wallet) {
|
|
|
25986
26181
|
}).use(arkRail()).use(arkAssetRail()).use(onchainRail({ feeInfo: walletFeeSource(wallet) }));
|
|
25987
26182
|
}
|
|
25988
26183
|
|
|
25989
|
-
export { ARKADE_MAGIC, ARKADE_SALTED_PREIMAGE_TAG, ARKADE_SWAP_PREIMAGE_TAG, ASSET_CARRIER_SATS, AbortError, ActivityRegistry, AmbiguousRouteError, ArkNote, Arkade, ArkadeCash, ArkadeCashCreateError, ArkadeCashOperatorMismatchError, AssetManager, BIP21, BIP21Error, BIP322, BLOCKED_UPGRADE_TIMEOUT_MS, Batch, CachingArkProvider, ChainedTxType, ConnectionDisposedError, ContractManager, ContractWatcher, DEFAULT_MESSAGE_TIMEOUTS, DEFAULT_MIN_BATCH_EXPIRY_SECONDS, DatabaseUpgradeBlockedError, DelegateManagerImpl, DelegateNotConfiguredError, DescriptorIdentity, DescriptorSigningProviderMissingError, DustChangeError, ELECTRUM_TCP_HOST, ELECTRUM_WS_URL, ESPLORA_URL, ElectrumOnchainProvider, EmulatorPacket, EsploraProvider, Estimator, Extension, ExtensionNotFoundError, ForeignDescriptorError, HDDescriptorProvider, INTENT_TERMINAL_STATES, InMemoryContractRepository, InMemoryIntentRepository, InMemoryVirtualTxRepository, InMemoryWalletRepository, IndexedDBContractRepository, IndexedDBIntentRepository, IndexedDBVirtualTxRepository, IndexedDBWalletRepository, KeyringDescriptorProvider, MAX_PAGE_SIZE, MAX_USED_SIGNING_DESCRIPTORS_LOOK_AHEAD, MESSAGE_BUS_INITIALIZING, MESSAGE_BUS_NOT_INITIALIZED, MessageBus, MessageBusInitializingError, MessageBusNotInitializedError, MissingSigningDescriptorError, MnemonicIdentity, OnchainWallet, OversizedChangeError, P2A, PaymentRouter, PrevTxUnavailableError, REGTEST_MIN_BATCH_EXPIRY_SECONDS, Ramps, ReadonlyAssetManager, ReadonlyDescriptorIdentity, ReadonlySingleKey, ReadonlyWallet, ReadonlyWalletError, RestDelegateProvider, RestEmulatorProvider, SeedIdentity, SendDeadlineExceededError, ServiceWorkerReadonlyWallet, ServiceWorkerTimeoutError, ServiceWorkerWallet, SingleKey, StaticDescriptorProvider, TxTree, TxType, TxWeightEstimator, UnannotatableInputError, UnilateralExit, UnknownPacket, Unroll, VtxoManager, VtxoReservedError, Wallet2 as Wallet, WalletCannotAllocateAddressError, WalletCannotSignError, WalletMessageHandler, WalletNotInitializedError, WsElectrumChainSource, adoptContractDescriptor, arkAssetRail, arkRail, arkTarget, arkade_exports, assertFinalCommitmentMatchesValidated, assertHistoryPageFilter, assertIntentIdUnique, assertNoAssets, assertNoSelection, assertPageRequest, assertRecipientArkadeAddress, assertSendDeadline, assertSendableAmount, assertSubmittedArkTxid, assertValidBatchExpiry, assertValidServerUnrollScript, assetMintResolver, assetsOf, attachPrevArkTxs, attachPrevoutTxs, awaitTransaction, boardingResolver, btcTarget, buildForfeitTx, buildOffchainTx, buildPreimageMessage, buildSaltedPreimageMessage, captureSendDeadline, checkSaveVtxosForScript, claimWithPreimageIdentity, classifyAgainstSignerSet, classifyContractSigner, closeDatabase, collabExitResolver, collectContracts, collectIntents, collectPages, collectScriptVtxos, collectTransactionHistory, collectUtxos, collectVtxos, combineTapscriptSigs, compareHistoryCursors, contractFilterMatchesNothing, contractFromArkContract, contractFromArkContractWithAddress, contractPreimage, contractSigner, createAssetPacket, createDefaultActivityRegistry, createDefaultPaymentRouter, createExitChainResolver, createManagedConnection, createdAtToIso, decodeArkContract, defaultBatchExpiryPolicy, deleteByIndex, deserializeAssets, deserializeExitPackage, deserializeUtxo, deserializeVtxo, encodeArkContract, exitObserverFor, extendVirtualCoinForContract,
|
|
25990
|
-
//# sourceMappingURL=chunk-
|
|
25991
|
-
//# sourceMappingURL=chunk-
|
|
26184
|
+
export { ARKADE_MAGIC, ARKADE_SALTED_PREIMAGE_TAG, ARKADE_SWAP_PREIMAGE_TAG, ASSET_CARRIER_SATS, AbortError, ActivityRegistry, AmbiguousRouteError, ArkNote, Arkade, ArkadeCash, ArkadeCashCreateError, ArkadeCashOperatorMismatchError, AssetManager, BIP21, BIP21Error, BIP322, BLOCKED_UPGRADE_TIMEOUT_MS, Batch, CachingArkProvider, CachingOperatorProvider, ChainedTxType, ConnectionDisposedError, ContractManager, ContractWatcher, DEFAULT_MESSAGE_TIMEOUTS, DEFAULT_MIN_BATCH_EXPIRY_SECONDS, DatabaseUpgradeBlockedError, DelegateManagerImpl, DelegateNotConfiguredError, DescriptorIdentity, DescriptorSigningProviderMissingError, DustChangeError, ELECTRUM_TCP_HOST, ELECTRUM_WS_URL, ESPLORA_URL, ElectrumOnchainProvider, EmulatorPacket, EsploraProvider, Estimator, Extension, ExtensionNotFoundError, ForeignDescriptorError, HDDescriptorProvider, INTENT_TERMINAL_STATES, InMemoryContractRepository, InMemoryIntentRepository, InMemoryVirtualTxRepository, InMemoryWalletRepository, IndexedDBContractRepository, IndexedDBIntentRepository, IndexedDBVirtualTxRepository, IndexedDBWalletRepository, KeyringDescriptorProvider, MAX_PAGE_SIZE, MAX_USED_SIGNING_DESCRIPTORS_LOOK_AHEAD, MESSAGE_BUS_INITIALIZING, MESSAGE_BUS_NOT_INITIALIZED, MessageBus, MessageBusInitializingError, MessageBusNotInitializedError, MissingSigningDescriptorError, MnemonicIdentity, OnchainWallet, OversizedChangeError, P2A, PaymentRouter, PrevTxUnavailableError, REGTEST_MIN_BATCH_EXPIRY_SECONDS, Ramps, ReadonlyAssetManager, ReadonlyDescriptorIdentity, ReadonlySingleKey, ReadonlyWallet, ReadonlyWalletError, RestDelegateProvider, RestEmulatorProvider, SeedIdentity, SendDeadlineExceededError, ServiceWorkerReadonlyWallet, ServiceWorkerTimeoutError, ServiceWorkerWallet, SingleKey, StaticDescriptorProvider, TreeSignerSession, TxTree, TxType, TxWeightEstimator, UnannotatableInputError, UnilateralExit, UnknownPacket, Unroll, VtxoManager, VtxoReservedError, Wallet2 as Wallet, WalletCannotAllocateAddressError, WalletCannotSignError, WalletMessageHandler, WalletNotInitializedError, WsElectrumChainSource, adoptContractDescriptor, applyWalletStateUpdate, arkAssetRail, arkRail, arkTarget, arkade_exports, assertFinalCommitmentMatchesValidated, assertHistoryPageFilter, assertIntentIdUnique, assertNoAssets, assertNoSelection, assertPageRequest, assertRecipientArkadeAddress, assertSendDeadline, assertSendableAmount, assertSubmittedArkTxid, assertValidBatchExpiry, assertValidServerUnrollScript, assetMintResolver, assetsOf, attachPrevArkTxs, attachPrevoutTxs, awaitTransaction, boardingResolver, btcTarget, buildForfeitTx, buildOffchainTx, buildPreimageMessage, buildSaltedPreimageMessage, captureSendDeadline, checkSaveVtxosForScript, claimWithPreimageIdentity, classifyAgainstSignerSet, classifyContractSigner, closeDatabase, collabExitResolver, collectContracts, collectIntents, collectPages, collectScriptVtxos, collectTransactionHistory, collectUtxos, collectVtxos, combineTapscriptSigs, compareHistoryCursors, contractFilterMatchesNothing, contractFromArkContract, contractFromArkContractWithAddress, contractPreimage, contractSigner, createAssetPacket, createDefaultActivityRegistry, createDefaultPaymentRouter, createExitChainResolver, createManagedConnection, createdAtToIso, decodeArkContract, defaultBatchExpiryPolicy, deleteByIndex, deserializeAssets, deserializeExitPackage, deserializeUtxo, deserializeVtxo, encodeArkContract, exitObserverFor, extendVirtualCoinForContract, extractOperatorProviderUrl, gateExclusion, gatedContracts, getAllByIndexValues, getRandomId, hasBoardingTxExpired, hasCandidates, intentMatchesFilter, invoiceTarget, isAddressAllocationCapable, isArkContract, isBatchSignable, isBtcAddress, isContractGenericallySpendable, isContractVtxoEvent, isCooperativelyMigratable, isDeterministicSigner, isDiscoverable, isHDAllocationCapable, isHDDeterministicSignCapable, isHDWalletCapable, isLightningInvoice, isLnurl, isMessageBusInitializingError, isMessageBusNotInitializedError, isPerArtifactDescriptor, isSigningIdentity, isSubdust, isTerminalIntentState, isValidArkAddress, isVtxoExpiringSoon, iteratePages, legacyVtxoFacts, logExcludedVtxos, makeHandle, matchServerCheckpoints, mergeChainedTxType, notifyExitObserved, onchainRail, openDatabase, outpointExclusion, outpointReasons, pageResult, promisifyRequest, provisionClaimSecret, provisionRefundKey, registerWalletRestoreHook, resolveAssetAmount, resolveBatchExpiryPolicy, resolveDescriptorSigner, resolvePrevTxs, resolveSendAmount, saveVtxosForContract, scriptFromArkAddress, selectCoinsWithAsset, selectVirtualCoins, selectionOf, serializeAssets, serializeExitPackage, serializeUtxo, serializeVtxo, setupServiceWorker, signAndSubmitOffchainTx, signerSetFromInfo, signingDescriptorIndex, strictSigningDescriptorIndex, submitViaEmulator, toXOnlySignerHex, tryResolveSendAmount, utxoEntries, validateBatchRecipients, validateConnectorsTxGraph, validateVtxoTxGraph, verifyTapscriptSignatures, waitForIncomingFunds, walletFeeSource, warnAndFilterVtxosForScript, withPrevTxs };
|
|
26185
|
+
//# sourceMappingURL=chunk-ZJHLLDBP.js.map
|
|
26186
|
+
//# sourceMappingURL=chunk-ZJHLLDBP.js.map
|