Skip to content

Commit 533acb8

Browse files
authored
wallet:ledger:address CLI command (#5693)
CLI command that displays the wallet address of the connected Ledger device.
1 parent 5ecdcef commit 533acb8

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4+
import { IronfishCommand } from '../../../command'
5+
import { JsonFlags, RemoteFlags } from '../../../flags'
6+
import { LedgerSingleSigner } from '../../../ledger'
7+
import * as ui from '../../../ui'
8+
9+
export class AddressCommand extends IronfishCommand {
10+
static description = `verify the ledger device's public address`
11+
12+
static flags = {
13+
...RemoteFlags,
14+
...JsonFlags,
15+
}
16+
17+
async start(): Promise<void> {
18+
const ledger = new LedgerSingleSigner()
19+
20+
const address = await ui.ledger({
21+
ledger,
22+
message: 'Retrieve Wallet Address',
23+
approval: true,
24+
action: () => ledger.getPublicAddress(true),
25+
})
26+
27+
this.log(ui.card({ Address: address }))
28+
}
29+
}

ironfish-cli/src/ledger/ledgerSingleSigner.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ export class LedgerSingleSigner extends Ledger {
1010
super(false)
1111
}
1212

13-
getPublicAddress = async () => {
13+
getPublicAddress = async (showInDevice: boolean = false) => {
1414
const response: KeyResponse = await this.tryInstruction((app) =>
15-
app.retrieveKeys(this.PATH, IronfishKeys.PublicAddress, false),
15+
app.retrieveKeys(this.PATH, IronfishKeys.PublicAddress, showInDevice),
1616
)
1717

1818
if (!isResponseAddress(response)) {

0 commit comments

Comments
 (0)