From 38876c503ff53f7adf44bc82be4fec3ae9b02d01 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 15 Oct 2022 16:19:14 +0200 Subject: -refactor DB for reserve history/status routines --- src/util/exchange_signatures.c | 94 ++++++++++++++++++++++++++++++++++++++++++ src/util/wallet_signatures.c | 2 +- 2 files changed, 95 insertions(+), 1 deletion(-) (limited to 'src/util') diff --git a/src/util/exchange_signatures.c b/src/util/exchange_signatures.c index d42f70d66..8ecb3cafe 100644 --- a/src/util/exchange_signatures.c +++ b/src/util/exchange_signatures.c @@ -1379,6 +1379,100 @@ TALER_exchange_online_purse_created_verify ( } +GNUNET_NETWORK_STRUCT_BEGIN + +/** + * Response by which the exchange affirms that it has + * received funds deposited into a purse. + */ +struct TALER_CoinPurseRefundConfirmationPS +{ + + /** + * Purpose is #TALER_SIGNATURE_EXCHANGE_CONFIRM_PURSE_REFUND + */ + struct GNUNET_CRYPTO_EccSignaturePurpose purpose; + + /** + * Public key of the purse. + */ + struct TALER_PurseContractPublicKeyP purse_pub; + + /** + * Public key of the coin. + */ + struct TALER_CoinSpendPublicKeyP coin_pub; + + /** + * How much will be refunded to the purse. + */ + struct TALER_AmountNBO refunded_amount; + + /** + * How much was the refund fee. + */ + struct TALER_AmountNBO refund_fee; + +}; + +GNUNET_NETWORK_STRUCT_END + + +enum TALER_ErrorCode +TALER_exchange_online_purse_refund_sign ( + TALER_ExchangeSignCallback scb, + const struct TALER_Amount *amount_without_fee, + const struct TALER_Amount *refund_fee, + const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct TALER_PurseContractPublicKeyP *purse_pub, + struct TALER_ExchangePublicKeyP *pub, + struct TALER_ExchangeSignatureP *sig) +{ + struct TALER_CoinPurseRefundConfirmationPS dc = { + .purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_PURSE_REFUND), + .purpose.size = htonl (sizeof (dc)), + .coin_pub = *coin_pub, + .purse_pub = *purse_pub, + }; + + TALER_amount_hton (&dc.refunded_amount, + amount_without_fee); + TALER_amount_hton (&dc.refund_fee, + refund_fee); + return scb (&dc.purpose, + pub, + sig); +} + + +enum GNUNET_GenericReturnValue +TALER_exchange_online_purse_refund_verify ( + const struct TALER_Amount *amount_without_fee, + const struct TALER_Amount *refund_fee, + const struct TALER_CoinSpendPublicKeyP *coin_pub, + const struct TALER_PurseContractPublicKeyP *purse_pub, + const struct TALER_ExchangePublicKeyP *pub, + const struct TALER_ExchangeSignatureP *sig) +{ + struct TALER_CoinPurseRefundConfirmationPS dc = { + .purpose.purpose = htonl (TALER_SIGNATURE_EXCHANGE_CONFIRM_PURSE_REFUND), + .purpose.size = htonl (sizeof (dc)), + .coin_pub = *coin_pub, + .purse_pub = *purse_pub, + }; + + TALER_amount_hton (&dc.refunded_amount, + amount_without_fee); + TALER_amount_hton (&dc.refund_fee, + refund_fee); + return + GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_EXCHANGE_CONFIRM_PURSE_REFUND, + &dc, + &sig->eddsa_signature, + &pub->eddsa_pub); +} + + GNUNET_NETWORK_STRUCT_BEGIN /** diff --git a/src/util/wallet_signatures.c b/src/util/wallet_signatures.c index c57506bd8..1209bb699 100644 --- a/src/util/wallet_signatures.c +++ b/src/util/wallet_signatures.c @@ -1422,7 +1422,7 @@ struct TALER_ReserveClosePS /** * Hash of the payto://-URI of the target account * for the closure, or all zeros for the reserve - * origina ccount. + * origin account. */ struct TALER_PaytoHashP target_account_h_payto; -- cgit v1.2.3