offline tool: add wire-fee cmd
This commit is contained in:
parent
6ee1a994ad
commit
94b39cfa5c
5 changed files with 108 additions and 21 deletions
|
|
@ -525,9 +525,6 @@ end
|
||||||
module WireFeeSetupMessage = struct
|
module WireFeeSetupMessage = struct
|
||||||
type t = {
|
type t = {
|
||||||
wire_method: string;
|
wire_method: string;
|
||||||
(* TODO over which struct?
|
|
||||||
Signature using the exchange's offline key
|
|
||||||
with purpose TALER_SIGNATURE_MASTER_WIRE_FEES *)
|
|
||||||
master_sig_wire: MasterWireFee.t;
|
master_sig_wire: MasterWireFee.t;
|
||||||
fee_start: Timestamp.t;
|
fee_start: Timestamp.t;
|
||||||
fee_end: Timestamp.t;
|
fee_end: Timestamp.t;
|
||||||
|
|
|
||||||
|
|
@ -407,8 +407,19 @@ module Wire_fee = struct
|
||||||
match wire_fees with
|
match wire_fees with
|
||||||
| [] ->
|
| [] ->
|
||||||
let+ () = Pg.insert_wire_fee db_conn v |> unwrap_err_caqti in
|
let+ () = Pg.insert_wire_fee db_conn v |> unwrap_err_caqti in
|
||||||
|
Logs.info (fun m -> m "added wire fee");
|
||||||
()
|
()
|
||||||
| _l -> Error "wire-fee already setup"
|
| [ vv ] -> (
|
||||||
|
match v.master_sig_wire = vv.sig_ with
|
||||||
|
| false ->
|
||||||
|
Error "a different wire-fee was already setup for this time frame"
|
||||||
|
| true ->
|
||||||
|
Logs.info (fun m -> m "an identical wire-fee was already setup");
|
||||||
|
Ok ())
|
||||||
|
| _ ->
|
||||||
|
Error
|
||||||
|
"invalid database state, multiple wire-fee found in database for \
|
||||||
|
this time frame"
|
||||||
|
|
||||||
let jsont = WireFeeSetupMessage.jsont
|
let jsont = WireFeeSetupMessage.jsont
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,24 +2,43 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
file1="tmp_file1.json"
|
a="tmp_a.json"
|
||||||
file2="tmp_file2.json"
|
b="tmp_b.json"
|
||||||
file3="tmp_file3.json"
|
|
||||||
file4="tmp_file4.json"
|
|
||||||
|
|
||||||
auditor_pub=$(<"./data/auditor_public_key")
|
auditor_pub=$(<"./data/auditor_public_key")
|
||||||
|
|
||||||
dune exec offline -- download --output $file1
|
dune exec offline -- download --output $a
|
||||||
dune exec offline -- sign --input $file1 --output $file2
|
dune exec offline -- sign --input $a --output $b
|
||||||
dune exec offline -- upload --input $file2 --url "/management/keys"
|
dune exec offline -- upload --input $b --url "/management/keys"
|
||||||
|
|
||||||
dune exec offline -- enable-auditor --output $file3 --auditor_url "auditor.example.com" --auditor_name "auditor example" --auditor_pub $auditor_pub --validity_start "0.0"
|
dune exec offline -- enable-auditor \
|
||||||
dune exec offline -- upload --input $file3 --url "/management/auditors"
|
--output $b \
|
||||||
|
--auditor_url "auditor.example.com" \
|
||||||
|
--auditor_name "auditor example" \
|
||||||
|
--auditor_pub $auditor_pub \
|
||||||
|
--validity_start "0.0"
|
||||||
|
dune exec offline -- upload --input $b --url "/management/auditors"
|
||||||
|
|
||||||
dune exec offline -- global-fees --output $file4 --start_date "0.0" --end_date "99999999.9" --history_fee "EUR:0.0" --account_fee "EUR:0.0" --purse_fee "EUR:0.0" --history_expiration "9999999.0" --purse_account_limit 1 --purse_timeout "9999999.0"
|
dune exec offline -- wire-fee \
|
||||||
dune exec offline -- upload --input $file4 --url "/management/global-fees"
|
--output $b \
|
||||||
|
--wire_method "magic" \
|
||||||
|
--fee_start "0.0" \
|
||||||
|
--fee_end "99999999.9" \
|
||||||
|
--closing_fee "EUR:0.0" \
|
||||||
|
--wire_fee "EUR:0.0"
|
||||||
|
dune exec offline -- upload --input $b --url "/management/wire-fee"
|
||||||
|
|
||||||
rm $file1
|
dune exec offline -- global-fees \
|
||||||
rm $file2
|
--output $b \
|
||||||
rm $file3
|
--start_date "0.0" \
|
||||||
rm $file4
|
--end_date "99999999.9" \
|
||||||
|
--history_fee "EUR:0.0" \
|
||||||
|
--account_fee "EUR:0.0" \
|
||||||
|
--purse_fee "EUR:0.0" \
|
||||||
|
--history_expiration "9999999.0" \
|
||||||
|
--purse_account_limit 1 \
|
||||||
|
--purse_timeout "9999999.0"
|
||||||
|
dune exec offline -- upload --input $b --url "/management/global-fees"
|
||||||
|
|
||||||
|
rm $a
|
||||||
|
rm $b
|
||||||
|
|
|
||||||
|
|
@ -152,6 +152,35 @@ let disable_auditor_cmd =
|
||||||
and+ validity_end = validity_end in
|
and+ validity_end = validity_end in
|
||||||
disable_auditor ~output ~master_key ~auditor_pub ~validity_end
|
disable_auditor ~output ~master_key ~auditor_pub ~validity_end
|
||||||
|
|
||||||
|
let wire_fee_cmd =
|
||||||
|
let doc = "Provides wire fee configuration." in
|
||||||
|
let wire_method =
|
||||||
|
Arg.(required & opt (some string) None & info [ "wire_method" ])
|
||||||
|
in
|
||||||
|
let fee_start =
|
||||||
|
Arg.(required & opt (some timestamp) None & info [ "fee_start" ])
|
||||||
|
in
|
||||||
|
let fee_end =
|
||||||
|
Arg.(required & opt (some timestamp) None & info [ "fee_end" ])
|
||||||
|
in
|
||||||
|
let closing_fee =
|
||||||
|
Arg.(required & opt (some amount) None & info [ "closing_fee" ])
|
||||||
|
in
|
||||||
|
let wire_fee =
|
||||||
|
Arg.(required & opt (some amount) None & info [ "wire_fee" ])
|
||||||
|
in
|
||||||
|
Cmd.make (Cmd.info "wire-fee" ~doc)
|
||||||
|
@@
|
||||||
|
let+ output = output
|
||||||
|
and+ master_key = master_key
|
||||||
|
and+ wire_method = wire_method
|
||||||
|
and+ fee_start = fee_start
|
||||||
|
and+ fee_end = fee_end
|
||||||
|
and+ closing_fee = closing_fee
|
||||||
|
and+ wire_fee = wire_fee in
|
||||||
|
Offline_impl.wire_fee ~output ~master_key ~wire_method ~fee_start ~fee_end
|
||||||
|
~closing_fee ~wire_fee
|
||||||
|
|
||||||
let global_fees_cmd =
|
let global_fees_cmd =
|
||||||
let doc = "Provides global fee configuration." in
|
let doc = "Provides global fee configuration." in
|
||||||
let start_date =
|
let start_date =
|
||||||
|
|
@ -210,14 +239,15 @@ let cli =
|
||||||
revoke_signkey_cmd;
|
revoke_signkey_cmd;
|
||||||
enable_auditor_cmd;
|
enable_auditor_cmd;
|
||||||
disable_auditor_cmd;
|
disable_auditor_cmd;
|
||||||
|
wire_fee_cmd;
|
||||||
global_fees_cmd;
|
global_fees_cmd;
|
||||||
]
|
]
|
||||||
|
|
||||||
let main () = Cmd.eval_result cli
|
let main () = Cmd.eval_result cli
|
||||||
let () = if !Sys.interactive then () else exit (main ())
|
let () = if !Sys.interactive then () else exit (main ())
|
||||||
|
|
||||||
(* TODO all management operations:
|
(* TODO
|
||||||
/management/wire-fee
|
all management operations:
|
||||||
/management/wire
|
/management/wire
|
||||||
/management/wire/disable
|
/management/wire/disable
|
||||||
/management/drain
|
/management/drain
|
||||||
|
|
|
||||||
|
|
@ -167,3 +167,33 @@ let disable_auditor ~output ~master_key ~auditor_pub ~validity_end =
|
||||||
let* s = Api.encode Api.AuditorTeardownMessage.jsont v in
|
let* s = Api.encode Api.AuditorTeardownMessage.jsont v in
|
||||||
let* () = write_file output s in
|
let* () = write_file output s in
|
||||||
Ok ()
|
Ok ()
|
||||||
|
|
||||||
|
let wire_fee ~output ~master_key ~wire_method ~fee_start ~fee_end ~closing_fee
|
||||||
|
~wire_fee =
|
||||||
|
let open Crypto in
|
||||||
|
let* key = read_master_key_file master_key in
|
||||||
|
let master_sig_wire =
|
||||||
|
let open Bin_sig.MasterWireFee in
|
||||||
|
sign_f ~f:(EddsaSignature.sign ~key)
|
||||||
|
{
|
||||||
|
h_wire_method= Bin_type.Hash_64_cstr.hash wire_method;
|
||||||
|
start_date= fee_start;
|
||||||
|
end_date= fee_end;
|
||||||
|
closing_fee;
|
||||||
|
wire_fee;
|
||||||
|
}
|
||||||
|
in
|
||||||
|
let v =
|
||||||
|
Api.WireFeeSetupMessage.
|
||||||
|
{
|
||||||
|
wire_method;
|
||||||
|
fee_start;
|
||||||
|
fee_end;
|
||||||
|
closing_fee;
|
||||||
|
wire_fee;
|
||||||
|
master_sig_wire;
|
||||||
|
}
|
||||||
|
in
|
||||||
|
let* s = Api.encode Api.WireFeeSetupMessage.jsont v in
|
||||||
|
let* () = write_file output s in
|
||||||
|
Ok ()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue