Removes matching htlc from unconnected_htlcs_in */
| 2657 | |
| 2658 | /* Removes matching htlc from unconnected_htlcs_in */ |
| 2659 | static bool wallet_stmt2htlc_out(struct wallet *wallet, |
| 2660 | struct channel *channel, |
| 2661 | struct db_stmt *stmt, struct htlc_out *out, |
| 2662 | struct htlc_in_map *unconnected_htlcs_in) |
| 2663 | { |
| 2664 | bool ok = true; |
| 2665 | out->dbid = db_col_u64(stmt, "id"); |
| 2666 | out->key.id = db_col_u64(stmt, "channel_htlc_id"); |
| 2667 | out->key.channel = channel; |
| 2668 | db_col_amount_msat(stmt, "msatoshi", &out->msat); |
| 2669 | out->cltv_expiry = db_col_int(stmt, "cltv_expiry"); |
| 2670 | out->hstate = db_col_int(stmt, "hstate"); |
| 2671 | db_col_sha256(stmt, "payment_hash", &out->payment_hash); |
| 2672 | /* FIXME: save blinding in db !*/ |
| 2673 | out->blinding = NULL; |
| 2674 | |
| 2675 | if (!db_col_is_null(stmt, "payment_key")) { |
| 2676 | out->preimage = tal(out, struct preimage); |
| 2677 | db_col_preimage(stmt, "payment_key", out->preimage); |
| 2678 | } else { |
| 2679 | out->preimage = NULL; |
| 2680 | } |
| 2681 | |
| 2682 | assert(db_col_bytes(stmt, "routing_onion") |
| 2683 | == sizeof(out->onion_routing_packet)); |
| 2684 | memcpy(&out->onion_routing_packet, db_col_blob(stmt, "routing_onion"), |
| 2685 | sizeof(out->onion_routing_packet)); |
| 2686 | |
| 2687 | if (db_col_is_null(stmt, "failuremsg")) |
| 2688 | out->failonion = NULL; |
| 2689 | else |
| 2690 | out->failonion = db_col_onionreply(out, stmt, "failuremsg"); |
| 2691 | |
| 2692 | if (db_col_is_null(stmt, "localfailmsg")) |
| 2693 | out->failmsg = NULL; |
| 2694 | else |
| 2695 | out->failmsg = db_col_arr(out, stmt, "localfailmsg", u8); |
| 2696 | |
| 2697 | out->in = NULL; |
| 2698 | db_col_amount_msat(stmt, "fees_msat", &out->fees); |
| 2699 | |
| 2700 | if (!db_col_is_null(stmt, "origin_htlc")) { |
| 2701 | u64 in_id = db_col_u64(stmt, "origin_htlc"); |
| 2702 | struct htlc_in *hin; |
| 2703 | |
| 2704 | /* If it failed / succeeded already, we could have |
| 2705 | * closed incoming htlc */ |
| 2706 | hin = remove_htlc_in_by_dbid(unconnected_htlcs_in, in_id); |
| 2707 | if (hin) |
| 2708 | htlc_out_connect_htlc_in(out, hin); |
| 2709 | out->am_origin = false; |
| 2710 | db_col_ignore(stmt, "partid"); |
| 2711 | db_col_ignore(stmt, "groupid"); |
| 2712 | } else { |
| 2713 | out->partid = db_col_u64(stmt, "partid"); |
| 2714 | out->groupid = db_col_u64(stmt, "groupid"); |
| 2715 | out->am_origin = true; |
| 2716 | } |
no test coverage detected