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 | |
parent | 8eb027085c388296e6885139638f4bba255c69f5 (diff) | |
download | merchant-549fec36b9d28d1b49d26ffcbb099f41f42b8ce6.tar.gz merchant-549fec36b9d28d1b49d26ffcbb099f41f42b8ce6.tar.bz2 merchant-549fec36b9d28d1b49d26ffcbb099f41f42b8ce6.zip |
adapt to exchange API change
-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 | ||||
-rw-r--r-- | src/backenddb/plugin_merchantdb_postgres.c | 18 | ||||
-rw-r--r-- | src/lib/merchant_api_pay.c | 10 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_pay.c | 2 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_pay_abort.c | 2 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_refund_lookup.c | 7 | ||||
-rw-r--r-- | src/lib/testing_api_cmd_track_transfer.c | 6 |
14 files changed, 59 insertions, 55 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)) ) diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c index 7ee776ba..61de4a5b 100644 --- a/src/backenddb/plugin_merchantdb_postgres.c +++ b/src/backenddb/plugin_merchantdb_postgres.c @@ -1017,7 +1017,7 @@ find_tip_authorizations_cb (void *cls, } else { - if (GNUNET_OK != + if (0 > TALER_amount_add (&ctx->authorized_amount, &ctx->authorized_amount, &amount)) @@ -2037,7 +2037,7 @@ process_refund_cb (void *cls, ictx->err = GNUNET_SYSERR; return; } - if (GNUNET_SYSERR == + if (0 > TALER_amount_add (&ictx->refunded_amount, &ictx->refunded_amount, &acc)) @@ -2174,7 +2174,7 @@ process_deposits_for_refund_cb (void *cls, deposit_amount_with_fee[i] = amount_with_fee; deposit_coin_pubs[i] = coin_pub; deposit_refund_fee[i] = refund_fee; - if (GNUNET_SYSERR == + if (0 > TALER_amount_add (¤t_refund, ¤t_refund, &ictx.refunded_amount)) @@ -2212,7 +2212,7 @@ process_deposits_for_refund_cb (void *cls, struct TALER_Amount remaining_refund; /* How much of the coin is left after the existing refunds? */ - if (GNUNET_SYSERR == + if (0 > TALER_amount_subtract (&left, &deposit_amount_with_fee[i], &deposit_refund[i])) @@ -2233,7 +2233,7 @@ process_deposits_for_refund_cb (void *cls, } /* How much of the refund is still to be paid back? */ - if (GNUNET_SYSERR == + if (0 > TALER_amount_subtract (&remaining_refund, ctx->refund, ¤t_refund)) @@ -2255,7 +2255,7 @@ process_deposits_for_refund_cb (void *cls, increment = &left; } - if (GNUNET_SYSERR == + if (0 > TALER_amount_add (¤t_refund, ¤t_refund, increment)) @@ -2558,7 +2558,7 @@ RETRY: { new_expiration = GNUNET_TIME_absolute_max (old_expiration, expiration); - if (GNUNET_OK != + if (0 > TALER_amount_add (&new_balance, credit, &old_balance)) @@ -2696,7 +2696,7 @@ RETRY: postgres_rollback (pg); return TALER_EC_TIP_AUTHORIZE_RESERVE_EXPIRED; } - if (GNUNET_SYSERR == + if (0 > TALER_amount_subtract (&new_balance, &old_balance, amount)) @@ -2958,7 +2958,7 @@ RETRY: { struct TALER_Amount new_left; - if (GNUNET_SYSERR == + if (0 > TALER_amount_subtract (&new_left, &left_amount, amount)) diff --git a/src/lib/merchant_api_pay.c b/src/lib/merchant_api_pay.c index fb9dbb45..97a0b444 100644 --- a/src/lib/merchant_api_pay.c +++ b/src/lib/merchant_api_pay.c @@ -257,7 +257,7 @@ check_coin_history (const struct TALER_MERCHANT_PaidCoin *pc, GNUNET_break_op (0); return GNUNET_SYSERR; } - if (GNUNET_OK != + if (0 > TALER_amount_add (&spent_plus_contrib, &spent, &pc->amount_with_fee)) @@ -610,7 +610,7 @@ request_pay_generic ( const struct TALER_MERCHANT_PaidCoin *pc = &coins[i]; struct TALER_Amount fee; - if (GNUNET_SYSERR == + if (0 > TALER_amount_subtract (&fee, &pc->amount_with_fee, &pc->amount_without_fee)) @@ -628,11 +628,11 @@ request_pay_generic ( } else { - if ( (GNUNET_OK != + if ( (0 > TALER_amount_add (&total_fee, &total_fee, &fee)) || - (GNUNET_OK != + (0 > TALER_amount_add (&total_amount, &total_amount, &pc->amount_with_fee)) ) @@ -825,7 +825,7 @@ prepare_pay_generic (struct GNUNET_CURL_Context *ctx, &dr.coin_pub.eddsa_pub); TALER_amount_hton (&dr.amount_with_fee, &coin->amount_with_fee); - if (GNUNET_SYSERR == + if (0 > TALER_amount_subtract (&fee, &coin->amount_with_fee, &coin->amount_without_fee)) diff --git a/src/lib/testing_api_cmd_pay.c b/src/lib/testing_api_cmd_pay.c index 1855d378..02bdf408 100644 --- a/src/lib/testing_api_cmd_pay.c +++ b/src/lib/testing_api_cmd_pay.c @@ -236,7 +236,7 @@ build_coins (struct TALER_MERCHANT_PayCoin **pc, TALER_TESTING_find_pk (is->keys, &icoin->denom_value))); - GNUNET_assert (GNUNET_SYSERR != + GNUNET_assert (0 <= TALER_amount_subtract (&icoin->amount_without_fee, &icoin->denom_value, &dpk->fee_deposit)); diff --git a/src/lib/testing_api_cmd_pay_abort.c b/src/lib/testing_api_cmd_pay_abort.c index 6db46eb2..5911dd1d 100644 --- a/src/lib/testing_api_cmd_pay_abort.c +++ b/src/lib/testing_api_cmd_pay_abort.c @@ -188,7 +188,7 @@ build_coins (struct TALER_MERCHANT_PayCoin **pc, TALER_TESTING_find_pk (is->keys, &icoin->denom_value))); - GNUNET_assert (GNUNET_SYSERR != + GNUNET_assert (0 <= TALER_amount_subtract (&icoin->amount_without_fee, &icoin->denom_value, &dpk->fee_deposit)); diff --git a/src/lib/testing_api_cmd_refund_lookup.c b/src/lib/testing_api_cmd_refund_lookup.c index 986f72f1..c677fe5b 100644 --- a/src/lib/testing_api_cmd_refund_lookup.c +++ b/src/lib/testing_api_cmd_refund_lookup.c @@ -260,9 +260,10 @@ refund_lookup_cb (void *cls, /* Can be NULL: not all coins are involved in refund */ if (NULL == iamount) continue; - GNUNET_assert (GNUNET_OK == TALER_amount_add (&acc, - &acc, - iamount)); + GNUNET_assert (0 <= + TALER_amount_add (&acc, + &acc, + iamount)); } GNUNET_free (coin_reference_dup); diff --git a/src/lib/testing_api_cmd_track_transfer.c b/src/lib/testing_api_cmd_track_transfer.c index 195d50b3..b0dfc478 100644 --- a/src/lib/testing_api_cmd_track_transfer.c +++ b/src/lib/testing_api_cmd_track_transfer.c @@ -179,17 +179,17 @@ track_transfer_cb (void *cls, TALER_TESTING_FAIL (tts->is); return; } - GNUNET_assert (GNUNET_SYSERR != + GNUNET_assert (0 <= TALER_amount_add (&sum, &sum, &amount_iter)); - GNUNET_assert (GNUNET_SYSERR != + GNUNET_assert (0 <= TALER_amount_subtract (&sum, &sum, &deposit_fee_iter)); } - GNUNET_assert (GNUNET_SYSERR != + GNUNET_assert (0 <= TALER_amount_subtract (&sum, &sum, &wire_fee)); |