From 5fa4bdbda2b9764b014f4891e3104004991be229 Mon Sep 17 00:00:00 2001 From: Otto Allmendinger Date: Wed, 2 Oct 2024 17:01:04 +0200 Subject: [PATCH 1/3] refactor(utxo-bin): add formatTreeOrJson Factor out common argument for tree or json output format into a shared constant. Issue: BTC-1351 --- modules/utxo-bin/src/args/format.ts | 13 +++++++++++++ modules/utxo-bin/src/args/index.ts | 1 + modules/utxo-bin/src/commands/cmdParseAddress.ts | 7 +++---- modules/utxo-bin/src/commands/cmdParseScript.ts | 7 +++---- modules/utxo-bin/src/commands/cmdParseTx.ts | 15 +++++++++++---- modules/utxo-bin/src/commands/formatString.ts | 5 ++--- 6 files changed, 33 insertions(+), 15 deletions(-) create mode 100644 modules/utxo-bin/src/args/format.ts diff --git a/modules/utxo-bin/src/args/format.ts b/modules/utxo-bin/src/args/format.ts new file mode 100644 index 0000000000..2284e1178a --- /dev/null +++ b/modules/utxo-bin/src/args/format.ts @@ -0,0 +1,13 @@ +export type FormatTreeOrJson = 'tree' | 'json'; + +export const formatTreeOrJson = { + type: 'string', + choices: ['tree', 'json'] as const, + default: 'tree', + coerce(arg: string): 'tree' | 'json' { + if (arg !== 'tree' && arg !== 'json') { + throw new Error(`invalid format ${arg}`); + } + return arg; + }, +} as const; diff --git a/modules/utxo-bin/src/args/index.ts b/modules/utxo-bin/src/args/index.ts index 264640f0a8..6367e269ba 100644 --- a/modules/utxo-bin/src/args/index.ts +++ b/modules/utxo-bin/src/args/index.ts @@ -1,3 +1,4 @@ export * from './parseString'; export * from './walletKeys'; export * from './parseNetwork'; +export * from './format'; diff --git a/modules/utxo-bin/src/commands/cmdParseAddress.ts b/modules/utxo-bin/src/commands/cmdParseAddress.ts index 3d37b004d1..4a74a56a0c 100644 --- a/modules/utxo-bin/src/commands/cmdParseAddress.ts +++ b/modules/utxo-bin/src/commands/cmdParseAddress.ts @@ -2,15 +2,14 @@ import * as utxolib from '@bitgo/utxo-lib'; import * as yargs from 'yargs'; import { AddressParser } from '../AddressParser'; -import { getNetworkOptions } from '../args'; +import { formatTreeOrJson, getNetworkOptions, FormatTreeOrJson } from '../args'; -import { OutputFormat } from './cmdParseTx'; import { formatString } from './formatString'; export type ArgsParseAddress = { network?: utxolib.Network; all: boolean; - format: OutputFormat; + format: FormatTreeOrJson; convert: boolean; address: string; }; @@ -26,7 +25,7 @@ export const cmdParseAddress = { builder(b: yargs.Argv): yargs.Argv { return b .options(getNetworkOptions()) - .option('format', { choices: ['tree', 'json'], default: 'tree' } as const) + .option('format', formatTreeOrJson) .option('convert', { type: 'boolean', default: false }) .option('all', { type: 'boolean', default: false }) .positional('address', { type: 'string', demandOption: true }); diff --git a/modules/utxo-bin/src/commands/cmdParseScript.ts b/modules/utxo-bin/src/commands/cmdParseScript.ts index 1fd6012779..fb2b8d212a 100644 --- a/modules/utxo-bin/src/commands/cmdParseScript.ts +++ b/modules/utxo-bin/src/commands/cmdParseScript.ts @@ -2,14 +2,13 @@ import * as utxolib from '@bitgo/utxo-lib'; import * as yargs from 'yargs'; import { ScriptParser } from '../ScriptParser'; -import { getNetworkOptions, stringToBuffer } from '../args'; +import { formatTreeOrJson, getNetworkOptions, FormatTreeOrJson, stringToBuffer } from '../args'; -import { OutputFormat } from './cmdParseTx'; import { formatString } from './formatString'; export type ArgsParseScript = { network?: utxolib.Network; - format: OutputFormat; + format: FormatTreeOrJson; all: boolean; script: string; }; @@ -24,7 +23,7 @@ export const cmdParseScript = { builder(b: yargs.Argv): yargs.Argv { return b .options(getNetworkOptions()) - .option('format', { choices: ['tree', 'json'], default: 'tree' } as const) + .option('format', formatTreeOrJson) .option('all', { type: 'boolean', default: false }) .positional('script', { type: 'string', demandOption: true }); }, diff --git a/modules/utxo-bin/src/commands/cmdParseTx.ts b/modules/utxo-bin/src/commands/cmdParseTx.ts index cd3bc422c8..c32cb4bc0c 100644 --- a/modules/utxo-bin/src/commands/cmdParseTx.ts +++ b/modules/utxo-bin/src/commands/cmdParseTx.ts @@ -1,7 +1,15 @@ import * as utxolib from '@bitgo/utxo-lib'; import * as yargs from 'yargs'; -import { argToString, getNetworkOptionsDemand, ReadStringOptions, readStringOptions, stringToBuffer } from '../args'; +import { + argToString, + formatTreeOrJson, + getNetworkOptionsDemand, + FormatTreeOrJson, + ReadStringOptions, + readStringOptions, + stringToBuffer, +} from '../args'; import { TxParser, TxParserArgs } from '../TxParser'; import { fetchOutputSpends, @@ -17,7 +25,6 @@ import { Parser } from '../Parser'; import { formatString } from './formatString'; -export type OutputFormat = 'tree' | 'json'; export type ArgsParseTransaction = ReadStringOptions & { network: utxolib.Network; txid?: string; @@ -25,7 +32,7 @@ export type ArgsParseTransaction = ReadStringOptions & { txIndex?: number; all: boolean; cache: boolean; - format: OutputFormat; + format: FormatTreeOrJson; fetchAll: boolean; fetchStatus: boolean; fetchInputs: boolean; @@ -95,7 +102,7 @@ export const cmdParseTx = { default: false, description: 'use local cache for http responses', }) - .option('format', { choices: ['tree', 'json'], default: 'tree' } as const) + .option('format', formatTreeOrJson) .option('parseError', { choices: ['continue', 'throw'], default: 'continue' } as const); }, diff --git a/modules/utxo-bin/src/commands/formatString.ts b/modules/utxo-bin/src/commands/formatString.ts index e63090081b..b5cc96b129 100644 --- a/modules/utxo-bin/src/commands/formatString.ts +++ b/modules/utxo-bin/src/commands/formatString.ts @@ -2,11 +2,10 @@ import * as yargs from 'yargs'; import { ParserNode } from '../Parser'; import { formatTree } from '../format'; - -import { OutputFormat } from './cmdParseTx'; +import { FormatTreeOrJson } from '../args'; export type FormatStringArgs = { - format: OutputFormat; + format: FormatTreeOrJson; all: boolean; }; From a96ecc76f1a6f5bb61076831958c32169db4d7a9 Mon Sep 17 00:00:00 2001 From: Otto Allmendinger Date: Wed, 2 Oct 2024 16:32:39 +0200 Subject: [PATCH 2/3] refactor(utxo-bin): add bip32 subcommand Now we have a new command `bip32` that has two subcommands: - `parse` that takes a bip32 key and shows its info - `generateFromSeed` that generates a bip32 key from a seed This replaces the `parseXpub` command. Issue: BTC-1351 --- modules/utxo-bin/bin/index.ts | 4 +- modules/utxo-bin/src/bip32.ts | 17 +++--- modules/utxo-bin/src/commands/cmdBip32.ts | 60 +++++++++++++++++++ modules/utxo-bin/src/commands/cmdParseXpub.ts | 32 ---------- modules/utxo-bin/src/commands/index.ts | 2 +- modules/utxo-bin/test/bip32.ts | 19 +++--- ...kfEBC9nuFibB2cjiKXYUwrZ7q8aMRbpWA7N2Pt.txt | 12 ++++ ...nuFibB2cjiKXYUwrZ7q8aMRbpWA7N2Pt_m_0_0.txt | 12 ++++ ...p7YJTAeVRfQMkjFjyTw8GzJiNaPQifio_m_0_0.txt | 11 ++++ ...1d5TdKzUKEL1di1ZevzZEyUg13vEBzFs5ciRm7.txt | 11 ---- ...zUKEL1di1ZevzZEyUg13vEBzFs5ciRm7_m_0_0.txt | 11 ---- 11 files changed, 117 insertions(+), 74 deletions(-) create mode 100644 modules/utxo-bin/src/commands/cmdBip32.ts delete mode 100644 modules/utxo-bin/src/commands/cmdParseXpub.ts create mode 100644 modules/utxo-bin/test/fixtures/bip32/xprv9s21ZrQH143K2Fnv8HGStbw1ckdpUZkV5DLHGmw82uiQo1rY59ZiZYhpG2u5HGENgJ5eykfEBC9nuFibB2cjiKXYUwrZ7q8aMRbpWA7N2Pt.txt create mode 100644 modules/utxo-bin/test/fixtures/bip32/xprv9s21ZrQH143K2Fnv8HGStbw1ckdpUZkV5DLHGmw82uiQo1rY59ZiZYhpG2u5HGENgJ5eykfEBC9nuFibB2cjiKXYUwrZ7q8aMRbpWA7N2Pt_m_0_0.txt create mode 100644 modules/utxo-bin/test/fixtures/bip32/xpub661MyMwAqRbcEjsPEJoTFjskAnUJt2ULSSFt5ALjbFFPfpBgcgsy7M2J7Kz66TNWwfYUBSKbhqNp7YJTAeVRfQMkjFjyTw8GzJiNaPQifio_m_0_0.txt delete mode 100644 modules/utxo-bin/test/fixtures/xpub/xpub661MyMwAqRbcFeZWpTJmysmtDt8q8fz671p5CKGbHe2WuJvJD2kBfdooYurUNqQ9SF6cK1d5TdKzUKEL1di1ZevzZEyUg13vEBzFs5ciRm7.txt delete mode 100644 modules/utxo-bin/test/fixtures/xpub/xpub661MyMwAqRbcFeZWpTJmysmtDt8q8fz671p5CKGbHe2WuJvJD2kBfdooYurUNqQ9SF6cK1d5TdKzUKEL1di1ZevzZEyUg13vEBzFs5ciRm7_m_0_0.txt diff --git a/modules/utxo-bin/bin/index.ts b/modules/utxo-bin/bin/index.ts index e204835e9a..845ce2c057 100644 --- a/modules/utxo-bin/bin/index.ts +++ b/modules/utxo-bin/bin/index.ts @@ -1,14 +1,14 @@ #!/usr/bin/env node import * as yargs from 'yargs'; -import { cmdParseTx, cmdParseAddress, cmdParseScript, cmdGenerateAddress, cmdParseXpub } from '../src/commands'; +import { cmdParseTx, cmdParseScript, cmdBip32, cmdGenerateAddress, cmdParseAddress } from '../src/commands'; yargs .command(cmdParseTx) .command(cmdParseAddress) .command(cmdParseScript) .command(cmdGenerateAddress) - .command(cmdParseXpub) + .command(cmdBip32) .demandCommand() .help() .parse(); diff --git a/modules/utxo-bin/src/bip32.ts b/modules/utxo-bin/src/bip32.ts index 03d2f176ae..a46350e9b0 100644 --- a/modules/utxo-bin/src/bip32.ts +++ b/modules/utxo-bin/src/bip32.ts @@ -3,18 +3,19 @@ import * as utxolib from '@bitgo/utxo-lib'; import { Parser, ParserNode } from './Parser'; import { parseUnknown } from './parseUnknown'; -export function parseXpub(xpub: string, params: { derive?: string }): ParserNode { - if (!xpub.startsWith('xpub')) { - throw new Error('expected xpub'); - } +export function parseBip32(bip32Key: string, params: { derive?: string }): ParserNode { const parser = new Parser(); - let xpubObj = utxolib.bip32.fromBase58(xpub); + let bip32 = utxolib.bip32.fromBase58(bip32Key); if (params.derive) { - xpubObj = xpubObj.derivePath(params.derive); + bip32 = bip32.derivePath(params.derive); } - const node = parseUnknown(parser, 'xpub', xpubObj, { + const label = bip32.isNeutered() ? 'xpub' : 'xprv'; + const node = parseUnknown(parser, label, bip32, { omit: ['network', '__Q', '__D', '__DEPTH', '__INDEX', '__PARENT_FINGERPRINT'], }); - node.value = xpubObj.toBase58(); + if (!bip32.isNeutered()) { + node.nodes?.unshift(parser.node('xpub', bip32.neutered().toBase58())); + } + node.value = bip32.toBase58(); return node; } diff --git a/modules/utxo-bin/src/commands/cmdBip32.ts b/modules/utxo-bin/src/commands/cmdBip32.ts new file mode 100644 index 0000000000..9c290b789f --- /dev/null +++ b/modules/utxo-bin/src/commands/cmdBip32.ts @@ -0,0 +1,60 @@ +import * as crypto from 'crypto'; + +import * as yargs from 'yargs'; +import { CommandModule } from 'yargs'; +import * as utxolib from '@bitgo/utxo-lib'; + +import { parseBip32 } from '../bip32'; +import { formatTreeOrJson, FormatTreeOrJson } from '../args'; + +import { formatString } from './formatString'; + +type ArgsBip32Generate = { + format: FormatTreeOrJson; + bip32Key: string; + derive?: string; + all: boolean; +}; + +export const cmdBip32Parse: CommandModule = { + command: 'parse [xpub|xprv]', + describe: 'show xpub info', + builder(b: yargs.Argv): yargs.Argv { + return b + .options({ format: formatTreeOrJson }) + .positional('bip32Key', { type: 'string', demandOption: true }) + .option('all', { type: 'boolean', default: false }) + .option('derive', { type: 'string', description: 'show xpub derived with path' }); + }, + handler(argv): void { + console.log(formatString(parseBip32(argv.bip32Key, { derive: argv.derive }), argv)); + }, +}; + +type GenerateBip32Args = { + seed: string; +}; + +export const cmdBip32Generate: CommandModule = { + command: 'generateFromSeed', + describe: 'generate keypair from seed - do not use for real keys!', + builder(b) { + return b.option('seed', { type: 'string', demandOption: true, default: 'setec astronomy' }); + }, + handler(argv) { + const key = utxolib.bip32.fromSeed(crypto.createHash('sha256').update(argv.seed).digest()); + console.log(key.toBase58()); + console.log(key.neutered().toBase58()); + }, +}; + +export const cmdBip32: CommandModule = { + command: 'bip32 ', + describe: 'bip32 commands', + builder(b: yargs.Argv): yargs.Argv { + return b.strict().command(cmdBip32Parse).command(cmdBip32Generate).demandCommand(); + }, + handler(): void { + // do nothing + }, +}; diff --git a/modules/utxo-bin/src/commands/cmdParseXpub.ts b/modules/utxo-bin/src/commands/cmdParseXpub.ts deleted file mode 100644 index 83988bf49c..0000000000 --- a/modules/utxo-bin/src/commands/cmdParseXpub.ts +++ /dev/null @@ -1,32 +0,0 @@ -import * as yargs from 'yargs'; - -import { parseXpub } from '../bip32'; - -import { formatString, FormatStringArgs } from './formatString'; - -export const cmdParseXpub = { - command: 'parseXpub [xpub]', - describe: 'show xpub info', - builder(b: yargs.Argv): yargs.Argv< - { - xpub: string; - derive?: string; - } & FormatStringArgs - > { - return b - .positional('xpub', { type: 'string', demandOption: true }) - .option('format', { choices: ['tree', 'json'], default: 'tree' } as const) - .option('all', { type: 'boolean', default: false }) - .option('derive', { type: 'string', description: 'show xpub derived with path' }); - }, - handler( - argv: yargs.Arguments< - { - xpub: string; - derive?: string; - } & FormatStringArgs - > - ): void { - console.log(formatString(parseXpub(argv.xpub, { derive: argv.derive }), argv)); - }, -}; diff --git a/modules/utxo-bin/src/commands/index.ts b/modules/utxo-bin/src/commands/index.ts index eb135ca9a3..96b6dd2da9 100644 --- a/modules/utxo-bin/src/commands/index.ts +++ b/modules/utxo-bin/src/commands/index.ts @@ -2,4 +2,4 @@ export * from './cmdParseTx'; export * from './cmdParseAddress'; export * from './cmdParseScript'; export * from './cmdGenerateAddress'; -export * from './cmdParseXpub'; +export * from './cmdBip32'; diff --git a/modules/utxo-bin/test/bip32.ts b/modules/utxo-bin/test/bip32.ts index 418153d410..319bd4f713 100644 --- a/modules/utxo-bin/test/bip32.ts +++ b/modules/utxo-bin/test/bip32.ts @@ -1,22 +1,23 @@ import * as assert from 'assert'; -import { parseXpub } from '../src/bip32'; +import { parseBip32 } from '../src/bip32'; import { formatTreeNoColor, getFixtureString } from './fixtures'; import { getKey } from './bip32.util'; -function runTest(xpub: string, args: { derive?: string }) { - describe('parse xpub', function () { - it('parses xpub', async function () { - const formatted = formatTreeNoColor(parseXpub(xpub, args), { showAll: true }); - const filename = [xpub]; +function runTest(bip32Key: string, args: { derive?: string }) { + describe(`parse bip32 ${JSON.stringify(args)}`, function () { + it('has expected output', async function () { + const formatted = formatTreeNoColor(parseBip32(bip32Key, args), { showAll: true }); + const filename = [bip32Key]; if (args.derive) { filename.push(args.derive.replace(/\//g, '_')); } - assert.strictEqual(await getFixtureString(`test/fixtures/xpub/${filename.join('_')}.txt`, formatted), formatted); + assert.strictEqual(await getFixtureString(`test/fixtures/bip32/${filename.join('_')}.txt`, formatted), formatted); }); }); } -runTest(getKey('parseXpub').neutered().toBase58(), {}); -runTest(getKey('parseXpub').neutered().toBase58(), { derive: 'm/0/0' }); +runTest(getKey('bip32').toBase58(), {}); +runTest(getKey('bip32').toBase58(), { derive: 'm/0/0' }); +runTest(getKey('bip32').neutered().toBase58(), { derive: 'm/0/0' }); diff --git a/modules/utxo-bin/test/fixtures/bip32/xprv9s21ZrQH143K2Fnv8HGStbw1ckdpUZkV5DLHGmw82uiQo1rY59ZiZYhpG2u5HGENgJ5eykfEBC9nuFibB2cjiKXYUwrZ7q8aMRbpWA7N2Pt.txt b/modules/utxo-bin/test/fixtures/bip32/xprv9s21ZrQH143K2Fnv8HGStbw1ckdpUZkV5DLHGmw82uiQo1rY59ZiZYhpG2u5HGENgJ5eykfEBC9nuFibB2cjiKXYUwrZ7q8aMRbpWA7N2Pt.txt new file mode 100644 index 0000000000..55b036439c --- /dev/null +++ b/modules/utxo-bin/test/fixtures/bip32/xprv9s21ZrQH143K2Fnv8HGStbw1ckdpUZkV5DLHGmw82uiQo1rY59ZiZYhpG2u5HGENgJ5eykfEBC9nuFibB2cjiKXYUwrZ7q8aMRbpWA7N2Pt.txt @@ -0,0 +1,12 @@ +xprv: xprv9s21ZrQH143K2Fnv8HGStbw1ckdpUZkV5DLHGmw82uiQo1rY59ZiZYhpG2u5HGENgJ5eykfEBC9nuFibB2cjiKXYUwrZ7q8aMRbpWA7N2Pt +├── xpub: xpub661MyMwAqRbcEjsPEJoTFjskAnUJt2ULSSFt5ALjbFFPfpBgcgsy7M2J7Kz66TNWwfYUBSKbhqNp7YJTAeVRfQMkjFjyTw8GzJiNaPQifio +├── lowR: false +├── chainCode: 13cd969b6f5948b45fe7a5e3e22e9d94830c82e9c2b61448af16565131736757 (32 bytes) +├── depth: 0 +├── index: 0 +├── parentFingerprint: 0 +├── identifier: c3b7cdefd973965dd7aef07784908ed11a3e13fb (20 bytes) +├── fingerprint: c3b7cdef (4 bytes) +├── compressed: true +├── publicKey: 03faab4c92cfdb174adb4df27dddbd984dcec499d57b308a6ae343876d8015d0da (33 bytes) +└── privateKey: ebe706fb107727a8af3a75ef3c96672c9ddf4ccd4377b047df7ec43a5020c1ab (32 bytes) diff --git a/modules/utxo-bin/test/fixtures/bip32/xprv9s21ZrQH143K2Fnv8HGStbw1ckdpUZkV5DLHGmw82uiQo1rY59ZiZYhpG2u5HGENgJ5eykfEBC9nuFibB2cjiKXYUwrZ7q8aMRbpWA7N2Pt_m_0_0.txt b/modules/utxo-bin/test/fixtures/bip32/xprv9s21ZrQH143K2Fnv8HGStbw1ckdpUZkV5DLHGmw82uiQo1rY59ZiZYhpG2u5HGENgJ5eykfEBC9nuFibB2cjiKXYUwrZ7q8aMRbpWA7N2Pt_m_0_0.txt new file mode 100644 index 0000000000..b525e4fff3 --- /dev/null +++ b/modules/utxo-bin/test/fixtures/bip32/xprv9s21ZrQH143K2Fnv8HGStbw1ckdpUZkV5DLHGmw82uiQo1rY59ZiZYhpG2u5HGENgJ5eykfEBC9nuFibB2cjiKXYUwrZ7q8aMRbpWA7N2Pt_m_0_0.txt @@ -0,0 +1,12 @@ +xprv: xprv9wLeZuTuzBVPggSspWwPzWp9WDL2NTDx5KhyfS3MNGdMpoYME6dZzXVukBSj1sWAJttfUoXck2GrnFHV2sUpmcRiFv26YGSe373QvEaMKpc +├── xpub: xpub6AKzyQzopZ3guAXLvYUQMekt4FAWmuwoSYdaTpSxvcALhbsVmdwpYKpPbST69B5kuSSn5LJFoGSmkcohTCc2Q5kjfa5vcuJaSVEqBY7B2Qk +├── lowR: false +├── chainCode: 4161a1f543ed7c95cc138bd8bfca549a9ba304349e926c6a0bc612a0c5a4e293 (32 bytes) +├── depth: 2 +├── index: 0 +├── parentFingerprint: 1273784303 +├── identifier: 7f8e7c282a46dbeb6b2634faea4d204eaad4eb85 (20 bytes) +├── fingerprint: 7f8e7c28 (4 bytes) +├── compressed: true +├── publicKey: 0224051902c8f2ccd8cf2f27bc5b25dfa12f84573b994007a0943acdd764d873f3 (33 bytes) +└── privateKey: 27340d788194503cf1fd5a1b453e3400537f0c26d40f317211a36d02435584f4 (32 bytes) diff --git a/modules/utxo-bin/test/fixtures/bip32/xpub661MyMwAqRbcEjsPEJoTFjskAnUJt2ULSSFt5ALjbFFPfpBgcgsy7M2J7Kz66TNWwfYUBSKbhqNp7YJTAeVRfQMkjFjyTw8GzJiNaPQifio_m_0_0.txt b/modules/utxo-bin/test/fixtures/bip32/xpub661MyMwAqRbcEjsPEJoTFjskAnUJt2ULSSFt5ALjbFFPfpBgcgsy7M2J7Kz66TNWwfYUBSKbhqNp7YJTAeVRfQMkjFjyTw8GzJiNaPQifio_m_0_0.txt new file mode 100644 index 0000000000..16e09a3cfa --- /dev/null +++ b/modules/utxo-bin/test/fixtures/bip32/xpub661MyMwAqRbcEjsPEJoTFjskAnUJt2ULSSFt5ALjbFFPfpBgcgsy7M2J7Kz66TNWwfYUBSKbhqNp7YJTAeVRfQMkjFjyTw8GzJiNaPQifio_m_0_0.txt @@ -0,0 +1,11 @@ +xpub: xpub6AKzyQzopZ3guAXLvYUQMekt4FAWmuwoSYdaTpSxvcALhbsVmdwpYKpPbST69B5kuSSn5LJFoGSmkcohTCc2Q5kjfa5vcuJaSVEqBY7B2Qk +├── lowR: false +├── chainCode: 4161a1f543ed7c95cc138bd8bfca549a9ba304349e926c6a0bc612a0c5a4e293 (32 bytes) +├── depth: 2 +├── index: 0 +├── parentFingerprint: 1273784303 +├── identifier: 7f8e7c282a46dbeb6b2634faea4d204eaad4eb85 (20 bytes) +├── fingerprint: 7f8e7c28 (4 bytes) +├── compressed: true +├── publicKey: 0224051902c8f2ccd8cf2f27bc5b25dfa12f84573b994007a0943acdd764d873f3 (33 bytes) +└── privateKey: undefined diff --git a/modules/utxo-bin/test/fixtures/xpub/xpub661MyMwAqRbcFeZWpTJmysmtDt8q8fz671p5CKGbHe2WuJvJD2kBfdooYurUNqQ9SF6cK1d5TdKzUKEL1di1ZevzZEyUg13vEBzFs5ciRm7.txt b/modules/utxo-bin/test/fixtures/xpub/xpub661MyMwAqRbcFeZWpTJmysmtDt8q8fz671p5CKGbHe2WuJvJD2kBfdooYurUNqQ9SF6cK1d5TdKzUKEL1di1ZevzZEyUg13vEBzFs5ciRm7.txt deleted file mode 100644 index cd386aa5fd..0000000000 --- a/modules/utxo-bin/test/fixtures/xpub/xpub661MyMwAqRbcFeZWpTJmysmtDt8q8fz671p5CKGbHe2WuJvJD2kBfdooYurUNqQ9SF6cK1d5TdKzUKEL1di1ZevzZEyUg13vEBzFs5ciRm7.txt +++ /dev/null @@ -1,11 +0,0 @@ -xpub: xpub661MyMwAqRbcFeZWpTJmysmtDt8q8fz671p5CKGbHe2WuJvJD2kBfdooYurUNqQ9SF6cK1d5TdKzUKEL1di1ZevzZEyUg13vEBzFs5ciRm7 -├── lowR: false -├── chainCode: 6f0d6b0d74f69ac6b05060a15c70d3fd67611375c4c3ced77924f914a268fcf2 (32 bytes) -├── depth: 0 -├── index: 0 -├── parentFingerprint: 0 -├── identifier: 1c567490638d7b6e3dbaa82e74d204ee8ffb6a27 (20 bytes) -├── fingerprint: 1c567490 (4 bytes) -├── compressed: true -├── publicKey: 03ef4ca69c4b8c2c3b7a9e0bfed84d9daddcdb195953e9c67cbcc10c5e16c5597a (33 bytes) -└── privateKey: undefined diff --git a/modules/utxo-bin/test/fixtures/xpub/xpub661MyMwAqRbcFeZWpTJmysmtDt8q8fz671p5CKGbHe2WuJvJD2kBfdooYurUNqQ9SF6cK1d5TdKzUKEL1di1ZevzZEyUg13vEBzFs5ciRm7_m_0_0.txt b/modules/utxo-bin/test/fixtures/xpub/xpub661MyMwAqRbcFeZWpTJmysmtDt8q8fz671p5CKGbHe2WuJvJD2kBfdooYurUNqQ9SF6cK1d5TdKzUKEL1di1ZevzZEyUg13vEBzFs5ciRm7_m_0_0.txt deleted file mode 100644 index 613e6a2f32..0000000000 --- a/modules/utxo-bin/test/fixtures/xpub/xpub661MyMwAqRbcFeZWpTJmysmtDt8q8fz671p5CKGbHe2WuJvJD2kBfdooYurUNqQ9SF6cK1d5TdKzUKEL1di1ZevzZEyUg13vEBzFs5ciRm7_m_0_0.txt +++ /dev/null @@ -1,11 +0,0 @@ -xpub: xpub6BQWUhRNV9BJZkzgvk9SMkUvXQCqo87nqQSwkpJLzxXWjmC61SujvtjpzsWiJFMdsYh51WHqGAg75Ck6qyeFD7U4zDURim11Xn8PWrbTfGD -├── lowR: false -├── chainCode: d9271cc20cab75075ac78ccf5ddf9cef1782818766687ff8aabd19ad37489a81 (32 bytes) -├── depth: 2 -├── index: 0 -├── parentFingerprint: 3733780091 -├── identifier: dd065ccd3af95f7afe3d9779d3ab6b9c8bfc4af5 (20 bytes) -├── fingerprint: dd065ccd (4 bytes) -├── compressed: true -├── publicKey: 034067f34da6d758623bc65937765470d67ba042d08891a2d0d9b4972565ff4d41 (33 bytes) -└── privateKey: undefined From 824ed100fa45b6c6161230114f3de796797e16ea Mon Sep 17 00:00:00 2001 From: Otto Allmendinger Date: Wed, 2 Oct 2024 17:45:16 +0200 Subject: [PATCH 3/3] feat(utxo-bin): add strict mode to yargs This has the effect of making yargs fail if an unknown command is passed. Issue: BTC-1351 --- modules/utxo-bin/bin/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/utxo-bin/bin/index.ts b/modules/utxo-bin/bin/index.ts index 845ce2c057..d59f8fc3e8 100644 --- a/modules/utxo-bin/bin/index.ts +++ b/modules/utxo-bin/bin/index.ts @@ -9,6 +9,7 @@ yargs .command(cmdParseScript) .command(cmdGenerateAddress) .command(cmdBip32) + .strict() .demandCommand() .help() .parse();