You need to set the ID, then connect_htlc_out this! */
| 264 | |
| 265 | /* You need to set the ID, then connect_htlc_out this! */ |
| 266 | struct htlc_out *new_htlc_out(const tal_t *ctx, |
| 267 | struct channel *channel, |
| 268 | struct amount_msat msat, |
| 269 | u32 cltv_expiry, |
| 270 | const struct sha256 *payment_hash, |
| 271 | const u8 *onion_routing_packet, |
| 272 | const struct pubkey *path_key, |
| 273 | const struct tlv_field* extra_tlvs, |
| 274 | bool am_origin, |
| 275 | struct amount_msat final_msat, |
| 276 | u64 partid, |
| 277 | u64 groupid, |
| 278 | struct htlc_in *in) |
| 279 | { |
| 280 | struct htlc_out *hout = tal(ctx, struct htlc_out); |
| 281 | |
| 282 | /* Mark this as an as of now unsaved HTLC */ |
| 283 | hout->dbid = 0; |
| 284 | |
| 285 | hout->key.channel = channel; |
| 286 | hout->key.id = HTLC_INVALID_ID; |
| 287 | hout->msat = msat; |
| 288 | hout->cltv_expiry = cltv_expiry; |
| 289 | hout->payment_hash = *payment_hash; |
| 290 | memcpy(hout->onion_routing_packet, onion_routing_packet, |
| 291 | sizeof(hout->onion_routing_packet)); |
| 292 | |
| 293 | hout->hstate = SENT_ADD_HTLC; |
| 294 | hout->failmsg = NULL; |
| 295 | hout->failonion = NULL; |
| 296 | hout->preimage = NULL; |
| 297 | hout->timeout = NULL; |
| 298 | |
| 299 | hout->path_key = tal_dup_or_null(hout, struct pubkey, path_key); |
| 300 | |
| 301 | if (extra_tlvs) |
| 302 | hout->extra_tlvs = tlv_field_arr_dup(hout, extra_tlvs); |
| 303 | else |
| 304 | hout->extra_tlvs = NULL; |
| 305 | |
| 306 | hout->am_origin = am_origin; |
| 307 | if (am_origin) { |
| 308 | hout->partid = partid; |
| 309 | hout->groupid = groupid; |
| 310 | |
| 311 | /* Stash the fees (for accounting) */ |
| 312 | if (!amount_msat_sub(&hout->fees, msat, final_msat)) |
| 313 | return corrupt("new_htlc_out", |
| 314 | "overflow subtract %s-%s", |
| 315 | fmt_amount_msat(tmpctx, msat), |
| 316 | fmt_amount_msat(tmpctx, final_msat)); |
| 317 | |
| 318 | } |
| 319 | hout->in = NULL; |
| 320 | if (in) { |
| 321 | htlc_out_connect_htlc_in(hout, in); |
| 322 | |
| 323 | /* Stash the fees (for accounting) */ |
no test coverage detected