fix currency bin encoding; ok master-signatures(?)

This commit is contained in:
swrup 2025-11-28 19:17:25 +01:00
parent ab82a357a9
commit f3672edad5
8 changed files with 87 additions and 20 deletions

View file

@ -1,7 +1,6 @@
(* TODO
- clean up cmdliner
- setup
- sign *)
- don't depends on wget *)
(* doc: https://docs.taler.net/manpages/taler-exchange-offline.1.html *)
let version = "%%VERSION%%"
@ -13,6 +12,24 @@ let download ~base_url ~output =
let wget = Cmd.(v "wget" % "-O" % output % uri) in
OS.Cmd.run wget
let upload ~base_url ~input =
let open Bos in
let uri =
Uri.with_path (Uri.of_string base_url) "/management/keys/" |> Uri.to_string
in
let wget =
Cmd.(
v "wget"
% "--method=POST"
% "--header='Content-Type: application/json'"
% "--body-file"
% input
% "-O"
% "/dev/null"
% uri)
in
OS.Cmd.run wget
let setup ~output =
let output = Fpath.v output in
let () = Mirage_crypto_rng_unix.use_default () in
@ -64,7 +81,7 @@ let setup_cmd =
| Ok () -> ()
let download_cmd =
let doc = "Downloads /management/keys/" in
let doc = "GET /management/keys/" in
let man =
[ `S Manpage.s_description; `P "$(cmd) download /management/keys." ]
in
@ -85,6 +102,29 @@ let download_cmd =
exit 1
| Ok () -> ()
let upload_cmd =
let doc = "POST /management/keys/" in
let man =
[ `S Manpage.s_description; `P "$(cmd) upload /management/keys." ]
in
let input =
let doc = "Input file." in
Arg.(
value & opt filepath "master_signatures.json" & info [ "i"; "input" ] ~doc)
in
let base_url =
let doc = "Base url of the exchange." in
Arg.(value & opt string "http://localhost:3434/" & info [ "base-url" ] ~doc)
in
Cmd.make (Cmd.info "upload" ~version ~doc ~man)
@@
let+ input = input and+ base_url = base_url in
match upload ~base_url ~input with
| Error (`Msg err) ->
Fmt.epr "Upload failure: %s@." err;
exit 1
| Ok () -> ()
let sign_cmd =
let doc = "Sign FutureKeysResponse." in
let input =
@ -119,7 +159,7 @@ let cli =
let doc = "MTE Offline CLI tool" in
Cmd.info "mte-offline" ~version ~doc
in
Cmd.group info [ setup_cmd; download_cmd; sign_cmd ]
Cmd.group info [ setup_cmd; download_cmd; sign_cmd; upload_cmd ]
let main () = Cmd.eval cli
let () = exit (main ())