@hardkas/toolkit 0.11.2-alpha → 0.11.4-alpha
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/dist/fee-estimator.d.ts +9 -0
- package/dist/fee-estimator.d.ts.map +1 -0
- package/dist/fee-estimator.js +32 -0
- package/dist/fee-estimator.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/indexer.d.ts +1 -0
- package/dist/indexer.d.ts.map +1 -1
- package/dist/indexer.js +7 -0
- package/dist/indexer.js.map +1 -1
- package/dist/query-api.d.ts +22 -0
- package/dist/query-api.d.ts.map +1 -0
- package/dist/query-api.js +116 -0
- package/dist/query-api.js.map +1 -0
- package/dist/snapshot/serialization.d.ts +0 -9
- package/dist/snapshot/serialization.d.ts.map +1 -1
- package/dist/snapshot/serialization.js +0 -12
- package/dist/snapshot/serialization.js.map +1 -1
- package/dist/subscriptions.d.ts +22 -0
- package/dist/subscriptions.d.ts.map +1 -0
- package/dist/subscriptions.js +91 -0
- package/dist/subscriptions.js.map +1 -0
- package/dist/wallet.d.ts +71 -1
- package/dist/wallet.d.ts.map +1 -1
- package/dist/wallet.js +296 -44
- package/dist/wallet.js.map +1 -1
- package/package.json +24 -9
- package/.turbo/turbo-build.log +0 -4
- package/src/dag/consensus.ts +0 -150
- package/src/dag/index.ts +0 -73
- package/src/dag/store.ts +0 -40
- package/src/dag/topology.ts +0 -108
- package/src/dag/types.ts +0 -20
- package/src/index.ts +0 -10
- package/src/indexer.ts +0 -134
- package/src/jobs.ts +0 -63
- package/src/payment.ts +0 -100
- package/src/silver/index.ts +0 -102
- package/src/silver/templates.ts +0 -27
- package/src/silver/types.ts +0 -37
- package/src/snapshot/backends/FsSnapshotBackend.ts +0 -100
- package/src/snapshot/backends/MemorySnapshotBackend.ts +0 -65
- package/src/snapshot/index.ts +0 -102
- package/src/snapshot/serialization.ts +0 -35
- package/src/snapshot/types.ts +0 -45
- package/src/stores/invoice-store.ts +0 -62
- package/src/stores/utxo-control-store.ts +0 -78
- package/src/utxos.ts +0 -451
- package/src/wallet.ts +0 -158
- package/test/silver.test.ts +0 -59
- package/test/snapshot.test.ts +0 -99
- package/test/toolkit.test.ts +0 -140
- package/tsconfig.json +0 -9
- package/vitest.config.ts +0 -8
package/dist/wallet.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { WalletManagerImpl, WalletStateStoreJson, AddressManager } from '@hardkas/accounts';
|
|
2
2
|
import { WalletQuery } from '@hardkas/query';
|
|
3
|
-
import { buildPaymentPlan } from '@hardkas/tx-builder';
|
|
3
|
+
import { buildPaymentPlan, toTxBuilderUtxo } from '@hardkas/tx-builder';
|
|
4
4
|
import { WalletUtxoApi } from './utxos.js';
|
|
5
5
|
import { UtxoControlStore } from './stores/utxo-control-store.js';
|
|
6
|
-
import { logger, metrics
|
|
6
|
+
import { logger, metrics } from '@hardkas/observability';
|
|
7
|
+
import { WalletSubscriptionManager } from './subscriptions.js';
|
|
8
|
+
import { calculateDynamicFeeRate } from './fee-estimator.js';
|
|
7
9
|
metrics.register({
|
|
8
10
|
name: "wallet_tx_generated_total",
|
|
9
11
|
help: "Total tx generated by wallet",
|
|
@@ -27,30 +29,66 @@ export class WalletToolkit {
|
|
|
27
29
|
addressManager;
|
|
28
30
|
walletQuery;
|
|
29
31
|
_utxosApi;
|
|
32
|
+
_subscriptionManager;
|
|
30
33
|
constructor(name, store, options) {
|
|
31
34
|
this.name = name;
|
|
32
35
|
this.store = store;
|
|
33
36
|
this.options = options;
|
|
34
37
|
this.walletManager = new WalletManagerImpl();
|
|
35
38
|
this.addressManager = AddressManager;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
let provider = options.provider;
|
|
40
|
+
if (!provider && options.rpc) {
|
|
41
|
+
provider = {
|
|
42
|
+
source: "rpc",
|
|
43
|
+
async getBalances(addresses) {
|
|
44
|
+
const res = {};
|
|
45
|
+
for (const addr of addresses) {
|
|
46
|
+
const bal = await options.rpc.getBalanceByAddress(addr);
|
|
47
|
+
res[addr] = bal.balanceSompi;
|
|
48
|
+
}
|
|
49
|
+
return res;
|
|
50
|
+
},
|
|
51
|
+
async getUtxos(addresses) {
|
|
52
|
+
const res = {};
|
|
53
|
+
for (const addr of addresses) {
|
|
54
|
+
const utxos = await options.rpc.getUtxosByAddress(addr);
|
|
55
|
+
res[addr] = utxos.map((u) => ({
|
|
56
|
+
transactionId: u.outpoint.transactionId,
|
|
57
|
+
outputIndex: u.outpoint.index,
|
|
58
|
+
amountSompi: u.amountSompi,
|
|
59
|
+
scriptPublicKey: u.scriptPublicKey,
|
|
60
|
+
address: u.address,
|
|
61
|
+
blockDaaScore: u.blockDaaScore,
|
|
62
|
+
isCoinbase: u.isCoinbase
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
return res;
|
|
66
|
+
},
|
|
67
|
+
async getHistory() {
|
|
68
|
+
return { items: [] };
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
else if (!provider) {
|
|
73
|
+
provider = {
|
|
74
|
+
source: "dummy",
|
|
75
|
+
async getBalances() { return {}; },
|
|
76
|
+
async getUtxos() { return {}; },
|
|
77
|
+
async getHistory() { return { items: [] }; }
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
this.walletQuery = new WalletQuery({ provider, network: options.network || "simnet" });
|
|
43
81
|
const utxoControlPath = options.storePath
|
|
44
82
|
? options.storePath.replace('.json', '-utxo-control.json')
|
|
45
83
|
: 'default-utxo-control.json';
|
|
46
84
|
const utxoStore = new UtxoControlStore(utxoControlPath);
|
|
47
85
|
this._utxosApi = new WalletUtxoApi(async () => {
|
|
48
|
-
const addr = await this.
|
|
86
|
+
const addr = await this.receive();
|
|
49
87
|
const res = await this.walletQuery.getUtxos([addr]);
|
|
50
88
|
if (!res.ok)
|
|
51
89
|
throw new Error(res.error || "Degraded query result");
|
|
52
90
|
return res.utxos[addr] || [];
|
|
53
|
-
}, async () => this.
|
|
91
|
+
}, async () => this.receive(), async (inputs, outputs) => BigInt(inputs * 1000 + outputs * 1000), // Dummy fee estimation
|
|
54
92
|
utxoStore);
|
|
55
93
|
}
|
|
56
94
|
static open(name, options = {}) {
|
|
@@ -60,7 +98,7 @@ export class WalletToolkit {
|
|
|
60
98
|
async create() {
|
|
61
99
|
this.walletManager.create({ walletId: this.name });
|
|
62
100
|
}
|
|
63
|
-
async
|
|
101
|
+
async receive() {
|
|
64
102
|
// High level facade: gets receive address
|
|
65
103
|
const seedRef = this.walletManager.getSeedRef(this.name);
|
|
66
104
|
return this.addressManager.derive({
|
|
@@ -72,64 +110,278 @@ export class WalletToolkit {
|
|
|
72
110
|
}).address;
|
|
73
111
|
}
|
|
74
112
|
async balance() {
|
|
75
|
-
const addr = await this.
|
|
113
|
+
const addr = await this.receive();
|
|
76
114
|
return (await this.walletQuery.getBalance([addr]));
|
|
77
115
|
}
|
|
78
116
|
get utxos() {
|
|
79
117
|
return this._utxosApi;
|
|
80
118
|
}
|
|
81
119
|
async history() {
|
|
82
|
-
const addr = await this.
|
|
83
|
-
|
|
120
|
+
const addr = await this.receive();
|
|
121
|
+
// Return local observed history (best-effort locally + remote if available)
|
|
122
|
+
const remoteHistory = await this.walletQuery.getHistory({ addresses: [addr] });
|
|
123
|
+
// Enhance with local mock/artifacts if needed, but per specs:
|
|
124
|
+
// "txs enviadas por HardKAS, UTXO changes observados, receipts locales"
|
|
125
|
+
// For now, we return remoteHistory items + potentially local state from utxos store
|
|
126
|
+
const items = remoteHistory?.items || remoteHistory || [];
|
|
127
|
+
return items;
|
|
128
|
+
}
|
|
129
|
+
async watch(cb) {
|
|
130
|
+
if (!this.options.rpc || !this.options.rpc.subscribeToUtxosChanged) {
|
|
131
|
+
throw new Error("RPC client with subscription support is required for watch()");
|
|
132
|
+
}
|
|
133
|
+
if (!this._subscriptionManager) {
|
|
134
|
+
this._subscriptionManager = new WalletSubscriptionManager(this.options.rpc, async () => this.receive());
|
|
135
|
+
}
|
|
136
|
+
return this._subscriptionManager.watch(cb);
|
|
84
137
|
}
|
|
85
138
|
async estimateFee(opts) {
|
|
86
|
-
const addr = await this.
|
|
139
|
+
const addr = await this.receive();
|
|
87
140
|
const availableUtxos = await this.utxos.list();
|
|
141
|
+
let finalFeeRate = opts.feeRate;
|
|
142
|
+
let evidence = "heuristic";
|
|
143
|
+
let mempoolSize;
|
|
144
|
+
if (!finalFeeRate) {
|
|
145
|
+
const dynamic = await calculateDynamicFeeRate(this.options.rpc, opts.priority || "normal");
|
|
146
|
+
finalFeeRate = dynamic.feeRate;
|
|
147
|
+
evidence = dynamic.evidence;
|
|
148
|
+
mempoolSize = dynamic.mempoolSize;
|
|
149
|
+
}
|
|
150
|
+
// Fetch current DAA score for coinbase maturity filtering
|
|
151
|
+
let virtualDaaScore;
|
|
152
|
+
let networkId;
|
|
153
|
+
if (this.options.rpc?.getBlockDagInfo) {
|
|
154
|
+
try {
|
|
155
|
+
const dagInfo = await this.options.rpc.getBlockDagInfo();
|
|
156
|
+
virtualDaaScore = dagInfo.virtualDaaScore;
|
|
157
|
+
networkId = dagInfo.networkId;
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
// If DAG info unavailable, proceed without maturity filtering
|
|
161
|
+
}
|
|
162
|
+
}
|
|
88
163
|
const plan = buildPaymentPlan({
|
|
89
164
|
fromAddress: addr,
|
|
90
165
|
outputs: [{ address: opts.to, amountSompi: opts.amount }],
|
|
91
166
|
availableUtxos: availableUtxos,
|
|
92
|
-
feeRateSompiPerMass:
|
|
93
|
-
changeAddress: addr
|
|
167
|
+
feeRateSompiPerMass: finalFeeRate || 1n,
|
|
168
|
+
changeAddress: addr,
|
|
169
|
+
coinbaseMaturity: networkId === "mainnet" ? 1000n : 100n,
|
|
170
|
+
...(virtualDaaScore !== undefined ? { virtualDaaScore } : {}),
|
|
171
|
+
...(networkId !== undefined ? { networkId } : {})
|
|
94
172
|
});
|
|
173
|
+
const exactMass = BigInt(plan.estimatedMass);
|
|
95
174
|
return {
|
|
96
175
|
fee: plan.estimatedFeeSompi,
|
|
176
|
+
feeRate: finalFeeRate || 1n,
|
|
177
|
+
estimatedMass: exactMass,
|
|
178
|
+
estimatedFee: plan.estimatedFeeSompi,
|
|
97
179
|
totalOut: opts.amount + plan.estimatedFeeSompi,
|
|
98
|
-
plan
|
|
180
|
+
plan,
|
|
181
|
+
evidence,
|
|
182
|
+
...(mempoolSize !== undefined ? { mempoolSize } : {})
|
|
99
183
|
};
|
|
100
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* @deprecated Use hardkas.tx.plan directly or the specific operation helpers like send() or consolidate()
|
|
187
|
+
*/
|
|
101
188
|
async planSend(opts) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
189
|
+
return {
|
|
190
|
+
message: "This is a stub, as requested by P61 audit. Real planning requires UTXO orchestration."
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* @deprecated sendSimulated is moved to testing patterns. Use hardkas.localnet.mine() and standard send() flows.
|
|
195
|
+
*/
|
|
196
|
+
async sendSimulated(opts) {
|
|
197
|
+
return `sim_tx_${Date.now()}`;
|
|
198
|
+
}
|
|
199
|
+
async signAndBroadcast(plan) {
|
|
200
|
+
if (!this.options.signer) {
|
|
201
|
+
const err = new Error("MISSING_SIGNER: WalletToolkit requires an explicit signer to sign transactions.");
|
|
202
|
+
err.code = "MISSING_SIGNER";
|
|
203
|
+
throw err;
|
|
107
204
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
logger.error("Wallet tx planning failed", { error: e.message });
|
|
111
|
-
throw e;
|
|
205
|
+
if (!this.options.rpc) {
|
|
206
|
+
throw new Error("RPC client is required for broadcast.");
|
|
112
207
|
}
|
|
208
|
+
const addr = await this.receive();
|
|
209
|
+
const fakeArtifact = {
|
|
210
|
+
schema: "hardkas.txPlan",
|
|
211
|
+
planId: "wallet-toolkit-inline",
|
|
212
|
+
networkId: this.options.network || "simnet",
|
|
213
|
+
mode: "real",
|
|
214
|
+
from: { address: addr },
|
|
215
|
+
to: { address: plan.outputs[0]?.address || addr },
|
|
216
|
+
amountSompi: plan.outputs.reduce((acc, out) => acc + BigInt(out.amountSompi), 0n).toString(),
|
|
217
|
+
estimatedFeeSompi: plan.estimatedFeeSompi.toString(),
|
|
218
|
+
inputs: plan.inputs,
|
|
219
|
+
outputs: plan.outputs,
|
|
220
|
+
change: plan.change,
|
|
221
|
+
};
|
|
222
|
+
const result = await (this.options.signer.signTxPlan
|
|
223
|
+
? this.options.signer.signTxPlan({ planArtifact: fakeArtifact })
|
|
224
|
+
: this.options.signer.signTransaction(fakeArtifact));
|
|
225
|
+
const rawTx = JSON.parse(result.signedTransaction.payload);
|
|
226
|
+
const submitRes = await this.options.rpc.submitTransaction(rawTx);
|
|
227
|
+
metrics.inc("wallet_tx_submitted_total");
|
|
228
|
+
logger.info("Wallet tx submitted successfully", { txId: submitRes.transactionId || result.txId });
|
|
229
|
+
// Return full artifact/evidence format
|
|
230
|
+
return {
|
|
231
|
+
txId: submitRes.transactionId || result.txId,
|
|
232
|
+
plan
|
|
233
|
+
};
|
|
113
234
|
}
|
|
114
|
-
async
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
235
|
+
async send(opts) {
|
|
236
|
+
return this.payMany({
|
|
237
|
+
outputs: [{ address: opts.to, amount: opts.amount }],
|
|
238
|
+
...(opts.priority !== undefined ? { priority: opts.priority } : {}),
|
|
239
|
+
...(opts.feeRate !== undefined ? { feeRate: opts.feeRate } : {})
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
async payMany(opts) {
|
|
243
|
+
const addr = await this.receive();
|
|
244
|
+
const availableUtxos = await this.utxos.list();
|
|
245
|
+
let finalFeeRate = opts.feeRate;
|
|
246
|
+
if (!finalFeeRate) {
|
|
247
|
+
const dynamic = await calculateDynamicFeeRate(this.options.rpc, opts.priority || "normal");
|
|
248
|
+
finalFeeRate = dynamic.feeRate;
|
|
249
|
+
}
|
|
250
|
+
// Fetch current DAA score for coinbase maturity filtering
|
|
251
|
+
let virtualDaaScore;
|
|
252
|
+
let networkId;
|
|
253
|
+
if (this.options.rpc?.getBlockDagInfo) {
|
|
254
|
+
try {
|
|
255
|
+
const dagInfo = await this.options.rpc.getBlockDagInfo();
|
|
256
|
+
virtualDaaScore = dagInfo.virtualDaaScore;
|
|
257
|
+
networkId = dagInfo.networkId;
|
|
258
|
+
}
|
|
259
|
+
catch {
|
|
260
|
+
// If DAG info unavailable, proceed without maturity filtering
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
const builderOutputs = opts.outputs.map(o => ({ address: o.address, amountSompi: o.amount }));
|
|
264
|
+
const mappedUtxos = availableUtxos.map(u => toTxBuilderUtxo(u));
|
|
265
|
+
const plan = buildPaymentPlan({
|
|
266
|
+
fromAddress: addr,
|
|
267
|
+
outputs: builderOutputs,
|
|
268
|
+
availableUtxos: mappedUtxos,
|
|
269
|
+
feeRateSompiPerMass: finalFeeRate || 1n,
|
|
270
|
+
changeAddress: addr,
|
|
271
|
+
coinbaseMaturity: networkId === "mainnet" ? 1000n : 100n,
|
|
272
|
+
...(virtualDaaScore !== undefined ? { virtualDaaScore } : {}),
|
|
273
|
+
...(networkId !== undefined ? { networkId } : {})
|
|
274
|
+
});
|
|
275
|
+
return this.signAndBroadcast(plan);
|
|
276
|
+
}
|
|
277
|
+
async sweep(opts) {
|
|
278
|
+
const addr = await this.receive();
|
|
279
|
+
let availableUtxos = await this.utxos.list();
|
|
280
|
+
if (availableUtxos.length === 0)
|
|
281
|
+
throw new Error("No UTXOs to sweep");
|
|
282
|
+
let finalFeeRate = opts.feeRate;
|
|
283
|
+
if (!finalFeeRate) {
|
|
284
|
+
const dynamic = await calculateDynamicFeeRate(this.options.rpc, opts.priority || "normal");
|
|
285
|
+
finalFeeRate = dynamic.feeRate;
|
|
286
|
+
}
|
|
287
|
+
// Filter immature coinbase UTXOs
|
|
288
|
+
if (this.options.rpc?.getBlockDagInfo) {
|
|
289
|
+
try {
|
|
290
|
+
const dagInfo = await this.options.rpc.getBlockDagInfo();
|
|
291
|
+
const virtualDaaScore = dagInfo.virtualDaaScore;
|
|
292
|
+
if (virtualDaaScore !== undefined) {
|
|
293
|
+
if (this.options.coinbaseMaturity === undefined) {
|
|
294
|
+
throw new Error("COINBASE_MATURITY_UNRESOLVED: WalletToolkit requires coinbaseMaturity to be explicitly provided");
|
|
295
|
+
}
|
|
296
|
+
const COINBASE_MATURITY = this.options.coinbaseMaturity;
|
|
297
|
+
availableUtxos = availableUtxos.filter((u) => {
|
|
298
|
+
if (u.isCoinbase && u.blockDaaScore !== undefined &&
|
|
299
|
+
(virtualDaaScore - BigInt(u.blockDaaScore)) < COINBASE_MATURITY) {
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
return true;
|
|
303
|
+
});
|
|
304
|
+
if (availableUtxos.length === 0)
|
|
305
|
+
throw new Error("No mature UTXOs to sweep");
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
catch (e) {
|
|
309
|
+
if (e.message?.includes("No mature UTXOs"))
|
|
310
|
+
throw e;
|
|
311
|
+
// If DAG info unavailable, proceed without maturity filtering
|
|
121
312
|
}
|
|
122
|
-
metrics.inc("wallet_tx_submitted_total");
|
|
123
|
-
logger.info("Wallet tx simulated successfully", { txid: hashStr });
|
|
124
|
-
span.end({ txid: hashStr });
|
|
125
|
-
return hashStr;
|
|
126
313
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
314
|
+
const { estimateTransactionMass } = await import("@hardkas/tx-builder");
|
|
315
|
+
const massRes = estimateTransactionMass({
|
|
316
|
+
inputCount: availableUtxos.length,
|
|
317
|
+
outputs: [{ address: opts.to }],
|
|
318
|
+
payloadBytes: 0,
|
|
319
|
+
hasChange: false
|
|
320
|
+
});
|
|
321
|
+
const fee = massRes.mass * (finalFeeRate || 1n);
|
|
322
|
+
const totalValue = availableUtxos.reduce((acc, u) => acc + BigInt(u.amountSompi), 0n);
|
|
323
|
+
const sendValue = totalValue - fee;
|
|
324
|
+
if (sendValue <= 0n) {
|
|
325
|
+
throw new Error("Insufficient funds to cover sweep fee");
|
|
132
326
|
}
|
|
327
|
+
const plan = {
|
|
328
|
+
inputs: availableUtxos,
|
|
329
|
+
outputs: [{ address: opts.to, amountSompi: sendValue }],
|
|
330
|
+
estimatedMass: massRes.mass,
|
|
331
|
+
estimatedFeeSompi: fee
|
|
332
|
+
};
|
|
333
|
+
return this.signAndBroadcast(plan);
|
|
334
|
+
}
|
|
335
|
+
async consolidate(opts) {
|
|
336
|
+
const addr = await this.receive();
|
|
337
|
+
const availableUtxos = await this.utxos.list();
|
|
338
|
+
const maxUtxos = opts.maxUtxos || 100;
|
|
339
|
+
if (availableUtxos.length <= 1) {
|
|
340
|
+
throw new Error("Not enough UTXOs to consolidate");
|
|
341
|
+
}
|
|
342
|
+
// Sort by smallest first to consolidate dust
|
|
343
|
+
const sortedUtxos = [...availableUtxos].sort((a, b) => {
|
|
344
|
+
const diff = BigInt(a.amountSompi) - BigInt(b.amountSompi);
|
|
345
|
+
return diff < 0n ? -1 : diff > 0n ? 1 : 0;
|
|
346
|
+
});
|
|
347
|
+
const selectedUtxos = sortedUtxos.slice(0, maxUtxos);
|
|
348
|
+
const toAddress = opts.to || addr;
|
|
349
|
+
let finalFeeRate = opts.feeRate;
|
|
350
|
+
if (!finalFeeRate) {
|
|
351
|
+
const dynamic = await calculateDynamicFeeRate(this.options.rpc, opts.priority || "normal");
|
|
352
|
+
finalFeeRate = dynamic.feeRate;
|
|
353
|
+
}
|
|
354
|
+
const { estimateTransactionMass } = await import("@hardkas/tx-builder");
|
|
355
|
+
const massRes = estimateTransactionMass({
|
|
356
|
+
inputCount: selectedUtxos.length,
|
|
357
|
+
outputs: [{ address: toAddress }],
|
|
358
|
+
payloadBytes: 0,
|
|
359
|
+
hasChange: false
|
|
360
|
+
});
|
|
361
|
+
const fee = massRes.mass * (finalFeeRate || 1n);
|
|
362
|
+
const totalValue = selectedUtxos.reduce((acc, u) => acc + BigInt(u.amountSompi), 0n);
|
|
363
|
+
const sendValue = totalValue - fee;
|
|
364
|
+
if (sendValue <= 0n) {
|
|
365
|
+
throw new Error("Insufficient funds to cover consolidate fee");
|
|
366
|
+
}
|
|
367
|
+
const plan = {
|
|
368
|
+
inputs: selectedUtxos,
|
|
369
|
+
outputs: [{ address: toAddress, amountSompi: sendValue }],
|
|
370
|
+
estimatedMass: massRes.mass,
|
|
371
|
+
estimatedFeeSompi: fee
|
|
372
|
+
};
|
|
373
|
+
return this.signAndBroadcast(plan);
|
|
374
|
+
}
|
|
375
|
+
async split(opts) {
|
|
376
|
+
if (opts.outputsCount <= 0)
|
|
377
|
+
throw new Error("outputsCount must be greater than 0");
|
|
378
|
+
const addr = await this.receive();
|
|
379
|
+
const outputs = Array(opts.outputsCount).fill({ address: addr, amount: opts.amountPerOutput });
|
|
380
|
+
return this.payMany({
|
|
381
|
+
outputs,
|
|
382
|
+
...(opts.priority !== undefined ? { priority: opts.priority } : {}),
|
|
383
|
+
...(opts.feeRate !== undefined ? { feeRate: opts.feeRate } : {})
|
|
384
|
+
});
|
|
133
385
|
}
|
|
134
386
|
}
|
|
135
387
|
//# sourceMappingURL=wallet.js.map
|
package/dist/wallet.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC5F,OAAO,EAAE,WAAW,EAAuB,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAA4B,gBAA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GAAG;YACT,MAAM,EAAE,aAAa;YACrB,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC;YACzD,aAAa,EAAE,OAAO,CAAC,IAAI;YAC3B,iBAAiB,EAAE,GAAG;SACzB,CAAC;QAEF,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAEM,KAAK,CAAC,KAAK,CAAC,IAAiG;QAChH,IAAI,IAAI,CAAC,YAAY,IAAI,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACnF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QAClC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC;QAC/F,OAAO,IAAI,CAAC,OAAO,CAAC;YAChB,OAAO;YACP,GAAG,CAAC,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACnE,GAAG,CAAC,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACnE,CAAC,CAAC;IACP,CAAC;CACJ"}
|
package/package.json
CHANGED
|
@@ -1,20 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hardkas/toolkit",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.4-alpha",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"require": "./dist/index.js",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
8
19
|
"dependencies": {
|
|
9
|
-
"@hardkas/observability": "0.11.
|
|
20
|
+
"@hardkas/observability": "0.11.4-alpha",
|
|
10
21
|
"fs-extra": "^11.2.0",
|
|
11
|
-
"@hardkas/accounts": "0.11.
|
|
12
|
-
"@hardkas/
|
|
13
|
-
"@hardkas/
|
|
14
|
-
"@hardkas/
|
|
15
|
-
"@hardkas/
|
|
16
|
-
"@hardkas/
|
|
17
|
-
"@hardkas/
|
|
22
|
+
"@hardkas/accounts": "0.11.4-alpha",
|
|
23
|
+
"@hardkas/jobs": "0.11.4-alpha",
|
|
24
|
+
"@hardkas/query": "0.11.4-alpha",
|
|
25
|
+
"@hardkas/kaspa-rpc": "0.11.4-alpha",
|
|
26
|
+
"@hardkas/query-store": "0.11.4-alpha",
|
|
27
|
+
"@hardkas/core": "0.11.4-alpha",
|
|
28
|
+
"@hardkas/artifacts": "0.11.4-alpha",
|
|
29
|
+
"@hardkas/tx-builder": "0.11.4-alpha"
|
|
18
30
|
},
|
|
19
31
|
"devDependencies": {
|
|
20
32
|
"@types/fs-extra": "^11.0.4",
|
|
@@ -22,6 +34,9 @@
|
|
|
22
34
|
"typescript": "^5.6.3",
|
|
23
35
|
"vitest": "^2.1.2"
|
|
24
36
|
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
25
40
|
"scripts": {
|
|
26
41
|
"build": "tsc",
|
|
27
42
|
"test": "vitest run"
|
package/.turbo/turbo-build.log
DELETED
package/src/dag/consensus.ts
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { LocalDagStore } from './store.js';
|
|
2
|
-
import { DAGTopology } from './topology.js';
|
|
3
|
-
import { DagBlock, DagStatistics } from './types.js';
|
|
4
|
-
|
|
5
|
-
export class ConsensusView {
|
|
6
|
-
// Memoize calculated blue scores to prevent exponential recursion
|
|
7
|
-
private blueScoreCache = new Map<string, number>();
|
|
8
|
-
|
|
9
|
-
public constructor(
|
|
10
|
-
private readonly store: LocalDagStore,
|
|
11
|
-
private readonly topology: DAGTopology
|
|
12
|
-
) {}
|
|
13
|
-
|
|
14
|
-
public clearCache(): void {
|
|
15
|
-
this.blueScoreCache.clear();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
public async blueScore(hash: string): Promise<number> {
|
|
19
|
-
// If provided explicitly in the payload, use it
|
|
20
|
-
const b = await this.topology.block(hash);
|
|
21
|
-
if (b.blueScore !== undefined) {
|
|
22
|
-
return b.blueScore;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (this.blueScoreCache.has(hash)) {
|
|
26
|
-
return this.blueScoreCache.get(hash)!;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (b.parents.length === 0) {
|
|
30
|
-
this.blueScoreCache.set(hash, 0);
|
|
31
|
-
return 0;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
let maxScore = 0;
|
|
35
|
-
for (const p of b.parents) {
|
|
36
|
-
try {
|
|
37
|
-
const score = await this.blueScore(p);
|
|
38
|
-
if (score > maxScore) maxScore = score;
|
|
39
|
-
} catch (e) {
|
|
40
|
-
// Ignore missing parents (orphans)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const calculatedScore = maxScore + 1;
|
|
45
|
-
this.blueScoreCache.set(hash, calculatedScore);
|
|
46
|
-
return calculatedScore;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
public async confirmations(hash: string): Promise<number> {
|
|
50
|
-
const isOrphan = await this.isOrphan(hash);
|
|
51
|
-
if (isOrphan) return 0;
|
|
52
|
-
|
|
53
|
-
const allBlocks = this.store.getAllBlocks();
|
|
54
|
-
const tips = allBlocks.filter(b => this.store.getChildrenHashes(b.hash).length === 0);
|
|
55
|
-
|
|
56
|
-
if (tips.length === 0) return 0;
|
|
57
|
-
|
|
58
|
-
let maxScore = -1;
|
|
59
|
-
let heaviestTip: DagBlock | null = null;
|
|
60
|
-
|
|
61
|
-
for (const tip of tips) {
|
|
62
|
-
const score = await this.blueScore(tip.hash);
|
|
63
|
-
if (score > maxScore) {
|
|
64
|
-
maxScore = score;
|
|
65
|
-
heaviestTip = tip;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (!heaviestTip) return 0;
|
|
70
|
-
|
|
71
|
-
// Verify reachability: does the heaviest tip actually include this block in its past?
|
|
72
|
-
const reachable = await this.topology.reachability(hash, heaviestTip.hash);
|
|
73
|
-
if (!reachable) return 0;
|
|
74
|
-
|
|
75
|
-
const blockScore = await this.blueScore(hash);
|
|
76
|
-
return Math.max(0, maxScore - blockScore);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
private async isOrphan(hash: string): Promise<boolean> {
|
|
80
|
-
const b = this.store.getBlock(hash);
|
|
81
|
-
if (!b) return false;
|
|
82
|
-
if (b.parents.length === 0) return false;
|
|
83
|
-
|
|
84
|
-
for (const p of b.parents) {
|
|
85
|
-
if (!this.store.getBlock(p)) return true;
|
|
86
|
-
}
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
public async trace(txid: string): Promise<{ txid: string, status: string, foundIn: string[] }> {
|
|
91
|
-
const allBlocks = this.store.getAllBlocks();
|
|
92
|
-
const foundInBlocks: string[] = [];
|
|
93
|
-
|
|
94
|
-
for (const block of allBlocks) {
|
|
95
|
-
if (block.transactions && block.transactions.some(tx => tx.id === txid)) {
|
|
96
|
-
foundInBlocks.push(block.hash);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (foundInBlocks.length === 0) {
|
|
101
|
-
return { txid, status: "not_found", foundIn: [] };
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (foundInBlocks.length === 1) {
|
|
105
|
-
const blockHash = foundInBlocks[0]!;
|
|
106
|
-
const isOrphan = await this.isOrphan(blockHash);
|
|
107
|
-
return { txid, status: isOrphan ? "orphan" : "accepted", foundIn: foundInBlocks };
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// Parallel branch conflict detection
|
|
111
|
-
let isConflict = false;
|
|
112
|
-
for (let i = 0; i < foundInBlocks.length; i++) {
|
|
113
|
-
for (let j = i + 1; j < foundInBlocks.length; j++) {
|
|
114
|
-
const b1 = foundInBlocks[i]!;
|
|
115
|
-
const b2 = foundInBlocks[j]!;
|
|
116
|
-
|
|
117
|
-
const reach1 = await this.topology.reachability(b1, b2);
|
|
118
|
-
const reach2 = await this.topology.reachability(b2, b1);
|
|
119
|
-
|
|
120
|
-
if (!reach1 && !reach2) {
|
|
121
|
-
isConflict = true;
|
|
122
|
-
break;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return {
|
|
128
|
-
txid,
|
|
129
|
-
status: isConflict ? "conflict" : "merged",
|
|
130
|
-
foundIn: foundInBlocks
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
public async statistics(): Promise<DagStatistics> {
|
|
135
|
-
const allBlocks = this.store.getAllBlocks();
|
|
136
|
-
const tips = allBlocks.filter(b => this.store.getChildrenHashes(b.hash).length === 0);
|
|
137
|
-
|
|
138
|
-
let highestBlueScore = 0;
|
|
139
|
-
for (const b of allBlocks) {
|
|
140
|
-
const score = await this.blueScore(b.hash);
|
|
141
|
-
if (score > highestBlueScore) highestBlueScore = score;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return {
|
|
145
|
-
totalBlocks: allBlocks.length,
|
|
146
|
-
totalTips: tips.length,
|
|
147
|
-
highestBlueScore
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
}
|