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:
Christian Decker
2019-11-19 14:33:35 +01:00
committed by Rusty Russell
parent d7b28ac480
commit e46f423ae9
3 changed files with 0 additions and 96 deletions

View File

@@ -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();
}