diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-04-08 23:54:52 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-04-08 23:54:52 +0200 |
commit | 549fec36b9d28d1b49d26ffcbb099f41f42b8ce6 (patch) | |
tree | 472515d802192ffffc1ea68330d71ad3ad46df38 /src/backend | |
parent | 8eb027085c388296e6885139638f4bba255c69f5 (diff) | |
download | merchant-549fec36b9d28d1b49d26ffcbb099f41f42b8ce6.tar.gz merchant-549fec36b9d28d1b49d26ffcbb099f41f42b8ce6.tar.bz2 merchant-549fec36b9d28d1b49d26ffcbb099f41f42b8ce6.zip |
adapt to exchange API change
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/taler-merchant-httpd_check-payment.c | 2 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_pay.c | 43 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_poll-payment.c | 2 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_tip-pickup.c | 4 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_tip-query.c | 2 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_tip-reserve-helper.c | 8 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_track-transaction.c | 2 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_track-transfer.c | 6 |
8 files changed, 36 insertions, 33 deletions
diff --git a/src/backend/taler-merchant-httpd_check-payment.c b/src/backend/taler-merchant-httpd_check-payment.c index 740cbe80..c632d356 100644 --- a/src/backend/taler-merchant-httpd_check-payment.c +++ b/src/backend/taler-merchant-httpd_check-payment.c @@ -157,7 +157,7 @@ process_refunds_cb (void *cls, if (cprc->refunded) { - GNUNET_assert (GNUNET_SYSERR != + GNUNET_assert (0 <= TALER_amount_add (&cprc->refund_amount, &cprc->refund_amount, refund_amount)); diff --git a/src/backend/taler-merchant-httpd_pay.c b/src/backend/taler-merchant-httpd_pay.c index 44466f18..8b255f07 100644 --- a/src/backend/taler-merchant-httpd_pay.c +++ b/src/backend/taler-merchant-httpd_pay.c @@ -728,11 +728,11 @@ check_payment_sufficient (struct PayContext *pc) struct DepositConfirmation *dc = &pc->dc[i]; GNUNET_assert (GNUNET_YES == dc->found_in_db); - if ( (GNUNET_OK != + if ( (0 > TALER_amount_add (&acc_fee, &dc->deposit_fee, &acc_fee)) || - (GNUNET_OK != + (0 > TALER_amount_add (&acc_amount, &dc->amount_with_fee, &acc_amount)) ) @@ -780,7 +780,7 @@ check_payment_sufficient (struct PayContext *pc) "exchange wire in different currency"); return GNUNET_SYSERR; } - if (GNUNET_OK != + if (0 > TALER_amount_add (&total_wire_fee, &total_wire_fee, &dc->wire_fee)) @@ -828,28 +828,31 @@ check_payment_sufficient (struct PayContext *pc) return GNUNET_SYSERR; } - if (GNUNET_OK == - TALER_amount_subtract (&wire_fee_delta, - &total_wire_fee, - &pc->max_wire_fee)) + switch (TALER_amount_subtract (&wire_fee_delta, + &total_wire_fee, + &pc->max_wire_fee)) { + case TALER_AAR_RESULT_POSITIVE: /* Actual wire fee is indeed higher than our maximum, compute how much the customer is expected to cover! */ TALER_amount_divide (&wire_fee_customer_contribution, &wire_fee_delta, pc->wire_fee_amortization); - } - else - { + break; + case TALER_AAR_RESULT_ZERO: + case TALER_AAR_INVALID_NEGATIVE_RESULT: /* Wire fee threshold is still above the wire fee amount. Customer is not going to contribute on this. */ GNUNET_assert (GNUNET_OK == TALER_amount_get_zero (total_wire_fee.currency, &wire_fee_customer_contribution)); + break; + default: + GNUNET_assert (0); } /* add wire fee contribution to the total fees */ - if (GNUNET_OK != + if (0 > TALER_amount_add (&acc_fee, &acc_fee, &wire_fee_customer_contribution)) @@ -872,12 +875,12 @@ check_payment_sufficient (struct PayContext *pc) struct TALER_Amount excess_fee; /* compute fee amount to be covered by customer */ - GNUNET_assert (GNUNET_OK == + GNUNET_assert (TALER_AAR_RESULT_POSITIVE == TALER_amount_subtract (&excess_fee, &acc_fee, &pc->max_fee)); /* add that to the total */ - if (GNUNET_OK != + if (0 > TALER_amount_add (&total_needed, &excess_fee, &pc->amount)) @@ -901,7 +904,7 @@ check_payment_sufficient (struct PayContext *pc) GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Subtracting total refunds from paid amount: %s\n", TALER_amount2s (&pc->total_refunded)); - if (GNUNET_SYSERR == + if (0 > TALER_amount_subtract (&final_amount, &acc_amount, &pc->total_refunded)) @@ -1412,7 +1415,7 @@ check_coin_paid (void *cls, "Coin (%s) already found in our DB.\n", TALER_b2s (coin_pub, sizeof (*coin_pub))); - if (GNUNET_OK != + if (0 > TALER_amount_add (&pc->total_paid, &pc->total_paid, amount_with_fee)) @@ -1422,7 +1425,7 @@ check_coin_paid (void *cls, GNUNET_break (0); continue; } - if (GNUNET_OK != + if (0 > TALER_amount_add (&pc->total_fees_paid, &pc->total_fees_paid, deposit_fee)) @@ -1810,10 +1813,10 @@ check_coin_refunded (void *cls, &dc->coin_pub)) { dc->refunded = GNUNET_YES; - GNUNET_break (GNUNET_OK == - TALER_amount_add (&pc->total_refunded, - &pc->total_refunded, - refund_amount)); + GNUNET_assert (0 <= + TALER_amount_add (&pc->total_refunded, + &pc->total_refunded, + refund_amount)); } } } diff --git a/src/backend/taler-merchant-httpd_poll-payment.c b/src/backend/taler-merchant-httpd_poll-payment.c index 8545e3a2..0e38c226 100644 --- a/src/backend/taler-merchant-httpd_poll-payment.c +++ b/src/backend/taler-merchant-httpd_poll-payment.c @@ -157,7 +157,7 @@ process_refunds_cb (void *cls, if (pprc->refunded) { - GNUNET_assert (GNUNET_SYSERR != + GNUNET_assert (0 <= TALER_amount_add (&pprc->refund_amount, &pprc->refund_amount, refund_amount)); diff --git a/src/backend/taler-merchant-httpd_tip-pickup.c b/src/backend/taler-merchant-httpd_tip-pickup.c index 7e75bbb7..1ea6b6f6 100644 --- a/src/backend/taler-merchant-httpd_tip-pickup.c +++ b/src/backend/taler-merchant-httpd_tip-pickup.c @@ -351,7 +351,7 @@ exchange_found_cb (void *cls, GNUNET_CRYPTO_hash_context_read (hc, pd->coin_ev, pd->coin_ev_size); - if (GNUNET_OK != + if (0 > TALER_amount_add (&amount_with_fee, &dk->value, &dk->fee_withdraw)) @@ -364,7 +364,7 @@ exchange_found_cb (void *cls, } else { - if (GNUNET_OK != + if (0 > TALER_amount_add (&total, &total, &amount_with_fee)) diff --git a/src/backend/taler-merchant-httpd_tip-query.c b/src/backend/taler-merchant-httpd_tip-query.c index 12198470..9c9b5538 100644 --- a/src/backend/taler-merchant-httpd_tip-query.c +++ b/src/backend/taler-merchant-httpd_tip-query.c @@ -95,7 +95,7 @@ generate_final_response (struct TipQueryContext *tqc) GNUNET_CRYPTO_eddsa_key_get_public (&tqc->ctr.reserve_priv.eddsa_priv, &reserve_pub); - if (GNUNET_SYSERR == + if (0 > TALER_amount_subtract (&amount_available, &tqc->ctr.amount_deposited, &tqc->ctr.amount_withdrawn)) diff --git a/src/backend/taler-merchant-httpd_tip-reserve-helper.c b/src/backend/taler-merchant-httpd_tip-reserve-helper.c index 564c1ffc..190aba2c 100644 --- a/src/backend/taler-merchant-httpd_tip-reserve-helper.c +++ b/src/backend/taler-merchant-httpd_tip-reserve-helper.c @@ -184,7 +184,7 @@ handle_status (void *cls, struct GNUNET_HashCode uuid; struct GNUNET_TIME_Absolute deposit_expiration; - if (GNUNET_OK != + if (0 > TALER_amount_add (&ctr->amount_deposited, &ctr->amount_deposited, &hi->amount)) @@ -226,7 +226,7 @@ handle_status (void *cls, } break; case TALER_EXCHANGE_RTT_WITHDRAWAL: - if (GNUNET_OK != + if (0 > TALER_amount_add (&ctr->amount_withdrawn, &ctr->amount_withdrawn, &hi->amount)) @@ -252,7 +252,7 @@ handle_status (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Encountered unexpected recoup operation on tipping reserve\n"); /* While unexpected, we can simply count these like deposits. */ - if (GNUNET_OK != + if (0 > TALER_amount_add (&ctr->amount_deposited, &ctr->amount_deposited, &hi->amount)) @@ -300,7 +300,7 @@ handle_status (void *cls, break; case TALER_EXCHANGE_RTT_CLOSE: /* We count 'closing' amounts just like withdrawals */ - if (GNUNET_OK != + if (0 > TALER_amount_add (&ctr->amount_withdrawn, &ctr->amount_withdrawn, &hi->amount)) diff --git a/src/backend/taler-merchant-httpd_track-transaction.c b/src/backend/taler-merchant-httpd_track-transaction.c index c23b07f4..8de4f05f 100644 --- a/src/backend/taler-merchant-httpd_track-transaction.c +++ b/src/backend/taler-merchant-httpd_track-transaction.c @@ -107,7 +107,7 @@ make_track_transaction_ok (unsigned int num_transfers, { const struct TALER_MERCHANT_CoinWireTransfer *coin = &transfer->coins[j]; - GNUNET_assert (GNUNET_SYSERR != + GNUNET_assert (0 <= TALER_amount_add (&sum, &sum, &coin->amount_with_fee)); diff --git a/src/backend/taler-merchant-httpd_track-transfer.c b/src/backend/taler-merchant-httpd_track-transfer.c index f82133a2..5b7ef9d5 100644 --- a/src/backend/taler-merchant-httpd_track-transfer.c +++ b/src/backend/taler-merchant-httpd_track-transfer.c @@ -241,7 +241,7 @@ build_deposits_response (void *cls, json_t *order_id; db->preflight (db->cls); - if (GNUNET_OK != + if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != db->find_contract_terms_from_hash (db->cls, &contract_terms, key, @@ -331,11 +331,11 @@ transform_response (const json_t *result, &h_key))) { /* The map already knows this h_contract_terms*/ - if ( (GNUNET_SYSERR == + if ( (0 > TALER_amount_add (¤t_entry->deposit_value, ¤t_entry->deposit_value, &iter_value)) || - (GNUNET_SYSERR == + (0 > TALER_amount_add (¤t_entry->deposit_fee, ¤t_entry->deposit_fee, &iter_fee)) ) |