|
3 | 3 | #include <ccan/crypto/siphash24/siphash24.h> |
4 | 4 | #include <ccan/tal/str/str.h> |
5 | 5 | #include <common/htlc.h> |
| 6 | +#include <common/htlc_wire.h> |
6 | 7 | #include <common/pseudorand.h> |
7 | 8 | #include <lightningd/htlc_end.h> |
8 | 9 | #include <lightningd/log.h> |
@@ -148,15 +149,10 @@ struct htlc_in *new_htlc_in(const tal_t *ctx, |
148 | 149 | hin->path_key = tal_dup_or_null(hin, struct pubkey, path_key); |
149 | 150 | memcpy(hin->onion_routing_packet, onion_routing_packet, |
150 | 151 | sizeof(hin->onion_routing_packet)); |
151 | | - if (extra_tlvs) { |
152 | | - hin->extra_tlvs = tal_dup_talarr(hin, struct tlv_field, extra_tlvs); |
153 | | - for (size_t i = 0; i < tal_count(extra_tlvs); i++) { |
154 | | - /* We need to attach the value to the correct parent */ |
155 | | - hin->extra_tlvs[i].value = tal_dup_talarr(hin, u8, hin->extra_tlvs[i].value); |
156 | | - } |
157 | | - } else { |
| 152 | + if (extra_tlvs) |
| 153 | + hin->extra_tlvs = tlv_field_arr_dup(hin, extra_tlvs); |
| 154 | + else |
158 | 155 | hin->extra_tlvs = NULL; |
159 | | - } |
160 | 156 |
|
161 | 157 | hin->hstate = RCVD_ADD_COMMIT; |
162 | 158 | hin->badonion = 0; |
@@ -304,15 +300,10 @@ struct htlc_out *new_htlc_out(const tal_t *ctx, |
304 | 300 |
|
305 | 301 | hout->path_key = tal_dup_or_null(hout, struct pubkey, path_key); |
306 | 302 |
|
307 | | - if (extra_tlvs) { |
308 | | - hout->extra_tlvs = tal_dup_talarr(hout, struct tlv_field, extra_tlvs); |
309 | | - for (size_t i = 0; i < tal_count(extra_tlvs); i++) { |
310 | | - /* We need to attach the value to the correct parent */ |
311 | | - hout->extra_tlvs[i].value = tal_dup_talarr(hout, u8, hout->extra_tlvs[i].value); |
312 | | - } |
313 | | - } else { |
| 303 | + if (extra_tlvs) |
| 304 | + hout->extra_tlvs = tlv_field_arr_dup(hout, extra_tlvs); |
| 305 | + else |
314 | 306 | hout->extra_tlvs = NULL; |
315 | | - } |
316 | 307 |
|
317 | 308 | hout->am_origin = am_origin; |
318 | 309 | if (am_origin) { |
|
0 commit comments