Moved the compiled sql statments from the stack to unique
pointers that are members of the window
This commit is contained in:
parent
883d8c5b51
commit
5f4fe3104b
@ -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<int64_t>() != WALLET_FILE_IDENTIFIER)throw MyException(sz_unrecognizable_wallet_file_format);
|
||||
if (!read_from_misc(2) || read_from_misc.value<int64_t>() != WALLET_FILE_SCHEMA_VERSION_0_0 || !read_from_misc(4))throw MyException(sz_unrecognized_wallet_schema);
|
||||
m_MasterSecret= *read_from_misc.value<ristretto255::scalar>();
|
||||
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<int64_t>() != WALLET_FILE_IDENTIFIER)throw MyException(sz_unrecognizable_wallet_file_format);
|
||||
if (!(*m_read_from_misc)(2) || m_read_from_misc->value<int64_t>() != WALLET_FILE_SCHEMA_VERSION_0_0 || !(*m_read_from_misc)(4))throw MyException(sz_unrecognized_wallet_schema);
|
||||
m_MasterSecret= *(m_read_from_misc->value<ristretto255::scalar>());
|
||||
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<const char*>(0);
|
||||
auto pubkey = *read_names_and_keys.column<ristretto255::point>(1);
|
||||
while (m_read_names_and_keys->step() == Icompiled_sql::ROW) {
|
||||
std::string name = m_read_names_and_keys->column<const char*>(0);
|
||||
auto pubkey = *(m_read_names_and_keys->column<ristretto255::point>(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(
|
||||
|
@ -7,6 +7,8 @@ public:
|
||||
private:
|
||||
typedef MenuLink<display_wallet> MenuLink;
|
||||
std::unique_ptr<ISqlite3> m_db;
|
||||
std::unique_ptr <sql_read_from_misc> m_read_from_misc;
|
||||
std::unique_ptr <ro::sql> m_read_names_and_keys;
|
||||
ristretto255::CMasterSecret m_MasterSecret;
|
||||
wxBoxSizer* m_lSizer;
|
||||
wxBoxSizer* m_rSizer;
|
||||
|
@ -75,7 +75,7 @@
|
||||
l = std::size(a);
|
||||
pt = &a[0];
|
||||
}
|
||||
return std::span<const byte>(static_cast<const byte *>(pt), l);
|
||||
return std::span(static_cast<const byte *>(pt), l);
|
||||
}
|
||||
|
||||
// Compile time test to see if a type has a blob array member
|
||||
|
Loading…
Reference in New Issue
Block a user