aboutsummaryrefslogtreecommitdiff
path: root/src/auditor/taler-auditor.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/auditor/taler-auditor.c')
-rw-r--r--src/auditor/taler-auditor.c315
1 files changed, 177 insertions, 138 deletions
diff --git a/src/auditor/taler-auditor.c b/src/auditor/taler-auditor.c
index df4afd49f..296af8222 100644
--- a/src/auditor/taler-auditor.c
+++ b/src/auditor/taler-auditor.c
@@ -409,30 +409,29 @@ report (json_t *array,
409 * emergency request to all wallets to deposit pending coins for the 409 * emergency request to all wallets to deposit pending coins for the
410 * denomination (and as an exchange suffer a huge financial loss). 410 * denomination (and as an exchange suffer a huge financial loss).
411 * 411 *
412 * @param dki denomination key where the loss was detected 412 * @param issue denomination key where the loss was detected
413 * @param risk maximum risk that might have just become real (coins created by this @a dki) 413 * @param risk maximum risk that might have just become real (coins created by this @a issue)
414 * @param loss actual losses already (actualized before denomination was revoked) 414 * @param loss actual losses already (actualized before denomination was revoked)
415 */ 415 */
416static void 416static void
417report_emergency_by_amount (const struct 417report_emergency_by_amount (const struct TALER_DenominationKeyValidityPS *issue,
418 TALER_EXCHANGEDB_DenominationKeyInformationP *dki,
419 const struct TALER_Amount *risk, 418 const struct TALER_Amount *risk,
420 const struct TALER_Amount *loss) 419 const struct TALER_Amount *loss)
421{ 420{
422 report (report_emergencies, 421 report (report_emergencies,
423 json_pack ("{s:o, s:o, s:o, s:o, s:o, s:o}", 422 json_pack ("{s:o, s:o, s:o, s:o, s:o, s:o}",
424 "denompub_hash", 423 "denompub_hash",
425 GNUNET_JSON_from_data_auto (&dki->properties.denom_hash), 424 GNUNET_JSON_from_data_auto (&issue->denom_hash),
426 "denom_risk", 425 "denom_risk",
427 TALER_JSON_from_amount (risk), 426 TALER_JSON_from_amount (risk),
428 "denom_loss", 427 "denom_loss",
429 TALER_JSON_from_amount (loss), 428 TALER_JSON_from_amount (loss),
430 "start", 429 "start",
431 json_from_time_abs_nbo (dki->properties.start), 430 json_from_time_abs_nbo (issue->start),
432 "deposit_end", 431 "deposit_end",
433 json_from_time_abs_nbo (dki->properties.expire_deposit), 432 json_from_time_abs_nbo (issue->expire_deposit),
434 "value", 433 "value",
435 TALER_JSON_from_amount_nbo (&dki->properties.value))); 434 TALER_JSON_from_amount_nbo (&issue->value)));
436 GNUNET_assert (GNUNET_OK == 435 GNUNET_assert (GNUNET_OK ==
437 TALER_amount_add (&reported_emergency_risk_by_amount, 436 TALER_amount_add (&reported_emergency_risk_by_amount,
438 &reported_emergency_risk_by_amount, 437 &reported_emergency_risk_by_amount,
@@ -453,14 +452,13 @@ report_emergency_by_amount (const struct
453 * coins for the denomination (and as an exchange suffer a huge 452 * coins for the denomination (and as an exchange suffer a huge
454 * financial loss). 453 * financial loss).
455 * 454 *
456 * @param dki denomination key where the loss was detected 455 * @param issue denomination key where the loss was detected
457 * @param num_issued number of coins that were issued 456 * @param num_issued number of coins that were issued
458 * @param num_known number of coins that have been deposited 457 * @param num_known number of coins that have been deposited
459 * @param risk amount that is at risk 458 * @param risk amount that is at risk
460 */ 459 */
461static void 460static void
462report_emergency_by_count (const struct 461report_emergency_by_count (const struct TALER_DenominationKeyValidityPS *issue,
463 TALER_EXCHANGEDB_DenominationKeyInformationP *dki,
464 uint64_t num_issued, 462 uint64_t num_issued,
465 uint64_t num_known, 463 uint64_t num_known,
466 const struct TALER_Amount *risk) 464 const struct TALER_Amount *risk)
@@ -470,7 +468,7 @@ report_emergency_by_count (const struct
470 report (report_emergencies_by_count, 468 report (report_emergencies_by_count,
471 json_pack ("{s:o, s:I, s:I, s:o, s:o, s:o, s:o}", 469 json_pack ("{s:o, s:I, s:I, s:o, s:o, s:o, s:o}",
472 "denompub_hash", 470 "denompub_hash",
473 GNUNET_JSON_from_data_auto (&dki->properties.denom_hash), 471 GNUNET_JSON_from_data_auto (&issue->denom_hash),
474 "num_issued", 472 "num_issued",
475 (json_int_t) num_issued, 473 (json_int_t) num_issued,
476 "num_known", 474 "num_known",
@@ -478,17 +476,17 @@ report_emergency_by_count (const struct
478 "denom_risk", 476 "denom_risk",
479 TALER_JSON_from_amount (risk), 477 TALER_JSON_from_amount (risk),
480 "start", 478 "start",
481 json_from_time_abs_nbo (dki->properties.start), 479 json_from_time_abs_nbo (issue->start),
482 "deposit_end", 480 "deposit_end",
483 json_from_time_abs_nbo (dki->properties.expire_deposit), 481 json_from_time_abs_nbo (issue->expire_deposit),
484 "value", 482 "value",
485 TALER_JSON_from_amount_nbo (&dki->properties.value))); 483 TALER_JSON_from_amount_nbo (&issue->value)));
486 GNUNET_assert (GNUNET_OK == 484 GNUNET_assert (GNUNET_OK ==
487 TALER_amount_add (&reported_emergency_risk_by_count, 485 TALER_amount_add (&reported_emergency_risk_by_count,
488 &reported_emergency_risk_by_count, 486 &reported_emergency_risk_by_count,
489 risk)); 487 risk));
490 TALER_amount_ntoh (&denom_value, 488 TALER_amount_ntoh (&denom_value,
491 &dki->properties.value); 489 &issue->value);
492 for (uint64_t i = num_issued; i<num_known; i++) 490 for (uint64_t i = num_issued; i<num_known; i++)
493 GNUNET_assert (GNUNET_OK == 491 GNUNET_assert (GNUNET_OK ==
494 TALER_amount_add (&reported_emergency_loss_by_count, 492 TALER_amount_add (&reported_emergency_loss_by_count,
@@ -644,81 +642,120 @@ report_row_inconsistency (const char *table,
644/* ************************* Transaction-global state ************************ */ 642/* ************************* Transaction-global state ************************ */
645 643
646/** 644/**
647 * Results about denominations, cached per-transaction. 645 * Results about denominations, cached per-transaction, maps denomination pub hashes
646 * to `struct TALER_DenominationKeyValidityPS`.
648 */ 647 */
649static struct GNUNET_CONTAINER_MultiHashMap *denominations; 648static struct GNUNET_CONTAINER_MultiHashMap *denominations;
650 649
651 650
652/** 651/**
653 * Obtain information about a @a denom_pub. 652 * Function called with the results of select_denomination_info()
654 * 653 *
655 * @param dh hash of the denomination public key to look up 654 * @param cls closure, NULL
656 * @param[out] dki set to detailed information about @a denom_pub, NULL if not found, must 655 * @param issue issuing information with value, fees and other info about the denomination.
657 * NOT be freed by caller 656 * @return #GNUNET_OK (to continue)
658 * @return transaction status code
659 */ 657 */
660static enum GNUNET_DB_QueryStatus 658static int
661get_denomination_info_by_hash (const struct GNUNET_HashCode *dh, 659add_denomination (void *cls,
662 const struct 660 const struct TALER_DenominationKeyValidityPS *issue)
663 TALER_EXCHANGEDB_DenominationKeyInformationP **
664 dki)
665{ 661{
666 struct TALER_EXCHANGEDB_DenominationKeyInformationP *dkip; 662 struct TALER_DenominationKeyValidityPS *i;
667 enum GNUNET_DB_QueryStatus qs;
668 663
669 if (NULL == denominations) 664 (void) cls;
670 denominations = GNUNET_CONTAINER_multihashmap_create (256, 665 if (NULL !=
671 GNUNET_NO); 666 GNUNET_CONTAINER_multihashmap_get (denominations,
672 dkip = GNUNET_CONTAINER_multihashmap_get (denominations, 667 &issue->denom_hash))
673 dh); 668 return; /* value already known */
674 if (NULL != dkip)
675 {
676 /* cache hit */
677 *dki = dkip;
678 return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
679 }
680 dkip = GNUNET_new (struct TALER_EXCHANGEDB_DenominationKeyInformationP);
681 qs = edb->get_denomination_info (edb->cls,
682 esession,
683 dh,
684 dkip);
685 if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
686 {
687 GNUNET_free (dkip);
688 *dki = NULL;
689 return qs;
690 }
691 { 669 {
692 struct TALER_Amount value; 670 struct TALER_Amount value;
693 671
694 TALER_amount_ntoh (&value, 672 TALER_amount_ntoh (&value,
695 &dkip->properties.value); 673 &issue->value);
696 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 674 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
697 "Tracking denomination `%s' (%s)\n", 675 "Tracking denomination `%s' (%s)\n",
698 GNUNET_h2s (dh), 676 GNUNET_h2s (&issue->denom_hash),
699 TALER_amount2s (&value)); 677 TALER_amount2s (&value));
700 TALER_amount_ntoh (&value, 678 TALER_amount_ntoh (&value,
701 &dkip->properties.fee_withdraw); 679 &issue->fee_withdraw);
702 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 680 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
703 "Withdraw fee is %s\n", 681 "Withdraw fee is %s\n",
704 TALER_amount2s (&value)); 682 TALER_amount2s (&value));
705 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 683 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
706 "Start time is %s\n", 684 "Start time is %s\n",
707 GNUNET_STRINGS_absolute_time_to_string 685 GNUNET_STRINGS_absolute_time_to_string
708 (GNUNET_TIME_absolute_ntoh (dkip->properties.start))); 686 (GNUNET_TIME_absolute_ntoh (issue->start)));
709 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 687 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
710 "Expire deposit time is %s\n", 688 "Expire deposit time is %s\n",
711 GNUNET_STRINGS_absolute_time_to_string 689 GNUNET_STRINGS_absolute_time_to_string
712 (GNUNET_TIME_absolute_ntoh ( 690 (GNUNET_TIME_absolute_ntoh (issue->expire_deposit)));
713 dkip->properties.expire_deposit)));
714 } 691 }
715 *dki = dkip; 692 i = GNUNET_new (struct TALER_DenominationKeyValidityPS);
693 *i = *issue;
716 GNUNET_assert (GNUNET_OK == 694 GNUNET_assert (GNUNET_OK ==
717 GNUNET_CONTAINER_multihashmap_put (denominations, 695 GNUNET_CONTAINER_multihashmap_put (denominations,
718 dh, 696 &issue->denom_hash,
719 dkip, 697 i,
720 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 698 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
721 return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; 699 return GNUNET_OK;
700}
701
702
703/**
704 * Obtain information about a @a denom_pub.
705 *
706 * @param dh hash of the denomination public key to look up
707 * @param[out] issue set to detailed information about @a denom_pub, NULL if not found, must
708 * NOT be freed by caller
709 * @return transaction status code
710 */
711static enum GNUNET_DB_QueryStatus
712get_denomination_info_by_hash (const struct GNUNET_HashCode *dh,
713 const struct
714 TALER_DenominationKeyValidityPS **issue)
715{
716 const struct TALER_DenominationKeyValidityPS *i;
717
718 if (NULL == denominations)
719 {
720 enum GNUNET_DB_QueryStatus qs;
721
722 denominations = GNUNET_CONTAINER_multihashmap_create (256,
723 GNUNET_NO);
724 qs = adb->select_denomination_info (adb->cls,
725 asession,
726 &master_pub,
727 &add_denomination,
728 NULL);
729 if (0 > qs)
730 {
731 *issue = NULL;
732 return qs;
733 }
734 }
735 i = GNUNET_CONTAINER_multihashmap_get (denominations,
736 dh);
737 if (NULL != i)
738 {
739 /* cache hit */
740 *issue = i;
741 return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
742 }
743 /* maybe database changed since we last iterated, give it one more shot */
744 qs = adb->select_denomination_info (adb->cls,
745 asession,
746 &master_pub,
747 &add_denomination,
748 NULL);
749 i = GNUNET_CONTAINER_multihashmap_get (denominations,
750 dh);
751 if (NULL != i)
752 {
753 /* cache hit */
754 *issue = i;
755 return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
756 }
757 /* nope, definitively not there, hard error */
758 return GNUNET_DB_STATUS_HARD_ERROR;
722} 759}
723 760
724 761
@@ -726,7 +763,7 @@ get_denomination_info_by_hash (const struct GNUNET_HashCode *dh,
726 * Obtain information about a @a denom_pub. 763 * Obtain information about a @a denom_pub.
727 * 764 *
728 * @param denom_pub key to look up 765 * @param denom_pub key to look up
729 * @param[out] dki set to detailed information about @a denom_pub, NULL if not found, must 766 * @param[out] issue set to detailed information about @a denom_pub, NULL if not found, must
730 * NOT be freed by caller 767 * NOT be freed by caller
731 * @param[out] dh set to the hash of @a denom_pub, may be NULL 768 * @param[out] dh set to the hash of @a denom_pub, may be NULL
732 * @return transaction status code 769 * @return transaction status code
@@ -734,7 +771,7 @@ get_denomination_info_by_hash (const struct GNUNET_HashCode *dh,
734static enum GNUNET_DB_QueryStatus 771static enum GNUNET_DB_QueryStatus
735get_denomination_info (const struct TALER_DenominationPublicKey *denom_pub, 772get_denomination_info (const struct TALER_DenominationPublicKey *denom_pub,
736 const struct 773 const struct
737 TALER_EXCHANGEDB_DenominationKeyInformationP **dki, 774 TALER_DenominationKeyValidityPS **issue,
738 struct GNUNET_HashCode *dh) 775 struct GNUNET_HashCode *dh)
739{ 776{
740 struct GNUNET_HashCode hc; 777 struct GNUNET_HashCode hc;
@@ -744,7 +781,7 @@ get_denomination_info (const struct TALER_DenominationPublicKey *denom_pub,
744 GNUNET_CRYPTO_rsa_public_key_hash (denom_pub->rsa_public_key, 781 GNUNET_CRYPTO_rsa_public_key_hash (denom_pub->rsa_public_key,
745 dh); 782 dh);
746 return get_denomination_info_by_hash (dh, 783 return get_denomination_info_by_hash (dh,
747 dki); 784 issue);
748} 785}
749 786
750 787
@@ -761,12 +798,12 @@ free_dk_info (void *cls,
761 const struct GNUNET_HashCode *key, 798 const struct GNUNET_HashCode *key,
762 void *value) 799 void *value)
763{ 800{
764 struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki = value; 801 struct TALER_DenominationKeyValidityPS *issue = value;
765 802
766 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 803 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
767 "Done with denomination `%s'\n", 804 "Done with denomination `%s'\n",
768 GNUNET_h2s (key)); 805 GNUNET_h2s (key));
769 GNUNET_free (dki); 806 GNUNET_free (issue);
770 return GNUNET_OK; 807 return GNUNET_OK;
771} 808}
772 809
@@ -1054,7 +1091,7 @@ handle_reserve_out (void *cls,
1054 struct TALER_WithdrawRequestPS wsrd; 1091 struct TALER_WithdrawRequestPS wsrd;
1055 struct GNUNET_HashCode key; 1092 struct GNUNET_HashCode key;
1056 struct ReserveSummary *rs; 1093 struct ReserveSummary *rs;
1057 const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki; 1094 const struct TALER_DenominationKeyValidityPS *issue;
1058 struct TALER_Amount withdraw_fee; 1095 struct TALER_Amount withdraw_fee;
1059 struct GNUNET_TIME_Absolute valid_start; 1096 struct GNUNET_TIME_Absolute valid_start;
1060 struct GNUNET_TIME_Absolute expire_withdraw; 1097 struct GNUNET_TIME_Absolute expire_withdraw;
@@ -1066,7 +1103,7 @@ handle_reserve_out (void *cls,
1066 1103
1067 /* lookup denomination pub data (make sure denom_pub is valid, establish fees) */ 1104 /* lookup denomination pub data (make sure denom_pub is valid, establish fees) */
1068 qs = get_denomination_info (denom_pub, 1105 qs = get_denomination_info (denom_pub,
1069 &dki, 1106 &issue,
1070 &wsrd.h_denomination_pub); 1107 &wsrd.h_denomination_pub);
1071 if (0 > qs) 1108 if (0 > qs)
1072 { 1109 {
@@ -1084,8 +1121,13 @@ handle_reserve_out (void *cls,
1084 } 1121 }
1085 1122
1086 /* check that execution date is within withdraw range for denom_pub */ 1123 /* check that execution date is within withdraw range for denom_pub */
1087 valid_start = GNUNET_TIME_absolute_ntoh (dki->properties.start); 1124 valid_start = GNUNET_TIME_absolute_ntoh (issue->start);
1088 expire_withdraw = GNUNET_TIME_absolute_ntoh (dki->properties.expire_withdraw); 1125 expire_withdraw = GNUNET_TIME_absolute_ntoh (issue->expire_withdraw);
1126 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1127 "Checking withdraw timing: %llu, expire: %llu, timing: %llu\n",
1128 (unsigned long long) valid_start.abs_value_us,
1129 (unsigned long long) expire_withdraw.abs_value_us,
1130 (unsigned long long) execution_date.abs_value_us);
1089 if ( (valid_start.abs_value_us > execution_date.abs_value_us) || 1131 if ( (valid_start.abs_value_us > execution_date.abs_value_us) ||
1090 (expire_withdraw.abs_value_us < execution_date.abs_value_us) ) 1132 (expire_withdraw.abs_value_us < execution_date.abs_value_us) )
1091 { 1133 {
@@ -1105,7 +1147,7 @@ handle_reserve_out (void *cls,
1105 wsrd.reserve_pub = *reserve_pub; 1147 wsrd.reserve_pub = *reserve_pub;
1106 TALER_amount_hton (&wsrd.amount_with_fee, 1148 TALER_amount_hton (&wsrd.amount_with_fee,
1107 amount_with_fee); 1149 amount_with_fee);
1108 wsrd.withdraw_fee = dki->properties.fee_withdraw; 1150 wsrd.withdraw_fee = issue->fee_withdraw;
1109 wsrd.h_coin_envelope = *h_blind_ev; 1151 wsrd.h_coin_envelope = *h_blind_ev;
1110 if (GNUNET_OK != 1152 if (GNUNET_OK !=
1111 GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WALLET_RESERVE_WITHDRAW, 1153 GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WALLET_RESERVE_WITHDRAW,
@@ -1168,7 +1210,7 @@ handle_reserve_out (void *cls,
1168 TALER_B2S (reserve_pub), 1210 TALER_B2S (reserve_pub),
1169 TALER_amount2s (amount_with_fee)); 1211 TALER_amount2s (amount_with_fee));
1170 TALER_amount_ntoh (&withdraw_fee, 1212 TALER_amount_ntoh (&withdraw_fee,
1171 &dki->properties.fee_withdraw); 1213 &issue->fee_withdraw);
1172 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 1214 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
1173 "Increasing withdraw profits by fee %s\n", 1215 "Increasing withdraw profits by fee %s\n",
1174 TALER_amount2s (&withdraw_fee)); 1216 TALER_amount2s (&withdraw_fee));
@@ -2143,7 +2185,7 @@ struct WireCheckContext
2143 * @param coin_pub public key of the coin (for reporting) 2185 * @param coin_pub public key of the coin (for reporting)
2144 * @param h_contract_terms hash of the proposal for which we calculate the amount 2186 * @param h_contract_terms hash of the proposal for which we calculate the amount
2145 * @param merchant_pub public key of the merchant (who is allowed to issue refunds) 2187 * @param merchant_pub public key of the merchant (who is allowed to issue refunds)
2146 * @param dki denomination information about the coin 2188 * @param issue denomination information about the coin
2147 * @param tl_head head of transaction history to verify 2189 * @param tl_head head of transaction history to verify
2148 * @param[out] merchant_gain amount the coin contributes to the wire transfer to the merchant 2190 * @param[out] merchant_gain amount the coin contributes to the wire transfer to the merchant
2149 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 2191 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
@@ -2156,8 +2198,7 @@ check_transaction_history_for_deposit (const struct
2156 const struct 2198 const struct
2157 TALER_MerchantPublicKeyP *merchant_pub, 2199 TALER_MerchantPublicKeyP *merchant_pub,
2158 const struct 2200 const struct
2159 TALER_EXCHANGEDB_DenominationKeyInformationP 2201 TALER_DenominationKeyValidityPS *issue,
2160 *dki,
2161 const struct 2202 const struct
2162 TALER_EXCHANGEDB_TransactionList *tl_head, 2203 TALER_EXCHANGEDB_TransactionList *tl_head,
2163 struct TALER_Amount *merchant_gain) 2204 struct TALER_Amount *merchant_gain)
@@ -2230,7 +2271,7 @@ check_transaction_history_for_deposit (const struct
2230 } 2271 }
2231 amount_with_fee = &tl->details.deposit->amount_with_fee; 2272 amount_with_fee = &tl->details.deposit->amount_with_fee;
2232 fee = &tl->details.deposit->deposit_fee; 2273 fee = &tl->details.deposit->deposit_fee;
2233 fee_dki = &dki->properties.fee_deposit; 2274 fee_dki = &issue->fee_deposit;
2234 if (GNUNET_OK != 2275 if (GNUNET_OK !=
2235 TALER_amount_add (&expenditures, 2276 TALER_amount_add (&expenditures,
2236 &expenditures, 2277 &expenditures,
@@ -2284,7 +2325,7 @@ check_transaction_history_for_deposit (const struct
2284 case TALER_EXCHANGEDB_TT_REFRESH_MELT: 2325 case TALER_EXCHANGEDB_TT_REFRESH_MELT:
2285 amount_with_fee = &tl->details.melt->session.amount_with_fee; 2326 amount_with_fee = &tl->details.melt->session.amount_with_fee;
2286 fee = &tl->details.melt->melt_fee; 2327 fee = &tl->details.melt->melt_fee;
2287 fee_dki = &dki->properties.fee_refresh; 2328 fee_dki = &issue->fee_refresh;
2288 if (GNUNET_OK != 2329 if (GNUNET_OK !=
2289 TALER_amount_add (&expenditures, 2330 TALER_amount_add (&expenditures,
2290 &expenditures, 2331 &expenditures,
@@ -2308,7 +2349,7 @@ check_transaction_history_for_deposit (const struct
2308 case TALER_EXCHANGEDB_TT_REFUND: 2349 case TALER_EXCHANGEDB_TT_REFUND:
2309 amount_with_fee = &tl->details.refund->refund_amount; 2350 amount_with_fee = &tl->details.refund->refund_amount;
2310 fee = &tl->details.refund->refund_fee; 2351 fee = &tl->details.refund->refund_fee;
2311 fee_dki = &dki->properties.fee_refund; 2352 fee_dki = &issue->fee_refund;
2312 if (GNUNET_OK != 2353 if (GNUNET_OK !=
2313 TALER_amount_add (&refunds, 2354 TALER_amount_add (&refunds,
2314 &refunds, 2355 &refunds,
@@ -2422,7 +2463,7 @@ check_transaction_history_for_deposit (const struct
2422 2463
2423 /* Now check that 'spent' is less or equal than total coin value */ 2464 /* Now check that 'spent' is less or equal than total coin value */
2424 TALER_amount_ntoh (&value, 2465 TALER_amount_ntoh (&value,
2425 &dki->properties.value); 2466 &issue->value);
2426 if (1 == TALER_amount_cmp (&spent, 2467 if (1 == TALER_amount_cmp (&spent,
2427 &value)) 2468 &value))
2428 { 2469 {
@@ -2493,7 +2534,7 @@ wire_transfer_information_cb (void *cls,
2493 const struct TALER_Amount *deposit_fee) 2534 const struct TALER_Amount *deposit_fee)
2494{ 2535{
2495 struct WireCheckContext *wcc = cls; 2536 struct WireCheckContext *wcc = cls;
2496 const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki; 2537 const struct TALER_DenominationKeyValidityPS *issue;
2497 struct TALER_Amount computed_value; 2538 struct TALER_Amount computed_value;
2498 struct TALER_Amount coin_value_without_fee; 2539 struct TALER_Amount coin_value_without_fee;
2499 struct TALER_EXCHANGEDB_TransactionList *tl; 2540 struct TALER_EXCHANGEDB_TransactionList *tl;
@@ -2559,7 +2600,7 @@ wire_transfer_information_cb (void *cls,
2559 } 2600 }
2560 GNUNET_assert (NULL != coin); /* hard check that switch worked */ 2601 GNUNET_assert (NULL != coin); /* hard check that switch worked */
2561 qs = get_denomination_info_by_hash (&coin->denom_pub_hash, 2602 qs = get_denomination_info_by_hash (&coin->denom_pub_hash,
2562 &dki); 2603 &issue);
2563 if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) 2604 if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
2564 { 2605 {
2565 GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs); 2606 GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR == qs);
@@ -2581,7 +2622,7 @@ wire_transfer_information_cb (void *cls,
2581 "row", (json_int_t) rowid, 2622 "row", (json_int_t) rowid,
2582 "loss", TALER_JSON_from_amount (coin_value), 2623 "loss", TALER_JSON_from_amount (coin_value),
2583 "key_pub", GNUNET_JSON_from_data_auto ( 2624 "key_pub", GNUNET_JSON_from_data_auto (
2584 &dki->properties.denom_hash))); 2625 &issue->denom_hash)));
2585 GNUNET_break (GNUNET_OK == 2626 GNUNET_break (GNUNET_OK ==
2586 TALER_amount_add (&total_bad_sig_loss, 2627 TALER_amount_add (&total_bad_sig_loss,
2587 &total_bad_sig_loss, 2628 &total_bad_sig_loss,
@@ -2596,14 +2637,14 @@ wire_transfer_information_cb (void *cls,
2596 return; 2637 return;
2597 } 2638 }
2598 2639
2599 GNUNET_assert (NULL != dki); /* mostly to help static analysis */ 2640 GNUNET_assert (NULL != issue); /* mostly to help static analysis */
2600 /* Check transaction history to see if it supports aggregate 2641 /* Check transaction history to see if it supports aggregate
2601 valuation */ 2642 valuation */
2602 if (GNUNET_OK != 2643 if (GNUNET_OK !=
2603 check_transaction_history_for_deposit (coin_pub, 2644 check_transaction_history_for_deposit (coin_pub,
2604 h_contract_terms, 2645 h_contract_terms,
2605 merchant_pub, 2646 merchant_pub,
2606 dki, 2647 issue,
2607 tl, 2648 tl,
2608 &computed_value)) 2649 &computed_value))
2609 { 2650 {
@@ -3156,7 +3197,7 @@ struct DenominationSummary
3156 /** 3197 /**
3157 * Denomination key information for this denomination. 3198 * Denomination key information for this denomination.
3158 */ 3199 */
3159 const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki; 3200 const struct TALER_DenominationKeyValidityPS *issue;
3160 3201
3161 /** 3202 /**
3162 * #GNUNET_YES if this record already existed in the DB. 3203 * #GNUNET_YES if this record already existed in the DB.
@@ -3297,14 +3338,13 @@ init_denomination (const struct GNUNET_HashCode *denom_hash,
3297 * Obtain the denomination summary for the given @a dh 3338 * Obtain the denomination summary for the given @a dh
3298 * 3339 *
3299 * @param cc our execution context 3340 * @param cc our execution context
3300 * @param dki denomination key information for @a dh 3341 * @param issue denomination key information for @a dh
3301 * @param dh the denomination hash to use for the lookup 3342 * @param dh the denomination hash to use for the lookup
3302 * @return NULL on error 3343 * @return NULL on error
3303 */ 3344 */
3304static struct DenominationSummary * 3345static struct DenominationSummary *
3305get_denomination_summary (struct CoinContext *cc, 3346get_denomination_summary (struct CoinContext *cc,
3306 const struct 3347 const struct TALER_DenominationKeyValidityPS *issue,
3307 TALER_EXCHANGEDB_DenominationKeyInformationP *dki,
3308 const struct GNUNET_HashCode *dh) 3348 const struct GNUNET_HashCode *dh)
3309{ 3349{
3310 struct DenominationSummary *ds; 3350 struct DenominationSummary *ds;
@@ -3314,7 +3354,7 @@ get_denomination_summary (struct CoinContext *cc,
3314 if (NULL != ds) 3354 if (NULL != ds)
3315 return ds; 3355 return ds;
3316 ds = GNUNET_new (struct DenominationSummary); 3356 ds = GNUNET_new (struct DenominationSummary);
3317 ds->dki = dki; 3357 ds->issue = issue;
3318 if (0 > (cc->qs = init_denomination (dh, 3358 if (0 > (cc->qs = init_denomination (dh,
3319 ds))) 3359 ds)))
3320 { 3360 {
@@ -3348,14 +3388,14 @@ sync_denomination (void *cls,
3348{ 3388{
3349 struct CoinContext *cc = cls; 3389 struct CoinContext *cc = cls;
3350 struct DenominationSummary *ds = value; 3390 struct DenominationSummary *ds = value;
3351 const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki = ds->dki; 3391 const struct TALER_DenominationKeyValidityPS *issue = ds->issue;
3352 struct GNUNET_TIME_Absolute now; 3392 struct GNUNET_TIME_Absolute now;
3353 struct GNUNET_TIME_Absolute expire_deposit; 3393 struct GNUNET_TIME_Absolute expire_deposit;
3354 struct GNUNET_TIME_Absolute expire_deposit_grace; 3394 struct GNUNET_TIME_Absolute expire_deposit_grace;
3355 enum GNUNET_DB_QueryStatus qs; 3395 enum GNUNET_DB_QueryStatus qs;
3356 3396
3357 now = GNUNET_TIME_absolute_get (); 3397 now = GNUNET_TIME_absolute_get ();
3358 expire_deposit = GNUNET_TIME_absolute_ntoh (dki->properties.expire_deposit); 3398 expire_deposit = GNUNET_TIME_absolute_ntoh (issue->expire_deposit);
3359 /* add day grace period to deal with clocks not being perfectly synchronized */ 3399 /* add day grace period to deal with clocks not being perfectly synchronized */
3360 expire_deposit_grace = GNUNET_TIME_absolute_add (expire_deposit, 3400 expire_deposit_grace = GNUNET_TIME_absolute_add (expire_deposit,
3361 DEPOSIT_GRACE_PERIOD); 3401 DEPOSIT_GRACE_PERIOD);
@@ -3434,14 +3474,14 @@ sync_denomination (void *cls,
3434 { 3474 {
3435 if (ds->num_issued < (uint64_t) cnt) 3475 if (ds->num_issued < (uint64_t) cnt)
3436 { 3476 {
3437 report_emergency_by_count (dki, 3477 report_emergency_by_count (issue,
3438 ds->num_issued, 3478 ds->num_issued,
3439 cnt, 3479 cnt,
3440 &ds->denom_risk); 3480 &ds->denom_risk);
3441 } 3481 }
3442 if (GNUNET_YES == ds->report_emergency) 3482 if (GNUNET_YES == ds->report_emergency)
3443 { 3483 {
3444 report_emergency_by_amount (dki, 3484 report_emergency_by_amount (issue,
3445 &ds->denom_risk, 3485 &ds->denom_risk,
3446 &ds->denom_loss); 3486 &ds->denom_loss);
3447 3487
@@ -3515,7 +3555,7 @@ withdraw_cb (void *cls,
3515 struct CoinContext *cc = cls; 3555 struct CoinContext *cc = cls;
3516 struct DenominationSummary *ds; 3556 struct DenominationSummary *ds;
3517 struct GNUNET_HashCode dh; 3557 struct GNUNET_HashCode dh;
3518 const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki; 3558 const struct TALER_DenominationKeyValidityPS *issue;
3519 struct TALER_Amount value; 3559 struct TALER_Amount value;
3520 enum GNUNET_DB_QueryStatus qs; 3560 enum GNUNET_DB_QueryStatus qs;
3521 3561
@@ -3523,7 +3563,7 @@ withdraw_cb (void *cls,
3523 ppc.last_withdraw_serial_id = rowid + 1; 3563 ppc.last_withdraw_serial_id = rowid + 1;
3524 3564
3525 qs = get_denomination_info (denom_pub, 3565 qs = get_denomination_info (denom_pub,
3526 &dki, 3566 &issue,
3527 &dh); 3567 &dh);
3528 if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) 3568 if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
3529 { 3569 {
@@ -3534,7 +3574,7 @@ withdraw_cb (void *cls,
3534 return GNUNET_SYSERR; 3574 return GNUNET_SYSERR;
3535 } 3575 }
3536 ds = get_denomination_summary (cc, 3576 ds = get_denomination_summary (cc,
3537 dki, 3577 issue,
3538 &dh); 3578 &dh);
3539 if (NULL == ds) 3579 if (NULL == ds)
3540 { 3580 {
@@ -3542,7 +3582,7 @@ withdraw_cb (void *cls,
3542 return GNUNET_SYSERR; 3582 return GNUNET_SYSERR;
3543 } 3583 }
3544 TALER_amount_ntoh (&value, 3584 TALER_amount_ntoh (&value,
3545 &dki->properties.value); 3585 &issue->value);
3546 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3586 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3547 "Issued coin in denomination `%s' of total value %s\n", 3587 "Issued coin in denomination `%s' of total value %s\n",
3548 GNUNET_h2s (&dh), 3588 GNUNET_h2s (&dh),
@@ -3604,7 +3644,7 @@ struct RevealContext
3604 struct TALER_DenominationPublicKey *new_dps; 3644 struct TALER_DenominationPublicKey *new_dps;
3605 3645
3606 /** 3646 /**
3607 * Size of the @a new_dp and @a new_dki arrays. 3647 * Size of the @a new_dp and @a new_dps arrays.
3608 */ 3648 */
3609 unsigned int num_newcoins; 3649 unsigned int num_newcoins;
3610}; 3650};
@@ -3720,7 +3760,7 @@ refresh_session_cb (void *cls,
3720{ 3760{
3721 struct CoinContext *cc = cls; 3761 struct CoinContext *cc = cls;
3722 struct TALER_RefreshMeltCoinAffirmationPS rmc; 3762 struct TALER_RefreshMeltCoinAffirmationPS rmc;
3723 const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki; 3763 const struct TALER_DenominationKeyValidityPS *issue;
3724 struct DenominationSummary *dso; 3764 struct DenominationSummary *dso;
3725 struct TALER_Amount amount_without_fee; 3765 struct TALER_Amount amount_without_fee;
3726 struct TALER_Amount tmp; 3766 struct TALER_Amount tmp;
@@ -3730,7 +3770,7 @@ refresh_session_cb (void *cls,
3730 ppc.last_melt_serial_id = rowid + 1; 3770 ppc.last_melt_serial_id = rowid + 1;
3731 3771
3732 qs = get_denomination_info (denom_pub, 3772 qs = get_denomination_info (denom_pub,
3733 &dki, 3773 &issue,
3734 NULL); 3774 NULL);
3735 if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) 3775 if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
3736 { 3776 {
@@ -3754,7 +3794,7 @@ refresh_session_cb (void *cls,
3754 rmc.rc = *rc; 3794 rmc.rc = *rc;
3755 TALER_amount_hton (&rmc.amount_with_fee, 3795 TALER_amount_hton (&rmc.amount_with_fee,
3756 amount_with_fee); 3796 amount_with_fee);
3757 rmc.melt_fee = dki->properties.fee_refresh; 3797 rmc.melt_fee = issue->fee_refresh;
3758 rmc.coin_pub = *coin_pub; 3798 rmc.coin_pub = *coin_pub;
3759 if (GNUNET_OK != 3799 if (GNUNET_OK !=
3760 GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WALLET_COIN_MELT, 3800 GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_WALLET_COIN_MELT,
@@ -3777,7 +3817,7 @@ refresh_session_cb (void *cls,
3777 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3817 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3778 "Melting coin %s in denomination `%s' of value %s\n", 3818 "Melting coin %s in denomination `%s' of value %s\n",
3779 TALER_B2S (coin_pub), 3819 TALER_B2S (coin_pub),
3780 GNUNET_h2s (&dki->properties.denom_hash), 3820 GNUNET_h2s (&issue->denom_hash),
3781 TALER_amount2s (amount_with_fee)); 3821 TALER_amount2s (amount_with_fee));
3782 3822
3783 { 3823 {
@@ -3821,9 +3861,8 @@ refresh_session_cb (void *cls,
3821 } 3861 }
3822 3862
3823 { 3863 {
3824 const struct 3864 const struct TALER_DenominationKeyValidityPS *new_issues[reveal_ctx.
3825 TALER_EXCHANGEDB_DenominationKeyInformationP *new_dkis[reveal_ctx. 3865 num_newcoins];
3826 num_newcoins];
3827 3866
3828 /* Update outstanding amounts for all new coin's denominations, and check 3867 /* Update outstanding amounts for all new coin's denominations, and check
3829 that the resulting amounts are consistent with the value being refreshed. */ 3868 that the resulting amounts are consistent with the value being refreshed. */
@@ -3832,7 +3871,7 @@ refresh_session_cb (void *cls,
3832 { 3871 {
3833 /* lookup new coin denomination key */ 3872 /* lookup new coin denomination key */
3834 qs = get_denomination_info (&reveal_ctx.new_dps[i], 3873 qs = get_denomination_info (&reveal_ctx.new_dps[i],
3835 &new_dkis[i], 3874 &new_issues[i],
3836 NULL); 3875 NULL);
3837 if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) 3876 if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
3838 { 3877 {
@@ -3858,9 +3897,9 @@ refresh_session_cb (void *cls,
3858 struct TALER_Amount value; 3897 struct TALER_Amount value;
3859 3898
3860 TALER_amount_ntoh (&fee, 3899 TALER_amount_ntoh (&fee,
3861 &new_dkis[i]->properties.fee_withdraw); 3900 &new_issues[i]->fee_withdraw);
3862 TALER_amount_ntoh (&value, 3901 TALER_amount_ntoh (&value,
3863 &new_dkis[i]->properties.value); 3902 &new_issues[i]->value);
3864 if ( (GNUNET_OK != 3903 if ( (GNUNET_OK !=
3865 TALER_amount_add (&refresh_cost, 3904 TALER_amount_add (&refresh_cost,
3866 &refresh_cost, 3905 &refresh_cost,
@@ -3881,7 +3920,7 @@ refresh_session_cb (void *cls,
3881 struct TALER_Amount melt_fee; 3920 struct TALER_Amount melt_fee;
3882 3921
3883 TALER_amount_ntoh (&melt_fee, 3922 TALER_amount_ntoh (&melt_fee,
3884 &dki->properties.fee_refresh); 3923 &issue->fee_refresh);
3885 if (GNUNET_OK != 3924 if (GNUNET_OK !=
3886 TALER_amount_subtract (&amount_without_fee, 3925 TALER_amount_subtract (&amount_without_fee,
3887 amount_with_fee, 3926 amount_with_fee,
@@ -3913,18 +3952,18 @@ refresh_session_cb (void *cls,
3913 struct TALER_Amount value; 3952 struct TALER_Amount value;
3914 3953
3915 dsi = get_denomination_summary (cc, 3954 dsi = get_denomination_summary (cc,
3916 new_dkis[i], 3955 new_issues[i],
3917 &new_dkis[i]->properties.denom_hash); 3956 &new_issues[i]->denom_hash);
3918 if (NULL == dsi) 3957 if (NULL == dsi)
3919 { 3958 {
3920 GNUNET_break (0); 3959 GNUNET_break (0);
3921 return GNUNET_SYSERR; 3960 return GNUNET_SYSERR;
3922 } 3961 }
3923 TALER_amount_ntoh (&value, 3962 TALER_amount_ntoh (&value,
3924 &new_dkis[i]->properties.value); 3963 &new_issues[i]->value);
3925 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3964 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3926 "Created fresh coin in denomination `%s' of value %s\n", 3965 "Created fresh coin in denomination `%s' of value %s\n",
3927 GNUNET_h2s (&new_dkis[i]->properties.denom_hash), 3966 GNUNET_h2s (&new_issues[i]->denom_hash),
3928 TALER_amount2s (&value)); 3967 TALER_amount2s (&value));
3929 dsi->num_issued++; 3968 dsi->num_issued++;
3930 if (GNUNET_OK != 3969 if (GNUNET_OK !=
@@ -3947,7 +3986,7 @@ refresh_session_cb (void *cls,
3947 } 3986 }
3948 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3987 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3949 "New balance of denomination `%s' is %s\n", 3988 "New balance of denomination `%s' is %s\n",
3950 GNUNET_h2s (&new_dkis[i]->properties.denom_hash), 3989 GNUNET_h2s (&new_issues[i]->denom_hash),
3951 TALER_amount2s (&dsi->denom_balance)); 3990 TALER_amount2s (&dsi->denom_balance));
3952 if (GNUNET_OK != 3991 if (GNUNET_OK !=
3953 TALER_amount_add (&total_escrow_balance, 3992 TALER_amount_add (&total_escrow_balance,
@@ -3973,8 +4012,8 @@ refresh_session_cb (void *cls,
3973 4012
3974 /* update old coin's denomination balance */ 4013 /* update old coin's denomination balance */
3975 dso = get_denomination_summary (cc, 4014 dso = get_denomination_summary (cc,
3976 dki, 4015 issue,
3977 &dki->properties.denom_hash); 4016 &issue->denom_hash);
3978 if (NULL == dso) 4017 if (NULL == dso)
3979 { 4018 {
3980 GNUNET_break (0); 4019 GNUNET_break (0);
@@ -4021,7 +4060,7 @@ refresh_session_cb (void *cls,
4021 4060
4022 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4061 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4023 "New balance of denomination `%s' after melt is %s\n", 4062 "New balance of denomination `%s' after melt is %s\n",
4024 GNUNET_h2s (&dki->properties.denom_hash), 4063 GNUNET_h2s (&issue->denom_hash),
4025 TALER_amount2s (&dso->denom_balance)); 4064 TALER_amount2s (&dso->denom_balance));
4026 4065
4027 /* update global melt fees */ 4066 /* update global melt fees */
@@ -4029,7 +4068,7 @@ refresh_session_cb (void *cls,
4029 struct TALER_Amount rfee; 4068 struct TALER_Amount rfee;
4030 4069
4031 TALER_amount_ntoh (&rfee, 4070 TALER_amount_ntoh (&rfee,
4032 &dki->properties.fee_refresh); 4071 &issue->fee_refresh);
4033 if (GNUNET_OK != 4072 if (GNUNET_OK !=
4034 TALER_amount_add (&total_melt_fee_income, 4073 TALER_amount_add (&total_melt_fee_income,
4035 &total_melt_fee_income, 4074 &total_melt_fee_income,
@@ -4083,7 +4122,7 @@ deposit_cb (void *cls,
4083 int done) 4122 int done)
4084{ 4123{
4085 struct CoinContext *cc = cls; 4124 struct CoinContext *cc = cls;
4086 const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki; 4125 const struct TALER_DenominationKeyValidityPS *issue;
4087 struct DenominationSummary *ds; 4126 struct DenominationSummary *ds;
4088 struct TALER_DepositRequestPS dr; 4127 struct TALER_DepositRequestPS dr;
4089 struct TALER_Amount tmp; 4128 struct TALER_Amount tmp;
@@ -4093,7 +4132,7 @@ deposit_cb (void *cls,
4093 ppc.last_deposit_serial_id = rowid + 1; 4132 ppc.last_deposit_serial_id = rowid + 1;
4094 4133
4095 qs = get_denomination_info (denom_pub, 4134 qs = get_denomination_info (denom_pub,
4096 &dki, 4135 &issue,
4097 NULL); 4136 NULL);
4098 if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) 4137 if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
4099 { 4138 {
@@ -4127,7 +4166,7 @@ deposit_cb (void *cls,
4127 dr.refund_deadline = GNUNET_TIME_absolute_hton (refund_deadline); 4166 dr.refund_deadline = GNUNET_TIME_absolute_hton (refund_deadline);
4128 TALER_amount_hton (&dr.amount_with_fee, 4167 TALER_amount_hton (&dr.amount_with_fee,
4129 amount_with_fee); 4168 amount_with_fee);
4130 dr.deposit_fee = dki->properties.fee_deposit; 4169 dr.deposit_fee = issue->fee_deposit;
4131 dr.merchant = *merchant_pub; 4170 dr.merchant = *merchant_pub;
4132 dr.coin_pub = *coin_pub; 4171 dr.coin_pub = *coin_pub;
4133 if (GNUNET_OK != 4172 if (GNUNET_OK !=
@@ -4151,13 +4190,13 @@ deposit_cb (void *cls,
4151 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4190 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4152 "Deposited coin %s in denomination `%s' of value %s\n", 4191 "Deposited coin %s in denomination `%s' of value %s\n",
4153 TALER_B2S (coin_pub), 4192 TALER_B2S (coin_pub),
4154 GNUNET_h2s (&dki->properties.denom_hash), 4193 GNUNET_h2s (&issue->denom_hash),
4155 TALER_amount2s (amount_with_fee)); 4194 TALER_amount2s (amount_with_fee));
4156 4195
4157 /* update old coin's denomination balance */ 4196 /* update old coin's denomination balance */
4158 ds = get_denomination_summary (cc, 4197 ds = get_denomination_summary (cc,
4159 dki, 4198 issue,
4160 &dki->properties.denom_hash); 4199 &issue->denom_hash);
4161 if (NULL == ds) 4200 if (NULL == ds)
4162 { 4201 {
4163 GNUNET_break (0); 4202 GNUNET_break (0);
@@ -4205,7 +4244,7 @@ deposit_cb (void *cls,
4205 4244
4206 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4245 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4207 "New balance of denomination `%s' after deposit is %s\n", 4246 "New balance of denomination `%s' after deposit is %s\n",
4208 GNUNET_h2s (&dki->properties.denom_hash), 4247 GNUNET_h2s (&issue->denom_hash),
4209 TALER_amount2s (&ds->denom_balance)); 4248 TALER_amount2s (&ds->denom_balance));
4210 4249
4211 /* update global up melt fees */ 4250 /* update global up melt fees */
@@ -4213,7 +4252,7 @@ deposit_cb (void *cls,
4213 struct TALER_Amount dfee; 4252 struct TALER_Amount dfee;
4214 4253
4215 TALER_amount_ntoh (&dfee, 4254 TALER_amount_ntoh (&dfee,
4216 &dki->properties.fee_deposit); 4255 &issue->fee_deposit);
4217 if (GNUNET_OK != 4256 if (GNUNET_OK !=
4218 TALER_amount_add (&total_deposit_fee_income, 4257 TALER_amount_add (&total_deposit_fee_income,
4219 &total_deposit_fee_income, 4258 &total_deposit_fee_income,
@@ -4258,7 +4297,7 @@ refund_cb (void *cls,
4258 const struct TALER_Amount *amount_with_fee) 4297 const struct TALER_Amount *amount_with_fee)
4259{ 4298{
4260 struct CoinContext *cc = cls; 4299 struct CoinContext *cc = cls;
4261 const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki; 4300 const struct TALER_DenominationKeyValidityPS *issue;
4262 struct DenominationSummary *ds; 4301 struct DenominationSummary *ds;
4263 struct TALER_RefundRequestPS rr; 4302 struct TALER_RefundRequestPS rr;
4264 struct TALER_Amount amount_without_fee; 4303 struct TALER_Amount amount_without_fee;
@@ -4269,7 +4308,7 @@ refund_cb (void *cls,
4269 ppc.last_refund_serial_id = rowid + 1; 4308 ppc.last_refund_serial_id = rowid + 1;
4270 4309
4271 qs = get_denomination_info (denom_pub, 4310 qs = get_denomination_info (denom_pub,
4272 &dki, 4311 &issue,
4273 NULL); 4312 NULL);
4274 if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) 4313 if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
4275 { 4314 {
@@ -4286,7 +4325,7 @@ refund_cb (void *cls,
4286 rr.rtransaction_id = GNUNET_htonll (rtransaction_id); 4325 rr.rtransaction_id = GNUNET_htonll (rtransaction_id);
4287 TALER_amount_hton (&rr.refund_amount, 4326 TALER_amount_hton (&rr.refund_amount,
4288 amount_with_fee); 4327 amount_with_fee);
4289 rr.refund_fee = dki->properties.fee_refund; 4328 rr.refund_fee = issue->fee_refund;
4290 if (GNUNET_OK != 4329 if (GNUNET_OK !=
4291 GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_REFUND, 4330 GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_REFUND,
4292 &rr.purpose, 4331 &rr.purpose,
@@ -4307,7 +4346,7 @@ refund_cb (void *cls,
4307 } 4346 }
4308 4347
4309 TALER_amount_ntoh (&refund_fee, 4348 TALER_amount_ntoh (&refund_fee,
4310 &dki->properties.fee_refund); 4349 &issue->fee_refund);
4311 if (GNUNET_OK != 4350 if (GNUNET_OK !=
4312 TALER_amount_subtract (&amount_without_fee, 4351 TALER_amount_subtract (&amount_without_fee,
4313 amount_with_fee, 4352 amount_with_fee,
@@ -4324,13 +4363,13 @@ refund_cb (void *cls,
4324 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4363 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4325 "Refunding coin %s in denomination `%s' value %s\n", 4364 "Refunding coin %s in denomination `%s' value %s\n",
4326 TALER_B2S (coin_pub), 4365 TALER_B2S (coin_pub),
4327 GNUNET_h2s (&dki->properties.denom_hash), 4366 GNUNET_h2s (&issue->denom_hash),
4328 TALER_amount2s (amount_with_fee)); 4367 TALER_amount2s (amount_with_fee));
4329 4368
4330 /* update coin's denomination balance */ 4369 /* update coin's denomination balance */
4331 ds = get_denomination_summary (cc, 4370 ds = get_denomination_summary (cc,
4332 dki, 4371 issue,
4333 &dki->properties.denom_hash); 4372 &issue->denom_hash);
4334 if (NULL == ds) 4373 if (NULL == ds)
4335 { 4374 {
4336 GNUNET_break (0); 4375 GNUNET_break (0);
@@ -4375,7 +4414,7 @@ refund_cb (void *cls,
4375 4414
4376 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4415 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4377 "New balance of denomination `%s' after refund is %s\n", 4416 "New balance of denomination `%s' after refund is %s\n",
4378 GNUNET_h2s (&dki->properties.denom_hash), 4417 GNUNET_h2s (&issue->denom_hash),
4379 TALER_amount2s (&ds->denom_balance)); 4418 TALER_amount2s (&ds->denom_balance));
4380 4419
4381 /* update total refund fee balance */ 4420 /* update total refund fee balance */
@@ -4418,7 +4457,7 @@ check_payback (struct CoinContext *cc,
4418 struct TALER_PaybackRequestPS pr; 4457 struct TALER_PaybackRequestPS pr;
4419 struct DenominationSummary *ds; 4458 struct DenominationSummary *ds;
4420 enum GNUNET_DB_QueryStatus qs; 4459 enum GNUNET_DB_QueryStatus qs;
4421 const struct TALER_EXCHANGEDB_DenominationKeyInformationP *dki; 4460 const struct TALER_DenominationKeyValidityPS *issue;
4422 4461
4423 if (GNUNET_OK != 4462 if (GNUNET_OK !=
4424 TALER_test_coin_valid (coin, 4463 TALER_test_coin_valid (coin,
@@ -4437,7 +4476,7 @@ check_payback (struct CoinContext *cc,
4437 amount)); 4476 amount));
4438 } 4477 }
4439 qs = get_denomination_info (denom_pub, 4478 qs = get_denomination_info (denom_pub,
4440 &dki, 4479 &issue,
4441 &pr.h_denom_pub); 4480 &pr.h_denom_pub);
4442 if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs) 4481 if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != qs)
4443 { 4482 {
@@ -4471,8 +4510,8 @@ check_payback (struct CoinContext *cc,
4471 return GNUNET_OK; 4510 return GNUNET_OK;
4472 } 4511 }
4473 ds = get_denomination_summary (cc, 4512 ds = get_denomination_summary (cc,
4474 dki, 4513 issue,
4475 &dki->properties.denom_hash); 4514 &issue->denom_hash);
4476 if (GNUNET_NO == ds->was_revoked) 4515 if (GNUNET_NO == ds->was_revoked)
4477 { 4516 {
4478 /* Woopsie, we allowed payback on non-revoked denomination!? */ 4517 /* Woopsie, we allowed payback on non-revoked denomination!? */