| 43 | } |
| 44 | |
| 45 | struct existing_htlc *new_existing_htlc(const tal_t *ctx, |
| 46 | u64 id, |
| 47 | enum htlc_state state, |
| 48 | struct amount_msat amount, |
| 49 | const struct sha256 *payment_hash, |
| 50 | u32 cltv_expiry, |
| 51 | const u8 onion_routing_packet[TOTAL_PACKET_SIZE(ROUTING_INFO_SIZE)], |
| 52 | const struct pubkey *path_key TAKES, |
| 53 | const struct preimage *preimage TAKES, |
| 54 | const struct failed_htlc *failed TAKES, |
| 55 | const struct tlv_field *extra_tlvs TAKES) |
| 56 | { |
| 57 | struct existing_htlc *existing = tal(ctx, struct existing_htlc); |
| 58 | |
| 59 | existing->id = id; |
| 60 | existing->state = state; |
| 61 | existing->amount = amount; |
| 62 | existing->cltv_expiry = cltv_expiry; |
| 63 | existing->payment_hash = *payment_hash; |
| 64 | memcpy(existing->onion_routing_packet, onion_routing_packet, |
| 65 | sizeof(existing->onion_routing_packet)); |
| 66 | existing->path_key = tal_dup_or_null(existing, struct pubkey, path_key); |
| 67 | existing->payment_preimage |
| 68 | = tal_dup_or_null(existing, struct preimage, preimage); |
| 69 | if (failed) |
| 70 | existing->failed = failed_htlc_dup(existing, failed); |
| 71 | else |
| 72 | existing->failed = NULL; |
| 73 | if (extra_tlvs) |
| 74 | existing->extra_tlvs = tlv_field_arr_dup(existing, extra_tlvs); |
| 75 | else |
| 76 | existing->extra_tlvs = NULL; |
| 77 | |
| 78 | return existing; |
| 79 | } |
| 80 | |
| 81 | static void towire_len_and_tlvstream(u8 **pptr, struct tlv_field *extra_tlvs) |
| 82 | { |
no test coverage detected