money.sql 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. -- Wallet definitions for this contract.
  2. -- We store data that is needed to be able to receive and send tokens.
  3. -- TODO: The tables should be prefixed with ContractId to prevent collision
  4. -- Arbitrary info that is potentially useful
  5. CREATE TABLE IF NOT EXISTS BZHKGQ26bzmBithTQYTJtjo2QdCqpkR9tjSBopT4yf4o_money_info (
  6. last_scanned_block INTEGER NOT NULL
  7. );
  8. -- The Merkle tree containing coins
  9. CREATE TABLE IF NOT EXISTS BZHKGQ26bzmBithTQYTJtjo2QdCqpkR9tjSBopT4yf4o_money_tree (
  10. tree BLOB NOT NULL
  11. );
  12. -- The keypairs in our wallet
  13. CREATE TABLE IF NOT EXISTS BZHKGQ26bzmBithTQYTJtjo2QdCqpkR9tjSBopT4yf4o_money_keys (
  14. key_id INTEGER PRIMARY KEY NOT NULL,
  15. is_default INTEGER NOT NULL,
  16. public BLOB NOT NULL,
  17. secret BLOB NOT NULL
  18. );
  19. -- The coins we have the information to and can spend
  20. CREATE TABLE IF NOT EXISTS BZHKGQ26bzmBithTQYTJtjo2QdCqpkR9tjSBopT4yf4o_money_coins (
  21. coin BLOB PRIMARY KEY NOT NULL,
  22. is_spent INTEGER NOT NULL,
  23. value BLOB NOT NULL,
  24. token_id BLOB NOT NULL,
  25. spend_hook BLOB NOT NULL,
  26. user_data BLOB NOT NULL,
  27. coin_blind BLOB NOT NULL,
  28. value_blind BLOB NOT NULL,
  29. token_blind BLOB NOT NULL,
  30. secret BLOB NOT NULL,
  31. nullifier BLOB NOT NULL,
  32. leaf_position BLOB NOT NULL,
  33. memo BLOB
  34. );
  35. -- Arbitrary tokens
  36. CREATE TABLE IF NOT EXISTS BZHKGQ26bzmBithTQYTJtjo2QdCqpkR9tjSBopT4yf4o_money_tokens (
  37. mint_authority BLOB PRIMARY KEY NOT NULL,
  38. token_id BLOB NOT NULL,
  39. is_frozen INTEGER NOT NULL
  40. );
  41. -- The token aliases in our wallet
  42. CREATE TABLE IF NOT EXISTS BZHKGQ26bzmBithTQYTJtjo2QdCqpkR9tjSBopT4yf4o_money_aliases (
  43. alias BLOB PRIMARY KEY NOT NULL,
  44. token_id BLOB NOT NULL
  45. );
  46. CREATE TABLE IF NOT EXISTS BZHKGQ26bzmBithTQYTJtjo2QdCqpkR9tjSBopT4yf4o_transactions_history (
  47. id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  48. transaction_hash TEXT UNIQUE NOT NULL,
  49. status TEXT NOT NULL,
  50. tx TEXT UNIQUE NOT NULL
  51. );