+ GlobalFees

This commit is contained in:
swrup 2025-12-04 16:45:03 +01:00
parent 6cccfe76ef
commit 689c08ddf5
2 changed files with 115 additions and 16 deletions

View file

@ -431,3 +431,55 @@ module WireFeeSetupMessage = struct
|> mem "wire_fee" Amount.jsont ~enc:wire_fee |> mem "wire_fee" Amount.jsont ~enc:wire_fee
|> finish |> finish
end end
module GlobalFees = struct
type t = {
start_date: Timestamp.t;
end_date: Timestamp.t;
history_fee: Amount.t;
account_fee: Amount.t;
purse_fee: Amount.t;
history_expiration: RelativeTime.t;
purse_account_limit: int;
purse_timeout: RelativeTime.t;
(* Signature of TALER_GlobalFeesPS. *)
master_sig: GlobalFeesPS.t;
}
let jsont =
let make start_date end_date history_fee account_fee purse_fee
history_expiration purse_account_limit purse_timeout master_sig =
{
start_date;
end_date;
history_fee;
account_fee;
purse_fee;
history_expiration;
purse_account_limit;
purse_timeout;
master_sig;
}
in
let start_date v = v.start_date in
let end_date v = v.end_date in
let history_fee v = v.history_fee in
let account_fee v = v.account_fee in
let purse_fee v = v.purse_fee in
let history_expiration v = v.history_expiration in
let purse_account_limit v = v.purse_account_limit in
let purse_timeout v = v.purse_timeout in
let master_sig v = v.master_sig in
let open Jsont.Object in
map ~kind:"GlobalFees" make
|> mem "start_date" Timestamp.jsont ~enc:start_date
|> mem "end_date" Timestamp.jsont ~enc:end_date
|> mem "history_fee" Amount.jsont ~enc:history_fee
|> mem "account_fee" Amount.jsont ~enc:account_fee
|> mem "purse_fee" Amount.jsont ~enc:purse_fee
|> mem "history_expiration" RelativeTime.jsont ~enc:history_expiration
|> mem "purse_account_limit" Jsont.int ~enc:purse_account_limit
|> mem "purse_timeout" RelativeTime.jsont ~enc:purse_timeout
|> mem "master_sig" GlobalFeesPS.jsont ~enc:master_sig
|> finish
end

View file

@ -292,6 +292,69 @@ module MasterDelAuditorPS = struct
include MK (R) include MK (R)
end end
module GlobalFeesPS = struct
module R = struct
(* purpose.purpose = TALER_SIGNATURE_MASTER_GLOBAL_FEES *)
type r = {
start_date: TimeAbsoluteNBO.t;
end_date: TimeAbsoluteNBO.t;
purse_timeout: TimeRelativeNBO.t;
kyc_timeout: TimeRelativeNBO.t;
history_expiration: TimeRelativeNBO.t;
history_fee: AmountNBO.t;
kyc_fee: AmountNBO.t;
account_fee: AmountNBO.t;
purse_fee: AmountNBO.t;
purse_account_limit: int32;
}
let bin =
let open Bin in
Purpose.make_bin Taler_signatures.master_global_fees @@ fun purpose ->
record
(fun
_purpose
start_date
end_date
purse_timeout
kyc_timeout
history_expiration
history_fee
kyc_fee
account_fee
purse_fee
purse_account_limit
->
{
start_date;
end_date;
purse_timeout;
kyc_timeout;
history_expiration;
history_fee;
kyc_fee;
account_fee;
purse_fee;
purse_account_limit;
})
|+ Purpose.field purpose
|+ field TimeAbsoluteNBO.bin (fun t -> t.start_date)
|+ field TimeRelativeNBO.bin (fun t -> t.end_date)
|+ field TimeRelativeNBO.bin (fun t -> t.purse_timeout)
|+ field TimeRelativeNBO.bin (fun t -> t.kyc_timeout)
|+ field TimeRelativeNBO.bin (fun t -> t.history_expiration)
|+ field AmountNBO.bin (fun t -> t.history_fee)
|+ field AmountNBO.bin (fun t -> t.kyc_fee)
|+ field AmountNBO.bin (fun t -> t.account_fee)
|+ field AmountNBO.bin (fun t -> t.purse_fee)
|+ field beint32 (fun t -> t.purse_account_limit)
|> sealr
end
include R
include MK (R)
end
(* ### BIN IMPL END ### *) (* ### BIN IMPL END ### *)
module WithdrawRequestPS = struct module WithdrawRequestPS = struct
@ -431,22 +494,6 @@ module MasterWireFeePS = struct
} }
end end
module GlobalFeesPS = struct
(* purpose.purpose = TALER_SIGNATURE_MASTER_GLOBAL_FEES *)
type t = {
start_date: TimeAbsoluteNBO.t;
end_date: TimeAbsoluteNBO.t;
purse_timeout: TimeRelativeNBO.t;
kyc_timeout: TimeRelativeNBO.t;
history_expiration: TimeRelativeNBO.t;
history_fee: AmountNBO.t;
kyc_fee: AmountNBO.t;
account_fee: AmountNBO.t;
purse_fee: AmountNBO.t;
purse_account_limit: int; (* uint32_t → int *)
}
end
module MasterDrainProfitPS = struct module MasterDrainProfitPS = struct
(* purpose.purpose = TALER_SIGNATURE_MASTER_DRAIN_PROFITS *) (* purpose.purpose = TALER_SIGNATURE_MASTER_DRAIN_PROFITS *)
type t = { type t = {