closeFactory
@totemsdk/omnia-factory / closeFactory
Function: closeFactory()
closeFactory(
factory,leaseProviders,chainProvider?):Promise<FactorySettlementPayload>
Cooperative N-of-N factory close.
Flow:
- Fail fast if
factory.fundingCoinIdis not set — settlement TX requires a concrete input coin. - Build the settlement OmniaTxDraft (N outputs, one per participant with a positive allocation) spending the factory's N-of-N MULTISIG input.
- Compute the TX draft digest via
computeTxDraftDigestfrom@totemsdk/omnia. - Collect N-of-N signatures — all participants sign + verify the TX digest via the full WOTS lease cycle (reserve → sign → verify → commit).
- Encode the concatenated WOTS signatures as the settlement TX witness.
- When
chainProvideris supplied: mine via@totemsdk/txpow'smineTxPoW, assemble the full TxPoW blob, and broadcast.
Parameters
factory
Active factory with no open virtual channels.
leaseProviders
Record<string, WotsLeaseBundle>
WOTS lease bundles for ALL N factory participants.
chainProvider?
ChainStateProvider
Optional: mine + broadcast the settlement TX.
Returns
Promise<FactorySettlementPayload>