tools/generate_wire.py: tlvs should start with tlv_

No more "towire_offer", but "towire_tlv_offer".

This means we double-up on the unfortunately-named `tlv_payload` inside
the onion, but we should rename that in the spec when we remove
old payloads.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2022-03-23 10:01:14 +10:30
parent f447e39d2d
commit fa0c29f959
22 changed files with 114 additions and 114 deletions

View File

@ -122,7 +122,7 @@ static u8 *enctlv_from_encmsg(const tal_t *ctx,
struct pubkey *node_alias)
{
u8 *encmsg_raw = tal_arr(NULL, u8, 0);
towire_encrypted_data_tlv(&encmsg_raw, encmsg);
towire_tlv_encrypted_data_tlv(&encmsg_raw, encmsg);
return enctlv_from_encmsg_raw(ctx, blinding, node, take(encmsg_raw),
next_blinding, node_alias);
}
@ -198,7 +198,7 @@ static struct tlv_encrypted_data_tlv *decrypt_encmsg(const tal_t *ctx,
* - MUST drop the message.
*/
encmsg = tlv_encrypted_data_tlv_new(ctx);
if (!fromwire_encrypted_data_tlv(&cursor, &maxlen, encmsg)
if (!fromwire_tlv_encrypted_data_tlv(&cursor, &maxlen, encmsg)
|| !tlv_fields_valid(encmsg->fields, NULL, NULL))
return tal_free(encmsg);

View File

@ -155,7 +155,7 @@ char *offer_encode(const tal_t *ctx, const struct tlv_offer *offer_tlv)
u8 *wire;
wire = tal_arr(tmpctx, u8, 0);
towire_offer(&wire, offer_tlv);
towire_tlv_offer(&wire, offer_tlv);
return to_bech32_charset(ctx, "lno", wire);
}
@ -174,7 +174,7 @@ struct tlv_offer *offer_decode(const tal_t *ctx,
if (!data)
return tal_free(offer);
if (!fromwire_offer(&data, &dlen, offer)) {
if (!fromwire_tlv_offer(&data, &dlen, offer)) {
*fail = tal_fmt(ctx, "invalid offer data");
return tal_free(offer);
}
@ -208,7 +208,7 @@ char *invrequest_encode(const tal_t *ctx, const struct tlv_invoice_request *invr
u8 *wire;
wire = tal_arr(tmpctx, u8, 0);
towire_invoice_request(&wire, invrequest_tlv);
towire_tlv_invoice_request(&wire, invrequest_tlv);
return to_bech32_charset(ctx, "lnr", wire);
}
@ -227,7 +227,7 @@ struct tlv_invoice_request *invrequest_decode(const tal_t *ctx,
if (!data)
return tal_free(invrequest);
if (!fromwire_invoice_request(&data, &dlen, invrequest)) {
if (!fromwire_tlv_invoice_request(&data, &dlen, invrequest)) {
*fail = tal_fmt(ctx, "invalid invoice_request data");
return tal_free(invrequest);
}
@ -247,7 +247,7 @@ char *invoice_encode(const tal_t *ctx, const struct tlv_invoice *invoice_tlv)
u8 *wire;
wire = tal_arr(tmpctx, u8, 0);
towire_invoice(&wire, invoice_tlv);
towire_tlv_invoice(&wire, invoice_tlv);
return to_bech32_charset(ctx, "lni", wire);
}
@ -266,7 +266,7 @@ struct tlv_invoice *invoice_decode_nosig(const tal_t *ctx,
if (!data)
return tal_free(invoice);
if (!fromwire_invoice(&data, &dlen, invoice)) {
if (!fromwire_tlv_invoice(&data, &dlen, invoice)) {
*fail = tal_fmt(ctx, "invalid invoice data");
return tal_free(invoice);
}

View File

@ -22,7 +22,7 @@ static u8 *make_tlv_hop(const tal_t *ctx,
/* We can't have over 64k anyway */
u8 *tlvs = tal_arr(ctx, u8, 3);
towire_tlv_payload(&tlvs, tlv);
towire_tlv_tlv_payload(&tlvs, tlv);
switch (bigsize_put(tlvs, tal_bytelen(tlvs) - 3)) {
case 1:
@ -195,7 +195,7 @@ static struct tlv_tlv_payload *decrypt_tlv(const tal_t *ctx,
tlv = tlv_tlv_payload_new(ctx);
cursor = dec;
max = tal_bytelen(dec);
if (!fromwire_tlv_payload(&cursor, &max, tlv))
if (!fromwire_tlv_tlv_payload(&cursor, &max, tlv))
return tal_free(tlv);
return tlv;
@ -220,7 +220,7 @@ struct onion_payload *onion_decode(const tal_t *ctx,
goto general_fail;
tlv = tlv_tlv_payload_new(p);
if (!fromwire_tlv_payload(&cursor, &max, tlv)) {
if (!fromwire_tlv_tlv_payload(&cursor, &max, tlv)) {
/* FIXME: Fill in correct thing here! */
goto general_fail;
}

View File

@ -133,7 +133,7 @@ static u8 *next_onion(const tal_t *ctx, u8 *omsg,
max = tal_bytelen(rs->raw_payload);
maxlen = fromwire_bigsize(&cursor, &max);
om = tlv_onionmsg_payload_new(tmpctx);
assert(fromwire_onionmsg_payload(&cursor, &maxlen, om));
assert(fromwire_tlv_onionmsg_payload(&cursor, &maxlen, om));
if (rs->nextcase == ONION_END)
return NULL;
@ -204,7 +204,7 @@ int main(int argc, char *argv[])
= tlv_onionmsg_payload_new(tmpctx);
payload->encrypted_data_tlv = enctlv[i];
onionmsg_payload[i] = tal_arr(tmpctx, u8, 0);
towire_onionmsg_payload(&onionmsg_payload[i], payload);
towire_tlv_onionmsg_payload(&onionmsg_payload[i], payload);
sphinx_add_modern_hop(sphinx_path, &alias[i],
onionmsg_payload[i]);
}

View File

@ -56,18 +56,6 @@ bool fromwire_bool(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
/* Generated stub for fromwire_fail */
void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
{ fprintf(stderr, "fromwire_fail called!\n"); abort(); }
/* Generated stub for fromwire_invoice */
bool fromwire_invoice(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct tlv_invoice * record UNNEEDED)
{ fprintf(stderr, "fromwire_invoice called!\n"); abort(); }
/* Generated stub for fromwire_invoice_request */
bool fromwire_invoice_request(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct tlv_invoice_request * record UNNEEDED)
{ fprintf(stderr, "fromwire_invoice_request called!\n"); abort(); }
/* Generated stub for fromwire_offer */
bool fromwire_offer(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct tlv_offer * record UNNEEDED)
{ fprintf(stderr, "fromwire_offer called!\n"); abort(); }
/* Generated stub for fromwire_secp256k1_ecdsa_signature */
void fromwire_secp256k1_ecdsa_signature(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
secp256k1_ecdsa_signature *signature UNNEEDED)
@ -79,6 +67,18 @@ void fromwire_sha256(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct sh
u8 *fromwire_tal_arrn(const tal_t *ctx UNNEEDED,
const u8 **cursor UNNEEDED, size_t *max UNNEEDED, size_t num UNNEEDED)
{ fprintf(stderr, "fromwire_tal_arrn called!\n"); abort(); }
/* Generated stub for fromwire_tlv_invoice */
bool fromwire_tlv_invoice(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct tlv_invoice * record UNNEEDED)
{ fprintf(stderr, "fromwire_tlv_invoice called!\n"); abort(); }
/* Generated stub for fromwire_tlv_invoice_request */
bool fromwire_tlv_invoice_request(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct tlv_invoice_request * record UNNEEDED)
{ fprintf(stderr, "fromwire_tlv_invoice_request called!\n"); abort(); }
/* Generated stub for fromwire_tlv_offer */
bool fromwire_tlv_offer(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct tlv_offer * record UNNEEDED)
{ fprintf(stderr, "fromwire_tlv_offer called!\n"); abort(); }
/* Generated stub for fromwire_u32 */
u32 fromwire_u32(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
{ fprintf(stderr, "fromwire_u32 called!\n"); abort(); }
@ -125,15 +125,6 @@ void towire(u8 **pptr UNNEEDED, const void *data UNNEEDED, size_t len UNNEEDED)
/* Generated stub for towire_bool */
void towire_bool(u8 **pptr UNNEEDED, bool v UNNEEDED)
{ fprintf(stderr, "towire_bool called!\n"); abort(); }
/* Generated stub for towire_invoice */
void towire_invoice(u8 **pptr UNNEEDED, const struct tlv_invoice *record UNNEEDED)
{ fprintf(stderr, "towire_invoice called!\n"); abort(); }
/* Generated stub for towire_invoice_request */
void towire_invoice_request(u8 **pptr UNNEEDED, const struct tlv_invoice_request *record UNNEEDED)
{ fprintf(stderr, "towire_invoice_request called!\n"); abort(); }
/* Generated stub for towire_offer */
void towire_offer(u8 **pptr UNNEEDED, const struct tlv_offer *record UNNEEDED)
{ fprintf(stderr, "towire_offer called!\n"); abort(); }
/* Generated stub for towire_secp256k1_ecdsa_signature */
void towire_secp256k1_ecdsa_signature(u8 **pptr UNNEEDED,
const secp256k1_ecdsa_signature *signature UNNEEDED)
@ -141,6 +132,15 @@ void towire_secp256k1_ecdsa_signature(u8 **pptr UNNEEDED,
/* Generated stub for towire_sha256 */
void towire_sha256(u8 **pptr UNNEEDED, const struct sha256 *sha256 UNNEEDED)
{ fprintf(stderr, "towire_sha256 called!\n"); abort(); }
/* Generated stub for towire_tlv_invoice */
void towire_tlv_invoice(u8 **pptr UNNEEDED, const struct tlv_invoice *record UNNEEDED)
{ fprintf(stderr, "towire_tlv_invoice called!\n"); abort(); }
/* Generated stub for towire_tlv_invoice_request */
void towire_tlv_invoice_request(u8 **pptr UNNEEDED, const struct tlv_invoice_request *record UNNEEDED)
{ fprintf(stderr, "towire_tlv_invoice_request called!\n"); abort(); }
/* Generated stub for towire_tlv_offer */
void towire_tlv_offer(u8 **pptr UNNEEDED, const struct tlv_offer *record UNNEEDED)
{ fprintf(stderr, "towire_tlv_offer called!\n"); abort(); }
/* Generated stub for towire_u32 */
void towire_u32(u8 **pptr UNNEEDED, u32 v UNNEEDED)
{ fprintf(stderr, "towire_u32 called!\n"); abort(); }

View File

@ -160,14 +160,14 @@ int main(int argc, char *argv[])
if (streq(tlvtype, "n1")) {
struct tlv_n1 *n1 = tlv_n1_new(tmpctx);
size_t len = tal_bytelen(tlv);
assert(fromwire_n1(&tlv, &len, n1));
assert(fromwire_tlv_n1(&tlv, &len, n1));
assert(len == 0);
merkle_tlv(n1->fields, &merkle);
assert(sha256_eq(&merkle, &expected_merkle));
} else if (streq(tlvtype, "offer")) {
struct tlv_offer *offer = tlv_offer_new(tmpctx);
size_t len = tal_bytelen(tlv);
assert(fromwire_offer(&tlv, &len, offer));
assert(fromwire_tlv_offer(&tlv, &len, offer));
assert(len == 0);
merkle_tlv(offer->fields, &merkle);
assert(sha256_eq(&merkle, &expected_merkle));

View File

@ -114,11 +114,11 @@ static void merkle_n1(const struct tlv_n1 *n1, struct sha256 *test_m)
/* Linearize to populate ->fields */
v = tal_arr(tmpctx, u8, 0);
towire_n1(&v, n1);
towire_tlv_n1(&v, n1);
len = tal_bytelen(v);
tmp = tlv_n1_new(tmpctx);
if (!fromwire_n1(cast_const2(const u8 **, &v), &len, tmp))
if (!fromwire_tlv_n1(cast_const2(const u8 **, &v), &len, tmp))
abort();
assert(len == 0);

View File

@ -59,18 +59,6 @@ bool fromwire_bool(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
/* Generated stub for fromwire_fail */
void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
{ fprintf(stderr, "fromwire_fail called!\n"); abort(); }
/* Generated stub for fromwire_invoice */
bool fromwire_invoice(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct tlv_invoice * record UNNEEDED)
{ fprintf(stderr, "fromwire_invoice called!\n"); abort(); }
/* Generated stub for fromwire_invoice_request */
bool fromwire_invoice_request(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct tlv_invoice_request * record UNNEEDED)
{ fprintf(stderr, "fromwire_invoice_request called!\n"); abort(); }
/* Generated stub for fromwire_offer */
bool fromwire_offer(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct tlv_offer * record UNNEEDED)
{ fprintf(stderr, "fromwire_offer called!\n"); abort(); }
/* Generated stub for fromwire_secp256k1_ecdsa_signature */
void fromwire_secp256k1_ecdsa_signature(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
secp256k1_ecdsa_signature *signature UNNEEDED)
@ -82,6 +70,18 @@ void fromwire_sha256(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, struct sh
u8 *fromwire_tal_arrn(const tal_t *ctx UNNEEDED,
const u8 **cursor UNNEEDED, size_t *max UNNEEDED, size_t num UNNEEDED)
{ fprintf(stderr, "fromwire_tal_arrn called!\n"); abort(); }
/* Generated stub for fromwire_tlv_invoice */
bool fromwire_tlv_invoice(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct tlv_invoice * record UNNEEDED)
{ fprintf(stderr, "fromwire_tlv_invoice called!\n"); abort(); }
/* Generated stub for fromwire_tlv_invoice_request */
bool fromwire_tlv_invoice_request(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct tlv_invoice_request * record UNNEEDED)
{ fprintf(stderr, "fromwire_tlv_invoice_request called!\n"); abort(); }
/* Generated stub for fromwire_tlv_offer */
bool fromwire_tlv_offer(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct tlv_offer * record UNNEEDED)
{ fprintf(stderr, "fromwire_tlv_offer called!\n"); abort(); }
/* Generated stub for fromwire_u32 */
u32 fromwire_u32(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
{ fprintf(stderr, "fromwire_u32 called!\n"); abort(); }
@ -132,15 +132,6 @@ void towire(u8 **pptr UNNEEDED, const void *data UNNEEDED, size_t len UNNEEDED)
/* Generated stub for towire_bool */
void towire_bool(u8 **pptr UNNEEDED, bool v UNNEEDED)
{ fprintf(stderr, "towire_bool called!\n"); abort(); }
/* Generated stub for towire_invoice */
void towire_invoice(u8 **pptr UNNEEDED, const struct tlv_invoice *record UNNEEDED)
{ fprintf(stderr, "towire_invoice called!\n"); abort(); }
/* Generated stub for towire_invoice_request */
void towire_invoice_request(u8 **pptr UNNEEDED, const struct tlv_invoice_request *record UNNEEDED)
{ fprintf(stderr, "towire_invoice_request called!\n"); abort(); }
/* Generated stub for towire_offer */
void towire_offer(u8 **pptr UNNEEDED, const struct tlv_offer *record UNNEEDED)
{ fprintf(stderr, "towire_offer called!\n"); abort(); }
/* Generated stub for towire_secp256k1_ecdsa_signature */
void towire_secp256k1_ecdsa_signature(u8 **pptr UNNEEDED,
const secp256k1_ecdsa_signature *signature UNNEEDED)
@ -148,6 +139,15 @@ void towire_secp256k1_ecdsa_signature(u8 **pptr UNNEEDED,
/* Generated stub for towire_sha256 */
void towire_sha256(u8 **pptr UNNEEDED, const struct sha256 *sha256 UNNEEDED)
{ fprintf(stderr, "towire_sha256 called!\n"); abort(); }
/* Generated stub for towire_tlv_invoice */
void towire_tlv_invoice(u8 **pptr UNNEEDED, const struct tlv_invoice *record UNNEEDED)
{ fprintf(stderr, "towire_tlv_invoice called!\n"); abort(); }
/* Generated stub for towire_tlv_invoice_request */
void towire_tlv_invoice_request(u8 **pptr UNNEEDED, const struct tlv_invoice_request *record UNNEEDED)
{ fprintf(stderr, "towire_tlv_invoice_request called!\n"); abort(); }
/* Generated stub for towire_tlv_offer */
void towire_tlv_offer(u8 **pptr UNNEEDED, const struct tlv_offer *record UNNEEDED)
{ fprintf(stderr, "towire_tlv_offer called!\n"); abort(); }
/* Generated stub for towire_u32 */
void towire_u32(u8 **pptr UNNEEDED, u32 v UNNEEDED)
{ fprintf(stderr, "towire_u32 called!\n"); abort(); }

View File

@ -151,7 +151,7 @@ static u8 *json_to_enctlvs(const tal_t *ctx,
}
}
ret = tal_arr(ctx, u8, 0);
towire_encrypted_data_tlv(&ret, enctlv);
towire_tlv_encrypted_data_tlv(&ret, enctlv);
towire_u8_array(&ret, appended, tal_bytelen(appended));
return ret;
}

View File

@ -156,7 +156,7 @@ static u8 *json_to_enctlvs(const tal_t *ctx,
}
}
ret = tal_arr(ctx, u8, 0);
towire_encrypted_data_tlv(&ret, enctlv);
towire_tlv_encrypted_data_tlv(&ret, enctlv);
towire_u8_array(&ret, appended, tal_bytelen(appended));
return ret;
}

View File

@ -102,7 +102,7 @@ void handle_onion_message(struct daemon *daemon,
}
om = tlv_onionmsg_payload_new(msg);
if (!fromwire_onionmsg_payload(&cursor, &maxlen, om)) {
if (!fromwire_tlv_onionmsg_payload(&cursor, &maxlen, om)) {
status_peer_debug(&peer->id, "onion msg: invalid onionmsg_payload %s",
tal_hex(tmpctx, rs->raw_payload));
return;

View File

@ -471,7 +471,7 @@ static struct command_result *json_createinvoicerequest(struct command *cmd,
* [Signature Calculation](#signature-calculation) using the `payer_key`.
*/
/* This populates the ->fields from our entries */
invreq->fields = tlv_make_fields(invreq, invoice_request);
invreq->fields = tlv_make_fields(invreq, tlv_invoice_request);
merkle_tlv(invreq->fields, &merkle);
invreq->signature = tal(invreq, struct bip340sig);
if (deprecated_apis)

View File

@ -149,7 +149,7 @@ void handle_onionmsg_to_us(struct lightningd *ld, const u8 *msg)
submsglen = tal_bytelen(submsg);
subptr = submsg;
payload->om = tlv_onionmsg_payload_new(payload);
if (!fromwire_onionmsg_payload(&subptr, &submsglen, payload->om)) {
if (!fromwire_tlv_onionmsg_payload(&subptr, &submsglen, payload->om)) {
log_broken(ld->log, "bad got_onionmsg_tous om: %s",
tal_hex(tmpctx, msg));
return;

View File

@ -120,7 +120,7 @@ static struct command_result *handle_error(struct command *cmd,
json_tok_full_len(errtok),
json_tok_full(buf, errtok));
json_out_start(details, NULL, '{');
if (!fromwire_invoice_error(&data, &dlen, err)) {
if (!fromwire_tlv_invoice_error(&data, &dlen, err)) {
plugin_log(cmd->plugin, LOG_DBG,
"Invalid invoice_error %.*s",
json_tok_full_len(errtok),
@ -186,7 +186,7 @@ static struct command_result *handle_invreq_response(struct command *cmd,
invbin = json_tok_bin_from_hex(cmd, buf, invtok);
len = tal_bytelen(invbin);
inv = tlv_invoice_new(cmd);
if (!fromwire_invoice(&invbin, &len, inv)) {
if (!fromwire_tlv_invoice(&invbin, &len, inv)) {
badfield = "invoice";
goto badinv;
}
@ -719,7 +719,7 @@ send_modern_message(struct command *cmd,
json_object_start(req->js, NULL);
json_add_pubkey(req->js, "id", &node_alias[i]);
tlv = tal_arr(tmpctx, u8, 0);
towire_onionmsg_payload(&tlv, payloads[i]);
towire_tlv_onionmsg_payload(&tlv, payloads[i]);
json_add_hex_talarr(req->js, "tlv", tlv);
json_object_end(req->js);
}
@ -830,7 +830,7 @@ sendinvreq_after_connect(struct command *cmd,
struct sent *sent)
{
u8 *rawinvreq = tal_arr(tmpctx, u8, 0);
towire_invoice_request(&rawinvreq, sent->invreq);
towire_tlv_invoice_request(&rawinvreq, sent->invreq);
return send_message(cmd, sent, "invoice_request", rawinvreq,
sendonionmsg_done);
@ -1091,11 +1091,11 @@ force_payer_secret(struct command *cmd,
/* Linearize populates ->fields */
msg = tal_arr(tmpctx, u8, 0);
towire_invoice_request(&msg, invreq);
towire_tlv_invoice_request(&msg, invreq);
p = msg;
len = tal_bytelen(msg);
sent->invreq = tlv_invoice_request_new(cmd);
if (!fromwire_invoice_request(&p, &len, sent->invreq))
if (!fromwire_tlv_invoice_request(&p, &len, sent->invreq))
plugin_err(cmd->plugin,
"Could not remarshall invreq %s", tal_hex(tmpctx, msg));
@ -1379,7 +1379,7 @@ sendinvoice_after_connect(struct command *cmd,
struct sent *sent)
{
u8 *rawinv = tal_arr(tmpctx, u8, 0);
towire_invoice(&rawinv, sent->inv);
towire_tlv_invoice(&rawinv, sent->inv);
return send_message(cmd, sent, "invoice", rawinv, prepare_inv_timeout);
}
@ -1474,11 +1474,11 @@ static struct command_result *listsendpays_done(struct command *cmd,
/* Linearize populates ->fields */
msg = tal_arr(tmpctx, u8, 0);
towire_invoice(&msg, sent->inv);
towire_tlv_invoice(&msg, sent->inv);
p = msg;
len = tal_bytelen(msg);
sent->inv = tlv_invoice_new(cmd);
if (!fromwire_invoice(&p, &len, sent->inv))
if (!fromwire_tlv_invoice(&p, &len, sent->inv))
plugin_err(cmd->plugin,
"Could not remarshall %s", tal_hex(tmpctx, msg));

View File

@ -357,7 +357,7 @@ static struct command_result *htlc_accepted_call(struct command *cmd,
if (s != max) {
return htlc_accepted_continue(cmd, NULL);
}
if (!fromwire_tlv_payload(&rawpayload, &max, payload)) {
if (!fromwire_tlv_tlv_payload(&rawpayload, &max, payload)) {
plugin_log(
cmd->plugin, LOG_UNUSUAL, "Malformed TLV payload %.*s",
json_tok_full_len(params),

View File

@ -79,7 +79,7 @@ send_onion_reply(struct command *cmd,
}
}
tlv = tal_arr(tmpctx, u8, 0);
towire_onionmsg_payload(&tlv, omp);
towire_tlv_onionmsg_payload(&tlv, omp);
json_add_hex_talarr(req->js, "tlv", tlv);
json_object_end(req->js);
}

View File

@ -56,7 +56,7 @@ fail_inv_level(struct command *cmd,
/* FIXME: Add suggested_value / erroneous_field! */
errdata = tal_arr(cmd, u8, 0);
towire_invoice_error(&errdata, err);
towire_tlv_invoice_error(&errdata, err);
return send_onion_reply(cmd, inv->reply_path, "invoice_error", errdata);
}
@ -329,7 +329,7 @@ struct command_result *handle_invoice(struct command *cmd,
inv->reply_path = tal_steal(inv, reply_path);
inv->inv = tlv_invoice_new(cmd);
if (!fromwire_invoice(&invbin, &len, inv->inv)) {
if (!fromwire_tlv_invoice(&invbin, &len, inv->inv)) {
return fail_inv(cmd, inv,
"Invalid invoice %s",
tal_hex(tmpctx, invbin));

View File

@ -62,7 +62,7 @@ fail_invreq_level(struct command *cmd,
/* FIXME: Add suggested_value / erroneous_field! */
errdata = tal_arr(cmd, u8, 0);
towire_invoice_error(&errdata, err);
towire_tlv_invoice_error(&errdata, err);
return send_onion_reply(cmd, invreq->reply_path,
"invoice_error", errdata);
}
@ -855,7 +855,7 @@ struct command_result *handle_invoice_request(struct command *cmd,
ir->reply_path = tal_steal(ir, reply_path);
ir->invreq = tlv_invoice_request_new(cmd);
if (!fromwire_invoice_request(&invreqbin, &len, ir->invreq)) {
if (!fromwire_tlv_invoice_request(&invreqbin, &len, ir->invreq)) {
return fail_invreq(cmd, ir,
"Invalid invreq %s",
tal_hex(tmpctx, invreqbin));

View File

@ -141,9 +141,9 @@ ${print_fieldset(msg.fields.values(), False, '&cursor', '&plen')}
% if bool(tlvs):
void print${options.enum_name}_tlv_message(const char *tlv_name, const u8 *msg) {
size_t plen = tal_count(msg);
% for tlv_name in tlvs:
if (strcmp(tlv_name, "${tlv_name}") == 0) {
printwire_tlvs(tlv_name, &msg, &plen, print_tlvs_${tlv_name}, ARRAY_SIZE(print_tlvs_${tlv_name}));
% for tlv in tlvs.values():
if (strcmp(tlv_name, "${tlv.name}") == 0) {
printwire_tlvs(tlv_name, &msg, &plen, print_tlvs_${tlv.name}, ARRAY_SIZE(print_tlvs_${tlv.name}));
}
% endfor
}

View File

@ -401,7 +401,7 @@ class Message(FieldSet):
class Tlv(object):
def __init__(self, name):
self.name = name
self.name = 'tlv_' + name
self.messages = {}
def add_message(self, tokens, comments=[]):
@ -415,7 +415,7 @@ class Tlv(object):
return 'struct ' + self.struct_name()
def struct_name(self):
return "tlv_{}".format(self.name)
return self.name
def find_message(self, name):
return self.messages[name]

View File

@ -117,14 +117,14 @@ generate-bolt-csv-patch: bolt-precheck
# tlvs_n1 and n2 are used for test vectors, thus not referenced: expose them
# for testing and to prevent compile error about them being unused.
# This will be easier if test vectors are moved to separate files.
wire/peer_wiregen.h_args := --include='common/channel_id.h' --include='bitcoin/tx.h' --include='bitcoin/preimage.h' --include='bitcoin/short_channel_id.h' --include='common/node_id.h' --include='common/bigsize.h' --include='bitcoin/block.h' --include='bitcoin/privkey.h' -s --expose-tlv-type=n1 --expose-tlv-type=n2
wire/peer_wiregen.h_args := --include='common/channel_id.h' --include='bitcoin/tx.h' --include='bitcoin/preimage.h' --include='bitcoin/short_channel_id.h' --include='common/node_id.h' --include='common/bigsize.h' --include='bitcoin/block.h' --include='bitcoin/privkey.h' -s --expose-tlv-type=tlv_n1 --expose-tlv-type=tlv_n2
wire/peer_wiregen.c_args := -s --expose-tlv-type=n1 --expose-tlv-type=n2
wire/peer_wiregen.c_args := -s --expose-tlv-type=tlv_n1 --expose-tlv-type=tlv_n2
# The tlv_payload isn't parsed in a fromwire, so we need to expose it.
wire/onion_wiregen.h_args := --include='bitcoin/short_channel_id.h' --include='bitcoin/privkey.h' --include='common/bigsize.h' --include='common/amount.h' --include='common/node_id.h' --include='bitcoin/block.h' -s --expose-tlv-type=tlv_payload
wire/onion_wiregen.h_args := --include='bitcoin/short_channel_id.h' --include='bitcoin/privkey.h' --include='common/bigsize.h' --include='common/amount.h' --include='common/node_id.h' --include='bitcoin/block.h' -s --expose-tlv-type=tlv_tlv_payload
wire/onion_wiregen.c_args := -s --expose-tlv-type=tlv_payload
wire/onion_wiregen.c_args := -s --expose-tlv-type=tlv_tlv_payload
# Same for _exp versions
wire/peer_exp_wiregen.h_args := $(wire/peer_wiregen.h_args) --include='wire/channel_type_wiregen.h'
@ -133,13 +133,13 @@ wire/peer_exp_printgen.h_args := --include='wire/channel_type_printgen.h'
wire/onion_exp_wiregen.h_args := $(wire/onion_wiregen.h_args)
wire/onion_exp_wiregen.c_args := $(wire/onion_wiregen.c_args)
wire/bolt12_wiregen.c_args := -s --expose-tlv-type=blinded_path --expose-tlv-type=invoice_request
wire/bolt12_wiregen.c_args := -s --expose-tlv-type=tlv_blinded_path --expose-tlv-type=tlv_invoice_request
wire/bolt12_wiregen.h_args := --include='bitcoin/short_channel_id.h' --include='bitcoin/signature.h' --include='bitcoin/privkey.h' --include='common/bigsize.h' --include='common/amount.h' --include='common/node_id.h' --include='bitcoin/block.h' --include='wire/onion_wire.h' $(wire/bolt12_wiregen.c_args)
# Same for _exp versions
wire/bolt12_exp_wiregen.h_args := $(wire/bolt12_wiregen.h_args)
wire/bolt12_exp_wiregen.c_args := $(wire/bolt12_wiregen.c_args)
wire/peer_wiregen.h_args := --include='common/channel_id.h' --include='bitcoin/tx.h' --include='bitcoin/preimage.h' --include='bitcoin/short_channel_id.h' --include='common/node_id.h' --include='common/bigsize.h' --include='bitcoin/block.h' --include='bitcoin/privkey.h' -s --expose-tlv-type=n1 --expose-tlv-type=n2
wire/peer_wiregen.h_args := --include='common/channel_id.h' --include='bitcoin/tx.h' --include='bitcoin/preimage.h' --include='bitcoin/short_channel_id.h' --include='common/node_id.h' --include='common/bigsize.h' --include='bitcoin/block.h' --include='bitcoin/privkey.h' -s --expose-tlv-type=tlv_n1 --expose-tlv-type=tlv_n2
wire/channel_type_wiregen.h_args := -s
wire/channel_type_wiregen.c_args := $(wire/channel_type_wiregen.h_args)

View File

@ -467,13 +467,13 @@ int main(int argc, char *argv[])
orig_p = stream(tmpctx, invalid_streams_either[i].hex);
max = tal_count(orig_p);
p = orig_p;
assert((!fromwire_n1(&p, &max, tlv_n1) && !p) ||
!n1_is_valid(tlv_n1, NULL));
assert((!fromwire_tlv_n1(&p, &max, tlv_n1) && !p) ||
!tlv_n1_is_valid(tlv_n1, NULL));
assert(strstr(invalid_streams_either[i].reason, reason));
max = tal_count(orig_p);
p = orig_p;
assert((!fromwire_n2(&p, &max, tlv_n2) && !p) ||
!n2_is_valid(tlv_n2, NULL));
assert((!fromwire_tlv_n2(&p, &max, tlv_n2) && !p) ||
!tlv_n2_is_valid(tlv_n2, NULL));
assert(strstr(invalid_streams_either[i].reason, reason));
}
@ -484,8 +484,8 @@ int main(int argc, char *argv[])
p = stream(tmpctx, invalid_streams_n1[i].hex);
max = tal_count(p);
assert((!fromwire_n1(&p, &max, tlv_n1) && !p) ||
!n1_is_valid(tlv_n1, NULL));
assert((!fromwire_tlv_n1(&p, &max, tlv_n1) && !p) ||
!tlv_n1_is_valid(tlv_n1, NULL));
assert(strstr(invalid_streams_n1[i].reason, reason));
}
@ -496,8 +496,8 @@ int main(int argc, char *argv[])
p = stream(tmpctx, invalid_streams_n1_combo[i].hex);
max = tal_count(p);
assert((!fromwire_n1(&p, &max, tlv_n1) && !p) ||
!n1_is_valid(tlv_n1, NULL));
assert((!fromwire_tlv_n1(&p, &max, tlv_n1) && !p) ||
!tlv_n1_is_valid(tlv_n1, NULL));
assert(strstr(invalid_streams_n1_combo[i].reason, reason));
}
@ -508,8 +508,8 @@ int main(int argc, char *argv[])
p = stream(tmpctx, invalid_streams_n2_combo[i].hex);
max = tal_count(p);
assert((!fromwire_n2(&p, &max, tlv_n2) && !p) ||
!n2_is_valid(tlv_n2, NULL));
assert((!fromwire_tlv_n2(&p, &max, tlv_n2) && !p) ||
!tlv_n2_is_valid(tlv_n2, NULL));
assert(strstr(invalid_streams_n2_combo[i].reason, reason));
}
@ -523,8 +523,8 @@ int main(int argc, char *argv[])
max = tal_count(orig_p);
p = orig_p;
assert(fromwire_n1(&p, &max, tlv_n1) &&
n1_is_valid(tlv_n1, NULL));
assert(fromwire_tlv_n1(&p, &max, tlv_n1) &&
tlv_n1_is_valid(tlv_n1, NULL));
assert(max == 0);
assert(tlv_n1_eq(tlv_n1, &valid_streams[i].expect));
@ -534,7 +534,7 @@ int main(int argc, char *argv[])
continue;
p2 = tal_arr(tmpctx, u8, 0);
towire_n1(&p2, tlv_n1);
towire_tlv_n1(&p2, tlv_n1);
assert(memeq(p2, tal_count(p2), orig_p, tal_count(orig_p)));
}
@ -555,12 +555,12 @@ int main(int argc, char *argv[])
invalid_streams_either[i].hex);
max = tal_count(orig_p);
p = orig_p;
assert((!fromwire_n1(&p, &max, tlv_n1) && !p) ||
!n1_is_valid(tlv_n1, NULL));
assert((!fromwire_tlv_n1(&p, &max, tlv_n1) && !p) ||
!tlv_n1_is_valid(tlv_n1, NULL));
max = tal_count(orig_p);
p = orig_p;
assert((!fromwire_n2(&p, &max, tlv_n2) && !p) ||
!n2_is_valid(tlv_n2, NULL));
assert((!fromwire_tlv_n2(&p, &max, tlv_n2) && !p) ||
!tlv_n2_is_valid(tlv_n2, NULL));
}
}
@ -573,8 +573,8 @@ int main(int argc, char *argv[])
p = stream2(tmpctx, valid_streams[j].hex,
invalid_streams_n1[i].hex);
max = tal_count(p);
assert((!fromwire_n1(&p, &max, tlv_n1) && !p) ||
!n1_is_valid(tlv_n1, NULL));
assert((!fromwire_tlv_n1(&p, &max, tlv_n1) && !p) ||
!tlv_n1_is_valid(tlv_n1, NULL));
}
}
@ -587,8 +587,8 @@ int main(int argc, char *argv[])
p = stream2(tmpctx, valid_streams[j].hex,
invalid_streams_n1_combo[i].hex);
max = tal_count(p);
assert((!fromwire_n1(&p, &max, tlv_n1) && !p) ||
!n1_is_valid(tlv_n1, NULL));
assert((!fromwire_tlv_n1(&p, &max, tlv_n1) && !p) ||
!tlv_n1_is_valid(tlv_n1, NULL));
}
}
@ -617,8 +617,8 @@ int main(int argc, char *argv[])
expect_success = pull_type(valid_streams[i].hex)
< pull_type(valid_streams[j].hex);
assert(fromwire_n1(&p, &max, tlv_n1) &&
n1_is_valid(tlv_n1, NULL) == expect_success);
assert(fromwire_tlv_n1(&p, &max, tlv_n1) &&
tlv_n1_is_valid(tlv_n1, NULL) == expect_success);
if (!expect_success)
continue;
@ -630,7 +630,7 @@ int main(int argc, char *argv[])
continue;
u8 *p2 = tal_arr(tmpctx, u8, 0);
towire_n1(&p2, tlv_n1);
towire_tlv_n1(&p2, tlv_n1);
assert(memeq(orig_p, tal_count(orig_p),
p2, tal_count(p2)));
}