Wood you see scratches on typically has a surface finish by an oil or something similar. It makes the surface darker than natural wood. The scratch will expose natural wood that is lighter in color.
Walnuts contain as you say oil and when it get into the wood in the scratch it get darker and is a lot harder to see. How well it works will depend on the color of the wood and what is on it, it might not get dark enough and something else needs to be used.
It’s oil and possibly even packing in a little ‘meat’ from the nut to fill in the groove of small scratches. Oil absorbs and darkens in the scratch, hiding it. If the furniture has a really dark stain, it might not match, but if it was closer to just a good sealer on natural wood color then the walnut oil should generate a very similar shade.
Walnut oil doesn’t go ‘rancid’ as it oxidizes over time either.
You might want to lightly buff with a microfiber cloth after letting it sit a day or so. But the fix should hold up visually at least for quite a while.
They sell sealers that are mixes of carnuba wax and walnut oil for things like soapstone and cutting boards (food safe). I use one after lasering on slate coasters for better contrast pop of the resulting pattern. But for easy one step scratch fix, nothing beats a plain old shelled raw walnut.
Latest Answers