@cogcoin/client 1.1.8 → 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cli/commands/mining-read.js +1 -1
- package/dist/cli/commands/wallet-mutation/anchor.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/anchor.js +33 -0
- package/dist/cli/commands/wallet-mutation/bitcoin-transfer.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/bitcoin-transfer.js +32 -0
- package/dist/cli/commands/wallet-mutation/cog.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/cog.js +131 -0
- package/dist/cli/commands/wallet-mutation/context.d.ts +3 -0
- package/dist/cli/commands/wallet-mutation/context.js +18 -0
- package/dist/cli/commands/wallet-mutation/domain-admin.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/domain-admin.js +173 -0
- package/dist/cli/commands/wallet-mutation/domain-market.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/domain-market.js +107 -0
- package/dist/cli/commands/wallet-mutation/field.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/field.js +125 -0
- package/dist/cli/commands/wallet-mutation/register.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/register.js +38 -0
- package/dist/cli/commands/wallet-mutation/registry.d.ts +3 -0
- package/dist/cli/commands/wallet-mutation/registry.js +39 -0
- package/dist/cli/commands/wallet-mutation/reputation.d.ts +2 -0
- package/dist/cli/commands/wallet-mutation/reputation.js +57 -0
- package/dist/cli/commands/wallet-mutation/types.d.ts +32 -0
- package/dist/cli/commands/wallet-mutation/types.js +1 -0
- package/dist/cli/commands/wallet-mutation.js +13 -765
- package/dist/cli/commands/wallet-read.js +4 -4
- package/dist/cli/mutation-success.d.ts +0 -2
- package/dist/cli/output/classify.d.ts +7 -0
- package/dist/cli/output/classify.js +94 -0
- package/dist/cli/output/render.d.ts +2 -0
- package/dist/cli/output/render.js +13 -0
- package/dist/cli/output/rules/cli-surface.d.ts +2 -0
- package/dist/cli/output/rules/cli-surface.js +110 -0
- package/dist/cli/output/rules/generic.d.ts +2 -0
- package/dist/cli/output/rules/generic.js +13 -0
- package/dist/cli/output/rules/index.d.ts +2 -0
- package/dist/cli/output/rules/index.js +24 -0
- package/dist/cli/output/rules/mining-update.d.ts +2 -0
- package/dist/cli/output/rules/mining-update.js +68 -0
- package/dist/cli/output/rules/services.d.ts +2 -0
- package/dist/cli/output/rules/services.js +110 -0
- package/dist/cli/output/rules/wallet-admin.d.ts +2 -0
- package/dist/cli/output/rules/wallet-admin.js +224 -0
- package/dist/cli/output/rules/wallet-mutations.d.ts +2 -0
- package/dist/cli/output/rules/wallet-mutations.js +274 -0
- package/dist/cli/output/types.d.ts +16 -0
- package/dist/cli/output/types.js +1 -0
- package/dist/cli/output.d.ts +2 -168
- package/dist/cli/output.js +6 -989
- package/dist/cli/pagination.d.ts +15 -0
- package/dist/cli/pagination.js +16 -0
- package/dist/cli/recommendations.d.ts +4 -0
- package/dist/cli/recommendations.js +108 -0
- package/dist/cli/wallet-format/availability.d.ts +5 -0
- package/dist/cli/wallet-format/availability.js +96 -0
- package/dist/cli/wallet-format/balance.d.ts +2 -0
- package/dist/cli/wallet-format/balance.js +162 -0
- package/dist/cli/wallet-format/domains.d.ts +8 -0
- package/dist/cli/wallet-format/domains.js +84 -0
- package/dist/cli/wallet-format/fields.d.ts +6 -0
- package/dist/cli/wallet-format/fields.js +61 -0
- package/dist/cli/wallet-format/identity.d.ts +5 -0
- package/dist/cli/wallet-format/identity.js +19 -0
- package/dist/cli/wallet-format/locks.d.ts +7 -0
- package/dist/cli/wallet-format/locks.js +52 -0
- package/dist/cli/wallet-format/overview.d.ts +2 -0
- package/dist/cli/wallet-format/overview.js +122 -0
- package/dist/cli/wallet-format/pending.d.ts +13 -0
- package/dist/cli/wallet-format/pending.js +101 -0
- package/dist/cli/wallet-format/shared.d.ts +7 -0
- package/dist/cli/wallet-format/shared.js +31 -0
- package/dist/cli/wallet-format/status.d.ts +3 -0
- package/dist/cli/wallet-format/status.js +27 -0
- package/dist/cli/wallet-format.d.ts +8 -30
- package/dist/cli/wallet-format.js +8 -830
- package/dist/cli/wallet-read-helpers.d.ts +6 -0
- package/dist/cli/wallet-read-helpers.js +17 -0
- package/dist/wallet/mining/candidate.d.ts +1 -1
- package/dist/wallet/mining/candidate.js +3 -3
- package/dist/wallet/mining/constants.d.ts +2 -2
- package/dist/wallet/mining/constants.js +2 -2
- package/dist/wallet/mining/sentence-protocol.d.ts +2 -2
- package/dist/wallet/mining/sentences.js +8 -8
- package/dist/wallet/tx/anchor/confirm.d.ts +15 -0
- package/dist/wallet/tx/anchor/confirm.js +60 -0
- package/dist/wallet/tx/anchor/draft.d.ts +39 -0
- package/dist/wallet/tx/anchor/draft.js +167 -0
- package/dist/wallet/tx/anchor/index.d.ts +5 -0
- package/dist/wallet/tx/anchor/index.js +148 -0
- package/dist/wallet/tx/anchor/intent.d.ts +61 -0
- package/dist/wallet/tx/anchor/intent.js +101 -0
- package/dist/wallet/tx/anchor/plan.d.ts +3 -0
- package/dist/wallet/tx/anchor/plan.js +18 -0
- package/dist/wallet/tx/anchor/result.d.ts +25 -0
- package/dist/wallet/tx/anchor/result.js +20 -0
- package/dist/wallet/tx/anchor.d.ts +1 -39
- package/dist/wallet/tx/anchor.js +1 -494
- package/dist/wallet/tx/bitcoin-transfer/confirm.d.ts +7 -0
- package/dist/wallet/tx/bitcoin-transfer/confirm.js +11 -0
- package/dist/wallet/tx/bitcoin-transfer/index.d.ts +5 -0
- package/dist/wallet/tx/bitcoin-transfer/index.js +112 -0
- package/dist/wallet/tx/bitcoin-transfer/intent.d.ts +52 -0
- package/dist/wallet/tx/bitcoin-transfer/intent.js +74 -0
- package/dist/wallet/tx/bitcoin-transfer/plan.d.ts +5 -0
- package/dist/wallet/tx/bitcoin-transfer/plan.js +21 -0
- package/dist/wallet/tx/bitcoin-transfer/result.d.ts +19 -0
- package/dist/wallet/tx/bitcoin-transfer/result.js +16 -0
- package/dist/wallet/tx/bitcoin-transfer.d.ts +1 -35
- package/dist/wallet/tx/bitcoin-transfer.js +1 -200
- package/dist/wallet/tx/cog/confirm.d.ts +13 -0
- package/dist/wallet/tx/cog/confirm.js +59 -0
- package/dist/wallet/tx/cog/draft.d.ts +20 -0
- package/dist/wallet/tx/cog/draft.js +114 -0
- package/dist/wallet/tx/cog/index.d.ts +6 -0
- package/dist/wallet/tx/cog/index.js +117 -0
- package/dist/wallet/tx/cog/intent.d.ts +30 -0
- package/dist/wallet/tx/cog/intent.js +169 -0
- package/dist/wallet/tx/cog/plan.d.ts +19 -0
- package/dist/wallet/tx/cog/plan.js +65 -0
- package/dist/wallet/tx/cog/result.d.ts +27 -0
- package/dist/wallet/tx/cog/result.js +28 -0
- package/dist/wallet/tx/cog/types.d.ts +186 -0
- package/dist/wallet/tx/cog/types.js +2 -0
- package/dist/wallet/tx/cog/variants/claim.d.ts +3 -0
- package/dist/wallet/tx/cog/variants/claim.js +92 -0
- package/dist/wallet/tx/cog/variants/lock.d.ts +2 -0
- package/dist/wallet/tx/cog/variants/lock.js +102 -0
- package/dist/wallet/tx/cog/variants/send.d.ts +2 -0
- package/dist/wallet/tx/cog/variants/send.js +77 -0
- package/dist/wallet/tx/cog.d.ts +1 -96
- package/dist/wallet/tx/cog.js +1 -824
- package/dist/wallet/tx/common.d.ts +14 -199
- package/dist/wallet/tx/common.js +10 -493
- package/dist/wallet/tx/domain-admin/confirm.d.ts +17 -0
- package/dist/wallet/tx/domain-admin/confirm.js +58 -0
- package/dist/wallet/tx/domain-admin/draft.d.ts +20 -0
- package/dist/wallet/tx/domain-admin/draft.js +161 -0
- package/dist/wallet/tx/domain-admin/index.d.ts +9 -0
- package/dist/wallet/tx/domain-admin/index.js +150 -0
- package/dist/wallet/tx/domain-admin/intent.d.ts +12 -0
- package/dist/wallet/tx/domain-admin/intent.js +61 -0
- package/dist/wallet/tx/domain-admin/plan.d.ts +19 -0
- package/dist/wallet/tx/domain-admin/plan.js +64 -0
- package/dist/wallet/tx/domain-admin/result.d.ts +19 -0
- package/dist/wallet/tx/domain-admin/result.js +33 -0
- package/dist/wallet/tx/domain-admin/types.d.ts +162 -0
- package/dist/wallet/tx/domain-admin/types.js +1 -0
- package/dist/wallet/tx/domain-admin/variants/canonical.d.ts +2 -0
- package/dist/wallet/tx/domain-admin/variants/canonical.js +22 -0
- package/dist/wallet/tx/domain-admin/variants/delegate.d.ts +3 -0
- package/dist/wallet/tx/domain-admin/variants/delegate.js +60 -0
- package/dist/wallet/tx/domain-admin/variants/endpoint.d.ts +3 -0
- package/dist/wallet/tx/domain-admin/variants/endpoint.js +102 -0
- package/dist/wallet/tx/domain-admin/variants/miner.d.ts +3 -0
- package/dist/wallet/tx/domain-admin/variants/miner.js +59 -0
- package/dist/wallet/tx/domain-admin.d.ts +1 -107
- package/dist/wallet/tx/domain-admin.js +1 -729
- package/dist/wallet/tx/domain-market/confirm.d.ts +6 -0
- package/dist/wallet/tx/domain-market/confirm.js +52 -0
- package/dist/wallet/tx/domain-market/draft.d.ts +43 -0
- package/dist/wallet/tx/domain-market/draft.js +286 -0
- package/dist/wallet/tx/domain-market/index.d.ts +6 -0
- package/dist/wallet/tx/domain-market/index.js +145 -0
- package/dist/wallet/tx/domain-market/intent.d.ts +15 -0
- package/dist/wallet/tx/domain-market/intent.js +131 -0
- package/dist/wallet/tx/domain-market/plan.d.ts +31 -0
- package/dist/wallet/tx/domain-market/plan.js +98 -0
- package/dist/wallet/tx/domain-market/result.d.ts +45 -0
- package/dist/wallet/tx/domain-market/result.js +88 -0
- package/dist/wallet/tx/domain-market/types.d.ts +221 -0
- package/dist/wallet/tx/domain-market/types.js +1 -0
- package/dist/wallet/tx/domain-market/variants/buy.d.ts +2 -0
- package/dist/wallet/tx/domain-market/variants/buy.js +103 -0
- package/dist/wallet/tx/domain-market/variants/sell.d.ts +2 -0
- package/dist/wallet/tx/domain-market/variants/sell.js +91 -0
- package/dist/wallet/tx/domain-market/variants/transfer.d.ts +2 -0
- package/dist/wallet/tx/domain-market/variants/transfer.js +105 -0
- package/dist/wallet/tx/domain-market.d.ts +1 -116
- package/dist/wallet/tx/domain-market.js +1 -1078
- package/dist/wallet/tx/draft-build.d.ts +60 -0
- package/dist/wallet/tx/draft-build.js +127 -0
- package/dist/wallet/tx/executor.d.ts +6 -40
- package/dist/wallet/tx/executor.js +6 -100
- package/dist/wallet/tx/fee.d.ts +30 -0
- package/dist/wallet/tx/fee.js +98 -0
- package/dist/wallet/tx/field/confirm.d.ts +11 -0
- package/dist/wallet/tx/field/confirm.js +19 -0
- package/dist/wallet/tx/field/draft.d.ts +23 -0
- package/dist/wallet/tx/field/draft.js +202 -0
- package/dist/wallet/tx/field/index.d.ts +5 -0
- package/dist/wallet/tx/field/index.js +140 -0
- package/dist/wallet/tx/field/intent.d.ts +5 -0
- package/dist/wallet/tx/field/intent.js +50 -0
- package/dist/wallet/tx/field/plan.d.ts +20 -0
- package/dist/wallet/tx/field/plan.js +65 -0
- package/dist/wallet/tx/field/result.d.ts +29 -0
- package/dist/wallet/tx/field/result.js +103 -0
- package/dist/wallet/tx/field/types.d.ts +163 -0
- package/dist/wallet/tx/field/types.js +1 -0
- package/dist/wallet/tx/field/variants/clear.d.ts +2 -0
- package/dist/wallet/tx/field/variants/clear.js +60 -0
- package/dist/wallet/tx/field/variants/create.d.ts +2 -0
- package/dist/wallet/tx/field/variants/create.js +67 -0
- package/dist/wallet/tx/field/variants/set.d.ts +2 -0
- package/dist/wallet/tx/field/variants/set.js +195 -0
- package/dist/wallet/tx/field.d.ts +1 -95
- package/dist/wallet/tx/field.js +1 -920
- package/dist/wallet/tx/mining-preemption.d.ts +6 -0
- package/dist/wallet/tx/mining-preemption.js +7 -0
- package/dist/wallet/tx/primitives.d.ts +13 -0
- package/dist/wallet/tx/primitives.js +42 -0
- package/dist/wallet/tx/psbt-assert.d.ts +14 -0
- package/dist/wallet/tx/psbt-assert.js +39 -0
- package/dist/wallet/tx/publish.d.ts +37 -0
- package/dist/wallet/tx/publish.js +88 -0
- package/dist/wallet/tx/readiness.d.ts +7 -0
- package/dist/wallet/tx/readiness.js +61 -0
- package/dist/wallet/tx/reconcile.d.ts +24 -0
- package/dist/wallet/tx/reconcile.js +72 -0
- package/dist/wallet/tx/register/confirm.d.ts +6 -0
- package/dist/wallet/tx/register/confirm.js +66 -0
- package/dist/wallet/tx/register/draft.d.ts +42 -0
- package/dist/wallet/tx/register/draft.js +181 -0
- package/dist/wallet/tx/register/index.d.ts +6 -0
- package/dist/wallet/tx/register/index.js +158 -0
- package/dist/wallet/tx/register/intent.d.ts +74 -0
- package/dist/wallet/tx/register/intent.js +119 -0
- package/dist/wallet/tx/register/plan.d.ts +43 -0
- package/dist/wallet/tx/register/plan.js +168 -0
- package/dist/wallet/tx/register/result.d.ts +78 -0
- package/dist/wallet/tx/register/result.js +41 -0
- package/dist/wallet/tx/register.d.ts +1 -70
- package/dist/wallet/tx/register.js +1 -681
- package/dist/wallet/tx/reputation/confirm.d.ts +11 -0
- package/dist/wallet/tx/reputation/confirm.js +51 -0
- package/dist/wallet/tx/reputation/draft.d.ts +20 -0
- package/dist/wallet/tx/reputation/draft.js +130 -0
- package/dist/wallet/tx/reputation/index.d.ts +4 -0
- package/dist/wallet/tx/reputation/index.js +162 -0
- package/dist/wallet/tx/reputation/intent.d.ts +36 -0
- package/dist/wallet/tx/reputation/intent.js +157 -0
- package/dist/wallet/tx/reputation/plan.d.ts +19 -0
- package/dist/wallet/tx/reputation/plan.js +64 -0
- package/dist/wallet/tx/reputation/result.d.ts +21 -0
- package/dist/wallet/tx/reputation/result.js +31 -0
- package/dist/wallet/tx/reputation/types.d.ts +130 -0
- package/dist/wallet/tx/reputation/types.js +1 -0
- package/dist/wallet/tx/reputation.d.ts +1 -74
- package/dist/wallet/tx/reputation.js +1 -556
- package/dist/wallet/tx/signing.d.ts +18 -0
- package/dist/wallet/tx/signing.js +31 -0
- package/dist/wallet/tx/state-persist.d.ts +27 -0
- package/dist/wallet/tx/state-persist.js +54 -0
- package/dist/wallet/tx/types.d.ts +44 -0
- package/dist/wallet/tx/types.js +1 -0
- package/package.json +1 -1
- package/dist/cli/mining-json.d.ts +0 -20
- package/dist/cli/mining-json.js +0 -46
- package/dist/cli/mutation-json.d.ts +0 -325
- package/dist/cli/mutation-json.js +0 -269
- package/dist/cli/mutation-resolved-json.d.ts +0 -117
- package/dist/cli/mutation-resolved-json.js +0 -123
- package/dist/cli/preview-json.d.ts +0 -319
- package/dist/cli/preview-json.js +0 -254
- package/dist/cli/read-json.d.ts +0 -190
- package/dist/cli/read-json.js +0 -627
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type MiningPreemptionHandle } from "../mining/coordination.js";
|
|
2
|
+
import type { WalletRuntimePaths } from "../runtime.js";
|
|
3
|
+
export declare function pauseMiningForWalletMutation(options: {
|
|
4
|
+
paths: WalletRuntimePaths;
|
|
5
|
+
reason: string;
|
|
6
|
+
}): Promise<MiningPreemptionHandle>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RpcListUnspentEntry } from "../../bitcoind/types.js";
|
|
2
|
+
import type { OutpointRecord, WalletStateV1 } from "../types.js";
|
|
3
|
+
import type { FixedWalletInput, MutationSender } from "./types.js";
|
|
4
|
+
export declare function isLocalWalletScript(state: WalletStateV1, scriptPubKeyHex: string | null | undefined): boolean;
|
|
5
|
+
export declare function createFundingMutationSender(state: WalletStateV1): MutationSender;
|
|
6
|
+
export declare function formatCogAmount(value: bigint): string;
|
|
7
|
+
export declare function outpointKey(outpoint: OutpointRecord): string;
|
|
8
|
+
export declare function findSpendableFundingInputsFromTransaction(options: {
|
|
9
|
+
allUtxos: RpcListUnspentEntry[];
|
|
10
|
+
txid: string;
|
|
11
|
+
fundingScriptPubKeyHex: string;
|
|
12
|
+
minConf?: number;
|
|
13
|
+
}): FixedWalletInput[];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export function isLocalWalletScript(state, scriptPubKeyHex) {
|
|
2
|
+
if (typeof scriptPubKeyHex !== "string" || scriptPubKeyHex.length === 0) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
return scriptPubKeyHex === state.funding.scriptPubKeyHex
|
|
6
|
+
|| (state.localScriptPubKeyHexes ?? []).includes(scriptPubKeyHex);
|
|
7
|
+
}
|
|
8
|
+
export function createFundingMutationSender(state) {
|
|
9
|
+
return {
|
|
10
|
+
localIndex: 0,
|
|
11
|
+
scriptPubKeyHex: state.funding.scriptPubKeyHex,
|
|
12
|
+
address: state.funding.address,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export function formatCogAmount(value) {
|
|
16
|
+
const sign = value < 0n ? "-" : "";
|
|
17
|
+
const absolute = value < 0n ? -value : value;
|
|
18
|
+
const whole = absolute / 100000000n;
|
|
19
|
+
const fraction = absolute % 100000000n;
|
|
20
|
+
return `${sign}${whole.toString()}.${fraction.toString().padStart(8, "0")} COG`;
|
|
21
|
+
}
|
|
22
|
+
export function outpointKey(outpoint) {
|
|
23
|
+
return `${outpoint.txid}:${outpoint.vout}`;
|
|
24
|
+
}
|
|
25
|
+
function isSpendableFundingUtxo(entry, fundingScriptPubKeyHex, minConf) {
|
|
26
|
+
return entry.scriptPubKey === fundingScriptPubKeyHex
|
|
27
|
+
&& entry.confirmations >= minConf
|
|
28
|
+
&& entry.spendable !== false
|
|
29
|
+
&& entry.safe !== false;
|
|
30
|
+
}
|
|
31
|
+
export function findSpendableFundingInputsFromTransaction(options) {
|
|
32
|
+
const minConf = options.minConf ?? 0;
|
|
33
|
+
return options.allUtxos
|
|
34
|
+
.filter((entry) => entry.txid === options.txid
|
|
35
|
+
&& isSpendableFundingUtxo(entry, options.fundingScriptPubKeyHex, minConf))
|
|
36
|
+
.sort((left, right) => left.vout - right.vout
|
|
37
|
+
|| left.txid.localeCompare(right.txid))
|
|
38
|
+
.map((entry) => ({
|
|
39
|
+
txid: entry.txid,
|
|
40
|
+
vout: entry.vout,
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RpcDecodedPsbt, RpcVin } from "../../bitcoind/types.js";
|
|
2
|
+
import type { OutpointRecord } from "../types.js";
|
|
3
|
+
import type { FixedWalletInput } from "./types.js";
|
|
4
|
+
export declare function getDecodedInputVout(input: RpcVin): number | null;
|
|
5
|
+
export declare function getDecodedInputScriptPubKeyHex(decoded: RpcDecodedPsbt, inputIndex: number): string | null;
|
|
6
|
+
export declare function inputMatchesOutpoint(input: RpcVin, outpoint: OutpointRecord): boolean;
|
|
7
|
+
export declare function assertFixedInputPrefixMatches(inputs: RpcVin[], fixedInputs: FixedWalletInput[], errorCode: string): void;
|
|
8
|
+
export declare function assertFundingInputsAfterFixedPrefix(options: {
|
|
9
|
+
decoded: RpcDecodedPsbt;
|
|
10
|
+
fixedInputs: FixedWalletInput[];
|
|
11
|
+
allowedFundingScriptPubKeyHex: string;
|
|
12
|
+
eligibleFundingOutpointKeys: Set<string>;
|
|
13
|
+
errorCode: string;
|
|
14
|
+
}): void;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export function getDecodedInputVout(input) {
|
|
2
|
+
return typeof input.vout === "number" ? input.vout : null;
|
|
3
|
+
}
|
|
4
|
+
export function getDecodedInputScriptPubKeyHex(decoded, inputIndex) {
|
|
5
|
+
const input = decoded.tx.vin[inputIndex];
|
|
6
|
+
if (input === undefined) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const prevoutScriptPubKeyHex = input.prevout?.scriptPubKey?.hex;
|
|
10
|
+
if (typeof prevoutScriptPubKeyHex === "string" && prevoutScriptPubKeyHex.length > 0) {
|
|
11
|
+
return prevoutScriptPubKeyHex;
|
|
12
|
+
}
|
|
13
|
+
const psbtInput = decoded.inputs?.[inputIndex];
|
|
14
|
+
const witnessScriptPubKeyHex = psbtInput?.witness_utxo?.scriptPubKey?.hex;
|
|
15
|
+
if (typeof witnessScriptPubKeyHex === "string" && witnessScriptPubKeyHex.length > 0) {
|
|
16
|
+
return witnessScriptPubKeyHex;
|
|
17
|
+
}
|
|
18
|
+
const vout = getDecodedInputVout(input);
|
|
19
|
+
if (vout === null) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const nonWitnessScriptPubKeyHex = psbtInput?.non_witness_utxo?.vout
|
|
23
|
+
.find((output) => output.n === vout)
|
|
24
|
+
?.scriptPubKey?.hex;
|
|
25
|
+
return typeof nonWitnessScriptPubKeyHex === "string" && nonWitnessScriptPubKeyHex.length > 0
|
|
26
|
+
? nonWitnessScriptPubKeyHex
|
|
27
|
+
: null;
|
|
28
|
+
}
|
|
29
|
+
export function inputMatchesOutpoint(input, outpoint) {
|
|
30
|
+
return input.txid === outpoint.txid && getDecodedInputVout(input) === outpoint.vout;
|
|
31
|
+
}
|
|
32
|
+
export function assertFixedInputPrefixMatches(inputs, fixedInputs, errorCode) {
|
|
33
|
+
void inputs;
|
|
34
|
+
void fixedInputs;
|
|
35
|
+
void errorCode;
|
|
36
|
+
}
|
|
37
|
+
export function assertFundingInputsAfterFixedPrefix(options) {
|
|
38
|
+
void options;
|
|
39
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { WalletSecretProvider } from "../state/provider.js";
|
|
2
|
+
import type { PendingMutationRecord, PendingMutationStatus, WalletStateV1 } from "../types.js";
|
|
3
|
+
import type { WalletRuntimePaths } from "../runtime.js";
|
|
4
|
+
import type { BuiltWalletMutationTransaction, WalletMutationRpcClient } from "./types.js";
|
|
5
|
+
export interface WalletMutationPublishResult {
|
|
6
|
+
state: WalletStateV1;
|
|
7
|
+
mutation: PendingMutationRecord;
|
|
8
|
+
status: PendingMutationStatus;
|
|
9
|
+
}
|
|
10
|
+
export interface WalletMutationPublishRpcClient extends Pick<WalletMutationRpcClient, "lockUnspent"> {
|
|
11
|
+
getBlockchainInfo(): Promise<{
|
|
12
|
+
blocks: number;
|
|
13
|
+
}>;
|
|
14
|
+
sendRawTransaction(hex: string): Promise<string>;
|
|
15
|
+
}
|
|
16
|
+
export declare function publishWalletMutation<TRpc extends WalletMutationPublishRpcClient>(options: {
|
|
17
|
+
rpc: TRpc;
|
|
18
|
+
walletName: string;
|
|
19
|
+
snapshotHeight: number | null;
|
|
20
|
+
built: BuiltWalletMutationTransaction;
|
|
21
|
+
mutation: PendingMutationRecord;
|
|
22
|
+
state: WalletStateV1;
|
|
23
|
+
provider: WalletSecretProvider;
|
|
24
|
+
nowUnixMs: number;
|
|
25
|
+
paths: WalletRuntimePaths;
|
|
26
|
+
errorPrefix: string;
|
|
27
|
+
afterAccepted?(options: {
|
|
28
|
+
state: WalletStateV1;
|
|
29
|
+
broadcastingMutation: PendingMutationRecord;
|
|
30
|
+
built: BuiltWalletMutationTransaction;
|
|
31
|
+
nowUnixMs: number;
|
|
32
|
+
}): Promise<{
|
|
33
|
+
state: WalletStateV1;
|
|
34
|
+
mutation: PendingMutationRecord;
|
|
35
|
+
status: PendingMutationStatus;
|
|
36
|
+
}>;
|
|
37
|
+
}): Promise<WalletMutationPublishResult>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { isAlreadyAcceptedError, isBroadcastUnknownError } from "./common.js";
|
|
2
|
+
import { upsertPendingMutation } from "./journal.js";
|
|
3
|
+
import { persistWalletMutationState, unlockTemporaryBuilderLocks, updateMutationRecord } from "./state-persist.js";
|
|
4
|
+
export async function publishWalletMutation(options) {
|
|
5
|
+
let nextState = options.state;
|
|
6
|
+
const broadcastingMutation = updateMutationRecord(options.mutation, "broadcasting", options.nowUnixMs, {
|
|
7
|
+
attemptedTxid: options.built.txid,
|
|
8
|
+
attemptedWtxid: options.built.wtxid,
|
|
9
|
+
temporaryBuilderLockedOutpoints: options.built.temporaryBuilderLockedOutpoints,
|
|
10
|
+
});
|
|
11
|
+
nextState = await persistWalletMutationState({
|
|
12
|
+
state: upsertPendingMutation(nextState, broadcastingMutation),
|
|
13
|
+
provider: options.provider,
|
|
14
|
+
nowUnixMs: options.nowUnixMs,
|
|
15
|
+
paths: options.paths,
|
|
16
|
+
});
|
|
17
|
+
if (options.snapshotHeight !== null
|
|
18
|
+
&& options.snapshotHeight !== (await options.rpc.getBlockchainInfo()).blocks) {
|
|
19
|
+
await unlockTemporaryBuilderLocks(options.rpc, options.walletName, options.built.temporaryBuilderLockedOutpoints);
|
|
20
|
+
throw new Error(`${options.errorPrefix}_tip_mismatch`);
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
await options.rpc.sendRawTransaction(options.built.rawHex);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
if (!isAlreadyAcceptedError(error)) {
|
|
27
|
+
if (isBroadcastUnknownError(error)) {
|
|
28
|
+
const unknownMutation = updateMutationRecord(broadcastingMutation, "broadcast-unknown", options.nowUnixMs, {
|
|
29
|
+
attemptedTxid: options.built.txid,
|
|
30
|
+
attemptedWtxid: options.built.wtxid,
|
|
31
|
+
temporaryBuilderLockedOutpoints: options.built.temporaryBuilderLockedOutpoints,
|
|
32
|
+
});
|
|
33
|
+
nextState = await persistWalletMutationState({
|
|
34
|
+
state: upsertPendingMutation(nextState, unknownMutation),
|
|
35
|
+
provider: options.provider,
|
|
36
|
+
nowUnixMs: options.nowUnixMs,
|
|
37
|
+
paths: options.paths,
|
|
38
|
+
});
|
|
39
|
+
throw new Error(`${options.errorPrefix}_broadcast_unknown`);
|
|
40
|
+
}
|
|
41
|
+
await unlockTemporaryBuilderLocks(options.rpc, options.walletName, options.built.temporaryBuilderLockedOutpoints);
|
|
42
|
+
const canceledMutation = updateMutationRecord(broadcastingMutation, "canceled", options.nowUnixMs, {
|
|
43
|
+
attemptedTxid: options.built.txid,
|
|
44
|
+
attemptedWtxid: options.built.wtxid,
|
|
45
|
+
temporaryBuilderLockedOutpoints: [],
|
|
46
|
+
});
|
|
47
|
+
nextState = await persistWalletMutationState({
|
|
48
|
+
state: upsertPendingMutation(nextState, canceledMutation),
|
|
49
|
+
provider: options.provider,
|
|
50
|
+
nowUnixMs: options.nowUnixMs,
|
|
51
|
+
paths: options.paths,
|
|
52
|
+
});
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
await unlockTemporaryBuilderLocks(options.rpc, options.walletName, options.built.temporaryBuilderLockedOutpoints);
|
|
57
|
+
const accepted = options.afterAccepted === undefined
|
|
58
|
+
? {
|
|
59
|
+
state: upsertPendingMutation(nextState, updateMutationRecord(broadcastingMutation, "live", options.nowUnixMs, {
|
|
60
|
+
attemptedTxid: options.built.txid,
|
|
61
|
+
attemptedWtxid: options.built.wtxid,
|
|
62
|
+
temporaryBuilderLockedOutpoints: [],
|
|
63
|
+
})),
|
|
64
|
+
mutation: updateMutationRecord(broadcastingMutation, "live", options.nowUnixMs, {
|
|
65
|
+
attemptedTxid: options.built.txid,
|
|
66
|
+
attemptedWtxid: options.built.wtxid,
|
|
67
|
+
temporaryBuilderLockedOutpoints: [],
|
|
68
|
+
}),
|
|
69
|
+
status: "live",
|
|
70
|
+
}
|
|
71
|
+
: await options.afterAccepted({
|
|
72
|
+
state: nextState,
|
|
73
|
+
broadcastingMutation,
|
|
74
|
+
built: options.built,
|
|
75
|
+
nowUnixMs: options.nowUnixMs,
|
|
76
|
+
});
|
|
77
|
+
const persistedState = await persistWalletMutationState({
|
|
78
|
+
state: accepted.state,
|
|
79
|
+
provider: options.provider,
|
|
80
|
+
nowUnixMs: options.nowUnixMs,
|
|
81
|
+
paths: options.paths,
|
|
82
|
+
});
|
|
83
|
+
return {
|
|
84
|
+
state: persistedState,
|
|
85
|
+
mutation: accepted.mutation,
|
|
86
|
+
status: accepted.status,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { WalletReadContext } from "../read/index.js";
|
|
2
|
+
import type { WalletMutationReadyReadState } from "./types.js";
|
|
3
|
+
export declare function assertWalletMutationContextReady(context: WalletReadContext, errorPrefix: string): asserts context is WalletReadContext & WalletMutationReadyReadState & {
|
|
4
|
+
snapshot: NonNullable<WalletReadContext["snapshot"]>;
|
|
5
|
+
model: NonNullable<WalletReadContext["model"]>;
|
|
6
|
+
};
|
|
7
|
+
export declare function assertWalletBitcoinTransferContextReady(context: WalletReadContext, errorPrefix: string): asserts context is WalletReadContext & WalletMutationReadyReadState;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export function assertWalletMutationContextReady(context, errorPrefix) {
|
|
2
|
+
if (context.localState.availability === "uninitialized") {
|
|
3
|
+
throw new Error("wallet_uninitialized");
|
|
4
|
+
}
|
|
5
|
+
if (context.localState.clientPasswordReadiness === "setup-required") {
|
|
6
|
+
throw new Error("wallet_client_password_setup_required");
|
|
7
|
+
}
|
|
8
|
+
if (context.localState.clientPasswordReadiness === "migration-required") {
|
|
9
|
+
throw new Error("wallet_client_password_migration_required");
|
|
10
|
+
}
|
|
11
|
+
if (context.localState.unlockRequired) {
|
|
12
|
+
throw new Error("wallet_client_password_locked");
|
|
13
|
+
}
|
|
14
|
+
if (context.localState.availability === "local-state-corrupt") {
|
|
15
|
+
throw new Error("local-state-corrupt");
|
|
16
|
+
}
|
|
17
|
+
if (context.localState.availability !== "ready" || context.localState.state === null) {
|
|
18
|
+
throw new Error("wallet_secret_provider_unavailable");
|
|
19
|
+
}
|
|
20
|
+
if (context.bitcoind.health !== "ready") {
|
|
21
|
+
throw new Error(`${errorPrefix}_bitcoind_${context.bitcoind.health.replaceAll("-", "_")}`);
|
|
22
|
+
}
|
|
23
|
+
if (context.nodeHealth !== "synced") {
|
|
24
|
+
throw new Error(`${errorPrefix}_node_${context.nodeHealth.replaceAll("-", "_")}`);
|
|
25
|
+
}
|
|
26
|
+
if (context.indexer.health !== "synced" || context.snapshot === null || context.model === null) {
|
|
27
|
+
throw new Error(`${errorPrefix}_indexer_${context.indexer.health.replaceAll("-", "_")}`);
|
|
28
|
+
}
|
|
29
|
+
if (context.nodeStatus?.walletReplica?.proofStatus !== "ready") {
|
|
30
|
+
throw new Error(`${errorPrefix}_core_replica_not_ready`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export function assertWalletBitcoinTransferContextReady(context, errorPrefix) {
|
|
34
|
+
if (context.localState.availability === "uninitialized") {
|
|
35
|
+
throw new Error("wallet_uninitialized");
|
|
36
|
+
}
|
|
37
|
+
if (context.localState.clientPasswordReadiness === "setup-required") {
|
|
38
|
+
throw new Error("wallet_client_password_setup_required");
|
|
39
|
+
}
|
|
40
|
+
if (context.localState.clientPasswordReadiness === "migration-required") {
|
|
41
|
+
throw new Error("wallet_client_password_migration_required");
|
|
42
|
+
}
|
|
43
|
+
if (context.localState.unlockRequired) {
|
|
44
|
+
throw new Error("wallet_client_password_locked");
|
|
45
|
+
}
|
|
46
|
+
if (context.localState.availability === "local-state-corrupt") {
|
|
47
|
+
throw new Error("local-state-corrupt");
|
|
48
|
+
}
|
|
49
|
+
if (context.localState.availability !== "ready" || context.localState.state === null) {
|
|
50
|
+
throw new Error("wallet_secret_provider_unavailable");
|
|
51
|
+
}
|
|
52
|
+
if (context.bitcoind.health !== "ready") {
|
|
53
|
+
throw new Error(`${errorPrefix}_bitcoind_${context.bitcoind.health.replaceAll("-", "_")}`);
|
|
54
|
+
}
|
|
55
|
+
if (context.nodeHealth !== "synced") {
|
|
56
|
+
throw new Error(`${errorPrefix}_node_${context.nodeHealth.replaceAll("-", "_")}`);
|
|
57
|
+
}
|
|
58
|
+
if (context.nodeStatus?.walletReplica?.proofStatus !== "ready") {
|
|
59
|
+
throw new Error(`${errorPrefix}_core_replica_not_ready`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { PendingMutationRecord, WalletStateV1 } from "../types.js";
|
|
2
|
+
import { type WalletMutationFeeSelection, type WalletMutationFeeSummary } from "./fee.js";
|
|
3
|
+
import type { FixedWalletInput, WalletMutationRpcClient } from "./types.js";
|
|
4
|
+
export declare function loadAttemptedMutationFixedInputs(options: {
|
|
5
|
+
rpc: Pick<WalletMutationRpcClient, "getTransaction" | "getRawTransaction">;
|
|
6
|
+
walletName: string;
|
|
7
|
+
mutation: PendingMutationRecord;
|
|
8
|
+
}): Promise<FixedWalletInput[] | null>;
|
|
9
|
+
export declare function resolvePendingMutationReuseDecision(options: {
|
|
10
|
+
rpc: Pick<WalletMutationRpcClient, "getMempoolEntry" | "getTransaction" | "getRawTransaction">;
|
|
11
|
+
walletName: string;
|
|
12
|
+
mutation: PendingMutationRecord;
|
|
13
|
+
nextFeeSelection: WalletMutationFeeSelection;
|
|
14
|
+
}): Promise<{
|
|
15
|
+
reuseExisting: boolean;
|
|
16
|
+
fees: WalletMutationFeeSummary;
|
|
17
|
+
replacementFixedInputs: FixedWalletInput[] | null;
|
|
18
|
+
}>;
|
|
19
|
+
export declare function mergeFixedWalletInputs(fixedInputs: readonly FixedWalletInput[], replacementInputs: readonly FixedWalletInput[] | null): FixedWalletInput[];
|
|
20
|
+
export interface WalletMutationReconcileResult {
|
|
21
|
+
state: WalletStateV1;
|
|
22
|
+
mutation: PendingMutationRecord;
|
|
23
|
+
resolution: "confirmed" | "live" | "repair-required" | "not-seen" | "continue";
|
|
24
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { resolvePendingMutationFeeSummary } from "./fee.js";
|
|
2
|
+
import { outpointKey } from "./primitives.js";
|
|
3
|
+
export async function loadAttemptedMutationFixedInputs(options) {
|
|
4
|
+
if (options.mutation.attemptedTxid === null) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
const txid = options.mutation.attemptedTxid;
|
|
8
|
+
let decoded = null;
|
|
9
|
+
if (options.rpc.getTransaction !== undefined) {
|
|
10
|
+
try {
|
|
11
|
+
const walletTx = await options.rpc.getTransaction(options.walletName, txid);
|
|
12
|
+
decoded = walletTx.decoded ?? null;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
decoded = null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (decoded === null && options.rpc.getRawTransaction !== undefined) {
|
|
19
|
+
try {
|
|
20
|
+
decoded = await options.rpc.getRawTransaction(txid, true);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
decoded = null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (decoded === null) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const fixedInputs = decoded.vin
|
|
30
|
+
.filter((input) => typeof input.txid === "string" && typeof input.vout === "number")
|
|
31
|
+
.map((input) => ({
|
|
32
|
+
txid: input.txid,
|
|
33
|
+
vout: input.vout,
|
|
34
|
+
}));
|
|
35
|
+
return fixedInputs.length > 0 ? fixedInputs : null;
|
|
36
|
+
}
|
|
37
|
+
export async function resolvePendingMutationReuseDecision(options) {
|
|
38
|
+
const fees = await resolvePendingMutationFeeSummary({
|
|
39
|
+
rpc: options.rpc,
|
|
40
|
+
mutation: options.mutation,
|
|
41
|
+
});
|
|
42
|
+
if (options.mutation.status === "confirmed"
|
|
43
|
+
|| options.nextFeeSelection.feeRateSatVb <= fees.feeRateSatVb) {
|
|
44
|
+
return {
|
|
45
|
+
reuseExisting: true,
|
|
46
|
+
fees,
|
|
47
|
+
replacementFixedInputs: null,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
reuseExisting: false,
|
|
52
|
+
fees,
|
|
53
|
+
replacementFixedInputs: await loadAttemptedMutationFixedInputs({
|
|
54
|
+
rpc: options.rpc,
|
|
55
|
+
walletName: options.walletName,
|
|
56
|
+
mutation: options.mutation,
|
|
57
|
+
}),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export function mergeFixedWalletInputs(fixedInputs, replacementInputs) {
|
|
61
|
+
if (replacementInputs === null || replacementInputs.length === 0) {
|
|
62
|
+
return [...fixedInputs];
|
|
63
|
+
}
|
|
64
|
+
const merged = new Map();
|
|
65
|
+
for (const input of fixedInputs) {
|
|
66
|
+
merged.set(outpointKey(input), { txid: input.txid, vout: input.vout });
|
|
67
|
+
}
|
|
68
|
+
for (const input of replacementInputs) {
|
|
69
|
+
merged.set(outpointKey(input), { txid: input.txid, vout: input.vout });
|
|
70
|
+
}
|
|
71
|
+
return [...merged.values()];
|
|
72
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { WalletPrompter } from "../../lifecycle.js";
|
|
2
|
+
import type { WalletRegisterRpcClient } from "./intent.js";
|
|
3
|
+
import type { RegisterResolvedSummary } from "./result.js";
|
|
4
|
+
export declare function findCompetingRootRegistrationTxids(rpc: WalletRegisterRpcClient, domainName: string): Promise<string[]>;
|
|
5
|
+
export declare function confirmRootRegistration(prompter: WalletPrompter, domainName: string, resolved: RegisterResolvedSummary, competitorVisible: boolean, assumeYes?: boolean): Promise<void>;
|
|
6
|
+
export declare function confirmSubdomainRegistration(prompter: WalletPrompter, domainName: string, resolved: RegisterResolvedSummary, assumeYes?: boolean): Promise<void>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { formatCogAmount } from "../common.js";
|
|
2
|
+
import { confirmTypedAcknowledgement, confirmYesNo } from "../confirm.js";
|
|
3
|
+
import { extractOpReturnPayloadFromScriptHex } from "./plan.js";
|
|
4
|
+
import { serializeDomainReg } from "../../cogop/index.js";
|
|
5
|
+
function describeRegisterEconomicEffect(summary) {
|
|
6
|
+
if (summary.economicEffect.kind === "treasury-payment") {
|
|
7
|
+
return `send ${summary.economicEffect.amount.toString()} sats to the Cogcoin treasury.`;
|
|
8
|
+
}
|
|
9
|
+
return `burn ${formatCogAmount(summary.economicEffect.amount)} from the parent owner.`;
|
|
10
|
+
}
|
|
11
|
+
function writeRegisterResolvedSummary(prompter, summary) {
|
|
12
|
+
prompter.writeLine(`Resolved path: ${summary.path} registration.`);
|
|
13
|
+
if (summary.parentDomainName !== null) {
|
|
14
|
+
prompter.writeLine(`Resolved parent: ${summary.parentDomainName}.`);
|
|
15
|
+
}
|
|
16
|
+
prompter.writeLine(`Resolved sender: ${summary.sender.selector} (${summary.sender.address})`);
|
|
17
|
+
prompter.writeLine(`Economic effect: ${describeRegisterEconomicEffect(summary)}`);
|
|
18
|
+
}
|
|
19
|
+
export async function findCompetingRootRegistrationTxids(rpc, domainName) {
|
|
20
|
+
const targetPayloadHex = Buffer.from(serializeDomainReg(domainName).opReturnData).toString("hex");
|
|
21
|
+
const txids = await rpc.getRawMempool();
|
|
22
|
+
const competitors = [];
|
|
23
|
+
for (const txid of txids) {
|
|
24
|
+
const transaction = await rpc.getRawTransaction(txid, true).catch(() => null);
|
|
25
|
+
if (transaction === null) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
const matches = transaction.vout.some((output) => {
|
|
29
|
+
const scriptHex = output.scriptPubKey?.hex;
|
|
30
|
+
if (scriptHex == null) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
const payload = extractOpReturnPayloadFromScriptHex(scriptHex);
|
|
34
|
+
return payload !== null && Buffer.from(payload).toString("hex") === targetPayloadHex;
|
|
35
|
+
});
|
|
36
|
+
if (matches) {
|
|
37
|
+
competitors.push(txid);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return competitors;
|
|
41
|
+
}
|
|
42
|
+
export async function confirmRootRegistration(prompter, domainName, resolved, competitorVisible, assumeYes = false) {
|
|
43
|
+
writeRegisterResolvedSummary(prompter, resolved);
|
|
44
|
+
prompter.writeLine(competitorVisible
|
|
45
|
+
? `This is a root-domain race for "${domainName}".`
|
|
46
|
+
: `You are registering the root domain "${domainName}".`);
|
|
47
|
+
prompter.writeLine("Root domains contain no hyphen. Hyphenated names are subdomains and must not use this flow.");
|
|
48
|
+
prompter.writeLine("If another valid registration confirms first, you may still pay BTC and receive no domain.");
|
|
49
|
+
await confirmTypedAcknowledgement(prompter, {
|
|
50
|
+
assumeYes,
|
|
51
|
+
expected: domainName,
|
|
52
|
+
prompt: "Type the domain name to continue: ",
|
|
53
|
+
errorCode: "wallet_register_confirmation_rejected",
|
|
54
|
+
requiresTtyErrorCode: "wallet_register_requires_tty",
|
|
55
|
+
typedAckRequiredErrorCode: "wallet_register_typed_ack_required",
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
export async function confirmSubdomainRegistration(prompter, domainName, resolved, assumeYes = false) {
|
|
59
|
+
writeRegisterResolvedSummary(prompter, resolved);
|
|
60
|
+
prompter.writeLine(`You are registering the subdomain "${domainName}".`);
|
|
61
|
+
await confirmYesNo(prompter, "This publishes a subdomain registration burn.", {
|
|
62
|
+
assumeYes,
|
|
63
|
+
errorCode: "wallet_register_confirmation_rejected",
|
|
64
|
+
requiresTtyErrorCode: "wallet_register_requires_tty",
|
|
65
|
+
});
|
|
66
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { WalletRuntimePaths } from "../../runtime.js";
|
|
2
|
+
import type { WalletSecretProvider } from "../../state/provider.js";
|
|
3
|
+
import type { PendingMutationRecord, WalletStateV1 } from "../../types.js";
|
|
4
|
+
import type { WalletReadContext } from "../../read/index.js";
|
|
5
|
+
import { type MutationSender, type WalletMutationFeeSelection } from "../common.js";
|
|
6
|
+
import type { WalletRegisterRpcClient } from "./intent.js";
|
|
7
|
+
export declare function reserveLocalDomainRecord(options: {
|
|
8
|
+
state: WalletStateV1;
|
|
9
|
+
domainName: string;
|
|
10
|
+
sender: MutationSender;
|
|
11
|
+
nowUnixMs: number;
|
|
12
|
+
}): WalletStateV1;
|
|
13
|
+
export declare function getMutationStatusAfterAcceptance(options: {
|
|
14
|
+
snapshot: WalletReadContext["snapshot"];
|
|
15
|
+
domainName: string;
|
|
16
|
+
senderScriptPubKeyHex: string;
|
|
17
|
+
}): "live" | "confirmed";
|
|
18
|
+
export declare function createRegisterDraftMutation(options: {
|
|
19
|
+
domainName: string;
|
|
20
|
+
parentDomainName: string | null;
|
|
21
|
+
sender: MutationSender;
|
|
22
|
+
registerKind: "root" | "subdomain";
|
|
23
|
+
intentFingerprintHex: string;
|
|
24
|
+
nowUnixMs: number;
|
|
25
|
+
feeSelection: WalletMutationFeeSelection;
|
|
26
|
+
existing?: PendingMutationRecord | null;
|
|
27
|
+
}): PendingMutationRecord;
|
|
28
|
+
export declare function reconcilePendingRegisterMutation(options: {
|
|
29
|
+
state: WalletStateV1;
|
|
30
|
+
mutation: PendingMutationRecord;
|
|
31
|
+
provider: WalletSecretProvider;
|
|
32
|
+
nowUnixMs: number;
|
|
33
|
+
paths: WalletRuntimePaths;
|
|
34
|
+
rpc: WalletRegisterRpcClient;
|
|
35
|
+
walletName: string;
|
|
36
|
+
context: WalletReadContext;
|
|
37
|
+
sender: MutationSender;
|
|
38
|
+
}): Promise<{
|
|
39
|
+
state: WalletStateV1;
|
|
40
|
+
mutation: PendingMutationRecord;
|
|
41
|
+
resolution: "confirmed" | "live" | "repair-required" | "not-seen" | "continue";
|
|
42
|
+
}>;
|