@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,92 @@
|
|
|
1
|
+
import { confirmClaim } from "../confirm.js";
|
|
2
|
+
import { createClaimCogOpReturnData, createCogIntentFingerprint, resolveClaimSender, ZERO_PREIMAGE_HEX, } from "../intent.js";
|
|
3
|
+
import { createCogDraftMutation } from "../draft.js";
|
|
4
|
+
import { createCogResult, createCogReuseResult, } from "../result.js";
|
|
5
|
+
function createClaimLikeVariant(options, reclaim) {
|
|
6
|
+
const preimageHex = reclaim ? ZERO_PREIMAGE_HEX : options.preimageHex;
|
|
7
|
+
const errorPrefix = reclaim ? "wallet_reclaim" : "wallet_claim";
|
|
8
|
+
return {
|
|
9
|
+
controlLockPurpose: reclaim ? "wallet-reclaim" : "wallet-claim",
|
|
10
|
+
preemptionReason: reclaim ? "wallet-reclaim" : "wallet-claim",
|
|
11
|
+
errorPrefix,
|
|
12
|
+
repairRequiredErrorCode: `${errorPrefix}_repair_required`,
|
|
13
|
+
resolveOperation(readContext) {
|
|
14
|
+
return {
|
|
15
|
+
...resolveClaimSender(readContext, options.lockId, preimageHex, reclaim),
|
|
16
|
+
preimageHex,
|
|
17
|
+
errorPrefix,
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
createIntentFingerprint(operation) {
|
|
21
|
+
return createCogIntentFingerprint([
|
|
22
|
+
reclaim ? "reclaim" : "claim",
|
|
23
|
+
operation.state.walletRootId,
|
|
24
|
+
operation.sender.scriptPubKeyHex,
|
|
25
|
+
operation.lockId,
|
|
26
|
+
operation.preimageHex,
|
|
27
|
+
]);
|
|
28
|
+
},
|
|
29
|
+
confirm(operation) {
|
|
30
|
+
return confirmClaim(options.prompter, {
|
|
31
|
+
kind: reclaim ? "reclaim" : "claim",
|
|
32
|
+
lockId: operation.lockId,
|
|
33
|
+
recipientDomainName: operation.recipientDomainName,
|
|
34
|
+
amountCogtoshi: operation.amountCogtoshi,
|
|
35
|
+
resolved: operation.resolved,
|
|
36
|
+
assumeYes: options.assumeYes,
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
createDraftMutation({ operation, existingMutation, feeSelection, intentFingerprintHex, nowUnixMs }) {
|
|
40
|
+
return createCogDraftMutation({
|
|
41
|
+
kind: "claim",
|
|
42
|
+
sender: operation.sender,
|
|
43
|
+
amountCogtoshi: operation.amountCogtoshi,
|
|
44
|
+
recipientDomainName: operation.recipientDomainName,
|
|
45
|
+
lockId: operation.lockId,
|
|
46
|
+
preimageHex: operation.preimageHex,
|
|
47
|
+
intentFingerprintHex,
|
|
48
|
+
nowUnixMs,
|
|
49
|
+
feeSelection,
|
|
50
|
+
existing: existingMutation,
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
createOpReturnData(operation) {
|
|
54
|
+
return createClaimCogOpReturnData(operation);
|
|
55
|
+
},
|
|
56
|
+
createReuseResult({ operation, mutation, resolution, fees }) {
|
|
57
|
+
return createCogReuseResult({
|
|
58
|
+
kind: "claim",
|
|
59
|
+
mutation,
|
|
60
|
+
resolution,
|
|
61
|
+
fees,
|
|
62
|
+
amountCogtoshi: operation.amountCogtoshi,
|
|
63
|
+
recipientDomainName: operation.recipientDomainName,
|
|
64
|
+
lockId: operation.lockId,
|
|
65
|
+
resolved: operation.resolved,
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
createResult({ operation, mutation, builtTxid, status, reusedExisting, fees }) {
|
|
69
|
+
return createCogResult({
|
|
70
|
+
kind: "claim",
|
|
71
|
+
mutation,
|
|
72
|
+
builtTxid,
|
|
73
|
+
status,
|
|
74
|
+
reusedExisting,
|
|
75
|
+
fees,
|
|
76
|
+
amountCogtoshi: operation.amountCogtoshi,
|
|
77
|
+
recipientDomainName: operation.recipientDomainName,
|
|
78
|
+
lockId: operation.lockId,
|
|
79
|
+
resolved: operation.resolved,
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export function createClaimCogVariant(options) {
|
|
85
|
+
return createClaimLikeVariant(options, false);
|
|
86
|
+
}
|
|
87
|
+
export function createReclaimCogVariant(options) {
|
|
88
|
+
return createClaimLikeVariant({
|
|
89
|
+
...options,
|
|
90
|
+
preimageHex: ZERO_PREIMAGE_HEX,
|
|
91
|
+
}, true);
|
|
92
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { lookupDomain } from "@cogcoin/indexer/queries";
|
|
2
|
+
import { confirmLock } from "../confirm.js";
|
|
3
|
+
import { createCogIntentFingerprint, createLockCogOpReturnData, MAX_LOCK_DURATION_BLOCKS, normalizeCogDomainName, normalizePositiveCogAmount, parseHex32, parseTimeoutHeight, resolveIdentitySender, } from "../intent.js";
|
|
4
|
+
import { createCogDraftMutation } from "../draft.js";
|
|
5
|
+
import { createCogResult, createCogReuseResult, } from "../result.js";
|
|
6
|
+
export function createLockCogVariant(options) {
|
|
7
|
+
const amountCogtoshi = normalizePositiveCogAmount(options.amountCogtoshi, "wallet_lock_invalid_amount");
|
|
8
|
+
const normalizedRecipientDomainName = normalizeCogDomainName(options.recipientDomainName);
|
|
9
|
+
const condition = parseHex32(options.conditionHex, "wallet_lock_invalid_condition");
|
|
10
|
+
if (condition.equals(Buffer.alloc(32))) {
|
|
11
|
+
throw new Error("wallet_lock_invalid_condition");
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
controlLockPurpose: "wallet-lock-cog",
|
|
15
|
+
preemptionReason: "wallet-cog-lock",
|
|
16
|
+
errorPrefix: "wallet_lock",
|
|
17
|
+
repairRequiredErrorCode: "wallet_lock_repair_required",
|
|
18
|
+
resolveOperation(readContext) {
|
|
19
|
+
const currentHeight = readContext.snapshot?.state.history.currentHeight ?? null;
|
|
20
|
+
if (currentHeight === null) {
|
|
21
|
+
throw new Error("wallet_lock_current_height_unavailable");
|
|
22
|
+
}
|
|
23
|
+
const timeoutHeight = parseTimeoutHeight(currentHeight, options.timeoutBlocksOrDuration, options.timeoutHeight ?? null);
|
|
24
|
+
if (timeoutHeight <= currentHeight || timeoutHeight > currentHeight + MAX_LOCK_DURATION_BLOCKS) {
|
|
25
|
+
throw new Error("wallet_lock_invalid_timeout_height");
|
|
26
|
+
}
|
|
27
|
+
const recipientDomain = lookupDomain(readContext.snapshot.state, normalizedRecipientDomainName);
|
|
28
|
+
if (recipientDomain === null) {
|
|
29
|
+
throw new Error("wallet_lock_domain_not_found");
|
|
30
|
+
}
|
|
31
|
+
if (!recipientDomain.anchored) {
|
|
32
|
+
throw new Error("wallet_lock_domain_not_anchored");
|
|
33
|
+
}
|
|
34
|
+
if (readContext.snapshot.state.consensus.nextLockId === 0xffff_ffff) {
|
|
35
|
+
throw new Error("wallet_lock_id_space_exhausted");
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
...resolveIdentitySender(readContext, "wallet_lock", amountCogtoshi, options.fromIdentity),
|
|
39
|
+
amountCogtoshi,
|
|
40
|
+
normalizedRecipientDomainName,
|
|
41
|
+
recipientDomain,
|
|
42
|
+
timeoutHeight,
|
|
43
|
+
conditionHex: Buffer.from(condition).toString("hex"),
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
createIntentFingerprint(operation) {
|
|
47
|
+
return createCogIntentFingerprint([
|
|
48
|
+
"lock",
|
|
49
|
+
operation.state.walletRootId,
|
|
50
|
+
operation.sender.scriptPubKeyHex,
|
|
51
|
+
operation.normalizedRecipientDomainName,
|
|
52
|
+
operation.amountCogtoshi,
|
|
53
|
+
operation.timeoutHeight,
|
|
54
|
+
operation.conditionHex,
|
|
55
|
+
]);
|
|
56
|
+
},
|
|
57
|
+
confirm(operation) {
|
|
58
|
+
return confirmLock(options.prompter, operation.resolved, operation.amountCogtoshi, operation.normalizedRecipientDomainName, operation.timeoutHeight, options.assumeYes);
|
|
59
|
+
},
|
|
60
|
+
createDraftMutation({ operation, existingMutation, feeSelection, intentFingerprintHex, nowUnixMs }) {
|
|
61
|
+
return createCogDraftMutation({
|
|
62
|
+
kind: "lock",
|
|
63
|
+
sender: operation.sender,
|
|
64
|
+
amountCogtoshi: operation.amountCogtoshi,
|
|
65
|
+
recipientDomainName: operation.normalizedRecipientDomainName,
|
|
66
|
+
timeoutHeight: operation.timeoutHeight,
|
|
67
|
+
conditionHex: operation.conditionHex,
|
|
68
|
+
intentFingerprintHex,
|
|
69
|
+
nowUnixMs,
|
|
70
|
+
feeSelection,
|
|
71
|
+
existing: existingMutation,
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
createOpReturnData(operation) {
|
|
75
|
+
return createLockCogOpReturnData(operation);
|
|
76
|
+
},
|
|
77
|
+
createReuseResult({ operation, mutation, resolution, fees }) {
|
|
78
|
+
return createCogReuseResult({
|
|
79
|
+
kind: "lock",
|
|
80
|
+
mutation,
|
|
81
|
+
resolution,
|
|
82
|
+
fees,
|
|
83
|
+
amountCogtoshi: operation.amountCogtoshi,
|
|
84
|
+
recipientDomainName: operation.normalizedRecipientDomainName,
|
|
85
|
+
resolved: operation.resolved,
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
createResult({ operation, mutation, builtTxid, status, reusedExisting, fees }) {
|
|
89
|
+
return createCogResult({
|
|
90
|
+
kind: "lock",
|
|
91
|
+
mutation,
|
|
92
|
+
builtTxid,
|
|
93
|
+
status,
|
|
94
|
+
reusedExisting,
|
|
95
|
+
fees,
|
|
96
|
+
amountCogtoshi: operation.amountCogtoshi,
|
|
97
|
+
recipientDomainName: operation.normalizedRecipientDomainName,
|
|
98
|
+
resolved: operation.resolved,
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { normalizeBtcTarget } from "../../targets.js";
|
|
2
|
+
import { confirmSend } from "../confirm.js";
|
|
3
|
+
import { createCogIntentFingerprint, createSendCogOpReturnData, normalizePositiveCogAmount, resolveIdentitySender, } from "../intent.js";
|
|
4
|
+
import { createCogDraftMutation } from "../draft.js";
|
|
5
|
+
import { createCogResult, createCogReuseResult, } from "../result.js";
|
|
6
|
+
export function createSendCogVariant(options) {
|
|
7
|
+
const amountCogtoshi = normalizePositiveCogAmount(options.amountCogtoshi, "wallet_send_invalid_amount");
|
|
8
|
+
const recipient = normalizeBtcTarget(options.target);
|
|
9
|
+
return {
|
|
10
|
+
controlLockPurpose: "wallet-send",
|
|
11
|
+
preemptionReason: "wallet-send",
|
|
12
|
+
errorPrefix: "wallet_send",
|
|
13
|
+
repairRequiredErrorCode: "wallet_send_repair_required",
|
|
14
|
+
resolveOperation(readContext) {
|
|
15
|
+
const operation = resolveIdentitySender(readContext, "wallet_send", amountCogtoshi, options.fromIdentity);
|
|
16
|
+
if (operation.sender.scriptPubKeyHex === recipient.scriptPubKeyHex) {
|
|
17
|
+
throw new Error("wallet_send_self_transfer");
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
...operation,
|
|
21
|
+
amountCogtoshi,
|
|
22
|
+
recipient,
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
createIntentFingerprint(operation) {
|
|
26
|
+
return createCogIntentFingerprint([
|
|
27
|
+
"send",
|
|
28
|
+
operation.state.walletRootId,
|
|
29
|
+
operation.sender.scriptPubKeyHex,
|
|
30
|
+
operation.recipient.scriptPubKeyHex,
|
|
31
|
+
operation.amountCogtoshi,
|
|
32
|
+
]);
|
|
33
|
+
},
|
|
34
|
+
confirm(operation) {
|
|
35
|
+
return confirmSend(options.prompter, operation.resolved, options.target, operation.recipient, operation.amountCogtoshi, options.assumeYes);
|
|
36
|
+
},
|
|
37
|
+
createDraftMutation({ operation, existingMutation, feeSelection, intentFingerprintHex, nowUnixMs }) {
|
|
38
|
+
return createCogDraftMutation({
|
|
39
|
+
kind: "send",
|
|
40
|
+
sender: operation.sender,
|
|
41
|
+
recipientScriptPubKeyHex: operation.recipient.scriptPubKeyHex,
|
|
42
|
+
amountCogtoshi: operation.amountCogtoshi,
|
|
43
|
+
intentFingerprintHex,
|
|
44
|
+
nowUnixMs,
|
|
45
|
+
feeSelection,
|
|
46
|
+
existing: existingMutation,
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
createOpReturnData(operation) {
|
|
50
|
+
return createSendCogOpReturnData(operation);
|
|
51
|
+
},
|
|
52
|
+
createReuseResult({ operation, mutation, resolution, fees }) {
|
|
53
|
+
return createCogReuseResult({
|
|
54
|
+
kind: "send",
|
|
55
|
+
mutation,
|
|
56
|
+
resolution,
|
|
57
|
+
fees,
|
|
58
|
+
amountCogtoshi: operation.amountCogtoshi,
|
|
59
|
+
recipientScriptPubKeyHex: operation.recipient.scriptPubKeyHex,
|
|
60
|
+
resolved: operation.resolved,
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
createResult({ operation, mutation, builtTxid, status, reusedExisting, fees }) {
|
|
64
|
+
return createCogResult({
|
|
65
|
+
kind: "send",
|
|
66
|
+
mutation,
|
|
67
|
+
builtTxid,
|
|
68
|
+
status,
|
|
69
|
+
reusedExisting,
|
|
70
|
+
fees,
|
|
71
|
+
amountCogtoshi: operation.amountCogtoshi,
|
|
72
|
+
recipientScriptPubKeyHex: operation.recipient.scriptPubKeyHex,
|
|
73
|
+
resolved: operation.resolved,
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
}
|
package/dist/wallet/tx/cog.d.ts
CHANGED
|
@@ -1,96 +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 CogMutationKind = "send" | "lock" | "claim";
|
|
10
|
-
interface WalletCogRpcClient extends WalletMutationRpcClient {
|
|
11
|
-
getBlockchainInfo(): Promise<{
|
|
12
|
-
blocks: number;
|
|
13
|
-
}>;
|
|
14
|
-
sendRawTransaction(hex: string): Promise<string>;
|
|
15
|
-
getRawTransaction(txid: string, verbose?: boolean): Promise<RpcTransaction>;
|
|
16
|
-
}
|
|
17
|
-
export type CogResolvedClaimPath = "recipient-claim" | "timeout-reclaim";
|
|
18
|
-
export interface CogResolvedSenderSummary {
|
|
19
|
-
selector: string;
|
|
20
|
-
localIndex: number;
|
|
21
|
-
scriptPubKeyHex: string;
|
|
22
|
-
address: string;
|
|
23
|
-
}
|
|
24
|
-
export interface CogResolvedSummary {
|
|
25
|
-
sender: CogResolvedSenderSummary;
|
|
26
|
-
claimPath: CogResolvedClaimPath | null;
|
|
27
|
-
}
|
|
28
|
-
export interface CogMutationResult {
|
|
29
|
-
kind: CogMutationKind;
|
|
30
|
-
txid: string;
|
|
31
|
-
status: "live" | "confirmed";
|
|
32
|
-
reusedExisting: boolean;
|
|
33
|
-
amountCogtoshi?: bigint;
|
|
34
|
-
recipientScriptPubKeyHex?: string | null;
|
|
35
|
-
recipientDomainName?: string | null;
|
|
36
|
-
lockId?: number | null;
|
|
37
|
-
resolved: CogResolvedSummary;
|
|
38
|
-
fees: WalletMutationFeeSummary;
|
|
39
|
-
}
|
|
40
|
-
export interface SendCogOptions {
|
|
41
|
-
amountCogtoshi: bigint;
|
|
42
|
-
target: string;
|
|
43
|
-
fromIdentity?: string | null;
|
|
44
|
-
feeRateSatVb?: number | null;
|
|
45
|
-
dataDir: string;
|
|
46
|
-
databasePath: string;
|
|
47
|
-
provider?: WalletSecretProvider;
|
|
48
|
-
prompter: WalletPrompter;
|
|
49
|
-
assumeYes?: boolean;
|
|
50
|
-
nowUnixMs?: number;
|
|
51
|
-
paths?: WalletRuntimePaths;
|
|
52
|
-
openReadContext?: typeof openWalletReadContext;
|
|
53
|
-
attachService?: typeof attachOrStartManagedBitcoindService;
|
|
54
|
-
rpcFactory?: (config: Parameters<typeof createRpcClient>[0]) => WalletCogRpcClient;
|
|
55
|
-
}
|
|
56
|
-
export interface LockCogToDomainOptions {
|
|
57
|
-
amountCogtoshi: bigint;
|
|
58
|
-
recipientDomainName: string;
|
|
59
|
-
fromIdentity?: string | null;
|
|
60
|
-
feeRateSatVb?: number | null;
|
|
61
|
-
timeoutHeight?: number | null;
|
|
62
|
-
timeoutBlocksOrDuration?: string | null;
|
|
63
|
-
conditionHex: string;
|
|
64
|
-
dataDir: string;
|
|
65
|
-
databasePath: string;
|
|
66
|
-
provider?: WalletSecretProvider;
|
|
67
|
-
prompter: WalletPrompter;
|
|
68
|
-
assumeYes?: boolean;
|
|
69
|
-
nowUnixMs?: number;
|
|
70
|
-
paths?: WalletRuntimePaths;
|
|
71
|
-
openReadContext?: typeof openWalletReadContext;
|
|
72
|
-
attachService?: typeof attachOrStartManagedBitcoindService;
|
|
73
|
-
rpcFactory?: (config: Parameters<typeof createRpcClient>[0]) => WalletCogRpcClient;
|
|
74
|
-
}
|
|
75
|
-
export interface ClaimCogLockOptions {
|
|
76
|
-
lockId: number;
|
|
77
|
-
preimageHex: string;
|
|
78
|
-
feeRateSatVb?: number | null;
|
|
79
|
-
dataDir: string;
|
|
80
|
-
databasePath: string;
|
|
81
|
-
provider?: WalletSecretProvider;
|
|
82
|
-
prompter: WalletPrompter;
|
|
83
|
-
assumeYes?: boolean;
|
|
84
|
-
nowUnixMs?: number;
|
|
85
|
-
paths?: WalletRuntimePaths;
|
|
86
|
-
openReadContext?: typeof openWalletReadContext;
|
|
87
|
-
attachService?: typeof attachOrStartManagedBitcoindService;
|
|
88
|
-
rpcFactory?: (config: Parameters<typeof createRpcClient>[0]) => WalletCogRpcClient;
|
|
89
|
-
}
|
|
90
|
-
export interface ReclaimCogLockOptions extends Omit<ClaimCogLockOptions, "preimageHex"> {
|
|
91
|
-
}
|
|
92
|
-
export declare function sendCog(options: SendCogOptions): Promise<CogMutationResult>;
|
|
93
|
-
export declare function lockCogToDomain(options: LockCogToDomainOptions): Promise<CogMutationResult>;
|
|
94
|
-
export declare function claimCogLock(options: ClaimCogLockOptions): Promise<CogMutationResult>;
|
|
95
|
-
export declare function reclaimCogLock(options: ReclaimCogLockOptions): Promise<CogMutationResult>;
|
|
96
|
-
export {};
|
|
1
|
+
export * from "./cog/index.js";
|