Skip to content

Commit

Permalink
refactor: move walletKeys.ts to args/
Browse files Browse the repository at this point in the history
Issue: BTC-1351
  • Loading branch information
OttoAllmendinger committed Sep 26, 2024
1 parent 072e21d commit bb2a70d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
1 change: 1 addition & 0 deletions modules/utxo-bin/src/args/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './parseString';
export * from './walletKeys';
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ export function isWalletKeyName(name: string): name is utxolib.bitgo.KeyName {
return name === 'user' || name === 'backup' || name === 'bitgo';
}

export const keyOptions = {
userKey: { type: 'string', demandOption: true },
userKeyPrefix: { type: 'string', default: '0/0' },
backupKey: { type: 'string', demandOption: true },
backupKeyPrefix: { type: 'string', default: '0/0' },
bitgoKey: { type: 'string', demandOption: true },
bitgoKeyPrefix: { type: 'string', default: '0/0' },
} as const;

export type KeyOptions = {
userKey: string;
userKeyPrefix?: string;
Expand Down
16 changes: 2 additions & 14 deletions modules/utxo-bin/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { AddressParser } from './AddressParser';
import { parseUnknown } from './parseUnknown';
import { getParserTxProperties } from './ParserTx';
import { ScriptParser } from './ScriptParser';
import { readStringOptions, argToString, stringToBuffer } from './args';
import { argToString, KeyOptions, keyOptions, readStringOptions, stringToBuffer } from './args';
import {
formatAddressTree,
formatAddressWithFormatString,
Expand Down Expand Up @@ -68,26 +68,14 @@ type ArgsParseScript = {
script: string;
};

export type ArgsGenerateAddress = {
export type ArgsGenerateAddress = KeyOptions & {
network?: string;
userKey: string;
backupKey: string;
bitgoKey: string;
chain?: number[];
format: string;
index?: string[];
limit?: number;
};

const keyOptions = {
userKey: { type: 'string', demandOption: true },
userKeyPrefix: { type: 'string', default: '0/0' },
backupKey: { type: 'string', demandOption: true },
backupKeyPrefix: { type: 'string', default: '0/0' },
bitgoKey: { type: 'string', demandOption: true },
bitgoKeyPrefix: { type: 'string', default: '0/0' },
} as const;

type FormatStringArgs = {
format: OutputFormat;
all: boolean;
Expand Down
2 changes: 1 addition & 1 deletion modules/utxo-bin/src/generateAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as utxolib from '@bitgo/utxo-lib';
import { Parser } from './Parser';
import { parseUnknown } from './parseUnknown';
import { formatTree } from './format';
import { KeyOptions, getRootWalletKeys } from './walletKeys';
import { KeyOptions, getRootWalletKeys } from './args';

function getDefaultChainCodes(): number[] {
return utxolib.bitgo.chainCodes.filter(
Expand Down

0 comments on commit bb2a70d

Please sign in to comment.