@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.
- package/LICENSE +21 -0
- package/README.md +136 -0
- package/dist/app-paths.d.ts +38 -0
- package/dist/app-paths.js +121 -0
- package/dist/art/banner.txt +13 -0
- package/dist/art/scroll.txt +13 -0
- package/dist/art/train-car.txt +6 -0
- package/dist/art/train-smoke.txt +6 -0
- package/dist/art/train.txt +6 -0
- package/dist/bitcoind/bootstrap/chainstate.d.ts +4 -0
- package/dist/bitcoind/bootstrap/chainstate.js +13 -0
- package/dist/bitcoind/bootstrap/constants.d.ts +7 -0
- package/dist/bitcoind/bootstrap/constants.js +12 -0
- package/dist/bitcoind/bootstrap/controller.d.ts +29 -0
- package/dist/bitcoind/bootstrap/controller.js +101 -0
- package/dist/bitcoind/bootstrap/download.d.ts +2 -0
- package/dist/bitcoind/bootstrap/download.js +196 -0
- package/dist/bitcoind/bootstrap/headers.d.ts +13 -0
- package/dist/bitcoind/bootstrap/headers.js +61 -0
- package/dist/bitcoind/bootstrap/paths.d.ts +4 -0
- package/dist/bitcoind/bootstrap/paths.js +15 -0
- package/dist/bitcoind/bootstrap/snapshot-file.d.ts +7 -0
- package/dist/bitcoind/bootstrap/snapshot-file.js +42 -0
- package/dist/bitcoind/bootstrap/state.d.ts +40 -0
- package/dist/bitcoind/bootstrap/state.js +70 -0
- package/dist/bitcoind/bootstrap/types.d.ts +28 -0
- package/dist/bitcoind/bootstrap/types.js +1 -0
- package/dist/bitcoind/bootstrap.d.ts +8 -0
- package/dist/bitcoind/bootstrap.js +7 -0
- package/dist/bitcoind/client/factory.d.ts +3 -0
- package/dist/bitcoind/client/factory.js +57 -0
- package/dist/bitcoind/client/follow-block-times.d.ts +8 -0
- package/dist/bitcoind/client/follow-block-times.js +25 -0
- package/dist/bitcoind/client/follow-loop.d.ts +10 -0
- package/dist/bitcoind/client/follow-loop.js +57 -0
- package/dist/bitcoind/client/internal-types.d.ts +63 -0
- package/dist/bitcoind/client/internal-types.js +18 -0
- package/dist/bitcoind/client/managed-client.d.ts +20 -0
- package/dist/bitcoind/client/managed-client.js +197 -0
- package/dist/bitcoind/client/rate-tracker.d.ts +2 -0
- package/dist/bitcoind/client/rate-tracker.js +24 -0
- package/dist/bitcoind/client/sync-engine.d.ts +3 -0
- package/dist/bitcoind/client/sync-engine.js +143 -0
- package/dist/bitcoind/client.d.ts +1 -0
- package/dist/bitcoind/client.js +1 -0
- package/dist/bitcoind/errors.d.ts +1 -0
- package/dist/bitcoind/errors.js +49 -0
- package/dist/bitcoind/index.d.ts +2 -0
- package/dist/bitcoind/index.js +1 -0
- package/dist/bitcoind/indexer-daemon-main.d.ts +1 -0
- package/dist/bitcoind/indexer-daemon-main.js +472 -0
- package/dist/bitcoind/indexer-daemon.d.ts +107 -0
- package/dist/bitcoind/indexer-daemon.js +391 -0
- package/dist/bitcoind/node.d.ts +8 -0
- package/dist/bitcoind/node.js +219 -0
- package/dist/bitcoind/normalize.d.ts +3 -0
- package/dist/bitcoind/normalize.js +47 -0
- package/dist/bitcoind/progress/assets.d.ts +10 -0
- package/dist/bitcoind/progress/assets.js +90 -0
- package/dist/bitcoind/progress/constants.d.ts +48 -0
- package/dist/bitcoind/progress/constants.js +53 -0
- package/dist/bitcoind/progress/controller.d.ts +28 -0
- package/dist/bitcoind/progress/controller.js +188 -0
- package/dist/bitcoind/progress/follow-scene.d.ts +40 -0
- package/dist/bitcoind/progress/follow-scene.js +367 -0
- package/dist/bitcoind/progress/formatting.d.ts +23 -0
- package/dist/bitcoind/progress/formatting.js +227 -0
- package/dist/bitcoind/progress/quote-scene.d.ts +4 -0
- package/dist/bitcoind/progress/quote-scene.js +137 -0
- package/dist/bitcoind/progress/train-scene.d.ts +9 -0
- package/dist/bitcoind/progress/train-scene.js +92 -0
- package/dist/bitcoind/progress/tty-renderer.d.ts +18 -0
- package/dist/bitcoind/progress/tty-renderer.js +150 -0
- package/dist/bitcoind/progress.d.ts +7 -0
- package/dist/bitcoind/progress.js +7 -0
- package/dist/bitcoind/quotes.d.ts +24 -0
- package/dist/bitcoind/quotes.js +195 -0
- package/dist/bitcoind/rpc.d.ts +71 -0
- package/dist/bitcoind/rpc.js +322 -0
- package/dist/bitcoind/service-paths.d.ts +19 -0
- package/dist/bitcoind/service-paths.js +49 -0
- package/dist/bitcoind/service.d.ts +40 -0
- package/dist/bitcoind/service.js +735 -0
- package/dist/bitcoind/testing.d.ts +9 -0
- package/dist/bitcoind/testing.js +9 -0
- package/dist/bitcoind/types.d.ts +396 -0
- package/dist/bitcoind/types.js +3 -0
- package/dist/bytes.d.ts +9 -0
- package/dist/bytes.js +36 -0
- package/dist/cli/commands/follow.d.ts +2 -0
- package/dist/cli/commands/follow.js +43 -0
- package/dist/cli/commands/mining-admin.d.ts +2 -0
- package/dist/cli/commands/mining-admin.js +92 -0
- package/dist/cli/commands/mining-read.d.ts +2 -0
- package/dist/cli/commands/mining-read.js +173 -0
- package/dist/cli/commands/mining-runtime.d.ts +2 -0
- package/dist/cli/commands/mining-runtime.js +108 -0
- package/dist/cli/commands/status.d.ts +2 -0
- package/dist/cli/commands/status.js +31 -0
- package/dist/cli/commands/sync.d.ts +2 -0
- package/dist/cli/commands/sync.js +52 -0
- package/dist/cli/commands/wallet-admin.d.ts +2 -0
- package/dist/cli/commands/wallet-admin.js +175 -0
- package/dist/cli/commands/wallet-mutation.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation.js +681 -0
- package/dist/cli/commands/wallet-read.d.ts +2 -0
- package/dist/cli/commands/wallet-read.js +265 -0
- package/dist/cli/context.d.ts +3 -0
- package/dist/cli/context.js +75 -0
- package/dist/cli/io.d.ts +3 -0
- package/dist/cli/io.js +12 -0
- package/dist/cli/mining-format.d.ts +5 -0
- package/dist/cli/mining-format.js +156 -0
- package/dist/cli/mining-json.d.ts +49 -0
- package/dist/cli/mining-json.js +89 -0
- package/dist/cli/mutation-command-groups.d.ts +15 -0
- package/dist/cli/mutation-command-groups.js +71 -0
- package/dist/cli/mutation-json.d.ts +430 -0
- package/dist/cli/mutation-json.js +311 -0
- package/dist/cli/mutation-resolved-json.d.ts +124 -0
- package/dist/cli/mutation-resolved-json.js +129 -0
- package/dist/cli/mutation-success.d.ts +20 -0
- package/dist/cli/mutation-success.js +47 -0
- package/dist/cli/mutation-text-format.d.ts +22 -0
- package/dist/cli/mutation-text-format.js +171 -0
- package/dist/cli/mutation-text-write.d.ts +13 -0
- package/dist/cli/mutation-text-write.js +16 -0
- package/dist/cli/output.d.ts +185 -0
- package/dist/cli/output.js +1085 -0
- package/dist/cli/parse.d.ts +3 -0
- package/dist/cli/parse.js +971 -0
- package/dist/cli/preview-json.d.ts +416 -0
- package/dist/cli/preview-json.js +293 -0
- package/dist/cli/prompt.d.ts +3 -0
- package/dist/cli/prompt.js +33 -0
- package/dist/cli/read-json.d.ts +187 -0
- package/dist/cli/read-json.js +675 -0
- package/dist/cli/runner.d.ts +2 -0
- package/dist/cli/runner.js +129 -0
- package/dist/cli/signals.d.ts +3 -0
- package/dist/cli/signals.js +63 -0
- package/dist/cli/status-format.d.ts +2 -0
- package/dist/cli/status-format.js +48 -0
- package/dist/cli/types.d.ts +148 -0
- package/dist/cli/types.js +2 -0
- package/dist/cli/wallet-format.d.ts +29 -0
- package/dist/cli/wallet-format.js +637 -0
- package/dist/cli/workflow-hints.d.ts +13 -0
- package/dist/cli/workflow-hints.js +94 -0
- package/dist/cli-runner.d.ts +3 -0
- package/dist/cli-runner.js +3 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +6 -0
- package/dist/client/default-client.d.ts +11 -0
- package/dist/client/default-client.js +118 -0
- package/dist/client/factory.d.ts +2 -0
- package/dist/client/factory.js +15 -0
- package/dist/client/initialization.d.ts +6 -0
- package/dist/client/initialization.js +30 -0
- package/dist/client/persistence.d.ts +5 -0
- package/dist/client/persistence.js +28 -0
- package/dist/client/store-adapter.d.ts +3 -0
- package/dist/client/store-adapter.js +20 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.js +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/passive-status.d.ts +36 -0
- package/dist/passive-status.js +100 -0
- package/dist/sqlite/better-sqlite3.d.ts +26 -0
- package/dist/sqlite/better-sqlite3.js +4 -0
- package/dist/sqlite/checkpoints.d.ts +11 -0
- package/dist/sqlite/checkpoints.js +27 -0
- package/dist/sqlite/driver.d.ts +17 -0
- package/dist/sqlite/driver.js +98 -0
- package/dist/sqlite/index.d.ts +4 -0
- package/dist/sqlite/index.js +9 -0
- package/dist/sqlite/migrate.d.ts +2 -0
- package/dist/sqlite/migrate.js +37 -0
- package/dist/sqlite/store.d.ts +3 -0
- package/dist/sqlite/store.js +122 -0
- package/dist/sqlite/tip-meta.d.ts +26 -0
- package/dist/sqlite/tip-meta.js +97 -0
- package/dist/sqlite/types.d.ts +10 -0
- package/dist/sqlite/types.js +1 -0
- package/dist/types.d.ts +55 -0
- package/dist/types.js +1 -0
- package/dist/wallet/archive.d.ts +4 -0
- package/dist/wallet/archive.js +39 -0
- package/dist/wallet/cogop/constants.d.ts +32 -0
- package/dist/wallet/cogop/constants.js +32 -0
- package/dist/wallet/cogop/index.d.ts +32 -0
- package/dist/wallet/cogop/index.js +213 -0
- package/dist/wallet/cogop/numeric.d.ts +3 -0
- package/dist/wallet/cogop/numeric.js +24 -0
- package/dist/wallet/cogop/scriptpubkey.d.ts +2 -0
- package/dist/wallet/cogop/scriptpubkey.js +13 -0
- package/dist/wallet/cogop/validate-name.d.ts +2 -0
- package/dist/wallet/cogop/validate-name.js +18 -0
- package/dist/wallet/fs/atomic.d.ts +6 -0
- package/dist/wallet/fs/atomic.js +46 -0
- package/dist/wallet/fs/lock.d.ts +19 -0
- package/dist/wallet/fs/lock.js +61 -0
- package/dist/wallet/fs/status-file.d.ts +1 -0
- package/dist/wallet/fs/status-file.js +4 -0
- package/dist/wallet/lifecycle.d.ts +193 -0
- package/dist/wallet/lifecycle.js +1475 -0
- package/dist/wallet/material.d.ts +45 -0
- package/dist/wallet/material.js +118 -0
- package/dist/wallet/mining/config.d.ts +18 -0
- package/dist/wallet/mining/config.js +44 -0
- package/dist/wallet/mining/constants.d.ts +24 -0
- package/dist/wallet/mining/constants.js +24 -0
- package/dist/wallet/mining/control.d.ts +53 -0
- package/dist/wallet/mining/control.js +758 -0
- package/dist/wallet/mining/coordination.d.ts +40 -0
- package/dist/wallet/mining/coordination.js +121 -0
- package/dist/wallet/mining/hook-protocol.d.ts +47 -0
- package/dist/wallet/mining/hook-protocol.js +161 -0
- package/dist/wallet/mining/hook-runner.d.ts +1 -0
- package/dist/wallet/mining/hook-runner.js +52 -0
- package/dist/wallet/mining/hooks.d.ts +38 -0
- package/dist/wallet/mining/hooks.js +520 -0
- package/dist/wallet/mining/index.d.ts +8 -0
- package/dist/wallet/mining/index.js +6 -0
- package/dist/wallet/mining/runner.d.ts +155 -0
- package/dist/wallet/mining/runner.js +2574 -0
- package/dist/wallet/mining/runtime-artifacts.d.ts +17 -0
- package/dist/wallet/mining/runtime-artifacts.js +166 -0
- package/dist/wallet/mining/sentences.d.ts +23 -0
- package/dist/wallet/mining/sentences.js +281 -0
- package/dist/wallet/mining/state.d.ts +9 -0
- package/dist/wallet/mining/state.js +75 -0
- package/dist/wallet/mining/types.d.ts +141 -0
- package/dist/wallet/mining/types.js +1 -0
- package/dist/wallet/mining/visualizer.d.ts +19 -0
- package/dist/wallet/mining/visualizer.js +134 -0
- package/dist/wallet/mining/worker-main.d.ts +1 -0
- package/dist/wallet/mining/worker-main.js +17 -0
- package/dist/wallet/read/context.d.ts +20 -0
- package/dist/wallet/read/context.js +532 -0
- package/dist/wallet/read/filter.d.ts +9 -0
- package/dist/wallet/read/filter.js +42 -0
- package/dist/wallet/read/index.d.ts +4 -0
- package/dist/wallet/read/index.js +3 -0
- package/dist/wallet/read/project.d.ts +11 -0
- package/dist/wallet/read/project.js +300 -0
- package/dist/wallet/read/types.d.ts +144 -0
- package/dist/wallet/read/types.js +1 -0
- package/dist/wallet/runtime.d.ts +26 -0
- package/dist/wallet/runtime.js +28 -0
- package/dist/wallet/state/crypto.d.ts +31 -0
- package/dist/wallet/state/crypto.js +127 -0
- package/dist/wallet/state/provider.d.ts +37 -0
- package/dist/wallet/state/provider.js +312 -0
- package/dist/wallet/state/session.d.ts +12 -0
- package/dist/wallet/state/session.js +23 -0
- package/dist/wallet/state/storage.d.ts +19 -0
- package/dist/wallet/state/storage.js +55 -0
- package/dist/wallet/tx/anchor.d.ts +40 -0
- package/dist/wallet/tx/anchor.js +1210 -0
- package/dist/wallet/tx/cog.d.ts +92 -0
- package/dist/wallet/tx/cog.js +1055 -0
- package/dist/wallet/tx/common.d.ts +89 -0
- package/dist/wallet/tx/common.js +156 -0
- package/dist/wallet/tx/confirm.d.ts +15 -0
- package/dist/wallet/tx/confirm.js +24 -0
- package/dist/wallet/tx/domain-admin.d.ts +105 -0
- package/dist/wallet/tx/domain-admin.js +869 -0
- package/dist/wallet/tx/domain-market.d.ts +112 -0
- package/dist/wallet/tx/domain-market.js +1365 -0
- package/dist/wallet/tx/field.d.ts +101 -0
- package/dist/wallet/tx/field.js +1853 -0
- package/dist/wallet/tx/identity-selector.d.ts +12 -0
- package/dist/wallet/tx/identity-selector.js +52 -0
- package/dist/wallet/tx/index.d.ts +7 -0
- package/dist/wallet/tx/index.js +7 -0
- package/dist/wallet/tx/journal.d.ts +5 -0
- package/dist/wallet/tx/journal.js +31 -0
- package/dist/wallet/tx/register.d.ts +68 -0
- package/dist/wallet/tx/register.js +952 -0
- package/dist/wallet/tx/reputation.d.ts +72 -0
- package/dist/wallet/tx/reputation.js +693 -0
- package/dist/wallet/tx/targets.d.ts +7 -0
- package/dist/wallet/tx/targets.js +122 -0
- package/dist/wallet/types.d.ts +249 -0
- package/dist/wallet/types.js +1 -0
- package/dist/writing_quotes.json +1654 -0
- package/package.json +78 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { WalletReadContext } from "../read/index.js";
|
|
2
|
+
type ReadyWalletMutationContext = WalletReadContext & {
|
|
3
|
+
localState: {
|
|
4
|
+
availability: "ready";
|
|
5
|
+
};
|
|
6
|
+
snapshot: NonNullable<WalletReadContext["snapshot"]>;
|
|
7
|
+
model: NonNullable<WalletReadContext["model"]>;
|
|
8
|
+
};
|
|
9
|
+
type ResolvedIdentity = ReadyWalletMutationContext["model"]["identities"][number];
|
|
10
|
+
export declare function getCanonicalIdentitySelector(identity: ResolvedIdentity): string;
|
|
11
|
+
export declare function resolveIdentityBySelector(context: ReadyWalletMutationContext, selector: string, errorPrefix: string): ResolvedIdentity;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { serializeDomainReg } from "../cogop/index.js";
|
|
2
|
+
function normalizeDomainName(value, errorCode) {
|
|
3
|
+
const normalized = value.trim().toLowerCase();
|
|
4
|
+
if (normalized.length === 0) {
|
|
5
|
+
throw new Error(errorCode);
|
|
6
|
+
}
|
|
7
|
+
serializeDomainReg(normalized);
|
|
8
|
+
return normalized;
|
|
9
|
+
}
|
|
10
|
+
export function getCanonicalIdentitySelector(identity) {
|
|
11
|
+
return identity.selectors.find((selector) => selector.startsWith("id:")) ?? `id:${identity.index}`;
|
|
12
|
+
}
|
|
13
|
+
export function resolveIdentityBySelector(context, selector, errorPrefix) {
|
|
14
|
+
const trimmed = selector.trim();
|
|
15
|
+
if (trimmed === "") {
|
|
16
|
+
throw new Error(`${errorPrefix}_sender_selector_missing`);
|
|
17
|
+
}
|
|
18
|
+
if (trimmed.startsWith("id:")) {
|
|
19
|
+
const index = Number.parseInt(trimmed.slice(3), 10);
|
|
20
|
+
const identity = context.model.identities.find((entry) => entry.index === index) ?? null;
|
|
21
|
+
if (identity === null) {
|
|
22
|
+
throw new Error(`${errorPrefix}_sender_not_found`);
|
|
23
|
+
}
|
|
24
|
+
return identity;
|
|
25
|
+
}
|
|
26
|
+
if (trimmed.startsWith("domain:")) {
|
|
27
|
+
const domainName = normalizeDomainName(trimmed.slice(7), `${errorPrefix}_sender_selector_invalid_domain`);
|
|
28
|
+
const domain = context.model.domains.find((entry) => entry.name === domainName) ?? null;
|
|
29
|
+
if (domain === null || domain.ownerLocalIndex === null) {
|
|
30
|
+
throw new Error(`${errorPrefix}_sender_not_found`);
|
|
31
|
+
}
|
|
32
|
+
const identity = context.model.identities.find((entry) => entry.index === domain.ownerLocalIndex) ?? null;
|
|
33
|
+
if (identity === null) {
|
|
34
|
+
throw new Error(`${errorPrefix}_sender_not_found`);
|
|
35
|
+
}
|
|
36
|
+
return identity;
|
|
37
|
+
}
|
|
38
|
+
if (trimmed.startsWith("spk:")) {
|
|
39
|
+
const scriptPubKeyHex = trimmed.slice(4).toLowerCase();
|
|
40
|
+
const identity = context.model.identities.find((entry) => entry.scriptPubKeyHex === scriptPubKeyHex) ?? null;
|
|
41
|
+
if (identity === null) {
|
|
42
|
+
throw new Error(`${errorPrefix}_sender_not_found`);
|
|
43
|
+
}
|
|
44
|
+
return identity;
|
|
45
|
+
}
|
|
46
|
+
const normalizedAddress = trimmed.toLowerCase();
|
|
47
|
+
const identity = context.model.identities.find((entry) => entry.address?.toLowerCase() === normalizedAddress) ?? null;
|
|
48
|
+
if (identity === null) {
|
|
49
|
+
throw new Error(`${errorPrefix}_sender_not_found`);
|
|
50
|
+
}
|
|
51
|
+
return identity;
|
|
52
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { extractOpReturnPayloadFromScriptHex, registerDomain, type RegisterDomainResult, } from "./register.js";
|
|
2
|
+
export { buyDomain, parseCogAmountToCogtoshi, sellDomain, transferDomain, type DomainMarketMutationResult, } from "./domain-market.js";
|
|
3
|
+
export { claimCogLock, lockCogToDomain, reclaimCogLock, sendCog, type CogMutationResult, } from "./cog.js";
|
|
4
|
+
export { anchorDomain, type AnchorDomainResult, } from "./anchor.js";
|
|
5
|
+
export { clearDomainDelegate, clearDomainEndpoint, clearDomainMiner, setDomainCanonical, setDomainDelegate, setDomainEndpoint, setDomainMiner, type DomainAdminMutationResult, } from "./domain-admin.js";
|
|
6
|
+
export { clearField, createField, setField, type ClearFieldOptions, type CreateFieldOptions, type FieldMutationResult, type FieldValueInputSource, type SetFieldOptions, } from "./field.js";
|
|
7
|
+
export { giveReputation, revokeReputation, type GiveReputationOptions, type ReputationMutationResult, type RevokeReputationOptions, } from "./reputation.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { extractOpReturnPayloadFromScriptHex, registerDomain, } from "./register.js";
|
|
2
|
+
export { buyDomain, parseCogAmountToCogtoshi, sellDomain, transferDomain, } from "./domain-market.js";
|
|
3
|
+
export { claimCogLock, lockCogToDomain, reclaimCogLock, sendCog, } from "./cog.js";
|
|
4
|
+
export { anchorDomain, } from "./anchor.js";
|
|
5
|
+
export { clearDomainDelegate, clearDomainEndpoint, clearDomainMiner, setDomainCanonical, setDomainDelegate, setDomainEndpoint, setDomainMiner, } from "./domain-admin.js";
|
|
6
|
+
export { clearField, createField, setField, } from "./field.js";
|
|
7
|
+
export { giveReputation, revokeReputation, } from "./reputation.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PendingMutationRecord, WalletStateV1 } from "../types.js";
|
|
2
|
+
export declare function getPendingMutations(state: WalletStateV1): PendingMutationRecord[];
|
|
3
|
+
export declare function listActivePendingMutations(state: WalletStateV1): PendingMutationRecord[];
|
|
4
|
+
export declare function findPendingMutationByIntent(state: WalletStateV1, intentFingerprintHex: string): PendingMutationRecord | null;
|
|
5
|
+
export declare function upsertPendingMutation(state: WalletStateV1, mutation: PendingMutationRecord): WalletStateV1;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const ACTIVE_MUTATION_STATUSES = new Set([
|
|
2
|
+
"draft",
|
|
3
|
+
"broadcasting",
|
|
4
|
+
"broadcast-unknown",
|
|
5
|
+
"live",
|
|
6
|
+
"repair-required",
|
|
7
|
+
]);
|
|
8
|
+
export function getPendingMutations(state) {
|
|
9
|
+
return state.pendingMutations ?? [];
|
|
10
|
+
}
|
|
11
|
+
export function listActivePendingMutations(state) {
|
|
12
|
+
return getPendingMutations(state).filter((mutation) => ACTIVE_MUTATION_STATUSES.has(mutation.status));
|
|
13
|
+
}
|
|
14
|
+
export function findPendingMutationByIntent(state, intentFingerprintHex) {
|
|
15
|
+
return getPendingMutations(state).find((mutation) => mutation.intentFingerprintHex === intentFingerprintHex) ?? null;
|
|
16
|
+
}
|
|
17
|
+
export function upsertPendingMutation(state, mutation) {
|
|
18
|
+
const pendingMutations = getPendingMutations(state);
|
|
19
|
+
const existingIndex = pendingMutations.findIndex((entry) => entry.mutationId === mutation.mutationId);
|
|
20
|
+
const nextPendingMutations = pendingMutations.slice();
|
|
21
|
+
if (existingIndex >= 0) {
|
|
22
|
+
nextPendingMutations[existingIndex] = mutation;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
nextPendingMutations.push(mutation);
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
...state,
|
|
29
|
+
pendingMutations: nextPendingMutations,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { loadBundledGenesisParameters } from "@cogcoin/indexer";
|
|
2
|
+
import { attachOrStartManagedBitcoindService } from "../../bitcoind/service.js";
|
|
3
|
+
import { createRpcClient } from "../../bitcoind/node.js";
|
|
4
|
+
import type { RpcTransaction } from "../../bitcoind/types.js";
|
|
5
|
+
import type { WalletPrompter } from "../lifecycle.js";
|
|
6
|
+
import { type WalletRuntimePaths } from "../runtime.js";
|
|
7
|
+
import { type WalletSecretProvider } from "../state/provider.js";
|
|
8
|
+
import { openWalletReadContext } from "../read/index.js";
|
|
9
|
+
import { type WalletMutationRpcClient } from "./common.js";
|
|
10
|
+
interface WalletRegisterRpcClient extends WalletMutationRpcClient {
|
|
11
|
+
getBlockchainInfo(): Promise<{
|
|
12
|
+
blocks: number;
|
|
13
|
+
}>;
|
|
14
|
+
sendRawTransaction(hex: string): Promise<string>;
|
|
15
|
+
getRawMempool(): Promise<string[]>;
|
|
16
|
+
getRawTransaction(txid: string, verbose?: boolean): Promise<RpcTransaction>;
|
|
17
|
+
}
|
|
18
|
+
type RegisterEconomicEffectKind = "treasury-payment" | "cog-burn";
|
|
19
|
+
export interface RegisterResolvedSenderSummary {
|
|
20
|
+
selector: string;
|
|
21
|
+
localIndex: number;
|
|
22
|
+
scriptPubKeyHex: string;
|
|
23
|
+
address: string;
|
|
24
|
+
}
|
|
25
|
+
export interface RegisterResolvedEconomicEffectSummary {
|
|
26
|
+
kind: RegisterEconomicEffectKind;
|
|
27
|
+
amount: bigint;
|
|
28
|
+
}
|
|
29
|
+
export interface RegisterResolvedSummary {
|
|
30
|
+
path: "root" | "subdomain";
|
|
31
|
+
parentDomainName: string | null;
|
|
32
|
+
sender: RegisterResolvedSenderSummary;
|
|
33
|
+
economicEffect: RegisterResolvedEconomicEffectSummary;
|
|
34
|
+
}
|
|
35
|
+
export interface RegisterDomainResult {
|
|
36
|
+
domainName: string;
|
|
37
|
+
registerKind: "root" | "subdomain";
|
|
38
|
+
parentDomainName: string | null;
|
|
39
|
+
senderSelector: string;
|
|
40
|
+
senderLocalIndex: number;
|
|
41
|
+
senderScriptPubKeyHex: string;
|
|
42
|
+
senderAddress: string;
|
|
43
|
+
economicEffectKind: RegisterEconomicEffectKind;
|
|
44
|
+
economicEffectAmount: bigint;
|
|
45
|
+
resolved: RegisterResolvedSummary;
|
|
46
|
+
txid: string;
|
|
47
|
+
status: "live" | "confirmed";
|
|
48
|
+
reusedExisting: boolean;
|
|
49
|
+
}
|
|
50
|
+
export interface RegisterDomainOptions {
|
|
51
|
+
domainName: string;
|
|
52
|
+
fromIdentity?: string | null;
|
|
53
|
+
dataDir: string;
|
|
54
|
+
databasePath: string;
|
|
55
|
+
forceRace?: boolean;
|
|
56
|
+
provider?: WalletSecretProvider;
|
|
57
|
+
prompter: WalletPrompter;
|
|
58
|
+
assumeYes?: boolean;
|
|
59
|
+
nowUnixMs?: number;
|
|
60
|
+
paths?: WalletRuntimePaths;
|
|
61
|
+
openReadContext?: typeof openWalletReadContext;
|
|
62
|
+
attachService?: typeof attachOrStartManagedBitcoindService;
|
|
63
|
+
rpcFactory?: (config: Parameters<typeof createRpcClient>[0]) => WalletRegisterRpcClient;
|
|
64
|
+
loadGenesisParameters?: typeof loadBundledGenesisParameters;
|
|
65
|
+
}
|
|
66
|
+
export declare function extractOpReturnPayloadFromScriptHex(scriptHex: string): Uint8Array | null;
|
|
67
|
+
export declare function registerDomain(options: RegisterDomainOptions): Promise<RegisterDomainResult>;
|
|
68
|
+
export {};
|