@arkade-os/sdk 0.4.29 → 0.4.31

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.
Files changed (53) hide show
  1. package/dist/adapters/expo.d.cts +2 -2
  2. package/dist/adapters/expo.d.ts +2 -2
  3. package/dist/adapters/indexedDB.cjs +2 -2
  4. package/dist/adapters/indexedDB.js +1 -1
  5. package/dist/{ark-ChhTwpLf.d.cts → ark-ibLW4Hte.d.cts} +20 -3
  6. package/dist/{ark-ChhTwpLf.d.ts → ark-ibLW4Hte.d.ts} +20 -3
  7. package/dist/{asyncStorageTaskQueue-DZ0nUuEJ.d.ts → asyncStorageTaskQueue-BEOFPNc0.d.ts} +1 -1
  8. package/dist/{asyncStorageTaskQueue-DW1-BpI7.d.cts → asyncStorageTaskQueue-VGHXWR9F.d.cts} +1 -1
  9. package/dist/{chunk-TH6T23XG.js → chunk-AXGVYRAL.js} +3 -3
  10. package/dist/{chunk-TH6T23XG.js.map → chunk-AXGVYRAL.js.map} +1 -1
  11. package/dist/{chunk-GDCTOSMV.cjs → chunk-GPZH5QNA.cjs} +63 -12
  12. package/dist/chunk-GPZH5QNA.cjs.map +1 -0
  13. package/dist/{chunk-BVP2U66Q.js → chunk-HJM6JPG4.js} +63 -12
  14. package/dist/chunk-HJM6JPG4.js.map +1 -0
  15. package/dist/{chunk-PJUFOJ2L.cjs → chunk-RN2OFLC3.cjs} +7 -7
  16. package/dist/{chunk-PJUFOJ2L.cjs.map → chunk-RN2OFLC3.cjs.map} +1 -1
  17. package/dist/contracts/handlers/index.d.cts +3 -3
  18. package/dist/contracts/handlers/index.d.ts +3 -3
  19. package/dist/{delegate-DN7RELL1.d.ts → delegate-BXaR1RNG.d.ts} +1 -1
  20. package/dist/{delegate-4JBUkUhR.d.cts → delegate-BvNTw44a.d.cts} +1 -1
  21. package/dist/{index-Cn82bBUu.d.ts → index-BusKawmy.d.ts} +2 -2
  22. package/dist/{index-DfT5xzgY.d.cts → index-C-5Tw7VA.d.cts} +2 -2
  23. package/dist/index.cjs +86 -86
  24. package/dist/index.d.cts +8 -7
  25. package/dist/index.d.ts +8 -7
  26. package/dist/index.js +1 -1
  27. package/dist/repositories/realm/index.cjs +10 -10
  28. package/dist/repositories/realm/index.d.cts +2 -2
  29. package/dist/repositories/realm/index.d.ts +2 -2
  30. package/dist/repositories/realm/index.js +1 -1
  31. package/dist/repositories/sqlite/index.cjs +10 -10
  32. package/dist/repositories/sqlite/index.d.cts +1 -1
  33. package/dist/repositories/sqlite/index.d.ts +1 -1
  34. package/dist/repositories/sqlite/index.js +1 -1
  35. package/dist/{taskRunner-B-vG08pX.d.ts → taskRunner-B1igKGAo.d.ts} +1 -1
  36. package/dist/{taskRunner-B-aPfHhK.d.cts → taskRunner-By92TQ1m.d.cts} +1 -1
  37. package/dist/wallet/expo/background.cjs +8 -8
  38. package/dist/wallet/expo/background.d.cts +3 -3
  39. package/dist/wallet/expo/background.d.ts +3 -3
  40. package/dist/wallet/expo/background.js +2 -2
  41. package/dist/wallet/expo/index.cjs +9 -9
  42. package/dist/wallet/expo/index.d.cts +4 -4
  43. package/dist/wallet/expo/index.d.ts +4 -4
  44. package/dist/wallet/expo/index.js +2 -2
  45. package/dist/{wallet-DjgFb_4T.d.cts → wallet-B_rxgQTu.d.cts} +2 -2
  46. package/dist/{wallet-CCtqT2Wb.d.ts → wallet-CyM4F7Bs.d.ts} +2 -2
  47. package/dist/worker/expo/index.cjs +6 -6
  48. package/dist/worker/expo/index.d.cts +4 -4
  49. package/dist/worker/expo/index.d.ts +4 -4
  50. package/dist/worker/expo/index.js +2 -2
  51. package/package.json +1 -1
  52. package/dist/chunk-BVP2U66Q.js.map +0 -1
  53. package/dist/chunk-GDCTOSMV.cjs.map +0 -1
@@ -1,5 +1,5 @@
1
- import { j as RestArkProvider, h as SettlementEvent, T as TxNotification, k as RestIndexerProvider, l as SubscriptionResponse } from '../ark-ChhTwpLf.cjs';
2
- export { m as ArkProvider, n as IndexerProvider } from '../ark-ChhTwpLf.cjs';
1
+ import { j as RestArkProvider, h as SettlementEvent, T as TxNotification, k as RestIndexerProvider, l as SubscriptionResponse } from '../ark-ibLW4Hte.cjs';
2
+ export { m as ArkProvider, n as IndexerProvider } from '../ark-ibLW4Hte.cjs';
3
3
  import '@scure/btc-signer/transaction.js';
4
4
  import '@scure/btc-signer/utils.js';
5
5
  import '@scure/btc-signer/psbt.js';
@@ -1,5 +1,5 @@
1
- import { j as RestArkProvider, h as SettlementEvent, T as TxNotification, k as RestIndexerProvider, l as SubscriptionResponse } from '../ark-ChhTwpLf.js';
2
- export { m as ArkProvider, n as IndexerProvider } from '../ark-ChhTwpLf.js';
1
+ import { j as RestArkProvider, h as SettlementEvent, T as TxNotification, k as RestIndexerProvider, l as SubscriptionResponse } from '../ark-ibLW4Hte.js';
2
+ export { m as ArkProvider, n as IndexerProvider } from '../ark-ibLW4Hte.js';
3
3
  import '@scure/btc-signer/transaction.js';
4
4
  import '@scure/btc-signer/utils.js';
5
5
  import '@scure/btc-signer/psbt.js';
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkGDCTOSMV_cjs = require('../chunk-GDCTOSMV.cjs');
3
+ var chunkGPZH5QNA_cjs = require('../chunk-GPZH5QNA.cjs');
4
4
  require('../chunk-6FLL2Q36.cjs');
5
5
  require('../chunk-IEO3XDKI.cjs');
6
6
  require('../chunk-WMIPYZSB.cjs');
