|
@ -21,13 +21,29 @@ void towire_tlvstream_raw(u8 **pptr, const struct tlv_field *fields) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static struct tlv_field *tlvstream_get_raw(struct tlv_field *stream, u64 type) |
|
|
|
|
|
{ |
|
|
|
|
|
for (size_t i=0; i<tal_count(stream); i++) |
|
|
|
|
|
if (stream[i].numtype == type) |
|
|
|
|
|
return &stream[i]; |
|
|
|
|
|
return NULL; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void tlvstream_set_raw(struct tlv_field **stream, u64 type, void *value, size_t valuelen) |
|
|
void tlvstream_set_raw(struct tlv_field **stream, u64 type, void *value, size_t valuelen) |
|
|
{ |
|
|
{ |
|
|
struct tlv_field f; |
|
|
struct tlv_field f, *e = tlvstream_get_raw(*stream, type); |
|
|
|
|
|
|
|
|
|
|
|
if (e != NULL) { |
|
|
|
|
|
tal_free(e->value); |
|
|
|
|
|
e->length = valuelen; |
|
|
|
|
|
e->value = tal_dup_arr(*stream, u8, value, e->length, 0); |
|
|
|
|
|
} else { |
|
|
|
|
|
/* If we haven't found it insert it insead. */ |
|
|
f.length = valuelen; |
|
|
f.length = valuelen; |
|
|
f.numtype = type; |
|
|
f.numtype = type; |
|
|
f.value = tal_dup_arr(*stream, u8, value, f.length, 0); |
|
|
f.value = tal_dup_arr(*stream, u8, value, f.length, 0); |
|
|
tal_arr_expand(stream, f); |
|
|
tal_arr_expand(stream, f); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void tlvstream_set_short_channel_id(struct tlv_field **stream, u64 type, |
|
|
void tlvstream_set_short_channel_id(struct tlv_field **stream, u64 type, |
|
@ -52,15 +68,6 @@ void tlvstream_set_tu32(struct tlv_field **stream, u64 type, u32 value) |
|
|
tlvstream_set_raw(stream, type, ser, tal_bytelen(ser)); |
|
|
tlvstream_set_raw(stream, type, ser, tal_bytelen(ser)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static struct tlv_field *tlvstream_get_raw(struct tlv_field *stream, u64 type) |
|
|
|
|
|
{ |
|
|
|
|
|
for (size_t i=0; i<tal_count(stream); i++) |
|
|
|
|
|
if (stream[i].numtype == type) |
|
|
|
|
|
return &stream[i]; |
|
|
|
|
|
return NULL; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool tlvstream_get_short_channel_id(struct tlv_field *stream, u64 type, |
|
|
bool tlvstream_get_short_channel_id(struct tlv_field *stream, u64 type, |
|
|
struct short_channel_id *value) |
|
|
struct short_channel_id *value) |
|
|
{ |
|
|
{ |
|
|