@arkade-os/sdk 0.4.34 → 0.4.36

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 (69) hide show
  1. package/dist/adapters/expo.cjs +4 -4
  2. package/dist/adapters/expo.d.cts +2 -2
  3. package/dist/adapters/expo.d.ts +2 -2
  4. package/dist/adapters/expo.js +2 -2
  5. package/dist/adapters/indexedDB.cjs +3 -3
  6. package/dist/adapters/indexedDB.js +2 -2
  7. package/dist/{ark-Dsv5Jq4E.d.cts → ark-D6sau_6-.d.cts} +458 -3
  8. package/dist/{ark-Dsv5Jq4E.d.ts → ark-D6sau_6-.d.ts} +458 -3
  9. package/dist/{asyncStorageTaskQueue-D92ch8yI.d.cts → asyncStorageTaskQueue-CpC027t_.d.cts} +2 -2
  10. package/dist/{asyncStorageTaskQueue-BH-zuth5.d.ts → asyncStorageTaskQueue-GT8fmPUG.d.ts} +2 -2
  11. package/dist/{chunk-FXFBPXV3.js → chunk-2JJKX2RK.js} +139 -41
  12. package/dist/chunk-2JJKX2RK.js.map +1 -0
  13. package/dist/{chunk-CCLNFHJ5.cjs → chunk-2XE5BSIY.cjs} +16 -10
  14. package/dist/chunk-2XE5BSIY.cjs.map +1 -0
  15. package/dist/{chunk-ZS3OZHC7.cjs → chunk-A5PY4NBP.cjs} +7 -7
  16. package/dist/{chunk-ZS3OZHC7.cjs.map → chunk-A5PY4NBP.cjs.map} +1 -1
  17. package/dist/{chunk-FSAXPBGP.cjs → chunk-C6OODRWD.cjs} +143 -40
  18. package/dist/chunk-C6OODRWD.cjs.map +1 -0
  19. package/dist/{chunk-HFXEUW55.js → chunk-HBPKIIMN.js} +1472 -202
  20. package/dist/chunk-HBPKIIMN.js.map +1 -0
  21. package/dist/{chunk-5WDBHWX3.js → chunk-KZV3FJJR.js} +10 -4
  22. package/dist/chunk-KZV3FJJR.js.map +1 -0
  23. package/dist/{chunk-XCHBQVMK.cjs → chunk-TUSGEWOX.cjs} +1540 -265
  24. package/dist/chunk-TUSGEWOX.cjs.map +1 -0
  25. package/dist/{chunk-VVGD3JIP.js → chunk-Z2VRVZW4.js} +3 -3
  26. package/dist/{chunk-VVGD3JIP.js.map → chunk-Z2VRVZW4.js.map} +1 -1
  27. package/dist/contracts/handlers/index.d.cts +3 -3
  28. package/dist/contracts/handlers/index.d.ts +3 -3
  29. package/dist/{delegate-BaS5SCIW.d.cts → delegate-C-L6gSZx.d.cts} +1 -1
  30. package/dist/{delegate-Baz_hb83.d.ts → delegate-De5__fpZ.d.ts} +1 -1
  31. package/dist/{index-FwXZveaX.d.ts → index-BETdjE_o.d.ts} +2 -2
  32. package/dist/{index-lNZ6qaO3.d.cts → index-jwQfHP6D.d.cts} +2 -2
  33. package/dist/index.cjs +129 -105
  34. package/dist/index.d.cts +69 -9
  35. package/dist/index.d.ts +69 -9
  36. package/dist/index.js +2 -2
  37. package/dist/repositories/realm/index.cjs +12 -12
  38. package/dist/repositories/realm/index.cjs.map +1 -1
  39. package/dist/repositories/realm/index.d.cts +2 -2
  40. package/dist/repositories/realm/index.d.ts +2 -2
  41. package/dist/repositories/realm/index.js +3 -3
  42. package/dist/repositories/realm/index.js.map +1 -1
  43. package/dist/repositories/sqlite/index.cjs +11 -11
  44. package/dist/repositories/sqlite/index.d.cts +1 -1
  45. package/dist/repositories/sqlite/index.d.ts +1 -1
  46. package/dist/repositories/sqlite/index.js +2 -2
  47. package/dist/{taskRunner-vFRA3F9b.d.cts → taskRunner-DCyp6Gea.d.cts} +2 -2
  48. package/dist/{taskRunner-B1NUWyWR.d.ts → taskRunner-DnxtObeq.d.ts} +2 -2
  49. package/dist/wallet/expo/background.cjs +12 -12
  50. package/dist/wallet/expo/background.d.cts +3 -3
  51. package/dist/wallet/expo/background.d.ts +3 -3
  52. package/dist/wallet/expo/background.js +4 -4
  53. package/dist/wallet/expo/index.cjs +11 -11
  54. package/dist/wallet/expo/index.d.cts +4 -4
  55. package/dist/wallet/expo/index.d.ts +4 -4
  56. package/dist/wallet/expo/index.js +3 -3
  57. package/dist/{wallet-D6uoBLmS.d.ts → wallet-BWHbd5b1.d.cts} +231 -8
  58. package/dist/{wallet-By9HIo0Q.d.cts → wallet-Bth5uucA.d.ts} +231 -8
  59. package/dist/worker/expo/index.cjs +7 -7
  60. package/dist/worker/expo/index.d.cts +4 -4
  61. package/dist/worker/expo/index.d.ts +4 -4
  62. package/dist/worker/expo/index.js +3 -3
  63. package/package.json +2 -2
  64. package/dist/chunk-5WDBHWX3.js.map +0 -1
  65. package/dist/chunk-CCLNFHJ5.cjs.map +0 -1
  66. package/dist/chunk-FSAXPBGP.cjs.map +0 -1
  67. package/dist/chunk-FXFBPXV3.js.map +0 -1
  68. package/dist/chunk-HFXEUW55.js.map +0 -1
  69. package/dist/chunk-XCHBQVMK.cjs.map +0 -1
