save

open override fun save(db: WalletDatabase)

Writes the current vault's unlock value, leaf index, and destination under contractDbKey. All values are read from destination.

On-disk layout:

  1. version byte

  2. unlock value (Int64)

  3. leaf index (Int32)

  4. the TimeLockVaultDestination itself

SERIALIZED_VERSION is written first so load can refuse a future-format record instead of mis-parsing it.

One record per contract — the key includes neither index nor unlock value — so save() always overwrites with the CURRENT vault and never rejects (forced shutdown saves must persist whatever exists). Prior vaults are not lost by the overwrite: their destinations survive in the wallet's receiving map (stamped with name) and on their tagged UTXOs — see knownVaults.

A no-op when no vault has been built yet — there is nothing to persist until buildDestination (or load) has run.