mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-01 17:47:30 +01:00
tlv: Migrate tlv serialization to typesafe function
This commit is contained in:
parent
e12b5c3824
commit
626675c83c
4 changed files with 4 additions and 10 deletions
|
@ -144,7 +144,7 @@ static void sphinx_add_tlv_hop(struct sphinx_path *path,
|
||||||
const struct tlv_tlv_payload *tlv)
|
const struct tlv_tlv_payload *tlv)
|
||||||
{
|
{
|
||||||
u8 *tlvs = tal_arr(path, u8, 0);
|
u8 *tlvs = tal_arr(path, u8, 0);
|
||||||
towire_tlvs(&tlvs, tlvs_tlv_payload, TLVS_TLV_PAYLOAD_ARRAY_SIZE, tlv);
|
towire_tlv_payload(&tlvs, tlv);
|
||||||
sphinx_add_raw_hop(path, pubkey, SPHINX_TLV_PAYLOAD, tlvs);
|
sphinx_add_raw_hop(path, pubkey, SPHINX_TLV_PAYLOAD, tlvs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,12 +43,6 @@ size_t bigsize_get(const u8 *p UNNEEDED, size_t max UNNEEDED, bigsize_t *val UNN
|
||||||
/* Generated stub for bigsize_put */
|
/* Generated stub for bigsize_put */
|
||||||
size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED)
|
size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED)
|
||||||
{ fprintf(stderr, "bigsize_put called!\n"); abort(); }
|
{ fprintf(stderr, "bigsize_put called!\n"); abort(); }
|
||||||
/* Generated stub for towire_tlvs */
|
|
||||||
void towire_tlvs(u8 **pptr UNNEEDED,
|
|
||||||
const struct tlv_record_type types[] UNNEEDED,
|
|
||||||
size_t num_types UNNEEDED,
|
|
||||||
const void *record UNNEEDED)
|
|
||||||
{ fprintf(stderr, "towire_tlvs called!\n"); abort(); }
|
|
||||||
/* AUTOGENERATED MOCKS END */
|
/* AUTOGENERATED MOCKS END */
|
||||||
|
|
||||||
secp256k1_context *secp256k1_ctx;
|
secp256k1_context *secp256k1_ctx;
|
||||||
|
|
|
@ -409,7 +409,7 @@ u8 *towire_${msg.name}(const tal_t *ctx${''.join([f.arg_desc_to() for f in msg.f
|
||||||
% endif
|
% endif
|
||||||
% endif
|
% endif
|
||||||
% elif f.type_obj.is_tlv():
|
% elif f.type_obj.is_tlv():
|
||||||
towire_tlvs(&p, tlvs_${f.type_obj.tlv.name}, ARRAY_SIZE(tlvs_${f.type_obj.tlv.name}), ${f.name});
|
towire_${f.type_obj.tlv.name}(&p, ${f.name});
|
||||||
% elif f.is_optional: ## is optional?
|
% elif f.is_optional: ## is optional?
|
||||||
if (!${f.name})
|
if (!${f.name})
|
||||||
towire_bool(&p, false);
|
towire_bool(&p, false);
|
||||||
|
|
|
@ -524,7 +524,7 @@ int main(void)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
p2 = tal_arr(tmpctx, u8, 0);
|
p2 = tal_arr(tmpctx, u8, 0);
|
||||||
towire_tlvs(&p2, tlvs_n1, TLVS_N1_ARRAY_SIZE, tlv_n1);
|
towire_n1(&p2, tlv_n1);
|
||||||
assert(memeq(p2, tal_count(p2), orig_p, tal_count(orig_p)));
|
assert(memeq(p2, tal_count(p2), orig_p, tal_count(orig_p)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -620,7 +620,7 @@ int main(void)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
u8 *p2 = tal_arr(tmpctx, u8, 0);
|
u8 *p2 = tal_arr(tmpctx, u8, 0);
|
||||||
towire_tlvs(&p2, tlvs_n1, TLVS_N1_ARRAY_SIZE, tlv_n1);
|
towire_n1(&p2, tlv_n1);
|
||||||
assert(memeq(orig_p, tal_count(orig_p),
|
assert(memeq(orig_p, tal_count(orig_p),
|
||||||
p2, tal_count(p2)));
|
p2, tal_count(p2)));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue