Client: preload encrypted keys when running a daemon (again)

This is 370114eb8b again, sigh.
This commit is contained in:
Grégoire Henry 2018-07-09 12:51:33 +02:00
parent d3589324f5
commit ea4e33b0e2
3 changed files with 18 additions and 0 deletions

View File

@ -192,6 +192,17 @@ let decrypt_all (cctxt : #Client_context.io_wallet) =
return_unit return_unit
end sks end sks
let decrypt_list (cctxt : #Client_context.io_wallet) keys =
Secret_key.load cctxt >>=? fun sks ->
iter_s begin fun (name, sk_uri) ->
if Uri.scheme (sk_uri : sk_uri :> Uri.t) = Some scheme &&
(keys = [] || List.mem name keys) then
decrypt cctxt ~name sk_uri >>=? fun _ ->
return_unit
else
return_unit
end sks
let rec read_passphrase (cctxt : #Client_context.io) = let rec read_passphrase (cctxt : #Client_context.io) =
cctxt#prompt_password cctxt#prompt_password
"Enter passphrase to encrypt your key: " >>=? fun password -> "Enter passphrase to encrypt your key: " >>=? fun password ->

View File

@ -33,6 +33,9 @@ val decrypt:
val decrypt_all: val decrypt_all:
#Client_context.io_wallet -> unit tzresult Lwt.t #Client_context.io_wallet -> unit tzresult Lwt.t
val decrypt_list:
#Client_context.io_wallet -> string list -> unit tzresult Lwt.t
val encrypt: val encrypt:
#Client_context.io -> #Client_context.io ->
Signature.secret_key -> Client_keys.sk_uri tzresult Lwt.t Signature.secret_key -> Client_keys.sk_uri tzresult Lwt.t

View File

@ -86,6 +86,8 @@ let baker_commands () =
directory_parameter directory_parameter
@@ seq_of_param Client_keys.Public_key_hash.alias_param) @@ seq_of_param Client_keys.Public_key_hash.alias_param)
(fun (max_priority, threshold) node_path delegates cctxt -> (fun (max_priority, threshold) node_path delegates cctxt ->
Tezos_signer_backends.Encrypted.decrypt_list
cctxt (List.map fst delegates) >>=? fun () ->
Client_daemon.Baker.run cctxt Client_daemon.Baker.run cctxt
?threshold ?threshold
?max_priority ?max_priority
@ -107,6 +109,8 @@ let endorser_commands () =
(prefixes [ "run" ] (prefixes [ "run" ]
@@ seq_of_param Client_keys.Public_key_hash.alias_param) @@ seq_of_param Client_keys.Public_key_hash.alias_param)
(fun endorsement_delay delegates cctxt -> (fun endorsement_delay delegates cctxt ->
Tezos_signer_backends.Encrypted.decrypt_list
cctxt (List.map fst delegates) >>=? fun () ->
Client_daemon.Endorser.run cctxt Client_daemon.Endorser.run cctxt
~delay:endorsement_delay ~delay:endorsement_delay
~min_date:((Time.add (Time.now ()) (Int64.neg 1800L))) ~min_date:((Time.add (Time.now ()) (Int64.neg 1800L)))