diff --git a/msvc/wxConfig.bat b/msvc/wxConfig.bat new file mode 100644 index 0000000..5d705d4 --- /dev/null +++ b/msvc/wxConfig.bat @@ -0,0 +1,49 @@ +echo on +call C:\"Program Files (x86)"\"Microsoft Visual Studio"\2022\BuildTools\VC\Auxiliary\Build\vcvarsamd64_x86.bat +call C:\"Program Files"\"Microsoft Visual Studio"\2022\Community\VC\Auxiliary\Build\vcvars64.bat" +echo on +cd wxWidgets\build\msw +msbuild wx_vc17.sln -m -p:Configuration=Release;Platform=x64;PlatformToolset=v143;WindowsTargetPlatformVersion=10.0 +echo off +IF %ERRORLEVEL% NEQ 0 ( + PAUSE + GOTO:EOF +) +echo on +msbuild wx_vc17.sln -m -p:Configuration=Debug;Platform=x64;PlatformToolset=v143;WindowsTargetPlatformVersion=10.0 +echo off +IF %ERRORLEVEL% NEQ 0 ( + PAUSE + GOTO:EOF +) + +echo on +cd ..\..\.. +msbuild wallet.sln -p:Configuration=Debug;Platform=x64 -m +echo off +IF %ERRORLEVEL% NEQ 0 ( + PAUSE + GOTO:EOF +) +echo on +msbuild wallet.sln -p:Configuration=Release;Platform=x64 -m +echo off +IF %ERRORLEVEL% NEQ 0 ( + PAUSE + GOTO:EOF +) +echo on +.\build\Debug\wallet.exe --complete --test +echo off +IF %ERRORLEVEL% NEQ 0 ( + echo failed unit test on debug build +) ELSE ( + echo passed unit test on debug build) +echo on +.\build\Release\wallet.exe --complete --test +echo off +IF %ERRORLEVEL% NEQ 0 ( + echo failed unit test on release build +) ELSE ( + echo passed unit test on release build +) diff --git a/src/db_accessors.h b/src/db_accessors.h index 72c037c..e68d6c0 100644 --- a/src/db_accessors.h +++ b/src/db_accessors.h @@ -166,7 +166,7 @@ public: class sql_read_from_misc :ro::sql { public: - sql_read_from_misc(ISqlite3 *p) : sql(p, R"|(SELECT "m" FROM "Misc" WHERE "index" = ?1;)|") {} + sql_read_from_misc(ISqlite3 *p) : sql(p, R"|(SELECT "m" FROM "Misc" WHERE "ROWID" = ?1;)|") {} sql_read_from_misc(const std::unique_ptr& p) : sql_read_from_misc(p.get()){} auto operator()(int i) { return read_one(i); @@ -188,8 +188,13 @@ class sql_insert_name { public: sql_insert_name(ISqlite3* p) : csql_begin(p, R"|(BEGIN IMMEDIATE;)|"), - csql_into_names(p, R"|(INSERT OR FAIL INTO "Names" VALUES(?1);)|"), - csql_namekey_into_keys(p, R"|(INSERT OR FAIL INTO "Keys" VALUES(?1, last_insert_rowid(), 1);)|"), + csql_into_names(p, R"|(INSERT OR FAIL INTO "Names" VALUES(NULL, ?1);)|"), + csql_namekey_into_keys(p, R"|(INSERT OR FAIL INTO "Keys" VALUES(NULL, ?1, last_insert_rowid(), 1);)|"), + /* NULL triggers special nonstandard Sqlite behavior to autogenerate a unique ROWID + Because we explicitly make the ROWID a named field in the table to avoid too much + non standard SQlite behavior, we must explicitly provide a placeholder in the INSERT + statement. So at least we only get special SQlite3 behavior when we deliberately + invoke it. */ csql_commit(p, R"|(COMMIT;)|"), csql_rollback(p, R"|(ROLLBACK;)|") {} @@ -219,13 +224,13 @@ public: class sql_read_name :ro::sql { public: - sql_read_name(ISqlite3* p) : sql(p, R"|(SELECT * FROM "Names" WHERE OID = ?1;)|") {} + sql_read_name(ISqlite3* p) : sql(p, R"|(SELECT * FROM "Names" WHERE ROWID = ?1;)|") {} sql_read_name(const std::unique_ptr& p) : sql_read_name(p.get()) {} bool operator()(int i) { return read_one(i) == Icompiled_sql::ROW; } auto name() const { - return sql::column(0); + return sql::column(1); } }; diff --git a/src/display_wallet.cpp b/src/display_wallet.cpp index 9430788..c463245 100644 --- a/src/display_wallet.cpp +++ b/src/display_wallet.cpp @@ -26,9 +26,9 @@ display_wallet::display_wallet(wxWindow* parent, wxFileName& walletfile) : sql_read_name read_name(m_db); //*It would be better to have a select statement goes through the name table, in name order. This is unit test code wrongly repurposed. // m_db.reset(nullptr);// Force error of premature destruction of Isqlite3 while (read_keys.step() == Icompiled_sql::ROW) { - auto pubkey = read_keys.column(0); - auto id = read_keys.column(1); - auto use = read_keys.column(2); + auto pubkey = read_keys.column(1); + auto id = read_keys.column(2); + auto use = read_keys.column(3); if (use != 1)throw MyException(sz_unknown_secret_key_algorithm); if (!read_name(id)) throw MyException(sz_no_corresponding_entry); const char* name = read_name.name(); diff --git a/src/frame.cpp b/src/frame.cpp index 250e2f2..bc031c0 100644 --- a/src/frame.cpp +++ b/src/frame.cpp @@ -250,7 +250,7 @@ PRAGMA journal_mode = WAL; PRAGMA synchronous = 1; BEGIN IMMEDIATE TRANSACTION; CREATE TABLE "Keys"( - "oid" INTEGER PRIMARY KEY, + "ROWID" INTEGER PRIMARY KEY, "pubkey" BLOB NOT NULL UNIQUE, "id" integer NOT NULL, "use" INTEGER NOT NULL); @@ -258,12 +258,14 @@ CREATE TABLE "Keys"( CREATE UNIQUE INDEX i_pubkey ON Keys (pubkey); CREATE TABLE "Names"( - "oid" INTEGER PRIMARY KEY, + "ROWID" INTEGER PRIMARY KEY, "name" TEXT NOT NULL UNIQUE ); +CREATE UNIQUE INDEX i_names ON Names (name); + CREATE TABLE "Misc"( - "index" INTEGER PRIMARY KEY, + "ROWID" INTEGER PRIMARY KEY, "m" BLOB ); COMMIT;)|"); diff --git a/src/stdafx.h b/src/stdafx.h index b578fed..0922ea6 100644 --- a/src/stdafx.h +++ b/src/stdafx.h @@ -62,7 +62,7 @@ constexpr bool b_WINDOWS = false; static_assert(wxUSE_UNSAFE_WXSTRING_CONV == 1, R"(In fully utf environment, (wallet.manifest plus /utf-8 compile option) all string conversions are safe.)"); -static_assert(wxMAJOR_VERSION == 3 && wxMINOR_VERSION == 2 && wxRELEASE_NUMBER == 2 && wxSUBRELEASE_NUMBER == 1 && wxVERSION_STRING == wxT("wxWidgets 3.2.2.1"), "expecting wxWidgets 3.2.2.1"); +static_assert(wxMAJOR_VERSION == 3 && wxMINOR_VERSION == 2 && wxRELEASE_NUMBER == 0 && wxSUBRELEASE_NUMBER == 1 && wxVERSION_STRING == wxT("wxWidgets 3.2.0"), "expecting wxWidgets 3.2.0"); static_assert(wxUSE_IPV6 == 1, "IP6 unavailable in wxWidgets"); static_assert(WXWIN_COMPATIBILITY_3_0 == 0, "wxWidgets api out of date"); static_assert(wxUSE_COMPILER_TLS == (b_WINDOWS ? 2 : 1), "out of date workarounds in wxWidgets for windows bugs"); diff --git a/src/unit_test.cpp b/src/unit_test.cpp index 40f6faa..df7166b 100644 --- a/src/unit_test.cpp +++ b/src/unit_test.cpp @@ -426,16 +426,22 @@ PRAGMA journal_mode = WAL; PRAGMA synchronous = 1; BEGIN IMMEDIATE TRANSACTION; CREATE TABLE "Keys"( - "pubkey" BLOB NOT NULL UNIQUE PRIMARY KEY, + "ROWID" INTEGER PRIMARY KEY, + "pubkey" BLOB NOT NULL UNIQUE, "id" integer NOT NULL, "use" INTEGER NOT NULL); +CREATE UNIQUE INDEX i_pubkey ON Keys (pubkey); + CREATE TABLE "Names"( + "ROWID" INTEGER PRIMARY KEY, "name" TEXT NOT NULL UNIQUE ); +CREATE UNIQUE INDEX i_names ON Names (name); + CREATE TABLE "Misc"( - "index" INTEGER NOT NULL UNIQUE PRIMARY KEY, + "ROWID" INTEGER PRIMARY KEY, "m" BLOB ); COMMIT;)|"); diff --git a/wxWidgets b/wxWidgets index 02e885c..2648eb4 160000 --- a/wxWidgets +++ b/wxWidgets @@ -1 +1 @@ -Subproject commit 02e885c6f079c6e12a632f92cd7cfcceecf0c39b +Subproject commit 2648eb4da156a751a377cfe96b91faa03e535c10