Signer/Ledger: improve tezos-client show ledger
command
This commit is contained in:
parent
02b1d3e93d
commit
8b054deee3
@ -522,12 +522,12 @@ let commands =
|
|||||||
end ledgers) ;
|
end ledgers) ;
|
||||||
|
|
||||||
Clic.command ~group
|
Clic.command ~group
|
||||||
~desc: "Show BIP32 derivation at path for Ledger"
|
~desc: "Display version/public-key/address information for a Ledger URI"
|
||||||
no_options
|
(args1 (switch ~doc:"Test signing operation" ~long:"test-sign" ()))
|
||||||
(prefixes [ "show" ; "ledger" ; "path" ]
|
(prefixes [ "show" ; "ledger" ]
|
||||||
@@ Client_keys.sk_uri_param
|
@@ Client_keys.sk_uri_param
|
||||||
@@ stop)
|
@@ stop)
|
||||||
(fun () sk_uri (cctxt : Client_context.io_wallet) ->
|
(fun test_sign sk_uri (cctxt : Client_context.io_wallet) ->
|
||||||
neuterize sk_uri >>=? fun pk_uri ->
|
neuterize sk_uri >>=? fun pk_uri ->
|
||||||
id_of_pk_uri pk_uri >>=? fun id ->
|
id_of_pk_uri pk_uri >>=? fun id ->
|
||||||
find_ledgers ~id () >>=? function
|
find_ledgers ~id () >>=? function
|
||||||
@ -538,28 +538,55 @@ let commands =
|
|||||||
Option.unopt ~default:"(none)" device_info.manufacturer_string in
|
Option.unopt ~default:"(none)" device_info.manufacturer_string in
|
||||||
let product =
|
let product =
|
||||||
Option.unopt ~default:"(none)" device_info.product_string in
|
Option.unopt ~default:"(none)" device_info.product_string in
|
||||||
cctxt#message "Found a valid Tezos application running on %s %s at [%s]."
|
cctxt#message
|
||||||
|
"Found a %a application running on a \
|
||||||
|
%s %s at [%s]."
|
||||||
|
Ledgerwallet_tezos.Version.pp version
|
||||||
manufacturer product device_info.path >>= fun () ->
|
manufacturer product device_info.path >>= fun () ->
|
||||||
|
begin match id with
|
||||||
|
| (Pkh _ | Animals (_, Some _)) -> (* → Can public keys. *)
|
||||||
public_key pk_uri >>=? fun pk ->
|
public_key pk_uri >>=? fun pk ->
|
||||||
public_key_hash pk_uri >>=? fun (pkh, _) ->
|
public_key_hash pk_uri >>=? fun (pkh, _) ->
|
||||||
|
cctxt#message
|
||||||
|
"@[<v 0>Tezos address at this path/curve: %a@,\
|
||||||
|
Corresponding full public key: %a@]"
|
||||||
|
Signature.Public_key_hash.pp pkh
|
||||||
|
Signature.Public_key.pp pk >>= fun () ->
|
||||||
|
begin match test_sign, version.app_class with
|
||||||
|
| true, Tezos ->
|
||||||
let pkh_bytes = Signature.Public_key_hash.to_bytes pkh in
|
let pkh_bytes = Signature.Public_key_hash.to_bytes pkh in
|
||||||
match version.app_class with
|
(* Signing requires validation on the device. *)
|
||||||
| TezBake -> return_unit
|
cctxt#message "Attempting a signature, please \
|
||||||
| Tezos ->
|
validate on the ledger." >>= fun () ->
|
||||||
sign ~watermark:Generic_operation
|
sign ~watermark:Generic_operation
|
||||||
sk_uri pkh_bytes >>=? fun signature ->
|
sk_uri pkh_bytes >>=? fun signature ->
|
||||||
match Signature.check ~watermark:Generic_operation
|
begin match Signature.check ~watermark:Generic_operation
|
||||||
pk signature pkh_bytes with
|
pk signature pkh_bytes with
|
||||||
| false ->
|
| false ->
|
||||||
failwith "Fatal: Ledger cannot sign with %a"
|
failwith "Fatal: Ledger cannot sign with %a"
|
||||||
Signature.Public_key_hash.pp pkh
|
Signature.Public_key_hash.pp pkh
|
||||||
| true ->
|
| true ->
|
||||||
cctxt#message
|
cctxt#message "Tezos Wallet successfully signed."
|
||||||
"@[<v 0>Tezos address at this path: %a@,\
|
>>= fun () ->
|
||||||
Corresponding full public key: %a@]"
|
|
||||||
Signature.Public_key_hash.pp pkh
|
|
||||||
Signature.Public_key.pp pk >>= fun () ->
|
|
||||||
return_unit
|
return_unit
|
||||||
|
end
|
||||||
|
| true, TezBake ->
|
||||||
|
failwith "Option --test-sign only works \
|
||||||
|
for the Tezos Wallet app."
|
||||||
|
| false, _ ->
|
||||||
|
return_unit
|
||||||
|
end
|
||||||
|
| Animals (_, None) when test_sign ->
|
||||||
|
failwith "Option --test-sign only works \
|
||||||
|
for the Tezos Wallet app with a \
|
||||||
|
curve/path specification."
|
||||||
|
| Animals (_, None) ->
|
||||||
|
cctxt#message "No curve was provided, \
|
||||||
|
there is no Tezos-address/public-key \
|
||||||
|
to show/test."
|
||||||
|
>>= fun () ->
|
||||||
|
return_unit
|
||||||
|
end
|
||||||
) ;
|
) ;
|
||||||
|
|
||||||
Clic.command ~group
|
Clic.command ~group
|
||||||
|
Loading…
Reference in New Issue
Block a user