Skip to content

Commit

Permalink
wallet:ledger:address CLI command
Browse files Browse the repository at this point in the history
CLI command that displays the wallet address of the connected Ledger device.
  • Loading branch information
patnir committed Dec 9, 2024
1 parent 5ecdcef commit 8b75c82
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
29 changes: 29 additions & 0 deletions ironfish-cli/src/commands/wallet/ledger/address.ts
Original file line number Diff line number Diff line change
@@ -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<void> {
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 }))
}
}
4 changes: 2 additions & 2 deletions ironfish-cli/src/ledger/ledgerSingleSigner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 8b75c82

Please sign in to comment.