@cogcoin/client 0.5.12 → 0.5.13

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.
@@ -8,7 +8,7 @@ import { resolveWalletRuntimePathsForTesting } from "../runtime.js";
8
8
  import { createDefaultWalletSecretProvider, } from "../state/provider.js";
9
9
  import { serializeRepCommit, serializeRepRevoke, validateDomainName, } from "../cogop/index.js";
10
10
  import { openWalletReadContext } from "../read/index.js";
11
- import { assertWalletMutationContextReady, buildWalletMutationTransaction, formatCogAmount, isAlreadyAcceptedError, isBroadcastUnknownError, pauseMiningForWalletMutation, saveWalletStatePreservingUnlock, unlockTemporaryBuilderLocks, updateMutationRecord, } from "./common.js";
11
+ import { assertFixedInputPrefixMatches, assertFundingInputsAfterFixedPrefix, assertWalletMutationContextReady, buildWalletMutationTransaction, formatCogAmount, isAlreadyAcceptedError, isBroadcastUnknownError, outpointKey, pauseMiningForWalletMutation, saveWalletStatePreservingUnlock, unlockTemporaryBuilderLocks, updateMutationRecord, } from "./common.js";
12
12
  import { confirmTypedAcknowledgement as confirmSharedTypedAcknowledgement, confirmYesNo as confirmSharedYesNo, } from "./confirm.js";
13
13
  import { getCanonicalIdentitySelector } from "./identity-selector.js";
14
14
  import { findPendingMutationByIntent, upsertPendingMutation } from "./journal.js";
@@ -162,9 +162,8 @@ function buildPlanForReputationOperation(options) {
162
162
  return {
163
163
  sender: options.sender,
164
164
  changeAddress: options.state.funding.address,
165
- inputs: [
165
+ fixedInputs: [
166
166
  { txid: anchorUtxo.txid, vout: anchorUtxo.vout },
167
- ...fundingUtxos.map((entry) => ({ txid: entry.txid, vout: entry.vout })),
168
167
  ],
169
168
  outputs: [
170
169
  { data: Buffer.from(options.opReturnData).toString("hex") },
@@ -175,6 +174,7 @@ function buildPlanForReputationOperation(options) {
175
174
  expectedAnchorScriptHex: options.sender.scriptPubKeyHex,
176
175
  expectedAnchorValueSats: BigInt(options.state.anchorValueSats),
177
176
  allowedFundingScriptPubKeyHex: options.state.funding.scriptPubKeyHex,
177
+ eligibleFundingOutpointKeys: new Set(fundingUtxos.map((entry) => outpointKey({ txid: entry.txid, vout: entry.vout }))),
178
178
  errorPrefix: options.errorPrefix,
179
179
  };
180
180
  }
@@ -184,14 +184,17 @@ function validateFundedDraft(decoded, funded, plan) {
184
184
  if (inputs.length === 0) {
185
185
  throw new Error(`${plan.errorPrefix}_missing_sender_input`);
186
186
  }
187
+ assertFixedInputPrefixMatches(inputs, plan.fixedInputs, `${plan.errorPrefix}_sender_input_mismatch`);
187
188
  if (inputs[0]?.prevout?.scriptPubKey?.hex !== plan.sender.scriptPubKeyHex) {
188
189
  throw new Error(`${plan.errorPrefix}_sender_input_mismatch`);
189
190
  }
190
- for (let index = 1; index < inputs.length; index += 1) {
191
- if (inputs[index]?.prevout?.scriptPubKey?.hex !== plan.allowedFundingScriptPubKeyHex) {
192
- throw new Error(`${plan.errorPrefix}_unexpected_funding_input`);
193
- }
194
- }
191
+ assertFundingInputsAfterFixedPrefix({
192
+ inputs,
193
+ fixedInputs: plan.fixedInputs,
194
+ allowedFundingScriptPubKeyHex: plan.allowedFundingScriptPubKeyHex,
195
+ eligibleFundingOutpointKeys: plan.eligibleFundingOutpointKeys,
196
+ errorCode: `${plan.errorPrefix}_unexpected_funding_input`,
197
+ });
195
198
  if (outputs[0]?.scriptPubKey?.hex !== plan.expectedOpReturnScriptHex) {
196
199
  throw new Error(`${plan.errorPrefix}_opreturn_mismatch`);
197
200
  }
@@ -218,6 +221,7 @@ async function buildTransaction(options) {
218
221
  return buildWalletMutationTransaction({
219
222
  rpc: options.rpc,
220
223
  walletName: options.walletName,
224
+ state: options.state,
221
225
  plan: options.plan,
222
226
  validateFundedDraft,
223
227
  finalizeErrorCode: `${options.plan.errorPrefix}_finalize_failed`,
@@ -635,6 +639,7 @@ async function submitReputationMutation(options) {
635
639
  const built = await buildTransaction({
636
640
  rpc,
637
641
  walletName,
642
+ state: nextState,
638
643
  plan: buildPlanForReputationOperation({
639
644
  state: nextState,
640
645
  allUtxos: await rpc.listUnspent(walletName, 1),
@@ -142,6 +142,8 @@ export interface WalletStateV1 {
142
142
  walletRootId: string;
143
143
  network: WalletNetwork;
144
144
  anchorValueSats: number;
145
+ proactiveReserveSats: number;
146
+ proactiveReserveOutpoints: OutpointRecord[];
145
147
  nextDedicatedIndex: number;
146
148
  fundingIndex: 0;
147
149
  mnemonic: {
@@ -191,6 +193,8 @@ export interface PortableWalletArchivePayloadV1 {
191
193
  walletRootId: string;
192
194
  network: WalletNetwork;
193
195
  anchorValueSats: number;
196
+ proactiveReserveSats: number;
197
+ proactiveReserveOutpoints: OutpointRecord[];
194
198
  nextDedicatedIndex: number;
195
199
  fundingIndex: 0;
196
200
  mnemonic: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cogcoin/client",
3
- "version": "0.5.12",
3
+ "version": "0.5.13",
4
4
  "description": "Store-backed Cogcoin client with wallet flows, SQLite persistence, and managed Bitcoin Core integration.",
5
5
  "license": "MIT",
6
6
  "type": "module",