askrene: expose additional_costs htable so child can access it.
What changed, and why it matters
This commit is a straightforward code reorganization: it moves the definition of a hash table type called additional_cost_htable from a private source file into a new public header file so that a child process can use it. There is no change to program behavior, no bug fix, and no security-related change.
No security action required; treat as normal refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors the askrene plugin by extracting the per_htlc_cost struct and the additional_cost_htable HTABLE_DEFINE_NODUPS_TYPE macro invocation from plugins/askrene/askrene.c into a new header plugins/askrene/child/additional_costs.h. It adds the new header to PLUGIN_ASKRENE_HEADER in the Makefile and includes it in askrene.c. The data structures, logic, and access patterns remain identical; only visibility/compilation scope changes.
Changed components
plugins/askrene/askrene.cplugins/askrene/child/additional_costs.hplugins/askrene/MakefileInspect captured patch +34 / −26
diff --git a/plugins/askrene/Makefile b/plugins/askrene/Makefile
index fd8e9f51..d870b0a5 100644
--- a/plugins/askrene/Makefile
+++ b/plugins/askrene/Makefile
@@ -17,7 +17,7 @@ PLUGIN_ASKRENE_CHILD_SRC := \
plugins/askrene/child/child_log.c \
PLUGIN_ASKRENE_SRC := $(PLUGIN_ASKRENE_PARENT_SRC) $(PLUGIN_ASKRENE_CHILD_SRC)
-PLUGIN_ASKRENE_HEADER := $(PLUGIN_ASKRENE_SRC:.c=.h)
+PLUGIN_ASKRENE_HEADER := $(PLUGIN_ASKRENE_SRC:.c=.h) plugins/askrene/child/additional_costs.h
PLUGIN_ASKRENE_OBJS := $(PLUGIN_ASKRENE_SRC:.c=.o)
diff --git a/plugins/askrene/askrene.c b/plugins/askrene/askrene.c
index b1384299..ef6d3a71 100644
--- a/plugins/askrene/askrene.c
+++ b/plugins/askrene/askrene.c
@@ -22,6 +22,7 @@
#include <inttypes.h>
#include <math.h>
#include <plugins/askrene/askrene.h>
+#include <plugins/askrene/child/additional_costs.h>
#include <plugins/askrene/child/child_log.h>
#include <plugins/askrene/child/entry.h>
#include <plugins/askrene/layer.h>
@@ -29,31 +30,6 @@
#include <sys/wait.h>
#include <wire/wire_sync.h>
-/* "spendable" for a channel assumes a single HTLC: for additional HTLCs,
- * the need to pay for fees (if we're the owner) reduces it */
-struct per_htlc_cost {
- struct short_channel_id_dir scidd;
- struct amount_msat per_htlc_cost;
-};
-
-static const struct short_channel_id_dir *
-per_htlc_cost_key(const struct per_htlc_cost *phc)
-{
- return &phc->scidd;
-}
-
-static inline bool per_htlc_cost_eq_key(const struct per_htlc_cost *phc,
- const struct short_channel_id_dir *scidd)
-{
- return short_channel_id_dir_eq(scidd, &phc->scidd);
-}
-
-HTABLE_DEFINE_NODUPS_TYPE(struct per_htlc_cost,
- per_htlc_cost_key,
- hash_scidd,
- per_htlc_cost_eq_key,
- additional_cost_htable);
-
static bool have_layer(const char **layers, const char *name)
{
for (size_t i = 0; i < tal_count(layers); i++) {
diff --git a/plugins/askrene/child/additional_costs.h b/plugins/askrene/child/additional_costs.h
new file mode 100644
index 00000000..44eb0971
--- /dev/null
+++ b/plugins/askrene/child/additional_costs.h
@@ -0,0 +1,32 @@
+#ifndef LIGHTNING_PLUGINS_ASKRENE_CHILD_ADDITIONAL_COSTS_H
+#define LIGHTNING_PLUGINS_ASKRENE_CHILD_ADDITIONAL_COSTS_H
+#include "config.h"
+#include <ccan/htable/htable_type.h>
+#include <ccan/tal/tal.h>
+
+/* "spendable" for a channel assumes a single HTLC: for additional HTLCs,
+ * the need to pay for fees (if we're the owner) reduces it */
+struct per_htlc_cost {
+ struct short_channel_id_dir scidd;
+ struct amount_msat per_htlc_cost;
+};
+
+static inline const struct short_channel_id_dir *
+per_htlc_cost_key(const struct per_htlc_cost *phc)
+{
+ return &phc->scidd;
+}
+
+static inline bool per_htlc_cost_eq_key(const struct per_htlc_cost *phc,
+ const struct short_channel_id_dir *scidd)
+{
+ return short_channel_id_dir_eq(scidd, &phc->scidd);
+}
+
+HTABLE_DEFINE_NODUPS_TYPE(struct per_htlc_cost,
+ per_htlc_cost_key,
+ hash_scidd,
+ per_htlc_cost_eq_key,
+ additional_cost_htable);
+
+#endif /* LIGHTNING_PLUGINS_ASKRENE_CHILD_ADDITIONAL_COSTS_H */
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.