Skip to content

A route hint reusing a known short_channel_id changes that channel's CLTV in xpay route finding #9672

Open

Description

@Nuhiat-Arefin

Issue and Steps to Reproduce

add_routehint keeps a route hint hop whose short_channel_id belongs to a channel the payer already knows. gossmap_apply_localmods then applies the hint's cltv_expiry_delta to that existing channel in xpay route finding. This happens on master at 1ebc4943 and in v26.06.9.

This test goes in common/test/run-gossmap_local-routehint.c. It loads the canned gossmap and builds a route hint hop from the example fields, reusing a known channel's short_channel_id with cltv_expiry_delta 1000. It applies the hop through gossmap_local_addchan then gossmap_local_setchan as add_routehint does. It links the objects that common/test/run-gossmap_local links.

/* Test local modifications to gossmap */
#include "config.h"
#include "../amount.c"
#include "../fp16.c"
#include "../gossmap.c"
#include "../node_id.c"
#include "../pseudorand.c"
#include <ccan/read_write_all/read_write_all.h>
#include <common/channel_type.h>
#include <common/setup.h>
#include <common/utils.h>
#include <stdio.h>

/* AUTOGENERATED MOCKS START */
/* Generated stub for fromwire_bigsize */
bigsize_t fromwire_bigsize(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
{ fprintf(stderr, "fromwire_bigsize called!\n"); abort(); }
/* Generated stub for fromwire_channel_id */
bool fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
			 struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "fromwire_channel_id called!\n"); abort(); }
