@metamask-previews/bitcoin-regtest-up 0.0.0-preview-82e080825

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.
@@ -0,0 +1,390 @@
1
+ /* eslint-disable import-x/no-nodejs-modules, no-restricted-globals */
2
+ import { spawn } from "node:child_process";
3
+ import { createHash } from "node:crypto";
4
+ import { createWriteStream, existsSync, readdirSync, readFileSync, statSync } from "node:fs";
5
+ import { chmod, mkdir, readFile, rename, rm, unlink, writeFile } from "node:fs/promises";
6
+ import { request as requestHttp } from "node:http";
7
+ import { request as requestHttps } from "node:https";
8
+ import { arch as osArch, homedir, platform as osPlatform } from "node:os";
9
+ import { dirname, join, resolve } from "node:path";
10
+ import { pipeline } from "node:stream/promises";
11
+ const BITCOIN_REGTEST_CACHE_NAMESPACE = 'bitcoin-regtest-up';
12
+ const BITCOIN_CORE_CACHE_NAMESPACE = 'bitcoin-core';
13
+ export const BITCOIN_REGTEST_DEFAULT_CORE = {
14
+ version: '30.2',
15
+ platforms: {
16
+ 'darwin-arm64': {
17
+ checksum: 'c2ecab62891de22228043815cb6211549a32272be3d5d052ff19847d3420bd10',
18
+ url: 'https://bitcoincore.org/bin/bitcoin-core-30.2/bitcoin-30.2-arm64-apple-darwin.tar.gz',
19
+ },
20
+ 'darwin-x64': {
21
+ checksum: '99d5cee9b9c37be506396c30837a4b98e320bfea71c474d6120a7e8eb6075c7b',
22
+ url: 'https://bitcoincore.org/bin/bitcoin-core-30.2/bitcoin-30.2-x86_64-apple-darwin.tar.gz',
23
+ },
24
+ 'linux-arm64': {
25
+ checksum: '73e76c14edc79808a0511c744d102ffbb494807ee90cbcba176568243254b532',
26
+ url: 'https://bitcoincore.org/bin/bitcoin-core-30.2/bitcoin-30.2-aarch64-linux-gnu.tar.gz',
27
+ },
28
+ 'linux-x64': {
29
+ checksum: '6aa7bb4feb699c4c6262dd23e4004191f6df7f373b5d5978b5bcdd4bb72f75d8',
30
+ url: 'https://bitcoincore.org/bin/bitcoin-core-30.2/bitcoin-30.2-x86_64-linux-gnu.tar.gz',
31
+ },
32
+ },
33
+ };
34
+ export function getBitcoinRegtestCacheDirectory({ cwd = process.cwd(), homeDirectory = homedir(), } = {}) {
35
+ const yarnRcPath = join(cwd, '.yarnrc.yml');
36
+ try {
37
+ const yarnRc = readFileSync(yarnRcPath, 'utf8');
38
+ if (/^\s*enableGlobalCache:\s*true\s*$/mu.test(yarnRc)) {
39
+ return join(homeDirectory, '.cache', 'metamask');
40
+ }
41
+ }
42
+ catch (error) {
43
+ if (!isFileMissingError(error)) {
44
+ console.warn(`Warning: Error reading ${yarnRcPath}, using local bitcoin-regtest-up cache:`, error);
45
+ }
46
+ }
47
+ return join(cwd, '.metamask', 'cache');
48
+ }
49
+ export function readBitcoinRegtestInstallOptionsFromPackageJson({ cwd = process.cwd(), packageJsonPath = join(cwd, 'package.json'), } = {}) {
50
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
51
+ const config = packageJson.bitcoinRegtestUp ??
52
+ packageJson.bitcoinregtestup ??
53
+ packageJson['bitcoin-regtest-up'];
54
+ const options = {};
55
+ if (config?.binDirectory) {
56
+ options.binDirectory = config.binDirectory;
57
+ }
58
+ if (config?.bitcoinCore) {
59
+ options.bitcoinCore = config.bitcoinCore;
60
+ }
61
+ if (config?.cacheDirectory) {
62
+ options.cacheDirectory = config.cacheDirectory;
63
+ }
64
+ return options;
65
+ }
66
+ export function parseBitcoinRegtestInstallCliOptions(args) {
67
+ const options = {};
68
+ const bitcoinCore = {};
69
+ for (let index = 0; index < args.length; index += 1) {
70
+ const arg = args[index];
71
+ const value = args[index + 1];
72
+ switch (arg) {
73
+ case '--bin-directory':
74
+ options.binDirectory = readCliValue(arg, value);
75
+ index += 1;
76
+ break;
77
+ case '--bitcoin-core-checksum':
78
+ bitcoinCore.checksum = readCliValue(arg, value);
79
+ index += 1;
80
+ break;
81
+ case '--bitcoin-core-url':
82
+ bitcoinCore.url = readCliValue(arg, value);
83
+ index += 1;
84
+ break;
85
+ case '--cache-directory':
86
+ options.cacheDirectory = readCliValue(arg, value);
87
+ index += 1;
88
+ break;
89
+ case '--platform':
90
+ options.platform = readCliValue(arg, value);
91
+ index += 1;
92
+ break;
93
+ default:
94
+ throw new Error(`Unknown bitcoin-regtest-up install option: ${arg}`);
95
+ }
96
+ }
97
+ if (bitcoinCore.url || bitcoinCore.checksum) {
98
+ options.bitcoinCore = {
99
+ platforms: {
100
+ current: requireCompletePlatformConfig(bitcoinCore, 'Bitcoin Core CLI options'),
101
+ },
102
+ };
103
+ }
104
+ return options;
105
+ }
106
+ export async function installBitcoinRegtest(options = {}, dependencies = {}) {
107
+ const cwd = options.cwd ?? process.cwd();
108
+ const cacheDirectory = options.cacheDirectory ?? getBitcoinRegtestCacheDirectory({ cwd });
109
+ const binDirectory = options.binDirectory ?? join(cwd, 'node_modules', '.bin');
110
+ const platformKey = options.platform ?? getPlatformKey();
111
+ const bitcoinCore = options.bitcoinCore ?? BITCOIN_REGTEST_DEFAULT_CORE;
112
+ const bitcoinCoreConfig = resolvePlatformConfig(bitcoinCore, platformKey, 'Bitcoin Core archive');
113
+ const bitcoinCoreResult = await installBitcoinCoreArchive({ cacheDirectory, config: bitcoinCoreConfig }, dependencies);
114
+ const bitcoindBinary = await installExecutableWrapper({
115
+ binDirectory,
116
+ commandName: 'bitcoind',
117
+ executableArgs: bitcoinCoreResult.sourceBitcoindArgs,
118
+ executablePath: bitcoinCoreResult.sourceBitcoindBinary,
119
+ });
120
+ const bitcoinCliBinary = await installExecutableWrapper({
121
+ binDirectory,
122
+ commandName: 'bitcoin-cli',
123
+ executablePath: bitcoinCoreResult.sourceBitcoinCliBinary,
124
+ });
125
+ return {
126
+ bitcoinCliBinary,
127
+ bitcoindBinary,
128
+ cacheHit: bitcoinCoreResult.cacheHit,
129
+ checksum: bitcoinCoreConfig.checksum,
130
+ sourceBitcoindArgs: bitcoinCoreResult.sourceBitcoindArgs,
131
+ sourceBitcoinCliBinary: bitcoinCoreResult.sourceBitcoinCliBinary,
132
+ sourceBitcoindBinary: bitcoinCoreResult.sourceBitcoindBinary,
133
+ version: bitcoinCore.version,
134
+ };
135
+ }
136
+ export async function cleanBitcoinRegtestCache(options = {}) {
137
+ const cwd = options.cwd ?? process.cwd();
138
+ const cacheDirectory = options.cacheDirectory ?? getBitcoinRegtestCacheDirectory({ cwd });
139
+ await rm(join(cacheDirectory, BITCOIN_REGTEST_CACHE_NAMESPACE), {
140
+ force: true,
141
+ recursive: true,
142
+ });
143
+ }
144
+ async function installBitcoinCoreArchive({ cacheDirectory, config, }, dependencies) {
145
+ const cacheKey = getCacheKey(config);
146
+ const cacheRoot = join(cacheDirectory, BITCOIN_REGTEST_CACHE_NAMESPACE, BITCOIN_CORE_CACHE_NAMESPACE, cacheKey);
147
+ const checksumPath = join(cacheRoot, '.source-checksum');
148
+ const cached = findBitcoinCoreBinaries(cacheRoot);
149
+ if (cached &&
150
+ existsSync(checksumPath) &&
151
+ readFileSync(checksumPath, 'utf8') === config.checksum &&
152
+ (await areBitcoinCoreBinariesRunnable(cached))) {
153
+ return { cacheHit: true, ...cached };
154
+ }
155
+ const tempRoot = `${cacheRoot}.downloading`;
156
+ const archivePath = join(tempRoot, 'bitcoin-core.tar.gz');
157
+ const downloadFile = dependencies.downloadFile ?? downloadFileFromUrl;
158
+ const extractArchive = dependencies.extractArchive ?? extractTarGzArchive;
159
+ await rm(tempRoot, { force: true, recursive: true });
160
+ await rm(cacheRoot, { force: true, recursive: true });
161
+ await mkdir(tempRoot, { recursive: true });
162
+ try {
163
+ await downloadFile(config.url, archivePath);
164
+ await verifyFileChecksum(archivePath, config.checksum, 'Downloaded Bitcoin Core');
165
+ await extractArchive(archivePath, tempRoot);
166
+ const binaries = findBitcoinCoreBinaries(tempRoot);
167
+ if (!binaries) {
168
+ throw new Error('Bitcoin Core archive did not contain a node daemon (bitcoind, bitcoin-node, or bitcoin) and bin/bitcoin-cli.');
169
+ }
170
+ await assertBitcoinCoreBinariesRunnable(binaries);
171
+ await writeFile(checksumPath.replace(cacheRoot, tempRoot), config.checksum);
172
+ await mkdir(dirname(cacheRoot), { recursive: true });
173
+ await rename(tempRoot, cacheRoot);
174
+ return {
175
+ cacheHit: false,
176
+ sourceBitcoindArgs: binaries.sourceBitcoindArgs,
177
+ sourceBitcoinCliBinary: binaries.sourceBitcoinCliBinary.replace(tempRoot, cacheRoot),
178
+ sourceBitcoindBinary: binaries.sourceBitcoindBinary.replace(tempRoot, cacheRoot),
179
+ };
180
+ }
181
+ catch (error) {
182
+ await rm(tempRoot, { force: true, recursive: true });
183
+ await rm(cacheRoot, { force: true, recursive: true });
184
+ throw error;
185
+ }
186
+ }
187
+ async function installExecutableWrapper({ binDirectory, commandName, executableArgs = [], executablePath, }) {
188
+ const binaryPath = join(binDirectory, commandName);
189
+ const resolvedExecutablePath = resolve(executablePath);
190
+ await mkdir(binDirectory, { recursive: true });
191
+ await unlink(binaryPath).catch((error) => {
192
+ if (!isFileMissingError(error)) {
193
+ throw error;
194
+ }
195
+ });
196
+ await writeFile(binaryPath, `#!/usr/bin/env node
197
+ const { spawnSync } = require('node:child_process');
198
+
199
+ const executablePath = ${JSON.stringify(resolvedExecutablePath)};
200
+ const result = spawnSync(executablePath, ${JSON.stringify(executableArgs)}.concat(process.argv.slice(2)), {
201
+ stdio: 'inherit',
202
+ });
203
+
204
+ if (result.error) {
205
+ console.error(result.error.message);
206
+ process.exit(1);
207
+ }
208
+
209
+ if (result.signal) {
210
+ process.kill(process.pid, result.signal);
211
+ }
212
+
213
+ process.exit(result.status ?? 0);
214
+ `);
215
+ await chmod(binaryPath, 0o755);
216
+ return binaryPath;
217
+ }
218
+ async function areBitcoinCoreBinariesRunnable(binaries) {
219
+ try {
220
+ await assertBitcoinCoreBinariesRunnable(binaries);
221
+ return true;
222
+ }
223
+ catch {
224
+ return false;
225
+ }
226
+ }
227
+ async function assertBitcoinCoreBinariesRunnable(binaries) {
228
+ await runCommand(binaries.sourceBitcoindBinary, [
229
+ ...binaries.sourceBitcoindArgs,
230
+ '-version',
231
+ ]);
232
+ await runCommand(binaries.sourceBitcoinCliBinary, ['-version']);
233
+ }
234
+ function findBitcoinCoreBinaries(root) {
235
+ const sourceBitcoinCliBinary = findExecutable(root, 'bitcoin-cli');
236
+ const sourceBitcoindBinary = findBitcoinCoreDaemonBinary(root);
237
+ if (!sourceBitcoindBinary || !sourceBitcoinCliBinary) {
238
+ return undefined;
239
+ }
240
+ return {
241
+ sourceBitcoindArgs: sourceBitcoindBinary.name === 'bitcoin' ? ['node'] : [],
242
+ sourceBitcoinCliBinary,
243
+ sourceBitcoindBinary: sourceBitcoindBinary.path,
244
+ };
245
+ }
246
+ function findBitcoinCoreDaemonBinary(root) {
247
+ for (const name of ['bitcoind', 'bitcoin-node', 'bitcoin']) {
248
+ const path = findExecutable(root, name);
249
+ if (path) {
250
+ return { name, path };
251
+ }
252
+ }
253
+ return undefined;
254
+ }
255
+ function findExecutable(root, name) {
256
+ if (!existsSync(root)) {
257
+ return undefined;
258
+ }
259
+ for (const entry of readdirSync(root)) {
260
+ const entryPath = join(root, entry);
261
+ const stat = statSync(entryPath);
262
+ if (stat.isDirectory()) {
263
+ const found = findExecutable(entryPath, name);
264
+ if (found) {
265
+ return found;
266
+ }
267
+ }
268
+ else if (entry === name) {
269
+ return entryPath;
270
+ }
271
+ }
272
+ return undefined;
273
+ }
274
+ function resolvePlatformConfig(config, platform, label) {
275
+ const platformConfig = config.platforms[platform] ?? config.platforms.current;
276
+ if (!platformConfig) {
277
+ throw new Error(`No ${label} is configured for ${platform}.`);
278
+ }
279
+ return platformConfig;
280
+ }
281
+ function requireCompletePlatformConfig(config, label) {
282
+ if (!config.url || !config.checksum) {
283
+ throw new Error(`${label} require both a URL and a checksum.`);
284
+ }
285
+ return {
286
+ checksum: config.checksum,
287
+ url: config.url,
288
+ };
289
+ }
290
+ function getCacheKey(config) {
291
+ return createHash('sha256')
292
+ .update(`${config.url}:${config.checksum}`)
293
+ .digest('hex');
294
+ }
295
+ async function verifyFileChecksum(filePath, expectedChecksum, label) {
296
+ const checksum = createHash('sha256')
297
+ .update(await readFile(filePath))
298
+ .digest('hex');
299
+ if (checksum !== expectedChecksum) {
300
+ throw new Error(`${label} checksum mismatch. Expected ${expectedChecksum}, got ${checksum}.`);
301
+ }
302
+ }
303
+ async function downloadFileFromUrl(url, destination) {
304
+ await mkdir(dirname(destination), { recursive: true });
305
+ await pipeline(await openDownloadStream(new URL(url)), createWriteStream(destination));
306
+ }
307
+ async function openDownloadStream(url, redirectsRemaining = 5) {
308
+ const request = url.protocol === 'http:' ? requestHttp : requestHttps;
309
+ return await new Promise((resolvePromise, rejectPromise) => {
310
+ const req = request(url, (response) => {
311
+ const { headers, statusCode, statusMessage } = response;
312
+ if (statusCode &&
313
+ statusCode >= 300 &&
314
+ statusCode < 400 &&
315
+ headers.location) {
316
+ response.resume();
317
+ if (redirectsRemaining <= 0) {
318
+ rejectPromise(new Error(`Too many redirects downloading ${url}`));
319
+ return;
320
+ }
321
+ openDownloadStream(new URL(headers.location, url), redirectsRemaining - 1)
322
+ .then(resolvePromise)
323
+ .catch(rejectPromise);
324
+ return;
325
+ }
326
+ if (!statusCode || statusCode < 200 || statusCode >= 300) {
327
+ response.resume();
328
+ rejectPromise(new Error(`Request to ${url} failed with ${statusCode ?? 'unknown'} ${statusMessage ?? ''}`.trim()));
329
+ return;
330
+ }
331
+ resolvePromise(response);
332
+ });
333
+ req.on('error', rejectPromise);
334
+ req.end();
335
+ });
336
+ }
337
+ async function extractTarGzArchive(archivePath, destination) {
338
+ await runCommand('tar', ['-xzf', archivePath, '-C', destination]);
339
+ }
340
+ async function runCommand(command, args) {
341
+ await new Promise((resolvePromise, rejectPromise) => {
342
+ const child = spawn(command, args, {
343
+ shell: false,
344
+ stdio: ['ignore', 'ignore', 'pipe'],
345
+ });
346
+ let stderr = '';
347
+ child.stderr.on('data', (chunk) => {
348
+ stderr += chunk.toString();
349
+ });
350
+ child.on('error', rejectPromise);
351
+ child.on('close', (code, signal) => {
352
+ if (code === 0) {
353
+ resolvePromise();
354
+ return;
355
+ }
356
+ const exitStatus = signal ? `signal ${signal}` : `code ${code ?? 'null'}`;
357
+ rejectPromise(new Error(`${command} ${args.join(' ')} failed with ${exitStatus}: ${stderr}`));
358
+ });
359
+ });
360
+ }
361
+ function getPlatformKey() {
362
+ const platform = osPlatform();
363
+ const arch = osArch();
364
+ if (platform === 'darwin' && arch === 'arm64') {
365
+ return 'darwin-arm64';
366
+ }
367
+ if (platform === 'darwin' && arch === 'x64') {
368
+ return 'darwin-x64';
369
+ }
370
+ if (platform === 'linux' && arch === 'arm64') {
371
+ return 'linux-arm64';
372
+ }
373
+ if (platform === 'linux' && arch === 'x64') {
374
+ return 'linux-x64';
375
+ }
376
+ return `${platform}-${arch}`;
377
+ }
378
+ function readCliValue(arg, value) {
379
+ if (!value || value.startsWith('--')) {
380
+ throw new Error(`${arg} requires a value.`);
381
+ }
382
+ return value;
383
+ }
384
+ function isFileMissingError(error) {
385
+ return (typeof error === 'object' &&
386
+ error !== null &&
387
+ Object.prototype.hasOwnProperty.call(error, 'code') &&
388
+ error.code === 'ENOENT');
389
+ }
390
+ //# sourceMappingURL=install.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.mjs","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,OAAO,EAAE,KAAK,EAAE,2BAA2B;AAC3C,OAAO,EAAE,UAAU,EAAE,oBAAoB;AACzC,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,WAAW,EACX,YAAY,EACZ,QAAQ,EACT,gBAAgB;AACjB,OAAO,EACL,KAAK,EACL,KAAK,EACL,QAAQ,EACR,MAAM,EACN,EAAE,EACF,MAAM,EACN,SAAS,EACV,yBAAyB;AAC1B,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,kBAAkB;AACnD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,mBAAmB;AACrD,OAAO,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yB;IAC1D,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,GAAG,GAAG,oBAAoB,CAAC,CAAC;IAC9C,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAc;IACxC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC;QAClD,KAA+B,CAAC,IAAI,KAAK,QAAQ,CACnD,CAAC;AACJ,CAAC","sourcesContent":["/* eslint-disable import-x/no-nodejs-modules, no-restricted-globals */\nimport { spawn } from 'node:child_process';\nimport { createHash } from 'node:crypto';\nimport {\n createWriteStream,\n existsSync,\n readdirSync,\n readFileSync,\n statSync,\n} from 'node:fs';\nimport {\n chmod,\n mkdir,\n readFile,\n rename,\n rm,\n unlink,\n writeFile,\n} from 'node:fs/promises';\nimport { request as requestHttp } from 'node:http';\nimport { request as requestHttps } from 'node:https';\nimport { arch as osArch, homedir, platform as osPlatform } from 'node:os';\nimport { dirname, join, resolve } from 'node:path';\nimport { pipeline } from 'node:stream/promises';\n\nconst BITCOIN_REGTEST_CACHE_NAMESPACE = 'bitcoin-regtest-up';\nconst BITCOIN_CORE_CACHE_NAMESPACE = 'bitcoin-core';\n\nexport type BitcoinRegtestArtifactConfig = {\n platforms: Record<string, BitcoinRegtestArtifactPlatformConfig | undefined>;\n version?: string;\n};\n\nexport type BitcoinRegtestArtifactPlatformConfig = {\n checksum: string;\n size?: number;\n url: string;\n};\n\nexport type BitcoinRegtestInstallOptions = {\n binDirectory?: string;\n bitcoinCore?: BitcoinRegtestArtifactConfig;\n cacheDirectory?: string;\n cwd?: string;\n platform?: string;\n};\n\nexport type BitcoinRegtestInstallResult = {\n bitcoinCliBinary: string;\n bitcoindBinary: string;\n cacheHit: boolean;\n checksum: string;\n sourceBitcoindArgs: string[];\n sourceBitcoinCliBinary: string;\n sourceBitcoindBinary: string;\n version?: string;\n};\n\nexport type BitcoinRegtestInstallDependencies = {\n downloadFile?: (url: string, destination: string) => Promise<void>;\n extractArchive?: (archivePath: string, destination: string) => Promise<void>;\n};\n\ntype BitcoinRegtestPackageJson = {\n 'bitcoin-regtest-up'?: BitcoinRegtestPackageJsonConfig;\n bitcoinRegtestUp?: BitcoinRegtestPackageJsonConfig;\n bitcoinregtestup?: BitcoinRegtestPackageJsonConfig;\n};\n\ntype BitcoinRegtestPackageJsonConfig = Pick<\n BitcoinRegtestInstallOptions,\n 'binDirectory' | 'bitcoinCore' | 'cacheDirectory'\n>;\n\nexport const BITCOIN_REGTEST_DEFAULT_CORE: BitcoinRegtestArtifactConfig = {\n version: '30.2',\n platforms: {\n 'darwin-arm64': {\n checksum:\n 'c2ecab62891de22228043815cb6211549a32272be3d5d052ff19847d3420bd10',\n url: 'https://bitcoincore.org/bin/bitcoin-core-30.2/bitcoin-30.2-arm64-apple-darwin.tar.gz',\n },\n 'darwin-x64': {\n checksum:\n '99d5cee9b9c37be506396c30837a4b98e320bfea71c474d6120a7e8eb6075c7b',\n url: 'https://bitcoincore.org/bin/bitcoin-core-30.2/bitcoin-30.2-x86_64-apple-darwin.tar.gz',\n },\n 'linux-arm64': {\n checksum:\n '73e76c14edc79808a0511c744d102ffbb494807ee90cbcba176568243254b532',\n url: 'https://bitcoincore.org/bin/bitcoin-core-30.2/bitcoin-30.2-aarch64-linux-gnu.tar.gz',\n },\n 'linux-x64': {\n checksum:\n '6aa7bb4feb699c4c6262dd23e4004191f6df7f373b5d5978b5bcdd4bb72f75d8',\n url: 'https://bitcoincore.org/bin/bitcoin-core-30.2/bitcoin-30.2-x86_64-linux-gnu.tar.gz',\n },\n },\n};\n\nexport function getBitcoinRegtestCacheDirectory({\n cwd = process.cwd(),\n homeDirectory = homedir(),\n}: {\n cwd?: string;\n homeDirectory?: string;\n} = {}): string {\n const yarnRcPath = join(cwd, '.yarnrc.yml');\n\n try {\n const yarnRc = readFileSync(yarnRcPath, 'utf8');\n if (/^\\s*enableGlobalCache:\\s*true\\s*$/mu.test(yarnRc)) {\n return join(homeDirectory, '.cache', 'metamask');\n }\n } catch (error) {\n if (!isFileMissingError(error)) {\n console.warn(\n `Warning: Error reading ${yarnRcPath}, using local bitcoin-regtest-up cache:`,\n error,\n );\n }\n }\n\n return join(cwd, '.metamask', 'cache');\n}\n\nexport function readBitcoinRegtestInstallOptionsFromPackageJson({\n cwd = process.cwd(),\n packageJsonPath = join(cwd, 'package.json'),\n}: {\n cwd?: string;\n packageJsonPath?: string;\n} = {}): BitcoinRegtestInstallOptions {\n const packageJson = JSON.parse(\n readFileSync(packageJsonPath, 'utf8'),\n ) as BitcoinRegtestPackageJson;\n const config =\n packageJson.bitcoinRegtestUp ??\n packageJson.bitcoinregtestup ??\n packageJson['bitcoin-regtest-up'];\n const options: BitcoinRegtestInstallOptions = {};\n\n if (config?.binDirectory) {\n options.binDirectory = config.binDirectory;\n }\n if (config?.bitcoinCore) {\n options.bitcoinCore = config.bitcoinCore;\n }\n if (config?.cacheDirectory) {\n options.cacheDirectory = config.cacheDirectory;\n }\n\n return options;\n}\n\nexport function parseBitcoinRegtestInstallCliOptions(\n args: string[],\n): BitcoinRegtestInstallOptions {\n const options: BitcoinRegtestInstallOptions = {};\n const bitcoinCore: Partial<BitcoinRegtestArtifactPlatformConfig> = {};\n\n for (let index = 0; index < args.length; index += 1) {\n const arg = args[index];\n const value = args[index + 1];\n\n switch (arg) {\n case '--bin-directory':\n options.binDirectory = readCliValue(arg, value);\n index += 1;\n break;\n case '--bitcoin-core-checksum':\n bitcoinCore.checksum = readCliValue(arg, value);\n index += 1;\n break;\n case '--bitcoin-core-url':\n bitcoinCore.url = readCliValue(arg, value);\n index += 1;\n break;\n case '--cache-directory':\n options.cacheDirectory = readCliValue(arg, value);\n index += 1;\n break;\n case '--platform':\n options.platform = readCliValue(arg, value);\n index += 1;\n break;\n default:\n throw new Error(`Unknown bitcoin-regtest-up install option: ${arg}`);\n }\n }\n\n if (bitcoinCore.url || bitcoinCore.checksum) {\n options.bitcoinCore = {\n platforms: {\n current: requireCompletePlatformConfig(\n bitcoinCore,\n 'Bitcoin Core CLI options',\n ),\n },\n };\n }\n\n return options;\n}\n\nexport async function installBitcoinRegtest(\n options: BitcoinRegtestInstallOptions = {},\n dependencies: BitcoinRegtestInstallDependencies = {},\n): Promise<BitcoinRegtestInstallResult> {\n const cwd = options.cwd ?? process.cwd();\n const cacheDirectory =\n options.cacheDirectory ?? getBitcoinRegtestCacheDirectory({ cwd });\n const binDirectory =\n options.binDirectory ?? join(cwd, 'node_modules', '.bin');\n const platformKey = options.platform ?? getPlatformKey();\n const bitcoinCore = options.bitcoinCore ?? BITCOIN_REGTEST_DEFAULT_CORE;\n const bitcoinCoreConfig = resolvePlatformConfig(\n bitcoinCore,\n platformKey,\n 'Bitcoin Core archive',\n );\n const bitcoinCoreResult = await installBitcoinCoreArchive(\n { cacheDirectory, config: bitcoinCoreConfig },\n dependencies,\n );\n const bitcoindBinary = await installExecutableWrapper({\n binDirectory,\n commandName: 'bitcoind',\n executableArgs: bitcoinCoreResult.sourceBitcoindArgs,\n executablePath: bitcoinCoreResult.sourceBitcoindBinary,\n });\n const bitcoinCliBinary = await installExecutableWrapper({\n binDirectory,\n commandName: 'bitcoin-cli',\n executablePath: bitcoinCoreResult.sourceBitcoinCliBinary,\n });\n\n return {\n bitcoinCliBinary,\n bitcoindBinary,\n cacheHit: bitcoinCoreResult.cacheHit,\n checksum: bitcoinCoreConfig.checksum,\n sourceBitcoindArgs: bitcoinCoreResult.sourceBitcoindArgs,\n sourceBitcoinCliBinary: bitcoinCoreResult.sourceBitcoinCliBinary,\n sourceBitcoindBinary: bitcoinCoreResult.sourceBitcoindBinary,\n version: bitcoinCore.version,\n };\n}\n\nexport async function cleanBitcoinRegtestCache(\n options: Pick<BitcoinRegtestInstallOptions, 'cacheDirectory' | 'cwd'> = {},\n): Promise<void> {\n const cwd = options.cwd ?? process.cwd();\n const cacheDirectory =\n options.cacheDirectory ?? getBitcoinRegtestCacheDirectory({ cwd });\n\n await rm(join(cacheDirectory, BITCOIN_REGTEST_CACHE_NAMESPACE), {\n force: true,\n recursive: true,\n });\n}\n\nasync function installBitcoinCoreArchive(\n {\n cacheDirectory,\n config,\n }: {\n cacheDirectory: string;\n config: BitcoinRegtestArtifactPlatformConfig;\n },\n dependencies: BitcoinRegtestInstallDependencies,\n): Promise<{\n cacheHit: boolean;\n sourceBitcoindArgs: string[];\n sourceBitcoinCliBinary: string;\n sourceBitcoindBinary: string;\n}> {\n const cacheKey = getCacheKey(config);\n const cacheRoot = join(\n cacheDirectory,\n BITCOIN_REGTEST_CACHE_NAMESPACE,\n BITCOIN_CORE_CACHE_NAMESPACE,\n cacheKey,\n );\n const checksumPath = join(cacheRoot, '.source-checksum');\n const cached = findBitcoinCoreBinaries(cacheRoot);\n\n if (\n cached &&\n existsSync(checksumPath) &&\n readFileSync(checksumPath, 'utf8') === config.checksum &&\n (await areBitcoinCoreBinariesRunnable(cached))\n ) {\n return { cacheHit: true, ...cached };\n }\n\n const tempRoot = `${cacheRoot}.downloading`;\n const archivePath = join(tempRoot, 'bitcoin-core.tar.gz');\n const downloadFile = dependencies.downloadFile ?? downloadFileFromUrl;\n const extractArchive = dependencies.extractArchive ?? extractTarGzArchive;\n\n await rm(tempRoot, { force: true, recursive: true });\n await rm(cacheRoot, { force: true, recursive: true });\n await mkdir(tempRoot, { recursive: true });\n\n try {\n await downloadFile(config.url, archivePath);\n await verifyFileChecksum(\n archivePath,\n config.checksum,\n 'Downloaded Bitcoin Core',\n );\n await extractArchive(archivePath, tempRoot);\n\n const binaries = findBitcoinCoreBinaries(tempRoot);\n if (!binaries) {\n throw new Error(\n 'Bitcoin Core archive did not contain a node daemon (bitcoind, bitcoin-node, or bitcoin) and bin/bitcoin-cli.',\n );\n }\n await assertBitcoinCoreBinariesRunnable(binaries);\n\n await writeFile(checksumPath.replace(cacheRoot, tempRoot), config.checksum);\n await mkdir(dirname(cacheRoot), { recursive: true });\n await rename(tempRoot, cacheRoot);\n\n return {\n cacheHit: false,\n sourceBitcoindArgs: binaries.sourceBitcoindArgs,\n sourceBitcoinCliBinary: binaries.sourceBitcoinCliBinary.replace(\n tempRoot,\n cacheRoot,\n ),\n sourceBitcoindBinary: binaries.sourceBitcoindBinary.replace(\n tempRoot,\n cacheRoot,\n ),\n };\n } catch (error) {\n await rm(tempRoot, { force: true, recursive: true });\n await rm(cacheRoot, { force: true, recursive: true });\n throw error;\n }\n}\n\nasync function installExecutableWrapper({\n binDirectory,\n commandName,\n executableArgs = [],\n executablePath,\n}: {\n binDirectory: string;\n commandName: string;\n executableArgs?: string[];\n executablePath: string;\n}): Promise<string> {\n const binaryPath = join(binDirectory, commandName);\n const resolvedExecutablePath = resolve(executablePath);\n\n await mkdir(binDirectory, { recursive: true });\n await unlink(binaryPath).catch((error) => {\n if (!isFileMissingError(error)) {\n throw error;\n }\n });\n await writeFile(\n binaryPath,\n `#!/usr/bin/env node\nconst { spawnSync } = require('node:child_process');\n\nconst executablePath = ${JSON.stringify(resolvedExecutablePath)};\nconst result = spawnSync(executablePath, ${JSON.stringify(executableArgs)}.concat(process.argv.slice(2)), {\n stdio: 'inherit',\n});\n\nif (result.error) {\n console.error(result.error.message);\n process.exit(1);\n}\n\nif (result.signal) {\n process.kill(process.pid, result.signal);\n}\n\nprocess.exit(result.status ?? 0);\n`,\n );\n await chmod(binaryPath, 0o755);\n\n return binaryPath;\n}\n\nasync function areBitcoinCoreBinariesRunnable(binaries: {\n sourceBitcoindArgs: string[];\n sourceBitcoinCliBinary: string;\n sourceBitcoindBinary: string;\n}): Promise<boolean> {\n try {\n await assertBitcoinCoreBinariesRunnable(binaries);\n return true;\n } catch {\n return false;\n }\n}\n\nasync function assertBitcoinCoreBinariesRunnable(binaries: {\n sourceBitcoindArgs: string[];\n sourceBitcoinCliBinary: string;\n sourceBitcoindBinary: string;\n}): Promise<void> {\n await runCommand(binaries.sourceBitcoindBinary, [\n ...binaries.sourceBitcoindArgs,\n '-version',\n ]);\n await runCommand(binaries.sourceBitcoinCliBinary, ['-version']);\n}\n\nfunction findBitcoinCoreBinaries(root: string):\n | {\n sourceBitcoindArgs: string[];\n sourceBitcoinCliBinary: string;\n sourceBitcoindBinary: string;\n }\n | undefined {\n const sourceBitcoinCliBinary = findExecutable(root, 'bitcoin-cli');\n const sourceBitcoindBinary = findBitcoinCoreDaemonBinary(root);\n\n if (!sourceBitcoindBinary || !sourceBitcoinCliBinary) {\n return undefined;\n }\n\n return {\n sourceBitcoindArgs: sourceBitcoindBinary.name === 'bitcoin' ? ['node'] : [],\n sourceBitcoinCliBinary,\n sourceBitcoindBinary: sourceBitcoindBinary.path,\n };\n}\n\nfunction findBitcoinCoreDaemonBinary(\n root: string,\n): { name: string; path: string } | undefined {\n for (const name of ['bitcoind', 'bitcoin-node', 'bitcoin']) {\n const path = findExecutable(root, name);\n if (path) {\n return { name, path };\n }\n }\n\n return undefined;\n}\n\nfunction findExecutable(root: string, name: string): string | undefined {\n if (!existsSync(root)) {\n return undefined;\n }\n\n for (const entry of readdirSync(root)) {\n const entryPath = join(root, entry);\n const stat = statSync(entryPath);\n if (stat.isDirectory()) {\n const found = findExecutable(entryPath, name);\n if (found) {\n return found;\n }\n } else if (entry === name) {\n return entryPath;\n }\n }\n\n return undefined;\n}\n\nfunction resolvePlatformConfig(\n config: BitcoinRegtestArtifactConfig,\n platform: string,\n label: string,\n): BitcoinRegtestArtifactPlatformConfig {\n const platformConfig = config.platforms[platform] ?? config.platforms.current;\n\n if (!platformConfig) {\n throw new Error(`No ${label} is configured for ${platform}.`);\n }\n\n return platformConfig;\n}\n\nfunction requireCompletePlatformConfig(\n config: Partial<BitcoinRegtestArtifactPlatformConfig>,\n label: string,\n): BitcoinRegtestArtifactPlatformConfig {\n if (!config.url || !config.checksum) {\n throw new Error(`${label} require both a URL and a checksum.`);\n }\n\n return {\n checksum: config.checksum,\n url: config.url,\n };\n}\n\nfunction getCacheKey(config: BitcoinRegtestArtifactPlatformConfig): string {\n return createHash('sha256')\n .update(`${config.url}:${config.checksum}`)\n .digest('hex');\n}\n\nasync function verifyFileChecksum(\n filePath: string,\n expectedChecksum: string,\n label: string,\n): Promise<void> {\n const checksum = createHash('sha256')\n .update(await readFile(filePath))\n .digest('hex');\n\n if (checksum !== expectedChecksum) {\n throw new Error(\n `${label} checksum mismatch. Expected ${expectedChecksum}, got ${checksum}.`,\n );\n }\n}\n\nasync function downloadFileFromUrl(\n url: string,\n destination: string,\n): Promise<void> {\n await mkdir(dirname(destination), { recursive: true });\n await pipeline(\n await openDownloadStream(new URL(url)),\n createWriteStream(destination),\n );\n}\n\nasync function openDownloadStream(\n url: URL,\n redirectsRemaining = 5,\n): Promise<NodeJS.ReadableStream> {\n const request = url.protocol === 'http:' ? requestHttp : requestHttps;\n\n return await new Promise((resolvePromise, rejectPromise) => {\n const req = request(url, (response) => {\n const { headers, statusCode, statusMessage } = response;\n\n if (\n statusCode &&\n statusCode >= 300 &&\n statusCode < 400 &&\n headers.location\n ) {\n response.resume();\n if (redirectsRemaining <= 0) {\n rejectPromise(new Error(`Too many redirects downloading ${url}`));\n return;\n }\n\n openDownloadStream(\n new URL(headers.location, url),\n redirectsRemaining - 1,\n )\n .then(resolvePromise)\n .catch(rejectPromise);\n return;\n }\n\n if (!statusCode || statusCode < 200 || statusCode >= 300) {\n response.resume();\n rejectPromise(\n new Error(\n `Request to ${url} failed with ${statusCode ?? 'unknown'} ${\n statusMessage ?? ''\n }`.trim(),\n ),\n );\n return;\n }\n\n resolvePromise(response);\n });\n\n req.on('error', rejectPromise);\n req.end();\n });\n}\n\nasync function extractTarGzArchive(\n archivePath: string,\n destination: string,\n): Promise<void> {\n await runCommand('tar', ['-xzf', archivePath, '-C', destination]);\n}\n\nasync function runCommand(command: string, args: string[]): Promise<void> {\n await new Promise<void>((resolvePromise, rejectPromise) => {\n const child = spawn(command, args, {\n shell: false,\n stdio: ['ignore', 'ignore', 'pipe'],\n });\n let stderr = '';\n\n child.stderr.on('data', (chunk) => {\n stderr += chunk.toString();\n });\n child.on('error', rejectPromise);\n child.on('close', (code, signal) => {\n if (code === 0) {\n resolvePromise();\n return;\n }\n const exitStatus = signal ? `signal ${signal}` : `code ${code ?? 'null'}`;\n rejectPromise(\n new Error(\n `${command} ${args.join(' ')} failed with ${exitStatus}: ${stderr}`,\n ),\n );\n });\n });\n}\n\nfunction getPlatformKey(): string {\n const platform = osPlatform();\n const arch = osArch();\n\n if (platform === 'darwin' && arch === 'arm64') {\n return 'darwin-arm64';\n }\n if (platform === 'darwin' && arch === 'x64') {\n return 'darwin-x64';\n }\n if (platform === 'linux' && arch === 'arm64') {\n return 'linux-arm64';\n }\n if (platform === 'linux' && arch === 'x64') {\n return 'linux-x64';\n }\n\n return `${platform}-${arch}`;\n}\n\nfunction readCliValue(arg: string, value: string | undefined): string {\n if (!value || value.startsWith('--')) {\n throw new Error(`${arg} requires a value.`);\n }\n\n return value;\n}\n\nfunction isFileMissingError(error: unknown): boolean {\n return (\n typeof error === 'object' &&\n error !== null &&\n Object.prototype.hasOwnProperty.call(error, 'code') &&\n (error as NodeJS.ErrnoException).code === 'ENOENT'\n );\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "@metamask-previews/bitcoin-regtest-up",
3
+ "version": "0.0.0-preview-82e080825",
4
+ "description": "Bitcoin Core regtest runtime installer for MetaMask E2E tests",
5
+ "keywords": [
6
+ "Ethereum",
7
+ "MetaMask"
8
+ ],
9
+ "homepage": "https://github.com/MetaMask/core/tree/main/packages/bitcoin-regtest-up#readme",
10
+ "bugs": {
11
+ "url": "https://github.com/MetaMask/core/issues"
12
+ },
13
+ "license": "(MIT OR Apache-2.0)",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/MetaMask/core.git"
17
+ },
18
+ "bin": "./dist/bin/bitcoin-regtest-up.mjs",
19
+ "files": [
20
+ "dist/"
21
+ ],
22
+ "sideEffects": false,
23
+ "main": "./dist/index.cjs",
24
+ "types": "./dist/index.d.cts",
25
+ "exports": {
26
+ ".": {
27
+ "import": {
28
+ "types": "./dist/index.d.mts",
29
+ "default": "./dist/index.mjs"
30
+ },
31
+ "require": {
32
+ "types": "./dist/index.d.cts",
33
+ "default": "./dist/index.cjs"
34
+ }
35
+ },
36
+ "./package.json": "./package.json"
37
+ },
38
+ "publishConfig": {
39
+ "access": "public",
40
+ "registry": "https://registry.npmjs.org/"
41
+ },
42
+ "scripts": {
43
+ "build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
44
+ "build:all": "ts-bridge --project tsconfig.build.json --verbose --clean",
45
+ "build:docs": "typedoc",
46
+ "changelog:update": "../../scripts/update-changelog.sh @metamask/bitcoin-regtest-up",
47
+ "changelog:validate": "../../scripts/validate-changelog.sh @metamask/bitcoin-regtest-up",
48
+ "messenger-action-types:check": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --check",
49
+ "messenger-action-types:generate": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --generate",
50
+ "since-latest-release": "../../scripts/since-latest-release.sh",
51
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
52
+ "test:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache",
53
+ "test:verbose": "NODE_OPTIONS=--experimental-vm-modules jest --verbose",
54
+ "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
55
+ },
56
+ "devDependencies": {
57
+ "@metamask/auto-changelog": "^6.1.0",
58
+ "@ts-bridge/cli": "^0.6.4",
59
+ "@types/jest": "^29.5.14",
60
+ "deepmerge": "^4.2.2",
61
+ "jest": "^29.7.0",
62
+ "ts-jest": "^29.2.5",
63
+ "tsx": "^4.20.5",
64
+ "typedoc": "^0.25.13",
65
+ "typedoc-plugin-missing-exports": "^2.0.0",
66
+ "typescript": "~5.3.3"
67
+ },
68
+ "engines": {
69
+ "node": "^18.18 || >=20"
70
+ }
71
+ }