Repository navigation
Add vault and P2 singleton puzzle types and a Cloud Wallet–compatible vault layout #948
Copy link
Copy link
Open
Labels
databaseRelates to the database schema or queriesRelates to the database schema or queriesenhancementNew feature or requestNew feature or request
Description
Parent: #945
Phase: 1
Summary
Add the storage and puzzle building blocks that every later vault issue depends on:
- vault assets
P2SingletonandP2ConditionsOrSingletonp2 puzzle kinds- vault custody configs
- a builder and memo decoder that match Chia Cloud Wallet's vault layout exactly
Scope
- Migration
0011_vaults.sql(0010is taken by0010_synced_p2_puzzles.sqlfrom Import addresses as watch-only wallets #964):AssetKind::Vaultplus avaultstable with:- asset ID and launcher ID
- current custody hash and amount (read from chain; don't assume 1 mojo)
- puzzle version (
Legacy/ForceSingletonRecreation) - state (active, recovery pending, melted)
- Vault config tables:
- custody and recovery thresholds, and the recovery timelock
- members, each with: kind (BLS, secp256r1, secp256k1, passkey, singleton, custom), public key or launcher ID, and fast-forward flag
- a source: decoded from a verified memo, imported from a config file, or unknown
P2PuzzleKind::P2Singleton (launcher_id, nonce). Kinds 0–4 are taken;External(4) came with Import addresses as watch-only wallets #964.P2PuzzleKind::P2ConditionsOrSingleton (launcher_id, nonce, fixed_conditions_hash, version, revealed conditions), used for offer pre-split coins in Make, take, and cancel offers from a vault #955.CoinKind::Vault.- Recreate the coin views, as
0006_clawback_v1.sqldoes. - Update the hardcoded
kind IN (...)lists andsubscription_coin_ids. Import addresses as watch-only wallets #964 already keeps arbor and external puzzles out of coin-ID subscriptions;P2Singletonpuzzles are custody and should be handled the same way. - New
P2Singletonrows start withis_synced = 0(from Import addresses as watch-only wallets #964), so new vault nonces sync from the start of the chain. - Refresh the sqlx offline cache.
- Match arms. Handle the new
P2Puzzlevariants everywhere they're matched:Wallet::complete_spends(return a clear error until Spend from a vault: spend pipeline, signing, and XCH/CAT transactions #952),Sage::get_asset_coins,sage_wallet::database::insert_puzzle, and similar. - Vault layout module:
- A builder
VaultConfig → (custody_hash, CHIP-0043 memo)that matches ent-wallet'sgetVaultInternalsandgetVaultMipsMemoListBytesbyte for byte:- member hashes sorted by bytes
- R1, K1 and passkey members fast-forward; BLS not
- nonce 0
- the recovery restriction stack for each
VaultVersion
- A recovery-state builder: original custody plus the timelocked finish member.
- A memo decoder built on
MipsMemo::from_clvm_bounded+verify(expected_hash). It rejects any memo that doesn't rebuild the expected hash. P2Singletonaddress helpers for each nonce.
- A builder
- Test vectors. Port the vectors from chia-wallet-sdk
primitives/mips/memo/vault_tests.rsand from ent-wallet, so the implementations agree. The SDK's builder is test-only today; consider upstreaming this one. - Feature flag. Add
VITE_DISABLE_VAULTS, following the options and XCHandles flags.
Acceptance criteria
- The migration applies to existing databases without data loss.
- The builder reproduces the SDK and ent-wallet custody hashes and memo bytes for single-signer, M-of-N,
LegacyandForceSingletonRecreationlayouts. - The decoder rejects tampered, oversized and hash-mismatched memos.
- Both versions round-trip: config → memo → config.
Metadata
Metadata
Assignees
Labels
databaseRelates to the database schema or queriesRelates to the database schema or queriesenhancementNew feature or requestNew feature or request
Type
Projects
- StatusShow more project fieldsNo status
Activity