+ drain
This commit is contained in:
parent
e716990b11
commit
c8301fba7d
7 changed files with 43 additions and 8 deletions
|
|
@ -647,7 +647,7 @@ end
|
|||
|
||||
module DrainProfitsMessage = struct
|
||||
type t = {
|
||||
wtid: B32.t;
|
||||
wtid: Bytes32.t;
|
||||
debit_account_section: string;
|
||||
credit_payto_uri: string;
|
||||
date: Timestamp.t;
|
||||
|
|
|
|||
|
|
@ -537,7 +537,17 @@ module Drain = struct
|
|||
}
|
||||
|
||||
let do_ ~db_conn v =
|
||||
let* opt =
|
||||
Pg.find_drain_profit db_conn v.DrainProfitsMessage.wtid
|
||||
|> unwrap_err_caqti
|
||||
in
|
||||
match opt with
|
||||
| Some _ ->
|
||||
Logs.info (fun m -> m "drain profit message already added to database");
|
||||
Ok ()
|
||||
| None ->
|
||||
let+ () = Pg.insert_drain_profit db_conn v |> unwrap_err_caqti in
|
||||
Logs.info (fun m -> m "added drain profit message to database");
|
||||
()
|
||||
|
||||
let jsont = DrainProfitsMessage.jsont
|
||||
|
|
|
|||
11
src/pg.ml
11
src/pg.ml
|
|
@ -288,11 +288,20 @@ let get_wire_accounts =
|
|||
in
|
||||
fun (module Conn : CONN) () -> Conn.collect_list req ()
|
||||
|
||||
let find_drain_profit =
|
||||
let req =
|
||||
Caqti_type.(octets ->? drain_profit_message)
|
||||
"SELECT wtid, account_section, payto_uri, trigger_date, (amount).*, \
|
||||
master_sig FROM profit_drains WHERE wtid=$1"
|
||||
in
|
||||
fun (module Conn : CONN) wtid -> Conn.find_opt req wtid
|
||||
|
||||
let insert_drain_profit =
|
||||
let req =
|
||||
Caqti_type.(drain_profit_message ->. unit)
|
||||
"INSERT INTO profit_drains (wtid, account_section, payto_uri, \
|
||||
trigger_date, amount, master_sig) VALUES ($1, $2, $3, $4, ($5,$6), $7)"
|
||||
trigger_date, amount, master_sig) VALUES ($1::BYTEA, $2, $3, $4, \
|
||||
($5,$6), $7)"
|
||||
in
|
||||
fun (module Conn : CONN) v -> Conn.exec req v
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ let eddsa_sig = EddsaSignature.caqti
|
|||
(* todo: enum type for wire_method? *)
|
||||
let wire_method = Caqti_type.string
|
||||
let payto_uri = Caqti_type.string
|
||||
let b32 = B32.caqti
|
||||
|
||||
include struct
|
||||
(* alias for hash *)
|
||||
|
|
@ -266,7 +265,7 @@ let drain_profit_message =
|
|||
amount;
|
||||
master_sig;
|
||||
})
|
||||
Caqti_type.(t6 b32 string string time amount master_sig)
|
||||
Caqti_type.(t6 octets string string time amount master_sig)
|
||||
|
||||
let aml_officer_setup =
|
||||
let master_sig = Signatures.MasterAmlOfficerStatus.caqti in
|
||||
|
|
|
|||
|
|
@ -98,6 +98,18 @@ offline_tool disable-wire \
|
|||
offline_tool upload --input $b --url $url"/management/wire/disable"
|
||||
echo "[OK] /management/wire/disable"
|
||||
|
||||
# todo test drain
|
||||
# wtid (after base32 decode) must be 32bytes
|
||||
wtid="000G40R40M30E209185GR38E1W8124GK2GAHC5RR34D1P70X3RFG"
|
||||
offline_tool drain \
|
||||
--master_key $master_key \
|
||||
--output $b \
|
||||
--debit_account_section "" \
|
||||
--credit_payto_uri "" \
|
||||
--wtid $wtid \
|
||||
--date 0 \
|
||||
--amount $zero_euro
|
||||
offline_tool upload --input $b --url $url"/management/drain"
|
||||
echo "[OK] /management/drain"
|
||||
|
||||
# todo test aml-officer
|
||||
# todo test partners
|
||||
|
|
|
|||
|
|
@ -365,9 +365,9 @@ let cli =
|
|||
disable_auditor_cmd;
|
||||
wire_fee_cmd;
|
||||
global_fees_cmd;
|
||||
drain_cmd;
|
||||
enable_wire_cmd;
|
||||
disable_wire_cmd;
|
||||
drain_cmd;
|
||||
(* - *)
|
||||
test_hash64_cmd;
|
||||
]
|
||||
|
|
|
|||
|
|
@ -411,6 +411,11 @@ let disable_wire ~output ~master_key ~payto_uri =
|
|||
let drain ~output ~master_key ~debit_account_section ~credit_payto_uri ~wtid
|
||||
~date ~amount =
|
||||
let* key = read_master_key_file master_key in
|
||||
let* () =
|
||||
match String.length wtid = 32 with
|
||||
| false -> Error "invalid wtid: must be 32 bytes"
|
||||
| true -> Ok ()
|
||||
in
|
||||
let master_sig =
|
||||
let open Signatures.MasterDrainProfit in
|
||||
signf (EddsaSignature.sign ~key)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue