@arkade-os/sdk 0.5.0-rc.2 → 0.5.0-rc.21
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 +90 -83
- package/dist/adapters/expo.cjs +5 -6
- package/dist/adapters/expo.d.cts +4 -4
- package/dist/adapters/expo.d.ts +4 -4
- package/dist/adapters/expo.js +3 -4
- package/dist/{asyncStorageTaskQueue-C5rBYlru.d.ts → asyncStorageTaskQueue-aL7K14e4.d.ts} +2 -2
- package/dist/{asyncStorageTaskQueue-BuDvgWh6.d.cts → asyncStorageTaskQueue-x8ok3tJy.d.cts} +2 -2
- package/dist/{chunk-ISO4TI5J.js → chunk-4FDNOLBO.js} +566 -459
- package/dist/chunk-4FDNOLBO.js.map +1 -0
- package/dist/{chunk-JZWLXNHV.cjs → chunk-5XBH5SAL.cjs} +574 -464
- package/dist/chunk-5XBH5SAL.cjs.map +1 -0
- package/dist/{chunk-3R476TDV.js → chunk-CXHJGED6.js} +293 -1071
- package/dist/chunk-CXHJGED6.js.map +1 -0
- package/dist/{chunk-ZRNQV6HV.js → chunk-EXFU6MTA.js} +4578 -4396
- package/dist/chunk-EXFU6MTA.js.map +1 -0
- package/dist/{chunk-43FKNLX4.cjs → chunk-GVF4OCTL.cjs} +357 -1114
- package/dist/chunk-GVF4OCTL.cjs.map +1 -0
- package/dist/{chunk-HLCGYOIH.cjs → chunk-HIZNPHB2.cjs} +37 -36
- package/dist/chunk-HIZNPHB2.cjs.map +1 -0
- package/dist/{chunk-4PKLULWT.js → chunk-JZAEFOE4.js} +109 -246
- package/dist/chunk-JZAEFOE4.js.map +1 -0
- package/dist/{chunk-ZOTXDOS5.js → chunk-LNJPVLIC.js} +30 -29
- package/dist/chunk-LNJPVLIC.js.map +1 -0
- package/dist/{chunk-NVZJSKZS.cjs → chunk-Q7PC3NHX.cjs} +121 -257
- package/dist/chunk-Q7PC3NHX.cjs.map +1 -0
- package/dist/{chunk-GMZZQXV5.cjs → chunk-R5OFJ23O.cjs} +4961 -4767
- package/dist/chunk-R5OFJ23O.cjs.map +1 -0
- package/dist/{chunk-6DNR46C7.js → chunk-S2WWOVFC.js} +7 -5
- package/dist/chunk-S2WWOVFC.js.map +1 -0
- package/dist/{chunk-D25O4EGY.cjs → chunk-VZMLADXQ.cjs} +12 -10
- package/dist/chunk-VZMLADXQ.cjs.map +1 -0
- package/dist/contracts/handlers/index.cjs +9 -10
- package/dist/contracts/handlers/index.d.cts +5 -5
- package/dist/contracts/handlers/index.d.ts +5 -5
- package/dist/contracts/handlers/index.js +2 -3
- package/dist/{delegate-BAX5QftB.d.ts → delegate-BT5iON1T.d.ts} +1 -1
- package/dist/{delegate-1yp1HyP7.d.cts → delegate-u6kXTtWY.d.cts} +1 -1
- package/dist/index-BCnhItOQ.d.cts +639 -0
- package/dist/{index-DUxufw76.d.cts → index-CK5QbTmZ.d.cts} +1387 -2404
- package/dist/{index-DUxufw76.d.ts → index-CK5QbTmZ.d.ts} +1387 -2404
- package/dist/index-D1D4cR-G.d.ts +639 -0
- package/dist/index.cjs +375 -340
- package/dist/index.d.cts +784 -1197
- package/dist/index.d.ts +784 -1197
- package/dist/index.js +4 -5
- package/dist/repositories/realm/index.cjs +201 -106
- package/dist/repositories/realm/index.cjs.map +1 -1
- package/dist/repositories/realm/index.d.cts +28 -16
- package/dist/repositories/realm/index.d.ts +28 -16
- package/dist/repositories/realm/index.js +190 -95
- package/dist/repositories/realm/index.js.map +1 -1
- package/dist/repositories/sqlite/index.cjs +301 -189
- package/dist/repositories/sqlite/index.cjs.map +1 -1
- package/dist/repositories/sqlite/index.d.cts +32 -21
- package/dist/repositories/sqlite/index.d.ts +32 -21
- package/dist/repositories/sqlite/index.js +294 -182
- package/dist/repositories/sqlite/index.js.map +1 -1
- package/dist/{taskRunner-D_iPiZIi.d.ts → taskRunner-BeYR6NpQ.d.ts} +2 -2
- package/dist/{taskRunner-Dr3NStc0.d.cts → taskRunner-Csey3EYJ.d.cts} +2 -2
- package/dist/wallet/expo/background.cjs +14 -15
- package/dist/wallet/expo/background.cjs.map +1 -1
- package/dist/wallet/expo/background.d.cts +10 -16
- package/dist/wallet/expo/background.d.ts +10 -16
- package/dist/wallet/expo/background.js +6 -7
- package/dist/wallet/expo/background.js.map +1 -1
- package/dist/wallet/expo/index.cjs +16 -23
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +6 -9
- package/dist/wallet/expo/index.d.ts +6 -9
- package/dist/wallet/expo/index.js +8 -15
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/wallet-DG3Qmbmt.d.cts +1848 -0
- package/dist/wallet-DzSLMxBZ.d.ts +1848 -0
- package/dist/worker/expo/index.cjs +9 -10
- package/dist/worker/expo/index.cjs.map +1 -1
- package/dist/worker/expo/index.d.cts +6 -6
- package/dist/worker/expo/index.d.ts +6 -6
- package/dist/worker/expo/index.js +5 -6
- package/dist/worker/expo/index.js.map +1 -1
- package/package.json +12 -51
- package/dist/adapters/asyncStorage.cjs +0 -48
- package/dist/adapters/asyncStorage.cjs.map +0 -1
- package/dist/adapters/asyncStorage.d.cts +0 -16
- package/dist/adapters/asyncStorage.d.ts +0 -16
- package/dist/adapters/asyncStorage.js +0 -46
- package/dist/adapters/asyncStorage.js.map +0 -1
- package/dist/adapters/fileSystem.cjs +0 -116
- package/dist/adapters/fileSystem.cjs.map +0 -1
- package/dist/adapters/fileSystem.d.cts +0 -17
- package/dist/adapters/fileSystem.d.ts +0 -17
- package/dist/adapters/fileSystem.js +0 -93
- package/dist/adapters/fileSystem.js.map +0 -1
- package/dist/adapters/indexedDB.cjs +0 -103
- package/dist/adapters/indexedDB.cjs.map +0 -1
- package/dist/adapters/indexedDB.d.cts +0 -18
- package/dist/adapters/indexedDB.d.ts +0 -18
- package/dist/adapters/indexedDB.js +0 -101
- package/dist/adapters/indexedDB.js.map +0 -1
- package/dist/adapters/localStorage.cjs +0 -50
- package/dist/adapters/localStorage.cjs.map +0 -1
- package/dist/adapters/localStorage.d.cts +0 -14
- package/dist/adapters/localStorage.d.ts +0 -14
- package/dist/adapters/localStorage.js +0 -48
- package/dist/adapters/localStorage.js.map +0 -1
- package/dist/chunk-3R476TDV.js.map +0 -1
- package/dist/chunk-43FKNLX4.cjs.map +0 -1
- package/dist/chunk-4PKLULWT.js.map +0 -1
- package/dist/chunk-5BLDMQED.cjs +0 -18
- package/dist/chunk-5BLDMQED.cjs.map +0 -1
- package/dist/chunk-6DNR46C7.js.map +0 -1
- package/dist/chunk-D25O4EGY.cjs.map +0 -1
- package/dist/chunk-GMZZQXV5.cjs.map +0 -1
- package/dist/chunk-HLCGYOIH.cjs.map +0 -1
- package/dist/chunk-ISO4TI5J.js.map +0 -1
- package/dist/chunk-JZWLXNHV.cjs.map +0 -1
- package/dist/chunk-NSBPE2FW.js +0 -15
- package/dist/chunk-NSBPE2FW.js.map +0 -1
- package/dist/chunk-NVZJSKZS.cjs.map +0 -1
- package/dist/chunk-ZOTXDOS5.js.map +0 -1
- package/dist/chunk-ZRNQV6HV.js.map +0 -1
- package/dist/hdWalletCapable-CmEU0NP1.d.ts +0 -2232
- package/dist/hdWalletCapable-eJgaT-ec.d.cts +0 -2232
- package/dist/index-Bem5vKzX.d.ts +0 -850
- package/dist/index-C0IanN1m.d.cts +0 -11
- package/dist/index-C0IanN1m.d.ts +0 -11
- package/dist/index-W_oMcOmG.d.cts +0 -850
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import { W as Wallet, R as ReadonlyWallet, b as ReceiveRotatorFactory, c as ReceiveRotatorBootOpts, d as ReceiveRotatorBoot, P as ProviderConnectionState, H as HDWalletCapable, a as HDAllocationCapable, A as AddressAllocationCapable, B as BatchExpiryPolicy, e as Batch } from './
|
|
4
|
-
export { f as AbortError, g as ArkError, h as ArkErrorName, i as ArkadeCashClaimResult, j as ArkadeCashCreateError, k as ArkadeCashUnclaimedReason, l as ArkadeCashUnclaimedVtxo, m as BoardingUtxoGroup, C as CheckpointExitDelayPolicy, D as DEFAULT_MIN_BATCH_EXPIRY_SECONDS,
|
|
5
|
-
import { P as Program, A as ArkadeParamValue, a as ArkadeProgramScript, b as ProgramKeys, c as ArkadeArgValue, C as CompiledProgramFunction, d as ArkadeFunction, I as InputRef, e as InputDef, f as ArkadeValueType, g as ArkadeArgType, h as ArkadeContractParams, i as ArkadeSegment, j as AsmToken, S as SUPPORTED_PROGRAM_VERSION, k as SignerRef, T as TapscriptSegment, W as WitnessRef,
|
|
6
|
-
export {
|
|
7
|
-
import { D as DefaultVtxo } from './delegate-
|
|
8
|
-
export { a as DelegateVtxo } from './delegate-
|
|
1
|
+
import { ah as ReadonlyIdentity, a as Identity, a3 as DescriptorSigningRequest, a4 as Transaction, az as SignerSession, a2 as DescriptorProvider, aD as IntentFeeConfig, aE as OffchainInput, aF as FeeAmount, aG as OnchainInput, aH as FeeOutput, X as IntentRepository, Y as ArkIntent, Z as IntentPageFilter, P as PageRequest, D as PageResult, O as Outpoint, _ as VirtualTxRepository, $ as VirtualTx, a0 as VtxoBranch, W as WalletRepository, B as ExtendedVirtualCoin, F as ScriptVtxoCursor, H as ScriptVtxoPageOptions, J as StoredVtxo, K as VtxoRepositoryKey, E as ExtendedCoin, L as TransactionHistoryPageFilter, M as TransactionHistoryPageCursor, h as ArkTransaction, Q as WalletState, z as Contract, C as ContractRepository, U as ContractFilter, I as IWallet, u as ArkProvider, ax as SettlementConfig, aI as ContractWatcherConfig, aJ as Asset, R as Recipient, aK as FeeInfo, o as SettlementEvent, N as NormalizedExtendedVirtualCoin, S as SettleParams, G as GetArkadeInfoOptions, aL as GetVtxosOptions, aM as PaginationOptions, f as GetVtxosFilter, g as GetSpendableVtxosFilter, aN as CreateContractParams, aO as GetContractsFilter, y as VirtualCoin, aP as GetSpendablePathsOptions, aQ as GetAllSpendingPathsOptions, l as GetNewAddressesOptions, aR as IssuanceParams, aS as ReissuanceParams, aT as BurnParams, aU as RenewVtxosOptions, A as ArkadeInfo, aV as NormalizedVtxoPage, c as ArkadeReader, d as ArkadeBroadcaster, e as WalletBalance, ao as ContractSyncState, as as ContractWithVtxos, aW as WatchedScript, aX as PathSelection, m as NewAddress, aY as ContractEvent, aZ as AssetDetails, a_ as IssuanceResult, a$ as DelegateInfo, b0 as MigrationGlobalSkipReason, b1 as MigrationLegSkipReason, b2 as SignerStatus, ag as IReadonlyWallet, i as ActivityRegistry, an as IReadonlyAssetManager, b3 as StorageConfig, j as Activity, k as IContractManager, q as IAssetManager, p as SendParams, n as IDelegateManager, b4 as IVtxoManager, ai as OnchainProvider, a5 as Network, aq as NetworkName, au as Coin, b5 as SendBitcoinParams, b6 as ExplorerTransaction, aA as SignedIntent, aB as Intent, b7 as TreeNonces, b8 as TreePartialSigs, T as TxNotificationEvent, b9 as PendingTx, x as TapLeafScript, ba as EncodedVtxoScript, a6 as CSVMultisigTapscript, w as RelativeTimelock, V as VtxoScript, bb as Status, ar as ArkAddress, bc as ChainTx, v as IndexerProvider, a9 as TxTree, bd as PathContext } from './index-CK5QbTmZ.js';
|
|
2
|
+
export { be as ActivityIntent, bf as ActivityResolver, bg as ArkIntentState, bh as ArkTapscript, bi as AssetMetadata, bj as BITCOIN_EMULATOR_PUBKEY, bk as BaseWalletConfig, ad as BatchFailedEvent, ab as BatchFinalizationEvent, ac as BatchFinalizedEvent, bl as BatchInfo, bm as BatchSignableIdentity, a7 as BatchStartedEvent, bn as CLTVMultisigTapscript, bo as CandidateDeps, bp as ChainTxType, a1 as ChainedTxType, bq as CommitmentTx, br as ConditionCSVMultisigTapscript, bs as ConditionMultisigTapscript, bt as ContractBalance, bu as ContractEventCallback, bv as ContractHandler, av as ContractManager, aw as ContractManagerConfig, bw as ContractState, bx as ContractVtxo, by as ContractVtxoEvent, bz as ContractWatcher, bA as DEFAULT_VTXO_PAGE_SIZE, bB as DelegateManagerImpl, bC as DelegateOptions, aj as DelegateProvider, bD as DeprecatedSignerMigrationReport, bE as DeprecatedSignerReport, bF as DigestMismatchError, bG as Discoverable, bH as DiscoveredContract, bI as DiscoveryDeps, bJ as ESPLORA_URL, bK as EsploraProvider, bL as EventSourceCapable, bM as EventSourceFactory, bN as EventSourceLike, bO as EventSourceUnavailableError, al as ExitCaptureMode, bP as ExitChainResolver, am as ExitDataSource, bQ as ExtendedContractVtxo, bR as GroupMembership, bS as HandlerError, bT as INTENT_TERMINAL_STATES, bU as IndexerTxType, bV as IntentCoin, bW as IntentFilter, bX as KnownMetadata, bY as MAX_PAGE_SIZE, bZ as MUTINYNET_EMULATOR_PUBKEY, b_ as MigrateDeprecatedSignerOptions, b$ as MigrationLegReport, c0 as MigrationVtxoRef, c1 as MultisigTapscript, c2 as NewAddressType, c3 as Nonces, c4 as Output, c5 as PageResponse, c6 as PartialSig, c7 as PrevTxSource, c8 as PrevTxUnavailableError, c9 as ProviderClass, ca as REGTEST_EMULATOR_PUBKEY, cb as RawTxSource, ak as ReadonlyWalletConfig, ap as RecipientArkadeAddressContext, cc as RenewalSplit, cd as RenewalSplitContext, r as RestArkProvider, ce as RestDelegateProvider, s as RestIndexerProvider, cf as ScanContractsOptions, cg as ScanResult, ch as ScheduledSession, ci as SettlementEventType, cj as SignRequest, ck as SignerClassification, cl as SignerSet, cm as SubscriptionEvent, cn as SubscriptionHeartbeat, t as SubscriptionResponse, co as SweepTxNotification, cp as TapLeaves, cq as TapTreeCoder, cr as TapscriptType, aC as TimeHeight, aa as TreeNoncesEvent, af as TreeSignatureEvent, a8 as TreeSigningStartedEvent, ae as TreeTxEvent, cs as Tx, ct as TxHistoryRecord, cu as TxKey, cv as TxNotification, cw as TxTag, cx as TxTreeNode, cy as TxType, cz as Vtxo, cA as VtxoChain, ay as VtxoManager, cB as VtxoType, b as WalletConfig, cC as WalletMode, cD as WithPrevTx, cE as assertAllowedSighashTypes, cF as assertPageRequest, cG as assertRecipientArkadeAddress, cH as assetMintResolver, cI as attachPrevArkTxs, cJ as attachPrevoutTxs, cK as boardingResolver, cL as canRecoverOnchain, cM as canSpendOffchain, cN as canSweepOnchain, cO as classifyAgainstSignerSet, cP as classifyContractSigner, cQ as collabExitResolver, cR as collectContracts, cS as collectIntents, cT as collectPages, cU as collectScriptVtxos, cV as collectTransactionHistory, cW as collectUtxos, cX as collectVtxos, cY as configureEventSource, cZ as createDefaultActivityRegistry, c_ as createExitChainResolver, c$ as decodeTapscript, d0 as defaultEmulatorPubkey, d1 as getAllNormalizedVtxos, d2 as getConfiguredEventSource, d3 as getNetwork, d4 as getNormalizedVtxos, d5 as getRandomId, d6 as getSequence, d7 as hasCandidates, d8 as isBatchSignable, d9 as isContractVtxoEvent, da as isCooperativelyMigratable, db as isDiscoverable, dc as isEventSourceUnavailableError, dd as isPastExpiry, de as isSigningIdentity, df as isSubdust, dg as isTerminalIntentState, dh as isVirtualCoin, di as isVtxoExpiringSoon, dj as isVtxoSpent, dk as iteratePages, dl as networkFromArkadeInfo, dm as networks, dn as pageResult, dp as resolveEmulatorPubkey, dq as resolveEventSource, dr as resolvePrevTxs, ds as scriptFromTapLeafScript, dt as signerSetFromInfo, du as toXOnlySignerHex, dv as withPrevTxs } from './index-CK5QbTmZ.js';
|
|
3
|
+
import { W as Wallet, R as ReadonlyWallet, b as ReceiveRotatorFactory, c as ReceiveRotatorBootOpts, d as ReceiveRotatorBoot, P as ProviderConnectionState, H as HDWalletCapable, a as HDAllocationCapable, A as AddressAllocationCapable, B as BatchExpiryPolicy, e as Batch } from './wallet-DzSLMxBZ.js';
|
|
4
|
+
export { f as AbortError, g as ArkError, h as ArkErrorName, i as ArkadeCashClaimResult, j as ArkadeCashCreateError, k as ArkadeCashUnclaimedReason, l as ArkadeCashUnclaimedVtxo, m as ArkadeCashVtxoRef, n as BoardingUtxoGroup, C as CheckpointExitDelayPolicy, D as DEFAULT_MIN_BATCH_EXPIRY_SECONDS, o as DEFAULT_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, F as ForeignDescriptorError, I as IncomingFunds, p as IndexedDBWalletRepository, K as KeyringDescriptorProvider, M as MAX_USED_SIGNING_DESCRIPTORS_LOOK_AHEAD, q as MUTINYNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, r as ProviderKind, s as ProviderUnavailableError, t as REGTEST_MIN_BATCH_EXPIRY_SECONDS, u as REGTEST_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, S as SIGNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, v as ServerInfoSource, w as ServerResponseMismatchError, x as WaitForIncomingFundsOptions, y as WalletCannotAllocateAddressError, z as assertValidBatchExpiry, E as assertValidServerUnrollScript, G as defaultBatchExpiryPolicy, J as defaultCheckpointExitDelayPolicy, L as isAddressAllocationCapable, N as isArkError, O as isHDAllocationCapable, Q as isHDWalletCapable, T as maybeArkError, U as resolveBatchExpiryPolicy, V as resolveCheckpointExitDelayPolicy, X as resolveDescriptorSigner, Y as selectVirtualCoins, Z as signingDescriptorIndex, _ as strictSigningDescriptorIndex, $ as waitForIncomingFunds } from './wallet-DzSLMxBZ.js';
|
|
5
|
+
import { P as Program, A as ArkadeParamValue, a as ArkadeProgramScript, b as ProgramKeys, c as ArkadeArgValue, C as CompiledProgramFunction, d as ArkadeFunction, I as InputRef, e as InputDef, f as ArkadeValueType, g as ArkadeArgType, h as ArkadeContractParams, i as ArkadeSegment, j as AsmToken, S as SUPPORTED_PROGRAM_VERSION, k as SignerRef, T as TapscriptSegment, l as TweakedSigner, W as WitnessRef, m as deserializeArkadeContractParams, p as parseArtifact, r as resolveAsm, s as serializeArkadeContractParams, n as stringifyArtifact, v as validateProgram, w as witnessRefToBytes } from './index-D1D4cR-G.js';
|
|
6
|
+
export { o as ArkadeContractHandler, B as BoardingContractHandler, q as BoardingContractParams, D as DefaultContractHandler, t as DefaultContractParams, u as DelegateContractHandler, x as DelegateContractParams, V as VHTLC, y as VHTLCContractHandler, z as VHTLCContractParams, E as VHTLCV2ContractHandler, F as VHTLCV2ContractParams, G as contractHandlers } from './index-D1D4cR-G.js';
|
|
7
|
+
import { D as DefaultVtxo } from './delegate-BT5iON1T.js';
|
|
8
|
+
export { a as DelegateVtxo } from './delegate-BT5iON1T.js';
|
|
9
9
|
import { Bytes, BTC_NETWORK } from '@scure/btc-signer/utils.js';
|
|
10
10
|
import { P2TR } from '@scure/btc-signer/payment.js';
|
|
11
11
|
import { Transaction as Transaction$1, OP, Script, ScriptType } from '@scure/btc-signer';
|
|
12
12
|
import { ElectrumWS } from 'ws-electrumx-client';
|
|
13
13
|
import { TransactionOutput, TransactionInputUpdate } from '@scure/btc-signer/psbt.js';
|
|
14
|
-
import { Transaction as Transaction$2 } from '@scure/btc-signer/transaction.js';
|
|
15
|
-
import { S as StorageAdapter } from './index-C0IanN1m.js';
|
|
16
14
|
import * as P from 'micro-packed';
|
|
15
|
+
import '@scure/btc-signer/transaction.js';
|
|
16
|
+
|
|
17
|
+
/** Validate an optional millisecond duration; zero retains its caller-defined meaning. */
|
|
18
|
+
declare function assertNonNegativeMs(name: string, ms: number | undefined): void;
|
|
19
|
+
/** Validate a timer delay without changing whether zero disables or immediately fires it. */
|
|
20
|
+
declare function assertTimerMs(name: string, ms: number | undefined): void;
|
|
17
21
|
|
|
18
22
|
/**
|
|
19
23
|
* Tagged envelope for a signing identity transported across the
|
|
@@ -55,18 +59,6 @@ type SerializedReadonlyIdentity = {
|
|
|
55
59
|
descriptor: string;
|
|
56
60
|
};
|
|
57
61
|
type SerializedIdentity = SerializedSigningIdentity | SerializedReadonlyIdentity;
|
|
58
|
-
/**
|
|
59
|
-
* Legacy untagged shape emitted by page builds prior to the tagged
|
|
60
|
-
* SerializedIdentity envelope. Retained so newer workers can still accept
|
|
61
|
-
* older pages during a rolling upgrade. Slated for removal in the next major.
|
|
62
|
-
*
|
|
63
|
-
* @deprecated Use {@link SerializedIdentity}.
|
|
64
|
-
*/
|
|
65
|
-
type LegacySerializedIdentity = {
|
|
66
|
-
privateKey: string;
|
|
67
|
-
} | {
|
|
68
|
-
publicKey: string;
|
|
69
|
-
};
|
|
70
62
|
|
|
71
63
|
/**
|
|
72
64
|
* Read-side HD capability marker. Exposes the wildcard-suffixed account
|
|
@@ -86,14 +78,8 @@ interface ReadonlyHDCapableIdentity extends ReadonlyIdentity {
|
|
|
86
78
|
* concrete descriptor by replacing the `*` with a derivation index.
|
|
87
79
|
*/
|
|
88
80
|
readonly descriptor: string;
|
|
89
|
-
/**
|
|
90
|
-
|
|
91
|
-
*
|
|
92
|
-
* @deprecated Prefer `DescriptorProvider.isOurs()` via
|
|
93
|
-
* `HDDescriptorProvider` for rotating HD wallets or
|
|
94
|
-
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
95
|
-
*/
|
|
96
|
-
isOurs(descriptor: string): boolean;
|
|
81
|
+
/** True iff `descriptor` derives from this identity's xpub/seed. */
|
|
82
|
+
ownsDescriptor(descriptor: string): boolean;
|
|
97
83
|
}
|
|
98
84
|
/**
|
|
99
85
|
* Capability marker for identities that can be rotated through an HD
|
|
@@ -110,22 +96,10 @@ interface ReadonlyHDCapableIdentity extends ReadonlyIdentity {
|
|
|
110
96
|
* explicitly-non-rotating use cases.
|
|
111
97
|
*/
|
|
112
98
|
interface HDCapableIdentity extends ReadonlyHDCapableIdentity, Identity {
|
|
113
|
-
/**
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
* `HDDescriptorProvider` or `StaticDescriptorProvider`. Identities keep
|
|
118
|
-
* this method only as backing implementation for descriptor providers.
|
|
119
|
-
*/
|
|
120
|
-
signWithDescriptor(requests: DescriptorSigningRequest[]): Promise<Transaction[]>;
|
|
121
|
-
/**
|
|
122
|
-
* Signs a message using the key derived from `descriptor`.
|
|
123
|
-
*
|
|
124
|
-
* @deprecated Prefer `DescriptorProvider.signMessageWithDescriptor()` via
|
|
125
|
-
* `HDDescriptorProvider` or `StaticDescriptorProvider`. Identities keep
|
|
126
|
-
* this method only as backing implementation for descriptor providers.
|
|
127
|
-
*/
|
|
128
|
-
signMessageWithDescriptor(descriptor: string, message: Uint8Array, signatureType?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
|
|
99
|
+
/** Signs each request with the key derived from its descriptor. */
|
|
100
|
+
signDescriptorTransactions(requests: DescriptorSigningRequest[]): Promise<Transaction[]>;
|
|
101
|
+
/** Signs a message using the key derived from `descriptor`. */
|
|
102
|
+
signDescriptorMessage(descriptor: string, message: Uint8Array, signatureType?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
|
|
129
103
|
}
|
|
130
104
|
|
|
131
105
|
/** Used for default BIP86 derivation with network selection. */
|
|
@@ -140,9 +114,8 @@ interface NetworkOptions {
|
|
|
140
114
|
/** Used for a caller-supplied account-descriptor template. */
|
|
141
115
|
interface DescriptorOptions {
|
|
142
116
|
/**
|
|
143
|
-
* Account-descriptor *template
|
|
144
|
-
*
|
|
145
|
-
* read by HD providers to rotate through derivation indices.
|
|
117
|
+
* Account-descriptor *template*; must end with the BIP-32 wildcard suffix `/*)`. Stored as-is
|
|
118
|
+
* on {@link SeedIdentity.descriptor} for HD providers to rotate through indices.
|
|
146
119
|
*/
|
|
147
120
|
descriptor: string;
|
|
148
121
|
}
|
|
@@ -154,32 +127,18 @@ type MnemonicOptions = SeedIdentityOptions & {
|
|
|
154
127
|
passphrase?: string;
|
|
155
128
|
};
|
|
156
129
|
/**
|
|
157
|
-
* Seed-based identity derived from a raw seed and an account descriptor
|
|
158
|
-
* *template*.
|
|
159
|
-
*
|
|
160
|
-
* This is the recommended identity type for most applications. It uses
|
|
161
|
-
* standard BIP86 (Taproot) derivation by default; callers that need a
|
|
162
|
-
* different path supply the wildcard template directly.
|
|
130
|
+
* Seed-based identity derived from a raw seed and an account descriptor *template*.
|
|
163
131
|
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
* raw nsec-style keys.
|
|
132
|
+
* The recommended identity type: BIP86 (Taproot) derivation by default, or a caller-supplied
|
|
133
|
+
* wildcard template. Prefer it (or @see MnemonicIdentity) over `SingleKey`, which exists for
|
|
134
|
+
* backward compatibility with raw nsec-style keys.
|
|
167
135
|
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
* field. HD rotation reads it directly; consumers that need a
|
|
171
|
-
* concrete descriptor at a specific index materialize it themselves
|
|
172
|
-
* (see `HDDescriptorProvider` in the wallet layer).
|
|
136
|
+
* {@link descriptor} holds the wildcard template (e.g. `tr([fp/86'/0'/0']xpub/0/*)`); consumers
|
|
137
|
+
* materialize concrete indices themselves (see `HDDescriptorProvider`).
|
|
173
138
|
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
* - `HDDescriptorProvider` for rotating receive addresses.
|
|
178
|
-
* - {@link StaticDescriptorProvider} for legacy, single-key behaviour.
|
|
179
|
-
*
|
|
180
|
-
* The split prevents a SeedIdentity from being silently used as a
|
|
181
|
-
* concrete descriptor source, which would defeat HD rotation without
|
|
182
|
-
* any compile-time signal that something was wrong.
|
|
139
|
+
* Deliberately NOT a `DescriptorProvider`, so it can't silently be used as a concrete
|
|
140
|
+
* descriptor source and defeat HD rotation. Wrap it in `HDDescriptorProvider` (rotating
|
|
141
|
+
* receive addresses) or {@link StaticDescriptorProvider} (legacy single-key behaviour).
|
|
183
142
|
*
|
|
184
143
|
* @example
|
|
185
144
|
* ```typescript
|
|
@@ -197,34 +156,21 @@ type MnemonicOptions = SeedIdentityOptions & {
|
|
|
197
156
|
*/
|
|
198
157
|
declare class SeedIdentity implements HDCapableIdentity {
|
|
199
158
|
private readonly derivedKey;
|
|
200
|
-
/**
|
|
201
|
-
* Wildcard account-descriptor template (e.g.
|
|
202
|
-
* `tr([fp/86'/0'/0']xpub/0/*)`). The canonical thing to pass
|
|
203
|
-
* through the system; consumers materialize a concrete descriptor
|
|
204
|
-
* at a specific index themselves (see `HDDescriptorProvider` in
|
|
205
|
-
* the wallet layer for the rotating-counter use case).
|
|
206
|
-
*/
|
|
159
|
+
/** Wildcard account-descriptor template (e.g. `tr([fp/86'/0'/0']xpub/0/*)`). */
|
|
207
160
|
readonly descriptor: string;
|
|
208
161
|
/**
|
|
209
|
-
* Constructs a SeedIdentity from a 64-byte seed and either a
|
|
210
|
-
*
|
|
211
|
-
* default BIP86 path at the requested network (`{ isMainnet }`).
|
|
212
|
-
* Prefer the {@link fromSeed} factory for symmetry with
|
|
213
|
-
* {@link MnemonicIdentity.fromMnemonic}.
|
|
162
|
+
* Constructs a SeedIdentity from a 64-byte seed and either a wildcard `{ descriptor }` or the
|
|
163
|
+
* default BIP86 path for `{ isMainnet }`. Prefer {@link fromSeed}.
|
|
214
164
|
*
|
|
215
|
-
* Throws on a non-wildcard descriptor, an xpub mismatch with the
|
|
216
|
-
*
|
|
165
|
+
* Throws on a non-wildcard descriptor, an xpub mismatch with the seed, or a missing
|
|
166
|
+
* derivation path.
|
|
217
167
|
*/
|
|
218
168
|
constructor(seed: Uint8Array, opts?: SeedIdentityOptions);
|
|
219
169
|
/**
|
|
220
|
-
* Creates a SeedIdentity from a raw 64-byte seed
|
|
221
|
-
*
|
|
222
|
-
* Pass `{ isMainnet }` for default BIP86 derivation, or
|
|
223
|
-
* `{ descriptor }` for a caller-supplied account-descriptor
|
|
224
|
-
* template (the option's value must end with `/*)`).
|
|
170
|
+
* Creates a SeedIdentity from a raw 64-byte seed: `{ isMainnet }` for default BIP86
|
|
171
|
+
* derivation, or `{ descriptor }` for a template ending in `/*)`.
|
|
225
172
|
*
|
|
226
173
|
* @param seed - 64-byte seed (typically from mnemonicToSeedSync)
|
|
227
|
-
* @param opts - Network selection or descriptor template.
|
|
228
174
|
*/
|
|
229
175
|
static fromSeed(seed: Uint8Array, opts?: SeedIdentityOptions): SeedIdentity;
|
|
230
176
|
xOnlyPublicKey(): Promise<Uint8Array>;
|
|
@@ -232,50 +178,23 @@ declare class SeedIdentity implements HDCapableIdentity {
|
|
|
232
178
|
sign(tx: Transaction, inputIndexes?: number[]): Promise<Transaction>;
|
|
233
179
|
signMessage(message: Uint8Array, signatureType?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
|
|
234
180
|
/**
|
|
235
|
-
* BIP-340 sign `messageHash` with this identity's own key, aux_rand = 0
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
* {@link signSchnorrDeterministicWithDescriptor}, for an `auto`-mode wallet
|
|
239
|
-
* whose bare `tr(pubkey)` resolves to the identity itself rather than to a
|
|
240
|
-
* {@link DescriptorIdentity}. Deliberately NOT routed through
|
|
241
|
-
* `signMessage`, whose schnorr branch draws a random aux_rand and would
|
|
242
|
-
* make the "deterministic" signature unreproducible.
|
|
181
|
+
* BIP-340 sign `messageHash` with this identity's own key, aux_rand = 0 (for an `auto`-mode
|
|
182
|
+
* wallet whose bare `tr(pubkey)` resolves to the identity itself). NOT via `signMessage`,
|
|
183
|
+
* whose random aux_rand would make the signature unreproducible.
|
|
243
184
|
*/
|
|
244
185
|
signSchnorrDeterministic(messageHash: Uint8Array): Promise<Uint8Array>;
|
|
245
186
|
signerSession(): SignerSession;
|
|
246
|
-
/**
|
|
247
|
-
* Converts to a watch-only identity that cannot sign. Carries the
|
|
248
|
-
* template forward, so the readonly side stays HD-capable (can
|
|
249
|
-
* derive descriptors at any index without seed access).
|
|
250
|
-
*/
|
|
187
|
+
/** Watch-only copy; carries the template forward, so it stays HD-capable without the seed. */
|
|
251
188
|
toReadonly(): Promise<ReadonlyDescriptorIdentity>;
|
|
252
|
-
/**
|
|
253
|
-
|
|
254
|
-
* HD descriptors match by account xpub; bare `tr(pubkey)` descriptors
|
|
255
|
-
* match by raw pubkey. See {@link descriptorIsOurs}.
|
|
256
|
-
*
|
|
257
|
-
* @deprecated Prefer `DescriptorProvider.isOurs()` via
|
|
258
|
-
* `HDDescriptorProvider` for rotating HD wallets or
|
|
259
|
-
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
260
|
-
*/
|
|
261
|
-
isOurs(descriptor: string): boolean;
|
|
189
|
+
/** Returns true when `descriptor` is derived from this identity's seed. */
|
|
190
|
+
ownsDescriptor(descriptor: string): boolean;
|
|
262
191
|
/**
|
|
263
192
|
* Signs each request with the key derived from its descriptor.
|
|
264
|
-
* Each descriptor must share this identity's seed ({@link
|
|
265
|
-
*
|
|
266
|
-
* @deprecated Prefer `DescriptorProvider.signWithDescriptor()` via
|
|
267
|
-
* `HDDescriptorProvider` or `StaticDescriptorProvider`. Identities keep
|
|
268
|
-
* this method only as backing implementation for descriptor providers.
|
|
193
|
+
* Each descriptor must share this identity's seed ({@link ownsDescriptor}).
|
|
269
194
|
*/
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
|
|
273
|
-
*
|
|
274
|
-
* @deprecated Prefer `DescriptorProvider.signMessageWithDescriptor()` via
|
|
275
|
-
* `HDDescriptorProvider` or `StaticDescriptorProvider`. Identities keep
|
|
276
|
-
* this method only as backing implementation for descriptor providers.
|
|
277
|
-
*/
|
|
278
|
-
signMessageWithDescriptor(descriptor: string, message: Uint8Array, signatureType?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
|
|
195
|
+
signDescriptorTransactions(requests: DescriptorSigningRequest[]): Promise<Transaction[]>;
|
|
196
|
+
/** Signs a message with the key derived from `descriptor`. */
|
|
197
|
+
signDescriptorMessage(descriptor: string, message: Uint8Array, signatureType?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
|
|
279
198
|
/**
|
|
280
199
|
* BIP-340 sign `messageHash` with the key derived from `descriptor`,
|
|
281
200
|
* aux_rand = 0. Backs {@link DescriptorIdentity.signSchnorrDeterministic},
|
|
@@ -287,12 +206,8 @@ declare class SeedIdentity implements HDCapableIdentity {
|
|
|
287
206
|
private signMessageWithKey;
|
|
288
207
|
}
|
|
289
208
|
/**
|
|
290
|
-
* Mnemonic-based identity derived from a BIP39 phrase
|
|
291
|
-
*
|
|
292
|
-
* This is the most user-friendly identity type — recommended for wallet
|
|
293
|
-
* applications where users manage their own backup phrase. Extends
|
|
294
|
-
* @see SeedIdentity with mnemonic validation and optional passphrase
|
|
295
|
-
* support.
|
|
209
|
+
* Mnemonic-based identity derived from a BIP39 phrase; recommended where users manage their own
|
|
210
|
+
* backup phrase. Extends @see SeedIdentity with mnemonic validation and an optional passphrase.
|
|
296
211
|
*
|
|
297
212
|
* @example
|
|
298
213
|
* ```typescript
|
|
@@ -305,27 +220,16 @@ declare class SeedIdentity implements HDCapableIdentity {
|
|
|
305
220
|
declare class MnemonicIdentity extends SeedIdentity {
|
|
306
221
|
private constructor();
|
|
307
222
|
/**
|
|
308
|
-
* Creates a MnemonicIdentity from a BIP39
|
|
309
|
-
*
|
|
310
|
-
* Pass `{ isMainnet }` for default BIP86 derivation, or
|
|
311
|
-
* `{ descriptor }` for a caller-supplied account-descriptor
|
|
312
|
-
* template (the option's value must end with `/*)`).
|
|
223
|
+
* Creates a MnemonicIdentity from a BIP39 phrase: `{ isMainnet }` for default BIP86
|
|
224
|
+
* derivation, or `{ descriptor }` for a template ending in `/*)`, plus optional passphrase.
|
|
313
225
|
*
|
|
314
226
|
* @param phrase - BIP39 mnemonic phrase (12 or 24 words)
|
|
315
|
-
* @param opts - Network selection or descriptor template, plus optional passphrase
|
|
316
227
|
*/
|
|
317
228
|
static fromMnemonic(phrase: string, opts?: MnemonicOptions): MnemonicIdentity;
|
|
318
229
|
}
|
|
319
230
|
/**
|
|
320
|
-
* Watch-only HD identity from a descriptor
|
|
321
|
-
*
|
|
322
|
-
* Can derive public keys but cannot sign transactions. Use this for
|
|
323
|
-
* watch-only wallets — given just an xpub-based template, the readonly
|
|
324
|
-
* side still rotates through HD indices.
|
|
325
|
-
*
|
|
326
|
-
* Constructed from a wildcard template (e.g.
|
|
327
|
-
* `tr([fp/86'/0'/0']xpub.../0/*)`); the {@link descriptor} field
|
|
328
|
-
* holds it for HD providers to consume.
|
|
231
|
+
* Watch-only HD identity from a wildcard descriptor template (e.g.
|
|
232
|
+
* `tr([fp/86'/0'/0']xpub.../0/*)`): derives public keys and rotates HD indices, cannot sign.
|
|
329
233
|
*
|
|
330
234
|
* @example
|
|
331
235
|
* ```typescript
|
|
@@ -338,40 +242,19 @@ declare class MnemonicIdentity extends SeedIdentity {
|
|
|
338
242
|
*/
|
|
339
243
|
declare class ReadonlyDescriptorIdentity implements ReadonlyHDCapableIdentity {
|
|
340
244
|
/**
|
|
341
|
-
* Index-0 expansion of {@link descriptor}
|
|
342
|
-
* (
|
|
343
|
-
* pubkey (derived through the bip32 node when needed) are read off
|
|
344
|
-
* this on demand — no separate caches.
|
|
245
|
+
* Index-0 expansion of {@link descriptor}; the x-only pubkey (32 bytes) and the compressed
|
|
246
|
+
* pubkey (via the bip32 node) are both read off it on demand.
|
|
345
247
|
*/
|
|
346
248
|
private readonly indexZero;
|
|
347
|
-
/**
|
|
348
|
-
* Wildcard account-descriptor template (e.g.
|
|
349
|
-
* `tr([fp/86'/0'/0']xpub/0/*)`). HD rotation consumers materialize
|
|
350
|
-
* a concrete descriptor at a specific index themselves.
|
|
351
|
-
*/
|
|
249
|
+
/** Wildcard account-descriptor template (e.g. `tr([fp/86'/0'/0']xpub/0/*)`). */
|
|
352
250
|
readonly descriptor: string;
|
|
353
251
|
private constructor();
|
|
354
|
-
/**
|
|
355
|
-
* Creates a ReadonlyDescriptorIdentity from an account-descriptor
|
|
356
|
-
* *template* (must end with the BIP-32 wildcard suffix `/*)`).
|
|
357
|
-
*
|
|
358
|
-
* @param descriptor - Wildcard-suffixed Taproot template
|
|
359
|
-
* (`tr([fp/path']xpub.../child/*)`).
|
|
360
|
-
*/
|
|
252
|
+
/** @param descriptor - Wildcard-suffixed Taproot template (`tr([fp/path']xpub.../child/*)`). */
|
|
361
253
|
static fromDescriptor(descriptor: string): ReadonlyDescriptorIdentity;
|
|
362
254
|
xOnlyPublicKey(): Promise<Uint8Array>;
|
|
363
255
|
compressedPublicKey(): Promise<Uint8Array>;
|
|
364
|
-
/**
|
|
365
|
-
|
|
366
|
-
* HD descriptors match by account xpub; bare `tr(pubkey)` descriptors
|
|
367
|
-
* fall back to comparing against the index-0 x-only pubkey. See
|
|
368
|
-
* {@link descriptorIsOurs}.
|
|
369
|
-
*
|
|
370
|
-
* @deprecated Prefer `DescriptorProvider.isOurs()` via
|
|
371
|
-
* `HDDescriptorProvider` for rotating HD wallets or
|
|
372
|
-
* `StaticDescriptorProvider` for legacy single-key wallets.
|
|
373
|
-
*/
|
|
374
|
-
isOurs(descriptor: string): boolean;
|
|
256
|
+
/** Returns true when `descriptor` derives from this identity's xpub. */
|
|
257
|
+
ownsDescriptor(descriptor: string): boolean;
|
|
375
258
|
}
|
|
376
259
|
|
|
377
260
|
/**
|
|
@@ -488,73 +371,19 @@ declare class DescriptorIdentity implements Identity {
|
|
|
488
371
|
}
|
|
489
372
|
|
|
490
373
|
/**
|
|
491
|
-
*
|
|
492
|
-
*
|
|
493
|
-
* @example
|
|
494
|
-
* ```typescript
|
|
495
|
-
* // Create from hex string
|
|
496
|
-
* const key = SingleKey.fromHex('your_private_key_hex');
|
|
497
|
-
*
|
|
498
|
-
* // Create from raw bytes
|
|
499
|
-
* const key = SingleKey.fromPrivateKey(privateKeyBytes);
|
|
500
|
-
*
|
|
501
|
-
* // Create random key
|
|
502
|
-
* const randomKey = SingleKey.fromRandomBytes();
|
|
503
|
-
*
|
|
504
|
-
* // Sign a transaction
|
|
505
|
-
* const signedTx = await key.sign(transaction);
|
|
506
|
-
* ```
|
|
374
|
+
* Wraps a legacy Identity (single-key) as a DescriptorProvider.
|
|
375
|
+
* The descriptor is always a simple tr(pubkey) format.
|
|
507
376
|
*/
|
|
508
|
-
declare class
|
|
509
|
-
private
|
|
510
|
-
private
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
* Export the private key as a hex string.
|
|
519
|
-
*
|
|
520
|
-
* @returns The private key as a hex string
|
|
521
|
-
*/
|
|
522
|
-
toHex(): string;
|
|
523
|
-
sign(tx: Transaction, inputIndexes?: number[]): Promise<Transaction>;
|
|
524
|
-
compressedPublicKey(): Promise<Uint8Array>;
|
|
525
|
-
xOnlyPublicKey(): Promise<Uint8Array>;
|
|
526
|
-
signerSession(): SignerSession;
|
|
527
|
-
signMessage(message: Uint8Array, signatureType?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
|
|
528
|
-
/**
|
|
529
|
-
* BIP-340 sign `messageHash` with aux_rand = 0, so the signature — and
|
|
530
|
-
* anything derived from it — is reproducible from the key alone.
|
|
531
|
-
*
|
|
532
|
-
* What lets a static wallet derive a swap preimage instead of storing one
|
|
533
|
-
* (see `wallet/contractSecrets.ts`). Deliberately NOT `signMessage`, whose
|
|
534
|
-
* schnorr branch draws a random aux_rand: a preimage derived from that is
|
|
535
|
-
* unrecoverable, and the loss would only surface at claim time.
|
|
536
|
-
*/
|
|
537
|
-
signSchnorrDeterministic(messageHash: Uint8Array): Promise<Uint8Array>;
|
|
538
|
-
toReadonly(): Promise<ReadonlySingleKey>;
|
|
539
|
-
}
|
|
540
|
-
declare class ReadonlySingleKey implements ReadonlyIdentity {
|
|
541
|
-
private readonly publicKey;
|
|
542
|
-
/** Create a readonly identity from a compressed public key. */
|
|
543
|
-
constructor(publicKey: Uint8Array);
|
|
544
|
-
/**
|
|
545
|
-
* Create a ReadonlySingleKey from a compressed public key.
|
|
546
|
-
*
|
|
547
|
-
* @param publicKey - 33-byte compressed public key (02/03 prefix + 32-byte x coordinate)
|
|
548
|
-
* @returns A new ReadonlySingleKey instance
|
|
549
|
-
* @example
|
|
550
|
-
* ```typescript
|
|
551
|
-
* const pubkey = new Uint8Array(33); // your compressed public key
|
|
552
|
-
* const readonlyKey = ReadonlySingleKey.fromPublicKey(pubkey);
|
|
553
|
-
* ```
|
|
554
|
-
*/
|
|
555
|
-
static fromPublicKey(publicKey: Uint8Array): ReadonlySingleKey;
|
|
556
|
-
xOnlyPublicKey(): Promise<Uint8Array>;
|
|
557
|
-
compressedPublicKey(): Promise<Uint8Array>;
|
|
377
|
+
declare class StaticDescriptorProvider implements DescriptorProvider {
|
|
378
|
+
private readonly identity;
|
|
379
|
+
private readonly descriptor;
|
|
380
|
+
private readonly pubKeyHex;
|
|
381
|
+
constructor(identity: Identity, pubKeyHex: string);
|
|
382
|
+
static create(identity: Identity): Promise<StaticDescriptorProvider>;
|
|
383
|
+
getNextSigningDescriptor(): Promise<string>;
|
|
384
|
+
isOurs(descriptor: string): boolean;
|
|
385
|
+
signWithDescriptor(requests: DescriptorSigningRequest[]): Promise<Transaction[]>;
|
|
386
|
+
signMessageWithDescriptor(descriptor: string, message: Uint8Array, type?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
|
|
558
387
|
}
|
|
559
388
|
|
|
560
389
|
/**
|
|
@@ -611,7 +440,7 @@ declare class InMemoryIntentRepository implements IntentRepository {
|
|
|
611
440
|
private byId;
|
|
612
441
|
clear(): Promise<void>;
|
|
613
442
|
saveIntent(intent: ArkIntent): Promise<void>;
|
|
614
|
-
|
|
443
|
+
getIntentsPage(filter: IntentPageFilter | undefined, page: PageRequest): Promise<PageResult<ArkIntent>>;
|
|
615
444
|
getLockedVtxoOutpoints(): Promise<Outpoint[]>;
|
|
616
445
|
[Symbol.asyncDispose](): Promise<void>;
|
|
617
446
|
}
|
|
@@ -631,11 +460,8 @@ declare class InMemoryVirtualTxRepository implements VirtualTxRepository {
|
|
|
631
460
|
}
|
|
632
461
|
|
|
633
462
|
/**
|
|
634
|
-
* @experimental Virtual-tx persistence is
|
|
635
|
-
*
|
|
636
|
-
* so it must be given a *dedicated* `dbName` distinct from the wallet/contract
|
|
637
|
-
* DB until this persistence is activated in the shared schema — otherwise the
|
|
638
|
-
* shared DB's version-conflict guard rejects the mismatched open.
|
|
463
|
+
* @experimental Virtual-tx persistence is opt-in. Stored in its own database,
|
|
464
|
+
* {@link BATCHES_DB_NAME} by default, never in the wallet/contract one.
|
|
639
465
|
*/
|
|
640
466
|
declare class IndexedDBVirtualTxRepository implements VirtualTxRepository {
|
|
641
467
|
readonly version: 1;
|
|
@@ -653,11 +479,8 @@ declare class IndexedDBVirtualTxRepository implements VirtualTxRepository {
|
|
|
653
479
|
}
|
|
654
480
|
|
|
655
481
|
/**
|
|
656
|
-
* @experimental Intent persistence is
|
|
657
|
-
*
|
|
658
|
-
* be given a *dedicated* `dbName` distinct from the wallet/contract DB until
|
|
659
|
-
* intent persistence is activated in the shared schema — otherwise the shared
|
|
660
|
-
* DB's version-conflict guard rejects the mismatched open.
|
|
482
|
+
* @experimental Intent persistence is opt-in. Stored in its own database,
|
|
483
|
+
* {@link BATCHES_DB_NAME} by default, never in the wallet/contract one.
|
|
661
484
|
*/
|
|
662
485
|
declare class IndexedDBIntentRepository implements IntentRepository {
|
|
663
486
|
readonly version: 1;
|
|
@@ -666,7 +489,7 @@ declare class IndexedDBIntentRepository implements IntentRepository {
|
|
|
666
489
|
private getDB;
|
|
667
490
|
clear(): Promise<void>;
|
|
668
491
|
saveIntent(intent: ArkIntent): Promise<void>;
|
|
669
|
-
|
|
492
|
+
getIntentsPage(filter: IntentPageFilter | undefined, page: PageRequest): Promise<PageResult<ArkIntent>>;
|
|
670
493
|
getLockedVtxoOutpoints(): Promise<Outpoint[]>;
|
|
671
494
|
[Symbol.asyncDispose](): Promise<void>;
|
|
672
495
|
}
|
|
@@ -676,21 +499,21 @@ declare class IndexedDBIntentRepository implements IntentRepository {
|
|
|
676
499
|
* Data is ephemeral and scoped to the instance.
|
|
677
500
|
*/
|
|
678
501
|
declare class InMemoryWalletRepository implements WalletRepository {
|
|
679
|
-
readonly version:
|
|
502
|
+
readonly version: 2;
|
|
680
503
|
private readonly vtxosByAddress;
|
|
681
504
|
private readonly utxosByAddress;
|
|
682
505
|
private readonly txsByAddress;
|
|
683
506
|
private walletState;
|
|
684
|
-
|
|
507
|
+
getVtxosPage(address: string, page: PageRequest<Outpoint>): Promise<PageResult<ExtendedVirtualCoin, Outpoint>>;
|
|
685
508
|
saveVtxos(address: string, vtxos: ExtendedVirtualCoin[]): Promise<void>;
|
|
686
509
|
deleteVtxos(address: string): Promise<void>;
|
|
687
|
-
|
|
510
|
+
getVtxosForScriptPage(script: string, page: PageRequest<ScriptVtxoCursor>, options?: ScriptVtxoPageOptions): Promise<PageResult<StoredVtxo, ScriptVtxoCursor>>;
|
|
688
511
|
saveVtxosForScript(key: VtxoRepositoryKey, vtxos: ExtendedVirtualCoin[]): Promise<void>;
|
|
689
512
|
deleteVtxosForScript(script: string): Promise<void>;
|
|
690
|
-
|
|
691
|
-
saveUtxos(
|
|
513
|
+
getUtxosPage(address: string, page: PageRequest<Outpoint>): Promise<PageResult<ExtendedCoin, Outpoint>>;
|
|
514
|
+
saveUtxos(addressOrBatch: string | ReadonlyMap<string, ExtendedCoin[]>, utxos?: ExtendedCoin[]): Promise<void>;
|
|
692
515
|
deleteUtxos(address: string): Promise<void>;
|
|
693
|
-
|
|
516
|
+
getTransactionHistoryPage(filter: TransactionHistoryPageFilter, page: PageRequest<TransactionHistoryPageCursor>): Promise<PageResult<ArkTransaction, TransactionHistoryPageCursor>>;
|
|
694
517
|
saveTransactions(address: string, txs: ArkTransaction[]): Promise<void>;
|
|
695
518
|
deleteTransactions(address: string): Promise<void>;
|
|
696
519
|
getWalletState(): Promise<WalletState | null>;
|
|
@@ -700,11 +523,8 @@ declare class InMemoryWalletRepository implements WalletRepository {
|
|
|
700
523
|
}
|
|
701
524
|
|
|
702
525
|
/**
|
|
703
|
-
* Whether generic wallet spending may select this contract's VTXOs.
|
|
704
|
-
*
|
|
705
|
-
* Default closed: a type whose handler declares nothing — a custom type, a
|
|
706
|
-
* plugin type, a row whose handler is not registered in this context — is not
|
|
707
|
-
* spendable. Every shipped handler answers explicitly.
|
|
526
|
+
* Whether generic wallet spending may select this contract's VTXOs. Default closed: a type whose
|
|
527
|
+
* handler declares nothing, or has no handler registered here, is not spendable.
|
|
708
528
|
*
|
|
709
529
|
* @see ContractHandler.isGenericallySpendable
|
|
710
530
|
*/
|
|
@@ -720,69 +540,47 @@ type ExcludableVtxo = {
|
|
|
720
540
|
vout: number;
|
|
721
541
|
script?: string;
|
|
722
542
|
};
|
|
543
|
+
/** {@link gatedContracts}' answer, as callers that only read it should take it. */
|
|
544
|
+
type GatedContracts = ReadonlyMap<string, string>;
|
|
723
545
|
/**
|
|
724
|
-
* Why generic spending skips a VTXO, or `undefined` when it does not
|
|
725
|
-
*
|
|
726
|
-
*
|
|
727
|
-
* Generic spending applies three exclusions (the contract gate, pending
|
|
728
|
-
* recovery, intent locks) that key on different things — script, script,
|
|
729
|
-
* outpoint. Stating each as a reason-or-undefined lets all three report through
|
|
730
|
-
* one path, so no exclusion can drop a coin silently while another logs.
|
|
546
|
+
* Why generic spending skips a VTXO, or `undefined` when it does not; phrased to follow the
|
|
547
|
+
* outpoint in a log line. One shape for all exclusions (contract gate, pending recovery, intent
|
|
548
|
+
* locks) so none can drop a coin silently while another logs.
|
|
731
549
|
*/
|
|
732
550
|
type VtxoExclusion = (vtxo: ExcludableVtxo) => string | undefined;
|
|
733
551
|
/**
|
|
734
|
-
* The contract gate as an exclusion,
|
|
735
|
-
*
|
|
736
|
-
*
|
|
737
|
-
* The two want opposite reactions from whoever reads the log. A decline is
|
|
738
|
-
* the gate working as designed — nothing to do. A missing handler means a
|
|
739
|
-
* contract row this build cannot interpret, e.g. a vendoring or version
|
|
740
|
-
* mismatch, which is worth a reader's attention. `contractHandlers` is
|
|
741
|
-
* already available here, so the message can tell them apart instead of
|
|
742
|
-
* collapsing both into one sentence that reads as the same case either way.
|
|
552
|
+
* The contract gate as an exclusion, distinguishing a handler's decline (working as designed)
|
|
553
|
+
* from a missing handler (a row this build can't interpret, e.g. a version mismatch, worth a
|
|
554
|
+
* reader's attention).
|
|
743
555
|
*/
|
|
744
|
-
declare function gateExclusion(gated:
|
|
556
|
+
declare function gateExclusion(gated: GatedContracts): VtxoExclusion;
|
|
745
557
|
/** Outpoints excluded for a shared reason, e.g. an intent-lock set. */
|
|
746
558
|
declare function outpointExclusion(outpoints: ReadonlySet<string>, reason: string): VtxoExclusion;
|
|
747
559
|
/**
|
|
748
|
-
* Outpoints excluded for
|
|
749
|
-
*
|
|
750
|
-
*
|
|
751
|
-
* Unlike {@link gateExclusion}, the reasons are the handlers' own sentences and
|
|
752
|
-
* are not rephrased to follow the outpoint: that text is what tells the reader
|
|
753
|
-
* when to retry, and a paraphrase here would be a second spelling to keep in
|
|
754
|
-
* step with it.
|
|
560
|
+
* Outpoints excluded for per-input reasons (e.g. a per-input timelock). The handlers' own
|
|
561
|
+
* sentences, unparaphrased: they tell the reader when to retry.
|
|
755
562
|
*
|
|
756
563
|
* @see outpointExclusion for the shared-reason form.
|
|
757
564
|
*/
|
|
758
565
|
declare function outpointReasons(reasons: ReadonlyMap<string, string>): VtxoExclusion;
|
|
759
566
|
/**
|
|
760
|
-
* Report VTXOs an exclusion dropped
|
|
761
|
-
*
|
|
762
|
-
* Debug level, one line per VTXO per reason.
|
|
567
|
+
* Report VTXOs an exclusion dropped, the only field-diagnosable signal for a coin missing from a
|
|
568
|
+
* spend. Debug level, one line per VTXO per reason.
|
|
763
569
|
*/
|
|
764
570
|
declare function logExcludedVtxos(source: string, vtxos: readonly ExcludableVtxo[], exclusions: readonly VtxoExclusion[]): void;
|
|
765
571
|
/**
|
|
766
|
-
* Thrown when a spend names VTXOs whose contract can no longer be annotated
|
|
767
|
-
*
|
|
768
|
-
*
|
|
769
|
-
*
|
|
770
|
-
* Raised before submission on purpose. Spending reads the tapscripts stored on
|
|
771
|
-
* each coin rather than re-deriving them, so such a spend would otherwise build
|
|
772
|
-
* and broadcast normally and only fail in the bookkeeping afterwards, leaving
|
|
773
|
-
* the transaction on the network and the local state behind it.
|
|
572
|
+
* Thrown before submission when a spend names VTXOs whose contract can no longer be annotated
|
|
573
|
+
* (handler unregistered, stored params rejected, or no row). Otherwise the spend would broadcast
|
|
574
|
+
* and fail in the bookkeeping, leaving local state behind the network.
|
|
774
575
|
*/
|
|
775
576
|
declare class UnannotatableInputError extends Error {
|
|
776
577
|
readonly name = "UnannotatableInputError";
|
|
777
578
|
}
|
|
778
579
|
|
|
779
580
|
/**
|
|
780
|
-
* Encode a contract to the arkcontract string format
|
|
781
|
-
*
|
|
782
|
-
*
|
|
783
|
-
*
|
|
784
|
-
* This format is compatible with NArk and allows contracts to be
|
|
785
|
-
* shared/imported across different Arkade SDKs.
|
|
581
|
+
* Encode a contract to the arkcontract string format:
|
|
582
|
+
* `arkcontract={type}&{key1}={value1}&...`. NArk-compatible, so contracts can be shared
|
|
583
|
+
* across Arkade SDKs.
|
|
786
584
|
*
|
|
787
585
|
* @example
|
|
788
586
|
* ```typescript
|
|
@@ -798,27 +596,18 @@ declare class UnannotatableInputError extends Error {
|
|
|
798
596
|
*/
|
|
799
597
|
declare function encodeArkContract(contract: Contract): string;
|
|
800
598
|
/**
|
|
801
|
-
*
|
|
802
|
-
*
|
|
803
|
-
* This is a low-level representation. For type-safe contract creation,
|
|
804
|
-
* use `contractFromArkContract` or `contractFromArkContractWithAddress`
|
|
805
|
-
* which validate params through the handler system.
|
|
599
|
+
* Raw (unvalidated) result of decoding an arkcontract string. For typed contracts use
|
|
600
|
+
* `contractFromArkContract` / `contractFromArkContractWithAddress`, which validate via handlers.
|
|
806
601
|
*/
|
|
807
602
|
interface ParsedArkContract {
|
|
808
603
|
/** Contract type (e.g., "vhtlc", "default") */
|
|
809
604
|
type: string;
|
|
810
|
-
/** All key-value pairs from the string */
|
|
605
|
+
/** All other key-value pairs from the string */
|
|
811
606
|
data: Record<string, string>;
|
|
812
607
|
}
|
|
813
608
|
/**
|
|
814
|
-
* Decode an arkcontract string into raw type and data.
|
|
815
|
-
*
|
|
816
|
-
* This is a low-level function that parses the URL-encoded format.
|
|
817
|
-
* For creating typed Contract objects, use `contractFromArkContract`
|
|
818
|
-
* or `contractFromArkContractWithAddress` instead.
|
|
609
|
+
* Decode an arkcontract string into raw type and data (low-level; see {@link ParsedArkContract}).
|
|
819
610
|
*
|
|
820
|
-
* @param encoded - The arkcontract string
|
|
821
|
-
* @returns Parsed type and key-value data
|
|
822
611
|
* @throws If the string is not a valid arkcontract
|
|
823
612
|
*
|
|
824
613
|
* @example
|
|
@@ -829,14 +618,9 @@ interface ParsedArkContract {
|
|
|
829
618
|
*/
|
|
830
619
|
declare function decodeArkContract(encoded: string): ParsedArkContract;
|
|
831
620
|
/**
|
|
832
|
-
* Create a Contract from an arkcontract string.
|
|
621
|
+
* Create a Contract (without script/address) from an arkcontract string.
|
|
833
622
|
*
|
|
834
|
-
*
|
|
835
|
-
*
|
|
836
|
-
* @param encoded - The arkcontract string
|
|
837
|
-
* @param options - Additional options for the contract
|
|
838
|
-
* @returns A Contract object
|
|
839
|
-
* @throws If the string is invalid or no handler exists for the type
|
|
623
|
+
* @throws If the string is invalid or no handler is registered for the type
|
|
840
624
|
*
|
|
841
625
|
* @example
|
|
842
626
|
* ```typescript
|
|
@@ -859,56 +643,26 @@ declare function contractFromArkContract(encoded: string, options?: {
|
|
|
859
643
|
/**
|
|
860
644
|
* Create a full Contract with derived script and address.
|
|
861
645
|
*
|
|
862
|
-
* @param encoded - The arkcontract string
|
|
863
646
|
* @param serverPubKey - Server public key (for address derivation)
|
|
864
647
|
* @param addressPrefix - Address prefix (e.g., "tark" for testnet)
|
|
865
|
-
* @param options - Additional options
|
|
866
|
-
* @returns A complete Contract object
|
|
867
648
|
*/
|
|
868
649
|
declare function contractFromArkContractWithAddress(encoded: string, serverPubKey: Uint8Array, addressPrefix?: string, options?: {
|
|
869
650
|
label?: string;
|
|
870
651
|
state?: "active" | "inactive";
|
|
871
652
|
metadata?: Record<string, unknown>;
|
|
872
653
|
}): Contract;
|
|
873
|
-
/**
|
|
874
|
-
* Check if a string is an arkcontract.
|
|
875
|
-
*/
|
|
654
|
+
/** Check if a string is an arkcontract. */
|
|
876
655
|
declare function isArkContract(str: string): boolean;
|
|
877
656
|
|
|
878
|
-
/**
|
|
879
|
-
* Thrown when a descriptor-capable contract (default, delegate, or boarding)
|
|
880
|
-
* cannot be routed to any signer: its owner key (`params.pubKey`) is not this
|
|
881
|
-
* wallet's baseline signing key, and the record carries no
|
|
882
|
-
* `metadata.signingDescriptor` to send it to a descriptor-aware signer.
|
|
883
|
-
*
|
|
884
|
-
* Note that this can arise also when a contract belongs to a different identity (storage reuse).
|
|
885
|
-
*/
|
|
886
|
-
declare class MissingSigningDescriptorError extends Error {
|
|
887
|
-
readonly contractScript: string;
|
|
888
|
-
readonly contractType: "default" | "delegate" | "boarding";
|
|
889
|
-
readonly name = "MissingSigningDescriptorError";
|
|
890
|
-
constructor(contractScript: string, contractType: "default" | "delegate" | "boarding");
|
|
891
|
-
}
|
|
892
|
-
/**
|
|
893
|
-
* Thrown when an input needs descriptor-aware signing but no
|
|
894
|
-
* DescriptorProvider was wired into the wallet.
|
|
895
|
-
*/
|
|
896
|
-
declare class DescriptorSigningProviderMissingError extends Error {
|
|
897
|
-
readonly name = "DescriptorSigningProviderMissingError";
|
|
898
|
-
constructor();
|
|
899
|
-
}
|
|
900
|
-
|
|
901
657
|
/**
|
|
902
658
|
* In-memory implementation of ContractRepository.
|
|
903
659
|
* Data is ephemeral and scoped to the instance.
|
|
904
660
|
*/
|
|
905
661
|
declare class InMemoryContractRepository implements ContractRepository {
|
|
906
|
-
readonly version:
|
|
907
|
-
private readonly contractData;
|
|
908
|
-
private readonly collections;
|
|
662
|
+
readonly version: 3;
|
|
909
663
|
private readonly contractsByScript;
|
|
910
664
|
clear(): Promise<void>;
|
|
911
|
-
|
|
665
|
+
getContractsPage(filter: ContractFilter | undefined, page: PageRequest): Promise<PageResult<Contract>>;
|
|
912
666
|
saveContract(contract: Contract): Promise<void>;
|
|
913
667
|
deleteContract(script: string): Promise<void>;
|
|
914
668
|
[Symbol.asyncDispose](): Promise<void>;
|
|
@@ -920,145 +674,119 @@ declare class InMemoryContractRepository implements ContractRepository {
|
|
|
920
674
|
* Data is stored as JSON strings in key/value stores.
|
|
921
675
|
*/
|
|
922
676
|
declare class IndexedDBContractRepository implements ContractRepository {
|
|
923
|
-
readonly version:
|
|
677
|
+
readonly version: 3;
|
|
924
678
|
private readonly connection;
|
|
925
679
|
constructor(dbName?: string);
|
|
926
680
|
clear(): Promise<void>;
|
|
927
|
-
|
|
681
|
+
getContractsPage(filter: ContractFilter | undefined, page: PageRequest): Promise<PageResult<Contract>>;
|
|
928
682
|
saveContract(contract: Contract): Promise<void>;
|
|
929
683
|
deleteContract(script: string): Promise<void>;
|
|
684
|
+
/** Up to `limit + 1` rows of `range` that pass `filter`, in key order. */
|
|
685
|
+
private readMatching;
|
|
930
686
|
private applyContractFilter;
|
|
931
687
|
private getDB;
|
|
932
688
|
[Symbol.asyncDispose](): Promise<void>;
|
|
933
689
|
}
|
|
934
690
|
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
declare class IndexedDBWalletRepository implements WalletRepository {
|
|
939
|
-
readonly version: 1;
|
|
940
|
-
private readonly connection;
|
|
941
|
-
constructor(dbName?: string);
|
|
942
|
-
clear(): Promise<void>;
|
|
943
|
-
[Symbol.asyncDispose](): Promise<void>;
|
|
944
|
-
getVtxos(address: string): Promise<ExtendedVirtualCoin[]>;
|
|
945
|
-
saveVtxos(address: string, vtxos: ExtendedVirtualCoin[]): Promise<void>;
|
|
946
|
-
deleteVtxos(address: string): Promise<void>;
|
|
947
|
-
getVtxosForScript(script: string): Promise<ExtendedVirtualCoin[]>;
|
|
948
|
-
saveVtxosForScript(key: VtxoRepositoryKey, vtxos: ExtendedVirtualCoin[]): Promise<void>;
|
|
949
|
-
deleteVtxosForScript(script: string): Promise<void>;
|
|
950
|
-
getUtxos(address: string): Promise<ExtendedCoin[]>;
|
|
951
|
-
saveUtxos(address: string, utxos: ExtendedCoin[]): Promise<void>;
|
|
952
|
-
deleteUtxos(address: string): Promise<void>;
|
|
953
|
-
getTransactionHistory(address: string): Promise<ArkTransaction[]>;
|
|
954
|
-
saveTransactions(address: string, txs: ArkTransaction[]): Promise<void>;
|
|
955
|
-
deleteTransactions(address: string): Promise<void>;
|
|
956
|
-
getWalletState(): Promise<WalletState | null>;
|
|
957
|
-
saveWalletState(state: WalletState): Promise<void>;
|
|
958
|
-
private getDB;
|
|
691
|
+
interface WalletRestoreHook {
|
|
692
|
+
id: string;
|
|
693
|
+
restore(wallet: IWallet): Promise<void>;
|
|
959
694
|
}
|
|
960
|
-
|
|
961
|
-
declare const MIGRATION_KEY: (repoType: "wallet" | "contract") => string;
|
|
962
|
-
type MigrationStatus = "pending" | "in-progress" | "done" | "not-needed";
|
|
963
|
-
declare function getMigrationStatus(repoType: "wallet" | "contract", storageAdapter: StorageAdapter): Promise<MigrationStatus>;
|
|
964
|
-
declare function requiresMigration(repoType: "wallet" | "contract", storageAdapter: StorageAdapter): Promise<boolean>;
|
|
965
|
-
declare function rollbackMigration(repoType: "wallet" | "contract", storageAdapter: StorageAdapter): Promise<void>;
|
|
966
|
-
/**
|
|
967
|
-
* Migrate wallet data from the legacy storage adapter to the new one.
|
|
968
|
-
* It accepts both onchain and offchain addresses, make sure to pass both.
|
|
969
|
-
*
|
|
970
|
-
* @param storageAdapter
|
|
971
|
-
* @param fresh
|
|
972
|
-
* @param addresses
|
|
973
|
-
*/
|
|
974
|
-
declare function migrateWalletRepository(storageAdapter: StorageAdapter, fresh: WalletRepository, addresses: {
|
|
975
|
-
onchain: string[];
|
|
976
|
-
offchain: string[];
|
|
977
|
-
}): Promise<void>;
|
|
695
|
+
declare function registerWalletRestoreHook(wallet: IWallet, hook: WalletRestoreHook): () => void;
|
|
978
696
|
|
|
979
697
|
/**
|
|
980
|
-
*
|
|
698
|
+
* In-memory single key implementation for Bitcoin transaction signing.
|
|
699
|
+
*
|
|
700
|
+
* @example
|
|
701
|
+
* ```typescript
|
|
702
|
+
* // Create from hex string
|
|
703
|
+
* const key = SingleKey.fromHex('your_private_key_hex');
|
|
704
|
+
*
|
|
705
|
+
* // Create from raw bytes
|
|
706
|
+
* const key = SingleKey.fromPrivateKey(privateKeyBytes);
|
|
707
|
+
*
|
|
708
|
+
* // Create random key
|
|
709
|
+
* const randomKey = SingleKey.fromRandomBytes();
|
|
710
|
+
*
|
|
711
|
+
* // Sign a transaction
|
|
712
|
+
* const signedTx = await key.sign(transaction);
|
|
713
|
+
* ```
|
|
981
714
|
*/
|
|
982
|
-
declare class
|
|
983
|
-
|
|
984
|
-
private
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
715
|
+
declare class SingleKey implements Identity {
|
|
716
|
+
private key;
|
|
717
|
+
private constructor();
|
|
718
|
+
/** Create a signing identity from raw private key bytes. */
|
|
719
|
+
static fromPrivateKey(privateKey: Uint8Array): SingleKey;
|
|
720
|
+
/** Create a signing identity from a hex-encoded private key. */
|
|
721
|
+
static fromHex(privateKeyHex: string): SingleKey;
|
|
722
|
+
/** Create a signing identity with a freshly generated random private key. */
|
|
723
|
+
static fromRandomBytes(): SingleKey;
|
|
724
|
+
/**
|
|
725
|
+
* Export the private key as a hex string.
|
|
726
|
+
*
|
|
727
|
+
* @returns The private key as a hex string
|
|
728
|
+
*/
|
|
729
|
+
toHex(): string;
|
|
730
|
+
sign(tx: Transaction, inputIndexes?: number[]): Promise<Transaction>;
|
|
731
|
+
compressedPublicKey(): Promise<Uint8Array>;
|
|
732
|
+
xOnlyPublicKey(): Promise<Uint8Array>;
|
|
733
|
+
signerSession(): SignerSession;
|
|
734
|
+
signMessage(message: Uint8Array, signatureType?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
|
|
735
|
+
/**
|
|
736
|
+
* BIP-340 sign `messageHash` with aux_rand = 0, so the signature — and
|
|
737
|
+
* anything derived from it — is reproducible from the key alone.
|
|
738
|
+
*
|
|
739
|
+
* What lets a static wallet derive a swap preimage instead of storing one
|
|
740
|
+
* (see `wallet/contractSecrets.ts`). Deliberately NOT `signMessage`, whose
|
|
741
|
+
* schnorr branch draws a random aux_rand: a preimage derived from that is
|
|
742
|
+
* unrecoverable, and the loss would only surface at claim time.
|
|
743
|
+
*/
|
|
744
|
+
signSchnorrDeterministic(messageHash: Uint8Array): Promise<Uint8Array>;
|
|
745
|
+
toReadonly(): Promise<ReadonlySingleKey>;
|
|
1002
746
|
}
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
[Symbol.asyncDispose](): Promise<void>;
|
|
747
|
+
declare class ReadonlySingleKey implements ReadonlyIdentity {
|
|
748
|
+
private readonly publicKey;
|
|
749
|
+
/** Create a readonly identity from a compressed public key. */
|
|
750
|
+
constructor(publicKey: Uint8Array);
|
|
751
|
+
/**
|
|
752
|
+
* Create a ReadonlySingleKey from a compressed public key.
|
|
753
|
+
*
|
|
754
|
+
* @param publicKey - 33-byte compressed public key (02/03 prefix + 32-byte x coordinate)
|
|
755
|
+
* @returns A new ReadonlySingleKey instance
|
|
756
|
+
* @example
|
|
757
|
+
* ```typescript
|
|
758
|
+
* const pubkey = new Uint8Array(33); // your compressed public key
|
|
759
|
+
* const readonlyKey = ReadonlySingleKey.fromPublicKey(pubkey);
|
|
760
|
+
* ```
|
|
761
|
+
*/
|
|
762
|
+
static fromPublicKey(publicKey: Uint8Array): ReadonlySingleKey;
|
|
763
|
+
xOnlyPublicKey(): Promise<Uint8Array>;
|
|
764
|
+
compressedPublicKey(): Promise<Uint8Array>;
|
|
1022
765
|
}
|
|
1023
766
|
|
|
1024
767
|
/**
|
|
1025
|
-
* Domain separator for the preimage derivation.
|
|
1026
|
-
*
|
|
1027
|
-
*
|
|
1028
|
-
*
|
|
1029
|
-
* scheme reproduces the same preimage and can recover an artifact another
|
|
1030
|
-
* SDK created. Deliberately distinct from the Boltz tag: a shared tag would
|
|
1031
|
-
* make one wallet key derive one preimage for both corridors.
|
|
768
|
+
* Domain separator for the preimage derivation. Protocol-scoped and versioned, mirroring NArk's
|
|
769
|
+
* `Arkade-Boltz-Preimage-v1` (`SwapsManagementService.cs:128`), so any Arkade SDK reproduces the
|
|
770
|
+
* same preimage and can recover another SDK's artifact. Deliberately distinct from the Boltz tag:
|
|
771
|
+
* a shared tag would make one wallet key derive one preimage for both corridors.
|
|
1032
772
|
*/
|
|
1033
773
|
declare const ARKADE_SWAP_PREIMAGE_TAG = "Arkade-RFQ-Preimage-v1";
|
|
1034
774
|
/**
|
|
1035
|
-
* Domain separator for the **salted**
|
|
1036
|
-
*
|
|
1037
|
-
*
|
|
1038
|
-
*
|
|
1039
|
-
* asymmetry is deliberate. The v1 tags must be per-corridor
|
|
1040
|
-
* (`Arkade-RFQ-Preimage-v1` here, NArk's `Arkade-Boltz-Preimage-v1` there)
|
|
1041
|
-
* because v1 pins its message index, so the tag is the only thing separating
|
|
1042
|
-
* two corridors that reach the same key. v2 mints a salt per artifact, so no
|
|
1043
|
-
* two artifacts share a message within a corridor, let alone across two — the
|
|
1044
|
-
* salt carries the separation, and the tag names the layer it belongs to.
|
|
775
|
+
* Domain separator for the **salted** derivation, used when the descriptor repeats across
|
|
776
|
+
* artifacts. Corridor-generic, unlike {@link ARKADE_SWAP_PREIMAGE_TAG}, deliberately: v1 pins its
|
|
777
|
+
* message index, so its tag is all that separates two corridors reaching the same key; here the
|
|
778
|
+
* per-artifact salt carries that separation.
|
|
1045
779
|
*/
|
|
1046
780
|
declare const ARKADE_SALTED_PREIMAGE_TAG = "Arkade-Contract-Preimage-Salted-v1";
|
|
1047
781
|
/**
|
|
1048
|
-
* `TAG ‖ xonly(32) ‖ u32le(index)` — the message that gets BIP-340 signed.
|
|
1049
|
-
*
|
|
1050
|
-
*
|
|
1051
|
-
* restore reconstructs a bare descriptor that serialises differently from the
|
|
1052
|
-
* signing descriptor used at creation, and only the key agrees across both.
|
|
782
|
+
* `TAG ‖ xonly(32) ‖ u32le(index)` — the message that gets BIP-340 signed. Anchored on the x-only
|
|
783
|
+
* key, not the descriptor string: a restore rebuilds a descriptor that serialises differently from
|
|
784
|
+
* the one used at creation, and only the key agrees across both.
|
|
1053
785
|
*/
|
|
1054
786
|
declare function buildPreimageMessage(xonly: Uint8Array, index: number): Uint8Array;
|
|
1055
787
|
/**
|
|
1056
|
-
* `TAG ‖ xonly(32) ‖ salt(32)` — the salted message that gets BIP-340 signed.
|
|
1057
|
-
*
|
|
1058
|
-
* The salt replaces v1's pinned index as the source of per-artifact
|
|
1059
|
-
* uniqueness, which is what lets a key that repeats across artifacts still
|
|
1060
|
-
* derive a distinct preimage for each. It is public: knowing it yields nothing
|
|
1061
|
-
* without the seed.
|
|
788
|
+
* `TAG ‖ xonly(32) ‖ salt(32)` — the salted message that gets BIP-340 signed. The salt replaces
|
|
789
|
+
* v1's pinned index as the per-artifact uniqueness source; it is public, useless without the seed.
|
|
1062
790
|
*/
|
|
1063
791
|
declare function buildSaltedPreimageMessage(xonly: Uint8Array, salt: Uint8Array): Uint8Array;
|
|
1064
792
|
/**
|
|
@@ -1077,18 +805,14 @@ interface ProvisionedKey {
|
|
|
1077
805
|
*/
|
|
1078
806
|
descriptor: string;
|
|
1079
807
|
/**
|
|
1080
|
-
* The
|
|
1081
|
-
*
|
|
1082
|
-
* callers building the lockup script do not need a separate
|
|
1083
|
-
* {@link IWallet.getAddress} round-trip or an `ArkAddress.decode` call.
|
|
808
|
+
* The pkScript of the wallet's current receive address, so callers building the lockup need
|
|
809
|
+
* no separate {@link IWallet.getAddress} or `ArkAddress.decode`.
|
|
1084
810
|
*/
|
|
1085
811
|
pkScript: Uint8Array;
|
|
1086
812
|
/**
|
|
1087
|
-
* The receive address {@link pkScript} was decoded from,
|
|
1088
|
-
*
|
|
1089
|
-
*
|
|
1090
|
-
* script, and two independent reads of a wallet that rotates its receive
|
|
1091
|
-
* address would not guarantee that — reuse this, never a second
|
|
813
|
+
* The receive address {@link pkScript} was decoded from, in the same {@link IWallet.getAddress}
|
|
814
|
+
* read. The quote-time refund address and the covenant's `refundPkScript` must name the same
|
|
815
|
+
* script, and two reads of a rotating wallet need not agree — reuse this, never a second
|
|
1092
816
|
* `getAddress()` call.
|
|
1093
817
|
*/
|
|
1094
818
|
address: string;
|
|
@@ -1103,93 +827,61 @@ interface ProvisionedClaimSecret extends Omit<ProvisionedKey, "pkScript" | "addr
|
|
|
1103
827
|
/** `sha256(preimage)` — what the contract commits to. */
|
|
1104
828
|
paymentHash: Uint8Array;
|
|
1105
829
|
/**
|
|
1106
|
-
* The salt {@link preimage} was derived from,
|
|
1107
|
-
*
|
|
1108
|
-
*
|
|
1109
|
-
* still cannot re-derive P.
|
|
1110
|
-
*
|
|
1111
|
-
* Absent on the other two arms: an HD child descriptor already names one
|
|
1112
|
-
* artifact, and a stored preimage needs no derivation input.
|
|
830
|
+
* The salt {@link preimage} was derived from, on the salted arm. **Public**, unlike
|
|
831
|
+
* {@link preimage}: persist it in the clear with the artifact — without it even the seed
|
|
832
|
+
* cannot re-derive P. Absent on the other arms.
|
|
1113
833
|
*/
|
|
1114
834
|
preimageSalt?: Uint8Array;
|
|
1115
835
|
/**
|
|
1116
|
-
* Persist `preimage` with the artifact: this wallet cannot re-derive it
|
|
1117
|
-
*
|
|
1118
|
-
*
|
|
1119
|
-
* given {@link preimageSalt}, where there is one — and nothing secret
|
|
1120
|
-
* needs to be stored.
|
|
836
|
+
* Persist `preimage` with the artifact: this wallet cannot re-derive it (caller-supplied P,
|
|
837
|
+
* or a signer that cannot sign deterministically). When false, P re-derives from the seed
|
|
838
|
+
* (given {@link preimageSalt}, if any) and nothing secret needs storing.
|
|
1121
839
|
*/
|
|
1122
840
|
mustPersistPreimage: boolean;
|
|
1123
841
|
}
|
|
1124
842
|
/**
|
|
1125
|
-
* The key that spends a leg we fund —
|
|
1126
|
-
* of a covenant's cancel path.
|
|
843
|
+
* The key that spends a leg we fund — an HTLC's refund key, a covenant's cancel-path user key.
|
|
1127
844
|
*
|
|
1128
|
-
*
|
|
1129
|
-
*
|
|
1130
|
-
*
|
|
1131
|
-
*
|
|
1132
|
-
* allocated by a worker rebound to another identity, a record restored onto
|
|
1133
|
-
* the wrong seed — and the covenant would bind it, the leg would fund, and
|
|
1134
|
-
* the failure would surface at refund time with the money already committed.
|
|
1135
|
-
* Throws {@link ForeignDescriptorError} instead, before there is a quote.
|
|
845
|
+
* `pubkey` comes from a signer the wallet produced, never the descriptor string alone: parsing
|
|
846
|
+
* succeeds just as well for a key this wallet cannot sign for (a worker rebound to another
|
|
847
|
+
* identity, a record restored onto the wrong seed), and the failure would surface at refund time
|
|
848
|
+
* with the money committed. Throws {@link ForeignDescriptorError} instead, before any quote.
|
|
1136
849
|
*
|
|
1137
|
-
*
|
|
1138
|
-
*
|
|
1139
|
-
* refund path is on the same key as the refund address the caller sends to
|
|
1140
|
-
* at quote time.
|
|
850
|
+
* Reuses the identity key rather than a fresh HD child, so no index is consumed for an artifact
|
|
851
|
+
* never built, and the refund path is on the same key as the quote-time refund address.
|
|
1141
852
|
*/
|
|
1142
853
|
declare function provisionRefundKey(wallet: IWallet): Promise<ProvisionedKey>;
|
|
1143
854
|
/**
|
|
1144
|
-
* The key that spends a leg we claim, plus the preimage that unlocks it.
|
|
855
|
+
* The key that spends a leg we claim, plus the preimage that unlocks it. Three arms:
|
|
1145
856
|
*
|
|
1146
|
-
*
|
|
1147
|
-
*
|
|
1148
|
-
*
|
|
1149
|
-
*
|
|
1150
|
-
*
|
|
1151
|
-
*
|
|
1152
|
-
*
|
|
1153
|
-
*
|
|
1154
|
-
* the pinned index. Nothing at rest. Raises rather than falling through if
|
|
1155
|
-
* the signer cannot sign deterministically — an HD descriptor whose wallet
|
|
1156
|
-
* refuses is a broken wallet, not a fallback case.
|
|
1157
|
-
* 3. **Anything else** — a static wallet's `tr(pubkey)`, or a constant
|
|
1158
|
-
* descriptor from a custom provider. Mints a public per-artifact salt and
|
|
1159
|
-
* derives from it, so a key that repeats still yields a distinct P. Only
|
|
1160
|
-
* this arm falls back to a stored random preimage, and only when the signer
|
|
1161
|
-
* refuses — which is discovered by deriving, never by probing.
|
|
857
|
+
* 1. **Caller-supplied `opts.preimage`** (32 bytes). Returned verbatim with
|
|
858
|
+
* `mustPersistPreimage: true`, since the wallet cannot re-derive what it did not choose.
|
|
859
|
+
* 2. **Per-artifact descriptor** (an HD child). Derives from the key alone at the pinned index;
|
|
860
|
+
* nothing at rest. Raises if the signer cannot sign deterministically — that is a broken HD
|
|
861
|
+
* wallet, not a fallback case.
|
|
862
|
+
* 3. **Anything else** (a static `tr(pubkey)`, a custom provider's constant descriptor). Mints a
|
|
863
|
+
* public per-artifact salt and derives from it. Only this arm falls back to a stored random
|
|
864
|
+
* preimage, and only when the signer refuses — discovered by deriving, never by probing.
|
|
1162
865
|
*/
|
|
1163
866
|
declare function provisionClaimSecret(wallet: IWallet, opts?: {
|
|
1164
867
|
preimage?: Uint8Array;
|
|
1165
868
|
}): Promise<ProvisionedClaimSecret>;
|
|
1166
869
|
/**
|
|
1167
|
-
* The signer for a provisioned descriptor, verified
|
|
1168
|
-
* descriptor's key
|
|
1169
|
-
*
|
|
1170
|
-
* The verification is a public-key equality, never a wallet-type probe: a
|
|
1171
|
-
* wallet that answers with the wrong key — another seed's, after a restore
|
|
1172
|
-
* mix-up — would sign happily, and the failure would surface only as a
|
|
1173
|
-
* counterparty rejection or a dead script.
|
|
870
|
+
* The signer for a provisioned descriptor, verified by public-key equality (never a wallet-type
|
|
871
|
+
* probe) to be that descriptor's key: a wallet answering with another seed's key would sign
|
|
872
|
+
* happily and fail only as a counterparty rejection or a dead script.
|
|
1174
873
|
*
|
|
1175
|
-
*
|
|
1176
|
-
*
|
|
1177
|
-
*
|
|
1178
|
-
*
|
|
1179
|
-
* comparison becomes a tautology. What rules that case out is
|
|
1180
|
-
* {@link resolveDescriptorSigner}'s `isOurs` test, which both shipped wallets
|
|
1181
|
-
* resolve through — so this is the backstop for a hand-rolled `IWallet`, not
|
|
1182
|
-
* the primary guarantee.
|
|
874
|
+
* Limit: this catches a wallet substituting its *baseline* identity. A descriptor-scoped identity
|
|
875
|
+
* over the same descriptor reads its pubkey back from the string, making the check a tautology;
|
|
876
|
+
* {@link resolveDescriptorSigner}'s `isOurs` test (used by both shipped wallets) rules that out,
|
|
877
|
+
* so this is the backstop for a hand-rolled `IWallet`, not the primary guarantee.
|
|
1183
878
|
*/
|
|
1184
879
|
declare function contractSigner(wallet: IWallet, descriptor: string): Promise<Identity>;
|
|
1185
880
|
/**
|
|
1186
|
-
* A wallet that holds a contract's key but cannot sign with it
|
|
1187
|
-
*
|
|
1188
|
-
*
|
|
1189
|
-
*
|
|
1190
|
-
* that one says "wrong wallet", this one says "this wallet, without its
|
|
1191
|
-
* signer". Raised at provisioning as well as at signing, so a wallet that
|
|
1192
|
-
* could never spend the leg finds out before it funds one.
|
|
881
|
+
* A wallet that holds a contract's key but cannot sign with it (watch-only, or a remote signer
|
|
882
|
+
* without its transport). Distinct from {@link ForeignDescriptorError} ("wrong wallet") because
|
|
883
|
+
* the remedy differs. Raised at provisioning too, so a wallet that could never spend a leg finds
|
|
884
|
+
* out before funding it.
|
|
1193
885
|
*/
|
|
1194
886
|
declare class WalletCannotSignError extends Error {
|
|
1195
887
|
readonly descriptor: string;
|
|
@@ -1197,18 +889,12 @@ declare class WalletCannotSignError extends Error {
|
|
|
1197
889
|
constructor(descriptor: string);
|
|
1198
890
|
}
|
|
1199
891
|
/**
|
|
1200
|
-
* The preimage for a provisioned descriptor
|
|
1201
|
-
* kept one, otherwise re-derived from the seed.
|
|
1202
|
-
*
|
|
1203
|
-
* Resolves in one precedence order, mirroring the arms
|
|
1204
|
-
* {@link provisionClaimSecret} chose between:
|
|
892
|
+
* The preimage for a provisioned descriptor, in the precedence {@link provisionClaimSecret} chose:
|
|
1205
893
|
*
|
|
1206
|
-
* 1. `opts.stored` — a caller-supplied P, or one
|
|
1207
|
-
* derive. Whatever the wallet can do now, a stored P is the artifact's.
|
|
894
|
+
* 1. `opts.stored` — a caller-supplied P, or one a wallet could not derive; always the artifact's.
|
|
1208
895
|
* 2. a per-artifact descriptor — derive at the pinned index.
|
|
1209
896
|
* 3. `opts.salt` — derive from the salted message.
|
|
1210
|
-
* 4. otherwise throw: a repeating descriptor with neither
|
|
1211
|
-
* nor a salt has nothing to derive from that would not collide.
|
|
897
|
+
* 4. otherwise throw: a repeating descriptor with neither has nothing collision-free to derive.
|
|
1212
898
|
*/
|
|
1213
899
|
declare function contractPreimage(wallet: IWallet, descriptor: string, opts?: {
|
|
1214
900
|
stored?: Uint8Array;
|
|
@@ -1219,33 +905,47 @@ declare function contractPreimage(wallet: IWallet, descriptor: string, opts?: {
|
|
|
1219
905
|
* rather than degrading to a random-aux signer. */
|
|
1220
906
|
interface DeterministicSigner extends ReadonlyIdentity {
|
|
1221
907
|
/**
|
|
1222
|
-
* Implementors wrapping a remote: throw only for a refusal that will
|
|
1223
|
-
*
|
|
1224
|
-
*
|
|
1225
|
-
* back to a stored random preimage for the artifact's whole life. That is
|
|
1226
|
-
* claimable, but it persists a secret the seed would otherwise have
|
|
1227
|
-
* replaced, and nothing surfaces the downgrade to the caller.
|
|
908
|
+
* Implementors wrapping a remote: throw only for a refusal that will repeat.
|
|
909
|
+
* {@link provisionClaimSecret} reads any throw (even a network hiccup) as "cannot derive" and
|
|
910
|
+
* silently falls back to a stored random preimage for the artifact's whole life.
|
|
1228
911
|
*/
|
|
1229
912
|
signSchnorrDeterministic(messageHash: Uint8Array): Promise<Uint8Array>;
|
|
1230
913
|
}
|
|
1231
914
|
declare function isDeterministicSigner(value: unknown): value is DeterministicSigner;
|
|
1232
915
|
/**
|
|
1233
|
-
* Claim a restored artifact's index so a later allocation cannot reissue it
|
|
1234
|
-
*
|
|
1235
|
-
* one.
|
|
1236
|
-
*
|
|
1237
|
-
* Monotonic, and a no-op wherever there is no index to reserve — a shared-key
|
|
1238
|
-
* descriptor, or another seed's artifact. Restores iterate whole histories, so
|
|
1239
|
-
* an artifact this wallet has nothing to adopt for must not abort the loop.
|
|
916
|
+
* Claim a restored artifact's index so a later allocation cannot reissue it (which would derive
|
|
917
|
+
* that artifact's preimage again, for a different one).
|
|
1240
918
|
*
|
|
1241
|
-
*
|
|
1242
|
-
*
|
|
1243
|
-
*
|
|
1244
|
-
*
|
|
1245
|
-
* skip. Every wallet shipped here implements both.
|
|
919
|
+
* Monotonic, and a no-op wherever there is no index to reserve (a shared-key descriptor, another
|
|
920
|
+
* seed's artifact), since restores iterate whole histories. Recognising "another seed's" needs
|
|
921
|
+
* {@link HDWalletCapable.signerForDescriptor}; without it a foreign artifact surfaces as the
|
|
922
|
+
* watermark call's untyped error. Every shipped wallet implements both.
|
|
1246
923
|
*/
|
|
1247
924
|
declare function adoptContractDescriptor(wallet: IWallet, descriptor: string): Promise<void>;
|
|
1248
925
|
|
|
926
|
+
/**
|
|
927
|
+
* Thrown when a descriptor-capable contract (default, delegate, or boarding)
|
|
928
|
+
* cannot be routed to any signer: its owner key (`params.pubKey`) is not this
|
|
929
|
+
* wallet's baseline signing key, and the record carries no
|
|
930
|
+
* `metadata.signingDescriptor` to send it to a descriptor-aware signer.
|
|
931
|
+
*
|
|
932
|
+
* Note that this can arise also when a contract belongs to a different identity (storage reuse).
|
|
933
|
+
*/
|
|
934
|
+
declare class MissingSigningDescriptorError extends Error {
|
|
935
|
+
readonly contractScript: string;
|
|
936
|
+
readonly contractType: "default" | "delegate" | "boarding";
|
|
937
|
+
readonly name = "MissingSigningDescriptorError";
|
|
938
|
+
constructor(contractScript: string, contractType: "default" | "delegate" | "boarding");
|
|
939
|
+
}
|
|
940
|
+
/**
|
|
941
|
+
* Thrown when an input needs descriptor-aware signing but no
|
|
942
|
+
* DescriptorProvider was wired into the wallet.
|
|
943
|
+
*/
|
|
944
|
+
declare class DescriptorSigningProviderMissingError extends Error {
|
|
945
|
+
readonly name = "DescriptorSigningProviderMissingError";
|
|
946
|
+
constructor();
|
|
947
|
+
}
|
|
948
|
+
|
|
1249
949
|
type RequestEnvelope = {
|
|
1250
950
|
tag: string;
|
|
1251
951
|
id: string;
|
|
@@ -1267,6 +967,11 @@ type ResponseEnvelope = {
|
|
|
1267
967
|
errorName?: string;
|
|
1268
968
|
broadcast?: boolean;
|
|
1269
969
|
};
|
|
970
|
+
type MessageBusServices = {
|
|
971
|
+
arkProvider: ArkProvider;
|
|
972
|
+
wallet?: Wallet;
|
|
973
|
+
readonlyWallet: ReadonlyWallet;
|
|
974
|
+
};
|
|
1270
975
|
interface MessageHandler<REQ extends RequestEnvelope = RequestEnvelope, RES extends ResponseEnvelope = ResponseEnvelope> {
|
|
1271
976
|
/**
|
|
1272
977
|
* A unique identifier for the updater.
|
|
@@ -1283,11 +988,7 @@ interface MessageHandler<REQ extends RequestEnvelope = RequestEnvelope, RES exte
|
|
|
1283
988
|
* bus re-init or `stop()` it goes inert on its own, so retaining one past
|
|
1284
989
|
* `stop()` cannot post.
|
|
1285
990
|
**/
|
|
1286
|
-
start(services: {
|
|
1287
|
-
arkProvider: ArkProvider;
|
|
1288
|
-
wallet?: Wallet;
|
|
1289
|
-
readonlyWallet: ReadonlyWallet;
|
|
1290
|
-
}, repositories: {
|
|
991
|
+
start(services: MessageBusServices, repositories: {
|
|
1291
992
|
walletRepository: WalletRepository;
|
|
1292
993
|
}, channel?: {
|
|
1293
994
|
broadcast(response: RES): void;
|
|
@@ -1333,32 +1034,26 @@ type Options = {
|
|
|
1333
1034
|
* `storage.intentRepository`. Same opt-in as a main-thread wallet: without
|
|
1334
1035
|
* it the worker persists no settlement intent, reconciles none on restart,
|
|
1335
1036
|
* and counts intent-locked VTXOs as available. Pass the same repository the
|
|
1336
|
-
* main thread uses so both sides read one intent state
|
|
1037
|
+
* main thread uses so both sides read one intent state, but settle from one
|
|
1038
|
+
* side only: reconciliation deletes from the server any pending intent the
|
|
1039
|
+
* worker's wallet is not settling itself.
|
|
1337
1040
|
*
|
|
1338
1041
|
* Ignored when `buildServices` is supplied — that override owns `storage`.
|
|
1339
1042
|
*/
|
|
1340
1043
|
intentRepository?: IntentRepository;
|
|
1341
1044
|
debug?: boolean;
|
|
1342
|
-
buildServices?: (config: Initialize["config"]) => Promise<
|
|
1343
|
-
arkProvider: ArkProvider;
|
|
1344
|
-
wallet?: Wallet;
|
|
1345
|
-
readonlyWallet: ReadonlyWallet;
|
|
1346
|
-
}>;
|
|
1045
|
+
buildServices?: (config: Initialize["config"]) => Promise<MessageBusServices>;
|
|
1347
1046
|
};
|
|
1348
1047
|
type Initialize = {
|
|
1349
1048
|
type: "INITIALIZE_MESSAGE_BUS";
|
|
1350
1049
|
id: string;
|
|
1351
1050
|
config: {
|
|
1352
|
-
wallet: SerializedIdentity
|
|
1051
|
+
wallet: SerializedIdentity;
|
|
1353
1052
|
arkServer: {
|
|
1354
1053
|
url: string;
|
|
1355
1054
|
publicKey?: string;
|
|
1356
1055
|
};
|
|
1357
1056
|
delegateUrl?: string;
|
|
1358
|
-
/** @deprecated alias for @see Initialize.config.delegateUrl */
|
|
1359
|
-
delegatorUrl?: string;
|
|
1360
|
-
indexerUrl?: string;
|
|
1361
|
-
esploraUrl?: string;
|
|
1362
1057
|
settlementConfig?: SettlementConfig | false;
|
|
1363
1058
|
walletMode?: "auto" | "static" | "hd";
|
|
1364
1059
|
watcherConfig?: Partial<Omit<ContractWatcherConfig, "indexerProvider">>;
|
|
@@ -1504,51 +1199,22 @@ declare class MessageBus {
|
|
|
1504
1199
|
static setup(path: string): Promise<ServiceWorker>;
|
|
1505
1200
|
}
|
|
1506
1201
|
|
|
1507
|
-
/**
|
|
1508
|
-
* A leaf node in the Taproot script tree, as consumed by
|
|
1509
|
-
* `@scure/btc-signer`'s `p2tr(internalKey, tree, ...)`.
|
|
1510
|
-
*/
|
|
1202
|
+
/** A leaf node in the Taproot script tree, as consumed by `@scure/btc-signer`'s `p2tr`. */
|
|
1511
1203
|
interface TaprootLeaf {
|
|
1512
1204
|
script: Bytes;
|
|
1513
1205
|
leafVersion: number;
|
|
1514
1206
|
}
|
|
1515
|
-
/**
|
|
1516
|
-
* Internal tree node shape consumed by `@scure/btc-signer`'s `p2tr`:
|
|
1517
|
-
* - A leaf is `{ script, leafVersion }`
|
|
1518
|
-
* - A branch is a 2-element tuple `[leftNode, rightNode]` of nodes
|
|
1519
|
-
*/
|
|
1207
|
+
/** A `p2tr` tree node: a leaf, or a `[left, right]` branch tuple. */
|
|
1520
1208
|
type TaprootTreeNode = TaprootLeaf | [TaprootTreeNode, TaprootTreeNode];
|
|
1521
1209
|
/**
|
|
1522
|
-
* Assemble a Taproot script tree
|
|
1523
|
-
*
|
|
1524
|
-
* (`txscript.AssembleTaprootScriptTree`, see
|
|
1525
|
-
* https://github.com/btcsuite/btcd/blob/master/txscript/taproot.go).
|
|
1526
|
-
*
|
|
1527
|
-
* The algorithm:
|
|
1528
|
-
*
|
|
1529
|
-
* Phase 1 — pair leaves left-to-right:
|
|
1530
|
-
* for i := 0; i < len(leaves); i += 2:
|
|
1531
|
-
* if i is the last index (odd leaf at end):
|
|
1532
|
-
* merge with the LAST branch built so far (do NOT pair as a fresh leaf)
|
|
1533
|
-
* else:
|
|
1534
|
-
* create a new branch from (leaves[i], leaves[i+1])
|
|
1210
|
+
* Assemble a Taproot script tree with btcd's `txscript.AssembleTaprootScriptTree` algorithm
|
|
1211
|
+
* (the one arkd uses).
|
|
1535
1212
|
*
|
|
1536
|
-
*
|
|
1537
|
-
*
|
|
1538
|
-
*
|
|
1213
|
+
* `@scure/btc-signer`'s `taprootListToTree` builds a Huffman tree instead; the two agree only for
|
|
1214
|
+
* power-of-2 leaf counts. Any other count yields a different merkle root → different output key
|
|
1215
|
+
* → arkd rejects spends with `INVALID_PSBT_INPUT`.
|
|
1539
1216
|
*
|
|
1540
|
-
*
|
|
1541
|
-
* Huffman tree (weight-1 leaves combine by smallest-weight pairs). For
|
|
1542
|
-
* power-of-2 leaf counts both algorithms happen to produce the same
|
|
1543
|
-
* perfectly-balanced binary tree and agree. For any other count they
|
|
1544
|
-
* produce DIFFERENT shapes → different merkle roots → different taproot
|
|
1545
|
-
* output keys → arkd rejects spends with `INVALID_PSBT_INPUT`.
|
|
1546
|
-
*
|
|
1547
|
-
* Reproducing btcd's algorithm here lets the SDK construct taptrees that
|
|
1548
|
-
* arkd accepts for arbitrary leaf counts.
|
|
1549
|
-
*
|
|
1550
|
-
* @param scripts - Raw tapscript bytes for each leaf, in the order they
|
|
1551
|
-
* should be encoded in the TapTree PSBT field.
|
|
1217
|
+
* @param scripts - Raw tapscript bytes per leaf, in TapTree PSBT field order.
|
|
1552
1218
|
* @returns The nested-tuple form `p2tr` accepts.
|
|
1553
1219
|
*/
|
|
1554
1220
|
declare function assembleBtcdTaprootTree(scripts: Bytes[]): TaprootTreeNode;
|
|
@@ -1609,11 +1275,10 @@ declare class AssetId {
|
|
|
1609
1275
|
readonly groupIndex: number;
|
|
1610
1276
|
private constructor();
|
|
1611
1277
|
/**
|
|
1612
|
-
* Create
|
|
1278
|
+
* Create a validated asset id from a genesis transaction id and group index.
|
|
1613
1279
|
*
|
|
1614
1280
|
* @param txid - Hex-encoded genesis transaction id
|
|
1615
1281
|
* @param groupIndex - Asset group index within the genesis transaction
|
|
1616
|
-
* @returns A validated asset id
|
|
1617
1282
|
* @throws Error if the txid is missing, malformed, or not 32 bytes long
|
|
1618
1283
|
* @see fromString
|
|
1619
1284
|
*/
|
|
@@ -1621,8 +1286,6 @@ declare class AssetId {
|
|
|
1621
1286
|
/**
|
|
1622
1287
|
* Decode an asset id from its hex string representation.
|
|
1623
1288
|
*
|
|
1624
|
-
* @param s - Hex-encoded asset id
|
|
1625
|
-
* @returns Decoded asset id
|
|
1626
1289
|
* @throws Error if the string is not valid hex or does not encode a valid asset id
|
|
1627
1290
|
* @see toString
|
|
1628
1291
|
*/
|
|
@@ -1630,22 +1293,18 @@ declare class AssetId {
|
|
|
1630
1293
|
/**
|
|
1631
1294
|
* Decode an asset id from its serialized bytes.
|
|
1632
1295
|
*
|
|
1633
|
-
* @param buf - Serialized asset id bytes
|
|
1634
|
-
* @returns Decoded asset id
|
|
1635
1296
|
* @throws Error if the buffer length is invalid
|
|
1636
1297
|
*/
|
|
1637
1298
|
static fromBytes(buf: Uint8Array): AssetId;
|
|
1638
1299
|
/**
|
|
1639
1300
|
* Serialize the asset id to raw bytes.
|
|
1640
1301
|
*
|
|
1641
|
-
* @returns Serialized asset id bytes
|
|
1642
1302
|
* @see fromBytes
|
|
1643
1303
|
*/
|
|
1644
1304
|
serialize(): Uint8Array;
|
|
1645
1305
|
/**
|
|
1646
1306
|
* Encode the asset id to a hex string.
|
|
1647
1307
|
*
|
|
1648
|
-
* @returns Hex-encoded asset id
|
|
1649
1308
|
* @see fromString
|
|
1650
1309
|
*/
|
|
1651
1310
|
toString(): string;
|
|
@@ -1656,17 +1315,14 @@ declare class AssetId {
|
|
|
1656
1315
|
*/
|
|
1657
1316
|
validate(): void;
|
|
1658
1317
|
/**
|
|
1659
|
-
* Decode an asset id from a binary reader.
|
|
1318
|
+
* Decode an asset id from a binary reader positioned at one.
|
|
1660
1319
|
*
|
|
1661
|
-
* @param reader - Reader positioned at an asset id
|
|
1662
|
-
* @returns Decoded asset id
|
|
1663
1320
|
* @throws Error if the reader does not contain enough bytes
|
|
1664
1321
|
*/
|
|
1665
1322
|
static fromReader(reader: BufferReader): AssetId;
|
|
1666
1323
|
/**
|
|
1667
1324
|
* Serialize the asset id into an existing binary writer.
|
|
1668
1325
|
*
|
|
1669
|
-
* @param writer - Writer to append the asset id to
|
|
1670
1326
|
* @see serialize
|
|
1671
1327
|
*/
|
|
1672
1328
|
serializeTo(writer: BufferWriter): void;
|
|
@@ -1696,27 +1352,18 @@ declare class AssetRef {
|
|
|
1696
1352
|
private constructor();
|
|
1697
1353
|
/** Reference type discriminator. */
|
|
1698
1354
|
get type(): AssetRefType;
|
|
1699
|
-
/**
|
|
1700
|
-
* Create an asset reference that points to a specific asset id.
|
|
1701
|
-
*
|
|
1702
|
-
* @param assetId - Asset id referenced by this pointer
|
|
1703
|
-
* @returns Asset reference by id
|
|
1704
|
-
* @see fromGroupIndex
|
|
1705
|
-
*/
|
|
1355
|
+
/** Reference a specific asset id. @see fromGroupIndex */
|
|
1706
1356
|
static fromId(assetId: AssetId): AssetRef;
|
|
1707
1357
|
/**
|
|
1708
|
-
*
|
|
1358
|
+
* Reference another asset group in the packet.
|
|
1709
1359
|
*
|
|
1710
1360
|
* @param groupIndex - Zero-based asset group index in the packet
|
|
1711
|
-
* @returns Asset reference by group index
|
|
1712
1361
|
* @see fromId
|
|
1713
1362
|
*/
|
|
1714
1363
|
static fromGroupIndex(groupIndex: number): AssetRef;
|
|
1715
1364
|
/**
|
|
1716
|
-
* Decode an asset reference from
|
|
1365
|
+
* Decode an asset reference from hex.
|
|
1717
1366
|
*
|
|
1718
|
-
* @param s - Hex-encoded asset reference
|
|
1719
|
-
* @returns Decoded asset reference
|
|
1720
1367
|
* @throws Error if the string is not valid hex or does not encode a valid asset reference
|
|
1721
1368
|
* @see toString
|
|
1722
1369
|
*/
|
|
@@ -1724,39 +1371,20 @@ declare class AssetRef {
|
|
|
1724
1371
|
/**
|
|
1725
1372
|
* Decode an asset reference from its serialized bytes.
|
|
1726
1373
|
*
|
|
1727
|
-
* @param buf - Serialized asset reference bytes
|
|
1728
|
-
* @returns Decoded asset reference
|
|
1729
1374
|
* @throws Error if the buffer is empty or malformed
|
|
1730
1375
|
*/
|
|
1731
1376
|
static fromBytes(buf: Uint8Array): AssetRef;
|
|
1732
|
-
/**
|
|
1733
|
-
* Serialize the asset reference to raw bytes.
|
|
1734
|
-
*
|
|
1735
|
-
* @returns Serialized asset reference bytes
|
|
1736
|
-
* @see fromBytes
|
|
1737
|
-
*/
|
|
1377
|
+
/** Serialize to raw bytes. @see fromBytes */
|
|
1738
1378
|
serialize(): Uint8Array;
|
|
1739
|
-
/**
|
|
1740
|
-
* Encode the asset reference to a hex string.
|
|
1741
|
-
*
|
|
1742
|
-
* @returns Hex-encoded asset reference
|
|
1743
|
-
* @see fromString
|
|
1744
|
-
*/
|
|
1379
|
+
/** Encode to hex. @see fromString */
|
|
1745
1380
|
toString(): string;
|
|
1746
1381
|
/**
|
|
1747
|
-
* Decode an asset reference from a
|
|
1382
|
+
* Decode an asset reference from a reader positioned at one.
|
|
1748
1383
|
*
|
|
1749
|
-
* @param reader - Reader positioned at an asset reference
|
|
1750
|
-
* @returns Decoded asset reference
|
|
1751
1384
|
* @throws Error if the type is unknown or the reader does not contain enough bytes
|
|
1752
1385
|
*/
|
|
1753
1386
|
static fromReader(reader: BufferReader): AssetRef;
|
|
1754
|
-
/**
|
|
1755
|
-
* Serialize the asset reference into an existing binary writer.
|
|
1756
|
-
*
|
|
1757
|
-
* @param writer - Writer to append the asset reference to
|
|
1758
|
-
* @see serialize
|
|
1759
|
-
*/
|
|
1387
|
+
/** Append the serialized reference to `writer`. @see serialize */
|
|
1760
1388
|
serializeTo(writer: BufferWriter): void;
|
|
1761
1389
|
}
|
|
1762
1390
|
|
|
@@ -2110,15 +1738,9 @@ declare class Packet implements ExtensionPacket {
|
|
|
2110
1738
|
* Shipped from `src/` rather than `test/` so consumers outside this package can
|
|
2111
1739
|
* pin the same bytes: `lightning-swap-service` imports this value, while NArk
|
|
2112
1740
|
* and go-sdk vendor the backing `assetIdVectors.json` from a pinned revision of
|
|
2113
|
-
* this repository.
|
|
2114
|
-
*
|
|
2115
|
-
*
|
|
2116
|
-
* disagreement between them fails silently — a flipped txid makes a covenant
|
|
2117
|
-
* unsatisfiable, a flipped group index resolves to a different asset, a case
|
|
2118
|
-
* mismatch is a routing miss. None of those name their cause, which is what
|
|
2119
|
-
* these vectors are for.
|
|
2120
|
-
*
|
|
2121
|
-
* @see plans/asset-id-shared-vectors.md
|
|
1741
|
+
* this repository. The encoding is implemented in seven places across three
|
|
1742
|
+
* repos, and every disagreement fails silently (a flipped txid makes a covenant
|
|
1743
|
+
* unsatisfiable, a flipped group index resolves to a different asset).
|
|
2122
1744
|
*/
|
|
2123
1745
|
interface AssetIdVectors {
|
|
2124
1746
|
readonly version: number;
|
|
@@ -2168,9 +1790,8 @@ interface AssetIdVectors {
|
|
|
2168
1790
|
* The asset-id test vectors, deeply frozen.
|
|
2169
1791
|
*
|
|
2170
1792
|
* @remarks
|
|
2171
|
-
* Frozen all the way down
|
|
2172
|
-
*
|
|
2173
|
-
* mutating an entry would corrupt it for every other consumer in the process.
|
|
1793
|
+
* Frozen all the way down: the module is a singleton, and one consumer mutating
|
|
1794
|
+
* a nested entry would corrupt it for every other consumer in the process.
|
|
2174
1795
|
*
|
|
2175
1796
|
* @example
|
|
2176
1797
|
* ```typescript
|
|
@@ -2240,6 +1861,13 @@ declare class DustChangeError extends Error {
|
|
|
2240
1861
|
readonly dustAmount: bigint;
|
|
2241
1862
|
constructor(change: bigint, dustAmount: bigint);
|
|
2242
1863
|
}
|
|
1864
|
+
/** Thrown when a collaborative exit's change VTXO is above the server's
|
|
1865
|
+
* per-output ceiling, which arkd answers with `AMOUNT_TOO_HIGH`. */
|
|
1866
|
+
declare class OversizedChangeError extends Error {
|
|
1867
|
+
readonly change: bigint;
|
|
1868
|
+
readonly maxAmount: bigint;
|
|
1869
|
+
constructor(change: bigint, maxAmount: bigint);
|
|
1870
|
+
}
|
|
2243
1871
|
/**
|
|
2244
1872
|
* Ramps is a class wrapping `settle` method to provide a more convenient interface for onboarding and offboarding operations.
|
|
2245
1873
|
*
|
|
@@ -2289,6 +1917,10 @@ declare class Ramps {
|
|
|
2289
1917
|
* @param feeInfo - The fee info to deduct from the offboard amount.
|
|
2290
1918
|
* @param amount - The amount to offboard. If not provided, the total amount of virtual outputs will be offboarded.
|
|
2291
1919
|
* @param eventCallback - Optional callback that receives settlement events
|
|
1920
|
+
* @param vtxos - Specific virtual outputs to spend, mirroring {@link onboard}'s
|
|
1921
|
+
* `boardingUtxos`. Omitted, every spendable one is spent — merging the whole
|
|
1922
|
+
* off-chain balance into a single change output. Taken as given like
|
|
1923
|
+
* `settle({ inputs })`: an `amount` these cannot cover is an error, not a top-up.
|
|
2292
1924
|
* @returns The Arkade transaction id created by settlement
|
|
2293
1925
|
* @throws Error if no virtual outputs remain after fee deduction or the destination address cannot be decoded
|
|
2294
1926
|
* @see IWallet.getSpendableVtxos
|
|
@@ -2300,26 +1932,35 @@ declare class Ramps {
|
|
|
2300
1932
|
* await ramps.offboard('bc1q...', feeInfo);
|
|
2301
1933
|
* ```
|
|
2302
1934
|
*/
|
|
2303
|
-
offboard(destinationAddress: string, feeInfo: FeeInfo, amount?: bigint, eventCallback?: (event: SettlementEvent) => void): ReturnType<IWallet["settle"]>;
|
|
1935
|
+
offboard(destinationAddress: string, feeInfo: FeeInfo, amount?: bigint, eventCallback?: (event: SettlementEvent) => void, vtxos?: NormalizedExtendedVirtualCoin[]): ReturnType<IWallet["settle"]>;
|
|
1936
|
+
/**
|
|
1937
|
+
* Collaboratively exit with the DESTINATION paid exactly `amount`, pricing the
|
|
1938
|
+
* fee on that output rather than on a grossed-up figure. {@link offboard} keeps
|
|
1939
|
+
* the other anchor, which needs `g - fee(g) = amount` solved — impossible for
|
|
1940
|
+
* a program charging the whole output.
|
|
1941
|
+
*/
|
|
1942
|
+
offboardExact(params: {
|
|
1943
|
+
destinationAddress: string;
|
|
1944
|
+
feeInfo: FeeInfo;
|
|
1945
|
+
/** Sats the destination receives, exactly. */
|
|
1946
|
+
amount: bigint;
|
|
1947
|
+
eventCallback?: (event: SettlementEvent) => void;
|
|
1948
|
+
vtxos?: NormalizedExtendedVirtualCoin[];
|
|
1949
|
+
}): ReturnType<IWallet["settle"]>;
|
|
1950
|
+
private offboardInputs;
|
|
1951
|
+
/** Fund the change output: pay its own fee, then judge it against both
|
|
1952
|
+
* server-side bounds. `0n` in is `0n` out — no change output at all. */
|
|
1953
|
+
private fundChange;
|
|
2304
1954
|
}
|
|
2305
1955
|
|
|
2306
1956
|
/**
|
|
2307
|
-
* HD-wallet {@link DescriptorProvider} that allocates a fresh signing
|
|
2308
|
-
*
|
|
2309
|
-
*
|
|
2310
|
-
* wallet currently bound to?" is answered by querying the contract
|
|
2311
|
-
* repository for active contracts, not by asking this provider.
|
|
1957
|
+
* HD-wallet {@link DescriptorProvider} that allocates a fresh signing descriptor on every call.
|
|
1958
|
+
* A pure rotating allocator: which descriptor the wallet is bound to is answered by the contract
|
|
1959
|
+
* repository, not this provider.
|
|
2312
1960
|
*
|
|
2313
|
-
* State
|
|
2314
|
-
*
|
|
2315
|
-
*
|
|
2316
|
-
* which carries the wildcard account descriptor template (for derivation)
|
|
2317
|
-
* and the signing primitives.
|
|
2318
|
-
*
|
|
2319
|
-
* The read-modify-write of the persisted index runs inside the shared per-
|
|
2320
|
-
* repo `updateWalletState` mutex, so two `getNextSigningDescriptor` callers
|
|
2321
|
-
* — including those driving separate `HDDescriptorProvider` instances on
|
|
2322
|
-
* the same repo — can never observe the same index.
|
|
1961
|
+
* State lives in `settings.hd` of the wallet state, so switching single-key → HD needs no schema
|
|
1962
|
+
* migration. Allocation runs inside the shared per-repo `updateWalletState` mutex, so callers
|
|
1963
|
+
* (even on separate instances over one repo) never observe the same index.
|
|
2323
1964
|
*
|
|
2324
1965
|
* @example
|
|
2325
1966
|
* ```ts
|
|
@@ -2335,104 +1976,50 @@ declare class HDDescriptorProvider implements DescriptorProvider, ReceiveRotator
|
|
|
2335
1976
|
private readonly walletRepository;
|
|
2336
1977
|
private constructor();
|
|
2337
1978
|
/**
|
|
2338
|
-
* Construct an HDDescriptorProvider. No I/O is
|
|
2339
|
-
*
|
|
2340
|
-
* `getNextSigningDescriptor`. A descriptor-mismatch error surfaces on
|
|
2341
|
-
* first use rather than at boot.
|
|
1979
|
+
* Construct an HDDescriptorProvider. No I/O: state is read lazily, so a descriptor-mismatch
|
|
1980
|
+
* error surfaces on first use rather than here.
|
|
2342
1981
|
*/
|
|
2343
1982
|
static create(identity: HDCapableIdentity, walletRepository: WalletRepository): Promise<HDDescriptorProvider>;
|
|
2344
|
-
/**
|
|
2345
|
-
* Allocate the next descriptor and return it. The first call on a fresh
|
|
2346
|
-
* wallet returns descriptor at index 0; subsequent calls return 1, 2, 3,
|
|
2347
|
-
* ... in order. Each call is atomic with respect to other rotations on
|
|
2348
|
-
* the same repo: two concurrent callers can never observe the same
|
|
2349
|
-
* index.
|
|
2350
|
-
*/
|
|
1983
|
+
/** Allocate and return the next descriptor (index 0, 1, 2, …), atomically per repo. */
|
|
2351
1984
|
getNextSigningDescriptor(): Promise<string>;
|
|
2352
1985
|
/**
|
|
2353
|
-
* Re-derive the descriptor
|
|
2354
|
-
*
|
|
2355
|
-
*
|
|
2356
|
-
* when no descriptor has ever been allocated on this repo.
|
|
2357
|
-
*
|
|
2358
|
-
* Used by the boot path to keep the wallet's display address
|
|
2359
|
-
* stable across restarts: when no tagged display contract exists
|
|
2360
|
-
* (e.g. a fresh wallet that hasn't rotated yet, or a wallet whose
|
|
2361
|
-
* baseline-only repo carries no rotation history), the boot should
|
|
2362
|
-
* re-derive the existing index rather than burn a new one.
|
|
1986
|
+
* Re-derive the descriptor `getNextSigningDescriptor` last returned, WITHOUT advancing;
|
|
1987
|
+
* `undefined` if none was ever allocated. Lets boot keep the display address stable across
|
|
1988
|
+
* restarts when no tagged display contract exists, instead of burning a new index.
|
|
2363
1989
|
*/
|
|
2364
1990
|
getCurrentSigningDescriptor(): Promise<string | undefined>;
|
|
2365
|
-
/**
|
|
2366
|
-
* The most recently allocated index, or `undefined` when nothing has ever
|
|
2367
|
-
* been allocated on this repo. Read-only peek at the watermark that
|
|
2368
|
-
* {@link getNextSigningDescriptor} advances.
|
|
2369
|
-
*/
|
|
1991
|
+
/** Read-only peek at the allocation watermark; `undefined` if nothing was ever allocated. */
|
|
2370
1992
|
getLastIndexUsed(): Promise<number | undefined>;
|
|
2371
1993
|
/**
|
|
2372
|
-
* Monotonically advance the
|
|
2373
|
-
* `
|
|
2374
|
-
*
|
|
2375
|
-
*
|
|
2376
|
-
* An invalid `index` (non-integer / negative / past the BIP32
|
|
2377
|
-
* non-hardened ceiling) is ignored (no-op): persisting it would corrupt
|
|
2378
|
-
* `lastIndexUsed` and make the next `parseSettings()` throw, mirroring
|
|
2379
|
-
* the validation parseSettings already enforces. The upper bound matters
|
|
2380
|
-
* because the damage outlives the call — `materializeDescriptorAt` cannot
|
|
2381
|
-
* derive at or above 2^31, so a watermark parked there would fail every
|
|
2382
|
-
* subsequent allocation for the life of the repo.
|
|
1994
|
+
* Monotonically advance the watermark past indices found by a restore scan; never rewinds.
|
|
1995
|
+
* An invalid `index` (non-integer, negative, or >= 2^31) is ignored: persisting it would make
|
|
1996
|
+
* `parseSettings()` throw, and a watermark at the hardened ceiling would fail every later
|
|
1997
|
+
* allocation for the life of the repo.
|
|
2383
1998
|
*/
|
|
2384
1999
|
advanceLastIndexUsed(index: number): Promise<void>;
|
|
2385
|
-
/**
|
|
2386
|
-
* Returns true when the given descriptor is derivable from this wallet's
|
|
2387
|
-
* seed. Delegates to the underlying identity, which handles both HD and
|
|
2388
|
-
* simple `tr(pubkey)` descriptors.
|
|
2389
|
-
*/
|
|
2000
|
+
/** Whether `descriptor` (HD or simple `tr(pubkey)`) is derivable from this wallet's seed. */
|
|
2390
2001
|
isOurs(descriptor: string): boolean;
|
|
2391
|
-
/**
|
|
2392
|
-
* Signs each request with the key derived from its descriptor. Delegates
|
|
2393
|
-
* to the identity's signing primitives — the identity, not the provider,
|
|
2394
|
-
* holds the seed.
|
|
2395
|
-
*/
|
|
2002
|
+
/** Signs each request with its descriptor's derived key (the identity holds the seed). */
|
|
2396
2003
|
signWithDescriptor(requests: DescriptorSigningRequest[]): Promise<Transaction[]>;
|
|
2397
2004
|
/** Signs a message using the key derived from `descriptor`. */
|
|
2398
2005
|
signMessageWithDescriptor(descriptor: string, message: Uint8Array, signatureType?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
|
|
2399
|
-
/**
|
|
2400
|
-
* HD providers participate in receive rotation. The default
|
|
2401
|
-
* factory boot (contract-repo lookup → allocate fresh descriptor)
|
|
2402
|
-
* is exactly what we want, so this just delegates to
|
|
2403
|
-
* {@link WalletReceiveRotator.defaultBoot}.
|
|
2404
|
-
*/
|
|
2006
|
+
/** HD providers take part in receive rotation via {@link WalletReceiveRotator.defaultBoot}. */
|
|
2405
2007
|
createReceiveRotator(opts: ReceiveRotatorBootOpts): Promise<ReceiveRotatorBoot | undefined>;
|
|
2406
2008
|
/**
|
|
2407
|
-
*
|
|
2408
|
-
*
|
|
2409
|
-
*
|
|
2410
|
-
* call validates that the input is a ranged template AND produces a
|
|
2411
|
-
* canonical materialized key expression at the given index.
|
|
2412
|
-
*
|
|
2413
|
-
* This is a pure read: it does NOT advance the allocation watermark.
|
|
2414
|
-
* Used by restore's gap-scan to peek descriptors at arbitrary indices
|
|
2415
|
-
* without side-effects.
|
|
2009
|
+
* Materialize the account template at `index` via the descriptors-scure parser (validates the
|
|
2010
|
+
* ranged template and yields a canonical key expression) rather than string substitution.
|
|
2011
|
+
* Pure: does NOT advance the watermark, so restore's gap-scan can peek arbitrary indices.
|
|
2416
2012
|
*/
|
|
2417
2013
|
materializeDescriptorAt(index: number): string;
|
|
2418
2014
|
/**
|
|
2419
|
-
*
|
|
2420
|
-
*
|
|
2421
|
-
*
|
|
2422
|
-
* surface; the mutated settings are then persisted as part of the same
|
|
2423
|
-
* atomic update.
|
|
2424
|
-
*
|
|
2425
|
-
* Doing the read inside the lock is what prevents two providers (or two
|
|
2426
|
-
* concurrent callers on the same provider) from racing on a stale index.
|
|
2015
|
+
* Read-modify-write HD settings inside the shared per-repo wallet-state mutex; `fn` mutates a
|
|
2016
|
+
* validated snapshot that is persisted atomically. Reading inside the lock prevents races on a
|
|
2017
|
+
* stale index.
|
|
2427
2018
|
*/
|
|
2428
2019
|
private mutate;
|
|
2429
2020
|
/**
|
|
2430
|
-
* Validate
|
|
2431
|
-
*
|
|
2432
|
-
*
|
|
2433
|
-
* The cast to `HDWalletSettings` trusts storage; a corrupted or
|
|
2434
|
-
* partially-migrated repo could otherwise produce `NaN` descriptors.
|
|
2435
|
-
* Fail loud rather than silently derive garbage.
|
|
2021
|
+
* Validate persisted HD settings (or init a fresh record) and return a mutable clone. Fails
|
|
2022
|
+
* loud: a corrupt repo would otherwise derive `NaN` descriptors.
|
|
2436
2023
|
*/
|
|
2437
2024
|
private parseSettings;
|
|
2438
2025
|
}
|
|
@@ -2446,25 +2033,9 @@ declare class ReadonlyWalletError extends Error {
|
|
|
2446
2033
|
declare class DelegateNotConfiguredError extends Error {
|
|
2447
2034
|
constructor();
|
|
2448
2035
|
}
|
|
2449
|
-
/** @deprecated alias for DelegateNotConfiguredError */
|
|
2450
|
-
declare const DelegatorNotConfiguredError: typeof DelegateNotConfiguredError;
|
|
2451
|
-
type DelegatorNotConfiguredError = DelegateNotConfiguredError;
|
|
2452
2036
|
type RequestInitWallet = RequestEnvelope & {
|
|
2453
2037
|
type: "INIT_WALLET";
|
|
2454
2038
|
payload: {
|
|
2455
|
-
/**
|
|
2456
|
-
* Legacy per-request key material. Ignored by the current handler —
|
|
2457
|
-
* identity hydration happens during INITIALIZE_MESSAGE_BUS. Retained
|
|
2458
|
-
* for wire compatibility with older workers that may still read it.
|
|
2459
|
-
* Slated for removal in the next major.
|
|
2460
|
-
*
|
|
2461
|
-
* @deprecated Identity is now carried by INITIALIZE_MESSAGE_BUS.
|
|
2462
|
-
*/
|
|
2463
|
-
key?: {
|
|
2464
|
-
privateKey: string;
|
|
2465
|
-
} | {
|
|
2466
|
-
publicKey: string;
|
|
2467
|
-
} | {};
|
|
2468
2039
|
arkServerUrl: string;
|
|
2469
2040
|
arkServerPublicKey?: string;
|
|
2470
2041
|
};
|
|
@@ -2484,16 +2055,6 @@ type ResponseSettle = ResponseEnvelope & {
|
|
|
2484
2055
|
txid: string;
|
|
2485
2056
|
};
|
|
2486
2057
|
};
|
|
2487
|
-
type RequestSendBitcoin = RequestEnvelope & {
|
|
2488
|
-
type: "SEND_BITCOIN";
|
|
2489
|
-
payload: SendBitcoinParams;
|
|
2490
|
-
};
|
|
2491
|
-
type ResponseSendBitcoin = ResponseEnvelope & {
|
|
2492
|
-
type: "SEND_BITCOIN_SUCCESS";
|
|
2493
|
-
payload: {
|
|
2494
|
-
txid: string;
|
|
2495
|
-
};
|
|
2496
|
-
};
|
|
2497
2058
|
type RequestGetAddress = RequestEnvelope & {
|
|
2498
2059
|
type: "GET_ADDRESS";
|
|
2499
2060
|
};
|
|
@@ -2586,13 +2147,14 @@ type ResponseGetVtxos = ResponseEnvelope & {
|
|
|
2586
2147
|
type RequestGetSpendableVtxos = RequestEnvelope & {
|
|
2587
2148
|
type: "GET_SPENDABLE_VTXOS";
|
|
2588
2149
|
payload: {
|
|
2589
|
-
filter?:
|
|
2150
|
+
filter?: GetSpendableVtxosFilter;
|
|
2590
2151
|
};
|
|
2591
2152
|
};
|
|
2592
2153
|
type ResponseGetSpendableVtxos = ResponseEnvelope & {
|
|
2593
2154
|
type: "SPENDABLE_VTXOS";
|
|
2594
2155
|
payload: {
|
|
2595
2156
|
vtxos: Awaited<ReturnType<IWallet["getSpendableVtxos"]>>;
|
|
2157
|
+
filterApplied?: boolean;
|
|
2596
2158
|
};
|
|
2597
2159
|
};
|
|
2598
2160
|
type RequestGetBoardingUtxos = RequestEnvelope & {
|
|
@@ -2690,12 +2252,53 @@ type RequestGetContractsWithVtxos = RequestEnvelope & {
|
|
|
2690
2252
|
type: "GET_CONTRACTS_WITH_VTXOS";
|
|
2691
2253
|
payload: {
|
|
2692
2254
|
filter?: GetContractsFilter;
|
|
2255
|
+
options?: {
|
|
2256
|
+
maxSyncAgeMs?: number;
|
|
2257
|
+
unspentOnly?: boolean;
|
|
2258
|
+
requireSynced?: boolean;
|
|
2259
|
+
};
|
|
2693
2260
|
};
|
|
2694
2261
|
};
|
|
2695
2262
|
type ResponseGetContractsWithVtxos = ResponseEnvelope & {
|
|
2696
2263
|
type: "CONTRACTS_WITH_VTXOS";
|
|
2697
2264
|
payload: {
|
|
2698
2265
|
contracts: ContractWithVtxos[];
|
|
2266
|
+
filterApplied?: boolean;
|
|
2267
|
+
};
|
|
2268
|
+
};
|
|
2269
|
+
type RequestWatchScript = RequestEnvelope & {
|
|
2270
|
+
type: "WATCH_SCRIPT";
|
|
2271
|
+
payload: {
|
|
2272
|
+
script: string | string[];
|
|
2273
|
+
label?: string;
|
|
2274
|
+
};
|
|
2275
|
+
};
|
|
2276
|
+
type ResponseWatchScript = ResponseEnvelope & {
|
|
2277
|
+
type: "SCRIPT_WATCHED";
|
|
2278
|
+
payload: {
|
|
2279
|
+
script: string | string[];
|
|
2280
|
+
};
|
|
2281
|
+
};
|
|
2282
|
+
type RequestUnwatchScript = RequestEnvelope & {
|
|
2283
|
+
type: "UNWATCH_SCRIPT";
|
|
2284
|
+
payload: {
|
|
2285
|
+
script: string | string[];
|
|
2286
|
+
};
|
|
2287
|
+
};
|
|
2288
|
+
type ResponseUnwatchScript = ResponseEnvelope & {
|
|
2289
|
+
type: "SCRIPT_UNWATCHED";
|
|
2290
|
+
payload: {
|
|
2291
|
+
script: string | string[];
|
|
2292
|
+
};
|
|
2293
|
+
};
|
|
2294
|
+
type RequestGetWatchedScripts = RequestEnvelope & {
|
|
2295
|
+
type: "GET_WATCHED_SCRIPTS";
|
|
2296
|
+
payload: Record<string, never>;
|
|
2297
|
+
};
|
|
2298
|
+
type ResponseGetWatchedScripts = ResponseEnvelope & {
|
|
2299
|
+
type: "WATCHED_SCRIPTS";
|
|
2300
|
+
payload: {
|
|
2301
|
+
scripts: WatchedScript[];
|
|
2699
2302
|
};
|
|
2700
2303
|
};
|
|
2701
2304
|
type RequestAnnotateVtxos = RequestEnvelope & {
|
|
@@ -2715,6 +2318,11 @@ type RequestUpdateContract = RequestEnvelope & {
|
|
|
2715
2318
|
payload: {
|
|
2716
2319
|
script: string;
|
|
2717
2320
|
updates: Partial<Omit<Contract, "id" | "createdAt">>;
|
|
2321
|
+
/**
|
|
2322
|
+
* Set only by the proxy's `setContractWatchState`, so the worker keeps its
|
|
2323
|
+
* unchanged-state no-op. A worker predating the flag ignores it and writes.
|
|
2324
|
+
*/
|
|
2325
|
+
watchStateOnly?: boolean;
|
|
2718
2326
|
};
|
|
2719
2327
|
};
|
|
2720
2328
|
type ResponseUpdateContract = ResponseEnvelope & {
|
|
@@ -2723,6 +2331,10 @@ type ResponseUpdateContract = ResponseEnvelope & {
|
|
|
2723
2331
|
contract: Contract;
|
|
2724
2332
|
};
|
|
2725
2333
|
};
|
|
2334
|
+
/** Answers a `watchStateOnly` update; carries no row, so nothing is re-read. */
|
|
2335
|
+
type ResponseContractWatchStateSet = ResponseEnvelope & {
|
|
2336
|
+
type: "CONTRACT_WATCH_STATE_SET";
|
|
2337
|
+
};
|
|
2726
2338
|
type RequestDeleteContract = RequestEnvelope & {
|
|
2727
2339
|
type: "DELETE_CONTRACT";
|
|
2728
2340
|
payload: {
|
|
@@ -2886,6 +2498,8 @@ type RequestSend = RequestEnvelope & {
|
|
|
2886
2498
|
recipients: [Recipient, ...Recipient[]];
|
|
2887
2499
|
/** @see SendParams.selectedVtxos */
|
|
2888
2500
|
selectedVtxos?: ExtendedVirtualCoin[];
|
|
2501
|
+
/** @see SendParams.maxChangeFee */
|
|
2502
|
+
maxChangeFee?: number;
|
|
2889
2503
|
};
|
|
2890
2504
|
};
|
|
2891
2505
|
type ResponseSend = ResponseEnvelope & {
|
|
@@ -3104,8 +2718,8 @@ type RequestRestoreWallet = RequestEnvelope & {
|
|
|
3104
2718
|
type ResponseRestoreWallet = ResponseEnvelope & {
|
|
3105
2719
|
type: "RESTORE_WALLET_SUCCESS";
|
|
3106
2720
|
};
|
|
3107
|
-
type WalletUpdaterRequest = RequestInitWallet | RequestSettle |
|
|
3108
|
-
type WalletUpdaterResponse = ResponseEnvelope & (ResponseInitWallet | ResponseSettle | ResponseSettleEvent |
|
|
2721
|
+
type WalletUpdaterRequest = RequestInitWallet | RequestSettle | RequestGetAddress | RequestGetBoardingAddress | RequestGetArkadeInfo | RequestIndexerGetVtxos | RequestIndexerGetVirtualTxs | RequestSubmitTx | RequestFinalizeTx | RequestGetBalance | RequestGetVtxos | RequestGetSpendableVtxos | RequestGetBoardingUtxos | RequestGetTransactionHistory | RequestGetStatus | RequestGetContractSyncState | RequestClear | RequestReloadWallet | RequestSignTransaction | RequestCreateContract | RequestGetContracts | RequestGetContractsWithVtxos | RequestWatchScript | RequestUnwatchScript | RequestGetWatchedScripts | RequestAnnotateVtxos | RequestUpdateContract | RequestDeleteContract | RequestGetSpendablePaths | RequestGetAllSpendingPaths | RequestIsContractManagerWatching | RequestRefreshVtxos | RequestRefreshOutpoints | RequestGetCurrentSigningDescriptor | RequestGetNextSigningDescriptor | RequestGetNewAddresses | RequestGetUsedSigningDescriptors | RequestAdvanceSigningDescriptorWatermark | RequestSend | RequestGetAssetDetails | RequestIssue | RequestReissue | RequestBurn | RequestDelegate | RequestGetDelegateInfo | RequestRecoverVtxos | RequestGetRecoverableBalance | RequestGetExpiringVtxos | RequestRenewVtxos | RequestGetExpiredBoardingUtxos | RequestSweepExpiredBoardingUtxos | RequestMigrateDeprecatedSignerVtxos | RequestGetDeprecatedSignerStatus | RequestRestoreWallet;
|
|
2722
|
+
type WalletUpdaterResponse = ResponseEnvelope & (ResponseInitWallet | ResponseSettle | ResponseSettleEvent | ResponseGetAddress | ResponseGetBoardingAddress | ResponseGetArkadeInfo | ResponseIndexerGetVtxos | ResponseIndexerGetVirtualTxs | ResponseSubmitTx | ResponseFinalizeTx | ResponseGetBalance | ResponseGetVtxos | ResponseGetSpendableVtxos | ResponseGetBoardingUtxos | ResponseGetTransactionHistory | ResponseGetStatus | ResponseGetContractSyncState | ResponseClear | ResponseReloadWallet | ResponseUtxoUpdate | ResponseVtxoUpdate | ResponseSignTransaction | ResponseCreateContract | ResponseGetContracts | ResponseGetContractsWithVtxos | ResponseWatchScript | ResponseUnwatchScript | ResponseGetWatchedScripts | ResponseAnnotateVtxos | ResponseUpdateContract | ResponseContractWatchStateSet | ResponseDeleteContract | ResponseGetSpendablePaths | ResponseGetAllSpendingPaths | ResponseIsContractManagerWatching | ResponseRefreshVtxos | ResponseRefreshOutpoints | ResponseGetCurrentSigningDescriptor | ResponseGetNextSigningDescriptor | ResponseGetNewAddresses | ResponseGetUsedSigningDescriptors | ResponseAdvanceSigningDescriptorWatermark | ResponseContractEvent | ResponseSend | ResponseGetAssetDetails | ResponseIssue | ResponseReissue | ResponseBurn | ResponseDelegate | ResponseGetDelegateInfo | ResponseRecoverVtxos | ResponseRecoverVtxosEvent | ResponseGetRecoverableBalance | ResponseGetExpiringVtxos | ResponseRenewVtxos | ResponseRenewVtxosEvent | ResponseGetExpiredBoardingUtxos | ResponseSweepExpiredBoardingUtxos | ResponseMigrateDeprecatedSignerVtxos | ResponseMigrateDeprecatedSignerVtxosEvent | ResponseGetDeprecatedSignerStatus | ResponseRestoreWallet);
|
|
3109
2723
|
declare class WalletMessageHandler implements MessageHandler<WalletUpdaterRequest, WalletUpdaterResponse> {
|
|
3110
2724
|
readonly messageTag: string;
|
|
3111
2725
|
private wallet;
|
|
@@ -3169,7 +2783,6 @@ declare class WalletMessageHandler implements MessageHandler<WalletUpdaterReques
|
|
|
3169
2783
|
*/
|
|
3170
2784
|
private reloadWallet;
|
|
3171
2785
|
private handleSettle;
|
|
3172
|
-
private handleSendBitcoin;
|
|
3173
2786
|
private handleSignTransaction;
|
|
3174
2787
|
private handleDelegate;
|
|
3175
2788
|
/**
|
|
@@ -3181,6 +2794,14 @@ declare class WalletMessageHandler implements MessageHandler<WalletUpdaterReques
|
|
|
3181
2794
|
/**
|
|
3182
2795
|
* Read all virtual outputs from the repository, aggregated across all contract
|
|
3183
2796
|
* addresses and the wallet's primary address, with deduplication.
|
|
2797
|
+
*
|
|
2798
|
+
* Recovery-only contracts (imported by `claimCash` for server-swept
|
|
2799
|
+
* arkcash) are excluded by default, mirroring {@link ReadonlyWallet.getVtxos}:
|
|
2800
|
+
* they are settled in their own isolated intent and must stay out of the
|
|
2801
|
+
* wallet's balance / VTXO / coin-selection / pending-tx views that read this.
|
|
2802
|
+
* The transaction-history caller opts back in via `includeRecoveryOnly` to
|
|
2803
|
+
* match the non-worker `getTransactionHistory`, which reads contracts
|
|
2804
|
+
* directly and does include them.
|
|
3184
2805
|
*/
|
|
3185
2806
|
private getVtxosFromRepo;
|
|
3186
2807
|
/**
|
|
@@ -3195,11 +2816,21 @@ declare class WalletMessageHandler implements MessageHandler<WalletUpdaterReques
|
|
|
3195
2816
|
* VTXOs with no matching row in the gate, and `gatedContracts` lists only
|
|
3196
2817
|
* what it knows is closed — so the coins of a just-registered escrowed
|
|
3197
2818
|
* contract would count as available until the next poll.
|
|
2819
|
+
*
|
|
2820
|
+
* Recovery-only contracts are skipped unless `includeRecoveryOnly` (see
|
|
2821
|
+
* {@link getVtxosFromRepo}).
|
|
3198
2822
|
*/
|
|
3199
2823
|
private repoSnapshot;
|
|
3200
2824
|
/**
|
|
3201
2825
|
* Build transaction history from cached virtual outputs, hitting the indexer only for
|
|
3202
2826
|
* uncached timestamps. Best-effort, like the plain Wallet path.
|
|
2827
|
+
*
|
|
2828
|
+
* Takes its own {@link repoSnapshot} rather than a caller-supplied VTXO
|
|
2829
|
+
* list: the coins and the gate that judges them have to come off one read
|
|
2830
|
+
* or they answer about different instants, and being the worker's only
|
|
2831
|
+
* history builder means neither caller can supply one without the other.
|
|
2832
|
+
* The snapshot and the boarding read are independent, so they run together
|
|
2833
|
+
* — the same pairing `handleGetBalance` makes.
|
|
3203
2834
|
*/
|
|
3204
2835
|
private buildTransactionHistoryFromCache;
|
|
3205
2836
|
private ensureContractEventBroadcasting;
|
|
@@ -3222,7 +2853,7 @@ declare const DEFAULT_MESSAGE_TIMEOUTS: Readonly<Record<RequestType, number>>;
|
|
|
3222
2853
|
* // SIMPLE: Recommended approach
|
|
3223
2854
|
* const wallet = await ServiceWorkerWallet.setup({
|
|
3224
2855
|
* serviceWorkerPath: '/service-worker.js',
|
|
3225
|
-
*
|
|
2856
|
+
* arkServer: { url: 'https://arkade.computer' },
|
|
3226
2857
|
* identity: MnemonicIdentity.fromMnemonic('abandon abandon...')
|
|
3227
2858
|
* });
|
|
3228
2859
|
*
|
|
@@ -3230,7 +2861,7 @@ declare const DEFAULT_MESSAGE_TIMEOUTS: Readonly<Record<RequestType, number>>;
|
|
|
3230
2861
|
* const serviceWorker = await setupServiceWorker("/service-worker.js");
|
|
3231
2862
|
* const wallet = await ServiceWorkerWallet.create({
|
|
3232
2863
|
* serviceWorker,
|
|
3233
|
-
*
|
|
2864
|
+
* arkServer: { url: 'https://arkade.computer' },
|
|
3234
2865
|
* identity: MnemonicIdentity.fromMnemonic('abandon abandon...')
|
|
3235
2866
|
* });
|
|
3236
2867
|
*
|
|
@@ -3240,27 +2871,11 @@ declare const DEFAULT_MESSAGE_TIMEOUTS: Readonly<Record<RequestType, number>>;
|
|
|
3240
2871
|
* ```
|
|
3241
2872
|
*/
|
|
3242
2873
|
interface ServiceWorkerWalletOptions {
|
|
3243
|
-
/**
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
* @deprecated Provide an explicit provider via the worker config instead.
|
|
3249
|
-
* URL-based configuration will be removed in a future major version.
|
|
3250
|
-
*/
|
|
3251
|
-
arkServerUrl?: string;
|
|
3252
|
-
/**
|
|
3253
|
-
* Optional override for the indexer URL.
|
|
3254
|
-
*
|
|
3255
|
-
* @deprecated Provide an explicit provider via the worker config instead.
|
|
3256
|
-
*/
|
|
3257
|
-
indexerUrl?: string;
|
|
3258
|
-
/**
|
|
3259
|
-
* Optional override for the Esplora API URL.
|
|
3260
|
-
*
|
|
3261
|
-
* @deprecated Provide an explicit provider via the worker config instead.
|
|
3262
|
-
*/
|
|
3263
|
-
esploraUrl?: string;
|
|
2874
|
+
/** Arkade server endpoint and optional public key. */
|
|
2875
|
+
arkServer?: {
|
|
2876
|
+
url: string;
|
|
2877
|
+
publicKey?: string;
|
|
2878
|
+
};
|
|
3264
2879
|
/**
|
|
3265
2880
|
* Repository-backed storage configuration overrides.
|
|
3266
2881
|
* Defaults to IndexedDB if unset.
|
|
@@ -3270,8 +2885,6 @@ interface ServiceWorkerWalletOptions {
|
|
|
3270
2885
|
identity: ReadonlyIdentity | Identity;
|
|
3271
2886
|
/** Optional delegation service URL. */
|
|
3272
2887
|
delegateUrl?: string;
|
|
3273
|
-
/** @deprecated alias for @see ServiceWorkerWalletOptions.delegateUrl */
|
|
3274
|
-
delegatorUrl?: string;
|
|
3275
2888
|
/**
|
|
3276
2889
|
* Override the default tag used for messages sent to and received from the service worker.
|
|
3277
2890
|
* @see DEFAULT_MESSAGE_TAG
|
|
@@ -3339,16 +2952,12 @@ type ServiceWorkerWalletSetupOptions = ServiceWorkerWalletOptions & {
|
|
|
3339
2952
|
serviceWorkerActivationTimeoutMs?: number;
|
|
3340
2953
|
};
|
|
3341
2954
|
type MessageBusInitConfig = {
|
|
3342
|
-
wallet: SerializedIdentity
|
|
2955
|
+
wallet: SerializedIdentity;
|
|
3343
2956
|
arkServer: {
|
|
3344
2957
|
url: string;
|
|
3345
2958
|
publicKey?: string;
|
|
3346
2959
|
};
|
|
3347
2960
|
delegateUrl?: string;
|
|
3348
|
-
/** @deprecated alias for @see MessageBusInitConfig.delegateUrl */
|
|
3349
|
-
delegatorUrl?: string;
|
|
3350
|
-
indexerUrl?: string;
|
|
3351
|
-
esploraUrl?: string;
|
|
3352
2961
|
timeoutMs?: number;
|
|
3353
2962
|
settlementConfig?: SettlementConfig | false;
|
|
3354
2963
|
walletMode?: ServiceWorkerWalletMode;
|
|
@@ -3370,15 +2979,6 @@ declare class ServiceWorkerReadonlyWallet implements IReadonlyWallet {
|
|
|
3370
2979
|
protected initWalletPayload: RequestInitWallet["payload"] | null;
|
|
3371
2980
|
protected messageBusTimeoutMs?: number;
|
|
3372
2981
|
protected messageTimeouts: Record<RequestType, number>;
|
|
3373
|
-
protected arkServerUrl?: string;
|
|
3374
|
-
protected arkServerPublicKey?: string;
|
|
3375
|
-
protected delegateUrl?: string;
|
|
3376
|
-
/** @deprecated alias for @see ServiceWorkerReadonlyWallet.delegateUrl */
|
|
3377
|
-
protected delegatorUrl?: string;
|
|
3378
|
-
protected indexerUrl?: string;
|
|
3379
|
-
protected esploraUrl?: string;
|
|
3380
|
-
protected watcherConfig?: Partial<Omit<ContractWatcherConfig, "indexerProvider">>;
|
|
3381
|
-
protected settlementConfig?: SettlementConfig | false;
|
|
3382
2982
|
private reinitPromise;
|
|
3383
2983
|
private pingPromise;
|
|
3384
2984
|
private inflightRequests;
|
|
@@ -3393,6 +2993,8 @@ declare class ServiceWorkerReadonlyWallet implements IReadonlyWallet {
|
|
|
3393
2993
|
* @throws Error if service-worker initialization fails
|
|
3394
2994
|
*/
|
|
3395
2995
|
static create(options: ServiceWorkerWalletCreateOptions): Promise<ServiceWorkerReadonlyWallet>;
|
|
2996
|
+
/** Shared tail of both `create()` factories: boot the bus, INIT_WALLET, cache for reinit. */
|
|
2997
|
+
protected static bootstrap<W extends ServiceWorkerReadonlyWallet>(wallet: W, options: ServiceWorkerWalletCreateOptions, serializedWallet: SerializedIdentity, busConfig: Omit<MessageBusInitConfig, "wallet" | "arkServer" | "messageTimeouts">): Promise<W>;
|
|
3396
2998
|
/**
|
|
3397
2999
|
* Simplified setup method that handles service worker registration
|
|
3398
3000
|
* and wallet initialization automatically.
|
|
@@ -3403,7 +3005,7 @@ declare class ServiceWorkerReadonlyWallet implements IReadonlyWallet {
|
|
|
3403
3005
|
* ```typescript
|
|
3404
3006
|
* const wallet = await ServiceWorkerReadonlyWallet.setup({
|
|
3405
3007
|
* serviceWorkerPath: '/service-worker.js',
|
|
3406
|
-
*
|
|
3008
|
+
* arkServer: { url: 'https://arkade.computer' },
|
|
3407
3009
|
* identity: ReadonlySingleKey.fromPublicKey('your_public_key_hex')
|
|
3408
3010
|
* });
|
|
3409
3011
|
* ```
|
|
@@ -3417,20 +3019,8 @@ declare class ServiceWorkerReadonlyWallet implements IReadonlyWallet {
|
|
|
3417
3019
|
onEvent: (response: WalletUpdaterResponse) => void;
|
|
3418
3020
|
isComplete: (response: WalletUpdaterResponse) => boolean;
|
|
3419
3021
|
}): Promise<WalletUpdaterResponse>;
|
|
3420
|
-
/**
|
|
3421
|
-
* Produce a serialized envelope for the wallet's identity. The base
|
|
3422
|
-
* class always emits a readonly envelope; `ServiceWorkerWallet`
|
|
3423
|
-
* overrides to emit a signing envelope.
|
|
3424
|
-
*/
|
|
3425
|
-
protected serializeIdentity(): Promise<SerializedIdentity>;
|
|
3426
|
-
/**
|
|
3427
|
-
* Return the cached init config, or rebuild one from live instance
|
|
3428
|
-
* state when the cache was never populated. Recovery path for
|
|
3429
|
-
* SDK-factory-created wallets; manual constructor bypasses do not
|
|
3430
|
-
* retain enough state here and will hit the "never initialized" throw.
|
|
3431
|
-
*/
|
|
3022
|
+
/** The init config cached by `create()`; manually constructed wallets have none. */
|
|
3432
3023
|
protected buildInitConfig(): Promise<MessageBusInitConfig>;
|
|
3433
|
-
/** Minimal INIT_WALLET payload used on reinitialize when the cache is gone. */
|
|
3434
3024
|
protected buildInitWalletPayload(): RequestInitWallet["payload"];
|
|
3435
3025
|
private reinitialize;
|
|
3436
3026
|
/**
|
|
@@ -3486,7 +3076,7 @@ declare class ServiceWorkerReadonlyWallet implements IReadonlyWallet {
|
|
|
3486
3076
|
* and falling back to `GET_VTXOS` there would silently spend ungated coins.
|
|
3487
3077
|
* Fail closed — loud and recoverable — rather than make the gate advisory.
|
|
3488
3078
|
*/
|
|
3489
|
-
getSpendableVtxos(filter?:
|
|
3079
|
+
getSpendableVtxos(filter?: GetSpendableVtxosFilter): Promise<NormalizedExtendedVirtualCoin[]>;
|
|
3490
3080
|
/**
|
|
3491
3081
|
* Trigger a wallet reload inside the service worker.
|
|
3492
3082
|
*
|
|
@@ -3502,9 +3092,9 @@ declare class ServiceWorkerWallet extends ServiceWorkerReadonlyWallet implements
|
|
|
3502
3092
|
readonly identity: Identity;
|
|
3503
3093
|
private readonly _assetManager;
|
|
3504
3094
|
private readonly hasDelegate;
|
|
3095
|
+
private _restoreInFlight?;
|
|
3505
3096
|
protected constructor(serviceWorker: ServiceWorker, identity: Identity, walletRepository: WalletRepository, contractRepository: ContractRepository, messageTag: string, hasDelegate: boolean);
|
|
3506
3097
|
get assetManager(): IAssetManager;
|
|
3507
|
-
protected serializeIdentity(): Promise<SerializedIdentity>;
|
|
3508
3098
|
static create(options: ServiceWorkerWalletCreateOptions): Promise<ServiceWorkerWallet>;
|
|
3509
3099
|
/**
|
|
3510
3100
|
* Simplified setup method that handles service worker registration
|
|
@@ -3514,7 +3104,7 @@ declare class ServiceWorkerWallet extends ServiceWorkerReadonlyWallet implements
|
|
|
3514
3104
|
* ```typescript
|
|
3515
3105
|
* const wallet = await ServiceWorkerWallet.setup({
|
|
3516
3106
|
* serviceWorkerPath: '/service-worker.js',
|
|
3517
|
-
*
|
|
3107
|
+
* arkServer: { url: 'https://arkade.computer' },
|
|
3518
3108
|
* identity: MnemonicIdentity.fromMnemonic('abandon abandon...')
|
|
3519
3109
|
* });
|
|
3520
3110
|
* ```
|
|
@@ -3570,7 +3160,6 @@ declare class ServiceWorkerWallet extends ServiceWorkerReadonlyWallet implements
|
|
|
3570
3160
|
* readonly class would promise something the boundary rejects.
|
|
3571
3161
|
*/
|
|
3572
3162
|
getArkadeBroadcaster(): Promise<ArkadeBroadcaster>;
|
|
3573
|
-
sendBitcoin(params: SendBitcoinParams): Promise<string>;
|
|
3574
3163
|
settle(params?: SettleParams, callback?: (event: SettlementEvent) => void): Promise<string>;
|
|
3575
3164
|
/**
|
|
3576
3165
|
* Explicitly recover this wallet's contracts and balance on a fresh repo.
|
|
@@ -3586,15 +3175,14 @@ declare class ServiceWorkerWallet extends ServiceWorkerReadonlyWallet implements
|
|
|
3586
3175
|
restore(opts?: {
|
|
3587
3176
|
gapLimit?: number;
|
|
3588
3177
|
}): Promise<void>;
|
|
3178
|
+
private _restoreWorkerWallet;
|
|
3589
3179
|
send(...args: [SendParams] | [Recipient, ...Recipient[]]): Promise<string>;
|
|
3590
3180
|
getDelegateManager(): Promise<IDelegateManager | undefined>;
|
|
3591
|
-
/** @deprecated alias for @see ServiceWorkerWallet.getDelegateManager */
|
|
3592
|
-
getDelegatorManager(): Promise<IDelegateManager | undefined>;
|
|
3593
3181
|
getVtxoManager(): Promise<IVtxoManager>;
|
|
3594
3182
|
}
|
|
3595
3183
|
|
|
3596
3184
|
/**
|
|
3597
|
-
* A zero-value anchor output.
|
|
3185
|
+
* A zero-value anchor output. An ark tx overrides the amount to carry its fee.
|
|
3598
3186
|
*/
|
|
3599
3187
|
declare const P2A: {
|
|
3600
3188
|
script: Uint8Array<ArrayBuffer>;
|
|
@@ -4074,7 +3662,7 @@ declare class CachingArkProvider implements ArkProvider {
|
|
|
4074
3662
|
/** Releases the inner provider's server-info subscription. */
|
|
4075
3663
|
dispose(): void;
|
|
4076
3664
|
get serverUrl(): string | undefined;
|
|
4077
|
-
getInfo(): Promise<
|
|
3665
|
+
getInfo(): Promise<ArkadeInfo>;
|
|
4078
3666
|
submitTx(signedArkTx: string, checkpointTxs: string[]): Promise<{
|
|
4079
3667
|
arkTxid: string;
|
|
4080
3668
|
finalArkTx: string;
|
|
@@ -4090,7 +3678,7 @@ declare class CachingArkProvider implements ArkProvider {
|
|
|
4090
3678
|
getEventStream(signal: AbortSignal, topics: string[]): AsyncIterableIterator<SettlementEvent>;
|
|
4091
3679
|
getTransactionsStream(signal: AbortSignal): AsyncIterableIterator<TxNotificationEvent>;
|
|
4092
3680
|
getPendingTxs(intent: SignedIntent<Intent.GetPendingTxMessage>): Promise<PendingTx[]>;
|
|
4093
|
-
onServerInfoChanged(listener: (info:
|
|
3681
|
+
onServerInfoChanged(listener: (info: ArkadeInfo) => void): () => void;
|
|
4094
3682
|
}
|
|
4095
3683
|
|
|
4096
3684
|
type ArkTxInput = {
|
|
@@ -4212,6 +3800,9 @@ declare function assertSubmittedArkTxid(response: {
|
|
|
4212
3800
|
interface VerifyServerSignatures {
|
|
4213
3801
|
/** The Ark server's key; x-only or compressed, both accepted. */
|
|
4214
3802
|
serverPubkey: Uint8Array;
|
|
3803
|
+
/** Retired signer keys the server still advertises: a leaf built before a
|
|
3804
|
+
* rotation names one of these, and it is the leaf that decides. */
|
|
3805
|
+
deprecatedServerPubkeys?: Uint8Array[];
|
|
4215
3806
|
}
|
|
4216
3807
|
/**
|
|
4217
3808
|
* Build, sign, submit, and finalize an offchain transaction whose every input
|
|
@@ -4494,13 +4085,15 @@ declare class ArkNote implements ExtendedCoin {
|
|
|
4494
4085
|
* It encodes a private key and contract parameters as a bech32m string,
|
|
4495
4086
|
* enabling wallet-to-wallet transfers without address exchange.
|
|
4496
4087
|
*
|
|
4497
|
-
* Format: arkadecash1... (bech32m encoded)
|
|
4088
|
+
* Format: arkadecash1... / tarkadecash1... (bech32m encoded)
|
|
4498
4089
|
* Payload: version (1 byte) + private key (32 bytes) + server pubkey (32 bytes) + csv timelock sequence (4 bytes)
|
|
4499
4090
|
*/
|
|
4500
4091
|
declare class ArkadeCash {
|
|
4501
4092
|
readonly csvTimelock: RelativeTimelock;
|
|
4502
4093
|
readonly hrp: string;
|
|
4503
4094
|
static readonly DefaultHRP = "arkadecash";
|
|
4095
|
+
/** The only prefixes minted or accepted: mainnet and test networks. */
|
|
4096
|
+
static readonly HRPs: readonly string[];
|
|
4504
4097
|
static readonly Version = 0;
|
|
4505
4098
|
static readonly PayloadLength: number;
|
|
4506
4099
|
private readonly _privateKey;
|
|
@@ -4526,6 +4119,12 @@ declare class ArkadeCash {
|
|
|
4526
4119
|
*
|
|
4527
4120
|
* The emulator is a signing service that executes Arkade scripts
|
|
4528
4121
|
* and co-signs transactions when the scripts pass validation.
|
|
4122
|
+
*
|
|
4123
|
+
* The read here goes through `baseFetch`, the SDK's shared fetch boundary, so
|
|
4124
|
+
* it picks up whatever policy that boundary carries. The four submit calls
|
|
4125
|
+
* deliberately do not: aborting a submit would not tell the caller whether the
|
|
4126
|
+
* emulator signed, and none of them has a way to find out, so they stay on the
|
|
4127
|
+
* global `fetch` with their transport-error type unchanged.
|
|
4529
4128
|
*/
|
|
4530
4129
|
|
|
4531
4130
|
interface EmulatorInfo {
|
|
@@ -5146,16 +4745,11 @@ declare const UnilateralExit: {
|
|
|
5146
4745
|
*
|
|
5147
4746
|
* Everything else (4xx, invalid JSON, schema violations, network mismatch,
|
|
5148
4747
|
* unsupported network) is terminal and returns `false`.
|
|
5149
|
-
*
|
|
5150
|
-
* NOTE (Step 2, Scope 2): this classifies the errors currently produced by the
|
|
5151
|
-
* boot-critical `getInfo` path. Normalizing the indexer's per-branch
|
|
5152
|
-
* `!res.ok` throws and the remaining Ark RPC methods into
|
|
5153
|
-
* {@link ProviderUnavailableError} is the broader Scope-2 work still pending.
|
|
5154
4748
|
*/
|
|
5155
4749
|
declare function isRetryableProviderError(error: unknown): boolean;
|
|
5156
4750
|
|
|
5157
4751
|
declare function validateConnectorsTxGraph(settlementTxB64: string, connectorsGraph: TxTree): void;
|
|
5158
|
-
declare function validateVtxoTxGraph(graph: TxTree, roundTransaction: Transaction
|
|
4752
|
+
declare function validateVtxoTxGraph(graph: TxTree, roundTransaction: Transaction, sweepTapTreeRoot: Uint8Array): void;
|
|
5159
4753
|
|
|
5160
4754
|
/**
|
|
5161
4755
|
* Assert the commitment tx received at batch finalization is the one validated
|
|
@@ -5296,14 +4890,16 @@ declare class Extension {
|
|
|
5296
4890
|
/**
|
|
5297
4891
|
* Arkade Script Opcodes
|
|
5298
4892
|
*
|
|
5299
|
-
* This module defines ONLY Arkade-specific opcodes (0xb3, 0xc3-
|
|
4893
|
+
* This module defines ONLY Arkade-specific opcodes (0xb3, 0xbb, 0xc3-0xf8).
|
|
5300
4894
|
* Standard Bitcoin opcodes are imported from @scure/btc-signer.
|
|
5301
4895
|
*
|
|
5302
|
-
* Reference: arkade-os/emulator
|
|
4896
|
+
* Reference: arkade-os/emulator pkg/arkade/opcode.go.
|
|
4897
|
+
* Byte 0xdc is OP_CHECKTIME, matching emulator v0.0.8 and compiler artifacts.
|
|
5303
4898
|
*/
|
|
5304
4899
|
|
|
5305
4900
|
declare const ARKADE_OP: {
|
|
5306
4901
|
readonly MERKLEBRANCHVERIFY: 179;
|
|
4902
|
+
readonly PUT: 187;
|
|
5307
4903
|
readonly DIGEST: 195;
|
|
5308
4904
|
readonly SHA256INITIALIZE: 196;
|
|
5309
4905
|
readonly SHA256UPDATE: 197;
|
|
@@ -5327,6 +4923,8 @@ declare const ARKADE_OP: {
|
|
|
5327
4923
|
readonly BIN2NUM: 216;
|
|
5328
4924
|
readonly REVERSEBYTES: 217;
|
|
5329
4925
|
readonly MODEXP: 218;
|
|
4926
|
+
readonly PUSHEXPIRY: 219;
|
|
4927
|
+
readonly CHECKTIME: 220;
|
|
5330
4928
|
readonly ECADD: 224;
|
|
5331
4929
|
readonly ECMUL: 225;
|
|
5332
4930
|
readonly ECPAIRING: 226;
|
|
@@ -5350,6 +4948,8 @@ declare const ARKADE_OP: {
|
|
|
5350
4948
|
readonly INSPECTPACKET: 244;
|
|
5351
4949
|
readonly INSPECTINPUTPACKET: 245;
|
|
5352
4950
|
readonly SIGHASH: 246;
|
|
4951
|
+
readonly TUNNEL: 247;
|
|
4952
|
+
readonly INSPECTINTENTMESSAGE: 248;
|
|
5353
4953
|
};
|
|
5354
4954
|
declare const ARKADE_OPCODES: number[];
|
|
5355
4955
|
declare const ARKADE_OPCODE_NAMES: Record<number, string>;
|
|
@@ -5398,6 +4998,7 @@ declare function getOpcodeValue(name: string): number | undefined;
|
|
|
5398
4998
|
*/
|
|
5399
4999
|
declare const ARKADE_OPS: {
|
|
5400
5000
|
readonly MERKLEBRANCHVERIFY: 179;
|
|
5001
|
+
readonly PUT: 187;
|
|
5401
5002
|
readonly DIGEST: 195;
|
|
5402
5003
|
readonly SHA256INITIALIZE: 196;
|
|
5403
5004
|
readonly SHA256UPDATE: 197;
|
|
@@ -5421,6 +5022,8 @@ declare const ARKADE_OPS: {
|
|
|
5421
5022
|
readonly BIN2NUM: 216;
|
|
5422
5023
|
readonly REVERSEBYTES: 217;
|
|
5423
5024
|
readonly MODEXP: 218;
|
|
5025
|
+
readonly PUSHEXPIRY: 219;
|
|
5026
|
+
readonly CHECKTIME: 220;
|
|
5424
5027
|
readonly ECADD: 224;
|
|
5425
5028
|
readonly ECMUL: 225;
|
|
5426
5029
|
readonly ECPAIRING: 226;
|
|
@@ -5444,119 +5047,121 @@ declare const ARKADE_OPS: {
|
|
|
5444
5047
|
readonly INSPECTPACKET: 244;
|
|
5445
5048
|
readonly INSPECTINPUTPACKET: 245;
|
|
5446
5049
|
readonly SIGHASH: 246;
|
|
5447
|
-
readonly
|
|
5448
|
-
readonly
|
|
5449
|
-
readonly
|
|
5450
|
-
readonly
|
|
5451
|
-
readonly
|
|
5452
|
-
readonly
|
|
5453
|
-
readonly
|
|
5454
|
-
readonly
|
|
5455
|
-
readonly
|
|
5456
|
-
readonly
|
|
5457
|
-
readonly
|
|
5458
|
-
readonly
|
|
5459
|
-
readonly
|
|
5460
|
-
readonly
|
|
5461
|
-
readonly
|
|
5462
|
-
readonly
|
|
5463
|
-
readonly
|
|
5464
|
-
readonly
|
|
5465
|
-
readonly
|
|
5466
|
-
readonly
|
|
5467
|
-
readonly
|
|
5468
|
-
readonly
|
|
5469
|
-
readonly
|
|
5470
|
-
readonly
|
|
5471
|
-
readonly
|
|
5472
|
-
readonly
|
|
5473
|
-
readonly
|
|
5474
|
-
readonly
|
|
5475
|
-
readonly
|
|
5476
|
-
readonly
|
|
5477
|
-
readonly
|
|
5478
|
-
readonly
|
|
5479
|
-
readonly
|
|
5480
|
-
readonly
|
|
5481
|
-
readonly
|
|
5482
|
-
readonly
|
|
5483
|
-
readonly '
|
|
5484
|
-
readonly '
|
|
5485
|
-
readonly '
|
|
5486
|
-
readonly '
|
|
5487
|
-
readonly
|
|
5488
|
-
readonly
|
|
5489
|
-
readonly
|
|
5490
|
-
readonly
|
|
5491
|
-
readonly
|
|
5492
|
-
readonly
|
|
5493
|
-
readonly
|
|
5494
|
-
readonly
|
|
5495
|
-
readonly
|
|
5496
|
-
readonly
|
|
5497
|
-
readonly
|
|
5498
|
-
readonly
|
|
5499
|
-
readonly
|
|
5500
|
-
readonly
|
|
5501
|
-
readonly
|
|
5502
|
-
readonly
|
|
5503
|
-
readonly
|
|
5504
|
-
readonly
|
|
5505
|
-
readonly
|
|
5506
|
-
readonly
|
|
5507
|
-
readonly
|
|
5508
|
-
readonly
|
|
5509
|
-
readonly
|
|
5510
|
-
readonly
|
|
5511
|
-
readonly
|
|
5512
|
-
readonly
|
|
5513
|
-
readonly '
|
|
5514
|
-
readonly '
|
|
5515
|
-
readonly
|
|
5516
|
-
readonly
|
|
5517
|
-
readonly
|
|
5518
|
-
readonly
|
|
5519
|
-
readonly
|
|
5520
|
-
readonly
|
|
5521
|
-
readonly
|
|
5522
|
-
readonly
|
|
5523
|
-
readonly
|
|
5524
|
-
readonly
|
|
5525
|
-
readonly
|
|
5526
|
-
readonly
|
|
5527
|
-
readonly
|
|
5528
|
-
readonly
|
|
5529
|
-
readonly
|
|
5530
|
-
readonly
|
|
5531
|
-
readonly
|
|
5532
|
-
readonly
|
|
5533
|
-
readonly
|
|
5534
|
-
readonly
|
|
5535
|
-
readonly
|
|
5536
|
-
readonly
|
|
5537
|
-
readonly
|
|
5538
|
-
readonly
|
|
5539
|
-
readonly
|
|
5540
|
-
readonly
|
|
5541
|
-
readonly
|
|
5542
|
-
readonly
|
|
5543
|
-
readonly
|
|
5544
|
-
readonly
|
|
5545
|
-
readonly
|
|
5546
|
-
readonly
|
|
5547
|
-
readonly
|
|
5548
|
-
readonly
|
|
5549
|
-
readonly
|
|
5550
|
-
readonly
|
|
5551
|
-
readonly
|
|
5552
|
-
readonly
|
|
5553
|
-
readonly
|
|
5554
|
-
readonly
|
|
5555
|
-
readonly
|
|
5556
|
-
readonly
|
|
5557
|
-
readonly
|
|
5558
|
-
readonly
|
|
5559
|
-
readonly
|
|
5050
|
+
readonly TUNNEL: 247;
|
|
5051
|
+
readonly INSPECTINTENTMESSAGE: 248;
|
|
5052
|
+
readonly OP_0: 0;
|
|
5053
|
+
readonly PUSHDATA1: 76;
|
|
5054
|
+
readonly PUSHDATA2: 77;
|
|
5055
|
+
readonly PUSHDATA4: 78;
|
|
5056
|
+
readonly '1NEGATE': 79;
|
|
5057
|
+
readonly RESERVED: 80;
|
|
5058
|
+
readonly OP_1: 81;
|
|
5059
|
+
readonly OP_2: 82;
|
|
5060
|
+
readonly OP_3: 83;
|
|
5061
|
+
readonly OP_4: 84;
|
|
5062
|
+
readonly OP_5: 85;
|
|
5063
|
+
readonly OP_6: 86;
|
|
5064
|
+
readonly OP_7: 87;
|
|
5065
|
+
readonly OP_8: 88;
|
|
5066
|
+
readonly OP_9: 89;
|
|
5067
|
+
readonly OP_10: 90;
|
|
5068
|
+
readonly OP_11: 91;
|
|
5069
|
+
readonly OP_12: 92;
|
|
5070
|
+
readonly OP_13: 93;
|
|
5071
|
+
readonly OP_14: 94;
|
|
5072
|
+
readonly OP_15: 95;
|
|
5073
|
+
readonly OP_16: 96;
|
|
5074
|
+
readonly NOP: 97;
|
|
5075
|
+
readonly VER: 98;
|
|
5076
|
+
readonly IF: 99;
|
|
5077
|
+
readonly NOTIF: 100;
|
|
5078
|
+
readonly VERIF: 101;
|
|
5079
|
+
readonly VERNOTIF: 102;
|
|
5080
|
+
readonly ELSE: 103;
|
|
5081
|
+
readonly ENDIF: 104;
|
|
5082
|
+
readonly VERIFY: 105;
|
|
5083
|
+
readonly RETURN: 106;
|
|
5084
|
+
readonly TOALTSTACK: 107;
|
|
5085
|
+
readonly FROMALTSTACK: 108;
|
|
5086
|
+
readonly '2DROP': 109;
|
|
5087
|
+
readonly '2DUP': 110;
|
|
5088
|
+
readonly '3DUP': 111;
|
|
5089
|
+
readonly '2OVER': 112;
|
|
5090
|
+
readonly '2ROT': 113;
|
|
5091
|
+
readonly '2SWAP': 114;
|
|
5092
|
+
readonly IFDUP: 115;
|
|
5093
|
+
readonly DEPTH: 116;
|
|
5094
|
+
readonly DROP: 117;
|
|
5095
|
+
readonly DUP: 118;
|
|
5096
|
+
readonly NIP: 119;
|
|
5097
|
+
readonly OVER: 120;
|
|
5098
|
+
readonly PICK: 121;
|
|
5099
|
+
readonly ROLL: 122;
|
|
5100
|
+
readonly ROT: 123;
|
|
5101
|
+
readonly SWAP: 124;
|
|
5102
|
+
readonly TUCK: 125;
|
|
5103
|
+
readonly CAT: 126;
|
|
5104
|
+
readonly SUBSTR: 127;
|
|
5105
|
+
readonly LEFT: 128;
|
|
5106
|
+
readonly RIGHT: 129;
|
|
5107
|
+
readonly SIZE: 130;
|
|
5108
|
+
readonly INVERT: 131;
|
|
5109
|
+
readonly AND: 132;
|
|
5110
|
+
readonly OR: 133;
|
|
5111
|
+
readonly XOR: 134;
|
|
5112
|
+
readonly EQUAL: 135;
|
|
5113
|
+
readonly EQUALVERIFY: 136;
|
|
5114
|
+
readonly RESERVED1: 137;
|
|
5115
|
+
readonly RESERVED2: 138;
|
|
5116
|
+
readonly '1ADD': 139;
|
|
5117
|
+
readonly '1SUB': 140;
|
|
5118
|
+
readonly '2MUL': 141;
|
|
5119
|
+
readonly '2DIV': 142;
|
|
5120
|
+
readonly NEGATE: 143;
|
|
5121
|
+
readonly ABS: 144;
|
|
5122
|
+
readonly NOT: 145;
|
|
5123
|
+
readonly '0NOTEQUAL': 146;
|
|
5124
|
+
readonly ADD: 147;
|
|
5125
|
+
readonly SUB: 148;
|
|
5126
|
+
readonly MUL: 149;
|
|
5127
|
+
readonly DIV: 150;
|
|
5128
|
+
readonly MOD: 151;
|
|
5129
|
+
readonly LSHIFT: 152;
|
|
5130
|
+
readonly RSHIFT: 153;
|
|
5131
|
+
readonly BOOLAND: 154;
|
|
5132
|
+
readonly BOOLOR: 155;
|
|
5133
|
+
readonly NUMEQUAL: 156;
|
|
5134
|
+
readonly NUMEQUALVERIFY: 157;
|
|
5135
|
+
readonly NUMNOTEQUAL: 158;
|
|
5136
|
+
readonly LESSTHAN: 159;
|
|
5137
|
+
readonly GREATERTHAN: 160;
|
|
5138
|
+
readonly LESSTHANOREQUAL: 161;
|
|
5139
|
+
readonly GREATERTHANOREQUAL: 162;
|
|
5140
|
+
readonly MIN: 163;
|
|
5141
|
+
readonly MAX: 164;
|
|
5142
|
+
readonly WITHIN: 165;
|
|
5143
|
+
readonly RIPEMD160: 166;
|
|
5144
|
+
readonly SHA1: 167;
|
|
5145
|
+
readonly SHA256: 168;
|
|
5146
|
+
readonly HASH160: 169;
|
|
5147
|
+
readonly HASH256: 170;
|
|
5148
|
+
readonly CODESEPARATOR: 171;
|
|
5149
|
+
readonly CHECKSIG: 172;
|
|
5150
|
+
readonly CHECKSIGVERIFY: 173;
|
|
5151
|
+
readonly CHECKMULTISIG: 174;
|
|
5152
|
+
readonly CHECKMULTISIGVERIFY: 175;
|
|
5153
|
+
readonly NOP1: 176;
|
|
5154
|
+
readonly CHECKLOCKTIMEVERIFY: 177;
|
|
5155
|
+
readonly CHECKSEQUENCEVERIFY: 178;
|
|
5156
|
+
readonly NOP4: 179;
|
|
5157
|
+
readonly NOP5: 180;
|
|
5158
|
+
readonly NOP6: 181;
|
|
5159
|
+
readonly NOP7: 182;
|
|
5160
|
+
readonly NOP8: 183;
|
|
5161
|
+
readonly NOP9: 184;
|
|
5162
|
+
readonly NOP10: 185;
|
|
5163
|
+
readonly CHECKSIGADD: 186;
|
|
5164
|
+
readonly INVALID: 255;
|
|
5560
5165
|
};
|
|
5561
5166
|
/** A single script operation: opcode string key, raw bytes, number, or bigint */
|
|
5562
5167
|
type ArkadeScriptOP = keyof typeof ARKADE_OPS | Uint8Array | number | bigint;
|
|
@@ -5678,45 +5283,71 @@ declare namespace bignum {
|
|
|
5678
5283
|
export { bignum_BIGNUM_MAX_BYTES as BIGNUM_MAX_BYTES, bignum_decode as decode, bignum_encode as encode };
|
|
5679
5284
|
}
|
|
5680
5285
|
|
|
5286
|
+
/**
|
|
5287
|
+
* Read the JSON `arkadec` writes into a {@link Program}: `$param` placeholders,
|
|
5288
|
+
* @scure opcode names, and one structured tapleaf per compiler leaf.
|
|
5289
|
+
*/
|
|
5290
|
+
|
|
5291
|
+
interface ArtifactParameter {
|
|
5292
|
+
name: string;
|
|
5293
|
+
type: string;
|
|
5294
|
+
}
|
|
5295
|
+
interface ArtifactStruct {
|
|
5296
|
+
name: string;
|
|
5297
|
+
fields: ArtifactParameter[];
|
|
5298
|
+
}
|
|
5299
|
+
interface ArtifactWitnessElement {
|
|
5300
|
+
name: string;
|
|
5301
|
+
type: string;
|
|
5302
|
+
encoding?: string;
|
|
5303
|
+
injected?: boolean;
|
|
5304
|
+
}
|
|
5305
|
+
interface ArtifactLeaf {
|
|
5306
|
+
name: string;
|
|
5307
|
+
witness?: ArtifactWitnessElement[];
|
|
5308
|
+
asm: string[];
|
|
5309
|
+
}
|
|
5310
|
+
interface ArtifactCovenant {
|
|
5311
|
+
inputs: ArtifactParameter[];
|
|
5312
|
+
asm: string[];
|
|
5313
|
+
}
|
|
5314
|
+
interface ArtifactGroup {
|
|
5315
|
+
name: string;
|
|
5316
|
+
arkade?: ArtifactCovenant;
|
|
5317
|
+
leaves: ArtifactLeaf[];
|
|
5318
|
+
}
|
|
5319
|
+
interface ContractArtifact {
|
|
5320
|
+
contractName: string;
|
|
5321
|
+
constructorInputs: ArtifactParameter[];
|
|
5322
|
+
structs?: ArtifactStruct[];
|
|
5323
|
+
functions: ArtifactGroup[];
|
|
5324
|
+
}
|
|
5325
|
+
/** `true` when `value` is an arkadec artifact rather than a Program. */
|
|
5326
|
+
declare function isContractArtifact(value: unknown): value is ContractArtifact;
|
|
5327
|
+
/** Adds `server`, and one param per child-output placeholder for the caller to bind to that output key. */
|
|
5328
|
+
declare function programFromArtifact(artifact: ContractArtifact): Program;
|
|
5329
|
+
|
|
5681
5330
|
/**
|
|
5682
5331
|
* Arkade Contract — artifact-driven, high-level covenant API.
|
|
5683
5332
|
*
|
|
5684
|
-
*
|
|
5685
|
-
*
|
|
5686
|
-
*
|
|
5687
|
-
*
|
|
5688
|
-
*
|
|
5689
|
-
*
|
|
5690
|
-
*
|
|
5691
|
-
*
|
|
5692
|
-
*
|
|
5693
|
-
*
|
|
5694
|
-
*
|
|
5695
|
-
*
|
|
5696
|
-
*
|
|
5697
|
-
*
|
|
5698
|
-
*
|
|
5699
|
-
*
|
|
5700
|
-
*
|
|
5701
|
-
*
|
|
5702
|
-
*
|
|
5703
|
-
* Contract functions are strongly typed from the program's literal shape: a
|
|
5704
|
-
* function declaring `inputs: [{ name: "preimage", type: "bytes" }]` produces a
|
|
5705
|
-
* `functions.claim(preimage: Uint8Array)` call signature. The type flows through
|
|
5706
|
-
* `arkade.contract(...)` automatically for inline literals; for a program stored
|
|
5707
|
-
* in a variable, annotate it with `satisfies Program` to preserve the literal
|
|
5708
|
-
* type (a plain `: Program` annotation would widen it away).
|
|
5709
|
-
*
|
|
5710
|
-
* Constructor `params` follow the same convention: bare name strings are
|
|
5711
|
-
* documentation only, while typed descriptors `{ name, type }` (the form the
|
|
5712
|
-
* ArkadeScript compiler emits) make the list authoritative — every declared
|
|
5713
|
-
* param must be bound, every `$name` reference must be declared, and bound
|
|
5714
|
-
* values are validated against their type at compilation.
|
|
5715
|
-
*
|
|
5716
|
-
* A covenant spend needs an `indexer`, not just an `emulator`: the co-signing
|
|
5717
|
-
* service resolves each input's prevout pkScript from the previous ark tx the
|
|
5718
|
-
* PSBT carries, and only the indexer can supply those bytes. Pure tapscript
|
|
5719
|
-
* spends go straight to arkd and need neither.
|
|
5333
|
+
* A contract is a {@link Program}: named functions, each split into a `tapscript` segment
|
|
5334
|
+
* enforced on-chain and an `arkadeScript` segment emulated by the co-signing service. The shape
|
|
5335
|
+
* mirrors the compiler artifact, so hand-written programs and compiler output share one resolver.
|
|
5336
|
+
* The SDK never interprets scripts; it resolves `$param` placeholders and signers, builds the
|
|
5337
|
+
* taproot tree (co-signer key tweaked by the arkade-script hash) and assembles the spend.
|
|
5338
|
+
*
|
|
5339
|
+
* Compilation lives in {@link ArkadeProgramScript} and is shared with the `"arkade"` contract
|
|
5340
|
+
* handler: pass a `contractManager` to {@link Arkade.connect} and call
|
|
5341
|
+
* {@link ArkadeContract.register} to persist and watch a contract.
|
|
5342
|
+
*
|
|
5343
|
+
* Functions are typed from the program's literal shape (`inputs: [{ name: "preimage", type:
|
|
5344
|
+
* "bytes" }]` → `functions.claim(preimage: Uint8Array)`). For a program stored in a variable use
|
|
5345
|
+
* `satisfies Program`; a `: Program` annotation widens the literal type away. Typed `params`
|
|
5346
|
+
* descriptors `{ name, type }` make the list authoritative (every param bound, every `$name`
|
|
5347
|
+
* declared, values type-checked); bare name strings are documentation only.
|
|
5348
|
+
*
|
|
5349
|
+
* A covenant spend needs an `indexer` as well as an `emulator`: the co-signer resolves each
|
|
5350
|
+
* input's prevout from the previous ark tx the PSBT carries. Pure tapscript spends need neither.
|
|
5720
5351
|
*
|
|
5721
5352
|
* @example
|
|
5722
5353
|
* ```typescript
|
|
@@ -5759,10 +5390,8 @@ type FnArgs<F extends ArkadeFunction> = F extends {
|
|
|
5759
5390
|
inputs: infer I extends readonly InputRef[];
|
|
5760
5391
|
} ? ArgsTuple<I> : [];
|
|
5761
5392
|
/**
|
|
5762
|
-
* The statically-typed `functions` map of a contract
|
|
5763
|
-
*
|
|
5764
|
-
* its `inputs`. When the program is the widened {@link Program} (an index
|
|
5765
|
-
* signature), it falls back to the loose {@link CallableFunctions}.
|
|
5393
|
+
* The statically-typed `functions` map of a contract: precisely typed per function for a literal
|
|
5394
|
+
* program, the loose {@link CallableFunctions} for the widened {@link Program}.
|
|
5766
5395
|
*/
|
|
5767
5396
|
type ContractFunctions<P extends Program> = string extends keyof P["functions"] ? CallableFunctions : {
|
|
5768
5397
|
[K in keyof P["functions"]]: (...args: FnArgs<P["functions"][K]>) => ArkadeTransactionBuilder;
|
|
@@ -5773,13 +5402,9 @@ interface Utxo {
|
|
|
5773
5402
|
vout: number;
|
|
5774
5403
|
value: number;
|
|
5775
5404
|
/**
|
|
5776
|
-
* Raw
|
|
5777
|
-
* the
|
|
5778
|
-
*
|
|
5779
|
-
* An override, not the only channel: covenant spends resolve the previous
|
|
5780
|
-
* tx of every input through the client's indexer. Supply it when the tx is
|
|
5781
|
-
* not yet indexable — a recursive covenant spending the output of an ark tx
|
|
5782
|
-
* the caller just built — and the resolved value is suppressed for input 0.
|
|
5405
|
+
* Raw bytes of the ark tx that created this VTXO, attached as input 0's PrevArkTx. Overrides
|
|
5406
|
+
* the indexer-resolved value; supply it when the tx isn't indexable yet (a recursive covenant
|
|
5407
|
+
* spending an ark tx the caller just built).
|
|
5783
5408
|
*/
|
|
5784
5409
|
sourceTx?: Uint8Array;
|
|
5785
5410
|
}
|
|
@@ -5815,33 +5440,19 @@ interface ArkadeSpendResult {
|
|
|
5815
5440
|
}
|
|
5816
5441
|
/** The callable spending paths of a contract. */
|
|
5817
5442
|
type CallableFunctions = Record<string, (...args: ArkadeArgValue[]) => ArkadeTransactionBuilder>;
|
|
5818
|
-
/**
|
|
5819
|
-
* What {@link Arkade} needs from the Arkade server.
|
|
5820
|
-
*
|
|
5821
|
-
* Only `getInfo` is required — see {@link ArkadeConnectOptions.arkade} for why.
|
|
5822
|
-
* Named so a caller building a derivation-only client has a type to import
|
|
5823
|
-
* rather than reaching into the options bag.
|
|
5824
|
-
*/
|
|
5443
|
+
/** What {@link Arkade} needs from the Arkade server; see {@link ArkadeConnectOptions.arkade}. */
|
|
5825
5444
|
type ArkadeServerProvider = Pick<ArkProvider, "getInfo"> & Partial<ArkadeBroadcaster>;
|
|
5826
5445
|
/** Options for {@link Arkade.connect}. */
|
|
5827
5446
|
interface ArkadeConnectOptions {
|
|
5828
5447
|
/**
|
|
5829
|
-
* The Arkade server provider.
|
|
5830
|
-
*
|
|
5831
|
-
*
|
|
5832
|
-
* checkpoint closure, and it is all a client needs to derive, register and
|
|
5833
|
-
* inspect contracts. `submitTx`/`finalizeTx` are needed solely to
|
|
5834
|
-
* broadcast, so a client built without them throws at `.send()` — the same
|
|
5835
|
-
* deferred, explicit failure an absent `indexer` gives `getUtxos()` and an
|
|
5836
|
-
* absent `emulator` gives a covenant spend. That lets a caller that already
|
|
5837
|
-
* holds the server info (`wallet.getArkadeInfo()`) connect without a
|
|
5838
|
-
* provider of its own, and without a second `/v1/info` round-trip.
|
|
5448
|
+
* The Arkade server provider. Only `getInfo` is required (enough to derive, register and
|
|
5449
|
+
* inspect contracts); without `submitTx`/`finalizeTx`, `.send()` throws. So a caller already
|
|
5450
|
+
* holding `wallet.getArkadeInfo()` can connect without a second `/v1/info` round-trip.
|
|
5839
5451
|
*/
|
|
5840
5452
|
arkade: ArkadeServerProvider;
|
|
5841
5453
|
/**
|
|
5842
|
-
* The co-signing (introspector/emulator) service.
|
|
5843
|
-
*
|
|
5844
|
-
* tapscript contracts (multisig/timelock/hashlock) don't need it.
|
|
5454
|
+
* The co-signing (introspector/emulator) service. Required only for functions with an
|
|
5455
|
+
* `arkadeScript` (covenant paths).
|
|
5845
5456
|
*/
|
|
5846
5457
|
emulator?: EmulatorProvider;
|
|
5847
5458
|
/**
|
|
@@ -5852,34 +5463,30 @@ interface ArkadeConnectOptions {
|
|
|
5852
5463
|
indexer?: Pick<IndexerProvider, "getVtxos" | "getVirtualTxs">;
|
|
5853
5464
|
/** Signer for paths that require a user signature; optional for watch-only. */
|
|
5854
5465
|
identity?: Identity;
|
|
5855
|
-
/**
|
|
5466
|
+
/**
|
|
5467
|
+
* Network for address derivation. Defaults to the network the server
|
|
5468
|
+
* reports on `getInfo` — or the SDK default when the server names none.
|
|
5469
|
+
*/
|
|
5856
5470
|
network?: Network;
|
|
5857
5471
|
/**
|
|
5858
|
-
* Co-sign with this emulator key (33-byte compressed hex) instead of the
|
|
5859
|
-
*
|
|
5860
|
-
*
|
|
5861
|
-
*
|
|
5862
|
-
* self-hosted emulator, or on a network with no pinned key at all (signet,
|
|
5863
|
-
* testnet, a hand-built `Network` — those throw without it). Setting it
|
|
5864
|
-
* means trusting that operator as co-signer in place of the network's.
|
|
5472
|
+
* Co-sign with this emulator key (33-byte compressed hex) instead of the one pinned for
|
|
5473
|
+
* `network`. Needed after a key rotation ahead of this SDK, for a self-hosted emulator, or on
|
|
5474
|
+
* networks with no pinned key (signet, testnet, a hand-built `Network` — those throw without
|
|
5475
|
+
* it). Setting it means trusting that operator as co-signer.
|
|
5865
5476
|
*
|
|
5866
5477
|
* @see resolveEmulatorPubkey
|
|
5867
5478
|
*/
|
|
5868
5479
|
emulatorPubkey?: string;
|
|
5869
5480
|
/**
|
|
5870
|
-
* The wallet's contract manager.
|
|
5871
|
-
*
|
|
5872
|
-
*
|
|
5873
|
-
* {@link ArkadeContract.getUtxos} reads repository-backed state
|
|
5874
|
-
* (offline-first) for registered contracts instead of querying the
|
|
5875
|
-
* indexer directly. Obtain it via `wallet.getContractManager()`.
|
|
5481
|
+
* The wallet's contract manager (`wallet.getContractManager()`). Enables
|
|
5482
|
+
* {@link ArkadeContract.register}, and makes {@link ArkadeContract.getUtxos} read
|
|
5483
|
+
* repository-backed state for registered contracts instead of the indexer.
|
|
5876
5484
|
*/
|
|
5877
5485
|
contractManager?: IContractManager;
|
|
5878
5486
|
}
|
|
5879
5487
|
/**
|
|
5880
|
-
* A connected Arkade client
|
|
5881
|
-
*
|
|
5882
|
-
* so spinning up contracts is synchronous.
|
|
5488
|
+
* A connected Arkade client holding the providers and resolved network constants (server key,
|
|
5489
|
+
* co-signer key, checkpoint closure), so creating contracts is synchronous.
|
|
5883
5490
|
*/
|
|
5884
5491
|
declare class Arkade {
|
|
5885
5492
|
readonly arkProvider: ArkadeServerProvider;
|
|
@@ -5888,14 +5495,10 @@ declare class Arkade {
|
|
|
5888
5495
|
readonly network: Network;
|
|
5889
5496
|
readonly serverKey: Uint8Array;
|
|
5890
5497
|
/**
|
|
5891
|
-
* The co-signer key covenants are built against (33-byte compressed),
|
|
5892
|
-
*
|
|
5893
|
-
*
|
|
5894
|
-
*
|
|
5895
|
-
* emulator's own report. When a claim is refused because the co-signer
|
|
5896
|
-
* disagrees, compare `hex.encode(arkade.emulatorKey)` against the
|
|
5897
|
-
* `signerPubkey` your emulator serves on `/v1/info`: if they differ, the
|
|
5898
|
-
* network rotated and this SDK's pin is stale.
|
|
5498
|
+
* The co-signer key covenants are built against (33-byte compressed), present only when an
|
|
5499
|
+
* emulator is configured. Resolved from the network or `emulatorPubkey`, never the emulator's
|
|
5500
|
+
* own report. If a claim is refused, compare it with the emulator's `/v1/info` `signerPubkey`:
|
|
5501
|
+
* a difference means the network rotated and this SDK's pin is stale.
|
|
5899
5502
|
*/
|
|
5900
5503
|
readonly emulatorKey: Uint8Array | undefined;
|
|
5901
5504
|
readonly checkpoint: CSVMultisigTapscript.Type;
|
|
@@ -5909,14 +5512,11 @@ declare class Arkade {
|
|
|
5909
5512
|
/** Connect and resolve the server key, checkpoint closure and (if present) the co-signer key. */
|
|
5910
5513
|
static connect(opts: ArkadeConnectOptions): Promise<Arkade>;
|
|
5911
5514
|
/**
|
|
5912
|
-
* Instantiate a contract from a program and its constructor arguments.
|
|
5913
|
-
*
|
|
5914
|
-
* contract's `functions` map is strongly typed — `functions.<name>(...)`
|
|
5915
|
-
* knows each argument's type from the function's `inputs` descriptors.
|
|
5515
|
+
* Instantiate a contract from a program and its constructor arguments. `const` inference keeps
|
|
5516
|
+
* the program's literal type, so `functions` is strongly typed.
|
|
5916
5517
|
*
|
|
5917
|
-
*
|
|
5918
|
-
*
|
|
5919
|
-
* key respectively; explicit args always win.
|
|
5518
|
+
* Unbound declared `server`/`user` params default to the client's server key / identity key;
|
|
5519
|
+
* explicit args win.
|
|
5920
5520
|
*/
|
|
5921
5521
|
contract<const P extends Program>(program: P, args?: Record<string, ArkadeParamValue>): ArkadeContract<P>;
|
|
5922
5522
|
}
|
|
@@ -5935,11 +5535,8 @@ declare class ArkadeContract<P extends Program = Program> {
|
|
|
5935
5535
|
private readonly compiled;
|
|
5936
5536
|
constructor(client: Arkade, program: P, args?: Record<string, ArkadeParamValue>, keys?: ProgramKeys);
|
|
5937
5537
|
/**
|
|
5938
|
-
* Rebuild a callable contract from a persisted `"arkade"`
|
|
5939
|
-
*
|
|
5940
|
-
* compilation — not the client's current ones — so the derived script and
|
|
5941
|
-
* address stay identical to the registered contract even after a server
|
|
5942
|
-
* signer rotation.
|
|
5538
|
+
* Rebuild a callable contract from a persisted `"arkade"` row. Compiles with the stored keys,
|
|
5539
|
+
* not the client's current ones, so script and address survive a server signer rotation.
|
|
5943
5540
|
*/
|
|
5944
5541
|
static fromContract(client: Arkade, contract: Contract): ArkadeContract;
|
|
5945
5542
|
/** Resolve the {@link TapLeafScript} for a spending path by its index. */
|
|
@@ -5948,16 +5545,11 @@ declare class ArkadeContract<P extends Program = Program> {
|
|
|
5948
5545
|
get address(): string;
|
|
5949
5546
|
/** Taproot output script. */
|
|
5950
5547
|
get pkScript(): Uint8Array;
|
|
5951
|
-
/**
|
|
5952
|
-
* Callable spending paths: `contract.functions.<name>(...args)`. Strongly
|
|
5953
|
-
* typed from the program's literal type — each function's argument types are
|
|
5954
|
-
* derived from its `inputs` descriptors (see {@link ContractFunctions}).
|
|
5955
|
-
*/
|
|
5548
|
+
/** Callable spending paths: `functions.<name>(...args)` (see {@link ContractFunctions}). */
|
|
5956
5549
|
get functions(): ContractFunctions<P>;
|
|
5957
5550
|
/**
|
|
5958
|
-
* The `createContract` payload
|
|
5959
|
-
*
|
|
5960
|
-
* through a manager the client does not hold.
|
|
5551
|
+
* The `createContract` payload (serialized program, args, keys, script, address), for
|
|
5552
|
+
* registering through a manager the client does not hold.
|
|
5961
5553
|
*/
|
|
5962
5554
|
toContractParams(): {
|
|
5963
5555
|
type: string;
|
|
@@ -5966,26 +5558,17 @@ declare class ArkadeContract<P extends Program = Program> {
|
|
|
5966
5558
|
address: string;
|
|
5967
5559
|
};
|
|
5968
5560
|
/**
|
|
5969
|
-
* Persist this contract through the wallet's {@link IContractManager}
|
|
5970
|
-
*
|
|
5971
|
-
* repository, watched for VTXO events, counted in repository-backed
|
|
5972
|
-
* balances, and re-derivable offline via the `"arkade"` contract handler.
|
|
5973
|
-
* Idempotent — re-registering the same script is a no-op.
|
|
5561
|
+
* Persist this contract through the wallet's {@link IContractManager} (stored, watched,
|
|
5562
|
+
* counted in balances, re-derivable via the `"arkade"` handler). Idempotent per script.
|
|
5974
5563
|
*/
|
|
5975
5564
|
register(options?: {
|
|
5976
5565
|
label?: string;
|
|
5977
5566
|
metadata?: Record<string, unknown>;
|
|
5978
5567
|
}): Promise<Contract>;
|
|
5979
5568
|
/**
|
|
5980
|
-
* Spendable VTXOs locked by this contract
|
|
5981
|
-
*
|
|
5982
|
-
*
|
|
5983
|
-
* reads the repository-backed state (offline-first, kept fresh by the
|
|
5984
|
-
* contract watcher). Otherwise falls back to a direct indexer query.
|
|
5985
|
-
*
|
|
5986
|
-
* Both branches refuse a spent or unilaterally exited output. They are not
|
|
5987
|
-
* otherwise interchangeable: the fallback asks `spendableOnly`, which also
|
|
5988
|
-
* drops swept coins — the manager branch keeps those.
|
|
5569
|
+
* Spendable VTXOs locked by this contract: repository-backed when registered with a
|
|
5570
|
+
* `contractManager`, otherwise a direct indexer query. Both drop spent and unrolled outputs;
|
|
5571
|
+
* only the indexer branch (`spendableOnly`) also drops swept coins.
|
|
5989
5572
|
*/
|
|
5990
5573
|
getUtxos(): Promise<VirtualCoin[]>;
|
|
5991
5574
|
/** Total spendable balance (requires an indexer). */
|
|
@@ -6082,6 +5665,7 @@ declare const index_AsmToken: typeof AsmToken;
|
|
|
6082
5665
|
type index_AssetSpec = AssetSpec;
|
|
6083
5666
|
type index_CallableFunctions = CallableFunctions;
|
|
6084
5667
|
declare const index_CompiledProgramFunction: typeof CompiledProgramFunction;
|
|
5668
|
+
type index_ContractArtifact = ContractArtifact;
|
|
6085
5669
|
type index_ContractFunctions<P extends Program> = ContractFunctions<P>;
|
|
6086
5670
|
declare const index_InputDef: typeof InputDef;
|
|
6087
5671
|
declare const index_InputRef: typeof InputRef;
|
|
@@ -6095,6 +5679,7 @@ declare const index_Script: typeof Script;
|
|
|
6095
5679
|
declare const index_ScriptType: typeof ScriptType;
|
|
6096
5680
|
declare const index_SignerRef: typeof SignerRef;
|
|
6097
5681
|
declare const index_TapscriptSegment: typeof TapscriptSegment;
|
|
5682
|
+
declare const index_TweakedSigner: typeof TweakedSigner;
|
|
6098
5683
|
type index_Utxo = Utxo;
|
|
6099
5684
|
declare const index_WitnessRef: typeof WitnessRef;
|
|
6100
5685
|
declare const index_arkadeScriptHash: typeof arkadeScriptHash;
|
|
@@ -6107,7 +5692,9 @@ declare const index_deserializeArkadeContractParams: typeof deserializeArkadeCon
|
|
|
6107
5692
|
declare const index_fromASM: typeof fromASM;
|
|
6108
5693
|
declare const index_getOpcodeName: typeof getOpcodeName;
|
|
6109
5694
|
declare const index_getOpcodeValue: typeof getOpcodeValue;
|
|
5695
|
+
declare const index_isContractArtifact: typeof isContractArtifact;
|
|
6110
5696
|
declare const index_parseArtifact: typeof parseArtifact;
|
|
5697
|
+
declare const index_programFromArtifact: typeof programFromArtifact;
|
|
6111
5698
|
declare const index_resolveAsm: typeof resolveAsm;
|
|
6112
5699
|
declare const index_serializeArkadeContractParams: typeof serializeArkadeContractParams;
|
|
6113
5700
|
declare const index_stringifyArtifact: typeof stringifyArtifact;
|
|
@@ -6115,7 +5702,7 @@ declare const index_toASM: typeof toASM;
|
|
|
6115
5702
|
declare const index_validateProgram: typeof validateProgram;
|
|
6116
5703
|
declare const index_witnessRefToBytes: typeof witnessRefToBytes;
|
|
6117
5704
|
declare namespace index {
|
|
6118
|
-
export { index_ARKADE_OP as ARKADE_OP, index_ARKADE_OPCODES as ARKADE_OPCODES, index_ARKADE_OPCODE_NAMES as ARKADE_OPCODE_NAMES, index_ARKADE_OPCODE_VALUES as ARKADE_OPCODE_VALUES, index_ARKADE_OPS as ARKADE_OPS, index_Arkade as Arkade, index_ArkadeArgType as ArkadeArgType, index_ArkadeArgValue as ArkadeArgValue, type index_ArkadeBatchInput as ArkadeBatchInput, type index_ArkadeConnectOptions as ArkadeConnectOptions, index_ArkadeContract as ArkadeContract, index_ArkadeContractParams as ArkadeContractParams, type index_ArkadeExtendedCoin as ArkadeExtendedCoin, type index_ArkadeExtendedVirtualCoin as ArkadeExtendedVirtualCoin, index_ArkadeFunction as ArkadeFunction, index_ArkadeParamValue as ArkadeParamValue, index_ArkadeProgramScript as ArkadeProgramScript, index_ArkadeScript as ArkadeScript, type index_ArkadeScriptOP as ArkadeScriptOP, type index_ArkadeScriptType as ArkadeScriptType, index_ArkadeSegment as ArkadeSegment, type index_ArkadeServerProvider as ArkadeServerProvider, type index_ArkadeSpendResult as ArkadeSpendResult, index_ArkadeTransactionBuilder as ArkadeTransactionBuilder, index_AsmToken as AsmToken, type index_AssetSpec as AssetSpec, bignum as BigNum, type index_CallableFunctions as CallableFunctions, index_CompiledProgramFunction as CompiledProgramFunction, type index_ContractFunctions as ContractFunctions, index_InputDef as InputDef, index_InputRef as InputRef, index_OP as OP, index_OPCODE_NAMES as OPCODE_NAMES, index_OPCODE_VALUES as OPCODE_VALUES, index_Program as Program, index_ProgramKeys as ProgramKeys, index_SUPPORTED_PROGRAM_VERSION as SUPPORTED_PROGRAM_VERSION, index_Script as Script, index_ScriptType as ScriptType, index_SignerRef as SignerRef, index_TapscriptSegment as TapscriptSegment, type index_Utxo as Utxo, index_WitnessRef as WitnessRef, index_arkadeScriptHash as arkadeScriptHash, index_arkadeWitnessHash as arkadeWitnessHash, index_asmToBytes as asmToBytes, index_bytesToASM as bytesToASM, index_computeArkadeScriptPublicKey as computeArkadeScriptPublicKey, index_createArkadeBatchHandler as createArkadeBatchHandler, index_deserializeArkadeContractParams as deserializeArkadeContractParams, index_fromASM as fromASM, index_getOpcodeName as getOpcodeName, index_getOpcodeValue as getOpcodeValue, index_parseArtifact as parseArtifact, index_resolveAsm as resolveAsm, index_serializeArkadeContractParams as serializeArkadeContractParams, index_stringifyArtifact as stringifyArtifact, index_toASM as toASM, index_validateProgram as validateProgram, index_witnessRefToBytes as witnessRefToBytes };
|
|
5705
|
+
export { index_ARKADE_OP as ARKADE_OP, index_ARKADE_OPCODES as ARKADE_OPCODES, index_ARKADE_OPCODE_NAMES as ARKADE_OPCODE_NAMES, index_ARKADE_OPCODE_VALUES as ARKADE_OPCODE_VALUES, index_ARKADE_OPS as ARKADE_OPS, index_Arkade as Arkade, index_ArkadeArgType as ArkadeArgType, index_ArkadeArgValue as ArkadeArgValue, type index_ArkadeBatchInput as ArkadeBatchInput, type index_ArkadeConnectOptions as ArkadeConnectOptions, index_ArkadeContract as ArkadeContract, index_ArkadeContractParams as ArkadeContractParams, type index_ArkadeExtendedCoin as ArkadeExtendedCoin, type index_ArkadeExtendedVirtualCoin as ArkadeExtendedVirtualCoin, index_ArkadeFunction as ArkadeFunction, index_ArkadeParamValue as ArkadeParamValue, index_ArkadeProgramScript as ArkadeProgramScript, index_ArkadeScript as ArkadeScript, type index_ArkadeScriptOP as ArkadeScriptOP, type index_ArkadeScriptType as ArkadeScriptType, index_ArkadeSegment as ArkadeSegment, type index_ArkadeServerProvider as ArkadeServerProvider, type index_ArkadeSpendResult as ArkadeSpendResult, index_ArkadeTransactionBuilder as ArkadeTransactionBuilder, index_AsmToken as AsmToken, type index_AssetSpec as AssetSpec, bignum as BigNum, type index_CallableFunctions as CallableFunctions, index_CompiledProgramFunction as CompiledProgramFunction, type index_ContractArtifact as ContractArtifact, type index_ContractFunctions as ContractFunctions, index_InputDef as InputDef, index_InputRef as InputRef, index_OP as OP, index_OPCODE_NAMES as OPCODE_NAMES, index_OPCODE_VALUES as OPCODE_VALUES, index_Program as Program, index_ProgramKeys as ProgramKeys, index_SUPPORTED_PROGRAM_VERSION as SUPPORTED_PROGRAM_VERSION, index_Script as Script, index_ScriptType as ScriptType, index_SignerRef as SignerRef, index_TapscriptSegment as TapscriptSegment, index_TweakedSigner as TweakedSigner, type index_Utxo as Utxo, index_WitnessRef as WitnessRef, index_arkadeScriptHash as arkadeScriptHash, index_arkadeWitnessHash as arkadeWitnessHash, index_asmToBytes as asmToBytes, index_bytesToASM as bytesToASM, index_computeArkadeScriptPublicKey as computeArkadeScriptPublicKey, index_createArkadeBatchHandler as createArkadeBatchHandler, index_deserializeArkadeContractParams as deserializeArkadeContractParams, index_fromASM as fromASM, index_getOpcodeName as getOpcodeName, index_getOpcodeValue as getOpcodeValue, index_isContractArtifact as isContractArtifact, index_parseArtifact as parseArtifact, index_programFromArtifact as programFromArtifact, index_resolveAsm as resolveAsm, index_serializeArkadeContractParams as serializeArkadeContractParams, index_stringifyArtifact as stringifyArtifact, index_toASM as toASM, index_validateProgram as validateProgram, index_witnessRefToBytes as witnessRefToBytes };
|
|
6119
5706
|
}
|
|
6120
5707
|
|
|
6121
5708
|
/** Known BIP21 parameters including Arkade-specific extensions. */
|
|
@@ -6193,23 +5780,14 @@ interface PaymentHandle {
|
|
|
6193
5780
|
}): Promise<RouteResult>;
|
|
6194
5781
|
}
|
|
6195
5782
|
/**
|
|
6196
|
-
* A priced route. The
|
|
6197
|
-
*
|
|
6198
|
-
*
|
|
6199
|
-
*
|
|
6200
|
-
* - `amount` — sats delivered **to the recipient**.
|
|
6201
|
-
* - `fee` — sats charged **on top**, by the rail and its counterparty.
|
|
6202
|
-
* - `total` — `amount + fee`; the sats that leave the wallet.
|
|
5783
|
+
* A priced route. The amounts are **receiver-exact** on every rail, so options rank on cost and
|
|
5784
|
+
* rails swap without changing what the recipient gets. Rails whose primitive *deducts* its fee
|
|
5785
|
+
* (collaborative exit) gross the amount up; a rail that can't (it doesn't choose the fee) flags
|
|
5786
|
+
* it via `claimFeeDeductedFromPayout`.
|
|
6203
5787
|
*
|
|
6204
|
-
*
|
|
6205
|
-
*
|
|
6206
|
-
*
|
|
6207
|
-
* never chooses, and flags that instead: see `claimFeeDeductedFromPayout`.
|
|
6208
|
-
*
|
|
6209
|
-
* `fee` is a pre-send estimate wherever the true cost is only fixed later: the
|
|
6210
|
-
* collaborative exit does not include the per-input intent fees, which depend
|
|
6211
|
-
* on the VTXO selection made at settlement. Treat it as a display and ranking
|
|
6212
|
-
* figure, not a guarantee.
|
|
5788
|
+
* `fee` is an estimate where cost is fixed later: the collaborative exit omits per-input intent
|
|
5789
|
+
* fees unless {@link PaymentRequest.selectedVtxos} is named. A display/ranking figure, not a
|
|
5790
|
+
* guarantee.
|
|
6213
5791
|
*/
|
|
6214
5792
|
interface RouteQuote {
|
|
6215
5793
|
railId: string;
|
|
@@ -6220,19 +5798,18 @@ interface RouteQuote {
|
|
|
6220
5798
|
/** `amount + fee` — what leaves the wallet. */
|
|
6221
5799
|
total: number;
|
|
6222
5800
|
/**
|
|
6223
|
-
*
|
|
6224
|
-
*
|
|
6225
|
-
*
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
*
|
|
6230
|
-
*
|
|
5801
|
+
* Unix seconds after which the counterparty stops honouring this quote. Absent means "no
|
|
5802
|
+
* check possible" (rails without a counterparty), not "never expires"; {@link send} may
|
|
5803
|
+
* still refuse, since swap rails re-check validity at spend time.
|
|
5804
|
+
*/
|
|
5805
|
+
validUntil?: number;
|
|
5806
|
+
/**
|
|
5807
|
+
* @experimental The asset shape is provisional, expected to converge with the v2 swap
|
|
5808
|
+
* client's `give`/`take`/`amountOn` over `AssetRef` in v0.5; not stable 0.4.x API.
|
|
6231
5809
|
*
|
|
6232
|
-
*
|
|
6233
|
-
*
|
|
6234
|
-
*
|
|
6235
|
-
* cost display.
|
|
5810
|
+
* The asset view; absent means BTC only. `amount` stays the sats carrier, not zero. On a
|
|
5811
|
+
* cross-asset route `delivered`/`spent` are different assets, so the purchase price lands in
|
|
5812
|
+
* `fee`; prefer `assets.spent` for a cost display.
|
|
6236
5813
|
*/
|
|
6237
5814
|
assets?: {
|
|
6238
5815
|
delivered: Asset;
|
|
@@ -6251,7 +5828,11 @@ interface RouterPreferences {
|
|
|
6251
5828
|
tieBreak?: "first" | "require-choice";
|
|
6252
5829
|
}
|
|
6253
5830
|
interface RouterContext {
|
|
6254
|
-
|
|
5831
|
+
/** A rail needing more than this takes it as a constructor dep, rather than
|
|
5832
|
+
* narrowing the context every other rail shares. */
|
|
5833
|
+
wallet: IWallet;
|
|
5834
|
+
/** Loosely typed in core to avoid a dependency on boltz-swap; swap rails cast it. */
|
|
5835
|
+
swaps?: unknown;
|
|
6255
5836
|
prefs: RouterPreferences;
|
|
6256
5837
|
}
|
|
6257
5838
|
/** Mirrors {@link Recipient}: an Arkade address is the same string for BTC and
|
|
@@ -6266,6 +5847,13 @@ interface PaymentRequest {
|
|
|
6266
5847
|
* Additive: an asset transfer also moves sats, so a 500 USDX request
|
|
6267
5848
|
* legitimately has both. A rail that cannot deliver assets must REFUSE. */
|
|
6268
5849
|
assets?: Asset[];
|
|
5850
|
+
/**
|
|
5851
|
+
* Spend exactly these (normalized) virtual outputs, as {@link SendParams.selectedVtxos}:
|
|
5852
|
+
* ungated like `settle({ inputs })`, and a shortfall is an error, not a top-up. Only rails
|
|
5853
|
+
* spending the wallet's own coins (`ark`, `ark-asset`, `onchain`) can honour it;
|
|
5854
|
+
* counterparty-funded rails must REFUSE, not ignore it.
|
|
5855
|
+
*/
|
|
5856
|
+
selectedVtxos?: NormalizedExtendedVirtualCoin[];
|
|
6269
5857
|
}
|
|
6270
5858
|
/** A payment rail — registered by id, mirrors the ActivityRegistry resolver shape. */
|
|
6271
5859
|
interface PaymentRail {
|
|
@@ -6298,10 +5886,11 @@ declare const isLightningInvoice: (raw: string) => boolean;
|
|
|
6298
5886
|
/**
|
|
6299
5887
|
* True for an LNURL or a Lightning address (`user@host`).
|
|
6300
5888
|
*
|
|
6301
|
-
*
|
|
6302
|
-
*
|
|
6303
|
-
*
|
|
6304
|
-
*
|
|
5889
|
+
* No rail here consumes it, and that is the layering rather than a gap:
|
|
5890
|
+
* routing an LNURL needs an LNURL client, so the rails ship from
|
|
5891
|
+
* `@arkade-os/lnurl-client/arkade` (`lnurlRails`) and are registered by the
|
|
5892
|
+
* app, as the solver rails from `@arkade-os/swap` are. With none registered,
|
|
5893
|
+
* `route()` throws "no rail for" on these targets.
|
|
6305
5894
|
*/
|
|
6306
5895
|
declare const isLnurl: (raw: string) => boolean;
|
|
6307
5896
|
/** True for a bech32 (segwit) or base58 (legacy) Bitcoin address, any network —
|
|
@@ -6338,6 +5927,11 @@ declare function assetsOf(req: PaymentRequest): Asset[];
|
|
|
6338
5927
|
/** For a BTC-only rail: refusing is what leaves the router free to rank an
|
|
6339
5928
|
* asset-capable one, instead of paying the carrier and dropping the asset. */
|
|
6340
5929
|
declare function assertNoAssets(railId: string, req: PaymentRequest): void;
|
|
5930
|
+
/** The inputs a request names. An EMPTY array is still a selection, covering nothing. */
|
|
5931
|
+
declare function selectionOf(req: PaymentRequest): NormalizedExtendedVirtualCoin[] | undefined;
|
|
5932
|
+
/** For a rail whose counterparty funds the spend: ignoring a named input set
|
|
5933
|
+
* would spend coins the caller had promised elsewhere, so refuse instead. */
|
|
5934
|
+
declare function assertNoSelection(railId: string, req: PaymentRequest): void;
|
|
6341
5935
|
/** Exactly one: `Wallet.send` takes a list because one output can carry
|
|
6342
5936
|
* several, but a routed PAYMENT is one thing being paid. */
|
|
6343
5937
|
declare function resolveAssetAmount(railId: string, req: PaymentRequest): Asset;
|
|
@@ -6406,23 +6000,36 @@ declare const ASSET_CARRIER_SATS = 330;
|
|
|
6406
6000
|
*/
|
|
6407
6001
|
declare function arkAssetRail(): PaymentRail;
|
|
6408
6002
|
|
|
6003
|
+
/** The canonical fee source for {@link onchainRail}: the operator's schedule, as
|
|
6004
|
+
* the wallet already reads it. Keeps the one `arkProvider` reach in one place,
|
|
6005
|
+
* so an app registering the rail itself need not know where fees live. */
|
|
6006
|
+
declare const walletFeeSource: (wallet: Wallet) => () => Promise<FeeInfo>;
|
|
6409
6007
|
/**
|
|
6410
6008
|
* On-chain BTC send via collaborative exit — the Wallet-only on-chain path (no
|
|
6411
6009
|
* swap). Matches a bare BTC address or the on-chain part of a unified BIP21 URI
|
|
6412
6010
|
* and offboards VTXOs to the address via {@link Ramps.offboard}, which owns
|
|
6413
6011
|
* fee-aware coin selection, dust-safe change, and settlement.
|
|
6414
6012
|
*
|
|
6415
|
-
*
|
|
6416
|
-
* the
|
|
6417
|
-
*
|
|
6418
|
-
*
|
|
6419
|
-
*
|
|
6420
|
-
*
|
|
6013
|
+
* The exit fee is priced on the DESTINATION output — the one arkd charges for —
|
|
6014
|
+
* and met from the balance, so the recipient receives exactly `quote.amount`
|
|
6015
|
+
* (see {@link RouteQuote}). {@link Ramps.offboardExact} carries that; the
|
|
6016
|
+
* gross-up this rail used to do could only approximate it.
|
|
6017
|
+
*
|
|
6018
|
+
* A request naming `selectedVtxos` offboards exactly those — so the exit need not
|
|
6019
|
+
* sweep the whole off-chain balance into one change output — and only then does
|
|
6020
|
+
* the quote carry the per-input intent fees: unselected, the coins are chosen
|
|
6021
|
+
* later at settlement and there is nothing here to price.
|
|
6421
6022
|
*
|
|
6422
6023
|
* An explicit amount is mandatory. To sweep the full balance, call
|
|
6423
6024
|
* `Ramps.offboard(address, feeInfo)` directly — the router has no amountless path.
|
|
6025
|
+
*
|
|
6026
|
+
* @param deps.feeInfo - Source of the operator's fee schedule. Required: a rail
|
|
6027
|
+
* that cannot price an offboard must not be constructible — a silently dropped
|
|
6028
|
+
* rail on the money path is worse than a wiring error at startup.
|
|
6424
6029
|
*/
|
|
6425
|
-
declare function onchainRail(
|
|
6030
|
+
declare function onchainRail(deps: {
|
|
6031
|
+
feeInfo: () => Promise<FeeInfo>;
|
|
6032
|
+
}): PaymentRail;
|
|
6426
6033
|
|
|
6427
6034
|
/**
|
|
6428
6035
|
* Default payment router with the Wallet-only rails: `ark` (off-chain BTC send),
|
|
@@ -6481,9 +6088,7 @@ declare function sequenceToTimelock(sequence: number): RelativeTimelock;
|
|
|
6481
6088
|
declare function toXOnly(key: Uint8Array, label?: string): Uint8Array;
|
|
6482
6089
|
|
|
6483
6090
|
declare const buildVersion = "0.9.9";
|
|
6484
|
-
/**
|
|
6485
|
-
* The SDK's own version string, sourced from package.json
|
|
6486
|
-
*/
|
|
6091
|
+
/** The SDK's own version string, sourced from package.json */
|
|
6487
6092
|
declare const sdkVersion: string;
|
|
6488
6093
|
/**
|
|
6489
6094
|
* Wraps a transport-level `fetch` rejection (DNS failure, connection refused,
|
|
@@ -6501,6 +6106,12 @@ declare class FetchError extends Error {
|
|
|
6501
6106
|
cause?: unknown;
|
|
6502
6107
|
});
|
|
6503
6108
|
}
|
|
6109
|
+
/**
|
|
6110
|
+
* Deadline for a read that carries no `AbortSignal` of its own. `fetch` has no default timeout,
|
|
6111
|
+
* so a silently dropped connection stays pending, and every retry ladder, queue or mutex built on
|
|
6112
|
+
* top of it waits with it.
|
|
6113
|
+
*/
|
|
6114
|
+
declare const READ_TIMEOUT_MS = 30000;
|
|
6504
6115
|
|
|
6505
6116
|
/**
|
|
6506
6117
|
* How long a blocked upgrade waits before the open is reported as failed.
|
|
@@ -6561,46 +6172,22 @@ interface ManagedConnection extends AsyncDisposable {
|
|
|
6561
6172
|
/**
|
|
6562
6173
|
* The open connection, opening it on first call.
|
|
6563
6174
|
*
|
|
6564
|
-
* Call
|
|
6565
|
-
*
|
|
6566
|
-
*
|
|
6567
|
-
*
|
|
6568
|
-
* after which every transaction on that handle throws `InvalidStateError`;
|
|
6569
|
-
* a later `get()` transparently reopens, but only for callers that ask
|
|
6570
|
-
* again. Holding the resolved database is exactly the defect this type
|
|
6571
|
-
* exists to remove.
|
|
6572
|
-
*
|
|
6573
|
-
* ## The dispose boundary
|
|
6175
|
+
* Call once per operation and use the handle for the transaction you start right away —
|
|
6176
|
+
* never store it or carry it across an `await`. It can be closed underneath you at any time
|
|
6177
|
+
* (`versionchange` from another tab, eviction, "clear site data"), after which every
|
|
6178
|
+
* transaction on it throws `InvalidStateError`; a later `get()` transparently reopens.
|
|
6574
6179
|
*
|
|
6575
|
-
*
|
|
6576
|
-
*
|
|
6577
|
-
*
|
|
6578
|
-
*
|
|
6579
|
-
* is no revive; construct a new repository, which constructs a new
|
|
6580
|
-
* connection, instead.
|
|
6581
|
-
*
|
|
6582
|
-
* Dispose neither awaits nor cancels work already in flight. A transaction
|
|
6583
|
-
* started just before it can abort when the underlying handle closes, and
|
|
6584
|
-
* an in-flight `get()` may resolve to a database that is closing. So
|
|
6585
|
-
* sequence disposal after the operations you care about have settled —
|
|
6586
|
-
* `await` the repository's outstanding calls first — rather than racing it
|
|
6587
|
-
* against them.
|
|
6588
|
-
*
|
|
6589
|
-
* Callers must not close the database themselves; the reference this
|
|
6590
|
-
* connection holds is released by its own dispose, once.
|
|
6180
|
+
* After `[Symbol.asyncDispose]` it rejects with {@link ConnectionDisposedError}, permanently:
|
|
6181
|
+
* reopening would take a refcount nothing releases, so construct a new repository instead.
|
|
6182
|
+
* Dispose neither awaits nor cancels in-flight work, so `await` outstanding repository calls
|
|
6183
|
+
* before disposing. Callers must not close the database themselves.
|
|
6591
6184
|
*/
|
|
6592
6185
|
get(): Promise<IDBDatabase>;
|
|
6593
6186
|
}
|
|
6594
6187
|
/**
|
|
6595
|
-
* Forget-and-reopen around {@link openDatabase}, shared by every IndexedDB
|
|
6596
|
-
*
|
|
6597
|
-
*
|
|
6598
|
-
* that handle throws `InvalidStateError` with no path back.
|
|
6599
|
-
*
|
|
6600
|
-
* Opens nothing until the first {@link ManagedConnection.get} — repositories
|
|
6601
|
-
* construct their storage in their own constructors, and an eager open would
|
|
6602
|
-
* move the "IndexedDB is not available in this environment" throw to
|
|
6603
|
-
* construction time.
|
|
6188
|
+
* Forget-and-reopen around {@link openDatabase}, shared by every IndexedDB repository: a cached
|
|
6189
|
+
* `IDBDatabase` throws `InvalidStateError` forever once the manager closes it on `versionchange`.
|
|
6190
|
+
* Lazy, so the "IndexedDB is not available" throw stays out of repository constructors.
|
|
6604
6191
|
*/
|
|
6605
6192
|
declare function createManagedConnection(dbName: string, version: number, initDatabase: (db: IDBDatabase, oldVersion: number, transaction: IDBTransaction | null) => void): ManagedConnection;
|
|
6606
6193
|
|
|
@@ -6710,4 +6297,4 @@ declare class AssetManager extends ReadonlyAssetManager implements IAssetManager
|
|
|
6710
6297
|
burn(params: BurnParams): Promise<string>;
|
|
6711
6298
|
}
|
|
6712
6299
|
|
|
6713
|
-
export { ARKADE_MAGIC, ARKADE_SALTED_PREIMAGE_TAG, ARKADE_SWAP_PREIMAGE_TAG, ASSET_CARRIER_SATS, Activity, ActivityRegistry, AddressAllocationCapable, AmbiguousRouteError, type AnchorBumper, ArkAddress,
|
|
6300
|
+
export { ARKADE_MAGIC, ARKADE_SALTED_PREIMAGE_TAG, ARKADE_SWAP_PREIMAGE_TAG, ASSET_CARRIER_SATS, Activity, ActivityRegistry, AddressAllocationCapable, AmbiguousRouteError, type AnchorBumper, ArkAddress, ArkIntent, ArkNote, ArkProvider, type ArkPsbtFieldCoder, ArkPsbtFieldKey, ArkPsbtFieldKeyType, ArkTransaction, type ArkTxInput, type ArkadeBatchInput, ArkadeBroadcaster, ArkadeCash, ArkadeContractParams, type ArkadeExtendedCoin, type ArkadeExtendedVirtualCoin, ArkadeInfo, ArkadeReader, Asset, AssetDetails, AssetManager, BIP21, BIP21Error, type BIP21Params, type BIP21ParseResult, BIP322, BLOCKED_UPGRADE_TIMEOUT_MS, Batch, BatchExpiryPolicy, BurnParams, CSVMultisigTapscript, CachingArkProvider, ChainTx, Coin, ConditionWitness, ConnectionDisposedError, type ConnectorTreeNode, Contract, ContractEvent, ContractFilter, ContractRepository, ContractSyncState, ContractWatcherConfig, ContractWithVtxos, CosignerPublicKey, CreateContractParams, DEFAULT_MESSAGE_TIMEOUTS, DatabaseUpgradeBlockedError, DefaultVtxo, DelegateInfo, DelegateNotConfiguredError, DescriptorIdentity, type DescriptorIdentityOptions, type DescriptorOptions, DescriptorProvider, type DescriptorSigner, DescriptorSigningProviderMissingError, DescriptorSigningRequest, type DeterministicSigner, DustChangeError, ELECTRUM_TCP_HOST, ELECTRUM_WS_URL, type BlockHeader as ElectrumBlockHeader, ElectrumOnchainProvider, type TransactionHistory as ElectrumTransactionHistory, type Unspent as ElectrumUnspent, type EmulatorEntry, type EmulatorInfo, EmulatorPacket, type EmulatorProvider, EncodedVtxoScript, Estimator, type ExcludableVtxo, type ExecutorEvent, type ExecutorOptions, type ExitDelay, type ExitFeeWallet, type ExitMode, type ExitOptions, type ExitPackage, type ExitQuote, type ExitStep, type ExitTotals, type ExitVtxoInfo, ExplorerTransaction, ExtendedCoin, ExtendedVirtualCoin, Extension, ExtensionNotFoundError, type ExtensionPacket, FeeAmount, FeeInfo, FeeOutput, FetchError, GetArkadeInfoOptions, GetNewAddressesOptions, GetSpendableVtxosFilter, GetVtxosFilter, GetVtxosOptions, HDAllocationCapable, HDDescriptorProvider, type HDDeterministicSignCapable, HDWalletCapable, IAssetManager, IContractManager, IDelegateManager, IReadonlyAssetManager, IReadonlyWallet, IVtxoManager, IWallet, Identity, InMemoryContractRepository, InMemoryIntentRepository, InMemoryVirtualTxRepository, InMemoryWalletRepository, IndexedDBContractRepository, IndexedDBIntentRepository, IndexedDBVirtualTxRepository, IndexerProvider, Intent, IntentFeeConfig, IntentPageFilter, IntentRepository, IssuanceParams, IssuanceResult, MESSAGE_BUS_INITIALIZING, MESSAGE_BUS_NOT_INITIALIZED, type ManagedConnection, MessageBus, MessageBusInitializingError, MessageBusNotInitializedError, type MessageHandler, type MessageTimeouts, MigrationGlobalSkipReason, MigrationLegSkipReason, MissingSigningDescriptorError, MnemonicIdentity, type MnemonicOptions, Network, NetworkName, type NetworkOptions, NewAddress, NormalizedExtendedVirtualCoin, NormalizedVtxoPage, OffchainInput, type OffchainTx, type OnExitObserved, OnchainInput, OnchainProvider, OnchainWallet, Outpoint, OversizedChangeError, P2A, PageRequest, PageResult, PaginationOptions, type ParsedArkContract, PathContext, PathSelection, type PaymentHandle, type PaymentOption, type PaymentRail, type PaymentRequest, PaymentRouter, type PaymentStatus, PrevArkTxField, PrevoutTxField, ProviderConnectionState, type ProvisionedClaimSecret, type ProvisionedKey, READ_TIMEOUT_MS, Ramps, ReadonlyAssetManager, ReadonlyDescriptorIdentity, ReadonlyIdentity, ReadonlySingleKey, ReadonlyWallet, ReadonlyWalletError, Recipient, ReissuanceParams, RelativeTimelock, RenewVtxosOptions, type RequestEnvelope, type ResponseEnvelope, RestEmulatorProvider, type RouteQuote, type RouteResult, type RouterContext, type RouterPreferences, ScriptVtxoCursor, ScriptVtxoPageOptions, SeedIdentity, type SeedIdentityOptions, SendBitcoinParams, SendParams, ServiceWorkerReadonlyWallet, ServiceWorkerTimeoutError, ServiceWorkerWallet, type ServiceWorkerWalletMode, SettleParams, SettlementConfig, SettlementEvent, SignedIntent, SignerSession, SignerStatus, SingleKey, StaticDescriptorProvider, Status, StorageConfig, StoredVtxo, TapLeafScript, Transaction, TransactionHistoryPageCursor, TransactionHistoryPageFilter, TreeNonces, TreePartialSigs, TxNotificationEvent, TxTree, TxWeightEstimator, UnannotatableInputError, UnilateralExit, UnknownPacket, Unroll, type VSize, type VerifyServerSignatures, VirtualCoin, VirtualTx, VirtualTxRepository, VtxoBranch, type VtxoExclusion, VtxoScript, VtxoTaprootTree, VtxoTreeExpiry, Wallet, WalletBalance, WalletCannotSignError, WalletMessageHandler, WalletNotInitializedError, WalletRepository, type WalletRestoreHook, WatchedScript, WsElectrumChainSource, adoptContractDescriptor, arkAssetRail, arkRail, arkTarget, index as arkade, assembleBtcdTaprootTree, assertFinalCommitmentMatchesValidated, assertNoAssets, assertNoSelection, assertNonNegativeMs, assertSendableAmount, assertSubmittedArkTxid, assertTimerMs, index$1 as asset, assetsOf, awaitTransaction, btcTarget, buildForfeitTx, buildOffchainTx, buildPreimageMessage, buildSaltedPreimageMessage, buildVersion, claimWithPreimageIdentity, closeDatabase, combineTapscriptSigs, contractFromArkContract, contractFromArkContractWithAddress, contractPreimage, contractSigner, createAssetPacket, createDefaultPaymentRouter, createManagedConnection, decodeArkContract, deleteByIndex, deriveDescriptorLeafCompressedPubKey, deriveDescriptorLeafPubKey, deserializeExitPackage, encodeArkContract, exitObserverFor, gateExclusion, gatedContracts, getAllByIndexValues, getArkPsbtFields, hasBoardingTxExpired, identityDescriptor, invoiceTarget, isArkContract, isBtcAddress, isCltvSatisfied, isContractGenericallySpendable, isCsvSpendable, isDeterministicSigner, isHDDeterministicSignCapable, isLightningInvoice, isLnurl, isMessageBusInitializingError, isMessageBusNotInitializedError, isPerArtifactDescriptor, isRetryableProviderError, isValidArkAddress, logExcludedVtxos, makeHandle, matchServerCheckpoints, normalizeToDescriptor, notifyExitObserved, onchainRail, openDatabase, outpointExclusion, outpointReasons, parseHDDescriptor, promisifyRequest, provisionClaimSecret, provisionRefundKey, registerWalletRestoreHook, resolveAssetAmount, resolveSendAmount, sdkVersion, selectCoinsWithAsset, selectionOf, sequenceToTimelock, serializeExitPackage, setArkPsbtField, setupServiceWorker, signAndSubmitOffchainTx, timelockToSequence, toXOnly, tryResolveSendAmount, validateBatchRecipients, validateConnectorsTxGraph, validateVtxoTxGraph, verifyTapscriptSignatures, walletFeeSource };
|