@bsv/wallet-toolbox-client 2.0.24 → 2.1.1
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/out/src/Wallet.js +1 -1
- package/out/src/Wallet.js.map +1 -1
- package/out/src/mockchain/MockChainMigrations.d.ts +20 -0
- package/out/src/mockchain/MockChainMigrations.d.ts.map +1 -0
- package/out/src/mockchain/MockChainMigrations.js +67 -0
- package/out/src/mockchain/MockChainMigrations.js.map +1 -0
- package/out/src/mockchain/MockChainStorage.d.ts +58 -0
- package/out/src/mockchain/MockChainStorage.d.ts.map +1 -0
- package/out/src/mockchain/MockChainStorage.js +101 -0
- package/out/src/mockchain/MockChainStorage.js.map +1 -0
- package/out/src/mockchain/MockChainTracker.d.ts +28 -0
- package/out/src/mockchain/MockChainTracker.d.ts.map +1 -0
- package/out/src/mockchain/MockChainTracker.js +95 -0
- package/out/src/mockchain/MockChainTracker.js.map +1 -0
- package/out/src/mockchain/MockMiner.d.ts +16 -0
- package/out/src/mockchain/MockMiner.d.ts.map +1 -0
- package/out/src/mockchain/MockMiner.js +136 -0
- package/out/src/mockchain/MockMiner.js.map +1 -0
- package/out/src/mockchain/MockServices.d.ts +44 -0
- package/out/src/mockchain/MockServices.d.ts.map +1 -0
- package/out/src/mockchain/MockServices.js +504 -0
- package/out/src/mockchain/MockServices.js.map +1 -0
- package/out/src/mockchain/merkleTree.d.ts +13 -0
- package/out/src/mockchain/merkleTree.d.ts.map +1 -0
- package/out/src/mockchain/merkleTree.js +113 -0
- package/out/src/mockchain/merkleTree.js.map +1 -0
- package/out/src/monitor/Monitor.d.ts +3 -3
- package/out/src/monitor/Monitor.d.ts.map +1 -1
- package/out/src/monitor/Monitor.js +7 -0
- package/out/src/monitor/Monitor.js.map +1 -1
- package/out/src/monitor/tasks/TaskMineBlock.d.ts +13 -0
- package/out/src/monitor/tasks/TaskMineBlock.d.ts.map +1 -0
- package/out/src/monitor/tasks/TaskMineBlock.js +29 -0
- package/out/src/monitor/tasks/TaskMineBlock.js.map +1 -0
- package/out/src/sdk/types.d.ts +1 -1
- package/out/src/sdk/types.d.ts.map +1 -1
- package/out/src/services/Services.d.ts.map +1 -1
- package/out/src/services/Services.js +14 -4
- package/out/src/services/Services.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.js +24 -6
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.js +8 -8
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.js +27 -21
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.js.map +1 -1
- package/out/src/services/createDefaultWalletServicesOptions.d.ts.map +1 -1
- package/out/src/services/createDefaultWalletServicesOptions.js +14 -4
- package/out/src/services/createDefaultWalletServicesOptions.js.map +1 -1
- package/out/src/services/providers/Bitails.d.ts.map +1 -1
- package/out/src/services/providers/Bitails.js +10 -1
- package/out/src/services/providers/Bitails.js.map +1 -1
- package/out/src/services/providers/SdkWhatsOnChain.d.ts +1 -1
- package/out/src/services/providers/SdkWhatsOnChain.d.ts.map +1 -1
- package/out/src/services/providers/SdkWhatsOnChain.js.map +1 -1
- package/out/src/services/providers/WhatsOnChain.d.ts.map +1 -1
- package/out/src/services/providers/WhatsOnChain.js +2 -0
- package/out/src/services/providers/WhatsOnChain.js.map +1 -1
- package/out/src/utility/utilityHelpers.d.ts +5 -0
- package/out/src/utility/utilityHelpers.d.ts.map +1 -1
- package/out/src/utility/utilityHelpers.js +24 -1
- package/out/src/utility/utilityHelpers.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.MockServices = void 0;
|
|
37
|
+
const sdk_1 = require("@bsv/sdk");
|
|
38
|
+
const WERR_errors_1 = require("../sdk/WERR_errors");
|
|
39
|
+
const utilityHelpers_1 = require("../utility/utilityHelpers");
|
|
40
|
+
const utilityHelpers_noBuffer_1 = require("../utility/utilityHelpers.noBuffer");
|
|
41
|
+
const Services_1 = require("../services/Services");
|
|
42
|
+
const MockChainStorage_1 = require("./MockChainStorage");
|
|
43
|
+
const MockChainTracker_1 = require("./MockChainTracker");
|
|
44
|
+
const MockMiner_1 = require("./MockMiner");
|
|
45
|
+
const merkleTree_1 = require("./merkleTree");
|
|
46
|
+
class MockServices {
|
|
47
|
+
constructor(knex) {
|
|
48
|
+
this.knex = knex;
|
|
49
|
+
this.chain = 'mock';
|
|
50
|
+
this.storage = new MockChainStorage_1.MockChainStorage(knex);
|
|
51
|
+
this.tracker = new MockChainTracker_1.MockChainTracker('mock', this.storage);
|
|
52
|
+
this.miner = new MockMiner_1.MockMiner();
|
|
53
|
+
}
|
|
54
|
+
async initialize() {
|
|
55
|
+
await this.storage.migrate();
|
|
56
|
+
// Mine genesis block if chain is empty
|
|
57
|
+
const tip = await this.storage.getChainTip();
|
|
58
|
+
if (!tip) {
|
|
59
|
+
await this.miner.mineBlock(this.storage);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async mineBlock() {
|
|
63
|
+
return this.miner.mineBlock(this.storage);
|
|
64
|
+
}
|
|
65
|
+
async postBeef(beef, txids) {
|
|
66
|
+
var _a;
|
|
67
|
+
const results = [];
|
|
68
|
+
for (const txid of txids) {
|
|
69
|
+
try {
|
|
70
|
+
// Find the transaction in the BEEF
|
|
71
|
+
const beefTx = beef.findTxid(txid);
|
|
72
|
+
if (!beefTx) {
|
|
73
|
+
results.push({
|
|
74
|
+
name: 'MockServices',
|
|
75
|
+
status: 'error',
|
|
76
|
+
error: new WERR_errors_1.WERR_INVALID_PARAMETER('txid', `present in provided BEEF. txid: ${txid}`),
|
|
77
|
+
txidResults: [{ txid, status: 'error' }]
|
|
78
|
+
});
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
const rawTx = beefTx.rawTx;
|
|
82
|
+
if (!rawTx) {
|
|
83
|
+
results.push({
|
|
84
|
+
name: 'MockServices',
|
|
85
|
+
status: 'error',
|
|
86
|
+
error: new WERR_errors_1.WERR_INVALID_PARAMETER('rawTx', `present in BEEF for txid: ${txid}`),
|
|
87
|
+
txidResults: [{ txid, status: 'error' }]
|
|
88
|
+
});
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
const tx = sdk_1.Transaction.fromBinary(rawTx);
|
|
92
|
+
// Validate inputs
|
|
93
|
+
const currentHeight = await this.tracker.currentHeight();
|
|
94
|
+
for (let i = 0; i < tx.inputs.length; i++) {
|
|
95
|
+
const input = tx.inputs[i];
|
|
96
|
+
const sourceTxid = input.sourceTXID || (input.sourceTransaction ? input.sourceTransaction.id('hex') : undefined);
|
|
97
|
+
if (!sourceTxid) {
|
|
98
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('input.sourceTXID', `defined for input ${i}`);
|
|
99
|
+
}
|
|
100
|
+
const sourceVout = input.sourceOutputIndex;
|
|
101
|
+
const utxo = await this.storage.getUtxo(sourceTxid, sourceVout);
|
|
102
|
+
if (!utxo) {
|
|
103
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('input', `reference a known UTXO. Input ${i}: ${sourceTxid}.${sourceVout} not found`);
|
|
104
|
+
}
|
|
105
|
+
if (utxo.spentByTxid) {
|
|
106
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('input', `not be already spent. Input ${i}: ${sourceTxid}.${sourceVout} spent by ${utxo.spentByTxid}`);
|
|
107
|
+
}
|
|
108
|
+
// Coinbase maturity check
|
|
109
|
+
if (utxo.isCoinbase && utxo.blockHeight !== null) {
|
|
110
|
+
if (currentHeight - utxo.blockHeight < 100) {
|
|
111
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('input', `not spend immature coinbase. Input ${i}: coinbase at height ${utxo.blockHeight}, current height ${currentHeight}, need 100 confirmations`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// Ensure source transaction is set for script validation
|
|
115
|
+
if (!input.sourceTransaction) {
|
|
116
|
+
const sourceTxRow = await this.storage.getTransaction(sourceTxid);
|
|
117
|
+
if (sourceTxRow) {
|
|
118
|
+
const sourceRaw = sourceTxRow.rawTx instanceof Buffer
|
|
119
|
+
? Array.from(sourceTxRow.rawTx)
|
|
120
|
+
: Array.isArray(sourceTxRow.rawTx)
|
|
121
|
+
? sourceTxRow.rawTx
|
|
122
|
+
: Array.from(sourceTxRow.rawTx);
|
|
123
|
+
input.sourceTransaction = sdk_1.Transaction.fromBinary(sourceRaw);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// Validate scripts using the SDK script interpreter
|
|
128
|
+
// We set sourceTransaction on each input above, so verify should work.
|
|
129
|
+
// Also set merklePath on source transactions to satisfy the SDK's proof requirement.
|
|
130
|
+
for (const input of tx.inputs) {
|
|
131
|
+
if (input.sourceTransaction && !input.sourceTransaction.merklePath) {
|
|
132
|
+
const stxid = input.sourceTransaction.id('hex');
|
|
133
|
+
const stx = await this.storage.getTransaction(stxid);
|
|
134
|
+
if (stx && stx.blockHeight !== null) {
|
|
135
|
+
const txsInBlock = await this.storage.getTransactionsInBlock(stx.blockHeight);
|
|
136
|
+
const stxids = txsInBlock.map(t => t.txid);
|
|
137
|
+
const idx = stxids.indexOf(stxid);
|
|
138
|
+
if (idx >= 0) {
|
|
139
|
+
input.sourceTransaction.merklePath = (0, merkleTree_1.computeMerklePath)(stxids, idx, stx.blockHeight);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const verified = await tx.verify('scripts only');
|
|
145
|
+
if (verified !== true) {
|
|
146
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('transaction', `pass script validation: ${verified}`);
|
|
147
|
+
}
|
|
148
|
+
// Store transaction
|
|
149
|
+
await this.storage.insertTransaction(txid, Array.from(rawTx));
|
|
150
|
+
// Create UTXOs for each output
|
|
151
|
+
for (let vout = 0; vout < tx.outputs.length; vout++) {
|
|
152
|
+
const output = tx.outputs[vout];
|
|
153
|
+
const scriptBinary = output.lockingScript.toBinary();
|
|
154
|
+
const scriptHash = (0, utilityHelpers_noBuffer_1.asString)((0, utilityHelpers_1.sha256Hash)(Array.from(scriptBinary)));
|
|
155
|
+
await this.storage.insertUtxo(txid, vout, Array.from(scriptBinary), (_a = output.satoshis) !== null && _a !== void 0 ? _a : 0, scriptHash);
|
|
156
|
+
}
|
|
157
|
+
// Spend inputs
|
|
158
|
+
for (const input of tx.inputs) {
|
|
159
|
+
const sourceTxid = input.sourceTXID || (input.sourceTransaction ? input.sourceTransaction.id('hex') : '');
|
|
160
|
+
await this.storage.markUtxoSpent(sourceTxid, input.sourceOutputIndex, txid);
|
|
161
|
+
}
|
|
162
|
+
results.push({
|
|
163
|
+
name: 'MockServices',
|
|
164
|
+
status: 'success',
|
|
165
|
+
txidResults: [{ txid, status: 'success' }]
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
catch (eu) {
|
|
169
|
+
const error = eu instanceof Error ? new WERR_errors_1.WERR_INTERNAL(eu.message) : new WERR_errors_1.WERR_INTERNAL(String(eu));
|
|
170
|
+
results.push({
|
|
171
|
+
name: 'MockServices',
|
|
172
|
+
status: 'error',
|
|
173
|
+
error,
|
|
174
|
+
txidResults: [{ txid, status: 'error' }]
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return results;
|
|
179
|
+
}
|
|
180
|
+
async reorg(startingHeight, numBlocks, txidMap) {
|
|
181
|
+
const oldTip = await this.storage.getChainTip();
|
|
182
|
+
if (!oldTip)
|
|
183
|
+
throw new WERR_errors_1.WERR_INTERNAL('Cannot reorg empty chain');
|
|
184
|
+
if (startingHeight > oldTip.height) {
|
|
185
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('startingHeight', `<= current tip height ${oldTip.height}`);
|
|
186
|
+
}
|
|
187
|
+
const deactivatedHeaders = [];
|
|
188
|
+
// Collect all deactivated headers
|
|
189
|
+
for (let h = startingHeight; h <= oldTip.height; h++) {
|
|
190
|
+
const header = await this.storage.getBlockHeaderByHeight(h);
|
|
191
|
+
if (header)
|
|
192
|
+
deactivatedHeaders.push(header);
|
|
193
|
+
}
|
|
194
|
+
await this.knex.transaction(async (trx) => {
|
|
195
|
+
const trxStorage = new MockChainStorage_1.MockChainStorage(trx);
|
|
196
|
+
// Tear down old blocks
|
|
197
|
+
for (let h = oldTip.height; h >= startingHeight; h--) {
|
|
198
|
+
const txsInBlock = await trxStorage.getTransactionsInBlock(h);
|
|
199
|
+
// Get coinbaseTxid from the raw row (not BlockHeader which lacks it)
|
|
200
|
+
const headerRow = await trxStorage.knex('mockchain_block_headers').where({ height: h }).first();
|
|
201
|
+
const coinbaseTxid = headerRow === null || headerRow === void 0 ? void 0 : headerRow.coinbaseTxid;
|
|
202
|
+
for (const tx of txsInBlock) {
|
|
203
|
+
if (coinbaseTxid && tx.txid === coinbaseTxid) {
|
|
204
|
+
// Delete coinbase UTXOs and transaction
|
|
205
|
+
await trxStorage.deleteUtxosByTxid(tx.txid);
|
|
206
|
+
await trxStorage.deleteTransaction(tx.txid);
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
// Return non-coinbase tx to mempool
|
|
210
|
+
await trxStorage.setTransactionBlock(tx.txid, null, null);
|
|
211
|
+
await trxStorage.setUtxoBlockHeight(tx.txid, null);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (headerRow) {
|
|
215
|
+
await trxStorage.deleteBlockHeader(h);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
// Mine numBlocks new blocks
|
|
219
|
+
for (let i = 0; i < numBlocks; i++) {
|
|
220
|
+
const newHeight = startingHeight + i;
|
|
221
|
+
// Determine which txids go in this block from txidMap
|
|
222
|
+
const mappedTxids = [];
|
|
223
|
+
if (txidMap) {
|
|
224
|
+
for (const [tid, offset] of Object.entries(txidMap)) {
|
|
225
|
+
if (offset === i)
|
|
226
|
+
mappedTxids.push(tid);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
// Get previous hash
|
|
230
|
+
let prevHash;
|
|
231
|
+
if (newHeight === 0) {
|
|
232
|
+
prevHash = '00'.repeat(32);
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
const prevHeader = await trxStorage.getBlockHeaderByHeight(newHeight - 1);
|
|
236
|
+
if (!prevHeader)
|
|
237
|
+
throw new WERR_errors_1.WERR_INTERNAL(`Missing block header at height ${newHeight - 1}`);
|
|
238
|
+
prevHash = prevHeader.hash;
|
|
239
|
+
}
|
|
240
|
+
// Create coinbase
|
|
241
|
+
const { createCoinbaseTransaction } = await Promise.resolve().then(() => __importStar(require('./MockMiner')));
|
|
242
|
+
const coinbaseTx = createCoinbaseTransaction(newHeight);
|
|
243
|
+
const coinbaseTxid = coinbaseTx.id('hex');
|
|
244
|
+
const coinbaseRawTx = Array.from(coinbaseTx.toBinary());
|
|
245
|
+
const allTxids = [coinbaseTxid, ...mappedTxids];
|
|
246
|
+
const { computeMerkleRoot } = await Promise.resolve().then(() => __importStar(require('./merkleTree')));
|
|
247
|
+
const merkleRoot = computeMerkleRoot(allTxids);
|
|
248
|
+
const time = Math.floor(Date.now() / 1000);
|
|
249
|
+
const bits = 0x207fffff;
|
|
250
|
+
const nonce = Math.floor(Math.random() * 0xffffffff);
|
|
251
|
+
const headerObj = { version: 1, previousHash: prevHash, merkleRoot, time, bits, nonce };
|
|
252
|
+
const headerBinary = (0, Services_1.toBinaryBaseBlockHeader)(headerObj);
|
|
253
|
+
const hash = (0, utilityHelpers_noBuffer_1.asString)((0, utilityHelpers_1.doubleSha256BE)(headerBinary));
|
|
254
|
+
// Insert coinbase tx
|
|
255
|
+
await trxStorage.knex('mockchain_transactions').insert({
|
|
256
|
+
txid: coinbaseTxid,
|
|
257
|
+
rawTx: Buffer.from(coinbaseRawTx),
|
|
258
|
+
blockHeight: newHeight,
|
|
259
|
+
blockIndex: 0
|
|
260
|
+
});
|
|
261
|
+
// Insert coinbase UTXO
|
|
262
|
+
const coinbaseOutputScript = [0x51];
|
|
263
|
+
const coinbaseScriptHash = (0, utilityHelpers_noBuffer_1.asString)((0, utilityHelpers_1.sha256Hash)(coinbaseOutputScript));
|
|
264
|
+
await trxStorage.knex('mockchain_utxos').insert({
|
|
265
|
+
txid: coinbaseTxid,
|
|
266
|
+
vout: 0,
|
|
267
|
+
lockingScript: Buffer.from(coinbaseOutputScript),
|
|
268
|
+
satoshis: 5000000000,
|
|
269
|
+
scriptHash: coinbaseScriptHash,
|
|
270
|
+
spentByTxid: null,
|
|
271
|
+
isCoinbase: true,
|
|
272
|
+
blockHeight: newHeight
|
|
273
|
+
});
|
|
274
|
+
// Update mapped txs
|
|
275
|
+
for (let j = 0; j < mappedTxids.length; j++) {
|
|
276
|
+
await trxStorage.setTransactionBlock(mappedTxids[j], newHeight, j + 1);
|
|
277
|
+
await trxStorage.setUtxoBlockHeight(mappedTxids[j], newHeight);
|
|
278
|
+
}
|
|
279
|
+
// Insert block header
|
|
280
|
+
await trxStorage.knex('mockchain_block_headers').insert({
|
|
281
|
+
height: newHeight,
|
|
282
|
+
hash,
|
|
283
|
+
previousHash: prevHash,
|
|
284
|
+
merkleRoot,
|
|
285
|
+
version: 1,
|
|
286
|
+
time,
|
|
287
|
+
bits,
|
|
288
|
+
nonce,
|
|
289
|
+
coinbaseTxid
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
const newTip = await this.storage.getChainTip();
|
|
294
|
+
if (!newTip)
|
|
295
|
+
throw new WERR_errors_1.WERR_INTERNAL('Chain tip missing after reorg');
|
|
296
|
+
return { oldTip, newTip, deactivatedHeaders };
|
|
297
|
+
}
|
|
298
|
+
async getRawTx(txid) {
|
|
299
|
+
const tx = await this.storage.getTransaction(txid);
|
|
300
|
+
if (!tx)
|
|
301
|
+
return { txid };
|
|
302
|
+
const rawTx = tx.rawTx instanceof Buffer
|
|
303
|
+
? Array.from(tx.rawTx)
|
|
304
|
+
: Array.isArray(tx.rawTx)
|
|
305
|
+
? tx.rawTx
|
|
306
|
+
: Array.from(tx.rawTx);
|
|
307
|
+
return { txid, rawTx, name: 'MockServices' };
|
|
308
|
+
}
|
|
309
|
+
async getMerklePath(txid) {
|
|
310
|
+
const tx = await this.storage.getTransaction(txid);
|
|
311
|
+
if (!tx || tx.blockHeight === null)
|
|
312
|
+
return {};
|
|
313
|
+
const txsInBlock = await this.storage.getTransactionsInBlock(tx.blockHeight);
|
|
314
|
+
const txids = txsInBlock.map(t => t.txid);
|
|
315
|
+
const targetIndex = txids.indexOf(txid);
|
|
316
|
+
if (targetIndex < 0)
|
|
317
|
+
return {};
|
|
318
|
+
const header = await this.storage.getBlockHeaderByHeight(tx.blockHeight);
|
|
319
|
+
const merklePath = (0, merkleTree_1.computeMerklePath)(txids, targetIndex, tx.blockHeight);
|
|
320
|
+
return { merklePath, header: header || undefined, name: 'MockServices' };
|
|
321
|
+
}
|
|
322
|
+
async getUtxoStatus(output, outputFormat, outpoint) {
|
|
323
|
+
const hashBE = (0, Services_1.validateScriptHash)(output, outputFormat);
|
|
324
|
+
// Convert hashBE to hashLE for our storage (which stores hashLE)
|
|
325
|
+
const hashLE = (0, utilityHelpers_noBuffer_1.asString)((0, utilityHelpers_noBuffer_1.asArray)(hashBE).reverse());
|
|
326
|
+
const utxos = await this.storage.getUtxosByScriptHash(hashLE);
|
|
327
|
+
const unspent = utxos.filter(u => !u.spentByTxid);
|
|
328
|
+
let isUtxo = unspent.length > 0;
|
|
329
|
+
const details = unspent.map(u => {
|
|
330
|
+
var _a;
|
|
331
|
+
return ({
|
|
332
|
+
txid: u.txid,
|
|
333
|
+
index: u.vout,
|
|
334
|
+
height: (_a = u.blockHeight) !== null && _a !== void 0 ? _a : undefined,
|
|
335
|
+
satoshis: Number(u.satoshis)
|
|
336
|
+
});
|
|
337
|
+
});
|
|
338
|
+
// If outpoint is provided, filter to match
|
|
339
|
+
if (outpoint && isUtxo) {
|
|
340
|
+
const [opTxid, opVoutStr] = outpoint.split('.');
|
|
341
|
+
const opVout = parseInt(opVoutStr, 10);
|
|
342
|
+
const match = details.find(d => d.txid === opTxid && d.index === opVout);
|
|
343
|
+
isUtxo = !!match;
|
|
344
|
+
}
|
|
345
|
+
return {
|
|
346
|
+
name: 'MockServices',
|
|
347
|
+
status: 'success',
|
|
348
|
+
isUtxo,
|
|
349
|
+
details
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
async getStatusForTxids(txids) {
|
|
353
|
+
const currentHeight = await this.tracker.currentHeight();
|
|
354
|
+
const results = await Promise.all(txids.map(async (txid) => {
|
|
355
|
+
const tx = await this.storage.getTransaction(txid);
|
|
356
|
+
if (!tx)
|
|
357
|
+
return { txid, status: 'unknown', depth: undefined };
|
|
358
|
+
if (tx.blockHeight !== null) {
|
|
359
|
+
const depth = currentHeight - tx.blockHeight + 1;
|
|
360
|
+
return { txid, status: 'mined', depth };
|
|
361
|
+
}
|
|
362
|
+
return { txid, status: 'known', depth: 0 };
|
|
363
|
+
}));
|
|
364
|
+
return { name: 'MockServices', status: 'success', results };
|
|
365
|
+
}
|
|
366
|
+
async getScriptHashHistory(hash) {
|
|
367
|
+
const utxos = await this.storage.getUtxosByScriptHash(hash);
|
|
368
|
+
const history = utxos.map(u => {
|
|
369
|
+
var _a;
|
|
370
|
+
return ({
|
|
371
|
+
txid: u.txid,
|
|
372
|
+
height: (_a = u.blockHeight) !== null && _a !== void 0 ? _a : undefined
|
|
373
|
+
});
|
|
374
|
+
});
|
|
375
|
+
return { name: 'MockServices', status: 'success', history };
|
|
376
|
+
}
|
|
377
|
+
async getChainTracker() {
|
|
378
|
+
return this.tracker;
|
|
379
|
+
}
|
|
380
|
+
async getHeaderForHeight(height) {
|
|
381
|
+
const header = await this.storage.getBlockHeaderByHeight(height);
|
|
382
|
+
if (!header)
|
|
383
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('height', `valid height '${height}' on mock chain`);
|
|
384
|
+
return (0, Services_1.toBinaryBaseBlockHeader)(header);
|
|
385
|
+
}
|
|
386
|
+
async getHeight() {
|
|
387
|
+
return this.tracker.currentHeight();
|
|
388
|
+
}
|
|
389
|
+
async hashToHeader(hash) {
|
|
390
|
+
const header = await this.storage.getBlockHeaderByHash(hash);
|
|
391
|
+
if (!header)
|
|
392
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('hash', `valid blockhash '${hash}' on mock chain`);
|
|
393
|
+
return header;
|
|
394
|
+
}
|
|
395
|
+
hashOutputScript(script) {
|
|
396
|
+
const hash = sdk_1.Utils.toHex((0, utilityHelpers_1.sha256Hash)(sdk_1.Utils.toArray(script, 'hex')));
|
|
397
|
+
return hash;
|
|
398
|
+
}
|
|
399
|
+
async isUtxo(output) {
|
|
400
|
+
if (!output.lockingScript) {
|
|
401
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('output.lockingScript', 'validated by storage provider validateOutputScript.');
|
|
402
|
+
}
|
|
403
|
+
const hash = this.hashOutputScript(sdk_1.Utils.toHex(output.lockingScript));
|
|
404
|
+
const or = await this.getUtxoStatus(hash, undefined, `${output.txid}.${output.vout}`);
|
|
405
|
+
return or.isUtxo === true;
|
|
406
|
+
}
|
|
407
|
+
async getBsvExchangeRate() {
|
|
408
|
+
return 50.0;
|
|
409
|
+
}
|
|
410
|
+
async getFiatExchangeRate(currency, base) {
|
|
411
|
+
if (currency === (base || 'USD'))
|
|
412
|
+
return 1;
|
|
413
|
+
return 1.0;
|
|
414
|
+
}
|
|
415
|
+
async getFiatExchangeRates(targetCurrencies) {
|
|
416
|
+
const rates = {};
|
|
417
|
+
for (const c of targetCurrencies)
|
|
418
|
+
rates[c] = 1;
|
|
419
|
+
return {
|
|
420
|
+
timestamp: new Date(),
|
|
421
|
+
base: 'USD',
|
|
422
|
+
rates
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
async nLockTimeIsFinal(tx) {
|
|
426
|
+
const MAXINT = 0xffffffff;
|
|
427
|
+
const BLOCK_LIMIT = 500000000;
|
|
428
|
+
let nLockTime;
|
|
429
|
+
if (typeof tx === 'number')
|
|
430
|
+
nLockTime = tx;
|
|
431
|
+
else {
|
|
432
|
+
if (typeof tx === 'string') {
|
|
433
|
+
tx = sdk_1.Transaction.fromHex(tx);
|
|
434
|
+
}
|
|
435
|
+
else if (Array.isArray(tx)) {
|
|
436
|
+
tx = sdk_1.Transaction.fromBinary(tx);
|
|
437
|
+
}
|
|
438
|
+
if (tx instanceof sdk_1.Transaction) {
|
|
439
|
+
if (tx.inputs.every(i => i.sequence === MAXINT))
|
|
440
|
+
return true;
|
|
441
|
+
nLockTime = tx.lockTime;
|
|
442
|
+
}
|
|
443
|
+
else {
|
|
444
|
+
throw new WERR_errors_1.WERR_INTERNAL('Unsupported transaction format');
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
if (nLockTime >= BLOCK_LIMIT) {
|
|
448
|
+
const limit = Math.floor(Date.now() / 1000);
|
|
449
|
+
return nLockTime < limit;
|
|
450
|
+
}
|
|
451
|
+
const height = await this.getHeight();
|
|
452
|
+
return nLockTime < height;
|
|
453
|
+
}
|
|
454
|
+
async getBeefForTxid(txid) {
|
|
455
|
+
const beef = new sdk_1.Beef();
|
|
456
|
+
const addTx = async (tid, alreadyAdded) => {
|
|
457
|
+
if (alreadyAdded.has(tid))
|
|
458
|
+
return;
|
|
459
|
+
alreadyAdded.add(tid);
|
|
460
|
+
const txRow = await this.storage.getTransaction(tid);
|
|
461
|
+
if (!txRow)
|
|
462
|
+
return;
|
|
463
|
+
const rawTx = txRow.rawTx instanceof Buffer
|
|
464
|
+
? Array.from(txRow.rawTx)
|
|
465
|
+
: Array.isArray(txRow.rawTx)
|
|
466
|
+
? txRow.rawTx
|
|
467
|
+
: Array.from(txRow.rawTx);
|
|
468
|
+
if (txRow.blockHeight !== null) {
|
|
469
|
+
// Mined: add with merkle path
|
|
470
|
+
const pathResult = await this.getMerklePath(tid);
|
|
471
|
+
if (pathResult.merklePath) {
|
|
472
|
+
const bumpIndex = beef.mergeBump(pathResult.merklePath);
|
|
473
|
+
beef.mergeRawTx(rawTx, bumpIndex);
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
// Unmined or no path: recursively add source transactions
|
|
478
|
+
const tx = sdk_1.Transaction.fromBinary(rawTx);
|
|
479
|
+
for (const input of tx.inputs) {
|
|
480
|
+
const sourceTxid = input.sourceTXID || (input.sourceTransaction ? input.sourceTransaction.id('hex') : undefined);
|
|
481
|
+
if (sourceTxid && sourceTxid !== '00'.repeat(32)) {
|
|
482
|
+
await addTx(sourceTxid, alreadyAdded);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
beef.mergeRawTx(rawTx);
|
|
486
|
+
};
|
|
487
|
+
await addTx(txid, new Set());
|
|
488
|
+
return beef;
|
|
489
|
+
}
|
|
490
|
+
getServicesCallHistory() {
|
|
491
|
+
return {
|
|
492
|
+
version: 2,
|
|
493
|
+
getMerklePath: { serviceName: 'getMerklePath', historyByProvider: {} },
|
|
494
|
+
getRawTx: { serviceName: 'getRawTx', historyByProvider: {} },
|
|
495
|
+
postBeef: { serviceName: 'postBeef', historyByProvider: {} },
|
|
496
|
+
getUtxoStatus: { serviceName: 'getUtxoStatus', historyByProvider: {} },
|
|
497
|
+
getStatusForTxids: { serviceName: 'getStatusForTxids', historyByProvider: {} },
|
|
498
|
+
getScriptHashHistory: { serviceName: 'getScriptHashHistory', historyByProvider: {} },
|
|
499
|
+
updateFiatExchangeRates: { serviceName: 'updateFiatExchangeRates', historyByProvider: {} }
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
exports.MockServices = MockServices;
|
|
504
|
+
//# sourceMappingURL=MockServices.js.map
|
|
@@ -0,0 +1 @@
|
|
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AAE,CAAC;YACV,aAAa,EAAE,EAAE,WAAW,EAAE,eAAe,EAAE,iBAAiB,EAAE,EAAE,EAAE;YACtE,QAAQ,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,iBAAiB,EAAE,EAAE,EAAE;YAC5D,QAAQ,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,iBAAiB,EAAE,EAAE,EAAE;YAC5D,aAAa,EAAE,EAAE,WAAW,EAAE,eAAe,EAAE,iBAAiB,EAAE,EAAE,EAAE;YACtE,iBAAiB,EAAE,EAAE,WAAW,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,EAAE,EAAE;YAC9E,oBAAoB,EAAE,EAAE,WAAW,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,EAAE,EAAE;YACpF,uBAAuB,EAAE,EAAE,WAAW,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,EAAE,EAAE;SAC3F,CAAA;IACH,CAAC;CACF;AAzgBD,oCAygBC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MerklePath } from '@bsv/sdk';
|
|
2
|
+
/**
|
|
3
|
+
* Compute the merkle root from an array of txids (big-endian hex strings).
|
|
4
|
+
* Returns the root as a big-endian hex string (reversed byte order from the
|
|
5
|
+
* natural double-SHA256 result, matching the standard block header format).
|
|
6
|
+
*/
|
|
7
|
+
export declare function computeMerkleRoot(txids: string[]): string;
|
|
8
|
+
/**
|
|
9
|
+
* Compute the MerklePath for a target transaction at `targetIndex` within a block at `blockHeight`.
|
|
10
|
+
* `txids` is the ordered list of all txids in the block (big-endian hex).
|
|
11
|
+
*/
|
|
12
|
+
export declare function computeMerklePath(txids: string[], targetIndex: number, blockHeight: number): MerklePath;
|
|
13
|
+
//# sourceMappingURL=merkleTree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merkleTree.d.ts","sourceRoot":"","sources":["../../../../src/mockchain/merkleTree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAIrC;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAsBzD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,UAAU,CAuFvG"}
|