@cogcoin/client 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (289) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +136 -0
  3. package/dist/app-paths.d.ts +38 -0
  4. package/dist/app-paths.js +121 -0
  5. package/dist/art/banner.txt +13 -0
  6. package/dist/art/scroll.txt +13 -0
  7. package/dist/art/train-car.txt +6 -0
  8. package/dist/art/train-smoke.txt +6 -0
  9. package/dist/art/train.txt +6 -0
  10. package/dist/bitcoind/bootstrap/chainstate.d.ts +4 -0
  11. package/dist/bitcoind/bootstrap/chainstate.js +13 -0
  12. package/dist/bitcoind/bootstrap/constants.d.ts +7 -0
  13. package/dist/bitcoind/bootstrap/constants.js +12 -0
  14. package/dist/bitcoind/bootstrap/controller.d.ts +29 -0
  15. package/dist/bitcoind/bootstrap/controller.js +101 -0
  16. package/dist/bitcoind/bootstrap/download.d.ts +2 -0
  17. package/dist/bitcoind/bootstrap/download.js +196 -0
  18. package/dist/bitcoind/bootstrap/headers.d.ts +13 -0
  19. package/dist/bitcoind/bootstrap/headers.js +61 -0
  20. package/dist/bitcoind/bootstrap/paths.d.ts +4 -0
  21. package/dist/bitcoind/bootstrap/paths.js +15 -0
  22. package/dist/bitcoind/bootstrap/snapshot-file.d.ts +7 -0
  23. package/dist/bitcoind/bootstrap/snapshot-file.js +42 -0
  24. package/dist/bitcoind/bootstrap/state.d.ts +40 -0
  25. package/dist/bitcoind/bootstrap/state.js +70 -0
  26. package/dist/bitcoind/bootstrap/types.d.ts +28 -0
  27. package/dist/bitcoind/bootstrap/types.js +1 -0
  28. package/dist/bitcoind/bootstrap.d.ts +8 -0
  29. package/dist/bitcoind/bootstrap.js +7 -0
  30. package/dist/bitcoind/client/factory.d.ts +3 -0
  31. package/dist/bitcoind/client/factory.js +57 -0
  32. package/dist/bitcoind/client/follow-block-times.d.ts +8 -0
  33. package/dist/bitcoind/client/follow-block-times.js +25 -0
  34. package/dist/bitcoind/client/follow-loop.d.ts +10 -0
  35. package/dist/bitcoind/client/follow-loop.js +57 -0
  36. package/dist/bitcoind/client/internal-types.d.ts +63 -0
  37. package/dist/bitcoind/client/internal-types.js +18 -0
  38. package/dist/bitcoind/client/managed-client.d.ts +20 -0
  39. package/dist/bitcoind/client/managed-client.js +197 -0
  40. package/dist/bitcoind/client/rate-tracker.d.ts +2 -0
  41. package/dist/bitcoind/client/rate-tracker.js +24 -0
  42. package/dist/bitcoind/client/sync-engine.d.ts +3 -0
  43. package/dist/bitcoind/client/sync-engine.js +143 -0
  44. package/dist/bitcoind/client.d.ts +1 -0
  45. package/dist/bitcoind/client.js +1 -0
  46. package/dist/bitcoind/errors.d.ts +1 -0
  47. package/dist/bitcoind/errors.js +49 -0
  48. package/dist/bitcoind/index.d.ts +2 -0
  49. package/dist/bitcoind/index.js +1 -0
  50. package/dist/bitcoind/indexer-daemon-main.d.ts +1 -0
  51. package/dist/bitcoind/indexer-daemon-main.js +472 -0
  52. package/dist/bitcoind/indexer-daemon.d.ts +107 -0
  53. package/dist/bitcoind/indexer-daemon.js +391 -0
  54. package/dist/bitcoind/node.d.ts +8 -0
  55. package/dist/bitcoind/node.js +219 -0
  56. package/dist/bitcoind/normalize.d.ts +3 -0
  57. package/dist/bitcoind/normalize.js +47 -0
  58. package/dist/bitcoind/progress/assets.d.ts +10 -0
  59. package/dist/bitcoind/progress/assets.js +90 -0
  60. package/dist/bitcoind/progress/constants.d.ts +48 -0
  61. package/dist/bitcoind/progress/constants.js +53 -0
  62. package/dist/bitcoind/progress/controller.d.ts +28 -0
  63. package/dist/bitcoind/progress/controller.js +188 -0
  64. package/dist/bitcoind/progress/follow-scene.d.ts +40 -0
  65. package/dist/bitcoind/progress/follow-scene.js +367 -0
  66. package/dist/bitcoind/progress/formatting.d.ts +23 -0
  67. package/dist/bitcoind/progress/formatting.js +227 -0
  68. package/dist/bitcoind/progress/quote-scene.d.ts +4 -0
  69. package/dist/bitcoind/progress/quote-scene.js +137 -0
  70. package/dist/bitcoind/progress/train-scene.d.ts +9 -0
  71. package/dist/bitcoind/progress/train-scene.js +92 -0
  72. package/dist/bitcoind/progress/tty-renderer.d.ts +18 -0
  73. package/dist/bitcoind/progress/tty-renderer.js +150 -0
  74. package/dist/bitcoind/progress.d.ts +7 -0
  75. package/dist/bitcoind/progress.js +7 -0
  76. package/dist/bitcoind/quotes.d.ts +24 -0
  77. package/dist/bitcoind/quotes.js +195 -0
  78. package/dist/bitcoind/rpc.d.ts +71 -0
  79. package/dist/bitcoind/rpc.js +322 -0
  80. package/dist/bitcoind/service-paths.d.ts +19 -0
  81. package/dist/bitcoind/service-paths.js +49 -0
  82. package/dist/bitcoind/service.d.ts +40 -0
  83. package/dist/bitcoind/service.js +735 -0
  84. package/dist/bitcoind/testing.d.ts +9 -0
  85. package/dist/bitcoind/testing.js +9 -0
  86. package/dist/bitcoind/types.d.ts +396 -0
  87. package/dist/bitcoind/types.js +3 -0
  88. package/dist/bytes.d.ts +9 -0
  89. package/dist/bytes.js +36 -0
  90. package/dist/cli/commands/follow.d.ts +2 -0
  91. package/dist/cli/commands/follow.js +43 -0
  92. package/dist/cli/commands/mining-admin.d.ts +2 -0
  93. package/dist/cli/commands/mining-admin.js +92 -0
  94. package/dist/cli/commands/mining-read.d.ts +2 -0
  95. package/dist/cli/commands/mining-read.js +173 -0
  96. package/dist/cli/commands/mining-runtime.d.ts +2 -0
  97. package/dist/cli/commands/mining-runtime.js +108 -0
  98. package/dist/cli/commands/status.d.ts +2 -0
  99. package/dist/cli/commands/status.js +31 -0
  100. package/dist/cli/commands/sync.d.ts +2 -0
  101. package/dist/cli/commands/sync.js +52 -0
  102. package/dist/cli/commands/wallet-admin.d.ts +2 -0
  103. package/dist/cli/commands/wallet-admin.js +175 -0
  104. package/dist/cli/commands/wallet-mutation.d.ts +2 -0
  105. package/dist/cli/commands/wallet-mutation.js +681 -0
  106. package/dist/cli/commands/wallet-read.d.ts +2 -0
  107. package/dist/cli/commands/wallet-read.js +265 -0
  108. package/dist/cli/context.d.ts +3 -0
  109. package/dist/cli/context.js +75 -0
  110. package/dist/cli/io.d.ts +3 -0
  111. package/dist/cli/io.js +12 -0
  112. package/dist/cli/mining-format.d.ts +5 -0
  113. package/dist/cli/mining-format.js +156 -0
  114. package/dist/cli/mining-json.d.ts +49 -0
  115. package/dist/cli/mining-json.js +89 -0
  116. package/dist/cli/mutation-command-groups.d.ts +15 -0
  117. package/dist/cli/mutation-command-groups.js +71 -0
  118. package/dist/cli/mutation-json.d.ts +430 -0
  119. package/dist/cli/mutation-json.js +311 -0
  120. package/dist/cli/mutation-resolved-json.d.ts +124 -0
  121. package/dist/cli/mutation-resolved-json.js +129 -0
  122. package/dist/cli/mutation-success.d.ts +20 -0
  123. package/dist/cli/mutation-success.js +47 -0
  124. package/dist/cli/mutation-text-format.d.ts +22 -0
  125. package/dist/cli/mutation-text-format.js +171 -0
  126. package/dist/cli/mutation-text-write.d.ts +13 -0
  127. package/dist/cli/mutation-text-write.js +16 -0
  128. package/dist/cli/output.d.ts +185 -0
  129. package/dist/cli/output.js +1085 -0
  130. package/dist/cli/parse.d.ts +3 -0
  131. package/dist/cli/parse.js +971 -0
  132. package/dist/cli/preview-json.d.ts +416 -0
  133. package/dist/cli/preview-json.js +293 -0
  134. package/dist/cli/prompt.d.ts +3 -0
  135. package/dist/cli/prompt.js +33 -0
  136. package/dist/cli/read-json.d.ts +187 -0
  137. package/dist/cli/read-json.js +675 -0
  138. package/dist/cli/runner.d.ts +2 -0
  139. package/dist/cli/runner.js +129 -0
  140. package/dist/cli/signals.d.ts +3 -0
  141. package/dist/cli/signals.js +63 -0
  142. package/dist/cli/status-format.d.ts +2 -0
  143. package/dist/cli/status-format.js +48 -0
  144. package/dist/cli/types.d.ts +148 -0
  145. package/dist/cli/types.js +2 -0
  146. package/dist/cli/wallet-format.d.ts +29 -0
  147. package/dist/cli/wallet-format.js +637 -0
  148. package/dist/cli/workflow-hints.d.ts +13 -0
  149. package/dist/cli/workflow-hints.js +94 -0
  150. package/dist/cli-runner.d.ts +3 -0
  151. package/dist/cli-runner.js +3 -0
  152. package/dist/cli.d.ts +2 -0
  153. package/dist/cli.js +6 -0
  154. package/dist/client/default-client.d.ts +11 -0
  155. package/dist/client/default-client.js +118 -0
  156. package/dist/client/factory.d.ts +2 -0
  157. package/dist/client/factory.js +15 -0
  158. package/dist/client/initialization.d.ts +6 -0
  159. package/dist/client/initialization.js +30 -0
  160. package/dist/client/persistence.d.ts +5 -0
  161. package/dist/client/persistence.js +28 -0
  162. package/dist/client/store-adapter.d.ts +3 -0
  163. package/dist/client/store-adapter.js +20 -0
  164. package/dist/client.d.ts +2 -0
  165. package/dist/client.js +2 -0
  166. package/dist/index.d.ts +2 -0
  167. package/dist/index.js +1 -0
  168. package/dist/passive-status.d.ts +36 -0
  169. package/dist/passive-status.js +100 -0
  170. package/dist/sqlite/better-sqlite3.d.ts +26 -0
  171. package/dist/sqlite/better-sqlite3.js +4 -0
  172. package/dist/sqlite/checkpoints.d.ts +11 -0
  173. package/dist/sqlite/checkpoints.js +27 -0
  174. package/dist/sqlite/driver.d.ts +17 -0
  175. package/dist/sqlite/driver.js +98 -0
  176. package/dist/sqlite/index.d.ts +4 -0
  177. package/dist/sqlite/index.js +9 -0
  178. package/dist/sqlite/migrate.d.ts +2 -0
  179. package/dist/sqlite/migrate.js +37 -0
  180. package/dist/sqlite/store.d.ts +3 -0
  181. package/dist/sqlite/store.js +122 -0
  182. package/dist/sqlite/tip-meta.d.ts +26 -0
  183. package/dist/sqlite/tip-meta.js +97 -0
  184. package/dist/sqlite/types.d.ts +10 -0
  185. package/dist/sqlite/types.js +1 -0
  186. package/dist/types.d.ts +55 -0
  187. package/dist/types.js +1 -0
  188. package/dist/wallet/archive.d.ts +4 -0
  189. package/dist/wallet/archive.js +39 -0
  190. package/dist/wallet/cogop/constants.d.ts +32 -0
  191. package/dist/wallet/cogop/constants.js +32 -0
  192. package/dist/wallet/cogop/index.d.ts +32 -0
  193. package/dist/wallet/cogop/index.js +213 -0
  194. package/dist/wallet/cogop/numeric.d.ts +3 -0
  195. package/dist/wallet/cogop/numeric.js +24 -0
  196. package/dist/wallet/cogop/scriptpubkey.d.ts +2 -0
  197. package/dist/wallet/cogop/scriptpubkey.js +13 -0
  198. package/dist/wallet/cogop/validate-name.d.ts +2 -0
  199. package/dist/wallet/cogop/validate-name.js +18 -0
  200. package/dist/wallet/fs/atomic.d.ts +6 -0
  201. package/dist/wallet/fs/atomic.js +46 -0
  202. package/dist/wallet/fs/lock.d.ts +19 -0
  203. package/dist/wallet/fs/lock.js +61 -0
  204. package/dist/wallet/fs/status-file.d.ts +1 -0
  205. package/dist/wallet/fs/status-file.js +4 -0
  206. package/dist/wallet/lifecycle.d.ts +193 -0
  207. package/dist/wallet/lifecycle.js +1475 -0
  208. package/dist/wallet/material.d.ts +45 -0
  209. package/dist/wallet/material.js +118 -0
  210. package/dist/wallet/mining/config.d.ts +18 -0
  211. package/dist/wallet/mining/config.js +44 -0
  212. package/dist/wallet/mining/constants.d.ts +24 -0
  213. package/dist/wallet/mining/constants.js +24 -0
  214. package/dist/wallet/mining/control.d.ts +53 -0
  215. package/dist/wallet/mining/control.js +758 -0
  216. package/dist/wallet/mining/coordination.d.ts +40 -0
  217. package/dist/wallet/mining/coordination.js +121 -0
  218. package/dist/wallet/mining/hook-protocol.d.ts +47 -0
  219. package/dist/wallet/mining/hook-protocol.js +161 -0
  220. package/dist/wallet/mining/hook-runner.d.ts +1 -0
  221. package/dist/wallet/mining/hook-runner.js +52 -0
  222. package/dist/wallet/mining/hooks.d.ts +38 -0
  223. package/dist/wallet/mining/hooks.js +520 -0
  224. package/dist/wallet/mining/index.d.ts +8 -0
  225. package/dist/wallet/mining/index.js +6 -0
  226. package/dist/wallet/mining/runner.d.ts +155 -0
  227. package/dist/wallet/mining/runner.js +2574 -0
  228. package/dist/wallet/mining/runtime-artifacts.d.ts +17 -0
  229. package/dist/wallet/mining/runtime-artifacts.js +166 -0
  230. package/dist/wallet/mining/sentences.d.ts +23 -0
  231. package/dist/wallet/mining/sentences.js +281 -0
  232. package/dist/wallet/mining/state.d.ts +9 -0
  233. package/dist/wallet/mining/state.js +75 -0
  234. package/dist/wallet/mining/types.d.ts +141 -0
  235. package/dist/wallet/mining/types.js +1 -0
  236. package/dist/wallet/mining/visualizer.d.ts +19 -0
  237. package/dist/wallet/mining/visualizer.js +134 -0
  238. package/dist/wallet/mining/worker-main.d.ts +1 -0
  239. package/dist/wallet/mining/worker-main.js +17 -0
  240. package/dist/wallet/read/context.d.ts +20 -0
  241. package/dist/wallet/read/context.js +532 -0
  242. package/dist/wallet/read/filter.d.ts +9 -0
  243. package/dist/wallet/read/filter.js +42 -0
  244. package/dist/wallet/read/index.d.ts +4 -0
  245. package/dist/wallet/read/index.js +3 -0
  246. package/dist/wallet/read/project.d.ts +11 -0
  247. package/dist/wallet/read/project.js +300 -0
  248. package/dist/wallet/read/types.d.ts +144 -0
  249. package/dist/wallet/read/types.js +1 -0
  250. package/dist/wallet/runtime.d.ts +26 -0
  251. package/dist/wallet/runtime.js +28 -0
  252. package/dist/wallet/state/crypto.d.ts +31 -0
  253. package/dist/wallet/state/crypto.js +127 -0
  254. package/dist/wallet/state/provider.d.ts +37 -0
  255. package/dist/wallet/state/provider.js +312 -0
  256. package/dist/wallet/state/session.d.ts +12 -0
  257. package/dist/wallet/state/session.js +23 -0
  258. package/dist/wallet/state/storage.d.ts +19 -0
  259. package/dist/wallet/state/storage.js +55 -0
  260. package/dist/wallet/tx/anchor.d.ts +40 -0
  261. package/dist/wallet/tx/anchor.js +1210 -0
  262. package/dist/wallet/tx/cog.d.ts +92 -0
  263. package/dist/wallet/tx/cog.js +1055 -0
  264. package/dist/wallet/tx/common.d.ts +89 -0
  265. package/dist/wallet/tx/common.js +156 -0
  266. package/dist/wallet/tx/confirm.d.ts +15 -0
  267. package/dist/wallet/tx/confirm.js +24 -0
  268. package/dist/wallet/tx/domain-admin.d.ts +105 -0
  269. package/dist/wallet/tx/domain-admin.js +869 -0
  270. package/dist/wallet/tx/domain-market.d.ts +112 -0
  271. package/dist/wallet/tx/domain-market.js +1365 -0
  272. package/dist/wallet/tx/field.d.ts +101 -0
  273. package/dist/wallet/tx/field.js +1853 -0
  274. package/dist/wallet/tx/identity-selector.d.ts +12 -0
  275. package/dist/wallet/tx/identity-selector.js +52 -0
  276. package/dist/wallet/tx/index.d.ts +7 -0
  277. package/dist/wallet/tx/index.js +7 -0
  278. package/dist/wallet/tx/journal.d.ts +5 -0
  279. package/dist/wallet/tx/journal.js +31 -0
  280. package/dist/wallet/tx/register.d.ts +68 -0
  281. package/dist/wallet/tx/register.js +952 -0
  282. package/dist/wallet/tx/reputation.d.ts +72 -0
  283. package/dist/wallet/tx/reputation.js +693 -0
  284. package/dist/wallet/tx/targets.d.ts +7 -0
  285. package/dist/wallet/tx/targets.js +122 -0
  286. package/dist/wallet/types.d.ts +249 -0
  287. package/dist/wallet/types.js +1 -0
  288. package/dist/writing_quotes.json +1654 -0
  289. package/package.json +78 -0
