@cogcoin/client 1.1.5 → 1.1.7
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 +2 -2
- package/dist/bitcoind/indexer-daemon.d.ts +3 -7
- package/dist/bitcoind/indexer-daemon.js +39 -204
- package/dist/bitcoind/managed-runtime/bitcoind-policy.d.ts +16 -0
- package/dist/bitcoind/managed-runtime/bitcoind-policy.js +177 -0
- package/dist/bitcoind/managed-runtime/bitcoind-runtime.d.ts +20 -0
- package/dist/bitcoind/managed-runtime/bitcoind-runtime.js +74 -0
- package/dist/bitcoind/managed-runtime/bitcoind-status.d.ts +11 -0
- package/dist/bitcoind/managed-runtime/bitcoind-status.js +44 -0
- package/dist/bitcoind/managed-runtime/indexer-policy.d.ts +34 -0
- package/dist/bitcoind/managed-runtime/indexer-policy.js +200 -0
- package/dist/bitcoind/managed-runtime/indexer-runtime.d.ts +15 -0
- package/dist/bitcoind/managed-runtime/indexer-runtime.js +82 -0
- package/dist/bitcoind/managed-runtime/status.d.ts +11 -0
- package/dist/bitcoind/managed-runtime/status.js +59 -0
- package/dist/bitcoind/managed-runtime/types.d.ts +77 -0
- package/dist/bitcoind/node.d.ts +2 -2
- package/dist/bitcoind/node.js +2 -2
- package/dist/bitcoind/rpc.d.ts +2 -1
- package/dist/bitcoind/rpc.js +53 -3
- package/dist/bitcoind/service.d.ts +2 -7
- package/dist/bitcoind/service.js +79 -207
- package/dist/cli/command-registry.d.ts +1 -1
- package/dist/cli/command-registry.js +2 -64
- package/dist/cli/commands/client-admin.js +3 -18
- package/dist/cli/commands/mining-runtime.js +4 -60
- package/dist/cli/commands/wallet-admin.js +6 -6
- package/dist/cli/context.js +1 -3
- package/dist/cli/mining-json.d.ts +1 -22
- package/dist/cli/mining-json.js +0 -23
- package/dist/cli/output.js +16 -2
- package/dist/cli/parse.js +0 -2
- package/dist/cli/preview-json.d.ts +1 -22
- package/dist/cli/preview-json.js +0 -19
- package/dist/cli/types.d.ts +1 -3
- package/dist/cli/wallet-format.js +1 -1
- package/dist/cli/workflow-hints.d.ts +1 -2
- package/dist/cli/workflow-hints.js +5 -8
- package/dist/wallet/lifecycle/access.d.ts +5 -0
- package/dist/wallet/lifecycle/access.js +79 -0
- package/dist/wallet/lifecycle/context.d.ts +26 -0
- package/dist/wallet/lifecycle/context.js +57 -0
- package/dist/wallet/lifecycle/managed-core.d.ts +1 -9
- package/dist/wallet/lifecycle/managed-core.js +3 -63
- package/dist/wallet/lifecycle/repair-bitcoind.d.ts +10 -0
- package/dist/wallet/lifecycle/repair-bitcoind.js +142 -0
- package/dist/wallet/lifecycle/repair-indexer.d.ts +8 -0
- package/dist/wallet/lifecycle/repair-indexer.js +117 -0
- package/dist/wallet/lifecycle/repair-mining.d.ts +1 -5
- package/dist/wallet/lifecycle/repair-mining.js +5 -39
- package/dist/wallet/lifecycle/repair.d.ts +2 -4
- package/dist/wallet/lifecycle/repair.js +74 -318
- package/dist/wallet/lifecycle/setup-prompts.d.ts +7 -0
- package/dist/wallet/lifecycle/setup-prompts.js +88 -0
- package/dist/wallet/lifecycle/setup-state.d.ts +26 -0
- package/dist/wallet/lifecycle/setup-state.js +159 -0
- package/dist/wallet/lifecycle/setup.d.ts +3 -4
- package/dist/wallet/lifecycle/setup.js +47 -351
- package/dist/wallet/lifecycle/types.d.ts +33 -5
- package/dist/wallet/managed-core-wallet.d.ts +2 -0
- package/dist/wallet/managed-core-wallet.js +27 -1
- package/dist/wallet/mining/candidate.d.ts +1 -0
- package/dist/wallet/mining/candidate.js +38 -6
- package/dist/wallet/mining/competitiveness.d.ts +1 -0
- package/dist/wallet/mining/competitiveness.js +6 -0
- package/dist/wallet/mining/cycle.d.ts +2 -0
- package/dist/wallet/mining/cycle.js +14 -4
- package/dist/wallet/mining/engine-types.d.ts +1 -0
- package/dist/wallet/mining/index.d.ts +1 -1
- package/dist/wallet/mining/index.js +1 -1
- package/dist/wallet/mining/publish.d.ts +3 -0
- package/dist/wallet/mining/publish.js +78 -6
- package/dist/wallet/mining/runner.d.ts +0 -32
- package/dist/wallet/mining/runner.js +59 -104
- package/dist/wallet/mining/stop.d.ts +7 -0
- package/dist/wallet/mining/stop.js +23 -0
- package/dist/wallet/mining/supervisor.d.ts +2 -36
- package/dist/wallet/mining/supervisor.js +139 -246
- package/dist/wallet/read/context.d.ts +1 -5
- package/dist/wallet/read/context.js +20 -379
- package/dist/wallet/read/managed-services.d.ts +33 -0
- package/dist/wallet/read/managed-services.js +222 -0
- package/dist/wallet/state/client-password/bootstrap.d.ts +2 -0
- package/dist/wallet/state/client-password/bootstrap.js +3 -0
- package/dist/wallet/state/client-password/context.d.ts +10 -0
- package/dist/wallet/state/client-password/context.js +46 -0
- package/dist/wallet/state/client-password/crypto.d.ts +34 -0
- package/dist/wallet/state/client-password/crypto.js +117 -0
- package/dist/wallet/state/client-password/files.d.ts +10 -0
- package/dist/wallet/state/client-password/files.js +109 -0
- package/dist/wallet/state/client-password/legacy-cleanup.d.ts +11 -0
- package/dist/wallet/state/client-password/legacy-cleanup.js +338 -0
- package/dist/wallet/state/client-password/messages.d.ts +3 -0
- package/dist/wallet/state/client-password/messages.js +9 -0
- package/dist/wallet/state/client-password/migration.d.ts +4 -0
- package/dist/wallet/state/client-password/migration.js +32 -0
- package/dist/wallet/state/client-password/prompts.d.ts +12 -0
- package/dist/wallet/state/client-password/prompts.js +79 -0
- package/dist/wallet/state/client-password/protected-secrets.d.ts +13 -0
- package/dist/wallet/state/client-password/protected-secrets.js +90 -0
- package/dist/wallet/state/client-password/readiness.d.ts +4 -0
- package/dist/wallet/state/client-password/readiness.js +48 -0
- package/dist/wallet/state/client-password/references.d.ts +1 -0
- package/dist/wallet/state/client-password/references.js +56 -0
- package/dist/wallet/state/client-password/rotation.d.ts +6 -0
- package/dist/wallet/state/client-password/rotation.js +98 -0
- package/dist/wallet/state/client-password/session-policy.d.ts +6 -0
- package/dist/wallet/state/client-password/session-policy.js +28 -0
- package/dist/wallet/state/client-password/session.d.ts +19 -0
- package/dist/wallet/state/client-password/session.js +170 -0
- package/dist/wallet/state/client-password/setup.d.ts +8 -0
- package/dist/wallet/state/client-password/setup.js +49 -0
- package/dist/wallet/state/client-password/types.d.ts +82 -0
- package/dist/wallet/state/client-password/types.js +5 -0
- package/dist/wallet/state/client-password.d.ts +7 -38
- package/dist/wallet/state/client-password.js +52 -937
- package/dist/wallet/tx/anchor.js +123 -216
- package/dist/wallet/tx/cog.js +294 -489
- package/dist/wallet/tx/common.d.ts +2 -0
- package/dist/wallet/tx/common.js +2 -0
- package/dist/wallet/tx/domain-admin.js +111 -220
- package/dist/wallet/tx/domain-market.js +401 -681
- package/dist/wallet/tx/executor.d.ts +176 -0
- package/dist/wallet/tx/executor.js +302 -0
- package/dist/wallet/tx/field.js +109 -215
- package/dist/wallet/tx/register.js +158 -269
- package/dist/wallet/tx/reputation.js +120 -227
- package/package.json +1 -1
- package/dist/wallet/mining/worker-main.js +0 -17
- package/dist/wallet/state/client-password-agent.d.ts +0 -1
- package/dist/wallet/state/client-password-agent.js +0 -211
- /package/dist/{wallet/mining/worker-main.d.ts → bitcoind/managed-runtime/types.js} +0 -0
package/dist/wallet/tx/field.js
CHANGED
|
@@ -4,15 +4,15 @@ import { resolve as resolvePath } from "node:path";
|
|
|
4
4
|
import { getBalance, lookupDomain, } from "@cogcoin/indexer/queries";
|
|
5
5
|
import { attachOrStartManagedBitcoindService } from "../../bitcoind/service.js";
|
|
6
6
|
import { createRpcClient } from "../../bitcoind/node.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { createDefaultWalletSecretProvider, } from "../state/provider.js";
|
|
7
|
+
import {} from "../runtime.js";
|
|
8
|
+
import {} from "../state/provider.js";
|
|
10
9
|
import { FIELD_FORMAT_BYTES, serializeDataUpdate, serializeFieldReg, } from "../cogop/index.js";
|
|
11
10
|
import { validateFieldName } from "../cogop/validate-name.js";
|
|
12
11
|
import { findDomainField, openWalletReadContext, } from "../read/index.js";
|
|
13
|
-
import { assertWalletMutationContextReady, buildWalletMutationTransactionWithReserveFallback,
|
|
12
|
+
import { assertWalletMutationContextReady, buildWalletMutationTransactionWithReserveFallback, createWalletMutationFeeMetadata, mergeFixedWalletInputs, outpointKey, unlockTemporaryBuilderLocks, updateMutationRecord, } from "./common.js";
|
|
14
13
|
import { confirmTypedAcknowledgement as confirmSharedTypedAcknowledgement, confirmYesNo as confirmSharedYesNo, } from "./confirm.js";
|
|
15
|
-
import {
|
|
14
|
+
import { executeWalletMutationOperation, persistWalletMutationState, publishWalletMutation, resolveExistingWalletMutation, } from "./executor.js";
|
|
15
|
+
import { upsertPendingMutation } from "./journal.js";
|
|
16
16
|
function createResolvedFieldSenderSummary(sender, selector) {
|
|
17
17
|
return {
|
|
18
18
|
selector,
|
|
@@ -220,18 +220,7 @@ async function buildFieldTransaction(options) {
|
|
|
220
220
|
});
|
|
221
221
|
}
|
|
222
222
|
async function saveUpdatedState(options) {
|
|
223
|
-
|
|
224
|
-
...options.state,
|
|
225
|
-
stateRevision: options.state.stateRevision + 1,
|
|
226
|
-
lastWrittenAtUnixMs: options.nowUnixMs,
|
|
227
|
-
};
|
|
228
|
-
await saveWalletStatePreservingUnlock({
|
|
229
|
-
state: nextState,
|
|
230
|
-
provider: options.provider,
|
|
231
|
-
nowUnixMs: options.nowUnixMs,
|
|
232
|
-
paths: options.paths,
|
|
233
|
-
});
|
|
234
|
-
return nextState;
|
|
223
|
+
return persistWalletMutationState(options);
|
|
235
224
|
}
|
|
236
225
|
function createStandaloneFieldMutation(options) {
|
|
237
226
|
if (options.existing !== null && options.existing !== undefined) {
|
|
@@ -579,237 +568,142 @@ async function loadFieldValue(source) {
|
|
|
579
568
|
valueHex: Buffer.from(value).toString("hex"),
|
|
580
569
|
};
|
|
581
570
|
}
|
|
582
|
-
async function sendStandaloneMutation(options) {
|
|
583
|
-
let nextState = options.state;
|
|
584
|
-
const broadcasting = updateMutationRecord(options.mutation, "broadcasting", options.nowUnixMs, {
|
|
585
|
-
attemptedTxid: options.built.txid,
|
|
586
|
-
attemptedWtxid: options.built.wtxid,
|
|
587
|
-
temporaryBuilderLockedOutpoints: options.built.temporaryBuilderLockedOutpoints,
|
|
588
|
-
});
|
|
589
|
-
nextState = upsertPendingMutation(nextState, broadcasting);
|
|
590
|
-
nextState = await saveUpdatedState({
|
|
591
|
-
state: nextState,
|
|
592
|
-
provider: options.provider,
|
|
593
|
-
nowUnixMs: options.nowUnixMs,
|
|
594
|
-
paths: options.paths,
|
|
595
|
-
});
|
|
596
|
-
if (options.snapshotHeight !== null && options.snapshotHeight !== (await options.rpc.getBlockchainInfo()).blocks) {
|
|
597
|
-
await unlockTemporaryBuilderLocks(options.rpc, options.walletName, options.built.temporaryBuilderLockedOutpoints);
|
|
598
|
-
throw new Error(`${options.errorPrefix}_tip_mismatch`);
|
|
599
|
-
}
|
|
600
|
-
try {
|
|
601
|
-
await options.rpc.sendRawTransaction(options.built.rawHex);
|
|
602
|
-
}
|
|
603
|
-
catch (error) {
|
|
604
|
-
if (!isAlreadyAcceptedError(error)) {
|
|
605
|
-
if (isBroadcastUnknownError(error)) {
|
|
606
|
-
const unknown = updateMutationRecord(broadcasting, "broadcast-unknown", options.nowUnixMs, {
|
|
607
|
-
attemptedTxid: options.built.txid,
|
|
608
|
-
attemptedWtxid: options.built.wtxid,
|
|
609
|
-
temporaryBuilderLockedOutpoints: options.built.temporaryBuilderLockedOutpoints,
|
|
610
|
-
});
|
|
611
|
-
nextState = upsertPendingMutation(nextState, unknown);
|
|
612
|
-
nextState = await saveUpdatedState({
|
|
613
|
-
state: nextState,
|
|
614
|
-
provider: options.provider,
|
|
615
|
-
nowUnixMs: options.nowUnixMs,
|
|
616
|
-
paths: options.paths,
|
|
617
|
-
});
|
|
618
|
-
throw new Error(`${options.errorPrefix}_broadcast_unknown`);
|
|
619
|
-
}
|
|
620
|
-
await unlockTemporaryBuilderLocks(options.rpc, options.walletName, options.built.temporaryBuilderLockedOutpoints);
|
|
621
|
-
const canceled = updateMutationRecord(broadcasting, "canceled", options.nowUnixMs, {
|
|
622
|
-
attemptedTxid: options.built.txid,
|
|
623
|
-
attemptedWtxid: options.built.wtxid,
|
|
624
|
-
temporaryBuilderLockedOutpoints: [],
|
|
625
|
-
});
|
|
626
|
-
nextState = upsertPendingMutation(nextState, canceled);
|
|
627
|
-
nextState = await saveUpdatedState({
|
|
628
|
-
state: nextState,
|
|
629
|
-
provider: options.provider,
|
|
630
|
-
nowUnixMs: options.nowUnixMs,
|
|
631
|
-
paths: options.paths,
|
|
632
|
-
});
|
|
633
|
-
throw error;
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
await unlockTemporaryBuilderLocks(options.rpc, options.walletName, options.built.temporaryBuilderLockedOutpoints);
|
|
637
|
-
const live = updateMutationRecord(broadcasting, "live", options.nowUnixMs, {
|
|
638
|
-
attemptedTxid: options.built.txid,
|
|
639
|
-
attemptedWtxid: options.built.wtxid,
|
|
640
|
-
temporaryBuilderLockedOutpoints: [],
|
|
641
|
-
});
|
|
642
|
-
nextState = upsertPendingMutation(nextState, live);
|
|
643
|
-
nextState = await saveUpdatedState({
|
|
644
|
-
state: nextState,
|
|
645
|
-
provider: options.provider,
|
|
646
|
-
nowUnixMs: options.nowUnixMs,
|
|
647
|
-
paths: options.paths,
|
|
648
|
-
});
|
|
649
|
-
return { state: nextState, mutation: live };
|
|
650
|
-
}
|
|
651
571
|
async function submitStandaloneFieldMutation(options) {
|
|
652
572
|
if (!options.prompter.isInteractive && options.assumeYes !== true) {
|
|
653
573
|
throw new Error(`${options.errorPrefix}_requires_tty`);
|
|
654
574
|
}
|
|
655
|
-
const
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
walletRootId: null,
|
|
661
|
-
});
|
|
662
|
-
try {
|
|
663
|
-
const miningPreemption = await pauseMiningForWalletMutation({
|
|
664
|
-
paths,
|
|
665
|
-
reason: options.errorPrefix,
|
|
666
|
-
});
|
|
667
|
-
const readContext = await (options.openReadContext ?? openWalletReadContext)({
|
|
668
|
-
dataDir: options.dataDir,
|
|
669
|
-
databasePath: options.databasePath,
|
|
670
|
-
secretProvider: provider,
|
|
671
|
-
walletControlLockHeld: true,
|
|
672
|
-
paths,
|
|
673
|
-
});
|
|
674
|
-
try {
|
|
575
|
+
const execution = await executeWalletMutationOperation({
|
|
576
|
+
...options,
|
|
577
|
+
controlLockPurpose: options.errorPrefix,
|
|
578
|
+
preemptionReason: options.errorPrefix,
|
|
579
|
+
resolveOperation(readContext) {
|
|
675
580
|
const normalizedDomainName = normalizeDomainName(options.domainName);
|
|
676
581
|
const normalizedFieldName = normalizeFieldName(options.fieldName);
|
|
677
582
|
const operation = resolveAnchoredFieldOperation(readContext, normalizedDomainName, options.errorPrefix);
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
options.kind,
|
|
681
|
-
operation.state.walletRootId,
|
|
583
|
+
return {
|
|
584
|
+
...operation,
|
|
682
585
|
normalizedDomainName,
|
|
683
586
|
normalizedFieldName,
|
|
587
|
+
existingObservedField: getObservedFieldState(readContext, normalizedDomainName, normalizedFieldName),
|
|
588
|
+
};
|
|
589
|
+
},
|
|
590
|
+
createIntentFingerprint(operation) {
|
|
591
|
+
return createIntentFingerprint([
|
|
592
|
+
options.kind,
|
|
593
|
+
operation.state.walletRootId,
|
|
594
|
+
operation.normalizedDomainName,
|
|
595
|
+
operation.normalizedFieldName,
|
|
684
596
|
]);
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
walletRootId: operation.state.walletRootId,
|
|
690
|
-
});
|
|
691
|
-
const rpc = (options.rpcFactory ?? createRpcClient)(node.rpc);
|
|
692
|
-
const walletName = operation.state.managedCoreWallet.walletName;
|
|
693
|
-
const feeSelection = await resolveWalletMutationFeeSelection({
|
|
694
|
-
rpc,
|
|
695
|
-
feeRateSatVb: options.feeRateSatVb ?? null,
|
|
696
|
-
});
|
|
697
|
-
const existingMutation = findPendingMutationByIntent(operation.state, intentFingerprintHex);
|
|
698
|
-
let workingState = operation.state;
|
|
699
|
-
let replacementFixedInputs = null;
|
|
700
|
-
if (existingMutation !== null) {
|
|
701
|
-
const reconciled = await reconcilePendingFieldMutation({
|
|
597
|
+
},
|
|
598
|
+
async resolveExistingMutation({ operation, existingMutation, execution }) {
|
|
599
|
+
if (existingMutation === null) {
|
|
600
|
+
return {
|
|
702
601
|
state: operation.state,
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
paths,
|
|
707
|
-
rpc,
|
|
708
|
-
walletName,
|
|
709
|
-
context: readContext,
|
|
710
|
-
});
|
|
711
|
-
workingState = reconciled.state;
|
|
712
|
-
if (reconciled.resolution === "confirmed" || reconciled.resolution === "live") {
|
|
713
|
-
const reuse = await resolvePendingMutationReuseDecision({
|
|
714
|
-
rpc,
|
|
715
|
-
walletName,
|
|
716
|
-
mutation: reconciled.mutation,
|
|
717
|
-
nextFeeSelection: feeSelection,
|
|
718
|
-
});
|
|
719
|
-
if (reuse.reuseExisting) {
|
|
720
|
-
return {
|
|
721
|
-
kind: options.kind,
|
|
722
|
-
domainName: normalizedDomainName,
|
|
723
|
-
fieldName: normalizedFieldName,
|
|
724
|
-
fieldId: reconciled.mutation.fieldId ?? existingObservedField?.fieldId ?? null,
|
|
725
|
-
txid: reconciled.mutation.attemptedTxid ?? "unknown",
|
|
726
|
-
permanent: reconciled.mutation.fieldPermanent ?? existingObservedField?.permanent ?? null,
|
|
727
|
-
format: reconciled.mutation.fieldFormat ?? existingObservedField?.format ?? null,
|
|
728
|
-
status: reconciled.resolution,
|
|
729
|
-
reusedExisting: true,
|
|
730
|
-
resolved: createResolvedFieldSummary({
|
|
731
|
-
sender: operation.sender,
|
|
732
|
-
senderSelector: operation.senderSelector,
|
|
733
|
-
kind: options.kind,
|
|
734
|
-
value: createResolvedFieldValueFromStoredData(options.kind, reconciled.mutation.fieldFormat ?? existingObservedField?.format ?? null, reconciled.mutation.fieldValueHex),
|
|
735
|
-
}),
|
|
736
|
-
fees: reuse.fees,
|
|
737
|
-
};
|
|
738
|
-
}
|
|
739
|
-
replacementFixedInputs = reuse.replacementFixedInputs;
|
|
740
|
-
}
|
|
741
|
-
if (reconciled.resolution === "repair-required") {
|
|
742
|
-
throw new Error(`${options.errorPrefix}_repair_required`);
|
|
743
|
-
}
|
|
602
|
+
replacementFixedInputs: null,
|
|
603
|
+
result: null,
|
|
604
|
+
};
|
|
744
605
|
}
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
606
|
+
return resolveExistingWalletMutation({
|
|
607
|
+
existingMutation,
|
|
608
|
+
execution,
|
|
609
|
+
repairRequiredErrorCode: `${options.errorPrefix}_repair_required`,
|
|
610
|
+
reconcileExistingMutation: (mutation) => reconcilePendingFieldMutation({
|
|
611
|
+
state: operation.state,
|
|
612
|
+
mutation,
|
|
613
|
+
provider: execution.provider,
|
|
614
|
+
nowUnixMs: execution.nowUnixMs,
|
|
615
|
+
paths: execution.paths,
|
|
616
|
+
rpc: execution.rpc,
|
|
617
|
+
walletName: execution.walletName,
|
|
618
|
+
context: execution.readContext,
|
|
619
|
+
}),
|
|
620
|
+
createReuseResult: ({ mutation, resolution, fees }) => ({
|
|
621
|
+
kind: options.kind,
|
|
622
|
+
domainName: operation.normalizedDomainName,
|
|
623
|
+
fieldName: operation.normalizedFieldName,
|
|
624
|
+
fieldId: mutation.fieldId ?? operation.existingObservedField?.fieldId ?? null,
|
|
625
|
+
txid: mutation.attemptedTxid ?? "unknown",
|
|
626
|
+
permanent: mutation.fieldPermanent ?? operation.existingObservedField?.permanent ?? null,
|
|
627
|
+
format: mutation.fieldFormat ?? operation.existingObservedField?.format ?? null,
|
|
628
|
+
status: resolution,
|
|
629
|
+
reusedExisting: true,
|
|
630
|
+
resolved: createResolvedFieldSummary({
|
|
631
|
+
sender: operation.sender,
|
|
632
|
+
senderSelector: operation.senderSelector,
|
|
633
|
+
kind: options.kind,
|
|
634
|
+
value: createResolvedFieldValueFromStoredData(options.kind, mutation.fieldFormat ?? operation.existingObservedField?.format ?? null, mutation.fieldValueHex),
|
|
635
|
+
}),
|
|
636
|
+
fees,
|
|
637
|
+
}),
|
|
753
638
|
});
|
|
639
|
+
},
|
|
640
|
+
confirm({ operation }) {
|
|
641
|
+
return options.confirm(operation);
|
|
642
|
+
},
|
|
643
|
+
async createDraftMutation({ operation, existingMutation, execution }) {
|
|
644
|
+
const prepared = await options.createMutation(operation, existingMutation, execution.feeSelection);
|
|
645
|
+
return {
|
|
646
|
+
mutation: prepared.mutation,
|
|
647
|
+
prepared: {
|
|
648
|
+
opReturnData: prepared.opReturnData,
|
|
649
|
+
},
|
|
650
|
+
};
|
|
651
|
+
},
|
|
652
|
+
async build({ operation, state, execution, replacementFixedInputs, prepared }) {
|
|
754
653
|
const fieldPlan = buildAnchoredFieldPlan({
|
|
755
|
-
state
|
|
756
|
-
allUtxos: await rpc.listUnspent(walletName, 1),
|
|
654
|
+
state,
|
|
655
|
+
allUtxos: await execution.rpc.listUnspent(execution.walletName, 1),
|
|
757
656
|
sender: operation.sender,
|
|
758
|
-
opReturnData:
|
|
657
|
+
opReturnData: prepared.opReturnData,
|
|
759
658
|
errorPrefix: options.errorPrefix,
|
|
760
659
|
});
|
|
761
|
-
|
|
762
|
-
rpc,
|
|
763
|
-
walletName,
|
|
764
|
-
state
|
|
660
|
+
return buildFieldTransaction({
|
|
661
|
+
rpc: execution.rpc,
|
|
662
|
+
walletName: execution.walletName,
|
|
663
|
+
state,
|
|
765
664
|
plan: {
|
|
766
665
|
...fieldPlan,
|
|
767
666
|
fixedInputs: mergeFixedWalletInputs(fieldPlan.fixedInputs, replacementFixedInputs),
|
|
768
667
|
},
|
|
769
|
-
feeRateSatVb: feeSelection.feeRateSatVb,
|
|
668
|
+
feeRateSatVb: execution.feeSelection.feeRateSatVb,
|
|
770
669
|
});
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
670
|
+
},
|
|
671
|
+
publish({ state, execution, built, mutation }) {
|
|
672
|
+
return publishWalletMutation({
|
|
673
|
+
rpc: execution.rpc,
|
|
674
|
+
walletName: execution.walletName,
|
|
675
|
+
snapshotHeight: execution.readContext.snapshot?.tip?.height ?? null,
|
|
775
676
|
built,
|
|
776
|
-
mutation
|
|
777
|
-
state
|
|
778
|
-
provider,
|
|
779
|
-
nowUnixMs,
|
|
780
|
-
paths,
|
|
677
|
+
mutation,
|
|
678
|
+
state,
|
|
679
|
+
provider: execution.provider,
|
|
680
|
+
nowUnixMs: execution.nowUnixMs,
|
|
681
|
+
paths: execution.paths,
|
|
781
682
|
errorPrefix: options.errorPrefix,
|
|
782
683
|
});
|
|
684
|
+
},
|
|
685
|
+
createResult({ operation, mutation, built, status, reusedExisting, fees }) {
|
|
783
686
|
return {
|
|
784
687
|
kind: options.kind,
|
|
785
|
-
domainName: normalizedDomainName,
|
|
786
|
-
fieldName: normalizedFieldName,
|
|
787
|
-
fieldId:
|
|
788
|
-
txid:
|
|
789
|
-
permanent:
|
|
790
|
-
format:
|
|
791
|
-
status:
|
|
792
|
-
reusedExisting
|
|
688
|
+
domainName: operation.normalizedDomainName,
|
|
689
|
+
fieldName: operation.normalizedFieldName,
|
|
690
|
+
fieldId: mutation.fieldId ?? operation.existingObservedField?.fieldId ?? null,
|
|
691
|
+
txid: mutation.attemptedTxid ?? built?.txid ?? "unknown",
|
|
692
|
+
permanent: mutation.fieldPermanent ?? operation.existingObservedField?.permanent ?? null,
|
|
693
|
+
format: mutation.fieldFormat ?? operation.existingObservedField?.format ?? null,
|
|
694
|
+
status: status,
|
|
695
|
+
reusedExisting,
|
|
793
696
|
resolved: createResolvedFieldSummary({
|
|
794
697
|
sender: operation.sender,
|
|
795
698
|
senderSelector: operation.senderSelector,
|
|
796
699
|
kind: options.kind,
|
|
797
|
-
value: createResolvedFieldValueFromStoredData(options.kind,
|
|
798
|
-
}),
|
|
799
|
-
fees: createBuiltWalletMutationFeeSummary({
|
|
800
|
-
selection: feeSelection,
|
|
801
|
-
built,
|
|
700
|
+
value: createResolvedFieldValueFromStoredData(options.kind, mutation.fieldFormat ?? operation.existingObservedField?.format ?? null, mutation.fieldValueHex),
|
|
802
701
|
}),
|
|
702
|
+
fees,
|
|
803
703
|
};
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
await miningPreemption.release();
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
finally {
|
|
811
|
-
await controlLock.release();
|
|
812
|
-
}
|
|
704
|
+
},
|
|
705
|
+
});
|
|
706
|
+
return execution.result;
|
|
813
707
|
}
|
|
814
708
|
export async function createField(options) {
|
|
815
709
|
const permanent = options.permanent ?? false;
|