@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.
- package/README.md +1 -1
- package/dist/bitcoind/client/sync-engine.js +7 -2
- package/dist/wallet/archive.js +10 -8
- package/dist/wallet/coin-control.d.ts +41 -0
- package/dist/wallet/coin-control.js +365 -0
- package/dist/wallet/lifecycle.js +39 -2
- package/dist/wallet/mining/runner.js +46 -44
- package/dist/wallet/read/context.js +15 -6
- package/dist/wallet/reset.js +2 -0
- package/dist/wallet/state/storage.js +5 -4
- package/dist/wallet/tx/anchor.js +36 -51
- package/dist/wallet/tx/cog.js +19 -12
- package/dist/wallet/tx/common.d.ts +41 -10
- package/dist/wallet/tx/common.js +112 -5
- package/dist/wallet/tx/domain-admin.js +13 -8
- package/dist/wallet/tx/domain-market.js +19 -12
- package/dist/wallet/tx/field.js +21 -18
- package/dist/wallet/tx/register.js +17 -12
- package/dist/wallet/tx/reputation.js +13 -8
- package/dist/wallet/types.d.ts +4 -0
- package/package.json +1 -1
|
@@ -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
|
-
|
|
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
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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),
|
package/dist/wallet/types.d.ts
CHANGED
|
@@ -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