| 2575 | } |
| 2576 | |
| 2577 | static bool wallet_stmt2htlc_in(struct channel *channel, |
| 2578 | struct db_stmt *stmt, struct htlc_in *in) |
| 2579 | { |
| 2580 | bool ok = true; |
| 2581 | in->dbid = db_col_u64(stmt, "id"); |
| 2582 | in->key.id = db_col_u64(stmt, "channel_htlc_id"); |
| 2583 | in->key.channel = channel; |
| 2584 | db_col_amount_msat(stmt, "msatoshi", &in->msat); |
| 2585 | in->cltv_expiry = db_col_int(stmt, "cltv_expiry"); |
| 2586 | in->hstate = db_col_int(stmt, "hstate"); |
| 2587 | in->status = NULL; |
| 2588 | /* FIXME: save blinding in db !*/ |
| 2589 | in->blinding = NULL; |
| 2590 | in->payload = NULL; |
| 2591 | |
| 2592 | db_col_sha256(stmt, "payment_hash", &in->payment_hash); |
| 2593 | |
| 2594 | if (!db_col_is_null(stmt, "payment_key")) { |
| 2595 | in->preimage = tal(in, struct preimage); |
| 2596 | db_col_preimage(stmt, "payment_key", in->preimage); |
| 2597 | } else { |
| 2598 | in->preimage = NULL; |
| 2599 | } |
| 2600 | |
| 2601 | assert(db_col_bytes(stmt, "routing_onion") |
| 2602 | == sizeof(in->onion_routing_packet)); |
| 2603 | memcpy(&in->onion_routing_packet, db_col_blob(stmt, "routing_onion"), |
| 2604 | sizeof(in->onion_routing_packet)); |
| 2605 | |
| 2606 | if (db_col_is_null(stmt, "failuremsg")) |
| 2607 | in->failonion = NULL; |
| 2608 | else |
| 2609 | in->failonion = db_col_onionreply(in, stmt, "failuremsg"); |
| 2610 | in->badonion = db_col_int(stmt, "malformed_onion"); |
| 2611 | if (db_col_is_null(stmt, "shared_secret")) { |
| 2612 | in->shared_secret = NULL; |
| 2613 | } else { |
| 2614 | assert(db_col_bytes(stmt, "shared_secret") == sizeof(struct secret)); |
| 2615 | in->shared_secret = tal(in, struct secret); |
| 2616 | memcpy(in->shared_secret, db_col_blob(stmt, "shared_secret"), |
| 2617 | sizeof(struct secret)); |
| 2618 | #ifdef COMPAT_V062 |
| 2619 | if (memeqzero(in->shared_secret, sizeof(*in->shared_secret))) |
| 2620 | in->shared_secret = tal_free(in->shared_secret); |
| 2621 | #endif |
| 2622 | } |
| 2623 | |
| 2624 | #ifdef COMPAT_V072 |
| 2625 | if (db_col_is_null(stmt, "received_time")) { |
| 2626 | in->received_time.ts.tv_sec = 0; |
| 2627 | in->received_time.ts.tv_nsec = 0; |
| 2628 | } else |
| 2629 | #endif /* COMPAT_V072 */ |
| 2630 | in->received_time = db_col_timeabs(stmt, "received_time"); |
| 2631 | |
| 2632 | #ifdef COMPAT_V080 |
| 2633 | /* This field is now reserved for badonion codes: the rest should |
| 2634 | * use the failonion field. */ |
no test coverage detected