/* Generated stub for fromwire_gossip_store_chan_dying */
bool fromwire_gossip_store_chan_dying(const void *p UNNEEDED, struct short_channel_id *scid UNNEEDED, u32 *blockheight UNNEEDED)
{ fprintf(stderr, "fromwire_gossip_store_chan_dying called!\n"); abort(); }
/* Generated stub for sciddir_or_pubkey_from_node_id */
bool sciddir_or_pubkey_from_node_id(struct sciddir_or_pubkey *sciddpk UNNEEDED,
				    const struct node_id *node_id UNNEEDED)
{ fprintf(stderr, "sciddir_or_pubkey_from_node_id called!\n"); abort(); }
/* Generated stub for towire_bigsize */
void towire_bigsize(u8 **pptr UNNEEDED, const bigsize_t val UNNEEDED)
{ fprintf(stderr, "towire_bigsize called!\n"); abort(); }
/* Generated stub for towire_channel_id */
void towire_channel_id(u8 **pptr UNNEEDED, const struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "towire_channel_id called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */

/* Canned gossmap, taken from tests/test_gossip.py, with channels mined.
 * $> od -tx1 -Anone -v < /tmp/ltests-rtchpzh1/test_gossip_store_compact_noappend_1/lightning-2/regtest/gossip_store  | sed 's/ / 0x/g'| cut -c2- | sed -e 's/ /,/g' -e 's/$/,/'
 */
static u8 canned_map[] = {
	0x0f,0x20,0x00,0x01,0xb0,0x6e,0x30,0x94,0x60,0x65,0x55,0xb3,0x60,0x01,0x00,0x00,
	0x33,0x57,0x33,0xf5,0x94,0x2d,0xf5,0xd9,0x50,0xeb,0x87,0x66,0xde,0xe3,0xa9,0xd6,
	0x62,0x69,0x22,0x84,0x4e,0xd6,0xae,0x7a,0x11,0x0d,0xd7,0xe7,0xed,0xc3,0x2e,0x3f,
	0x6f,0x3d,0x9a,0xc5,0xcd,0xea,0x23,0xce,0x25,0xbb,0x8d,0xbf,0x76,0x1f,0xd3,0xd5,
	0xfc,0x56,0xc0,0x5b,0x68,0x56,0x31,0x6d,0x12,0xe9,0xd3,0x2c,0xa0,0xf0,0x8c,0x69,
	0xca,0x03,0x06,0xfe,0x71,0x6e,0x7b,0x51,0x51,0x31,0x7d,0x64,0x40,0xb7,0x37,0x3d,
	0x9f,0xbc,0x64,0x6e,0xad,0x48,0xf2,0x16,0x3f,0x2b,0x6d,0x51,0x1a,0xfe,0x6a,0x79,
	0xc7,0x55,0x51,0xc2,0x62,0x0f,0xc8,0x09,0x74,0xf2,0xf8,0x64,0x32,0x9d,0x97,0x78,
	0xa0,0x8c,0xdf,0xbc,0x9f,0x2c,0x9c,0x13,0x44,0xc4,0x32,0x70,0x2c,0x66,0x80,0x7c,
	0xfb,0x4d,0xb6,0x9b,0x80,0xfa,0xe8,0xc3,0x3c,0x70,0x14,0x3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0x9c,0x3a,0x5d,0x88,0x5d,0x02,0x90,0x53,0x52,0x1d,
	0x6e,0xa7,0xa5,0x2c,0xdd,0x55,0xf7,0x33,0xd0,0xfb,0x2d,0x07,0x7c,0x03,0x73,0xb0,
	0x05,0x3b,0x5b,0x81,0x0d,0x92,0x72,0x44,0x06,0x1b,0x75,0x73,0x02,0xd6,0x06,0x3d,
	0x02,0x26,0x91,0xb2,0x49,0x0a,0xb4,0x54,0xde,0xe7,0x3a,0x57,0xc6,0xff,0x5d,0x30,
	0x83,0x52,0xb4,0x61,0xec,0xe6,0x9f,0x3c,0x28,0x4f,0x2c,0x24,0x12,0x20,0x00,0x00,
	0x0a,0x91,0x11,0x83,0xf6,0x00,0x00,0x00,0x00,0x10,0x05,0x00,0x00,0x00,0x00,0x00,
	0x0f,0x42,0x40,0xa0,0x00,0x00,0x8a,0xc5,0x33,0xff,0x38,0x65,0x55,0xb3,0x60,0x01,
	0x02,0x2f,0xd9,0x23,0x60,0x1e,0x1c,0xa0,0xac,0xe5,0x06,0x8c,0xe4,0x8e,0x14,0xf3,
	0xcd,0x31,0x44,0x16,0xc4,0x0d,0x2e,0x14,0x8c,0xa1,0xc8,0x4f,0xa6,0xa8,0xe4,0x64,
	0x9b,0x45,0x79,0xd1,0xb5,0x2f,0x04,0x19,0x86,0xe5,0x5c,0x99,0x43,0xf1,0xd0,0xf3,
	0x6f,0x52,0xd6,0x88,0xf0,0x9b,0x9c,0x58,0x98,0x69,0x0d,0x4e,0x76,0x3e,0xbd,0x6e,
	0x95,0x06,0x22,0x6e,0x46,0x11,0x1a,0x0b,0x59,0xca,0xaf,0x12,0x60,0x43,0xeb,0x5b,
	0xbf,0x28,0xc3,0x4f,0x3a,0x5e,0x33,0x2a,0x1f,0xc7,0xb2,0xb7,0x3c,0xf1,0x88,0x91,
	0x0f,0x00,0x00,0x67,0x00,0x00,0x01,0x00,0x00,0x65,0x55,0xb3,0x60,0x01,0x00,0x00,
	0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
	0x0a,0x00,0x00,0x00,0x00,0x3b,0x02,0x33,0x80,0x20,0x00,0x00,0x95,0x97,0xd7,0xa4,
	0x39,0x65,0x55,0xb3,0x65,0x01,0x01,0x36,0x59,0x20,0x77,0x0e,0xf4,0x73,0x10,0xd7,
	0xb6,0x59,0x5a,0x7c,0xbe,0xd0,0x56,0x51,0x3d,0x97,0xbe,0x84,0xb7,0x02,0xb5,0x89,
	0x72,0xbd,0xb3,0x19,0x2a,0x54,0x5f,0x57,0x52,0x09,0x1d,0xff,0x0f,0xe6,0x70,0x1e,
	0x71,0x23,0xaa,0x3f,0x98,0x89,0x86,0x35,0x87,0xc2,0x66,0xd9,0x99,0xbd,0xa2,0x7e,
	0x16,0x12,0xd9,0x6b,0xc4,0xd3,0x0c,0x00,0x07,0x88,0xa0,0x00,0x0a,0x0a,0x69,0xa2,
	0x65,0x55,0xb3,0x65,0x02,0x2d,0x22,0x36,0x20,0xa3,0x59,0xa4,0x7f,0xf7,0xf7,0xac,
	0x44,0x7c,0x85,0xc4,0x6c,0x92,0x3d,0xa5,0x33,0x89,0x22,0x1a,0x00,0x54,0xc1,0x1c,
	0x1e,0x3c,0xa3,0x1d,0x59,0x02,0x2d,0x22,0x53,0x49,0x4c,0x45,0x4e,0x54,0x41,0x52,
	0x54,0x49,0x53,0x54,0x2d,0x31,0x2d,0x31,0x2d,0x67,0x63,0x63,0x65,0x34,0x66,0x36,
	0x38,0x2d,0x6d,0x6f,0x64,0x64,0x65,0x64,0x00,0x00,0xa0,0x00,0x00,0x8a,0xd0,0xde,
	0x20,0xc6,0x65,0x55,0xb3,0x60,0x01,0x02,0x11,0xd6,0x4b,0xc5,0x88,0x33,0x4b,0x6c,
	0x1e,0x0c,0x4c,0x5c,0x65,0x69,0x35,0x66,0x45,0x80,0xbc,0x4b,0x56,0x3d,0x98,0x2c,
	0xb3,0x45,0xef,0x22,0x44,0x6e,0xca,0x6c,0x1f,0xe9,0x2a,0xf2,0x4a,0xe1,0x26,0xdb,
	0x15,0x6f,0x7e,0x3b,0xdd,0xd3,0x40,0x54,0xb2,0xc7,0x07,0xfe,0x67,0xb0,0xf3,0x35,
	0x56,0x25,0xc6,0x53,0xfd,0x54,0x56,0x5e,0x06,0x22,0x6e,0x46,0x11,0x1a,0x0b,0x59,
	0xca,0xaf,0x12,0x60,0x43,0xeb,0x5b,0xbf,0x28,0xc3,0x4f,0x3a,0x5e,0x33,0x2a,0x1f,
	0xc7,0xb2,0xb7,0x3c,0xf1,0x88,0x91,0x0f,0x00,0x00,0x67,0x00,0x00,0x01,0x00,0x00,
	0x65,0x55,0xb3,0x60,0x01,0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x00,0x3b,0x02,0x33,0x80,
	0x20,0x00,0x00,0x95,0x87,0xf8,0x92,0xf3,0x65,0x55,0xb3,0x65,0x01,0x01,0x32,0x6c,
	0xde,0x4a,0xc5,0xe8,0xd4,0xa0,0xed,0xbc,0x2c,0x13,0x5e,0xb9,0x1e,0xc3,0xc3,0x86,
	0xcb,0x75,0xeb,0x6f,0xce,0xc5,0xc5,0x57,0x01,0x1c,0x9c,0xb7,0x32,0x17,0x01,0x10,
	0x8c,0xdd,0x04,0x31,0x78,0xae,0xb4,0x88,0x8d,0xf8,0xe8,0x35,0x90,0x69,0x91,0x84,
	0xd0,0x16,0xd8,0x44,0xbc,0xde,0x37,0xe8,0x4e,0x1a,0x95,0xb6,0xa6,0x73,0x00,0x07,
	0x88,0xa0,0x00,0x0a,0x0a,0x69,0xa2,0x65,0x55,0xb3,0x65,0x03,0x5d,0x2b,0x11,0x92,
	0xdf,0xba,0x13,0x4e,0x10,0xe5,0x40,0x87,0x5d,0x36,0x6e,0xbc,0x8b,0xc3,0x53,0xd5,
	0xaa,0x76,0x6b,0x80,0xc0,0x90,0xb3,0x9c,0x3a,0x5d,0x88,0x5d,0x03,0x5d,0x2b,0x48,
	0x4f,0x50,0x50,0x49,0x4e,0x47,0x46,0x49,0x52,0x45,0x2d,0x63,0x31,0x2d,0x31,0x2d,
	0x67,0x63,0x63,0x65,0x34,0x66,0x36,0x38,0x2d,0x6d,0x6f,0x64,0x64,0x65,0x64,0x00,
	0x00,0x20,0x00,0x00,0x8a,0xcb,0xd4,0xc7,0xa1,0x65,0x55,0xb3,0x65,0x01,0x02,0x1d,
	0x3f,0x42,0x7f,0x3d,0xdb,0x58,0x2b,0xcb,0x78,0x5d,0x24,0xf1,0x67,0xc6,0xc7,0xd8,
	0x6e,0x6c,0x5b,0xf8,0xfb,0x27,0x17,0x58,0xaa,0x7e,0x46,0x86,0x49,0x66,0x21,0x47,
	0x76,0xbd,0xf2,0x2d,0xae,0x29,0xf0,0x6f,0x17,0x6e,0xf2,0x7f,0x01,0xda,0x16,0xa9,
	0x1d,0x6a,0x61,0x4c,0x41,0x71,0x19,0x4d,0x37,0xac,0x8a,0x28,0xd8,0x62,0xfb,0x06,
	0x22,0x6e,0x46,0x11,0x1a,0x0b,0x59,0xca,0xaf,0x12,0x60,0x43,0xeb,0x5b,0xbf,0x28,
	0xc3,0x4f,0x3a,0x5e,0x33,0x2a,0x1f,0xc7,0xb2,0xb7,0x3c,0xf1,0x88,0x91,0x0f,0x00,
	0x00,0x67,0x00,0x00,0x01,0x00,0x00,0x65,0x55,0xb3,0x65,0x01,0x00,0x00,0x06,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x03,0xe8,0x00,
	0x00,0x00,0x00,0x3b,0x02,0x33,0x80,0x20,0x00,0x00,0x8a,0xbf,0x0d,0x7a,0xbc,0x65,
	0x55,0xb3,0x6f,0x01,0x02,0x59,0xc9,0x36,0x84,0xaa,0x13,0x70,0x73,0x7d,0xa7,0xe6,
	0x8a,0x72,0x05,0x15,0xa9,0x06,0x69,0xe0,0xc0,0x0d,0x15,0x6d,0x22,0x5c,0xd6,0x1a,
	0x3e,0x56,0xaa,0x9d,0x98,0x68,0x5a,0x3c,0xdc,0x38,0x71,0xee,0x0d,0x02,0x3e,0x2f,
	0xd0,0x97,0xd7,0xab,0xe2,0x0d,0xdf,0xf5,0xa6,0xd1,0x9c,0xb6,0xb9,0x30,0xd6,0xdd,
	0x10,0xa7,0xa3,0xce,0x5e,0x06,0x22,0x6e,0x46,0x11,0x1a,0x0b,0x59,0xca,0xaf,0x12,
	0x60,0x43,0xeb,0x5b,0xbf,0x28,0xc3,0x4f,0x3a,0x5e,0x33,0x2a,0x1f,0xc7,0xb2,0xb7,
	0x3c,0xf1,0x88,0x91,0x0f,0x00,0x00,0x67,0x00,0x00,0x01,0x00,0x00,0x65,0x55,0xb3,
	0x6f,0x01,0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x14,0x00,0x00,0x03,0xe8,0x00,0x00,0x00,0x00,0x3b,0x02,0x33,0x80,0x20,0x00,0x01,
	0xb0,0xb8,0x17,0x71,0xe9,0x65,0x55,0xb3,0x71,0x01,0x00,0x0d,0xef,0xc0,0x12,0x4f,
	0xd4,0xe4,0x1c,0xce,0xc3,0xf4,0x83,0x17,0x21,0x7e,0x33,0x11,0x5a,0x8f,0x8c,0x39,
	0xae,0xbb,0x06,0x2b,0x4e,0x73,0xa6,0x52,0xee,0x0e,0x61,0x03,0xf9,0xf1,0x16,0x7b,
	0x22,0xbd,0xcb,0x92,0xcf,0x82,0x2d,0x0f,0xcc,0x26,0xcb,0x11,0x9f,0x0a,0xf5,0x23,
	0xf4,0x26,0x97,0x86,0x7e,0x21,0x51,0x85,0x16,0x3a,0x0e,0x4b,0x1f,0x64,0xf3,0x62,
	0xf4,0x2f,0x13,0x54,0x5c,0x9a,0xed,0xd6,0x9d,0x5d,0xf5,0x17,0x85,0xcc,0x5d,0x53,
	0xa4,0x84,0x36,0x9b,0xe9,0xa7,0x4a,0x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,0x7c,0x85,0xc4,0x6c,0x92,0x3d,0xa5,0x33,0x89,0x22,0x1a,0x00,0x54,0xc1,
	0x1c,0x1e,0x3c,0xa3,0x1d,0x59,0x02,0x66,0xe4,0x59,0x8d,0x1d,0x3c,0x41,0x5f,0x57,
	0x2a,0x84,0x88,0x83,0x0b,0x60,0xf7,0xe7,0x44,0xed,0x92,0x35,0xeb,0x0b,0x1b,0xa9,
	0x32,0x83,0xb3,0x15,0xc0,0x35,0x18,0x03,0xbb,0xee,0x60,0xc3,0x95,0x05,0x6b,0x8a,
	0x12,0x01,0xe0,0x6e,0xd7,0x9e,0x29,0x14,0xc1,0x1a,0x61,0xd7,0xb1,0xaa,0x78,0x18,
	0x46,0x46,0x8d,0x02,0x48,0x9d,0xba,0x69,0x02,0x32,0x42,0x66,0xde,0x84,0x03,0xb3,
	0xab,0x15,0x7a,0x09,0xf1,0xf7,0x84,0xd5,0x87,0xaf,0x61,0x83,0x1c,0x99,0x8c,0x15,
	0x1b,0xcc,0x21,0xbb,0x74,0xc2,0xb2,0x31,0x4b,0x20,0x00,0x00,0x0a,0x91,0x11,0x83,
	0xf6,0x00,0x00,0x00,0x00,0x10,0x05,0x00,0x00,0x00,0x00,0x00,0x0f,0x42,0x40,0x20,
	0x00,0x00,0x8a,0xe1,0x31,0x6b,0x76,0x65,0x55,0xb3,0x71,0x01,0x02,0x5d,0xf9,0x14,
	0xa0,0xd1,0x46,0x69,0x9a,0x2a,0x97,0xf7,0xb3,0x83,0xf0,0x30,0x73,0x48,0x5e,0x7b,
	0x3e,0x6c,0x45,0xd3,0xf1,0x51,0xf8,0xbc,0x4b,0xd7,0xae,0x02,0xd9,0x57,0x51,0x73,
	0x8f,0x0f,0xd0,0xdd,0x38,0x36,0x48,0xcd,0xda,0xea,0x01,0x24,0x16,0x3d,0x14,0x7e,
	0x5a,0x9e,0xac,0xcd,0x81,0xd1,0x96,0x30,0xd9,0xbc,0xa6,0xe4,0xe8,0x06,0x22,0x6e,
	0x46,0x11,0x1a,0x0b,0x59,0xca,0xaf,0x12,0x60,0x43,0xeb,0x5b,0xbf,0x28,0xc3,0x4f,
	0x3a,0x5e,0x33,0x2a,0x1f,0xc7,0xb2,0xb7,0x3c,0xf1,0x88,0x91,0x0f,0x00,0x00,0x6e,
	0x00,0x00,0x01,0x00,0x00,0x65,0x55,0xb3,0x71,0x01,0x00,0x00,0x06,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x03,0xe8,0x00,0x00,0x00,
	0x00,0x3b,0x02,0x33,0x80,0x20,0x00,0x00,0x8a,0xbd,0x6f,0x26,0xdf,0x65,0x55,0xb3,
	0x71,0x01,0x02,0x26,0x62,0x25,0x68,0x2d,0x27,0x06,0x9a,0x3b,0xaa,0x1a,0x43,0x93,
	0xac,0xb5,0x05,0x14,0x1c,0x09,0x22,0x8d,0xfb,0x54,0x43,0x73,0x3a,0x88,0xaa,0xa3,
	0x18,0xc8,0xd8,0x0d,0x36,0xd4,0x26,0x10,0xe9,0x82,0xa6,0x3c,0xb4,0x38,0x24,0xaf,
	0xdc,0x06,0xd5,0x3d,0xe3,0x7a,0xe8,0x39,0xdd,0xd4,0x5f,0xd8,0x92,0xf5,0x4b,0xe7,
	0x8d,0xf7,0xab,0x06,0x22,0x6e,0x46,0x11,0x1a,0x0b,0x59,0xca,0xaf,0x12,0x60,0x43,
	0xeb,0x5b,0xbf,0x28,0xc3,0x4f,0x3a,0x5e,0x33,0x2a,0x1f,0xc7,0xb2,0xb7,0x3c,0xf1,
	0x88,0x91,0x0f,0x00,0x00,0x6e,0x00,0x00,0x01,0x00,0x00,0x65,0x55,0xb3,0x71,0x01,
	0x01,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x00,
	0x00,0x03,0xe8,0x00,0x00,0x00,0x00,0x3b,0x02,0x33,0x80,0x20,0x00,0x00,0x95,0xf6,
	0xd7,0x24,0x69,0x65,0x55,0xb3,0x79,0x01,0x01,0x42,0x62,0x2b,0xf0,0x0a,0x44,0xc3,
	0xe0,0x78,0x3c,0xa7,0x08,0x5a,0xa0,0xaa,0x9d,0xb2,0xdc,0x2e,0xa7,0x29,0x0a,0x39,
	0x3d,0x01,0x57,0xbf,0x34,0x23,0x0f,0xb9,0x19,0x33,0x6f,0xc2,0xfb,0x9f,0x25,0xac,
	0xc4,0xc9,0x47,0xb7,0x41,0x92,0xdb,0x2f,0xd5,0xf0,0x1f,0x24,0x32,0xdf,0x38,0x30,
	0x89,0x93,0xeb,0xc9,0xec,0xf1,0x09,0x51,0xbb,0x00,0x07,0x88,0xa0,0x00,0x0a,0x0a,
	0x69,0xa2,0x65,0x55,0xb3,0x79,0x02,0x66,0xe4,0x59,0x8d,0x1d,0x3c,0x41,0x5f,0x57,
	0x2a,0x84,0x88,0x83,0x0b,0x60,0xf7,0xe7,0x44,0xed,0x92,0x35,0xeb,0x0b,0x1b,0xa9,
	0x32,0x83,0xb3,0x15,0xc0,0x35,0x18,0x02,0x66,0xe4,0x4a,0x55,0x4e,0x49,0x4f,0x52,
	0x42,0x45,0x41,0x4d,0x2d,0x72,0x63,0x31,0x2d,0x31,0x2d,0x67,0x63,0x63,0x65,0x34,
	0x66,0x36,0x38,0x2d,0x6d,0x6f,0x64,0x64,0x65,0x64,0x00,0x00,
};

/* A BOLT #11 route hint (`r` field) hop is a struct route_info:
 *   { pubkey, short_channel_id, fee_base_msat, fee_proportional_millionths,
 *     cltv_expiry_delta }.
 * xpay's add_routehint() turns each hop into a private-layer channel:
 * askrene-create-channel (gossmap_local_addchan) then askrene-update-channel
 * (gossmap_local_setchan) carrying the hop's cltv_expiry_delta, in the
 * direction node_id_idx(hop.pubkey, next).  We build one hop from the example
 * fields and apply it exactly as add_routehint() does. */
static void apply_routehint_hop(struct gossmap_localmods *mods,
				const struct node_id *src,
				const struct node_id *dst,
				struct short_channel_id scid,
				struct amount_msat capacity,
				struct amount_msat fee_base_msat,
				u32 fee_proportional_millionths,
				u16 cltv_expiry_delta)
{
	int dir = node_id_idx(src, dst);

	/* askrene-create-channel: a no-op when scid is already known. */
	assert(gossmap_local_addchan(mods, src, dst, scid, capacity, NULL));
	/* askrene-update-channel: carries the hint's cltv_expiry_delta. */
	assert(gossmap_local_setchan(mods, scid,
				     AMOUNT_MSAT(0), capacity,
				     fee_base_msat, fee_proportional_millionths,
				     cltv_expiry_delta, true, dir));
}

static u16 scid_delay(const struct gossmap *map, struct short_channel_id scid,
		      int dir)
{
	u32 timestamp, fee_base_msat, fee_proportional_millionths;
	u16 cltv_expiry_delta;
	u8 message_flags, channel_flags;
	struct amount_msat htlc_minimum_msat, htlc_maximum_msat;

	gossmap_chan_get_update_details(map, gossmap_find_chan(map, &scid), dir,
					&timestamp, &message_flags,
					&channel_flags, &cltv_expiry_delta,
					&fee_base_msat,
					&fee_proportional_millionths,
					&htlc_minimum_msat, &htlc_maximum_msat);
	return cltv_expiry_delta;
}

int main(int argc, char *argv[])
{
	int fd;
	char *gossfile;
	struct gossmap *map;
	struct node_id l1, l2, l3, hop;
	struct short_channel_id scid12;
	struct gossmap_localmods *mods;
	int dir;
	u16 before, after;

	common_setup(argv[0]);

	fd = tmpdir_mkstemp(tmpctx, "run-gossmap_local-routehint.XXXXXX", &gossfile);
	assert(write_all(fd, canned_map, sizeof(canned_map)));

	map = gossmap_load(tmpctx, gossfile, NULL, NULL);
	assert(map);

	/* Canned map: l1 is the payer A, its peer l2 is B, and 110x1x0 is the
	 * A-B channel l1 already knows.  l1 sorts after l2. */
	assert(node_id_from_hexstr("0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518", 66, &l1));
	assert(node_id_from_hexstr("022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59", 66, &l2));
	assert(node_id_from_hexstr("035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d", 66, &l3));
	assert(short_channel_id_from_str("110x1x0", 7, &scid12));
	assert(gossmap_find_chan(map, &scid12));

	/* The route hint hop, built from the example fields: pubkey 6*G (not the
	 * payer), the known A-B short_channel_id, zero fees, cltv_expiry_delta
	 * 1000.  The next hop is B (l2), so add_routehint() keeps this hop and
	 * applies it in direction node_id_idx(6*G, l2). */
	assert(node_id_from_hexstr("03fff97bd5755eeea420453a14355235d382f6472f8568a18b2f057a1460297556", 66, &hop));
	/* add_routehint() drops only hops whose pubkey is the payer's. */
	assert(node_id_cmp(&hop, &l1) != 0);
	dir = node_id_idx(&hop, &l2);

	before = scid_delay(map, scid12, dir);
	warnx("known channel 110x1x0 dir %i cltv_expiry_delta before: %u",
	      dir, before);

	mods = gossmap_localmods_new(tmpctx);
	apply_routehint_hop(mods, &hop, &l2, scid12,
			    AMOUNT_MSAT(100000000),
			    AMOUNT_MSAT(0), 0, 1000);
	gossmap_apply_localmods(map, mods);

	after = scid_delay(map, scid12, dir);
	warnx("known channel 110x1x0 dir %i cltv_expiry_delta after hint: %u",
	      dir, after);

	/* A route hint reusing a channel the payer already knows must not change
	 * that channel's cltv_expiry_delta.  The hop's 1000 overwrites it
	 * instead, so A's HTLC to B gets the inflated delay the draft reports. */
	assert(after == before);

	common_shutdown();
}

Build and run it with make unittest/common/test/run-gossmap_local-routehint. The output on master 1ebc494 is:

run-gossmap_local-routehint: known channel 110x1x0 dir 1 cltv_expiry_delta before: 6
run-gossmap_local-routehint: known channel 110x1x0 dir 1 cltv_expiry_delta after hint: 1000
run-gossmap_local-routehint: common/test/run-gossmap_local-routehint.c:286: main: Assertion `after == before' failed.
make: *** [Makefile:942: unittest/common/test/run-gossmap_local-routehint] Error 134

add_routehint drops only a hint hop whose node id is the payer's at xpay.c:2114-2117. It keeps a hop whose short_channel_id belongs to a channel the payer already knows. Then gossmap_apply_localmods applies the hint's cltv_expiry_delta to that existing channel instead of adding a new one at gossmap.c:1233-1241. The same reuse of a public channel's scid loses the hop, so route finding reports a payee reachable only through it as "Unknown destination node".

A hint that reuses a known channel's scid should not change that channel's cltv_expiry_delta. A's HTLC to B then keeps the expiry it has without the hop, height + 28.

getinfo output

master 1ebc4943ed37: "version": "1ebc494", "network": "regtest"
v26.06.9, a2176589f235: "version": "a217658", "network": "regtest"

Activity

  1. added a commit that references this issue on Nov 15, 2026
    967c76f
  2. AkashKP02 commented on Nov 15, 2026

    @AkashKP02

    Hi @Nuhiat-Arefin , I've opened #9736 to resolve this issue. Please let me know your thoughts on this implementation when you have a moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions