insert_records_by_table.c (83175B)
1 /* 2 This file is part of GNUnet 3 Copyright (C) 2020-2025 Taler Systems SA 4 5 GNUnet is free software: you can redistribute it and/or modify it 6 under the terms of the GNU Affero General Public License as published 7 by the Free Software Foundation, either version 3 of the License, 8 or (at your option) any later version. 9 10 GNUnet is distributed in the hope that it will be useful, but 11 WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Affero General Public License for more details. 14 15 You should have received a copy of the GNU Affero General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 SPDX-License-Identifier: AGPL3.0-or-later 19 */ 20 /** 21 * @file exchangedb/insert_records_by_table.c 22 * @brief replicate_records_by_table implementation 23 * @author Christian Grothoff 24 * @author Özgür Kesim 25 */ 26 #include "taler/taler_error_codes.h" 27 #include "taler/taler_dbevents.h" 28 #include "taler/taler_pq_lib.h" 29 #include "exchange-database/insert_records_by_table.h" 30 #include "helper.h" 31 #include <gnunet/gnunet_pq_lib.h> 32 33 34 /** 35 * Signature of helper functions of #TALER_EXCHANGEDB_insert_records_by_table(). 36 * 37 * @param pg plugin context 38 * @param td record to insert 39 * @return transaction status code 40 */ 41 typedef enum GNUNET_DB_QueryStatus 42 (*InsertRecordCallback)(struct TALER_EXCHANGEDB_PostgresContext *pg, 43 const struct TALER_EXCHANGEDB_TableData *td); 44 45 46 /** 47 * Function called with denominations records to insert into table. 48 * 49 * @param pg plugin context 50 * @param td record to insert 51 */ 52 static enum GNUNET_DB_QueryStatus 53 irbt_cb_table_denominations (struct TALER_EXCHANGEDB_PostgresContext *pg, 54 const struct TALER_EXCHANGEDB_TableData *td) 55 { 56 struct TALER_DenominationHashP denom_hash; 57 struct GNUNET_PQ_QueryParam params[] = { 58 GNUNET_PQ_query_param_uint64 (&td->serial), 59 GNUNET_PQ_query_param_auto_from_type (&denom_hash), 60 GNUNET_PQ_query_param_uint32 ( 61 &td->details.denominations.denom_type), 62 GNUNET_PQ_query_param_uint32 ( 63 &td->details.denominations.age_mask), 64 TALER_PQ_query_param_denom_pub ( 65 &td->details.denominations.denom_pub), 66 GNUNET_PQ_query_param_auto_from_type ( 67 &td->details.denominations.master_sig), 68 GNUNET_PQ_query_param_timestamp ( 69 &td->details.denominations.valid_from), 70 GNUNET_PQ_query_param_timestamp ( 71 &td->details.denominations.expire_withdraw), 72 GNUNET_PQ_query_param_timestamp ( 73 &td->details.denominations.expire_deposit), 74 GNUNET_PQ_query_param_timestamp ( 75 &td->details.denominations.expire_legal), 76 TALER_PQ_query_param_amount ( 77 pg->conn, 78 &td->details.denominations.coin), 79 TALER_PQ_query_param_amount ( 80 pg->conn, 81 &td->details.denominations.fees.withdraw), 82 TALER_PQ_query_param_amount ( 83 pg->conn, 84 &td->details.denominations.fees.deposit), 85 TALER_PQ_query_param_amount ( 86 pg->conn, 87 &td->details.denominations.fees.refresh), 88 TALER_PQ_query_param_amount ( 89 pg->conn, 90 &td->details.denominations.fees.refund), 91 GNUNET_PQ_query_param_end 92 }; 93 94 PREPARE (pg, 95 "insert_records_by_table_into_table_denominations", 96 "INSERT INTO denominations" 97 "(denominations_serial" 98 ",denom_pub_hash" 99 ",denom_type" 100 ",age_mask" 101 ",denom_pub" 102 ",master_sig" 103 ",valid_from" 104 ",expire_withdraw" 105 ",expire_deposit" 106 ",expire_legal" 107 ",coin" 108 ",fee_withdraw" 109 ",fee_deposit" 110 ",fee_refresh" 111 ",fee_refund" 112 ") VALUES " 113 "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10," 114 " $11, $12, $13, $14, $15);"); 115 116 TALER_denom_pub_hash ( 117 &td->details.denominations.denom_pub, 118 &denom_hash); 119 120 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 121 "insert_records_by_table_into_table_denominations", 122 params); 123 } 124 125 126 /** 127 * Function called with denomination_revocations records to insert into table. 128 * 129 * @param pg plugin context 130 * @param td record to insert 131 */ 132 static enum GNUNET_DB_QueryStatus 133 irbt_cb_table_denomination_revocations ( 134 struct TALER_EXCHANGEDB_PostgresContext *pg, 135 const struct TALER_EXCHANGEDB_TableData *td) 136 { 137 struct GNUNET_PQ_QueryParam params[] = { 138 GNUNET_PQ_query_param_uint64 (&td->serial), 139 GNUNET_PQ_query_param_auto_from_type ( 140 &td->details.denomination_revocations.master_sig), 141 GNUNET_PQ_query_param_uint64 ( 142 &td->details.denomination_revocations.denominations_serial), 143 GNUNET_PQ_query_param_end 144 }; 145 146 PREPARE (pg, 147 "insert_records_by_table_into_table_denomination_revocations", 148 "INSERT INTO denomination_revocations" 149 "(denom_revocations_serial_id" 150 ",master_sig" 151 ",denominations_serial" 152 ") VALUES " 153 "($1, $2, $3);"); 154 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 155 "insert_records_by_table_into_table_denomination_revocations", 156 params); 157 } 158 159 160 /** 161 * Function called with wire target records to insert into table. 162 * 163 * @param pg plugin context 164 * @param td record to insert 165 */ 166 static enum GNUNET_DB_QueryStatus 167 irbt_cb_table_wire_targets (struct TALER_EXCHANGEDB_PostgresContext *pg, 168 const struct TALER_EXCHANGEDB_TableData *td) 169 { 170 struct TALER_NormalizedPaytoHashP normalized_payto_hash; 171 struct TALER_FullPaytoHashP full_payto_hash; 172 struct GNUNET_PQ_QueryParam params[] = { 173 GNUNET_PQ_query_param_uint64 (&td->serial), 174 GNUNET_PQ_query_param_auto_from_type (&full_payto_hash), 175 GNUNET_PQ_query_param_auto_from_type (&normalized_payto_hash), 176 GNUNET_PQ_query_param_string ( 177 td->details.wire_targets.full_payto_uri.full_payto), 178 GNUNET_PQ_query_param_end 179 }; 180 181 TALER_full_payto_hash ( 182 td->details.wire_targets.full_payto_uri, 183 &full_payto_hash); 184 TALER_full_payto_normalize_and_hash ( 185 td->details.wire_targets.full_payto_uri, 186 &normalized_payto_hash); 187 PREPARE (pg, 188 "insert_records_by_table_into_table_wire_targets", 189 "INSERT INTO wire_targets" 190 "(wire_target_serial_id" 191 ",wire_target_h_payto" 192 ",h_normalized_payto" 193 ",payto_uri" 194 ") VALUES " 195 "($1, $2, $3, $4);"); 196 return GNUNET_PQ_eval_prepared_non_select ( 197 pg->conn, 198 "insert_records_by_table_into_table_wire_targets", 199 params); 200 } 201 202 203 /** 204 * Function called with kyc target records to insert into table. 205 * 206 * @param pg plugin context 207 * @param td record to insert 208 */ 209 static enum GNUNET_DB_QueryStatus 210 irbt_cb_table_kyc_targets (struct TALER_EXCHANGEDB_PostgresContext *pg, 211 const struct TALER_EXCHANGEDB_TableData *td) 212 { 213 struct GNUNET_PQ_QueryParam params[] = { 214 GNUNET_PQ_query_param_uint64 (&td->serial), 215 GNUNET_PQ_query_param_auto_from_type ( 216 &td->details.kyc_targets.h_normalized_payto), 217 GNUNET_PQ_query_param_auto_from_type ( 218 &td->details.kyc_targets.access_token), 219 td->details.kyc_targets.no_account 220 ? GNUNET_PQ_query_param_null () 221 : GNUNET_PQ_query_param_auto_from_type ( 222 &td->details.kyc_targets.target_pub), 223 GNUNET_PQ_query_param_bool ( 224 td->details.kyc_targets.is_wallet), 225 GNUNET_PQ_query_param_end 226 }; 227 228 PREPARE (pg, 229 "insert_records_by_table_into_table_kyc_targets", 230 "INSERT INTO kyc_targets" 231 "(kyc_target_serial_id" 232 ",h_normalized_payto" 233 ",access_token" 234 ",target_pub" 235 ",is_wallet" 236 ") VALUES " 237 "($1, $2, $3, $4, $5);"); 238 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 239 "insert_records_by_table_into_table_kyc_targets", 240 params); 241 } 242 243 244 /** 245 * Function called with records to insert into table. 246 * 247 * @param pg plugin context 248 * @param td record to insert 249 */ 250 static enum GNUNET_DB_QueryStatus 251 irbt_cb_table_legitimization_measures ( 252 struct TALER_EXCHANGEDB_PostgresContext *pg, 253 const struct TALER_EXCHANGEDB_TableData *td) 254 { 255 struct GNUNET_PQ_QueryParam params[] = { 256 GNUNET_PQ_query_param_uint64 (&td->serial), 257 GNUNET_PQ_query_param_auto_from_type ( 258 &td->details.legitimization_measures.target_token), 259 GNUNET_PQ_query_param_absolute_time ( 260 &td->details.legitimization_measures.start_time), 261 TALER_PQ_query_param_json ( 262 td->details.legitimization_measures.measures), 263 GNUNET_PQ_query_param_uint32 ( 264 &td->details.legitimization_measures.display_priority), 265 GNUNET_PQ_query_param_end 266 }; 267 268 PREPARE (pg, 269 "insert_records_by_table_into_table_legitimization_measures", 270 "INSERT INTO legitimization_measures" 271 "(legitimization_measure_serial_id" 272 ",access_token" 273 ",start_time" 274 ",jmeasures" 275 ",display_priority" 276 ") VALUES " 277 "($1, $2, $3, $4::TEXT::JSONB, $5);"); 278 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 279 "insert_records_by_table_into_table_legitimization_measures", 280 params); 281 } 282 283 284 /** 285 * Function called with records to insert into table. 286 * 287 * @param pg plugin context 288 * @param td record to insert 289 */ 290 static enum GNUNET_DB_QueryStatus 291 irbt_cb_table_legitimization_outcomes ( 292 struct TALER_EXCHANGEDB_PostgresContext *pg, 293 const struct TALER_EXCHANGEDB_TableData *td) 294 { 295 struct GNUNET_PQ_QueryParam params[] = { 296 GNUNET_PQ_query_param_uint64 (&td->serial), 297 GNUNET_PQ_query_param_auto_from_type ( 298 &td->details.legitimization_outcomes.h_payto), 299 GNUNET_PQ_query_param_timestamp ( 300 &td->details.legitimization_outcomes.decision_time), 301 GNUNET_PQ_query_param_timestamp ( 302 &td->details.legitimization_outcomes.expiration_time), 303 NULL == td->details.legitimization_outcomes.properties 304 ? GNUNET_PQ_query_param_null () 305 : TALER_PQ_query_param_json ( 306 td->details.legitimization_outcomes.properties), 307 GNUNET_PQ_query_param_bool ( 308 td->details.legitimization_outcomes.to_investigate), 309 TALER_PQ_query_param_json ( 310 td->details.legitimization_outcomes.new_rules), 311 GNUNET_PQ_query_param_end 312 }; 313 314 PREPARE (pg, 315 "insert_records_by_table_into_table_legitimization_outcomes", 316 "INSERT INTO legitimization_outcomes" 317 "(outcome_serial_id" 318 ",h_payto" 319 ",decision_time" 320 ",expiration_time" 321 ",jproperties" 322 ",to_investigate" 323 ",jnew_rules" 324 ") VALUES " 325 "($1, $2, $3, $4, $5::TEXT::JSONB, $6, $7::TEXT::JSONB);"); 326 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 327 "insert_records_by_table_into_table_legitimization_outcomes", 328 params); 329 } 330 331 332 /** 333 * Function called with records to insert into table. 334 * 335 * @param pg plugin context 336 * @param td record to insert 337 */ 338 static enum GNUNET_DB_QueryStatus 339 irbt_cb_table_legitimization_processes ( 340 struct TALER_EXCHANGEDB_PostgresContext *pg, 341 const struct TALER_EXCHANGEDB_TableData *td) 342 { 343 struct GNUNET_PQ_QueryParam params[] = { 344 GNUNET_PQ_query_param_uint64 (&td->serial), 345 GNUNET_PQ_query_param_auto_from_type ( 346 &td->details.legitimization_processes.h_payto), 347 GNUNET_PQ_query_param_absolute_time ( 348 &td->details.legitimization_processes.start_time), 349 GNUNET_PQ_query_param_timestamp ( 350 &td->details.legitimization_processes.expiration_time), 351 GNUNET_PQ_query_param_uint64 ( 352 &td->details.legitimization_processes.legitimization_measure_serial_id), 353 GNUNET_PQ_query_param_uint32 ( 354 &td->details.legitimization_processes.measure_index), 355 GNUNET_PQ_query_param_string ( 356 td->details.legitimization_processes.provider_name), 357 NULL == td->details.legitimization_processes.provider_user_id 358 ? GNUNET_PQ_query_param_null () 359 : GNUNET_PQ_query_param_string ( 360 td->details.legitimization_processes.provider_user_id), 361 NULL == td->details.legitimization_processes.provider_legitimization_id 362 ? GNUNET_PQ_query_param_null () 363 : GNUNET_PQ_query_param_string ( 364 td->details.legitimization_processes.provider_legitimization_id), 365 NULL == td->details.legitimization_processes.redirect_url 366 ? GNUNET_PQ_query_param_null () 367 : GNUNET_PQ_query_param_string ( 368 td->details.legitimization_processes.redirect_url), 369 GNUNET_PQ_query_param_end 370 }; 371 372 PREPARE (pg, 373 "insert_records_by_table_into_table_legitimization_processes", 374 "INSERT INTO legitimization_processes" 375 "(legitimization_process_serial_id" 376 ",h_payto" 377 ",start_time" 378 ",expiration_time" 379 ",legitimization_measure_serial_id" 380 ",measure_index" 381 ",provider_name" 382 ",provider_user_id" 383 ",provider_legitimization_id" 384 ",redirect_url" 385 ") VALUES " 386 "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10);"); 387 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 388 "insert_records_by_table_into_table_legitimization_processes", 389 params); 390 } 391 392 393 /** 394 * Function called with reserves records to insert into table. 395 * 396 * @param pg plugin context 397 * @param td record to insert 398 */ 399 static enum GNUNET_DB_QueryStatus 400 irbt_cb_table_reserves (struct TALER_EXCHANGEDB_PostgresContext *pg, 401 const struct TALER_EXCHANGEDB_TableData *td) 402 { 403 struct GNUNET_PQ_QueryParam params[] = { 404 GNUNET_PQ_query_param_uint64 (&td->serial), 405 GNUNET_PQ_query_param_auto_from_type (&td->details.reserves.reserve_pub), 406 GNUNET_PQ_query_param_timestamp (&td->details.reserves.expiration_date), 407 GNUNET_PQ_query_param_timestamp (&td->details.reserves.gc_date), 408 GNUNET_PQ_query_param_end 409 }; 410 411 PREPARE (pg, 412 "insert_records_by_table_into_table_reserves", 413 "INSERT INTO reserves" 414 "(reserve_uuid" 415 ",reserve_pub" 416 ",expiration_date" 417 ",gc_date" 418 ") VALUES " 419 "($1, $2, $3, $4);"); 420 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 421 "insert_records_by_table_into_table_reserves", 422 params); 423 } 424 425 426 /** 427 * Function called with reserves_in records to insert into table. 428 * 429 * @param pg plugin context 430 * @param td record to insert 431 */ 432 static enum GNUNET_DB_QueryStatus 433 irbt_cb_table_reserves_in (struct TALER_EXCHANGEDB_PostgresContext *pg, 434 const struct TALER_EXCHANGEDB_TableData *td) 435 { 436 struct GNUNET_PQ_QueryParam params[] = { 437 GNUNET_PQ_query_param_uint64 (&td->serial), 438 GNUNET_PQ_query_param_uint64 (&td->details.reserves_in.wire_reference), 439 TALER_PQ_query_param_amount ( 440 pg->conn, 441 &td->details.reserves_in.credit), 442 GNUNET_PQ_query_param_auto_from_type ( 443 &td->details.reserves_in.sender_account_h_payto), 444 GNUNET_PQ_query_param_string ( 445 td->details.reserves_in.exchange_account_section), 446 GNUNET_PQ_query_param_timestamp ( 447 &td->details.reserves_in.execution_date), 448 GNUNET_PQ_query_param_auto_from_type (&td->details.reserves_in.reserve_pub), 449 GNUNET_PQ_query_param_end 450 }; 451 452 PREPARE (pg, 453 "insert_records_by_table_into_table_reserves_in", 454 "INSERT INTO reserves_in" 455 "(reserve_in_serial_id" 456 ",wire_reference" 457 ",credit" 458 ",wire_source_h_payto" 459 ",exchange_account_section" 460 ",execution_date" 461 ",reserve_pub" 462 ") VALUES " 463 "($1, $2, $3, $4, $5, $6, $7);"); 464 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 465 "insert_records_by_table_into_table_reserves_in", 466 params); 467 } 468 469 470 /** 471 * Function called with kycauth_in records to insert into table. 472 * 473 * @param pg plugin context 474 * @param td record to insert 475 */ 476 static enum GNUNET_DB_QueryStatus 477 irbt_cb_table_kycauths_in (struct TALER_EXCHANGEDB_PostgresContext *pg, 478 const struct TALER_EXCHANGEDB_TableData *td) 479 { 480 struct GNUNET_PQ_QueryParam params[] = { 481 GNUNET_PQ_query_param_uint64 (&td->serial), 482 GNUNET_PQ_query_param_uint64 (&td->details.kycauth_in.wire_reference), 483 TALER_PQ_query_param_amount ( 484 pg->conn, 485 &td->details.reserves_in.credit), 486 GNUNET_PQ_query_param_auto_from_type ( 487 &td->details.reserves_in.sender_account_h_payto), 488 GNUNET_PQ_query_param_string ( 489 td->details.reserves_in.exchange_account_section), 490 GNUNET_PQ_query_param_timestamp ( 491 &td->details.reserves_in.execution_date), 492 GNUNET_PQ_query_param_auto_from_type (&td->details.kycauth_in.account_pub), 493 GNUNET_PQ_query_param_end 494 }; 495 496 PREPARE (pg, 497 "insert_records_by_table_into_table_kycauth_in", 498 "INSERT INTO kycauths_in" 499 "(kycauth_in_serial_id" 500 ",wire_reference" 501 ",credit" 502 ",wire_source_h_payto" 503 ",exchange_account_section" 504 ",execution_date" 505 ",account_pub" 506 ") VALUES " 507 "($1, $2, $3, $4, $5, $6, $7);"); 508 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 509 "insert_records_by_table_into_table_kycauth_in", 510 params); 511 } 512 513 514 /** 515 * Function called with reserves_open_requests records to insert into table. 516 * 517 * @param pg plugin context 518 * @param td record to insert 519 */ 520 static enum GNUNET_DB_QueryStatus 521 irbt_cb_table_reserves_open_requests ( 522 struct TALER_EXCHANGEDB_PostgresContext *pg, 523 const struct TALER_EXCHANGEDB_TableData *td) 524 { 525 struct GNUNET_PQ_QueryParam params[] = { 526 GNUNET_PQ_query_param_uint64 (&td->serial), 527 GNUNET_PQ_query_param_auto_from_type ( 528 &td->details.reserves_open_requests.reserve_pub), 529 GNUNET_PQ_query_param_timestamp ( 530 &td->details.reserves_open_requests.request_timestamp), 531 GNUNET_PQ_query_param_timestamp ( 532 &td->details.reserves_open_requests.expiration_date), 533 GNUNET_PQ_query_param_auto_from_type ( 534 &td->details.reserves_open_requests.reserve_sig), 535 TALER_PQ_query_param_amount ( 536 pg->conn, 537 &td->details.reserves_open_requests.reserve_payment), 538 GNUNET_PQ_query_param_uint32 ( 539 &td->details.reserves_open_requests.requested_purse_limit), 540 GNUNET_PQ_query_param_end 541 }; 542 543 PREPARE (pg, 544 "insert_records_by_table_into_table_reserves_open_requests", 545 "INSERT INTO reserves_open_requests" 546 "(open_request_uuid" 547 ",reserve_pub" 548 ",request_timestamp" 549 ",expiration_date" 550 ",reserve_sig" 551 ",reserve_payment" 552 ",requested_purse_limit" 553 ") VALUES " 554 "($1, $2, $3, $4, $5, $6, $7);"); 555 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 556 "insert_records_by_table_into_table_reserves_open_requests", 557 params); 558 } 559 560 561 /** 562 * Function called with reserves_open_deposits records to insert into table. 563 * 564 * @param pg plugin context 565 * @param td record to insert 566 */ 567 static enum GNUNET_DB_QueryStatus 568 irbt_cb_table_reserves_open_deposits ( 569 struct TALER_EXCHANGEDB_PostgresContext *pg, 570 const struct TALER_EXCHANGEDB_TableData *td) 571 { 572 struct GNUNET_PQ_QueryParam params[] = { 573 GNUNET_PQ_query_param_uint64 (&td->serial), 574 GNUNET_PQ_query_param_auto_from_type ( 575 &td->details.reserves_open_deposits.reserve_sig), 576 GNUNET_PQ_query_param_auto_from_type ( 577 &td->details.reserves_open_deposits.reserve_pub), 578 GNUNET_PQ_query_param_auto_from_type ( 579 &td->details.reserves_open_deposits.coin_pub), 580 GNUNET_PQ_query_param_auto_from_type ( 581 &td->details.reserves_open_deposits.coin_sig), 582 TALER_PQ_query_param_amount ( 583 pg->conn, 584 &td->details.reserves_open_deposits.contribution), 585 GNUNET_PQ_query_param_end 586 }; 587 588 PREPARE (pg, 589 "insert_records_by_table_into_table_reserves_open_deposits", 590 "INSERT INTO reserves_open_deposits" 591 "(reserve_open_deposit_uuid" 592 ",reserve_sig" 593 ",reserve_pub" 594 ",coin_pub" 595 ",coin_sig" 596 ",contribution" 597 ") VALUES " 598 "($1, $2, $3, $4, $5, $6);"); 599 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 600 "insert_records_by_table_into_table_reserves_open_deposits", 601 params); 602 } 603 604 605 /** 606 * Function called with reserves_close records to insert into table. 607 * 608 * @param pg plugin context 609 * @param td record to insert 610 */ 611 static enum GNUNET_DB_QueryStatus 612 irbt_cb_table_reserves_close (struct TALER_EXCHANGEDB_PostgresContext *pg, 613 const struct TALER_EXCHANGEDB_TableData *td) 614 { 615 struct GNUNET_PQ_QueryParam params[] = { 616 GNUNET_PQ_query_param_uint64 (&td->serial), 617 GNUNET_PQ_query_param_timestamp ( 618 &td->details.reserves_close.execution_date), 619 GNUNET_PQ_query_param_auto_from_type ( 620 &td->details.reserves_close.wtid), 621 GNUNET_PQ_query_param_auto_from_type ( 622 &td->details.reserves_close.sender_account_h_payto), 623 TALER_PQ_query_param_amount ( 624 pg->conn, 625 &td->details.reserves_close.amount), 626 TALER_PQ_query_param_amount ( 627 pg->conn, 628 &td->details.reserves_close.closing_fee), 629 GNUNET_PQ_query_param_auto_from_type ( 630 &td->details.reserves_close.reserve_pub), 631 GNUNET_PQ_query_param_end 632 }; 633 634 PREPARE (pg, 635 "insert_records_by_table_into_table_reserves_close", 636 "INSERT INTO reserves_close" 637 "(close_uuid" 638 ",execution_date" 639 ",wtid" 640 ",wire_target_h_payto" 641 ",amount" 642 ",closing_fee" 643 ",reserve_pub" 644 ") VALUES " 645 "($1, $2, $3, $4, $5, $6, $7);"); 646 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 647 "insert_records_by_table_into_table_reserves_close", 648 params); 649 } 650 651 652 /** 653 * Function called with auditors records to insert into table. 654 * 655 * @param pg plugin context 656 * @param td record to insert 657 */ 658 static enum GNUNET_DB_QueryStatus 659 irbt_cb_table_auditors (struct TALER_EXCHANGEDB_PostgresContext *pg, 660 const struct TALER_EXCHANGEDB_TableData *td) 661 { 662 struct GNUNET_PQ_QueryParam params[] = { 663 GNUNET_PQ_query_param_uint64 (&td->serial), 664 GNUNET_PQ_query_param_auto_from_type (&td->details.auditors.auditor_pub), 665 GNUNET_PQ_query_param_string (td->details.auditors.auditor_name), 666 GNUNET_PQ_query_param_string (td->details.auditors.auditor_url), 667 GNUNET_PQ_query_param_bool (td->details.auditors.is_active), 668 GNUNET_PQ_query_param_timestamp (&td->details.auditors.last_change), 669 GNUNET_PQ_query_param_end 670 }; 671 672 PREPARE (pg, 673 "insert_records_by_table_into_table_auditors", 674 "INSERT INTO auditors" 675 "(auditor_uuid" 676 ",auditor_pub" 677 ",auditor_name" 678 ",auditor_url" 679 ",is_active" 680 ",last_change" 681 ") VALUES " 682 "($1, $2, $3, $4, $5, $6);"); 683 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 684 "insert_records_by_table_into_table_auditors", 685 params); 686 } 687 688 689 /** 690 * Function called with auditor_denom_sigs records to insert into table. 691 * 692 * @param pg plugin context 693 * @param td record to insert 694 */ 695 static enum GNUNET_DB_QueryStatus 696 irbt_cb_table_auditor_denom_sigs (struct TALER_EXCHANGEDB_PostgresContext *pg, 697 const struct TALER_EXCHANGEDB_TableData *td) 698 { 699 struct GNUNET_PQ_QueryParam params[] = { 700 GNUNET_PQ_query_param_uint64 (&td->serial), 701 GNUNET_PQ_query_param_uint64 (&td->details.auditor_denom_sigs.auditor_uuid), 702 GNUNET_PQ_query_param_uint64 ( 703 &td->details.auditor_denom_sigs.denominations_serial), 704 GNUNET_PQ_query_param_auto_from_type ( 705 &td->details.auditor_denom_sigs.auditor_sig), 706 GNUNET_PQ_query_param_end 707 }; 708 709 PREPARE (pg, 710 "insert_records_by_table_into_table_auditor_denom_sigs", 711 "INSERT INTO auditor_denom_sigs" 712 "(auditor_denom_serial" 713 ",auditor_uuid" 714 ",denominations_serial" 715 ",auditor_sig" 716 ") VALUES " 717 "($1, $2, $3, $4);"); 718 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 719 "insert_records_by_table_into_table_auditor_denom_sigs", 720 params); 721 } 722 723 724 /** 725 * Function called with exchange_sign_keys records to insert into table. 726 * 727 * @param pg plugin context 728 * @param td record to insert 729 */ 730 static enum GNUNET_DB_QueryStatus 731 irbt_cb_table_exchange_sign_keys (struct TALER_EXCHANGEDB_PostgresContext *pg, 732 const struct TALER_EXCHANGEDB_TableData *td) 733 { 734 struct GNUNET_PQ_QueryParam params[] = { 735 GNUNET_PQ_query_param_uint64 (&td->serial), 736 GNUNET_PQ_query_param_auto_from_type ( 737 &td->details.exchange_sign_keys.exchange_pub), 738 GNUNET_PQ_query_param_auto_from_type ( 739 &td->details.exchange_sign_keys.master_sig), 740 GNUNET_PQ_query_param_timestamp ( 741 &td->details.exchange_sign_keys.meta.start), 742 GNUNET_PQ_query_param_timestamp ( 743 &td->details.exchange_sign_keys.meta.expire_sign), 744 GNUNET_PQ_query_param_timestamp ( 745 &td->details.exchange_sign_keys.meta.expire_legal), 746 GNUNET_PQ_query_param_end 747 }; 748 749 PREPARE (pg, 750 "insert_records_by_table_into_table_exchange_sign_keys", 751 "INSERT INTO exchange_sign_keys" 752 "(esk_serial" 753 ",exchange_pub" 754 ",master_sig" 755 ",valid_from" 756 ",expire_sign" 757 ",expire_legal" 758 ") VALUES " 759 "($1, $2, $3, $4, $5, $6);"); 760 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 761 "insert_records_by_table_into_table_exchange_sign_keys", 762 params); 763 } 764 765 766 /** 767 * Function called with signkey_revocations records to insert into table. 768 * 769 * @param pg plugin context 770 * @param td record to insert 771 */ 772 static enum GNUNET_DB_QueryStatus 773 irbt_cb_table_signkey_revocations (struct TALER_EXCHANGEDB_PostgresContext *pg, 774 const struct TALER_EXCHANGEDB_TableData *td) 775 { 776 struct GNUNET_PQ_QueryParam params[] = { 777 GNUNET_PQ_query_param_uint64 (&td->serial), 778 GNUNET_PQ_query_param_uint64 (&td->details.signkey_revocations.esk_serial), 779 GNUNET_PQ_query_param_auto_from_type ( 780 &td->details.signkey_revocations.master_sig), 781 GNUNET_PQ_query_param_end 782 }; 783 784 PREPARE (pg, 785 "insert_records_by_table_into_table_signkey_revocations", 786 "INSERT INTO signkey_revocations" 787 "(signkey_revocations_serial_id" 788 ",esk_serial" 789 ",master_sig" 790 ") VALUES " 791 "($1, $2, $3);"); 792 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 793 "insert_records_by_table_into_table_signkey_revocations", 794 params); 795 } 796 797 798 /** 799 * Function called with known_coins records to insert into table. 800 * 801 * @param pg plugin context 802 * @param td record to insert 803 */ 804 static enum GNUNET_DB_QueryStatus 805 irbt_cb_table_known_coins (struct TALER_EXCHANGEDB_PostgresContext *pg, 806 const struct TALER_EXCHANGEDB_TableData *td) 807 { 808 struct GNUNET_PQ_QueryParam params[] = { 809 GNUNET_PQ_query_param_uint64 (&td->serial), 810 GNUNET_PQ_query_param_auto_from_type ( 811 &td->details.known_coins.coin_pub), 812 TALER_PQ_query_param_denom_sig ( 813 &td->details.known_coins.denom_sig), 814 GNUNET_PQ_query_param_uint64 ( 815 &td->details.known_coins.denominations_serial), 816 GNUNET_PQ_query_param_end 817 }; 818 819 PREPARE (pg, 820 "insert_records_by_table_into_table_known_coins", 821 "INSERT INTO known_coins" 822 "(known_coin_id" 823 ",coin_pub" 824 ",denom_sig" 825 ",denominations_serial" 826 ") VALUES " 827 "($1, $2, $3, $4);"); 828 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 829 "insert_records_by_table_into_table_known_coins", 830 params); 831 } 832 833 834 /** 835 * Function called with refresh records to insert into table. 836 * 837 * @param pg plugin context 838 * @param td record to insert 839 */ 840 static enum GNUNET_DB_QueryStatus 841 irbt_cb_table_refresh (struct TALER_EXCHANGEDB_PostgresContext *pg, 842 const struct TALER_EXCHANGEDB_TableData *td) 843 { 844 struct GNUNET_PQ_QueryParam params[] = { 845 GNUNET_PQ_query_param_uint64 (&td->serial), 846 GNUNET_PQ_query_param_auto_from_type (&td->details.refresh.rc), 847 GNUNET_PQ_query_param_auto_from_type (&td->details.refresh.execution_date), 848 TALER_PQ_query_param_amount ( 849 pg->conn, 850 &td->details.refresh.amount_with_fee), 851 GNUNET_PQ_query_param_auto_from_type ( 852 &td->details.refresh.old_coin_pub), 853 GNUNET_PQ_query_param_auto_from_type ( 854 &td->details.refresh.old_coin_sig), 855 GNUNET_PQ_query_param_auto_from_type ( 856 &td->details.refresh.refresh_seed), 857 GNUNET_PQ_query_param_uint32 ( 858 &td->details.refresh.noreveal_index), 859 GNUNET_PQ_query_param_auto_from_type ( 860 &td->details.refresh.planchets_h), 861 GNUNET_PQ_query_param_auto_from_type ( 862 &td->details.refresh.selected_h), 863 td->details.refresh.no_blinding_seed 864 ? GNUNET_PQ_query_param_null () 865 : GNUNET_PQ_query_param_auto_from_type ( 866 &td->details.refresh.blinding_seed), 867 td->details.refresh.no_blinding_seed 868 ? GNUNET_PQ_query_param_null () 869 : TALER_PQ_query_param_array_cs_r_pub ( 870 td->details.refresh.num_cs_r_values, 871 td->details.refresh.cs_r_values, 872 pg->conn), 873 td->details.refresh.no_blinding_seed 874 ? GNUNET_PQ_query_param_null () 875 : GNUNET_PQ_query_param_uint64 ( 876 &td->details.refresh.cs_r_choices), 877 GNUNET_PQ_query_param_array_uint64 ( 878 td->details.refresh.num_coins, 879 td->details.refresh.denom_serials, 880 pg->conn), 881 TALER_PQ_query_param_array_blinded_denom_sig ( 882 td->details.refresh.num_coins, 883 td->details.refresh.denom_sigs, 884 pg->conn), 885 (NULL == td->details.refresh.transfer_pubs) 886 ? GNUNET_PQ_query_param_null () 887 : GNUNET_PQ_query_param_array_auto_from_type ( 888 td->details.refresh.num_coins, 889 td->details.refresh.transfer_pubs, 890 pg->conn), 891 GNUNET_PQ_query_param_bool (td->details.refresh.revealed), 892 GNUNET_PQ_query_param_uint32 ( 893 &td->details.refresh.rc_version), 894 GNUNET_PQ_query_param_end 895 }; 896 enum GNUNET_DB_QueryStatus qs; 897 898 PREPARE (pg, 899 "insert_records_by_table_into_table_refresh", 900 "INSERT INTO refresh" 901 "(refresh_id" 902 ",rc" 903 ",execution_date" 904 ",amount_with_fee" 905 ",old_coin_pub" 906 ",old_coin_sig" 907 ",refresh_seed" 908 ",noreveal_index" 909 ",planchets_h" 910 ",selected_h" 911 ",blinding_seed" 912 ",cs_r_values" 913 ",cs_r_choices" 914 ",denom_serials" 915 ",denom_sigs" 916 ",transfer_pubs" 917 ",revealed" 918 ",rc_version" 919 ") VALUES " 920 "($1, $2, $3, $4, $5, $6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17," 921 "$18);"); 922 qs = GNUNET_PQ_eval_prepared_non_select (pg->conn, 923 "insert_records_by_table_into_table_refresh", 924 params); 925 GNUNET_PQ_cleanup_query_params_closures (params); 926 return qs; 927 } 928 929 930 /** 931 * Function called with batch deposits records to insert into table. 932 * 933 * @param pg plugin context 934 * @param td record to insert 935 */ 936 static enum GNUNET_DB_QueryStatus 937 irbt_cb_table_batch_deposits (struct TALER_EXCHANGEDB_PostgresContext *pg, 938 const struct TALER_EXCHANGEDB_TableData *td) 939 { 940 struct GNUNET_PQ_QueryParam params[] = { 941 GNUNET_PQ_query_param_uint64 (&td->serial), 942 GNUNET_PQ_query_param_uint64 (&td->details.batch_deposits.shard), 943 GNUNET_PQ_query_param_auto_from_type ( 944 &td->details.batch_deposits.merchant_pub), 945 GNUNET_PQ_query_param_timestamp ( 946 &td->details.batch_deposits.wallet_timestamp), 947 GNUNET_PQ_query_param_timestamp ( 948 &td->details.batch_deposits.exchange_timestamp), 949 GNUNET_PQ_query_param_timestamp ( 950 &td->details.batch_deposits.refund_deadline), 951 GNUNET_PQ_query_param_timestamp (&td->details.batch_deposits.wire_deadline), 952 GNUNET_PQ_query_param_auto_from_type ( 953 &td->details.batch_deposits.h_contract_terms), 954 td->details.batch_deposits.no_wallet_data_hash 955 ? GNUNET_PQ_query_param_null () 956 : GNUNET_PQ_query_param_auto_from_type ( 957 &td->details.batch_deposits.wallet_data_hash), 958 GNUNET_PQ_query_param_auto_from_type ( 959 &td->details.batch_deposits.wire_salt), 960 GNUNET_PQ_query_param_auto_from_type ( 961 &td->details.batch_deposits.wire_target_h_payto), 962 TALER_PQ_query_param_amount ( 963 pg->conn, 964 &td->details.batch_deposits.total_amount), 965 TALER_PQ_query_param_amount ( 966 pg->conn, 967 &td->details.batch_deposits.total_without_fee), 968 GNUNET_PQ_query_param_auto_from_type ( 969 &td->details.batch_deposits.merchant_sig), 970 GNUNET_PQ_query_param_bool (td->details.batch_deposits.done), 971 GNUNET_PQ_query_param_end 972 }; 973 974 PREPARE (pg, 975 "insert_records_by_table_into_table_batch_deposits", 976 "INSERT INTO batch_deposits" 977 "(batch_deposit_serial_id" 978 ",shard" 979 ",merchant_pub" 980 ",wallet_timestamp" 981 ",exchange_timestamp" 982 ",refund_deadline" 983 ",wire_deadline" 984 ",h_contract_terms" 985 ",wallet_data_hash" 986 ",wire_salt" 987 ",wire_target_h_payto" 988 ",total_amount" 989 ",total_without_fee" 990 ",merchant_sig" 991 ",done" 992 ") VALUES " 993 "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10," 994 " $11, $12, $13, $14, $15);"); 995 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 996 "insert_records_by_table_into_table_batch_deposits", 997 params); 998 } 999 1000 1001 /** 1002 * Function called with deposits records to insert into table. 1003 * 1004 * @param pg plugin context 1005 * @param td record to insert 1006 */ 1007 static enum GNUNET_DB_QueryStatus 1008 irbt_cb_table_coin_deposits (struct TALER_EXCHANGEDB_PostgresContext *pg, 1009 const struct TALER_EXCHANGEDB_TableData *td) 1010 { 1011 struct GNUNET_PQ_QueryParam params[] = { 1012 GNUNET_PQ_query_param_uint64 (&td->serial), 1013 GNUNET_PQ_query_param_uint64 ( 1014 &td->details.coin_deposits.batch_deposit_serial_id), 1015 GNUNET_PQ_query_param_auto_from_type ( 1016 &td->details.coin_deposits.coin_pub), 1017 GNUNET_PQ_query_param_auto_from_type ( 1018 &td->details.coin_deposits.coin_sig), 1019 TALER_PQ_query_param_amount ( 1020 pg->conn, 1021 &td->details.coin_deposits.amount_with_fee), 1022 GNUNET_PQ_query_param_end 1023 }; 1024 1025 PREPARE (pg, 1026 "insert_records_by_table_into_table_coin_deposits", 1027 "INSERT INTO coin_deposits" 1028 "(coin_deposit_serial_id" 1029 ",batch_deposit_serial_id" 1030 ",coin_pub" 1031 ",coin_sig" 1032 ",amount_with_fee" 1033 ") VALUES " 1034 "($1, $2, $3, $4, $5);"); 1035 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 1036 "insert_records_by_table_into_table_coin_deposits", 1037 params); 1038 } 1039 1040 1041 /** 1042 * Function called with refunds records to insert into table. 1043 * 1044 * @param pg plugin context 1045 * @param td record to insert 1046 */ 1047 static enum GNUNET_DB_QueryStatus 1048 irbt_cb_table_refunds (struct TALER_EXCHANGEDB_PostgresContext *pg, 1049 const struct TALER_EXCHANGEDB_TableData *td) 1050 { 1051 struct GNUNET_PQ_QueryParam params[] = { 1052 GNUNET_PQ_query_param_uint64 (&td->serial), 1053 GNUNET_PQ_query_param_auto_from_type (&td->details.refunds.coin_pub), 1054 GNUNET_PQ_query_param_auto_from_type (&td->details.refunds.merchant_sig), 1055 GNUNET_PQ_query_param_uint64 (&td->details.refunds.rtransaction_id), 1056 TALER_PQ_query_param_amount ( 1057 pg->conn, 1058 &td->details.refunds.amount_with_fee), 1059 GNUNET_PQ_query_param_uint64 ( 1060 &td->details.refunds.batch_deposit_serial_id), 1061 GNUNET_PQ_query_param_end 1062 }; 1063 1064 PREPARE (pg, 1065 "insert_records_by_table_into_table_refunds", 1066 "INSERT INTO refunds" 1067 "(refund_serial_id" 1068 ",coin_pub" 1069 ",merchant_sig" 1070 ",rtransaction_id" 1071 ",amount_with_fee" 1072 ",batch_deposit_serial_id" 1073 ") VALUES " 1074 "($1, $2, $3, $4, $5, $6);"); 1075 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 1076 "insert_records_by_table_into_table_refunds", 1077 params); 1078 } 1079 1080 1081 /** 1082 * Function called with wire_out records to insert into table. 1083 * 1084 * @param pg plugin context 1085 * @param td record to insert 1086 */ 1087 static enum GNUNET_DB_QueryStatus 1088 irbt_cb_table_wire_out (struct TALER_EXCHANGEDB_PostgresContext *pg, 1089 const struct TALER_EXCHANGEDB_TableData *td) 1090 { 1091 struct GNUNET_PQ_QueryParam params[] = { 1092 GNUNET_PQ_query_param_uint64 (&td->serial), 1093 GNUNET_PQ_query_param_timestamp (&td->details.wire_out.execution_date), 1094 GNUNET_PQ_query_param_auto_from_type (&td->details.wire_out.wtid_raw), 1095 GNUNET_PQ_query_param_auto_from_type ( 1096 &td->details.wire_out.wire_target_h_payto), 1097 GNUNET_PQ_query_param_string ( 1098 td->details.wire_out.exchange_account_section), 1099 TALER_PQ_query_param_amount ( 1100 pg->conn, 1101 &td->details.wire_out.amount), 1102 GNUNET_PQ_query_param_end 1103 }; 1104 1105 PREPARE (pg, 1106 "insert_records_by_table_into_table_wire_out", 1107 "INSERT INTO wire_out" 1108 "(wireout_uuid" 1109 ",execution_date" 1110 ",wtid_raw" 1111 ",wire_target_h_payto" 1112 ",exchange_account_section" 1113 ",amount" 1114 ") VALUES " 1115 "($1, $2, $3, $4, $5, $6);"); 1116 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 1117 "insert_records_by_table_into_table_wire_out", 1118 params); 1119 } 1120 1121 1122 /** 1123 * Function called with aggregation_tracking records to insert into table. 1124 * 1125 * @param pg plugin context 1126 * @param td record to insert 1127 */ 1128 static enum GNUNET_DB_QueryStatus 1129 irbt_cb_table_aggregation_tracking (struct TALER_EXCHANGEDB_PostgresContext *pg, 1130 const struct TALER_EXCHANGEDB_TableData *td) 1131 { 1132 struct GNUNET_PQ_QueryParam params[] = { 1133 GNUNET_PQ_query_param_uint64 (&td->serial), 1134 GNUNET_PQ_query_param_uint64 ( 1135 &td->details.aggregation_tracking.batch_deposit_serial_id), 1136 GNUNET_PQ_query_param_auto_from_type ( 1137 &td->details.aggregation_tracking.wtid_raw), 1138 GNUNET_PQ_query_param_end 1139 }; 1140 1141 PREPARE (pg, 1142 "insert_records_by_table_into_table_aggregation_tracking", 1143 "INSERT INTO aggregation_tracking" 1144 "(aggregation_serial_id" 1145 ",batch_deposit_serial_id" 1146 ",wtid_raw" 1147 ") VALUES " 1148 "($1, $2, $3);"); 1149 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 1150 "insert_records_by_table_into_table_aggregation_tracking", 1151 params); 1152 } 1153 1154 1155 /** 1156 * Function called with aggregation_deferrals records to insert into table. 1157 * 1158 * @param pg plugin context 1159 * @param td record to insert 1160 */ 1161 static enum GNUNET_DB_QueryStatus 1162 irbt_cb_table_aggregation_deferrals ( 1163 struct TALER_EXCHANGEDB_PostgresContext *pg, 1164 const struct TALER_EXCHANGEDB_TableData *td) 1165 { 1166 struct GNUNET_PQ_QueryParam params[] = { 1167 GNUNET_PQ_query_param_uint64 (&td->serial), 1168 GNUNET_PQ_query_param_uint64 ( 1169 &td->details.aggregation_deferrals.batch_deposit_serial_id), 1170 GNUNET_PQ_query_param_auto_from_type ( 1171 &td->details.aggregation_deferrals.wtid_raw), 1172 GNUNET_PQ_query_param_auto_from_type ( 1173 &td->details.aggregation_deferrals.wire_target_h_payto), 1174 TALER_PQ_query_param_amount ( 1175 pg->conn, 1176 &td->details.aggregation_deferrals.amount), 1177 GNUNET_PQ_query_param_uint32 ( 1178 &td->details.aggregation_deferrals.deferral_reason), 1179 GNUNET_PQ_query_param_uint64 ( 1180 &td->details.aggregation_deferrals.legitimization_requirement_serial_id), 1181 GNUNET_PQ_query_param_timestamp ( 1182 &td->details.aggregation_deferrals.deferral_time), 1183 GNUNET_PQ_query_param_end 1184 }; 1185 1186 PREPARE (pg, 1187 "insert_records_by_table_into_table_aggregation_deferrals", 1188 "INSERT INTO aggregation_deferrals" 1189 "(aggregation_deferral_serial_id" 1190 ",batch_deposit_serial_id" 1191 ",wtid_raw" 1192 ",wire_target_h_payto" 1193 ",amount" 1194 ",deferral_reason" 1195 ",legitimization_requirement_serial_id" 1196 ",deferral_time" 1197 ") VALUES " 1198 "($1, $2, $3, $4, $5, $6, $7, $8);"); 1199 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 1200 "insert_records_by_table_into_table_aggregation_deferrals", 1201 params); 1202 } 1203 1204 1205 /** 1206 * Function called with wire_fee records to insert into table. 1207 * 1208 * @param pg plugin context 1209 * @param td record to insert 1210 */ 1211 static enum GNUNET_DB_QueryStatus 1212 irbt_cb_table_wire_fee (struct TALER_EXCHANGEDB_PostgresContext *pg, 1213 const struct TALER_EXCHANGEDB_TableData *td) 1214 { 1215 struct GNUNET_PQ_QueryParam params[] = { 1216 GNUNET_PQ_query_param_uint64 (&td->serial), 1217 GNUNET_PQ_query_param_string (td->details.wire_fee.wire_method), 1218 GNUNET_PQ_query_param_timestamp (&td->details.wire_fee.start_date), 1219 GNUNET_PQ_query_param_timestamp (&td->details.wire_fee.end_date), 1220 TALER_PQ_query_param_amount ( 1221 pg->conn, 1222 &td->details.wire_fee.fees.wire), 1223 TALER_PQ_query_param_amount ( 1224 pg->conn, 1225 &td->details.wire_fee.fees.closing), 1226 GNUNET_PQ_query_param_auto_from_type (&td->details.wire_fee.master_sig), 1227 GNUNET_PQ_query_param_end 1228 }; 1229 1230 PREPARE (pg, 1231 "insert_records_by_table_into_table_wire_fee", 1232 "INSERT INTO wire_fee" 1233 "(wire_fee_serial" 1234 ",wire_method" 1235 ",start_date" 1236 ",end_date" 1237 ",wire_fee" 1238 ",closing_fee" 1239 ",master_sig" 1240 ") VALUES " 1241 "($1, $2, $3, $4, $5, $6, $7);"); 1242 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 1243 "insert_records_by_table_into_table_wire_fee", 1244 params); 1245 } 1246 1247 1248 /** 1249 * Function called with wire_fee records to insert into table. 1250 * 1251 * @param pg plugin context 1252 * @param td record to insert 1253 */ 1254 static enum GNUNET_DB_QueryStatus 1255 irbt_cb_table_global_fee (struct TALER_EXCHANGEDB_PostgresContext *pg, 1256 const struct TALER_EXCHANGEDB_TableData *td) 1257 { 1258 struct GNUNET_PQ_QueryParam params[] = { 1259 GNUNET_PQ_query_param_uint64 ( 1260 &td->serial), 1261 GNUNET_PQ_query_param_timestamp ( 1262 &td->details.global_fee.start_date), 1263 GNUNET_PQ_query_param_timestamp ( 1264 &td->details.global_fee.end_date), 1265 TALER_PQ_query_param_amount ( 1266 pg->conn, 1267 &td->details.global_fee.fees.history), 1268 TALER_PQ_query_param_amount ( 1269 pg->conn, 1270 &td->details.global_fee.fees.account), 1271 TALER_PQ_query_param_amount ( 1272 pg->conn, 1273 &td->details.global_fee.fees.purse), 1274 GNUNET_PQ_query_param_relative_time ( 1275 &td->details.global_fee.purse_timeout), 1276 GNUNET_PQ_query_param_relative_time ( 1277 &td->details.global_fee.history_expiration), 1278 GNUNET_PQ_query_param_uint32 ( 1279 &td->details.global_fee.purse_account_limit), 1280 GNUNET_PQ_query_param_auto_from_type ( 1281 &td->details.global_fee.master_sig), 1282 GNUNET_PQ_query_param_end 1283 }; 1284 1285 PREPARE (pg, 1286 "insert_records_by_table_into_table_global_fee", 1287 "INSERT INTO global_fee" 1288 "(global_fee_serial" 1289 ",start_date" 1290 ",end_date" 1291 ",history_fee" 1292 ",account_fee" 1293 ",purse_fee" 1294 ",purse_timeout" 1295 ",history_expiration" 1296 ",purse_account_limit" 1297 ",master_sig" 1298 ") VALUES " 1299 "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10);"); 1300 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 1301 "insert_records_by_table_into_table_global_fee", 1302 params); 1303 } 1304 1305 1306 /** 1307 * Function called with recoup records to insert into table. 1308 * 1309 * @param pg plugin context 1310 * @param td record to insert 1311 */ 1312 static enum GNUNET_DB_QueryStatus 1313 irbt_cb_table_recoup (struct TALER_EXCHANGEDB_PostgresContext *pg, 1314 const struct TALER_EXCHANGEDB_TableData *td) 1315 { 1316 struct GNUNET_PQ_QueryParam params[] = { 1317 GNUNET_PQ_query_param_uint64 (&td->serial), 1318 GNUNET_PQ_query_param_auto_from_type (&td->details.recoup.coin_sig), 1319 GNUNET_PQ_query_param_auto_from_type (&td->details.recoup.coin_blind), 1320 TALER_PQ_query_param_amount ( 1321 pg->conn, 1322 &td->details.recoup.amount), 1323 GNUNET_PQ_query_param_timestamp (&td->details.recoup.timestamp), 1324 GNUNET_PQ_query_param_auto_from_type ( 1325 &td->details.recoup.coin_pub), 1326 GNUNET_PQ_query_param_uint64 (&td->details.recoup.withdraw_serial_id), 1327 GNUNET_PQ_query_param_uint32 (&td->details.recoup.coin_index), 1328 GNUNET_PQ_query_param_end 1329 }; 1330 1331 PREPARE (pg, 1332 "insert_records_by_table_into_table_recoup", 1333 "INSERT INTO recoup" 1334 "(recoup_uuid" 1335 ",coin_sig" 1336 ",coin_blind" 1337 ",amount" 1338 ",recoup_timestamp" 1339 ",coin_pub" 1340 ",withdraw_id" 1341 ",coin_index" 1342 ") VALUES " 1343 "($1, $2, $3, $4, $5, $6, $7, $8);"); 1344 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 1345 "insert_records_by_table_into_table_recoup", 1346 params); 1347 } 1348 1349 1350 /** 1351 * Function called with recoup_refresh records to insert into table. 1352 * 1353 * @param pg plugin context 1354 * @param td record to insert 1355 */ 1356 static enum GNUNET_DB_QueryStatus 1357 irbt_cb_table_recoup_refresh (struct TALER_EXCHANGEDB_PostgresContext *pg, 1358 const struct TALER_EXCHANGEDB_TableData *td) 1359 { 1360 struct GNUNET_PQ_QueryParam params[] = { 1361 GNUNET_PQ_query_param_uint64 ( 1362 &td->serial), 1363 GNUNET_PQ_query_param_auto_from_type ( 1364 &td->details.recoup_refresh.coin_sig), 1365 GNUNET_PQ_query_param_auto_from_type ( 1366 &td->details.recoup_refresh.coin_blind), 1367 TALER_PQ_query_param_amount ( 1368 pg->conn, 1369 &td->details.recoup_refresh.amount), 1370 GNUNET_PQ_query_param_timestamp ( 1371 &td->details.recoup_refresh.recoup_timestamp), 1372 GNUNET_PQ_query_param_uint64 ( 1373 &td->details.recoup_refresh.known_coin_id), 1374 GNUNET_PQ_query_param_auto_from_type ( 1375 &td->details.recoup_refresh.coin_pub), 1376 GNUNET_PQ_query_param_uint64 ( 1377 &td->details.recoup_refresh.refresh_id), 1378 GNUNET_PQ_query_param_uint32 ( 1379 &td->details.recoup_refresh.coin_index), 1380 GNUNET_PQ_query_param_end 1381 }; 1382 1383 PREPARE (pg, 1384 "insert_records_by_table_into_table_recoup_refresh", 1385 "INSERT INTO recoup_refresh" 1386 "(recoup_refresh_uuid" 1387 ",coin_sig" 1388 ",coin_blind" 1389 ",amount" 1390 ",recoup_timestamp" 1391 ",known_coin_id" 1392 ",coin_pub" 1393 ",refresh_id" 1394 ",coin_index" 1395 ") VALUES " 1396 "($1, $2, $3, $4, $5, $6, $7, $8, $9);"); 1397 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 1398 "insert_records_by_table_into_table_recoup_refresh", 1399 params); 1400 } 1401 1402 1403 /** 1404 * Function called with purse_requests records to insert into table. 1405 * 1406 * @param pg plugin context 1407 * @param td record to insert 1408 */ 1409 static enum GNUNET_DB_QueryStatus 1410 irbt_cb_table_purse_requests (struct TALER_EXCHANGEDB_PostgresContext *pg, 1411 const struct TALER_EXCHANGEDB_TableData *td) 1412 { 1413 struct GNUNET_PQ_QueryParam params[] = { 1414 GNUNET_PQ_query_param_uint64 (&td->serial), 1415 GNUNET_PQ_query_param_auto_from_type ( 1416 &td->details.purse_requests.purse_pub), 1417 GNUNET_PQ_query_param_auto_from_type ( 1418 &td->details.purse_requests.merge_pub), 1419 GNUNET_PQ_query_param_timestamp ( 1420 &td->details.purse_requests.purse_creation), 1421 GNUNET_PQ_query_param_timestamp ( 1422 &td->details.purse_requests.purse_expiration), 1423 GNUNET_PQ_query_param_auto_from_type ( 1424 &td->details.purse_requests.h_contract_terms), 1425 GNUNET_PQ_query_param_uint32 (&td->details.purse_requests.age_limit), 1426 GNUNET_PQ_query_param_uint32 (&td->details.purse_requests.flags), 1427 TALER_PQ_query_param_amount ( 1428 pg->conn, 1429 &td->details.purse_requests.amount_with_fee), 1430 TALER_PQ_query_param_amount ( 1431 pg->conn, 1432 &td->details.purse_requests.purse_fee), 1433 GNUNET_PQ_query_param_auto_from_type ( 1434 &td->details.purse_requests.purse_sig), 1435 GNUNET_PQ_query_param_end 1436 }; 1437 1438 PREPARE (pg, 1439 "insert_records_by_table_into_table_purse_requests", 1440 "INSERT INTO purse_requests" 1441 "(purse_requests_serial_id" 1442 ",purse_pub" 1443 ",merge_pub" 1444 ",purse_creation" 1445 ",purse_expiration" 1446 ",h_contract_terms" 1447 ",age_limit" 1448 ",flags" 1449 ",amount_with_fee" 1450 ",purse_fee" 1451 ",purse_sig" 1452 ") VALUES " 1453 "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11);"); 1454 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 1455 "insert_records_by_table_into_table_purse_requests", 1456 params); 1457 } 1458 1459 1460 /** 1461 * Function called with purse_decision records to insert into table. 1462 * 1463 * @param pg plugin context 1464 * @param td record to insert 1465 */ 1466 static enum GNUNET_DB_QueryStatus 1467 irbt_cb_table_purse_decision (struct TALER_EXCHANGEDB_PostgresContext *pg, 1468 const struct TALER_EXCHANGEDB_TableData *td) 1469 { 1470 struct GNUNET_PQ_QueryParam params[] = { 1471 GNUNET_PQ_query_param_uint64 (&td->serial), 1472 GNUNET_PQ_query_param_auto_from_type ( 1473 &td->details.purse_decision.purse_pub), 1474 GNUNET_PQ_query_param_timestamp ( 1475 &td->details.purse_decision.action_timestamp), 1476 GNUNET_PQ_query_param_bool ( 1477 td->details.purse_decision.refunded), 1478 GNUNET_PQ_query_param_end 1479 }; 1480 1481 PREPARE (pg, 1482 "insert_records_by_table_into_table_purse_decision", 1483 "INSERT INTO purse_decision" 1484 "(purse_decision_serial_id" 1485 ",purse_pub" 1486 ",action_timestamp" 1487 ",refunded" 1488 ") VALUES " 1489 "($1, $2, $3, $4);"); 1490 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 1491 "insert_records_by_table_into_table_purse_decision", 1492 params); 1493 } 1494 1495 1496 /** 1497 * Function called with purse_merges records to insert into table. 1498 * 1499 * @param pg plugin context 1500 * @param td record to insert 1501 */ 1502 static enum GNUNET_DB_QueryStatus 1503 irbt_cb_table_purse_merges (struct TALER_EXCHANGEDB_PostgresContext *pg, 1504 const struct TALER_EXCHANGEDB_TableData *td) 1505 { 1506 struct GNUNET_PQ_QueryParam params[] = { 1507 GNUNET_PQ_query_param_uint64 (&td->serial), 1508 GNUNET_PQ_query_param_uint64 (&td->details.purse_merges.partner_serial_id), 1509 GNUNET_PQ_query_param_auto_from_type ( 1510 &td->details.purse_merges.reserve_pub), 1511 GNUNET_PQ_query_param_auto_from_type (&td->details.purse_merges.purse_pub), 1512 GNUNET_PQ_query_param_auto_from_type (&td->details.purse_merges.merge_sig), 1513 GNUNET_PQ_query_param_timestamp (&td->details.purse_merges.merge_timestamp), 1514 GNUNET_PQ_query_param_end 1515 }; 1516 1517 PREPARE (pg, 1518 "insert_records_by_table_into_table_purse_merges", 1519 "INSERT INTO purse_merges" 1520 "(purse_merge_request_serial_id" 1521 ",partner_serial_id" 1522 ",reserve_pub" 1523 ",purse_pub" 1524 ",merge_sig" 1525 ",merge_timestamp" 1526 ") VALUES " 1527 "($1, $2, $3, $4, $5, $6);"); 1528 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 1529 "insert_records_by_table_into_table_purse_merges", 1530 params); 1531 } 1532 1533 1534 /** 1535 * Function called with purse_deposits records to insert into table. 1536 * 1537 * @param pg plugin context 1538 * @param td record to insert 1539 */ 1540 static enum GNUNET_DB_QueryStatus 1541 irbt_cb_table_purse_deposits (struct TALER_EXCHANGEDB_PostgresContext *pg, 1542 const struct TALER_EXCHANGEDB_TableData *td) 1543 { 1544 struct GNUNET_PQ_QueryParam params[] = { 1545 GNUNET_PQ_query_param_uint64 (&td->serial), 1546 GNUNET_PQ_query_param_uint64 ( 1547 &td->details.purse_deposits.partner_serial_id), 1548 GNUNET_PQ_query_param_auto_from_type ( 1549 &td->details.purse_deposits.purse_pub), 1550 GNUNET_PQ_query_param_auto_from_type (&td->details.purse_deposits.coin_pub), 1551 TALER_PQ_query_param_amount ( 1552 pg->conn, 1553 &td->details.purse_deposits.amount_with_fee), 1554 GNUNET_PQ_query_param_auto_from_type (&td->details.purse_deposits.coin_sig), 1555 GNUNET_PQ_query_param_end 1556 }; 1557 1558 PREPARE (pg, 1559 "insert_records_by_table_into_table_purse_deposits", 1560 "INSERT INTO purse_deposits" 1561 "(purse_deposit_serial_id" 1562 ",partner_serial_id" 1563 ",purse_pub" 1564 ",coin_pub" 1565 ",amount_with_fee" 1566 ",coin_sig" 1567 ") VALUES " 1568 "($1, $2, $3, $4, $5, $6);"); 1569 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 1570 "insert_records_by_table_into_table_purse_deposits", 1571 params); 1572 } 1573 1574 1575 /** 1576 x * Function called with account_mergers records to insert into table. 1577 * 1578 * @param pg plugin context 1579 * @param td record to insert 1580 */ 1581 static enum GNUNET_DB_QueryStatus 1582 irbt_cb_table_account_mergers (struct TALER_EXCHANGEDB_PostgresContext *pg, 1583 const struct TALER_EXCHANGEDB_TableData *td) 1584 { 1585 struct GNUNET_PQ_QueryParam params[] = { 1586 GNUNET_PQ_query_param_uint64 (&td->serial), 1587 GNUNET_PQ_query_param_auto_from_type ( 1588 &td->details.account_merges.reserve_pub), 1589 GNUNET_PQ_query_param_auto_from_type ( 1590 &td->details.account_merges.reserve_sig), 1591 GNUNET_PQ_query_param_auto_from_type ( 1592 &td->details.account_merges.purse_pub), 1593 GNUNET_PQ_query_param_auto_from_type ( 1594 &td->details.account_merges.wallet_h_payto), 1595 GNUNET_PQ_query_param_end 1596 }; 1597 1598 PREPARE (pg, 1599 "insert_records_by_table_into_table_account_merges", 1600 "INSERT INTO account_merges" 1601 "(account_merge_request_serial_id" 1602 ",reserve_pub" 1603 ",reserve_sig" 1604 ",purse_pub" 1605 ",wallet_h_payto" 1606 ") VALUES " 1607 "($1, $2, $3, $4, $5);"); 1608 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 1609 "insert_records_by_table_into_table_account_merges", 1610 params); 1611 } 1612 1613 1614 /** 1615 * Function called with history_requests records to insert into table. 1616 * 1617 * @param pg plugin context 1618 * @param td record to insert 1619 */ 1620 static enum GNUNET_DB_QueryStatus 1621 irbt_cb_table_history_requests (struct TALER_EXCHANGEDB_PostgresContext *pg, 1622 const struct TALER_EXCHANGEDB_TableData *td) 1623 { 1624 struct GNUNET_PQ_QueryParam params[] = { 1625 GNUNET_PQ_query_param_uint64 (&td->serial), 1626 GNUNET_PQ_query_param_auto_from_type ( 1627 &td->details.history_requests.reserve_pub), 1628 GNUNET_PQ_query_param_timestamp ( 1629 &td->details.history_requests.request_timestamp), 1630 GNUNET_PQ_query_param_auto_from_type ( 1631 &td->details.history_requests.reserve_sig), 1632 TALER_PQ_query_param_amount ( 1633 pg->conn, 1634 &td->details.history_requests.history_fee), 1635 GNUNET_PQ_query_param_end 1636 }; 1637 1638 PREPARE (pg, 1639 "insert_records_by_table_into_table_history_requests", 1640 "INSERT INTO history_requests" 1641 "(history_request_serial_id" 1642 ",reserve_pub" 1643 ",request_timestamp" 1644 ",reserve_sig" 1645 ",history_fee" 1646 ") VALUES " 1647 "($1, $2, $3, $4, $5);"); 1648 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 1649 "insert_records_by_table_into_table_history_requests", 1650 params); 1651 } 1652 1653 1654 /** 1655 * Function called with close_requests records to insert into table. 1656 * 1657 * @param pg plugin context 1658 * @param td record to insert 1659 */ 1660 static enum GNUNET_DB_QueryStatus 1661 irbt_cb_table_close_requests (struct TALER_EXCHANGEDB_PostgresContext *pg, 1662 const struct TALER_EXCHANGEDB_TableData *td) 1663 { 1664 struct GNUNET_PQ_QueryParam params[] = { 1665 GNUNET_PQ_query_param_uint64 (&td->serial), 1666 GNUNET_PQ_query_param_auto_from_type ( 1667 &td->details.close_requests.reserve_pub), 1668 GNUNET_PQ_query_param_timestamp ( 1669 &td->details.close_requests.close_timestamp), 1670 GNUNET_PQ_query_param_auto_from_type ( 1671 &td->details.close_requests.reserve_sig), 1672 TALER_PQ_query_param_amount ( 1673 pg->conn, 1674 &td->details.close_requests.close), 1675 TALER_PQ_query_param_amount ( 1676 pg->conn, 1677 &td->details.close_requests.close_fee), 1678 GNUNET_PQ_query_param_string ( 1679 td->details.close_requests.payto_uri.full_payto), 1680 GNUNET_PQ_query_param_end 1681 }; 1682 1683 PREPARE (pg, 1684 "insert_records_by_table_into_table_close_requests", 1685 "INSERT INTO close_requests" 1686 "(close_request_serial_id" 1687 ",reserve_pub" 1688 ",close_timestamp" 1689 ",reserve_sig" 1690 ",close" 1691 ",close_fee" 1692 ",payto_uri" 1693 ") VALUES " 1694 "($1, $2, $3, $4, $5, $6, $7);"); 1695 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 1696 "insert_records_by_table_into_table_close_requests", 1697 params); 1698 } 1699 1700 1701 /** 1702 * Function called with wads_out records to insert into table. 1703 * 1704 * @param pg plugin context 1705 * @param td record to insert 1706 */ 1707 static enum GNUNET_DB_QueryStatus 1708 irbt_cb_table_wads_out (struct TALER_EXCHANGEDB_PostgresContext *pg, 1709 const struct TALER_EXCHANGEDB_TableData *td) 1710 { 1711 struct GNUNET_PQ_QueryParam params[] = { 1712 GNUNET_PQ_query_param_uint64 (&td->serial), 1713 GNUNET_PQ_query_param_auto_from_type (&td->details.wads_out.wad_id), 1714 GNUNET_PQ_query_param_uint64 (&td->details.wads_out.partner_serial_id), 1715 TALER_PQ_query_param_amount ( 1716 pg->conn, 1717 &td->details.wads_out.amount), 1718 GNUNET_PQ_query_param_timestamp (&td->details.wads_out.execution_time), 1719 GNUNET_PQ_query_param_end 1720 }; 1721 1722 PREPARE (pg, 1723 "insert_records_by_table_into_table_wads_out", 1724 "INSERT INTO wads_out" 1725 "(wad_out_serial_id" 1726 ",wad_id" 1727 ",partner_serial_id" 1728 ",amount" 1729 ",execution_time" 1730 ") VALUES " 1731 "($1, $2, $3, $4, $5);"); 1732 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 1733 "insert_records_by_table_into_table_wads_out", 1734 params); 1735 } 1736 1737 1738 /** 1739 * Function called with wads_out_entries records to insert into table. 1740 * 1741 * @param pg plugin context 1742 * @param td record to insert 1743 */ 1744 static enum GNUNET_DB_QueryStatus 1745 irbt_cb_table_wads_out_entries (struct TALER_EXCHANGEDB_PostgresContext *pg, 1746 const struct TALER_EXCHANGEDB_TableData *td) 1747 { 1748 struct GNUNET_PQ_QueryParam params[] = { 1749 GNUNET_PQ_query_param_uint64 (&td->serial), 1750 GNUNET_PQ_query_param_uint64 ( 1751 &td->details.wads_out_entries.wad_out_serial_id), 1752 GNUNET_PQ_query_param_auto_from_type ( 1753 &td->details.wads_out_entries.reserve_pub), 1754 GNUNET_PQ_query_param_auto_from_type ( 1755 &td->details.wads_out_entries.purse_pub), 1756 GNUNET_PQ_query_param_auto_from_type ( 1757 &td->details.wads_out_entries.h_contract), 1758 GNUNET_PQ_query_param_timestamp ( 1759 &td->details.wads_out_entries.purse_expiration), 1760 GNUNET_PQ_query_param_timestamp ( 1761 &td->details.wads_out_entries.merge_timestamp), 1762 TALER_PQ_query_param_amount ( 1763 pg->conn, 1764 &td->details.wads_out_entries.amount_with_fee), 1765 TALER_PQ_query_param_amount ( 1766 pg->conn, 1767 &td->details.wads_out_entries.wad_fee), 1768 TALER_PQ_query_param_amount ( 1769 pg->conn, 1770 &td->details.wads_out_entries.deposit_fees), 1771 GNUNET_PQ_query_param_auto_from_type ( 1772 &td->details.wads_out_entries.reserve_sig), 1773 GNUNET_PQ_query_param_auto_from_type ( 1774 &td->details.wads_out_entries.purse_sig), 1775 GNUNET_PQ_query_param_end 1776 }; 1777 1778 PREPARE (pg, 1779 "insert_records_by_table_into_table_wad_out_entries", 1780 "INSERT INTO wad_out_entries" 1781 "(wad_out_entry_serial_id" 1782 ",wad_out_serial_id" 1783 ",reserve_pub" 1784 ",purse_pub" 1785 ",h_contract" 1786 ",purse_expiration" 1787 ",merge_timestamp" 1788 ",amount_with_fee" 1789 ",wad_fee" 1790 ",deposit_fees" 1791 ",reserve_sig" 1792 ",purse_sig" 1793 ") VALUES " 1794 "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12);"); 1795 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 1796 "insert_records_by_table_into_table_wad_out_entries", 1797 params); 1798 } 1799 1800 1801 /** 1802 * Function called with wads_in records to insert into table. 1803 * 1804 * @param pg plugin context 1805 * @param td record to insert 1806 */ 1807 static enum GNUNET_DB_QueryStatus 1808 irbt_cb_table_wads_in (struct TALER_EXCHANGEDB_PostgresContext *pg, 1809 const struct TALER_EXCHANGEDB_TableData *td) 1810 { 1811 struct GNUNET_PQ_QueryParam params[] = { 1812 GNUNET_PQ_query_param_uint64 (&td->serial), 1813 GNUNET_PQ_query_param_auto_from_type (&td->details.wads_in.wad_id), 1814 GNUNET_PQ_query_param_string (td->details.wads_in.origin_exchange_url), 1815 TALER_PQ_query_param_amount ( 1816 pg->conn, 1817 &td->details.wads_in.amount), 1818 GNUNET_PQ_query_param_timestamp (&td->details.wads_in.arrival_time), 1819 GNUNET_PQ_query_param_end 1820 }; 1821 1822 PREPARE (pg, 1823 "insert_records_by_table_into_table_wads_in", 1824 "INSERT INTO wads_in" 1825 "(wad_in_serial_id" 1826 ",wad_id" 1827 ",origin_exchange_url" 1828 ",amount" 1829 ",arrival_time" 1830 ") VALUES " 1831 "($1, $2, $3, $4, $5);"); 1832 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 1833 "insert_records_by_table_into_table_wads_in", 1834 params); 1835 } 1836 1837 1838 /** 1839 * Function called with wads_in_entries records to insert into table. 1840 * 1841 * @param pg plugin context 1842 * @param td record to insert 1843 */ 1844 static enum GNUNET_DB_QueryStatus 1845 irbt_cb_table_wads_in_entries (struct TALER_EXCHANGEDB_PostgresContext *pg, 1846 const struct TALER_EXCHANGEDB_TableData *td) 1847 { 1848 struct GNUNET_PQ_QueryParam params[] = { 1849 GNUNET_PQ_query_param_uint64 (&td->serial), 1850 GNUNET_PQ_query_param_uint64 ( 1851 &td->details.wads_in_entries.wad_in_serial_id), 1852 GNUNET_PQ_query_param_auto_from_type ( 1853 &td->details.wads_in_entries.reserve_pub), 1854 GNUNET_PQ_query_param_auto_from_type ( 1855 &td->details.wads_in_entries.purse_pub), 1856 GNUNET_PQ_query_param_auto_from_type ( 1857 &td->details.wads_in_entries.h_contract), 1858 GNUNET_PQ_query_param_timestamp ( 1859 &td->details.wads_in_entries.purse_expiration), 1860 GNUNET_PQ_query_param_timestamp ( 1861 &td->details.wads_in_entries.merge_timestamp), 1862 TALER_PQ_query_param_amount ( 1863 pg->conn, 1864 &td->details.wads_in_entries.amount_with_fee), 1865 TALER_PQ_query_param_amount ( 1866 pg->conn, 1867 &td->details.wads_in_entries.wad_fee), 1868 TALER_PQ_query_param_amount ( 1869 pg->conn, 1870 &td->details.wads_in_entries.deposit_fees), 1871 GNUNET_PQ_query_param_auto_from_type ( 1872 &td->details.wads_in_entries.reserve_sig), 1873 GNUNET_PQ_query_param_auto_from_type ( 1874 &td->details.wads_in_entries.purse_sig), 1875 GNUNET_PQ_query_param_end 1876 }; 1877 1878 PREPARE (pg, 1879 "insert_records_by_table_into_table_wad_in_entries", 1880 "INSERT INTO wad_in_entries" 1881 "(wad_in_entry_serial_id" 1882 ",wad_in_serial_id" 1883 ",reserve_pub" 1884 ",purse_pub" 1885 ",h_contract" 1886 ",purse_expiration" 1887 ",merge_timestamp" 1888 ",amount_with_fee" 1889 ",wad_fee" 1890 ",deposit_fees" 1891 ",reserve_sig" 1892 ",purse_sig" 1893 ") VALUES " 1894 "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12);"); 1895 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 1896 "insert_records_by_table_into_table_wad_in_entries", 1897 params); 1898 } 1899 1900 1901 /** 1902 * Function called with profit_drains records to insert into table. 1903 * 1904 * @param pg plugin context 1905 * @param td record to insert 1906 */ 1907 static enum GNUNET_DB_QueryStatus 1908 irbt_cb_table_profit_drains (struct TALER_EXCHANGEDB_PostgresContext *pg, 1909 const struct TALER_EXCHANGEDB_TableData *td) 1910 { 1911 struct GNUNET_PQ_QueryParam params[] = { 1912 GNUNET_PQ_query_param_uint64 (&td->serial), 1913 GNUNET_PQ_query_param_auto_from_type ( 1914 &td->details.profit_drains.wtid), 1915 GNUNET_PQ_query_param_string ( 1916 td->details.profit_drains.account_section), 1917 GNUNET_PQ_query_param_string ( 1918 td->details.profit_drains.payto_uri.full_payto), 1919 GNUNET_PQ_query_param_timestamp ( 1920 &td->details.profit_drains.trigger_date), 1921 TALER_PQ_query_param_amount ( 1922 pg->conn, 1923 &td->details.profit_drains.amount), 1924 GNUNET_PQ_query_param_auto_from_type ( 1925 &td->details.profit_drains.master_sig), 1926 GNUNET_PQ_query_param_end 1927 }; 1928 1929 PREPARE (pg, 1930 "insert_records_by_table_into_table_profit_drains", 1931 "INSERT INTO profit_drains" 1932 "(profit_drain_serial_id" 1933 ",wtid" 1934 ",account_section" 1935 ",payto_uri" 1936 ",trigger_date" 1937 ",amount" 1938 ",master_sig" 1939 ") VALUES " 1940 "($1, $2, $3, $4, $5, $6, $7);"); 1941 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 1942 "insert_records_by_table_into_table_profit_drains", 1943 params); 1944 } 1945 1946 1947 /** 1948 * Function called with aml_staff records to insert into table. 1949 * 1950 * @param pg plugin context 1951 * @param td record to insert 1952 */ 1953 static enum GNUNET_DB_QueryStatus 1954 irbt_cb_table_aml_staff (struct TALER_EXCHANGEDB_PostgresContext *pg, 1955 const struct TALER_EXCHANGEDB_TableData *td) 1956 { 1957 struct GNUNET_PQ_QueryParam params[] = { 1958 GNUNET_PQ_query_param_uint64 (&td->serial), 1959 GNUNET_PQ_query_param_auto_from_type ( 1960 &td->details.aml_staff.decider_pub), 1961 GNUNET_PQ_query_param_auto_from_type ( 1962 &td->details.aml_staff.master_sig), 1963 GNUNET_PQ_query_param_string ( 1964 td->details.aml_staff.decider_name), 1965 GNUNET_PQ_query_param_bool ( 1966 td->details.aml_staff.is_active), 1967 GNUNET_PQ_query_param_bool ( 1968 td->details.aml_staff.read_only), 1969 GNUNET_PQ_query_param_timestamp ( 1970 &td->details.aml_staff.last_change), 1971 GNUNET_PQ_query_param_end 1972 }; 1973 1974 PREPARE (pg, 1975 "insert_records_by_table_into_table_aml_staff", 1976 "INSERT INTO aml_staff" 1977 "(aml_staff_uuid" 1978 ",decider_pub" 1979 ",master_sig" 1980 ",decider_name" 1981 ",is_active" 1982 ",read_only" 1983 ",last_change" 1984 ") VALUES " 1985 "($1, $2, $3, $4, $5, $6, $7);"); 1986 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 1987 "insert_records_by_table_into_table_aml_staff", 1988 params); 1989 } 1990 1991 1992 /** 1993 * Function called with kyc_attributes records to insert into table. 1994 * 1995 * @param pg plugin context 1996 * @param td record to insert 1997 */ 1998 static enum GNUNET_DB_QueryStatus 1999 irbt_cb_table_kyc_attributes (struct TALER_EXCHANGEDB_PostgresContext *pg, 2000 const struct TALER_EXCHANGEDB_TableData *td) 2001 { 2002 struct GNUNET_PQ_QueryParam params[] = { 2003 GNUNET_PQ_query_param_uint64 (&td->serial), 2004 GNUNET_PQ_query_param_auto_from_type ( 2005 &td->details.kyc_attributes.h_payto), 2006 GNUNET_PQ_query_param_uint64 ( 2007 &td->details.kyc_attributes.legitimization_serial), 2008 GNUNET_PQ_query_param_timestamp ( 2009 &td->details.kyc_attributes.collection_time), 2010 GNUNET_PQ_query_param_timestamp ( 2011 &td->details.kyc_attributes.expiration_time), 2012 NULL == td->details.kyc_attributes.form_name 2013 ? GNUNET_PQ_query_param_null () 2014 : GNUNET_PQ_query_param_string ( 2015 td->details.kyc_attributes.form_name), 2016 GNUNET_PQ_query_param_bool ( 2017 td->details.kyc_attributes.by_aml_officer), 2018 GNUNET_PQ_query_param_fixed_size ( 2019 td->details.kyc_attributes.encrypted_attributes, 2020 td->details.kyc_attributes.encrypted_attributes_size), 2021 GNUNET_PQ_query_param_end 2022 }; 2023 2024 PREPARE (pg, 2025 "insert_records_by_table_into_table_kyc_attributes", 2026 "INSERT INTO kyc_attributes" 2027 "(kyc_attributes_serial_id" 2028 ",h_payto" 2029 ",legitimization_serial" 2030 ",collection_time" 2031 ",expiration_time" 2032 ",form_name" 2033 ",by_aml_officer" 2034 ",encrypted_attributes" 2035 ") VALUES " 2036 "($1, $2, $3, $4, $5, $6, $7, $8);"); 2037 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 2038 "insert_records_by_table_into_table_kyc_attributes", 2039 params); 2040 } 2041 2042 2043 /** 2044 * Function called with aml_history records to insert into table. 2045 * 2046 * @param pg plugin context 2047 * @param td record to insert 2048 */ 2049 static enum GNUNET_DB_QueryStatus 2050 irbt_cb_table_aml_history (struct TALER_EXCHANGEDB_PostgresContext *pg, 2051 const struct TALER_EXCHANGEDB_TableData *td) 2052 { 2053 struct GNUNET_PQ_QueryParam params[] = { 2054 GNUNET_PQ_query_param_uint64 (&td->serial), 2055 GNUNET_PQ_query_param_auto_from_type ( 2056 &td->details.aml_history.h_payto), 2057 GNUNET_PQ_query_param_uint64 ( 2058 &td->details.aml_history.outcome_serial_id), 2059 GNUNET_PQ_query_param_string ( 2060 td->details.aml_history.justification), 2061 GNUNET_PQ_query_param_auto_from_type ( 2062 &td->details.aml_history.decider_pub), 2063 GNUNET_PQ_query_param_auto_from_type ( 2064 &td->details.aml_history.decider_sig), 2065 td->details.aml_history.no_kyc_attributes_hash 2066 ? GNUNET_PQ_query_param_null () 2067 : GNUNET_PQ_query_param_auto_from_type ( 2068 &td->details.aml_history.kyc_attributes_hash), 2069 td->details.aml_history.no_kyc_attributes_serial_id 2070 ? GNUNET_PQ_query_param_null () 2071 : GNUNET_PQ_query_param_uint64 ( 2072 &td->details.aml_history.kyc_attributes_serial_id), 2073 GNUNET_PQ_query_param_end 2074 }; 2075 2076 PREPARE (pg, 2077 "insert_records_by_table_into_table_aml_history", 2078 "INSERT INTO aml_history" 2079 "(aml_history_serial_id" 2080 ",h_payto" 2081 ",outcome_serial_id" 2082 ",justification" 2083 ",decider_pub" 2084 ",decider_sig" 2085 ",kyc_attributes_hash" 2086 ",kyc_attributes_serial_id" 2087 ") VALUES " 2088 "($1, $2, $3, $4, $5, $6, $7, $8);"); 2089 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 2090 "insert_records_by_table_into_table_aml_history", 2091 params); 2092 } 2093 2094 2095 /** 2096 * Function called with kyc_event records to insert into table. 2097 * 2098 * @param pg plugin context 2099 * @param td record to insert 2100 */ 2101 static enum GNUNET_DB_QueryStatus 2102 irbt_cb_table_kyc_events (struct TALER_EXCHANGEDB_PostgresContext *pg, 2103 const struct TALER_EXCHANGEDB_TableData *td) 2104 { 2105 struct GNUNET_PQ_QueryParam params[] = { 2106 GNUNET_PQ_query_param_uint64 (&td->serial), 2107 GNUNET_PQ_query_param_timestamp ( 2108 &td->details.kyc_events.event_timestamp), 2109 GNUNET_PQ_query_param_string ( 2110 td->details.kyc_events.event_type), 2111 GNUNET_PQ_query_param_end 2112 }; 2113 2114 PREPARE (pg, 2115 "insert_records_by_table_into_table_kyc_events", 2116 "INSERT INTO kyc_events" 2117 "(kyc_event_serial_id" 2118 ",event_timestamp" 2119 ",event_type" 2120 ") VALUES " 2121 "($1, $2, $3);"); 2122 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 2123 "insert_records_by_table_into_table_kyc_events", 2124 params); 2125 } 2126 2127 2128 /** 2129 * Function called with purse_deletion records to insert into table. 2130 * 2131 * @param pg plugin context 2132 * @param td record to insert 2133 */ 2134 static enum GNUNET_DB_QueryStatus 2135 irbt_cb_table_purse_deletion (struct TALER_EXCHANGEDB_PostgresContext *pg, 2136 const struct TALER_EXCHANGEDB_TableData *td) 2137 { 2138 struct GNUNET_PQ_QueryParam params[] = { 2139 GNUNET_PQ_query_param_uint64 (&td->serial), 2140 GNUNET_PQ_query_param_auto_from_type ( 2141 &td->details.purse_deletion.purse_pub), 2142 GNUNET_PQ_query_param_auto_from_type ( 2143 &td->details.purse_deletion.purse_sig), 2144 GNUNET_PQ_query_param_end 2145 }; 2146 2147 PREPARE (pg, 2148 "insert_records_by_table_into_table_purse_deletion", 2149 "INSERT INTO purse_deletion" 2150 "(purse_deletion_serial_id" 2151 ",purse_pub" 2152 ",purse_sig" 2153 ") VALUES " 2154 "($1, $2, $3);"); 2155 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 2156 "insert_records_by_table_into_table_purse_deletion", 2157 params); 2158 } 2159 2160 2161 /** 2162 * Function called with withdraw records to insert into table. 2163 * 2164 * @param pg plugin context 2165 * @param td record to insert 2166 */ 2167 static enum GNUNET_DB_QueryStatus 2168 irbt_cb_table_withdraw ( 2169 struct TALER_EXCHANGEDB_PostgresContext *pg, 2170 const struct TALER_EXCHANGEDB_TableData *td) 2171 { 2172 struct GNUNET_PQ_QueryParam params[] = { 2173 GNUNET_PQ_query_param_uint64 (&td->serial), 2174 GNUNET_PQ_query_param_auto_from_type ( 2175 &td->details.withdraw.planchets_h), 2176 GNUNET_PQ_query_param_timestamp ( 2177 &td->details.withdraw.execution_date), 2178 TALER_PQ_query_param_amount ( 2179 pg->conn, 2180 &td->details.withdraw.amount_with_fee), 2181 GNUNET_PQ_query_param_auto_from_type ( 2182 &td->details.withdraw.reserve_pub), 2183 GNUNET_PQ_query_param_auto_from_type ( 2184 &td->details.withdraw.reserve_sig), 2185 td->details.withdraw.age_proof_required 2186 ? GNUNET_PQ_query_param_uint16 ( 2187 &td->details.withdraw.max_age) 2188 : GNUNET_PQ_query_param_null (), 2189 td->details.withdraw.age_proof_required 2190 ? GNUNET_PQ_query_param_uint16 ( 2191 &td->details.withdraw.noreveal_index) 2192 : GNUNET_PQ_query_param_null (), 2193 td->details.withdraw.age_proof_required 2194 ? GNUNET_PQ_query_param_auto_from_type ( 2195 &td->details.withdraw.selected_h) 2196 : GNUNET_PQ_query_param_null (), 2197 td->details.withdraw.no_blinding_seed 2198 ? GNUNET_PQ_query_param_null () 2199 : GNUNET_PQ_query_param_auto_from_type ( 2200 &td->details.withdraw.blinding_seed), 2201 (0 < td->details.withdraw.num_cs_r_values) 2202 ? TALER_PQ_query_param_array_cs_r_pub ( 2203 td->details.withdraw.num_cs_r_values, 2204 td->details.withdraw.cs_r_values, 2205 pg->conn) 2206 : GNUNET_PQ_query_param_null (), 2207 (0 < td->details.withdraw.num_cs_r_values) 2208 ? GNUNET_PQ_query_param_uint64 ( 2209 &td->details.withdraw.cs_r_choices) 2210 : GNUNET_PQ_query_param_null (), 2211 GNUNET_PQ_query_param_array_uint64 ( 2212 td->details.withdraw.num_coins, 2213 td->details.withdraw.denom_serials, 2214 pg->conn), 2215 TALER_PQ_query_param_array_blinded_denom_sig ( 2216 td->details.withdraw.num_coins, 2217 td->details.withdraw.denom_sigs, 2218 pg->conn), 2219 GNUNET_PQ_query_param_end 2220 }; 2221 enum GNUNET_DB_QueryStatus qs; 2222 2223 PREPARE (pg, 2224 "insert_records_by_table_into_table_withdraw", 2225 "INSERT INTO withdraw" 2226 "(withdraw_id" 2227 ",planchets_h" 2228 ",execution_date" 2229 ",amount_with_fee" 2230 ",reserve_pub" 2231 ",reserve_sig" 2232 ",max_age" 2233 ",noreveal_index" 2234 ",selected_h" 2235 ",blinding_seed" 2236 ",cs_r_values" 2237 ",cs_r_choices" 2238 ",denom_serials" 2239 ",denom_sigs" 2240 ") VALUES " 2241 "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14);"); 2242 qs = GNUNET_PQ_eval_prepared_non_select (pg->conn, 2243 "insert_records_by_table_into_table_withdraw", 2244 params); 2245 GNUNET_PQ_cleanup_query_params_closures (params); 2246 return qs; 2247 } 2248 2249 2250 enum GNUNET_DB_QueryStatus 2251 TALER_EXCHANGEDB_insert_records_by_table ( 2252 struct TALER_EXCHANGEDB_PostgresContext *pg, 2253 const struct TALER_EXCHANGEDB_TableData *td) 2254 { 2255 InsertRecordCallback rh = NULL; 2256 2257 switch (td->table) 2258 { 2259 case TALER_EXCHANGEDB_RT_DENOMINATIONS: 2260 rh = &irbt_cb_table_denominations; 2261 break; 2262 case TALER_EXCHANGEDB_RT_DENOMINATION_REVOCATIONS: 2263 rh = &irbt_cb_table_denomination_revocations; 2264 break; 2265 case TALER_EXCHANGEDB_RT_WIRE_TARGETS: 2266 rh = &irbt_cb_table_wire_targets; 2267 break; 2268 case TALER_EXCHANGEDB_RT_KYC_TARGETS: 2269 rh = &irbt_cb_table_kyc_targets; 2270 break; 2271 case TALER_EXCHANGEDB_RT_RESERVES: 2272 rh = &irbt_cb_table_reserves; 2273 break; 2274 case TALER_EXCHANGEDB_RT_RESERVES_IN: 2275 rh = &irbt_cb_table_reserves_in; 2276 break; 2277 case TALER_EXCHANGEDB_RT_KYCAUTHS_IN: 2278 rh = &irbt_cb_table_kycauths_in; 2279 break; 2280 case TALER_EXCHANGEDB_RT_RESERVES_CLOSE: 2281 rh = &irbt_cb_table_reserves_close; 2282 break; 2283 case TALER_EXCHANGEDB_RT_RESERVES_OPEN_REQUESTS: 2284 rh = &irbt_cb_table_reserves_open_requests; 2285 break; 2286 case TALER_EXCHANGEDB_RT_RESERVES_OPEN_DEPOSITS: 2287 rh = &irbt_cb_table_reserves_open_deposits; 2288 break; 2289 case TALER_EXCHANGEDB_RT_AUDITORS: 2290 rh = &irbt_cb_table_auditors; 2291 break; 2292 case TALER_EXCHANGEDB_RT_AUDITOR_DENOM_SIGS: 2293 rh = &irbt_cb_table_auditor_denom_sigs; 2294 break; 2295 case TALER_EXCHANGEDB_RT_EXCHANGE_SIGN_KEYS: 2296 rh = &irbt_cb_table_exchange_sign_keys; 2297 break; 2298 case TALER_EXCHANGEDB_RT_SIGNKEY_REVOCATIONS: 2299 rh = &irbt_cb_table_signkey_revocations; 2300 break; 2301 case TALER_EXCHANGEDB_RT_KNOWN_COINS: 2302 rh = &irbt_cb_table_known_coins; 2303 break; 2304 case TALER_EXCHANGEDB_RT_REFRESH: 2305 rh = &irbt_cb_table_refresh; 2306 break; 2307 case TALER_EXCHANGEDB_RT_BATCH_DEPOSITS: 2308 rh = &irbt_cb_table_batch_deposits; 2309 break; 2310 case TALER_EXCHANGEDB_RT_COIN_DEPOSITS: 2311 rh = &irbt_cb_table_coin_deposits; 2312 break; 2313 case TALER_EXCHANGEDB_RT_REFUNDS: 2314 rh = &irbt_cb_table_refunds; 2315 break; 2316 case TALER_EXCHANGEDB_RT_WIRE_OUT: 2317 rh = &irbt_cb_table_wire_out; 2318 break; 2319 case TALER_EXCHANGEDB_RT_AGGREGATION_TRACKING: 2320 rh = &irbt_cb_table_aggregation_tracking; 2321 break; 2322 case TALER_EXCHANGEDB_RT_AGGREGATION_DEFERRALS: 2323 rh = &irbt_cb_table_aggregation_deferrals; 2324 break; 2325 case TALER_EXCHANGEDB_RT_WIRE_FEE: 2326 rh = &irbt_cb_table_wire_fee; 2327 break; 2328 case TALER_EXCHANGEDB_RT_GLOBAL_FEE: 2329 rh = &irbt_cb_table_global_fee; 2330 break; 2331 case TALER_EXCHANGEDB_RT_RECOUP: 2332 rh = &irbt_cb_table_recoup; 2333 break; 2334 case TALER_EXCHANGEDB_RT_RECOUP_REFRESH: 2335 rh = &irbt_cb_table_recoup_refresh; 2336 break; 2337 case TALER_EXCHANGEDB_RT_PURSE_REQUESTS: 2338 rh = &irbt_cb_table_purse_requests; 2339 break; 2340 case TALER_EXCHANGEDB_RT_PURSE_DECISION: 2341 rh = &irbt_cb_table_purse_decision; 2342 break; 2343 case TALER_EXCHANGEDB_RT_PURSE_MERGES: 2344 rh = &irbt_cb_table_purse_merges; 2345 break; 2346 case TALER_EXCHANGEDB_RT_PURSE_DEPOSITS: 2347 rh = &irbt_cb_table_purse_deposits; 2348 break; 2349 case TALER_EXCHANGEDB_RT_ACCOUNT_MERGES: 2350 rh = &irbt_cb_table_account_mergers; 2351 break; 2352 case TALER_EXCHANGEDB_RT_HISTORY_REQUESTS: 2353 rh = &irbt_cb_table_history_requests; 2354 break; 2355 case TALER_EXCHANGEDB_RT_CLOSE_REQUESTS: 2356 rh = &irbt_cb_table_close_requests; 2357 break; 2358 case TALER_EXCHANGEDB_RT_WADS_OUT: 2359 rh = &irbt_cb_table_wads_out; 2360 break; 2361 case TALER_EXCHANGEDB_RT_WADS_OUT_ENTRIES: 2362 rh = &irbt_cb_table_wads_out_entries; 2363 break; 2364 case TALER_EXCHANGEDB_RT_WADS_IN: 2365 rh = &irbt_cb_table_wads_in; 2366 break; 2367 case TALER_EXCHANGEDB_RT_WADS_IN_ENTRIES: 2368 rh = &irbt_cb_table_wads_in_entries; 2369 break; 2370 case TALER_EXCHANGEDB_RT_PROFIT_DRAINS: 2371 rh = &irbt_cb_table_profit_drains; 2372 break; 2373 case TALER_EXCHANGEDB_RT_AML_STAFF: 2374 rh = &irbt_cb_table_aml_staff; 2375 break; 2376 case TALER_EXCHANGEDB_RT_PURSE_DELETION: 2377 rh = &irbt_cb_table_purse_deletion; 2378 break; 2379 case TALER_EXCHANGEDB_RT_WITHDRAW: 2380 rh = &irbt_cb_table_withdraw; 2381 break; 2382 case TALER_EXCHANGEDB_RT_LEGITIMIZATION_MEASURES: 2383 rh = &irbt_cb_table_legitimization_measures; 2384 break; 2385 case TALER_EXCHANGEDB_RT_LEGITIMIZATION_OUTCOMES: 2386 rh = &irbt_cb_table_legitimization_outcomes; 2387 break; 2388 case TALER_EXCHANGEDB_RT_LEGITIMIZATION_PROCESSES: 2389 rh = &irbt_cb_table_legitimization_processes; 2390 break; 2391 case TALER_EXCHANGEDB_RT_KYC_ATTRIBUTES: 2392 rh = &irbt_cb_table_kyc_attributes; 2393 break; 2394 case TALER_EXCHANGEDB_RT_AML_HISTORY: 2395 rh = &irbt_cb_table_aml_history; 2396 break; 2397 case TALER_EXCHANGEDB_RT_KYC_EVENTS: 2398 rh = &irbt_cb_table_kyc_events; 2399 break; 2400 } 2401 if (NULL == rh) 2402 { 2403 GNUNET_break (0); 2404 return GNUNET_DB_STATUS_HARD_ERROR; 2405 } 2406 return rh (pg, 2407 td); 2408 } 2409 2410 2411 /* end of insert_records_by_table.c */