@cogcoin/client 1.1.8 → 1.1.9
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/README.md +1 -1
- package/dist/cli/commands/mining-read.js +1 -1
- package/dist/cli/commands/wallet-mutation/anchor.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/anchor.js +33 -0
- package/dist/cli/commands/wallet-mutation/bitcoin-transfer.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/bitcoin-transfer.js +32 -0
- package/dist/cli/commands/wallet-mutation/cog.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/cog.js +131 -0
- package/dist/cli/commands/wallet-mutation/context.d.ts +3 -0
- package/dist/cli/commands/wallet-mutation/context.js +18 -0
- package/dist/cli/commands/wallet-mutation/domain-admin.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/domain-admin.js +173 -0
- package/dist/cli/commands/wallet-mutation/domain-market.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/domain-market.js +107 -0
- package/dist/cli/commands/wallet-mutation/field.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/field.js +125 -0
- package/dist/cli/commands/wallet-mutation/register.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/register.js +38 -0
- package/dist/cli/commands/wallet-mutation/registry.d.ts +3 -0
- package/dist/cli/commands/wallet-mutation/registry.js +39 -0
- package/dist/cli/commands/wallet-mutation/reputation.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/reputation.js +57 -0
- package/dist/cli/commands/wallet-mutation/types.d.ts +32 -0
- package/dist/cli/commands/wallet-mutation/types.js +1 -0
- package/dist/cli/commands/wallet-mutation.js +13 -765
- package/dist/cli/commands/wallet-read.js +4 -4
- package/dist/cli/mutation-success.d.ts +0 -2
- package/dist/cli/output/classify.d.ts +7 -0
- package/dist/cli/output/classify.js +94 -0
- package/dist/cli/output/render.d.ts +2 -0
- package/dist/cli/output/render.js +13 -0
- package/dist/cli/output/rules/cli-surface.d.ts +2 -0
- package/dist/cli/output/rules/cli-surface.js +110 -0
- package/dist/cli/output/rules/generic.d.ts +2 -0
- package/dist/cli/output/rules/generic.js +13 -0
- package/dist/cli/output/rules/index.d.ts +2 -0
- package/dist/cli/output/rules/index.js +24 -0
- package/dist/cli/output/rules/mining-update.d.ts +2 -0
- package/dist/cli/output/rules/mining-update.js +68 -0
- package/dist/cli/output/rules/services.d.ts +2 -0
- package/dist/cli/output/rules/services.js +110 -0
- package/dist/cli/output/rules/wallet-admin.d.ts +2 -0
- package/dist/cli/output/rules/wallet-admin.js +224 -0
- package/dist/cli/output/rules/wallet-mutations.d.ts +2 -0
- package/dist/cli/output/rules/wallet-mutations.js +274 -0
- package/dist/cli/output/types.d.ts +16 -0
- package/dist/cli/output/types.js +1 -0
- package/dist/cli/output.d.ts +2 -168
- package/dist/cli/output.js +6 -989
- package/dist/cli/pagination.d.ts +15 -0
- package/dist/cli/pagination.js +16 -0
- package/dist/cli/recommendations.d.ts +4 -0
- package/dist/cli/recommendations.js +108 -0
- package/dist/cli/wallet-format/availability.d.ts +5 -0
- package/dist/cli/wallet-format/availability.js +96 -0
- package/dist/cli/wallet-format/balance.d.ts +2 -0
- package/dist/cli/wallet-format/balance.js +162 -0
- package/dist/cli/wallet-format/domains.d.ts +8 -0
- package/dist/cli/wallet-format/domains.js +84 -0
- package/dist/cli/wallet-format/fields.d.ts +6 -0
- package/dist/cli/wallet-format/fields.js +61 -0
- package/dist/cli/wallet-format/identity.d.ts +5 -0
- package/dist/cli/wallet-format/identity.js +19 -0
- package/dist/cli/wallet-format/locks.d.ts +7 -0
- package/dist/cli/wallet-format/locks.js +52 -0
- package/dist/cli/wallet-format/overview.d.ts +2 -0
- package/dist/cli/wallet-format/overview.js +122 -0
- package/dist/cli/wallet-format/pending.d.ts +13 -0
- package/dist/cli/wallet-format/pending.js +101 -0
- package/dist/cli/wallet-format/shared.d.ts +7 -0
- package/dist/cli/wallet-format/shared.js +31 -0
- package/dist/cli/wallet-format/status.d.ts +3 -0
- package/dist/cli/wallet-format/status.js +27 -0
- package/dist/cli/wallet-format.d.ts +8 -30
- package/dist/cli/wallet-format.js +8 -830
- package/dist/cli/wallet-read-helpers.d.ts +6 -0
- package/dist/cli/wallet-read-helpers.js +17 -0
- package/dist/wallet/mining/candidate.d.ts +1 -1
- package/dist/wallet/mining/candidate.js +3 -3
- package/dist/wallet/mining/constants.d.ts +2 -2
- package/dist/wallet/mining/constants.js +2 -2
- package/dist/wallet/mining/sentence-protocol.d.ts +2 -2
- package/dist/wallet/mining/sentences.js +8 -8
- package/dist/wallet/tx/anchor/confirm.d.ts +15 -0
- package/dist/wallet/tx/anchor/confirm.js +60 -0
- package/dist/wallet/tx/anchor/draft.d.ts +39 -0
- package/dist/wallet/tx/anchor/draft.js +167 -0
- package/dist/wallet/tx/anchor/index.d.ts +5 -0
- package/dist/wallet/tx/anchor/index.js +148 -0
- package/dist/wallet/tx/anchor/intent.d.ts +61 -0
- package/dist/wallet/tx/anchor/intent.js +101 -0
- package/dist/wallet/tx/anchor/plan.d.ts +3 -0
- package/dist/wallet/tx/anchor/plan.js +18 -0
- package/dist/wallet/tx/anchor/result.d.ts +25 -0
- package/dist/wallet/tx/anchor/result.js +20 -0
- package/dist/wallet/tx/anchor.d.ts +1 -39
- package/dist/wallet/tx/anchor.js +1 -494
- package/dist/wallet/tx/bitcoin-transfer/confirm.d.ts +7 -0
- package/dist/wallet/tx/bitcoin-transfer/confirm.js +11 -0
- package/dist/wallet/tx/bitcoin-transfer/index.d.ts +5 -0
- package/dist/wallet/tx/bitcoin-transfer/index.js +112 -0
- package/dist/wallet/tx/bitcoin-transfer/intent.d.ts +52 -0
- package/dist/wallet/tx/bitcoin-transfer/intent.js +74 -0
- package/dist/wallet/tx/bitcoin-transfer/plan.d.ts +5 -0
- package/dist/wallet/tx/bitcoin-transfer/plan.js +21 -0
- package/dist/wallet/tx/bitcoin-transfer/result.d.ts +19 -0
- package/dist/wallet/tx/bitcoin-transfer/result.js +16 -0
- package/dist/wallet/tx/bitcoin-transfer.d.ts +1 -35
- package/dist/wallet/tx/bitcoin-transfer.js +1 -200
- package/dist/wallet/tx/cog/confirm.d.ts +13 -0
- package/dist/wallet/tx/cog/confirm.js +59 -0
- package/dist/wallet/tx/cog/draft.d.ts +20 -0
- package/dist/wallet/tx/cog/draft.js +114 -0
- package/dist/wallet/tx/cog/index.d.ts +6 -0
- package/dist/wallet/tx/cog/index.js +117 -0
- package/dist/wallet/tx/cog/intent.d.ts +30 -0
- package/dist/wallet/tx/cog/intent.js +169 -0
- package/dist/wallet/tx/cog/plan.d.ts +19 -0
- package/dist/wallet/tx/cog/plan.js +65 -0
- package/dist/wallet/tx/cog/result.d.ts +27 -0
- package/dist/wallet/tx/cog/result.js +28 -0
- package/dist/wallet/tx/cog/types.d.ts +186 -0
- package/dist/wallet/tx/cog/types.js +2 -0
- package/dist/wallet/tx/cog/variants/claim.d.ts +3 -0
- package/dist/wallet/tx/cog/variants/claim.js +92 -0
- package/dist/wallet/tx/cog/variants/lock.d.ts +2 -0
- package/dist/wallet/tx/cog/variants/lock.js +102 -0
- package/dist/wallet/tx/cog/variants/send.d.ts +2 -0
- package/dist/wallet/tx/cog/variants/send.js +77 -0
- package/dist/wallet/tx/cog.d.ts +1 -96
- package/dist/wallet/tx/cog.js +1 -824
- package/dist/wallet/tx/common.d.ts +14 -199
- package/dist/wallet/tx/common.js +10 -493
- package/dist/wallet/tx/domain-admin/confirm.d.ts +17 -0
- package/dist/wallet/tx/domain-admin/confirm.js +58 -0
- package/dist/wallet/tx/domain-admin/draft.d.ts +20 -0
- package/dist/wallet/tx/domain-admin/draft.js +161 -0
- package/dist/wallet/tx/domain-admin/index.d.ts +9 -0
- package/dist/wallet/tx/domain-admin/index.js +150 -0
- package/dist/wallet/tx/domain-admin/intent.d.ts +12 -0
- package/dist/wallet/tx/domain-admin/intent.js +61 -0
- package/dist/wallet/tx/domain-admin/plan.d.ts +19 -0
- package/dist/wallet/tx/domain-admin/plan.js +64 -0
- package/dist/wallet/tx/domain-admin/result.d.ts +19 -0
- package/dist/wallet/tx/domain-admin/result.js +33 -0
- package/dist/wallet/tx/domain-admin/types.d.ts +162 -0
- package/dist/wallet/tx/domain-admin/types.js +1 -0
- package/dist/wallet/tx/domain-admin/variants/canonical.d.ts +2 -0
- package/dist/wallet/tx/domain-admin/variants/canonical.js +22 -0
- package/dist/wallet/tx/domain-admin/variants/delegate.d.ts +3 -0
- package/dist/wallet/tx/domain-admin/variants/delegate.js +60 -0
- package/dist/wallet/tx/domain-admin/variants/endpoint.d.ts +3 -0
- package/dist/wallet/tx/domain-admin/variants/endpoint.js +102 -0
- package/dist/wallet/tx/domain-admin/variants/miner.d.ts +3 -0
- package/dist/wallet/tx/domain-admin/variants/miner.js +59 -0
- package/dist/wallet/tx/domain-admin.d.ts +1 -107
- package/dist/wallet/tx/domain-admin.js +1 -729
- package/dist/wallet/tx/domain-market/confirm.d.ts +6 -0
- package/dist/wallet/tx/domain-market/confirm.js +52 -0
- package/dist/wallet/tx/domain-market/draft.d.ts +43 -0
- package/dist/wallet/tx/domain-market/draft.js +286 -0
- package/dist/wallet/tx/domain-market/index.d.ts +6 -0
- package/dist/wallet/tx/domain-market/index.js +145 -0
- package/dist/wallet/tx/domain-market/intent.d.ts +15 -0
- package/dist/wallet/tx/domain-market/intent.js +131 -0
- package/dist/wallet/tx/domain-market/plan.d.ts +31 -0
- package/dist/wallet/tx/domain-market/plan.js +98 -0
- package/dist/wallet/tx/domain-market/result.d.ts +45 -0
- package/dist/wallet/tx/domain-market/result.js +88 -0
- package/dist/wallet/tx/domain-market/types.d.ts +221 -0
- package/dist/wallet/tx/domain-market/types.js +1 -0
- package/dist/wallet/tx/domain-market/variants/buy.d.ts +2 -0
- package/dist/wallet/tx/domain-market/variants/buy.js +103 -0
- package/dist/wallet/tx/domain-market/variants/sell.d.ts +2 -0
- package/dist/wallet/tx/domain-market/variants/sell.js +91 -0
- package/dist/wallet/tx/domain-market/variants/transfer.d.ts +2 -0
- package/dist/wallet/tx/domain-market/variants/transfer.js +105 -0
- package/dist/wallet/tx/domain-market.d.ts +1 -116
- package/dist/wallet/tx/domain-market.js +1 -1078
- package/dist/wallet/tx/draft-build.d.ts +60 -0
- package/dist/wallet/tx/draft-build.js +127 -0
- package/dist/wallet/tx/executor.d.ts +6 -40
- package/dist/wallet/tx/executor.js +6 -100
- package/dist/wallet/tx/fee.d.ts +30 -0
- package/dist/wallet/tx/fee.js +98 -0
- package/dist/wallet/tx/field/confirm.d.ts +11 -0
- package/dist/wallet/tx/field/confirm.js +19 -0
- package/dist/wallet/tx/field/draft.d.ts +23 -0
- package/dist/wallet/tx/field/draft.js +202 -0
- package/dist/wallet/tx/field/index.d.ts +5 -0
- package/dist/wallet/tx/field/index.js +140 -0
- package/dist/wallet/tx/field/intent.d.ts +5 -0
- package/dist/wallet/tx/field/intent.js +50 -0
- package/dist/wallet/tx/field/plan.d.ts +20 -0
- package/dist/wallet/tx/field/plan.js +65 -0
- package/dist/wallet/tx/field/result.d.ts +29 -0
- package/dist/wallet/tx/field/result.js +103 -0
- package/dist/wallet/tx/field/types.d.ts +163 -0
- package/dist/wallet/tx/field/types.js +1 -0
- package/dist/wallet/tx/field/variants/clear.d.ts +2 -0
- package/dist/wallet/tx/field/variants/clear.js +60 -0
- package/dist/wallet/tx/field/variants/create.d.ts +2 -0
- package/dist/wallet/tx/field/variants/create.js +67 -0
- package/dist/wallet/tx/field/variants/set.d.ts +2 -0
- package/dist/wallet/tx/field/variants/set.js +195 -0
- package/dist/wallet/tx/field.d.ts +1 -95
- package/dist/wallet/tx/field.js +1 -920
- package/dist/wallet/tx/mining-preemption.d.ts +6 -0
- package/dist/wallet/tx/mining-preemption.js +7 -0
- package/dist/wallet/tx/primitives.d.ts +13 -0
- package/dist/wallet/tx/primitives.js +42 -0
- package/dist/wallet/tx/psbt-assert.d.ts +14 -0
- package/dist/wallet/tx/psbt-assert.js +39 -0
- package/dist/wallet/tx/publish.d.ts +37 -0
- package/dist/wallet/tx/publish.js +88 -0
- package/dist/wallet/tx/readiness.d.ts +7 -0
- package/dist/wallet/tx/readiness.js +61 -0
- package/dist/wallet/tx/reconcile.d.ts +24 -0
- package/dist/wallet/tx/reconcile.js +72 -0
- package/dist/wallet/tx/register/confirm.d.ts +6 -0
- package/dist/wallet/tx/register/confirm.js +66 -0
- package/dist/wallet/tx/register/draft.d.ts +42 -0
- package/dist/wallet/tx/register/draft.js +181 -0
- package/dist/wallet/tx/register/index.d.ts +6 -0
- package/dist/wallet/tx/register/index.js +158 -0
- package/dist/wallet/tx/register/intent.d.ts +74 -0
- package/dist/wallet/tx/register/intent.js +119 -0
- package/dist/wallet/tx/register/plan.d.ts +43 -0
- package/dist/wallet/tx/register/plan.js +168 -0
- package/dist/wallet/tx/register/result.d.ts +78 -0
- package/dist/wallet/tx/register/result.js +41 -0
- package/dist/wallet/tx/register.d.ts +1 -70
- package/dist/wallet/tx/register.js +1 -681
- package/dist/wallet/tx/reputation/confirm.d.ts +11 -0
- package/dist/wallet/tx/reputation/confirm.js +51 -0
- package/dist/wallet/tx/reputation/draft.d.ts +20 -0
- package/dist/wallet/tx/reputation/draft.js +130 -0
- package/dist/wallet/tx/reputation/index.d.ts +4 -0
- package/dist/wallet/tx/reputation/index.js +162 -0
- package/dist/wallet/tx/reputation/intent.d.ts +36 -0
- package/dist/wallet/tx/reputation/intent.js +157 -0
- package/dist/wallet/tx/reputation/plan.d.ts +19 -0
- package/dist/wallet/tx/reputation/plan.js +64 -0
- package/dist/wallet/tx/reputation/result.d.ts +21 -0
- package/dist/wallet/tx/reputation/result.js +31 -0
- package/dist/wallet/tx/reputation/types.d.ts +130 -0
- package/dist/wallet/tx/reputation/types.js +1 -0
- package/dist/wallet/tx/reputation.d.ts +1 -74
- package/dist/wallet/tx/reputation.js +1 -556
- package/dist/wallet/tx/signing.d.ts +18 -0
- package/dist/wallet/tx/signing.js +31 -0
- package/dist/wallet/tx/state-persist.d.ts +27 -0
- package/dist/wallet/tx/state-persist.js +54 -0
- package/dist/wallet/tx/types.d.ts +44 -0
- package/dist/wallet/tx/types.js +1 -0
- package/package.json +1 -1
- package/dist/cli/mining-json.d.ts +0 -20
- package/dist/cli/mining-json.js +0 -46
- package/dist/cli/mutation-json.d.ts +0 -325
- package/dist/cli/mutation-json.js +0 -269
- package/dist/cli/mutation-resolved-json.d.ts +0 -117
- package/dist/cli/mutation-resolved-json.js +0 -123
- package/dist/cli/preview-json.d.ts +0 -319
- package/dist/cli/preview-json.js +0 -254
- package/dist/cli/read-json.d.ts +0 -190
- package/dist/cli/read-json.js +0 -627
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { getBalance, getListing, lookupDomain, } from "@cogcoin/indexer/queries";
|
|
3
|
+
import { validateDomainName } from "../../cogop/index.js";
|
|
4
|
+
import { assertWalletMutationContextReady, createFundingMutationSender, } from "../common.js";
|
|
5
|
+
import { getCanonicalIdentitySelector, } from "../identity-selector.js";
|
|
6
|
+
import { normalizeBtcTarget } from "../targets.js";
|
|
7
|
+
export function normalizeDomainMarketDomainName(domainName) {
|
|
8
|
+
const normalized = domainName.trim().toLowerCase();
|
|
9
|
+
if (normalized.length === 0) {
|
|
10
|
+
throw new Error("wallet_domain_missing_domain");
|
|
11
|
+
}
|
|
12
|
+
validateDomainName(normalized);
|
|
13
|
+
return normalized;
|
|
14
|
+
}
|
|
15
|
+
export function parseCogAmountToCogtoshi(raw) {
|
|
16
|
+
const match = /^(-?)(\d+)(?:\.(\d{0,8}))?$/.exec(raw.trim());
|
|
17
|
+
if (match == null) {
|
|
18
|
+
throw new Error(`wallet_sell_invalid_amount_${raw}`);
|
|
19
|
+
}
|
|
20
|
+
const sign = match[1] === "-" ? -1n : 1n;
|
|
21
|
+
const whole = BigInt(match[2] ?? "0");
|
|
22
|
+
const fraction = BigInt((match[3] ?? "").padEnd(8, "0"));
|
|
23
|
+
return sign * ((whole * 100000000n) + fraction);
|
|
24
|
+
}
|
|
25
|
+
export function createDomainMarketIntentFingerprint(parts) {
|
|
26
|
+
return createHash("sha256")
|
|
27
|
+
.update(parts.join("\n"))
|
|
28
|
+
.digest("hex");
|
|
29
|
+
}
|
|
30
|
+
export function createResolvedDomainMarketSenderSummary(sender, selector) {
|
|
31
|
+
return {
|
|
32
|
+
selector,
|
|
33
|
+
localIndex: sender.localIndex,
|
|
34
|
+
scriptPubKeyHex: sender.scriptPubKeyHex,
|
|
35
|
+
address: sender.address,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export function createResolvedDomainMarketRecipientSummary(recipient) {
|
|
39
|
+
return {
|
|
40
|
+
scriptPubKeyHex: recipient.scriptPubKeyHex,
|
|
41
|
+
address: recipient.address,
|
|
42
|
+
opaque: recipient.opaque,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export function createTransferEconomicEffectSummary(clearsListing) {
|
|
46
|
+
return {
|
|
47
|
+
kind: "ownership-transfer",
|
|
48
|
+
clearsListing,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export function createSellEconomicEffectSummary(listedPriceCogtoshi) {
|
|
52
|
+
if (listedPriceCogtoshi === 0n) {
|
|
53
|
+
return {
|
|
54
|
+
kind: "listing-clear",
|
|
55
|
+
listedPriceCogtoshi: "0",
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
kind: "listing-set",
|
|
60
|
+
listedPriceCogtoshi: listedPriceCogtoshi.toString(),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export function resolveOwnedDomainOperation(context, domainName, errorPrefix) {
|
|
64
|
+
assertWalletMutationContextReady(context, errorPrefix);
|
|
65
|
+
const chainDomain = lookupDomain(context.snapshot.state, domainName);
|
|
66
|
+
if (chainDomain === null) {
|
|
67
|
+
throw new Error(`${errorPrefix}_domain_not_found`);
|
|
68
|
+
}
|
|
69
|
+
if (chainDomain.anchored) {
|
|
70
|
+
throw new Error(`${errorPrefix}_domain_anchored`);
|
|
71
|
+
}
|
|
72
|
+
const ownerHex = Buffer.from(chainDomain.ownerScriptPubKey).toString("hex");
|
|
73
|
+
if (ownerHex !== context.localState.state.funding.scriptPubKeyHex || context.model.walletAddress == null) {
|
|
74
|
+
throw new Error(`${errorPrefix}_owner_not_locally_controlled`);
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
readContext: context,
|
|
78
|
+
state: context.localState.state,
|
|
79
|
+
sender: createFundingMutationSender(context.localState.state),
|
|
80
|
+
senderSelector: context.model.walletAddress,
|
|
81
|
+
chainDomain,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export function resolveBuyOperation(context, domainName, fromIdentity = null) {
|
|
85
|
+
void fromIdentity;
|
|
86
|
+
assertWalletMutationContextReady(context, "wallet_buy");
|
|
87
|
+
const chainDomain = lookupDomain(context.snapshot.state, domainName);
|
|
88
|
+
if (chainDomain === null) {
|
|
89
|
+
throw new Error("wallet_buy_domain_not_found");
|
|
90
|
+
}
|
|
91
|
+
if (chainDomain.anchored) {
|
|
92
|
+
throw new Error("wallet_buy_domain_anchored");
|
|
93
|
+
}
|
|
94
|
+
const listing = getListing(context.snapshot.state, chainDomain.domainId);
|
|
95
|
+
if (listing === null) {
|
|
96
|
+
throw new Error("wallet_buy_domain_not_listed");
|
|
97
|
+
}
|
|
98
|
+
if (context.model.walletAddress === null) {
|
|
99
|
+
throw new Error("wallet_buy_funding_identity_unavailable");
|
|
100
|
+
}
|
|
101
|
+
const ownerHex = Buffer.from(chainDomain.ownerScriptPubKey).toString("hex");
|
|
102
|
+
if (ownerHex === context.localState.state.funding.scriptPubKeyHex) {
|
|
103
|
+
throw new Error("wallet_buy_already_owner");
|
|
104
|
+
}
|
|
105
|
+
if (getBalance(context.snapshot.state, context.localState.state.funding.scriptPubKeyHex) < listing.priceCogtoshi) {
|
|
106
|
+
throw new Error("wallet_buy_insufficient_cog_balance");
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
readContext: context,
|
|
110
|
+
state: context.localState.state,
|
|
111
|
+
sender: createFundingMutationSender(context.localState.state),
|
|
112
|
+
senderSelector: context.model.walletAddress,
|
|
113
|
+
chainDomain,
|
|
114
|
+
listingPriceCogtoshi: listing.priceCogtoshi,
|
|
115
|
+
buyerSelector: context.model.walletAddress,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
export function createResolvedBuyerSummary(selector, sender) {
|
|
119
|
+
return {
|
|
120
|
+
selector,
|
|
121
|
+
localIndex: sender.localIndex,
|
|
122
|
+
scriptPubKeyHex: sender.scriptPubKeyHex,
|
|
123
|
+
address: sender.address,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
export function createResolvedSellerSummary(scriptPubKeyHex, address) {
|
|
127
|
+
return {
|
|
128
|
+
scriptPubKeyHex,
|
|
129
|
+
address,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { RpcListUnspentEntry } from "../../../bitcoind/types.js";
|
|
2
|
+
import type { WalletRuntimePaths } from "../../runtime.js";
|
|
3
|
+
import type { WalletSecretProvider } from "../../state/provider.js";
|
|
4
|
+
import type { WalletStateV1 } from "../../types.js";
|
|
5
|
+
import { type MutationSender } from "../common.js";
|
|
6
|
+
import type { BuiltDomainMarketTransaction, DomainMarketBuildState, DomainMarketPlan, DomainMarketRpcClient } from "./types.js";
|
|
7
|
+
import type { RpcDecodedPsbt } from "../../../bitcoind/types.js";
|
|
8
|
+
export declare function prepareDomainMarketBuildState(options: {
|
|
9
|
+
rpc: DomainMarketRpcClient;
|
|
10
|
+
walletName: string;
|
|
11
|
+
state: WalletStateV1;
|
|
12
|
+
provider: WalletSecretProvider;
|
|
13
|
+
nowUnixMs: number;
|
|
14
|
+
paths: WalletRuntimePaths;
|
|
15
|
+
preflightCoinControl: boolean;
|
|
16
|
+
}): Promise<DomainMarketBuildState>;
|
|
17
|
+
export declare function buildPlanForDomainOperation(options: {
|
|
18
|
+
state: WalletStateV1;
|
|
19
|
+
allUtxos: RpcListUnspentEntry[];
|
|
20
|
+
sender: MutationSender;
|
|
21
|
+
opReturnData: Uint8Array;
|
|
22
|
+
errorPrefix: string;
|
|
23
|
+
}): DomainMarketPlan;
|
|
24
|
+
export declare function validateFundedDomainMarketDraft(decoded: RpcDecodedPsbt, funded: BuiltDomainMarketTransaction["funded"], plan: DomainMarketPlan): void;
|
|
25
|
+
export declare function buildDomainMarketTransaction(options: {
|
|
26
|
+
rpc: DomainMarketRpcClient;
|
|
27
|
+
walletName: string;
|
|
28
|
+
state: WalletStateV1;
|
|
29
|
+
plan: DomainMarketPlan;
|
|
30
|
+
feeRateSatVb: number;
|
|
31
|
+
}): Promise<BuiltDomainMarketTransaction>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { reconcilePersistentPolicyLocks as reconcileWalletCoinControlLocks } from "../../coin-control.js";
|
|
2
|
+
import { buildWalletMutationTransactionWithReserveFallback, outpointKey, saveWalletStatePreservingUnlock, } from "../common.js";
|
|
3
|
+
function encodeOpReturnScript(payload) {
|
|
4
|
+
if (payload.length <= 75) {
|
|
5
|
+
return Buffer.concat([
|
|
6
|
+
Buffer.from([0x6a, payload.length]),
|
|
7
|
+
Buffer.from(payload),
|
|
8
|
+
]).toString("hex");
|
|
9
|
+
}
|
|
10
|
+
return Buffer.concat([
|
|
11
|
+
Buffer.from([0x6a, 0x4c, payload.length]),
|
|
12
|
+
Buffer.from(payload),
|
|
13
|
+
]).toString("hex");
|
|
14
|
+
}
|
|
15
|
+
export async function prepareDomainMarketBuildState(options) {
|
|
16
|
+
if (!options.preflightCoinControl) {
|
|
17
|
+
return {
|
|
18
|
+
state: options.state,
|
|
19
|
+
allUtxos: (await options.rpc.listUnspent(options.walletName, 1)).slice(),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const reconciled = await reconcileWalletCoinControlLocks({
|
|
23
|
+
rpc: options.rpc,
|
|
24
|
+
walletName: options.walletName,
|
|
25
|
+
state: options.state,
|
|
26
|
+
});
|
|
27
|
+
const nextState = reconciled.changed
|
|
28
|
+
? {
|
|
29
|
+
...reconciled.state,
|
|
30
|
+
stateRevision: reconciled.state.stateRevision + 1,
|
|
31
|
+
lastWrittenAtUnixMs: options.nowUnixMs,
|
|
32
|
+
}
|
|
33
|
+
: reconciled.state;
|
|
34
|
+
if (reconciled.changed) {
|
|
35
|
+
await saveWalletStatePreservingUnlock({
|
|
36
|
+
state: nextState,
|
|
37
|
+
provider: options.provider,
|
|
38
|
+
nowUnixMs: options.nowUnixMs,
|
|
39
|
+
paths: options.paths,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
state: nextState,
|
|
44
|
+
allUtxos: (await options.rpc.listUnspent(options.walletName, 1)).slice(),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export function buildPlanForDomainOperation(options) {
|
|
48
|
+
const fundingUtxos = options.allUtxos.filter((entry) => entry.scriptPubKey === options.state.funding.scriptPubKeyHex
|
|
49
|
+
&& entry.confirmations >= 1
|
|
50
|
+
&& entry.spendable !== false
|
|
51
|
+
&& entry.safe !== false);
|
|
52
|
+
return {
|
|
53
|
+
sender: options.sender,
|
|
54
|
+
changeAddress: options.state.funding.address,
|
|
55
|
+
fixedInputs: [],
|
|
56
|
+
outputs: [{ data: Buffer.from(options.opReturnData).toString("hex") }],
|
|
57
|
+
changePosition: 1,
|
|
58
|
+
expectedOpReturnScriptHex: encodeOpReturnScript(options.opReturnData),
|
|
59
|
+
allowedFundingScriptPubKeyHex: options.state.funding.scriptPubKeyHex,
|
|
60
|
+
eligibleFundingOutpointKeys: new Set(fundingUtxos.map((entry) => outpointKey({ txid: entry.txid, vout: entry.vout }))),
|
|
61
|
+
errorPrefix: options.errorPrefix,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export function validateFundedDomainMarketDraft(decoded, funded, plan) {
|
|
65
|
+
const inputs = decoded.tx.vin;
|
|
66
|
+
const outputs = decoded.tx.vout;
|
|
67
|
+
if (inputs.length === 0) {
|
|
68
|
+
throw new Error(`${plan.errorPrefix}_missing_sender_input`);
|
|
69
|
+
}
|
|
70
|
+
if (outputs[0]?.scriptPubKey?.hex !== plan.expectedOpReturnScriptHex) {
|
|
71
|
+
throw new Error(`${plan.errorPrefix}_opreturn_mismatch`);
|
|
72
|
+
}
|
|
73
|
+
const expectedWithoutChange = 1;
|
|
74
|
+
if (funded.changepos === -1) {
|
|
75
|
+
if (outputs.length !== expectedWithoutChange) {
|
|
76
|
+
throw new Error(`${plan.errorPrefix}_unexpected_output_count`);
|
|
77
|
+
}
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (funded.changepos !== plan.changePosition || outputs.length !== expectedWithoutChange + 1) {
|
|
81
|
+
throw new Error(`${plan.errorPrefix}_change_position_mismatch`);
|
|
82
|
+
}
|
|
83
|
+
if (outputs[funded.changepos]?.scriptPubKey?.hex !== plan.allowedFundingScriptPubKeyHex) {
|
|
84
|
+
throw new Error(`${plan.errorPrefix}_change_output_mismatch`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export async function buildDomainMarketTransaction(options) {
|
|
88
|
+
return buildWalletMutationTransactionWithReserveFallback({
|
|
89
|
+
rpc: options.rpc,
|
|
90
|
+
walletName: options.walletName,
|
|
91
|
+
state: options.state,
|
|
92
|
+
plan: options.plan,
|
|
93
|
+
validateFundedDraft: validateFundedDomainMarketDraft,
|
|
94
|
+
finalizeErrorCode: `${options.plan.errorPrefix}_finalize_failed`,
|
|
95
|
+
mempoolRejectPrefix: `${options.plan.errorPrefix}_mempool_rejected`,
|
|
96
|
+
feeRate: options.feeRateSatVb,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { PendingMutationRecord } from "../../types.js";
|
|
2
|
+
import type { WalletMutationFeeSummary } from "../common.js";
|
|
3
|
+
import type { BuyDomainMutationOperation, DomainMarketMutationResult, SellDomainMutationOperation, TransferDomainMutationOperation } from "./types.js";
|
|
4
|
+
export declare function createTransferReuseResult(options: {
|
|
5
|
+
operation: TransferDomainMutationOperation;
|
|
6
|
+
mutation: PendingMutationRecord;
|
|
7
|
+
resolution: "confirmed" | "live";
|
|
8
|
+
fees: WalletMutationFeeSummary;
|
|
9
|
+
}): DomainMarketMutationResult;
|
|
10
|
+
export declare function createTransferResult(options: {
|
|
11
|
+
operation: TransferDomainMutationOperation;
|
|
12
|
+
mutation: PendingMutationRecord;
|
|
13
|
+
builtTxid: string | null;
|
|
14
|
+
status: "live" | "confirmed";
|
|
15
|
+
reusedExisting: boolean;
|
|
16
|
+
fees: WalletMutationFeeSummary;
|
|
17
|
+
}): DomainMarketMutationResult;
|
|
18
|
+
export declare function createSellReuseResult(options: {
|
|
19
|
+
operation: SellDomainMutationOperation;
|
|
20
|
+
mutation: PendingMutationRecord;
|
|
21
|
+
resolution: "confirmed" | "live";
|
|
22
|
+
fees: WalletMutationFeeSummary;
|
|
23
|
+
}): DomainMarketMutationResult;
|
|
24
|
+
export declare function createSellResult(options: {
|
|
25
|
+
operation: SellDomainMutationOperation;
|
|
26
|
+
mutation: PendingMutationRecord;
|
|
27
|
+
builtTxid: string | null;
|
|
28
|
+
status: "live" | "confirmed";
|
|
29
|
+
reusedExisting: boolean;
|
|
30
|
+
fees: WalletMutationFeeSummary;
|
|
31
|
+
}): DomainMarketMutationResult;
|
|
32
|
+
export declare function createBuyReuseResult(options: {
|
|
33
|
+
operation: BuyDomainMutationOperation;
|
|
34
|
+
mutation: PendingMutationRecord;
|
|
35
|
+
resolution: "confirmed" | "live";
|
|
36
|
+
fees: WalletMutationFeeSummary;
|
|
37
|
+
}): DomainMarketMutationResult;
|
|
38
|
+
export declare function createBuyResult(options: {
|
|
39
|
+
operation: BuyDomainMutationOperation;
|
|
40
|
+
mutation: PendingMutationRecord;
|
|
41
|
+
builtTxid: string | null;
|
|
42
|
+
status: "live" | "confirmed";
|
|
43
|
+
reusedExisting: boolean;
|
|
44
|
+
fees: WalletMutationFeeSummary;
|
|
45
|
+
}): DomainMarketMutationResult;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
export function createTransferReuseResult(options) {
|
|
2
|
+
return {
|
|
3
|
+
kind: "transfer",
|
|
4
|
+
domainName: options.operation.normalizedDomainName,
|
|
5
|
+
txid: options.mutation.attemptedTxid ?? "unknown",
|
|
6
|
+
status: options.resolution,
|
|
7
|
+
reusedExisting: true,
|
|
8
|
+
recipientScriptPubKeyHex: options.operation.recipient.scriptPubKeyHex,
|
|
9
|
+
resolved: {
|
|
10
|
+
sender: options.operation.resolvedSender,
|
|
11
|
+
recipient: options.operation.resolvedRecipient,
|
|
12
|
+
economicEffect: options.operation.resolvedEconomicEffect,
|
|
13
|
+
},
|
|
14
|
+
fees: options.fees,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function createTransferResult(options) {
|
|
18
|
+
return {
|
|
19
|
+
kind: "transfer",
|
|
20
|
+
domainName: options.operation.normalizedDomainName,
|
|
21
|
+
txid: options.mutation.attemptedTxid ?? options.builtTxid ?? "unknown",
|
|
22
|
+
status: options.status,
|
|
23
|
+
reusedExisting: options.reusedExisting,
|
|
24
|
+
recipientScriptPubKeyHex: options.operation.recipient.scriptPubKeyHex,
|
|
25
|
+
resolved: {
|
|
26
|
+
sender: options.operation.resolvedSender,
|
|
27
|
+
recipient: options.operation.resolvedRecipient,
|
|
28
|
+
economicEffect: options.operation.resolvedEconomicEffect,
|
|
29
|
+
},
|
|
30
|
+
fees: options.fees,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export function createSellReuseResult(options) {
|
|
34
|
+
return {
|
|
35
|
+
kind: "sell",
|
|
36
|
+
domainName: options.operation.normalizedDomainName,
|
|
37
|
+
txid: options.mutation.attemptedTxid ?? "unknown",
|
|
38
|
+
status: options.resolution,
|
|
39
|
+
reusedExisting: true,
|
|
40
|
+
listedPriceCogtoshi: options.operation.listedPriceCogtoshi,
|
|
41
|
+
resolved: {
|
|
42
|
+
sender: options.operation.resolvedSender,
|
|
43
|
+
economicEffect: options.operation.resolvedEconomicEffect,
|
|
44
|
+
},
|
|
45
|
+
fees: options.fees,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export function createSellResult(options) {
|
|
49
|
+
return {
|
|
50
|
+
kind: "sell",
|
|
51
|
+
domainName: options.operation.normalizedDomainName,
|
|
52
|
+
txid: options.mutation.attemptedTxid ?? options.builtTxid ?? "unknown",
|
|
53
|
+
status: options.status,
|
|
54
|
+
reusedExisting: options.reusedExisting,
|
|
55
|
+
listedPriceCogtoshi: options.operation.listedPriceCogtoshi,
|
|
56
|
+
resolved: {
|
|
57
|
+
sender: options.operation.resolvedSender,
|
|
58
|
+
economicEffect: options.operation.resolvedEconomicEffect,
|
|
59
|
+
},
|
|
60
|
+
fees: options.fees,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export function createBuyReuseResult(options) {
|
|
64
|
+
return {
|
|
65
|
+
kind: "buy",
|
|
66
|
+
domainName: options.operation.normalizedDomainName,
|
|
67
|
+
txid: options.mutation.attemptedTxid ?? "unknown",
|
|
68
|
+
status: options.resolution,
|
|
69
|
+
reusedExisting: true,
|
|
70
|
+
listedPriceCogtoshi: options.operation.listingPriceCogtoshi,
|
|
71
|
+
resolvedBuyer: options.operation.resolvedBuyer,
|
|
72
|
+
resolvedSeller: options.operation.resolvedSeller,
|
|
73
|
+
fees: options.fees,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export function createBuyResult(options) {
|
|
77
|
+
return {
|
|
78
|
+
kind: "buy",
|
|
79
|
+
domainName: options.operation.normalizedDomainName,
|
|
80
|
+
txid: options.mutation.attemptedTxid ?? options.builtTxid ?? "unknown",
|
|
81
|
+
status: options.status,
|
|
82
|
+
reusedExisting: options.reusedExisting,
|
|
83
|
+
listedPriceCogtoshi: options.operation.listingPriceCogtoshi,
|
|
84
|
+
resolvedBuyer: options.operation.resolvedBuyer,
|
|
85
|
+
resolvedSeller: options.operation.resolvedSeller,
|
|
86
|
+
fees: options.fees,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import type { lookupDomain } from "@cogcoin/indexer/queries";
|
|
2
|
+
import type { RpcListUnspentEntry, RpcTransaction } from "../../../bitcoind/types.js";
|
|
3
|
+
import type { WalletPrompter } from "../../lifecycle.js";
|
|
4
|
+
import type { WalletReadContext } from "../../read/index.js";
|
|
5
|
+
import type { WalletRuntimePaths } from "../../runtime.js";
|
|
6
|
+
import type { WalletSecretProvider } from "../../state/provider.js";
|
|
7
|
+
import type { PendingMutationRecord, WalletStateV1 } from "../../types.js";
|
|
8
|
+
import type { BuiltWalletMutationTransaction, FixedWalletInput, MutationSender, WalletMutationFeeSummary, WalletMutationRpcClient } from "../common.js";
|
|
9
|
+
export type DomainMarketKind = "transfer" | "sell" | "buy";
|
|
10
|
+
export interface DomainMarketRpcClient 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
|
+
export interface DomainMarketPlan {
|
|
19
|
+
sender: MutationSender;
|
|
20
|
+
changeAddress: string;
|
|
21
|
+
fixedInputs: FixedWalletInput[];
|
|
22
|
+
outputs: unknown[];
|
|
23
|
+
changePosition: number;
|
|
24
|
+
expectedOpReturnScriptHex: string;
|
|
25
|
+
allowedFundingScriptPubKeyHex: string;
|
|
26
|
+
eligibleFundingOutpointKeys: Set<string>;
|
|
27
|
+
errorPrefix: string;
|
|
28
|
+
}
|
|
29
|
+
export interface BuiltDomainMarketTransaction extends BuiltWalletMutationTransaction {
|
|
30
|
+
}
|
|
31
|
+
export interface DomainOperationContext {
|
|
32
|
+
readContext: WalletReadContext;
|
|
33
|
+
state: WalletStateV1;
|
|
34
|
+
sender: MutationSender;
|
|
35
|
+
senderSelector: string;
|
|
36
|
+
chainDomain: NonNullable<ReturnType<typeof lookupDomain>>;
|
|
37
|
+
}
|
|
38
|
+
export interface BuyOperationContext extends DomainOperationContext {
|
|
39
|
+
listingPriceCogtoshi: bigint;
|
|
40
|
+
buyerSelector: string;
|
|
41
|
+
}
|
|
42
|
+
export interface TransferDomainMutationOperation extends DomainOperationContext {
|
|
43
|
+
normalizedDomainName: string;
|
|
44
|
+
recipient: ReturnType<typeof import("../targets.js").normalizeBtcTarget>;
|
|
45
|
+
resolvedSender: DomainMarketResolvedSenderSummary;
|
|
46
|
+
resolvedRecipient: DomainMarketResolvedRecipientSummary;
|
|
47
|
+
resolvedEconomicEffect: DomainMarketResolvedEconomicEffect;
|
|
48
|
+
}
|
|
49
|
+
export interface SellDomainMutationOperation extends DomainOperationContext {
|
|
50
|
+
normalizedDomainName: string;
|
|
51
|
+
listedPriceCogtoshi: bigint;
|
|
52
|
+
resolvedSender: DomainMarketResolvedSenderSummary;
|
|
53
|
+
resolvedEconomicEffect: DomainMarketResolvedEconomicEffect;
|
|
54
|
+
}
|
|
55
|
+
export interface BuyDomainMutationOperation extends BuyOperationContext {
|
|
56
|
+
normalizedDomainName: string;
|
|
57
|
+
sellerScriptPubKeyHex: string;
|
|
58
|
+
resolvedBuyer: DomainMarketResolvedBuyerSummary;
|
|
59
|
+
resolvedSeller: DomainMarketResolvedSellerSummary;
|
|
60
|
+
}
|
|
61
|
+
export type DomainMarketOperation = TransferDomainMutationOperation | SellDomainMutationOperation | BuyDomainMutationOperation;
|
|
62
|
+
export interface DomainMarketResolvedSenderSummary {
|
|
63
|
+
selector: string;
|
|
64
|
+
localIndex: number;
|
|
65
|
+
scriptPubKeyHex: string;
|
|
66
|
+
address: string;
|
|
67
|
+
}
|
|
68
|
+
export interface DomainMarketResolvedRecipientSummary {
|
|
69
|
+
scriptPubKeyHex: string;
|
|
70
|
+
address: string | null;
|
|
71
|
+
opaque: boolean;
|
|
72
|
+
}
|
|
73
|
+
export interface DomainMarketResolvedBuyerSummary {
|
|
74
|
+
selector: string;
|
|
75
|
+
localIndex: number;
|
|
76
|
+
scriptPubKeyHex: string;
|
|
77
|
+
address: string;
|
|
78
|
+
}
|
|
79
|
+
export interface DomainMarketResolvedSellerSummary {
|
|
80
|
+
scriptPubKeyHex: string;
|
|
81
|
+
address: string | null;
|
|
82
|
+
}
|
|
83
|
+
export type DomainMarketResolvedEconomicEffect = {
|
|
84
|
+
kind: "ownership-transfer";
|
|
85
|
+
clearsListing: boolean;
|
|
86
|
+
} | {
|
|
87
|
+
kind: "listing-set";
|
|
88
|
+
listedPriceCogtoshi: string;
|
|
89
|
+
} | {
|
|
90
|
+
kind: "listing-clear";
|
|
91
|
+
listedPriceCogtoshi: "0";
|
|
92
|
+
};
|
|
93
|
+
export interface DomainMarketResolvedSummary {
|
|
94
|
+
sender: DomainMarketResolvedSenderSummary;
|
|
95
|
+
recipient?: DomainMarketResolvedRecipientSummary | null;
|
|
96
|
+
economicEffect: DomainMarketResolvedEconomicEffect;
|
|
97
|
+
}
|
|
98
|
+
export interface TransferDomainOptions {
|
|
99
|
+
domainName: string;
|
|
100
|
+
target: string;
|
|
101
|
+
feeRateSatVb?: number | null;
|
|
102
|
+
dataDir: string;
|
|
103
|
+
databasePath: string;
|
|
104
|
+
provider?: WalletSecretProvider;
|
|
105
|
+
prompter: WalletPrompter;
|
|
106
|
+
assumeYes?: boolean;
|
|
107
|
+
nowUnixMs?: number;
|
|
108
|
+
paths?: WalletRuntimePaths;
|
|
109
|
+
openReadContext?: typeof import("../../read/index.js").openWalletReadContext;
|
|
110
|
+
attachService?: typeof import("../../../bitcoind/service.js").attachOrStartManagedBitcoindService;
|
|
111
|
+
rpcFactory?: (config: Parameters<typeof import("../../../bitcoind/node.js").createRpcClient>[0]) => DomainMarketRpcClient;
|
|
112
|
+
}
|
|
113
|
+
export interface SellDomainOptions {
|
|
114
|
+
domainName: string;
|
|
115
|
+
listedPriceCogtoshi: bigint;
|
|
116
|
+
feeRateSatVb?: number | null;
|
|
117
|
+
dataDir: string;
|
|
118
|
+
databasePath: string;
|
|
119
|
+
provider?: WalletSecretProvider;
|
|
120
|
+
prompter: WalletPrompter;
|
|
121
|
+
assumeYes?: boolean;
|
|
122
|
+
nowUnixMs?: number;
|
|
123
|
+
paths?: WalletRuntimePaths;
|
|
124
|
+
openReadContext?: typeof import("../../read/index.js").openWalletReadContext;
|
|
125
|
+
attachService?: typeof import("../../../bitcoind/service.js").attachOrStartManagedBitcoindService;
|
|
126
|
+
rpcFactory?: (config: Parameters<typeof import("../../../bitcoind/node.js").createRpcClient>[0]) => DomainMarketRpcClient;
|
|
127
|
+
}
|
|
128
|
+
export interface BuyDomainOptions {
|
|
129
|
+
domainName: string;
|
|
130
|
+
fromIdentity?: string | null;
|
|
131
|
+
feeRateSatVb?: number | null;
|
|
132
|
+
dataDir: string;
|
|
133
|
+
databasePath: string;
|
|
134
|
+
provider?: WalletSecretProvider;
|
|
135
|
+
prompter: WalletPrompter;
|
|
136
|
+
assumeYes?: boolean;
|
|
137
|
+
nowUnixMs?: number;
|
|
138
|
+
paths?: WalletRuntimePaths;
|
|
139
|
+
openReadContext?: typeof import("../../read/index.js").openWalletReadContext;
|
|
140
|
+
attachService?: typeof import("../../../bitcoind/service.js").attachOrStartManagedBitcoindService;
|
|
141
|
+
rpcFactory?: (config: Parameters<typeof import("../../../bitcoind/node.js").createRpcClient>[0]) => DomainMarketRpcClient;
|
|
142
|
+
}
|
|
143
|
+
export interface DomainMarketMutationResult {
|
|
144
|
+
kind: DomainMarketKind;
|
|
145
|
+
domainName: string;
|
|
146
|
+
txid: string;
|
|
147
|
+
status: "live" | "confirmed";
|
|
148
|
+
reusedExisting: boolean;
|
|
149
|
+
listedPriceCogtoshi?: bigint;
|
|
150
|
+
recipientScriptPubKeyHex?: string | null;
|
|
151
|
+
resolved?: DomainMarketResolvedSummary | null;
|
|
152
|
+
resolvedBuyer?: DomainMarketResolvedBuyerSummary | null;
|
|
153
|
+
resolvedSeller?: DomainMarketResolvedSellerSummary | null;
|
|
154
|
+
fees: WalletMutationFeeSummary;
|
|
155
|
+
}
|
|
156
|
+
export interface DomainMarketDraftMutationOptions {
|
|
157
|
+
kind: DomainMarketKind;
|
|
158
|
+
domainName: string;
|
|
159
|
+
sender: MutationSender;
|
|
160
|
+
intentFingerprintHex: string;
|
|
161
|
+
nowUnixMs: number;
|
|
162
|
+
feeSelection: {
|
|
163
|
+
feeRateSatVb: number;
|
|
164
|
+
source: "custom-satvb" | "estimated-next-block-plus-one" | "fallback-default";
|
|
165
|
+
};
|
|
166
|
+
parentDomainName?: string | null;
|
|
167
|
+
recipientScriptPubKeyHex?: string | null;
|
|
168
|
+
priceCogtoshi?: bigint | null;
|
|
169
|
+
existing?: PendingMutationRecord | null;
|
|
170
|
+
}
|
|
171
|
+
export interface DomainMarketBuildState {
|
|
172
|
+
state: WalletStateV1;
|
|
173
|
+
allUtxos: RpcListUnspentEntry[];
|
|
174
|
+
}
|
|
175
|
+
export interface DomainMarketMutationVariant<TOperation extends DomainMarketOperation> {
|
|
176
|
+
controlLockPurpose: string;
|
|
177
|
+
preemptionReason: string;
|
|
178
|
+
errorPrefix: string;
|
|
179
|
+
repairRequiredErrorCode: string;
|
|
180
|
+
resolveOperation(readContext: WalletReadContext): TOperation;
|
|
181
|
+
createIntentFingerprint(operation: TOperation): string;
|
|
182
|
+
confirm(operation: TOperation): Promise<void>;
|
|
183
|
+
createDraftMutation(options: {
|
|
184
|
+
operation: TOperation;
|
|
185
|
+
existingMutation: PendingMutationRecord | null;
|
|
186
|
+
feeSelection: {
|
|
187
|
+
feeRateSatVb: number;
|
|
188
|
+
source: "custom-satvb" | "estimated-next-block-plus-one" | "fallback-default";
|
|
189
|
+
};
|
|
190
|
+
intentFingerprintHex: string;
|
|
191
|
+
nowUnixMs: number;
|
|
192
|
+
}): PendingMutationRecord;
|
|
193
|
+
createOpReturnData(operation: TOperation): Uint8Array;
|
|
194
|
+
beforePublish?(operation: TOperation): Promise<void>;
|
|
195
|
+
afterAccepted(options: {
|
|
196
|
+
operation: TOperation;
|
|
197
|
+
acceptedState: WalletStateV1;
|
|
198
|
+
broadcastingMutation: PendingMutationRecord;
|
|
199
|
+
built: BuiltDomainMarketTransaction;
|
|
200
|
+
nowUnixMs: number;
|
|
201
|
+
snapshot: WalletReadContext["snapshot"];
|
|
202
|
+
}): Promise<{
|
|
203
|
+
state: WalletStateV1;
|
|
204
|
+
mutation: PendingMutationRecord;
|
|
205
|
+
status: "live" | "confirmed";
|
|
206
|
+
}>;
|
|
207
|
+
createReuseResult(options: {
|
|
208
|
+
operation: TOperation;
|
|
209
|
+
mutation: PendingMutationRecord;
|
|
210
|
+
resolution: "confirmed" | "live";
|
|
211
|
+
fees: WalletMutationFeeSummary;
|
|
212
|
+
}): DomainMarketMutationResult;
|
|
213
|
+
createResult(options: {
|
|
214
|
+
operation: TOperation;
|
|
215
|
+
mutation: PendingMutationRecord;
|
|
216
|
+
builtTxid: string | null;
|
|
217
|
+
status: "live" | "confirmed";
|
|
218
|
+
reusedExisting: boolean;
|
|
219
|
+
fees: WalletMutationFeeSummary;
|
|
220
|
+
}): DomainMarketMutationResult;
|
|
221
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|