| 39 | } |
| 40 | |
| 41 | struct existing_htlc *new_existing_htlc(const tal_t *ctx, |
| 42 | u64 id, |
| 43 | enum htlc_state state, |
| 44 | struct amount_msat amount, |
| 45 | const struct sha256 *payment_hash, |
| 46 | u32 cltv_expiry, |
| 47 | const u8 onion_routing_packet[TOTAL_PACKET_SIZE(ROUTING_INFO_SIZE)], |
| 48 | const struct pubkey *blinding TAKES, |
| 49 | const struct preimage *preimage TAKES, |
| 50 | const struct failed_htlc *failed TAKES) |
| 51 | { |
| 52 | struct existing_htlc *existing = tal(ctx, struct existing_htlc); |
| 53 | |
| 54 | existing->id = id; |
| 55 | existing->state = state; |
| 56 | existing->amount = amount; |
| 57 | existing->cltv_expiry = cltv_expiry; |
| 58 | existing->payment_hash = *payment_hash; |
| 59 | memcpy(existing->onion_routing_packet, onion_routing_packet, |
| 60 | sizeof(existing->onion_routing_packet)); |
| 61 | existing->blinding = tal_dup_or_null(existing, struct pubkey, blinding); |
| 62 | existing->payment_preimage |
| 63 | = tal_dup_or_null(existing, struct preimage, preimage); |
| 64 | if (failed) |
| 65 | existing->failed = failed_htlc_dup(existing, failed); |
| 66 | else |
| 67 | existing->failed = NULL; |
| 68 | |
| 69 | return existing; |
| 70 | } |
| 71 | |
| 72 | /* FIXME: We could adapt tools/generate-wire.py to generate structures |
| 73 | * and code like this. */ |
no test coverage detected