Skip to content

Commit

Permalink
Merge pull request #4184 from BitGo/BTC-0.add-keyprefix-arg
Browse files Browse the repository at this point in the history
feat(utxo-bin): add arguments --{user,backup,bitgo}KeyPrefix
  • Loading branch information
OttoAllmendinger authored Jan 6, 2024
2 parents df4d8a6 + e7a9a03 commit 57880ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions modules/utxo-bin/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,11 @@ export const cmdGenerateAddress = {
return b
.option('network', { alias: 'n', type: 'string' })
.option('userKey', { type: 'string', demandOption: true })
.option('userKeyPrefix', { type: 'string', default: '0/0' })
.option('backupKey', { type: 'string', demandOption: true })
.option('backupKeyPrefix', { type: 'string', default: '0/0' })
.option('bitgoKey', { type: 'string', demandOption: true })
.option('bitgoKeyPrefix', { type: 'string', default: '0/0' })
.option('format', {
type: 'string',
default: '%p0\t%a',
Expand Down
9 changes: 8 additions & 1 deletion modules/utxo-bin/src/generateAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,22 @@ export function parseIndexRange(ranges: string[]): number[] {
export function* generateAddress(argv: {
network?: utxolib.Network;
userKey: string;
userKeyPrefix?: string;
backupKey: string;
backupKeyPrefix?: string;
bitgoKey: string;
bitgoKeyPrefix?: string;
chain?: number[];
format: string;
index: number[];
}): Generator<AddressProperties> {
const xpubs = [argv.userKey, argv.backupKey, argv.bitgoKey].map((k) => utxolib.bip32.fromBase58(k));
assert(utxolib.bitgo.isTriple(xpubs));
const rootXpubs = new utxolib.bitgo.RootWalletKeys(xpubs);
const rootXpubs = new utxolib.bitgo.RootWalletKeys(xpubs, [
argv.userKeyPrefix ?? utxolib.bitgo.RootWalletKeys.defaultPrefix,
argv.backupKeyPrefix ?? utxolib.bitgo.RootWalletKeys.defaultPrefix,
argv.bitgoKeyPrefix ?? utxolib.bitgo.RootWalletKeys.defaultPrefix,
]);
const chains = argv.chain ?? getDefaultChainCodes();
for (const i of argv.index) {
for (const chain of chains) {
Expand Down

0 comments on commit 57880ca

Please sign in to comment.