@@ -524,6 +524,101 @@ type EncodedVtxoScript = {
524
524
  */
525
525
  declare function getSequence(tapLeafScript: TapLeafScript): number | undefined;
526
526
 
527
+ /**
528
+ * Machine-readable classification of a contract's server signer relative to a
529
+ * fresh {@link ArkInfo} snapshot. Drives both the migration selection (Section
530
+ * 3) and the user-facing cutoff reporting (Section 6) without persisting any
531
+ * stale-key metadata: staleness is always derived at read time from the
532
+ * contract's `params.serverPubKey` plus the server's advertised signer set.
533
+ *
534
+ * - `CURRENT`: the contract was minted under the server's active signer; no
535
+ * migration needed.
536
+ * - `MIGRATABLE`: the contract's signer is advertised as deprecated and its
537
+ * cutoff has not passed — cooperative migration is still possible.
538
+ * - `DUE_NOW`: the contract's signer is advertised as deprecated with no cutoff
539
+ * date (arkd advertises this as a `0n` cutoff), so migration should start
540
+ * immediately.
541
+ * - `EXPIRED`: the contract's signer is deprecated and its cutoff has passed —
542
+ * cooperative migration is closed. These funds are NOT stranded: the VTXO
543
+ * keeps its own batch expiry, the server sweeps that batch at expiry, and the
544
+ * swept VTXO then recovers into the active signer through the normal recovery
545
+ * settle (no deprecated key, no forfeit, no on-chain exit). Unilateral exit
546
+ * remains an opt-in escape hatch, not a requirement (Section 6 / post-cutoff).
547
+ * - `UNKNOWN_SIGNER`: the contract's signer is neither the active signer nor an
548
+ * advertised deprecated signer. The SDK does not attempt to migrate these.
549
+ */
550
+ type SignerStatus = "CURRENT" | "MIGRATABLE" | "DUE_NOW" | "EXPIRED" | "UNKNOWN_SIGNER";
551
+ /**
552
+ * Result of classifying a single contract's server signer against the current
553
+ * {@link ArkInfo} signer set.
554
+ */
555
+ interface SignerClassification {
556
+ status: SignerStatus;
557
+ /** The contract's server signer, normalized to x-only (32-byte) hex. */
558
+ signerPubKey: string;
559
+ /**
560
+ * Absolute cutoff as a Unix timestamp in seconds, present only when the
561
+ * server advertised one for this deprecated signer.
562
+ */
563
+ cutoffDate?: bigint;
564
+ /**
565
+ * Derived seconds until the advertised cutoff (`cutoffDate - now`), present
566
+ * only for `MIGRATABLE`/`EXPIRED` (i.e. an advertised cutoff exists).
567
+ * Negative once the cutoff has passed.
568
+ */
569
+ secondsUntilCutoff?: number;
570
+ }
571
+ /**
572
+ * The server's signer set, pre-normalized to x-only hex for cheap repeated
573
+ * lookups. Built once per migration/reporting pass from a fresh
574
+ * {@link ArkInfo} snapshot via {@link signerSetFromInfo}.
575
+ */
576
+ interface SignerSet {
577
+ /** Active signer, x-only (32-byte) hex. */
578
+ active: string;
579
+ /**
580
+ * Deprecated signers keyed by x-only hex, mapped to their cutoff. The cutoff
581
+ * is always a bigint (arkd advertises it non-nullable); `0n` means "no cutoff
582
+ * advertised" (→ `DUE_NOW`).
583
+ */
584
+ deprecated: Map<string, bigint>;
585
+ }
586
+ /**
587
+ * Normalize a server signer pubkey hex to the x-only (32-byte) form contract
588
+ * scripts and `params.serverPubKey` use. A 33-byte compressed key drops its
589
+ * parity prefix; a 32-byte key is canonicalized to lowercase. Mirrors the
590
+ * wallet's `hex.decode(info.signerPubkey).slice(1)` setup path so the active
591
+ * signer and the deprecated signers (which arkd may advertise compressed)
592
+ * compare equal to the x-only `params.serverPubKey` persisted on contracts.
593
+ */
594
+ declare function toXOnlySignerHex(pubkeyHex: string): string;
595
+ /**
596
+ * Build the {@link SignerSet} from a server-info snapshot. Deprecated signers
597
+ * with an empty pubkey are skipped.
598
+ */
599
+ declare function signerSetFromInfo(info: ArkInfo): SignerSet;
600
+ /**
601
+ * Classify a contract's server signer against a pre-built {@link SignerSet}.
602
+ *
603
+ * @param contractServerPubKeyHex - the contract's `params.serverPubKey`
604
+ * @param signerSet - the server's signer set
605
+ * @param nowSeconds - current Unix time in seconds (compared against the
606
+ * advertised cutoff). Defaults to `Math.floor(Date.now() / 1000)`.
607
+ */
608
+ declare function classifyAgainstSignerSet(contractServerPubKeyHex: string, signerSet: SignerSet, nowSeconds?: number): SignerClassification;
609
+ /**
610
+ * Convenience wrapper that builds the signer set from {@link ArkInfo} and
611
+ * classifies a single contract signer. Prefer {@link classifyAgainstSignerSet}
612
+ * with a shared signer set when classifying many contracts in one pass.
613
+ */
614
+ declare function classifyContractSigner(contractServerPubKeyHex: string, info: ArkInfo, nowSeconds?: number): SignerClassification;
615
+ /**
616
+ * Whether a signer status admits cooperative migration (i.e. a `settle()`
617
+ * intent should be built for VTXOs under this signer). True for `MIGRATABLE`
618
+ * and `DUE_NOW`; false for `CURRENT`, `EXPIRED`, and `UNKNOWN_SIGNER`.
619
+ */
620
+ declare function isCooperativelyMigratable(status: SignerStatus): boolean;
621
+
527
622
  /**
528
623
  * Configuration options for automatic virtual output renewal
529
624
  *
@@ -618,6 +713,24 @@ interface SettlementConfig {
618
713
  * @defaultValue `60_000` (1 minute)
619
714
  */
620
715
  pollIntervalMs?: number;
716
+ /**
717
+ * Automatically migrate VTXOs minted under a now-deprecated server signer
718
+ * back to the wallet's active-signer address before their cutoff window
719
+ * closes (planned arkd key rotation).
720
+ *
721
+ * When enabled, each poll cycle cooperatively migrates stale-signer VTXOs
722
+ * via the normal `settle()` path, applying a mid-session server-signer
723
+ * rotation first when the wallet's own snapshot signer has been deprecated.
724
+ * The explicit {@link IVtxoManager.migrateDeprecatedSignerVtxos} method
725
+ * remains available for manual migration regardless of this flag.
726
+ *
727
+ * Setting `settlementConfig: false` disables all background settlement,
728
+ * including migration. Set this field to `false` to keep renewal/sweep but
729
+ * skip automatic deprecated-signer migration specifically.
730
+ *
731
+ * @defaultValue `true`
732
+ */
733
+ deprecatedSignerMigration?: boolean;
621
734
  }
