This is perhaps an overly complicated way to complete this task. For example, it's probably simpler to use the "Extract Vertices" and "Explode Lines" tools in QGIS. Then use the Field Calculator on the exploded lines to calculate bearing: degrees(azimuth(point_n($geometry,1),point_n($geometry,2)))
and distance: $length
. Then join the results to the extracted vertices.
The results of the script look like this in QGIS: