mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 21:35:11 +01:00
common: remove unused functions or make static.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
d9968bbc0c
commit
786732601c
@ -415,17 +415,17 @@ struct tlv_invoice *invoice_decode(const tal_t *ctx,
|
||||
return invoice;
|
||||
}
|
||||
|
||||
bool bolt12_has_invoice_prefix(const char *str)
|
||||
static bool bolt12_has_invoice_prefix(const char *str)
|
||||
{
|
||||
return strstarts(str, "lni1") || strstarts(str, "LNI1");
|
||||
}
|
||||
|
||||
bool bolt12_has_request_prefix(const char *str)
|
||||
static bool bolt12_has_request_prefix(const char *str)
|
||||
{
|
||||
return strstarts(str, "lnr1") || strstarts(str, "LNR1");
|
||||
}
|
||||
|
||||
bool bolt12_has_offer_prefix(const char *str)
|
||||
static bool bolt12_has_offer_prefix(const char *str)
|
||||
{
|
||||
return strstarts(str, "lno1") || strstarts(str, "LNO1");
|
||||
}
|
||||
|
@ -115,21 +115,6 @@ void offer_period_paywindow(const struct tlv_offer_recurrence *recurrence,
|
||||
u64 *period_start, u64 *period_end);
|
||||
|
||||
|
||||
/**
|
||||
* Preliminary prefix check to see if the string might be a bolt12 invoice.
|
||||
*/
|
||||
bool bolt12_has_invoice_prefix(const char *str);
|
||||
|
||||
/**
|
||||
* Preliminary prefix check to see if the string might be a bolt12 request.
|
||||
*/
|
||||
bool bolt12_has_request_prefix(const char *str);
|
||||
|
||||
/**
|
||||
* Preliminary prefix check to see if the string might be a bolt12 offer.
|
||||
*/
|
||||
bool bolt12_has_offer_prefix(const char *str);
|
||||
|
||||
/**
|
||||
* Preliminary prefix check to see if the string might be a bolt12 string.
|
||||
*/
|
||||
|
@ -35,12 +35,6 @@ u32 dijkstra_distance(const struct dijkstra *dij, u32 node_idx)
|
||||
return dij[node_idx].distance;
|
||||
}
|
||||
|
||||
/* Total CLTV delay */
|
||||
u32 dijkstra_delay(const struct dijkstra *dij, u32 node_idx)
|
||||
{
|
||||
return dij[node_idx].total_delay;
|
||||
}
|
||||
|
||||
struct gossmap_chan *dijkstra_best_chan(const struct dijkstra *dij,
|
||||
u32 node_idx)
|
||||
{
|
||||
|
@ -39,9 +39,6 @@ dijkstra_(const tal_t *ctx,
|
||||
/* Returns UINT_MAX if unreachable. */
|
||||
u32 dijkstra_distance(const struct dijkstra *dij, u32 node_idx);
|
||||
|
||||
/* Total CLTV delay (0 if unreachable) */
|
||||
u32 dijkstra_delay(const struct dijkstra *dij, u32 node_idx);
|
||||
|
||||
/* Best path we found to here */
|
||||
struct gossmap_chan *dijkstra_best_chan(const struct dijkstra *dij,
|
||||
u32 node_idx);
|
||||
|
@ -43,12 +43,6 @@ struct gossip_hdr {
|
||||
*/
|
||||
u8 *gossip_store_next(const tal_t *ctx, struct per_peer_state *pps);
|
||||
|
||||
/**
|
||||
* Switches the gossip store fd, and gets to the correct offset.
|
||||
*/
|
||||
void gossip_store_switch_fd(struct per_peer_state *pps,
|
||||
int newfd, u64 offset_shorter);
|
||||
|
||||
/**
|
||||
* Sets up the tiemstamp filter once they told us to set it.(
|
||||
*/
|
||||
|
@ -5,8 +5,8 @@
|
||||
#include <common/htlc_wire.h>
|
||||
#include <common/onionreply.h>
|
||||
|
||||
struct failed_htlc *failed_htlc_dup(const tal_t *ctx,
|
||||
const struct failed_htlc *f TAKES)
|
||||
static struct failed_htlc *failed_htlc_dup(const tal_t *ctx,
|
||||
const struct failed_htlc *f TAKES)
|
||||
{
|
||||
struct failed_htlc *newf;
|
||||
|
||||
@ -129,7 +129,7 @@ void towire_failed_htlc(u8 **pptr, const struct failed_htlc *failed)
|
||||
}
|
||||
}
|
||||
|
||||
void towire_htlc_state(u8 **pptr, const enum htlc_state hstate)
|
||||
static void towire_htlc_state(u8 **pptr, const enum htlc_state hstate)
|
||||
{
|
||||
towire_u8(pptr, hstate);
|
||||
}
|
||||
@ -234,7 +234,7 @@ struct failed_htlc *fromwire_failed_htlc(const tal_t *ctx, const u8 **cursor, si
|
||||
return failed;
|
||||
}
|
||||
|
||||
enum htlc_state fromwire_htlc_state(const u8 **cursor, size_t *max)
|
||||
static enum htlc_state fromwire_htlc_state(const u8 **cursor, size_t *max)
|
||||
{
|
||||
enum htlc_state hstate = fromwire_u8(cursor, max);
|
||||
if (hstate >= HTLC_STATE_INVALID) {
|
||||
|
@ -74,14 +74,11 @@ struct existing_htlc *new_existing_htlc(const tal_t *ctx,
|
||||
const struct preimage *preimage TAKES,
|
||||
const struct failed_htlc *failed TAKES);
|
||||
|
||||
struct failed_htlc *failed_htlc_dup(const tal_t *ctx, const struct failed_htlc *f TAKES);
|
||||
|
||||
void towire_added_htlc(u8 **pptr, const struct added_htlc *added);
|
||||
void towire_existing_htlc(u8 **pptr, const struct existing_htlc *existing);
|
||||
void towire_fulfilled_htlc(u8 **pptr, const struct fulfilled_htlc *fulfilled);
|
||||
void towire_failed_htlc(u8 **pptr, const struct failed_htlc *failed);
|
||||
void towire_changed_htlc(u8 **pptr, const struct changed_htlc *changed);
|
||||
void towire_htlc_state(u8 **pptr, const enum htlc_state hstate);
|
||||
void towire_side(u8 **pptr, const enum side side);
|
||||
void towire_shachain(u8 **pptr, const struct shachain *shachain);
|
||||
|
||||
@ -95,7 +92,6 @@ struct failed_htlc *fromwire_failed_htlc(const tal_t *ctx, const u8 **cursor,
|
||||
size_t *max);
|
||||
void fromwire_changed_htlc(const u8 **cursor, size_t *max,
|
||||
struct changed_htlc *changed);
|
||||
enum htlc_state fromwire_htlc_state(const u8 **cursor, size_t *max);
|
||||
enum side fromwire_side(const u8 **cursor, size_t *max);
|
||||
void fromwire_shachain(const u8 **cursor, size_t *max,
|
||||
struct shachain *shachain);
|
||||
|
@ -300,8 +300,9 @@ const jsmntok_t *json_next(const jsmntok_t *tok)
|
||||
return t;
|
||||
}
|
||||
|
||||
const jsmntok_t *json_get_membern(const char *buffer, const jsmntok_t tok[],
|
||||
const char *label, size_t len)
|
||||
static const jsmntok_t *json_get_membern(const char *buffer,
|
||||
const jsmntok_t tok[],
|
||||
const char *label, size_t len)
|
||||
{
|
||||
const jsmntok_t *t;
|
||||
size_t i;
|
||||
@ -665,20 +666,6 @@ const char *jsmntype_to_string(jsmntype_t t)
|
||||
return "INVALID";
|
||||
}
|
||||
|
||||
void json_tok_print(const char *buffer, const jsmntok_t *tok)
|
||||
{
|
||||
const jsmntok_t *first = tok;
|
||||
const jsmntok_t *last = json_next(tok);
|
||||
printf("size: %d, count: %td\n", tok->size, last - first);
|
||||
while (first != last) {
|
||||
printf("%td. %.*s, %s\n", first - tok,
|
||||
first->end - first->start, buffer + first->start,
|
||||
jsmntype_to_string(first->type));
|
||||
first++;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
jsmntok_t *json_tok_copy(const tal_t *ctx, const jsmntok_t *tok)
|
||||
{
|
||||
return tal_dup_arr(ctx, jsmntok_t, tok, json_next(tok) - tok, 0);
|
||||
|
@ -90,10 +90,6 @@ const jsmntok_t *json_next(const jsmntok_t *tok);
|
||||
const jsmntok_t *json_get_member(const char *buffer, const jsmntok_t tok[],
|
||||
const char *label);
|
||||
|
||||
/* Get top-level member, with explicit label length */
|
||||
const jsmntok_t *json_get_membern(const char *buffer, const jsmntok_t tok[],
|
||||
const char *label, size_t len);
|
||||
|
||||
/* Get index'th array member. */
|
||||
const jsmntok_t *json_get_arr(const jsmntok_t tok[], size_t index);
|
||||
|
||||
@ -134,9 +130,6 @@ jsmntok_t *json_parse_simple(const tal_t *ctx, const char *input, int len);
|
||||
/* Convert a jsmntype_t enum to a human readable string. */
|
||||
const char *jsmntype_to_string(jsmntype_t t);
|
||||
|
||||
/* Print a json value for debugging purposes. */
|
||||
void json_tok_print(const char *buffer, const jsmntok_t *params);
|
||||
|
||||
/* Return a copy of a json value as an array. */
|
||||
jsmntok_t *json_tok_copy(const tal_t *ctx, const jsmntok_t *tok);
|
||||
|
||||
|
@ -282,18 +282,6 @@ void json_add_short_channel_id(struct json_stream *response,
|
||||
short_channel_id_outnum(scid));
|
||||
}
|
||||
|
||||
void json_add_short_channel_id_dir(struct json_stream *response,
|
||||
const char *fieldname,
|
||||
const struct short_channel_id_dir *scidd)
|
||||
{
|
||||
json_add_member(response, fieldname, true, "%dx%dx%d/%d",
|
||||
short_channel_id_blocknum(&scidd->scid),
|
||||
short_channel_id_txnum(&scidd->scid),
|
||||
short_channel_id_outnum(&scidd->scid),
|
||||
scidd->dir
|
||||
);
|
||||
}
|
||||
|
||||
void json_add_address(struct json_stream *response, const char *fieldname,
|
||||
const struct wireaddr *addr)
|
||||
{
|
||||
|
@ -132,11 +132,6 @@ void json_add_short_channel_id(struct json_stream *response,
|
||||
const char *fieldname,
|
||||
const struct short_channel_id *id);
|
||||
|
||||
/* '"fieldname" : "1234:5:6/7"' */
|
||||
void json_add_short_channel_id_dir(struct json_stream *response,
|
||||
const char *fieldname,
|
||||
const struct short_channel_id_dir *id);
|
||||
|
||||
/* JSON serialize a network address for a node */
|
||||
void json_add_address(struct json_stream *response, const char *fieldname,
|
||||
const struct wireaddr *addr);
|
||||
|
@ -43,7 +43,13 @@ struct json_stream *json_stream_dup(const tal_t *ctx,
|
||||
return js;
|
||||
}
|
||||
|
||||
bool json_stream_still_writing(const struct json_stream *js)
|
||||
/**
|
||||
* json_stream_still_writing - is someone currently writing to this stream?
|
||||
* @js: the json_stream.
|
||||
*
|
||||
* Has this json_stream not been closed yet?
|
||||
*/
|
||||
static bool json_stream_still_writing(const struct json_stream *js)
|
||||
{
|
||||
return js->writer != NULL;
|
||||
}
|
||||
|
@ -65,15 +65,6 @@ void json_stream_close(struct json_stream *js, struct command *writer);
|
||||
/* For low-level JSON stream access: */
|
||||
void json_stream_log_suppress(struct json_stream *js, const char *cmd_name);
|
||||
|
||||
/**
|
||||
* json_stream_still_writing - is someone currently writing to this stream?
|
||||
* @js: the json_stream.
|
||||
*
|
||||
* Has this json_stream not been closed yet?
|
||||
*/
|
||||
bool json_stream_still_writing(const struct json_stream *js);
|
||||
|
||||
|
||||
/* '"fieldname" : [ ' or '[ ' if fieldname is NULL */
|
||||
void json_array_start(struct json_stream *js, const char *fieldname);
|
||||
/* '"fieldname" : { ' or '{ ' if fieldname is NULL */
|
||||
|
@ -581,9 +581,11 @@ struct command_result *param_extra_tlvs(struct command *cmd, const char *name,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct command_result *param_routehint(struct command *cmd, const char *name,
|
||||
const char *buffer, const jsmntok_t *tok,
|
||||
struct route_info **ri)
|
||||
static struct command_result *param_routehint(struct command *cmd,
|
||||
const char *name,
|
||||
const char *buffer,
|
||||
const jsmntok_t *tok,
|
||||
struct route_info **ri)
|
||||
{
|
||||
size_t i;
|
||||
const jsmntok_t *curr;
|
||||
|
@ -198,10 +198,6 @@ struct command_result *param_extra_tlvs(struct command *cmd, const char *name,
|
||||
const jsmntok_t *tok,
|
||||
struct tlv_field **fields);
|
||||
|
||||
struct command_result *param_routehint(struct command *cmd, const char *name,
|
||||
const char *buffer, const jsmntok_t *tok,
|
||||
struct route_info **ri);
|
||||
|
||||
struct command_result *
|
||||
param_routehint_array(struct command *cmd, const char *name, const char *buffer,
|
||||
const jsmntok_t *tok, struct route_info ***ris);
|
||||
|
@ -2,93 +2,6 @@
|
||||
#include <common/permute_tx.h>
|
||||
#include <wally_psbt.h>
|
||||
|
||||
static bool input_better(const struct wally_tx_input *a,
|
||||
const struct wally_tx_input *b)
|
||||
{
|
||||
int cmp;
|
||||
|
||||
cmp = memcmp(a->txhash, b->txhash, sizeof(a->txhash));
|
||||
if (cmp != 0)
|
||||
return cmp < 0;
|
||||
if (a->index != b->index)
|
||||
return a->index < b->index;
|
||||
|
||||
/* These shouldn't happen, but let's get a canonical order anyway. */
|
||||
if (a->script_len != b->script_len)
|
||||
return a->script_len < b->script_len;
|
||||
|
||||
cmp = memcmp(a->script, b->script, a->script_len);
|
||||
if (cmp != 0)
|
||||
return cmp < 0;
|
||||
return a->sequence < b->sequence;
|
||||
}
|
||||
|
||||
static size_t find_best_in(struct wally_tx_input *inputs, size_t num)
|
||||
{
|
||||
size_t i, best = 0;
|
||||
|
||||
for (i = 1; i < num; i++) {
|
||||
if (input_better(&inputs[i], &inputs[best]))
|
||||
best = i;
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
static void swap_wally_inputs(struct wally_tx_input *inputs,
|
||||
struct wally_tx_input *psbt_global_ins,
|
||||
struct wally_psbt_input *psbt_ins,
|
||||
const void **map,
|
||||
size_t i1, size_t i2)
|
||||
{
|
||||
struct wally_tx_input tmpinput;
|
||||
struct wally_psbt_input tmppsbtin;
|
||||
const void *tmp;
|
||||
|
||||
if (i1 == i2)
|
||||
return;
|
||||
|
||||
tmpinput = inputs[i1];
|
||||
inputs[i1] = inputs[i2];
|
||||
inputs[i2] = tmpinput;
|
||||
|
||||
/* For the PSBT, we swap the psbt inputs and
|
||||
* the global tx's inputs */
|
||||
tmpinput = psbt_global_ins[i1];
|
||||
psbt_global_ins[i1] = psbt_global_ins[i2];
|
||||
psbt_global_ins[i2] = tmpinput;
|
||||
|
||||
tmppsbtin = psbt_ins[i1];
|
||||
psbt_ins[i1] = psbt_ins[i2];
|
||||
psbt_ins[i2] = tmppsbtin;
|
||||
|
||||
if (map) {
|
||||
tmp = map[i1];
|
||||
map[i1] = map[i2];
|
||||
map[i2] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
void permute_inputs(struct bitcoin_tx *tx, const void **map)
|
||||
{
|
||||
size_t i, best_pos;
|
||||
struct wally_tx_input *inputs = tx->wtx->inputs;
|
||||
size_t num_inputs = tx->wtx->num_inputs;
|
||||
|
||||
/* We can't permute nothing! */
|
||||
if (num_inputs == 0)
|
||||
return;
|
||||
|
||||
/* Now do a dumb sort (num_inputs is small). */
|
||||
for (i = 0; i < num_inputs-1; i++) {
|
||||
best_pos = i + find_best_in(inputs + i, num_inputs - i);
|
||||
/* Swap best into first place. */
|
||||
swap_wally_inputs(tx->wtx->inputs,
|
||||
tx->psbt->tx->inputs,
|
||||
tx->psbt->inputs,
|
||||
map, i, best_pos);
|
||||
}
|
||||
}
|
||||
|
||||
static void swap_wally_outputs(struct wally_tx_output *outputs,
|
||||
struct wally_tx_output *psbt_global_outs,
|
||||
struct wally_psbt_output *psbt_outs,
|
||||
|
@ -5,13 +5,6 @@
|
||||
|
||||
struct htlc;
|
||||
|
||||
/**
|
||||
* permute_inputs: permute the transaction inputs into BIP69 order.
|
||||
* @tx: the transaction whose inputs are to be sorted (inputs must be tal_arr).
|
||||
* @map: if non-NULL, pointers to be permuted the same as the inputs.
|
||||
*/
|
||||
void permute_inputs(struct bitcoin_tx *tx, const void **map);
|
||||
|
||||
/**
|
||||
* permute_outputs: permute the transaction outputs into BIP69 + cltv order.
|
||||
* @tx: the transaction whose outputs are to be sorted (outputs must be tal_arr).
|
||||
|
Loading…
Reference in New Issue
Block a user