MCPcopy Create free account
hub / github.com/ElementsProject/lightning / create_test_wallet

Function create_test_wallet

wallet/test/run-wallet.c:963–997  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

961}
962
963static struct wallet *create_test_wallet(struct lightningd *ld, const tal_t *ctx)
964{
965 char *dsn, *filename;
966 int fd = tmpdir_mkstemp(ctx, "ldb-XXXXXX", &filename);
967 struct wallet *w = tal(ctx, struct wallet);
968 static unsigned char badseed[BIP32_ENTROPY_LEN_128];
969 const struct ext_key *bip32_base = NULL;
970 CHECK_MSG(fd != -1, "Unable to generate temp filename");
971 close(fd);
972
973 dsn = tal_fmt(NULL, "sqlite3://%s", filename);
974 w->db = db_open(w, dsn);
975 w->db->report_changes_fn = NULL;
976 tal_free(dsn);
977 tal_add_destructor2(w, cleanup_test_wallet, filename);
978
979 list_head_init(&w->unstored_payments);
980 w->ld = ld;
981 ld->wallet = w;
982
983 w->bip32_base = tal(w, struct ext_key);
984 CHECK(bip32_key_from_seed(badseed, sizeof(badseed),
985 BIP32_VER_TEST_PRIVATE, 0,
986 w->bip32_base) == WALLY_OK);
987
988 CHECK_MSG(w->db, "Failed opening the db");
989 w->db->data_version = 0;
990 db_begin_transaction(w->db);
991 db_migrate(ld, w->db, bip32_base);
992 db_commit_transaction(w->db);
993 CHECK_MSG(!wallet_err, wallet_err);
994 w->max_channel_dbid = 0;
995
996 return w;
997}
998
999static bool test_wallet_outputs(struct lightningd *ld, const tal_t *ctx)
1000{

Callers 7

test_wallet_outputsFunction · 0.85
test_shachain_crudFunction · 0.85
test_channel_crudFunction · 0.85
test_channel_config_crudFunction · 0.85
test_htlc_crudFunction · 0.85
test_payment_crudFunction · 0.85

Calls 6

tmpdir_mkstempFunction · 0.85
db_openFunction · 0.85
tal_freeFunction · 0.85
list_head_initFunction · 0.85
db_migrateFunction · 0.50
db_commit_transactionFunction · 0.50

Tested by

no test coverage detected