@cogcoin/client 1.1.8 → 1.1.10
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/bitcoind/managed-bitcoind-service-config.d.ts +13 -0
- package/dist/bitcoind/managed-bitcoind-service-config.js +165 -0
- package/dist/bitcoind/managed-bitcoind-service-lifecycle.d.ts +28 -0
- package/dist/bitcoind/managed-bitcoind-service-lifecycle.js +290 -0
- package/dist/bitcoind/managed-bitcoind-service-process.d.ts +8 -0
- package/dist/bitcoind/managed-bitcoind-service-process.js +48 -0
- package/dist/bitcoind/managed-bitcoind-service-replica.d.ts +8 -0
- package/dist/bitcoind/managed-bitcoind-service-replica.js +142 -0
- package/dist/bitcoind/managed-bitcoind-service-status.d.ts +42 -0
- package/dist/bitcoind/managed-bitcoind-service-status.js +178 -0
- package/dist/bitcoind/managed-bitcoind-service-types.d.ts +36 -0
- package/dist/bitcoind/managed-bitcoind-service-types.js +1 -0
- package/dist/bitcoind/service.d.ts +7 -63
- package/dist/bitcoind/service.js +7 -797
- 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/engine-types.d.ts +1 -0
- package/dist/wallet/mining/engine-types.js +9 -1
- package/dist/wallet/mining/publish.js +3 -6
- package/dist/wallet/mining/runner.js +30 -18
- package/dist/wallet/mining/sentence-protocol.d.ts +2 -2
- package/dist/wallet/mining/sentences.js +8 -8
- package/dist/wallet/mining/visualizer.js +7 -6
- package/dist/wallet/read/context.d.ts +4 -10
- package/dist/wallet/read/context.js +4 -227
- package/dist/wallet/read/local-state.d.ts +28 -0
- package/dist/wallet/read/local-state.js +233 -0
- package/dist/wallet/read/managed-bitcoind.d.ts +30 -0
- package/dist/wallet/read/managed-bitcoind.js +138 -0
- package/dist/wallet/read/managed-indexer.d.ts +23 -0
- package/dist/wallet/read/managed-indexer.js +87 -0
- package/dist/wallet/read/managed-services.d.ts +6 -21
- package/dist/wallet/read/managed-services.js +23 -196
- 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,103 @@
|
|
|
1
|
+
import { serializeDomainBuy } from "../../../cogop/index.js";
|
|
2
|
+
import { confirmBuy } from "../confirm.js";
|
|
3
|
+
import { createDomainMarketIntentFingerprint, createResolvedBuyerSummary, createResolvedSellerSummary, normalizeDomainMarketDomainName, resolveBuyOperation, } from "../intent.js";
|
|
4
|
+
import { createDomainMarketDraftMutation, getBuyStatusAfterAcceptance, reserveTransferredDomainRecord, } from "../draft.js";
|
|
5
|
+
import { createBuyResult, createBuyReuseResult, } from "../result.js";
|
|
6
|
+
import { upsertPendingMutation } from "../../journal.js";
|
|
7
|
+
import { updateMutationRecord } from "../../common.js";
|
|
8
|
+
export function createBuyDomainVariant(options) {
|
|
9
|
+
const normalizedDomainName = normalizeDomainMarketDomainName(options.domainName);
|
|
10
|
+
return {
|
|
11
|
+
controlLockPurpose: "wallet-buy",
|
|
12
|
+
preemptionReason: "wallet-buy",
|
|
13
|
+
errorPrefix: "wallet_buy",
|
|
14
|
+
repairRequiredErrorCode: "wallet_buy_repair_required",
|
|
15
|
+
resolveOperation(readContext) {
|
|
16
|
+
const operation = resolveBuyOperation(readContext, normalizedDomainName, options.fromIdentity ?? null);
|
|
17
|
+
const model = readContext.model;
|
|
18
|
+
const sellerScriptPubKeyHex = Buffer.from(operation.chainDomain.ownerScriptPubKey).toString("hex");
|
|
19
|
+
const sellerAddress = sellerScriptPubKeyHex === model.walletScriptPubKeyHex ? model.walletAddress : null;
|
|
20
|
+
return {
|
|
21
|
+
...operation,
|
|
22
|
+
normalizedDomainName,
|
|
23
|
+
sellerScriptPubKeyHex,
|
|
24
|
+
resolvedBuyer: createResolvedBuyerSummary(operation.buyerSelector, operation.sender),
|
|
25
|
+
resolvedSeller: createResolvedSellerSummary(sellerScriptPubKeyHex, sellerAddress),
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
createIntentFingerprint(operation) {
|
|
29
|
+
return createDomainMarketIntentFingerprint([
|
|
30
|
+
"buy",
|
|
31
|
+
operation.state.walletRootId,
|
|
32
|
+
operation.normalizedDomainName,
|
|
33
|
+
operation.sender.scriptPubKeyHex,
|
|
34
|
+
operation.listingPriceCogtoshi.toString(),
|
|
35
|
+
]);
|
|
36
|
+
},
|
|
37
|
+
confirm(operation) {
|
|
38
|
+
return confirmBuy(options.prompter, operation.normalizedDomainName, operation.buyerSelector, operation.sender, operation.sellerScriptPubKeyHex, operation.resolvedSeller.address, operation.listingPriceCogtoshi, options.assumeYes);
|
|
39
|
+
},
|
|
40
|
+
createDraftMutation({ operation, existingMutation, feeSelection, intentFingerprintHex, nowUnixMs }) {
|
|
41
|
+
return createDomainMarketDraftMutation({
|
|
42
|
+
kind: "buy",
|
|
43
|
+
domainName: operation.normalizedDomainName,
|
|
44
|
+
sender: operation.sender,
|
|
45
|
+
priceCogtoshi: operation.listingPriceCogtoshi,
|
|
46
|
+
intentFingerprintHex,
|
|
47
|
+
nowUnixMs,
|
|
48
|
+
feeSelection,
|
|
49
|
+
existing: existingMutation,
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
createOpReturnData(operation) {
|
|
53
|
+
return serializeDomainBuy(operation.chainDomain.domainId, operation.listingPriceCogtoshi).opReturnData;
|
|
54
|
+
},
|
|
55
|
+
async beforePublish(operation) {
|
|
56
|
+
const currentSellerHex = Buffer.from(operation.chainDomain.ownerScriptPubKey).toString("hex");
|
|
57
|
+
if (currentSellerHex !== operation.sellerScriptPubKeyHex) {
|
|
58
|
+
throw new Error("wallet_buy_stale_listing_owner");
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
async afterAccepted({ operation, acceptedState, broadcastingMutation, built, nowUnixMs, snapshot }) {
|
|
62
|
+
const finalStatus = getBuyStatusAfterAcceptance({
|
|
63
|
+
snapshot,
|
|
64
|
+
domainName: operation.normalizedDomainName,
|
|
65
|
+
buyerScriptPubKeyHex: operation.sender.scriptPubKeyHex,
|
|
66
|
+
});
|
|
67
|
+
const finalMutation = updateMutationRecord(broadcastingMutation, finalStatus, nowUnixMs, {
|
|
68
|
+
attemptedTxid: built.txid,
|
|
69
|
+
attemptedWtxid: built.wtxid,
|
|
70
|
+
temporaryBuilderLockedOutpoints: [],
|
|
71
|
+
});
|
|
72
|
+
return {
|
|
73
|
+
state: reserveTransferredDomainRecord({
|
|
74
|
+
state: upsertPendingMutation(acceptedState, finalMutation),
|
|
75
|
+
domainName: operation.normalizedDomainName,
|
|
76
|
+
domainId: operation.chainDomain.domainId,
|
|
77
|
+
currentOwnerScriptPubKeyHex: operation.sender.scriptPubKeyHex,
|
|
78
|
+
nowUnixMs,
|
|
79
|
+
}),
|
|
80
|
+
mutation: finalMutation,
|
|
81
|
+
status: finalStatus,
|
|
82
|
+
};
|
|
83
|
+
},
|
|
84
|
+
createReuseResult({ operation, mutation, resolution, fees }) {
|
|
85
|
+
return createBuyReuseResult({
|
|
86
|
+
operation,
|
|
87
|
+
mutation,
|
|
88
|
+
resolution,
|
|
89
|
+
fees,
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
createResult({ operation, mutation, builtTxid, status, reusedExisting, fees }) {
|
|
93
|
+
return createBuyResult({
|
|
94
|
+
operation,
|
|
95
|
+
mutation,
|
|
96
|
+
builtTxid,
|
|
97
|
+
status,
|
|
98
|
+
reusedExisting,
|
|
99
|
+
fees,
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { serializeDomainSell } from "../../../cogop/index.js";
|
|
2
|
+
import { confirmSell } from "../confirm.js";
|
|
3
|
+
import { createDomainMarketIntentFingerprint, createResolvedDomainMarketSenderSummary, createSellEconomicEffectSummary, normalizeDomainMarketDomainName, resolveOwnedDomainOperation, } from "../intent.js";
|
|
4
|
+
import { createDomainMarketDraftMutation, getSellStatusAfterAcceptance, } from "../draft.js";
|
|
5
|
+
import { createSellResult, createSellReuseResult, } from "../result.js";
|
|
6
|
+
import { upsertPendingMutation } from "../../journal.js";
|
|
7
|
+
import { updateMutationRecord } from "../../common.js";
|
|
8
|
+
export function createSellDomainVariant(options) {
|
|
9
|
+
const normalizedDomainName = normalizeDomainMarketDomainName(options.domainName);
|
|
10
|
+
return {
|
|
11
|
+
controlLockPurpose: "wallet-sell",
|
|
12
|
+
preemptionReason: "wallet-sell",
|
|
13
|
+
errorPrefix: "wallet_sell",
|
|
14
|
+
repairRequiredErrorCode: "wallet_sell_repair_required",
|
|
15
|
+
resolveOperation(readContext) {
|
|
16
|
+
const operation = resolveOwnedDomainOperation(readContext, normalizedDomainName, "wallet_sell");
|
|
17
|
+
return {
|
|
18
|
+
...operation,
|
|
19
|
+
normalizedDomainName,
|
|
20
|
+
listedPriceCogtoshi: options.listedPriceCogtoshi,
|
|
21
|
+
resolvedSender: createResolvedDomainMarketSenderSummary(operation.sender, operation.senderSelector),
|
|
22
|
+
resolvedEconomicEffect: createSellEconomicEffectSummary(options.listedPriceCogtoshi),
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
createIntentFingerprint(operation) {
|
|
26
|
+
return createDomainMarketIntentFingerprint([
|
|
27
|
+
"sell",
|
|
28
|
+
operation.state.walletRootId,
|
|
29
|
+
operation.normalizedDomainName,
|
|
30
|
+
operation.sender.scriptPubKeyHex,
|
|
31
|
+
operation.listedPriceCogtoshi.toString(),
|
|
32
|
+
]);
|
|
33
|
+
},
|
|
34
|
+
async confirm(operation) {
|
|
35
|
+
if (operation.listedPriceCogtoshi > 0n) {
|
|
36
|
+
await confirmSell(options.prompter, operation.normalizedDomainName, operation.resolvedSender, operation.listedPriceCogtoshi, options.assumeYes);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
createDraftMutation({ operation, existingMutation, feeSelection, intentFingerprintHex, nowUnixMs }) {
|
|
40
|
+
return createDomainMarketDraftMutation({
|
|
41
|
+
kind: "sell",
|
|
42
|
+
domainName: operation.normalizedDomainName,
|
|
43
|
+
sender: operation.sender,
|
|
44
|
+
priceCogtoshi: operation.listedPriceCogtoshi,
|
|
45
|
+
intentFingerprintHex,
|
|
46
|
+
nowUnixMs,
|
|
47
|
+
feeSelection,
|
|
48
|
+
existing: existingMutation,
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
createOpReturnData(operation) {
|
|
52
|
+
return serializeDomainSell(operation.chainDomain.domainId, operation.listedPriceCogtoshi).opReturnData;
|
|
53
|
+
},
|
|
54
|
+
async afterAccepted({ operation, acceptedState, broadcastingMutation, built, nowUnixMs, snapshot }) {
|
|
55
|
+
const finalStatus = getSellStatusAfterAcceptance({
|
|
56
|
+
snapshot,
|
|
57
|
+
domainName: operation.normalizedDomainName,
|
|
58
|
+
senderScriptPubKeyHex: operation.sender.scriptPubKeyHex,
|
|
59
|
+
listedPriceCogtoshi: operation.listedPriceCogtoshi,
|
|
60
|
+
});
|
|
61
|
+
const finalMutation = updateMutationRecord(broadcastingMutation, finalStatus, nowUnixMs, {
|
|
62
|
+
attemptedTxid: built.txid,
|
|
63
|
+
attemptedWtxid: built.wtxid,
|
|
64
|
+
temporaryBuilderLockedOutpoints: [],
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
state: upsertPendingMutation(acceptedState, finalMutation),
|
|
68
|
+
mutation: finalMutation,
|
|
69
|
+
status: finalStatus,
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
createReuseResult({ operation, mutation, resolution, fees }) {
|
|
73
|
+
return createSellReuseResult({
|
|
74
|
+
operation,
|
|
75
|
+
mutation,
|
|
76
|
+
resolution,
|
|
77
|
+
fees,
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
createResult({ operation, mutation, builtTxid, status, reusedExisting, fees }) {
|
|
81
|
+
return createSellResult({
|
|
82
|
+
operation,
|
|
83
|
+
mutation,
|
|
84
|
+
builtTxid,
|
|
85
|
+
status,
|
|
86
|
+
reusedExisting,
|
|
87
|
+
fees,
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { getListing } from "@cogcoin/indexer/queries";
|
|
2
|
+
import { serializeDomainTransfer } from "../../../cogop/index.js";
|
|
3
|
+
import { confirmTransfer } from "../confirm.js";
|
|
4
|
+
import { createDomainMarketDraftMutation } from "../draft.js";
|
|
5
|
+
import { createDomainMarketIntentFingerprint, createResolvedDomainMarketRecipientSummary, createResolvedDomainMarketSenderSummary, createTransferEconomicEffectSummary, normalizeDomainMarketDomainName, resolveOwnedDomainOperation, } from "../intent.js";
|
|
6
|
+
import { getTransferStatusAfterAcceptance, reserveTransferredDomainRecord, } from "../draft.js";
|
|
7
|
+
import { createTransferResult, createTransferReuseResult, } from "../result.js";
|
|
8
|
+
import { normalizeBtcTarget } from "../../targets.js";
|
|
9
|
+
import { upsertPendingMutation } from "../../journal.js";
|
|
10
|
+
import { updateMutationRecord } from "../../common.js";
|
|
11
|
+
export function createTransferDomainVariant(options) {
|
|
12
|
+
const normalizedDomainName = normalizeDomainMarketDomainName(options.domainName);
|
|
13
|
+
const recipient = normalizeBtcTarget(options.target);
|
|
14
|
+
return {
|
|
15
|
+
controlLockPurpose: "wallet-transfer",
|
|
16
|
+
preemptionReason: "wallet-transfer",
|
|
17
|
+
errorPrefix: "wallet_transfer",
|
|
18
|
+
repairRequiredErrorCode: "wallet_transfer_repair_required",
|
|
19
|
+
resolveOperation(readContext) {
|
|
20
|
+
const operation = resolveOwnedDomainOperation(readContext, normalizedDomainName, "wallet_transfer");
|
|
21
|
+
const resolvedSender = createResolvedDomainMarketSenderSummary(operation.sender, operation.senderSelector);
|
|
22
|
+
const resolvedRecipient = createResolvedDomainMarketRecipientSummary(recipient);
|
|
23
|
+
const resolvedEconomicEffect = createTransferEconomicEffectSummary(getListing(readContext.snapshot.state, operation.chainDomain.domainId) !== null);
|
|
24
|
+
if (operation.sender.scriptPubKeyHex === recipient.scriptPubKeyHex) {
|
|
25
|
+
throw new Error("wallet_transfer_self_transfer");
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
...operation,
|
|
29
|
+
normalizedDomainName,
|
|
30
|
+
recipient,
|
|
31
|
+
resolvedSender,
|
|
32
|
+
resolvedRecipient,
|
|
33
|
+
resolvedEconomicEffect,
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
createIntentFingerprint(operation) {
|
|
37
|
+
return createDomainMarketIntentFingerprint([
|
|
38
|
+
"transfer",
|
|
39
|
+
operation.state.walletRootId,
|
|
40
|
+
operation.normalizedDomainName,
|
|
41
|
+
operation.sender.scriptPubKeyHex,
|
|
42
|
+
operation.recipient.scriptPubKeyHex,
|
|
43
|
+
]);
|
|
44
|
+
},
|
|
45
|
+
confirm(operation) {
|
|
46
|
+
return confirmTransfer(options.prompter, operation.normalizedDomainName, operation.resolvedSender, operation.resolvedRecipient, operation.resolvedEconomicEffect, options.assumeYes);
|
|
47
|
+
},
|
|
48
|
+
createDraftMutation({ operation, existingMutation, feeSelection, intentFingerprintHex, nowUnixMs }) {
|
|
49
|
+
return createDomainMarketDraftMutation({
|
|
50
|
+
kind: "transfer",
|
|
51
|
+
domainName: operation.normalizedDomainName,
|
|
52
|
+
sender: operation.sender,
|
|
53
|
+
recipientScriptPubKeyHex: operation.recipient.scriptPubKeyHex,
|
|
54
|
+
intentFingerprintHex,
|
|
55
|
+
nowUnixMs,
|
|
56
|
+
feeSelection,
|
|
57
|
+
existing: existingMutation,
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
createOpReturnData(operation) {
|
|
61
|
+
return serializeDomainTransfer(operation.chainDomain.domainId, Buffer.from(operation.recipient.scriptPubKeyHex, "hex")).opReturnData;
|
|
62
|
+
},
|
|
63
|
+
async afterAccepted({ operation, acceptedState, broadcastingMutation, built, nowUnixMs, snapshot }) {
|
|
64
|
+
const finalStatus = getTransferStatusAfterAcceptance({
|
|
65
|
+
snapshot,
|
|
66
|
+
domainName: operation.normalizedDomainName,
|
|
67
|
+
recipientScriptPubKeyHex: operation.recipient.scriptPubKeyHex,
|
|
68
|
+
});
|
|
69
|
+
const finalMutation = updateMutationRecord(broadcastingMutation, finalStatus, nowUnixMs, {
|
|
70
|
+
attemptedTxid: built.txid,
|
|
71
|
+
attemptedWtxid: built.wtxid,
|
|
72
|
+
temporaryBuilderLockedOutpoints: [],
|
|
73
|
+
});
|
|
74
|
+
return {
|
|
75
|
+
state: reserveTransferredDomainRecord({
|
|
76
|
+
state: upsertPendingMutation(acceptedState, finalMutation),
|
|
77
|
+
domainName: operation.normalizedDomainName,
|
|
78
|
+
domainId: operation.chainDomain.domainId,
|
|
79
|
+
currentOwnerScriptPubKeyHex: operation.recipient.scriptPubKeyHex,
|
|
80
|
+
nowUnixMs,
|
|
81
|
+
}),
|
|
82
|
+
mutation: finalMutation,
|
|
83
|
+
status: finalStatus,
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
createReuseResult({ operation, mutation, resolution, fees }) {
|
|
87
|
+
return createTransferReuseResult({
|
|
88
|
+
operation,
|
|
89
|
+
mutation,
|
|
90
|
+
resolution,
|
|
91
|
+
fees,
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
createResult({ operation, mutation, builtTxid, status, reusedExisting, fees }) {
|
|
95
|
+
return createTransferResult({
|
|
96
|
+
operation,
|
|
97
|
+
mutation,
|
|
98
|
+
builtTxid,
|
|
99
|
+
status,
|
|
100
|
+
reusedExisting,
|
|
101
|
+
fees,
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
}
|
|
@@ -1,116 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { createRpcClient } from "../../bitcoind/node.js";
|
|
3
|
-
import type { RpcTransaction } from "../../bitcoind/types.js";
|
|
4
|
-
import type { WalletPrompter } from "../lifecycle.js";
|
|
5
|
-
import { type WalletRuntimePaths } from "../runtime.js";
|
|
6
|
-
import { type WalletSecretProvider } from "../state/provider.js";
|
|
7
|
-
import { openWalletReadContext } from "../read/index.js";
|
|
8
|
-
import { type WalletMutationFeeSummary, type WalletMutationRpcClient } from "./common.js";
|
|
9
|
-
type DomainMarketKind = "transfer" | "sell" | "buy";
|
|
10
|
-
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 DomainMarketResolvedSenderSummary {
|
|
19
|
-
selector: string;
|
|
20
|
-
localIndex: number;
|
|
21
|
-
scriptPubKeyHex: string;
|
|
22
|
-
address: string;
|
|
23
|
-
}
|
|
24
|
-
export interface DomainMarketResolvedRecipientSummary {
|
|
25
|
-
scriptPubKeyHex: string;
|
|
26
|
-
address: string | null;
|
|
27
|
-
opaque: boolean;
|
|
28
|
-
}
|
|
29
|
-
export interface DomainMarketResolvedBuyerSummary {
|
|
30
|
-
selector: string;
|
|
31
|
-
localIndex: number;
|
|
32
|
-
scriptPubKeyHex: string;
|
|
33
|
-
address: string;
|
|
34
|
-
}
|
|
35
|
-
export interface DomainMarketResolvedSellerSummary {
|
|
36
|
-
scriptPubKeyHex: string;
|
|
37
|
-
address: string | null;
|
|
38
|
-
}
|
|
39
|
-
export type DomainMarketResolvedEconomicEffect = {
|
|
40
|
-
kind: "ownership-transfer";
|
|
41
|
-
clearsListing: boolean;
|
|
42
|
-
} | {
|
|
43
|
-
kind: "listing-set";
|
|
44
|
-
listedPriceCogtoshi: string;
|
|
45
|
-
} | {
|
|
46
|
-
kind: "listing-clear";
|
|
47
|
-
listedPriceCogtoshi: "0";
|
|
48
|
-
};
|
|
49
|
-
export interface DomainMarketResolvedSummary {
|
|
50
|
-
sender: DomainMarketResolvedSenderSummary;
|
|
51
|
-
recipient?: DomainMarketResolvedRecipientSummary | null;
|
|
52
|
-
economicEffect: DomainMarketResolvedEconomicEffect;
|
|
53
|
-
}
|
|
54
|
-
export interface TransferDomainOptions {
|
|
55
|
-
domainName: string;
|
|
56
|
-
target: string;
|
|
57
|
-
feeRateSatVb?: number | null;
|
|
58
|
-
dataDir: string;
|
|
59
|
-
databasePath: string;
|
|
60
|
-
provider?: WalletSecretProvider;
|
|
61
|
-
prompter: WalletPrompter;
|
|
62
|
-
assumeYes?: boolean;
|
|
63
|
-
nowUnixMs?: number;
|
|
64
|
-
paths?: WalletRuntimePaths;
|
|
65
|
-
openReadContext?: typeof openWalletReadContext;
|
|
66
|
-
attachService?: typeof attachOrStartManagedBitcoindService;
|
|
67
|
-
rpcFactory?: (config: Parameters<typeof createRpcClient>[0]) => DomainMarketRpcClient;
|
|
68
|
-
}
|
|
69
|
-
export interface SellDomainOptions {
|
|
70
|
-
domainName: string;
|
|
71
|
-
listedPriceCogtoshi: bigint;
|
|
72
|
-
feeRateSatVb?: number | null;
|
|
73
|
-
dataDir: string;
|
|
74
|
-
databasePath: string;
|
|
75
|
-
provider?: WalletSecretProvider;
|
|
76
|
-
prompter: WalletPrompter;
|
|
77
|
-
assumeYes?: boolean;
|
|
78
|
-
nowUnixMs?: number;
|
|
79
|
-
paths?: WalletRuntimePaths;
|
|
80
|
-
openReadContext?: typeof openWalletReadContext;
|
|
81
|
-
attachService?: typeof attachOrStartManagedBitcoindService;
|
|
82
|
-
rpcFactory?: (config: Parameters<typeof createRpcClient>[0]) => DomainMarketRpcClient;
|
|
83
|
-
}
|
|
84
|
-
export interface BuyDomainOptions {
|
|
85
|
-
domainName: string;
|
|
86
|
-
fromIdentity?: string | null;
|
|
87
|
-
feeRateSatVb?: number | null;
|
|
88
|
-
dataDir: string;
|
|
89
|
-
databasePath: string;
|
|
90
|
-
provider?: WalletSecretProvider;
|
|
91
|
-
prompter: WalletPrompter;
|
|
92
|
-
assumeYes?: boolean;
|
|
93
|
-
nowUnixMs?: number;
|
|
94
|
-
paths?: WalletRuntimePaths;
|
|
95
|
-
openReadContext?: typeof openWalletReadContext;
|
|
96
|
-
attachService?: typeof attachOrStartManagedBitcoindService;
|
|
97
|
-
rpcFactory?: (config: Parameters<typeof createRpcClient>[0]) => DomainMarketRpcClient;
|
|
98
|
-
}
|
|
99
|
-
export interface DomainMarketMutationResult {
|
|
100
|
-
kind: DomainMarketKind;
|
|
101
|
-
domainName: string;
|
|
102
|
-
txid: string;
|
|
103
|
-
status: "live" | "confirmed";
|
|
104
|
-
reusedExisting: boolean;
|
|
105
|
-
listedPriceCogtoshi?: bigint;
|
|
106
|
-
recipientScriptPubKeyHex?: string | null;
|
|
107
|
-
resolved?: DomainMarketResolvedSummary | null;
|
|
108
|
-
resolvedBuyer?: DomainMarketResolvedBuyerSummary | null;
|
|
109
|
-
resolvedSeller?: DomainMarketResolvedSellerSummary | null;
|
|
110
|
-
fees: WalletMutationFeeSummary;
|
|
111
|
-
}
|
|
112
|
-
export declare function parseCogAmountToCogtoshi(raw: string): bigint;
|
|
113
|
-
export declare function transferDomain(options: TransferDomainOptions): Promise<DomainMarketMutationResult>;
|
|
114
|
-
export declare function sellDomain(options: SellDomainOptions): Promise<DomainMarketMutationResult>;
|
|
115
|
-
export declare function buyDomain(options: BuyDomainOptions): Promise<DomainMarketMutationResult>;
|
|
116
|
-
export {};
|
|
1
|
+
export * from "./domain-market/index.js";
|