diff --git a/src/display_wallet.cpp b/src/display_wallet.cpp index 9c52a99..74502fc 100644 --- a/src/display_wallet.cpp +++ b/src/display_wallet.cpp @@ -13,10 +13,13 @@ display_wallet::display_wallet(wxWindow* parent, wxFileName& walletfile) : walletfile.GetFullPath().append(" does not exist.").ToUTF8(), __LINE__, __func__, SrcFilename); m_db.reset(Sqlite3_open(walletfile.GetFullPath().ToUTF8())); - sql_read_from_misc read_from_misc(m_db); - if (!read_from_misc(1) || read_from_misc.value() != WALLET_FILE_IDENTIFIER)throw MyException(sz_unrecognizable_wallet_file_format); - if (!read_from_misc(2) || read_from_misc.value() != WALLET_FILE_SCHEMA_VERSION_0_0 || !read_from_misc(4))throw MyException(sz_unrecognized_wallet_schema); - m_MasterSecret= *read_from_misc.value(); + m_read_from_misc.reset(new sql_read_from_misc(m_db)); + m_read_names_and_keys.reset(new ro::sql(m_db, + R"|(SELECT "Names".name AS name, "Keys".pubkey AS pubkey FROM "Names" INNER JOIN "Keys" )|" + R"|(ON "Names"."ROWID"="Keys".id AND "Keys".use=1 ORDER BY LOWER(name), name COLLATE BINARY;)|")); + if (!(*m_read_from_misc)(1) || m_read_from_misc->value() != WALLET_FILE_IDENTIFIER)throw MyException(sz_unrecognizable_wallet_file_format); + if (!(*m_read_from_misc)(2) || m_read_from_misc->value() != WALLET_FILE_SCHEMA_VERSION_0_0 || !(*m_read_from_misc)(4))throw MyException(sz_unrecognized_wallet_schema); + m_MasterSecret= *(m_read_from_misc->value()); ILogMessage(std::format("\t\tmaster secret: #{}", ro::base58(m_MasterSecret).operator const char* ()).c_str()); if(!m_MasterSecret.valid()) throw MyException(sz_cold_wallets_not_yet_implemented, __LINE__, __func__, SrcFilename); auto sizer = new wxBoxSizer(wxHORIZONTAL); @@ -26,11 +29,9 @@ display_wallet::display_wallet(wxWindow* parent, wxFileName& walletfile) : sizer->Add(m_rSizer, 50, wxGROW, 4); SetSizer(sizer); try { - ro::sql read_names_and_keys(m_db, - R"|(SELECT Names.name AS name, Keys.pubkey AS pubkey FROM Names INNER JOIN Keys ON Names.ROWID=Keys.id AND Keys.use=1 ORDER BY LOWER(name), name COLLATE BINARY;)|"); - while (read_names_and_keys.step() == Icompiled_sql::ROW) { - std::string name = read_names_and_keys.column(0); - auto pubkey = *read_names_and_keys.column(1); + while (m_read_names_and_keys->step() == Icompiled_sql::ROW) { + std::string name = m_read_names_and_keys->column(0); + auto pubkey = *(m_read_names_and_keys->column(1)); if (m_MasterSecret(name).timesBase() != pubkey)throw MyException(std::string(sz_public_key_of) + name + sz_fails_to_correspond); m_lSizer->Add( new wxStaticText( diff --git a/src/display_wallet.h b/src/display_wallet.h index b597c79..00243fa 100644 --- a/src/display_wallet.h +++ b/src/display_wallet.h @@ -7,6 +7,8 @@ public: private: typedef MenuLink MenuLink; std::unique_ptr m_db; + std::unique_ptr m_read_from_misc; + std::unique_ptr m_read_names_and_keys; ristretto255::CMasterSecret m_MasterSecret; wxBoxSizer* m_lSizer; wxBoxSizer* m_rSizer; diff --git a/src/serialization.h b/src/serialization.h index c35a143..cf6a371 100644 --- a/src/serialization.h +++ b/src/serialization.h @@ -75,7 +75,7 @@ l = std::size(a); pt = &a[0]; } - return std::span(static_cast(pt), l); + return std::span(static_cast(pt), l); } // Compile time test to see if a type has a blob array member