wallet: separate migration table into its own source file.
This will make it easier to share with the downgrade tool. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -237,7 +237,8 @@ struct anchor_details *create_anchor_details(const tal_t *ctx UNNEEDED,
|
||||
const struct bitcoin_tx *tx UNNEEDED)
|
||||
{ fprintf(stderr, "create_anchor_details called!\n"); abort(); }
|
||||
/* Generated stub for delete_channel */
|
||||
void delete_channel(struct channel *channel STEALS UNNEEDED, bool completely_eliminate UNNEEDED)
|
||||
void delete_channel(struct channel *channel STEALS UNNEEDED,
|
||||
bool completely_eliminate UNNEEDED)
|
||||
{ fprintf(stderr, "delete_channel called!\n"); abort(); }
|
||||
/* Generated stub for depthcb_update_scid */
|
||||
bool depthcb_update_scid(struct channel *channel UNNEEDED,
|
||||
|
||||
@@ -4,6 +4,7 @@ WALLET_LIB_SRC := \
|
||||
wallet/account_migration.c \
|
||||
wallet/db.c \
|
||||
wallet/invoices.c \
|
||||
wallet/migrations.c \
|
||||
wallet/psbt_fixup.c \
|
||||
wallet/txfilter.c \
|
||||
wallet/wallet.c \
|
||||
@@ -34,6 +35,7 @@ WALLET_SQL_FILES := \
|
||||
wallet/account_migration.c \
|
||||
wallet/db.c \
|
||||
wallet/invoices.c \
|
||||
wallet/migrations.c \
|
||||
wallet/wallet.c \
|
||||
wallet/test/run-db.c \
|
||||
wallet/test/run-wallet.c \
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <lightningd/lightningd.h>
|
||||
#include <unistd.h>
|
||||
#include <wallet/account_migration.h>
|
||||
#include <wallet/migrations.h>
|
||||
|
||||
/* These functions and definitions copied almost exactly from old
|
||||
* plugins/bkpr/{recorder.c,chain_event.h,channel_event.h}
|
||||
|
||||
1224
wallet/db.c
1224
wallet/db.c
File diff suppressed because it is too large
Load Diff
@@ -26,8 +26,4 @@ struct db *db_setup(const tal_t *ctx, struct lightningd *ld,
|
||||
/* We store last wait indices in our var table. */
|
||||
void load_indexes(struct db *db, struct indexes *indexes);
|
||||
|
||||
/* Migration function for old commando datastore runes. */
|
||||
void migrate_datastore_commando_runes(struct lightningd *ld, struct db *db);
|
||||
/* Migrate old runes with incorrect id fields */
|
||||
void migrate_runes_idfix(struct lightningd *ld, struct db *db);
|
||||
#endif /* LIGHTNING_WALLET_DB_H */
|
||||
|
||||
1088
wallet/migrations.c
Normal file
1088
wallet/migrations.c
Normal file
File diff suppressed because it is too large
Load Diff
65
wallet/migrations.h
Normal file
65
wallet/migrations.h
Normal file
@@ -0,0 +1,65 @@
|
||||
#ifndef LIGHTNING_WALLET_MIGRATIONS_H
|
||||
#define LIGHTNING_WALLET_MIGRATIONS_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
struct lightningd;
|
||||
|
||||
struct db_migration {
|
||||
const char *sql;
|
||||
void (*func)(struct lightningd *ld, struct db *db);
|
||||
const char *revertsql;
|
||||
/* If non-NULL, returns string explaining why downgrade is impossible */
|
||||
const char *(*revertfn)(const tal_t *ctx, struct db *db);
|
||||
};
|
||||
|
||||
const struct db_migration *get_db_migrations(size_t *num);
|
||||
|
||||
/* All the functions provided by migrations.c */
|
||||
void migrate_pr2342_feerate_per_channel(struct lightningd *ld, struct db *db);
|
||||
void migrate_our_funding(struct lightningd *ld, struct db *db);
|
||||
void migrate_last_tx_to_psbt(struct lightningd *ld, struct db *db);
|
||||
void migrate_inflight_last_tx_to_psbt(struct lightningd *ld, struct db *db);
|
||||
void fillin_missing_scriptpubkeys(struct lightningd *ld, struct db *db);
|
||||
void fillin_missing_channel_id(struct lightningd *ld, struct db *db);
|
||||
void fillin_missing_local_basepoints(struct lightningd *ld,
|
||||
struct db *db);
|
||||
void fillin_missing_channel_blockheights(struct lightningd *ld,
|
||||
struct db *db);
|
||||
void migrate_channels_scids_as_integers(struct lightningd *ld,
|
||||
struct db *db);
|
||||
void migrate_payments_scids_as_integers(struct lightningd *ld,
|
||||
struct db *db);
|
||||
void fillin_missing_lease_satoshi(struct lightningd *ld,
|
||||
struct db *db);
|
||||
void migrate_invalid_last_tx_psbts(struct lightningd *ld,
|
||||
struct db *db);
|
||||
void migrate_fill_in_channel_type(struct lightningd *ld,
|
||||
struct db *db);
|
||||
void migrate_normalize_invstr(struct lightningd *ld,
|
||||
struct db *db);
|
||||
void migrate_initialize_invoice_wait_indexes(struct lightningd *ld,
|
||||
struct db *db);
|
||||
void migrate_invoice_created_index_var(struct lightningd *ld,
|
||||
struct db *db);
|
||||
void migrate_initialize_payment_wait_indexes(struct lightningd *ld,
|
||||
struct db *db);
|
||||
void migrate_forwards_add_rowid(struct lightningd *ld,
|
||||
struct db *db);
|
||||
void migrate_initialize_forwards_wait_indexes(struct lightningd *ld,
|
||||
struct db *db);
|
||||
void migrate_initialize_alias_local(struct lightningd *ld,
|
||||
struct db *db);
|
||||
void insert_addrtype_to_addresses(struct lightningd *ld,
|
||||
struct db *db);
|
||||
void migrate_convert_old_channel_keyidx(struct lightningd *ld,
|
||||
struct db *db);
|
||||
void migrate_initialize_channel_htlcs_wait_indexes_and_fixup_forwards(struct lightningd *ld,
|
||||
struct db *db);
|
||||
void migrate_fail_pending_payments_without_htlcs(struct lightningd *ld,
|
||||
struct db *db);
|
||||
void migrate_remove_chain_moves_duplicates(struct lightningd *ld, struct db *db);
|
||||
void migrate_from_account_db(struct lightningd *ld, struct db *db);
|
||||
void migrate_datastore_commando_runes(struct lightningd *ld, struct db *db);
|
||||
void migrate_runes_idfix(struct lightningd *ld, struct db *db);
|
||||
#endif /* LIGHTNING_WALLET_MIGRATIONS_H */
|
||||
@@ -22,6 +22,7 @@ static void db_log_(struct logger *log UNUSED, enum log_level level UNUSED, cons
|
||||
#include "db/exec.c"
|
||||
#include "db/utils.c"
|
||||
#include "wallet/db.c"
|
||||
#include "wallet/migrations.c"
|
||||
#include "common/coin_mvt.c"
|
||||
|
||||
/* AUTOGENERATED MOCKS START */
|
||||
|
||||
@@ -12,6 +12,7 @@ static void db_log_(struct logger *log UNUSED, enum log_level level UNUSED, cons
|
||||
#include "db/utils.c"
|
||||
#include "wallet/db.c"
|
||||
#include "wallet/wallet.c"
|
||||
#include "wallet/migrations.c"
|
||||
|
||||
#include "test_utils.h"
|
||||
|
||||
|
||||
@@ -124,6 +124,9 @@ void get_channel_basepoints(struct lightningd *ld UNNEEDED,
|
||||
struct basepoints *local_basepoints UNNEEDED,
|
||||
struct pubkey *local_funding_pubkey UNNEEDED)
|
||||
{ fprintf(stderr, "get_channel_basepoints called!\n"); abort(); }
|
||||
/* Generated stub for get_db_migrations */
|
||||
const struct db_migration *get_db_migrations(size_t *num UNNEEDED)
|
||||
{ fprintf(stderr, "get_db_migrations called!\n"); abort(); }
|
||||
/* Generated stub for hash_cid */
|
||||
size_t hash_cid(const struct channel_id *cid UNNEEDED)
|
||||
{ fprintf(stderr, "hash_cid called!\n"); abort(); }
|
||||
@@ -172,9 +175,6 @@ struct invoices *invoices_new(const tal_t *ctx UNNEEDED,
|
||||
void logv(struct logger *logger UNNEEDED, enum log_level level UNNEEDED, const struct node_id *node_id UNNEEDED,
|
||||
bool call_notifier UNNEEDED, const char *fmt UNNEEDED, va_list ap UNNEEDED)
|
||||
{ fprintf(stderr, "logv called!\n"); abort(); }
|
||||
/* Generated stub for migrate_from_account_db */
|
||||
void migrate_from_account_db(struct lightningd *ld UNNEEDED, struct db *db UNNEEDED)
|
||||
{ fprintf(stderr, "migrate_from_account_db called!\n"); abort(); }
|
||||
/* Generated stub for new_channel */
|
||||
struct channel *new_channel(struct peer *peer UNNEEDED, u64 dbid UNNEEDED,
|
||||
/* NULL or stolen */
|
||||
|
||||
@@ -36,6 +36,7 @@ static void test_error(struct lightningd *ld, bool fatal, const char *fmt, va_li
|
||||
#include "db/exec.c"
|
||||
#include "db/utils.c"
|
||||
#include "wallet/db.c"
|
||||
#include "wallet/migrations.c"
|
||||
|
||||
#include <common/setup.h>
|
||||
#include <common/utils.h>
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <lightningd/runes.h>
|
||||
#include <onchaind/onchaind_wiregen.h>
|
||||
#include <wallet/invoices.h>
|
||||
#include <wallet/migrations.h>
|
||||
#include <wallet/txfilter.h>
|
||||
#include <wallet/wallet.h>
|
||||
#include <wally_bip32.h>
|
||||
|
||||
@@ -2006,6 +2006,5 @@ void wallet_datastore_save_payment_description(struct db *db,
|
||||
const struct sha256 *payment_hash,
|
||||
const char *desc);
|
||||
void migrate_setup_coinmoves(struct lightningd *ld, struct db *db);
|
||||
void migrate_remove_chain_moves_duplicates(struct lightningd *ld, struct db *db);
|
||||
|
||||
#endif /* LIGHTNING_WALLET_WALLET_H */
|
||||
|
||||
Reference in New Issue
Block a user