fix currency bin encoding; ok master-signatures(?)
This commit is contained in:
parent
ab82a357a9
commit
f3672edad5
8 changed files with 87 additions and 20 deletions
|
|
@ -92,6 +92,13 @@ let of_string =
|
|||
let jsont = Jsont.of_of_string ~kind:"Amount" of_string ~enc:to_string
|
||||
let currency_len = 12
|
||||
|
||||
let pad_currency s =
|
||||
let len = String.length s in
|
||||
assert (len <= 11);
|
||||
let b = Bytes.make 12 '\x00' in
|
||||
Bytes.blit_string s 0 b 0 len;
|
||||
Bytes.to_string b
|
||||
|
||||
let bin =
|
||||
let open Bin in
|
||||
record (fun _value _fraction _currency ->
|
||||
|
|
@ -99,7 +106,7 @@ let bin =
|
|||
assert false)
|
||||
|+ field neint64 (fun t -> t.value)
|
||||
|+ field neint32 (fun t -> t.fraction)
|
||||
|+ field (bytes currency_len) (fun t -> t.currency)
|
||||
|+ field (bytes currency_len) (fun t -> pad_currency t.currency)
|
||||
|> sealr
|
||||
|
||||
let bin_nbo =
|
||||
|
|
@ -107,5 +114,5 @@ let bin_nbo =
|
|||
record (fun _value _fraction _currency -> assert false)
|
||||
|+ field beint64 (fun t -> t.value)
|
||||
|+ field beint32 (fun t -> t.fraction)
|
||||
|+ field (bytes currency_len) (fun t -> t.currency)
|
||||
|+ field (bytes currency_len) (fun t -> pad_currency t.currency)
|
||||
|> sealr
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue