kee

Offline IOU signer with QR as transport
git clone https://holbrook.no/src/kee
Info | Log | Files | Refs | README | LICENSE

commit 57cfb966d5ad96aaa171b0e72f96c04a3c6b996b
parent 442616fe98b68a984fd50d818f7fbc317359123e
Author: lash <dev@holbrook.no>
Date:   Sun, 16 Jun 2024 04:46:24 +0100

Add more fields to ledger cli sprint

Diffstat:
Msrc/ledger.c | 25+++++++++++++++++++++++++
1 file changed, 25 insertions(+), 0 deletions(-)

diff --git a/src/ledger.c b/src/ledger.c @@ -2,6 +2,7 @@ #include <string.h> #include <libtasn1.h> #include <gcrypt.h> +#include <time.h> #include <rerr.h> #include <hex.h> @@ -1296,11 +1297,23 @@ int kee_ledger_verify(struct kee_ledger_t *ledger, int *idx) { return ERR_OK; } +/// \todo move to explicitly included source void kee_ledger_item_sprint(struct kee_ledger_item_t *item, char *out, size_t *char_len) { + struct tm item_time; + int c; char *p; p = out; + p = stpcpy(p, "time\t"); + + gmtime_r(&item->time.tv_sec, &item_time); + c = strftime(p, *char_len, "%F", &item_time); + p += c; + *p = 0x0a; + p++; + *char_len -= c - 1; + p = stpcpy(p, "sig us\t"); if (memcmp(item->alice_signature, zero_content, SIGNATURE_LENGTH)) { b2h((unsigned char*)item->alice_signature, SIGNATURE_LENGTH, (unsigned char*)p); @@ -1320,6 +1333,18 @@ void kee_ledger_item_sprint(struct kee_ledger_item_t *item, char *out, size_t *c } *p = 0x0a; p++; + + c = sprintf(p, "us credit delta:\t%d\n", item->alice_credit_delta); + p += c; + + c = sprintf(p, "them credit delta:\t%d\n", item->bob_credit_delta); + p += c; + + c = sprintf(p, "us collateral delta:\t%d\n", item->alice_collateral_delta); + p += c; + + c = sprintf(p, "them collateral delta:\t%d\n", item->bob_collateral_delta); + p += c; *char_len = (int)(p - out); }