mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-21 16:14:23 +01:00
offers: remove backwards-compatiblity invoice_request signatures.
We changed the field name in v0.11.0, so this breaks compat with v0.10.2. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -473,11 +473,6 @@ static struct command_result *json_createinvoicerequest(struct command *cmd,
|
|||||||
invreq->fields = tlv_make_fields(invreq, tlv_invoice_request);
|
invreq->fields = tlv_make_fields(invreq, tlv_invoice_request);
|
||||||
merkle_tlv(invreq->fields, &merkle);
|
merkle_tlv(invreq->fields, &merkle);
|
||||||
invreq->signature = tal(invreq, struct bip340sig);
|
invreq->signature = tal(invreq, struct bip340sig);
|
||||||
if (deprecated_apis)
|
|
||||||
hsm_sign_b12(cmd->ld, "invoice_request", "payer_signature",
|
|
||||||
&merkle, invreq->payer_info, invreq->payer_key,
|
|
||||||
invreq->signature);
|
|
||||||
else
|
|
||||||
hsm_sign_b12(cmd->ld, "invoice_request", "signature",
|
hsm_sign_b12(cmd->ld, "invoice_request", "signature",
|
||||||
&merkle, invreq->payer_info, invreq->payer_key,
|
&merkle, invreq->payer_info, invreq->payer_key,
|
||||||
invreq->signature);
|
invreq->signature);
|
||||||
|
|||||||
@@ -1196,9 +1196,6 @@ force_payer_secret(struct command *cmd,
|
|||||||
"Could not remarshall invreq %s", tal_hex(tmpctx, msg));
|
"Could not remarshall invreq %s", tal_hex(tmpctx, msg));
|
||||||
|
|
||||||
merkle_tlv(sent->invreq->fields, &merkle);
|
merkle_tlv(sent->invreq->fields, &merkle);
|
||||||
if (deprecated_apis)
|
|
||||||
sighash_from_merkle("invoice_request", "payer_signature", &merkle, &sha);
|
|
||||||
else
|
|
||||||
sighash_from_merkle("invoice_request", "signature", &merkle, &sha);
|
sighash_from_merkle("invoice_request", "signature", &merkle, &sha);
|
||||||
|
|
||||||
sent->invreq->signature = tal(invreq, struct bip340sig);
|
sent->invreq->signature = tal(invreq, struct bip340sig);
|
||||||
|
|||||||
@@ -776,25 +776,10 @@ static void json_add_invoice_request(struct json_stream *js,
|
|||||||
"signature",
|
"signature",
|
||||||
invreq->payer_key,
|
invreq->payer_key,
|
||||||
invreq->signature)) {
|
invreq->signature)) {
|
||||||
bool sig_valid;
|
|
||||||
|
|
||||||
if (deprecated_apis) {
|
|
||||||
/* The old name? */
|
|
||||||
sig_valid = bolt12_check_signature(invreq->fields,
|
|
||||||
"invoice_request",
|
|
||||||
"payer_signature",
|
|
||||||
invreq->payer_key,
|
|
||||||
invreq->signature);
|
|
||||||
} else {
|
|
||||||
sig_valid = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sig_valid) {
|
|
||||||
json_add_string(js, "warning_invoice_request_invalid_signature",
|
json_add_string(js, "warning_invoice_request_invalid_signature",
|
||||||
"Bad signature");
|
"Bad signature");
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
json_add_string(js, "warning_invoice_request_missing_signature",
|
json_add_string(js, "warning_invoice_request_missing_signature",
|
||||||
"Missing signature");
|
"Missing signature");
|
||||||
|
|||||||
@@ -431,23 +431,11 @@ static bool check_payer_sig(struct command *cmd,
|
|||||||
merkle_tlv(invreq->fields, &merkle);
|
merkle_tlv(invreq->fields, &merkle);
|
||||||
sighash_from_merkle("invoice_request", "signature", &merkle, &sighash);
|
sighash_from_merkle("invoice_request", "signature", &merkle, &sighash);
|
||||||
|
|
||||||
if (secp256k1_schnorrsig_verify(secp256k1_ctx,
|
|
||||||
sig->u8,
|
|
||||||
sighash.u.u8, sizeof(sighash.u.u8), &payer_key->pubkey) == 1)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (!deprecated_apis)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
/* Try old name */
|
|
||||||
plugin_log(cmd->plugin, LOG_DBG,
|
|
||||||
"Testing invoice_request with old name 'payer_signature'");
|
|
||||||
sighash_from_merkle("invoice_request", "payer_signature",
|
|
||||||
&merkle, &sighash);
|
|
||||||
|
|
||||||
return secp256k1_schnorrsig_verify(secp256k1_ctx,
|
return secp256k1_schnorrsig_verify(secp256k1_ctx,
|
||||||
sig->u8,
|
sig->u8,
|
||||||
sighash.u.u8, sizeof(sighash.u.u8), &payer_key->pubkey) == 1;
|
sighash.u.u8,
|
||||||
|
sizeof(sighash.u.u8),
|
||||||
|
&payer_key->pubkey) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct command_result *invreq_amount_by_quantity(struct command *cmd,
|
static struct command_result *invreq_amount_by_quantity(struct command *cmd,
|
||||||
|
|||||||
@@ -4540,20 +4540,6 @@ def test_offer(node_factory, bitcoind):
|
|||||||
assert 'recurrence: every 600 seconds paywindow -10 to +600 (pay proportional)\n' in output
|
assert 'recurrence: every 600 seconds paywindow -10 to +600 (pay proportional)\n' in output
|
||||||
|
|
||||||
|
|
||||||
def test_deprecated_offer(node_factory, bitcoind):
|
|
||||||
"""Test that we allow old invreq name `payer_signature` with deprecated_apis"""
|
|
||||||
l1, l2 = node_factory.line_graph(2, opts={'experimental-offers': None,
|
|
||||||
'allow-deprecated-apis': True})
|
|
||||||
|
|
||||||
offer = l2.rpc.call('offer', {'amount': 10000,
|
|
||||||
'description': 'test'})['bolt12']
|
|
||||||
|
|
||||||
inv = l1.rpc.call('fetchinvoice', {'offer': offer})['invoice']
|
|
||||||
l2.daemon.wait_for_log("Testing invoice_request with old name 'payer_signature'")
|
|
||||||
|
|
||||||
l1.rpc.pay(inv)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.developer("dev-no-modern-onion is DEVELOPER-only")
|
@pytest.mark.developer("dev-no-modern-onion is DEVELOPER-only")
|
||||||
def test_fetchinvoice_3hop(node_factory, bitcoind):
|
def test_fetchinvoice_3hop(node_factory, bitcoind):
|
||||||
l1, l2, l3, l4 = node_factory.line_graph(4, wait_for_announce=True,
|
l1, l2, l3, l4 = node_factory.line_graph(4, wait_for_announce=True,
|
||||||
|
|||||||
Reference in New Issue
Block a user