mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +01:00
patch remove-payer-backcompat.patch
This commit is contained in:
committed by
neil saitug
parent
e4e1396447
commit
424ac84263
@@ -553,8 +553,7 @@ int main(int argc, char *argv[])
|
|||||||
print_features(invreq->features);
|
print_features(invreq->features);
|
||||||
if (invreq->quantity)
|
if (invreq->quantity)
|
||||||
print_quantity(*invreq->quantity);
|
print_quantity(*invreq->quantity);
|
||||||
/* Note: old format didn't include this, so we don't complain! */
|
if (must_have(invreq, payer_signature))
|
||||||
if (invreq->payer_signature)
|
|
||||||
well_formed &= print_signature("invoice_request",
|
well_formed &= print_signature("invoice_request",
|
||||||
"payer_signature",
|
"payer_signature",
|
||||||
invreq->fields,
|
invreq->fields,
|
||||||
@@ -563,18 +562,8 @@ int main(int argc, char *argv[])
|
|||||||
if (invreq->recurrence_counter) {
|
if (invreq->recurrence_counter) {
|
||||||
print_recurrence_counter(invreq->recurrence_counter,
|
print_recurrence_counter(invreq->recurrence_counter,
|
||||||
invreq->recurrence_start);
|
invreq->recurrence_start);
|
||||||
/* Old form included recurrence_signature */
|
|
||||||
if (invreq->recurrence_signature)
|
|
||||||
well_formed &= print_signature("invoice_request",
|
|
||||||
"recurrence_signature",
|
|
||||||
invreq->fields,
|
|
||||||
invreq->payer_key,
|
|
||||||
invreq->recurrence_signature);
|
|
||||||
else /* New form definitely should have this! */
|
|
||||||
must_have(invreq, payer_signature);
|
|
||||||
} else {
|
} else {
|
||||||
must_not_have(invreq, recurrence_start);
|
must_not_have(invreq, recurrence_start);
|
||||||
must_not_have(invreq, recurrence_signature);
|
|
||||||
}
|
}
|
||||||
if (!print_extra_fields(invreq->fields))
|
if (!print_extra_fields(invreq->fields))
|
||||||
well_formed = false;
|
well_formed = false;
|
||||||
|
|||||||
@@ -461,13 +461,6 @@ static struct command_result *json_createinvoicerequest(struct command *cmd,
|
|||||||
&merkle, invreq->payer_info, invreq->payer_key,
|
&merkle, invreq->payer_info, invreq->payer_key,
|
||||||
invreq->payer_signature);
|
invreq->payer_signature);
|
||||||
|
|
||||||
/* Backwards compat for older version! */
|
|
||||||
if (deprecated_apis && invreq->recurrence_counter) {
|
|
||||||
invreq->recurrence_signature = tal(invreq, struct bip340sig);
|
|
||||||
hsm_sign_b12(cmd->ld, "invoice_request", "recurrence_signature",
|
|
||||||
&merkle, invreq->payer_info, invreq->payer_key,
|
|
||||||
invreq->recurrence_signature);
|
|
||||||
}
|
|
||||||
response = json_stream_success(cmd);
|
response = json_stream_success(cmd);
|
||||||
json_add_string(response, "bolt12", invrequest_encode(tmpctx, invreq));
|
json_add_string(response, "bolt12", invrequest_encode(tmpctx, invreq));
|
||||||
if (label)
|
if (label)
|
||||||
|
|||||||
@@ -674,10 +674,7 @@ static void json_add_invoice_request(struct json_stream *js,
|
|||||||
* - MUST fail the request if there is no `payer_signature` field.
|
* - MUST fail the request if there is no `payer_signature` field.
|
||||||
* - MUST fail the request if `payer_signature` is not correct.
|
* - MUST fail the request if `payer_signature` is not correct.
|
||||||
*/
|
*/
|
||||||
/* Older spec didn't have this, so we allow omission for now. */
|
|
||||||
if (invreq->payer_signature) {
|
if (invreq->payer_signature) {
|
||||||
json_add_bip340sig(js, "payer_signature",
|
|
||||||
invreq->payer_signature);
|
|
||||||
if (invreq->payer_key
|
if (invreq->payer_key
|
||||||
&& !bolt12_check_signature(invreq->fields,
|
&& !bolt12_check_signature(invreq->fields,
|
||||||
"invoice_request",
|
"invoice_request",
|
||||||
@@ -691,23 +688,9 @@ static void json_add_invoice_request(struct json_stream *js,
|
|||||||
} else {
|
} else {
|
||||||
json_add_string(js, "warning_invoice_request_missing_payer_signature",
|
json_add_string(js, "warning_invoice_request_missing_payer_signature",
|
||||||
"Missing payer_signature");
|
"Missing payer_signature");
|
||||||
if (!deprecated_apis)
|
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deprecated_apis && invreq->recurrence_counter) {
|
|
||||||
if (invreq->payer_key
|
|
||||||
&& !bolt12_check_signature(invreq->fields,
|
|
||||||
"invoice_request",
|
|
||||||
"recurrence_signature",
|
|
||||||
invreq->payer_key,
|
|
||||||
invreq->recurrence_signature)) {
|
|
||||||
json_add_string(js, "warning_invoice_request_invalid_recurrence_signature",
|
|
||||||
"Bad recurrence_signature");
|
|
||||||
valid = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
json_add_bool(js, "valid", valid);
|
json_add_bool(js, "valid", valid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -408,21 +408,6 @@ static struct command_result *check_previous_invoice(struct command *cmd,
|
|||||||
return send_outreq(cmd->plugin, req);
|
return send_outreq(cmd->plugin, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Obsolete recurrence_signature; we still check if present. */
|
|
||||||
static bool check_recurrence_sig(const struct tlv_invoice_request *invreq,
|
|
||||||
const struct pubkey32 *payer_key,
|
|
||||||
const struct bip340sig *sig)
|
|
||||||
{
|
|
||||||
struct sha256 merkle, sighash;
|
|
||||||
merkle_tlv(invreq->fields, &merkle);
|
|
||||||
sighash_from_merkle("invoice_request", "recurrence_signature",
|
|
||||||
&merkle, &sighash);
|
|
||||||
|
|
||||||
return secp256k1_schnorrsig_verify(secp256k1_ctx,
|
|
||||||
sig->u8,
|
|
||||||
sighash.u.u8, &payer_key->pubkey) == 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* BOLT-offers #12:
|
/* BOLT-offers #12:
|
||||||
* - MUST fail the request if `payer_signature` is not correct.
|
* - MUST fail the request if `payer_signature` is not correct.
|
||||||
*/
|
*/
|
||||||
@@ -721,9 +706,6 @@ static struct command_result *listoffers_done(struct command *cmd,
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: payer_signature is now always required, but we let it go
|
|
||||||
* for now. */
|
|
||||||
if (!deprecated_apis) {
|
|
||||||
err = invreq_must_have(cmd, ir, payer_signature);
|
err = invreq_must_have(cmd, ir, payer_signature);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
@@ -732,7 +714,6 @@ static struct command_result *listoffers_done(struct command *cmd,
|
|||||||
ir->invreq->payer_signature)) {
|
ir->invreq->payer_signature)) {
|
||||||
return fail_invreq(cmd, ir, "bad payer_signature");
|
return fail_invreq(cmd, ir, "bad payer_signature");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (ir->offer->recurrence) {
|
if (ir->offer->recurrence) {
|
||||||
/* BOLT-offers #12:
|
/* BOLT-offers #12:
|
||||||
@@ -748,23 +729,6 @@ static struct command_result *listoffers_done(struct command *cmd,
|
|||||||
err = invreq_must_have(cmd, ir, recurrence_counter);
|
err = invreq_must_have(cmd, ir, recurrence_counter);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
if (deprecated_apis) {
|
|
||||||
if (ir->invreq->recurrence_signature) {
|
|
||||||
if (!check_recurrence_sig(ir->invreq,
|
|
||||||
ir->invreq->payer_key,
|
|
||||||
ir->invreq->recurrence_signature)) {
|
|
||||||
return fail_invreq(cmd, ir,
|
|
||||||
"bad recurrence_signature");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* You really do need payer_signature if
|
|
||||||
* you're using recurrence: we rely on it! */
|
|
||||||
err = invreq_must_have(cmd, ir, payer_signature);
|
|
||||||
if (err)
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
/* BOLT-offers #12:
|
/* BOLT-offers #12:
|
||||||
* - otherwise (the offer had no `recurrence`):
|
* - otherwise (the offer had no `recurrence`):
|
||||||
|
|||||||
@@ -63,10 +63,8 @@ tlvtype,invoice_request,payer_info,50
|
|||||||
tlvdata,invoice_request,payer_info,blob,byte,...
|
tlvdata,invoice_request,payer_info,blob,byte,...
|
||||||
tlvtype,invoice_request,replace_invoice,56
|
tlvtype,invoice_request,replace_invoice,56
|
||||||
tlvdata,invoice_request,replace_invoice,payment_hash,sha256,
|
tlvdata,invoice_request,replace_invoice,payment_hash,sha256,
|
||||||
tlvtype,invoice_request,payer_signature,241
|
tlvtype,invoice_request,payer_signature,240
|
||||||
tlvdata,invoice_request,payer_signature,sig,bip340sig,
|
tlvdata,invoice_request,payer_signature,sig,bip340sig,
|
||||||
tlvtype,invoice_request,recurrence_signature,240
|
|
||||||
tlvdata,invoice_request,recurrence_signature,sig,bip340sig,
|
|
||||||
tlvtype,invoice,chains,2
|
tlvtype,invoice,chains,2
|
||||||
tlvdata,invoice,chains,chains,chain_hash,...
|
tlvdata,invoice,chains,chains,chain_hash,...
|
||||||
tlvtype,invoice,offer_id,4
|
tlvtype,invoice,offer_id,4
|
||||||
|
|||||||
|
@@ -63,10 +63,8 @@ tlvtype,invoice_request,payer_info,50
|
|||||||
tlvdata,invoice_request,payer_info,blob,byte,...
|
tlvdata,invoice_request,payer_info,blob,byte,...
|
||||||
tlvtype,invoice_request,replace_invoice,56
|
tlvtype,invoice_request,replace_invoice,56
|
||||||
tlvdata,invoice_request,replace_invoice,payment_hash,sha256,
|
tlvdata,invoice_request,replace_invoice,payment_hash,sha256,
|
||||||
tlvtype,invoice_request,payer_signature,241
|
tlvtype,invoice_request,payer_signature,240
|
||||||
tlvdata,invoice_request,payer_signature,sig,bip340sig,
|
tlvdata,invoice_request,payer_signature,sig,bip340sig,
|
||||||
tlvtype,invoice_request,recurrence_signature,240
|
|
||||||
tlvdata,invoice_request,recurrence_signature,sig,bip340sig,
|
|
||||||
tlvtype,invoice,chains,2
|
tlvtype,invoice,chains,2
|
||||||
tlvdata,invoice,chains,chains,chain_hash,...
|
tlvdata,invoice,chains,chains,chain_hash,...
|
||||||
tlvtype,invoice,offer_id,4
|
tlvtype,invoice,offer_id,4
|
||||||
|
|||||||
|
32
wire/bolt12_wiregen.c
generated
32
wire/bolt12_wiregen.c
generated
@@ -855,29 +855,6 @@ static void fromwire_tlv_invoice_request_payer_signature(const u8 **cursor, size
|
|||||||
|
|
||||||
fromwire_bip340sig(cursor, plen, &*r->payer_signature);
|
fromwire_bip340sig(cursor, plen, &*r->payer_signature);
|
||||||
}
|
}
|
||||||
/* INVOICE_REQUEST MSG: recurrence_signature */
|
|
||||||
static u8 *towire_tlv_invoice_request_recurrence_signature(const tal_t *ctx, const void *vrecord)
|
|
||||||
{
|
|
||||||
const struct tlv_invoice_request *r = vrecord;
|
|
||||||
u8 *ptr;
|
|
||||||
|
|
||||||
if (!r->recurrence_signature)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
|
|
||||||
ptr = tal_arr(ctx, u8, 0);
|
|
||||||
|
|
||||||
towire_bip340sig(&ptr, r->recurrence_signature);
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
static void fromwire_tlv_invoice_request_recurrence_signature(const u8 **cursor, size_t *plen, void *vrecord)
|
|
||||||
{
|
|
||||||
struct tlv_invoice_request *r = vrecord;
|
|
||||||
|
|
||||||
r->recurrence_signature = tal(r, struct bip340sig);
|
|
||||||
|
|
||||||
fromwire_bip340sig(cursor, plen, &*r->recurrence_signature);
|
|
||||||
}
|
|
||||||
|
|
||||||
const struct tlv_record_type tlvs_invoice_request[] = {
|
const struct tlv_record_type tlvs_invoice_request[] = {
|
||||||
{ 2, towire_tlv_invoice_request_chains, fromwire_tlv_invoice_request_chains },
|
{ 2, towire_tlv_invoice_request_chains, fromwire_tlv_invoice_request_chains },
|
||||||
@@ -891,19 +868,18 @@ const struct tlv_record_type tlvs_invoice_request[] = {
|
|||||||
{ 50, towire_tlv_invoice_request_payer_info, fromwire_tlv_invoice_request_payer_info },
|
{ 50, towire_tlv_invoice_request_payer_info, fromwire_tlv_invoice_request_payer_info },
|
||||||
{ 56, towire_tlv_invoice_request_replace_invoice, fromwire_tlv_invoice_request_replace_invoice },
|
{ 56, towire_tlv_invoice_request_replace_invoice, fromwire_tlv_invoice_request_replace_invoice },
|
||||||
{ 68, towire_tlv_invoice_request_recurrence_start, fromwire_tlv_invoice_request_recurrence_start },
|
{ 68, towire_tlv_invoice_request_recurrence_start, fromwire_tlv_invoice_request_recurrence_start },
|
||||||
{ 240, towire_tlv_invoice_request_recurrence_signature, fromwire_tlv_invoice_request_recurrence_signature },
|
{ 240, towire_tlv_invoice_request_payer_signature, fromwire_tlv_invoice_request_payer_signature },
|
||||||
{ 241, towire_tlv_invoice_request_payer_signature, fromwire_tlv_invoice_request_payer_signature },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void towire_invoice_request(u8 **pptr, const struct tlv_invoice_request *record)
|
void towire_invoice_request(u8 **pptr, const struct tlv_invoice_request *record)
|
||||||
{
|
{
|
||||||
towire_tlv(pptr, tlvs_invoice_request, 13, record);
|
towire_tlv(pptr, tlvs_invoice_request, 12, record);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool fromwire_invoice_request(const u8 **cursor, size_t *max, struct tlv_invoice_request *record)
|
bool fromwire_invoice_request(const u8 **cursor, size_t *max, struct tlv_invoice_request *record)
|
||||||
{
|
{
|
||||||
return fromwire_tlv(cursor, max, tlvs_invoice_request, 13, record, &record->fields);
|
return fromwire_tlv(cursor, max, tlvs_invoice_request, 12, record, &record->fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool invoice_request_is_valid(const struct tlv_invoice_request *record, size_t *err_index)
|
bool invoice_request_is_valid(const struct tlv_invoice_request *record, size_t *err_index)
|
||||||
@@ -1708,4 +1684,4 @@ bool invoice_error_is_valid(const struct tlv_invoice_error *record, size_t *err_
|
|||||||
return tlv_fields_valid(record->fields, NULL, err_index);
|
return tlv_fields_valid(record->fields, NULL, err_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SHA256STAMP:4e69a9a1519146453c234fe466d01c351cd0a21dc2c4e90538f73ed2f37fdc77
|
// SHA256STAMP:95d5be81bb0846cff337017b812800a19bf176d3182dd605bfe03086c14ef1f4
|
||||||
|
|||||||
8
wire/bolt12_wiregen.h
generated
8
wire/bolt12_wiregen.h
generated
@@ -94,7 +94,6 @@ struct tlv_invoice_request {
|
|||||||
u8 *payer_info;
|
u8 *payer_info;
|
||||||
struct sha256 *replace_invoice;
|
struct sha256 *replace_invoice;
|
||||||
struct bip340sig *payer_signature;
|
struct bip340sig *payer_signature;
|
||||||
struct bip340sig *recurrence_signature;
|
|
||||||
};
|
};
|
||||||
struct tlv_invoice {
|
struct tlv_invoice {
|
||||||
/* Raw fields including unknown ones. */
|
/* Raw fields including unknown ones. */
|
||||||
@@ -215,7 +214,7 @@ void towire_invoice_request(u8 **pptr, const struct tlv_invoice_request *record)
|
|||||||
bool invoice_request_is_valid(const struct tlv_invoice_request *record,
|
bool invoice_request_is_valid(const struct tlv_invoice_request *record,
|
||||||
size_t *err_index);
|
size_t *err_index);
|
||||||
|
|
||||||
#define TLVS_ARRAY_SIZE_invoice_request 13
|
#define TLVS_ARRAY_SIZE_invoice_request 12
|
||||||
extern const struct tlv_record_type tlvs_invoice_request[];
|
extern const struct tlv_record_type tlvs_invoice_request[];
|
||||||
|
|
||||||
|
|
||||||
@@ -233,8 +232,7 @@ enum invoice_request_types {
|
|||||||
TLV_INVOICE_REQUEST_PAYER_INFO = 50,
|
TLV_INVOICE_REQUEST_PAYER_INFO = 50,
|
||||||
TLV_INVOICE_REQUEST_REPLACE_INVOICE = 56,
|
TLV_INVOICE_REQUEST_REPLACE_INVOICE = 56,
|
||||||
TLV_INVOICE_REQUEST_RECURRENCE_START = 68,
|
TLV_INVOICE_REQUEST_RECURRENCE_START = 68,
|
||||||
TLV_INVOICE_REQUEST_RECURRENCE_SIGNATURE = 240,
|
TLV_INVOICE_REQUEST_PAYER_SIGNATURE = 240,
|
||||||
TLV_INVOICE_REQUEST_PAYER_SIGNATURE = 241,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct tlv_invoice *tlv_invoice_new(const tal_t *ctx);
|
struct tlv_invoice *tlv_invoice_new(const tal_t *ctx);
|
||||||
@@ -325,4 +323,4 @@ struct fallback_address *fromwire_fallback_address(const tal_t *ctx, const u8 **
|
|||||||
|
|
||||||
|
|
||||||
#endif /* LIGHTNING_WIRE_BOLT12_WIREGEN_H */
|
#endif /* LIGHTNING_WIRE_BOLT12_WIREGEN_H */
|
||||||
// SHA256STAMP:4e69a9a1519146453c234fe466d01c351cd0a21dc2c4e90538f73ed2f37fdc77
|
// SHA256STAMP:95d5be81bb0846cff337017b812800a19bf176d3182dd605bfe03086c14ef1f4
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
diff --git a/wire/bolt12_wire.csv b/wire/bolt12_wire.csv
|
|
||||||
index 4c7108b98..7216e6b22 100644
|
|
||||||
--- a/wire/bolt12_wire.csv
|
|
||||||
+++ b/wire/bolt12_wire.csv
|
|
||||||
@@ -65,6 +65,8 @@ tlvtype,invoice_request,replace_invoice,56
|
|
||||||
tlvdata,invoice_request,replace_invoice,payment_hash,sha256,
|
|
||||||
tlvtype,invoice_request,payer_signature,241
|
|
||||||
tlvdata,invoice_request,payer_signature,sig,bip340sig,
|
|
||||||
+tlvtype,invoice_request,recurrence_signature,240
|
|
||||||
+tlvdata,invoice_request,recurrence_signature,sig,bip340sig,
|
|
||||||
tlvtype,invoice,chains,2
|
|
||||||
tlvdata,invoice,chains,chains,chain_hash,...
|
|
||||||
tlvtype,invoice,offer_id,4
|
|
||||||
Reference in New Issue
Block a user