1
0
forked from cheng/wallet

My update of wxWidgets broke. wxWidgets bug, or bug in the way I use it.

My update of the schema to explicitly name the ROWID column broke everything because I was using position rather than names for fields
This commit is contained in:
Cheng 2023-09-14 10:45:12 +10:00
parent 529cc368c9
commit 408942a336
No known key found for this signature in database
GPG Key ID: 571C3A9C3B9E6FCA
7 changed files with 77 additions and 15 deletions

49
msvc/wxConfig.bat Normal file
View File

@ -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
)

View File

@ -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<ISqlite3>& 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<ISqlite3>& p) : sql_read_name(p.get()) {}
bool operator()(int i) {
return read_one(i) == Icompiled_sql::ROW;
}
auto name() const {
return sql::column<const char*>(0);
return sql::column<const char*>(1);
}
};

View File

@ -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<ristretto255::point>(0);
auto id = read_keys.column<int>(1);
auto use = read_keys.column<int>(2);
auto pubkey = read_keys.column<ristretto255::point>(1);
auto id = read_keys.column<int>(2);
auto use = read_keys.column<int>(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();

View File

@ -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;)|");

View File

@ -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");

View File

@ -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;)|");

@ -1 +1 @@
Subproject commit 02e885c6f079c6e12a632f92cd7cfcceecf0c39b
Subproject commit 2648eb4da156a751a377cfe96b91faa03e535c10