This commit is contained in:
swrup 2026-02-10 14:51:09 +01:00
parent a0340bd100
commit b04f0dc949
3 changed files with 25 additions and 25 deletions

View file

@ -2,27 +2,35 @@
set -e
a="tmp_a.json"
b="tmp_b.json"
a="/tmp/a.json"
b="/tmp/b.json"
url="http://localhost:3434"
auditor_pub=$(<"./test/auditor_public_key")
master_key="./default/master_offline_private_key"
zero_euro="EUR:0.0"
dune exec offline -- download --output $a
dune exec offline -- sign --master_key $master_key --input $a --output $b
dune exec offline -- upload --input $b --url "/management/keys"
offline_tool() {
dune exec offline -- "$@"
}
dune exec offline -- enable-auditor \
offline_tool download --output $a --url $url"/management/keys"
offline_tool sign \
--master_key $master_key \
--input $a \
--output $b
offline_tool upload --input $b --url $url"/management/keys"
offline_tool enable-auditor \
--master_key $master_key \
--output $b \
--auditor_url "auditor.example.com" \
--auditor_name "auditor example" \
--auditor_pub $auditor_pub \
--validity_start 0
dune exec offline -- upload --input $b --url "/management/auditors"
offline_tool upload --input $b --url $url"/management/auditors"
dune exec offline -- wire-fee \
offline_tool wire-fee \
--master_key $master_key \
--output $b \
--wire_method "xxx" \
@ -30,9 +38,9 @@ dune exec offline -- wire-fee \
--fee_end 99999999 \
--closing_fee $zero_euro \
--wire_fee $zero_euro
dune exec offline -- upload --input $b --url "/management/wire-fee"
offline_tool upload --input $b --url $url"/management/wire-fee"
dune exec offline -- global-fees \
offline_tool global-fees \
--master_key $master_key \
--output $b \
--start_date 0 \
@ -43,7 +51,4 @@ dune exec offline -- global-fees \
--history_expiration 9999999 \
--purse_account_limit 1 \
--purse_timeout 9999999
dune exec offline -- upload --input $b --url "/management/global-fees"
rm $a
rm $b
offline_tool upload --input $b --url $url"/management/global-fees"

View file

@ -1,5 +1,5 @@
(* TODO
change download_cmd/upload_cmd
better cmd doc
change arguments: '_' -> '-'
all management operations:
@ -99,8 +99,8 @@ let download_cmd =
let doc = "GET" in
Cmd.make (Cmd.info "download" ~doc)
@@
let+ output = output in
download ~output
let+ output = output and+ url = url in
download ~output ~url
let upload_cmd =
let doc = "POST" in

View file

@ -161,18 +161,13 @@ let read_master_key_file filename =
let* master_key = read_file filename in
Crypto.EddsaPrivateKey.of_octets master_key
let base_url = Uri.of_string "http://localhost:3434/"
let full_url path = Uri.with_path base_url path |> Uri.to_string
let download ~output =
let download ~output ~url =
let open Bos in
let uri = full_url "/management/keys/" in
OS.Cmd.run Cmd.(v "curl" % "-s" % "-o" % output % "-X" % "GET" % uri)
OS.Cmd.run Cmd.(v "curl" % "-s" % "-o" % output % "-X" % "GET" % url)
|> unwrap_err_msg
let upload ~input ~url =
let open Bos in
let uri = full_url url in
OS.Cmd.run
Cmd.(
v "curl"
@ -183,7 +178,7 @@ let upload ~input ~url =
% "Content-Type: application/json"
% "--data"
% ("@" ^ input)
% uri)
% url)
|> unwrap_err_msg
let setup ~output =