From 8b75c8201846317d9beefe69968d7977d5baa205 Mon Sep 17 00:00:00 2001 From: Rahul Patni Date: Mon, 9 Dec 2024 09:16:06 -0800 Subject: [PATCH] wallet:ledger:address CLI command CLI command that displays the wallet address of the connected Ledger device. --- .../src/commands/wallet/ledger/address.ts | 29 +++++++++++++++++++ ironfish-cli/src/ledger/ledgerSingleSigner.ts | 4 +-- 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 ironfish-cli/src/commands/wallet/ledger/address.ts diff --git a/ironfish-cli/src/commands/wallet/ledger/address.ts b/ironfish-cli/src/commands/wallet/ledger/address.ts new file mode 100644 index 0000000000..57f5086966 --- /dev/null +++ b/ironfish-cli/src/commands/wallet/ledger/address.ts @@ -0,0 +1,29 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +import { IronfishCommand } from '../../../command' +import { JsonFlags, RemoteFlags } from '../../../flags' +import { LedgerSingleSigner } from '../../../ledger' +import * as ui from '../../../ui' + +export class AddressCommand extends IronfishCommand { + static description = `verify the ledger device's public address` + + static flags = { + ...RemoteFlags, + ...JsonFlags, + } + + async start(): Promise { + const ledger = new LedgerSingleSigner() + + const address = await ui.ledger({ + ledger, + message: 'Retrieve Wallet Address', + approval: true, + action: () => ledger.getPublicAddress(true), + }) + + this.log(ui.card({ Address: address })) + } +} diff --git a/ironfish-cli/src/ledger/ledgerSingleSigner.ts b/ironfish-cli/src/ledger/ledgerSingleSigner.ts index 8dc313a3a7..12c4178752 100644 --- a/ironfish-cli/src/ledger/ledgerSingleSigner.ts +++ b/ironfish-cli/src/ledger/ledgerSingleSigner.ts @@ -10,9 +10,9 @@ export class LedgerSingleSigner extends Ledger { super(false) } - getPublicAddress = async () => { + getPublicAddress = async (showInDevice: boolean = false) => { const response: KeyResponse = await this.tryInstruction((app) => - app.retrieveKeys(this.PATH, IronfishKeys.PublicAddress, false), + app.retrieveKeys(this.PATH, IronfishKeys.PublicAddress, showInDevice), ) if (!isResponseAddress(response)) {