diff --git a/gossipd/gossipd.c b/gossipd/gossipd.c index 8e939b503..bcc4636cf 100644 --- a/gossipd/gossipd.c +++ b/gossipd/gossipd.c @@ -386,7 +386,7 @@ static u8 *handle_onion_message(struct peer *peer, const u8 *msg) enum onion_wire badreason; struct onionpacket *op; struct secret ss, *blinding_ss; - struct pubkey *blinding_in; + struct pubkey *blinding_in, ephemeral; struct route_step *rs; u8 *onion; const u8 *cursor; @@ -412,6 +412,7 @@ static u8 *handle_onion_message(struct peer *peer, const u8 *msg) return NULL; } + ephemeral = op->ephemeralkey; if (tlvs->blinding) { struct secret hmac; @@ -430,7 +431,7 @@ static u8 *handle_onion_message(struct peer *peer, const u8 *msg) * our normal privkey: since hsmd knows only how to ECDH with * our real key */ if (secp256k1_ec_pubkey_tweak_mul(secp256k1_ctx, - &op->ephemeralkey.pubkey, + &ephemeral.pubkey, hmac.data) != 1) { status_debug("peer %s: onion msg: can't tweak pubkey", type_to_string(tmpctx, struct node_id, &peer->id)); @@ -441,7 +442,7 @@ static u8 *handle_onion_message(struct peer *peer, const u8 *msg) blinding_in = NULL; } - ecdh(&op->ephemeralkey, &ss); + ecdh(&ephemeral, &ss); /* We make sure we can parse onion packet, so we know if shared secret * is actually valid (this checks hmac). */ diff --git a/tests/test_pay.py b/tests/test_pay.py index 41ce0a60b..173d3ca67 100644 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -4117,6 +4117,16 @@ def test_offer(node_factory, bitcoind): assert 'recurrence: every 600 seconds paywindow -10 to +600 (pay proportional)\n' in output +def test_fetchinvoice_3hop(node_factory, bitcoind): + l1, l2, l3, l4 = node_factory.line_graph(4, wait_for_announce=True, + opts={'experimental-offers': None}) + offer1 = l4.rpc.call('offer', {'amount': '2msat', + 'description': 'simple test'}) + assert offer1['created'] is True + + l1.rpc.call('fetchinvoice', {'offer': offer1['bolt12']}) + + def test_fetchinvoice(node_factory, bitcoind): # We remove the conversion plugin on l3, causing it to get upset. l1, l2, l3 = node_factory.line_graph(3, wait_for_announce=True,