From 484222b0a191412ee7a6cb9e937362683cc8e361 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sat, 4 Dec 2021 21:57:06 +1030 Subject: [PATCH] daemons: remove unused functions or make static. Signed-off-by: Rusty Russell --- gossipd/gossip_store.h | 3 - gossipd/gossipd.h | 6 -- lightningd/channel_control.c | 2 +- lightningd/channel_control.h | 3 - lightningd/connect_control.h | 1 - lightningd/gossip_msg.c | 187 ----------------------------------- lightningd/gossip_msg.h | 15 --- lightningd/plugin.c | 105 ++++++++++---------- lightningd/plugin.h | 14 --- plugins/funder_policy.c | 2 +- plugins/funder_policy.h | 14 --- wallet/invoices.h | 16 --- wallet/wallet.c | 112 +++++++-------------- wallet/wallet.h | 95 +----------------- wallet/walletrpc.c | 6 +- wallet/walletrpc.h | 7 -- wire/tlvstream.c | 45 --------- wire/tlvstream.h | 6 -- 18 files changed, 95 insertions(+), 544 deletions(-) diff --git a/gossipd/gossip_store.h b/gossipd/gossip_store.h index 597c781c7af3..f717491896fe 100644 --- a/gossipd/gossip_store.h +++ b/gossipd/gossip_store.h @@ -92,7 +92,4 @@ bool gossip_store_compact(struct gossip_store *gs); */ int gossip_store_readonly_fd(struct gossip_store *gs); -/* Callback inside gossipd when store is compacted */ -void update_peers_broadcast_index(struct list_head *peers, u32 offset); - #endif /* LIGHTNING_GOSSIPD_GOSSIP_STORE_H */ diff --git a/gossipd/gossipd.h b/gossipd/gossipd.h index db37dbfdcf9d..fe2082c74b26 100644 --- a/gossipd/gossipd.h +++ b/gossipd/gossipd.h @@ -128,10 +128,4 @@ void queue_peer_msg(struct peer *peer, const u8 *msg TAKES); void queue_peer_from_store(struct peer *peer, const struct broadcastable *bcast); -/* Reset gossip range for this peer. */ -void setup_gossip_range(struct peer *peer); - -/* A peer has given us these short channel ids: see if we need to catch up */ -void process_scids(struct daemon *daemon, const struct short_channel_id *scids); - #endif /* LIGHTNING_GOSSIPD_GOSSIPD_H */ diff --git a/lightningd/channel_control.c b/lightningd/channel_control.c index b8d90cbcba23..e6fb0af00ab0 100644 --- a/lightningd/channel_control.c +++ b/lightningd/channel_control.c @@ -404,7 +404,7 @@ static void handle_error_channel(struct channel *channel, forget(channel); } -void forget_channel(struct channel *channel, const char *why) +static void forget_channel(struct channel *channel, const char *why) { channel->error = towire_errorfmt(channel, &channel->cid, "%s", why); diff --git a/lightningd/channel_control.h b/lightningd/channel_control.h index bf32b5897ba4..ce91cf68bcfc 100644 --- a/lightningd/channel_control.h +++ b/lightningd/channel_control.h @@ -36,9 +36,6 @@ bool channel_on_funding_locked(struct channel *channel, /* Record channel open (coin movement notifications) */ void channel_record_open(struct channel *channel); -/* Forget a channel. Deletes the channel and handles all - * associated waiting commands, if present. Notifies peer if available */ -void forget_channel(struct channel *channel, const char *err_msg); /* A channel has unrecoverably fallen behind */ void channel_fallen_behind(struct channel *channel, const u8 *msg); diff --git a/lightningd/connect_control.h b/lightningd/connect_control.h index 9714aa158996..830332b3d37c 100644 --- a/lightningd/connect_control.h +++ b/lightningd/connect_control.h @@ -15,6 +15,5 @@ void delay_then_reconnect(struct channel *channel, u32 seconds_delay, void connect_succeeded(struct lightningd *ld, const struct peer *peer, bool incoming, const struct wireaddr_internal *addr); -void gossip_connect_result(struct lightningd *ld, const u8 *msg); #endif /* LIGHTNING_LIGHTNINGD_CONNECT_CONTROL_H */ diff --git a/lightningd/gossip_msg.c b/lightningd/gossip_msg.c index 20dcc5f97625..9e74c5904831 100644 --- a/lightningd/gossip_msg.c +++ b/lightningd/gossip_msg.c @@ -5,113 +5,6 @@ #include #include -struct gossip_getnodes_entry *fromwire_gossip_getnodes_entry(const tal_t *ctx, - const u8 **pptr, size_t *max) -{ - u8 numaddresses, i; - struct gossip_getnodes_entry *entry; - u16 flen; - bool has_rates; - - entry = tal(ctx, struct gossip_getnodes_entry); - fromwire_node_id(pptr, max, &entry->nodeid); - - entry->last_timestamp = fromwire_u64(pptr, max); - if (entry->last_timestamp < 0) { - entry->addresses = NULL; - return entry; - } - - flen = fromwire_u16(pptr, max); - entry->features = fromwire_tal_arrn(entry, pptr, max, flen); - - numaddresses = fromwire_u8(pptr, max); - - entry->addresses = tal_arr(entry, struct wireaddr, numaddresses); - for (i=0; iaddresses[i])) - return fromwire_fail(pptr, max); - } - fromwire(pptr, max, entry->alias, ARRAY_SIZE(entry->alias)); - fromwire(pptr, max, entry->color, ARRAY_SIZE(entry->color)); - - has_rates = fromwire_u8(pptr, max); - if (has_rates) { - entry->rates = tal(entry, struct lease_rates); - fromwire_lease_rates(pptr, max, entry->rates); - } else - entry->rates = NULL; - - return entry; -} - -void towire_gossip_getnodes_entry(u8 **pptr, - const struct gossip_getnodes_entry *entry) -{ - towire_node_id(pptr, &entry->nodeid); - towire_u64(pptr, entry->last_timestamp); - - if (entry->last_timestamp < 0) - return; - - towire_u16(pptr, tal_count(entry->features)); - towire_u8_array(pptr, entry->features, tal_count(entry->features)); - towire_u8(pptr, tal_count(entry->addresses)); - for (size_t i = 0; i < tal_count(entry->addresses); i++) { - towire_wireaddr(pptr, &entry->addresses[i]); - } - towire(pptr, entry->alias, ARRAY_SIZE(entry->alias)); - towire(pptr, entry->color, ARRAY_SIZE(entry->color)); - - if (entry->rates) { - towire_u8(pptr, 1); - towire_lease_rates(pptr, entry->rates); - } else - towire_u8(pptr, 0); -} - -struct route_hop *fromwire_route_hop(const tal_t *ctx, - const u8 **pptr, size_t *max) -{ - struct route_hop *entry = tal(ctx, struct route_hop); - size_t enclen; - - fromwire_node_id(pptr, max, &entry->node_id); - fromwire_short_channel_id(pptr, max, &entry->scid); - entry->direction = fromwire_u8(pptr, max); - entry->amount = fromwire_amount_msat(pptr, max); - entry->delay = fromwire_u32(pptr, max); - entry->style = fromwire_u8(pptr, max); - if (fromwire_bool(pptr, max)) { - entry->blinding = tal(entry, struct pubkey); - fromwire_pubkey(pptr, max, entry->blinding); - } - enclen = fromwire_u16(pptr, max); - if (enclen) - entry->enctlv = fromwire_tal_arrn(entry, pptr, max, enclen); - else - entry->enctlv = NULL; - return entry; -} - -void towire_route_hop(u8 **pptr, const struct route_hop *entry) -{ - towire_node_id(pptr, &entry->node_id); - towire_short_channel_id(pptr, &entry->scid); - towire_u8(pptr, entry->direction); - towire_amount_msat(pptr, entry->amount); - towire_u32(pptr, entry->delay); - towire_u8(pptr, entry->style); - if (entry->blinding) { - towire_bool(pptr, true); - towire_pubkey(pptr, entry->blinding); - } else - towire_bool(pptr, false); - towire_u16(pptr, tal_bytelen(entry->enctlv)); - towire_u8_array(pptr, entry->enctlv, tal_bytelen(entry->enctlv)); -} - void fromwire_route_info(const u8 **pptr, size_t *max, struct route_info *entry) { fromwire_node_id(pptr, max, &entry->pubkey); @@ -129,83 +22,3 @@ void towire_route_info(u8 **pptr, const struct route_info *entry) towire_u32(pptr, entry->fee_proportional_millionths); towire_u16(pptr, entry->cltv_expiry_delta); } - -static void fromwire_gossip_halfchannel_entry(const u8 **pptr, size_t *max, - struct gossip_halfchannel_entry *entry) -{ - entry->message_flags = fromwire_u8(pptr, max); - entry->channel_flags = fromwire_u8(pptr, max); - entry->last_update_timestamp = fromwire_u32(pptr, max); - entry->delay = fromwire_u32(pptr, max); - entry->base_fee_msat = fromwire_u32(pptr, max); - entry->fee_per_millionth = fromwire_u32(pptr, max); - entry->min = fromwire_amount_msat(pptr, max); - entry->max = fromwire_amount_msat(pptr, max); -} - -struct gossip_getchannels_entry * -fromwire_gossip_getchannels_entry(const tal_t *ctx, - const u8 **pptr, size_t *max) -{ - struct gossip_getchannels_entry *entry; - - entry= tal(ctx, struct gossip_getchannels_entry); - fromwire_node_id(pptr, max, &entry->node[0]); - fromwire_node_id(pptr, max, &entry->node[1]); - entry->sat = fromwire_amount_sat(pptr, max); - fromwire_short_channel_id(pptr, max, &entry->short_channel_id); - entry->public = fromwire_bool(pptr, max); - entry->local_disabled = fromwire_bool(pptr, max); - entry->features = fromwire_tal_arrn(entry, - pptr, max, fromwire_u16(pptr, max)); - - if (fromwire_bool(pptr, max)) { - entry->e[0] = tal(entry, struct gossip_halfchannel_entry); - fromwire_gossip_halfchannel_entry(pptr, max, entry->e[0]); - } else - entry->e[0] = NULL; - if (fromwire_bool(pptr, max)) { - entry->e[1] = tal(entry, struct gossip_halfchannel_entry); - fromwire_gossip_halfchannel_entry(pptr, max, entry->e[1]); - } else - entry->e[1] = NULL; - - return entry; -} - -static void towire_gossip_halfchannel_entry(u8 **pptr, - const struct gossip_halfchannel_entry *entry) -{ - towire_u8(pptr, entry->message_flags); - towire_u8(pptr, entry->channel_flags); - towire_u32(pptr, entry->last_update_timestamp); - towire_u32(pptr, entry->delay); - towire_u32(pptr, entry->base_fee_msat); - towire_u32(pptr, entry->fee_per_millionth); - towire_amount_msat(pptr, entry->min); - towire_amount_msat(pptr, entry->max); -} - -void towire_gossip_getchannels_entry(u8 **pptr, - const struct gossip_getchannels_entry *entry) -{ - towire_node_id(pptr, &entry->node[0]); - towire_node_id(pptr, &entry->node[1]); - towire_amount_sat(pptr, entry->sat); - towire_short_channel_id(pptr, &entry->short_channel_id); - towire_bool(pptr, entry->public); - towire_bool(pptr, entry->local_disabled); - towire_u16(pptr, tal_bytelen(entry->features)); - towire_u8_array(pptr, entry->features, tal_bytelen(entry->features)); - if (entry->e[0]) { - towire_bool(pptr, true); - towire_gossip_halfchannel_entry(pptr, entry->e[0]); - } else - towire_bool(pptr, false); - - if (entry->e[1]) { - towire_bool(pptr, true); - towire_gossip_halfchannel_entry(pptr, entry->e[1]); - } else - towire_bool(pptr, false); -} diff --git a/lightningd/gossip_msg.h b/lightningd/gossip_msg.h index b259705d93ec..3e65236d6fb7 100644 --- a/lightningd/gossip_msg.h +++ b/lightningd/gossip_msg.h @@ -38,22 +38,7 @@ struct gossip_getchannels_entry { u8 *features; }; -struct gossip_getnodes_entry * -fromwire_gossip_getnodes_entry(const tal_t *ctx, const u8 **pptr, size_t *max); -void towire_gossip_getnodes_entry(u8 **pptr, - const struct gossip_getnodes_entry *entry); - -struct route_hop *fromwire_route_hop(const tal_t *ctx, - const u8 **pptr, size_t *max); -void towire_route_hop(u8 **pprt, const struct route_hop *entry); - void fromwire_route_info(const u8 **pprt, size_t *max, struct route_info *entry); void towire_route_info(u8 **pprt, const struct route_info *entry); -struct gossip_getchannels_entry * -fromwire_gossip_getchannels_entry(const tal_t *ctx, - const u8 **pptr, size_t *max); -void towire_gossip_getchannels_entry( - u8 **pptr, const struct gossip_getchannels_entry *entry); - #endif /* LIGHTNING_LIGHTNINGD_GOSSIP_MSG_H */ diff --git a/lightningd/plugin.c b/lightningd/plugin.c index d37b6135cac1..142f20ed143b 100644 --- a/lightningd/plugin.c +++ b/lightningd/plugin.c @@ -110,6 +110,30 @@ static void plugin_check_subscriptions(struct plugins *plugins, } } +static bool plugins_any_in_state(const struct plugins *plugins, + enum plugin_state state) +{ + const struct plugin *p; + + list_for_each(&plugins->plugins, p, list) { + if (p->plugin_state == state) + return true; + } + return false; +} + +static bool plugins_all_in_state(const struct plugins *plugins, + enum plugin_state state) +{ + const struct plugin *p; + + list_for_each(&plugins->plugins, p, list) { + if (p->plugin_state != state) + return false; + } + return true; +} + /* Once they've all replied with their manifests, we can order them. */ static void check_plugins_manifests(struct plugins *plugins) { @@ -493,6 +517,36 @@ static const char *plugin_notification_handle(struct plugin *plugin, return NULL; } +struct plugin_destroyed { + const struct plugin *plugin; +}; + +static void mark_plugin_destroyed(const struct plugin *unused, + struct plugin_destroyed *pd) +{ + pd->plugin = NULL; +} + +static struct plugin_destroyed * +plugin_detect_destruction(const struct plugin *plugin) +{ + struct plugin_destroyed *pd = tal(NULL, struct plugin_destroyed); + pd->plugin = plugin; + tal_add_destructor2(plugin, mark_plugin_destroyed, pd); + return pd; +} + +static bool was_plugin_destroyed(struct plugin_destroyed *pd) +{ + if (pd->plugin) { + tal_del_destructor2(pd->plugin, mark_plugin_destroyed, pd); + tal_free(pd); + return false; + } + tal_free(pd); + return true; +} + /* Returns the error string, or NULL */ static const char *plugin_response_handle(struct plugin *plugin, const jsmntok_t *toks, @@ -1459,28 +1513,6 @@ static const char *plugin_parse_getmanifest_response(const char *buffer, return err; } -bool plugins_any_in_state(const struct plugins *plugins, enum plugin_state state) -{ - const struct plugin *p; - - list_for_each(&plugins->plugins, p, list) { - if (p->plugin_state == state) - return true; - } - return false; -} - -bool plugins_all_in_state(const struct plugins *plugins, enum plugin_state state) -{ - const struct plugin *p; - - list_for_each(&plugins->plugins, p, list) { - if (p->plugin_state != state) - return false; - } - return true; -} - /** * Callback for the plugin_manifest request. */ @@ -2056,35 +2088,6 @@ void plugins_set_builtin_plugins_dir(struct plugins *plugins, NULL, NULL); } -struct plugin_destroyed { - const struct plugin *plugin; -}; - -static void mark_plugin_destroyed(const struct plugin *unused, - struct plugin_destroyed *pd) -{ - pd->plugin = NULL; -} - -struct plugin_destroyed *plugin_detect_destruction(const struct plugin *plugin) -{ - struct plugin_destroyed *pd = tal(NULL, struct plugin_destroyed); - pd->plugin = plugin; - tal_add_destructor2(plugin, mark_plugin_destroyed, pd); - return pd; -} - -bool was_plugin_destroyed(struct plugin_destroyed *pd) -{ - if (pd->plugin) { - tal_del_destructor2(pd->plugin, mark_plugin_destroyed, pd); - tal_free(pd); - return false; - } - tal_free(pd); - return true; -} - static void plugin_shutdown_timeout(struct lightningd *ld) { io_break(plugin_shutdown_timeout); diff --git a/lightningd/plugin.h b/lightningd/plugin.h index 5aef22ce1bd2..d26509472a30 100644 --- a/lightningd/plugin.h +++ b/lightningd/plugin.h @@ -266,16 +266,6 @@ struct command_result *plugin_register_all_complete(struct lightningd *ld, */ void plugins_config(struct plugins *plugins); -/** - * Are any plugins at this state still? - */ -bool plugins_any_in_state(const struct plugins *plugins, enum plugin_state state); - -/** - * Are all plugins at this state? - */ -bool plugins_all_in_state(const struct plugins *plugins, enum plugin_state state); - /** * This populates the jsonrpc request with the plugin/lightningd specifications */ @@ -372,8 +362,4 @@ struct log *plugin_get_log(struct plugin *plugin); void plugins_set_builtin_plugins_dir(struct plugins *plugins, const char *dir); -/* Pair of functions to detect if plugin destroys itself: must always - * call both! */ -struct plugin_destroyed *plugin_detect_destruction(const struct plugin *plugin); -bool was_plugin_destroyed(struct plugin_destroyed *destroyed); #endif /* LIGHTNING_LIGHTNINGD_PLUGIN_H */ diff --git a/plugins/funder_policy.c b/plugins/funder_policy.c index e28fe679cf91..5584cfd58cd0 100644 --- a/plugins/funder_policy.c +++ b/plugins/funder_policy.c @@ -51,7 +51,7 @@ const char *funder_policy_desc(const tal_t *ctx, /* FIXME: add in more info? */ } -struct funder_policy * +static struct funder_policy * new_funder_policy(const tal_t *ctx, enum funder_opt opt, u64 policy_mod, diff --git a/plugins/funder_policy.h b/plugins/funder_policy.h index 80840b3e6fa8..8b38ec51c1a8 100644 --- a/plugins/funder_policy.h +++ b/plugins/funder_policy.h @@ -63,20 +63,6 @@ struct funder_policy { struct lease_rates *rates; }; -struct funder_policy * -new_funder_policy(const tal_t *ctx, - enum funder_opt opt, - u64 policy_mod, - struct amount_sat min_their_funding, - struct amount_sat max_their_funding, - struct amount_sat per_channel_min, - struct amount_sat per_channel_max, - u32 fuzz_factor, - struct amount_sat reserve_tank, - u32 fund_probability, - bool leases_only, - struct lease_rates *rates); - /* Get a new funder_policy, set to the defaults */ struct funder_policy * default_funder_policy(const tal_t *ctx, diff --git a/wallet/invoices.h b/wallet/invoices.h index 7a65971f5c8b..00acf384c772 100644 --- a/wallet/invoices.h +++ b/wallet/invoices.h @@ -118,22 +118,6 @@ bool invoices_delete(struct invoices *invoices, void invoices_delete_expired(struct invoices *invoices, u64 max_expiry_time); -/** - * invoices_autoclean_set - Set up automatic deletion of - * expired invoices. - * - * @invoices - the invoice handler. - * @cycle_seconds - The number of seconds to repeat the - * automatic deletion. If 0, do not perform automatic - * deletion. - * @expiry_by - Each cycle, delete invoices that - * have been expired for at least `expiry_by` - * seconds. - */ -void invoices_autoclean_set(struct invoices *invoices, - u64 cycle_seconds, - u64 expired_by); - /** * invoices_iterate - Iterate over all existing invoices * diff --git a/wallet/wallet.c b/wallet/wallet.c index e035686f4425..98d650ba6a87 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -393,25 +393,6 @@ struct utxo *wallet_utxo_get(const tal_t *ctx, struct wallet *w, return utxo; } -bool wallet_unreserve_output(struct wallet *w, - const struct bitcoin_outpoint *outpoint) -{ - return wallet_update_output_status(w, outpoint, - OUTPUT_STATE_RESERVED, - OUTPUT_STATE_AVAILABLE); -} - -void wallet_confirm_utxos(struct wallet *w, const struct utxo **utxos) -{ - for (size_t i = 0; i < tal_count(utxos); i++) { - if (!wallet_update_output_status( - w, &utxos[i]->outpoint, - OUTPUT_STATE_RESERVED, OUTPUT_STATE_SPENT)) { - fatal("Unable to mark output as spent"); - } - } -} - static void db_set_utxo(struct db *db, const struct utxo *utxo) { struct db_stmt *stmt; @@ -634,8 +615,8 @@ bool wallet_add_onchaind_utxo(struct wallet *w, return true; } -bool wallet_can_spend(struct wallet *w, const u8 *script, - u32 *index, bool *output_is_p2sh) +static bool wallet_can_spend(struct wallet *w, const u8 *script, + u32 *index, bool *output_is_p2sh) { struct ext_key ext; u64 bip32_max_index = db_get_intvar(w->db, "bip32_max_index", 0); @@ -774,8 +755,8 @@ bool wallet_shachain_add_hash(struct wallet *wallet, return true; } -bool wallet_shachain_load(struct wallet *wallet, u64 id, - struct wallet_shachain *chain) +static bool wallet_shachain_load(struct wallet *wallet, u64 id, + struct wallet_shachain *chain) { struct db_stmt *stmt; chain->id = id; @@ -1194,6 +1175,37 @@ static bool wallet_channel_load_inflights(struct wallet *w, return ok; } +static bool wallet_channel_config_load(struct wallet *w, const u64 id, + struct channel_config *cc) +{ + bool ok = true; + const char *query = SQL( + "SELECT dust_limit_satoshis, max_htlc_value_in_flight_msat, " + "channel_reserve_satoshis, htlc_minimum_msat, to_self_delay, " + "max_accepted_htlcs, max_dust_htlc_exposure_msat" + " FROM channel_configs WHERE id= ? ;"); + struct db_stmt *stmt = db_prepare_v2(w->db, query); + db_bind_u64(stmt, 0, id); + db_query_prepared(stmt); + + if (!db_step(stmt)) + return false; + + cc->id = id; + db_col_amount_sat(stmt, "dust_limit_satoshis", &cc->dust_limit); + db_col_amount_msat(stmt, "max_htlc_value_in_flight_msat", + &cc->max_htlc_value_in_flight); + db_col_amount_sat(stmt, "channel_reserve_satoshis", + &cc->channel_reserve); + db_col_amount_msat(stmt, "htlc_minimum_msat", &cc->htlc_minimum); + cc->to_self_delay = db_col_int(stmt, "to_self_delay"); + cc->max_accepted_htlcs = db_col_int(stmt, "max_accepted_htlcs"); + db_col_amount_msat(stmt, "max_dust_htlc_exposure_msat", + &cc->max_dust_htlc_exposure_msat); + tal_free(stmt); + return ok; +} + /** * wallet_stmt2channel - Helper to populate a wallet_channel from a `db_stmt` */ @@ -1737,37 +1749,6 @@ static void wallet_channel_config_save(struct wallet *w, db_exec_prepared_v2(take(stmt)); } -bool wallet_channel_config_load(struct wallet *w, const u64 id, - struct channel_config *cc) -{ - bool ok = true; - const char *query = SQL( - "SELECT dust_limit_satoshis, max_htlc_value_in_flight_msat, " - "channel_reserve_satoshis, htlc_minimum_msat, to_self_delay, " - "max_accepted_htlcs, max_dust_htlc_exposure_msat" - " FROM channel_configs WHERE id= ? ;"); - struct db_stmt *stmt = db_prepare_v2(w->db, query); - db_bind_u64(stmt, 0, id); - db_query_prepared(stmt); - - if (!db_step(stmt)) - return false; - - cc->id = id; - db_col_amount_sat(stmt, "dust_limit_satoshis", &cc->dust_limit); - db_col_amount_msat(stmt, "max_htlc_value_in_flight_msat", - &cc->max_htlc_value_in_flight); - db_col_amount_sat(stmt, "channel_reserve_satoshis", - &cc->channel_reserve); - db_col_amount_msat(stmt, "htlc_minimum_msat", &cc->htlc_minimum); - cc->to_self_delay = db_col_int(stmt, "to_self_delay"); - cc->max_accepted_htlcs = db_col_int(stmt, "max_accepted_htlcs"); - db_col_amount_msat(stmt, "max_dust_htlc_exposure_msat", - &cc->max_dust_htlc_exposure_msat); - tal_free(stmt); - return ok; -} - u64 wallet_get_channel_dbid(struct wallet *wallet) { return ++wallet->max_channel_dbid; @@ -3064,29 +3045,6 @@ void wallet_payment_store(struct wallet *wallet, } } -void wallet_payment_delete(struct wallet *wallet, - const struct sha256 *payment_hash, - u64 partid) -{ - struct db_stmt *stmt; - struct wallet_payment *payment; - - payment = find_unstored_payment(wallet, payment_hash, partid); - if (payment) { - tal_free(payment); - return; - } - - stmt = db_prepare_v2( - wallet->db, SQL("DELETE FROM payments WHERE payment_hash = ?" - " AND partid = ?")); - - db_bind_sha256(stmt, 0, payment_hash); - db_bind_u64(stmt, 1, partid); - - db_exec_prepared_v2(take(stmt)); -} - u64 wallet_payment_get_groupid(struct wallet *wallet, const struct sha256 *payment_hash) { diff --git a/wallet/wallet.h b/wallet/wallet.h index 833f3ef60621..619cb464bb1d 100644 --- a/wallet/wallet.h +++ b/wallet/wallet.h @@ -490,37 +490,6 @@ void wallet_unreserve_utxo(struct wallet *w, struct utxo *utxo, struct utxo *wallet_utxo_get(const tal_t *ctx, struct wallet *w, const struct bitcoin_outpoint *outpoint); -/** - * wallet_select_specific - Select utxos given an array of txids and an array of outputs index - * - * Returns an array of `utxo` structs. - */ -const struct utxo **wallet_select_specific(const tal_t *ctx, struct wallet *w, - struct bitcoin_txid **txids, - u32 **outnums); - -/** - * wallet_confirm_utxos - Once we've spent a set of utxos, mark them confirmed. - * - * May be called once the transaction spending these UTXOs has been - * broadcast. If something fails use `tal_free(utxos)` instead to undo - * the reservation. - */ -void wallet_confirm_utxos(struct wallet *w, const struct utxo **utxos); - -/** - * wallet_can_spend - Do we have the private key matching this scriptpubkey? - * - * FIXME: This is very slow with lots of inputs! - * - * @w: (in) wallet holding the pubkeys to check against (privkeys are on HSM) - * @script: (in) the script to check - * @index: (out) the bip32 derivation index that matched the script - * @output_is_p2sh: (out) whether the script is a p2sh, or p2wpkh - */ -bool wallet_can_spend(struct wallet *w, const u8 *script, - u32 *index, bool *output_is_p2sh); - /** * wallet_get_newindex - get a new index from the wallet. * @ld: (in) lightning daemon @@ -537,17 +506,6 @@ bool wallet_shachain_add_hash(struct wallet *wallet, uint64_t index, const struct secret *hash); -/** - * wallet_shachain_load -- Load an existing shachain from the wallet. - * - * @wallet: the wallet to load from - * @id: the shachain id to load - * @chain: where to load the shachain into - */ -bool wallet_shachain_load(struct wallet *wallet, u64 id, - struct wallet_shachain *chain); - - /** * wallet_get_uncommitted_channel_dbid -- get a unique channel dbid * @@ -617,12 +575,6 @@ struct state_change_entry *wallet_state_change_get(struct wallet *w, */ void wallet_peer_delete(struct wallet *w, u64 peer_dbid); -/** - * wallet_channel_config_load -- Load channel_config from database into cc - */ -bool wallet_channel_config_load(struct wallet *w, const u64 id, - struct channel_config *cc); - /** * wallet_init_channels -- Loads active channels into peers * and inits the dbid counter for next channel. @@ -938,16 +890,6 @@ bool wallet_invoice_delete(struct wallet *wallet, void wallet_invoice_delete_expired(struct wallet *wallet, u64 max_expiry_time); -/** - * wallet_invoice_autoclean - Set up a repeating autoclean of - * expired invoices. - * Cleans (deletes) expired invoices every @cycle_seconds. - * Clean only those invoices that have been expired for at - * least @expired_by seconds or more. - */ -void wallet_invoice_autoclean(struct wallet * wallet, - u64 cycle_seconds, - u64 expired_by); /** * wallet_invoice_iterate - Iterate over all existing invoices @@ -1082,15 +1024,6 @@ void wallet_payment_setup(struct wallet *wallet, struct wallet_payment *payment) void wallet_payment_store(struct wallet *wallet, struct wallet_payment *payment TAKES); -/** - * wallet_payment_delete - Remove a payment - * - * Removes the payment from the database. - */ -void wallet_payment_delete(struct wallet *wallet, - const struct sha256 *payment_hash, - u64 partid); - /** * wallet_payment_delete_by_hash - Remove a payment * @@ -1391,32 +1324,6 @@ bool wallet_remote_ann_sigs_load(const tal_t *ctx, struct wallet *w, u64 id, secp256k1_ecdsa_signature **remote_ann_node_sig, secp256k1_ecdsa_signature **remote_ann_bitcoin_sig); -/** - * wallet_clean_utxos: clean up any reserved UTXOs on restart. - * @w: wallet - * - * If we crash, it's unclear if we have actually used the inputs. eg. if - * we crash around transaction broadcast. - * - * We ask bitcoind to clarify in this case. - */ -void wallet_clean_utxos(struct wallet *w, struct bitcoind *bitcoind); - -/* Operations for unreleased transactions */ -struct unreleased_tx *find_unreleased_tx(struct wallet *w, - const struct bitcoin_txid *txid); -void remove_unreleased_tx(struct unreleased_tx *utx); -void add_unreleased_tx(struct wallet *w, struct unreleased_tx *utx); - -/* These will touch the db, so need to be explicitly freed. */ -void free_unreleased_txs(struct wallet *w); - -/* wallet_unreserve_output - Unreserve a utxo - * - * We unreserve utxos so that they can be spent elsewhere. - * */ -bool wallet_unreserve_output(struct wallet *w, - const struct bitcoin_outpoint *outpoint); /** * Get a list of transactions that we track in the wallet. * @@ -1553,7 +1460,7 @@ char *wallet_offer_find(const tal_t *ctx, * @w: the wallet * @offer_id: the first offer id (if returns non-NULL) * - * Returns pointer to hand as @stmt to wallet_offer_next(), or NULL. + * Returns pointer to hand as @stmt to wallet_offer_id_next(), or NULL. * If you choose not to call wallet_offer_id_next() you must free it! */ struct db_stmt *wallet_offer_id_first(struct wallet *w, diff --git a/wallet/walletrpc.c b/wallet/walletrpc.c index 5c1fa2e7aabe..e0c5405afe6b 100644 --- a/wallet/walletrpc.c +++ b/wallet/walletrpc.c @@ -291,9 +291,9 @@ static void json_add_utxo(struct json_stream *response, json_object_end(response); } -void json_add_utxos(struct json_stream *response, - struct wallet *wallet, - struct utxo **utxos) +static void json_add_utxos(struct json_stream *response, + struct wallet *wallet, + struct utxo **utxos) { for (size_t i = 0; i < tal_count(utxos); i++) json_add_utxo(response, NULL, wallet, utxos[i]); diff --git a/wallet/walletrpc.h b/wallet/walletrpc.h index 25af4a0a525f..5a2136fa1aa6 100644 --- a/wallet/walletrpc.h +++ b/wallet/walletrpc.h @@ -1,16 +1,9 @@ #ifndef LIGHTNING_WALLET_WALLETRPC_H #define LIGHTNING_WALLET_WALLETRPC_H #include "config.h" -#include -struct command; -struct json_stream; struct utxo; -void json_add_utxos(struct json_stream *response, - struct wallet *wallet, - struct utxo **utxos); - /* We evaluate reserved timeouts lazily, so use this. */ bool is_reserved(const struct utxo *utxo, u32 current_height); diff --git a/wire/tlvstream.c b/wire/tlvstream.c index 7b529b202b96..9bf10a77431a 100644 --- a/wire/tlvstream.c +++ b/wire/tlvstream.c @@ -82,51 +82,6 @@ void tlvstream_set_tu32(struct tlv_field **stream, u64 type, u32 value) tlvstream_set_raw(stream, type, take(ser), tal_bytelen(ser)); } -bool tlvstream_get_short_channel_id(struct tlv_field *stream, u64 type, - struct short_channel_id *value) -{ - struct tlv_field *raw = tlvstream_get_raw(stream, type); - const u8 *v; - size_t max; - if (raw == NULL || raw->length != 8) - return false; - - max = raw->length; - v = raw->value; - fromwire_short_channel_id(&v, &max, value); - - return true; -} - -bool tlvstream_get_tu64(struct tlv_field *stream, u64 type, u64 *value) -{ - struct tlv_field *raw = tlvstream_get_raw(stream, type); - const u8 *v; - size_t max; - if (raw == NULL || raw->length != 8) - return false; - - max = raw->length; - v = raw->value; - *value = fromwire_tu64(&v, &max); - - return true; -} - -bool tlvstream_get_tu32(struct tlv_field *stream, u64 type, u32 *value) -{ - struct tlv_field *raw = tlvstream_get_raw(stream, type); - const u8 *v; - size_t max; - if (raw == NULL || raw->length != 8) - return false; - - max = raw->length; - v = raw->value; - *value = fromwire_tu64(&v, &max); - return true; -} - bool fromwire_tlv(const u8 **cursor, size_t *max, const struct tlv_record_type *types, size_t num_types, void *record, struct tlv_field **fields) diff --git a/wire/tlvstream.h b/wire/tlvstream.h index eb155ce4591a..e289513e60be 100644 --- a/wire/tlvstream.h +++ b/wire/tlvstream.h @@ -55,10 +55,4 @@ void tlvstream_set_short_channel_id(struct tlv_field **stream, u64 type, void tlvstream_set_tu64(struct tlv_field **stream, u64 type, u64 value); void tlvstream_set_tu32(struct tlv_field **stream, u64 type, u32 value); -/* Generic primitive gettes for tlvstreams. */ -bool tlvstream_get_short_channel_id(struct tlv_field *stream, u64 type, - struct short_channel_id *value); -bool tlvstream_get_tu64(struct tlv_field *stream, u64 type, u64 *value); -bool tlvstream_get_tu32(struct tlv_field *stream, u64 type, u32 *value); - #endif /* LIGHTNING_WIRE_TLVSTREAM_H */