diff --git a/src/app/cli/src/coda.ml b/src/app/cli/src/coda.ml index 15d7f2b7c44..e68b68148c9 100644 --- a/src/app/cli/src/coda.ml +++ b/src/app/cli/src/coda.ml @@ -350,7 +350,8 @@ let setup_daemon logger = | None -> return None | Some s -> - Secrets.Libp2p_keypair.Terminal_stdin.read_from_env_exn s + Secrets.Libp2p_keypair.Terminal_stdin.read_from_env_exn + ~which:"libp2p keypair" s |> Deferred.map ~f:Option.some ) in let%bind () = @@ -505,12 +506,9 @@ let setup_daemon logger = | Error err -> ( match handle_missing with | `Must_exist -> - [%log fatal] - "Failed reading configuration from $config_file: $error" - ~metadata: - [ ("config_file", `String config_file) - ; ("error", Error_json.error_to_yojson err) ] ; - Error.raise err + Mina_user_error.raisef ~where:"reading configuration file" + "The configuration file %s could not be read:\n%s" + config_file (Error.to_string_hum err) | `May_be_missing -> [%log warn] "Could not read configuration from $config_file: $error" @@ -650,25 +648,25 @@ let setup_daemon logger = ; transaction_pool_diff= log_transaction_pool_diff ; new_state= log_received_blocks } in - let json_to_publickey_compressed_option json = + let json_to_publickey_compressed_option which json = YJ.Util.to_string_option json |> Option.bind ~f:(fun pk_str -> match Public_key.Compressed.of_base58_check pk_str with | Ok key -> Some key - | Error e -> - [%log error] "Error decoding public key ($key): $error" - ~metadata: - [ ("key", `String pk_str) - ; ("error", Error_json.error_to_yojson e) ] ; - None ) + | Error _e -> + Mina_user_error.raisef ~where:"decoding a public key" + "The %s public key %s could not be decoded." which pk_str + ) in let run_snark_worker_flag = - maybe_from_config json_to_publickey_compressed_option + maybe_from_config + (json_to_publickey_compressed_option "snark worker") "run-snark-worker" run_snark_worker_flag in let run_snark_coordinator_flag = - maybe_from_config json_to_publickey_compressed_option + maybe_from_config + (json_to_publickey_compressed_option "snark coordinator") "run-snark-coordinator" run_snark_coordinator_flag in let snark_worker_parallelism_flag = @@ -676,7 +674,8 @@ let setup_daemon logger = snark_worker_parallelism_flag in let coinbase_receiver_flag = - maybe_from_config json_to_publickey_compressed_option + maybe_from_config + (json_to_publickey_compressed_option "coinbase receiver") "coinbase-receiver" coinbase_receiver_flag in let%bind external_ip = @@ -697,7 +696,8 @@ let setup_daemon logger = block_production_key in let block_production_pubkey = - maybe_from_config json_to_publickey_compressed_option + maybe_from_config + (json_to_publickey_compressed_option "block producer") "block-producer-pubkey" block_production_pubkey in let block_production_password = @@ -718,15 +718,15 @@ let setup_daemon logger = let%bind block_production_keypair = match (block_production_key, block_production_pubkey) with | Some _, Some _ -> - eprintf - "Error: You cannot provide both `block-producer-key` and \ - `block_production_pubkey`\n" ; - exit 11 + Mina_user_error.raise + "You cannot provide both `block-producer-key` and \ + `block_production_pubkey`" | None, None -> Deferred.return None | Some sk_file, _ -> let%map kp = - Secrets.Keypair.Terminal_stdin.read_from_env_exn sk_file + Secrets.Keypair.Terminal_stdin.read_from_env_exn + ~which:"block producer keypair" sk_file in Some kp | _, Some tracked_pubkey -> @@ -736,7 +736,8 @@ let setup_daemon logger = in let sk_file = Secrets.Wallets.get_path wallets tracked_pubkey in let%map kp = - Secrets.Keypair.Terminal_stdin.read_from_env_exn sk_file + Secrets.Keypair.Terminal_stdin.read_from_env_exn + ~which:"block producer keypair" sk_file in Some kp in @@ -750,7 +751,15 @@ let setup_daemon logger = match Unix.getenv "CODA_CLIENT_TRUSTLIST" with | Some envstr -> let cidrs = - String.split ~on:',' envstr |> List.map ~f:Unix.Cidr.of_string + String.split ~on:',' envstr + |> List.filter_map ~f:(fun str -> + try Some (Unix.Cidr.of_string str) + with _ -> + [%log warn] + "Could not parse address $address in \ + CODA_CLIENT_TRUSTLIST" + ~metadata:[("address", `String str)] ; + None ) in Some (List.append cidrs (Option.value ~default:[] client_trustlist)) @@ -833,13 +842,13 @@ let setup_daemon logger = |> List.filter ~f:(fun s -> not (String.is_empty s)) |> List.map ~f:Coda_net2.Multiaddr.of_string |> return - | Error e -> - [%log fatal] - ~metadata:[("error", `String (Error.to_string_mach e))] - "Unable to read peer-list file properly. It must be a \ - newline separated series of libp2p multiaddrs (ex: \ - /ip4/IPADDR/tcp/PORT/p2p/PEERID)" ; - exit 15 ) + | Error _ -> + Mina_user_error.raisef + ~where:"reading libp2p peer address file" + "The file %s could not be read.\n\n\ + It must be a newline-separated list of libp2p multiaddrs \ + (ex: /ip4/IPADDR/tcp/PORT/p2p/PEERID)" + file ) in let initial_peers = List.concat diff --git a/src/app/cli/src/init/client.ml b/src/app/cli/src/init/client.ml index 2280cb57a27..b8b8b54b2be 100644 --- a/src/app/cli/src/init/client.ml +++ b/src/app/cli/src/init/client.ml @@ -470,7 +470,9 @@ let batch_send_payments = in let main port (privkey_path, payments_path) = let open Deferred.Let_syntax in - let%bind keypair = Secrets.Keypair.Terminal_stdin.read_exn privkey_path + let%bind keypair = + Secrets.Keypair.Terminal_stdin.read_exn ~which:"coda keypair" + privkey_path and infos = get_infos payments_path in let ts : User_command_input.t list = List.map infos ~f:(fun {receiver; valid_until; amount; fee} -> @@ -855,7 +857,10 @@ let dump_keypair = Cli_lib.Exceptions.handle_nicely @@ fun () -> let open Deferred.Let_syntax in - let%map kp = Secrets.Keypair.Terminal_stdin.read_exn privkey_path in + let%map kp = + Secrets.Keypair.Terminal_stdin.read_exn ~which:"coda keypair" + privkey_path + in printf "Public key: %s\nPrivate key: %s\n" ( kp.public_key |> Public_key.compress |> Public_key.Compressed.to_base58_check ) @@ -1153,7 +1158,8 @@ let import_key = in let wallets_disk_location = conf_dir ^/ "wallets" in let%bind ({Keypair.public_key; _} as keypair) = - Secrets.Keypair.Terminal_stdin.read_exn privkey_path + Secrets.Keypair.Terminal_stdin.read_exn ~which:"coda keypair" + privkey_path in let pk = Public_key.compress public_key in let%bind wallets = diff --git a/src/app/rosetta/lib/signer.ml b/src/app/rosetta/lib/signer.ml index a90a121ac3c..6a3894ffbc3 100644 --- a/src/app/rosetta/lib/signer.ml +++ b/src/app/rosetta/lib/signer.ml @@ -21,12 +21,11 @@ module Keys = struct let of_private_key_box secret_box_string = let json = Yojson.Safe.from_string secret_box_string in - let which = Secrets.Keypair.T.which in let sb : Secrets.Secret_box.t = Secrets.Secret_box.of_yojson json |> Result.ok |> Option.value_exn in let output : Bytes.t = - Secrets.Secret_box.decrypt ~password:(Bytes.of_string "") ~which sb + Secrets.Secret_box.decrypt ~password:(Bytes.of_string "") sb |> Result.ok |> Option.value_exn in let sk = output |> Bigstring.of_bytes |> Private_key.of_bigstring_exn in diff --git a/src/lib/genesis_ledger_helper/genesis_ledger_helper.ml b/src/lib/genesis_ledger_helper/genesis_ledger_helper.ml index aaa9f69152b..922ba938907 100644 --- a/src/lib/genesis_ledger_helper/genesis_ledger_helper.ml +++ b/src/lib/genesis_ledger_helper/genesis_ledger_helper.ml @@ -1390,9 +1390,12 @@ let upgrade_old_config ~logger filename json = `Assoc (("daemon", `Assoc old_fields) :: remaining_fields) in let%map () = - Writer.with_file filename ~f:(fun w -> - Deferred.return - @@ Writer.write w (Yojson.Safe.pretty_to_string upgraded_json) ) + Deferred.Or_error.try_with (fun () -> + Writer.with_file filename ~f:(fun w -> + Deferred.return + @@ Writer.write w + (Yojson.Safe.pretty_to_string upgraded_json) ) ) + |> Deferred.ignore_m in upgraded_json ) | _ -> diff --git a/src/lib/mina_user_error/mina_user_error.ml b/src/lib/mina_user_error/mina_user_error.ml index 92aa6564775..bae62e37233 100644 --- a/src/lib/mina_user_error/mina_user_error.ml +++ b/src/lib/mina_user_error/mina_user_error.ml @@ -1,3 +1,29 @@ exception Mina_user_error of {message: string; where: string option} +let raisef ?where = + Format.ksprintf (fun message -> raise (Mina_user_error {message; where})) + let raise ?where message = raise (Mina_user_error {message; where}) + +let () = + Stdlib.Printexc.register_printer (fun exn -> + match exn with + | Mina_user_error {message; where} -> + let error = + match where with + | None -> + "encountered a configuration error" + | Some where -> + Printf.sprintf "encountered a configuration error %s" where + in + Some + (Printf.sprintf {err| +FATAL ERROR + + ☠ Coda %s. + + %s +%!|err} + error message) + | _ -> + None ) diff --git a/src/lib/secrets/dune b/src/lib/secrets/dune index 8a39db45f4d..5ec2e9b74c0 100644 --- a/src/lib/secrets/dune +++ b/src/lib/secrets/dune @@ -4,7 +4,7 @@ (library_flags -linkall) (inline_tests) (libraries core async_unix sodium ppx_deriving_yojson.runtime yojson - coda_base coda_net2) + coda_base coda_net2 mina_user_error) (preprocess (pps ppx_coda ppx_version ppx_jane ppx_deriving_yojson ppx_deriving.make)) (instrumentation (backend bisect_ppx)) diff --git a/src/lib/secrets/keypair.ml b/src/lib/secrets/keypair.ml index 3430fbf5026..f52eaa754c1 100644 --- a/src/lib/secrets/keypair.ml +++ b/src/lib/secrets/keypair.ml @@ -22,7 +22,7 @@ module T = struct in match%bind Secret_file.write ~path:privkey_path ~mkdir:true ~plaintext:privkey_bytes - ~password ~which + ~password with | Ok () -> (* The hope is that if [Secret_file.write] succeeded then this ought to @@ -33,13 +33,13 @@ module T = struct Writer.write_line pubkey_f pubkey_string ; Writer.close pubkey_f | Error e -> - Privkey_error.raise e + Privkey_error.raise ~which e (** Reads a private key from [privkey_path] using [Secret_file] *) let read ~(privkey_path : string) ~(password : Secret_file.password) : (Keypair.t, Privkey_error.t) Deferred.Result.t = let open Deferred.Result.Let_syntax in - let%bind pk_bytes = Secret_file.read ~path:privkey_path ~password ~which in + let%bind pk_bytes = Secret_file.read ~path:privkey_path ~password in let open Result.Let_syntax in Deferred.return @@ let%bind sk = @@ -50,7 +50,6 @@ module T = struct Privkey_error.corrupted_privkey (Error.createf "Error parsing decrypted private key file: %s" (Exn.to_string exn)) - which in try return (Keypair.of_private_key_exn sk) with exn -> @@ -59,7 +58,6 @@ module T = struct "Error computing public key from private, is your keyfile \ corrupt? %s" (Exn.to_string exn)) - which (** Reads a private key from [privkey_path] using [Secret_file], throws on failure *) let read_exn ~(privkey_path : string) ~(password : Secret_file.password) : @@ -68,7 +66,7 @@ module T = struct | Ok keypair -> keypair | Error priv_key_error -> - Privkey_error.raise priv_key_error + Privkey_error.raise ~which priv_key_error let read_exn' path = read_exn ~privkey_path:path diff --git a/src/lib/secrets/keypair_common.ml b/src/lib/secrets/keypair_common.ml index e1451b32972..96e9fc95942 100644 --- a/src/lib/secrets/keypair_common.ml +++ b/src/lib/secrets/keypair_common.ml @@ -35,7 +35,7 @@ struct prompt_password prompt ) else return pw2 - let read_exn ?(should_reask = true) path = + let read_exn ?(should_reask = true) ~which path = let read_privkey password = read ~privkey_path:path ~password in let%bind result = match Sys.getenv env with @@ -44,7 +44,9 @@ struct | None -> let read_file () = read_privkey - (lazy (Password.read_hidden_line "Secret key password: ")) + ( lazy + (Password.read_hidden_line ~error_help_message:"" + "Secret key password: ") ) in let rec read_until_correct () = match%bind read_file () with @@ -54,7 +56,7 @@ struct eprintf "Wrong password! Please try again\n" ; read_until_correct () | Error exn -> - Privkey_error.raise exn + Deferred.Result.fail exn in if should_reask then read_until_correct () else read_file () in @@ -62,22 +64,22 @@ struct | Ok result -> return result | Error e -> - Privkey_error.raise e + Privkey_error.raise ~which e - let read_from_env_exn path = + let read_from_env_exn ~which path = let read_privkey password = read ~privkey_path:path ~password in let%bind result = match Sys.getenv env with | Some password -> read_privkey (lazy (Deferred.return @@ Bytes.of_string password)) | None -> - Privkey_error.raise (`Password_not_in_environment env) + Deferred.Result.fail (`Password_not_in_environment env) in match result with | Ok result -> return result | Error e -> - Privkey_error.raise e + Privkey_error.raise ~which e let write_exn kp ~privkey_path = write_exn kp ~privkey_path diff --git a/src/lib/secrets/libp2p_keypair.ml b/src/lib/secrets/libp2p_keypair.ml index b1cbd057b4a..2523966c097 100644 --- a/src/lib/secrets/libp2p_keypair.ml +++ b/src/lib/secrets/libp2p_keypair.ml @@ -16,7 +16,7 @@ module T = struct let str = Coda_net2.Keypair.to_string kp in match%bind Secret_file.write ~path:privkey_path ~mkdir:true - ~plaintext:(Bytes.of_string str) ~password ~which + ~plaintext:(Bytes.of_string str) ~password with | Ok () -> (* The hope is that if [Secret_file.write] succeeded then this ought to @@ -27,20 +27,20 @@ module T = struct Writer.write_line pubkey_f (Coda_net2.Keypair.to_peer_id kp) ; Writer.close pubkey_f | Error e -> - Privkey_error.raise e + Privkey_error.raise ~which e (** Reads a private key from [privkey_path] using [Secret_file] *) let read ~(privkey_path : string) ~(password : Secret_file.password) : (t, Privkey_error.t) Deferred.Result.t = let open Deferred.Result.Let_syntax in - let%bind bytes = Secret_file.read ~path:privkey_path ~password ~which in + let%bind bytes = Secret_file.read ~path:privkey_path ~password in Deferred.return @@ match Coda_net2.Keypair.of_string (Bytes.to_string bytes) with | Ok kp -> Ok kp | Error e -> - Privkey_error.corrupted_privkey e which + Privkey_error.corrupted_privkey e (** Reads a private key from [privkey_path] using [Secret_file], throws on failure *) let read_exn ~(privkey_path : string) ~(password : Secret_file.password) : @@ -49,7 +49,7 @@ module T = struct | Ok keypair -> keypair | Error priv_key_error -> - Privkey_error.raise priv_key_error + Privkey_error.raise ~which priv_key_error let read_exn' path = read_exn ~privkey_path:path diff --git a/src/lib/secrets/password.ml b/src/lib/secrets/password.ml index 923f9779fd1..a9654c5c19d 100644 --- a/src/lib/secrets/password.ml +++ b/src/lib/secrets/password.ml @@ -1,6 +1,6 @@ open Core -let read_hidden_line prompt : Bytes.t Async.Deferred.t = +let read_hidden_line ~error_help_message prompt : Bytes.t Async.Deferred.t = let open Unix in let open Async_unix in let open Async.Deferred.Let_syntax in @@ -31,12 +31,23 @@ let read_hidden_line prompt : Bytes.t Async.Deferred.t = | `Ok pwd -> Bytes.of_string pwd | `Eof -> - failwith "got EOF while reading password" + Mina_user_error.raisef {|No password was provided. -let hidden_line_or_env prompt ~env : Bytes.t Async.Deferred.t = +%s|} + error_help_message + +let hidden_line_or_env ?error_help_message prompt ~env : + Bytes.t Async.Deferred.t = let open Async.Deferred.Let_syntax in match Sys.getenv env with | Some p -> return (Bytes.of_string p) | _ -> - read_hidden_line prompt + let error_help_message = + match error_help_message with + | None -> + sprintf "Set the %s environment variable to the password" env + | Some s -> + s + in + read_hidden_line ~error_help_message prompt diff --git a/src/lib/secrets/password.mli b/src/lib/secrets/password.mli index 978acfac060..49577d78fdd 100644 --- a/src/lib/secrets/password.mli +++ b/src/lib/secrets/password.mli @@ -1,5 +1,7 @@ open Async -val read_hidden_line : string -> Bytes.t Deferred.t +val read_hidden_line : + error_help_message:string -> string -> Bytes.t Deferred.t -val hidden_line_or_env : string -> env:string -> Bytes.t Deferred.t +val hidden_line_or_env : + ?error_help_message:string -> string -> env:string -> Bytes.t Deferred.t diff --git a/src/lib/secrets/privkey_error.ml b/src/lib/secrets/privkey_error.ml index e7d7e53a22c..af82df85b00 100644 --- a/src/lib/secrets/privkey_error.ml +++ b/src/lib/secrets/privkey_error.ml @@ -1,28 +1,30 @@ open Core type t = - [ `Corrupted_privkey of Error.t * string + [ `Corrupted_privkey of Error.t | `Incorrect_password_or_corrupted_privkey | `Cannot_open_file of string | `Parent_directory_does_not_exist of string | `Password_not_in_environment of string ] -exception Privkey_exn of t - let to_string : t -> string = function - | `Corrupted_privkey (e, which) -> - sprintf !"Corrupted %s: %s" which (Error.to_string_hum e) + | `Corrupted_privkey e -> + sprintf !"The key was corrupted: %s" (Error.to_string_hum e) | `Incorrect_password_or_corrupted_privkey -> - "Incorrect_password_or_corrupted_privkey" + "The password was incorrect, or the key is corrupted" | `Cannot_open_file path -> sprintf !"Cannot open file: %s" path | `Parent_directory_does_not_exist directory_name -> sprintf - !"Parent directory %s does not exist Hint: mkdir -p %s; chmod 700 %s\n" + !"Parent directory %s does not exist\n\n\ + Hint: mkdir -p %s; chmod 700 %s\n" directory_name directory_name directory_name | `Password_not_in_environment env_var -> sprintf !"No password was specified in environment variable %s" env_var -let raise t = Error.raise (Error.of_string (to_string t)) +let raise ~which t = + let where = sprintf "loading %s" which in + Mina_user_error.raise ~where (to_string t) -let corrupted_privkey error which = Error (`Corrupted_privkey (error, which)) +let corrupted_privkey error : (_, t) Result.t = + Error (`Corrupted_privkey error) diff --git a/src/lib/secrets/secret_box.ml b/src/lib/secrets/secret_box.ml index b3ab607ead3..8938780859e 100644 --- a/src/lib/secrets/secret_box.ml +++ b/src/lib/secrets/secret_box.ml @@ -93,7 +93,7 @@ let encrypt ~(password : Bytes.t) ~(plaintext : Bytes.t) = ; ciphertext } (** warning: this will zero [password] *) -let decrypt ~(password : Bytes.t) ~which +let decrypt ~(password : Bytes.t) { box_primitive ; pw_primitive ; nonce @@ -103,17 +103,15 @@ let decrypt ~(password : Bytes.t) ~which if box_primitive <> Secret_box.primitive then Error (`Corrupted_privkey - ( Error.createf - !"don't know how to handle a %s secret_box" - box_primitive - , which )) + (Error.createf + !"don't know how to handle a %s secret_box" + box_primitive)) else if pw_primitive <> Password_hash.primitive then Error (`Corrupted_privkey - ( Error.createf - !"don't know how to handle a %s password_hash" - pw_primitive - , which )) + (Error.createf + !"don't know how to handle a %s password_hash" + pw_primitive)) else let nonce = Secret_box.Bytes.to_nonce nonce in let salt = Password_hash.Bytes.to_salt pwsalt in @@ -132,9 +130,7 @@ let%test_unit "successful roundtrip" = ~trials:4 ~f:(fun (password, plaintext) -> let enc = encrypt ~password:(Bytes.copy password) ~plaintext in - let dec = - Option.value_exn (decrypt enc ~password ~which:"test" |> Result.ok) - in + let dec = Option.value_exn (decrypt enc ~password |> Result.ok) in [%test_eq: Bytes.t] dec plaintext ) let%test "bad password fails" = @@ -142,5 +138,4 @@ let%test "bad password fails" = encrypt ~password:(Bytes.of_string "foobar") ~plaintext:(Bytes.of_string "yo") in - Result.is_error - (decrypt ~password:(Bytes.of_string "barfoo") ~which:"test" enc) + Result.is_error (decrypt ~password:(Bytes.of_string "barfoo") enc) diff --git a/src/lib/secrets/secret_box.mli b/src/lib/secrets/secret_box.mli index 4cea5e02590..e8a39d53669 100644 --- a/src/lib/secrets/secret_box.mli +++ b/src/lib/secrets/secret_box.mli @@ -22,9 +22,8 @@ val encrypt : password:Bytes.t -> plaintext:Bytes.t -> t (** Decrypt some bytes with a password *) val decrypt : password:Bytes.t - -> which:string -> t -> ( Bytes.t - , [> `Corrupted_privkey of Error.t * string + , [> `Corrupted_privkey of Error.t | `Incorrect_password_or_corrupted_privkey ] ) Result.t diff --git a/src/lib/secrets/secret_file.ml b/src/lib/secrets/secret_file.ml index 720ca09040a..7f4b3b4293d 100644 --- a/src/lib/secrets/secret_file.ml +++ b/src/lib/secrets/secret_file.ml @@ -3,8 +3,8 @@ open Async type password = Bytes.t Async.Deferred.t Lazy.t -let handle_open ~mkdir ~(f : string -> 'a Deferred.t) ~which path = - let corrupted_privkey e = Privkey_error.corrupted_privkey e which in +let handle_open ~mkdir ~(f : string -> 'a Deferred.t) path = + let corrupted_privkey = Privkey_error.corrupted_privkey in let open Unix.Error in let open Deferred.Result.Let_syntax in let dn = Filename.dirname path in @@ -69,11 +69,10 @@ let handle_open ~mkdir ~(f : string -> 'a Deferred.t) ~which path = let lift (t : 'a Deferred.t) : ('a, 'b) Deferred.Result.t = t >>| fun x -> Ok x -let write ~path ~mkdir ~(password : Bytes.t Deferred.t Lazy.t) ~plaintext - ~which = +let write ~path ~mkdir ~(password : Bytes.t Deferred.t Lazy.t) ~plaintext = let open Deferred.Result.Let_syntax in let%bind privkey_f = - handle_open ~mkdir ~f:(fun path -> Writer.open_file path) path ~which + handle_open ~mkdir ~f:(fun path -> Writer.open_file path) path in let%bind password = lift @@ Lazy.force password in let sb = Secret_box.encrypt ~plaintext ~password in @@ -84,11 +83,11 @@ let write ~path ~mkdir ~(password : Bytes.t Deferred.t Lazy.t) ~plaintext let%bind () = lift (Unix.chmod path ~perm:0o600) in lift (Writer.close privkey_f) -let read ~path ~(password : Bytes.t Deferred.t Lazy.t) ~which = +let read ~path ~(password : Bytes.t Deferred.t Lazy.t) = let to_corrupt_privkey = - Deferred.Result.map_error ~f:(fun e -> `Corrupted_privkey (e, which)) + Deferred.Result.map_error ~f:(fun e -> `Corrupted_privkey e) in - let handle_open ~mkdir ~f p = handle_open ~mkdir ~f ~which p in + let handle_open ~mkdir ~f p = handle_open ~mkdir ~f p in let open Deferred.Result.Let_syntax in let read_all r = lift (Pipe.to_list (Reader.lines r)) @@ -133,8 +132,7 @@ let read ~path ~(password : Bytes.t Deferred.t Lazy.t) ~which = | Error e -> Deferred.return (Privkey_error.corrupted_privkey - (Error.createf "couldn't parse %s: %s" path e) - which) + (Error.createf "couldn't parse %s: %s" path e)) in let%bind password = lift (Lazy.force password) in - Deferred.return (Secret_box.decrypt ~password ~which sb) + Deferred.return (Secret_box.decrypt ~password sb) diff --git a/src/lib/secrets/secret_file.mli b/src/lib/secrets/secret_file.mli index e6e3a4f9dfd..6838c7570ed 100644 --- a/src/lib/secrets/secret_file.mli +++ b/src/lib/secrets/secret_file.mli @@ -17,7 +17,6 @@ type password = Bytes.t Deferred.t Lazy.t val read : path:string -> password:password - -> which:string -> (Bytes.t, Privkey_error.t) Deferred.Result.t (** Write [contents] to [path], after wrapping it in a [Secret_box] with [password]. @@ -33,5 +32,4 @@ val write : -> mkdir:bool -> password:password -> plaintext:Bytes.t - -> which:string -> (unit, Privkey_error.t) Deferred.Result.t