Skip to content

feat(packages): multi-provider pegin support in PeginManager #1634

@jonybur

Description

@jonybur

Parent epic: #1633

Summary

Generalize PeginManager.preparePegin to accept multiple vault providers in one call. Today it accepts vaultProviderBtcPubkey: string (singular); needs to accept an array of providers and produce per-provider HTLC outputs while keeping the shared Pre-PegIn structure intact.

This is the foundation for the entire batch-vault-creation initiative — every other ticket in #1633 depends on this landing.

Scope

  • Extend PreparePeginParams with vaultProviders: { address: string; btcPubkey: string }[] (deprecate the singular field; keep a single-element-array shim for one release).
  • Update preparePegin() to loop sizing + commitment construction per provider while keeping the shared Pre-PegIn output structure intact.
  • Return: { perProvider: { provider: Address; transaction: PreparePeginTransaction }[] }.
  • Per CLAUDE.md §4: vault-secret derivation is per-vault, so each provider's vault gets its own root derivation. Add a two-vault test across distinct providers with overlapping funding inputs (mandatory per §4).

Files

  • packages/babylon-ts-sdk/src/tbv/core/managers/PeginManager.ts
  • packages/babylon-ts-sdk/src/tbv/core/primitives/psbt/pegin.ts (only if build helpers need adjusting)

Acceptance

  • Unit test: single-provider call produces output byte-identical to the current single-provider flow.
  • Unit test: two providers with overlapping funding inputs produce distinct vault roots (CLAUDE.md §4 two-vault test requirement).
  • All existing pegin tests pass unchanged.
  • Golden vectors in this repo and btc-vault re-verified.

Dependencies

None — this is foundational.

Metadata

Metadata

Assignees

No one assigned

    Labels

    deposit-flow-v2Deposit flow redesign (Figma frame 735:48725)enhancementNew feature or requesthighHigh-priority item

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions