Skip to content

Commit f9d31b3

Browse files
committed
Make sure redeempattern is set for each account when loading vault file.
1 parent 0879fd5 commit f9d31b3

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

deps/CoinDB/src/Schema.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,7 @@ class Account : public std::enable_shared_from_this<Account>
699699
const CoinQ::Script::ScriptTemplate& redeemtemplate() const { return redeemtemplate_; }
700700

701701
void initScriptPatterns();
702+
bool redeempattern_set() const { return !redeempattern_.empty(); }
702703

703704
private:
704705
friend class odb::access;

deps/CoinDB/src/Vault.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,15 @@ void Vault::open(int argc, char** argv, bool create, uint32_t version, const std
224224

225225
t.commit();
226226
}
227+
228+
{
229+
odb::core::session s;
230+
for (auto& account: db_->query<Account>())
231+
{
232+
if (!account.redeempattern_set())
233+
throw std::runtime_error("Error in vault file. Please import keychains into a new vault file and recreate account.");
234+
}
235+
}
227236
}
228237
}
229238

@@ -305,6 +314,14 @@ void Vault::open(const std::string& dbuser, const std::string& dbpasswd, const s
305314
t.commit();
306315
}
307316

317+
{
318+
odb::core::session s;
319+
for (auto& account: db_->query<Account>())
320+
{
321+
if (!account.redeempattern_set())
322+
throw std::runtime_error("Error in vault file. Please import keychains into a new vault file and recreate account.");
323+
}
324+
}
308325
}
309326
}
310327

0 commit comments

Comments
 (0)