Skip to content
LogoLogo

Vault

A vault policy (Liana-style) lets a primary key spend at any time and a recovery key spend only once the coin is old enough. If the primary key is lost, the recovery key takes over after the delay; if the recovery key leaks, the owner keeps moving coins before it can use them.

vault(primary, recovery, delay_blocks) =
  OR( KEY(primary),
      AND(KEY(recovery), OLDER(delay_blocks)) )

OLDER(n) is a relative timelock: it needs a version-2 transaction whose input sequence has bit 31 clear and sequence & 0xFFFF ≥ n, and consensus checks that the coin is at least n blocks old (tx-premature-relative otherwise). n ranges from 1 to 65,535 blocks; at 120 s per block, 720 blocks is about one day.

Steps

  1. Build the policy with the SDK's vault template and wrap it with policyLock.
  2. Pay coins to the lock. A POLICY lock has no address, so the payer needs the lock itself (or use it inside your own wallet).
  3. Everyday spend: sign with the primary key; the recovery branch is left empty.
  4. Recovery: wait delay_blocks after the coin confirmed, set the input sequence, sign with the recovery key.

Refresh coins (spend them to a new vault output) before the delay elapses if you want the recovery path to stay locked.