@@ -11,7 +11,7 @@ var IndexedDBStorageAdapter = class {
11
11
  dbName;
12
12
  version;
13
13
  db = null;
14
- constructor(dbName, version = chunkGDCTOSMV_cjs.DB_VERSION) {
14
+ constructor(dbName, version = chunkGPZH5QNA_cjs.DB_VERSION) {
15
15
  this.dbName = dbName;
16
16
  this.version = version;
17
17
  }
@@ -1,4 +1,4 @@
1
- import { DB_VERSION } from '../chunk-BVP2U66Q.js';
1
+ import { DB_VERSION } from '../chunk-HJM6JPG4.js';
2
2
  import '../chunk-6NWNOLL3.js';
3
3
  import '../chunk-YA4G7RFB.js';
4
4
  import '../chunk-TU3LVAPX.js';
@@ -608,6 +608,19 @@ interface SettlementConfig {
608
608
  * @returns true if virtual output expires within threshold, false otherwise
609
609
  */
610
610
  declare function isVtxoExpiringSoon(vtxo: ExtendedVirtualCoin, thresholdMs: number): boolean;
611
+ /**
612
+ * Optional arguments for {@link IVtxoManager.renewVtxos}.
613
+ */
614
+ interface RenewVtxosOptions {
615
+ /**
616
+ * Override the renewal threshold for this call only, in seconds.
617
+ *
618
+ * When provided, takes precedence over `SettlementConfig.vtxoThreshold`
619
+ * and the default (3 days). Useful for renewing only VTXOs that are
620
+ * more urgently expiring than the globally configured threshold.
621
+ */
622
+ thresholdSeconds?: number;
623
+ }
611
624
  /**
612
625
  * VtxoManager is a unified class for managing virtual output lifecycle operations including
613
626
  * recovery of swept/expired virtual outputs and renewal to prevent expiration.
@@ -662,7 +675,7 @@ interface IVtxoManager {
662
675
  vtxoCount: number;
663
676
  }>;
664
677
  getExpiringVtxos(thresholdMs?: number): Promise<ExtendedVirtualCoin[]>;
665
- renewVtxos(eventCallback?: (event: SettlementEvent) => void): Promise<string>;
678
+ renewVtxos(eventCallback?: (event: SettlementEvent) => void, options?: RenewVtxosOptions): Promise<string>;
666
679
  getExpiredBoardingUtxos(): Promise<ExtendedCoin[]>;
667
680
  sweepExpiredBoardingUtxos(): Promise<string>;
668
681
  dispose(): Promise<void>;
@@ -784,6 +797,7 @@ declare class VtxoManager implements AsyncDisposable, IVtxoManager {
784
797
  * primary way to prevent virtual outputs from expiring.
785
798
  *
786
799
  * @param eventCallback - Optional callback for settlement events
800
+ * @param options - Optional per-call overrides; see {@link RenewVtxosOptions}
787
801
  * @returns Settlement transaction ID
788
802
  * @throws Error if no virtual outputs available to renew
789
803
  * @throws Error if total amount is below dust threshold
@@ -799,9 +813,12 @@ declare class VtxoManager implements AsyncDisposable, IVtxoManager {
799
813
  * const txid = await manager.renewVtxos((event) => {
800
814
  * console.log('Settlement event:', event.type);
801
815
  * });
816
+ *
817
+ * // Renew only VTXOs that expire within 6 hours
818
+ * const txid = await manager.renewVtxos(undefined, { thresholdSeconds: 6 * 60 * 60 });
802
819
  * ```
803
820
  */
804
- renewVtxos(eventCallback?: (event: SettlementEvent) => void): Promise<string>;
821
+ renewVtxos(eventCallback?: (event: SettlementEvent) => void, options?: RenewVtxosOptions): Promise<string>;
805
822
  /**
806
823
  * Get boarding inputs whose timelock has expired.
807
824
  *
@@ -3889,4 +3906,4 @@ declare namespace ProtoTypes {
3889
3906
  export { };
3890
3907
  }
3891
3908
 
3892
- export { CSVMultisigTapscript as $, type ArkTransaction as A, type BatchStartedEvent as B, type ContractRepository as C, type BatchFailedEvent as D, type ExtendedVirtualCoin as E, type TreeTxEvent as F, type GetVtxosFilter as G, type TreeSignatureEvent as H, type IWallet as I, type DescriptorProvider as J, type IReadonlyWallet as K, type ReadonlyIdentity as L, type DelegateProvider as M, type Network as N, type OnchainProvider as O, type ReadonlyWalletConfig as P, type IReadonlyAssetManager as Q, type Recipient as R, type SendBitcoinParams as S, type TxNotification as T, type NetworkName as U, VtxoScript as V, type WalletRepository as W, type ArkInfo as X, ArkAddress as Y, type Coin as Z, ContractManager as _, type Identity as a, type IDelegatorManager as a$, type SettlementConfig as a0, VtxoManager as a1, type SignerSession as a2, type SignedIntent as a3, Intent as a4, type DescriptorSigningRequest as a5, Transaction as a6, type IntentFeeConfig as a7, type OffchainInput as a8, FeeAmount as a9, type AssetMetadata as aA, type BaseWalletConfig as aB, type BatchInfo as aC, type BatchSignableIdentity as aD, CLTVMultisigTapscript as aE, ChainTxType as aF, type CommitmentTx as aG, ConditionCSVMultisigTapscript as aH, ConditionMultisigTapscript as aI, type ContractBalance as aJ, type ContractEventCallback as aK, type ContractHandler as aL, type ContractManagerConfig as aM, type ContractState as aN, type ContractVtxo as aO, ContractWatcher as aP, DelegateManagerImpl as aQ, type DelegateOptions as aR, DelegatorManagerImpl as aS, type DelegatorProvider as aT, type Discoverable as aU, type DiscoveredContract as aV, type DiscoveryDeps as aW, ESPLORA_URL as aX, EsploraProvider as aY, type ExtendedContractVtxo as aZ, type HandlerError as a_, type OnchainInput as aa, type FeeOutput as ab, type ContractWatcherConfig as ac, type FeeInfo as ad, type CreateContractParams as ae, type GetContractsFilter as af, type GetSpendablePathsOptions as ag, type GetAllSpendingPathsOptions as ah, type IssuanceParams as ai, type ReissuanceParams as aj, type BurnParams as ak, type ContractWithVtxos as al, type PathSelection as am, type ContractEvent as an, type AssetDetails as ao, type IssuanceResult as ap, type DelegateInfo as aq, type StorageConfig as ar, type IVtxoManager as as, type ExplorerTransaction as at, type EncodedVtxoScript as au, type Status as av, type Outpoint as aw, type ChainTx as ax, type ArkTapscript as ay, type Asset as az, type WalletConfig as b, IndexerTxType as b0, type KnownMetadata as b1, MultisigTapscript as b2, type Nonces as b3, type Output as b4, type PageResponse as b5, type PaginationOptions as b6, PartialSig as b7, type PathContext as b8, type ProviderClass as b9, isBatchSignable as bA, isDiscoverable as bB, isExpired as bC, isRecoverable as bD, isSpendable as bE, isSubdust as bF, isVtxoExpiringSoon as bG, networks as bH, RestDelegateProvider as ba, RestDelegatorProvider as bb, type ScanContractsOptions as bc, type ScanResult as bd, type ScheduledSession as be, SettlementEventType as bf, type SignRequest as bg, type SubscriptionEvent as bh, type SubscriptionHeartbeat as bi, type TapLeaves as bj, TapTreeCoder as bk, TapscriptType as bl, type TreeNonces as bm, type TreePartialSigs as bn, type Tx as bo, type TxHistoryRecord as bp, type TxKey as bq, type TxTreeNode as br, TxType as bs, type VirtualStatus as bt, type Vtxo as bu, type VtxoChain as bv, type VtxoType as bw, type WalletMode as bx, decodeTapscript as by, getSequence as bz, type WalletBalance as c, type ExtendedCoin as d, type IContractManager as e, type IDelegateManager as f, type SettleParams as g, type SettlementEvent as h, type IAssetManager as i, RestArkProvider as j, RestIndexerProvider as k, type SubscriptionResponse as l, type ArkProvider as m, type IndexerProvider as n, type RelativeTimelock as o, type TapLeafScript as p, type VirtualCoin as q, type Contract as r, type VtxoRepositoryKey as s, type WalletState as t, type ContractFilter as u, type TreeSigningStartedEvent as v, TxTree as w, type TreeNoncesEvent as x, type BatchFinalizationEvent as y, type BatchFinalizedEvent as z };
3909
+ export { CSVMultisigTapscript as $, type ArkTransaction as A, type BatchStartedEvent as B, type ContractRepository as C, type BatchFailedEvent as D, type ExtendedVirtualCoin as E, type TreeTxEvent as F, type GetVtxosFilter as G, type TreeSignatureEvent as H, type IWallet as I, type DescriptorProvider as J, type IReadonlyWallet as K, type ReadonlyIdentity as L, type DelegateProvider as M, type Network as N, type OnchainProvider as O, type ReadonlyWalletConfig as P, type IReadonlyAssetManager as Q, type Recipient as R, type SendBitcoinParams as S, type TxNotification as T, type NetworkName as U, VtxoScript as V, type WalletRepository as W, type ArkInfo as X, ArkAddress as Y, type Coin as Z, ContractManager as _, type Identity as a, type HandlerError as a$, type SettlementConfig as a0, VtxoManager as a1, type SignerSession as a2, type SignedIntent as a3, Intent as a4, type DescriptorSigningRequest as a5, Transaction as a6, type IntentFeeConfig as a7, type OffchainInput as a8, FeeAmount as a9, type Asset as aA, type AssetMetadata as aB, type BaseWalletConfig as aC, type BatchInfo as aD, type BatchSignableIdentity as aE, CLTVMultisigTapscript as aF, ChainTxType as aG, type CommitmentTx as aH, ConditionCSVMultisigTapscript as aI, ConditionMultisigTapscript as aJ, type ContractBalance as aK, type ContractEventCallback as aL, type ContractHandler as aM, type ContractManagerConfig as aN, type ContractState as aO, type ContractVtxo as aP, ContractWatcher as aQ, DelegateManagerImpl as aR, type DelegateOptions as aS, DelegatorManagerImpl as aT, type DelegatorProvider as aU, type Discoverable as aV, type DiscoveredContract as aW, type DiscoveryDeps as aX, ESPLORA_URL as aY, EsploraProvider as aZ, type ExtendedContractVtxo as a_, type OnchainInput as aa, type FeeOutput as ab, type ContractWatcherConfig as ac, type FeeInfo as ad, type CreateContractParams as ae, type GetContractsFilter as af, type GetSpendablePathsOptions as ag, type GetAllSpendingPathsOptions as ah, type IssuanceParams as ai, type ReissuanceParams as aj, type BurnParams as ak, type RenewVtxosOptions as al, type ContractWithVtxos as am, type PathSelection as an, type ContractEvent as ao, type AssetDetails as ap, type IssuanceResult as aq, type DelegateInfo as ar, type StorageConfig as as, type IVtxoManager as at, type ExplorerTransaction as au, type EncodedVtxoScript as av, type Status as aw, type Outpoint as ax, type ChainTx as ay, type ArkTapscript as az, type WalletConfig as b, type IDelegatorManager as b0, IndexerTxType as b1, type KnownMetadata as b2, MultisigTapscript as b3, type Nonces as b4, type Output as b5, type PageResponse as b6, type PaginationOptions as b7, PartialSig as b8, type PathContext as b9, getSequence as bA, isBatchSignable as bB, isDiscoverable as bC, isExpired as bD, isRecoverable as bE, isSpendable as bF, isSubdust as bG, isVtxoExpiringSoon as bH, networks as bI, type ProviderClass as ba, RestDelegateProvider as bb, RestDelegatorProvider as bc, type ScanContractsOptions as bd, type ScanResult as be, type ScheduledSession as bf, SettlementEventType as bg, type SignRequest as bh, type SubscriptionEvent as bi, type SubscriptionHeartbeat as bj, type TapLeaves as bk, TapTreeCoder as bl, TapscriptType as bm, type TreeNonces as bn, type TreePartialSigs as bo, type Tx as bp, type TxHistoryRecord as bq, type TxKey as br, type TxTreeNode as bs, TxType as bt, type VirtualStatus as bu, type Vtxo as bv, type VtxoChain as bw, type VtxoType as bx, type WalletMode as by, decodeTapscript as bz, type WalletBalance as c, type ExtendedCoin as d, type IContractManager as e, type IDelegateManager as f, type SettleParams as g, type SettlementEvent as h, type IAssetManager as i, RestArkProvider as j, RestIndexerProvider as k, type SubscriptionResponse as l, type ArkProvider as m, type IndexerProvider as n, type RelativeTimelock as o, type TapLeafScript as p, type VirtualCoin as q, type Contract as r, type VtxoRepositoryKey as s, type WalletState as t, type ContractFilter as u, type TreeSigningStartedEvent as v, TxTree as w, type TreeNoncesEvent as x, type BatchFinalizationEvent as y, type BatchFinalizedEvent as z };
@@ -608,6 +608,19 @@ interface SettlementConfig {
608
608
  * @returns true if virtual output expires within threshold, false otherwise
609
609
  */
610
610
  declare function isVtxoExpiringSoon(vtxo: ExtendedVirtualCoin, thresholdMs: number): boolean;
611
+ /**
612
+ * Optional arguments for {@link IVtxoManager.renewVtxos}.
613
+ */
614
+ interface RenewVtxosOptions {
615
+ /**
616
+ * Override the renewal threshold for this call only, in seconds.
617
+ *
618
+ * When provided, takes precedence over `SettlementConfig.vtxoThreshold`
619
+ * and the default (3 days). Useful for renewing only VTXOs that are
620
+ * more urgently expiring than the globally configured threshold.
621
+ */
622
+ thresholdSeconds?: number;
623
+ }
611
624
  /**
612
625
  * VtxoManager is a unified class for managing virtual output lifecycle operations including
613
626
  * recovery of swept/expired virtual outputs and renewal to prevent expiration.
@@ -662,7 +675,7 @@ interface IVtxoManager {
662
675
  vtxoCount: number;
663
676
  }>;
664
677
  getExpiringVtxos(thresholdMs?: number): Promise<ExtendedVirtualCoin[]>;
665
- renewVtxos(eventCallback?: (event: SettlementEvent) => void): Promise<string>;
678
+ renewVtxos(eventCallback?: (event: SettlementEvent) => void, options?: RenewVtxosOptions): Promise<string>;
666
679
  getExpiredBoardingUtxos(): Promise<ExtendedCoin[]>;
667
680
  sweepExpiredBoardingUtxos(): Promise<string>;
668
681
  dispose(): Promise<void>;
@@ -784,6 +797,7 @@ declare class VtxoManager implements AsyncDisposable, IVtxoManager {
784
797
  * primary way to prevent virtual outputs from expiring.
785
798
  *
786
799
  * @param eventCallback - Optional callback for settlement events
800
+ * @param options - Optional per-call overrides; see {@link RenewVtxosOptions}
787
801
  * @returns Settlement transaction ID
788
802
  * @throws Error if no virtual outputs available to renew
789
803
  * @throws Error if total amount is below dust threshold
@@ -799,9 +813,12 @@ declare class VtxoManager implements AsyncDisposable, IVtxoManager {
799
813
  * const txid = await manager.renewVtxos((event) => {
800
814
  * console.log('Settlement event:', event.type);
801
815
  * });
816
+ *
817
+ * // Renew only VTXOs that expire within 6 hours
818
+ * const txid = await manager.renewVtxos(undefined, { thresholdSeconds: 6 * 60 * 60 });
802
819
  * ```
803
820
  */
804
- renewVtxos(eventCallback?: (event: SettlementEvent) => void): Promise<string>;
821
+ renewVtxos(eventCallback?: (event: SettlementEvent) => void, options?: RenewVtxosOptions): Promise<string>;
805
822
  /**
806
823
  * Get boarding inputs whose timelock has expired.
807
824
  *
@@ -3889,4 +3906,4 @@ declare namespace ProtoTypes {
3889
3906
  export { };
3890
3907
  }
3891
3908
 
3892
- export { CSVMultisigTapscript as $, type ArkTransaction as A, type BatchStartedEvent as B, type ContractRepository as C, type BatchFailedEvent as D, type ExtendedVirtualCoin as E, type TreeTxEvent as F, type GetVtxosFilter as G, type TreeSignatureEvent as H, type IWallet as I, type DescriptorProvider as J, type IReadonlyWallet as K, type ReadonlyIdentity as L, type DelegateProvider as M, type Network as N, type OnchainProvider as O, type ReadonlyWalletConfig as P, type IReadonlyAssetManager as Q, type Recipient as R, type SendBitcoinParams as S, type TxNotification as T, type NetworkName as U, VtxoScript as V, type WalletRepository as W, type ArkInfo as X, ArkAddress as Y, type Coin as Z, ContractManager as _, type Identity as a, type IDelegatorManager as a$, type SettlementConfig as a0, VtxoManager as a1, type SignerSession as a2, type SignedIntent as a3, Intent as a4, type DescriptorSigningRequest as a5, Transaction as a6, type IntentFeeConfig as a7, type OffchainInput as a8, FeeAmount as a9, type AssetMetadata as aA, type BaseWalletConfig as aB, type BatchInfo as aC, type BatchSignableIdentity as aD, CLTVMultisigTapscript as aE, ChainTxType as aF, type CommitmentTx as aG, ConditionCSVMultisigTapscript as aH, ConditionMultisigTapscript as aI, type ContractBalance as aJ, type ContractEventCallback as aK, type ContractHandler as aL, type ContractManagerConfig as aM, type ContractState as aN, type ContractVtxo as aO, ContractWatcher as aP, DelegateManagerImpl as aQ, type DelegateOptions as aR, DelegatorManagerImpl as aS, type DelegatorProvider as aT, type Discoverable as aU, type DiscoveredContract as aV, type DiscoveryDeps as aW, ESPLORA_URL as aX, EsploraProvider as aY, type ExtendedContractVtxo as aZ, type HandlerError as a_, type OnchainInput as aa, type FeeOutput as ab, type ContractWatcherConfig as ac, type FeeInfo as ad, type CreateContractParams as ae, type GetContractsFilter as af, type GetSpendablePathsOptions as ag, type GetAllSpendingPathsOptions as ah, type IssuanceParams as ai, type ReissuanceParams as aj, type BurnParams as ak, type ContractWithVtxos as al, type PathSelection as am, type ContractEvent as an, type AssetDetails as ao, type IssuanceResult as ap, type DelegateInfo as aq, type StorageConfig as ar, type IVtxoManager as as, type ExplorerTransaction as at, type EncodedVtxoScript as au, type Status as av, type Outpoint as aw, type ChainTx as ax, type ArkTapscript as ay, type Asset as az, type WalletConfig as b, IndexerTxType as b0, type KnownMetadata as b1, MultisigTapscript as b2, type Nonces as b3, type Output as b4, type PageResponse as b5, type PaginationOptions as b6, PartialSig as b7, type PathContext as b8, type ProviderClass as b9, isBatchSignable as bA, isDiscoverable as bB, isExpired as bC, isRecoverable as bD, isSpendable as bE, isSubdust as bF, isVtxoExpiringSoon as bG, networks as bH, RestDelegateProvider as ba, RestDelegatorProvider as bb, type ScanContractsOptions as bc, type ScanResult as bd, type ScheduledSession as be, SettlementEventType as bf, type SignRequest as bg, type SubscriptionEvent as bh, type SubscriptionHeartbeat as bi, type TapLeaves as bj, TapTreeCoder as bk, TapscriptType as bl, type TreeNonces as bm, type TreePartialSigs as bn, type Tx as bo, type TxHistoryRecord as bp, type TxKey as bq, type TxTreeNode as br, TxType as bs, type VirtualStatus as bt, type Vtxo as bu, type VtxoChain as bv, type VtxoType as bw, type WalletMode as bx, decodeTapscript as by, getSequence as bz, type WalletBalance as c, type ExtendedCoin as d, type IContractManager as e, type IDelegateManager as f, type SettleParams as g, type SettlementEvent as h, type IAssetManager as i, RestArkProvider as j, RestIndexerProvider as k, type SubscriptionResponse as l, type ArkProvider as m, type IndexerProvider as n, type RelativeTimelock as o, type TapLeafScript as p, type VirtualCoin as q, type Contract as r, type VtxoRepositoryKey as s, type WalletState as t, type ContractFilter as u, type TreeSigningStartedEvent as v, TxTree as w, type TreeNoncesEvent as x, type BatchFinalizationEvent as y, type BatchFinalizedEvent as z };
3909
+ export { CSVMultisigTapscript as $, type ArkTransaction as A, type BatchStartedEvent as B, type ContractRepository as C, type BatchFailedEvent as D, type ExtendedVirtualCoin as E, type TreeTxEvent as F, type GetVtxosFilter as G, type TreeSignatureEvent as H, type IWallet as I, type DescriptorProvider as J, type IReadonlyWallet as K, type ReadonlyIdentity as L, type DelegateProvider as M, type Network as N, type OnchainProvider as O, type ReadonlyWalletConfig as P, type IReadonlyAssetManager as Q, type Recipient as R, type SendBitcoinParams as S, type TxNotification as T, type NetworkName as U, VtxoScript as V, type WalletRepository as W, type ArkInfo as X, ArkAddress as Y, type Coin as Z, ContractManager as _, type Identity as a, type HandlerError as a$, type SettlementConfig as a0, VtxoManager as a1, type SignerSession as a2, type SignedIntent as a3, Intent as a4, type DescriptorSigningRequest as a5, Transaction as a6, type IntentFeeConfig as a7, type OffchainInput as a8, FeeAmount as a9, type Asset as aA, type AssetMetadata as aB, type BaseWalletConfig as aC, type BatchInfo as aD, type BatchSignableIdentity as aE, CLTVMultisigTapscript as aF, ChainTxType as aG, type CommitmentTx as aH, ConditionCSVMultisigTapscript as aI, ConditionMultisigTapscript as aJ, type ContractBalance as aK, type ContractEventCallback as aL, type ContractHandler as aM, type ContractManagerConfig as aN, type ContractState as aO, type ContractVtxo as aP, ContractWatcher as aQ, DelegateManagerImpl as aR, type DelegateOptions as aS, DelegatorManagerImpl as aT, type DelegatorProvider as aU, type Discoverable as aV, type DiscoveredContract as aW, type DiscoveryDeps as aX, ESPLORA_URL as aY, EsploraProvider as aZ, type ExtendedContractVtxo as a_, type OnchainInput as aa, type FeeOutput as ab, type ContractWatcherConfig as ac, type FeeInfo as ad, type CreateContractParams as ae, type GetContractsFilter as af, type GetSpendablePathsOptions as ag, type GetAllSpendingPathsOptions as ah, type IssuanceParams as ai, type ReissuanceParams as aj, type BurnParams as ak, type RenewVtxosOptions as al, type ContractWithVtxos as am, type PathSelection as an, type ContractEvent as ao, type AssetDetails as ap, type IssuanceResult as aq, type DelegateInfo as ar, type StorageConfig as as, type IVtxoManager as at, type ExplorerTransaction as au, type EncodedVtxoScript as av, type Status as aw, type Outpoint as ax, type ChainTx as ay, type ArkTapscript as az, type WalletConfig as b, type IDelegatorManager as b0, IndexerTxType as b1, type KnownMetadata as b2, MultisigTapscript as b3, type Nonces as b4, type Output as b5, type PageResponse as b6, type PaginationOptions as b7, PartialSig as b8, type PathContext as b9, getSequence as bA, isBatchSignable as bB, isDiscoverable as bC, isExpired as bD, isRecoverable as bE, isSpendable as bF, isSubdust as bG, isVtxoExpiringSoon as bH, networks as bI, type ProviderClass as ba, RestDelegateProvider as bb, RestDelegatorProvider as bc, type ScanContractsOptions as bd, type ScanResult as be, type ScheduledSession as bf, SettlementEventType as bg, type SignRequest as bh, type SubscriptionEvent as bi, type SubscriptionHeartbeat as bj, type TapLeaves as bk, TapTreeCoder as bl, TapscriptType as bm, type TreeNonces as bn, type TreePartialSigs as bo, type Tx as bp, type TxHistoryRecord as bq, type TxKey as br, type TxTreeNode as bs, TxType as bt, type VirtualStatus as bu, type Vtxo as bv, type VtxoChain as bw, type VtxoType as bx, type WalletMode as by, decodeTapscript as bz, type WalletBalance as c, type ExtendedCoin as d, type IContractManager as e, type IDelegateManager as f, type SettleParams as g, type SettlementEvent as h, type IAssetManager as i, RestArkProvider as j, RestIndexerProvider as k, type SubscriptionResponse as l, type ArkProvider as m, type IndexerProvider as n, type RelativeTimelock as o, type TapLeafScript as p, type VirtualCoin as q, type Contract as r, type VtxoRepositoryKey as s, type WalletState as t, type ContractFilter as u, type TreeSigningStartedEvent as v, TxTree as w, type TreeNoncesEvent as x, type BatchFinalizationEvent as y, type BatchFinalizedEvent as z };
@@ -1,4 +1,4 @@
1
- import { a as TaskQueue, c as TaskItem, d as TaskResult } from './taskRunner-B-vG08pX.js';
1
+ import { a as TaskQueue, c as TaskItem, d as TaskResult } from './taskRunner-B1igKGAo.js';
2
2
 
3
3
  /**
4
4
  * Minimal async key-value storage interface.
@@ -1,4 +1,4 @@
1
- import { a as TaskQueue, c as TaskItem, d as TaskResult } from './taskRunner-B-aPfHhK.cjs';
1
+ import { a as TaskQueue, c as TaskItem, d as TaskResult } from './taskRunner-By92TQ1m.cjs';
2
2
 
3
3
  /**
4
4
  * Minimal async key-value storage interface.
@@ -1,4 +1,4 @@
1
- import { getRandomId, extendVirtualCoinForContract, warnAndFilterVtxosForScript, saveVtxosForContract } from './chunk-BVP2U66Q.js';
1
+ import { getRandomId, extendVirtualCoinForContract, warnAndFilterVtxosForScript, saveVtxosForContract } from './chunk-HJM6JPG4.js';
2
2
 
3
3
  // src/worker/expo/taskRunner.ts
4
4
  async function runTasks(queue, processors, deps) {
@@ -91,5 +91,5 @@ var contractPollProcessor = {
91
91
  };
92
92
 
93
93
  export { CONTRACT_POLL_TASK_TYPE, contractPollProcessor, createTaskDependencies, runTasks };
94
- //# sourceMappingURL=chunk-TH6T23XG.js.map
95
- //# sourceMappingURL=chunk-TH6T23XG.js.map
94
+ //# sourceMappingURL=chunk-AXGVYRAL.js.map
95
+ //# sourceMappingURL=chunk-AXGVYRAL.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/worker/expo/taskRunner.ts","../src/worker/expo/processors/contractPollProcessor.ts"],"names":[],"mappings":";;;AAkDA,eAAsB,QAAA,CAClB,KAAA,EACA,UAAA,EACA,IAAA,EACqB;AACrB,EAAA,MAAM,KAAA,GAAQ,MAAM,KAAA,CAAM,QAAA,EAAS;AACnC,EAAA,MAAM,YAAA,GAAe,IAAI,GAAA,CAAI,UAAA,CAAW,GAAA,CAAI,CAAC,CAAA,KAAM,CAAC,CAAA,CAAE,QAAA,EAAU,CAAC,CAAC,CAAC,CAAA;AACnE,EAAA,MAAM,UAAwB,EAAC;AAE/B,EAAA,KAAA,MAAW,QAAQ,KAAA,EAAO;AACtB,IAAA,MAAM,SAAA,GAAY,YAAA,CAAa,GAAA,CAAI,IAAA,CAAK,IAAI,CAAA;AAE5C,IAAA,IAAI,OAAA;AAEJ,IAAA,IAAI,CAAC,SAAA,EAAW;AACZ,MAAA,O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AoB,UAAA;AAAW,KAC3C;AAAA,EACJ;AACJ","file":"chunk-TH6T23XG.js","sourcesContent":["import type { TaskItem, TaskResult, TaskQueue } from \"./taskQueue\";\nimport type { WalletRepository } from \"../../repositories/walletRepository\";\nimport type { ContractRepository } from \"../../repositories/contractRepository\";\nimport type { IndexerProvider } from \"../../providers/indexer\";\nimport type { ArkProvider } from \"../../providers/ark\";\nimport type { ExtendedVirtualCoin, VirtualCoin } from \"../../wallet\";\nimport type { Contract } from \"../../contracts/types\";\nimport { getRandomId, extendVirtualCoinForContract } from \"../../wallet/utils\";\n\n/**\n * Shared dependencies injected into every processor at runtime.\n *\n * `extendVtxo` requires the owning contract — processors must resolve each\n * vtxo's `script` to a known contract (via the contract repository) before\n * calling this. The strict signature prevents the footgun where a missing\n * contract silently falls back to the wallet's default tapscript.\n */\nexport interface TaskDependencies {\n walletRepository: WalletRepository;\n contractRepository: ContractRepository;\n indexerProvider: IndexerProvider;\n arkProvider: ArkProvider;\n extendVtxo: (vtxo: VirtualCoin, contract: Contract) => ExtendedVirtualCoin;\n}\n\n/**\n * A stateless unit that handles one type of task item.\n *\n * Processors must not keep in-memory state across invocations —\n * all coordination lives in the @see TaskQueue and repositories.\n *\n * The `TDeps` parameter defaults to @see TaskDependencies but\n * can be overridden for domain-specific processors (e.g. swap processing).\n */\nexport interface TaskProcessor<TDeps = TaskDependencies> {\n readonly taskType: string;\n execute(item: TaskItem, deps: TDeps): Promise<Omit<TaskResult, \"id\" | \"executedAt\">>;\n}\n\n/**\n * Run all pending tasks from the queue through matching processors.\n *\n * For each task in the inbox:\n * 1. Find the processor whose `taskType` matches `task.type`.\n * 2. Execute it, producing a @see TaskResult.\n * 3. Push the result to the outbox and remove the task from the inbox.\n *\n * Tasks with no matching processor produce a `\"noop\"` result.\n * Processor errors produce a `\"failed\"` result with the error message.\n */\nexport async function runTasks<TDeps = TaskDependencies>(\n queue: TaskQueue,\n processors: TaskProcessor<TDeps>[],\n deps: TDeps,\n): Promise<TaskResult[]> {\n const tasks = await queue.getTasks();\n const processorMap = new Map(processors.map((p) => [p.taskType, p]));\n const results: TaskResult[] = [];\n\n for (const task of tasks) {\n const processor = processorMap.get(task.type);\n\n let partial: Omit<TaskResult, \"id\" | \"executedAt\">;\n\n if (!processor) {\n partial = {\n taskItemId: task.id,\n type: task.type,\n status: \"noop\",\n };\n } else {\n try {\n partial = await processor.execute(task, deps);\n } catch (error) {\n partial = {\n taskItemId: task.id,\n type: task.type,\n status: \"failed\",\n data: {\n error: error instanceof Error ? error.message : String(error),\n },\n };\n }\n }\n\n const result: TaskResult = {\n ...partial,\n id: getRandomId(),\n executedAt: Date.now(),\n };\n\n await queue.pushResult(result);\n await queue.removeTask(task.id);\n results.push(result);\n }\n\n return results;\n}\n\n/**\n * Options for @see createTaskDependencies.\n */\nexport interface CreateTaskDependenciesOptions {\n walletRepository: WalletRepository;\n contractRepository: ContractRepository;\n indexerProvider: IndexerProvider;\n arkProvider: ArkProvider;\n}\n\n/**\n * Build the @see TaskDependencies needed by task processors\n * (e.g. `src/worker/expo/processors/contractPollProcessor.ts`)\n *\n * This is the same construction that `defineExpoBackgroundTask` does\n * internally, extracted so that consumers with custom schedulers\n * (e.g. bare React Native with `react-native-background-fetch`)\n * can build deps without depending on Expo.\n */\nexport function createTaskDependencies(options: CreateTaskDependenciesOptions): TaskDependencies {\n return {\n ...options,\n extendVtxo: (vtxo: VirtualCoin, contract: Contract) =>\n extendVirtualCoinForContract(vtxo, contract),\n };\n}\n","import type { TaskItem, TaskResult } from \"../taskQueue\";\nimport type { TaskProcessor, TaskDependencies } from \"../taskRunner\";\nimport type { ExtendedVirtualCoin } from \"../../../wallet\";\nimport {\n warnAndFilterVtxosForScript,\n saveVtxosForContract,\n} from \"../../../contracts/vtxoOwnership\";\n\nexport const CONTRACT_POLL_TASK_TYPE = \"contract-poll\";\n\n/**\n * Polls the indexer for the latest VTXO state of every contract and\n * persists the results to the wallet repository.\n *\n * Replicates the polling subset of @see ContractManager.initialize:\n * 1. Load all contracts from the contract repository.\n * 2. Paginated fetch of every VTXO (including spent) from the indexer.\n * 3. Extend each VTXO with tapscript data.\n * 4. Save to the wallet repository.\n *\n * NOTE: the indexer query deliberately omits `spendableOnly`. Every\n * repository implements `saveVtxos` as an upsert with no batch delete,\n * so filtering to spendable-only would leave VTXOs that became spent\n * between polls marked as spendable forever. Fetching the full set lets\n * the upsert overwrite stale records with their latest state.\n */\nexport const contractPollProcessor: TaskProcessor = {\n taskType: CONTRACT_POLL_TASK_TYPE,\n\n async execute(\n item: TaskItem,\n deps: TaskDependencies,\n ): Promise<Omit<TaskResult, \"id\" | \"executedAt\">> {\n const { contractRepository, walletRepository, indexerProvider, extendVtxo } = deps;\n\n const contracts = await contractRepository.getContracts();\n let contractsProcessed = 0;\n let vtxosSaved = 0;\n\n for (const contract of contracts) {\n // Paginated fetch of spendable virtual outputs\n const pageSize = 100;\n let pageIndex = 0;\n let hasMore = true;\n const allVtxos: ExtendedVirtualCoin[] = [];\n\n while (hasMore) {\n const { vtxos, page } = await indexerProvider.getVtxos({\n scripts: [contract.script],\n pageIndex,\n pageSize,\n });\n\n for (const vtxo of vtxos) {\n allVtxos.push(extendVtxo(vtxo, contract));\n }\n\n hasMore = page ? vtxos.length === pageSize : false;\n pageIndex++;\n }\n\n // Skip wrong-script rows (legacy duplicates or indexer drift)\n // before persisting; the loop must keep going for the remaining\n // contracts even when one row is rejected.\n const filtered = warnAndFilterVtxosForScript(\n allVtxos,\n contract.script,\n \"contractPollProcessor\",\n );\n await saveVtxosForContract(walletRepository, contract, filtered);\n vtxosSaved += filtered.length;\n contractsProcessed++;\n }\n\n return {\n taskItemId: item.id,\n type: CONTRACT_POLL_TASK_TYPE,\n status: \"success\",\n data: { contractsProcessed, vtxosSaved },\n };\n },\n};\n"]}
1
+ {"version":3,"sources":["../src/worker/expo/taskRunner.ts","../src/worker/expo/processors/contractPollProcessor.ts"],"names":[],"mappings":";;;AAkDA,eAAsB,QAAA,CAClB,KAAA,EACA,U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AW,KAAA;AAC7C,QAAA,SAAA,EAAA;AAAA,MACJ;AAKA,MAAA,MAAM,QAAA,GAAW,2BAAA;AAAA,QACb,QAAA;AAAA,QACA,QAAA,CAAS,MAAA;AAAA,QACT;AAAA,OACJ;AACA,MAAA,MAAM,oBAAA,CAAqB,gBAAA,EAAkB,QAAA,EAAU,QAAQ,CAAA;AAC/D,MAAA,UAAA,IAAc,QAAA,CAAS,MAAA;AACvB,MAAA,kBAAA,EAAA;AAAA,IACJ;AAEA,IAAA,OAAO;AAAA,MACH,YAAY,IAAA,CAAK,EAAA;AAAA,MACjB,IAAA,EAAM,uBAAA;AAAA,MACN,MAAA,EAAQ,SAAA;AAAA,MACR,IAAA,EAAM,EAAE,kBAAA,EAAoB,UAAA;AAAW,KAC3C;AAAA,EACJ;AACJ","file":"chunk-AXGVYRAL.js","sourcesContent":["import type { TaskItem, TaskResult, TaskQueue } from \"./taskQueue\";\nimport type { WalletRepository } from \"../../repositories/walletRepository\";\nimport type { ContractRepository } from \"../../repositories/contractRepository\";\nimport type { IndexerProvider } from \"../../providers/indexer\";\nimport type { ArkProvider } from \"../../providers/ark\";\nimport type { ExtendedVirtualCoin, VirtualCoin } from \"../../wallet\";\nimport type { Contract } from \"../../contracts/types\";\nimport { getRandomId, extendVirtualCoinForContract } from \"../../wallet/utils\";\n\n/**\n * Shared dependencies injected into every processor at runtime.\n *\n * `extendVtxo` requires the owning contract — processors must resolve each\n * vtxo's `script` to a known contract (via the contract repository) before\n * calling this. The strict signature prevents the footgun where a missing\n * contract silently falls back to the wallet's default tapscript.\n */\nexport interface TaskDependencies {\n walletRepository: WalletRepository;\n contractRepository: ContractRepository;\n indexerProvider: IndexerProvider;\n arkProvider: ArkProvider;\n extendVtxo: (vtxo: VirtualCoin, contract: Contract) => ExtendedVirtualCoin;\n}\n\n/**\n * A stateless unit that handles one type of task item.\n *\n * Processors must not keep in-memory state across invocations —\n * all coordination lives in the @see TaskQueue and repositories.\n *\n * The `TDeps` parameter defaults to @see TaskDependencies but\n * can be overridden for domain-specific processors (e.g. swap processing).\n */\nexport interface TaskProcessor<TDeps = TaskDependencies> {\n readonly taskType: string;\n execute(item: TaskItem, deps: TDeps): Promise<Omit<TaskResult, \"id\" | \"executedAt\">>;\n}\n\n/**\n * Run all pending tasks from the queue through matching processors.\n *\n * For each task in the inbox:\n * 1. Find the processor whose `taskType` matches `task.type`.\n * 2. Execute it, producing a @see TaskResult.\n * 3. Push the result to the outbox and remove the task from the inbox.\n *\n * Tasks with no matching processor produce a `\"noop\"` result.\n * Processor errors produce a `\"failed\"` result with the error message.\n */\nexport async function runTasks<TDeps = TaskDependencies>(\n queue: TaskQueue,\n processors: TaskProcessor<TDeps>[],\n deps: TDeps,\n): Promise<TaskResult[]> {\n const tasks = await queue.getTasks();\n const processorMap = new Map(processors.map((p) => [p.taskType, p]));\n const results: TaskResult[] = [];\n\n for (const task of tasks) {\n const processor = processorMap.get(task.type);\n\n let partial: Omit<TaskResult, \"id\" | \"executedAt\">;\n\n if (!processor) {\n partial = {\n taskItemId: task.id,\n type: task.type,\n status: \"noop\",\n };\n } else {\n try {\n partial = await processor.execute(task, deps);\n } catch (error) {\n partial = {\n taskItemId: task.id,\n type: task.type,\n status: \"failed\",\n data: {\n error: error instanceof Error ? error.message : String(error),\n },\n };\n }\n }\n\n const result: TaskResult = {\n ...partial,\n id: getRandomId(),\n executedAt: Date.now(),\n };\n\n await queue.pushResult(result);\n await queue.removeTask(task.id);\n results.push(result);\n }\n\n return results;\n}\n\n/**\n * Options for @see createTaskDependencies.\n */\nexport interface CreateTaskDependenciesOptions {\n walletRepository: WalletRepository;\n contractRepository: ContractRepository;\n indexerProvider: IndexerProvider;\n arkProvider: ArkProvider;\n}\n\n/**\n * Build the @see TaskDependencies needed by task processors\n * (e.g. `src/worker/expo/processors/contractPollProcessor.ts`)\n *\n * This is the same construction that `defineExpoBackgroundTask` does\n * internally, extracted so that consumers with custom schedulers\n * (e.g. bare React Native with `react-native-background-fetch`)\n * can build deps without depending on Expo.\n */\nexport function createTaskDependencies(options: CreateTaskDependenciesOptions): TaskDependencies {\n return {\n ...options,\n extendVtxo: (vtxo: VirtualCoin, contract: Contract) =>\n extendVirtualCoinForContract(vtxo, contract),\n };\n}\n","import type { TaskItem, TaskResult } from \"../taskQueue\";\nimport type { TaskProcessor, TaskDependencies } from \"../taskRunner\";\nimport type { ExtendedVirtualCoin } from \"../../../wallet\";\nimport {\n warnAndFilterVtxosForScript,\n saveVtxosForContract,\n} from \"../../../contracts/vtxoOwnership\";\n\nexport const CONTRACT_POLL_TASK_TYPE = \"contract-poll\";\n\n/**\n * Polls the indexer for the latest VTXO state of every contract and\n * persists the results to the wallet repository.\n *\n * Replicates the polling subset of @see ContractManager.initialize:\n * 1. Load all contracts from the contract repository.\n * 2. Paginated fetch of every VTXO (including spent) from the indexer.\n * 3. Extend each VTXO with tapscript data.\n * 4. Save to the wallet repository.\n *\n * NOTE: the indexer query deliberately omits `spendableOnly`. Every\n * repository implements `saveVtxos` as an upsert with no batch delete,\n * so filtering to spendable-only would leave VTXOs that became spent\n * between polls marked as spendable forever. Fetching the full set lets\n * the upsert overwrite stale records with their latest state.\n */\nexport const contractPollProcessor: TaskProcessor = {\n taskType: CONTRACT_POLL_TASK_TYPE,\n\n async execute(\n item: TaskItem,\n deps: TaskDependencies,\n ): Promise<Omit<TaskResult, \"id\" | \"executedAt\">> {\n const { contractRepository, walletRepository, indexerProvider, extendVtxo } = deps;\n\n const contracts = await contractRepository.getContracts();\n let contractsProcessed = 0;\n let vtxosSaved = 0;\n\n for (const contract of contracts) {\n // Paginated fetch of spendable virtual outputs\n const pageSize = 100;\n let pageIndex = 0;\n let hasMore = true;\n const allVtxos: ExtendedVirtualCoin[] = [];\n\n while (hasMore) {\n const { vtxos, page } = await indexerProvider.getVtxos({\n scripts: [contract.script],\n pageIndex,\n pageSize,\n });\n\n for (const vtxo of vtxos) {\n allVtxos.push(extendVtxo(vtxo, contract));\n }\n\n hasMore = page ? vtxos.length === pageSize : false;\n pageIndex++;\n }\n\n // Skip wrong-script rows (legacy duplicates or indexer drift)\n // before persisting; the loop must keep going for the remaining\n // contracts even when one row is rejected.\n const filtered = warnAndFilterVtxosForScript(\n allVtxos,\n contract.script,\n \"contractPollProcessor\",\n );\n await saveVtxosForContract(walletRepository, contract, filtered);\n vtxosSaved += filtered.length;\n contractsProcessed++;\n }\n\n return {\n taskItemId: item.id,\n type: CONTRACT_POLL_TASK_TYPE,\n status: \"success\",\n data: { contractsProcessed, vtxosSaved },\n };\n },\n};\n"]}
@@ -2278,27 +2278,57 @@ function extendCoin(wallet, utxo) {
2278
2278
  tapTree: wallet.boardingTapscript.encode()
2279
2279
  };
2280
2280
  }
2281
- function extendVtxoFromContract(vtxo, contract) {
2281
+ function deriveContractTapscripts(contract) {
2282
2282
  const handler = chunkIEO3XDKI_cjs.contractHandlers.get(contract.type);
2283
2283
  if (!handler) {
2284
2284
  throw new Error(`No handler for contract type '${contract.type}'`);
2285
2285
  }
2286
2286
  const script = handler.createScript(contract.params);
2287
2287
  return {
2288
- ...vtxo,
2289
2288
  forfeitTapLeafScript: script.forfeit(),
2290
2289
  intentTapLeafScript: script.forfeit(),
2291
2290
  tapTree: script.encode()
2292
2291
  };
2293
2292
  }
2294
- function extendVirtualCoinForContract(vtxo, contractOrMap) {
2293
+ function cloneTapLeafScript([
2294
+ controlBlock,
2295
+ script
2296
+ ]) {
2297
+ return [
2298
+ {
2299
+ version: controlBlock.version,
2300
+ internalKey: new Uint8Array(controlBlock.internalKey),
2301
+ merklePath: controlBlock.merklePath.map((hash) => new Uint8Array(hash))
2302
+ },
2303
+ new Uint8Array(script)
2304
+ ];
2305
+ }
2306
+ function cloneContractTapscripts(tapscripts) {
2307
+ return {
2308
+ forfeitTapLeafScript: cloneTapLeafScript(tapscripts.forfeitTapLeafScript),
2309
+ intentTapLeafScript: cloneTapLeafScript(tapscripts.intentTapLeafScript),
2310
+ tapTree: new Uint8Array(tapscripts.tapTree)
2311
+ };
2312
+ }
2313
+ function extendVtxoFromContract(vtxo, contract, cache) {
2314
+ if (!cache) {
2315
+ return { ...vtxo, ...deriveContractTapscripts(contract) };
2316
+ }
2317
+ let tapscripts = cache.get(contract.script);
2318
+ if (!tapscripts) {
2319
+ tapscripts = deriveContractTapscripts(contract);
2320
+ cache.set(contract.script, tapscripts);
2321
+ }
2322
+ return { ...vtxo, ...cloneContractTapscripts(tapscripts) };
2323
+ }
2324
+ function extendVirtualCoinForContract(vtxo, contractOrMap, cache) {
2295
2325
  const contract = resolveContract(vtxo, contractOrMap);
2296
2326
  if (!contract) {
2297
2327
  throw new Error(
2298
2328
  "extendVirtualCoinForContract: no contract matched vtxo.script \u2014 callers must resolve the owning contract before annotating"
2299
2329
  );
2300
2330
  }
2301
- return extendVtxoFromContract(vtxo, contract);
2331
+ return extendVtxoFromContract(vtxo, contract, cache);
2302
2332
  }
2303
2333
  function isContractMap(value) {
2304
2334
  return typeof value.get === "function";
@@ -2621,6 +2651,7 @@ var VtxoManager = class _VtxoManager {
2621
2651
  * primary way to prevent virtual outputs from expiring.
2622
2652
  *
2623
2653
  * @param eventCallback - Optional callback for settlement events
2654
+ * @param options - Optional per-call overrides; see {@link RenewVtxosOptions}
2624
2655
  * @returns Settlement transaction ID
2625
2656
  * @throws Error if no virtual outputs available to renew
2626
2657
  * @throws Error if total amount is below dust threshold
@@ -2636,15 +2667,33 @@ var VtxoManager = class _VtxoManager {
2636
2667
  * const txid = await manager.renewVtxos((event) => {
2637
2668
  * console.log('Settlement event:', event.type);
2638
2669
  * });
2670
+ *
2671
+ * // Renew only VTXOs that expire within 6 hours
2672
+ * const txid = await manager.renewVtxos(undefined, { thresholdSeconds: 6 * 60 * 60 });
2639
2673
  * ```
2640
2674
  */
2641
- async renewVtxos(eventCallback) {
2675
+ async renewVtxos(eventCallback, options) {
2676
+ if (options?.thresholdSeconds !== void 0) {
2677
+ const { thresholdSeconds } = options;
2678
+ if (typeof thresholdSeconds !== "number" || !Number.isFinite(thresholdSeconds) || thresholdSeconds <= 0) {
2679
+ throw new TypeError(
2680
+ `Invalid thresholdSeconds: expected a positive finite number, got ${String(thresholdSeconds)}`
2681
+ );
2682
+ }
2683
+ }
2642
2684
  if (this.renewalInProgress) {
2643
2685
  throw new Error("Renewal already in progress");
2644
2686
  }
2645
2687
  this.renewalInProgress = true;
2646
2688
  try {
2647
- const threshold = this.settlementConfig !== false && this.settlementConfig?.vtxoThreshold !== void 0 ? this.settlementConfig.vtxoThreshold * 1e3 : DEFAULT_RENEWAL_CONFIG.thresholdMs;
2689
+ let threshold;
2690
+ if (options?.thresholdSeconds !== void 0) {
2691
+ threshold = options.thresholdSeconds * 1e3;
2692
+ } else if (this.settlementConfig !== false && this.settlementConfig?.vtxoThreshold !== void 0) {
2693
+ threshold = this.settlementConfig.vtxoThreshold * 1e3;
2694
+ } else {
2695
+ threshold = DEFAULT_RENEWAL_CONFIG.thresholdMs;
2696
+ }
2648
2697
  let vtxos = await this.getExpiringVtxos(threshold);
2649
2698
  if (vtxos.length === 0) {
2650
2699
  throw new Error("No VTXOs available to renew");
@@ -6692,7 +6741,8 @@ var ContractManager = class _ContractManager {
6692
6741
  for (const contract of contracts) {
6693
6742
  byScript.set(contract.script, contract);
6694
6743
  }
6695
- return vtxos.map((vtxo) => extendVirtualCoinForContract(vtxo, byScript));
6744
+ const tapscriptCache = /* @__PURE__ */ new Map();
6745
+ return vtxos.map((vtxo) => extendVirtualCoinForContract(vtxo, byScript, tapscriptCache));
6696
6746
  }
6697
6747
  buildContractsDbFilter(filter) {
6698
6748
  return {
@@ -10929,7 +10979,7 @@ var WalletMessageHandler = class {
10929
10979
  payload: e
10930
10980
  })
10931
10981
  );
10932
- });
10982
+ }, message.payload);
10933
10983
  return this.tagged({
10934
10984
  id,
10935
10985
  type: "RENEW_VTXOS_SUCCESS",
@@ -12546,11 +12596,12 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
12546
12596
  throw new Error(`Failed to get expiring vtxos: ${e}`);
12547
12597
  }
12548
12598
  },
12549
- async renewVtxos(eventCallback) {
12599
+ async renewVtxos(eventCallback, options) {
12550
12600
  const message = {
12551
12601
  tag: messageTag,
12552
12602
  type: "RENEW_VTXOS",
12553
- id: getRandomId()
12603
+ id: getRandomId(),
12604
+ payload: options
12554
12605
  };
12555
12606
  try {
12556
12607
  const response = await wallet.sendMessageWithEvents(
@@ -14054,5 +14105,5 @@ exports.validateVtxoTxGraph = validateVtxoTxGraph;
14054
14105
  exports.verifyTapscriptSignatures = verifyTapscriptSignatures;
14055
14106
  exports.waitForIncomingFunds = waitForIncomingFunds;
14056
14107
  exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
14057
- //# sourceMappingURL=chunk-GDCTOSMV.cjs.map
14058
- //# sourceMappingURL=chunk-GDCTOSMV.cjs.map
14108
+ //# sourceMappingURL=chunk-GPZH5QNA.cjs.map
14109
+ //# sourceMappingURL=chunk-GPZH5QNA.cjs.map