@@ -0,0 +1,98 @@
1
+ import { cloneBytes } from "../bytes.js";
2
+ import { loadBetterSqlite3 } from "./better-sqlite3.js";
3
+ function normalizeValue(value) {
4
+ if (value instanceof Uint8Array) {
5
+ return Buffer.from(value);
6
+ }
7
+ return value;
8
+ }
9
+ function normalizeRow(row) {
10
+ if (row === null || row === undefined) {
11
+ return null;
12
+ }
13
+ if (typeof row !== "object" || row === null) {
14
+ return row;
15
+ }
16
+ const next = { ...row };
17
+ for (const [key, value] of Object.entries(next)) {
18
+ if (value instanceof Uint8Array) {
19
+ next[key] = cloneBytes(value);
20
+ }
21
+ else if (Buffer.isBuffer(value)) {
22
+ next[key] = new Uint8Array(value);
23
+ }
24
+ }
25
+ return next;
26
+ }
27
+ function normalizeRows(rows) {
28
+ return rows.map((row) => normalizeRow(row));
29
+ }
30
+ async function openBetterSqliteDatabase(options) {
31
+ const BetterSqlite3 = await loadBetterSqlite3();
32
+ const openOptions = {};
33
+ if (options.fileMustExist !== undefined) {
34
+ openOptions.fileMustExist = options.fileMustExist;
35
+ }
36
+ if (options.readonly !== undefined) {
37
+ openOptions.readonly = options.readonly;
38
+ }
39
+ const database = new BetterSqlite3(options.filename, openOptions);
40
+ return {
41
+ async exec(sql) {
42
+ database.exec(sql);
43
+ },
44
+ async run(sql, params = []) {
45
+ const statement = database.prepare(sql);
46
+ const result = statement.run(...params.map(normalizeValue));
47
+ return {
48
+ changes: Number(result.changes),
49
+ lastInsertRowid: result.lastInsertRowid,
50
+ };
51
+ },
52
+ async get(sql, params = []) {
53
+ const statement = database.prepare(sql);
54
+ return normalizeRow(statement.get(...params.map(normalizeValue)) ?? null);
55
+ },
56
+ async all(sql, params = []) {
57
+ const statement = database.prepare(sql);
58
+ return normalizeRows(statement.all(...params.map(normalizeValue)) ?? []);
59
+ },
60
+ async transaction(operation) {
61
+ database.exec("BEGIN IMMEDIATE");
62
+ try {
63
+ const result = await operation();
64
+ database.exec("COMMIT");
65
+ return result;
66
+ }
67
+ catch (error) {
68
+ database.exec("ROLLBACK");
69
+ throw error;
70
+ }
71
+ },
72
+ async close() {
73
+ database.close();
74
+ },
75
+ };
76
+ }
77
+ async function applyPragmas(database, pragmas) {
78
+ const foreignKeys = pragmas?.foreignKeys ?? true;
79
+ const busyTimeoutMs = pragmas?.busyTimeoutMs ?? 5000;
80
+ const journalMode = pragmas?.journalMode ?? "WAL";
81
+ const synchronous = pragmas?.synchronous ?? "FULL";
82
+ await database.exec(`PRAGMA foreign_keys = ${foreignKeys ? "ON" : "OFF"}`);
83
+ await database.exec(`PRAGMA busy_timeout = ${busyTimeoutMs}`);
84
+ await database.get("PRAGMA journal_mode = " + journalMode);
85
+ await database.exec(`PRAGMA synchronous = ${synchronous}`);
86
+ }
87
+ export async function openSqliteDatabase(options) {
88
+ const database = await openBetterSqliteDatabase(options);
89
+ await applyPragmas(database, options.pragmas);
90
+ return database;
91
+ }
92
+ export async function openReadonlySqliteDatabase(filename) {
93
+ return openBetterSqliteDatabase({
94
+ filename,
95
+ fileMustExist: true,
96
+ readonly: true,
97
+ });
98
+ }
@@ -0,0 +1,4 @@
1
+ import type { SqliteStoreOptions } from "./types.js";
2
+ export { migrateSqliteStore } from "./migrate.js";
3
+ export type * from "./types.js";
4
+ export declare function openSqliteStore(options: SqliteStoreOptions): Promise<import("../types.js").ClientStoreAdapter>;
@@ -0,0 +1,9 @@
1
+ import { createSqliteStoreAdapter } from "./store.js";
2
+ import { openSqliteDatabase } from "./driver.js";
3
+ import { migrateSqliteStore } from "./migrate.js";
4
+ export { migrateSqliteStore } from "./migrate.js";
5
+ export async function openSqliteStore(options) {
6
+ const database = await openSqliteDatabase(options);
7
+ await migrateSqliteStore(database);
8
+ return createSqliteStoreAdapter(database);
9
+ }
@@ -0,0 +1,2 @@
1
+ import type { SqliteDatabase } from "./driver.js";
2
+ export declare function migrateSqliteStore(database: SqliteDatabase): Promise<void>;
@@ -0,0 +1,37 @@
1
+ const SCHEMA_VERSION = 1;
2
+ export async function migrateSqliteStore(database) {
3
+ const versionRow = await database.get("PRAGMA user_version");
4
+ const currentVersion = versionRow?.user_version ?? 0;
5
+ if (currentVersion > SCHEMA_VERSION) {
6
+ throw new Error("sqlite_store_schema_version_unsupported");
7
+ }
8
+ if (currentVersion === 0) {
9
+ await database.transaction(async () => {
10
+ await database.exec(`
11
+ CREATE TABLE IF NOT EXISTS meta (
12
+ key TEXT PRIMARY KEY,
13
+ value BLOB NOT NULL
14
+ )
15
+ `);
16
+ await database.exec(`
17
+ CREATE TABLE IF NOT EXISTS checkpoints (
18
+ height INTEGER PRIMARY KEY,
19
+ block_hash BLOB NOT NULL,
20
+ state_bytes BLOB NOT NULL,
21
+ created_at INTEGER NOT NULL
22
+ )
23
+ `);
24
+ await database.exec(`
25
+ CREATE TABLE IF NOT EXISTS block_records (
26
+ height INTEGER PRIMARY KEY,
27
+ block_hash BLOB NOT NULL UNIQUE,
28
+ previous_hash BLOB NOT NULL,
29
+ record_bytes BLOB NOT NULL,
30
+ state_hash_hex TEXT NOT NULL,
31
+ created_at INTEGER NOT NULL
32
+ )
33
+ `);
34
+ await database.exec("PRAGMA user_version = 1");
35
+ });
36
+ }
37
+ }
@@ -0,0 +1,3 @@
1
+ import type { ClientStoreAdapter } from "../types.js";
2
+ import type { SqliteDatabase } from "./driver.js";
3
+ export declare function createSqliteStoreAdapter(database: SqliteDatabase): ClientStoreAdapter;
@@ -0,0 +1,122 @@
1
+ import { bytesToHex, cloneBytes, hexToBytes, } from "../bytes.js";
2
+ import { deleteCheckpointsAbove, loadLatestCheckpoint, replaceCheckpoint, } from "./checkpoints.js";
3
+ import { loadTipSnapshotMeta, writeTipMeta, } from "./tip-meta.js";
4
+ export function createSqliteStoreAdapter(database) {
5
+ let writeQueue = Promise.resolve();
6
+ let closed = false;
7
+ function assertOpen() {
8
+ if (closed) {
9
+ throw new Error("sqlite_store_closed");
10
+ }
11
+ }
12
+ function enqueueWrite(operation) {
13
+ const next = writeQueue.then(operation, operation);
14
+ writeQueue = next.then(() => undefined, () => undefined);
15
+ return next;
16
+ }
17
+ return {
18
+ async loadTip() {
19
+ assertOpen();
20
+ const decoded = await loadTipSnapshotMeta(database);
21
+ return decoded === null ? null : decoded.tip;
22
+ },
23
+ async loadLatestSnapshot() {
24
+ assertOpen();
25
+ const tipMeta = await loadTipSnapshotMeta(database);
26
+ if (tipMeta !== null) {
27
+ return {
28
+ height: tipMeta.tip.height,
29
+ blockHashHex: tipMeta.tip.blockHashHex,
30
+ stateBytes: tipMeta.stateBytes,
31
+ createdAt: tipMeta.updatedAt,
32
+ };
33
+ }
34
+ const row = await loadLatestCheckpoint(database);
35
+ if (row === null) {
36
+ return null;
37
+ }
38
+ return {
39
+ height: row.height,
40
+ blockHashHex: row.blockHashHex,
41
+ stateBytes: row.stateBytes,
42
+ createdAt: row.createdAt,
43
+ };
44
+ },
45
+ async loadBlockRecordsAfter(height) {
46
+ assertOpen();
47
+ const rows = await database.all(`SELECT height, block_hash, previous_hash, record_bytes, state_hash_hex, created_at
48
+ FROM block_records
49
+ WHERE height > ?
50
+ ORDER BY height ASC`, [height]);
51
+ return rows.map((row) => ({
52
+ height: row.height,
53
+ blockHashHex: bytesToHex(row.block_hash),
54
+ previousHashHex: row.previous_hash.length === 0 ? null : bytesToHex(row.previous_hash),
55
+ stateHashHex: row.state_hash_hex.length === 0 ? null : row.state_hash_hex,
56
+ recordBytes: cloneBytes(row.record_bytes),
57
+ createdAt: row.created_at,
58
+ }));
59
+ },
60
+ async writeAppliedBlock(entry) {
61
+ assertOpen();
62
+ await enqueueWrite(async () => {
63
+ const createdAt = entry.blockRecord?.createdAt ?? entry.checkpoint?.createdAt ?? Date.now();
64
+ await database.transaction(async () => {
65
+ if (entry.deleteAboveHeight !== null && entry.deleteAboveHeight !== undefined) {
66
+ await database.run(`DELETE FROM block_records WHERE height > ?`, [entry.deleteAboveHeight]);
67
+ await deleteCheckpointsAbove(database, entry.deleteAboveHeight);
68
+ }
69
+ if (entry.blockRecord !== null && entry.blockRecord !== undefined) {
70
+ await database.run(`INSERT INTO block_records (height, block_hash, previous_hash, record_bytes, state_hash_hex, created_at)
71
+ VALUES (?, ?, ?, ?, ?, ?)`, [
72
+ entry.blockRecord.height,
73
+ hexToBytes(entry.blockRecord.blockHashHex),
74
+ entry.blockRecord.previousHashHex === null ? new Uint8Array() : hexToBytes(entry.blockRecord.previousHashHex),
75
+ entry.blockRecord.recordBytes,
76
+ entry.blockRecord.stateHashHex ?? "",
77
+ entry.blockRecord.createdAt,
78
+ ]);
79
+ }
80
+ await writeTipMeta(database, entry.tip, entry.stateBytes, createdAt);
81
+ if (entry.checkpoint !== null && entry.checkpoint !== undefined) {
82
+ await replaceCheckpoint(database, entry.checkpoint);
83
+ }
84
+ });
85
+ });
86
+ },
87
+ async deleteBlockRecordsAbove(height) {
88
+ assertOpen();
89
+ await enqueueWrite(async () => {
90
+ await database.transaction(async () => {
91
+ await database.run(`DELETE FROM block_records WHERE height > ?`, [height]);
92
+ await deleteCheckpointsAbove(database, height);
93
+ });
94
+ });
95
+ },
96
+ async loadBlockRecord(height) {
97
+ assertOpen();
98
+ const row = await database.get(`SELECT height, block_hash, previous_hash, record_bytes, state_hash_hex, created_at
99
+ FROM block_records
100
+ WHERE height = ?`, [height]);
101
+ if (row === null) {
102
+ return null;
103
+ }
104
+ return {
105
+ height: row.height,
106
+ blockHashHex: bytesToHex(row.block_hash),
107
+ previousHashHex: row.previous_hash.length === 0 ? null : bytesToHex(row.previous_hash),
108
+ stateHashHex: row.state_hash_hex.length === 0 ? null : row.state_hash_hex,
109
+ recordBytes: cloneBytes(row.record_bytes),
110
+ createdAt: row.created_at,
111
+ };
112
+ },
113
+ async close() {
114
+ if (closed) {
115
+ return;
116
+ }
117
+ await writeQueue;
118
+ closed = true;
119
+ await database.close();
120
+ },
121
+ };
122
+ }
@@ -0,0 +1,26 @@
1
+ import type { ClientTip } from "../types.js";
2
+ import type { SqliteDatabase } from "./driver.js";
3
+ export declare const TIP_META_KEYS: {
4
+ readonly tipHeight: "tip_height";
5
+ readonly tipBlockHash: "tip_block_hash";
6
+ readonly tipPreviousHash: "tip_previous_hash";
7
+ readonly tipStateHashHex: "tip_state_hash_hex";
8
+ readonly tipStateBytes: "tip_state_bytes";
9
+ readonly tipUpdatedAt: "tip_updated_at";
10
+ };
11
+ export interface StoredTipMeta {
12
+ tip: ClientTip;
13
+ stateBytes: Uint8Array | null;
14
+ updatedAt: number;
15
+ }
16
+ export interface StoredTipSnapshot {
17
+ tip: ClientTip;
18
+ stateBytes: Uint8Array;
19
+ updatedAt: number;
20
+ }
21
+ export declare function decodeTipMeta(meta: Map<string, Uint8Array>): StoredTipMeta | null;
22
+ export declare function requireTipStateBytes(meta: StoredTipMeta | null): StoredTipSnapshot | null;
23
+ export declare function loadTipMeta(database: SqliteDatabase): Promise<StoredTipMeta | null>;
24
+ export declare function loadTipSnapshotMeta(database: SqliteDatabase): Promise<StoredTipSnapshot | null>;
25
+ export declare function clearTipMeta(database: SqliteDatabase): Promise<void>;
26
+ export declare function writeTipMeta(database: SqliteDatabase, tip: ClientTip | null, stateBytes: Uint8Array | null, updatedAt: number): Promise<void>;
@@ -0,0 +1,97 @@
1
+ import { bytesToHex, cloneBytes, decodeInteger, decodeNullableText, encodeInteger, encodeNullableText, hexToBytes, } from "../bytes.js";
2
+ export const TIP_META_KEYS = {
3
+ tipHeight: "tip_height",
4
+ tipBlockHash: "tip_block_hash",
5
+ tipPreviousHash: "tip_previous_hash",
6
+ tipStateHashHex: "tip_state_hash_hex",
7
+ tipStateBytes: "tip_state_bytes",
8
+ tipUpdatedAt: "tip_updated_at",
9
+ };
10
+ function readMetaValue(meta, key) {
11
+ return meta.get(key) ?? null;
12
+ }
13
+ function allTipMetaKeys() {
14
+ return [
15
+ TIP_META_KEYS.tipHeight,
16
+ TIP_META_KEYS.tipBlockHash,
17
+ TIP_META_KEYS.tipPreviousHash,
18
+ TIP_META_KEYS.tipStateHashHex,
19
+ TIP_META_KEYS.tipStateBytes,
20
+ TIP_META_KEYS.tipUpdatedAt,
21
+ ];
22
+ }
23
+ export function decodeTipMeta(meta) {
24
+ const heightBytes = readMetaValue(meta, TIP_META_KEYS.tipHeight);
25
+ const hashBytes = readMetaValue(meta, TIP_META_KEYS.tipBlockHash);
26
+ const previousHashBytes = readMetaValue(meta, TIP_META_KEYS.tipPreviousHash);
27
+ const stateHashHexBytes = readMetaValue(meta, TIP_META_KEYS.tipStateHashHex);
28
+ const stateBytes = readMetaValue(meta, TIP_META_KEYS.tipStateBytes);
29
+ const updatedAtBytes = readMetaValue(meta, TIP_META_KEYS.tipUpdatedAt);
30
+ if (heightBytes === null &&
31
+ hashBytes === null &&
32
+ previousHashBytes === null &&
33
+ stateHashHexBytes === null &&
34
+ stateBytes === null &&
35
+ updatedAtBytes === null) {
36
+ return null;
37
+ }
38
+ if (heightBytes === null ||
39
+ hashBytes === null ||
40
+ previousHashBytes === null ||
41
+ stateHashHexBytes === null ||
42
+ updatedAtBytes === null) {
43
+ throw new Error("sqlite_store_tip_meta_incomplete");
44
+ }
45
+ return {
46
+ tip: {
47
+ height: decodeInteger(heightBytes),
48
+ blockHashHex: bytesToHex(hashBytes),
49
+ previousHashHex: previousHashBytes.length === 0 ? null : bytesToHex(previousHashBytes),
50
+ stateHashHex: decodeNullableText(stateHashHexBytes),
51
+ },
52
+ stateBytes: stateBytes === null ? null : cloneBytes(stateBytes),
53
+ updatedAt: decodeInteger(updatedAtBytes),
54
+ };
55
+ }
56
+ export function requireTipStateBytes(meta) {
57
+ if (meta === null) {
58
+ return null;
59
+ }
60
+ if (meta.stateBytes === null) {
61
+ throw new Error("sqlite_store_tip_meta_incomplete");
62
+ }
63
+ return {
64
+ tip: meta.tip,
65
+ stateBytes: meta.stateBytes,
66
+ updatedAt: meta.updatedAt,
67
+ };
68
+ }
69
+ export async function loadTipMeta(database) {
70
+ const rows = await database.all(`SELECT key, value FROM meta WHERE key IN (?, ?, ?, ?, ?, ?)`, allTipMetaKeys());
71
+ const meta = new Map();
72
+ for (const row of rows) {
73
+ meta.set(row.key, cloneBytes(row.value));
74
+ }
75
+ return decodeTipMeta(meta);
76
+ }
77
+ export async function loadTipSnapshotMeta(database) {
78
+ return requireTipStateBytes(await loadTipMeta(database));
79
+ }
80
+ async function upsertMeta(database, key, value) {
81
+ await database.run(`INSERT INTO meta (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value`, [key, value]);
82
+ }
83
+ export async function clearTipMeta(database) {
84
+ await database.run(`DELETE FROM meta WHERE key IN (?, ?, ?, ?, ?, ?)`, allTipMetaKeys());
85
+ }
86
+ export async function writeTipMeta(database, tip, stateBytes, updatedAt) {
87
+ if (tip === null || stateBytes === null) {
88
+ await clearTipMeta(database);
89
+ return;
90
+ }
91
+ await upsertMeta(database, TIP_META_KEYS.tipHeight, encodeInteger(tip.height));
92
+ await upsertMeta(database, TIP_META_KEYS.tipBlockHash, hexToBytes(tip.blockHashHex));
93
+ await upsertMeta(database, TIP_META_KEYS.tipPreviousHash, tip.previousHashHex === null ? new Uint8Array() : hexToBytes(tip.previousHashHex));
94
+ await upsertMeta(database, TIP_META_KEYS.tipStateHashHex, encodeNullableText(tip.stateHashHex));
95
+ await upsertMeta(database, TIP_META_KEYS.tipStateBytes, stateBytes);
96
+ await upsertMeta(database, TIP_META_KEYS.tipUpdatedAt, encodeInteger(updatedAt));
97
+ }
@@ -0,0 +1,10 @@
1
+ export interface SqlitePragmaOptions {
2
+ foreignKeys?: boolean;
3
+ busyTimeoutMs?: number;
4
+ journalMode?: "WAL" | "DELETE" | "TRUNCATE" | "PERSIST" | "MEMORY" | "OFF";
5
+ synchronous?: "FULL" | "NORMAL" | "OFF" | "EXTRA";
6
+ }
7
+ export interface SqliteStoreOptions {
8
+ filename: string;
9
+ pragmas?: SqlitePragmaOptions;
10
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,55 @@
1
+ import type { AppliedBlock, BitcoinBlock, BlockRecord, GenesisParameters, IndexerState } from "@cogcoin/indexer/types";
2
+ export interface ClientTip {
3
+ height: number;
4
+ blockHashHex: string;
5
+ previousHashHex: string | null;
6
+ stateHashHex: string | null;
7
+ }
8
+ export interface ClientCheckpoint {
9
+ height: number;
10
+ blockHashHex: string;
11
+ stateBytes: Uint8Array;
12
+ createdAt: number;
13
+ }
14
+ export interface StoredBlockRecord {
15
+ height: number;
16
+ blockHashHex: string;
17
+ previousHashHex: string | null;
18
+ stateHashHex: string | null;
19
+ recordBytes: Uint8Array;
20
+ createdAt: number;
21
+ }
22
+ export interface WriteAppliedBlockEntry {
23
+ tip: ClientTip | null;
24
+ stateBytes: Uint8Array | null;
25
+ blockRecord?: StoredBlockRecord | null;
26
+ checkpoint?: ClientCheckpoint | null;
27
+ deleteAboveHeight?: number | null;
28
+ }
29
+ export interface ClientStoreAdapter {
30
+ loadTip(): Promise<ClientTip | null>;
31
+ loadLatestSnapshot(): Promise<ClientCheckpoint | null>;
32
+ loadBlockRecordsAfter(height: number): Promise<StoredBlockRecord[]>;
33
+ writeAppliedBlock(entry: WriteAppliedBlockEntry): Promise<void>;
34
+ deleteBlockRecordsAbove(height: number): Promise<void>;
35
+ loadBlockRecord(height: number): Promise<StoredBlockRecord | null>;
36
+ close(): Promise<void>;
37
+ }
38
+ export interface ClientOptions {
39
+ store: ClientStoreAdapter;
40
+ genesisParameters?: GenesisParameters;
41
+ snapshotInterval?: number;
42
+ }
43
+ export interface ApplyBlockResult {
44
+ tip: ClientTip;
45
+ checkpoint: ClientCheckpoint | null;
46
+ applied: AppliedBlock;
47
+ }
48
+ export interface Client {
49
+ getTip(): Promise<ClientTip | null>;
50
+ getState(): Promise<IndexerState>;
51
+ applyBlock(block: BitcoinBlock): Promise<ApplyBlockResult>;
52
+ rewindToHeight(height: number): Promise<ClientTip | null>;
53
+ close(): Promise<void>;
54
+ }
55
+ export type { BitcoinBlock, BlockRecord, GenesisParameters, IndexerState, };
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { PortableWalletArchivePayloadV1 } from "./types.js";
2
+ export declare const PORTABLE_WALLET_ARCHIVE_FORMAT = "cogcoin-portable-wallet-archive";
3
+ export declare function writePortableWalletArchive(path: string, payload: PortableWalletArchivePayloadV1, passphrase: Uint8Array | string): Promise<void>;
4
+ export declare function readPortableWalletArchive(path: string, passphrase: Uint8Array | string): Promise<PortableWalletArchivePayloadV1>;
@@ -0,0 +1,39 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import { writeJsonFileAtomic } from "./fs/atomic.js";
3
+ import { decryptJsonWithPassphrase, encryptJsonWithPassphrase, } from "./state/crypto.js";
4
+ export const PORTABLE_WALLET_ARCHIVE_FORMAT = "cogcoin-portable-wallet-archive";
5
+ function assertPortableWalletArchivePayload(payload) {
6
+ if (payload.schemaVersion !== 1
7
+ || payload.walletRootId.trim() === ""
8
+ || payload.mnemonic.phrase.trim() === ""
9
+ || payload.expected.accountPath.trim() === ""
10
+ || payload.expected.publicExternalDescriptor.trim() === ""
11
+ || payload.expected.fundingAddress0.trim() === ""
12
+ || payload.expected.fundingScriptPubKeyHex0.trim() === "") {
13
+ throw new Error("wallet_archive_payload_invalid");
14
+ }
15
+ return payload;
16
+ }
17
+ export async function writePortableWalletArchive(path, payload, passphrase) {
18
+ const envelope = await encryptJsonWithPassphrase(assertPortableWalletArchivePayload(payload), passphrase, {
19
+ format: PORTABLE_WALLET_ARCHIVE_FORMAT,
20
+ });
21
+ await writeJsonFileAtomic(path, envelope, { mode: 0o600 });
22
+ }
23
+ export async function readPortableWalletArchive(path, passphrase) {
24
+ let raw;
25
+ try {
26
+ raw = await readFile(path, "utf8");
27
+ }
28
+ catch (error) {
29
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") {
30
+ throw new Error("wallet_import_archive_not_found");
31
+ }
32
+ throw error;
33
+ }
34
+ const envelope = JSON.parse(raw);
35
+ if (envelope.format !== PORTABLE_WALLET_ARCHIVE_FORMAT || envelope.version !== 1) {
36
+ throw new Error("wallet_archive_format_invalid");
37
+ }
38
+ return assertPortableWalletArchivePayload(await decryptJsonWithPassphrase(envelope, passphrase));
39
+ }
@@ -0,0 +1,32 @@
1
+ export declare const COG_PREFIX: Uint8Array<ArrayBuffer>;
2
+ export declare const MIN_OP_RETURN_BYTES = 4;
3
+ export declare const MAX_OP_RETURN_BYTES = 80;
4
+ export declare const MIN_SCRIPT_PUBKEY_BYTES = 1;
5
+ export declare const MAX_SCRIPT_PUBKEY_BYTES = 67;
6
+ export declare const MIN_NAME_BYTES = 1;
7
+ export declare const MAX_NAME_BYTES = 63;
8
+ export declare const FIELD_FORMAT_BYTES: {
9
+ readonly clear: 0;
10
+ readonly bytes: 1;
11
+ readonly text: 2;
12
+ readonly json: 9;
13
+ };
14
+ export declare const COG_OPCODES: {
15
+ readonly MINE: 1;
16
+ readonly COG_TRANSFER: 2;
17
+ readonly COG_LOCK: 3;
18
+ readonly COG_CLAIM: 4;
19
+ readonly DOMAIN_REG: 5;
20
+ readonly DOMAIN_TRANSFER: 6;
21
+ readonly DOMAIN_SELL: 7;
22
+ readonly DOMAIN_BUY: 8;
23
+ readonly FIELD_REG: 9;
24
+ readonly DATA_UPDATE: 10;
25
+ readonly SET_ENDPOINT: 11;
26
+ readonly REP_COMMIT: 12;
27
+ readonly REP_REVOKE: 13;
28
+ readonly SET_CANONICAL: 14;
29
+ readonly DOMAIN_ANCHOR: 15;
30
+ readonly SET_DELEGATE: 16;
31
+ readonly SET_MINER: 17;
32
+ };
@@ -0,0 +1,32 @@
1
+ export const COG_PREFIX = new Uint8Array([0x43, 0x4f, 0x47]);
2
+ export const MIN_OP_RETURN_BYTES = 4;
3
+ export const MAX_OP_RETURN_BYTES = 80;
4
+ export const MIN_SCRIPT_PUBKEY_BYTES = 1;
5
+ export const MAX_SCRIPT_PUBKEY_BYTES = 67;
6
+ export const MIN_NAME_BYTES = 1;
7
+ export const MAX_NAME_BYTES = 63;
8
+ export const FIELD_FORMAT_BYTES = {
9
+ clear: 0x00,
10
+ bytes: 0x01,
11
+ text: 0x02,
12
+ json: 0x09,
13
+ };
14
+ export const COG_OPCODES = {
15
+ MINE: 0x01,
16
+ COG_TRANSFER: 0x02,
17
+ COG_LOCK: 0x03,
18
+ COG_CLAIM: 0x04,
19
+ DOMAIN_REG: 0x05,
20
+ DOMAIN_TRANSFER: 0x06,
21
+ DOMAIN_SELL: 0x07,
22
+ DOMAIN_BUY: 0x08,
23
+ FIELD_REG: 0x09,
24
+ DATA_UPDATE: 0x0a,
25
+ SET_ENDPOINT: 0x0b,
26
+ REP_COMMIT: 0x0c,
27
+ REP_REVOKE: 0x0d,
28
+ SET_CANONICAL: 0x0e,
29
+ DOMAIN_ANCHOR: 0x0f,
30
+ SET_DELEGATE: 0x10,
31
+ SET_MINER: 0x11,
32
+ };
@@ -0,0 +1,32 @@
1
+ import { FIELD_FORMAT_BYTES } from "./constants.js";
2
+ import { writeU8, writeU32BE, writeU64BE } from "./numeric.js";
3
+ import { validateExternalScriptPubKey, writeLenPrefixedSpk } from "./scriptpubkey.js";
4
+ import { validateDomainName, validateFieldName } from "./validate-name.js";
5
+ export type ScriptPubKey = Uint8Array;
6
+ export type Bytes32 = Uint8Array;
7
+ export type Coglex60 = Uint8Array;
8
+ export type OpReturnPayload = Uint8Array;
9
+ export interface SerializerResult {
10
+ opReturnData: Uint8Array;
11
+ }
12
+ declare function concatParts(parts: Uint8Array[]): Uint8Array;
13
+ declare function writeAsciiName(name: string, validator: (value: string) => void): Uint8Array;
14
+ export declare function computeRootRegistrationPriceSats(rootName: string): bigint;
15
+ export declare function serializeMine(domainId: number, referencedBlockHashInternal: Bytes32, sentence60: Coglex60, minerData?: Uint8Array): SerializerResult;
16
+ export declare function serializeCogTransfer(amount: bigint, recipientSpk: ScriptPubKey): SerializerResult;
17
+ export declare function serializeCogLock(amount: bigint, timeoutHeight: number, recipientDomainId: number, condition32: Bytes32): SerializerResult;
18
+ export declare function serializeCogClaim(lockId: number, preimage32: Bytes32): SerializerResult;
19
+ export declare function serializeDomainReg(name: string): SerializerResult;
20
+ export declare function serializeDomainTransfer(domainId: number, recipientSpk: ScriptPubKey): SerializerResult;
21
+ export declare function serializeDomainSell(domainId: number, listedPrice: bigint): SerializerResult;
22
+ export declare function serializeDomainBuy(domainId: number, expectedPrice: bigint): SerializerResult;
23
+ export declare function serializeFieldReg(parentDomainId: number, permanent: boolean, fieldName: string): SerializerResult;
24
+ export declare function serializeDataUpdate(domainId: number, fieldId: number, format: number, value?: Uint8Array): SerializerResult;
25
+ export declare function serializeSetEndpoint(domainId: number, endpoint?: Uint8Array): SerializerResult;
26
+ export declare function serializeRepCommit(sourceDomainId: number, targetDomainId: number, amount: bigint, review60?: Coglex60): SerializerResult;
27
+ export declare function serializeRepRevoke(sourceDomainId: number, targetDomainId: number, amount: bigint, review60?: Coglex60): SerializerResult;
28
+ export declare function serializeSetCanonical(domainId: number): SerializerResult;
29
+ export declare function serializeDomainAnchor(domainId: number, foundingMessage60?: Coglex60): SerializerResult;
30
+ export declare function serializeSetDelegate(domainId: number, delegateSpk?: ScriptPubKey): SerializerResult;
31
+ export declare function serializeSetMiner(domainId: number, minerSpk?: ScriptPubKey): SerializerResult;
32
+ export { concatParts, FIELD_FORMAT_BYTES, validateDomainName, validateExternalScriptPubKey, validateFieldName, writeAsciiName, writeLenPrefixedSpk, writeU8, writeU32BE, writeU64BE, };