622
735
  /**
623
736
  * Check if a virtual output is expiring soon based on threshold
@@ -640,6 +753,147 @@ interface RenewVtxosOptions {
640
753
  */
641
754
  thresholdSeconds?: number;
642
755
  }
756
+ /**
757
+ * Optional arguments for {@link IVtxoManager.migrateDeprecatedSignerVtxos}.
758
+ */
759
+ interface MigrateDeprecatedSignerOptions {
760
+ /** Callback to receive settlement events during the migration intent. */
761
+ eventCallback?: (event: SettlementEvent) => void;
762
+ }
763
+ /**
764
+ * A single VTXO referenced in a {@link DeprecatedSignerMigrationReport}.
765
+ */
766
+ interface MigrationVtxoRef {
767
+ txid: string;
768
+ vout: number;
769
+ value: number;
770
+ /** The deprecated signer the VTXO was minted under (x-only hex). */
771
+ signerPubKey: string;
772
+ /** Absolute cutoff (Unix seconds) when the server advertised one. */
773
+ cutoffDate?: bigint;
774
+ }
775
+ /**
776
+ * Machine-readable status for a single deprecated signer the wallet holds
777
+ * funds under (Section 6). Derived at read time from contract params plus a
778
+ * fresh {@link ArkInfo} snapshot — never persisted.
779
+ */
780
+ interface DeprecatedSignerReport {
781
+ /** Deprecated signer key (x-only hex). */
782
+ signerPubKey: string;
783
+ /** One of `migratable` | `dueNow` | `expired` | `unknownSigner`. */
784
+ status: SignerStatus;
785
+ /** Absolute cutoff (Unix seconds), present only when advertised. */
786
+ cutoffDate?: bigint;
787
+ /** Derived seconds until cutoff; negative once passed. */
788
+ secondsUntilCutoff?: number;
789
+ /** Number of spendable VTXOs the wallet holds under this signer. */
790
+ vtxoCount: number;
791
+ /** Total value of those VTXOs in satoshis. */
792
+ totalValue: number;
793
+ /**
794
+ * Number of spendable boarding UTXOs the wallet holds under this signer
795
+ * (Section 7). Counts every confirmed boarding coin, including those whose
796
+ * own CSV exit window has elapsed (they leave via the unilateral sweep).
797
+ */
798
+ boardingCount: number;
799
+ /** Total value of those boarding UTXOs in satoshis (Section 7). */
800
+ boardingValue: number;
801
+ /**
802
+ * Expired-signer VTXOs already swept and queued for recovery to the active
803
+ * signer (the recover-on-sweep default — see {@link SignerStatus} `EXPIRED`).
804
+ * Non-zero only on `EXPIRED` rows; these drain on the next recovery pass
805
+ * (Section 6 / post-cutoff).
806
+ */
807
+ recoverableCount: number;
808
+ recoverableValue: number;
809
+ /**
810
+ * Expired-signer VTXOs not yet swept; awaiting the server batch sweep before
811
+ * they become recoverable. Non-zero only on `EXPIRED` rows — nothing for the
812
+ * user to do but wait (Section 6 / post-cutoff).
813
+ */
814
+ awaitingSweepCount: number;
815
+ awaitingSweepValue: number;
816
+ /**
817
+ * Soonest batch expiry (ms since epoch) among the awaiting-sweep VTXOs, as a
818
+ * recovery ETA hint. Present only when an `EXPIRED` row has awaiting-sweep
819
+ * VTXOs that carry a batch expiry (Section 6 / post-cutoff).
820
+ */
821
+ nextSweepEta?: number;
822
+ }
823
+ /**
824
+ * Why a single migration leg (VTXO send or boarding settle) submitted nothing.
825
+ * `oversized-only` means every migratable input in that leg individually
826
+ * exceeds the server's per-output ceiling (`vtxoMaxAmount`) — see
827
+ * {@link MigrationLegReport.oversized}.
828
+ */
829
+ type MigrationLegSkipReason = "below-dust" | "oversized-only";
830
+ /**
831
+ * Why the whole pass submitted nothing, before either leg was built.
832
+ * `no-deprecated-vtxos` means BOTH migratable sets (VTXO and boarding) were
833
+ * empty; `unknown-wallet-signer` means the wallet's own snapshot signer is
834
+ * neither active nor advertised deprecated, so the pass refuses to rotate.
835
+ */
836
+ type MigrationGlobalSkipReason = "no-deprecated-vtxos" | "unknown-wallet-signer";
837
+ /**
838
+ * Outcome of one migration leg. The VTXO leg migrates through the Ark send path
839
+ * ({@link Wallet.sendSelectedVtxosToSelf}); the boarding leg keeps its
840
+ * settle-backed migration (boarding coins are on-chain inputs with no send
841
+ * path). Each leg owns its full sizing pipeline (oversized filtering, count +
842
+ * amount caps, its own dust floor) and reports independently — a failure or skip
843
+ * in one leg never suppresses the other.
844
+ */
845
+ interface MigrationLegReport {
846
+ /** VTXO leg: Ark transaction id from send. Boarding leg: settle commitment txid. */
847
+ txid?: string;
848
+ /** Inputs submitted and accepted in this leg's transaction; empty on error/skip. */
849
+ migrated: MigrationVtxoRef[];
850
+ /** Why this leg submitted nothing (every candidate below dust or oversized). */
851
+ skipped?: MigrationLegSkipReason;
852
+ /**
853
+ * Migratable inputs deferred to a later pass by this leg's own caps (the
854
+ * input count {@link MAX_VTXOS_PER_SETTLEMENT} or the per-output amount
855
+ * ceiling `vtxoMaxAmount`). Present and non-zero only when a cap bound and
856
+ * the leg actually submitted; makes the truncation visible.
857
+ */
858
+ deferred?: number;
859
+ /**
860
+ * Inputs whose value alone exceeds the per-output ceiling (`vtxoMaxAmount`):
861
+ * a single ≤-ceiling output can never hold them, so they never migrate
862
+ * cooperatively and require a unilateral exit. Present only when non-empty;
863
+ * absent when the server advertises no ceiling (`vtxoMaxAmount < 0`).
864
+ */
865
+ oversized?: MigrationVtxoRef[];
866
+ /** Error message when this leg's submission failed; the other leg still runs. */
867
+ error?: string;
868
+ }
869
+ /**
870
+ * Result of a {@link IVtxoManager.migrateDeprecatedSignerVtxos} pass, split into
871
+ * two symmetric legs: VTXOs migrate through the send path, boarding UTXOs keep a
872
+ * separate settle-backed migration. They are never combined into one intent.
873
+ */
874
+ interface DeprecatedSignerMigrationReport {
875
+ /** Whether a mid-session server-signer rotation was applied first. */
876
+ rotated: boolean;
877
+ /** Global skip; when set, neither leg is present. */
878
+ skipped?: MigrationGlobalSkipReason;
879
+ /** Send leg. Present iff ≥1 cooperatively-migratable VTXO existed this pass. */
880
+ vtxos?: MigrationLegReport;
881
+ /** Settle leg. Present iff ≥1 cooperatively-migratable boarding UTXO existed this pass. */
882
+ boarding?: MigrationLegReport;
883
+ /**
884
+ * Cutoff-expired inputs of both kinds (a classification outcome, not a leg
885
+ * outcome). Skipped because their signer cutoff has passed: cooperative
886
+ * migration is closed for them. They are NOT pushed to a unilateral exit —
887
+ * each keeps its own batch expiry, the server sweeps it at expiry, and the
888
+ * recovery path then re-mints it under the active signer. The per-signer
889
+ * sweep/recovery lifecycle is surfaced on {@link signers}
890
+ * ({@link DeprecatedSignerReport.recoverableCount} /
891
+ * {@link DeprecatedSignerReport.awaitingSweepCount}).
892
+ */
893
+ expired: MigrationVtxoRef[];
894
+ /** Per-deprecated-signer status snapshot (Section 6). */
895
+ signers: DeprecatedSignerReport[];
896
+ }
643
897
  /**
644
898
  * VtxoManager is a unified class for managing virtual output lifecycle operations including
645
899
  * recovery of swept/expired virtual outputs and renewal to prevent expiration.
@@ -697,6 +951,29 @@ interface IVtxoManager {
697
951
  renewVtxos(eventCallback?: (event: SettlementEvent) => void, options?: RenewVtxosOptions): Promise<string>;
698
952
  getExpiredBoardingUtxos(): Promise<ExtendedCoin[]>;
699
953
  sweepExpiredBoardingUtxos(): Promise<string>;
954
+ /**
955
+ * Cooperatively migrate VTXOs minted under a now-deprecated server signer
956
+ * to the wallet's active-signer address (planned arkd key rotation).
957
+ *
958
+ * Applies a mid-session server-signer rotation first when the wallet's own
959
+ * snapshot signer has been deprecated, so the migration output commits to
960
+ * the active signer. Selects spendable VTXOs under deprecated-signer
961
+ * contracts, prioritizing those closest to their cutoff, and settles them
962
+ * back to the (rotated) Ark address. VTXOs whose cutoff has already passed
963
+ * are reported as `expired` rather than migrated.
964
+ *
965
+ * Available regardless of the `deprecatedSignerMigration` config flag (that
966
+ * flag only gates the automatic poll-loop pass).
967
+ *
968
+ * @returns A report of what was migrated, skipped, expired, or failed.
969
+ */
970
+ migrateDeprecatedSignerVtxos(options?: MigrateDeprecatedSignerOptions): Promise<DeprecatedSignerMigrationReport>;
971
+ /**
972
+ * Machine-readable status of every deprecated server signer the wallet
973
+ * currently holds funds under, without performing any migration. Lets
974
+ * consumers surface cutoff warnings on their own schedule.
975
+ */
976
+ getDeprecatedSignerStatus(): Promise<DeprecatedSignerReport[]>;
700
977
  dispose(): Promise<void>;
