mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
sphinx: Cleanup route_step_decode_* functions
We have consolidated the two functions into a single `route_step_decode` function, and made it static since we call it in the `process_onionpacket` function. We remove the two exposed functions since they're no longer useful.
This commit is contained in:
committed by
Rusty Russell
parent
d7b28ac480
commit
e46f423ae9
@@ -932,74 +932,3 @@ struct onionreply *unwrap_onionreply(const tal_t *ctx,
|
||||
return oreply;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to extract fields from ONION_END.
|
||||
*/
|
||||
bool route_step_decode_end(const struct route_step *rs,
|
||||
struct amount_msat *amt_forward,
|
||||
u32 *outgoing_cltv)
|
||||
{
|
||||
assert(rs->nextcase == ONION_END);
|
||||
|
||||
switch (rs->type) {
|
||||
case SPHINX_V0_PAYLOAD:
|
||||
*amt_forward = rs->payload.v0.amt_forward;
|
||||
*outgoing_cltv = rs->payload.v0.outgoing_cltv;
|
||||
return true;
|
||||
case SPHINX_TLV_PAYLOAD:
|
||||
if (!rs->payload.tlv->amt_to_forward)
|
||||
return false;
|
||||
if (!rs->payload.tlv->outgoing_cltv_value)
|
||||
return false;
|
||||
amt_forward->millisatoshis /* Raw: tu64 -> millisatoshis */
|
||||
= rs->payload.tlv->amt_to_forward->amt_to_forward;
|
||||
*outgoing_cltv = rs->payload.tlv->outgoing_cltv_value->outgoing_cltv_value;
|
||||
return true;
|
||||
case SPHINX_INVALID_PAYLOAD:
|
||||
return false;
|
||||
|
||||
/* This should probably be removed, as it's just for testing */
|
||||
case SPHINX_RAW_PAYLOAD:
|
||||
abort();
|
||||
}
|
||||
abort();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to extract fields from ONION_FORWARD.
|
||||
*/
|
||||
bool route_step_decode_forward(const struct route_step *rs,
|
||||
struct amount_msat *amt_forward,
|
||||
u32 *outgoing_cltv,
|
||||
struct short_channel_id *scid)
|
||||
{
|
||||
assert(rs->nextcase == ONION_FORWARD);
|
||||
|
||||
switch (rs->type) {
|
||||
case SPHINX_V0_PAYLOAD:
|
||||
*amt_forward = rs->payload.v0.amt_forward;
|
||||
*outgoing_cltv = rs->payload.v0.outgoing_cltv;
|
||||
*scid = rs->payload.v0.channel_id;
|
||||
return true;
|
||||
case SPHINX_TLV_PAYLOAD:
|
||||
if (!rs->payload.tlv->amt_to_forward)
|
||||
return false;
|
||||
amt_forward->millisatoshis /* Raw: tu64 -> millisatoshis */
|
||||
= rs->payload.tlv->amt_to_forward->amt_to_forward;
|
||||
if (!rs->payload.tlv->outgoing_cltv_value)
|
||||
return false;
|
||||
*outgoing_cltv = rs->payload.tlv->outgoing_cltv_value->outgoing_cltv_value;
|
||||
if (!rs->payload.tlv->short_channel_id)
|
||||
return false;
|
||||
*scid = rs->payload.tlv->short_channel_id->short_channel_id;
|
||||
return true;
|
||||
case SPHINX_INVALID_PAYLOAD:
|
||||
return false;
|
||||
|
||||
/* This should probably be removed, as it's just for testing */
|
||||
case SPHINX_RAW_PAYLOAD:
|
||||
abort();
|
||||
}
|
||||
abort();
|
||||
}
|
||||
|
||||
@@ -249,18 +249,4 @@ void sphinx_add_final_hop(struct sphinx_path *path,
|
||||
struct amount_msat forward,
|
||||
u32 outgoing_cltv);
|
||||
|
||||
/**
|
||||
* Helper to extract fields from ONION_END.
|
||||
*/
|
||||
bool route_step_decode_end(const struct route_step *rs,
|
||||
struct amount_msat *amt_forward,
|
||||
u32 *outgoing_cltv);
|
||||
|
||||
/**
|
||||
* Helper to extract fields from ONION_FORWARD.
|
||||
*/
|
||||
bool route_step_decode_forward(const struct route_step *rs,
|
||||
struct amount_msat *amt_forward,
|
||||
u32 *outgoing_cltv,
|
||||
struct short_channel_id *scid);
|
||||
#endif /* LIGHTNING_COMMON_SPHINX_H */
|
||||
|
||||
@@ -524,17 +524,6 @@ struct route_step *process_onionpacket(
|
||||
const size_t assocdatalen
|
||||
)
|
||||
{ fprintf(stderr, "process_onionpacket called!\n"); abort(); }
|
||||
/* Generated stub for route_step_decode_end */
|
||||
bool route_step_decode_end(const struct route_step *rs UNNEEDED,
|
||||
struct amount_msat *amt_forward UNNEEDED,
|
||||
u32 *outgoing_cltv UNNEEDED)
|
||||
{ fprintf(stderr, "route_step_decode_end called!\n"); abort(); }
|
||||
/* Generated stub for route_step_decode_forward */
|
||||
bool route_step_decode_forward(const struct route_step *rs UNNEEDED,
|
||||
struct amount_msat *amt_forward UNNEEDED,
|
||||
u32 *outgoing_cltv UNNEEDED,
|
||||
struct short_channel_id *scid UNNEEDED)
|
||||
{ fprintf(stderr, "route_step_decode_forward called!\n"); abort(); }
|
||||
/* Generated stub for serialize_onionpacket */
|
||||
u8 *serialize_onionpacket(
|
||||
const tal_t *ctx UNNEEDED,
|
||||
|
||||
Reference in New Issue
Block a user