701
978
  }
702
979
  declare class VtxoManager implements AsyncDisposable, IVtxoManager {
@@ -704,7 +981,6 @@ declare class VtxoManager implements AsyncDisposable, IVtxoManager {
704
981
  /** @deprecated Use settlementConfig instead */
705
982
  readonly renewalConfig?: RenewalConfig | undefined;
706
983
  readonly settlementConfig: SettlementConfig | false;
707
- private contractEventsSubscription?;
708
984
  private readonly contractEventsSubscriptionReady;
709
985
  private disposePromise?;
710
986
  private pollTimeoutId?;
@@ -726,6 +1002,10 @@ declare class VtxoManager implements AsyncDisposable, IVtxoManager {
726
1002
  private lastVtxoSpentRefreshTimestamp;
727
1003
  private vtxoSpentRefreshPromise?;
728
1004
  private static readonly VTXO_SPENT_REFRESH_COOLDOWN_MS;
1005
+ private lastMigrationTimestamp;
1006
+ private consecutiveMigrationFailures;
1007
+ private static readonly MIGRATION_COOLDOWN_MS;
1008
+ private static readonly MIGRATION_MAX_BACKOFF_MS;
729
1009
  constructor(wallet: IWallet,
730
1010
  /** @deprecated Use settlementConfig instead */
731
1011
  renewalConfig?: RenewalConfig | undefined, settlementConfig?: SettlementConfig | false);
@@ -893,6 +1173,120 @@ declare class VtxoManager implements AsyncDisposable, IVtxoManager {
893
1173
  * ```
894
1174
  */
895
1175
  sweepExpiredBoardingUtxos(prefetchedUtxos?: ExtendedCoin[]): Promise<string>;
1176
+ /**
1177
+ * Cooperatively migrate VTXOs minted under a now-deprecated server signer
1178
+ * to the wallet's active-signer address. See {@link IVtxoManager}.
1179
+ */
1180
+ migrateDeprecatedSignerVtxos(options?: MigrateDeprecatedSignerOptions): Promise<DeprecatedSignerMigrationReport>;
1181
+ /**
1182
+ * Machine-readable status of every deprecated server signer the wallet
1183
+ * currently holds funds under (Section 6), without migrating. Covers both
1184
+ * VTXO and boarding holdings (Section 7), merged per signer.
1185
+ *
1186
+ * @remarks This is no longer a pure repository/info read: surfacing boarding
1187
+ * holdings fans out per boarding address (`getCoins` round trips) and
1188
+ * refreshes the UTXO cache via `saveUtxos`.
1189
+ */
1190
+ getDeprecatedSignerStatus(): Promise<DeprecatedSignerReport[]>;
1191
+ /**
1192
+ * Core migration routine shared by the manual API and the automatic poll
1193
+ * pass. Fetches a fresh {@link ArkInfo}, applies a mid-session signer
1194
+ * rotation when the wallet's own snapshot signer has been deprecated,
1195
+ * selects spendable VTXOs under deprecated-signer contracts (cutoff-first),
1196
+ * and settles them to the active-signer Ark address.
1197
+ */
1198
+ private migrateCore;
1199
+ /**
1200
+ * Size and submit one migration leg. Filters inputs whose value alone
1201
+ * exceeds the per-output ceiling (`vtxoMaxAmount`; `< 0` means no limit) —
1202
+ * those can never form a ≤-ceiling output and must exit unilaterally — then
1203
+ * caps the rest (highest-value first; bounded by {@link MAX_VTXOS_PER_SETTLEMENT}
1204
+ * AND a gross total within `vtxoMaxAmount`), applies the protocol dust floor,
1205
+ * and submits the capped batch through `submit`. A throw from `submit` lands
1206
+ * in `error`; the caller's other leg still runs.
1207
+ *
1208
+ * Migration is mandatory and fee-exempt: every selected input moves at its
1209
+ * full value, so the gross total IS the aggregated output amount (kept under
1210
+ * the server ceiling by the cap). The dust floor guards the degenerate cases
1211
+ * where every input was oversized or the whole holding sums below dust.
1212
+ */
1213
+ private runMigrationLeg;
1214
+ /**
1215
+ * Enumerate the wallet's `default`/`delegate` contracts, classify each
1216
+ * against the fresh signer set, and split their spendable VTXOs into
1217
+ * cooperatively-migratable and cutoff-expired sets while building the
1218
+ * per-signer status report. Current-signer contracts are skipped; swept
1219
+ * (recoverable) VTXOs are excluded from the settle sets — those follow the
1220
+ * recovery path — but are still counted on EXPIRED report rows
1221
+ * (`recoverableCount`) so post-cutoff funds in flight stay visible.
1222
+ */
1223
+ private classifyDeprecatedSignerContracts;
1224
+ /**
1225
+ * Boarding sibling of {@link classifyDeprecatedSignerContracts} (Section 7):
1226
+ * fan out over the wallet's boarding addresses (current + historical), group
1227
+ * the on-chain UTXOs per address, classify each address's signer against the
1228
+ * fresh signer set, and split the confirmed boarding coins into cooperatively-
1229
+ * migratable and cutoff-expired sets while building the per-signer report.
1230
+ *
1231
+ * Discovery sees the active signer plus EVERY deprecated key (EXPIRED
1232
+ * included), so expired-signer boarding is still reported; migration
1233
+ * eligibility is gated afterwards by {@link isCooperativelyMigratable} and a
1234
+ * per-row boarding-output CSV check — never by the fetch. Current-signer
1235
+ * coins are classified `CURRENT` and ignored; foreign-ASP rows are excluded
1236
+ * because their keys are not in the signer set.
1237
+ */
1238
+ private classifyDeprecatedSignerBoarding;
1239
+ /**
1240
+ * Automatic migration pass invoked from the poll loop. Self-contained:
1241
+ * respects an exponential cooldown and logs failures rather than throwing,
1242
+ * so a persistently failing migration backs off instead of re-submitting
1243
+ * an identical intent every cycle.
1244
+ */
1245
+ private runMigrationPass;
1246
+ /** Asserts migration capability and returns the typed wallet. */
1247
+ private requireMigrationCapableWallet;
1248
+ /**
1249
+ * If the wallet's own construction-time signer snapshot has been deprecated,
1250
+ * re-derive its receive/boarding state under the active signer so any output
1251
+ * built afterwards commits to the active key. No-op when the snapshot is
1252
+ * already current. Returns whether a rotation was applied. Treats an
1253
+ * unknown-signer snapshot as "do not rotate" (caller decides).
1254
+ *
1255
+ * Shared by the migration pass (where the wallet's own snapshot is the thing
1256
+ * being migrated) and the recovery/renewal/periodic-settle paths (via
1257
+ * {@link rotateForRecoverableInputs}), so a swept old-signer VTXO recovered
1258
+ * after cutoff re-mints under the active signer rather than re-committing to
1259
+ * the deprecated key (Section 6 / post-cutoff). `rotateServerSigner` is
1260
+ * idempotent and serializes itself against HD receive rotation, so repeated
1261
+ * calls across passes are safe.
1262
+ */
1263
+ private ensureReceiveOnActiveSigner;
1264
+ /**
1265
+ * Rotation guard for the recovery-bearing settle paths (recover / renew /
1266
+ * periodic settle). Pins the wallet's receive snapshot to the active signer
1267
+ * before they build their output, but ONLY when this pass actually carries
1268
+ * an input minted under a deprecated signer — so a routine current-signer
1269
+ * settle on a long-lived pre-rotation instance does not eagerly rotate.
1270
+ *
1271
+ * Cheap in the common case: a watch-only/proxy wallet (not migration-capable)
1272
+ * and a current/unknown wallet snapshot both short-circuit before the
1273
+ * contract round-trip, so the only instance that pays for the input scan is
1274
+ * the long-lived deprecated-snapshot one that genuinely needs rotating.
1275
+ *
1276
+ * Runs OUTSIDE any `renewalInProgress` window the caller sets, and
1277
+ * `rotateServerSigner` does not depend on that flag, so it cannot deadlock
1278
+ * against the receive rotator. Returns whether a rotation was applied.
1279
+ */
1280
+ private rotateForRecoverableInputs;
1281
+ /**
1282
+ * Whether any of the given input outpoints belongs to a contract whose
1283
+ * server signer classifies as non-`CURRENT` against the fresh signer set —
1284
+ * i.e. a deprecated-signer (incl. EXPIRED) input. Maps outpoints to their
1285
+ * owning contract via the ContractManager so it works on the typed
1286
+ * {@link ExtendedVirtualCoin}/{@link ExtendedCoin} inputs the recovery paths
1287
+ * carry (which don't expose `contractScript`).
1288
+ */
1289
+ private anyInputUnderDeprecatedSigner;
896
1290
  /** Asserts sweep capability and returns the typed wallet. */
897
1291
  private getSweepWallet;
898
1292
  /** Decodes the boarding tapscript exit path to extract the CSV timelock. */
@@ -903,6 +1297,14 @@ declare class VtxoManager implements AsyncDisposable, IVtxoManager {
903
1297
  private getOnchainProvider;
904
1298
  /** Returns the Ark provider for intent fee and server info lookups. */
905
1299
  private getArkProvider;
1300
+ /**
1301
+ * Read-only access to the ark provider for fetching server limits. Unlike
1302
+ * {@link getArkProvider}, this does not require full boarding-sweep
1303
+ * capability — recovery and renewal only need it to read `vtxoMaxAmount`.
1304
+ * Returns undefined when no provider is wired, which callers treat as
1305
+ * "no limit".
1306
+ */
1307
+ private getInfoProvider;
906
1308
  /** Returns the Bitcoin network configuration from the wallet. */
907
1309
  private getNetwork;
908
1310
  private initializeSubscription;
@@ -2737,7 +3139,14 @@ interface WalletBalance {
2737
3139
  available: number;
2738
3140
  /** Recoverable balance from subdust or expired (swept) virtual outputs. */
2739
3141
  recoverable: number;
2740
- /** Total balance across offchain, recoverable, and boarding funds. */
3142
+ /**
3143
+ * Funds under a now-deprecated signer past its cutoff (EXPIRED) that have not
3144
+ * yet been swept by the server. NOT spendable until they recover, so excluded
3145
+ * from `available`/`settled`/`preconfirmed` and from coin selection — but
3146
+ * still the wallet's funds, so counted in `total`.
3147
+ */
3148
+ pendingRecovery: number;
3149
+ /** Total balance across offchain, recoverable, pending-recovery, and boarding funds. */
2741
3150
  total: number;
2742
3151
  /** Asset balance entries (`assetId` & `amount`) */
2743
3152
  assets: Asset[];
@@ -3614,6 +4023,17 @@ interface FeeOutput {
3614
4023
  script: string;
3615
4024
  }
3616
4025
 
4026
+ /**
4027
+ * Thrown by {@link RestArkProvider} when arkd rejects a request with
4028
+ * `DIGEST_MISMATCH` — the client's cached server info was stale (e.g. an
4029
+ * operator signer rotation). By the time this surfaces the provider has already
4030
+ * refreshed its info and fired `onServerInfoChanged`; the caller should rebuild
4031
+ * the request under the fresh server info and retry. Mirrors NArk's
4032
+ * `DigestMismatchException` (dotnet-sdk #131): the SDK never silently retries.
4033
+ */
4034
+ declare class DigestMismatchError extends Error {
4035
+ constructor(message: string);
4036
+ }
3617
4037
  /** Output requested during settlement or transaction submission. */
3618
4038
  type Output = {
3619
4039
  /** Destination address, either onchain or Arkade (offchain). */
@@ -3704,6 +4124,15 @@ interface PendingTx {
3704
4124
  signedCheckpointTxs: string[];
3705
4125
  }
3706
4126
  interface DeprecatedSigner {
4127
+ /**
4128
+ * Unix timestamp (seconds) after which the server no longer accepts this
4129
+ * signer's VTXOs as cooperative-migration inputs. arkd advertises this as a
4130
+ * non-nullable field, so it is always present: `0n` is the sentinel for "no
4131
+ * cutoff advertised" — the deprecated signer is due for migration
4132
+ * immediately ({@link classifyContractSigner} maps `0n` to `DUE_NOW`). A
4133
+ * positive value is a real deadline (`MIGRATABLE` until it passes, then
4134
+ * `EXPIRED`).
4135
+ */
3707
4136
  cutoffDate: bigint;
3708
4137
  pubkey: string;
3709
4138
  }
@@ -3810,6 +4239,32 @@ interface ArkProvider {
3810
4239
  declare class RestArkProvider implements ArkProvider {
3811
4240
  serverUrl: string;
3812
4241
  constructor(serverUrl?: string);
4242
+ /**
4243
+ * Last server-info digest seen (from {@link getInfo}). Sent as `X-Digest`
4244
+ * on outgoing requests so arkd can reject a client whose cached info is
4245
+ * stale. Empty until the first {@link getInfo}.
4246
+ */
4247
+ private _digest;
4248
+ private _serverInfoListeners;
4249
+ /**
4250
+ * Subscribe to server-info changes. Fired when a request is rejected with
4251
+ * `DIGEST_MISMATCH` and fresh info is re-fetched, so consumers (the wallet)
4252
+ * can re-derive signer-dependent state mid-session without polling. Returns
4253
+ * an unsubscribe function.
4254
+ */
4255
+ onServerInfoChanged(listener: (info: ArkInfo) => void): () => void;
4256
+ private emitServerInfoChanged;
4257
+ /**
4258
+ * `fetch` wrapper for arkd requests that participates in server-info digest
4259
+ * negotiation. Sends the cached `X-Digest`; when arkd rejects a request with
4260
+ * `DIGEST_MISMATCH`, refreshes {@link getInfo} (updating the digest), fires
4261
+ * {@link onServerInfoChanged}, and THROWS {@link DigestMismatchError} — it
4262
+ * never silently retries, since the in-flight request was built against the
4263
+ * now-stale config. Dormant until arkd returns the error — then it is the
4264
+ * instant, event-driven signer-rotation trigger. {@link getInfo} itself never
4265
+ * routes through here: it is the refresh path and must not be digest-gated.
4266
+ */
4267
+ private authedFetch;
3813
4268
  getInfo(): Promise<ArkInfo>;
3814
4269
  submitTx(signedArkTx: string, checkpointTxs: string[]): Promise<{
3815
4270
  arkTxid: string;
@@ -3977,4 +4432,4 @@ declare namespace ProtoTypes {
3977
4432
  export { };
3978
4433
  }
3979
4434
 
3980
- export { type SignerSession as $, type ArkTransaction as A, type BatchStartedEvent as B, type ContractRepository as C, type DescriptorProvider as D, type ExtendedVirtualCoin as E, type IReadonlyWallet as F, type GetVtxosFilter as G, type ReadonlyIdentity as H, type IWallet as I, type DelegateProvider as J, type ReadonlyWalletConfig as K, type IReadonlyAssetManager as L, type NetworkName as M, type Network as N, type OnchainProvider as O, type ArkInfo as P, ArkAddress as Q, type Recipient as R, type SendBitcoinParams as S, type TxNotification as T, type Coin as U, VtxoScript as V, type WalletRepository as W, ContractManager as X, CSVMultisigTapscript as Y, type SettlementConfig as Z, VtxoManager as _, type Identity as a, type ExtendedContractVtxo as a$, type SignedIntent as a0, Intent as a1, type VtxoRepositoryKey as a2, type WalletState as a3, type ContractFilter as a4, type DescriptorSigningRequest as a5, Transaction as a6, type IntentFeeConfig as a7, type OffchainInput as a8, FeeAmount as a9, type ArkTapscript as aA, type Asset as aB, type AssetMetadata as aC, type BaseWalletConfig as aD, type BatchInfo as aE, type BatchSignableIdentity as aF, CLTVMultisigTapscript as aG, ChainTxType as aH, type CommitmentTx as aI, ConditionCSVMultisigTapscript as aJ, ConditionMultisigTapscript as aK, type ContractBalance as aL, type ContractEventCallback as aM, type ContractHandler as aN, type ContractManagerConfig as aO, type ContractState as aP, type ContractVtxo as aQ, ContractWatcher as aR, DelegateManagerImpl as aS, type DelegateOptions as aT, DelegatorManagerImpl as aU, type DelegatorProvider as aV, type Discoverable as aW, type DiscoveredContract as aX, type DiscoveryDeps as aY, ESPLORA_URL as aZ, EsploraProvider 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 PathContext as az, type WalletConfig as b, type HandlerError as b0, type IDelegatorManager as b1, IndexerTxType as b2, type KnownMetadata as b3, MultisigTapscript as b4, type Nonces as b5, type Output as b6, type PageResponse as b7, type PaginationOptions as b8, PartialSig 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 TreeSigningStartedEvent as s, TxTree as t, type TreeNoncesEvent as u, type BatchFinalizationEvent as v, type BatchFinalizedEvent as w, type BatchFailedEvent as x, type TreeTxEvent as y, type TreeSignatureEvent as z };
4435
+ 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, DigestMismatchError 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 Outpoint as aA, type ChainTx as aB, type PathContext as aC, type ArkTapscript as aD, type Asset as aE, type AssetMetadata as aF, type BaseWalletConfig as aG, type BatchInfo as aH, type BatchSignableIdentity as aI, CLTVMultisigTapscript as aJ, ChainTxType as aK, type CommitmentTx as aL, ConditionCSVMultisigTapscript as aM, ConditionMultisigTapscript as aN, type ContractBalance as aO, type ContractEventCallback as aP, type ContractHandler as aQ, type ContractManagerConfig as aR, type ContractState as aS, type ContractVtxo as aT, ContractWatcher as aU, DelegateManagerImpl as aV, type DelegateOptions as aW, DelegatorManagerImpl as aX, type DelegatorProvider as aY, type DeprecatedSignerMigrationReport as aZ, type DeprecatedSignerReport 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 MigrationGlobalSkipReason as as, type MigrationLegSkipReason as at, type SignerStatus as au, type StorageConfig as av, type IVtxoManager as aw, type ExplorerTransaction as ax, type EncodedVtxoScript as ay, type Status as az, type WalletConfig as b, type Discoverable as b0, type DiscoveredContract as b1, type DiscoveryDeps as b2, ESPLORA_URL as b3, EsploraProvider as b4, type ExtendedContractVtxo as b5, type HandlerError as b6, type IDelegatorManager as b7, IndexerTxType as b8, type KnownMetadata as b9, type Tx as bA, type TxHistoryRecord as bB, type TxKey as bC, type TxTreeNode as bD, TxType as bE, type VirtualStatus as bF, type Vtxo as bG, type VtxoChain as bH, type VtxoType as bI, type WalletMode as bJ, classifyAgainstSignerSet as bK, classifyContractSigner as bL, decodeTapscript as bM, getSequence as bN, isBatchSignable as bO, isCooperativelyMigratable as bP, isDiscoverable as bQ, isExpired as bR, isRecoverable as bS, isSpendable as bT, isSubdust as bU, isVtxoExpiringSoon as bV, networks as bW, signerSetFromInfo as bX, toXOnlySignerHex as bY, type MigrateDeprecatedSignerOptions as ba, type MigrationLegReport as bb, type MigrationVtxoRef as bc, MultisigTapscript as bd, type Nonces as be, type Output as bf, type PageResponse as bg, type PaginationOptions as bh, PartialSig as bi, type ProviderClass as bj, RestDelegateProvider as bk, RestDelegatorProvider as bl, type ScanContractsOptions as bm, type ScanResult as bn, type ScheduledSession as bo, SettlementEventType as bp, type SignRequest as bq, type SignerClassification as br, type SignerSet as bs, type SubscriptionEvent as bt, type SubscriptionHeartbeat as bu, type TapLeaves as bv, TapTreeCoder as bw, TapscriptType as bx, type TreeNonces as by, type TreePartialSigs 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-vFRA3F9b.cjs';
1
+ import { c as TaskQueue, b as TaskItem, d as TaskResult } from './taskRunner-DCyp6Gea.cjs';
2
2
 
3
3
  /**
4
4
  * Minimal async key-value storage interface.
@@ -46,4 +46,4 @@ declare class AsyncStorageTaskQueue implements TaskQueue {
46
46
  private writeList;
47
47
  }
48
48
 
49
- export { AsyncStorageTaskQueue as A, type AsyncStorageLike as a };
49
+ export { type AsyncStorageLike as A, AsyncStorageTaskQueue as a };
@@ -1,4 +1,4 @@
1
- import { a as TaskQueue, c as TaskItem, d as TaskResult } from './taskRunner-B1NUWyWR.js';
1
+ import { c as TaskQueue, b as TaskItem, d as TaskResult } from './taskRunner-DnxtObeq.js';
2
2
 
3
3
  /**
4
4
  * Minimal async key-value storage interface.
@@ -46,4 +46,4 @@ declare class AsyncStorageTaskQueue implements TaskQueue {
46
46
  private writeList;
47
47
  }
48
48
 
49
- export { AsyncStorageTaskQueue as A, type AsyncStorageLike as a };
49
+ export { type AsyncStorageLike as A, AsyncStorageTaskQueue as a };